mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
update script
This commit is contained in:
1 parent
d62405e8ff
commit
848c6ab131
8 files changed
+106
-69
No files matched your search
@@ -85,4 +85,3 @@
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
//# sourceMappingURL=artplayer-plugin-subtitle.js.map
|
||||
+7
-3
@@ -5,8 +5,12 @@
|
||||
"scripts": {
|
||||
"bootstrap": "node ./node_modules/.bin/lerna bootstrap",
|
||||
"publish": "node ./node_modules/.bin/lerna publish",
|
||||
"dev": "node ./node_modules/.bin/cross-env NODE_ENV=development node ./script/dev.js",
|
||||
"build": "node ./node_modules/.bin/cross-env NODE_ENV=production node ./script/build.js",
|
||||
"dev:artplayer": "cross-env NODE_ENV=development cross-env TARGET=artplayer rollup -w -c scripts/config.js",
|
||||
"dev:artplayer-plugin-danmu": "cross-env NODE_ENV=development cross-env TARGET=artplayer-plugin-danmu rollup -w -c scripts/config.js",
|
||||
"dev:artplayer-plugin-subtitle": "cross-env NODE_ENV=development cross-env TARGET=artplayer-plugin-subtitle rollup -w -c scripts/config.js",
|
||||
"build:artplayer": "cross-env NODE_ENV=production TARGET=artplayer rollup -c scripts/config.js",
|
||||
"build:artplayer-plugin-danmu": "cross-env NODE_ENV=production TARGET=artplayer-plugin-danmu rollup -c scripts/config.js",
|
||||
"build:artplayer-plugin-subtitle": "cross-env NODE_ENV=production TARGET=artplayer-plugin-subtitle rollup -c scripts/config.js",
|
||||
"test": "node ./node_modules/.bin/mocha-chrome ./docs/test/index.html --mocha '{\"ui\":\"bdd\"}'",
|
||||
"lint": "node ./node_modules/.bin/eslint packages/*/src"
|
||||
},
|
||||
@@ -24,7 +28,7 @@
|
||||
"url": "https://github.com/zhw2590582/ArtPlayer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/zhw2590582/ArtPlayer#readme",
|
||||
"devDependencies": {
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.1.2",
|
||||
"@babel/plugin-external-helpers": "^7.0.0",
|
||||
"@babel/plugin-transform-runtime": "^7.1.0",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*!
|
||||
* artplayer-plugin-subtitle.js v1.0.3
|
||||
* artplayer-plugin-subtitle.js v1.0.4
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer#readme
|
||||
* (c) 2017-2018 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["artplayer-plugin-subtitle"]={})}(this,function(t){"use strict";function e(i){var t=i.i18n,a=i.events.proxy;return{title:"Subtitle",name:"subtitle",index:20,html:'\n <div class="art-setting-header">\n '.concat(t.get("Subtitle offset time"),': <span class="art-subtitle-value">0</span>s\n </div>\n <div class="art-setting-body">\n <input\n style="width: 100%;height: 3px;outline: none;appearance: none;-moz-appearance: none;-webkit-appearance: none;background-color: #fff;"\n class="art-subtitle-range"\n type="range"\n min="-5"\n max="5"\n step="0.5"\n >\n </div>\n '),mounted:function(t){var e=t.querySelector(".art-subtitle-range"),n=t.querySelector(".art-subtitle-value");a(e,"change",function(){var t=e.value;n.innerText=t,i.plugins.artplayerPluginSubtitle.set(Number(t))}),i.on("subtitle:switch",function(){e.value=0,n.innerText=0}),i.on("artplayerPluginSubtitle:set",function(t){e.value!==t&&(e.value=t,n.innerText=t)})}}}function n(i){var a=i.constructor.utils.clamp,t=i.setting,r=i.notice,u=i.refs,o=i.i18n;o.update({"zh-cn":{"Subtitle offset time":"字幕偏移时间"},"zh-tw":{"Subtitle offset time":"字幕偏移時間"}}),t.add(e);var s=[];return i.on("subtitle:switch",function(){s=[]}),{set:function(t){var e=Array.from(u.$track.track.cues),n=a(t,-5,5);e.forEach(function(t,e){s[e]||(s[e]={startTime:t.startTime,endTime:t.endTime}),t.startTime=s[e].startTime+n,t.endTime=s[e].endTime+n}),r.show("".concat(o.get("Subtitle offset time"),": ").concat(t,"s")),i.emit("artplayerPluginSubtitle:set",t)}}}window.artplayerPluginSubtitle=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})});
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["artplayer-plugin-subtitle"]={})}(this,function(t){"use strict";function e(i){var t=i.i18n,a=i.events.proxy;return{title:"Subtitle",name:"subtitle",index:20,html:'\n <div class="art-setting-header">\n '.concat(t.get("Subtitle offset time"),': <span class="art-subtitle-value">0</span>s\n </div>\n <div class="art-setting-body">\n <input\n style="width: 100%;height: 3px;outline: none;appearance: none;-moz-appearance: none;-webkit-appearance: none;background-color: #fff;"\n class="art-subtitle-range"\n type="range"\n min="-5"\n max="5"\n step="0.5"\n >\n </div>\n '),mounted:function(t){var e=t.querySelector(".art-subtitle-range"),n=t.querySelector(".art-subtitle-value");a(e,"change",function(){var t=e.value;n.innerText=t,i.plugins.artplayerPluginSubtitle.offset(Number(t))}),i.on("subtitle:switch",function(){e.value=0,n.innerText=0}),i.on("artplayerPluginSubtitle:set",function(t){e.value!==t&&(e.value=t,n.innerText=t)})}}}function n(i){var a=i.constructor.utils.clamp,t=i.setting,r=i.notice,u=i.template,o=i.i18n;o.update({"zh-cn":{"Subtitle offset time":"字幕偏移时间"},"zh-tw":{"Subtitle offset time":"字幕偏移時間"}}),t.add(e);var l=[];return i.on("subtitle:switch",function(){l=[]}),{offset:function(t){var e=Array.from(u.$track.track.cues),n=a(t,-5,5);e.forEach(function(t,e){l[e]||(l[e]={startTime:t.startTime,endTime:t.endTime}),t.startTime=l[e].startTime+n,t.endTime=l[e].endTime+n}),r.show("".concat(o.get("Subtitle offset time"),": ").concat(t,"s")),i.emit("artplayerPluginSubtitle:set",t)}}}window.artplayerPluginSubtitle=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})});
|
||||
Whitespace-only changes.
@@ -1,63 +0,0 @@
|
||||
const path = require('path');
|
||||
const babel = require('rollup-plugin-babel');
|
||||
const commonjs = require('rollup-plugin-commonjs');
|
||||
const nodeResolve = require('rollup-plugin-node-resolve');
|
||||
const postcss = require('rollup-plugin-postcss');
|
||||
const { eslint } = require('rollup-plugin-eslint');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const cssnano = require('cssnano');
|
||||
const replace = require('rollup-plugin-replace');
|
||||
const svgo = require('rollup-plugin-svgo');
|
||||
const { uglify } = require('rollup-plugin-uglify');
|
||||
const { version, homepage, name } = require('./package.json');
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
const banner =
|
||||
'/*!\n' +
|
||||
` * ${name}.js v${version}\n` +
|
||||
` * Github: ${homepage}\n` +
|
||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
||||
' * Released under the MIT License.\n' +
|
||||
' */\n';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
name,
|
||||
file: isProd ? `dist/${name}.js` : path.join(process.cwd(), '../../', `docs/uncompiled/${name}.js`),
|
||||
format: 'umd',
|
||||
exports: 'named',
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
exclude: ['node_modules/**', 'src/**/*.scss', 'src/**/*.svg'],
|
||||
}),
|
||||
postcss({
|
||||
plugins: [autoprefixer, cssnano],
|
||||
extract: isProd ? `dist/${name}.css` : path.join(process.cwd(), '../../', `docs/uncompiled/${name}.css`),
|
||||
}),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
babel({
|
||||
runtimeHelpers: true,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { modules: false }]],
|
||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
|
||||
}),
|
||||
svgo({
|
||||
raw: true,
|
||||
}),
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
|
||||
__VERSION__: version,
|
||||
}),
|
||||
isProd &&
|
||||
uglify({
|
||||
output: {
|
||||
preamble: banner,
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const babel = require('rollup-plugin-babel');
|
||||
const commonjs = require('rollup-plugin-commonjs');
|
||||
const nodeResolve = require('rollup-plugin-node-resolve');
|
||||
const postcss = require('rollup-plugin-postcss');
|
||||
const { eslint } = require('rollup-plugin-eslint');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
const cssnano = require('cssnano');
|
||||
const replace = require('rollup-plugin-replace');
|
||||
const svgo = require('rollup-plugin-svgo');
|
||||
const { uglify } = require('rollup-plugin-uglify');
|
||||
|
||||
function creatRollupConfig(target) {
|
||||
const projectPath = path.join(process.cwd(), 'packages', target);
|
||||
console.log(projectPath);
|
||||
const packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, 'package.json'), 'utf-8'));
|
||||
const { version, homepage, name } = packageJson;
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
const banner =
|
||||
'/*!\n' +
|
||||
` * ${name}.js v${version}\n` +
|
||||
` * Github: ${homepage}\n` +
|
||||
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
||||
' * Released under the MIT License.\n' +
|
||||
' */\n';
|
||||
|
||||
return {
|
||||
input: path.join(projectPath, 'src/index.js'),
|
||||
output: {
|
||||
name,
|
||||
file: isProd ? path.join(projectPath, `dist/${name}.js`) : path.join(process.cwd(), `docs/uncompiled/${name}.js`),
|
||||
format: 'umd',
|
||||
exports: 'named',
|
||||
},
|
||||
plugins: [
|
||||
eslint({
|
||||
exclude: ['node_modules/**', 'src/**/*.scss', 'src/**/*.svg'],
|
||||
}),
|
||||
postcss({
|
||||
plugins: [autoprefixer, cssnano],
|
||||
extract: isProd ? path.join(projectPath, `dist/${name}.css`) : path.join(process.cwd(), `docs/uncompiled/${name}.css`),
|
||||
}),
|
||||
nodeResolve(),
|
||||
commonjs(),
|
||||
babel({
|
||||
runtimeHelpers: true,
|
||||
exclude: 'node_modules/**',
|
||||
presets: [['@babel/env', { modules: false }]],
|
||||
plugins: ['@babel/plugin-external-helpers', '@babel/plugin-transform-runtime'],
|
||||
}),
|
||||
svgo({
|
||||
raw: true,
|
||||
}),
|
||||
replace({
|
||||
exclude: 'node_modules/**',
|
||||
__ENV__: JSON.stringify(process.env.NODE_ENV || 'development'),
|
||||
__VERSION__: version,
|
||||
}),
|
||||
isProd &&
|
||||
uglify({
|
||||
output: {
|
||||
preamble: banner,
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = creatRollupConfig(process.env.TARGET);
|
||||
File renamed without changes.
@@ -0,0 +1,27 @@
|
||||
const chalk = require('chalk');
|
||||
const { format } = require('util');
|
||||
|
||||
const prefix = 'artplayer-cli';
|
||||
const sep = chalk.gray('·');
|
||||
|
||||
exports.log = function log(...args) {
|
||||
const msg = format.apply(format, args);
|
||||
console.log(chalk.white(prefix), sep, msg);
|
||||
};
|
||||
|
||||
exports.fatal = function fatal(...args) {
|
||||
if (args[0] instanceof Error) args[0] = args[0].message.trim();
|
||||
const msg = format.apply(format, args);
|
||||
console.error(chalk.red(prefix), sep, msg);
|
||||
process.exit(1);
|
||||
};
|
||||
|
||||
exports.success = function success(...args) {
|
||||
const msg = format.apply(format, args);
|
||||
console.log(chalk.green(prefix), sep, msg);
|
||||
};
|
||||
|
||||
exports.warn = function warn(...args) {
|
||||
const msg = format.apply(format, args);
|
||||
console.log(chalk.yellow(prefix), sep, msg);
|
||||
};
|
||||
Reference in new issue
Block a user