build all packages

This commit is contained in:
zhw2590582 committed 2019-04-27 15:39:29 +08:00
1 parent dd6a2dafda
commit 86dd34dc37
14 files changed
+391 -54

No files matched your search

+77
View File
@@ -1,3 +1,80 @@
# artplayer-plugin-danmu
Danmu plugin for ArtPlayer
## Demo
[Checkout the demo](https://artplayer.org/?libs=.%2Funcompiled%2Fartplayer-plugin-danmu.js&example=danmu) from Github Pages
## Install
Install with `npm`
```
$ npm install artplayer-plugin-danmu
```
Or install with `yarn`
```
$ yarn add artplayer-plugin-danmu
```
```js
import artplayerPluginBacklight from 'artplayer-plugin-danmu';
```
Or umd builds are also available
```html
<script src="artplayer-plugin-danmu.js"></script>
```
Will expose the global variable to `window.artplayerPluginDanmu`.
## Usage
```js
var art = new Artplayer({
container: '.artplayer-app',
url: 'path/to/video.mp4',
plugins: [artplayerPluginDanmu({
danmus: [], // Can be an array or return the promised function or danmuku xml url
speed: 5, // Animation time
opacity: 1, // Opacity
color: '#fff', // Font color
size: 25, // Font size
maxlength: 50, // The maximum number of words in the danmu
margin: [10, 20], // Margin top and margin bottom
})],
});
// Send danmu
art.plugins.artplayerPluginDanmu.emit({
text: '666', // Danmu text
time: 5, // Video time
color: '#fff', // Danmu color
size: 25, // Danmu size
border: '#fff' // Danmu border color
});
// Start danmu
art.plugins.artplayerPluginDanmu.start();
// Stop danmu
art.plugins.artplayerPluginDanmu.stop();
// Hide danmu
art.plugins.artplayerPluginDanmu.hide();
// Show danmu
art.plugins.artplayerPluginDanmu.show();
// Config danmu
art.plugins.artplayerPluginDanmu.config({
// option
});
```
## License
MIT © [Harvey Zack](https://sleepy.im/)
@@ -5,4 +5,4 @@
* Released under the MIT License.
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self)["artplayer-plugin-danmu"]=n()}(this,function(){"use strict";function e(e){var n=e.prototype;console.log(n)}return window.artplayerPluginDanmu=e});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self)["artplayer-plugin-danmu"]=e()}(this,function(){"use strict";var n=function(t){if(Array.isArray(t))return t};var i=function(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{i||null==s.return||s.return()}finally{if(r)throw o}}return n};var r=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")};var p=function(t,e){return n(t)||i(t,e)||r()};function e(t){if("string"!=typeof t)return[];var e=t.match(/<d([\S ]*?>[\S ]*?)<\/d>/gi);return e.length?e.map(function(t){var e=t.match(/<d p="(.+)">(.+)<\/d>/),n=p(e,3),i=n[1],r=n[2],o=i.split(",");return 8===o.length&&r.trim()?{text:r,time:Number(o[0]),mode:Number(o[1]),size:Number(o[2]),color:"#".concat(Number(o[3]).toString(16)),timestamp:Number(o[4]),pool:Number(o[5]),userID:o[6],rowID:Number(o[7])}:null}):[]}function o(t){return fetch(t).then(function(t){return t.text()}).then(function(t){return e(t)})}var a=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var s=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),i.forEach(function(t){a(e,t,n[t])})}return e};var u=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function l(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var t=function(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),t};function c(t){var e=function(t){for(var e=0,n=0,i=1;i<t.length;i+=1){var r=t[i],o=t[i-1],a=o.top+o.height,s=r.top-a;n<s&&(e=a,n=s)}return e}(t);return 0===e&&(e=function(t){for(var e={},n=0;n<t.length;n+=1){var i=t[n];e[i.top]?e[i.top].push(i):e[i.top]=[i]}for(var r=0,o=0,a=Object.keys(e),s=0;s<a.length;s+=1){for(var u=t[0].width,l=e[a[s]],h=0;h<l.length;h+=1){var c=l[h];c.right<u&&(u=c.right)}r<u&&(r=u,o=p(l,1)[0].top)}return 0===o&&(o=a[Math.floor(Math.random()*(2-a.length)+a.length-1)]),o}(t)),e}var h=function(){function h(e,t){var n=this;u(this,h),this.art=e,this.queue=[],this.layer=null,this.isStop=!1,this.animationFrameTimer=null,e.on("video:play",this.start.bind(this)),e.on("video:playing",this.start.bind(this)),e.on("video:pause",this.stop.bind(this)),e.on("video:waiting",this.stop.bind(this)),e.on("destroy",this.stop.bind(this)),this.config(t),"function"==typeof this.option.danmus?this.option.danmus().then(function(t){t.forEach(n.addToQueue.bind(n)),n.init(),e.emit("artplayerPluginDanmu:loaded",t)}):"string"==typeof this.option.danmus?o(this.option.danmus).then(function(t){t.forEach(n.addToQueue.bind(n)),n.init(),e.emit("artplayerPluginDanmu:loaded",t)}):(this.option.danmus.forEach(this.addToQueue.bind(this)),this.init())}return t(h,[{key:"config",value:function(t){var e=this.art.constructor,n=e.utils.clamp,i=e.validator;this.option=Object.assign({},h.option,t),i(this.option,h.scheme),this.option.speed=n(this.option.speed,1,10),this.option.opacity=n(this.option.opacity,0,1),this.option.size=n(this.option.size,12,30),this.option.maxlength=n(this.option.maxlength,10,100),this.option.margin[0]=n(this.option.margin[0],0,100),this.option.margin[1]=n(this.option.margin[1],0,100)}},{key:"init",value:function(){this.layer=this.art.layers.add({name:"danmu",style:{position:"absolute",left:0,top:0,right:0,bottom:0,width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none",opacity:this.option.opacity}})}},{key:"emit",value:function(t){var e=this.art.template.$player;t.$ref=this.getDanmuRef(),t.$ref.innerText=t.text,t.$ref.style.fontSize="".concat(t.size||this.option.size,"px");var n=h.getRect(e,"width"),i=h.getRect(t.$ref,"width");t.$restWidth=n+i+5,t.$restTime=this.option.speed,t.$lastStartTime=Date.now(),t.$ref.style.color=t.color||this.option.color,t.$ref.style.left="".concat(n,"px"),t.$ref.style.top="".concat(this.getDanmuTop(),"px"),t.$ref.style.transform="translateX(".concat(-t.$restWidth,"px) translateY(0px) translateZ(0px)"),t.$ref.style.transition="-webkit-transform ".concat(t.$restTime,"s linear 0s"),t.border&&(t.$ref.style.border="1px solid ".concat(t.border)),t.$state="emit"}},{key:"suspend",value:function(t){var e=this.art.template.$player,n=h.getRect(e),i=n.left,r=n.width,o=h.getRect(t.$ref).left;t.$restTime-=(Date.now()-t.$lastStartTime)/1e3;var a=r-(o-i)+5;t.$ref.style.transform="translateX(".concat(-a,"px) translateY(0px) translateZ(0px)"),t.$ref.style.transition="-webkit-transform 0s linear 0s",t.$state="stop"}},{key:"addToQueue",value:function(t){var e=this.art,n=e.notice,i=e.player;t.teLine truncated
@@ -22,17 +22,21 @@ export function bilibiliDanmuParseFromXml(xmlString) {
: [];
}
export function bilibiliDanmuParseFromUrl(url) {
return fetch(url)
.then(res => res.text())
.then(xmlString => {
return bilibiliDanmuParseFromXml(xmlString);
});
}
export function bilibiliDanmuParseFromAv(av) {
const corsUrl = 'https://cors-anywhere.herokuapp.com/';
return fetch(`${corsUrl}https://api.bilibili.com/x/web-interface/view?aid=${av}`)
.then(res => res.json())
.then(res => {
if (res.code === 0 && res.data && res.data.cid) {
return fetch(`${corsUrl}https://api.bilibili.com/x/v1/dm/list.so?oid=${res.data.cid}`)
.then(res => res.text())
.then(xmlString => {
return bilibiliDanmuParseFromXml(xmlString);
});
return bilibiliDanmuParseFromUrl(`${corsUrl}https://api.bilibili.com/x/v1/dm/list.so?oid=${res.data.cid}`);
}
throw new Error(`Unable to get data: ${JSON.stringify(res)}`);
});
+68 -9
View File
@@ -1,23 +1,31 @@
import { bilibiliDanmuParseFromUrl } from './bilibiliDanmuParse';
import getDanmuTop from './getDanmuTop';
export default class Danmuku {
constructor(art, option = {}) {
constructor(art, option) {
this.art = art;
this.queue = [];
this.layer = null;
this.isStop = false;
this.animationFrameTimer = null;
this.option = Object.assign({}, Danmuku.option, option);
art.constructor.validator(this.option, Danmuku.scheme);
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('destroy', this.stop.bind(this));
this.config(option);
if (typeof this.option.danmus === 'function') {
this.option.danmus().then(danmus => {
danmus.forEach(this.addToQueue.bind(this));
this.init();
art.emit('artplayerPluginDanmu:loaded', danmus);
});
} else if (typeof this.option.danmus === 'string') {
bilibiliDanmuParseFromUrl(this.option.danmus).then(danmus => {
danmus.forEach(this.addToQueue.bind(this));
this.init();
art.emit('artplayerPluginDanmu:loaded', danmus);
});
} else {
this.option.danmus.forEach(this.addToQueue.bind(this));
this.init();
@@ -38,7 +46,7 @@ export default class Danmuku {
static get scheme() {
return {
danmus: 'array|function',
danmus: 'array|function|string',
speed: 'number',
opacity: 'number',
color: 'string',
@@ -53,6 +61,21 @@ export default class Danmuku {
return key ? result[key] : result;
}
config(option) {
const {
utils: { clamp },
validator,
} = this.art.constructor;
this.option = Object.assign({}, Danmuku.option, option);
validator(this.option, Danmuku.scheme);
this.option.speed = clamp(this.option.speed, 1, 10);
this.option.opacity = clamp(this.option.opacity, 0, 1);
this.option.size = clamp(this.option.size, 12, 30);
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);
}
init() {
this.layer = this.art.layers.add({
name: 'danmu',
@@ -86,6 +109,9 @@ export default class Danmuku {
danmu.$ref.style.top = `${this.getDanmuTop()}px`;
danmu.$ref.style.transform = `translateX(${-danmu.$restWidth}px) translateY(0px) translateZ(0px)`;
danmu.$ref.style.transition = `-webkit-transform ${danmu.$restTime}s linear 0s`;
if (danmu.border) {
danmu.$ref.style.border = `1px solid ${danmu.border}`;
}
danmu.$state = 'emit';
}
@@ -174,17 +200,50 @@ export default class Danmuku {
getDanmuTop() {
const { $player } = this.art.template;
const playerHeight = Danmuku.getRect($player, 'height');
const { left: playerLeft, top: playerTop, height: playerHeight, width: playerWidth } = Danmuku.getRect($player);
const danmus = this.queue.filter(danmu => danmu.$state === 'emit');
if (danmus.length === 0) {
return this.option.margin[0];
}
if (danmus.length === 1) {
return this.option.margin[0] + Danmuku.getRect(danmus[0].$ref, 'height');
}
const danmusBySort = danmus
.map(danmu => {
const { left: danmuLeft, top: danmuTop, width: danmuWidth, height: danmuHeight } = Danmuku.getRect(
danmu.$ref,
);
const top = danmuTop - playerTop;
const left = danmuLeft - playerLeft;
const right = playerWidth - left - danmuWidth;
return {
top,
left,
right,
height: danmuHeight,
width: danmuWidth,
};
})
.sort((prev, next) => {
return prev.top - next.top;
});
return 0;
danmusBySort.unshift({
top: 0,
left: 0,
right: 0,
height: this.option.margin[0],
width: playerWidth,
});
danmusBySort.push({
top: playerHeight - this.option.margin[1],
left: 0,
right: 0,
height: this.option.margin[1],
width: playerWidth,
});
return getDanmuTop(danmusBySort);
}
update() {
@@ -0,0 +1,62 @@
function getDanmuTopByDiff(danmus) {
let top = 0;
let maxDiff = 0;
for (let index = 1; index < danmus.length; index += 1) {
const item = danmus[index];
const prev = danmus[index - 1];
const prevTop = prev.top + prev.height;
const diff = item.top - prevTop;
if (diff > maxDiff) {
top = prevTop;
maxDiff = diff;
}
}
return top;
}
function getDanmuTopBySparse(danmus) {
const topMap = {};
for (let index = 0; index < danmus.length; index += 1) {
const item = danmus[index];
if (topMap[item.top]) {
topMap[item.top].push(item);
} else {
topMap[item.top] = [item];
}
}
let maxRight = 0;
let top = 0;
const topMapKeys = Object.keys(topMap);
for (let index = 0; index < topMapKeys.length; index += 1) {
let minRight = danmus[0].width;
const topKey = topMapKeys[index];
const danmuArr = topMap[topKey];
for (let index = 0; index < danmuArr.length; index += 1) {
const danmu = danmuArr[index];
if (danmu.right < minRight) {
minRight = danmu.right;
}
}
if (minRight > maxRight) {
maxRight = minRight;
[{ top }] = danmuArr;
}
}
if (top === 0) {
const randomKey = Math.floor(Math.random() * (2 - topMapKeys.length) + topMapKeys.length - 1);
top = topMapKeys[randomKey];
}
return top;
}
export default function getDanmuTop(danmus) {
let top = getDanmuTopByDiff(danmus);
if (top === 0) {
top = getDanmuTopBySparse(danmus);
}
return top;
}
+3 -1
View File
@@ -1,4 +1,4 @@
import { bilibiliDanmuParseFromXml, bilibiliDanmuParseFromAv } from './bilibiliDanmuParse';
import { bilibiliDanmuParseFromXml, bilibiliDanmuParseFromAv, bilibiliDanmuParseFromUrl } from './bilibiliDanmuParse';
import Danmuku from './danmuku';
function artplayerPluginDanmu(option) {
@@ -7,6 +7,7 @@ function artplayerPluginDanmu(option) {
return {
name: 'artplayerPluginDanmu',
emit: danmuku.addToQueue.bind(danmuku),
config: danmuku.config.bind(danmuku),
start: danmuku.start.bind(danmuku),
stop: danmuku.stop.bind(danmuku),
hide: danmuku.hide.bind(danmuku),
@@ -17,5 +18,6 @@ function artplayerPluginDanmu(option) {
artplayerPluginDanmu.bilibiliDanmuParseFromXml = bilibiliDanmuParseFromXml;
artplayerPluginDanmu.bilibiliDanmuParseFromAv = bilibiliDanmuParseFromAv;
artplayerPluginDanmu.bilibiliDanmuParseFromUrl = bilibiliDanmuParseFromUrl;
window.artplayerPluginDanmu = artplayerPluginDanmu;
export default artplayerPluginDanmu;
+1 -1
View File
@@ -5,4 +5,4 @@
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).artplayer=e()}(this,function(){"use strict";var a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t},r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=e(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=i=function(t){return n(t)}:e.exports=i=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},i(t)}e.exports=i});var s=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var c=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?s(t):e},l=e(function(e){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}e.exports=n}),u=e(function(n){function i(t,e){return n.exports=i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(t,e)}n.exports=i});var d=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)};function f(){}f.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this;function o(){i.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;i<o;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,a=i.length;r<a;r++)i[r].fn!==e&&i[r].fn._!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}};var p=f,h=f;p.TinyEmitter=h;var v=e(function(t,e){t.exports=function(){function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var c=Object.prototype.toString,a=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e,n,i,o,r,a=s(t);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===l(t)?"generatorfunction":"function";if(e=t,Array.isArray?Array.isArray(e):e instanceof Array)return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if((n=t)instanceof Date||"function"==typeof n.toDateString&&"function"==typeof n.getDate&&"function"==typeof n.setDate)return"date";if((i=t)instanceof Error||"string"==typeof i.message&&i.constructor&&"number"==typeof i.constructor.stackTraceLimit)return"error";if((o=t)instanceof RegExp||"string"==typeof o.flags&&"boolean"==typeof o.ignoreCase&&"boolean"==typeof o.multiline&&"boolean"==typeof o.global)return"regexp";switch(l(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if("function"==typeof(r=t).throw&&"function"==typeof r.return&&"function"==typeof r.next)return"generator";switch(a=c.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};functLine truncated
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).artplayer=e()}(this,function(){"use strict";var a=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")};function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var o=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t},r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t,e){return t(e={exports:{}},e.exports),e.exports}var n=e(function(e){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?e.exports=i=function(t){return n(t)}:e.exports=i=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},i(t)}e.exports=i});var s=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t};var c=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?s(t):e},l=e(function(e){function n(t){return e.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(t)}e.exports=n}),u=e(function(n){function i(t,e){return n.exports=i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(t,e)}n.exports=i});var d=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)};function f(){}f.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this;function o(){i.off(t,o),e.apply(n,arguments)}return o._=e,this.on(t,o,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;i<o;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,a=i.length;r<a;r++)i[r].fn!==e&&i[r].fn._!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}};var p=f,h=f;p.TinyEmitter=h;var v=e(function(t,e){t.exports=function(){function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var c=Object.prototype.toString,a=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e,n,i,o,r,a=s(t);if("boolean"===a)return"boolean";if("string"===a)return"string";if("number"===a)return"number";if("symbol"===a)return"symbol";if("function"===a)return"GeneratorFunction"===l(t)?"generatorfunction":"function";if(e=t,Array.isArray?Array.isArray(e):e instanceof Array)return"array";if(function(t){return!(!t.constructor||"function"!=typeof t.constructor.isBuffer)&&t.constructor.isBuffer(t)}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if((n=t)instanceof Date||"function"==typeof n.toDateString&&"function"==typeof n.getDate&&"function"==typeof n.setDate)return"date";if((i=t)instanceof Error||"string"==typeof i.message&&i.constructor&&"number"==typeof i.constructor.stackTraceLimit)return"error";if((o=t)instanceof RegExp||"string"==typeof o.flags&&"boolean"==typeof o.ignoreCase&&"boolean"==typeof o.multiline&&"boolean"==typeof o.global)return"regexp";switch(l(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if("function"==typeof(r=t).throw&&"function"==typeof r.return&&"function"==typeof r.next)return"generator";switch(a=c.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return a.slice(8,-1).toLowerCase().replace(/\s/g,"")};functLine truncated