diff --git a/packages/artplayer-template/next.js/.eslintrc.json b/packages/artplayer-template/next.js/.eslintrc.json new file mode 100644 index 000000000..bffb357a7 --- /dev/null +++ b/packages/artplayer-template/next.js/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "next/core-web-vitals" +} diff --git a/packages/artplayer-template/next.js/.gitignore b/packages/artplayer-template/next.js/.gitignore new file mode 100644 index 000000000..55175ef86 --- /dev/null +++ b/packages/artplayer-template/next.js/.gitignore @@ -0,0 +1,32 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env*.local + +# vercel +.vercel diff --git a/packages/artplayer-template/next.js/README.md b/packages/artplayer-template/next.js/README.md new file mode 100644 index 000000000..b12f3e33e --- /dev/null +++ b/packages/artplayer-template/next.js/README.md @@ -0,0 +1,34 @@ +This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). + +## Getting Started + +First, run the development server: + +```bash +npm run dev +# or +yarn dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. + +[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. + +The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. + +## Learn More + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. diff --git a/packages/artplayer-template/next.js/next.config.js b/packages/artplayer-template/next.js/next.config.js new file mode 100644 index 000000000..a843cbee0 --- /dev/null +++ b/packages/artplayer-template/next.js/next.config.js @@ -0,0 +1,6 @@ +/** @type {import('next').NextConfig} */ +const nextConfig = { + reactStrictMode: true, +} + +module.exports = nextConfig diff --git a/packages/artplayer-template/next.js/package.json b/packages/artplayer-template/next.js/package.json new file mode 100644 index 000000000..c4184c4bb --- /dev/null +++ b/packages/artplayer-template/next.js/package.json @@ -0,0 +1,21 @@ +{ + "name": "next.js", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "lint": "next lint" + }, + "dependencies": { + "artplayer": "latest", + "next": "12.1.6", + "react": "18.1.0", + "react-dom": "18.1.0" + }, + "devDependencies": { + "eslint": "8.14.0", + "eslint-config-next": "12.1.6" + } +} diff --git a/packages/artplayer-template/next.js/pages/ArtPlayer.js b/packages/artplayer-template/next.js/pages/ArtPlayer.js new file mode 100644 index 000000000..1c7af62e1 --- /dev/null +++ b/packages/artplayer-template/next.js/pages/ArtPlayer.js @@ -0,0 +1,25 @@ +import { useEffect, useRef } from "react"; +import Artplayer from "artplayer"; + +export default function ({ 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); + } + }; + }, [option, getInstance]); + + return
; +} diff --git a/packages/artplayer-template/next.js/pages/_app.js b/packages/artplayer-template/next.js/pages/_app.js new file mode 100644 index 000000000..1e1cec924 --- /dev/null +++ b/packages/artplayer-template/next.js/pages/_app.js @@ -0,0 +1,7 @@ +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 new file mode 100644 index 000000000..df63de88f --- /dev/null +++ b/packages/artplayer-template/next.js/pages/api/hello.js @@ -0,0 +1,5 @@ +// 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 new file mode 100644 index 000000000..44a39160f --- /dev/null +++ b/packages/artplayer-template/next.js/pages/index.js @@ -0,0 +1,21 @@ +import { useRef } from "react"; +import Artplayer from "./Artplayer"; + +export default function Home() { + const option = useRef({ + url: "https://artplayer.org/assets/sample/video.mp4", + autoSize: true, + }); + + return ( + console.log(art)} + /> + ); +} diff --git a/packages/artplayer-template/next.js/public/favicon.ico b/packages/artplayer-template/next.js/public/favicon.ico new file mode 100644 index 000000000..718d6fea4 Binary files /dev/null and b/packages/artplayer-template/next.js/public/favicon.ico differ diff --git a/packages/artplayer-template/next.js/public/vercel.svg b/packages/artplayer-template/next.js/public/vercel.svg new file mode 100644 index 000000000..fbf0e25a6 --- /dev/null +++ b/packages/artplayer-template/next.js/public/vercel.svg @@ -0,0 +1,4 @@ + + + \ 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 new file mode 100644 index 000000000..32a57d52f --- /dev/null +++ b/packages/artplayer-template/next.js/styles/Home.module.css @@ -0,0 +1,116 @@ +.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 new file mode 100644 index 000000000..e5e2dcc23 --- /dev/null +++ b/packages/artplayer-template/next.js/styles/globals.css @@ -0,0 +1,16 @@ +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 new file mode 100644 index 000000000..a6b984db0 --- /dev/null +++ b/packages/artplayer-template/nuxt.js/.gitignore @@ -0,0 +1,105 @@ +# 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 new file mode 100644 index 000000000..a3d91057b --- /dev/null +++ b/packages/artplayer-template/nuxt.js/Artplayer.vue @@ -0,0 +1,36 @@ + + + \ No newline at end of file diff --git a/packages/artplayer-template/nuxt.js/LICENSE b/packages/artplayer-template/nuxt.js/LICENSE new file mode 100644 index 000000000..6ea0c1891 --- /dev/null +++ b/packages/artplayer-template/nuxt.js/LICENSE @@ -0,0 +1,21 @@ +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 new file mode 100644 index 000000000..61b92025f --- /dev/null +++ b/packages/artplayer-template/nuxt.js/README.md @@ -0,0 +1,42 @@ +# 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 new file mode 100644 index 000000000..d7723d18a --- /dev/null +++ b/packages/artplayer-template/nuxt.js/app.vue @@ -0,0 +1,35 @@ + + + \ No newline at end of file diff --git a/packages/artplayer-template/nuxt.js/nuxt.config.ts b/packages/artplayer-template/nuxt.js/nuxt.config.ts new file mode 100644 index 000000000..ac44f39e6 --- /dev/null +++ b/packages/artplayer-template/nuxt.js/nuxt.config.ts @@ -0,0 +1,6 @@ +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 new file mode 100644 index 000000000..3c2f186cc --- /dev/null +++ b/packages/artplayer-template/nuxt.js/package.json @@ -0,0 +1,15 @@ +{ + "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 new file mode 100644 index 000000000..a7bfa186c --- /dev/null +++ b/packages/artplayer-template/nuxt.js/tsconfig.json @@ -0,0 +1,4 @@ +{ + // 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 new file mode 100644 index 000000000..4d29575de --- /dev/null +++ b/packages/artplayer-template/react.js/.gitignore @@ -0,0 +1,23 @@ +# 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 new file mode 100644 index 000000000..58beeaccd --- /dev/null +++ b/packages/artplayer-template/react.js/README.md @@ -0,0 +1,70 @@ +# 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 new file mode 100644 index 000000000..9e5fc41eb --- /dev/null +++ b/packages/artplayer-template/react.js/package.json @@ -0,0 +1,39 @@ +{ + "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 new file mode 100644 index 000000000..a11777cc4 Binary files /dev/null and b/packages/artplayer-template/react.js/public/favicon.ico differ diff --git a/packages/artplayer-template/react.js/public/index.html b/packages/artplayer-template/react.js/public/index.html new file mode 100644 index 000000000..aa069f27c --- /dev/null +++ b/packages/artplayer-template/react.js/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + React App + + + +
+ + + diff --git a/packages/artplayer-template/react.js/public/logo192.png b/packages/artplayer-template/react.js/public/logo192.png new file mode 100644 index 000000000..fc44b0a37 Binary files /dev/null and b/packages/artplayer-template/react.js/public/logo192.png differ diff --git a/packages/artplayer-template/react.js/public/logo512.png b/packages/artplayer-template/react.js/public/logo512.png new file mode 100644 index 000000000..a4e47a654 Binary files /dev/null and b/packages/artplayer-template/react.js/public/logo512.png differ diff --git a/packages/artplayer-template/react.js/public/manifest.json b/packages/artplayer-template/react.js/public/manifest.json new file mode 100644 index 000000000..080d6c77a --- /dev/null +++ b/packages/artplayer-template/react.js/public/manifest.json @@ -0,0 +1,25 @@ +{ + "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 new file mode 100644 index 000000000..e9e57dc4d --- /dev/null +++ b/packages/artplayer-template/react.js/public/robots.txt @@ -0,0 +1,3 @@ +# 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 new file mode 100644 index 000000000..74b5e0534 --- /dev/null +++ b/packages/artplayer-template/react.js/src/App.css @@ -0,0 +1,38 @@ +.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 new file mode 100644 index 000000000..fe4da118f --- /dev/null +++ b/packages/artplayer-template/react.js/src/App.js @@ -0,0 +1,23 @@ +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 new file mode 100644 index 000000000..1f03afeec --- /dev/null +++ b/packages/artplayer-template/react.js/src/App.test.js @@ -0,0 +1,8 @@ +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 new file mode 100644 index 000000000..ad0f5a337 --- /dev/null +++ b/packages/artplayer-template/react.js/src/ArtPlayer.js @@ -0,0 +1,25 @@ +import { useEffect, useRef } from "react"; +import Artplayer from "artplayer"; + +export default function ArtplayerReact({ 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); + } + }; + }, [option, getInstance]); + + return
; +} diff --git a/packages/artplayer-template/react.js/src/index.css b/packages/artplayer-template/react.js/src/index.css new file mode 100644 index 000000000..ec2585e8c --- /dev/null +++ b/packages/artplayer-template/react.js/src/index.css @@ -0,0 +1,13 @@ +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 new file mode 100644 index 000000000..d563c0fb1 --- /dev/null +++ b/packages/artplayer-template/react.js/src/index.js @@ -0,0 +1,17 @@ +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 new file mode 100644 index 000000000..9dfc1c058 --- /dev/null +++ b/packages/artplayer-template/react.js/src/logo.svg @@ -0,0 +1 @@ + \ 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 new file mode 100644 index 000000000..5253d3ad9 --- /dev/null +++ b/packages/artplayer-template/react.js/src/reportWebVitals.js @@ -0,0 +1,13 @@ +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 new file mode 100644 index 000000000..8f2609b7b --- /dev/null +++ b/packages/artplayer-template/react.js/src/setupTests.js @@ -0,0 +1,5 @@ +// 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/vue.js/.gitignore b/packages/artplayer-template/vue.js/.gitignore new file mode 100644 index 000000000..38adffa64 --- /dev/null +++ b/packages/artplayer-template/vue.js/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/packages/artplayer-template/vue.js/README.md b/packages/artplayer-template/vue.js/README.md new file mode 100644 index 000000000..072204873 --- /dev/null +++ b/packages/artplayer-template/vue.js/README.md @@ -0,0 +1,29 @@ +# vue.js + +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). + +## Customize configuration + +See [Vite Configuration Reference](https://vitejs.dev/config/). + +## Project Setup + +```sh +npm install +``` + +### Compile and Hot-Reload for Development + +```sh +npm run dev +``` + +### Compile and Minify for Production + +```sh +npm run build +``` diff --git a/packages/artplayer-template/vue.js/index.html b/packages/artplayer-template/vue.js/index.html new file mode 100644 index 000000000..030a6ff51 --- /dev/null +++ b/packages/artplayer-template/vue.js/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/packages/artplayer-template/vue.js/package.json b/packages/artplayer-template/vue.js/package.json new file mode 100644 index 000000000..b992b4e85 --- /dev/null +++ b/packages/artplayer-template/vue.js/package.json @@ -0,0 +1,17 @@ +{ + "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/vue.js/public/favicon.ico b/packages/artplayer-template/vue.js/public/favicon.ico new file mode 100644 index 000000000..df36fcfb7 Binary files /dev/null and b/packages/artplayer-template/vue.js/public/favicon.ico differ 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..b9673cf14 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/App.vue @@ -0,0 +1,31 @@ + + + \ No newline at end of file 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..a3d91057b --- /dev/null +++ b/packages/artplayer-template/vue.js/src/Artplayer.vue @@ -0,0 +1,36 @@ + + + \ No newline at end of file diff --git a/packages/artplayer-template/vue.js/src/assets/base.css b/packages/artplayer-template/vue.js/src/assets/base.css new file mode 100644 index 000000000..71dc55a3c --- /dev/null +++ b/packages/artplayer-template/vue.js/src/assets/base.css @@ -0,0 +1,74 @@ +/* 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/vue.js/src/assets/logo.svg b/packages/artplayer-template/vue.js/src/assets/logo.svg new file mode 100644 index 000000000..bc826fed8 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/artplayer-template/vue.js/src/components/HelloWorld.vue b/packages/artplayer-template/vue.js/src/components/HelloWorld.vue new file mode 100644 index 000000000..1b8faac15 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/HelloWorld.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/packages/artplayer-template/vue.js/src/components/TheWelcome.vue b/packages/artplayer-template/vue.js/src/components/TheWelcome.vue new file mode 100644 index 000000000..6c09bb990 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/TheWelcome.vue @@ -0,0 +1,84 @@ + + + diff --git a/packages/artplayer-template/vue.js/src/components/WelcomeItem.vue b/packages/artplayer-template/vue.js/src/components/WelcomeItem.vue new file mode 100644 index 000000000..ba0def33c --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/WelcomeItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/packages/artplayer-template/vue.js/src/components/icons/IconCommunity.vue b/packages/artplayer-template/vue.js/src/components/icons/IconCommunity.vue new file mode 100644 index 000000000..2dc8b0552 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/icons/IconCommunity.vue @@ -0,0 +1,7 @@ + diff --git a/packages/artplayer-template/vue.js/src/components/icons/IconDocumentation.vue b/packages/artplayer-template/vue.js/src/components/icons/IconDocumentation.vue new file mode 100644 index 000000000..6d4791cfb --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/icons/IconDocumentation.vue @@ -0,0 +1,7 @@ + diff --git a/packages/artplayer-template/vue.js/src/components/icons/IconEcosystem.vue b/packages/artplayer-template/vue.js/src/components/icons/IconEcosystem.vue new file mode 100644 index 000000000..c3a4f078c --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/icons/IconEcosystem.vue @@ -0,0 +1,7 @@ + diff --git a/packages/artplayer-template/vue.js/src/components/icons/IconSupport.vue b/packages/artplayer-template/vue.js/src/components/icons/IconSupport.vue new file mode 100644 index 000000000..7452834d3 --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/icons/IconSupport.vue @@ -0,0 +1,7 @@ + diff --git a/packages/artplayer-template/vue.js/src/components/icons/IconTooling.vue b/packages/artplayer-template/vue.js/src/components/icons/IconTooling.vue new file mode 100644 index 000000000..660598d7c --- /dev/null +++ b/packages/artplayer-template/vue.js/src/components/icons/IconTooling.vue @@ -0,0 +1,19 @@ + + 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..116273fb2 --- /dev/null +++ b/packages/artplayer-template/vue.js/vite.config.js @@ -0,0 +1,14 @@ +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/scripts/projects.js b/scripts/projects.js index 99bff8e8a..e6c793848 100644 --- a/scripts/projects.js +++ b/scripts/projects.js @@ -3,7 +3,7 @@ import glob from 'glob'; export default glob .sync(path.join(process.cwd(), 'packages/*')) - .filter((item) => !item.endsWith('artplayer-document')) + .filter((item) => !item.endsWith('artplayer-document') && !item.endsWith('artplayer-template')) .reduce((result, item) => { const name = item.split(path.sep).pop(); result[name] = item;