diff --git a/docs/compiled/i18n/ar.mjs b/docs/compiled/i18n/ar.mjs new file mode 100644 index 000000000..df699e26a --- /dev/null +++ b/docs/compiled/i18n/ar.mjs @@ -0,0 +1 @@ +!function(e,t,n,r,o,i,l,u){var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof f[r]&&f[r],a=d.i||{},c=d.cache||{},s="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!c[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof f[r]&&f[r];if(!n&&i)return i(t,!0);if(d)return d(t,!0);if(s&&"string"==typeof t)return s(t);var l=Error("Cannot find module '"+t+"'");throw l.code="MODULE_NOT_FOUND",l}a.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},a.cache={};var u=c[t]=new p.Module(t);e[t][0].call(u.exports,a,u,u.exports,f)}return c[t].exports;function a(e){var t=a.resolve(e);return!1===t?{}:p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=s,this.exports={}},p.modules=e,p.cache=c,p.parent=d,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=a,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return f[r]}}),f[r]=p;for(var y=0;y { - const art = new Artplayer({ - ...option, - container: artRef.current, - }); - - if (getInstance && typeof getInstance === 'function') { - getInstance(art); - } - - return () => { - if (art && art.destroy) { - art.destroy(false); - } - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return
; -} diff --git a/packages/artplayer-template/next.js/pages/_app.js b/packages/artplayer-template/next.js/pages/_app.js deleted file mode 100644 index bee613e3a..000000000 --- a/packages/artplayer-template/next.js/pages/_app.js +++ /dev/null @@ -1,7 +0,0 @@ -import '../styles/globals.css'; - -function MyApp({ Component, pageProps }) { - return ; -} - -export default MyApp; diff --git a/packages/artplayer-template/next.js/pages/api/hello.js b/packages/artplayer-template/next.js/pages/api/hello.js deleted file mode 100644 index 839be9fe1..000000000 --- a/packages/artplayer-template/next.js/pages/api/hello.js +++ /dev/null @@ -1,5 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -export default function handler(req, res) { - res.status(200).json({ name: 'John Doe' }); -} diff --git a/packages/artplayer-template/next.js/pages/index.js b/packages/artplayer-template/next.js/pages/index.js deleted file mode 100644 index b4bb75381..000000000 --- a/packages/artplayer-template/next.js/pages/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import Artplayer from './ArtPlayer'; - -function App() { - return ( -
- console.log(art)} - /> -
- ); -} - -export default App; diff --git a/packages/artplayer-template/next.js/public/favicon.ico b/packages/artplayer-template/next.js/public/favicon.ico deleted file mode 100644 index 718d6fea4..000000000 Binary files a/packages/artplayer-template/next.js/public/favicon.ico and /dev/null differ diff --git a/packages/artplayer-template/next.js/public/vercel.svg b/packages/artplayer-template/next.js/public/vercel.svg deleted file mode 100644 index fbf0e25a6..000000000 --- a/packages/artplayer-template/next.js/public/vercel.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - \ No newline at end of file diff --git a/packages/artplayer-template/next.js/styles/Home.module.css b/packages/artplayer-template/next.js/styles/Home.module.css deleted file mode 100644 index 200500d79..000000000 --- a/packages/artplayer-template/next.js/styles/Home.module.css +++ /dev/null @@ -1,125 +0,0 @@ -.container { - padding: 0 2rem; -} - -.main { - min-height: 100vh; - padding: 4rem 0; - flex: 1; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; -} - -.footer { - display: flex; - flex: 1; - padding: 2rem 0; - border-top: 1px solid #eaeaea; - justify-content: center; - align-items: center; -} - -.footer a { - display: flex; - justify-content: center; - align-items: center; - flex-grow: 1; -} - -.title a { - color: #0070f3; - text-decoration: none; -} - -.title a:hover, -.title a:focus, -.title a:active { - text-decoration: underline; -} - -.title { - margin: 0; - line-height: 1.15; - font-size: 4rem; -} - -.title, -.description { - text-align: center; -} - -.description { - margin: 4rem 0; - line-height: 1.5; - font-size: 1.5rem; -} - -.code { - background: #fafafa; - border-radius: 5px; - padding: 0.75rem; - font-size: 1.1rem; - font-family: - Menlo, - Monaco, - Lucida Console, - Liberation Mono, - DejaVu Sans Mono, - Bitstream Vera Sans Mono, - Courier New, - monospace; -} - -.grid { - display: flex; - align-items: center; - justify-content: center; - flex-wrap: wrap; - max-width: 800px; -} - -.card { - margin: 1rem; - padding: 1.5rem; - text-align: left; - color: inherit; - text-decoration: none; - border: 1px solid #eaeaea; - border-radius: 10px; - transition: - color 0.15s ease, - border-color 0.15s ease; - max-width: 300px; -} - -.card:hover, -.card:focus, -.card:active { - color: #0070f3; - border-color: #0070f3; -} - -.card h2 { - margin: 0 0 1rem 0; - font-size: 1.5rem; -} - -.card p { - margin: 0; - font-size: 1.25rem; - line-height: 1.5; -} - -.logo { - height: 1em; - margin-left: 0.5rem; -} - -@media (max-width: 600px) { - .grid { - width: 100%; - flex-direction: column; - } -} diff --git a/packages/artplayer-template/next.js/styles/globals.css b/packages/artplayer-template/next.js/styles/globals.css deleted file mode 100644 index ca375514c..000000000 --- a/packages/artplayer-template/next.js/styles/globals.css +++ /dev/null @@ -1,26 +0,0 @@ -html, -body { - padding: 0; - margin: 0; - font-family: - -apple-system, - BlinkMacSystemFont, - Segoe UI, - Roboto, - Oxygen, - Ubuntu, - Cantarell, - Fira Sans, - Droid Sans, - Helvetica Neue, - sans-serif; -} - -a { - color: inherit; - text-decoration: none; -} - -* { - box-sizing: border-box; -} diff --git a/packages/artplayer-template/nuxt.js/.gitignore b/packages/artplayer-template/nuxt.js/.gitignore deleted file mode 100644 index a6b984db0..000000000 --- a/packages/artplayer-template/nuxt.js/.gitignore +++ /dev/null @@ -1,105 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# Next.js build output -.next - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and *not* Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port -.DS_Store diff --git a/packages/artplayer-template/nuxt.js/Artplayer.vue b/packages/artplayer-template/nuxt.js/Artplayer.vue deleted file mode 100644 index 0c29a4a6f..000000000 --- a/packages/artplayer-template/nuxt.js/Artplayer.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/packages/artplayer-template/nuxt.js/LICENSE b/packages/artplayer-template/nuxt.js/LICENSE deleted file mode 100644 index 6ea0c1891..000000000 --- a/packages/artplayer-template/nuxt.js/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Harvey Zack - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/artplayer-template/nuxt.js/README.md b/packages/artplayer-template/nuxt.js/README.md deleted file mode 100644 index 61b92025f..000000000 --- a/packages/artplayer-template/nuxt.js/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Nuxt 3 Minimal Starter - -Look at the [nuxt 3 documentation](https://v3.nuxtjs.org) to learn more. - -## Setup - -Make sure to install the dependencies: - -```bash -# yarn -yarn install - -# npm -npm install - -# pnpm -pnpm install --shamefully-hoist -``` - -## Development Server - -Start the development server on http://localhost:3000 - -```bash -npm run dev -``` - -## Production - -Build the application for production: - -```bash -npm run build -``` - -Locally preview production build: - -```bash -npm run preview -``` - -Checkout the [deployment documentation](https://v3.nuxtjs.org/docs/deployment) for more information. diff --git a/packages/artplayer-template/nuxt.js/app.vue b/packages/artplayer-template/nuxt.js/app.vue deleted file mode 100644 index 01ece30d4..000000000 --- a/packages/artplayer-template/nuxt.js/app.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/packages/artplayer-template/nuxt.js/nuxt.config.ts b/packages/artplayer-template/nuxt.js/nuxt.config.ts deleted file mode 100644 index 387b2ba44..000000000 --- a/packages/artplayer-template/nuxt.js/nuxt.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { defineNuxtConfig } from 'nuxt'; - -// https://v3.nuxtjs.org/api/configuration/nuxt.config -export default defineNuxtConfig({}); diff --git a/packages/artplayer-template/nuxt.js/package.json b/packages/artplayer-template/nuxt.js/package.json deleted file mode 100644 index dc10b5269..000000000 --- a/packages/artplayer-template/nuxt.js/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "private": true, - "scripts": { - "build": "nuxt build", - "dev": "nuxt dev", - "generate": "nuxt generate", - "preview": "nuxt preview" - }, - "devDependencies": { - "nuxt": "3.0.0-rc.1" - }, - "dependencies": { - "artplayer": "latest" - } -} diff --git a/packages/artplayer-template/nuxt.js/tsconfig.json b/packages/artplayer-template/nuxt.js/tsconfig.json deleted file mode 100644 index d1ddce884..000000000 --- a/packages/artplayer-template/nuxt.js/tsconfig.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - // https://v3.nuxtjs.org/concepts/typescript - "extends": "./.nuxt/tsconfig.json" -} diff --git a/packages/artplayer-template/react.js/.gitignore b/packages/artplayer-template/react.js/.gitignore deleted file mode 100644 index 4d29575de..000000000 --- a/packages/artplayer-template/react.js/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. - -# dependencies -/node_modules -/.pnp -.pnp.js - -# testing -/coverage - -# production -/build - -# misc -.DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/packages/artplayer-template/react.js/README.md b/packages/artplayer-template/react.js/README.md deleted file mode 100644 index 58beeaccd..000000000 --- a/packages/artplayer-template/react.js/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# Getting Started with Create React App - -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts - -In the project directory, you can run: - -### `npm start` - -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in your browser. - -The page will reload when you make changes.\ -You may also see any lint errors in the console. - -### `npm test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can't go back!** - -If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. - -You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). - -### Code Splitting - -This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) - -### Analyzing the Bundle Size - -This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) - -### Making a Progressive Web App - -This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) - -### Advanced Configuration - -This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) - -### Deployment - -This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) - -### `npm run build` fails to minify - -This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) diff --git a/packages/artplayer-template/react.js/package.json b/packages/artplayer-template/react.js/package.json deleted file mode 100644 index d4c0158c1..000000000 --- a/packages/artplayer-template/react.js/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "react.js", - "version": "0.1.0", - "private": true, - "dependencies": { - "@testing-library/jest-dom": "^5.16.4", - "@testing-library/react": "^13.1.1", - "@testing-library/user-event": "^13.5.0", - "artplayer": "latest", - "react": "^18.1.0", - "react-dom": "^18.1.0", - "react-scripts": "5.0.1", - "web-vitals": "^2.1.4" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "eslintConfig": { - "extends": [ - "react-app", - "react-app/jest" - ] - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } -} diff --git a/packages/artplayer-template/react.js/public/favicon.ico b/packages/artplayer-template/react.js/public/favicon.ico deleted file mode 100644 index a11777cc4..000000000 Binary files a/packages/artplayer-template/react.js/public/favicon.ico and /dev/null differ diff --git a/packages/artplayer-template/react.js/public/index.html b/packages/artplayer-template/react.js/public/index.html deleted file mode 100644 index b26d0bc13..000000000 --- a/packages/artplayer-template/react.js/public/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - React App - - - -
- - diff --git a/packages/artplayer-template/react.js/public/logo192.png b/packages/artplayer-template/react.js/public/logo192.png deleted file mode 100644 index fc44b0a37..000000000 Binary files a/packages/artplayer-template/react.js/public/logo192.png and /dev/null differ diff --git a/packages/artplayer-template/react.js/public/logo512.png b/packages/artplayer-template/react.js/public/logo512.png deleted file mode 100644 index a4e47a654..000000000 Binary files a/packages/artplayer-template/react.js/public/logo512.png and /dev/null differ diff --git a/packages/artplayer-template/react.js/public/manifest.json b/packages/artplayer-template/react.js/public/manifest.json deleted file mode 100644 index f01493ff0..000000000 --- a/packages/artplayer-template/react.js/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/packages/artplayer-template/react.js/public/robots.txt b/packages/artplayer-template/react.js/public/robots.txt deleted file mode 100644 index e9e57dc4d..000000000 --- a/packages/artplayer-template/react.js/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/packages/artplayer-template/react.js/src/App.css b/packages/artplayer-template/react.js/src/App.css deleted file mode 100644 index 78b8850cf..000000000 --- a/packages/artplayer-template/react.js/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/packages/artplayer-template/react.js/src/App.js b/packages/artplayer-template/react.js/src/App.js deleted file mode 100644 index b4bb75381..000000000 --- a/packages/artplayer-template/react.js/src/App.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import Artplayer from './ArtPlayer'; - -function App() { - return ( -
- console.log(art)} - /> -
- ); -} - -export default App; diff --git a/packages/artplayer-template/react.js/src/App.test.js b/packages/artplayer-template/react.js/src/App.test.js deleted file mode 100644 index f0b6a29f7..000000000 --- a/packages/artplayer-template/react.js/src/App.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/packages/artplayer-template/react.js/src/ArtPlayer.js b/packages/artplayer-template/react.js/src/ArtPlayer.js deleted file mode 100644 index 58286581f..000000000 --- a/packages/artplayer-template/react.js/src/ArtPlayer.js +++ /dev/null @@ -1,26 +0,0 @@ -import { useEffect, useRef } from 'react'; -import Artplayer from 'artplayer'; - -export default function Player({ option, getInstance, ...rest }) { - const artRef = useRef(); - - useEffect(() => { - const art = new Artplayer({ - ...option, - container: artRef.current, - }); - - if (getInstance && typeof getInstance === 'function') { - getInstance(art); - } - - return () => { - if (art && art.destroy) { - art.destroy(false); - } - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - return
; -} diff --git a/packages/artplayer-template/react.js/src/index.css b/packages/artplayer-template/react.js/src/index.css deleted file mode 100644 index 4b9042860..000000000 --- a/packages/artplayer-template/react.js/src/index.css +++ /dev/null @@ -1,12 +0,0 @@ -body { - margin: 0; - font-family: - -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', - 'Droid Sans', 'Helvetica Neue', sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; -} diff --git a/packages/artplayer-template/react.js/src/index.js b/packages/artplayer-template/react.js/src/index.js deleted file mode 100644 index d0763bfaa..000000000 --- a/packages/artplayer-template/react.js/src/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; - -const root = ReactDOM.createRoot(document.getElementById('root')); -root.render( - - - , -); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); diff --git a/packages/artplayer-template/react.js/src/logo.svg b/packages/artplayer-template/react.js/src/logo.svg deleted file mode 100644 index 9dfc1c058..000000000 --- a/packages/artplayer-template/react.js/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/artplayer-template/react.js/src/reportWebVitals.js b/packages/artplayer-template/react.js/src/reportWebVitals.js deleted file mode 100644 index 17f8ad171..000000000 --- a/packages/artplayer-template/react.js/src/reportWebVitals.js +++ /dev/null @@ -1,13 +0,0 @@ -const reportWebVitals = (onPerfEntry) => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals; diff --git a/packages/artplayer-template/react.js/src/setupTests.js b/packages/artplayer-template/react.js/src/setupTests.js deleted file mode 100644 index 8f2609b7b..000000000 --- a/packages/artplayer-template/react.js/src/setupTests.js +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom'; diff --git a/packages/artplayer-template/vue3.js/.gitignore b/packages/artplayer-template/vue.js/.gitignore similarity index 95% rename from packages/artplayer-template/vue3.js/.gitignore rename to packages/artplayer-template/vue.js/.gitignore index 38adffa64..8ee54e8d3 100644 --- a/packages/artplayer-template/vue3.js/.gitignore +++ b/packages/artplayer-template/vue.js/.gitignore @@ -26,3 +26,5 @@ coverage *.njsproj *.sln *.sw? + +*.tsbuildinfo diff --git a/packages/artplayer-template/vue3.js/README.md b/packages/artplayer-template/vue.js/README.md similarity index 56% rename from packages/artplayer-template/vue3.js/README.md rename to packages/artplayer-template/vue.js/README.md index 072204873..bf72983ef 100644 --- a/packages/artplayer-template/vue3.js/README.md +++ b/packages/artplayer-template/vue.js/README.md @@ -1,14 +1,14 @@ -# vue.js +# vue-project This template should help get you started developing with Vue 3 in Vite. ## Recommended IDE Setup -[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin). +[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur). ## Customize configuration -See [Vite Configuration Reference](https://vitejs.dev/config/). +See [Vite Configuration Reference](https://vite.dev/config/). ## Project Setup diff --git a/packages/artplayer-template/vue.js/index.html b/packages/artplayer-template/vue.js/index.html new file mode 100644 index 000000000..0948ecfd0 --- /dev/null +++ b/packages/artplayer-template/vue.js/index.html @@ -0,0 +1,13 @@ + + + + + + + Artplayer Vite App + + +
+ + + diff --git a/packages/artplayer-template/vue.js/jsconfig.json b/packages/artplayer-template/vue.js/jsconfig.json new file mode 100644 index 000000000..5a1f2d222 --- /dev/null +++ b/packages/artplayer-template/vue.js/jsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "paths": { + "@/*": ["./src/*"] + } + }, + "exclude": ["node_modules", "dist"] +} diff --git a/packages/artplayer-template/vue.js/package.json b/packages/artplayer-template/vue.js/package.json new file mode 100644 index 000000000..3de866254 --- /dev/null +++ b/packages/artplayer-template/vue.js/package.json @@ -0,0 +1,22 @@ +{ + "name": "vue-project", + "type": "module", + "version": "0.0.0", + "private": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "vue": "^3.5.18" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^6.0.1", + "vite": "^7.0.6", + "vite-plugin-vue-devtools": "^8.0.0" + } +} diff --git a/packages/artplayer-template/vue2.js/public/favicon.ico b/packages/artplayer-template/vue.js/public/favicon.ico similarity index 100% rename from packages/artplayer-template/vue2.js/public/favicon.ico rename to packages/artplayer-template/vue.js/public/favicon.ico diff --git a/packages/artplayer-template/vue.js/src/App.vue b/packages/artplayer-template/vue.js/src/App.vue new file mode 100644 index 000000000..3874ae132 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/App.vue @@ -0,0 +1,24 @@ + + + diff --git a/packages/artplayer-template/vue.js/src/Artplayer.vue b/packages/artplayer-template/vue.js/src/Artplayer.vue new file mode 100644 index 000000000..fa020a889 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/Artplayer.vue @@ -0,0 +1,53 @@ + + + diff --git a/packages/artplayer-template/vue.js/src/main.js b/packages/artplayer-template/vue.js/src/main.js new file mode 100644 index 000000000..01433bca2 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/main.js @@ -0,0 +1,4 @@ +import { createApp } from 'vue' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/packages/artplayer-template/vue.js/vite.config.js b/packages/artplayer-template/vue.js/vite.config.js new file mode 100644 index 000000000..48e16d2b4 --- /dev/null +++ b/packages/artplayer-template/vue.js/vite.config.js @@ -0,0 +1,18 @@ +import { fileURLToPath, URL } from 'node:url' + +import vue from '@vitejs/plugin-vue' +import { defineConfig } from 'vite' +import vueDevTools from 'vite-plugin-vue-devtools' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [ + vue(), + vueDevTools(), + ], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)), + }, + }, +}) diff --git a/packages/artplayer-template/vue2.js/.gitignore b/packages/artplayer-template/vue2.js/.gitignore deleted file mode 100644 index 403adbc1e..000000000 --- a/packages/artplayer-template/vue2.js/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -.DS_Store -node_modules -/dist - - -# local env files -.env.local -.env.*.local - -# Log files -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# Editor directories and files -.idea -.vscode -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/packages/artplayer-template/vue2.js/README.md b/packages/artplayer-template/vue2.js/README.md deleted file mode 100644 index a53e845ab..000000000 --- a/packages/artplayer-template/vue2.js/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# hello-world - -## Project setup - -``` -npm install -``` - -### Compiles and hot-reloads for development - -``` -npm run serve -``` - -### Compiles and minifies for production - -``` -npm run build -``` - -### Lints and fixes files - -``` -npm run lint -``` - -### Customize configuration - -See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/packages/artplayer-template/vue2.js/babel.config.js b/packages/artplayer-template/vue2.js/babel.config.js deleted file mode 100644 index 218963bd8..000000000 --- a/packages/artplayer-template/vue2.js/babel.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - presets: ['@vue/cli-plugin-babel/preset'], -}; diff --git a/packages/artplayer-template/vue2.js/jsconfig.json b/packages/artplayer-template/vue2.js/jsconfig.json deleted file mode 100644 index 351067a61..000000000 --- a/packages/artplayer-template/vue2.js/jsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "module": "esnext", - "baseUrl": "./", - "moduleResolution": "node", - "paths": { - "@/*": ["src/*"] - }, - "lib": ["esnext", "dom", "dom.iterable", "scripthost"] - } -} diff --git a/packages/artplayer-template/vue2.js/package.json b/packages/artplayer-template/vue2.js/package.json deleted file mode 100644 index adcba229e..000000000 --- a/packages/artplayer-template/vue2.js/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "hello-world", - "version": "0.1.0", - "private": true, - "scripts": { - "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "lint": "vue-cli-service lint" - }, - "dependencies": { - "artplayer": "^4.4.7", - "core-js": "^3.8.3", - "vue": "^2.6.14" - }, - "devDependencies": { - "@babel/core": "^7.12.16", - "@babel/eslint-parser": "^7.12.16", - "@vue/cli-plugin-babel": "~5.0.0", - "@vue/cli-plugin-eslint": "~5.0.0", - "@vue/cli-service": "~5.0.0", - "eslint": "^7.32.0", - "eslint-plugin-vue": "^8.0.3", - "vue-template-compiler": "^2.6.14" - }, - "eslintConfig": { - "root": true, - "env": { - "node": true - }, - "extends": [ - "plugin:vue/essential", - "eslint:recommended" - ], - "parserOptions": { - "parser": "@babel/eslint-parser" - }, - "rules": {} - }, - "browserslist": [ - "> 1%", - "last 2 versions", - "not dead" - ] -} diff --git a/packages/artplayer-template/vue2.js/public/index.html b/packages/artplayer-template/vue2.js/public/index.html deleted file mode 100644 index ed2c7f4a8..000000000 --- a/packages/artplayer-template/vue2.js/public/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - <%= htmlWebpackPlugin.options.title %> - - - -
- - - diff --git a/packages/artplayer-template/vue2.js/src/App.vue b/packages/artplayer-template/vue2.js/src/App.vue deleted file mode 100644 index 01ece30d4..000000000 --- a/packages/artplayer-template/vue2.js/src/App.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/packages/artplayer-template/vue2.js/src/Artplayer.vue b/packages/artplayer-template/vue2.js/src/Artplayer.vue deleted file mode 100644 index 5dc066851..000000000 --- a/packages/artplayer-template/vue2.js/src/Artplayer.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/packages/artplayer-template/vue2.js/src/assets/logo.png b/packages/artplayer-template/vue2.js/src/assets/logo.png deleted file mode 100644 index f3d2503fc..000000000 Binary files a/packages/artplayer-template/vue2.js/src/assets/logo.png and /dev/null differ diff --git a/packages/artplayer-template/vue2.js/src/components/HelloWorld.vue b/packages/artplayer-template/vue2.js/src/components/HelloWorld.vue deleted file mode 100644 index de8a597fb..000000000 --- a/packages/artplayer-template/vue2.js/src/components/HelloWorld.vue +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - diff --git a/packages/artplayer-template/vue2.js/src/main.js b/packages/artplayer-template/vue2.js/src/main.js deleted file mode 100644 index da64c6fc5..000000000 --- a/packages/artplayer-template/vue2.js/src/main.js +++ /dev/null @@ -1,8 +0,0 @@ -import Vue from 'vue'; -import App from './App.vue'; - -Vue.config.productionTip = false; - -new Vue({ - render: (h) => h(App), -}).$mount('#app'); diff --git a/packages/artplayer-template/vue2.js/vue.config.js b/packages/artplayer-template/vue2.js/vue.config.js deleted file mode 100644 index 88ab39131..000000000 --- a/packages/artplayer-template/vue2.js/vue.config.js +++ /dev/null @@ -1,5 +0,0 @@ -const { defineConfig } = require('@vue/cli-service'); -module.exports = defineConfig({ - transpileDependencies: true, - lintOnSave: false, -}); diff --git a/packages/artplayer-template/vue3.js/index.html b/packages/artplayer-template/vue3.js/index.html deleted file mode 100644 index 9f112579b..000000000 --- a/packages/artplayer-template/vue3.js/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - Vite App - - -
- - - diff --git a/packages/artplayer-template/vue3.js/package.json b/packages/artplayer-template/vue3.js/package.json deleted file mode 100644 index f37ea6b48..000000000 --- a/packages/artplayer-template/vue3.js/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "vue.js", - "version": "0.0.0", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview --port 5050" - }, - "dependencies": { - "artplayer": "latest", - "vue": "^3.2.33" - }, - "devDependencies": { - "@vitejs/plugin-vue": "^2.3.1", - "vite": "^2.9.5" - } -} diff --git a/packages/artplayer-template/vue3.js/public/favicon.ico b/packages/artplayer-template/vue3.js/public/favicon.ico deleted file mode 100644 index df36fcfb7..000000000 Binary files a/packages/artplayer-template/vue3.js/public/favicon.ico and /dev/null differ diff --git a/packages/artplayer-template/vue3.js/src/App.vue b/packages/artplayer-template/vue3.js/src/App.vue deleted file mode 100644 index 01ece30d4..000000000 --- a/packages/artplayer-template/vue3.js/src/App.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/packages/artplayer-template/vue3.js/src/Artplayer.vue b/packages/artplayer-template/vue3.js/src/Artplayer.vue deleted file mode 100644 index e898f9f72..000000000 --- a/packages/artplayer-template/vue3.js/src/Artplayer.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/packages/artplayer-template/vue3.js/src/assets/base.css b/packages/artplayer-template/vue3.js/src/assets/base.css deleted file mode 100644 index 39e883cc9..000000000 --- a/packages/artplayer-template/vue3.js/src/assets/base.css +++ /dev/null @@ -1,87 +0,0 @@ -/* color palette from */ -:root { - --vt-c-white: #ffffff; - --vt-c-white-soft: #f8f8f8; - --vt-c-white-mute: #f2f2f2; - - --vt-c-black: #181818; - --vt-c-black-soft: #222222; - --vt-c-black-mute: #282828; - - --vt-c-indigo: #2c3e50; - - --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); - --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); - --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); - --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); - - --vt-c-text-light-1: var(--vt-c-indigo); - --vt-c-text-light-2: rgba(60, 60, 60, 0.66); - --vt-c-text-dark-1: var(--vt-c-white); - --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); -} - -/* semantic color variables for this project */ -:root { - --color-background: var(--vt-c-white); - --color-background-soft: var(--vt-c-white-soft); - --color-background-mute: var(--vt-c-white-mute); - - --color-border: var(--vt-c-divider-light-2); - --color-border-hover: var(--vt-c-divider-light-1); - - --color-heading: var(--vt-c-text-light-1); - --color-text: var(--vt-c-text-light-1); - - --section-gap: 160px; -} - -@media (prefers-color-scheme: dark) { - :root { - --color-background: var(--vt-c-black); - --color-background-soft: var(--vt-c-black-soft); - --color-background-mute: var(--vt-c-black-mute); - - --color-border: var(--vt-c-divider-dark-2); - --color-border-hover: var(--vt-c-divider-dark-1); - - --color-heading: var(--vt-c-text-dark-1); - --color-text: var(--vt-c-text-dark-2); - } -} - -*, -*::before, -*::after { - box-sizing: border-box; - margin: 0; - position: relative; - font-weight: normal; -} - -body { - min-height: 100vh; - color: var(--color-text); - background: var(--color-background); - transition: - color 0.5s, - background-color 0.5s; - line-height: 1.6; - font-family: - Inter, - -apple-system, - BlinkMacSystemFont, - 'Segoe UI', - Roboto, - Oxygen, - Ubuntu, - Cantarell, - 'Fira Sans', - 'Droid Sans', - 'Helvetica Neue', - sans-serif; - font-size: 15px; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} diff --git a/packages/artplayer-template/vue3.js/src/assets/logo.svg b/packages/artplayer-template/vue3.js/src/assets/logo.svg deleted file mode 100644 index bc826fed8..000000000 --- a/packages/artplayer-template/vue3.js/src/assets/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/artplayer-template/vue3.js/src/components/HelloWorld.vue b/packages/artplayer-template/vue3.js/src/components/HelloWorld.vue deleted file mode 100644 index ed8bbc4e8..000000000 --- a/packages/artplayer-template/vue3.js/src/components/HelloWorld.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - - - diff --git a/packages/artplayer-template/vue3.js/src/components/TheWelcome.vue b/packages/artplayer-template/vue3.js/src/components/TheWelcome.vue deleted file mode 100644 index e8af89690..000000000 --- a/packages/artplayer-template/vue3.js/src/components/TheWelcome.vue +++ /dev/null @@ -1,81 +0,0 @@ - - - diff --git a/packages/artplayer-template/vue3.js/src/components/WelcomeItem.vue b/packages/artplayer-template/vue3.js/src/components/WelcomeItem.vue deleted file mode 100644 index 2ddfdb8b3..000000000 --- a/packages/artplayer-template/vue3.js/src/components/WelcomeItem.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/packages/artplayer-template/vue3.js/src/components/icons/IconCommunity.vue b/packages/artplayer-template/vue3.js/src/components/icons/IconCommunity.vue deleted file mode 100644 index 36348e2ee..000000000 --- a/packages/artplayer-template/vue3.js/src/components/icons/IconCommunity.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/packages/artplayer-template/vue3.js/src/components/icons/IconDocumentation.vue b/packages/artplayer-template/vue3.js/src/components/icons/IconDocumentation.vue deleted file mode 100644 index 0c0fa7610..000000000 --- a/packages/artplayer-template/vue3.js/src/components/icons/IconDocumentation.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/packages/artplayer-template/vue3.js/src/components/icons/IconEcosystem.vue b/packages/artplayer-template/vue3.js/src/components/icons/IconEcosystem.vue deleted file mode 100644 index 0702bbbe1..000000000 --- a/packages/artplayer-template/vue3.js/src/components/icons/IconEcosystem.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/packages/artplayer-template/vue3.js/src/components/icons/IconSupport.vue b/packages/artplayer-template/vue3.js/src/components/icons/IconSupport.vue deleted file mode 100644 index 908b94c4f..000000000 --- a/packages/artplayer-template/vue3.js/src/components/icons/IconSupport.vue +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/packages/artplayer-template/vue3.js/src/components/icons/IconTooling.vue b/packages/artplayer-template/vue3.js/src/components/icons/IconTooling.vue deleted file mode 100644 index 9e8206842..000000000 --- a/packages/artplayer-template/vue3.js/src/components/icons/IconTooling.vue +++ /dev/null @@ -1,19 +0,0 @@ - - diff --git a/packages/artplayer-template/vue3.js/src/main.js b/packages/artplayer-template/vue3.js/src/main.js deleted file mode 100644 index 684d04215..000000000 --- a/packages/artplayer-template/vue3.js/src/main.js +++ /dev/null @@ -1,4 +0,0 @@ -import { createApp } from 'vue'; -import App from './App.vue'; - -createApp(App).mount('#app'); diff --git a/packages/artplayer-template/vue3.js/vite.config.js b/packages/artplayer-template/vue3.js/vite.config.js deleted file mode 100644 index 69726edd9..000000000 --- a/packages/artplayer-template/vue3.js/vite.config.js +++ /dev/null @@ -1,14 +0,0 @@ -import { fileURLToPath, URL } from 'url'; - -import { defineConfig } from 'vite'; -import vue from '@vitejs/plugin-vue'; - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [vue()], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)), - }, - }, -}); diff --git a/packages/artplayer/package.json b/packages/artplayer/package.json index dc09aeb3f..c7c5ce0ab 100644 --- a/packages/artplayer/package.json +++ b/packages/artplayer/package.json @@ -1,6 +1,6 @@ { "name": "artplayer", - "version": "5.2.6", + "version": "5.3.0", "description": "ArtPlayer.js is a modern and full featured HTML5 video player", "author": "Harvey Zack ", "license": "MIT", @@ -17,9 +17,24 @@ "video", "player" ], - "main": "dist/artplayer.js", - "legacy": "dist/artplayer.legacy.js", - "types": "types/artplayer.d.ts", + "exports": { + ".": { + "import": "./dist/artplayer.mjs", + "require": "./dist/artplayer.js" + }, + "./i18n/*": { + "import": "./dist/i18n/*.mjs", + "require": "./dist/i18n/*.js" + }, + "./dist/i18n/*": { + "import": "./dist/i18n/*.mjs", + "require": "./dist/i18n/*.js" + } + }, + "main": "./dist/artplayer.js", + "module": "./dist/artplayer.mjs", + "types": "./types/artplayer.d.ts", + "legacy": "./dist/artplayer.legacy.js", "browserslist": "last 1 Chrome version", "dependencies": { "option-validator": "^2.0.6" diff --git a/scripts/build-i18n.js b/scripts/build-i18n.js index e0870210f..fba082849 100644 --- a/scripts/build-i18n.js +++ b/scripts/build-i18n.js @@ -2,58 +2,81 @@ import fs from 'node:fs' import path from 'node:path' import process from 'node:process' import { Parcel } from '@parcel/core' -import cpy from 'cpy' import { glob } from 'glob' const basePath = 'packages/artplayer' const i18nSrcDir = path.join(basePath, 'src/i18n') const distDir = path.join(basePath, 'dist/i18n') -const compiledPath = path.resolve('docs/compiled/i18n') const entries = glob.sync('*.js', { cwd: i18nSrcDir, ignore: ['index.js', 'zh-cn.js'], -}).map(f => path.join(i18nSrcDir, f)); +}).map(f => path.join(i18nSrcDir, f)) -(async function build() { +async function buildI18n() { if (fs.existsSync(distDir)) { fs.rmSync(distDir, { recursive: true, force: true }) } - fs.mkdirSync(distDir, { recursive: true }) - const bundler = new Parcel({ + // --- 1. 构建 global(.js) 到临时目录 --- + const distJs = path.join(distDir, 'cjs') + const bundlerJs = new Parcel({ entries, defaultConfig: '@parcel/config-default', mode: 'production', defaultTargetOptions: { - distDir, + distDir: distJs, outputFormat: 'global', sourceMaps: false, isLibrary: true, - engines: { - browsers: ['last 1 Chrome version'], - }, - }, - env: { - NODE_ENV: 'production', + engines: { browsers: ['last 1 Chrome version'] }, }, + env: { NODE_ENV: 'production' }, }) + await bundlerJs.run() + console.log('✅ Built i18n global (.js)') - try { - const { bundleGraph, buildTime } = await bundler.run() - const bundles = bundleGraph.getBundles() - console.log(`✨ Built [i18n] ${bundles.length} bundles in ${buildTime}ms`) - await cpy(distDir, compiledPath) - } - catch (err) { - console.error('❌ Build i18n failed.') - if (err?.diagnostics) { - console.error(err.diagnostics) + // --- 2. 构建 esmodule(.mjs) 到临时目录 --- + const distMjs = path.join(distDir, 'esm') + const bundlerMjs = new Parcel({ + entries, + defaultConfig: '@parcel/config-default', + mode: 'production', + defaultTargetOptions: { + distDir: distMjs, + outputFormat: 'esmodule', + sourceMaps: false, + isLibrary: true, + engines: { browsers: ['last 1 Chrome version'] }, + }, + env: { NODE_ENV: 'production' }, + }) + const { bundleGraph } = await bundlerMjs.run() + const bundles = bundleGraph.getBundles() + for (const bundle of bundles) { + if (bundle.type === 'js') { + const oldPath = bundle.filePath + const newPath = oldPath.replace(/\.js$/, '.mjs') + fs.renameSync(oldPath, newPath) } - else { - console.error(err) - } - process.exitCode = 1 } -})() + console.log('✅ Built i18n esm (.mjs)') + + // --- 3. 合并两个目录到 dist/i18n --- + for (const f of fs.readdirSync(distJs)) { + fs.renameSync(path.join(distJs, f), path.join(distDir, f)) + } + for (const f of fs.readdirSync(distMjs)) { + fs.renameSync(path.join(distMjs, f), path.join(distDir, f)) + } + fs.rmSync(distJs, { recursive: true, force: true }) + fs.rmSync(distMjs, { recursive: true, force: true }) + + console.log('✨ Finished building i18n with both .js and .mjs') +} + +buildI18n().catch((err) => { + console.error('❌ Build i18n failed', err) + process.exitCode = 1 +})