mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 19:06:15 -08:00
* chore: Bump artplayer-plugin-danmuku version to 5.1.0 * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Refactor getDanmuTop function to handle additional cases * chore: Refactor getDanmuTop function to handle additional cases * chore: Update danmuku plugin with new mount option * chore: Update danmuku plugin with new mount option * chore: Refactor danmuku plugin to always create a new Setting instance * Refactor danmuku plugin to always create a new Setting instance * Refactor danmuku plugin to always create a new Setting instance * Update danmuku.js * Update danmuku.js * Refactor danmuku plugin to include a new Setting instance * Refactor danmuku plugin to include a new Setting instance * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * Refactor danmuku plugin styles for better alignment and spacing * chore: Update package.json files * Refactor danmuku plugin to remove unnecessary whitespace in the setting template * chore: Remove ESLint configuration files and update npm dependencies * chore: Update ESLint configuration to disable console warnings and fix unused variable warnings * chore: Update ESLint configuration to fix quotes rule * Update package.json * Update package.json * Update setting.js * chore: Compress CSS code in build script * chore: Update build script to compress JavaScript code * chore: Update build script to compress JavaScript code * chore: Refactor setting.js to improve code organization and remove unused variables * chore: Add isHover flag to Control component for better control hiding behavior * chore: Update Control component to use $bottom instead of $controls for better control hiding behavior * Update package.json * Update package.json * Update package.json * chore: Update lerna.json to use independent versioning and yarn as npm client * refactor: Update Danmuku class to support configurable modes and visibility * refactor: Update Danmuku styles for better visibility and configurability * feat: Update font weight in Danmuku styles for better readability * refactor: Update Danmuku class to support configurable modes and visibility * refactor: Add opacity, area, font, and speed sliders to Danmuku settings * refactor: Initialize sliders for opacity, area, font, and speed in Danmuku settings * feat: Add slider UI for opacity, area, and speed in Danmuku settings * feat: Update slider styles in Danmuku settings for better visibility and configurability * refactor: Improve Danmuku settings UI for better visibility and configurability * refactor: Improve Danmuku settings UI for better visibility and configurability * refactor: Update slider styles in Danmuku settings for better visibility and configurability * refactor: Update margin slider initialization in Danmuku settings * refactor: Update slider styles and initialization in Danmuku settings * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku class to support configurable visibility * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Improve Danmuku settings UI for better visibility and configurability * add lock * refactor: Add lock and unlock methods to Danmuku settings * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * Update artplayer-plugin-danmuku.d.ts * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings event listeners * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability * refactor: Update Danmuku settings UI for better visibility and configurability
125 lines
3.6 KiB
JavaScript
125 lines
3.6 KiB
JavaScript
import fs from 'fs';
|
|
import cpy from 'cpy';
|
|
import path from 'path';
|
|
import prompts from 'prompts';
|
|
import { Parcel } from '@parcel/core';
|
|
import { formatDate, getProjects } from './utils.js';
|
|
|
|
const projects = getProjects();
|
|
const compiledPath = path.resolve(`docs/compiled`);
|
|
|
|
function compressString(input) {
|
|
const compressedHtmlString = input.replace(/\s*(<[^>]+>)\s*/g, '$1');
|
|
const compressedCssString = compressedHtmlString
|
|
.replace(/\s*([{}:;,])\s*/g, '$1')
|
|
.replace(/\s+/g, ' ')
|
|
.trim();
|
|
return compressedCssString;
|
|
}
|
|
|
|
async function build(name, targetName) {
|
|
const { version } = JSON.parse(fs.readFileSync(`${projects[name]}/package.json`, 'utf-8'));
|
|
process.chdir(projects[name]);
|
|
|
|
const targets = {
|
|
main: {
|
|
context: 'browser',
|
|
distDir: `${projects[name]}/dist`,
|
|
sourceMap: false,
|
|
outputFormat: 'global',
|
|
engines: {
|
|
browsers: 'last 1 Chrome version',
|
|
},
|
|
},
|
|
legacy: {
|
|
context: 'browser',
|
|
distDir: `${projects[name]}/dist`,
|
|
sourceMap: false,
|
|
outputFormat: 'global',
|
|
engines: {
|
|
browsers: 'IE 11',
|
|
},
|
|
},
|
|
};
|
|
|
|
const names = {
|
|
main: name,
|
|
legacy: `${name}.legacy`,
|
|
};
|
|
|
|
const bundler = new Parcel({
|
|
entries: `${projects[name]}/src/index.js`,
|
|
defaultConfig: '@parcel/config-default',
|
|
mode: 'production',
|
|
targets: {
|
|
[targetName]: targets[targetName],
|
|
},
|
|
env: {
|
|
NODE_ENV: 'production',
|
|
APP_VER: version,
|
|
BUILD_DATE: formatDate(Date.now()),
|
|
},
|
|
});
|
|
|
|
const banner =
|
|
'/*!\n' +
|
|
` * ${name}.js v${version}\n` +
|
|
` * Github: https://github.com/zhw2590582/ArtPlayer\n` +
|
|
` * (c) 2017-${new Date().getFullYear()} Harvey Zack\n` +
|
|
' * Released under the MIT License.\n' +
|
|
' */\n';
|
|
|
|
const { bundleGraph, buildTime } = await bundler.run();
|
|
const bundles = bundleGraph.getBundles();
|
|
|
|
const filePath = `${projects[name]}/dist/index.js`;
|
|
const newFilePath = `${projects[name]}/dist/${names[targetName]}.js`;
|
|
const code = String(fs.readFileSync(filePath));
|
|
fs.writeFileSync(filePath, banner + compressString(code));
|
|
fs.renameSync(filePath, newFilePath);
|
|
await cpy(newFilePath, compiledPath);
|
|
const size = fs.statSync(newFilePath).size / 1024;
|
|
console.log(
|
|
`✨ Built@${targetName} ${name}@${version}`,
|
|
`Bundles@${bundles.length}`,
|
|
`Time@${buildTime}ms`,
|
|
`Size@${size}kb`,
|
|
);
|
|
}
|
|
|
|
function runPromisesInSeries(ps) {
|
|
return ps.reduce((p, next) => p.then(next), Promise.resolve());
|
|
}
|
|
|
|
if (process.argv.pop() === 'all') {
|
|
const bundles = Object.keys(projects).map((name) => async () => {
|
|
await build(name, 'main');
|
|
await build(name, 'legacy');
|
|
});
|
|
|
|
runPromisesInSeries(bundles).then(() => {
|
|
console.log(`✨ Finished building all packages!`);
|
|
});
|
|
} else {
|
|
(async () => {
|
|
const response = await prompts({
|
|
type: 'select',
|
|
name: 'value',
|
|
message: 'Which project do you want to build?',
|
|
choices: Object.keys(projects).map((name) => {
|
|
return {
|
|
title: name,
|
|
value: name,
|
|
description: projects[name],
|
|
};
|
|
}),
|
|
initial: 0,
|
|
});
|
|
|
|
if (response.value) {
|
|
await build(response.value, 'main');
|
|
await build(response.value, 'legacy');
|
|
}
|
|
})();
|
|
}
|