diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..55bcfb54f --- /dev/null +++ b/.eslintrc @@ -0,0 +1,216 @@ +{ + "root": true, + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true, + "globalReturn": true, + "impliedStrict": true + } + }, + "env": { + "es6": true, + "amd": true, + "node": true, + "mocha": true, + "worker": true, + "jquery": true, + "browser": true, + "commonjs": true, + "serviceworker": true, + "shared-node-browser": true + }, + "rules": { + "no-await-in-loop": 2, + "no-compare-neg-zero": 2, + "no-cond-assign": 2, + "no-console": 0, + "no-constant-condition": [2, { "checkLoops": false }], + "no-debugger": 2, + "no-dupe-args": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-empty": 1, + "no-empty-character-class": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": 2, + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-obj-calls": 2, + "no-regex-spaces": 1, + "no-sparse-arrays": 2, + "no-template-curly-in-string": 2, + "no-unexpected-multiline": 2, + "no-unreachable": 2, + "no-unsafe-finally": 2, + "no-unsafe-negation": 2, + "use-isnan": 2, + "valid-jsdoc": [2, { "requireReturn": false }], + "valid-typeof": 2, + + "accessor-pairs": 1, + "array-callback-return": 1, + "block-scoped-var": 1, + "class-methods-use-this": 0, + "curly": 1, + "default-case": 1, + "dot-location": [1, "property"], + "eqeqeq": [1, "smart"], + "guard-for-in": 1, + "no-alert": 2, + "no-caller": 1, + "no-div-regex": 1, + "no-else-return": 1, + "no-empty-function": 1, + "no-empty-pattern": 1, + "no-eq-null": 1, + "no-eval": 0, + "no-extend-native": 2, + "no-extra-bind": 1, + "no-extra-label": 1, + "no-fallthrough": 1, + "no-floating-decimal": 1, + "no-global-assign": 2, + "no-implicit-coercion": 1, + "no-implied-eval": 2, + "no-invalid-this": 1, + "no-iterator": 2, + "no-labels": 1, + "no-lone-blocks": 1, + "no-loop-func": 2, + "no-multi-spaces": 1, + "no-multi-str": 1, + "no-new-func": 0, + "no-new-wrappers": 1, + "no-octal": 1, + "no-octal-escape": 1, + "no-param-reassign": 1, + "no-proto": 1, + "no-redeclare": 1, + "no-return-assign": 1, + "no-return-await": 1, + "no-script-url": 2, + "no-self-assign": 1, + "no-self-compare": 1, + "no-sequences": 1, + "no-throw-literal": 1, + "no-unmodified-loop-condition": 1, + "no-unused-expressions": 0, + "no-unused-labels": 1, + "no-useless-call": 1, + "no-useless-concat": 1, + "no-useless-escape": 1, + "no-useless-return": 1, + "no-void": 1, + "no-with": 2, + "prefer-promise-reject-errors": 1, + "require-await": 2, + "vars-on-top": 1, + "wrap-iife": [1, "any"], + "yoda": 2, + + "strict": 2, + + "no-catch-shadow": 2, + "no-delete-var": 2, + "no-label-var": 2, + "no-shadow": 2, + "no-shadow-restricted-names": 2, + "no-undef": 2, + "no-undef-init": 2, + "no-undefined": 0, + "no-unused-vars": 2, + "no-use-before-define": 2, + + "callback-return": 2, + "global-require": 1, + "handle-callback-err": 1, + "no-mixed-requires": [1, { "allowCall": true }], + "no-new-require": 2, + "no-path-concat": 2, + "no-process-env": 2, + "no-process-exit": 2, + + "array-bracket-spacing": 1, + "block-spacing": 1, + "brace-style": 1, + "camelcase": 1, + "capitalized-comments": 0, + "comma-dangle": 1, + "comma-spacing": 1, + "comma-style": 1, + "computed-property-spacing": 1, + "consistent-this": [1, "that", "self"], + "eol-last": 1, + "func-call-spacing": 1, + "func-names": 1, + "indent": [1, 2, { "SwitchCase": 1 }], + "key-spacing": 1, + "keyword-spacing": 1, + "linebreak-style": 1, + "lines-around-comment": 1, + "new-cap": 0, + "new-parens": 1, + "no-array-constructor": 1, + "no-continue": 1, + "no-inline-comments": 1, + "no-mixed-spaces-and-tabs": 2, + "no-multi-assign": 1, + "no-multiple-empty-lines": 1, + "no-negated-condition": 0, + "no-nested-ternary": 2, + "no-new-object": 1, + "no-tabs": 2, + "no-trailing-spaces": 1, + "no-unneeded-ternary": 1, + "no-whitespace-before-property": 1, + "object-curly-spacing": 0, + "object-property-newline": [1, { "allowMultiplePropertiesPerLine": true }], + "one-var": [1, "never"], + "operator-assignment": 1, + "operator-linebreak": 1, + "padded-blocks": 0, + "quotes": [1, "single"], + "require-jsdoc": 2, + "semi": 1, + "semi-spacing": 1, + "space-before-blocks": 1, + "space-before-function-paren": [1, "never"], + "space-in-parens": 1, + "space-infix-ops": 1, + "space-unary-ops": [1, { "words": true, "nonwords": false }], + "spaced-comment": [1, "always"], + "wrap-regex": 1, + + "arrow-body-style": 1, + "arrow-parens": 0, + "arrow-spacing": 1, + "constructor-super": 2, + "generator-star-spacing": 1, + "no-class-assign": 2, + "no-confusing-arrow": 2, + "no-const-assign": 2, + "no-dupe-class-members": 2, + "no-duplicate-imports": 2, + "no-new-symbol": 1, + "no-this-before-super": 2, + "no-useless-computed-key": 1, + "no-useless-constructor": 1, + "no-useless-rename": 1, + "no-var": 1, + "prefer-const": 1, + "prefer-destructuring": 1, + "prefer-spread": 1, + "prefer-template": 1, + "require-yield": 2, + "rest-spread-spacing": 1, + "symbol-description": 2, + "template-curly-spacing": 1, + "yield-star-spacing": 1 + } +} diff --git a/docs/js/artplayer.js b/docs/js/artplayer.js index a1874a266..23a7487a0 100644 --- a/docs/js/artplayer.js +++ b/docs/js/artplayer.js @@ -1,10 +1,247 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/inherits')) : + typeof define === 'function' && define.amd ? define(['exports', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/inherits'], factory) : + (factory((global.artplayer = {}),global._classCallCheck,global._createClass,global._possibleConstructorReturn,global._getPrototypeOf,global._inherits)); +}(this, (function (exports,_classCallCheck,_createClass,_possibleConstructorReturn,_getPrototypeOf,_inherits) { 'use strict'; - console.log("test"); + _classCallCheck = _classCallCheck && _classCallCheck.hasOwnProperty('default') ? _classCallCheck['default'] : _classCallCheck; + _createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass; + _possibleConstructorReturn = _possibleConstructorReturn && _possibleConstructorReturn.hasOwnProperty('default') ? _possibleConstructorReturn['default'] : _possibleConstructorReturn; + _getPrototypeOf = _getPrototypeOf && _getPrototypeOf.hasOwnProperty('default') ? _getPrototypeOf['default'] : _getPrototypeOf; + _inherits = _inherits && _inherits.hasOwnProperty('default') ? _inherits['default'] : _inherits; + + 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; 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; + } + }; + + var tinyEmitter = E; + + function verification(option) {// + } + + var ZHCN = {}; + + var ZHTW = {}; + + var EN = {}; + + var JP = {}; + + var i18nMap = { + "zh": ZHCN, + "zh-CN": ZHCN, + "zh-TW": ZHTW, + "en": EN, + "jp": JP + }; + + var I18n = + /*#__PURE__*/ + function () { + function I18n(_ref) { + var option = _ref.option; + + _classCallCheck(this, I18n); + + this.language = i18nMap[option.language] || i18nMap.en; + } + + _createClass(I18n, [{ + key: "get", + value: function get(key) { + return this.language[key] || key; + } + }]); + + return I18n; + }(); + + var Player = function Player(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Player); + }; + + var Controls = function Controls(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Controls); + }; + + var Contextmenu = function Contextmenu(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Contextmenu); + }; + + var Danmu = function Danmu(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Danmu); + }; + + var Info = function Info(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Info); + }; + + var Captions = function Captions(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Captions); + }; + + var Events = function Events(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Events); + }; + + var Hotkey = function Hotkey(_ref) {// + + var option = _ref.option; + + _classCallCheck(this, Hotkey); + }; + + var id = 0; + var instances = []; + + var Artplayer = + /*#__PURE__*/ + function (_Emitter) { + _inherits(Artplayer, _Emitter); + + function Artplayer(option) { + var _this; + + _classCallCheck(this, Artplayer); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(Artplayer).call(this)); + _this.option = Object.assign({}, Artplayer.DEFAULTS, option); + verification(_this.option); + + _this.init(); + + return _this; + } + + _createClass(Artplayer, [{ + key: "init", + value: function init() { + this.refs = {}; + this.destroyEvents = []; + this.i18n = new I18n(this); + this.player = new Player(this); + this.controls = new Controls(this); + this.contextmenu = new Contextmenu(this); + this.danmu = new Danmu(this); + this.captions = new Captions(this); + this.info = new Info(this); + this.events = new Events(this); + this.hotkey = new Hotkey(this); + this.id = id++; + instances.push(this); + console.log(this); + } + }, { + key: "destroy", + value: function destroy() { + this.destroyEvents.forEach(function (event) { + return event.destroy(); + }); + this.refs.container.innerHTML = ""; + } + }], [{ + key: "version", + get: function get() { + return "1.0.0"; + } + }, { + key: "DEFAULTS", + get: function get() { + return {// + }; + } + }]); + + return Artplayer; + }(tinyEmitter); + + window.Artplayer = Artplayer; + + exports.instances = instances; + exports.default = Artplayer; + + Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=artplayer.js.map diff --git a/docs/js/artplayer.js.map b/docs/js/artplayer.js.map index e44626294..bff171a0c 100644 --- a/docs/js/artplayer.js.map +++ b/docs/js/artplayer.js.map @@ -1 +1 @@ -{"version":3,"file":"artplayer.js","sources":["../../src/index.js"],"sourcesContent":["import \"./style/index.scss\";\n\nconsole.log(\"test\");"],"names":["console","log"],"mappings":";;;;;;IAEAA,OAAO,CAACC,GAAR,CAAY,MAAZ;;;;"} \ No newline at end of file +{"version":3,"file":"artplayer.js","sources":["../../node_modules/tiny-emitter/index.js","../../src/utils/verification.js","../../src/i18n/zh-CN.js","../../src/i18n/zh-TW.js","../../src/i18n/en.js","../../src/i18n/jp.js","../../src/i18n/index.js","../../src/player.js","../../src/controls/index.js","../../src/contextmenu.js","../../src/danmu.js","../../src/info.js","../../src/captions.js","../../src/events.js","../../src/hotkey.js","../../src/index.js"],"sourcesContent":["function E () {\n // Keep this empty so it's easier to inherit from\n // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)\n}\n\nE.prototype = {\n on: function (name, callback, ctx) {\n var e = this.e || (this.e = {});\n\n (e[name] || (e[name] = [])).push({\n fn: callback,\n ctx: ctx\n });\n\n return this;\n },\n\n once: function (name, callback, ctx) {\n var self = this;\n function listener () {\n self.off(name, listener);\n callback.apply(ctx, arguments);\n };\n\n listener._ = callback\n return this.on(name, listener, ctx);\n },\n\n emit: function (name) {\n var data = [].slice.call(arguments, 1);\n var evtArr = ((this.e || (this.e = {}))[name] || []).slice();\n var i = 0;\n var len = evtArr.length;\n\n for (i; i < len; i++) {\n evtArr[i].fn.apply(evtArr[i].ctx, data);\n }\n\n return this;\n },\n\n off: function (name, callback) {\n var e = this.e || (this.e = {});\n var evts = e[name];\n var liveEvents = [];\n\n if (evts && callback) {\n for (var i = 0, len = evts.length; i < len; i++) {\n if (evts[i].fn !== callback && evts[i].fn._ !== callback)\n liveEvents.push(evts[i]);\n }\n }\n\n // Remove event from queue to prevent memory leak\n // Suggested by https://github.com/lazd\n // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910\n\n (liveEvents.length)\n ? e[name] = liveEvents\n : delete e[name];\n\n return this;\n }\n};\n\nmodule.exports = E;\n","export function verification (option) {\n //\n}","export default {\n \n}","export default {\n \n}","export default {\n \n}","export default {\n \n}","import ZHCN from \"./zh-CN\";\nimport ZHTW from \"./zh-TW\";\nimport EN from \"./en\";\nimport JP from \"./jp\";\n\nconst i18nMap = {\n \"zh\": ZHCN,\n \"zh-CN\": ZHCN,\n \"zh-TW\": ZHTW,\n \"en\": EN,\n \"jp\": JP\n};\n\nexport default class I18n {\n constructor({ option }) {\n this.language = i18nMap[option.language] || i18nMap.en;\n }\n\n get(key) {\n return this.language[key] || key;\n }\n}\n","export default class Player {\n constructor({ option }) {\n //\n }\n}\n","export default class Controls {\n constructor({ option }) {\n //\n }\n}\n","export default class Contextmenu {\n constructor({ option }) {\n //\n }\n}\n","export default class Danmu {\n constructor({ option }) {\n //\n }\n}\n","export default class Info {\n constructor({ option }) {\n //\n }\n}\n","export default class Captions {\n constructor({ option }) {\n //\n }\n}\n","export default class Events {\n constructor({ option }) {\n //\n }\n}\n","export default class Hotkey {\n constructor({ option }) {\n //\n }\n}\n","import \"./style/index.scss\";\nimport Emitter from 'tiny-emitter';\nimport { verification } from \"./utils\";\nimport I18n from \"./i18n\";\nimport Player from \"./player\";\nimport Controls from \"./controls\";\nimport Contextmenu from \"./contextmenu\";\nimport Danmu from \"./danmu\";\nimport Info from \"./info\";\nimport Captions from \"./captions\";\nimport Events from \"./events\";\nimport Hotkey from \"./hotkey\";\n\nlet id = 0;\nexport const instances = [];\n\nclass Artplayer extends Emitter {\n constructor(option) {\n super();\n this.option = Object.assign({}, Artplayer.DEFAULTS, option);\n verification(this.option);\n this.init();\n }\n\n static get version() {\n return \"__VERSION__\";\n }\n\n static get DEFAULTS() {\n return {\n //\n };\n }\n\n init() {\n this.refs = {};\n this.destroyEvents = [];\n\n this.i18n = new I18n(this);\n this.player = new Player(this);\n this.controls = new Controls(this);\n this.contextmenu = new Contextmenu(this);\n this.danmu = new Danmu(this);\n this.captions = new Captions(this);\n this.info = new Info(this);\n this.events = new Events(this);\n this.hotkey = new Hotkey(this);\n\n this.id = id++;\n instances.push(this);\n\n console.log(this);\n }\n\n destroy() {\n this.destroyEvents.forEach(event => event.destroy());\n this.refs.container.innerHTML = \"\";\n }\n}\n\nwindow.Artplayer = Artplayer;\nexport default Artplayer;\n"],"names":["verification","option","i18nMap","ZHCN","ZHTW","EN","JP","I18n","language","en","key","Player","Controls","Contextmenu","Danmu","Info","Captions","Events","Hotkey","id","instances","Artplayer","Object","assign","DEFAULTS","init","refs","destroyEvents","i18n","player","controls","contextmenu","danmu","captions","info","events","hotkey","push","console","log","forEach","event","destroy","container","innerHTML","Emitter","window"],"mappings":";;;;;;;;;;;;IAAA,SAAS,CAAC,IAAI;;;KAGb;;IAED,CAAC,CAAC,SAAS,GAAG;MACZ,EAAE,EAAE,UAAU,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE;QACjC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;;QAEhC,CAAC,CAAC,CAAC,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AAb;IACA,WAAKmB,QAAL,GAAgB,IAAIjB,QAAJ,CAAa,IAAb,CAAhB;IACA,WAAKkB,IAAL,GAAY,IAAInB,IAAJ,CAAS,IAAT,CAAZ;IACA,WAAKoB,MAAL,GAAc,IAAIlB,MAAJ,CAAW,IAAX,CAAd;IACA,WAAKmB,MAAL,GAAc,IAAIlB,MAAJ,CAAW,IAAX,CAAd;IAEA,WAAKC,EAAL,GAAUA,EAAE,EAAZ;IACAC,MAAAA,SAAS,CAACiB,IAAV,CAAe,IAAf;IAEAC,MAAAA,OAAO,CAACC,GAAR,CAAY,IAAZ;IACD;;;kCAES;IACR,WAAKZ,aAAL,CAAmBa,OAAnB,CAA2B,UAAAC,KAAK;IAAA,eAAIA,KAAK,CAACC,OAAN,EAAJ;IAAA,OAAhC;IACA,WAAKhB,IAAL,CAAUiB,SAAV,CAAoBC,SAApB,GAAgC,EAAhC;IACD;;;4BAjCoB;IACnB,aAAO,OAAP;IACD;;;4BAEqB;IACpB,aAAO;IAAA,OAAP;IAGD;;;;MAhBqBC;;IA4CxBC,MAAM,CAACzB,SAAP,GAAmBA,SAAnB;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/src/captions.js b/src/captions.js index e69de29bb..ddbeee624 100644 --- a/src/captions.js +++ b/src/captions.js @@ -0,0 +1,5 @@ +export default class Captions { + constructor({ option }) { + // + } +} diff --git a/src/contextmenu.js b/src/contextmenu.js index e69de29bb..4cce46451 100644 --- a/src/contextmenu.js +++ b/src/contextmenu.js @@ -0,0 +1,5 @@ +export default class Contextmenu { + constructor({ option }) { + // + } +} diff --git a/src/controls/index.js b/src/controls/index.js index e69de29bb..1b1bc1135 100644 --- a/src/controls/index.js +++ b/src/controls/index.js @@ -0,0 +1,5 @@ +export default class Controls { + constructor({ option }) { + // + } +} diff --git a/src/screenshot.js b/src/controls/screenshot.js similarity index 100% rename from src/screenshot.js rename to src/controls/screenshot.js diff --git a/src/danmu.js b/src/danmu.js index e69de29bb..3e84e0ae0 100644 --- a/src/danmu.js +++ b/src/danmu.js @@ -0,0 +1,5 @@ +export default class Danmu { + constructor({ option }) { + // + } +} diff --git a/src/events.js b/src/events.js index e69de29bb..095109ba8 100644 --- a/src/events.js +++ b/src/events.js @@ -0,0 +1,5 @@ +export default class Events { + constructor({ option }) { + // + } +} diff --git a/src/hotkey.js b/src/hotkey.js index e69de29bb..6cd2b5577 100644 --- a/src/hotkey.js +++ b/src/hotkey.js @@ -0,0 +1,5 @@ +export default class Hotkey { + constructor({ option }) { + // + } +} diff --git a/src/i18n/index.js b/src/i18n/index.js index 432c9351a..ff206b754 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -1,19 +1,19 @@ -import ZHCN from "./zh-CN"; -import ZHTW from "./zh-TW"; -import EN from "./en"; -import JP from "./jp"; +import ZHCN from './zh-CN'; +import ZHTW from './zh-TW'; +import EN from './en'; +import JP from './jp'; const i18nMap = { - "zh": ZHCN, - "zh-CN": ZHCN, - "zh-TW": ZHTW, - "en": EN, - "jp": JP + zh: ZHCN, + 'zh-CN': ZHCN, + 'zh-TW': ZHTW, + en: EN, + jp: JP }; export default class I18n { constructor({ option }) { - this.language = i18nMap[option.language || "en"]; + this.language = i18nMap[option.language] || i18nMap.en; } get(key) { diff --git a/src/index.js b/src/index.js index 91a9e982f..ffcc76ad0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,16 +1,15 @@ -import "./style/index.scss"; +import './style/index.scss'; import Emitter from 'tiny-emitter'; -import { verification } from "./utils"; -import I18n from "./i18n"; -import Player from "./player"; -import Controls from "./controls"; -import Screenshot from "./screenshot"; -import Contextmenu from "./contextmenu"; -import Danmu from "./danmu"; -import Info from "./info"; -import Captions from "./captions"; -import Events from "./events"; -import Hotkey from "./hotkey"; +import { verification } from './utils'; +import I18n from './i18n'; +import Player from './player'; +import Controls from './controls'; +import Contextmenu from './contextmenu'; +import Danmu from './danmu'; +import Info from './info'; +import Captions from './captions'; +import Events from './events'; +import Hotkey from './hotkey'; let id = 0; export const instances = []; @@ -24,7 +23,7 @@ class Artplayer extends Emitter { } static get version() { - return "__VERSION__"; + return '__VERSION__'; } static get DEFAULTS() { @@ -40,7 +39,6 @@ class Artplayer extends Emitter { this.i18n = new I18n(this); this.player = new Player(this); this.controls = new Controls(this); - this.screenshot = new Screenshot(this); this.contextmenu = new Contextmenu(this); this.danmu = new Danmu(this); this.captions = new Captions(this); @@ -50,11 +48,13 @@ class Artplayer extends Emitter { this.id = id++; instances.push(this); + + console.log(this); } destroy() { this.destroyEvents.forEach(event => event.destroy()); - this.refs.container.innerHTML = ""; + this.refs.container.innerHTML = ''; } } diff --git a/src/info.js b/src/info.js index e69de29bb..222502375 100644 --- a/src/info.js +++ b/src/info.js @@ -0,0 +1,5 @@ +export default class Info { + constructor({ option }) { + // + } +} diff --git a/src/player.js b/src/player.js new file mode 100644 index 000000000..b844d5603 --- /dev/null +++ b/src/player.js @@ -0,0 +1,5 @@ +export default class Player { + constructor({ option }) { + // + } +} diff --git a/src/utils/index.js b/src/utils/index.js index e69de29bb..8c89bd913 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -0,0 +1 @@ +export * from './verification'; diff --git a/src/utils/verification.js b/src/utils/verification.js index e69de29bb..d19ff9004 100644 --- a/src/utils/verification.js +++ b/src/utils/verification.js @@ -0,0 +1,3 @@ +export function verification(option) { + // +} diff --git a/src/video.js b/src/video.js deleted file mode 100644 index e69de29bb..000000000