build:all

This commit is contained in:
Harvey Zack committed 2023-05-03 10:14:46 +08:00
1 parent 283861b198
commit 5959eb4669
137 files changed
+1869 -2351

No files matched your search

+7 -9
View File
@@ -14,15 +14,13 @@ export default class Events {
this.hover = this.hover.bind(this);
this.loadImg = this.loadImg.bind(this);
if (art.whitelist.state) {
clickInit(art, this);
hoverInit(art, this);
moveInit(art, this);
resizeInit(art, this);
gestureInit(art, this);
viewInit(art, this);
documentInit(art, this);
}
clickInit(art, this);
hoverInit(art, this);
moveInit(art, this);
resizeInit(art, this);
gestureInit(art, this);
viewInit(art, this);
documentInit(art, this);
}
proxy(target, name, callback, option = {}) {
+15 -25
View File
@@ -4,7 +4,6 @@ import Emitter from './utils/emitter';
import * as utils from './utils';
import scheme from './scheme';
import config from './config';
import Whitelist from './whitelist';
import Template from './template';
import I18n from './i18n';
import Player from './player';
@@ -22,7 +21,6 @@ import Icons from './icons';
import Setting from './setting';
import Storage from './storage';
import Plugins from './plugins';
import Mobile from './mobile';
let id = 0;
const instances = [];
@@ -44,29 +42,23 @@ export default class Artplayer extends Emitter {
this.isRotate = false;
this.isDestroy = false;
this.whitelist = new Whitelist(this);
this.template = new Template(this);
this.events = new Events(this);
if (this.whitelist.state) {
this.storage = new Storage(this);
this.icons = new Icons(this);
this.i18n = new I18n(this);
this.notice = new Notice(this);
this.player = new Player(this);
this.layers = new Layer(this);
this.controls = new Control(this);
this.contextmenu = new Contextmenu(this);
this.subtitle = new Subtitle(this);
this.info = new Info(this);
this.loading = new Loading(this);
this.hotkey = new Hotkey(this);
this.mask = new Mask(this);
this.setting = new Setting(this);
this.plugins = new Plugins(this);
} else {
this.mobile = new Mobile(this);
}
this.storage = new Storage(this);
this.icons = new Icons(this);
this.i18n = new I18n(this);
this.notice = new Notice(this);
this.player = new Player(this);
this.layers = new Layer(this);
this.controls = new Control(this);
this.contextmenu = new Contextmenu(this);
this.subtitle = new Subtitle(this);
this.info = new Info(this);
this.loading = new Loading(this);
this.hotkey = new Hotkey(this);
this.mask = new Mask(this);
this.setting = new Setting(this);
this.plugins = new Plugins(this);
if (typeof readyCallback === 'function') {
this.on('ready', () => readyCallback.call(this, this));
@@ -135,7 +127,6 @@ export default class Artplayer extends Emitter {
container: '#artplayer',
url: '',
poster: '',
title: '',
type: '',
theme: '#f00',
volume: 0.7,
@@ -172,7 +163,6 @@ export default class Artplayer extends Emitter {
quality: [],
highlight: [],
plugins: [],
whitelist: [],
thumbnails: {
url: '',
number: 60,
-53
View File
@@ -1,53 +0,0 @@
import config from './config';
import { clamp, getExt } from './utils';
export default class Mobile {
constructor(art) {
const {
option,
proxy,
template: { $video },
} = art;
for (let index = 0; index < config.events.length; index++) {
proxy($video, config.events[index], (event) => {
art.emit(`video:${event.type}`, event);
});
}
for (const key in option.moreVideoAttr) {
$video[key] = option.moreVideoAttr[key];
}
$video.controls = true;
if (option.muted) {
$video.muted = option.muted;
}
if (option.volume) {
$video.volume = clamp(option.volume, 0, 1);
}
if (option.poster) {
$video.poster = option.poster;
}
if (option.autoplay) {
$video.autoplay = option.autoplay;
}
if (option.playsInline) {
$video.playsInline = true;
$video['webkit-playsinline'] = true;
}
const typeName = option.type || getExt(option.url);
const typeCallback = option.customType[typeName];
if (typeName && typeCallback) {
typeCallback($video, option.url, art);
} else {
$video.src = option.url;
}
}
}
-2
View File
@@ -26,7 +26,6 @@ import posterMix from './posterMix';
import autoHeightMix from './autoHeightMix';
import cssVarMix from './cssVarMix';
import themeMix from './themeMix';
import titleMix from './titleMix';
import typeMix from './typeMix';
import stateMix from './stateMix';
import subtitleOffsetMix from './subtitleOffsetMix';
@@ -64,7 +63,6 @@ export default class Player {
autoHeightMix(art);
cssVarMix(art);
themeMix(art);
titleMix(art);
typeMix(art);
stateMix(art);
subtitleOffsetMix(art);
@@ -2,7 +2,6 @@ import { secondToTime, download, def, createElement } from '../utils';
export default function screenshotMix(art) {
const {
option,
notice,
template: { $video },
} = art;
@@ -44,7 +43,7 @@ export default function screenshotMix(art) {
def(art, 'screenshot', {
value: async () => {
const dataUri = await art.getDataURL();
download(dataUri, `${option.title || 'artplayer'}_${secondToTime($video.currentTime)}.png`);
download(dataUri, `artplayer_${secondToTime($video.currentTime)}.png`);
art.emit('screenshot', dataUri);
return dataUri;
},
-12
View File
@@ -1,12 +0,0 @@
import { def } from '../utils';
export default function titleMix(art) {
def(art, 'title', {
get() {
return art.option.title;
},
set(title) {
art.option.title = title;
},
});
}
-3
View File
@@ -6,7 +6,6 @@ const s = 'string';
const n = 'number';
const o = 'object';
const f = 'function';
const r = 'regexp';
function validElement(value, type, paths) {
return errorHandle(
@@ -39,7 +38,6 @@ export default {
container: validElement,
url: s,
poster: s,
title: s,
type: s,
theme: s,
lang: s,
@@ -71,7 +69,6 @@ export default {
autoOrientation: b,
airplay: b,
plugins: [f],
whitelist: [`${s}|${f}|${r}`],
layers: [ComponentOption],
contextmenu: [ComponentOption],
settings: [ComponentOption],
+3 -17
View File
@@ -3,7 +3,7 @@ import { errorHandle, query, addClass, replaceElement, isMobile } from './utils'
export default class Template {
constructor(art) {
this.art = art;
const { option, constructor, whitelist } = art;
const { option, constructor } = art;
if (option.container instanceof Element) {
this.$container = option.container;
@@ -24,11 +24,7 @@ export default class Template {
this.$container.dataset.artId = art.id;
this.$original = this.$container.cloneNode(true);
if (whitelist.state) {
this.desktop();
} else {
this.mobile();
}
this.init();
}
static get html() {
@@ -97,7 +93,7 @@ export default class Template {
return query(className, this.$container);
}
desktop() {
init() {
const { option } = this.art;
if (!option.useSSR) {
@@ -137,16 +133,6 @@ export default class Template {
}
}
mobile() {
this.$container.innerHTML = `
<div class="art-video-player">
<video class="art-video"></video>
</div>
`;
this.$player = this.query('.art-video-player');
this.$video = this.query('.art-video');
}
destroy(removeHtml) {
if (removeHtml) {
replaceElement(this.$original, this.$container);
-31
View File
@@ -1,31 +0,0 @@
import { userAgent, isMobile } from './utils';
export default class Whitelist {
constructor(art) {
this.art = art;
}
get state() {
const {
option,
constructor: { kindOf },
} = this.art;
return (
!isMobile ||
!option.whitelist.length ||
option.whitelist.some((item) => {
switch (kindOf(item)) {
case 'string':
return item === '*' || userAgent.indexOf(item) > -1;
case 'function':
return item(userAgent);
case 'regexp':
return item.test(userAgent);
default:
return false;
}
})
);
}
}