Fix dev.js

This commit is contained in:
Harvey committed 2022-04-28 13:04:58 +08:00
1 parent 9cb8c56e4d
commit dd8ba4c64d
9 files changed
+1119 -6

No files matched your search

+2 -2
View File
@@ -29,14 +29,14 @@
<li class="title">Plugins</li>
<li>
<a
href="./?libs=.%2Funcompiled%2Fartplayer-plugin-danmuku.js&example=danmuku">artplayer-plugin-danmuku</a>
href="/?libs=./uncompiled/artplayer-plugin-danmuku/index.js&example=danmuku">artplayer-plugin-danmuku</a>
</li>
</ul>
<ul>
<li class="title">Tools</li>
<li>
<a
href="./?libs=.%2Funcompiled%2Fartplayer-tool-thumbnail.js&example=thumbnail">artplayer-tool-thumbnail</a>
href="/?libs=./uncompiled/artplayer-tool-thumbnail/index.js&example=thumbnail">artplayer-tool-thumbnail</a>
</li>
</ul>
</div>
@@ -0,0 +1,648 @@
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
(function (modules, entry, mainEntry, parcelRequireName, globalName) {
/* eslint-disable no-undef */
var globalObject =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {};
/* eslint-enable no-undef */
// Save the require from previous bundle to this closure if any
var previousRequire =
typeof globalObject[parcelRequireName] === 'function' &&
globalObject[parcelRequireName];
var cache = previousRequire.cache || {};
// Do not use `require` to prevent Webpack from trying to bundle this call
var nodeRequire =
typeof module !== 'undefined' &&
typeof module.require === 'function' &&
module.require.bind(module);
function newRequire(name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire =
typeof globalObject[parcelRequireName] === 'function' &&
globalObject[parcelRequireName];
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
// Try the node require function if it exists.
if (nodeRequire && typeof name === 'string') {
return nodeRequire(name);
}
var err = new Error("Cannot find module '" + name + "'");
err.code = 'MODULE_NOT_FOUND';
throw err;
}
localRequire.resolve = resolve;
localRequire.cache = {};
var module = (cache[name] = new newRequire.Module(name));
modules[name][0].call(
module.exports,
localRequire,
module,
module.exports,
this
);
}
return cache[name].exports;
function localRequire(x) {
var res = localRequire.resolve(x);
return res === false ? {} : newRequire(res);
}
function resolve(x) {
var id = modules[name][1][x];
return id != null ? id : x;
}
}
function Module(moduleName) {
this.id = moduleName;
this.bundle = newRequire;
this.exports = {};
}
newRequire.isParcelRequire = true;
newRequire.Module = Module;
newRequire.modules = modules;
newRequire.cache = cache;
newRequire.parent = previousRequire;
newRequire.register = function (id, exports) {
modules[id] = [
function (require, module) {
module.exports = exports;
},
{},
];
};
Object.defineProperty(newRequire, 'root', {
get: function () {
return globalObject[parcelRequireName];
},
});
globalObject[parcelRequireName] = newRequire;
for (var i = 0; i < entry.length; i++) {
newRequire(entry[i]);
}
if (mainEntry) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire(mainEntry);
// CommonJS
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = mainExports;
// RequireJS
} else if (typeof define === 'function' && define.amd) {
define(function () {
return mainExports;
});
// <script>
} else if (globalName) {
this[globalName] = mainExports;
}
}
})({"lIf7X":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _danmuku = require("./danmuku");
var _danmukuDefault = parcelHelpers.interopDefault(_danmuku);
function artplayerPluginDanmuku(option) {
return (art)=>{
const danmuku = new _danmukuDefault.default(art, option);
return {
name: 'artplayerPluginDanmuku',
emit: danmuku.emit.bind(danmuku),
config: danmuku.config.bind(danmuku),
hide: danmuku.hide.bind(danmuku),
show: danmuku.show.bind(danmuku),
get isHide () {
return danmuku.isHide;
}
};
};
}
exports.default = artplayerPluginDanmuku;
window['artplayerPluginDanmuku'] = artplayerPluginDanmuku;
},{"./danmuku":"cv7fe","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"cv7fe":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _i18N = require("./i18n");
var _i18NDefault = parcelHelpers.interopDefault(_i18N);
var _utils = require("./utils");
var _bilibili = require("./bilibili");
var _getDanmuTop = require("./getDanmuTop");
var _getDanmuTopDefault = parcelHelpers.interopDefault(_getDanmuTop);
class Danmuku {
constructor(art, option){
art.i18n.update(_i18NDefault.default);
this.art = art;
this.queue = [];
this.option = {};
this.config(option);
this.isStop = false;
this.isHide = false;
this.animationFrameTimer = null;
this.$danmuku = art.template.$danmuku;
art.on('video:play', this.start.bind(this));
art.on('video:playing', this.start.bind(this));
art.on('video:pause', this.stop.bind(this));
art.on('video:waiting', this.stop.bind(this));
art.on('resize', this.resize.bind(this));
art.on('destroy', this.stop.bind(this));
this.load();
}
static get option() {
return {
danmuku: [],
speed: 5,
maxlength: 50,
margin: [
10,
100
],
opacity: 1,
fontSize: 25,
synchronousPlayback: false
};
}
static get scheme() {
return {
danmuku: 'array|function|string',
speed: 'number',
maxlength: 'number',
margin: 'array',
opacity: 'number',
fontSize: 'number',
synchronousPlayback: 'boolean'
};
}
load() {
if (typeof this.option.danmuku === 'function') this.option.danmuku().then((danmus)=>{
this.queue = [];
this.$danmuku.innerText = '';
danmus.forEach(this.emit.bind(this));
this.art.emit('artplayerPluginDanmuku:loaded');
});
else if (typeof this.option.danmuku === 'string') _bilibili.bilibiliDanmuParseFromUrl(this.option.danmuku).then((danmus)=>{
this.queue = [];
this.$danmuku.innerText = '';
danmus.forEach(this.emit.bind(this));
this.art.emit('artplayerPluginDanmuku:loaded');
});
else {
this.queue = [];
this.$danmuku.innerText = '';
this.option.danmuku.forEach(this.emit.bind(this));
this.art.emit('artplayerPluginDanmuku:loaded');
}
return this;
}
config(option) {
const { utils: { clamp } , validator , } = this.art.constructor;
this.option = Object.assign({}, Danmuku.option, this.option, option);
validator(this.option, Danmuku.scheme);
this.option.speed = clamp(this.option.speed, 1, 10);
this.option.maxlength = clamp(this.option.maxlength, 10, 100);
this.option.margin[0] = clamp(this.option.margin[0], 0, 100);
this.option.margin[1] = clamp(this.option.margin[1], 0, 100);
this.option.opacity = clamp(this.option.opacity, 0, 1);
this.option.fontSize = clamp(this.option.fontSize, 12, 30);
this.art.emit('artplayerPluginDanmuku:config', this.option);
return this;
}
continue() {
_utils.filter(this.queue, 'stop', (danmu)=>{
danmu.$state = 'emit';
danmu.$lastStartTime = Date.now();
switch(danmu.mode){
case 0:
danmu.$ref.style.transform = `translateX(${-danmu.$restWidth}px) translateY(0px) translateZ(0px)`;
danmu.$ref.style.transition = `transform ${danmu.$restTime}s linear 0s`;
break;
default:
break;
}
});
return this;
}
suspend() {
const { $player } = this.art.template;
_utils.filter(this.queue, 'emit', (danmu)=>{
danmu.$state = 'stop';
switch(danmu.mode){
case 0:
{
const { left: playerLeft , width: playerWidth } = _utils.getRect($player);
const { left: danmuLeft } = _utils.getRect(danmu.$ref);
const translateX = playerWidth - (danmuLeft - playerLeft) + 5;
danmu.$ref.style.transform = `translateX(${-translateX}px) translateY(0px) translateZ(0px)`;
danmu.$ref.style.transition = 'transform 0s linear 0s';
break;
}
default:
break;
}
});
return this;
}
resize() {
const { $player } = this.art.template;
const danmuLeft = _utils.getRect($player, 'width');
_utils.filter(this.queue, 'wait', (danmu)=>{
if (danmu.$ref) {
danmu.$ref.style.border = 'none';
danmu.$ref.style.left = `${danmuLeft}px`;
danmu.$ref.style.marginLeft = '0px';
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
danmu.$ref.style.transition = 'transform 0s linear 0s';
}
});
return this;
}
update() {
const { $player } = this.art.template;
this.animationFrameTimer = window.requestAnimationFrame(()=>{
if (this.art.playing && !this.isHide) {
const danmuLeft = _utils.getRect($player, 'width');
_utils.filter(this.queue, 'emit', (danmu)=>{
danmu.$restTime -= (Date.now() - danmu.$lastStartTime) / 1000;
danmu.$lastStartTime = Date.now();
if (danmu.$restTime <= 0) {
danmu.$state = 'wait';
danmu.$ref.style.border = 'none';
danmu.$ref.style.left = `${danmuLeft}px`;
danmu.$ref.style.marginLeft = '0px';
danmu.$ref.style.transform = 'translateX(0px) translateY(0px) translateZ(0px)';
danmu.$ref.style.transition = 'transform 0s linear 0s';
}
});
this.queue.filter((danmu)=>this.art.currentTime + 0.1 >= danmu.time && danmu.time >= this.art.currentTime - 0.1 && danmu.$state === 'wait'
).forEach((danmu)=>{
danmu.$ref = _utils.getDanmuRef(this.queue);
this.$danmuku.appendChild(danmu.$ref);
danmu.$ref.style.opacity = this.option.opacity;
danmu.$ref.style.fontSize = `${this.option.fontSize}px`;
danmu.$ref.innerText = danmu.text;
danmu.$ref.style.color = danmu.color || '#fff';
danmu.$ref.style.border = danmu.border ? `1px solid ${danmu.color || '#fff'}` : 'none';
danmu.$restTime = this.option.synchronousPlayback && this.art.playbackRate ? this.option.speed / Number(this.art.playbackRate) : this.option.speed;
danmu.$lastStartTime = Date.now();
const danmuWidth = _utils.getRect(danmu.$ref, 'width');
const danmuTop = _getDanmuTopDefault.default(this, danmu);
danmu.$state = 'emit';
switch(danmu.mode){
case 0:
danmu.$restWidth = danmuLeft + danmuWidth + 5;
danmu.$ref.style.left = `${danmuLeft}px`;
danmu.$ref.style.top = `${danmuTop}px`;
danmu.$ref.style.transform = `translateX(${-danmu.$restWidth}px) translateY(0px) translateZ(0px)`;
danmu.$ref.style.transition = `transform ${danmu.$restTime}s linear 0s`;
break;
case 1:
danmu.$ref.style.top = `${danmuTop}px`;
danmu.$ref.style.left = '50%';
danmu.$ref.style.marginLeft = `-${danmuWidth / 2}px`;
break;
default:
break;
}
});
}
if (!this.isStop) this.update();
});
return this;
}
stop() {
this.isStop = true;
this.suspend();
window.cancelAnimationFrame(this.animationFrameTimer);
this.art.emit('artplayerPluginDanmuku:stop');
return this;
}
start() {
this.isStop = false;
this.continue();
this.update();
this.art.emit('artplayerPluginDanmuku:start');
return this;
}
show() {
this.isHide = false;
this.$danmuku.style.display = 'block';
this.art.emit('artplayerPluginDanmuku:show');
return this;
}
hide() {
this.isHide = true;
this.$danmuku.style.display = 'none';
this.art.emit('artplayerPluginDanmuku:hide');
return this;
}
emit(danmu) {
const { notice , i18n } = this.art;
const { utils: { clamp } , validator , } = this.art.constructor;
validator(danmu, {
text: 'string',
mode: 'number|undefined',
color: 'string|undefined',
time: 'number|undefined',
border: 'boolean|undefined'
});
if (!danmu.text.trim()) {
notice.show = i18n.get('Danmu text cannot be empty');
return this;
}
if (danmu.text.length > this.option.maxlength) {
notice.show = `${i18n.get('The length of the danmu does not exceed')} ${this.option.maxlength}`;
return this;
}
if (danmu.time) danmu.time = clamp(danmu.time, 0, Infinity);
else danmu.time = this.art.currentTime + 0.5;
this.queue.push({
mode: 0,
...danmu,
$state: 'wait',
$ref: null,
$restTime: 0,
$lastStartTime: 0,
$restWidth: 0
});
return this;
}
}
exports.default = Danmuku;
},{"./i18n":"jX6xP","./utils":"9VWnI","./bilibili":"95SuC","./getDanmuTop":"2ouQq","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"jX6xP":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
exports.default = {
'zh-cn': {
'Danmu opacity': '弹幕透明度',
'Danmu speed': '弹幕速度',
'Danmu size': '弹幕大小',
'Danmu text cannot be empty': '弹幕文本不能为空',
'The length of the danmu does not exceed': '弹幕文本字数不能超过',
'Danmu speed synchronous playback multiple': '弹幕速度同步播放倍数'
},
'zh-tw': {
'Danmu opacity': '彈幕透明度',
'Danmu speed': '彈幕速度',
'Danmu size': '弹幕大小',
'Danmu text cannot be empty': '彈幕文本不能為空',
'The length of the danmu does not exceed': '彈幕文本字數不能超過',
'Danmu speed synchronous playback multiple': '彈幕速度同步播放倍數'
}
};
},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"5dUr6":[function(require,module,exports) {
exports.interopDefault = function(a) {
return a && a.__esModule ? a : {
default: a
};
};
exports.defineInteropFlag = function(a) {
Object.defineProperty(a, '__esModule', {
value: true
});
};
exports.exportAll = function(source, dest) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) return;
Object.defineProperty(dest, key, {
enumerable: true,
get: function() {
return source[key];
}
});
});
return dest;
};
exports.export = function(dest, destName, get) {
Object.defineProperty(dest, destName, {
enumerable: true,
get: get
});
};
},{}],"9VWnI":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "filter", ()=>filter
);
parcelHelpers.export(exports, "getRect", ()=>getRect
);
parcelHelpers.export(exports, "getDanmuRef", ()=>getDanmuRef
);
function filter(queue, state, callback) {
return queue.filter((danmu)=>danmu.$state === state
).map(callback);
}
function getRect(ref, key) {
const result = ref.getBoundingClientRect();
return key ? result[key] : result;
}
function getDanmuRef(queue) {
const result = queue.find((danmu)=>{
return danmu.$ref && danmu.$state === 'wait';
});
if (result) {
const { $ref } = result;
result.$ref = null;
return $ref;
}
const $ref = document.createElement('div');
$ref.style.cssText = `
user-select: none;
position: absolute;
white-space: pre;
pointer-events: none;
perspective: 500px;
display: inline-block;
will-change: transform;
font-family: SimHei, "Microsoft JhengHei", Arial, Helvetica, sans-serif;
font-weight: normal;
line-height: 1.125;
text-shadow: rgb(0, 0, 0) 1px 0px 1px, rgb(0, 0, 0) 0px 1px 1px, rgb(0, 0, 0) 0px -1px 1px, rgb(0, 0, 0) -1px 0px 1px;
`;
return $ref;
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"95SuC":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "getMode", ()=>getMode
);
parcelHelpers.export(exports, "bilibiliDanmuParseFromXml", ()=>bilibiliDanmuParseFromXml
);
parcelHelpers.export(exports, "bilibiliDanmuParseFromUrl", ()=>bilibiliDanmuParseFromUrl
);
function getMode(key) {
switch(key){
case 1:
case 2:
case 3:
return 0;
case 4:
case 5:
return 1;
default:
return 0;
}
}
function bilibiliDanmuParseFromXml(xmlString) {
if (typeof xmlString !== 'string') return [];
const srtList = xmlString.match(/<d([\S ]*?>[\S ]*?)<\/d>/gi);
return srtList && srtList.length ? srtList.map((item)=>{
const [, attrStr, text] = item.match(/<d p="(.+)">(.+)<\/d>/);
const attr = attrStr.split(',');
return attr.length === 8 && text.trim() ? {
text,
time: Number(attr[0]),
mode: getMode(Number(attr[1])),
fontSize: Number(attr[2]),
color: `#${Number(attr[3]).toString(16)}`,
timestamp: Number(attr[4]),
pool: Number(attr[5]),
userID: attr[6],
rowID: Number(attr[7])
} : null;
}) : [];
}
function bilibiliDanmuParseFromUrl(url) {
return fetch(url).then((res)=>res.text()
).then((xmlString)=>bilibiliDanmuParseFromXml(xmlString)
);
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"2ouQq":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _utils = require("./utils");
function calculatedTop(danmus) {
let top = 0;
const topMap = {};
for(let index3 = 0; index3 < danmus.length; index3 += 1){
const item = danmus[index3];
if (topMap[item.top]) topMap[item.top].push(item);
else topMap[item.top] = [
item
];
}
const topMapKeys = Object.keys(topMap);
let maxDiff = 0;
for(let index1 = 1; index1 < danmus.length; index1 += 1){
const item = danmus[index1];
const prev = danmus[index1 - 1];
const prevTop = prev.top + prev.height;
const diff = item.top - prevTop;
if (diff > maxDiff) {
top = prevTop;
maxDiff = diff;
}
}
if (top === 0) {
let maxRight = 0;
for(let index = 0; index < topMapKeys.length; index += 1){
let minRight = danmus[0].width;
const topKey = topMapKeys[index];
const danmuArr = topMap[topKey];
for(let index2 = 0; index2 < danmuArr.length; index2 += 1){
const danmu = danmuArr[index2];
if (danmu.right < minRight) minRight = danmu.right;
}
if (minRight > maxRight) {
maxRight = minRight;
[{ top }] = danmuArr;
}
}
}
if (top === 0) [top] = topMapKeys.filter((item, index)=>{
return index !== 0 && index !== topMapKeys.length - 1;
}).sort((prev, next)=>{
return topMap[prev].length - topMap[next].length;
});
return top;
}
function getDanmuTop(ins, danmu) {
const [marginTop, marginBottom] = ins.option.margin;
const playerData = _utils.getRect(ins.art.template.$player);
const danmus = ins.queue.filter((item)=>item.mode === danmu.mode && item.$state === 'emit' && item.$ref && item.$ref.style.fontSize === danmu.$ref.style.fontSize && parseFloat(item.$ref.style.top) <= playerData.height - marginBottom
).map((item)=>{
const danmuData = _utils.getRect(item.$ref);
const { width , height } = danmuData;
const top = danmuData.top - playerData.top;
const left = danmuData.left - playerData.left;
const right = playerData.width - left - width;
return {
top,
left,
height,
width,
right
};
}).sort((prev, next)=>prev.top - next.top
);
if (danmus.length === 0) return marginTop;
danmus.unshift({
top: 0,
left: 0,
right: 0,
height: marginTop,
width: playerData.width
});
danmus.push({
top: playerData.height - marginBottom,
left: 0,
right: 0,
height: marginBottom,
width: playerData.width
});
return calculatedTop(danmus);
}
exports.default = getDanmuTop;
},{"./utils":"9VWnI","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}]},["lIf7X"], "lIf7X", "parcelRequire4dc0")
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA,mCAAgC;;AAEjB,SAAS,sBAAsB,CAAC,MAAM,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I;gBACd,KAAK,CAAC;oBACF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,mCAAmC,CAAC,CAAC;oBAClG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;oBACxE,MAAM;gBACV;oBACI,MAAM;aACb;SACJ,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;KACf;IAED,OAAO,GAAG;QACN,MAAM,EAAE,OAAO,CAAA,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,AAAC;QACtC,aAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,GAAK;YAClC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;YACtB,OAAQ,KAAK,CAAC,IAAI;gBACd,KAAK,CAAC;oBAAE;wBACJ,MAAM,EAAE,IAAI,EAAE,UAAU,CAAA,EAAE,KAAK,EAAE,WAAW,CAAA,EAAE,GAAG,cAAO,CAAC,OAAO,CAAC,AAAC;wBAClE,MAAM,EAAE,IAAILine truncated
@@ -0,0 +1,457 @@
// modules are defined as an array
// [ module function, map of requires ]
//
// map of requires is short require name -> numeric require
//
// anything defined in a previous bundle is accessed via the
// orig method which is the require for previous bundles
(function (modules, entry, mainEntry, parcelRequireName, globalName) {
/* eslint-disable no-undef */
var globalObject =
typeof globalThis !== 'undefined'
? globalThis
: typeof self !== 'undefined'
? self
: typeof window !== 'undefined'
? window
: typeof global !== 'undefined'
? global
: {};
/* eslint-enable no-undef */
// Save the require from previous bundle to this closure if any
var previousRequire =
typeof globalObject[parcelRequireName] === 'function' &&
globalObject[parcelRequireName];
var cache = previousRequire.cache || {};
// Do not use `require` to prevent Webpack from trying to bundle this call
var nodeRequire =
typeof module !== 'undefined' &&
typeof module.require === 'function' &&
module.require.bind(module);
function newRequire(name, jumped) {
if (!cache[name]) {
if (!modules[name]) {
// if we cannot find the module within our internal map or
// cache jump to the current global require ie. the last bundle
// that was added to the page.
var currentRequire =
typeof globalObject[parcelRequireName] === 'function' &&
globalObject[parcelRequireName];
if (!jumped && currentRequire) {
return currentRequire(name, true);
}
// If there are other bundles on this page the require from the
// previous one is saved to 'previousRequire'. Repeat this as
// many times as there are bundles until the module is found or
// we exhaust the require chain.
if (previousRequire) {
return previousRequire(name, true);
}
// Try the node require function if it exists.
if (nodeRequire && typeof name === 'string') {
return nodeRequire(name);
}
var err = new Error("Cannot find module '" + name + "'");
err.code = 'MODULE_NOT_FOUND';
throw err;
}
localRequire.resolve = resolve;
localRequire.cache = {};
var module = (cache[name] = new newRequire.Module(name));
modules[name][0].call(
module.exports,
localRequire,
module,
module.exports,
this
);
}
return cache[name].exports;
function localRequire(x) {
var res = localRequire.resolve(x);
return res === false ? {} : newRequire(res);
}
function resolve(x) {
var id = modules[name][1][x];
return id != null ? id : x;
}
}
function Module(moduleName) {
this.id = moduleName;
this.bundle = newRequire;
this.exports = {};
}
newRequire.isParcelRequire = true;
newRequire.Module = Module;
newRequire.modules = modules;
newRequire.cache = cache;
newRequire.parent = previousRequire;
newRequire.register = function (id, exports) {
modules[id] = [
function (require, module) {
module.exports = exports;
},
{},
];
};
Object.defineProperty(newRequire, 'root', {
get: function () {
return globalObject[parcelRequireName];
},
});
globalObject[parcelRequireName] = newRequire;
for (var i = 0; i < entry.length; i++) {
newRequire(entry[i]);
}
if (mainEntry) {
// Expose entry point to Node, AMD or browser globals
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
var mainExports = newRequire(mainEntry);
// CommonJS
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = mainExports;
// RequireJS
} else if (typeof define === 'function' && define.amd) {
define(function () {
return mainExports;
});
// <script>
} else if (globalName) {
this[globalName] = mainExports;
}
}
})({"d19bT":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
var _tinyEmitter = require("tiny-emitter");
var _tinyEmitterDefault = parcelHelpers.interopDefault(_tinyEmitter);
var _utils = require("./utils");
class ArtplayerToolThumbnail extends _tinyEmitterDefault.default {
constructor(option = {}){
super();
this.processing = false;
this.option = {};
this.setup(Object.assign({}, ArtplayerToolThumbnail.DEFAULTS, option));
this.video = ArtplayerToolThumbnail.creatVideo();
this.duration = 0;
this.inputChange = this.inputChange.bind(this);
this.ondrop = this.ondrop.bind(this);
this.option.fileInput.addEventListener('change', this.inputChange);
this.option.fileInput.addEventListener('dragover', ArtplayerToolThumbnail.ondragover);
this.option.fileInput.addEventListener('drop', ArtplayerToolThumbnail.ondrop);
}
static get DEFAULTS() {
return {
number: 60,
width: 160,
height: 90,
column: 10,
begin: 0,
end: NaN
};
}
static ondragover(event) {
event.preventDefault();
}
ondrop(event) {
event.preventDefault();
const file = event.dataTransfer.files[0];
this.loadVideo(file);
}
setup(option = {}) {
this.option = Object.assign({}, this.option, option);
const { fileInput , number , width , column } = this.option;
this.errorHandle(fileInput instanceof Element, "The 'fileInput' is not a Element");
if (!(fileInput.tagName === 'INPUT' && fileInput.type === 'file')) {
fileInput.style.position = 'relative';
const newFileInput = document.createElement('input');
newFileInput.type = 'file';
newFileInput.style.position = 'absolute';
newFileInput.style.width = '100%';
newFileInput.style.height = '100%';
newFileInput.style.left = '0';
newFileInput.style.top = '0';
newFileInput.style.right = '0';
newFileInput.style.bottom = '0';
newFileInput.style.opacity = '0';
fileInput.appendChild(newFileInput);
this.option.fileInput = newFileInput;
}
[
'number',
'width',
'column',
'begin',
'end'
].forEach((item)=>{
this.errorHandle(typeof this.option[item] === 'number', `The '${item}' is not a number`);
});
this.option.number = _utils.clamp(number, 10, 1000);
this.option.width = _utils.clamp(width, 10, 1000);
this.option.column = _utils.clamp(column, 1, 1000);
return this;
}
static creatVideo() {
const video = document.createElement('video');
video.style.position = 'absolute';
video.style.top = '-9999px';
video.style.left = '-9999px';
video.muted = true;
video.controls = true;
document.body.appendChild(video);
return video;
}
inputChange(event) {
const file = this.option.fileInput.files[0];
this.loadVideo(file);
event.target.value = '';
}
loadVideo(file) {
if (file) {
const canPlayType = this.video.canPlayType(file.type);
this.errorHandle(canPlayType === 'maybe' || canPlayType === 'probably', `Playback of this file format is not supported: ${file.type}`);
const videoUrl = URL.createObjectURL(file);
this.videoUrl = videoUrl;
this.file = file;
this.emit('file', this.file);
this.video.src = videoUrl;
this.emit('video', this.video);
}
}
start() {
if (!this.video.duration) return _utils.sleep(1000).then(()=>this.start()
);
const { width , number , begin , end } = this.option;
const height = this.video.videoHeight / this.video.videoWidth * width;
this.option.height = height;
this.option.begin = _utils.clamp(begin, 0, this.video.duration);
this.option.end = _utils.clamp(end || this.video.duration, begin, this.video.duration);
this.errorHandle(this.option.end > this.option.begin, `End time must be greater than the start time`);
this.duration = this.option.end - this.option.begin;
this.density = number / this.duration;
this.errorHandle(this.file && this.video, 'Please select the video file first');
this.errorHandle(!this.processing, 'There is currently a task in progress, please wait a moment...');
this.errorHandle(this.density <= 1, `The preview density cannot be greater than 1, but got ${this.density}`);
const screenshotDate = this.creatScreenshotDate();
const canvas = this.creatCanvas();
const context2D = canvas.getContext('2d');
this.emit('canvas', canvas);
const promiseList = screenshotDate.map((item, index)=>()=>{
return new Promise((resolve)=>{
this.video.oncanplay = ()=>{
context2D.drawImage(this.video, item.x, item.y, width, height);
canvas.toBlob((blob)=>{
if (this.thumbnailUrl) URL.revokeObjectURL(this.thumbnailUrl);
this.thumbnailUrl = URL.createObjectURL(blob);
this.emit('update', this.thumbnailUrl, (index + 1) / number);
this.video.oncanplay = null;
resolve();
});
};
this.video.currentTime = item.time;
});
}
);
this.processing = true;
return _utils.runPromisesInSeries(promiseList).then(()=>{
this.processing = false;
this.emit('done');
}).catch((err)=>{
this.processing = false;
this.emit('error', err.message);
throw err;
});
}
creatScreenshotDate() {
const { number , width , height , column , begin } = this.option;
const timeGap = this.duration / number;
const timePoints = [
begin + timeGap
];
while(timePoints.length < number){
const last = timePoints[timePoints.length - 1];
timePoints.push(last + timeGap);
}
return timePoints.map((item, index)=>({
time: item - timeGap / 2,
x: index % column * width,
y: Math.floor(index / column) * height
})
);
}
creatCanvas() {
const { number , width , height , column } = this.option;
const canvas = document.createElement('canvas');
const context2D = canvas.getContext('2d');
canvas.width = width * column;
canvas.height = Math.ceil(number / column) * height + 30;
context2D.fillStyle = 'black';
context2D.fillRect(0, 0, canvas.width, canvas.height);
context2D.font = '14px Georgia';
context2D.fillStyle = '#fff';
context2D.fillText(`From: https://artplayer.org/, Number: ${number}, Width: ${width}, Height: ${height}, Column: ${column}`, 10, canvas.height - 11);
return canvas;
}
download() {
this.errorHandle(this.file && this.thumbnailUrl, 'Download does not seem to be ready, please create preview first');
this.errorHandle(!this.processing, 'There is currently a task in progress, please wait a moment...');
const elink = document.createElement('a');
const name = `${_utils.getFileName(this.file.name)}.png`;
elink.download = name;
elink.href = this.thumbnailUrl;
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
this.emit('download', name);
return this;
}
errorHandle(condition, msg) {
if (!condition) {
this.emit('error', msg);
throw new Error(msg);
}
}
destroy() {
this.option.fileInput.removeEventListener('change', this.inputChange);
this.option.fileInput.removeEventListener('dragover', ArtplayerToolThumbnail.ondragover);
this.option.fileInput.removeEventListener('drop', ArtplayerToolThumbnail.ondrop);
document.body.removeChild(this.video);
if (this.videoUrl) URL.revokeObjectURL(this.videoUrl);
if (this.thumbnailUrl) URL.revokeObjectURL(this.thumbnailUrl);
this.emit('destroy');
}
}
exports.default = ArtplayerToolThumbnail;
window['ArtplayerToolThumbnail'] = ArtplayerToolThumbnail;
},{"tiny-emitter":"ltU3o","./utils":"OYkYn","@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"ltU3o":[function(require,module,exports) {
function E() {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
}
E.prototype = {
on: function(name, callback, ctx) {
var e = this.e || (this.e = {});
(e[name] || (e[name] = [])).push({
fn: callback,
ctx: ctx
});
return this;
},
once: function(name, callback, ctx) {
var self = this;
function listener() {
self.off(name, listener);
callback.apply(ctx, arguments);
}
listener._ = callback;
return this.on(name, listener, ctx);
},
emit: function(name) {
var data = [].slice.call(arguments, 1);
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
var i = 0;
var len = evtArr.length;
for(; i < len; i++)evtArr[i].fn.apply(evtArr[i].ctx, data);
return this;
},
off: function(name, callback) {
var e = this.e || (this.e = {});
var evts = e[name];
var liveEvents = [];
if (evts && callback) {
for(var i = 0, len = evts.length; i < len; i++)if (evts[i].fn !== callback && evts[i].fn._ !== callback) liveEvents.push(evts[i]);
}
// Remove event from queue to prevent memory leak
// Suggested by https://github.com/lazd
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
liveEvents.length ? e[name] = liveEvents : delete e[name];
return this;
}
};
module.exports = E;
module.exports.TinyEmitter = E;
},{}],"OYkYn":[function(require,module,exports) {
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
parcelHelpers.defineInteropFlag(exports);
parcelHelpers.export(exports, "sleep", ()=>sleep
);
parcelHelpers.export(exports, "runPromisesInSeries", ()=>runPromisesInSeries
);
parcelHelpers.export(exports, "getFileName", ()=>getFileName
);
parcelHelpers.export(exports, "clamp", ()=>clamp
);
function sleep(ms) {
return new Promise((resolve)=>setTimeout(resolve, ms)
);
}
function runPromisesInSeries(ps) {
return ps.reduce((p, next)=>p.then(next)
, Promise.resolve());
}
function getFileName(name) {
const nameArray = name.split('.');
nameArray.pop();
return nameArray.join('.');
}
function clamp(num, a, b) {
return Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
}
},{"@parcel/transformer-js/src/esmodule-helpers.js":"5dUr6"}],"5dUr6":[function(require,module,exports) {
exports.interopDefault = function(a) {
return a && a.__esModule ? a : {
default: a
};
};
exports.defineInteropFlag = function(a) {
Object.defineProperty(a, '__esModule', {
value: true
});
};
exports.exportAll = function(source, dest) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) return;
Object.defineProperty(dest, key, {
enumerable: true,
get: function() {
return source[key];
}
});
});
return dest;
};
exports.export = function(dest, destName, get) {
Object.defineProperty(dest, destName, {
enumerable: true,
get: get
});
};
},{}]},["d19bT"], "d19bT", "parcelRequire4dc0")
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA,0CAAmC;;AACnC,+BAAyE;AAE1D,MAAM,sBAAsB,SAAS,2BAAO;IACvD,YAAY,MAAM,GAAG,EAAE,CAAE;QACrB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,GAAG,sBAAsB,CAAC,UAAU,EAAE,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM,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E,gEAAgE,CAAC,CAAC;QACrG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,sDAAsD,Line truncated
+1 -1
View File
@@ -242,7 +242,7 @@ class Artplayer extends _emitterDefault.default {
return "development";
}
static get build() {
return "1651120263095";
return "1651122272517";
}
static get config() {
return _configDefault.default;
@@ -15,3 +15,5 @@ export default function artplayerPluginDanmuku(option) {
};
};
}
window['artplayerPluginDanmuku'] = artplayerPluginDanmuku;
@@ -1,7 +1,7 @@
import Emitter from 'tiny-emitter';
import { runPromisesInSeries, sleep, getFileName, clamp } from './utils';
class ArtplayerToolThumbnail extends Emitter {
export default class ArtplayerToolThumbnail extends Emitter {
constructor(option = {}) {
super();
this.processing = false;
@@ -221,4 +221,4 @@ class ArtplayerToolThumbnail extends Emitter {
}
}
export default ArtplayerToolThumbnail;
window['ArtplayerToolThumbnail'] = ArtplayerToolThumbnail;
+5 -1
View File
@@ -8,6 +8,7 @@ import { Parcel } from '@parcel/core';
import openBrowser from 'servor/utils/openBrowser.js';
async function develop(name) {
let isOpenBrowser = false;
const uncompiledPath = path.resolve(`docs/uncompiled/${name}`);
const { version } = JSON.parse(fs.readFileSync(`${projects[name]}/package.json`, 'utf-8'));
@@ -18,7 +19,6 @@ async function develop(name) {
port: 8081,
});
openBrowser(url);
process.chdir(projects[name]);
const bundler = new Parcel({
@@ -52,6 +52,10 @@ async function develop(name) {
if (event.type === 'buildSuccess') {
const bundles = event.bundleGraph.getBundles();
console.log(`[${name}]`, `✨ Built ${bundles.length} bundles in ${event.buildTime}ms!`);
if (!isOpenBrowser) {
isOpenBrowser = true;
openBrowser(url);
}
} else if (event.type === 'buildFailure') {
console.log(`[${name}]`, event.diagnostics);
}