diff --git a/.travis.yml b/.travis.yml index c7369da..ac6674b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: node_js -sudo: required dist: trusty addons: - chrome: stable + apt: + packages: + - libnss3 node_js: - "12.2.0" before_install: diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 26dac39..8ec7462 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -15,102 +15,26 @@ module.exports = (grunt) -> 'src/css/fontalias.css' ] - SRC_CORE = [ - 'src/Array.js' - 'src/CommentManager.js' - 'compiled_src/core/Comment.js' - 'compiled_src/core/CommentFactory.js' - 'compiled_src/core/CommentSpaceAllocator.js' - 'compiled_src/core/CommentUtils.js' - 'compiled_src/core/css-renderer/CssComment.js' - ] - - SRC_MODULES = - 'filter': ['src/filter/CommentFilter.js'] - 'provider': ['src/CommentProvider.js', 'src/Promises.js'] - 'format-bilibili': ['src/parsers/BilibiliFormat.js'] - 'format-acfun': ['src/parsers/AcfunFormat.js'] - 'format-common': ['src/parsers/CommonDanmakuFormat.js'] - - # Typescript targets - SRC_TS_CORE = [ - 'src/core/Comment.ts' - 'src/core/CommentFactory.ts' - 'src/core/CommentSpaceAllocator.ts' - 'src/core/CommentUtils.ts' - 'src/core/css-renderer/CssComment.ts' - ] - - SRC_TS_SCRIPTING_KAGEROU = - 'Display': ['src/scripting/api/Display/Display.ts'] - 'Runtime': ['src/scripting/api/Runtime/Runtime.ts'] - 'Player': ['src/scripting/api/Player/Player.ts'] - 'Utils': ['src/scripting/api/Utils/Utils.ts'] - 'Tween': ['src/scripting/api/Tween/Tween.ts'] - # ==== Below this point is logic to generate compile configurations ==== # You probably do not need to edit anything below here - - # Dynamically generate the target for all - CMP_ALL = [] - CMP_ALL = CMP_ALL.concat SRC_CORE - for name, source of SRC_MODULES - CMP_ALL = CMP_ALL.concat source - - # Generate the core ts targets - CMP_CORE_TS = - 'core': - src: SRC_TS_CORE - outDir: 'compiled_src/' - CMP_CORE_NAME = ['ts:core'] - - # Dynamically generate the kagerou ts targets - CMP_KAGEROU_TS = {} - CMP_KAGEROU_NAME = [] - for target, src of SRC_TS_SCRIPTING_KAGEROU - CMP_KAGEROU_NAME.push ('ts:kagerou_engine_' + target.toLowerCase()) - CMP_KAGEROU_TS['kagerou_engine_' + target.toLowerCase()] = - src: src - out: 'dist/scripting/api/' + target + '.js' - - # Append Typescript Tasks - ts_config = - options: - target: 'es5' - sourceMap: false - rootDir: 'src/' - for key,value of CMP_CORE_TS - ts_config[key] = value - for key,value of CMP_KAGEROU_TS - ts_config[key] = value - grunt.loadNpmTasks 'grunt-contrib-coffee' - grunt.loadNpmTasks 'grunt-contrib-jasmine' grunt.initConfig( clean: - scripting: ['dist/scripting'] - dist: ['dist'] - - # Concat CSS and JS files - # dist_core : builds CCL with just the comment system - # dist_all : builds CCL with everything - # scripting_host : builds just the scripting host - concat: - dist_core: - files: - 'dist/css/style.css': CSS - 'dist/CommentCoreLibrary.js': SRC_CORE - dist_all: - files: - 'dist/css/style.css': CSS - 'dist/CommentCoreLibrary.js': CMP_ALL - scripting_host: - files: - 'dist/scripting/Host.js': ['src/scripting/Host.js','src/scripting/Unpacker.js'] + temp: [ + 'compiled_spec/', + 'compiled_src/' + ] + dist: [ + 'dist' + ] # Compile TypeScript - ts: ts_config + ts: { + default: { + tsconfig: './tsconfig.json' + } + } # Copy copy: @@ -170,42 +94,6 @@ module.exports = (grunt) -> all: src: ['src/*.js'] - # Jasmine test - jasmine: - coverage: - src: ['src/**/*.js', 'compiled_src/**/*.js'] - options: - specs: ['compiled_spec/*_spec.js'] - helpers: ['compiled_spec/*_helper.js'] - vendor: [ - 'node_modules/jquery/dist/jquery.js' - 'node_modules/sinon/pkg/sinon.js' - 'node_modules/jasmine-sinon/lib/jasmine-sinon.js' - ] - # Don't use this, it doesnt work anymore - #template: require('grunt-template-jasmine-istanbul') - #templateOptions: - # report: 'coverage' - # coverage: 'coverage/coverage.json' - ci: - src: ['dist/CommentCoreLibrary.js'] - options: - specs: ['compiled_spec/*_spec.js'] - helpers: ['compiled_spec/*_helper.js'] - vendor: [ - 'node_modules/jquery/dist/jquery.js' - 'node_modules/sinon/pkg/sinon.js' - 'node_modules/jasmine-sinon/lib/jasmine-sinon.js' - ] - # Don't use this, it doesnt work anymore - #template: require('grunt-template-jasmine-istanbul') - #templateOptions: - # report: - # type: 'lcovonly' - # options: - # dir: 'coverage' - # coverage: 'coverage/coverage.json' - coffee: glob_to_multiple: expand: true, @@ -215,16 +103,11 @@ module.exports = (grunt) -> ext: '.js' ) - # Register special compiles - grunt.registerTask 'compile:ts-core', CMP_CORE_NAME - grunt.registerTask 'compile:ts-kagerou', CMP_KAGEROU_NAME # Register our tasks - grunt.registerTask 'build', ['compile:ts-core', 'concat:dist_all', 'autoprefixer', 'cssmin', 'uglify:all'] - grunt.registerTask 'build:core', ['compile:ts-core', 'concat:dist_core', 'autoprefixer', 'cssmin', 'uglify:core'] - grunt.registerTask 'build:scripting', ['clean:scripting','concat:scripting_host', 'compile:ts-kagerou', 'copy:scripting_sandbox'] + grunt.registerTask 'build', ['clean', 'ts'] - grunt.registerTask 'ci', ['build', 'coffee', 'jasmine:ci'] - grunt.registerTask 'test', ['coffee', 'jasmine:coverage'] + grunt.registerTask 'test', ['build'] # And do tests + grunt.registerTask 'ci', ['build'] # Do CI stuff - grunt.registerTask 'default', ['clean', 'build', 'build:scripting'] + grunt.registerTask 'default', ['build', 'watch'] diff --git a/LICENSE b/LICENSE index 4486bca..babd810 100644 --- a/LICENSE +++ b/LICENSE @@ -1,16 +1,16 @@ -Copyright (c) 2017 Jim Chen +Copyright (c) 2019 Jim Chen -Permission is hereby granted, free of charge, to any person obtaining a copy of this software -and associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, -sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT -NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT +NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 0d0a04d..f23e66f 100644 --- a/README.md +++ b/README.md @@ -16,24 +16,22 @@ Developers willing to incorporate similar comment streaming functionalities inside their own projects (whether web based or not) are encouraged to learn from and extend from the CommentCoreLibrary. -## Testing +## Demo We have a live demo [here](http://jabbany.github.io/CommentCoreLibrary/demo). Feel free to [open tickets](CONTRIBUTING.md) if this demo test has bugs. ## License -The CommentCoreLibrary is licensed under the permissive MIT License. If you wish -to use this in any project, you can simply include the following line: - - CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT license +CommentCoreLibrary is licensed under the permissive [MIT License](LICENSE). ## Installing -With [bower](http://bower.io/): -`bower install comment-core-library` +With [yarn](https://yarnpkg.com/): +`yarn add comment-core-library` With [npm](https://www.npmjs.org/): `npm install comment-core-library` -For Rails, installing with [rails-assets](https://rails-assets.org/) is recommended +For Rails, installing with [rails-assets](https://rails-assets.org/) is +recommended In Gemfile: ```ruby @@ -43,6 +41,13 @@ source 'https://rails-assets.org' gem 'rails-assets-comment-core-library' ``` +### Front-end Framework Integration +To use this library with [React](https://reactjs.org/), please use the +`react-ccl` package instead. + +To use this library with [Vue](https://vuejs.org/), please use the `vue-ccl` +package instead. + ## Examples and Documentation - [Documentation](docs/) can be found inside the `docs/` folder. - Experimental modules are in `experimental/`. diff --git a/README.zh_CN.md b/README.zh_CN.md index 9426760..533dc02 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -1,7 +1,6 @@ # 弹幕核心通用构件 CommentCoreLibrary [![NPM version](https://badge.fury.io/js/comment-core-library.svg)](http://badge.fury.io/js/comment-core-library) [![Bower version](https://badge.fury.io/bo/comment-core-library.svg)](http://badge.fury.io/bo/comment-core-library) -[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/) [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT) [![Build Status: Linux](https://travis-ci.org/jabbany/CommentCoreLibrary.svg?branch=master)](https://travis-ci.org/jabbany/CommentCoreLibrary) [![Coverage Status](https://img.shields.io/coveralls/jabbany/CommentCoreLibrary.svg)](https://coveralls.io/r/jabbany/CommentCoreLibrary?branch=master) @@ -17,14 +16,11 @@ 高级弹幕效果 (5) 基础格式解析 (6) 代码弹幕支持。 ## 测试 -你可以在[这里](http://jabbany.github.io/CommentCoreLibrary/demo) 访问到测试页面。 +你可以在[这里](http://jabbany.github.io/CommentCoreLibrary/demo) 访问到在线测试页面。 我们欢迎各种[BUG报告](CONTRIBUTING.md)。 ## 许可 -本项目采取非常宽松的MIT许可。该许可允许你把本项目运用在任何开源或是闭源的,非营利或商业性的项目中。 -您只需在使用到的地方添加下面一行注释: - - CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT license +本项目采取非常宽松的[MIT许可](LICENSE)。 ## 使用 - 有关本项目的[文档](docs/) 可以在 `docs/` 文件夹里面找到。 @@ -33,7 +29,8 @@ ## 做出贡献 非常欢迎提交问题报告和意见建议,同时你也可以在GitHub上Fork本工程,并发送Pull请求来提交 -你对项目的贡献。我们非常欢迎二次开发哟!有关具体介绍请参考 [CONTRIBUTING](CONTRIBUTING.md)。 +你对项目的贡献。我们非常欢迎二次开发哟!有关具体介绍请参考 +[CONTRIBUTING](CONTRIBUTING.md)。 我们欢迎对项目任何细节处的针对性研发,尤其比如:解析功能、高级弹幕/代码弹幕和CSS优化等。 如果希望研发播放器的构造和功能,请参考姊妹项目 ABPlayerHTML5。 diff --git a/bower.json b/bower.json deleted file mode 100644 index 2977d4e..0000000 --- a/bower.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "comment-core-library", - "description": "Javascript library for organizing and displaying danmaku comments", - "license": "MIT", - "authors": [ - "Jim Chen " - ], - "main": ["dist/CommentCoreLibrary.js","dist/style.css"], - "ignore": [ - "test/**/*", - "experimental/**/*", - "demo/**/*" - ], - "dependencies": { - } -} diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js deleted file mode 100644 index 0d7525b..0000000 --- a/dist/CommentCoreLibrary.js +++ /dev/null @@ -1,2500 +0,0 @@ -/** - * Binary Search Stubs for JS Arrays - * @license MIT - * @author Jim Chen - */ -var BinArray = (function () { - - var BinArray = {}; - - /** - * Performs binary search on the array - * Note: The array MUST ALREADY BE SORTED. Some cases will fail but we don't - * guarantee that we can catch all cases. - * - * @param arr - array to search on - * @param what - element to search for (may not be present) - * @param how - function comparator (a, b). Returns positive value if a > b - * @return index of the element (or index of the element if it were in the array) - **/ - BinArray.bsearch = function (arr, what, how) { - if (!Array.isArray(arr)) { - throw new Error('Bsearch can only be run on arrays'); - } - if (arr.length === 0) { - return 0; - } - if (how(what,arr[0]) < 0) { - return 0; - } - if (how(what,arr[arr.length - 1]) >= 0) { - return arr.length; - } - var low = 0; - var i = 0; - var count = 0; - var high = arr.length - 1; - while (low <= high) { - i = Math.floor((high + low + 1)/2); - count++; - if (how(what,arr[i-1]) >= 0 && how(what,arr[i]) < 0) { - return i; - } else if (how(what,arr[i-1]) < 0) { - high = i-1; - } else if (how(what,arr[i]) >= 0) { - low = i; - } else { - throw new Error('Program Error. Inconsistent comparator or unsorted array!'); - } - if (count > 1500) { - throw new Error('Iteration depth exceeded. Inconsistent comparator or astronomical dataset!'); - } - } - return -1; - }; - - /** - * Insert an element into its position in the array signified by bsearch - * - * @param arr - array to insert into - * @param what - element to insert - * @param how - comparator (see bsearch) - * @return index that the element was inserted to. - **/ - BinArray.binsert = function (arr, what, how) { - var index = BinArray.bsearch(arr,what,how); - arr.splice(index,0,what); - return index; - }; - - return BinArray; -})(); - -/*! - * Comment Core Library CommentManager - * @license MIT - * @author Jim Chen - * - * Copyright (c) 2014 Jim Chen - */ -var CommentManager = (function() { - var _defaultComparator = function (a,b) { - if (a.stime > b.stime) { - return 2; - } else if (a.stime < b.stime) { - return -2; - } else { - if (a.date > b.date) { - return 1; - } else if (a.date < b.date) { - return -1; - } else if (a.dbid != null && b.dbid != null) { - if (a.dbid > b.dbid) { - return 1; - } else if (a.dbid < b.dbid) { - return -1; - } - return 0; - } else { - return 0; - } - } - }; - - function CommentManager(stageObject){ - var __timer = 0; - - this._listeners = {}; - this._lastPosition = 0; - - this.stage = stageObject; - this.options = { - global:{ - opacity:1, - scale:1, - className:"cmt" - }, - scroll:{ - opacity:1, - scale:1 - }, - limit: 0, - seekTrigger: 2000 - }; - this.timeline = []; - this.runline = []; - this.position = 0; - - this.factory = null; - this.filter = null; - this.csa = { - scroll: new CommentSpaceAllocator(0,0), - top: new AnchorCommentSpaceAllocator(0,0), - bottom: new AnchorCommentSpaceAllocator(0,0), - reverse: new CommentSpaceAllocator(0,0), - scrollbtm: new CommentSpaceAllocator(0,0) - }; - - /** Precompute the offset width **/ - this.width = this.stage.offsetWidth; - this.height = this.stage.offsetHeight; - this._startTimer = function () { - if (__timer > 0) { - return; - } - var lastTPos = new Date().getTime(); - var cmMgr = this; - __timer = window.setInterval(function () { - var elapsed = new Date().getTime() - lastTPos; - lastTPos = new Date().getTime(); - cmMgr.onTimerEvent(elapsed,cmMgr); - },10); - }; - this._stopTimer = function () { - window.clearInterval(__timer); - __timer = 0; - }; - } - - /** Public **/ - CommentManager.prototype.stop = function(){ - this._stopTimer(); - // Send stop signal to all comments - this.runline.forEach(function (c) { c.stop(); }); - }; - - CommentManager.prototype.start = function(){ - this._startTimer(); - }; - - CommentManager.prototype.seek = function(time){ - this.position = BinArray.bsearch(this.timeline, time, function(a,b){ - if (a < b.stime) { - return -1 - } else if(a > b.stime) { - return 1; - } else { - return 0; - } - }); - }; - - CommentManager.prototype.validate = function(cmt){ - if (cmt == null) { - return false; - } - return this.filter.doValidate(cmt); - }; - - CommentManager.prototype.load = function(a){ - this.timeline = a; - this.timeline.sort(_defaultComparator); - this.dispatchEvent("load"); - }; - - CommentManager.prototype.insert = function(c){ - var index = BinArray.binsert(this.timeline, c, _defaultComparator); - if (index <= this.position) { - this.position++; - } - this.dispatchEvent("insert"); - }; - - CommentManager.prototype.clear = function () { - while (this.runline.length > 0) { - this.runline[0].finish(); - } - this.dispatchEvent("clear"); - }; - - CommentManager.prototype.setBounds = function () { - this.width = this.stage.offsetWidth; - this.height= this.stage.offsetHeight; - this.dispatchEvent("resize"); - for (var comAlloc in this.csa) { - this.csa[comAlloc].setBounds(this.width,this.height); - } - // Update 3d perspective - this.stage.style.perspective = this.width / Math.tan(55 * Math.PI/180) / 2 + "px"; - this.stage.style.webkitPerspective = this.width / Math.tan(55 * Math.PI/180) / 2 + "px"; - }; - - CommentManager.prototype.init = function (renderer) { - this.setBounds(); - if (this.filter == null) { - this.filter = new CommentFilter(); //Only create a filter if none exist - } - if (this.factory == null) { - switch (renderer) { - case 'legacy': - this.factory = CommentFactory.defaultFactory(); - break; - default: - case 'css': - this.factory = CommentFactory.defaultCssRenderFactory(); - break; - } - } - }; - - CommentManager.prototype.time = function (time) { - time = time - 1; - if (this.position >= this.timeline.length || - Math.abs(this._lastPosition - time) >= this.options.seekTrigger) { - - this.seek(time); - this._lastPosition = time; - if (this.timeline.length <= this.position) { - return; - } - } else { - this._lastPosition = time; - } - var batch = []; - for (;this.position < this.timeline.length;this.position++) { - if (this.timeline[this.position]['stime'] <= time) { - if (this.options.limit > 0 && - this.runline.length + batch.length >= this.options.limit) { - - continue; // Skip comments but still move the position pointer - } else if (this.validate(this.timeline[this.position])) { - batch.push(this.timeline[this.position]); - } - } else { - break; - } - } - if (batch.length > 0) { - this.send(batch); - } - }; - - CommentManager.prototype.rescale = function () { - // TODO: Implement rescaling - }; - - CommentManager.prototype._preprocess = function (data) { - if (data.mode === 8) { - // This comment is not managed by the comment manager - console.log(data); - if (this.scripting) { - console.log(this.scripting.eval(data.code)); - } - return null; - } - if (this.filter != null) { - data = this.filter.doModify(data); - } - return data; - } - - CommentManager.prototype._allocateSpace = function (cmt) { - switch (cmt.mode) { - default: - case 1: { this.csa.scroll.add(cmt); } break; - case 2: { this.csa.scrollbtm.add(cmt); } break; - case 4: { this.csa.bottom.add(cmt); } break; - case 5: { this.csa.top.add(cmt); } break; - case 6: { this.csa.reverse.add(cmt); } break; - case 7: - case 17: {/* Do NOT manage these comments! */} break; - } - } - - CommentManager.prototype.send = function (data) { - if (!Array.isArray(data)) { - data = [ data ]; - } - // Validate all the comments - data = data.map( - this._preprocess.bind(this)).filter(function (item) { - return item !== null; - }); - if (data.length === 0) { - return; - } - data.map((function (item) { - // Create and insert the comments into the DOM - return this.factory.create(this, item); - }).bind(this)).map((function (cmt) { - this._allocateSpace(cmt); - return cmt; - }).bind(this)).forEach((function (cmt) { - cmt.y = cmt.y; - this.dispatchEvent("enterComment", cmt); - this.runline.push(cmt); - }).bind(this)); - }; - - CommentManager.prototype.finish = function (cmt) { - this.dispatchEvent("exitComment", cmt); - this.stage.removeChild(cmt.dom); - var index = this.runline.indexOf(cmt); - if (index >= 0) { - this.runline.splice(index, 1); - } - switch (cmt.mode) { - default: - case 1: {this.csa.scroll.remove(cmt);} break; - case 2: {this.csa.scrollbtm.remove(cmt);} break; - case 4: {this.csa.bottom.remove(cmt);} break; - case 5: {this.csa.top.remove(cmt);} break; - case 6: {this.csa.reverse.remove(cmt);} break; - case 7: break; - } - }; - - CommentManager.prototype.addEventListener = function (event, listener) { - if (typeof this._listeners[event] !== "undefined") { - this._listeners[event].push(listener); - } else { - this._listeners[event] = [listener]; - } - }; - - CommentManager.prototype.dispatchEvent = function (event, data) { - if (typeof this._listeners[event] !== "undefined") { - for (var i = 0; i < this._listeners[event].length; i++) { - try { - this._listeners[event][i](data); - } catch (e) { - console.error(e.stack); - } - } - } - }; - - /** Static Functions **/ - CommentManager.prototype.onTimerEvent = function (timePassed,cmObj) { - for (var i= 0;i < cmObj.runline.length; i++) { - var cmt = cmObj.runline[i]; - cmt.time(timePassed); - } - }; - - return CommentManager; -})(); - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var CoreComment = (function () { - function CoreComment(parent, init) { - if (init === void 0) { init = {}; } - this.mode = 1; - this.stime = 0; - this.text = ''; - this.ttl = 4000; - this.dur = 4000; - this.cindex = -1; - this.motion = []; - this.movable = true; - this._alphaMotion = null; - this.absolute = true; - this.align = 0; - this.axis = 0; - this._alpha = 1; - this._size = 25; - this._color = 0xffffff; - this._border = false; - this._shadow = true; - this._font = ''; - this._transform = null; - if (!parent) { - throw new Error('Comment not bound to comment manager.'); - } - else { - this.parent = parent; - } - if (init.hasOwnProperty('stime')) { - this.stime = init['stime']; - } - if (init.hasOwnProperty('mode')) { - this.mode = init['mode']; - } - else { - this.mode = 1; - } - if (init.hasOwnProperty('dur')) { - this.dur = init['dur']; - this.ttl = this.dur; - } - this.dur *= this.parent.options.global.scale; - this.ttl *= this.parent.options.global.scale; - if (init.hasOwnProperty('text')) { - this.text = init['text']; - } - if (init.hasOwnProperty('motion')) { - this._motionStart = []; - this._motionEnd = []; - this.motion = init['motion']; - var head = 0; - for (var i = 0; i < init['motion'].length; i++) { - this._motionStart.push(head); - var maxDur = 0; - for (var k in init['motion'][i]) { - var m = init['motion'][i][k]; - maxDur = Math.max(m.dur + m.delay, maxDur); - if (m.easing === null || m.easing === undefined) { - init['motion'][i][k]['easing'] = CoreComment.LINEAR; - } - } - head += maxDur; - this._motionEnd.push(head); - } - this._curMotion = 0; - } - if (init.hasOwnProperty('color')) { - this._color = init['color']; - } - if (init.hasOwnProperty('size')) { - this._size = init['size']; - } - if (init.hasOwnProperty('border')) { - this._border = init['border']; - } - if (init.hasOwnProperty('opacity')) { - this._alpha = init['opacity']; - } - if (init.hasOwnProperty('alpha')) { - this._alphaMotion = init['alpha']; - } - if (init.hasOwnProperty('font')) { - this._font = init['font']; - } - if (init.hasOwnProperty('x')) { - this._x = init['x']; - } - if (init.hasOwnProperty('y')) { - this._y = init['y']; - } - if (init.hasOwnProperty('shadow')) { - this._shadow = init['shadow']; - } - if (init.hasOwnProperty('align')) { - this.align = init['align']; - } - if (init.hasOwnProperty('axis')) { - this.axis = init['axis']; - } - if (init.hasOwnProperty('transform')) { - this._transform = new CommentUtils.Matrix3D(init['transform']); - } - if (init.hasOwnProperty('position')) { - if (init['position'] === 'relative') { - this.absolute = false; - if (this.mode < 7) { - console.warn('Using relative position for CSA comment.'); - } - } - } - } - CoreComment.prototype._toggleClass = function (className, toggle) { - if (toggle === void 0) { toggle = false; } - if (!this.dom) { - return; - } - if (this.dom.classList) { - this.dom.classList.toggle(className, toggle); - } - else { - var classList = this.dom.className.split(' '); - var index = classList.indexOf(className); - if (index >= 0 && !toggle) { - classList.splice(index, 1); - this.dom.className = classList.join(' '); - } - else if (index < 0 && toggle) { - classList.push(className); - this.dom.className = classList.join(' '); - } - } - }; - CoreComment.prototype.init = function (recycle) { - if (recycle === void 0) { recycle = null; } - if (recycle !== null) { - this.dom = recycle.dom; - } - else { - this.dom = document.createElement('div'); - } - this.dom.className = this.parent.options.global.className; - this.dom.appendChild(document.createTextNode(this.text)); - this.dom.textContent = this.text; - this.dom.innerText = this.text; - this.size = this._size; - if (this._color != 0xffffff) { - this.color = this._color; - } - this.shadow = this._shadow; - if (this._border) { - this.border = this._border; - } - if (this._font !== '') { - this.font = this._font; - } - if (this._x !== undefined) { - this.x = this._x; - } - if (this._y !== undefined) { - this.y = this._y; - } - if (this._alpha !== 1 || this.parent.options.global.opacity < 1) { - this.alpha = this._alpha; - } - if (this._transform !== null && !this._transform.isIdentity()) { - this.transform = this._transform.flatArray; - } - if (this.motion.length > 0) { - this.animate(); - } - }; - Object.defineProperty(CoreComment.prototype, "x", { - get: function () { - if (this._x === null || this._x === undefined) { - if (this.axis % 2 === 0) { - if (this.align % 2 === 0) { - this._x = this.dom.offsetLeft; - } - else { - this._x = this.dom.offsetLeft + this.width; - } - } - else { - if (this.align % 2 === 0) { - this._x = this.parent.width - this.dom.offsetLeft; - } - else { - this._x = this.parent.width - this.dom.offsetLeft - this.width; - } - } - } - if (!this.absolute) { - return this._x / this.parent.width; - } - return this._x; - }, - set: function (x) { - this._x = x; - if (!this.absolute) { - this._x *= this.parent.width; - } - if (this.axis % 2 === 0) { - this.dom.style.left = (this._x + (this.align % 2 === 0 ? 0 : -this.width)) + 'px'; - } - else { - this.dom.style.right = (this._x + (this.align % 2 === 0 ? -this.width : 0)) + 'px'; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "y", { - get: function () { - if (this._y === null || this._y === undefined) { - if (this.axis < 2) { - if (this.align < 2) { - this._y = this.dom.offsetTop; - } - else { - this._y = this.dom.offsetTop + this.height; - } - } - else { - if (this.align < 2) { - this._y = this.parent.height - this.dom.offsetTop; - } - else { - this._y = this.parent.height - this.dom.offsetTop - this.height; - } - } - } - if (!this.absolute) { - return this._y / this.parent.height; - } - return this._y; - }, - set: function (y) { - this._y = y; - if (!this.absolute) { - this._y *= this.parent.height; - } - if (this.axis < 2) { - this.dom.style.top = (this._y + (this.align < 2 ? 0 : -this.height)) + 'px'; - } - else { - this.dom.style.bottom = (this._y + (this.align < 2 ? -this.height : 0)) + 'px'; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "bottom", { - get: function () { - var sameDirection = Math.floor(this.axis / 2) === Math.floor(this.align / 2); - return this.y + (sameDirection ? this.height : 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "right", { - get: function () { - var sameDirection = this.axis % 2 === this.align % 2; - return this.x + (sameDirection ? this.width : 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "width", { - get: function () { - if (this._width === null || this._width === undefined) { - this._width = this.dom.offsetWidth; - } - return this._width; - }, - set: function (w) { - this._width = w; - this.dom.style.width = this._width + 'px'; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "height", { - get: function () { - if (this._height === null || this._height === undefined) { - this._height = this.dom.offsetHeight; - } - return this._height; - }, - set: function (h) { - this._height = h; - this.dom.style.height = this._height + 'px'; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "size", { - get: function () { - return this._size; - }, - set: function (s) { - this._size = s; - this.dom.style.fontSize = this._size + 'px'; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "color", { - get: function () { - return this._color; - }, - set: function (c) { - this._color = c; - var color = c.toString(16); - color = color.length >= 6 ? color : new Array(6 - color.length + 1).join('0') + color; - this.dom.style.color = '#' + color; - if (this._color === 0) { - this._toggleClass('reverse-shadow', true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "alpha", { - get: function () { - return this._alpha; - }, - set: function (a) { - this._alpha = a; - this.dom.style.opacity = Math.min(this._alpha, this.parent.options.global.opacity) + ''; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "border", { - get: function () { - return this._border; - }, - set: function (b) { - this._border = b; - if (this._border) { - this.dom.style.border = '1px solid #00ffff'; - } - else { - this.dom.style.border = 'none'; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "shadow", { - get: function () { - return this._shadow; - }, - set: function (s) { - this._shadow = s; - if (!this._shadow) { - this._toggleClass('no-shadow', true); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "font", { - get: function () { - return this._font; - }, - set: function (f) { - this._font = f; - if (this._font.length > 0) { - this.dom.style.fontFamily = this._font; - } - else { - this.dom.style.fontFamily = ''; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CoreComment.prototype, "transform", { - get: function () { - return this._transform.flatArray; - }, - set: function (array) { - this._transform = new CommentUtils.Matrix3D(array); - if (this.dom !== null) { - this.dom.style.transform = this._transform.toCss(); - } - }, - enumerable: true, - configurable: true - }); - CoreComment.prototype.time = function (time) { - this.ttl -= time; - if (this.ttl < 0) { - this.ttl = 0; - } - if (this.movable) { - this.update(); - } - if (this.ttl <= 0) { - this.finish(); - } - }; - CoreComment.prototype.update = function () { - this.animate(); - }; - CoreComment.prototype.invalidate = function () { - this._x = null; - this._y = null; - this._width = null; - this._height = null; - }; - CoreComment.prototype._execMotion = function (currentMotion, time) { - for (var prop in currentMotion) { - if (currentMotion.hasOwnProperty(prop)) { - var m = currentMotion[prop]; - this[prop] = m.easing(Math.min(Math.max(time - m.delay, 0), m.dur), m.from, m.to - m.from, m.dur); - } - } - }; - CoreComment.prototype.animate = function () { - if (this._alphaMotion) { - this.alpha = - (this.dur - this.ttl) * - (this._alphaMotion['to'] - this._alphaMotion['from']) / - this.dur + - this._alphaMotion['from']; - } - if (this.motion.length === 0) { - return; - } - var ttl = Math.max(this.ttl, 0); - var time = (this.dur - ttl) - this._motionStart[this._curMotion]; - this._execMotion(this.motion[this._curMotion], time); - if (this.dur - ttl > this._motionEnd[this._curMotion]) { - this._curMotion++; - if (this._curMotion >= this.motion.length) { - this._curMotion = this.motion.length - 1; - } - return; - } - }; - CoreComment.prototype.stop = function () { - }; - CoreComment.prototype.finish = function () { - this.parent.finish(this); - }; - CoreComment.prototype.toString = function () { - return ['[', this.stime, '|', this.ttl, '/', this.dur, ']', '(', this.mode, ')', this.text].join(''); - }; - CoreComment.LINEAR = function (t, b, c, d) { - return t * c / d + b; - }; - return CoreComment; -}()); -var ScrollComment = (function (_super) { - __extends(ScrollComment, _super); - function ScrollComment(parent, data) { - var _this = _super.call(this, parent, data) || this; - _this.dur *= _this.parent.options.scroll.scale; - _this.ttl *= _this.parent.options.scroll.scale; - return _this; - } - Object.defineProperty(ScrollComment.prototype, "alpha", { - set: function (a) { - this._alpha = a; - this.dom.style.opacity = Math.min(Math.min(this._alpha, this.parent.options.global.opacity), this.parent.options.scroll.opacity) + ''; - }, - enumerable: true, - configurable: true - }); - ScrollComment.prototype.init = function (recycle) { - if (recycle === void 0) { recycle = null; } - _super.prototype.init.call(this, recycle); - this.x = this.parent.width; - if (this.parent.options.scroll.opacity < 1) { - this.alpha = this._alpha; - } - this.absolute = true; - }; - ScrollComment.prototype.update = function () { - this.x = (this.ttl / this.dur) * (this.parent.width + this.width) - this.width; - }; - return ScrollComment; -}(CoreComment)); - -var CommentFactory = (function () { - function CommentFactory() { - this._bindings = {}; - } - CommentFactory._simpleCssScrollingInitializer = function (manager, data) { - var cmt = new CssScrollComment(manager, data); - switch (cmt.mode) { - case 1: { - cmt.align = 0; - cmt.axis = 0; - break; - } - case 2: { - cmt.align = 2; - cmt.axis = 2; - break; - } - case 6: { - cmt.align = 1; - cmt.axis = 1; - break; - } - } - cmt.init(); - manager.stage.appendChild(cmt.dom); - return cmt; - }; - CommentFactory._simpleScrollingInitializer = function (manager, data) { - var cmt = new ScrollComment(manager, data); - switch (cmt.mode) { - case 1: { - cmt.align = 0; - cmt.axis = 0; - break; - } - case 2: { - cmt.align = 2; - cmt.axis = 2; - break; - } - case 6: { - cmt.align = 1; - cmt.axis = 1; - break; - } - } - cmt.init(); - manager.stage.appendChild(cmt.dom); - return cmt; - }; - CommentFactory._simpleAnchoredInitializer = function (manager, data) { - var cmt = new CoreComment(manager, data); - switch (cmt.mode) { - case 4: { - cmt.align = 2; - cmt.axis = 2; - break; - } - case 5: { - cmt.align = 0; - cmt.axis = 0; - break; - } - } - cmt.init(); - manager.stage.appendChild(cmt.dom); - return cmt; - }; - ; - CommentFactory._advancedCoreInitializer = function (manager, data) { - var cmt = new CoreComment(manager, data); - cmt.init(); - cmt.transform = CommentUtils.Matrix3D.createRotationMatrix(0, data['rY'], data['rZ']).flatArray; - manager.stage.appendChild(cmt.dom); - return cmt; - }; - CommentFactory.defaultFactory = function () { - var factory = new CommentFactory(); - factory.bind(1, CommentFactory._simpleScrollingInitializer); - factory.bind(2, CommentFactory._simpleScrollingInitializer); - factory.bind(6, CommentFactory._simpleScrollingInitializer); - factory.bind(4, CommentFactory._simpleAnchoredInitializer); - factory.bind(5, CommentFactory._simpleAnchoredInitializer); - factory.bind(7, CommentFactory._advancedCoreInitializer); - factory.bind(17, CommentFactory._advancedCoreInitializer); - return factory; - }; - CommentFactory.defaultCssRenderFactory = function () { - var factory = new CommentFactory(); - factory.bind(1, CommentFactory._simpleCssScrollingInitializer); - factory.bind(2, CommentFactory._simpleCssScrollingInitializer); - factory.bind(6, CommentFactory._simpleCssScrollingInitializer); - factory.bind(4, CommentFactory._simpleAnchoredInitializer); - factory.bind(5, CommentFactory._simpleAnchoredInitializer); - factory.bind(7, CommentFactory._advancedCoreInitializer); - factory.bind(17, CommentFactory._advancedCoreInitializer); - return factory; - }; - CommentFactory.defaultCanvasRenderFactory = function () { - throw new Error('Not implemented'); - }; - CommentFactory.defaultSvgRenderFactory = function () { - throw new Error('Not implemented'); - }; - CommentFactory.prototype.bind = function (mode, factory) { - this._bindings[mode] = factory; - }; - CommentFactory.prototype.canCreate = function (comment) { - return this._bindings.hasOwnProperty(comment['mode']); - }; - CommentFactory.prototype.create = function (manager, comment) { - if (comment === null || !comment.hasOwnProperty('mode')) { - throw new Error('Comment format incorrect'); - } - if (!this._bindings.hasOwnProperty(comment['mode'])) { - throw new Error('No binding for comment type ' + comment['mode']); - } - return this._bindings[comment['mode']](manager, comment); - }; - return CommentFactory; -}()); - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var CommentSpaceAllocator = (function () { - function CommentSpaceAllocator(width, height) { - if (width === void 0) { width = 0; } - if (height === void 0) { height = 0; } - this._pools = [ - [] - ]; - this.avoid = 1; - this._width = width; - this._height = height; - } - CommentSpaceAllocator.prototype.willCollide = function (existing, check) { - return existing.stime + existing.ttl >= check.stime + check.ttl / 2; - }; - CommentSpaceAllocator.prototype.pathCheck = function (y, comment, pool) { - var bottom = y + comment.height; - var right = comment.right; - for (var i = 0; i < pool.length; i++) { - if (pool[i].y > bottom || pool[i].bottom < y) { - continue; - } - else if (pool[i].right < comment.x || pool[i].x > right) { - if (this.willCollide(pool[i], comment)) { - return false; - } - else { - continue; - } - } - else { - return false; - } - } - return true; - }; - CommentSpaceAllocator.prototype.assign = function (comment, cindex) { - while (this._pools.length <= cindex) { - this._pools.push([]); - } - var pool = this._pools[cindex]; - if (pool.length === 0) { - comment.cindex = cindex; - return 0; - } - else if (this.pathCheck(0, comment, pool)) { - comment.cindex = cindex; - return 0; - } - var y = 0; - for (var k = 0; k < pool.length; k++) { - y = pool[k].bottom + this.avoid; - if (y + comment.height > this._height) { - break; - } - if (this.pathCheck(y, comment, pool)) { - comment.cindex = cindex; - return y; - } - } - return this.assign(comment, cindex + 1); - }; - CommentSpaceAllocator.prototype.add = function (comment) { - if (comment.height > this._height) { - comment.cindex = -2; - comment.y = 0; - } - else { - comment.y = this.assign(comment, 0); - BinArray.binsert(this._pools[comment.cindex], comment, function (a, b) { - if (a.bottom < b.bottom) { - return -1; - } - else if (a.bottom > b.bottom) { - return 1; - } - else { - return 0; - } - }); - } - }; - CommentSpaceAllocator.prototype.remove = function (comment) { - if (comment.cindex < 0) { - return; - } - if (comment.cindex >= this._pools.length) { - throw new Error('cindex out of bounds'); - } - var index = this._pools[comment.cindex].indexOf(comment); - if (index < 0) - return; - this._pools[comment.cindex].splice(index, 1); - }; - CommentSpaceAllocator.prototype.setBounds = function (width, height) { - this._width = width; - this._height = height; - }; - return CommentSpaceAllocator; -}()); -var AnchorCommentSpaceAllocator = (function (_super) { - __extends(AnchorCommentSpaceAllocator, _super); - function AnchorCommentSpaceAllocator() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnchorCommentSpaceAllocator.prototype.add = function (comment) { - _super.prototype.add.call(this, comment); - comment.x = (this._width - comment.width) / 2; - }; - AnchorCommentSpaceAllocator.prototype.willCollide = function (a, b) { - return true; - }; - AnchorCommentSpaceAllocator.prototype.pathCheck = function (y, comment, pool) { - var bottom = y + comment.height; - for (var i = 0; i < pool.length; i++) { - if (pool[i].y > bottom || pool[i].bottom < y) { - continue; - } - else { - return false; - } - } - return true; - }; - return AnchorCommentSpaceAllocator; -}(CommentSpaceAllocator)); - -var CommentUtils; -(function (CommentUtils) { - var Matrix3D = (function () { - function Matrix3D(array) { - this._internalArray = null; - if (!Array.isArray(array)) { - throw new Error('Not an array. Cannot construct matrix.'); - } - if (array.length != 16) { - throw new Error('Illegal Dimensions. Matrix3D should be 4x4 matrix.'); - } - this._internalArray = array; - } - Object.defineProperty(Matrix3D.prototype, "flatArray", { - get: function () { - return this._internalArray.slice(0); - }, - set: function (array) { - throw new Error('Not permitted. Matrices are immutable.'); - }, - enumerable: true, - configurable: true - }); - Matrix3D.prototype.isIdentity = function () { - return this.equals(Matrix3D.identity()); - }; - Matrix3D.prototype.dot = function (matrix) { - var a = this._internalArray.slice(0); - var b = matrix._internalArray.slice(0); - var res = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (var i = 0; i < 4; i++) { - for (var j = 0; j < 4; j++) { - for (var k = 0; k < 4; k++) { - res[i * 4 + j] += a[i * 4 + k] * b[k * 4 + j]; - } - } - } - return new Matrix3D(res); - }; - Matrix3D.prototype.equals = function (matrix) { - for (var i = 0; i < 16; i++) { - if (this._internalArray[i] !== matrix._internalArray[i]) { - return false; - } - } - return true; - }; - Matrix3D.prototype.toCss = function () { - var matrix = this._internalArray.slice(0); - for (var i = 0; i < matrix.length; i++) { - if (Math.abs(matrix[i]) < 0.000001) { - matrix[i] = 0; - } - } - return 'matrix3d(' + matrix.join(',') + ')'; - }; - Matrix3D.identity = function () { - return new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }; - Matrix3D.createScaleMatrix = function (xscale, yscale, zscale) { - return new Matrix3D([xscale, 0, 0, 0, 0, yscale, 0, 0, 0, 0, zscale, 0, 0, 0, 0, 1]); - }; - Matrix3D.createRotationMatrix = function (xrot, yrot, zrot) { - var DEG2RAD = Math.PI / 180; - var yr = yrot * DEG2RAD; - var zr = zrot * DEG2RAD; - var COS = Math.cos; - var SIN = Math.sin; - var matrix = [ - COS(yr) * COS(zr), COS(yr) * SIN(zr), SIN(yr), 0, - (-SIN(zr)), COS(zr), 0, 0, - (-SIN(yr) * COS(zr)), (-SIN(yr) * SIN(zr)), COS(yr), 0, - 0, 0, 0, 1 - ]; - return new Matrix3D(matrix.map(function (v) { return Math.round(v * 1e10) * 1e-10; })); - }; - return Matrix3D; - }()); - CommentUtils.Matrix3D = Matrix3D; -})(CommentUtils || (CommentUtils = {})); - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var CssCompatLayer = (function () { - function CssCompatLayer() { - } - CssCompatLayer.transform = function (dom, trans) { - dom.style.transform = trans; - dom.style["webkitTransform"] = trans; - dom.style["msTransform"] = trans; - dom.style["oTransform"] = trans; - }; - return CssCompatLayer; -}()); -var CssScrollComment = (function (_super) { - __extends(CssScrollComment, _super); - function CssScrollComment() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._dirtyCSS = true; - return _this; - } - CssScrollComment.prototype.init = function (recycle) { - if (recycle === void 0) { recycle = null; } - _super.prototype.init.call(this, recycle); - this._toggleClass('css-optimize', true); - }; - Object.defineProperty(CssScrollComment.prototype, "x", { - get: function () { - return (this.ttl / this.dur) * (this.parent.width + this.width) - this.width; - }, - set: function (x) { - if (this._x !== null && typeof this._x === "number") { - var dx = x - this._x; - this._x = x; - CssCompatLayer.transform(this.dom, "translateX(" + - (this.axis % 2 === 0 ? dx : -dx) + "px)"); - } - else { - this._x = x; - if (!this.absolute) { - this._x *= this.parent.width; - } - if (this.axis % 2 === 0) { - this.dom.style.left = - (this._x + (this.align % 2 === 0 ? 0 : -this.width)) + 'px'; - } - else { - this.dom.style.right = - (this._x + (this.align % 2 === 0 ? -this.width : 0)) + 'px'; - } - } - }, - enumerable: true, - configurable: true - }); - CssScrollComment.prototype.update = function () { - if (this._dirtyCSS) { - this.dom.style.transition = "transform " + this.ttl + "ms linear"; - this.x = -this.width; - this._dirtyCSS = false; - } - }; - CssScrollComment.prototype.invalidate = function () { - _super.prototype.invalidate.call(this); - this._dirtyCSS = true; - }; - CssScrollComment.prototype.stop = function () { - _super.prototype.stop.call(this); - this.dom.style.transition = ''; - this.x = this._x; - this._x = null; - this.x = this.x; - this._dirtyCSS = true; - }; - return CssScrollComment; -}(ScrollComment)); - -/** - * Comment Filters Module Simplified - * @license MIT - * @author Jim Chen - */ -var CommentFilter = (function () { - - /** - * Matches a rule against an input that could be the full or a subset of - * the comment data. - * - * @param rule - rule object to match - * @param cmtData - full or portion of comment data - * @return boolean indicator of match - */ - function _match (rule, cmtData) { - var path = rule.subject.split('.'); - var extracted = cmtData; - while (path.length > 0) { - var item = path.shift(); - if (item === '') { - continue; - } - if (extracted.hasOwnProperty(item)) { - extracted = extracted[item]; - } - if (extracted === null || typeof extracted === 'undefined') { - extracted = null; - break; - } - } - if (extracted === null) { - // Null precondition implies anything - return true; - } - switch (rule.op) { - case '<': - return extracted < rule.value; - case '>': - return extracted > rule.value; - case '~': - case 'regexp': - return (new RegExp(rule.value)).test(extracted.toString()); - case '=': - case 'eq': - return rule.value === - ((typeof extracted === 'number') ? - extracted : extracted.toString()); - case '!': - case 'not': - return !_match(rule.value, extracted); - case '&&': - case 'and': - if (Array.isArray(rule.value)) { - return rule.value.every(function (r) { - return _match(r, extracted); - }); - } else { - return false; - } - case '||': - case 'or': - if (Array.isArray(rule.value)) { - return rule.value.some(function (r) { - return _match(r, extracted); - }); - } else { - return false; - } - default: - return false; - } - } - - /** - * Constructor for CommentFilter - * @constructor - */ - function CommentFilter() { - this.rules = []; - this.modifiers = []; - this.allowUnknownTypes = true; - this.allowTypes = { - '1': true, - '2': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '17': true - }; - } - - /** - * Runs all modifiers against current comment - * - * @param cmt - comment to run modifiers on - * @return modified comment - */ - CommentFilter.prototype.doModify = function (cmt) { - return this.modifiers.reduce(function (c, f) { - return f(c); - }, cmt); - }; - - /** - * Executes a method defined to be executed right before the comment object - * (built from commentData) is placed onto the runline. - * - * @deprecated - * @param cmt - comment data - * @return cmt - */ - CommentFilter.prototype.beforeSend = function (cmt) { - return cmt; - }; - - /** - * Performs validation of the comment data before it is allowed to get sent - * by applying type constraints and rules - * - * @param cmtData - comment data - * @return boolean indicator of whether this commentData should be shown - */ - CommentFilter.prototype.doValidate = function (cmtData) { - if (!cmtData.hasOwnProperty('mode')) { - return false; - } - if ((!this.allowUnknownTypes || - cmtData.mode.toString() in this.allowTypes) && - !this.allowTypes[cmtData.mode.toString()]) { - return false; - } - return this.rules.every(function (rule) { - // Decide if matched - try { - var matched = _match(rule, cmtData); - } catch (e) { - var matched = false; - } - return rule.mode === 'accept' ? matched : !matched; - }); - }; - - /** - * Adds a rule for use with validation - * - * @param rule - object containing rule definitions - * @throws Exception when rule mode is incorrect - */ - CommentFilter.prototype.addRule = function (rule) { - if (rule.mode !== 'accept' && rule.mode !== 'reject') { - throw new Error('Rule must be of accept type or reject type.'); - } - this.rules.push(rule); - }; - - /** - * Removes a rule - * - * @param rule - the rule that was added - * @return true if the rule was removed, false if not found - */ - CommentFilter.prototype.removeRule = function (rule) { - var index = this.rules.indexOf(rule); - if (index >= 0) { - this.rules.splice(index, 1); - return true; - } else { - return false; - } - }; - - /** - * Adds a modifier to be used - * - * @param modifier - modifier function that takes in comment data and - * returns modified comment data - * @throws Exception when modifier is not a function - */ - CommentFilter.prototype.addModifier = function (f) { - if (typeof f !== 'function') { - throw new Error('Modifiers need to be functions.'); - } - this.modifiers.push(f); - }; - - return CommentFilter; -})(); - -/** - * Comment Provider - * Provides functionality to send or receive danmaku - * @license MIT - * @author Jim Chen -**/ - -var CommentProvider = (function () { - - function CommentProvider () { - this._started = false; - this._destroyed = false; - this._staticSources = {}; - this._dynamicSources = {}; - this._parsers = {} - this._targets = []; - } - - CommentProvider.SOURCE_JSON = 'JSON'; - CommentProvider.SOURCE_XML = 'XML'; - CommentProvider.SOURCE_TEXT = 'TEXT'; - - /** - * Provider for HTTP content. This returns a promise that resolves to TEXT. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {string} responseType - type of response expected. - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.BaseHttpProvider = function (method, url, responseType, args, body) { - return new Promise(function (resolve, reject) { - var xhr = new XMLHttpRequest(); - var uri = url; - if (args && (method === 'POST' || method === 'PUT')) { - uri += '?'; - var argsArray = []; - for (var key in args) { - if (args.hasOwnProperty(key)) { - argsArray.push(encodeURIComponent(key) + - '=' + encodeURIComponent(args[key])); - } - } - uri += argsArray.join('&'); - } - - xhr.onload = function () { - if (this.status >= 200 && this.status < 300) { - resolve(this.response); - } else { - reject(new Error(this.status + " " + this.statusText)); - } - }; - - xhr.onerror = function () { - reject(new Error(this.status + " " + this.statusText)); - }; - - xhr.open(method, uri); - - // Limit the response type based on input - xhr.responseType = typeof responseType === "string" ? - responseType : ""; - - if (typeof body !== 'undefined') { - xhr.send(body); - } else { - xhr.send(); - } - }); - }; - - /** - * Provider for JSON content. This returns a promise that resolves to JSON. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.JSONProvider = function (method, url, args, body) { - return CommentProvider.BaseHttpProvider( - method, url, "json", args, body).then(function (response) { - return response; - }); - }; - - /** - * Provider for XML content. This returns a promise that resolves to Document. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.XMLProvider = function (method, url, args, body) { - return CommentProvider.BaseHttpProvider( - method, url, "document", args, body).then(function (response) { - return response; - }); - }; - - /** - * Provider for text content. This returns a promise that resolves to Text. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.TextProvider = function (method, url, args, body) { - return CommentProvider.BaseHttpProvider( - method, url, "text", args, body).then(function (response) { - return response; - }); - }; - - /** - * Attaches a static source to the corresponding type. - * NOTE: Multiple static sources will race to determine the initial comment - * list so it is imperative that they all parse to the SAME content. - * - * @param {Provider} source - Promise that resolves to one of the supported types - * @param {Type} type - Type that the provider resolves to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addStaticSource = function (source, type) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' + - 'cannot attach more sources.'); - } - if (!(type in this._staticSources)) { - this._staticSources[type] = []; - } - this._staticSources[type].push(source); - return this; - }; - - /** - * Attaches a dynamic source to the corresponding type - * NOTE: Multiple dynamic sources will collectively provide comment data. - * - * @param {DynamicProvider} source - Listenable that resolves to one of the supported types - * @param {Type} type - Type that the provider resolves to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addDynamicSource = function (source, type) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' + - 'cannot attach more sources.'); - } - if (!(type in this._dynamicSources)) { - this._dynamicSources[type] = []; - } - this._dynamicSources[type].push(source); - return this; - }; - - /** - * Attaches a target comment manager so that we can stream comments to it - * - * @param {CommentManager} commentManager - Comment Manager instance to attach to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addTarget = function (commentManager) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' - +'cannot attach more targets.'); - } - if (!(commentManager instanceof CommentManager)) { - throw new Error( - 'Expected the target to be an instance of CommentManager.'); - } - this._targets.push(commentManager); - return this; - }; - - /** - * Adds a parser for an incoming data type. If multiple parsers are added, - * parsers added later take precedence. - * - * @param {CommentParser} parser - Parser spec compliant parser - * @param {Type} type - Type that the provider resolves to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addParser = function (parser, type) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' + - 'cannot attach more parsers.'); - } - if (!(type in this._parsers)) { - this._parsers[type] = []; - } - this._parsers[type].unshift(parser); - return this; - }; - - CommentProvider.prototype.applyParsersOne = function (data, type) { - return new Promise(function (resolve, reject) { - if (!(type in this._parsers)) { - reject(new Error('No parsers defined for "' + type + '"')); - return; - } - for (var i = 0; i < this._parsers[type].length; i++) { - var output = null; - try { - output = this._parsers[type][i].parseOne(data); - } catch (e) { - // TODO: log this failure - console.error(e); - } - if (output !== null) { - resolve(output); - return; - } - } - reject(new Error("Ran out of parsers for they target type")); - }.bind(this)); - }; - - CommentProvider.prototype.applyParsersList = function (data, type) { - return new Promise(function (resolve, reject) { - if (!(type in this._parsers)) { - reject(new Error('No parsers defined for "' + type + '"')); - return; - } - for (var i = 0; i < this._parsers[type].length; i++) { - var output = null; - try { - output = this._parsers[type][i].parseMany(data); - } catch (e) { - // TODO: log this failure - console.error(e); - } - if (output !== null) { - resolve(output); - return; - } - } - reject(new Error("Ran out of parsers for the target type")); - }.bind(this)); - }; - - /** - * (Re)loads static comments - * - * @return {Promise} that is resolved when the static sources have been - * loaded - */ - CommentProvider.prototype.load = function () { - if (this._destroyed) { - throw new Error('Cannot load sources on a destroyed provider.'); - } - var promises = []; - // TODO: This race logic needs to be rethought to provide redundancy - for (var type in this._staticSources) { - promises.push(Promises.any(this._staticSources[type]) - .then(function (data) { - return this.applyParsersList(data, type); - }.bind(this))); - } - if (promises.length === 0) { - // No static loaders - return Promise.resolve([]); - } - return Promises.any(promises).then(function (commentList) { - for (var i = 0; i < this._targets.length; i++) { - this._targets[i].load(commentList); - } - return Promise.resolve(commentList); - }.bind(this)); - }; - - /** - * Commit the changes and boot up the provider - * - * @return {Promise} that is resolved when all the static sources are loaded - * and all the dynamic sources are hooked up - **/ - CommentProvider.prototype.start = function () { - if (this._destroyed) { - throw new Error('Cannot start a provider that has been destroyed.'); - } - this._started = true; - return this.load().then(function (commentList) { - // Bind the dynamic sources - for (var type in this._dynamicSources) { - this._dynamicSources[type].forEach(function (source) { - source.addEventListener('receive', function (data) { - for (var i = 0; i < this._targets.length; i++) { - this._targets[i].send( - this.applyParserOne(data, type)); - } - }.bind(this)); - }.bind(this)); - } - return Promise.resolve(commentList); - }.bind(this)); - }; - - /** - * Send out comments to both dynamic sources and POST targets. - * - * @param commentData - commentData to be sent to the server. Object. - * @param requireAll - Do we require that all servers to accept the comment - * for the promise to resolve. Defaults to true. If - * false, the returned promise will resolve as long as a - * single target accepts. - * @return Promise that is resolved when the server accepts or rejects the - * comment. Dynamic sources will decide based on their promise while - * POST targets are considered accepted if they return a successful - * HTTP response code. - **/ - CommentProvider.prototype.send = function (commentData, requireAll) { - throw new Error('Not implemented'); - }; - - /** - * Stop providing dynamic comments to the targets - * - * @return Promise that is resolved when all bindings between dynamic - * sources have been successfully unloaded. - **/ - CommentProvider.prototype.destroy = function () { - if (this._destroyed) { - return Promise.resolve(); - } - // TODO: implement debinding for sources - this._destroyed = true; - return Promise.resolve(); - }; - - return CommentProvider; -})(); - -/** - * Promises extra functionality - * @license MIT - * @author Jim Chen - */ -var Promises = (function( ) { - - var Promises = {}; - - /** - * Resolves as soon as any promise resolves in the order of the input array - * - * @param arr - array of promises - * @return promise that resolves if any one promise resolves and rejects - * if otherwise - **/ - Promises.any = function (promises) { - if (!Array.isArray(promises)) { - // Is raw object or promise, resolve it directly - return Promise.resolve(promises); - } - if (promises.length === 0) { - // No promises to resolve so we think it failed - return Promise.reject(); - } - return new Promise(function (resolve, reject) { - var hasResolved = false; - var hasCompleted = 0; - var errors = []; - for (var i = 0; i < promises.length; i++) { - promises[i].then(function (value) { - hasCompleted++; - if (!hasResolved) { - hasResolved = true; - resolve(value); - } - }).catch((function (i) { - return function (e) { - hasCompleted++; - errors[i] = e; - if (hasCompleted === promises.length) { - // All promises have completed and we are in rejecting case - if (!hasResolved) { - reject(errors); - } - } - } - })(i)); - } - }); - }; - - return Promises; -})(); - -/** - * Bilibili Format Parser - * Takes in an XMLDoc/LooseXMLDoc and parses that into a Generic Comment List - * @license MIT License - **/ -var BilibiliFormat = (function () { - var BilibiliFormat = {}; - - // Fix comments to be valid - var _format = function (text) { - return text.replace(/\t/,"\\t"); - }; - - // Fix Mode7 comments when they are bad - var _formatmode7 = function (text) { - if (text.charAt(0) === '[') { - switch (text.charAt(text.length - 1)) { - case ']': - return text; - case '"': - return text + ']'; - case ',': - return text.substring(0, text.length - 1) + '"]'; - default: - return _formatmode7(text.substring(0, text.length - 1)); - } - } else { - return text; - } - }; - - // Try to escape unsafe HTML code. DO NOT trust that this handles all cases - // Please do not allow insecure DOM parsing unless you can trust your input source. - var _escapeUnsafe = function (text) { - text = text.replace(new RegExp('= 7) { - comment.rZ = parseInt(extendedParams[5], 10); - comment.rY = parseInt(extendedParams[6], 10); - } - comment.motion = []; - comment.movable = false; - if (extendedParams.length >= 11) { - comment.movable = true; - var singleStepDur = 500; - var motion = { - 'x': { - 'from': comment.x, - 'to': parseFloat(extendedParams[7]), - 'dur': singleStepDur, - 'delay': 0 - }, - 'y': { - 'from': comment.y, - 'to': parseFloat(extendedParams[8]), - 'dur': singleStepDur, - 'delay': 0 - } - }; - if (extendedParams[9] !== '') { - singleStepDur = parseInt(extendedParams[9], 10); - motion.x.dur = singleStepDur; - motion.y.dur = singleStepDur; - } - if (extendedParams[10] !== '') { - motion.x.delay = parseInt(extendedParams[10], 10); - motion.y.delay = parseInt(extendedParams[10], 10); - } - if (extendedParams.length > 11) { - comment.shadow = (extendedParams[11] !== 'false' && extendedParams[11] !== false); - if (extendedParams[12] != null) { - comment.font = extendedParams[12]; - } - if (extendedParams.length > 14) { - // Support for Bilibili advanced Paths - if (comment.position === 'relative') { - if (this._logBadComments) { - console.warn('Cannot mix relative and absolute positioning!'); - } - comment.position = 'absolute'; - } - var path = extendedParams[14]; - var lastPoint = { - x: motion.x.from, - y: motion.y.from - }; - var pathMotion = []; - var regex = new RegExp('([a-zA-Z])\\s*(\\d+)[, ](\\d+)','g'); - var counts = path.split(/[a-zA-Z]/).length - 1; - var m = regex.exec(path); - while (m !== null) { - switch (m[1]) { - case 'M': { - lastPoint.x = parseInt(m[2],10); - lastPoint.y = parseInt(m[3],10); - } - break; - case 'L': { - pathMotion.push({ - 'x': { - 'from': lastPoint.x, - 'to': parseInt(m[2],10), - 'dur': singleStepDur / counts, - 'delay': 0 - }, - 'y': { - 'from': lastPoint.y, - 'to': parseInt(m[3],10), - 'dur': singleStepDur / counts, - 'delay': 0 - } - }); - lastPoint.x = parseInt(m[2],10); - lastPoint.y = parseInt(m[3],10); - } - break; - } - m = regex.exec(path); - } - motion = null; - comment.motion = pathMotion; - } - } - if (motion !== null) { - comment.motion.push(motion); - } - } - comment.dur = 2500; - if (extendedParams[3] < 12) { - comment.dur = extendedParams[3] * 1000; - } - var tmp = extendedParams[2].split('-'); - if (tmp != null && tmp.length > 1) { - var alphaFrom = parseFloat(tmp[0]); - var alphaTo = parseFloat(tmp[1]); - comment.opacity = alphaFrom; - if (alphaFrom !== alphaTo) { - comment.alpha = { - 'from':alphaFrom, - 'to':alphaTo - }; - } - } - } catch (e) { - if (this._logBadComments) { - console.warn('Error occurred in JSON parsing. Could not parse comment.'); - console.log('[DEBUG] ' + text); - } - } - } else if(comment.mode === 8) { - comment.code = text; // Code comments are special. Treat them that way. - } else { - if (this._logBadComments) { - console.warn('Unknown comment type : ' + comment.mode + '. Not doing further parsing.'); - console.log('[DEBUG] ' + text); - } - } - } - if (comment.text !== null && typeof comment.text === 'string') { - comment.text = comment.text.replace(/\u25a0/g,"\u2588"); - } - return comment; - }; - - BilibiliFormat.XMLParser.prototype.parseMany = function (xmldoc) { - var elements = []; - try { - elements = xmldoc.getElementsByTagName('d'); - } catch (e) { - // TODO: handle XMLDOC errors. - return null; // Bail, I can't handle - } - var commentList = []; - for (var i = 0; i < elements.length; i++) { - var comment = this.parseOne(elements[i]); - if (comment !== null) { - commentList.push(comment); - } - } - return commentList; - }; - - BilibiliFormat.TextParser = function (params) { - this._allowInsecureDomParsing = true; - this._attemptEscaping = true; - this._canSecureNativeParse = false; - if (typeof params === 'object') { - this._allowInsecureDomParsing = params.allowInsecureDomParsing === false ? false : true; - this._attemptEscaping = params.attemptEscaping === false ? false : true; - } - if (typeof document === 'undefined' || !document || !document.createElement) { - // We can't rely on innerHTML anyways. Maybe we're in a restricted context (i.e. node). - this._allowInsecureDomParsing = false; - } - if (typeof DOMParser !== 'undefined' && DOMParser !== null) { - this._canSecureNativeParse = true; - } - if (this._allowInsecureDomParsing || this._canSecureNativeParse) { - this._xmlParser = new BilibiliFormat.XMLParser(params); - } - }; - - BilibiliFormat.TextParser.prototype.parseOne = function (comment) { - // Attempt to parse a single tokenized tag - if (this._allowInsecureDomParsing) { - var source = comment; - if (this._attemptEscaping) { - source = _escapeUnsafe(source); - } - var temp = document.createElement('div'); - temp.innerHTML = source; - var tags = temp.getElementsByTagName('d'); - if (tags.length !== 1) { - return null; // Can't parse, delegate - } else { - return this._xmlParser.parseOne(tags[0]); - } - } else if (this._canSecureNativeParse) { - var domParser = new DOMParser(); - return this._xmlParser.parseOne( - domParser.parseFromString(comment, 'application/xml')); - } else { - throw new Error('Secure native js parsing not implemented yet.'); - } - }; - - BilibiliFormat.TextParser.prototype.parseMany = function (comment) { - // Attempt to parse a comment list - if (this._allowInsecureDomParsing) { - var source = comment; - if (this._attemptEscaping) { - source = _escapeUnsafe(source); - } - var temp = document.createElement('div'); - temp.innerHTML = source; - return this._xmlParser.parseMany(temp); - } else if (this._canSecureNativeParse) { - var domParser = new DOMParser(); - return this._xmlParser.parseMany( - domParser.parseFromString(comment, 'application/xml')); - } else { - throw new Error('Secure native js parsing not implemented yet.'); - } - }; - - return BilibiliFormat; -})(); - -/** - * AcFun Format Parser - * Takes in JSON and parses it based on current documentation for AcFun comments - * @license MIT License - **/ -var AcfunFormat = (function () { - var AcfunFormat = {}; - - AcfunFormat.JSONParser = function (params) { - this._logBadComments = true; - this._logNotImplemented = false; - if (typeof params === 'object') { - this._logBadComments = params.logBadComments === false ? false : true; - this._logNotImplemented = params.logNotImplemented === true ? true : false; - } - }; - - AcfunFormat.JSONParser.prototype.parseOne = function (comment) { - // Read a comment and generate a correct comment object - var data = {}; - if (typeof comment !== 'object' || comment == null || !comment.hasOwnProperty('c')) { - // This cannot be parsed. The comment contains no config data - return null; - } - var config = comment['c'].split(','); - if (config.length >= 6) { - data.stime = parseFloat(config[0]) * 1000; - data.color = parseInt(config[1]) - data.mode = parseInt(config[2]); - data.size = parseInt(config[3]); - data.hash = config[4]; - data.date = parseInt(config[5]); - data.position = "absolute"; - if (data.mode !== 7) { - // Do some text normalization on low complexity comments - data.text = comment.m.replace(/(\/n|\\n|\n|\r\n|\\r)/g,"\n"); - data.text = data.text.replace(/\r/g,"\n"); - data.text = data.text.replace(/\s/g,"\u00a0"); - } else { - try { - var x = JSON.parse(comment.m); - } catch (e) { - if (this._logBadComments) { - console.warn('Error parsing internal data for comment'); - console.log('[Dbg] ' + data.text); - } - return null; // Can't actually parse this! - } - data.position = "relative"; - data.text = x.n; /*.replace(/\r/g,"\n");*/ - data.text = data.text.replace(/\ /g,"\u00a0"); - if (typeof x.a === 'number') { - data.opacity = x.a; - } else { - data.opacity = 1; - } - if (typeof x.p === 'object') { - // Relative position - data.x = x.p.x / 1000; - data.y = x.p.y / 1000; - } else { - data.x = 0; - data.y = 0; - } - if (typeof x.c === 'number') { - switch (x.c) { - case 0: data.align = 0; break; - case 2: data.align = 1; break; - case 6: data.align = 2; break; - case 8: data.align = 3; break; - default: - if (this._logNotImplemented) { - console.log('Cannot handle aligning to center! AlignMode=' + x.c); - } - } - } - // Use default axis - data.axis = 0; - data.shadow = x.b; - data.dur = 4000; - if (typeof x.l === 'number') { - data.dur = x.l * 1000; - } - if (x.z != null && x.z.length > 0) { - data.movable = true; - data.motion = []; - var moveDuration = 0; - var last = { - x: data.x, - y: data.y, - alpha: data.opacity, - color: data.color - }; - for (var m = 0; m < x.z.length; m++) { - var dur = x.z[m].l != null ? (x.z[m].l * 1000) : 500; - moveDuration += dur; - var motion = {}; - if (x.z[m].hasOwnProperty('rx') && typeof x.z[m].rx === 'number') { - // TODO: Support this - if (this._logNotImplemented) { - console.log('Encountered animated x-axis rotation. Ignoring.'); - } - } - if (x.z[m].hasOwnProperty('e') && typeof x.z[m].e === 'number') { - // TODO: Support this - if (this._logNotImplemented) { - console.log('Encountered animated y-axis rotation. Ignoring.'); - } - } - if (x.z[m].hasOwnProperty('d') && typeof x.z[m].d === 'number') { - // TODO: Support this - if (this._logNotImplemented) { - console.log('Encountered animated z-axis rotation. Ignoring.'); - } - } - if (x.z[m].hasOwnProperty('x') && typeof x.z[m].x === 'number') { - motion.x = { - from: last.x, - to: x.z[m].x / 1000, - dur: dur, - delay: 0 - }; - } - if (x.z[m].hasOwnProperty('y') && typeof x.z[m].y === 'number') { - motion.y = { - from: last.y, - to: x.z[m].y / 1000, - dur: dur, - delay: 0 - }; - } - last.x = motion.hasOwnProperty('x') ? motion.x.to : last.x; - last.y = motion.hasOwnProperty('y') ? motion.y.to : last.y; - if (x.z[m].hasOwnProperty('t') && - typeof x.z[m].t === 'number' && - x.z[m].t !== last.alpha) { - motion.alpha = { - from: last.alpha, - to: x.z[m].t, - dur: dur, - delay: 0 - }; - last.alpha = motion.alpha.to; - } - if (x.z[m].hasOwnProperty('c') && - typeof x.z[m].c === 'number' && - x.z[m].c !== last.color) { - motion.color = { - from: last.color, - to:x.z[m].c, - dur: dur, - delay: 0 - }; - last.color = motion.color.to; - } - data.motion.push(motion); - } - data.dur = moveDuration + (data.moveDelay ? data.moveDelay : 0); - } - if (x.hasOwnProperty('w')) { - if (x.w.hasOwnProperty('f')) { - data.font = x.w.f; - } - if (x.w.hasOwnProperty('l') && Array.isArray(x.w.l)) { - if (x.w.l.length > 0) { - // Filters - if (this._logNotImplemented) { - console.log('[Dbg] Filters not supported! ' + - JSON.stringify(x.w.l)); - } - } - } - } - if (x.r != null && x.k != null) { - data.rX = x.r; - data.rY = x.k; - } - - } - return data; - } else { - // Not enough arguments. - if (this._logBadComments) { - console.warn('Dropping this comment due to insufficient parameters. Got: ' + config.length); - console.log('[Dbg] ' + comment['c']); - } - return null; - } - }; - - AcfunFormat.JSONParser.prototype.parseMany = function (comments) { - if (!Array.isArray(comments)) { - return null; - } - var list = []; - for (var i = 0; i < comments.length; i++) { - var comment = this.parseOne(comments[i]); - if (comment !== null) { - list.push(comment); - } - } - return list; - }; - - AcfunFormat.TextParser = function (param) { - this._jsonParser = new AcfunFormat.JSONParser(param); - } - - AcfunFormat.TextParser.prototype.parseOne = function (comment) { - try { - return this._jsonParser.parseOne(JSON.parse(comment)); - } catch (e) { - console.warn(e); - return null; - } - } - - AcfunFormat.TextParser.prototype.parseMany = function (comment) { - try { - return this._jsonParser.parseMany(JSON.parse(comment)); - } catch (e) { - console.warn(e); - return null; - } - } - - return AcfunFormat; -})(); - -/** - * CommonDanmakuFormat Parser - * Example parser for parsing comments that the CCL can accept directly. - * @license MIT - * @author Jim Chen - **/ - -var CommonDanmakuFormat = (function () { - var CommonDanmakuFormat = {}; - var _check = function (comment) { - // Sanity check to see if we should be parsing these comments or not - if (typeof comment.mode !== 'number' || typeof comment.stime !== 'number') { - return false; - } - if (comment.mode === 8 && !(typeof comment.code === 'string')) { - return false; - } - if (typeof comment.text !== 'string') { - return false; - } - return true; - }; - - CommonDanmakuFormat.JSONParser = function () { }; - CommonDanmakuFormat.JSONParser.prototype.parseOne = function (comment) { - // Refuse to parse the comment does not pass sanity check - return _check(comment) ? comment : null; - }; - - CommonDanmakuFormat.JSONParser.prototype.parseMany = function (comments) { - // Refuse to parse if any comment does not pass sanity check - return comments.every(_check) ? comments : null; - }; - - CommonDanmakuFormat.XMLParser = function () { }; - CommonDanmakuFormat.XMLParser.prototype.parseOne = function (comment) { - var data = {} - try { - data.stime = parseInt(comment.getAttribute('stime')); - data.mode = parseInt(comment.getAttribute('mode')); - data.size = parseInt(comment.getAttribute('size')); - data.color = parseInt(comment.getAttribute('color')); - data.text = comment.textContent; - } catch (e) { - return null; - } - return data; - }; - - CommonDanmakuFormat.XMLParser.prototype.parseMany = function (commentsElem) { - try { - var comments = commentsElem.getElementsByTagName('comment'); - } catch (e) { - return null; - } - var commentList = []; - for (var i = 0; i < comments.length; i++) { - var comment = this.parseOne(comments[i]); - if (comment !== null) { - commentList.push(comment); - } - } - return commentList; - }; - - return CommonDanmakuFormat; -})(); diff --git a/dist/CommentCoreLibrary.min.js b/dist/CommentCoreLibrary.min.js deleted file mode 100644 index 0fecbf1..0000000 --- a/dist/CommentCoreLibrary.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*!Copyright(c) CommentCoreLibrary v0.11.0 (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT License */ -var CommentUtils,BinArray=function(){var n={bsearch:function(t,e,r){if(!Array.isArray(t))throw new Error("Bsearch can only be run on arrays");if(0===t.length)return 0;if(r(e,t[0])<0)return 0;if(0<=r(e,t[t.length-1]))return t.length;for(var i=0,n=0,o=0,s=t.length-1;i<=s;){if(o++,0<=r(e,t[(n=Math.floor((s+i+1)/2))-1])&&r(e,t[n])<0)return n;if(r(e,t[n-1])<0)s=n-1;else{if(!(0<=r(e,t[n])))throw new Error("Program Error. Inconsistent comparator or unsorted array!");i=n}if(1500e.stime?2:t.stimee.date?1:t.datee.dbid?1:t.dbide.stime?1:0})},t.prototype.validate=function(t){return null!=t&&this.filter.doValidate(t)},t.prototype.load=function(t){this.timeline=t,this.timeline.sort(e),this.dispatchEvent("load")},t.prototype.insert=function(t){BinArray.binsert(this.timeline,t,e)<=this.position&&this.position++,this.dispatchEvent("insert")},t.prototype.clear=function(){for(;0=this.timeline.length||Math.abs(this._lastPosition-t)>=this.options.seekTrigger){if(this.seek(t),this._lastPosition=t,this.timeline.length<=this.position)return}else this._lastPosition=t;for(var e=[];this.position=this.options.limit||this.validate(this.timeline[this.position])&&e.push(this.timeline[this.position]);0this._motionEnd[this._curMotion]?(this._curMotion++,void(this._curMotion>=this.motion.length&&(this._curMotion=this.motion.length-1))):void 0}},a.prototype.stop=function(){},a.prototype.finish=function(){this.parent.finish(this)},a.prototype.toString=function(){return["[",this.stime,"|",this.ttl,"/",this.dur,"]","(",this.mode,")",this.text].join("")},a.LINEAR=function(t,e,r,i){return t*r/i+e},a}(),ScrollComment=function(i){function t(t,e){var r=i.call(this,t,e)||this;return r.dur*=r.parent.options.scroll.scale,r.ttl*=r.parent.options.scroll.scale,r}return __extends(t,i),Object.defineProperty(t.prototype,"alpha",{set:function(t){this._alpha=t,this.dom.style.opacity=Math.min(Math.min(this._alpha,this.parent.options.global.opacity),this.parent.options.scroll.opacity)+""},enumerable:!0,configurable:!0}),t.prototype.init=function(t){void 0===t&&(t=null),i.prototype.init.call(this,t),this.x=this.parent.width,this.parent.options.scroll.opacity<1&&(this.alpha=this._alpha),this.absolute=!0},t.prototype.update=function(){this.x=this.ttl/this.dur*(this.parent.width+this.width)-this.width},t}(CoreComment),CommentFactory=function(){function e(){this._bindings={}}return e._simpleCssScrollingInitializer=function(t,e){var r=new CssScrollComment(t,e);switch(r.mode){case 1:r.align=0,r.axis=0;break;case 2:r.align=2,r.axis=2;break;case 6:r.align=1,r.axis=1}return r.init(),t.stage.appendChild(r.dom),r},e._simpleScrollingInitializer=function(t,e){var r=new ScrollComment(t,e);switch(r.mode){case 1:r.align=0,r.axis=0;break;case 2:r.align=2,r.axis=2;break;case 6:r.align=1,r.axis=1}return r.init(),t.stage.appendChild(r.dom),r},e._simpleAnchoredInitializer=function(t,e){var r=new CoreComment(t,e);switch(r.mode){case 4:r.align=2,r.axis=2;break;case 5:r.align=0,r.axis=0}return r.init(),t.stage.appendChild(r.dom),r},e._advancedCoreInitializer=function(t,e){var r=new CoreComment(t,e);return r.init(),r.transform=CommentUtils.Matrix3D.createRotationMatrix(0,e.rY,e.rZ).flatArray,t.stage.appendChild(r.dom),r},e.defaultFactory=function(){var t=new e;return t.bind(1,e._simpleScrollingInitializer),t.bind(2,e._simpleScrollingInitializer),t.bind(6,e._simpleScrollingInitializer),t.bind(4,e._simpleAnchoredInitializer),t.bind(5,e._simpleAnchoredInitializer),t.bind(7,e._advancedCoreInitializer),t.bind(17,e._advancedCoreInitializer),t},e.defaultCssRenderFactory=function(){var t=new e;return t.bind(1,e._simpleCssScrollingInitializer),t.bind(2,e._simpleCssScrollingInitializer),t.bind(6,e._simpleCssScrollingInitializer),t.bind(4,e._simpleAnchoredInitializer),t.bind(5,e._simpleAnchoredInitializer),t.bind(7,e._advancedCoreInitializer),t.bind(17,e._advancedCoreInitializer),t},e.defaultCanvasRenderFactory=function(){throw new Error("Not implemented")},e.defaultSvgRenderFactory=function(){throw new Error("Not implemented")},e.prototype.bind=function(t,e){this._bindings[t]=e},e.prototype.canCreate=function(t){return this._bindings.hasOwnProperty(t.mode)},e.prototype.create=function(t,e){if(null===e||!e.hasOwnProperty("mode"))throw new Error("Comment format incorrect");if(!this._bindings.hasOwnProperty(e.mode))throw new Error("No binding for comment type "+e.mode);return this._bindings[e.mode](t,e)},e}(),CommentSpaceAllocator=(__extends=this&&this.__extends||function(){var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};return function(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._pools=[[]],this.avoid=1,this._width=t,this._height=e}return t.prototype.willCollide=function(t,e){return t.stime+t.ttl>=e.stime+e.ttl/2},t.prototype.pathCheck=function(t,e,r){for(var i=t+e.height,n=e.right,o=0;oi||r[o].bottomn))return!1;if(this.willCollide(r[o],e))return!1}return!0},t.prototype.assign=function(t,e){for(;this._pools.length<=e;)this._pools.push([]);var r=this._pools[e];if(0===r.length)return t.cindex=e,0;if(this.pathCheck(0,t,r))return t.cindex=e,0;for(var i=0,n=0;nthis._height);n++)if(this.pathCheck(i,t,r))return t.cindex=e,i;return this.assign(t,e+1)},t.prototype.add=function(t){t.height>this._height?(t.cindex=-2,t.y=0):(t.y=this.assign(t,0),BinArray.binsert(this._pools[t.cindex],t,function(t,e){return t.bottome.bottom?1:0}))},t.prototype.remove=function(t){if(!(t.cindex<0)){if(t.cindex>=this._pools.length)throw new Error("cindex out of bounds");var e=this._pools[t.cindex].indexOf(t);e<0||this._pools[t.cindex].splice(e,1)}},t.prototype.setBounds=function(t,e){this._width=t,this._height=e},t}()),AnchorCommentSpaceAllocator=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.add=function(t){e.prototype.add.call(this,t),t.x=(this._width-t.width)/2},t.prototype.willCollide=function(t,e){return!0},t.prototype.pathCheck=function(t,e,r){for(var i=t+e.height,n=0;ni||r[n].bottom":return n>t.value;case"~":case"regexp":return new RegExp(t.value).test(n.toString());case"=":case"eq":return t.value===("number"==typeof n?n:n.toString());case"!":case"not":return!e(t.value,n);case"&&":case"and":return!!Array.isArray(t.value)&&t.value.every(function(t){return e(t,n)});case"||":case"or":return!!Array.isArray(t.value)&&t.value.some(function(t){return e(t,n)});default:return!1}}(t,r)}catch(t){e=!1}return"accept"===t.mode?e:!e}))},t.prototype.addRule=function(t){if("accept"!==t.mode&&"reject"!==t.mode)throw new Error("Rule must be of accept type or reject type.");this.rules.push(t)},t.prototype.removeRule=function(t){var e=this.rules.indexOf(t);return 0<=e&&(this.rules.splice(e,1),!0)},t.prototype.addModifier=function(t){if("function"!=typeof t)throw new Error("Modifiers need to be functions.");this.modifiers.push(t)},t}(),CommentProvider=function(){function n(){this._started=!1,this._destroyed=!1,this._staticSources={},this._dynamicSources={},this._parsers={},this._targets=[]}return n.SOURCE_JSON="JSON",n.SOURCE_XML="XML",n.SOURCE_TEXT="TEXT",n.BaseHttpProvider=function(s,a,h,l,c){return new Promise(function(t,e){var r=new XMLHttpRequest,i=a;if(l&&("POST"===s||"PUT"===s)){i+="?";var n=[];for(var o in l)l.hasOwnProperty(o)&&n.push(encodeURIComponent(o)+"="+encodeURIComponent(l[o]));i+=n.join("&")}r.onload=function(){200<=this.status&&this.status<300?t(this.response):e(new Error(this.status+" "+this.statusText))},r.onerror=function(){e(new Error(this.status+" "+this.statusText))},r.open(s,i),r.responseType="string"==typeof h?h:"",void 0!==c?r.send(c):r.send()})},n.JSONProvider=function(t,e,r,i){return n.BaseHttpProvider(t,e,"json",r,i).then(function(t){return t})},n.XMLProvider=function(t,e,r,i){return n.BaseHttpProvider(t,e,"document",r,i).then(function(t){return t})},n.TextProvider=function(t,e,r,i){return n.BaseHttpProvider(t,e,"text",r,i).then(function(t){return t})},n.prototype.addStaticSource=function(t,e){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more sources.");return e in this._staticSources||(this._staticSources[e]=[]),this._staticSources[e].push(t),this},n.prototype.addDynamicSource=function(t,e){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more sources.");return e in this._dynamicSources||(this._dynamicSources[e]=[]),this._dynamicSources[e].push(t),this},n.prototype.addTarget=function(t){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more targets.");if(!(t instanceof CommentManager))throw new Error("Expected the target to be an instance of CommentManager.");return this._targets.push(t),this},n.prototype.addParser=function(t,e){if(this._destroyed)throw new Error("Comment provider has been destroyed, cannot attach more parsers.");return e in this._parsers||(this._parsers[e]=[]),this._parsers[e].unshift(t),this},n.prototype.applyParsersOne=function(n,o){return new Promise(function(t,e){if(o in this._parsers){for(var r=0;r 0){ - if(channels[channel].listeners.length >= channels[channel].max){ - return false; - } - } - channels[channel].listeners.push(listener); - return true; - }; - - var dispatchMessage = function(msg){ - if(channels[msg.channel] && channels[msg.channel].listeners){ - for(var i = 0; i < channels[msg.channel].listeners.length; i++){ - channels[msg.channel].listeners[i](msg.payload); - } - }else{ - scripter.logger.warn("Message for channel \"" + msg.channel + - "\" but channel not existant."); - } - }; - - var WorkerHook = function(event){ - try{ - var resp = JSON.parse(event.data); - } catch(e) { - if (e.stack) { - scripter.logger.error(e.stack); - } else { - scripter.logger.error(e); - } - return; - } - if(resp.channel === ""){ - switch(resp.mode){ - case "log": - default:{ - scripter.logger.log(resp.obj); - break; - } - case "warn":{ - scripter.logger.warn(resp.obj); - break; - } - case "err":{ - scripter.logger.error(resp.obj); - break; - } - case "fatal":{ - scripter.logger.error(resp.obj); - sandbox.resetWorker(); - return; - } - }; - return; - } - if(resp.channel.substring(0,8) === "::worker"){ - var RN = resp.channel.substring(8); - switch(RN){ - case ":state":{ - if(resp.payload === "running" && resp.auth === "worker"){ - isRunning = true; - channels = {}; - sandbox.init(); - } - break; - } - case ':debug':{ - scripter.logger.log(JSON.stringify(resp.payload)); - break; - } - default:{ - scripter.logger.log(JSON.stringify(resp)); - break; - } - } - }else{ - dispatchMessage(resp); - } - }; - - this.resetWorker = function(){ - try{ - worker.terminate(); - } catch(e) { - - } - worker = scripter.getWorker(); - if(!worker){ - throw new Error("SANDBOX: Worker pool exhausted."); - } - worker.addEventListener("message", WorkerHook); - }; - - worker.addEventListener("message", WorkerHook); - - this.eval = function(code){ - // Pushes the code to be evaluated on the Worker - if(!isRunning){ - throw new Error("Worker offline"); - } - worker.postMessage(JSON.stringify({ - "channel":"::eval", - "payload":code - })); - }; - - this.send = function(channel, payload){ - // Low level send - worker.postMessage(JSON.stringify({ - "channel":channel, - "payload":payload - })); - }; - }; - CCLScripting.prototype.BridgedSandbox.prototype.init = function(){ - var self = this; - /** Post whatever we need to **/ - self.send("Update:DimensionUpdate", self.getContext().getDimensions()); - /** Hook Listeners **/ - this.addListener("Runtime::alert", function(msg){ - alert(msg); - }); - this.addListener("Runtime::clear", function(){ - self.getContext().clear(); - }); - this.addListener("Player::action", function(msg){ - try{ - if(self.getPlayer() == null){ - self.getLogger().warn("Player not initialized!"); - return; - }; - switch(msg.action){ - default:return; - case "play": self.getPlayer().play();break; - case "pause": self.getPlayer().pause();break; - case "seek": self.getPlayer().seek(msg.params);break; - case "jump": self.getPlayer().jump(msg.params);break; - } - }catch(e){ - if(e.stack){ - self.getLogger().error(e.stack); - }else{ - self.getLogger().error(e.toString()); - } - } - }); - this.addListener("Runtime:RegisterObject", function(pl){ - self.getContext().registerObject(pl.id, pl.data); - }); - this.addListener("Runtime:DeregisterObject", function(pl){ - self.getContext().deregisterObject(pl.id); - }); - this.addListener("Runtime:CallMethod", function(pl){ - self.getContext().callMethod(pl.id, pl.method, pl.params); - }); - this.addListener("Runtime:UpdateProperty", function(pl){ - self.getContext().updateProperty(pl.id, pl.name, pl.value); - }); - self.getContext().registerObject("__root", {"class":"SpriteRoot"}); - }; -})(); - -/** Define some Unpackers **/ -(function(){ - /** This is the DOM Manipulation Library **/ - var _ = function (type, props, children, callback) { - var elem = null; - if (type === "text") { - return document.createTextNode(props); - } else if(type === "svg"){ - elem = document.createElementNS("http://www.w3.org/2000/svg", "svg"); - }else { - elem = document.createElement(type); - } - for(var n in props){ - if(n !== "style" && n !== "className"){ - elem.setAttribute(n, props[n]); - }else if(n === "className"){ - elem.className = props[n]; - }else{ - for(var x in props.style){ - elem.style[x] = props.style[x]; - } - } - } - if (children) { - for(var i = 0; i < children.length; i++){ - if(children[i] != null) - elem.appendChild(children[i]); - } - } - if (callback && typeof callback === "function") { - callback(elem); - } - return elem; - }; - var ScriptingContext = CCLScripting.prototype.ScriptingContext; - ScriptingContext.prototype.Unpack.TextField = function(stage, data, ctx){ - this.DOM = _("div",{ - "style":{ - "position":"absolute", - "opacity":data.alpha != null ? data.alpha : 1, - "transformOrigin":"0 0 0" - }, - "className":"cmt" - }); - /** Load the text **/ - this.DOM.appendChild(document.createTextNode(data.text)); - var getColor = function(c){ - if(typeof c === "string"){ - c = parseInt(c); - if(c === NaN){ - c = 0; - } - } - var color = c.toString(16); - while(color.length < 6){ - color = "0" + color; - } - return "#" + color; - }; - this.setTextFormat = function(textFormat){ - this.DOM.style.fontFamily = textFormat.font; - this.DOM.style.fontSize = textFormat.size + "px"; - this.DOM.style.color = getColor(textFormat.color); - if(textFormat.color <= 16){ - this.DOM.style.textShadow = "0 0 1px #fff"; - }; - if(textFormat.bold) - this.DOM.style.fontWeight = "bold"; - if(textFormat.underline) - this.DOM.style.textDecoration = "underline"; - if(textFormat.italic) - this.DOM.style.fontStyle = "italic"; - this.DOM.style.margin = textFormat.margin; - }; - /** Load the text format **/ - this.setTextFormat(data.textFormat); - - this.setX = function(x){ - data.x = x; - this.DOM.style.left = data.x + "px"; - }; - - this.setY = function(y){ - data.y = y; - this.DOM.style.top = data.y + "px"; - }; - this.setAlpha = function(a){ - data.alpha = a; - this.DOM.style.opacity = a; - } - /** Load x,y **/ - this.setX(data.x); - this.setY(data.y); - - /** Other **/ - this.setText = function(text){ - this.DOM.innerHTML = ""; - this.DOM.appendChild(_("text",text)); - }; - this.__defineSetter__("visible", function(f){ - this.DOM.style.visibility = f ? "visible" : "hidden"; - }); - this.__defineGetter__("visible", function(f){ - return this.DOM.style.visibility === "hidden" ? false : true; - }); - this.__defineSetter__("alpha", function(f){ - this.setAlpha(f); - }); - this.__defineGetter__("alpha", function(f){ - return data.alpha; - }); - this.__defineSetter__("x", function(f){ - this.setX(f); - }); - this.__defineSetter__("y", function(f){ - this.setY(f); - }); - this.__defineGetter__("x", function(f){ - return data.x; - }); - this.__defineGetter__("y", function(f){ - return data.y; - }); - this.__defineGetter__("text", function(f){ - return this.DOM.textContent; - }); - this.__defineSetter__("text", function(f){ - this.setText(f); - }); - this.__defineGetter__("filters", function(f){ - return []; - }); - this.__defineSetter__("filters", function(f){ - this.setFilters([f]); - }); - - this.__defineGetter__("transform", function(f){ - return {}; - }); - this.__defineGetter__("transform", function(f){ - return {}; - }); - this.__defineSetter__("transform", function(f){ - if(f.mode === "2d"){ - var rm = [f.matrix[0],f.matrix[3], f.matrix[1], f.matrix[4], f.matrix[2], f.matrix[5]]; - var _transform = "matrix(" + (rm.join(",")) + ")"; - }else{ - var _transform = "matrix3d(" + (f.matrix.join(",")) + ")"; - } - this.DOM.style.transform = _transform; - }); - this.setFilters = function(params){ - var shadows = []; - for(var i = 0; i < params[0].length; i++){ - var filter = params[0][i]; - if(filter.type === "blur"){ - //this.DOM.style.color = "transparent"; - shadows.push([0,0, Math.max( - filter.params.blurX, filter.params.blurY) + - "px"].join(" ")); - }else if(filter.type === "glow"){ - for(var i = 0; i < Math.min(2, filter.params.strength); i++){ - shadows.push([0,0, Math.max( - filter.params.blurX, filter.params.blurY) + - "px", getColor(filter.params.color)].join(" ")); - } - } - }; - this.DOM.style.textShadow = shadows.join(","); - }; - - /** Common **/ - this.unload = function(){ - try{ - stage.removeChild(this.DOM); - }catch(e){}; - }; - // Hook child - stage.appendChild(this.DOM); - }; - - ScriptingContext.prototype.Unpack.Shape = function(stage, data, ctx){ - this.DOM = _("svg",{ - "width":stage.offsetWidth * 2, - "height":stage.offsetHeight * 2, - "style":{ - "position":"absolute", - "top":"0px", - "left":"0px", - "width":(stage.offsetWidth * 2) + "px", - "height":(stage.offsetWidth * 2) + "px", - "transform":"matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)" - } - }); - this._x = data.x ? data.x : 0; - this._y = data.y ? data.y : 0; - this._alpha = data.alpha ? data.alpha : 1; - this._transform = ""; - - // Helpers - var __ = function(e, attr){ - if(typeof e === "string"){ - var elem = - document.createElementNS("http://www.w3.org/2000/svg",e); - }else{ - var elem = e; - } - if(attr){ - for(var x in attr){ - elem.setAttribute(x, attr[x]); - } - } - return elem; - }; - - var globalDefs = __('defs'); - var defaultEffects = __("defs"); - var defaultGroup = __("g",{ - }); - var defaultContainer = __("g",{ - "transform":"translate(" + this._x + "," + this._y + ")", - "opacity":this._alpha, - }); - - defaultContainer.appendChild(defaultGroup); - var defaultGroupWithEffects = defaultContainer; - this.DOM.appendChild(globalDefs); - this.DOM.appendChild(defaultEffects); - this.DOM.appendChild(defaultGroupWithEffects); - /** PROPS **/ - this.__defineSetter__("visible", function(f){ - this.DOM.style.visibility = f ? "visible" : "hidden"; - }); - this.__defineGetter__("visible", function(f){ - return this.DOM.style.visibility === "hidden" ? false : true; - }); - this.__defineSetter__("x", function(f){ - this.setX(f); - }); - this.__defineSetter__("y", function(f){ - this.setY(f); - }); - this.__defineSetter__("alpha", function(f){ - this.setAlpha(f); - }); - this.__defineSetter__("blendMode", function(f){ - this.DOM.style.backgroundBlendMode = f; - this.DOM.style.mixBlendMode = f; - }); - this.__defineGetter__("blendMode", function(f){ - return ''; - }); - this.__defineGetter__("x", function(f){ - return this._x; - }); - this.__defineGetter__("y", function(f){ - return this._y; - }); - this.__defineGetter__("alpha", function(f){ - return this._alpha; - }); - this.__defineGetter__("transform", function(f){ - return {}; - }); - this.__defineSetter__("transform", function(f){ - if(f.mode === "2d"){ - var rm = [f.matrix[0],f.matrix[3], f.matrix[1], f.matrix[4], f.matrix[2], f.matrix[5]]; - this._transform = "matrix(" + (rm.join(",")) + ")"; - }else{ - this._transform = "matrix3d(" + (f.matrix.join(",")) + ")"; - } - if(f.mode === "2d"){ - this.DOM.style.transform = "matrix(1,0,0,1,0,0)"; - __(defaultGroup,{ - "transform":this._transform - }); - }else{ - // We must resort to HTML - this.DOM.style.transformOrigin = (this._x + offsetX) + "px " + (this._y + offsetY) + "px 0"; - this.DOM.style.transform = this._transform; - } - }); - /** /PROPS **/ - - this.line = { - width:0, - color:"#ffffff", - alpha:1 - }; - this.fill = { - fill:"none", - alpha:1, - fillRule:"nonzero" - }; - var toRGB = function(number){ - var string = parseInt(number).toString(16); - while(string.length < 6){ - string = "0" + string; - } - return "#" + string; - }; - var applyStroke = function(p, ref){ - __(p, { - "stroke": ref.line.color, - "stroke-width": ref.line.width, - "stroke-opacity": ref.line.alpha - }); - if(ref.line.caps){ - p.setAttribute("stroke-linecap", ref.line.caps); - } - if(ref.line.joints){ - p.setAttribute("stroke-linejoin", ref.line.joints); - } - if(ref.line.miterLimit){ - p.setAttribute("stroke-miterlimit", ref.line.miterLimit); - } - }; - - var applyFill = function(p, ref){ - __(p, { - "fill": ref.fill.fill, - "fill-opacity": ref.fill.alpha, - "fill-rule": ref.fill.fillRule - }); - }; - - var state = { - lastPath : null, - scheduleClear: [], - }; - /** Offsets for canvas **/ - var offsetX = 0, offsetY = 0; - - this.offset = function(x,y){ - offsetX = x; - offsetY = y; - __(defaultContainer,{ - "transform":"translate(" + (this._x + offsetX) + "," + (this._y + offsetY) + ")" - }); - }; - /** Public methods **/ - this.setX = function(x){ - if(!x) - return; - this._x = x; - __(defaultContainer,{ - "transform":"translate(" + (this._x + offsetX) + "," + (this._y + offsetY) + ")" - }); - }; - this.setY = function(y){ - if(!y) - return; - this._y = y; - __(defaultContainer,{ - "transform":"translate(" + (this._x + offsetX) + "," + (this._y + offsetY) + ")" - }); - }; - this.setAlpha = function(alpha){ - if(!alpha) - return; - this._alpha = alpha; - __(defaultContainer,{ - "opacity":this._alpha - }); - }; - this.moveTo = function(params){ - var p = __("path",{ - "d":"M" + params.join(" ") - }); - applyFill(p, this); - state.lastPath = p; - applyStroke(p, this); - defaultGroup.appendChild(state.lastPath); - }; - this.lineTo = function(params){ - if(!state.lastPath){ - state.lastPath = __("path",{ - "d":"M0 0" - }); - applyFill(state.lastPath, this); - applyStroke(state.lastPath, this); - defaultGroup.appendChild(state.lastPath); - } - __(state.lastPath,{ - "d": state.lastPath.getAttribute("d") + " L" + params.join(" ") - }); - }; - this.curveTo = function(params){ - if(!state.lastPath){ - state.lastPath = __("path",{ - "d":"M0 0" - }); - applyFill(state.lastPath, this); - applyStroke(state.lastPath, this); - defaultGroup.appendChild(state.lastPath); - } - __(state.lastPath,{ - "d": state.lastPath.getAttribute("d") + " Q" + params.join(" ") - }); - }; - this.lineStyle = function(params){ - if(params.length < 3) - return; - this.line.width = params[0]; - this.line.color = toRGB(params[1]); - this.line.alpha = params[2]; - if(params[3]){ - this.line.caps = params[3]; - } - if(params[4]){ - this.line.joints = params[4]; - } - if(params[5]){ - this.line.miterLimit = params[5]; - } - if(state.lastPath){ - applyStroke(state.lastPath, this); - } - }; - this.drawPath = function(params){ - var commands = params[0]; - var data = params[1]; - this.fill.fillRule = (params[2] === "nonZero" ? "nonzero" : "evenodd"); - var d = "M0 0"; - for(var i = 0; i < commands.length; i++){ - switch(commands[i]){ - default: - case 0:{ - /* NoOp x0 */ - continue; - }break; - case 1: { - /* MoveTo x2 */ - d += " M" + data.splice(0,2).join(" "); - }break; - case 2: { - /* LineTo x2 */ - d += " L" + data.splice(0,2).join(" "); - }break; - case 3: { - /* CurveTo x4 */ - d += " Q" + data.splice(0,4).join(" "); - }break; - case 4: { - /* wide MoveTo x4 */ - data.splice(0,2); - d += " M" + data.splice(0,2).join(" "); - }break; - case 5: { - /* wide LineTo x4 */ - data.splice(0,2); - d += " L" + data.splice(0,2).join(" "); - }break; - case 6: { - /* CubicCurveTo x6 */ - d += " C" + data.splice(0,6).join(" "); - }break; - } - }; - var path = __("path",{ - "d": d - }); - applyFill(path, this); - applyStroke(path, this); - defaultGroup.appendChild(path); - this._clear(); - }; - this.beginFill = function(params){ - if(params.length === 0) - return; - this.fill.fill = toRGB(params[0]); - if(params.length > 1){ - this.fill.alpha = params[1]; - } - }; - this.beginGradientFill = function(params) { - if(params.length === 0) { - return; - } - var gradId = 'gradient-' + params[0] + '-' + globalDefs.childNodes.length; - var grad; - if (params[0] === 'linear') { - grad = __('linearGradient', {'id': gradId, 'spreadMethod': params[5]}); - } else { - grad = __('radialGradient', {'id': gradId, 'spreadMethod': params[5]}); - } - // Figure out all the stops - var colors = params[1]; - var alphas = params[2]; - var ratios = params[3]; - for (var i = 0; i < ratios.length; i++) { - grad.appendChild(__('stop', { - 'offset': ratios[i] / 255, - 'stop-color': toRGB(colors[i]), - 'stop-opacity': alphas[i] - })); - } - globalDefs.appendChild(grad); - this.fill.fill = 'url(#' + gradId + ')'; - }; - this.endFill = function(params){ - this.fill.fill = "none"; - }; - this.drawRect = function(params){ - if(state.drawing) - console.log(state.drawing); - if(params[2] < 0){ - params[0] += params[2]; - params[2] = -params[2]; - } - if(params[3] < 0){ - params[1] += params[3]; - params[3] = -params[3]; - } - var r = __("rect",{ - "x": params[0], - "y": params[1], - "width": params[2], - "height": params[3] - }); - applyFill(r, this); - applyStroke(r, this); - defaultGroup.appendChild(r); - }; - this.drawRoundRect = function(params){ - var r = __("rect",{ - "x": params[0], - "y": params[1], - "width": params[2], - "height": params[3], - "rx":params[4], - "ry":params[5] - }); - applyFill(r, this); - applyStroke(r, this); - defaultGroup.appendChild(r); - }; - this.drawCircle = function(params){ - var c = __("circle",{ - "cx": params[0], - "cy": params[1], - "r": params[2] - }); - applyFill(c, this); - applyStroke(c, this); - defaultGroup.appendChild(c); - }; - - this.drawEllipse = function(params){ - var e = __("ellipse",{ - "cx": params[0], - "cy": params[1], - "rx": params[2], - "ry": params[3] - }); - applyFill(e, this); - applyStroke(e, this); - defaultGroup.appendChild(e); - }; - - this.drawTriangles = function(params){ - if(params[1].length % 3 !== 0){ - throw new Error("Illegal drawTriangles index argument. Indices array size must be a multiple of 3."); - } - var commands = [], data = []; - for(var i = 0; i < params[1].length / 3; i++){ - var a = params[1][3 * i], - b = params[1][3 * i + 1], - c = params[1][3 * i + 2]; - var ax = params[0][2 * a], ay = params[0][2 * a + 1]; - var bx = params[0][2 * b], by = params[0][2 * b + 1]; - var cx = params[0][2 * c], cy = params[0][2 * c + 1]; - commands.push(1,2,2,2); - data.push(ax,ay,bx,by,cx,cy,ax,ay); - } - this.drawPath([commands,data,"evenOdd"]); - }; - - this._clear = function(){ - if(state.scheduleClear.length < 1) - return; - if(state.scheduleTimer > -1){ - clearTimeout(state.scheduleTimer); - state.scheduleTimer = -1; - } - while (defaultGroup.lastChild && state.scheduleClear.length > 0) { - defaultGroup.removeChild(state.scheduleClear.pop()); - } - state.scheduleClear = []; - }; - - this.clear = function(){ - var children = defaultGroup.children ? defaultGroup.children : defaultGroup.childNodes; - for (var i = 0; i < children.length; i++) { - state.scheduleClear.push(children[i]); - } - var self = this; - state.scheduleTimer = setTimeout(function(){ - self._clear(); - state.scheduleTimer = -1; - }, 60); - }; - - this.__defineGetter__("filters", function(f){ - return []; - }); - this.__defineSetter__("filters", function(f){ - this.setFilters([f]); - }); - this.setFilters = function(params){ - var filters = params[0]; - this.DOM.removeChild(defaultEffects); - defaultEffects = __("defs"); - for(var i = 0; i < filters.length; i++){ - var filter = filters[i]; - var dFilter = __("filter",{ - "id":"fe" + filter.type + i, - "x":"-50%", - "y":"-50%", - "width":"200%", - "height":"200%" - }); - switch(filter.type){ - default:break; - case "blur":{ - dFilter.appendChild(__("feGaussianBlur",{ - "in":"SourceGraphic", - "stdDeviation":filter.params.blurX + " " - + filter.params.blurY, - })); - }break; - case "glow":{ - var cR = Math.floor(filter.params.color / 65536), - cG = Math.floor((filter.params.color % 65536)/256), - cB = filter.params.color % 256; - var cMatrix = [ - 0,0,0,cR/256,0, - 0,0,0,cG/256,0, - 0,0,0,cB/256,0, - 0,0,0,1,0, - ]; - dFilter.appendChild(__("feColorMatrix",{ - "type":"matrix", - "values": cMatrix.join(" ") - })); - dFilter.appendChild(__("feGaussianBlur",{ - "stdDeviation":filter.params.blurX + " " - + filter.params.blurY, - "result":"coloredBlur" - })); - var m = __("feMerge"); - m.appendChild(__("feMergeNode",{ - "in":"coloredBlur" - })); - m.appendChild(__("feMergeNode",{ - "in":"SourceGraphic" - })); - dFilter.appendChild(m); - }break; - } - defaultEffects.appendChild(dFilter); - }; - // Add new filters - this.DOM.appendChild(defaultEffects); - // Apply filters - this.DOM.removeChild(defaultGroupWithEffects); - var tGroup = defaultContainer; - for(var i = 0; i < filters.length; i++){ - var layeredG = __("g",{ - "filter":"url(#" + "fe" + filters[i].type + i + ")" - }); - layeredG.appendChild(tGroup); - tGroup = layeredG; - } - this.DOM.appendChild(tGroup); - defaultGroupWithEffects = tGroup; - }; - - this.unload = function(){ - try{ - stage.removeChild(this.DOM); - }catch(e){}; - }; - // Hook Child - stage.appendChild(this.DOM); - }; - - ScriptingContext.prototype.Unpack.Sprite = function(stage, data, ctx){ - this.DOM = _("div",{"style":{ - "position":"absolute", - "top": data.y ? data.y + "px" : "0px", - "left": data.x ? data.x + "px" : "0px", - "width":"100%", - "height":"100%", - "overflow":"visible", - "transformOrigin":"0 0 0" - }}); - - data.scaleX = 1; - data.scaleY = 1; - data.children = []; - this.__defineSetter__("visible", function(f){ - this.DOM.style.visibility = f ? "visible" : "hidden"; - }); - this.__defineGetter__("visible", function(f){ - return this.DOM.style.visibility === "hidden" ? false : true; - }); - this.__defineSetter__("alpha", function(f){ - this.DOM.style.opacity = f; - }); - this.__defineGetter__("alpha", function(f){ - return this.DOM.style.opacity; - }); - - this.__defineSetter__("x", function(f){ - this.setX(f); - }); - this.__defineSetter__("y", function(f){ - this.setY(f); - }); - this.__defineSetter__("blendMode", function(f){ - this.DOM.style.backgroundBlendMode = f; - this.DOM.style.mixBlendMode = f; - }); - this.__defineGetter__("blendMode", function(f){ - return ''; - }); - this.__defineGetter__("x", function(f){ - return this.DOM.offsetLeft; - }); - this.__defineGetter__("y", function(f){ - return this.DOM.offsetTop; - }); - this.__defineGetter__("transform", function(f){ - return {}; - }); - this.__defineSetter__("transform", function(f){ - if(f.mode === "2d"){ - var rm = [f.matrix[0],f.matrix[3], f.matrix[1], f.matrix[4], f.matrix[2], f.matrix[5]]; - var _transform = "matrix(" + (rm.join(",")) + ")"; - }else{ - var _transform = "matrix3d(" + (f.matrix.join(",")) + ")"; - } - this.DOM.style.transform = _transform; - }); - this.setX = function(x){ - this.DOM.style.left = x + "px"; - }; - - this.setY = function(y){ - this.DOM.style.top = y + "px"; - }; - - this.setWidth = function(width){ - this.DOM.style.width = width + "px"; - }; - - this.setHeight = function(height){ - this.DOM.style.height = height + "px"; - }; - - this.addChild = function(childitem){ - var child = ctx.getObject(childitem); - data.children.push(child); - if(!child) - return; - if(child.DOM){ - if(child.getClass() === "Shape"){ - var tX = this.x + (stage.offsetWidth / 2), tY = this.y + (stage.offsetHeight / 2); - child.offset(tX, tY); - child.DOM.style.left = -tX+ "px"; - child.DOM.style.top = -tY+ "px"; - } - this.DOM.appendChild(child.DOM); - }else{ - ctx.invokeError("Sprite.addChild failed. Attempted to add non object","err"); - } - }; - - this.removeChild = function(childitem){ - var child = ctx.getObject(childitem); - if(!child) - return; - try{ - this.DOM.removeChild(child.DOM); - }catch(e){ - ctx.invokeError(e.stack, "err"); - } - }; - - this.unload = function(){ - try{ - stage.removeChild(this.DOM); - }catch(e){}; - }; - // Hook child - stage.appendChild(this.DOM); - } - - ScriptingContext.prototype.Unpack.SpriteRoot = function(stage, data, ctx){ - this.DOM = stage; - this.addChild = function(childitem){ - var child = ctx.getObject(childitem); - if(!child) - return; - if(child.DOM){ - if(child.getClass() === "Shape"){ - var tX = (stage.offsetWidth / 2), tY = (stage.offsetHeight / 2); - child.offset(tX, tY); - child.DOM.style.left = -tX+ "px"; - child.DOM.style.top = -tY+ "px"; - } - this.DOM.appendChild(child.DOM); - }else{ - ctx.invokeError("Sprite.addChild failed. Attempted to add non object","err"); - } - }; - - this.removeChild = function(childitem){ - var child = ctx.getObject(childitem); - if(!child) - return; - try{ - this.DOM.removeChild(child.DOM); - }catch(e){ - ctx.invokeError(e.stack, "err"); - } - }; - }; - - ScriptingContext.prototype.Unpack.Button = function(stage, data, ctx){ - this.DOM = _("div",{ - "className":"button", - "style":{ - "position":"absolute", - "top": data.y ? data.y + "px" : "0px", - "left": data.x ? data.x + "px" : "0px" - } - },[_("text", data.text)]); - - data.scaleX = 1; - data.scaleY = 1; - this.__defineSetter__("visible", function(f){ - this.DOM.style.visibility = f ? "visible" : "hidden"; - }); - this.__defineGetter__("visible", function(f){ - return this.DOM.style.visibility === "hidden" ? false : true; - }); - this.__defineGetter__("transform", function(f){ - return {}; - }); - this.__defineSetter__("transform", function(f){ - //if(f.mode === "2d"){ - // this.DOM.style.transform = "matrix(" + (f.matrix.slice(0,6).join(",")) + ")"; - //}else{ - // this.DOM.style.transform = "matrix3d(" + (f.matrix.join(",")) + ")"; - //} - }); - this.__defineSetter__("filters", function(f){ - // Ignore now - }); - this.__defineGetter__("filters", function(f){ - return []; - }); - this.__defineSetter__("alpha", function(f){ - data.alpha = Math.min(Math.max(f,0),1); - this.DOM.style.opacity = data.alpha + ""; - }); - this.__defineGetter__("alpha", function(f){ - return data.alpha !== undefined ? data.alpha : 1; - }); - this.__defineSetter__("scaleX", function(f){ - if(f > 50) - return; - data.scaleX = f; - for(var i = 0; i < this.DOM.children.length; i++){ - this.DOM.children[i].style.transform = "scale(" + data.scaleX + "," + data.scaleY + ")"; - } - }); - this.__defineSetter__("scaleY", function(f){ - if(f > 50) - return; - data.scaleY = f; - for(var i = 0; i < this.DOM.children.length; i++){ - this.DOM.children[i].style.transform = "scale(" + data.scaleX + "," + data.scaleY + ")"; - } - }); - this.__defineGetter__("scaleX", function(f){ - return data.scaleX; - }); - this.__defineGetter__("scaleY", function(f){ - return data.scaleY; - }); - - this.__defineSetter__("x", function(f){ - this.setX(f); - }); - this.__defineSetter__("y", function(f){ - this.setY(f); - }); - this.__defineGetter__("x", function(f){ - return this.DOM.offsetLeft; - }); - this.__defineGetter__("y", function(f){ - return this.DOM.offsetTop; - }); - - this.setX = function(x){ - this.DOM.style.left = x + "px"; - }; - - this.setY = function(y){ - this.DOM.style.top = y + "px"; - }; - - this.setWidth = function(width){ - this.DOM.style.width = width + "px"; - }; - - this.setHeight = function(height){ - this.DOM.style.height = height + "px"; - }; - - this.addChild = function(childitem){ - var child = ctx.getObject(childitem); - if(!child) - return; - if(child.DOM){ - if(child.getClass() === "Shape"){ - child.DOM.style.left = -this.x + "px"; - child.DOM.style.top = -this.y + "px"; - child.setX(this.x); - child.setY(this.y); - } - this.DOM.appendChild(child.DOM); - }else{ - ctx.invokeError("Sprite.addChild failed. Attempted to add non object","err"); - } - }; - - this.removeChild = function(childitem){ - var child = ctx.getObject(childitem); - if(!child) - return; - try{ - this.DOM.removeChild(child.DOM); - }catch(e){ - ctx.invokeError(e.stack, "err"); - } - }; - - this.unload = function(){ - try{ - stage.removeChild(this.DOM); - }catch(e){}; - }; - // Hook child - stage.appendChild(this.DOM); - } - - // Load all the getClass Prototypes - for(var cl in ScriptingContext.prototype.Unpack){ - ScriptingContext.prototype.Unpack[cl].prototype.getClass = (function(){ - var n = cl; - return function(){ - return n; - } - })(); - } -})(); diff --git a/dist/scripting/OOAPI.js b/dist/scripting/OOAPI.js deleted file mode 100644 index 4f72485..0000000 --- a/dist/scripting/OOAPI.js +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Out-of-API Methods - * @license MIT - * @description This is the definition bridge for OOAPI methods. - * Please always include it - **/ -var __OOAPI = new function () { - var channels = {}; - - function dispatchMessage (msg) { - if (channels.hasOwnProperty(msg.channel)) { - for(var i = 0; i < channels[msg.channel].listeners.length; i++) { - try { - channels[msg.channel].listeners[i](msg.payload); - } catch(e) { - if (e.stack) { - __trace(e.stack.toString(), 'err'); - } else { - __trace(e.toString(), 'err'); - } - } - } - } else { - __trace('Got message on channel "' + msg.channel + - '" but channel does not exist.', 'warn'); - } - }; - - self.addEventListener('message', function (event) { - if (!event) { - return; - } - try { - var msg = JSON.parse(event.data); - } catch (e) { - __trace(e, 'err'); - return; - } - if (msg !== null && msg.hasOwnProperty('channel') && - typeof msg.channel === 'string') { - dispatchMessage(msg); - } else { - __trace(msg, 'warn'); - } - }); - - this.listChannels = function () { - var chl = {}; - for (var chan in channels) { - chl[chan] = { - 'max': channels[chan].max, - 'listeners': channels[chan].listeners.length - }; - } - return chl; - }; - - this.deleteChannel = function (channelId, authToken){ - if (!(channelId in channels)) { - return true; - } - if (authToken || channels[channelId].auth) { - if (authToken === channels[channelId].auth) { - delete channels[channelId]; - return true; - } - return false; - } else { - delete channels[channelId]; - return true; - } - }; - - this.createChannel = function (channelId, maximum, authToken) { - if (!(channelId in channels)) { - channels[channelId] = { - 'max': maximum ? maximum : 0, - 'auth': authToken, - 'listeners': [] - }; - return true; - } - return false; - }; - - this.addListenerChannel = function (channel, listener) { - if (!(channel in channels)) { - channels[channel] = { - 'max': 0, - 'listeners': [] - }; - } - if (channels[channel].max > 0) { - if (channels[channel].listeners.length >= - channels[channel].max) { - return false; - } - } - channels[channel].listeners.push(listener); - return true; - }; -}; - -function __trace (obj, traceMode) { - self.postMessage(JSON.stringify({ - 'channel': '', - 'obj': obj, - 'mode': (traceMode ? traceMode : 'log') - })); -}; - -function __channel (id, payload, callback) { - self.postMessage(JSON.stringify({ - 'channel': id, - 'payload': payload, - 'callback': true - })); - __OOAPI.addListenerChannel(id, callback); -}; - -function __schannel (id, callback) { - __OOAPI.addListenerChannel(id, callback); -}; - -function __pchannel (id, payload) { - self.postMessage(JSON.stringify({ - 'channel': id, - 'payload': payload, - 'callback': false - })); -}; - -function __achannel (id, auth, payload) { - self.postMessage(JSON.stringify({ - 'channel': id, - 'auth': auth, - 'payload': payload, - 'callback': false - })); -}; diff --git a/dist/scripting/Worker.js b/dist/scripting/Worker.js deleted file mode 100644 index b85f070..0000000 --- a/dist/scripting/Worker.js +++ /dev/null @@ -1,55 +0,0 @@ -var __OOAPI; - -importScripts("OOAPI.js"); - -if (!__OOAPI) { - console.log("Error: OOAPI Not Loaded"); - self.close(); -} - -// Hook independent channels that cannot be removed -__OOAPI.createChannel("::eval", 1, Math.round(Math.random() * 100000)); -__OOAPI.createChannel("::debug", 1, Math.round(Math.random() * 100000)); - -// Load the BSE Abstraction Runtime -importScripts('api/Runtime.js', - 'api/Player.js', - 'api/Display.js', - 'api/Tween.js', - 'api/Utils.js', - 'api/Global.js', - 'api/Function.js'); - -// Immediately Hook into the eval channel, blocking future hooks -__schannel("::eval", function (msg) { - // Prevent some things from being accessed in eval easily - (function (__code, importScripts, postMessage, addEventListener, self) { - if (Tween && Tween.extendWithEasingFunctions) { - Tween.extendWithEasingFunctions(this); - } - var clearTimeout = Utils.clearTimeout; - var clearInterval = Utils.clearInterval; - eval(__code); - })(msg); -}); - -__schannel("::debug", function (msg) { - if (typeof msg === 'undefined' || msg === null || - !msg.hasOwnProperty('action')) { - __achannel('::worker:debug', 'worker', 'Malformed request'); - return; - } - if (msg.action === 'list-channels') { - __achannel('::worker:debug', 'worker', __OOAPI.listChannels()); - } else if (msg.action === 'raw-eval') { - try { - __achannel('::worker:debug', 'worker', eval(msg.code)); - } catch (e) { - __achannel('::worker:debug', 'worker', 'Error: ' + e); - } - } else { - __achannel('::worker:debug', 'worker', 'Unrecognized action'); - } -}); - -__achannel("::worker:state", "worker", "running"); diff --git a/dist/scripting/api/Display.js b/dist/scripting/api/Display.js deleted file mode 100644 index ce9a6da..0000000 --- a/dist/scripting/api/Display.js +++ /dev/null @@ -1,2930 +0,0 @@ -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var Display; -(function (Display) { - var Point = (function () { - function Point(x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - this.x = x; - this.y = y; - } - Object.defineProperty(Point.prototype, "length", { - get: function () { - return Math.sqrt(this.x * this.x + this.y * this.y); - }, - set: function (l) { - __trace('Point.length is read-only', 'err'); - }, - enumerable: true, - configurable: true - }); - Point.prototype.add = function (p) { - return new Point(p.x + this.x, p.y + this.y); - }; - Point.prototype.subtract = function (p) { - return new Point(this.x - p.x, this.y - p.y); - }; - Point.interpolate = function (a, b, f) { - return new Point((b.x - a.x) * f + a.x, (b.y - a.y) * f + a.y); - }; - Point.prototype.offset = function (dx, dy) { - this.x += dx; - this.y += dy; - }; - Point.prototype.normalize = function (thickness) { - var ratio = thickness / this.length; - this.x *= ratio; - this.y *= ratio; - }; - Point.polar = function (r, theta) { - return new Point(r * Math.cos(theta), r * Math.sin(theta)); - }; - Point.prototype.setTo = function (x, y) { - this.x = x; - this.y = y; - }; - Point.prototype.equals = function (p) { - if (p.x === this.x && p.y === this.y) { - return true; - } - return false; - }; - Point.prototype.toString = function () { - return '(x=' + this.x + ', y=' + this.y + ')'; - }; - Point.prototype.clone = function () { - return new Point(this.x, this.y); - }; - return Point; - }()); - Display.Point = Point; - var Matrix = (function () { - function Matrix(a, b, c, d, tx, ty) { - if (a === void 0) { a = 1; } - if (b === void 0) { b = 0; } - if (c === void 0) { c = 0; } - if (d === void 0) { d = 1; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - this._data = [a, c, tx, b, d, ty, 0, 0, 1]; - } - Matrix.prototype.dotProduct = function (o) { - if (o.length < 9) { - throw new Error('Matrix dot product expects a 3x3 Matrix'); - } - var res = [0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (var i = 0; i < 3; i++) { - for (var j = 0; j < 3; j++) { - for (var k = 0; k < 3; k++) { - res[i * 3 + j] += this._data[i * 3 + k] * o[k * 3 + j]; - } - } - } - return res; - }; - Matrix.prototype.setTo = function (a, b, c, d, tx, ty) { - if (a === void 0) { a = 1; } - if (b === void 0) { b = 0; } - if (c === void 0) { c = 0; } - if (d === void 0) { d = 1; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - this._data = [a, c, tx, b, d, ty, 0, 0, 1]; - }; - Matrix.prototype.translate = function (tX, tY) { - this._data[2] += tX; - this._data[5] += tY; - }; - Matrix.prototype.rotate = function (q) { - this._data = this.dotProduct([ - Math.cos(q), -Math.sin(q), 0, - Math.sin(q), Math.cos(q), 0, - 0, 0, 1 - ]); - }; - Matrix.prototype.scale = function (sx, sy) { - this._data = this.dotProduct([ - sx, 0, 0, - 0, sy, 0, - 0, 0, 1 - ]); - }; - Matrix.prototype.identity = function () { - this.setTo(1, 0, 0, 1, 0, 0); - }; - Matrix.prototype.createGradientBox = function (width, height, rotation, tX, tY) { - this.createBox(width, height, rotation, tX, tY); - }; - Matrix.prototype.createBox = function (sX, sY, q, tX, tY) { - this.identity(); - this.rotate(q); - this.scale(sX, sY); - this.translate(tX, tY); - }; - Matrix.prototype.clone = function () { - var a = this._data[0], b = this._data[3], c = this._data[1], d = this._data[4], tx = this._data[2], ty = this._data[5]; - return new Matrix(a, b, c, d, tx, ty); - }; - Matrix.prototype.serialize = function () { - return this._data; - }; - return Matrix; - }()); - Display.Matrix = Matrix; - var Matrix3D = (function () { - function Matrix3D(iv) { - if (iv === void 0) { iv = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; } - if (iv.length === 16) { - this._data = iv; - } - else if (iv.length === 0) { - this.identity(); - } - else { - __trace('Matrix3D initialization vector invalid', 'warn'); - this.identity(); - } - } - Matrix3D.prototype.dotProduct = function (a, b) { - if (a.length !== 16 || b.length !== 16) { - throw new Error('Matrix3D dot product expects a 4xr Matrix3D'); - } - var res = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (var i = 0; i < 4; i++) { - for (var j = 0; j < 4; j++) { - for (var k = 0; k < 4; k++) { - res[i * 4 + j] += a[i * 4 + k] * b[k * 4 + j]; - } - } - } - return res; - }; - Matrix3D.prototype.rotationMatrix = function (angle, axis) { - var sT = Math.sin(angle), cT = Math.cos(angle); - return [ - cT + axis.x * axis.x * (1 - cT), axis.x * axis.y * (1 - cT) - axis.z * sT, axis.x * axis.z * (1 - cT) + axis.y * sT, 0, - axis.x * axis.y * (1 - cT) + axis.z * sT, cT + axis.y * axis.y * (1 - cT), axis.y * axis.z * (1 - cT) - axis.x * sT, 0, - axis.z * axis.x * (1 - cT) - axis.y * sT, axis.z * axis.y * (1 - cT) + axis.x * sT, cT + axis.z * axis.z * (1 - cT), 0, - 0, 0, 0, 1 - ]; - }; - Matrix3D.prototype.identity = function () { - this._data = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; - }; - Matrix3D.prototype.append = function (lhs) { - this._data = this.dotProduct(lhs._data, this._data); - }; - Matrix3D.prototype.appendRotation = function (degrees, axis, pivotPoint) { - if (pivotPoint === void 0) { pivotPoint = null; } - if (pivotPoint !== null) { - this.appendTranslation(pivotPoint.x, pivotPoint.y, pivotPoint.z); - } - this._data = this.dotProduct(this.rotationMatrix(degrees * Math.PI / 180, axis), this._data); - if (pivotPoint !== null) { - this.appendTranslation(-pivotPoint.x, -pivotPoint.y, -pivotPoint.z); - } - }; - Matrix3D.prototype.appendTranslation = function (x, y, z) { - this._data = this.dotProduct([ - 1, 0, 0, x, - 0, 1, 0, y, - 0, 0, 1, z, - 0, 0, 0, 1 - ], this._data); - }; - Matrix3D.prototype.appendScale = function (sX, sY, sZ) { - if (sX === void 0) { sX = 1; } - if (sY === void 0) { sY = 1; } - if (sZ === void 0) { sZ = 1; } - this._data = this.dotProduct([ - sX, 0, 0, 0, - 0, sY, 0, 0, - 0, 0, sZ, 0, - 0, 0, 0, 1 - ], this._data); - }; - Matrix3D.prototype.prepend = function (rhs) { - this._data = this.dotProduct(this._data, rhs._data); - }; - Matrix3D.prototype.prependRotation = function (degrees, axis, pivotPoint) { - if (pivotPoint === void 0) { pivotPoint = null; } - if (pivotPoint !== null) { - this.prependTranslation(pivotPoint.x, pivotPoint.y, pivotPoint.z); - } - this._data = this.dotProduct(this._data, this.rotationMatrix(degrees * Math.PI / 180, axis)); - if (pivotPoint !== null) { - this.prependTranslation(-pivotPoint.x, -pivotPoint.y, -pivotPoint.z); - } - }; - Matrix3D.prototype.prependTranslation = function (x, y, z) { - this._data = this.dotProduct(this._data, [ - 1, 0, 0, x, - 0, 1, 0, y, - 0, 0, 1, z, - 0, 0, 0, 1 - ]); - }; - Matrix3D.prototype.prependScale = function (sX, sY, sZ) { - this._data = this.dotProduct(this._data, [ - sX, 0, 0, 0, - 0, sY, 0, 0, - 0, 0, sZ, 0, - 0, 0, 0, 1 - ]); - }; - Matrix3D.prototype.transformVector = function (v) { - var rx = this._data[0] * v.x + this._data[1] * v.y + - this._data[2] * v.z + this._data[3] * v.w; - var ry = this._data[4] * v.x + this._data[5] * v.y + - this._data[6] * v.z + this._data[7] * v.w; - var rz = this._data[8] * v.x + this._data[9] * v.y + - this._data[10] * v.z + this._data[11] * v.w; - var rw = this._data[12] * v.x + this._data[13] * v.y + - this._data[14] * v.z + this._data[15] * v.w; - return new Vector3D(rx, ry, rz, rw); - }; - Matrix3D.prototype.transformVectors = function (vin, vout) { - if (vin.length % 3 !== 0) { - __trace('Matrix3D.transformVectors expects input size to be multiple of 3.', 'err'); - return; - } - for (var i = 0; i < vin.length / 3; i++) { - var x = vin[i * 3], y = vin[i * 3 + 1], z = vin[i * 3 + 2]; - var rx = this._data[0] * x + this._data[1] * y + this._data[2] * z; - var ry = this._data[4] * x + this._data[5] * y + this._data[6] * z; - var rz = this._data[8] * x + this._data[9] * y + this._data[10] * z; - vout.push(rx, ry, rz); - } - }; - Matrix3D.prototype.transpose = function () { - this._data = [ - this._data[0], this._data[4], this._data[8], this._data[12], - this._data[1], this._data[5], this._data[9], this._data[13], - this._data[2], this._data[6], this._data[10], this._data[14], - this._data[3], this._data[7], this._data[11], this._data[15] - ]; - }; - Matrix3D.prototype.clone = function () { - return new Matrix3D(this._data); - }; - Matrix3D.prototype.serialize = function () { - return this._data; - }; - return Matrix3D; - }()); - Display.Matrix3D = Matrix3D; - var Vector3D = (function () { - function Vector3D(x, y, z, w) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (z === void 0) { z = 0; } - if (w === void 0) { w = 0; } - this.x = x; - this.y = y; - this.z = z; - this.w = w; - } - Vector3D.prototype.toString = function () { - return '(x=' + this.x + ', y=' + this.y + ', z=' + this.z + ', w=' + this.w + ')'; - }; - Vector3D.X_AXIS = new Vector3D(1, 0, 0); - Vector3D.Y_AXIS = new Vector3D(0, 1, 0); - Vector3D.Z_AXIS = new Vector3D(0, 0, 1); - return Vector3D; - }()); - Display.Vector3D = Vector3D; - function createMatrix(a, b, c, d, tx, ty) { - return new Matrix(a, b, c, d, tx, ty); - } - Display.createMatrix = createMatrix; - function createMatrix3D(iv) { - return new Matrix3D(iv); - } - Display.createMatrix3D = createMatrix3D; - function createGradientBox(width, height, rotation, tX, tY) { - var m = new Matrix(); - m.createGradientBox(width / 1638.4, height / 1638.4, rotation, tX + width / 2, tY + height / 2); - return m; - } - Display.createGradientBox = createGradientBox; - function createVector3D(x, y, z, w) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (z === void 0) { z = 0; } - if (w === void 0) { w = 0; } - return new Vector3D(x, y, z, w); - } - Display.createVector3D = createVector3D; - function projectVector(matrix, vector) { - return matrix.transformVector(vector); - } - Display.projectVector = projectVector; - function projectVectors(matrix, verts, projectedVerts, uvts) { - while (projectedVerts.length > 0) { - projectedVerts.pop(); - } - if (verts.length % 3 !== 0) { - __trace('Display.projectVectors input vertex Vector must be a multiple of 3.', 'err'); - return; - } - var transformed = []; - matrix.transformVectors(verts, transformed); - for (var i = 0; i < transformed.length / 3; i++) { - var x = transformed[i * 3], y = transformed[i * 3 + 1]; - projectedVerts.push(x, y); - } - } - Display.projectVectors = projectVectors; - function createPoint(x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - return new Point(x, y); - } - Display.createPoint = createPoint; - function toIntVector(array) { - Object.defineProperty(array, 'as3Type', { - get: function () { - return 'Vector'; - }, - set: function (value) { - __trace('as3Type should not be set.', 'warn'); - } - }); - return array.map(Math.floor); - } - Display.toIntVector = toIntVector; - function toNumberVector(array) { - Object.defineProperty(array, 'as3Type', { - get: function () { - return 'Vector'; - }, - set: function (value) { - __trace('as3Type should not be set.', 'warn'); - } - }); - return array; - } - Display.toNumberVector = toNumberVector; -})(Display || (Display = {})); -var Display; -(function (Display) { - var ColorTransform = (function () { - function ColorTransform(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) { - if (redMultiplier === void 0) { redMultiplier = 1; } - if (greenMultiplier === void 0) { greenMultiplier = 1; } - if (blueMultiplier === void 0) { blueMultiplier = 1; } - if (alphaMultiplier === void 0) { alphaMultiplier = 1; } - if (redOffset === void 0) { redOffset = 0; } - if (greenOffset === void 0) { greenOffset = 0; } - if (blueOffset === void 0) { blueOffset = 0; } - if (alphaOffset === void 0) { alphaOffset = 0; } - this.redMultiplier = redMultiplier; - this.greenMultiplier = greenMultiplier; - this.blueMultiplier = blueMultiplier; - this.alphaMultiplier = alphaMultiplier; - this.redOffset = redOffset; - this.greenOffset = greenOffset; - this.blueOffset = blueOffset; - this.alphaOffset = alphaOffset; - } - Object.defineProperty(ColorTransform.prototype, "color", { - get: function () { - return this.redOffset << 16 | this.greenOffset << 8 | this.blueOffset; - }, - set: function (color) { - this.redOffset = ((color >> 16) & 0xFF); - this.greenOffset = ((color >> 8) & 0xFF); - this.blueOffset = color & 0xFF; - this.redMultiplier = 0; - this.greenMultiplier = 0; - this.blueMultiplier = 0; - }, - enumerable: true, - configurable: true - }); - ColorTransform.prototype.concat = function (second) { - this.redMultiplier *= second.redMultiplier; - this.greenMultiplier *= second.greenMultiplier; - this.blueMultiplier *= second.blueMultiplier; - this.alphaMultiplier *= second.alphaMultiplier; - this.redOffset += second.redOffset; - this.greenOffset += second.greenOffset; - this.blueOffset += second.blueOffset; - this.alphaOffset += second.alphaOffset; - }; - ColorTransform.prototype.serialize = function () { - return { - 'class': 'ColorTransform', - 'red': { - 'offset': this.redOffset, - 'multiplier': this.redMultiplier - }, - 'green': { - 'offset': this.greenOffset, - 'multiplier': this.greenMultiplier - }, - 'blue': { - 'offset': this.blueOffset, - 'multiplier': this.blueMultiplier - }, - 'alpha': { - 'offset': this.alphaOffset, - 'multiplier': this.alphaMultiplier - } - }; - }; - return ColorTransform; - }()); - Display.ColorTransform = ColorTransform; - function createColorTransform(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) { - if (redMultiplier === void 0) { redMultiplier = 1; } - if (greenMultiplier === void 0) { greenMultiplier = 1; } - if (blueMultiplier === void 0) { blueMultiplier = 1; } - if (alphaMultiplier === void 0) { alphaMultiplier = 1; } - if (redOffset === void 0) { redOffset = 0; } - if (greenOffset === void 0) { greenOffset = 0; } - if (blueOffset === void 0) { blueOffset = 0; } - if (alphaOffset === void 0) { alphaOffset = 0; } - return new ColorTransform(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset); - } - Display.createColorTransform = createColorTransform; -})(Display || (Display = {})); -var Display; -(function (Display) { - var PerspectiveProjection = (function () { - function PerspectiveProjection(t) { - if (t === void 0) { t = null; } - this.fieldOfView = 55; - this.projectionCenter = new Display.Point(0, 0); - this.focalLength = 0; - if (t !== null) { - this.projectionCenter = new Display.Point(t.width / 2, t.height / 2); - this.fieldOfView = 55; - this.focalLength = t.width / 2 / Math.tan(this.fieldOfView / 2); - } - } - PerspectiveProjection.prototype.toMatrix3D = function () { - return new Display.Matrix3D(); - }; - PerspectiveProjection.prototype.clone = function () { - var proj = new PerspectiveProjection(); - proj.fieldOfView = this.fieldOfView; - proj.projectionCenter = this.projectionCenter; - proj.focalLength = this.focalLength; - return proj; - }; - return PerspectiveProjection; - }()); - Display.PerspectiveProjection = PerspectiveProjection; - var Transform = (function () { - function Transform(parent) { - this._matrix = new Display.Matrix(); - this._matrix3d = null; - this._parent = parent; - this._perspectiveProjection = new PerspectiveProjection(parent); - this._colorTransform = new Display.ColorTransform(); - } - Object.defineProperty(Transform.prototype, "parent", { - get: function () { - return this._parent; - }, - set: function (p) { - this._parent = p; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "perspectiveProjection", { - get: function () { - return this._perspectiveProjection; - }, - set: function (projection) { - this._perspectiveProjection = projection; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "matrix3D", { - get: function () { - return this._matrix3d; - }, - set: function (m) { - if (m === null) { - if (this._matrix3d === null) { - return; - } - this._matrix3d = null; - this._matrix = new Display.Matrix(); - } - else { - this._matrix = null; - this._matrix3d = m; - } - this.update(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Transform.prototype, "matrix", { - get: function () { - return this._matrix; - }, - set: function (m) { - if (m === null) { - if (this._matrix === null) { - return; - } - this._matrix = null; - this._matrix3d = new Display.Matrix3D(); - } - else { - this._matrix3d = null; - this._matrix = m; - } - this.update(); - }, - enumerable: true, - configurable: true - }); - Transform.prototype.box3d = function (sX, sY, sZ, rotX, rotY, rotZ, tX, tY, tZ) { - if (sX === void 0) { sX = 1; } - if (sY === void 0) { sY = 1; } - if (sZ === void 0) { sZ = 1; } - if (rotX === void 0) { rotX = 0; } - if (rotY === void 0) { rotY = 0; } - if (rotZ === void 0) { rotZ = 0; } - if (tX === void 0) { tX = 0; } - if (tY === void 0) { tY = 0; } - if (tZ === void 0) { tZ = 0; } - if (this._matrix !== null || this._matrix3d === null) { - this._matrix = null; - this._matrix3d = new Display.Matrix3D(); - } - this._matrix3d.identity(); - this._matrix3d.appendRotation(rotX, Display.Vector3D.X_AXIS); - this._matrix3d.appendRotation(rotY, Display.Vector3D.Y_AXIS); - this._matrix3d.appendRotation(rotZ, Display.Vector3D.Z_AXIS); - this._matrix3d.appendScale(sX, sY, sZ); - this._matrix3d.appendTranslation(tX, tY, tZ); - }; - Transform.prototype.box = function (sX, sY, rot, tX, tY) { - if (sX === void 0) { sX = 1; } - if (sY === void 0) { sY = 1; } - if (rot === void 0) { rot = 0; } - if (tX === void 0) { tX = 0; } - if (tY === void 0) { tY = 0; } - if (this._matrix) { - this._matrix.createBox(sX, sY, rot, tX, tY); - } - else { - this.box3d(sX, sY, 1, 0, 0, rot, tX, tY, 0); - } - }; - Transform.prototype.update = function () { - if (this._parent === null) { - return; - } - this._parent.transform = this; - }; - Transform.prototype.getRelativeMatrix3D = function (relativeTo) { - __trace('Transform.getRelativeMatrix3D not implemented', 'warn'); - return new Display.Matrix3D(); - }; - Transform.prototype.getMatrix = function () { - if (this._matrix) { - return this._matrix; - } - else { - return this._matrix3d; - } - }; - Transform.prototype.getMatrixType = function () { - return this._matrix ? '2d' : '3d'; - }; - Transform.prototype.clone = function () { - var t = new Transform(null); - t._matrix = this._matrix; - t._matrix3d = this._matrix3d; - return t; - }; - Transform.prototype.serialize = function () { - return { - 'mode': this.getMatrixType(), - 'matrix': this.getMatrix().serialize() - }; - }; - return Transform; - }()); - Display.Transform = Transform; -})(Display || (Display = {})); -var Display; -(function (Display) { - var Filter = (function () { - function Filter() { - } - Filter.prototype.serialize = function () { - return { - 'class': 'Filter', - 'type': 'nullfilter' - }; - }; - return Filter; - }()); - Display.Filter = Filter; - var BlurFilter = (function (_super) { - __extends(BlurFilter, _super); - function BlurFilter(blurX, blurY) { - if (blurX === void 0) { blurX = 4.0; } - if (blurY === void 0) { blurY = 4.0; } - var _this = _super.call(this) || this; - _this._blurX = blurX; - _this._blurY = blurY; - return _this; - } - BlurFilter.prototype.serialize = function () { - var s = _super.prototype.serialize.call(this); - s['type'] = 'blur'; - s['params'] = { - 'blurX': this._blurX, - 'blurY': this._blurY - }; - return s; - }; - return BlurFilter; - }(Filter)); - var GlowFilter = (function (_super) { - __extends(GlowFilter, _super); - function GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout) { - if (color === void 0) { color = 16711680; } - if (alpha === void 0) { alpha = 1.0; } - if (blurX === void 0) { blurX = 6.0; } - if (blurY === void 0) { blurY = 6.0; } - if (strength === void 0) { strength = 2; } - if (quality === void 0) { quality = null; } - if (inner === void 0) { inner = false; } - if (knockout === void 0) { knockout = false; } - var _this = _super.call(this) || this; - _this._color = color; - _this._alpha = alpha; - _this._blurX = blurX; - _this._blurY = blurY; - _this._strength = strength; - _this._quality = quality; - _this._inner = inner; - _this._knockout = knockout; - return _this; - } - GlowFilter.prototype.serialize = function () { - var s = _super.prototype.serialize.call(this); - s['type'] = 'glow'; - s['params'] = { - 'color': this._color, - 'alpha': this._alpha, - 'blurX': this._blurX, - 'blurY': this._blurY, - 'strength': this._strength, - 'inner': this._inner, - 'knockout': this._knockout - }; - return s; - }; - return GlowFilter; - }(Filter)); - var DropShadowFilter = (function (_super) { - __extends(DropShadowFilter, _super); - function DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality) { - if (distance === void 0) { distance = 4.0; } - if (angle === void 0) { angle = 45; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1; } - if (blurX === void 0) { blurX = 4.0; } - if (blurY === void 0) { blurY = 4.0; } - if (strength === void 0) { strength = 1.0; } - if (quality === void 0) { quality = 1; } - var _this = _super.call(this) || this; - _this._color = color; - _this._alpha = alpha; - _this._blurX = blurX; - _this._blurY = blurY; - _this._strength = strength; - _this._quality = quality; - _this._inner = false; - _this._knockout = false; - _this._distance = distance; - _this._angle = angle; - return _this; - } - DropShadowFilter.prototype.serialize = function () { - var s = _super.prototype.serialize.call(this); - s['type'] = 'dropShadow'; - s['params'] = { - 'distance': this._distance, - 'angle': this._angle, - 'color': this._color, - 'blurY': this._blurY, - 'strength': this._strength, - 'inner': this._inner, - 'knockout': this._knockout - }; - return s; - }; - return DropShadowFilter; - }(Filter)); - var ConvolutionFilter = (function (_super) { - __extends(ConvolutionFilter, _super); - function ConvolutionFilter(matrixX, matrixY, matrix, divisor, bias, preserveAlpha, clamp, color, alpha) { - if (matrixX === void 0) { matrixX = 0; } - if (matrixY === void 0) { matrixY = 0; } - if (matrix === void 0) { matrix = null; } - if (divisor === void 0) { divisor = 1.0; } - if (bias === void 0) { bias = 0.0; } - if (preserveAlpha === void 0) { preserveAlpha = true; } - if (clamp === void 0) { clamp = true; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 0.0; } - return _super.call(this) || this; - } - ; - ConvolutionFilter.prototype.serialize = function () { - var s = _super.prototype.serialize.call(this); - s['type'] = 'convolution'; - s['matrix'] = { - 'x': this._matrixX, - 'y': this._matrixY, - 'data': this._matrix - }; - s['divisor'] = this._divisor; - s['preserveAlpha'] = this._preserveAlpha; - s['clamp'] = this._clamp; - s['color'] = this._color; - s['alpha'] = this._alpha; - return s; - }; - return ConvolutionFilter; - }(Filter)); - function createDropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality) { - if (distance === void 0) { distance = 4.0; } - if (angle === void 0) { angle = 45; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1; } - if (blurX === void 0) { blurX = 4.0; } - if (blurY === void 0) { blurY = 4.0; } - if (strength === void 0) { strength = 1.0; } - if (quality === void 0) { quality = 1; } - return new DropShadowFilter(distance, angle, color, alpha, blurX, blurY, strength, quality); - } - Display.createDropShadowFilter = createDropShadowFilter; - function createGlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout) { - if (color === void 0) { color = 16711680; } - if (alpha === void 0) { alpha = 1.0; } - if (blurX === void 0) { blurX = 6.0; } - if (blurY === void 0) { blurY = 6.0; } - if (strength === void 0) { strength = 2; } - if (quality === void 0) { quality = null; } - if (inner === void 0) { inner = false; } - if (knockout === void 0) { knockout = false; } - return new GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout); - } - Display.createGlowFilter = createGlowFilter; - function createBlurFilter(blurX, blurY, strength) { - if (blurX === void 0) { blurX = 6.0; } - if (blurY === void 0) { blurY = 6.0; } - if (strength === void 0) { strength = 2; } - return new BlurFilter(blurX, blurY); - } - Display.createBlurFilter = createBlurFilter; - function createBevelFilter() { - throw new Error('Display.createBevelFilter not implemented'); - } - Display.createBevelFilter = createBevelFilter; - function createConvolutionFilter(matrixX, matrixY, matrix, divisor, bias, preserveAlpha, clamp, color, alpha) { - if (matrixX === void 0) { matrixX = 0; } - if (matrixY === void 0) { matrixY = 0; } - if (matrix === void 0) { matrix = null; } - if (divisor === void 0) { divisor = 1.0; } - if (bias === void 0) { bias = 0.0; } - if (preserveAlpha === void 0) { preserveAlpha = true; } - if (clamp === void 0) { clamp = true; } - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 0.0; } - return new ConvolutionFilter(matrixX, matrixY, matrix, divisor, bias, preserveAlpha, clamp, color, alpha); - } - Display.createConvolutionFilter = createConvolutionFilter; - function createDisplacementMapFilter() { - throw new Error('Display.createDisplacementMapFilter not implemented'); - } - Display.createDisplacementMapFilter = createDisplacementMapFilter; - function createGradientBevelFilter() { - throw new Error('Display.createGradientBevelFilter not implemented'); - } - Display.createGradientBevelFilter = createGradientBevelFilter; - function createGradientGlowFilter() { - throw new Error('Display.createGradientGlowFilter not implemented'); - } - Display.createGradientGlowFilter = createGradientGlowFilter; - function createColorMatrixFilter() { - throw new Error('Display.createColorMatrixFilter not implemented'); - } - Display.createColorMatrixFilter = createColorMatrixFilter; -})(Display || (Display = {})); -var Display; -(function (Display) { - var BlendMode = (function () { - function BlendMode() { - } - BlendMode.ADD = "add"; - BlendMode.ALPHA = "alpha"; - BlendMode.DARKEN = "darken"; - BlendMode.DIFFERENCE = "difference"; - BlendMode.ERASE = "erase"; - BlendMode.HARDLIGHT = "hardlight"; - BlendMode.INVERT = "invert"; - BlendMode.LAYER = "layer"; - BlendMode.LIGHTEN = "lighten"; - BlendMode.MULTIPLY = "multiply"; - BlendMode.NORMAL = "normal"; - BlendMode.OVERLAY = "overlay"; - BlendMode.SCREEN = "screen"; - BlendMode.SHADER = "shader"; - BlendMode.SUBTRACT = "subtract"; - return BlendMode; - }()); - Display.BlendMode = BlendMode; - var Rectangle = (function () { - function Rectangle(x, y, width, height) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (width === void 0) { width = 0; } - if (height === void 0) { height = 0; } - this._x = x; - this._y = y; - this._width = width; - this._height = height; - } - Object.defineProperty(Rectangle.prototype, "x", { - get: function () { - return this._x; - }, - set: function (v) { - if (v !== null) { - this._x = v; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "y", { - get: function () { - return this._y; - }, - set: function (v) { - if (v !== null) { - this._y = v; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "width", { - get: function () { - return this._width; - }, - set: function (v) { - if (v !== null) { - this._width = v; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "height", { - get: function () { - return this._height; - }, - set: function (v) { - if (v !== null) { - this._height = v; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "left", { - get: function () { - return this._x; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "right", { - get: function () { - return this._x + this._width; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "top", { - get: function () { - return this._y; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "bottom", { - get: function () { - return this._y + this._height; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Rectangle.prototype, "size", { - get: function () { - return Display.createPoint(this._width, this._height); - }, - enumerable: true, - configurable: true - }); - Rectangle.prototype.contains = function (x, y) { - return x >= this.left && - y >= this.top && - x <= this.right && - y <= this.bottom; - }; - Rectangle.prototype.containsPoint = function (p) { - return this.contains(p.x, p.y); - }; - Rectangle.prototype.containsRect = function (r) { - return this.contains(r.left, r.top) && this.contains(r.right, r.bottom); - }; - Rectangle.prototype.copyFrom = function (source) { - this._x = source._x; - this._y = source._y; - this._width = source._width; - this._height = source._height; - }; - Rectangle.prototype.equals = function (other) { - return this._x === other._x && - this._y === other._y && - this._width === other._width && - this._height === other._height; - }; - Rectangle.prototype.inflate = function (dx, dy) { - if (dx === void 0) { dx = 0; } - if (dy === void 0) { dy = 0; } - this._x -= dx; - this._width += 2 * dx; - this._y -= dy; - this._height += 2 * dy; - }; - Rectangle.prototype.inflatePoint = function (p) { - this.inflate(p.x, p.y); - }; - Rectangle.prototype.isEmpty = function () { - return this._width <= 0 || this.height <= 0; - }; - Rectangle.prototype.setTo = function (x, y, width, height) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (width === void 0) { width = 0; } - if (height === void 0) { height = 0; } - this._x = x; - this._y = y; - this._width = width; - this._height = height; - }; - Rectangle.prototype.offset = function (x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - this._x += x; - this._y += y; - }; - Rectangle.prototype.offsetPoint = function (p) { - this.offset(p.x, p.y); - }; - Rectangle.prototype.setEmpty = function () { - this.setTo(0, 0, 0, 0); - }; - Rectangle.prototype.unionCoord = function (x, y) { - var dx = x - this._x; - var dy = y - this._y; - if (dx >= 0) { - this._width = Math.max(this._width, dx); - } - else { - this._x += dx; - this._width -= dx; - } - if (dy >= 0) { - this._height = Math.max(this._height, dy); - } - else { - this._y += dy; - this._height -= dy; - } - }; - Rectangle.prototype.unionPoint = function (p) { - this.unionCoord(p.x, p.y); - }; - Rectangle.prototype.union = function (r) { - var n = this.clone(); - n.unionCoord(r.left, r.top); - n.unionCoord(r.right, r.bottom); - return n; - }; - Rectangle.prototype.toString = function () { - return "(x=" + this._x + ", y=" + this._y + ", width=" + this._width + - ", height=" + this._height + ")"; - }; - Rectangle.prototype.clone = function () { - return new Rectangle(this._x, this._y, this._width, this._height); - }; - Rectangle.prototype.serialize = function () { - return { - x: this._x, - y: this._y, - width: this._width, - height: this._height - }; - }; - return Rectangle; - }()); - Display.Rectangle = Rectangle; - var DisplayObject = (function () { - function DisplayObject(id) { - if (id === void 0) { id = Runtime.generateId(); } - this._alpha = 1; - this._anchor = new Display.Point(); - this._boundingBox = new Rectangle(); - this._z = 0; - this._scaleX = 1; - this._scaleY = 1; - this._scaleZ = 1; - this._rotationX = 0; - this._rotationY = 0; - this._rotationZ = 0; - this._filters = []; - this._visible = false; - this._blendMode = "normal"; - this._listeners = {}; - this._parent = null; - this._name = ""; - this._children = []; - this._transform = new Display.Transform(this); - this._hasSetDefaults = false; - this._id = id; - this._visible = true; - } - DisplayObject.prototype.setDefaults = function (defaults) { - if (defaults === void 0) { defaults = {}; } - if (this._hasSetDefaults) { - __trace("DisplayObject.setDefaults called more than once.", "warn"); - return; - } - this._hasSetDefaults = true; - try { - if (defaults.hasOwnProperty("motion")) { - var motion = defaults["motion"]; - if (motion.hasOwnProperty("alpha")) { - this._alpha = motion["alpha"]["fromValue"]; - } - if (motion.hasOwnProperty("x")) { - this._anchor.x = motion["x"]["fromValue"]; - } - if (motion.hasOwnProperty("y")) { - this._anchor.y = motion["y"]["fromValue"]; - } - } - else if (defaults.hasOwnProperty("motionGroup") && - defaults["motionGroup"] && defaults["motionGroup"].length > 0) { - var motion = defaults["motionGroup"][0]; - if (motion.hasOwnProperty("alpha")) { - this._alpha = motion["alpha"]["fromValue"]; - } - if (motion.hasOwnProperty("x")) { - this._anchor.x = motion["x"]["fromValue"]; - } - if (motion.hasOwnProperty("y")) { - this._anchor.y = motion["y"]["fromValue"]; - } - } - } - catch (e) { - } - if (defaults.hasOwnProperty("alpha")) { - this._alpha = defaults["alpha"]; - } - if (defaults.hasOwnProperty("x")) { - this._anchor.x = defaults["x"]; - } - if (defaults.hasOwnProperty("y")) { - this._anchor.y = defaults["y"]; - } - }; - DisplayObject.prototype.eventToggle = function (eventName, mode) { - if (mode === void 0) { mode = "enable"; } - if (DisplayObject.SANDBOX_EVENTS.indexOf(eventName) > -1) { - return; - } - __pchannel("Runtime:ManageEvent", { - "id": this._id, - "name": eventName, - "mode": mode - }); - }; - DisplayObject.prototype.propertyUpdate = function (propertyName, updatedValue) { - __pchannel("Runtime:UpdateProperty", { - "id": this._id, - "name": propertyName, - "value": updatedValue - }); - }; - DisplayObject.prototype.methodCall = function (methodName, params) { - __pchannel("Runtime:CallMethod", { - "id": this._id, - "method": methodName, - "params": params - }); - }; - Object.defineProperty(DisplayObject.prototype, "alpha", { - get: function () { - return this._alpha; - }, - set: function (value) { - this._alpha = value; - this.propertyUpdate("alpha", value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "anchor", { - get: function () { - return this._anchor; - }, - set: function (p) { - this._anchor = p; - this.propertyUpdate("x", p.x); - this.propertyUpdate("y", p.y); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "boundingBox", { - get: function () { - return this._boundingBox; - }, - set: function (r) { - this._boundingBox = r; - this.propertyUpdate("boundingBox", r.serialize()); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "cacheAsBitmap", { - get: function () { - return false; - }, - set: function (value) { - __trace("DisplayObject.cacheAsBitmap is not supported", "warn"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "filters", { - get: function () { - return this._filters; - }, - set: function (filters) { - this._filters = filters ? filters : []; - var serializedFilters = []; - for (var i = 0; i < this._filters.length; i++) { - if (!this.filters[i]) { - continue; - } - serializedFilters.push(this._filters[i].serialize()); - } - this.propertyUpdate("filters", serializedFilters); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "root", { - get: function () { - return Display.root; - }, - set: function (s) { - __trace("DisplayObject.root is read-only.", "warn"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "stage", { - get: function () { - return Display.root; - }, - set: function (s) { - __trace("DisplayObject.stage is read-only.", "warn"); - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype._updateBox = function (mode) { - if (mode === void 0) { mode = this._transform.getMatrixType(); } - if (mode === "3d") { - this._transform.box3d(this._scaleX, this._scaleY, this._scaleZ, this._rotationX, this._rotationY, this._rotationZ, 0, 0, this._z); - } - else { - this._transform.box(this._scaleX, this._scaleY, this._rotationZ * Math.PI / 180); - } - this.transform = this._transform; - }; - Object.defineProperty(DisplayObject.prototype, "rotationX", { - get: function () { - return this._rotationX; - }, - set: function (x) { - this._rotationX = x; - this._updateBox("3d"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "rotationY", { - get: function () { - return this._rotationY; - }, - set: function (y) { - this._rotationY = y; - this._updateBox("3d"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "rotationZ", { - get: function () { - return this._rotationZ; - }, - set: function (z) { - this._rotationZ = z; - this._updateBox(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "rotation", { - get: function () { - return this._rotationZ; - }, - set: function (r) { - this._rotationZ = r; - this._updateBox(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "scaleX", { - get: function () { - return this._scaleX; - }, - set: function (val) { - this._scaleX = val; - this._updateBox(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "scaleY", { - get: function () { - return this._scaleY; - }, - set: function (val) { - this._scaleY = val; - this._updateBox(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "scaleZ", { - get: function () { - return this._scaleZ; - }, - set: function (val) { - this._scaleZ = val; - this._updateBox("3d"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "x", { - get: function () { - return this._anchor.x; - }, - set: function (val) { - this._anchor.x = val; - this.propertyUpdate("x", val); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "y", { - get: function () { - return this._anchor.y; - }, - set: function (val) { - this._anchor.y = val; - this.propertyUpdate("y", val); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "z", { - get: function () { - return this._z; - }, - set: function (val) { - this._z = val; - this._updateBox("3d"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "width", { - get: function () { - return this._boundingBox.width; - }, - set: function (w) { - this._boundingBox.width = w; - this.propertyUpdate('width', w); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "height", { - get: function () { - return this._boundingBox.height; - }, - set: function (h) { - this._boundingBox.height = h; - this.propertyUpdate('height', h); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "visible", { - get: function () { - return this._visible; - }, - set: function (visible) { - this._visible = visible; - this.propertyUpdate('visible', visible); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "blendMode", { - get: function () { - return this._blendMode; - }, - set: function (blendMode) { - this._blendMode = blendMode; - this.propertyUpdate('blendMode', blendMode); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "transform", { - get: function () { - return this._transform; - }, - set: function (t) { - this._transform = t; - if (this._transform.parent !== this) { - this._transform.parent = this; - } - this.propertyUpdate('transform', this._transform.serialize()); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "name", { - get: function () { - return this._name; - }, - set: function (name) { - this._name = name; - this.propertyUpdate('name', name); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "loaderInfo", { - get: function () { - __trace("DisplayObject.loaderInfo is not supported", "warn"); - return {}; - }, - set: function (name) { - __trace("DisplayObject.loaderInfo is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DisplayObject.prototype, "parent", { - get: function () { - return this._parent !== null ? this._parent : Display.root; - }, - set: function (p) { - __trace("DisplayObject.parent is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.dispatchEvent = function (event, data) { - if (this._listeners.hasOwnProperty(event)) { - if (this._listeners[event] !== null) { - for (var i = 0; i < this._listeners[event].length; i++) { - try { - this._listeners[event][i](data); - } - catch (e) { - if (e.hasOwnProperty('stack')) { - __trace(e.stack.toString(), 'err'); - } - else { - __trace(e.toString(), 'err'); - } - } - } - } - } - }; - DisplayObject.prototype.addEventListener = function (event, listener) { - if (!this._listeners.hasOwnProperty(event)) { - this._listeners[event] = []; - } - this._listeners[event].push(listener); - if (this._listeners[event].length === 1) { - this.eventToggle(event, 'enable'); - } - }; - DisplayObject.prototype.removeEventListener = function (event, listener) { - if (!this._listeners.hasOwnProperty(event) || - this._listeners[event].length === 0) { - return; - } - var index = this._listeners[event].indexOf(listener); - if (index >= 0) { - this._listeners[event].splice(index, 1); - } - if (this._listeners[event].length === 0) { - this.eventToggle(event, 'disable'); - } - }; - Object.defineProperty(DisplayObject.prototype, "numChildren", { - get: function () { - return this._children.length; - }, - enumerable: true, - configurable: true - }); - DisplayObject.prototype.addChild = function (o) { - if (typeof o === 'undefined' || o === null) { - throw new Error('Cannot add an empty child!'); - } - if (o.contains(this)) { - throw new Error('Attempting to add an ancestor of this DisplayObject as a child!'); - } - this._children.push(o); - this._boundingBox.unionCoord(o._anchor.x + o._boundingBox.left, o._anchor.y + o._boundingBox.top); - this._boundingBox.unionCoord(o._anchor.x + o._boundingBox.right, o._anchor.y + o._boundingBox.bottom); - o._parent = this; - this.methodCall('addChild', o._id); - }; - DisplayObject.prototype.removeChild = function (o) { - var index = this._children.indexOf(o); - if (index >= 0) { - this.removeChildAt(index); - } - }; - DisplayObject.prototype.getChildAt = function (index) { - if (index < 0 || index > this._children.length) { - throw new RangeError('No child at index ' + index); - } - return this._children[index]; - }; - DisplayObject.prototype.getChildIndex = function (o) { - return this._children.indexOf(o); - }; - DisplayObject.prototype.removeChildAt = function (index) { - var o = this.getChildAt(index); - this._children.splice(index, 1); - o._parent = null; - this.methodCall('removeChild', o._id); - }; - DisplayObject.prototype.removeChildren = function (begin, end) { - if (end === void 0) { end = this._children.length; } - var removed = this._children.splice(begin, end - begin); - var ids = []; - for (var i = 0; i < removed.length; i++) { - removed[i]._parent = null; - ids.push(removed[i]._id); - } - this.methodCall('removeChildren', ids); - }; - DisplayObject.prototype.contains = function (child) { - if (child === this) { - return true; - } - if (this._children.indexOf(child) >= 0) { - return true; - } - for (var i = 0; i < this._children.length; i++) { - if (this._children[i].contains(child)) { - return true; - } - } - return false; - }; - DisplayObject.prototype.remove = function () { - if (this._parent !== null) { - this._parent.removeChild(this); - } - else { - this.root.removeChild(this); - } - }; - DisplayObject.prototype.toString = function () { - return '[' + (this._name.length > 0 ? this._name : 'displayObject') + - ' DisplayObject]@' + this._id; - }; - DisplayObject.prototype.clone = function () { - var alternate = new DisplayObject(); - alternate._transform = this._transform.clone(); - alternate._transform.parent = alternate; - alternate._boundingBox = this._boundingBox.clone(); - alternate._anchor = this._anchor.clone(); - alternate._alpha = this._alpha; - return alternate; - }; - DisplayObject.prototype.hasOwnProperty = function (prop) { - if (prop === 'clone') { - return true; - } - else { - return Object.prototype.hasOwnProperty.call(this, prop); - } - }; - DisplayObject.prototype.serialize = function () { - this._hasSetDefaults = true; - var filters = []; - for (var i = 0; i < this._filters.length; i++) { - filters.push(this._filters[i].serialize()); - } - return { - 'class': 'DisplayObject', - 'x': this._anchor.x, - 'y': this._anchor.y, - 'alpha': this._alpha, - 'filters': filters - }; - }; - DisplayObject.prototype.unload = function () { - this._visible = false; - this.remove(); - this.methodCall('unload', null); - }; - DisplayObject.prototype.getId = function () { - return this._id; - }; - DisplayObject.SANDBOX_EVENTS = ["enterFrame"]; - return DisplayObject; - }()); - Display.DisplayObject = DisplayObject; -})(Display || (Display = {})); -var Display; -(function (Display) { - var Graphics = (function () { - function Graphics(parent) { - this._lineWidth = 1; - if (typeof parent === 'undefined' || parent === null) { - throw new Error('Cannot initialize a display not bound to an element.'); - } - this._parent = parent; - } - Graphics.prototype._evaluateBoundingBox = function (x, y) { - this._parent.boundingBox.unionCoord(x + this._lineWidth / 2, y + this._lineWidth / 2); - }; - Graphics.prototype._callDrawMethod = function (method, params) { - __pchannel('Runtime:CallMethod', { - 'id': this._parent.getId(), - 'context': 'graphics', - 'method': method, - 'params': params - }); - }; - Graphics.prototype.lineTo = function (x, y) { - this._evaluateBoundingBox(x, y); - this._callDrawMethod('lineTo', [x, y]); - }; - Graphics.prototype.moveTo = function (x, y) { - this._evaluateBoundingBox(x, y); - this._callDrawMethod('moveTo', [x, y]); - }; - Graphics.prototype.curveTo = function (cx, cy, ax, ay) { - this._evaluateBoundingBox(ax, ay); - this._evaluateBoundingBox(cx, cy); - this._callDrawMethod('curveTo', [cx, cy, ax, ay]); - }; - Graphics.prototype.cubicCurveTo = function (cax, cay, cbx, cby, ax, ay) { - this._evaluateBoundingBox(cax, cay); - this._evaluateBoundingBox(cbx, cby); - this._evaluateBoundingBox(ax, ay); - this._callDrawMethod('cubicCurveTo', [cax, cay, cbx, cby, ax, ay]); - }; - Graphics.prototype.lineStyle = function (thickness, color, alpha, hinting, scale, caps, joints, miter) { - if (color === void 0) { color = 0; } - if (alpha === void 0) { alpha = 1.0; } - if (hinting === void 0) { hinting = false; } - if (scale === void 0) { scale = 'normal'; } - if (caps === void 0) { caps = 'none'; } - if (joints === void 0) { joints = 'round'; } - if (miter === void 0) { miter = 3; } - this._lineWidth = thickness; - this._callDrawMethod('lineStyle', [thickness, color, alpha, caps, joints, miter]); - }; - Graphics.prototype.drawRect = function (x, y, w, h) { - this._evaluateBoundingBox(x, y); - this._evaluateBoundingBox(x + w, y + h); - this._callDrawMethod('drawRect', [x, y, w, h]); - }; - Graphics.prototype.drawCircle = function (x, y, r) { - this._evaluateBoundingBox(x - r, y - r); - this._evaluateBoundingBox(x + r, y + r); - this._callDrawMethod('drawCircle', [x, y, r]); - }; - Graphics.prototype.drawEllipse = function (cx, cy, w, h) { - this._evaluateBoundingBox(cx - w / 2, cy - h / 2); - this._evaluateBoundingBox(cx + w / 2, cy + h / 2); - this._callDrawMethod('drawEllipse', [cx + w / 2, cy + h / 2, w / 2, h / 2]); - }; - Graphics.prototype.drawRoundRect = function (x, y, w, h, elw, elh) { - this._evaluateBoundingBox(x, y); - this._evaluateBoundingBox(x + w, y + h); - this._callDrawMethod('drawRoundRect', [x, y, w, h, elw, elh]); - }; - Graphics.prototype.drawPath = function (commands, data, winding) { - if (winding === void 0) { winding = "evenOdd"; } - this._callDrawMethod('drawPath', [commands, data, winding]); - }; - Graphics.prototype.beginFill = function (color, alpha) { - if (alpha === void 0) { alpha = 1.0; } - this._callDrawMethod('beginFill', [color, alpha]); - }; - Graphics.prototype.beginGradientFill = function (fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio) { - if (matrix === void 0) { matrix = null; } - if (spreadMethod === void 0) { spreadMethod = 'pad'; } - if (interpolationMethod === void 0) { interpolationMethod = 'rgb'; } - if (focalPointRatio === void 0) { focalPointRatio = 0; } - __trace('Graphics.beginGradientFill still needs work.', 'warn'); - if (fillType !== 'linear' && fillType !== 'radial') { - __trace('Graphics.beginGradientFill unsupported fill type : ' + - fillType, 'warn'); - return; - } - this._callDrawMethod('beginGradientFill', [ - fillType, - colors, - alphas, - ratios, - matrix === null ? null : matrix.serialize, - spreadMethod, - interpolationMethod, - focalPointRatio - ]); - }; - Graphics.prototype.beginShaderFill = function (shader, matrix) { - __trace('Graphics.beginShaderFill not supported.', 'warn'); - }; - Graphics.prototype.endFill = function () { - this._callDrawMethod('endFill', []); - }; - Graphics.prototype.drawTriangles = function (verts, indices, uvtData, culling) { - if (indices === void 0) { indices = null; } - if (uvtData === void 0) { uvtData = null; } - if (culling === void 0) { culling = 'none'; } - if (indices === null) { - indices = []; - for (var i = 0; i < verts.length; i += 2) { - indices.push(i / 2); - } - } - else { - indices = indices.slice(0); - } - if (indices.length % 3 !== 0) { - __trace('Graphics.drawTriangles malformed indices count. ' + - 'Must be multiple of 3.', 'err'); - return; - } - if (culling !== 'none') { - for (var i = 0; i < indices.length / 3; i++) { - var ux = verts[2 * indices[i * 3 + 1]] - verts[2 * indices[i * 3]], uy = verts[2 * indices[i * 3 + 1] + 1] - verts[2 * indices[i * 3] + 1], vx = verts[2 * indices[i * 3 + 2]] - verts[2 * indices[i * 3 + 1]], vy = verts[2 * indices[i * 3 + 2] + 1] - verts[2 * indices[i * 3 + 1] + 1]; - var zcomp = ux * vy - vx * uy; - if (zcomp < 0 && culling === 'positive' || - zcomp > 0 && culling === 'negative') { - indices.splice(i * 3, 3); - i--; - } - } - } - for (var i = 0; i < indices.length; i++) { - this._evaluateBoundingBox(verts[2 * indices[i]], verts[2 * indices[i] + 1]); - } - this._callDrawMethod('drawTriangles', [verts, indices, culling]); - }; - Graphics.prototype.clear = function () { - this._parent.boundingBox.setEmpty(); - this._callDrawMethod('clear', []); - }; - return Graphics; - }()); - Display.Graphics = Graphics; -})(Display || (Display = {})); -var Display; -(function (Display) { - var Sprite = (function (_super) { - __extends(Sprite, _super); - function Sprite(id) { - var _this = _super.call(this, id) || this; - _this._mouseEnabled = true; - _this._mousePosition = new Display.Point(0, 0); - _this._useHandCursor = false; - _this._graphics = new Display.Graphics(_this); - return _this; - } - Object.defineProperty(Sprite.prototype, "graphics", { - get: function () { - return this._graphics; - }, - set: function (g) { - __trace('Sprite.graphics is read-only.', 'warn'); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite.prototype, "mouseEnabled", { - get: function () { - return this._mouseEnabled; - }, - set: function (enabled) { - this._mouseEnabled = enabled; - this.propertyUpdate('mouseEnabled', enabled); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite.prototype, "useHandCursor", { - get: function () { - return this._useHandCursor; - }, - set: function (use) { - this._useHandCursor = use; - this.propertyUpdate('useHandCursor', use); - }, - enumerable: true, - configurable: true - }); - Sprite.prototype.serialize = function () { - var serialized = _super.prototype.serialize.call(this); - serialized['class'] = 'Sprite'; - return serialized; - }; - return Sprite; - }(Display.DisplayObject)); - Display.Sprite = Sprite; - var RootSprite = (function (_super) { - __extends(RootSprite, _super); - function RootSprite() { - return _super.call(this, '__root') || this; - } - Object.defineProperty(RootSprite.prototype, "parent", { - get: function () { - __trace('SecurityError: No access above root sprite.', 'err'); - return null; - }, - enumerable: true, - configurable: true - }); - return RootSprite; - }(Sprite)); - Display.RootSprite = RootSprite; - var UIComponent = (function (_super) { - __extends(UIComponent, _super); - function UIComponent(id) { - var _this = _super.call(this, id) || this; - _this._styles = {}; - return _this; - } - UIComponent.prototype.clearStyle = function (style) { - delete this._styles[style]; - }; - UIComponent.prototype.getStyle = function (style) { - return this._styles[style]; - }; - UIComponent.prototype.setStyle = function (styleProp, value) { - __trace("UIComponent.setStyle not implemented", "warn"); - this._styles[styleProp] = value; - }; - UIComponent.prototype.setFocus = function () { - this.methodCall("setFocus", null); - }; - UIComponent.prototype.setSize = function (width, height) { - this.width = width; - this.height = height; - }; - UIComponent.prototype.move = function (x, y) { - this.x = x; - this.y = y; - }; - return UIComponent; - }(Sprite)); - Display.UIComponent = UIComponent; -})(Display || (Display = {})); -var Display; -(function (Display) { - var DirtyArea = (function () { - function DirtyArea() { - this._xBegin = null; - this._yBegin = null; - this._xEnd = null; - this._yEnd = null; - } - DirtyArea.prototype.expand = function (x, y) { - this._xBegin = this._xBegin === null ? x : Math.min(this._xBegin, x); - this._xEnd = this._xEnd === null ? x : Math.max(this._xEnd, x); - this._yBegin = this._yBegin === null ? y : Math.min(this._yBegin, y); - this._yEnd = this._xEnd === null ? y : Math.max(this._yEnd, y); - }; - DirtyArea.prototype.asRect = function () { - if (this.isEmpty()) { - return new Display.Rectangle(0, 0, 0, 0); - } - return new Display.Rectangle(this._xBegin, this._yBegin, this._xEnd - this._xBegin, this._yEnd - this._yBegin); - }; - DirtyArea.prototype.isEmpty = function () { - return this._xBegin === null || this._yBegin === null || - this._xEnd === null || this._yEnd === null; - }; - DirtyArea.prototype.reset = function () { - this._xBegin = null; - this._xEnd = null; - this._yBegin = null; - this._yEnd = null; - }; - return DirtyArea; - }()); - var Bitmap = (function (_super) { - __extends(Bitmap, _super); - function Bitmap() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Bitmap; - }(Display.DisplayObject)); - Display.Bitmap = Bitmap; - var ByteArray = (function (_super) { - __extends(ByteArray, _super); - function ByteArray() { - var params = []; - for (var _i = 0; _i < arguments.length; _i++) { - params[_i] = arguments[_i]; - } - var _this = _super.apply(this, params) || this; - _this._readPosition = 0; - return _this; - } - Object.defineProperty(ByteArray.prototype, "bytesAvailable", { - get: function () { - return this.length - this._readPosition; - }, - set: function (n) { - __trace('ByteArray.bytesAvailable is read-only', 'warn'); - }, - enumerable: true, - configurable: true - }); - ByteArray.prototype.clear = function () { - this.length = 0; - this._readPosition = 0; - }; - ByteArray.prototype.compress = function (algorithm) { - if (algorithm === void 0) { algorithm = 'zlib'; } - __trace('ByteArray.compress not implemented', 'warn'); - }; - ByteArray.prototype.uncompress = function (algorithm) { - if (algorithm === void 0) { algorithm = 'zlib'; } - __trace('ByteArray.uncompress not implemented', 'warn'); - }; - ByteArray.prototype.deflate = function () { - __trace('ByteArray.deflate not implemented', 'warn'); - }; - ByteArray.prototype.inflate = function () { - __trace('ByteArray.inflate not implemented', 'warn'); - }; - ByteArray.prototype.readUTFBytes = function (length) { - var subArray = this.slice(this._readPosition, length); - this._readPosition += Math.min(length, this.length - this._readPosition); - var str = ''; - subArray.forEach(function (cc) { - str += String.fromCharCode(cc); - }); - return str; - }; - ByteArray.prototype.writeUTFBytes = function (value) { - for (var i = 0; i < value.length; i++) { - Array.prototype.push.apply(this, [value.charCodeAt(i)]); - } - }; - return ByteArray; - }(Array)); - Display.ByteArray = ByteArray; - var BitmapData = (function () { - function BitmapData(width, height, transparent, fillColor, id) { - if (transparent === void 0) { transparent = true; } - if (fillColor === void 0) { fillColor = 0xffffffff; } - if (id === void 0) { id = Runtime.generateId(); } - this._locked = false; - this._id = id; - this._rect = new Display.Rectangle(0, 0, width, height); - this._transparent = transparent; - this._fillColor = fillColor; - this._fill(); - } - BitmapData.prototype._fill = function () { - this._byteArray = []; - for (var i = 0; i < this._rect.width * this._rect.height; i++) { - this._byteArray.push(this._fillColor); - } - }; - BitmapData.prototype._updateBox = function (changeRect) { - if (changeRect === void 0) { changeRect = null; } - if (this._dirtyArea.isEmpty()) { - return; - } - if (this._locked) { - return; - } - var change = changeRect === null ? this._dirtyArea.asRect() : - changeRect; - if (!this._rect.containsRect(change)) { - __trace('BitmapData._updateBox box ' + change.toString() + - ' out of bonunds ' + this._rect.toString(), 'err'); - throw new Error('Rectangle provided was not within image bounds.'); - } - var region = []; - for (var i = 0; i < change.height; i++) { - for (var j = 0; j < change.width; j++) { - region.push(this._byteArray[(change.y + i) * this._rect.width + - change.x + j]); - } - } - this._call('updateBox', { - 'box': change.serialize(), - 'values': region - }); - }; - BitmapData.prototype._call = function (method, args) { - __pchannel('Runtime:CallMethod', { - 'id': this.getId(), - 'name': name, - 'value': args, - }); - }; - Object.defineProperty(BitmapData.prototype, "height", { - get: function () { - return this._rect.height; - }, - set: function (height) { - __trace('BitmapData.height is read-only', 'warn'); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BitmapData.prototype, "width", { - get: function () { - return this._rect.width; - }, - set: function (width) { - __trace('BitmapData.height is read-only', 'warn'); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BitmapData.prototype, "rect", { - get: function () { - return this._rect; - }, - set: function (rect) { - __trace('BitmapData.rect is read-only', 'warn'); - }, - enumerable: true, - configurable: true - }); - BitmapData.prototype.getPixel = function (x, y) { - return this.getPixel32(x, y) & 0x00ffffff; - }; - BitmapData.prototype.getPixel32 = function (x, y) { - if (x >= this._rect.width || y >= this._rect.height || - x < 0 || y < 0) { - throw new Error('Coordinates out of bounds'); - } - try { - return this._transparent ? this._byteArray[y * this._rect.width + x] : - this._byteArray[y * this._rect.width + x] + 0xff000000; - } - catch (e) { - return this._fillColor; - } - }; - BitmapData.prototype.getPixels = function (rect) { - if (typeof rect === 'undefined' || rect === null) { - throw new Error('Expected a region to acquire pixels.'); - } - if (rect.width === 0 || rect.height === 0) { - return new ByteArray(); - } - var region = new ByteArray(); - for (var i = 0; i < rect.height; i++) { - Array.prototype.push.apply(region, this._byteArray.slice((rect.y + i) * this._rect.width + rect.x, (rect.y + i) * this._rect.width + rect.x + rect.width)); - } - return region; - }; - BitmapData.prototype.setPixel = function (x, y, color) { - this.setPixel32(x, y, color); - }; - BitmapData.prototype.setPixel32 = function (x, y, color) { - if (!this._transparent) { - color = color & 0x00ffffff; - } - else { - color = color & 0xffffffff; - } - this._byteArray[y * this._rect.width + x] = color; - this._dirtyArea.expand(x, y); - }; - BitmapData.prototype.setPixels = function (rect, input) { - if (rect.width === 0 || rect.height === 0) { - return; - } - if (input.length !== rect.width * rect.height) { - throw new Error('setPixels expected ' + (rect.width * rect.height) + - ' pixels, but actually got ' + input.length); - } - for (var i = 0; i < rect.width; i++) { - for (var j = 0; j < rect.height; j++) { - this._byteArray[(rect.y + j) * this.width + (rect.x + i)] = - input[j * rect.width + i]; - this._dirtyArea.expand(i, j); - } - } - }; - BitmapData.prototype.lock = function () { - this._locked = true; - }; - BitmapData.prototype.unlock = function (changeRect) { - if (changeRect === void 0) { changeRect = null; } - this._locked = false; - if (changeRect == null) { - this._updateBox(); - } - else { - this._updateBox(changeRect); - } - }; - BitmapData.prototype.getId = function () { - return this._id; - }; - BitmapData.prototype.serialize = function () { - return { - 'class': 'BitmapData' - }; - }; - return BitmapData; - }()); - Display.BitmapData = BitmapData; -})(Display || (Display = {})); -var Display; -(function (Display) { - var MotionManager = (function () { - function MotionManager(o, dur, independentTimer) { - if (dur === void 0) { dur = 1000; } - if (independentTimer === void 0) { independentTimer = false; } - this._isRunning = false; - this.oncomplete = null; - if (typeof o === 'undefined' || o === null) { - throw new Error('MotionManager must be bound to a DisplayObject.'); - } - this._ttl = dur; - this._dur = dur; - this._parent = o; - this._independentTimer = independentTimer; - this._timeKeeper = new Runtime.TimeKeeper(); - var self = this; - if (this._independentTimer) { - this._timer = new Runtime.Timer(41, 0); - this._timer.addEventListener('timer', function () { - self._onTimerEvent(); - }); - this._timer.start(); - } - else { - this._parent.addEventListener('enterFrame', function () { - self._onTimerEvent(); - }); - } - } - Object.defineProperty(MotionManager.prototype, "dur", { - get: function () { - return this._dur; - }, - set: function (dur) { - this._timeKeeper.reset(); - this._ttl = dur; - this._dur = dur; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(MotionManager.prototype, "running", { - get: function () { - return this._isRunning; - }, - enumerable: true, - configurable: true - }); - MotionManager.prototype._onTimerEvent = function () { - if (!this._isRunning) { - return; - } - this._ttl -= this._timeKeeper.elapsed; - this._timeKeeper.reset(); - if (this._ttl <= 0) { - this.stop(); - if (typeof this.oncomplete === 'function') { - this.oncomplete(); - } - this._parent.unload(); - } - }; - MotionManager.prototype.reset = function () { - this._ttl = this._dur; - this._timeKeeper.reset(); - }; - MotionManager.prototype.play = function () { - if (this._isRunning) { - return; - } - if (this._dur === 0 || this._ttl <= 0) { - return; - } - this._isRunning = true; - this._timeKeeper.reset(); - if (this._tween) { - this._tween.play(); - } - }; - MotionManager.prototype.stop = function () { - if (!this._isRunning) { - return; - } - this._isRunning = false; - this._timeKeeper.reset(); - if (this._tween) { - this._tween.stop(); - } - }; - MotionManager.prototype.forecasting = function (time) { - __trace('MotionManager.forecasting always returns false', 'warn'); - return false; - }; - MotionManager.prototype.setPlayTime = function (playtime) { - this._ttl = this._dur - playtime; - if (this._tween) { - if (this._isRunning) { - this._tween.gotoAndPlay(playtime); - } - else { - this._tween.gotoAndStop(playtime); - } - } - }; - MotionManager.prototype.motionSetToTween = function (motion) { - var tweens = []; - for (var movingVars in motion) { - if (!motion.hasOwnProperty(movingVars)) { - continue; - } - var mProp = motion[movingVars]; - if (!mProp.hasOwnProperty("fromValue")) { - continue; - } - if (!mProp.hasOwnProperty("toValue")) { - mProp["toValue"] = mProp["fromValue"]; - } - if (!mProp.hasOwnProperty("lifeTime")) { - mProp["lifeTime"] = this._dur; - } - var src = {}, dst = {}; - src[movingVars] = mProp["fromValue"]; - dst[movingVars] = mProp["toValue"]; - if (typeof mProp["easing"] === "string") { - mProp["easing"] = Tween.getEasingFuncByName(mProp["easing"]); - } - if (mProp.hasOwnProperty("startDelay")) { - tweens.push(Tween.delay(Tween.tween(this._parent, dst, src, mProp["lifeTime"], mProp["easing"]), mProp["startDelay"] / 1000)); - } - else { - tweens.push(Tween.tween(this._parent, dst, src, mProp["lifeTime"], mProp["easing"])); - } - } - return Tween.parallel.apply(Tween, tweens); - }; - MotionManager.prototype.initTween = function (motion, repeat) { - this._tween = this.motionSetToTween(motion); - }; - MotionManager.prototype.initTweenGroup = function (motionGroup, lifeTime) { - var tweens = []; - for (var i = 0; i < motionGroup.length; i++) { - tweens.push(this.motionSetToTween(motionGroup[i])); - } - this._tween = Tween.serial.apply(Tween, tweens); - }; - MotionManager.prototype.setCompleteListener = function (listener) { - this.oncomplete = listener; - }; - return MotionManager; - }()); - Display.MotionManager = MotionManager; -})(Display || (Display = {})); -var Display; -(function (Display) { - var CommentBitmap = (function (_super) { - __extends(CommentBitmap, _super); - function CommentBitmap(params) { - var _this = _super.call(this) || this; - _this._mM = new Display.MotionManager(_this); - _this.initStyle(params); - Runtime.registerObject(_this); - _this.bindParent(params); - _this._mM.play(); - return _this; - } - Object.defineProperty(CommentBitmap.prototype, "motionManager", { - get: function () { - return this._mM; - }, - set: function (m) { - __trace("IComment.motionManager is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - CommentBitmap.prototype.bindParent = function (params) { - if (params.hasOwnProperty("parent")) { - params["parent"].addChild(this); - } - }; - CommentBitmap.prototype.initStyle = function (style) { - }; - return CommentBitmap; - }(Display.Bitmap)); - Display.CommentBitmap = CommentBitmap; - function createBitmap(params) { - return new CommentBitmap(params); - } - Display.createBitmap = createBitmap; - function createParticle(params) { - __trace('Bitmap.createParticle not implemented', 'warn'); - return new CommentBitmap(params); - } - Display.createParticle = createParticle; - function createBitmapData(width, height, transparent, fillColor) { - if (transparent === void 0) { transparent = true; } - if (fillColor === void 0) { fillColor = 0xffffffff; } - return new Display.BitmapData(width, height, transparent, fillColor); - } - Display.createBitmapData = createBitmapData; -})(Display || (Display = {})); -var Bitmap; -(function (Bitmap) { - function createBitmap(params) { - return Display.createBitmap(params); - } - Bitmap.createBitmap = createBitmap; - function createParticle(params) { - return Display.createParticle(params); - } - Bitmap.createParticle = createParticle; - function createBitmapData(width, height, transparent, fillColor) { - if (transparent === void 0) { transparent = true; } - if (fillColor === void 0) { fillColor = 0xffffffff; } - return Display.createBitmapData(width, height, transparent, fillColor); - } - Bitmap.createBitmapData = createBitmapData; - function createRectangle(x, y, width, height) { - return new Display.Rectangle(x, y, width, height); - } - Bitmap.createRectangle = createRectangle; -})(Bitmap || (Bitmap = {})); -var Display; -(function (Display) { - var CommentButton = (function (_super) { - __extends(CommentButton, _super); - function CommentButton(params) { - var _this = _super.call(this) || this; - _this._mM = new Display.MotionManager(_this); - _this._label = ""; - _this.setDefaults(params); - _this.initStyle(params); - Runtime.registerObject(_this); - _this.bindParent(params); - _this._mM.play(); - return _this; - } - Object.defineProperty(CommentButton.prototype, "motionManager", { - get: function () { - return this._mM; - }, - set: function (m) { - __trace("IComment.motionManager is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - CommentButton.prototype.bindParent = function (params) { - if (params.hasOwnProperty("parent")) { - params["parent"].addChild(this); - } - }; - CommentButton.prototype.initStyle = function (style) { - if (typeof style === 'undefined' || style === null) { - style = {}; - } - if ("lifeTime" in style) { - this._mM.dur = style["lifeTime"] * 1000; - } - else { - this._mM.dur = 4000; - } - if (style.hasOwnProperty("text")) { - this._label = style["text"]; - } - if (style.hasOwnProperty("motionGroup")) { - this._mM.initTweenGroup(style["motionGroup"], this._mM.dur); - } - else if (style.hasOwnProperty("motion")) { - this._mM.initTween(style["motion"], false); - } - }; - CommentButton.prototype.serialize = function () { - var serialized = _super.prototype.serialize.call(this); - serialized["class"] = "Button"; - serialized["text"] = this._label; - return serialized; - }; - return CommentButton; - }(Display.UIComponent)); - function createButton(params) { - return new CommentButton(params); - } - Display.createButton = createButton; -})(Display || (Display = {})); -var Display; -(function (Display) { - var CommentCanvas = (function (_super) { - __extends(CommentCanvas, _super); - function CommentCanvas(params) { - var _this = _super.call(this) || this; - _this._mM = new Display.MotionManager(_this); - _this.setDefaults(params); - _this.initStyle(params); - Runtime.registerObject(_this); - _this.bindParent(params); - _this._mM.play(); - return _this; - } - Object.defineProperty(CommentCanvas.prototype, "motionManager", { - get: function () { - return this._mM; - }, - set: function (m) { - __trace("IComment.motionManager is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - CommentCanvas.prototype.bindParent = function (params) { - if (params.hasOwnProperty("parent")) { - params["parent"].addChild(this); - } - }; - CommentCanvas.prototype.initStyle = function (style) { - if (style["lifeTime"]) { - this._mM.dur = style["lifeTime"] * 1000; - } - if (style.hasOwnProperty("motionGroup")) { - this._mM.initTweenGroup(style["motionGroup"], this._mM.dur); - } - else if (style.hasOwnProperty("motion")) { - this._mM.initTween(style["motion"], false); - } - }; - return CommentCanvas; - }(Display.Sprite)); - function createCanvas(params) { - return new CommentCanvas(params); - } - Display.createCanvas = createCanvas; -})(Display || (Display = {})); -var Display; -(function (Display) { - var Shape = (function (_super) { - __extends(Shape, _super); - function Shape() { - var _this = _super.call(this) || this; - _this._graphics = new Display.Graphics(_this); - return _this; - } - Object.defineProperty(Shape.prototype, "graphics", { - get: function () { - return this._graphics; - }, - enumerable: true, - configurable: true - }); - Shape.prototype.serialize = function () { - var serialized = _super.prototype.serialize.call(this); - serialized['class'] = 'Shape'; - return serialized; - }; - return Shape; - }(Display.DisplayObject)); - Display.Shape = Shape; -})(Display || (Display = {})); -var Display; -(function (Display) { - var CommentShape = (function (_super) { - __extends(CommentShape, _super); - function CommentShape(params) { - var _this = _super.call(this) || this; - _this._mM = new Display.MotionManager(_this); - _this.setDefaults(params); - _this.initStyle(params); - Runtime.registerObject(_this); - _this.bindParent(params); - _this._mM.play(); - return _this; - } - Object.defineProperty(CommentShape.prototype, "motionManager", { - get: function () { - return this._mM; - }, - set: function (m) { - __trace("IComment.motionManager is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - CommentShape.prototype.bindParent = function (params) { - if (params.hasOwnProperty("parent")) { - params["parent"].addChild(this); - } - }; - CommentShape.prototype.initStyle = function (style) { - if (typeof style === 'undefined' || style === null) { - style = {}; - } - if (style["lifeTime"]) { - this._mM.dur = style["lifeTime"] * 1000; - } - if (style.hasOwnProperty("motionGroup")) { - this._mM.initTweenGroup(style["motionGroup"], this._mM.dur); - } - else if (style.hasOwnProperty("motion")) { - this._mM.initTween(style["motion"], false); - } - }; - return CommentShape; - }(Display.Shape)); - function createShape(params) { - return new CommentShape(params); - } - Display.createShape = createShape; -})(Display || (Display = {})); -var Display; -(function (Display) { - var TextFormat = (function () { - function TextFormat(font, size, color, bold, italic, underline, url, target, align, leftMargin, rightMargin, indent, leading) { - if (font === void 0) { font = "SimHei"; } - if (size === void 0) { size = 25; } - if (color === void 0) { color = 0xFFFFFF; } - if (bold === void 0) { bold = false; } - if (italic === void 0) { italic = false; } - if (underline === void 0) { underline = false; } - if (url === void 0) { url = ""; } - if (target === void 0) { target = ""; } - if (align === void 0) { align = "left"; } - if (leftMargin === void 0) { leftMargin = 0; } - if (rightMargin === void 0) { rightMargin = 0; } - if (indent === void 0) { indent = 0; } - if (leading === void 0) { leading = 0; } - this.font = font; - this.size = size; - this.color = color; - this.bold = bold; - this.italic = italic; - this.underline = underline; - } - TextFormat.prototype.serialize = function () { - return { - "class": "TextFormat", - "font": this.font, - "size": this.size, - "color": this.color, - "bold": this.bold, - "underline": this.underline, - "italic": this.italic - }; - }; - return TextFormat; - }()); - var TextField = (function (_super) { - __extends(TextField, _super); - function TextField(text, color) { - if (text === void 0) { text = ""; } - if (color === void 0) { color = 0; } - var _this = _super.call(this) || this; - _this._background = false; - _this._backgroundColor = 0xffffff; - _this._border = false; - _this._borderColor = 0; - _this._text = text; - _this._textFormat = new TextFormat(); - _this._textFormat.color = color; - _this.boundingBox.width = _this.textWidth; - _this.boundingBox.height = _this.textHeight; - return _this; - } - Object.defineProperty(TextField.prototype, "text", { - get: function () { - return this._text; - }, - set: function (t) { - this._text = t; - this.boundingBox.width = this.textWidth; - this.boundingBox.height = this.textHeight; - this.propertyUpdate("text", this._text); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "length", { - get: function () { - return this.text.length; - }, - set: function (l) { - __trace("TextField.length is read-only.", "warn"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "htmlText", { - get: function () { - return this.text; - }, - set: function (text) { - __trace("TextField.htmlText is restricted due to security policy.", "warn"); - this.text = text.replace(/<\/?[^>]+(>|$)/g, ''); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "textWidth", { - get: function () { - return this._text.length * this._textFormat.size; - }, - set: function (w) { - __trace("TextField.textWidth is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "textHeight", { - get: function () { - return this._textFormat.size; - }, - set: function (h) { - __trace("TextField.textHeight is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "color", { - get: function () { - return this._textFormat.color; - }, - set: function (c) { - this._textFormat.color = c; - this.setTextFormat(this._textFormat); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "background", { - get: function () { - return this._background; - }, - set: function (enabled) { - this._background = enabled; - this.propertyUpdate("background", enabled); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "backgroundColor", { - get: function () { - return this._backgroundColor; - }, - set: function (color) { - this._backgroundColor = color; - this.propertyUpdate("backgroundColor", color); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "border", { - get: function () { - return this._border; - }, - set: function (enabled) { - this._border = enabled; - this.propertyUpdate('border', enabled); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TextField.prototype, "borderColor", { - get: function () { - return this._borderColor; - }, - set: function (color) { - this._borderColor = color; - this.propertyUpdate('borderColor', color); - }, - enumerable: true, - configurable: true - }); - TextField.prototype.getTextFormat = function () { - return this._textFormat; - }; - TextField.prototype.setTextFormat = function (tf) { - this._textFormat = tf; - this.methodCall("setTextFormat", tf.serialize()); - }; - TextField.prototype.appendText = function (t) { - this.text = this.text + t; - }; - TextField.prototype.serialize = function () { - var serialized = _super.prototype.serialize.call(this); - serialized["class"] = "TextField"; - serialized["text"] = this._text; - serialized["textFormat"] = this._textFormat.serialize(); - return serialized; - }; - return TextField; - }(Display.DisplayObject)); - Display.TextField = TextField; - function createTextFormat() { - return new TextFormat(); - } - Display.createTextFormat = createTextFormat; -})(Display || (Display = {})); -var Display; -(function (Display) { - var CommentField = (function (_super) { - __extends(CommentField, _super); - function CommentField(text, params) { - if (params === void 0) { params = {}; } - var _this = _super.call(this, text, 0xffffff) || this; - _this._mM = new Display.MotionManager(_this); - _this.setDefaults(params); - _this.initStyle(params); - Runtime.registerObject(_this); - _this.bindParent(params); - _this._mM.play(); - return _this; - } - Object.defineProperty(CommentField.prototype, "fontsize", { - get: function () { - return this.getTextFormat().fontsize; - }, - set: function (size) { - var tf = this.getTextFormat(); - tf.size = size; - this.setTextFormat(tf); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CommentField.prototype, "font", { - get: function () { - return this.getTextFormat().font; - }, - set: function (fontname) { - var tf = this.getTextFormat(); - tf.font = fontname; - this.setTextFormat(tf); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CommentField.prototype, "align", { - get: function () { - return this.getTextFormat().align; - }, - set: function (a) { - var tf = this.getTextFormat(); - tf.align = a; - this.setTextFormat(tf); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CommentField.prototype, "bold", { - get: function () { - return this.getTextFormat().bold; - }, - set: function (b) { - var tf = this.getTextFormat(); - tf.bold = b; - this.setTextFormat(tf); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CommentField.prototype, "motionManager", { - get: function () { - return this._mM; - }, - set: function (m) { - __trace("IComment.motionManager is read-only", "warn"); - }, - enumerable: true, - configurable: true - }); - CommentField.prototype.bindParent = function (params) { - if (params.hasOwnProperty("parent")) { - params["parent"].addChild(this); - } - }; - CommentField.prototype.initStyle = function (style) { - if (typeof style === 'undefined' || style === null) { - style = {}; - } - if ("lifeTime" in style) { - this._mM.dur = style["lifeTime"] * 1000; - } - if ("fontsize" in style) { - this.getTextFormat().size = style["fontsize"]; - } - if ("font" in style) { - this.getTextFormat().font = style["font"]; - } - if ("color" in style) { - this.getTextFormat().color = style["color"]; - } - if ("bold" in style) { - this.getTextFormat().bold = style["bold"]; - } - if (style.hasOwnProperty("motionGroup")) { - this._mM.initTweenGroup(style["motionGroup"], this._mM.dur); - } - else if (style.hasOwnProperty("motion")) { - this._mM.initTween(style["motion"], false); - } - }; - return CommentField; - }(Display.TextField)); - function createComment(text, params) { - return new CommentField(text, params); - } - Display.createComment = createComment; - function createTextField() { - return new CommentField("", {}); - } - Display.createTextField = createTextField; -})(Display || (Display = {})); -var Display; -(function (Display) { - var _root = new Display.RootSprite(); - var _width = 0; - var _height = 0; - var _fullScreenWidth = 0; - var _fullScreenHeight = 0; - var _frameRate = 24; - Object.defineProperty(Display, 'root', { - get: function () { - return _root; - }, - set: function (value) { - __trace("Display.root is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'loaderInfo', { - get: function () { - return {}; - }, - set: function (value) { - __trace("Display.loaderInfo is disabled", "warn"); - } - }); - Object.defineProperty(Display, 'stage', { - get: function () { - return _root; - }, - set: function (value) { - __trace("Display.stage is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'version', { - get: function () { - return "CCLDisplay/1.0 HTML5/* (bilibili, like BSE, like flash, AS3 compatible) KagerouEngine/v1"; - }, - set: function (value) { - __trace("Display.version is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'width', { - get: function () { - return _width; - }, - set: function (value) { - __trace("Display.width is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'height', { - get: function () { - return _height; - }, - set: function (value) { - __trace("Display.height is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'fullScreenWidth', { - get: function () { - return _fullScreenWidth; - }, - set: function (value) { - __trace("Display.fullScreenWidth is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'fullScreenHeight', { - get: function () { - return _fullScreenHeight; - }, - set: function (value) { - __trace("Display.fullScreenHeight is read-only", "warn"); - } - }); - Object.defineProperty(Display, 'frameRate', { - get: function () { - return _frameRate; - }, - set: function (value) { - _frameRate = value; - __pchannel("Display:SetFrameRate", value); - } - }); - function toString() { - return "[display Display]"; - } - Display.toString = toString; - __schannel("Update:DimensionUpdate", function (payload) { - _width = payload["stageWidth"]; - _height = payload["stageHeight"]; - if (payload.hasOwnProperty("screenWidth") && payload.hasOwnProperty("screenHeight")) { - _fullScreenWidth = payload["screenWidth"]; - _fullScreenHeight = payload["screenHeight"]; - } - }); -})(Display || (Display = {})); -var $ = Display; diff --git a/dist/scripting/api/Function.js b/dist/scripting/api/Function.js deleted file mode 100644 index cd229a0..0000000 --- a/dist/scripting/api/Function.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Global Functions - * @description Functions defined in the global namespace. - **/ - -function trace (msg) { - if (typeof msg === 'object') { - __trace(JSON.stringify(msg), 'log'); - } else { - __trace(msg, 'log'); - } -} - -function load (library, onComplete) { - if (typeof Runtime === 'undefined' || Runtime === null) { - __trace('No runtime defined. Attempting to raw-load library!', 'warn'); - importScripts(library + '.js'); - } else { - // Delegate this to runtime - Runtime.requestLibrary(library, function (error, response) { - if (error) { - __trace('Load: ' + error, 'warn'); - } else { - if (response.type === 'import') { - importScripts(response.location); - } else if (response.type === 'raw') { - try { - eval(response.code); - } catch (e) { - __trace('Load: ' + e, 'warn'); - } - } else if (response.type === 'object') { - if (typeof self === 'object' && self !== null) { - self[response.name] = response.obj; - } - } else if (response.type === 'noop') { - // Don't do anything - // This means library was already loaded - } - // Execute the remaining code - if (typeof onComplete === 'function') { - onComplete(); - } - } - }); - } -} - -function clone (target) { - if (null === target || 'object' !== typeof target) { - return target; - } - - // Clone an array - if (Array.isArray(target)) { - return target.slice(0); - } - - // Call the object's own clone method if possible - if (target.hasOwnProperty('clone') || typeof target['clone'] === 'function') { - return target.clone(); - } - - // Perform a shallow clone - var copy = {}; - copy.constructor = copy.constructor; - copy.prototype = copy.prototype; - for (var x in target) { - copy[x] = target[x]; - } - return copy; -} - -function foreach (enumerable, f) { - if (null === enumerable || "object" !== typeof enumerable) { - return; - } - // DisplayObjects do not have any enumerable properties - if (enumerable instanceof Display.DisplayObject) { - return; - } - - for (var x in enumerable) { - if (enumerable.hasOwnProperty(x)) { - f(x, enumerable[x]); - } - } - return; -} - -var none = null; diff --git a/dist/scripting/api/Global.js b/dist/scripting/api/Global.js deleted file mode 100644 index 08dc230..0000000 --- a/dist/scripting/api/Global.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Global Key-Value Store - * @description Key-value store in the global namespace - */ - -var Global = new function () { - var _store = {}; - - this._set = function (key, val) { - _store[key] = val; - }; - - this._get = function (key) { - return _store[key]; - }; - - this._ = function (key) { - return this._get(key); - }; -}; - -var $G = Global; diff --git a/dist/scripting/api/Player.js b/dist/scripting/api/Player.js deleted file mode 100644 index 74b0946..0000000 --- a/dist/scripting/api/Player.js +++ /dev/null @@ -1,220 +0,0 @@ -var CommentData = (function () { - function CommentData(comment) { - this._dbid = 0; - this.blocked = false; - this.blockType = 0; - this.border = false; - this.credit = false; - this.date = ""; - this.deleted = false; - this.id = 0; - this.mode = 0; - this.msg = ""; - this.live = true; - this.locked = true; - this.on = true; - this.pool = 0; - this.preview = false; - this.reported = false; - this.size = 25; - this.stime = 0; - this.text = ""; - this.type = ""; - this.uid = ""; - this._dbid = comment["dbid"]; - this.size = comment["size"]; - this.text = comment["text"]; - this.mode = comment["mode"]; - this.stime = comment["stime"]; - this.date = comment["date"]; - } - Object.defineProperty(CommentData.prototype, "danmuId", { - get: function () { - return this._dbid; - }, - enumerable: true, - configurable: true - }); - return CommentData; -}()); -var Player; -(function (Player) { - var Sound = (function () { - function Sound(type, onload) { - this._isPlaying = false; - this.onload = onload; - this._source = type; - } - Sound.prototype.createFromURL = function (url) { - this._source = url; - }; - Sound.prototype.play = function () { - }; - Sound.prototype.remove = function () { - }; - Sound.prototype.stop = function () { - }; - Sound.prototype.loadPercent = function () { - return 0; - }; - Sound.prototype.serialize = function () { - return { - 'class': 'Sound', - 'url': this._source - }; - }; - return Sound; - }()); -})(Player || (Player = {})); -var Player; -(function (Player) { - var _state = ''; - var _time; - var _commentList; - var _refreshRate; - var _width; - var _height; - var _videoWidth; - var _videoHeight; - var _lastUpdate = new Runtime.TimeKeeper(); - Object.defineProperty(Player, 'state', { - get: function () { return _state; }, - set: function (value) { - __trace('Player.state is read-only', 'warn'); - } - }); - Object.defineProperty(Player, 'time', { - get: function () { - if (_state !== 'playing') { - return _time; - } - else { - return _time + _lastUpdate.elapsed; - } - }, - set: function (value) { - __trace('Player.time is read-only', 'warn'); - } - }); - Object.defineProperty(Player, 'commentList', { - get: function () { - return _commentList; - }, - set: function (value) { - __trace('Player.commentData is read-only', 'warn'); - } - }); - Object.defineProperty(Player, 'refreshRate', { - get: function () { - return _refreshRate; - }, - set: function (value) { - __trace("Player.refreshRate deprecated. Please use Display.frameRate", "warn"); - } - }); - Object.defineProperty(Player, 'width', { - get: function () { return _width; }, - set: function (value) { - __trace("Player.width is read-only", "warn"); - } - }); - Object.defineProperty(Player, 'height', { - get: function () { return _height; }, - set: function (value) { - __trace("Player.height is read-only", "warn"); - } - }); - Object.defineProperty(Player, 'videoWidth', { - get: function () { return _videoWidth; }, - set: function (value) { - __trace("Player.videoWidth is read-only", "warn"); - } - }); - Object.defineProperty(Player, 'videoHeight', { - get: function () { return _videoHeight; }, - set: function (value) { - __trace("Player.videoHeight is read-only", "warn"); - } - }); - Object.defineProperty(Player, 'version', { - get: function () { - return 'CCLPlayer/1.0 HTML5/* (bilibili, like BSE, like flash)'; - }, - set: function (value) { - __trace('Player.version is read-only', 'warn'); - } - }); - function play() { - __pchannel("Player::action", { - "action": "play" - }); - } - Player.play = play; - function pause() { - __pchannel("Player::action", { - "action": "pause" - }); - } - Player.pause = pause; - function seek(offset) { - __pchannel("Player::action", { - "action": "seek", - "params": offset - }); - } - Player.seek = seek; - function jump(video, page, newWindow) { - if (page === void 0) { page = 1; } - if (newWindow === void 0) { newWindow = false; } - __pchannel("Player::action", { - "action": "jump", - "params": { - "vid": video, - "page": page, - "window": newWindow - } - }); - } - Player.jump = jump; - function commentTrigger(callback, timeout) { - if (!Runtime.hasObject('__player')) { - __trace('Your environment does not support player triggers.', 'warn'); - return; - } - __trace('Comment trigger: not implemented', 'warn'); - } - Player.commentTrigger = commentTrigger; - function keyTrigger(callback, timeout) { - if (!Runtime.hasObject('__player')) { - __trace('Your environment does not support key triggers.', 'warn'); - return; - } - var player = Runtime.getObject('__player'); - player.addEventListener('keydown', function (key) { - callback(key.keyCode); - }); - } - Player.keyTrigger = keyTrigger; - function setMask(mask) { - __trace('Masking not supported yet', 'warn'); - } - Player.setMask = setMask; - function toString() { - return '[player Player]'; - } - Player.toString = toString; - __schannel('Update:DimensionUpdate', function (payload) { - _width = payload["stageWidth"]; - _height = payload["stageHeight"]; - if (payload.hasOwnProperty("videoWidth") && - payload.hasOwnProperty("videoHeight")) { - _videoWidth = payload["videoWidth"]; - _videoHeight = payload["videoHeight"]; - } - }); - __schannel("Update:TimeUpdate", function (payload) { - _state = payload["state"]; - _time = payload["time"]; - _lastUpdate.reset(); - }); -})(Player || (Player = {})); diff --git a/dist/scripting/api/Runtime.js b/dist/scripting/api/Runtime.js deleted file mode 100644 index 52eeeb2..0000000 --- a/dist/scripting/api/Runtime.js +++ /dev/null @@ -1,673 +0,0 @@ -var Runtime; -(function (Runtime) { - var NotCrypto; - (function (NotCrypto) { - var _rngState = [ - Math.floor(Date.now() / 1024) % 1024, - Date.now() % 1024 - ]; - var Rc4 = (function () { - function Rc4(key) { - this._s = []; - for (var i = 0; i < 256; i++) { - this._s[i] = i; - } - var j = 0; - for (var i = 0; i < 256; i++) { - j = j + this._s[i] + key[i % key.length] % 256; - var m = this._s[i]; - this._s[i] = this._s[j]; - this._s[j] = m; - } - } - return Rc4; - }()); - function random(bits) { - if (bits === void 0) { bits = 16; } - if (bits > 32) { - throw new Error('NotCrypto.random expects 32 bits or less'); - } - if (Math && Math.random) { - var value = 0; - for (var i = 0; i < bits; i++) { - value = (value << 1) + (Math.random() < 0.5 ? 0 : 1); - } - return value; - } - else { - return Runtime.NotCrypto.fallbackRandom(Date.now() % 1024, bits); - } - } - NotCrypto.random = random; - function xorshift128p() { - var s0 = _rngState[1], s1 = _rngState[0]; - _rngState[0] = s0; - s1 ^= s1 << 23; - s1 ^= s1 >> 17; - s1 ^= s0; - s1 ^= s0 >> 26; - _rngState[1] = s1; - } - function fallbackRandom(seed, bits) { - if (bits === void 0) { bits = 16; } - if (bits > 32) { - throw new Error('NotCrypto.fallbackRandom expects 32 bits or less'); - } - for (var i = 0; i < seed; i++) { - xorshift128p(); - } - var mask = 0; - for (var i = 0; i < bits; i++) { - mask = (mask << 1) + 1; - } - return (_rngState[0] + _rngState[1]) & mask; - } - NotCrypto.fallbackRandom = fallbackRandom; - function toHex(value, length) { - if (length === void 0) { length = 0; } - if (length <= 0) { - return value.toString(16); - } - var base = value.toString(16); - while (base.length < length) { - base = '0' + base; - } - return base; - } - NotCrypto.toHex = toHex; - })(NotCrypto = Runtime.NotCrypto || (Runtime.NotCrypto = {})); -})(Runtime || (Runtime = {})); -var Runtime; -(function (Runtime) { - var RuntimeTimer = (function () { - function RuntimeTimer(type, dur, key, callback) { - this.ttl = dur; - this.dur = dur; - this.key = key; - this.type = type; - this.callback = callback; - } - return RuntimeTimer; - }()); - var TimerRuntime = (function () { - function TimerRuntime(precision) { - if (precision === void 0) { precision = 10; } - this._timer = -1; - this._timers = []; - this._lastToken = 0; - this._key = 0; - this._precision = precision; - } - Object.defineProperty(TimerRuntime.prototype, "isRunning", { - get: function () { - return this._timer > -1; - }, - set: function (state) { - if (state == false) { - this.stop(); - } - else { - this.start(); - } - }, - enumerable: true, - configurable: true - }); - TimerRuntime.prototype.start = function () { - if (this._timer < 0) { - this._lastToken = Date.now(); - var _self = this; - this._timer = setInterval(function () { - var elapsed = Date.now() - _self._lastToken; - for (var i = 0; i < _self._timers.length; i++) { - var timer = _self._timers[i]; - if (timer.type === "timeout") { - timer.ttl -= elapsed; - if (timer.ttl <= 0) { - try { - timer.callback(); - } - catch (e) { - __trace(e.stack.toString(), 'err'); - } - _self._timers.splice(i, 1); - i--; - } - } - else if (timer.type === 'interval') { - timer.ttl -= elapsed; - if (timer.ttl <= 0) { - try { - timer.callback(); - } - catch (e) { - __trace(e.stack.toString(), 'err'); - } - timer.ttl += timer.dur; - } - } - else { - } - } - _self._lastToken = Date.now(); - }, this._precision); - } - }; - TimerRuntime.prototype.stop = function () { - if (this._timer > -1) { - clearInterval(this._timer); - this._timer = -1; - } - }; - TimerRuntime.prototype.setInterval = function (f, interval) { - var myKey = this._key++; - this._timers.push(new RuntimeTimer('interval', interval, myKey, f)); - return myKey; - }; - TimerRuntime.prototype.setTimeout = function (f, timeout) { - var myKey = this._key++; - this._timers.push(new RuntimeTimer('timeout', timeout, myKey, f)); - return myKey; - }; - TimerRuntime.prototype.clearInterval = function (id) { - for (var i = 0; i < this._timers.length; i++) { - if (this._timers[i].type === 'interval' && - this._timers[i].key === id) { - this._timers.splice(i, 1); - return; - } - } - }; - TimerRuntime.prototype.clearTimeout = function (id) { - for (var i = 0; i < this._timers.length; i++) { - if (this._timers[i].type === 'timeout' && - this._timers[i].key === id) { - this._timers.splice(i, 1); - return; - } - } - }; - TimerRuntime.prototype.clearAll = function (type) { - if (type === void 0) { type = 'all'; } - if (type === 'timer') { - this._timers = this._timers.filter(function (t) { return t.type !== 'timer'; }); - } - else if (type === 'interval') { - this._timers = this._timers.filter(function (t) { return t.type !== 'interval'; }); - } - else { - this._timers = []; - } - }; - return TimerRuntime; - }()); - var Timer = (function () { - function Timer(delay, repeatCount) { - if (repeatCount === void 0) { repeatCount = 0; } - this._repeatCount = 0; - this._delay = 0; - this._microtime = 0; - this._timer = -1; - this._listeners = []; - this._complete = []; - this.currentCount = 0; - this._delay = delay; - this._repeatCount = repeatCount; - } - Object.defineProperty(Timer.prototype, "isRunning", { - get: function () { - return this._timer >= 0; - }, - set: function (b) { - __trace('Timer.isRunning is read-only', 'warn'); - }, - enumerable: true, - configurable: true - }); - Timer.prototype.start = function () { - if (!this.isRunning) { - var lastTime = Date.now(); - var self = this; - this._timer = setInterval(function () { - var elapsed = Date.now() - lastTime; - self._microtime += elapsed; - if (self._microtime > self._delay) { - self._microtime -= self._delay; - self.currentCount++; - self.dispatchEvent('timer'); - } - lastTime = Date.now(); - if (self._repeatCount > 0 && - self._repeatCount <= self.currentCount) { - self.stop(); - self.dispatchEvent('timerComplete'); - } - }, 20); - } - }; - Timer.prototype.stop = function () { - if (this.isRunning) { - clearInterval(this._timer); - this._timer = -1; - } - }; - Timer.prototype.reset = function () { - this.stop(); - this.currentCount = 0; - this._microtime = 0; - }; - Timer.prototype.addEventListener = function (type, listener) { - if (type === 'timer') { - this._listeners.push(listener); - } - else if (type === 'timerComplete') { - this._complete.push(listener); - } - }; - Timer.prototype.dispatchEvent = function (event) { - if (event === 'timer') { - for (var i = 0; i < this._listeners.length; i++) { - this._listeners[i](); - } - } - else if (event === 'timerComplete') { - for (var i = 0; i < this._complete.length; i++) { - this._complete[i](); - } - } - }; - return Timer; - }()); - Runtime.Timer = Timer; - var TimeKeeper = (function () { - function TimeKeeper(clock) { - if (clock === void 0) { clock = function () { return Date.now(); }; } - this._clock = clock; - this.reset(); - } - Object.defineProperty(TimeKeeper.prototype, "elapsed", { - get: function () { - return this._clock() - this._lastTime; - }, - enumerable: true, - configurable: true - }); - TimeKeeper.prototype.reset = function () { - this._lastTime = this._clock(); - }; - return TimeKeeper; - }()); - Runtime.TimeKeeper = TimeKeeper; - var masterTimer = new TimerRuntime(); - var internalTimer = new Timer(40); - var enterFrameDispatcher = function () { - for (var object in Runtime.registeredObjects) { - if (object.substring(0, 2) === '__') { - continue; - } - try { - Runtime.registeredObjects[object].dispatchEvent('enterFrame'); - } - catch (e) { } - } - }; - masterTimer.start(); - internalTimer.start(); - internalTimer.addEventListener('timer', enterFrameDispatcher); - function getTimer() { - return masterTimer; - } - Runtime.getTimer = getTimer; - function updateFrameRate(frameRate) { - if (frameRate > 60 || frameRate < 0) { - __trace('Frame rate should be in the range (0, 60]', 'warn'); - return; - } - if (frameRate === 0) { - internalTimer.stop(); - return; - } - internalTimer.stop(); - internalTimer = new Timer(Math.floor(1000 / frameRate)); - internalTimer.addEventListener('timer', enterFrameDispatcher); - internalTimer.start(); - } - Runtime.updateFrameRate = updateFrameRate; -})(Runtime || (Runtime = {})); -var Runtime; -(function (Runtime) { - var ScriptManagerImpl = (function () { - function ScriptManagerImpl() { - this._managedElements = {}; - } - ScriptManagerImpl.prototype._registerElement = function (name, mM) { - this._managedElements[name] = mM; - }; - ScriptManagerImpl.prototype.clearTimer = function () { - Runtime.getTimer().clearAll('interval'); - }; - ScriptManagerImpl.prototype.clearEl = function () { - __trace("ScriptManager.clearEl not implemented.", "warn"); - }; - ScriptManagerImpl.prototype.clearTrigger = function () { - __trace("ScriptManager.clearTrigger not implemented.", "warn"); - }; - ScriptManagerImpl.prototype.pushEl = function (el) { - __trace("ScriptManager.pushEl not implemented.", "warn"); - }; - ScriptManagerImpl.prototype.popEl = function (el) { - __trace("ScriptManager.popEl is not properly implemented.", "warn"); - if (el['motionManager']) { - el['motionManager'].stop(); - } - }; - ScriptManagerImpl.prototype.pushTimer = function (t) { - __trace("ScriptManager.pushTimer not implemented.", "warn"); - }; - ScriptManagerImpl.prototype.popTimer = function (t) { - __trace("ScriptManager.popTimer not implemented.", "warn"); - }; - ScriptManagerImpl.prototype.toString = function () { - return '[scriptManager ScriptManager]'; - }; - return ScriptManagerImpl; - }()); - Runtime._defaultScriptManager = new ScriptManagerImpl(); -})(Runtime || (Runtime = {})); -var ScriptManager = Runtime._defaultScriptManager; -var Runtime; -(function (Runtime) { - var permissions = {}; - function requestPermission(name, callback) { - __channel("Runtime:RequestPermission", { - "name": name - }, function (result) { - if (result === true) { - permissions[name] = true; - } - else { - permissions[name] = false; - } - if (typeof callback === "function") { - callback(result); - } - }); - } - Runtime.requestPermission = requestPermission; - function hasPermission(name) { - if (permissions.hasOwnProperty(name) && - permissions[name]) { - return true; - } - return false; - } - Runtime.hasPermission = hasPermission; - function openWindow(url, params, callback) { - if (callback === void 0) { callback = null; } - __channel("Runtime:PrivilegedAPI", { - "method": "openWindow", - "params": [url, params] - }, function (windowId) { - var WND = { - "moveTo": function (x, y) { - __pchannel("Runtime:PrivilegedAPI", { - "method": "window", - "params": [windowId, "moveTo", [x, y]] - }); - }, - "resizeTo": function (w, h) { - __pchannel("Runtime:PrivilegedAPI", { - "method": "window", - "params": [windowId, "resizeTo", [w, h]] - }); - }, - "focus": function () { - __pchannel("Runtime:PrivilegedAPI", { - "method": "window", - "params": [windowId, "focus"] - }); - }, - "close": function () { - __pchannel("Runtime:PrivilegedAPI", { - "method": "window", - "params": [windowId, "close"] - }); - } - }; - if (callback !== null) { - callback(WND); - } - }); - } - Runtime.openWindow = openWindow; - function injectStyle(referenceObject, style) { - __pchannel("Runtime:PrivilegedAPI", { - "method": "injectStyle", - "params": [referenceObject, style] - }); - } - Runtime.injectStyle = injectStyle; - function privilegedCode() { - __trace('Runtime.privilegedCode not available.', 'warn'); - } - Runtime.privilegedCode = privilegedCode; -})(Runtime || (Runtime = {})); -var Runtime; -(function (Runtime) { - var supported = { - "js": ["*"], - "Runtime": ["*", "openWindow", "injectStyle"], - "Display": ["*"], - "Player": ["*"], - "Tween": ["*"], - "Utils": ["*"] - }; - function supports(featureName, subfeature) { - if (subfeature === void 0) { subfeature = "*"; } - if (!supported.hasOwnProperty(featureName)) { - return false; - } - else { - if (supported[featureName].indexOf(subfeature) >= 0) { - return true; - } - } - return false; - } - Runtime.supports = supports; - ; - function requestLibrary(libraryName, callback) { - if (libraryName === 'libBitmap') { - callback(null, { - 'type': 'noop' - }); - } - else { - callback(new Error('Could not load unknown library [' + libraryName + ']'), null); - } - } - Runtime.requestLibrary = requestLibrary; -})(Runtime || (Runtime = {})); -var Runtime; -(function (Runtime) { - var MetaObject = (function () { - function MetaObject(name) { - this._listeners = {}; - if (name.slice(0, 2) !== '__') { - throw new Error('MetaObject names must start with two underscores.'); - } - this._name = name; - } - MetaObject.prototype.addEventListener = function (event, listener, useCapture, priority) { - if (useCapture === void 0) { useCapture = false; } - if (priority === void 0) { priority = 0; } - if (!(event in this._listeners)) { - this._listeners[event] = []; - } - this._listeners[event].push(listener); - }; - MetaObject.prototype.removeEventListener = function (event, listener, useCapture) { - if (useCapture === void 0) { useCapture = false; } - if (!(event in this._listeners)) { - return; - } - var index = this._listeners[event].indexOf(listener); - if (index >= 0) { - this._listeners[event].splice(index, 1); - } - }; - MetaObject.prototype.hasEventListener = function (event) { - return event in this._listeners && this._listeners[event].length > 0; - }; - MetaObject.prototype.dispatchEvent = function (event, data) { - if (!(event in this._listeners)) { - return; - } - for (var i = 0; i < this._listeners[event].length; i++) { - this._listeners[event][i](data); - } - }; - MetaObject.prototype.getId = function () { - return this._name; - }; - MetaObject.prototype.serialize = function () { - return { - "class": this._name - }; - }; - MetaObject.prototype.unload = function () { - throw new Error('Meta objects should not be unloaded!'); - }; - return MetaObject; - }()); - var objCount = 0; - var _registeredObjects = { - '__self': new MetaObject('__self'), - '__player': new MetaObject('__player'), - '__root': new MetaObject('__root') - }; - Object.defineProperty(Runtime, 'registeredObjects', { - get: function () { - return _registeredObjects; - }, - set: function (value) { - __trace('Runtime.registeredObjects is read-only', 'warn'); - } - }); - function _dispatchEvent(objectId, event, payload) { - var obj = _registeredObjects[objectId]; - if (typeof obj === "object") { - if (obj.dispatchEvent) { - obj.dispatchEvent(event, payload); - } - } - } - function hasObject(objectId) { - return _registeredObjects.hasOwnProperty(objectId) && - _registeredObjects[objectId] !== null; - } - Runtime.hasObject = hasObject; - function getObject(objectId) { - return _registeredObjects[objectId]; - } - Runtime.getObject = getObject; - function registerObject(object) { - if (!object.getId) { - __trace('Cannot register object without getId method.', 'warn'); - return; - } - if (!Runtime.hasObject(object.getId())) { - _registeredObjects[object.getId()] = object; - __pchannel('Runtime:RegisterObject', { - 'id': object.getId(), - 'data': object.serialize() - }); - __schannel("object::(" + object.getId() + ")", function (payload) { - if (payload.hasOwnProperty('type') && - payload.type === 'event') { - _dispatchEvent(object.getId(), payload.event, payload.data); - } - }); - objCount++; - return; - } - else { - __trace('Attempted to re-register object or id collision @ ' + - object.getId(), 'warn'); - return; - } - } - Runtime.registerObject = registerObject; - function deregisterObject(object) { - var objectId = object.getId(); - deregisterObjectById(objectId); - } - Runtime.deregisterObject = deregisterObject; - function deregisterObjectById(objectId) { - if (Runtime.hasObject(objectId)) { - if (objectId.substr(0, 2) === '__') { - __trace('Runtime.deregisterObject cannot de-register a MetaObject', 'warn'); - return; - } - __pchannel('Runtime:DeregisterObject', { - 'id': objectId - }); - if (typeof _registeredObjects[objectId].unload === "function") { - _registeredObjects[objectId].unload(); - } - _registeredObjects[objectId] = null; - delete _registeredObjects[objectId]; - } - } - function _getId(type, container) { - if (type === void 0) { type = 'obj'; } - if (container === void 0) { container = 'rt'; } - var randomSeed = Math.random(); - var randomSegment = ''; - return; - } - function generateId(type) { - if (type === void 0) { type = "obj"; } - var id = [type, ':', Date.now(), '|', - Runtime.NotCrypto.random(16), ':', objCount].join(); - while (Runtime.hasObject(id)) { - id = type + ":" + Date.now() + "|" + - Runtime.NotCrypto.random(16) + ":" + objCount; - } - return id; - } - Runtime.generateId = generateId; - ; - function reset() { - for (var i in _registeredObjects) { - if (i.substr(0, 2) !== "__") { - deregisterObjectById(i); - } - } - } - Runtime.reset = reset; - function clear() { - for (var i in _registeredObjects) { - if (i.substr(0, 2) === "__") { - continue; - } - if (typeof _registeredObjects[i].unload === 'function') { - _registeredObjects[i].unload(); - } - } - } - Runtime.clear = clear; - function crash() { - __trace("Runtime.crash() : Manual crash", "fatal"); - } - Runtime.crash = crash; - function exit() { - __achannel("::worker:state", "worker", "terminated"); - self.close(); - } - Runtime.exit = exit; - function alert(msg) { - __achannel("Runtime::alert", "::Runtime", msg); - } - Runtime.alert = alert; -})(Runtime || (Runtime = {})); diff --git a/dist/scripting/api/Tween.js b/dist/scripting/api/Tween.js deleted file mode 100644 index a4d31a0..0000000 --- a/dist/scripting/api/Tween.js +++ /dev/null @@ -1,453 +0,0 @@ -var Tween; -(function (Tween) { - function linear(t, b, c, d) { - return t * c / d + b; - } - Tween.linear = linear; - function quadratic(t, b, c, d) { - t /= d / 2; - if (t < 1) - return c / 2 * t * t + b; - t--; - return -c / 2 * (t * (t - 2) - 1) + b; - } - Tween.quadratic = quadratic; - function cubic(t, b, c, d) { - t /= d / 2; - if (t < 1) - return c / 2 * t * t * t + b; - t -= 2; - return c / 2 * (t * t * t + 2) + b; - } - Tween.cubic = cubic; - function quartic(t, b, c, d) { - t /= d / 2; - if (t < 1) - return c / 2 * t * t * t * t + b; - t -= 2; - return -c / 2 * (t * t * t * t - 2) + b; - } - Tween.quartic = quartic; - function quintic(t, b, c, d) { - t /= d / 2; - if (t < 1) - return c / 2 * t * t * t * t * t + b; - t -= 2; - return c / 2 * (t * t * t * t * t + 2) + b; - } - Tween.quintic = quintic; - function circular(t, b, c, d) { - t /= d / 2; - if (t < 1) - return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; - t -= 2; - return c / 2 * (Math.sqrt(1 - t * t) + 1) + b; - } - Tween.circular = circular; - function sine(t, b, c, d) { - return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; - } - Tween.sine = sine; - function exponential(t, b, c, d) { - t /= d / 2; - if (t < 1) - return c / 2 * Math.pow(2, 10 * (t - 1)) + b; - t--; - return c / 2 * (-Math.pow(2, -10 * t) + 2) + b; - } - Tween.exponential = exponential; - function extendWithEasingFunctions(runtime) { - var load = { - linear: Tween.linear, - back: null, - bounce: null, - circular: Tween.circular, - cubic: Tween.cubic, - elastic: null, - exponential: Tween.exponential, - sine: Tween.sine, - quintic: Tween.quintic - }; - for (var i in load) { - runtime[i] = load[i]; - } - } - Tween.extendWithEasingFunctions = extendWithEasingFunctions; - function getEasingFuncByName(easing) { - if (easing === void 0) { easing = "None"; } - easing = easing.toLowerCase(); - switch (easing) { - case "none": - case "linear": - default: - return Tween.linear; - case "exponential": - return Tween.exponential; - case "circular": - return Tween.circular; - case "quadratic": - return Tween.quadratic; - case "cubic": - return Tween.cubic; - case "quartic": - return Tween.quartic; - case "quintic": - return Tween.quintic; - case "sine": - return Tween.sine; - } - } - Tween.getEasingFuncByName = getEasingFuncByName; -})(Tween || (Tween = {})); -Tween.extendWithEasingFunctions(self); -var Tween; -(function (Tween) { - var ITween = (function () { - function ITween(target, duration) { - if (duration === void 0) { duration = 0; } - this._target = null; - this._isPlaying = false; - this._currentTime = 0; - this._repeats = 0; - this.easing = Tween.linear; - this.step = function () { }; - this._target = target; - this._duration = duration; - this._timeKeeper = new Runtime.TimeKeeper(); - this._timer = new Runtime.Timer(40); - var self = this; - this._timer.addEventListener("timer", function () { - self._onTimerEvent(); - }); - } - ITween.prototype._onTimerEvent = function () { - if (this._isPlaying) { - this._currentTime += this._timeKeeper.elapsed; - this._timeKeeper.reset(); - this.step(this._target, this._currentTime, this._duration); - if (this._currentTime >= this._duration) { - this._repeats--; - if (this._repeats < 0) { - this.stop(); - this._currentTime = this._duration; - } - else { - this._currentTime = 0; - } - this.step(this._target, this._currentTime, this._duration); - } - } - }; - Object.defineProperty(ITween.prototype, "duration", { - get: function () { - return this._duration; - }, - set: function (dur) { - this._duration = dur; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ITween.prototype, "position", { - get: function () { - return this._currentTime; - }, - set: function (position) { - this._currentTime = position; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ITween.prototype, "repeat", { - get: function () { - return this._repeats; - }, - set: function (r) { - this._repeats = r; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ITween.prototype, "target", { - get: function () { - return this._target; - }, - set: function (a) { - __trace("Deprecated: You should not set a new target for an old tween.", "warn"); - this._target = a; - }, - enumerable: true, - configurable: true - }); - ITween.prototype.clone = function () { - var clone = new ITween(this._target, this._duration); - clone.easing = this.easing; - clone.step = this.step; - return clone; - }; - ITween.prototype.scale = function (factor) { - this._currentTime *= factor; - this._duration *= factor; - }; - ITween.prototype.play = function () { - if (this._isPlaying) { - return; - } - this.gotoAndPlay(this._currentTime); - }; - ITween.prototype.stop = function () { - if (!this._isPlaying) { - return; - } - this.gotoAndStop(this._currentTime); - }; - ITween.prototype.gotoAndStop = function (position) { - this._currentTime = position; - if (this._isPlaying) { - this._isPlaying = false; - this._timer.stop(); - } - this.step(this._target, this._currentTime, this._duration); - }; - ITween.prototype.gotoAndPlay = function (position) { - this._currentTime = position; - if (!this._isPlaying) { - this._isPlaying = true; - this._timer.start(); - } - this.step(this._target, this._currentTime, this._duration); - }; - ITween.prototype.togglePause = function () { - if (this._isPlaying) { - this.stop(); - } - else { - this.play(); - } - }; - return ITween; - }()); - Tween.ITween = ITween; - function createStepFunction(object, dest, src, tween) { - for (var property in dest) { - if (!src.hasOwnProperty(property)) { - src[property] = object[property]; - } - } - for (var property in src) { - if (!dest.hasOwnProperty(property)) { - dest[property] = src[property]; - } - } - return function (object, currentTime, totalTime) { - for (var property in src) { - if (!src.hasOwnProperty(property)) { - continue; - } - object[property] = tween.easing(currentTime, src[property], dest[property] - src[property], totalTime); - } - }; - } - function tween(object, dest, src, duration, easing) { - if (dest === void 0) { dest = {}; } - if (src === void 0) { src = {}; } - if (duration === void 0) { duration = 0; } - if (easing === void 0) { easing = null; } - var t = new ITween(object, duration * 1000); - t.step = createStepFunction(object, dest, src, t); - if (easing !== null) { - t.easing = easing; - } - return t; - } - Tween.tween = tween; - function to(object, dest, duration, easing) { - if (dest === void 0) { dest = {}; } - if (duration === void 0) { duration = 0; } - if (easing === void 0) { easing = null; } - var src = {}; - for (var x in dest) { - if (dest.hasOwnProperty(x)) { - if (typeof object[x] !== "undefined") { - src[x] = object[x]; - } - else { - src[x] = 0; - } - } - } - return Tween.tween(object, dest, src, duration, easing); - } - Tween.to = to; - function bezier(object, dest, src, control, duration, easing) { - if (duration === void 0) { duration = 1.0; } - if (easing === void 0) { easing = null; } - var tween = new ITween(object, duration * 1000); - if (easing !== null && typeof easing === 'function') { - tween.easing = easing; - } - var finalControlPoints = {}; - for (var prop in control) { - if (Array.isArray(control[prop]) && control[prop].length > 0) { - finalControlPoints[prop] = control[prop]; - } - } - if (typeof src === 'undefined' || src === null) { - src = {}; - } - if (typeof dest === 'undefined' || dest === null) { - dest = {}; - } - for (var prop in finalControlPoints) { - if (!(prop in src)) { - src[prop] = tween.target[prop]; - } - if (!(prop in dest)) { - dest[prop] = finalControlPoints[prop][finalControlPoints[prop].length - 1]; - } - } - tween.step = function (target, currentTime, totalTime) { - var t = Math.min(tween.easing(currentTime, 0, 1, totalTime), 1); - for (var prop in finalControlPoints) { - var controlPoints = finalControlPoints[prop]; - var numControl = controlPoints.length; - var firstIndex = Math.floor(t * numControl); - var segmentT = (t - firstIndex / numControl) * numControl; - if (numControl === 1) { - target[prop] = src[prop] + - 2 * t * (1 - t) * (controlPoints[0] - src[prop]) + - t * t * (dest[prop] - src[prop]); - } - else { - var p1 = 0; - var p2 = 0; - if (firstIndex === 0) { - p1 = src[prop]; - p2 = (controlPoints[0] + controlPoints[1]) / 2; - } - else if (firstIndex === numControl - 1) { - p1 = (controlPoints[firstIndex - 1] + controlPoints[firstIndex]) / 2; - p2 = dest[prop]; - } - else { - p1 = (controlPoints[firstIndex - 1] + controlPoints[firstIndex]) / 2; - p2 = (controlPoints[firstIndex] + controlPoints[firstIndex + 1]) / 2; - } - target[prop] = p1 + - 2 * segmentT * (1 - segmentT) * (controlPoints[firstIndex] - p1) + - segmentT * segmentT * (p2 - p1); - } - } - }; - return tween; - } - Tween.bezier = bezier; - function scale(src, scale) { - var clone = src.clone(); - clone.scale(scale); - return clone; - } - Tween.scale = scale; - function delay(src, delay) { - var newTween = new ITween(src.target, src.duration + delay * 1000); - newTween.step = function (target, currentTime, totalTime) { - if (currentTime <= delay * 1000) { - return; - } - src.step(target, currentTime - delay * 1000, totalTime - delay * 1000); - }; - return newTween; - } - Tween.delay = delay; - function reverse(src) { - var newTween = new ITween(src.target, src.duration); - newTween.step = function (target, currentTime, totalTime) { - src.step(target, totalTime - currentTime, totalTime); - }; - return newTween; - } - Tween.reverse = reverse; - function repeat(src, times) { - var newTween = new ITween(src.target, src.duration * times); - newTween.step = function (target, currentTime, totalTime) { - src.step(target, currentTime % src.duration, src.duration); - }; - return newTween; - } - Tween.repeat = repeat; - function slice(src, from, to) { - if (to === null) { - to = src.duration; - } - if (to < from) { - to = from; - } - from *= 1000; - to *= 1000; - var newTween = new ITween(src.target, to - from); - newTween.step = function (target, currentTime, totalTime) { - src.step(target, from + currentTime, src.duration); - }; - return newTween; - } - Tween.slice = slice; - function serial() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - if (args.length === 0) { - return new ITween({}, 0); - } - var totalTime = 0; - var end = []; - var start = []; - for (var i = 0; i < args.length; i++) { - start.push(totalTime); - totalTime += args[i].duration; - end.push(totalTime); - } - var newTween = new ITween({}, totalTime); - newTween["lastSeek"] = 0; - newTween.step = function (target, currentTime, totalTime) { - if (currentTime <= end[newTween["lastSeek"]]) { - var currentTween = args[newTween["lastSeek"]]; - currentTween.step(currentTween.target, currentTime - start[newTween["lastSeek"]], currentTween.duration); - return; - } - else { - var oldTween = args[newTween["lastSeek"]]; - oldTween.step(oldTween.target, oldTween.duration, oldTween.duration); - } - for (var seek = 0; seek < end.length; seek++) { - if (currentTime < end[seek]) { - newTween["lastSeek"] = seek; - var currentTween = args[newTween["lastSeek"]]; - currentTween.step(currentTween.target, currentTime - start[newTween["lastSeek"]], currentTween.duration); - return; - } - } - }; - return newTween; - } - Tween.serial = serial; - function parallel() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var totalTime = 0; - for (var i = 0; i < args.length; i++) { - totalTime = Math.max(args[i].duration, totalTime); - } - var tweens = args; - var newTween = new ITween({}, totalTime); - newTween.step = function (target, currentTime, totalTime) { - for (var i = 0; i < tweens.length; i++) { - tweens[i].step(tweens[i].target, Math.min(currentTime, tweens[i].duration), tweens[i].duration); - } - }; - return newTween; - } - Tween.parallel = parallel; -})(Tween || (Tween = {})); diff --git a/dist/scripting/api/Utils.js b/dist/scripting/api/Utils.js deleted file mode 100644 index 96fb5c3..0000000 --- a/dist/scripting/api/Utils.js +++ /dev/null @@ -1,114 +0,0 @@ -var Utils; -(function (Utils) { - var _startTime = Date.now(); - function HSV2RGB(hue, saturation, brightness) { - var r, g, b; - if (saturation == 0) { - r = g = b = 1; - } - else { - var h = (hue % 360) / 60; - var i = h | 0; - var f = h - i; - var p = 1 - saturation; - var q = 1 - saturation * f; - var t = 1 - saturation * (1 - f); - switch (i) { - case 0: - r = 1; - g = t; - b = p; - break; - case 1: - r = q; - g = 1; - b = p; - break; - case 2: - r = p; - g = 1; - b = t; - break; - case 3: - r = p; - g = q; - b = 1; - break; - case 4: - r = t; - g = p; - b = 1; - break; - case 5: - r = 1; - g = p; - b = q; - break; - } - } - r *= 255 * brightness; - g *= 255 * brightness; - b *= 255 * brightness; - return r << 16 | g << 8 | b; - } - function rgb(r, g, b) { - return r << 16 | g << 8 | b; - } - Utils.rgb = rgb; - function hue(h, s, v) { - if (s === void 0) { s = 1; } - if (v === void 0) { v = 1; } - return HSV2RGB(h, s, v); - } - Utils.hue = hue; - function formatTimes(time) { - return Math.floor(time / 60) + ":" + (time % 60 > 9 ? "" : "0") + time % 60; - } - Utils.formatTimes = formatTimes; - function distance(x1, y1, x2, y2) { - return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); - } - Utils.distance = distance; - function rand(min, max) { - return min + Math.floor(Math.random() * (max - min)); - } - Utils.rand = rand; - function getTimer() { - return Date.now() - _startTime; - } - Utils.getTimer = getTimer; - function timer(callback, delay) { - if (delay === void 0) { delay = 1000; } - return Runtime.getTimer().setTimeout(callback, delay); - } - Utils.timer = timer; - function interval(callback, interval, repeatCount) { - if (interval === void 0) { interval = 1000; } - if (repeatCount === void 0) { repeatCount = 1; } - if (repeatCount === 0) { - return Runtime.getTimer().setInterval(callback, interval); - } - var ivl = Runtime.getTimer().setInterval(function () { - repeatCount--; - if (repeatCount < 0) { - Runtime.getTimer().clearInterval(ivl); - } - else { - callback(); - } - }, interval); - return ivl; - } - Utils.interval = interval; - function clearTimeout(tid) { - Runtime.getTimer().clearTimeout(tid); - } - Utils.clearTimeout = clearTimeout; - function clearInterval(iid) { - Runtime.getTimer().clearInterval(iid); - } - Utils.clearInterval = clearInterval; -})(Utils || (Utils = {})); -var getTimer = Utils.getTimer; -var interval = Utils.interval; -var timer = Utils.timer; diff --git a/package-lock.json b/package-lock.json index d1ca94e..cbddb30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "comment-core-library", - "version": "0.11.0", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -13,6 +13,147 @@ "@babel/highlight": "^7.0.0" } }, + "@babel/core": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.5.tgz", + "integrity": "sha512-OvjIh6aqXtlsA8ujtGKfC7LYWksYSX8yQcM8Ay3LuvVeQ63lcOKgoZWVqcpFwkd29aYU9rVx7jxhfhiEDV9MZA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.4.4", + "@babel/helpers": "^7.4.4", + "@babel/parser": "^7.4.5", + "@babel/template": "^7.4.4", + "@babel/traverse": "^7.4.5", + "@babel/types": "^7.4.4", + "convert-source-map": "^1.1.0", + "debug": "^4.1.0", + "json5": "^2.1.0", + "lodash": "^4.17.11", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz", + "integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==", + "dev": true, + "requires": { + "@babel/types": "^7.4.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.11", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + }, + "dependencies": { + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "@babel/helper-create-class-features-plugin": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.4.4.tgz", + "integrity": "sha512-UbBHIa2qeAGgyiNR9RszVF7bUHEdgS4JAUNT8SiqrAN6YJVxlOxeLr5pBzb5kan302dejJ9nla4RyKcR1XT6XA==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-member-expression-to-functions": "^7.0.0", + "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-replace-supers": "^7.4.4", + "@babel/helper-split-export-declaration": "^7.4.4" + } + }, + "@babel/helper-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", + "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", + "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.0.0.tgz", + "integrity": "sha512-avo+lm/QmZlv27Zsi0xEor2fKcqWG56D5ae9dzklpIaY7cQMK5N8VSpaNVPPagiqmy7LrEjK1IWdGMOqPu5csg==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz", + "integrity": "sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", + "integrity": "sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==", + "dev": true + }, + "@babel/helper-replace-supers": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.4.4.tgz", + "integrity": "sha512-04xGEnd+s01nY1l15EuMS1rfKktNF+1CkKmHoErDppjAAZL+IUBZpzT748x262HF7fibaQPhbvWUl5HeSt1EXg==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.0.0", + "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", + "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", + "dev": true, + "requires": { + "@babel/types": "^7.4.4" + } + }, + "@babel/helpers": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.4.tgz", + "integrity": "sha512-igczbR/0SeuPR8RFfC7tGrbdTbFL3QTvH6D+Z6zNxnTe//GyqmtHmDkzrqDmyZ3eSwPqB/LhyKoU5DXsp+Vp2A==", + "dev": true, + "requires": { + "@babel/template": "^7.4.4", + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" + } + }, "@babel/highlight": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", @@ -24,6 +165,109 @@ "js-tokens": "^4.0.0" } }, + "@babel/parser": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.5.tgz", + "integrity": "sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==", + "dev": true + }, + "@babel/plugin-proposal-class-properties": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.4.4.tgz", + "integrity": "sha512-WjKTI8g8d5w1Bc9zgwSz2nfrsNQsXcCf9J9cdCvrJV6RF56yztwm4TmJC0MgJ9tvwO9gUA/mcYe89bLdGfiXFg==", + "dev": true, + "requires": { + "@babel/helper-create-class-features-plugin": "^7.4.4", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.4.4.tgz", + "integrity": "sha512-dMBG6cSPBbHeEBdFXeQ2QLc5gUpg4Vkaz8octD4aoW/ISO+jBOcsuxYL7bsb5WSu8RLP6boxrBIALEHgoHtO9g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.2.0" + } + }, + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz", + "integrity": "sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-typescript": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz", + "integrity": "sha512-dGwbSMA1YhVS8+31CnPR7LB4pcbrzcV99wQzby4uAfrkZPYZlQ7ImwdpzLqi6Z6IL02b8IAL379CaMwo0x5Lag==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-typescript": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.4.5.tgz", + "integrity": "sha512-RPB/YeGr4ZrFKNwfuQRlMf2lxoCUaU01MTw39/OFE/RiL8HDjtn68BwEPft1P7JN4akyEmjGWAMNldOV7o9V2g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-typescript": "^7.2.0" + } + }, + "@babel/preset-typescript": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.3.3.tgz", + "integrity": "sha512-mzMVuIP4lqtn4du2ynEfdO0+RYcslwrZiJHXu4MGaC1ctJiW2fyaeDrtjJGs7R/KebZ1sgowcIoWf4uRpEfKEg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-transform-typescript": "^7.3.2" + } + }, + "@babel/template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", + "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.4.4", + "@babel/types": "^7.4.4" + } + }, + "@babel/traverse": { + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.5.tgz", + "integrity": "sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.4.4", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.4.5", + "@babel/types": "^7.4.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.11" + } + }, + "@babel/types": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", + "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.11", + "to-fast-properties": "^2.0.0" + } + }, "@sinonjs/commons": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", @@ -66,52 +310,12 @@ "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", "dev": true }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", "dev": true }, - "acorn": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", - "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", - "dev": true - }, - "acorn-jsx": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", - "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", - "dev": true - }, - "agent-base": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", - "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", - "dev": true, - "requires": { - "es6-promisify": "^5.0.0" - } - }, - "agentkeepalive": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-3.5.2.tgz", - "integrity": "sha512-e0L/HNe6qkQ7H19kTlRRqUibEAwDK5AFk6y3PtMsuut2VAH6+Q4xZml1tNDJD7kSAyqmbG/K08K5WEJYtUrSlQ==", - "dev": true, - "requires": { - "humanize-ms": "^1.2.1" - } - }, "ajv": { "version": "6.10.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", @@ -130,12 +334,6 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, - "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true - }, "ansi-regex": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-1.1.1.tgz", @@ -172,12 +370,6 @@ } } }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "dev": true - }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -262,12 +454,6 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, - "astral-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", - "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", - "dev": true - }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -280,12 +466,6 @@ "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", "dev": true }, - "async-limiter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", - "dev": true - }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -398,12 +578,6 @@ "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, - "bluebird": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.4.tgz", - "integrity": "sha512-FG+nFEZChJrbQ9tIccIfZJBz3J7mLrAhxakAbnrJWn8d7aKOC+LWifa0G+p4ZqKp4y13T7juYvdhq9NzKdsrjw==", - "dev": true - }, "body": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz", @@ -464,71 +638,12 @@ "caniuse-db": "^1.0.30000153" } }, - "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true - }, - "builtins": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/builtins/-/builtins-1.0.3.tgz", - "integrity": "sha1-y5T662HIaWRR2zZTThQi+U8K7og=", - "dev": true - }, "bytes": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-1.0.0.tgz", "integrity": "sha1-NWnt6Lo0MV+rmcPpLLBMciDeH6g=", "dev": true }, - "cacache": { - "version": "11.3.2", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-11.3.2.tgz", - "integrity": "sha512-E0zP4EPGDOaT2chM08Als91eYnf8Z+eH1awwwVsngUmgppfM5jjJ8l3z5vO5p5w/I3LsiXawb1sW0VY65pQABg==", - "dev": true, - "requires": { - "bluebird": "^3.5.3", - "chownr": "^1.1.1", - "figgy-pudding": "^3.5.1", - "glob": "^7.1.3", - "graceful-fs": "^4.1.15", - "lru-cache": "^5.1.1", - "mississippi": "^3.0.0", - "mkdirp": "^0.5.1", - "move-concurrently": "^1.0.1", - "promise-inflight": "^1.0.1", - "rimraf": "^2.6.2", - "ssri": "^6.0.1", - "unique-filename": "^1.1.1", - "y18n": "^4.0.0" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dev": true, - "requires": { - "yallist": "^3.0.2" - } - } - } - }, "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", @@ -546,12 +661,6 @@ "unset-value": "^1.0.0" } }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true - }, "camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", @@ -591,12 +700,6 @@ "supports-color": "^5.3.0" } }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true - }, "chokidar": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz", @@ -617,12 +720,6 @@ "upath": "^1.1.1" } }, - "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", - "dev": true - }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -663,47 +760,6 @@ } } }, - "cli": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz", - "integrity": "sha1-IoF1NPJL+klQw01TLUjsvGIbjBQ=", - "dev": true, - "requires": { - "exit": "0.1.2", - "glob": "^7.1.1" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } - } - }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "^2.0.0" - } - }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true - }, "coffeescript": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.10.0.tgz", @@ -750,12 +806,6 @@ "delayed-stream": "~1.0.0" } }, - "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true - }, "component-emitter": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", @@ -768,45 +818,19 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "inherits": "^2.0.3", - "readable-stream": "^2.2.2", - "typedarray": "^0.0.6" - } - }, - "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "dev": true, - "requires": { - "date-now": "^0.1.4" - } - }, "continuable-cache": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/continuable-cache/-/continuable-cache-0.3.1.tgz", "integrity": "sha1-vXJ6f67XfnH/OYWskzUakSczrQ8=", "dev": true }, - "copy-concurrently": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", - "integrity": "sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A==", + "convert-source-map": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", "dev": true, "requires": { - "aproba": "^1.1.1", - "fs-write-stream-atomic": "^1.0.8", - "iferr": "^0.1.5", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.4", - "run-queue": "^1.0.0" + "safe-buffer": "~5.1.1" } }, "copy-descriptor": { @@ -835,19 +859,6 @@ "request": "^2.86.0" } }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, "csproj2ts": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/csproj2ts/-/csproj2ts-1.1.0.tgz", @@ -877,12 +888,6 @@ "array-find-index": "^1.0.1" } }, - "cyclist": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", - "integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=", - "dev": true - }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", @@ -892,12 +897,6 @@ "assert-plus": "^1.0.0" } }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", - "dev": true - }, "dateformat": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", @@ -929,12 +928,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -1003,76 +996,12 @@ "integrity": "sha1-/Qeh8fiRUZ2ZBaTJqJ3PWnC2YDc=", "dev": true }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "dom-serializer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", - "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", - "dev": true, - "requires": { - "domelementtype": "^1.3.0", - "entities": "^1.1.1" - }, - "dependencies": { - "entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", - "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", - "dev": true - } - } - }, - "domelementtype": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", - "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", - "dev": true - }, - "domhandler": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.3.0.tgz", - "integrity": "sha1-LeWaCCLVAn+r/28DLCsloqir5zg=", - "dev": true, - "requires": { - "domelementtype": "1" - } - }, - "domutils": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.5.1.tgz", - "integrity": "sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8=", - "dev": true, - "requires": { - "dom-serializer": "0", - "domelementtype": "1" - } - }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", "dev": true }, - "duplexify": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", - "integrity": "sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g==", - "dev": true, - "requires": { - "end-of-stream": "^1.0.0", - "inherits": "^2.0.1", - "readable-stream": "^2.0.0", - "stream-shift": "^1.0.0" - } - }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -1083,42 +1012,6 @@ "safer-buffer": "^2.1.0" } }, - "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", - "dev": true - }, - "encoding": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", - "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", - "dev": true, - "requires": { - "iconv-lite": "~0.4.13" - } - }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "dev": true, - "requires": { - "once": "^1.4.0" - } - }, - "entities": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.0.0.tgz", - "integrity": "sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY=", - "dev": true - }, - "err-code": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/err-code/-/err-code-1.1.2.tgz", - "integrity": "sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA=", - "dev": true - }, "error": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/error/-/error-7.0.2.tgz", @@ -1144,167 +1037,18 @@ "integrity": "sha1-lu258v2wGZWCKyY92KratnSBgbw=", "dev": true }, - "es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "dev": true, - "requires": { - "es6-promise": "^4.0.3" - }, - "dependencies": { - "es6-promise": { - "version": "4.2.6", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz", - "integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==", - "dev": true - } - } - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.7.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.11", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, - "eslint-scope": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", - "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", - "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", - "dev": true - }, - "eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", - "dev": true - }, - "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", - "dev": true, - "requires": { - "acorn": "^6.0.7", - "acorn-jsx": "^5.0.0", - "eslint-visitor-keys": "^1.0.0" - } - }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, - "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", - "dev": true, - "requires": { - "estraverse": "^4.0.0" - } - }, - "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", - "dev": true, - "requires": { - "estraverse": "^4.1.0" - } - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -1400,17 +1144,6 @@ } } }, - "external-editor": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", - "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -1476,35 +1209,6 @@ } } }, - "extract-zip": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.7.tgz", - "integrity": "sha1-qEC0uK9kAyZMjbV/Txp0Mz74H+k=", - "dev": true, - "requires": { - "concat-stream": "1.6.2", - "debug": "2.6.9", - "mkdirp": "0.5.1", - "yauzl": "2.4.1" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", @@ -1523,12 +1227,6 @@ "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", "dev": true }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, "faye-websocket": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.10.0.tgz", @@ -1538,21 +1236,6 @@ "websocket-driver": ">=0.5.1" } }, - "fd-slicer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", - "dev": true, - "requires": { - "pend": "~1.2.0" - } - }, - "figgy-pudding": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", - "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==", - "dev": true - }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -1563,15 +1246,6 @@ "object-assign": "^4.1.0" } }, - "file-entry-cache": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", - "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", - "dev": true, - "requires": { - "flat-cache": "^2.0.1" - } - }, "file-sync-cmp": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/file-sync-cmp/-/file-sync-cmp-0.1.1.tgz", @@ -1635,33 +1309,6 @@ } } }, - "flat-cache": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", - "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", - "dev": true, - "requires": { - "flatted": "^2.0.0", - "rimraf": "2.6.3", - "write": "1.0.3" - } - }, - "flatted": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", - "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", - "dev": true - }, - "flush-write-stream": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.1.1.tgz", - "integrity": "sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "readable-stream": "^2.3.6" - } - }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -1694,37 +1341,6 @@ "map-cache": "^0.2.2" } }, - "from2": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", - "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.0" - } - }, - "fs-minipass": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", - "integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", - "dev": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs-write-stream-atomic": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", - "integrity": "sha1-tH31NJPvkR33VzHnCp3tAYnbQMk=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "iferr": "^0.1.5", - "imurmurhash": "^0.1.4", - "readable-stream": "1 || 2" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2345,12 +1961,6 @@ } } }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, "gaze": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.3.tgz", @@ -2360,27 +1970,12 @@ "globule": "^1.0.0" } }, - "genfun": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/genfun/-/genfun-5.0.0.tgz", - "integrity": "sha512-KGDOARWVga7+rnB3z9Sd2Letx515owfk0hSxHGuqjANb1M+x2bGZGqHLiozPsYMdM2OubeMni/Hpwmjq6qIUhA==", - "dev": true - }, "get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", "dev": true }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -2566,6 +2161,12 @@ } } }, + "grunt-babel": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/grunt-babel/-/grunt-babel-8.0.0.tgz", + "integrity": "sha512-WuiZFvGzcyzlEoPIcY1snI234ydDWeWWV5bpnB7PZsOLHcDsxWKnrR1rMWEUsbdVPPjvIirwFNsuo4CbJmsdFQ==", + "dev": true + }, "grunt-contrib-clean": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/grunt-contrib-clean/-/grunt-contrib-clean-2.0.0.tgz", @@ -2746,77 +2347,6 @@ "maxmin": "^2.1.0" } }, - "grunt-contrib-jasmine": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/grunt-contrib-jasmine/-/grunt-contrib-jasmine-2.0.3.tgz", - "integrity": "sha512-He3oN00gxMSXAEicndDQssLiQ4D/as4Feaj3ctcOxO84+wSkCyFHbABSqMp/TOR9nxA3KthiuJzg0TbN2K1pcw==", - "dev": true, - "requires": { - "chalk": "^2.4.1", - "grunt-eslint": "21.0.0", - "lodash": "^4.17.11", - "pacote": "9.2.3", - "puppeteer": "1.13.0", - "rimraf": "^2.6.2", - "sprintf-js": "~1.1.1" - }, - "dependencies": { - "puppeteer": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-1.13.0.tgz", - "integrity": "sha512-LUXgvhjfB/P6IOUDAKxOcbCz9ISwBLL9UpKghYrcBDwrOGx1m60y0iN2M64mdAUbT4+7oZM5DTxOW7equa2fxQ==", - "dev": true, - "requires": { - "debug": "^4.1.0", - "extract-zip": "^1.6.6", - "https-proxy-agent": "^2.2.1", - "mime": "^2.0.3", - "progress": "^2.0.1", - "proxy-from-env": "^1.0.0", - "rimraf": "^2.6.1", - "ws": "^6.1.0" - } - }, - "sprintf-js": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", - "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", - "dev": true - }, - "ws": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", - "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", - "dev": true, - "requires": { - "async-limiter": "~1.0.0" - } - } - } - }, - "grunt-contrib-jshint": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/grunt-contrib-jshint/-/grunt-contrib-jshint-2.1.0.tgz", - "integrity": "sha512-65S2/C/6RfjY/umTxfwXXn+wVvaYmykHkHSsW6Q6rhkbv3oudTEgqnFFZvWzWCoHUb+3GMZLbP3oSrNyvshmIQ==", - "dev": true, - "requires": { - "chalk": "^2.4.2", - "hooker": "^0.2.3", - "jshint": "~2.10.2" - } - }, - "grunt-contrib-uglify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-4.0.1.tgz", - "integrity": "sha512-dwf8/+4uW1+7pH72WButOEnzErPGmtUvc8p08B0eQS/6ON0WdeQu0+WFeafaPTbbY1GqtS25lsHWaDeiTQNWPg==", - "dev": true, - "requires": { - "chalk": "^2.4.1", - "maxmin": "^2.1.0", - "uglify-js": "^3.5.0", - "uri-path": "^1.0.0" - } - }, "grunt-contrib-watch": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/grunt-contrib-watch/-/grunt-contrib-watch-1.1.0.tgz", @@ -2840,16 +2370,6 @@ } } }, - "grunt-eslint": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/grunt-eslint/-/grunt-eslint-21.0.0.tgz", - "integrity": "sha512-HJocD9P35lpCvy6pPPCTgzBavzckrT1nt7lpqV55Vy8E6LQJv4RortXoH1jJTYhO5DYY7RPATv7Uc4383PUYqQ==", - "dev": true, - "requires": { - "chalk": "^2.1.0", - "eslint": "^5.0.0" - } - }, "grunt-known-options": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-1.1.1.tgz", @@ -3008,52 +2528,7 @@ "hosted-git-info": { "version": "2.7.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", - "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", - "dev": true - }, - "htmlparser2": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.8.3.tgz", - "integrity": "sha1-mWwosZFRaovoZQGn15dX5ccMEGg=", - "dev": true, - "requires": { - "domelementtype": "1", - "domhandler": "2.3", - "domutils": "1.5", - "entities": "1.0", - "readable-stream": "1.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, - "http-cache-semantics": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", - "integrity": "sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", "dev": true }, "http-parser-js": { @@ -3062,33 +2537,6 @@ "integrity": "sha512-cZdEF7r4gfRIq7ezX9J0T+kQmJNOub71dWbgAXVHDct80TKP4MCETtZQ31xyv38UwgzkWPYF/Xc0ge55dW9Z9w==", "dev": true }, - "http-proxy-agent": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", - "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", - "dev": true, - "requires": { - "agent-base": "4", - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - } - } - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -3100,36 +2548,6 @@ "sshpk": "^1.7.0" } }, - "https-proxy-agent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", - "integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==", - "dev": true, - "requires": { - "agent-base": "^4.1.0", - "debug": "^3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "humanize-ms": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=", - "dev": true, - "requires": { - "ms": "^2.0.0" - } - }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -3139,43 +2557,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "iferr": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", - "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=", - "dev": true - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true - }, - "ignore-walk": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", - "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", - "dev": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "import-fresh": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", - "integrity": "sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, "indent-string": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", @@ -3201,59 +2582,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "inquirer": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", - "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", - "dev": true, - "requires": { - "ansi-escapes": "^3.2.0", - "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.11", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^6.4.0", - "string-width": "^2.1.0", - "strip-ansi": "^5.1.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", - "dev": true - }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", @@ -3355,12 +2683,6 @@ "number-is-nan": "^1.0.0" } }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, "is-glob": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", @@ -3399,12 +2721,6 @@ "isobject": "^3.0.1" } }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -3490,29 +2806,11 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, - "jshint": { - "version": "2.10.2", - "resolved": "https://registry.npmjs.org/jshint/-/jshint-2.10.2.tgz", - "integrity": "sha512-e7KZgCSXMJxznE/4WULzybCMNXNAd/bf5TSrvVEq78Q/K8ZwFpmBqQeDtNiHc3l49nV4E/+YeHU/JZjSUIrLAA==", - "dev": true, - "requires": { - "cli": "~1.0.0", - "console-browserify": "1.1.x", - "exit": "0.1.x", - "htmlparser2": "3.8.x", - "lodash": "~4.17.11", - "minimatch": "~3.0.2", - "shelljs": "0.3.x", - "strip-json-comments": "1.0.x" - }, - "dependencies": { - "strip-json-comments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true - } - } + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true }, "jsmin2": { "version": "1.2.1", @@ -3520,12 +2818,6 @@ "integrity": "sha1-iPvi+/dfCpH2YCD9mBzWk/S/5X4=", "dev": true }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", @@ -3538,23 +2830,20 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true + "json5": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", + "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } }, "jsprim": { "version": "1.4.1", @@ -3586,16 +2875,6 @@ "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", "dev": true }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, "livereload-js": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.4.0.tgz", @@ -3673,43 +2952,6 @@ "signal-exit": "^3.0.0" } }, - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "dev": true, - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - }, - "dependencies": { - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true - } - } - }, - "make-fetch-happen": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-4.0.1.tgz", - "integrity": "sha512-7R5ivfy9ilRJ1EMKIOziwrns9fGeAD4bAha8EB7BIiBBLHm2KeTUGCrICFt2rbHfzheTLynv50GnNTK1zDTrcQ==", - "dev": true, - "requires": { - "agentkeepalive": "^3.4.1", - "cacache": "^11.0.1", - "http-cache-semantics": "^3.8.1", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1", - "lru-cache": "^4.1.2", - "mississippi": "^3.0.0", - "node-fetch-npm": "^2.0.2", - "promise-retry": "^1.1.1", - "socks-proxy-agent": "^4.0.0", - "ssri": "^6.0.0" - } - }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -3833,12 +3075,6 @@ "to-regex": "^3.0.2" } }, - "mime": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.3.tgz", - "integrity": "sha512-QgrPRJfE+riq5TPZMcHZOtm8c6K/yYrMbKIoRfapfiGLxS8OTeIfRhUGW5LU7MlRa52KOAGCfUNruqLrIBvWZw==", - "dev": true - }, "mime-db": { "version": "1.40.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", @@ -3854,12 +3090,6 @@ "mime-db": "1.40.0" } }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -3875,43 +3105,6 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, - "minipass": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", - "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", - "dev": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", - "integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", - "dev": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mississippi": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-3.0.0.tgz", - "integrity": "sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA==", - "dev": true, - "requires": { - "concat-stream": "^1.5.0", - "duplexify": "^3.4.2", - "end-of-stream": "^1.1.0", - "flush-write-stream": "^1.0.0", - "from2": "^2.1.0", - "parallel-transform": "^1.1.0", - "pump": "^3.0.0", - "pumpify": "^1.3.3", - "stream-each": "^1.1.0", - "through2": "^2.0.0" - } - }, "mixin-deep": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", @@ -3950,20 +3143,6 @@ } } }, - "move-concurrently": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", - "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", - "dev": true, - "requires": { - "aproba": "^1.1.1", - "copy-concurrently": "^1.0.0", - "fs-write-stream-atomic": "^1.0.8", - "mkdirp": "^0.5.1", - "rimraf": "^2.5.4", - "run-queue": "^1.0.3" - } - }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -3983,12 +3162,6 @@ "minimatch": "^3.0.4" } }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, "nan": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", @@ -4015,24 +3188,12 @@ "to-regex": "^3.0.1" } }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, "ncp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/ncp/-/ncp-0.5.1.tgz", "integrity": "sha1-dDmFMW49tFkoG1hxaehFc1oFQ58=", "dev": true }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, "nise": { "version": "1.4.10", "resolved": "https://registry.npmjs.org/nise/-/nise-1.4.10.tgz", @@ -4054,17 +3215,6 @@ } } }, - "node-fetch-npm": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz", - "integrity": "sha512-nJIxm1QmAj4v3nfCvEeCrYSoVwXyxLnaPBK5W1W5DGEJwjlKuC2VEUycGw5oxk+4zZahRrB84PUJJgEmhFTDFw==", - "dev": true, - "requires": { - "encoding": "^0.1.11", - "json-parse-better-errors": "^1.0.0", - "safe-buffer": "^5.1.1" - } - }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -4092,59 +3242,6 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "dev": true }, - "npm-bundled": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", - "integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", - "dev": true - }, - "npm-package-arg": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-6.1.0.tgz", - "integrity": "sha512-zYbhP2k9DbJhA0Z3HKUePUgdB1x7MfIfKssC+WLPFMKTBZKpZh5m13PgexJjCq6KW7j17r0jHWcCpxEqnnncSA==", - "dev": true, - "requires": { - "hosted-git-info": "^2.6.0", - "osenv": "^0.1.5", - "semver": "^5.5.0", - "validate-npm-package-name": "^3.0.0" - } - }, - "npm-packlist": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", - "integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", - "dev": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npm-pick-manifest": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-2.2.3.tgz", - "integrity": "sha512-+IluBC5K201+gRU85vFlUwX3PFShZAbAgDNp2ewJdWMVSppdo/Zih0ul2Ecky/X7b51J7LrrUAP+XOmOCvYZqA==", - "dev": true, - "requires": { - "figgy-pudding": "^3.5.1", - "npm-package-arg": "^6.0.0", - "semver": "^5.4.1" - } - }, - "npm-registry-fetch": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-3.9.0.tgz", - "integrity": "sha512-srwmt8YhNajAoSAaDWndmZgx89lJwIZ1GWxOuckH4Coek4uHv5S+o/l9FLQe/awA+JwTnj4FJHldxhlXdZEBmw==", - "dev": true, - "requires": { - "JSONStream": "^1.3.4", - "bluebird": "^3.5.1", - "figgy-pudding": "^3.4.1", - "lru-cache": "^4.1.3", - "make-fetch-happen": "^4.0.1", - "npm-package-arg": "^6.1.0" - } - }, "num2fraction": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/num2fraction/-/num2fraction-1.2.2.tgz", @@ -4222,151 +3319,35 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "^1.0.0" - } - }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "osenv": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", - "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", - "dev": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "pacote": { - "version": "9.2.3", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-9.2.3.tgz", - "integrity": "sha512-Y3+yY3nBRAxMlZWvr62XLJxOwCmG9UmkGZkFurWHoCjqF0cZL72cTOCRJTvWw8T4OhJS2RTg13x4oYYriauvEw==", - "dev": true, - "requires": { - "bluebird": "^3.5.2", - "cacache": "^11.2.0", - "figgy-pudding": "^3.5.1", - "get-stream": "^4.1.0", - "glob": "^7.1.3", - "lru-cache": "^4.1.3", - "make-fetch-happen": "^4.0.1", - "minimatch": "^3.0.4", - "minipass": "^2.3.5", - "mississippi": "^3.0.0", - "mkdirp": "^0.5.1", - "normalize-package-data": "^2.4.0", - "npm-package-arg": "^6.1.0", - "npm-packlist": "^1.1.12", - "npm-pick-manifest": "^2.2.3", - "npm-registry-fetch": "^3.8.0", - "osenv": "^0.1.5", - "promise-inflight": "^1.0.1", - "promise-retry": "^1.1.1", - "protoduck": "^5.0.1", - "rimraf": "^2.6.2", - "safe-buffer": "^5.1.2", - "semver": "^5.6.0", - "ssri": "^6.0.1", - "tar": "^4.4.6", - "unique-filename": "^1.1.1", - "which": "^1.3.1" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "dev": true, + "requires": { + "wrappy": "1" } }, - "parallel-transform": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", - "integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", + "p-limit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", "dev": true, "requires": { - "cyclist": "~0.2.2", - "inherits": "^2.0.3", - "readable-stream": "^2.1.5" + "p-try": "^2.0.0" } }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "dev": true, "requires": { - "callsites": "^3.0.0" + "p-limit": "^2.0.0" } }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -4403,18 +3384,6 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", @@ -4449,12 +3418,6 @@ "pinkie-promise": "^2.0.0" } }, - "pend": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true - }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -4519,12 +3482,6 @@ "source-map": "~0.4.2" } }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, "pretty-bytes": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-3.0.1.tgz", @@ -4540,88 +3497,12 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", - "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true - }, - "promise-inflight": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", - "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", - "dev": true - }, - "promise-retry": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-1.1.1.tgz", - "integrity": "sha1-ZznpaOMFHaIM5kl/srUPaRHfPW0=", - "dev": true, - "requires": { - "err-code": "^1.0.0", - "retry": "^0.10.0" - } - }, - "protoduck": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/protoduck/-/protoduck-5.0.1.tgz", - "integrity": "sha512-WxoCeDCoCBY55BMvj4cAEjdVUFGRWed9ZxPlqTKYyw1nDDTQ4pqmnIMAGfJlg7Dx35uB/M+PHJPTmGOvaCaPTg==", - "dev": true, - "requires": { - "genfun": "^5.0.0" - } - }, - "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", - "dev": true - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true - }, "psl": { "version": "1.1.31", "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", "dev": true }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "pumpify": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", - "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", - "dev": true, - "requires": { - "duplexify": "^3.6.0", - "inherits": "^2.0.3", - "pump": "^2.0.0" - }, - "dependencies": { - "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - } - } - }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", @@ -4719,12 +3600,6 @@ "safe-regex": "^1.1.0" } }, - "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", - "dev": true - }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -4789,12 +3664,6 @@ "path-parse": "^1.0.6" } }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true - }, "resolve-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg/-/resolve-pkg-2.0.0.tgz", @@ -4818,28 +3687,12 @@ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "^2.0.0", - "signal-exit": "^3.0.2" - } - }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true }, - "retry": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/retry/-/retry-0.10.1.tgz", - "integrity": "sha1-52OI0heZLCUnUCQdPTlW/tmNj/Q=", - "dev": true - }, "rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -4865,33 +3718,6 @@ } } }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "^2.1.0" - } - }, - "run-queue": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", - "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", - "dev": true, - "requires": { - "aproba": "^1.1.1" - } - }, - "rxjs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", - "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -4954,27 +3780,6 @@ } } }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "shelljs": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz", - "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=", - "dev": true - }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -5004,23 +3809,6 @@ } } }, - "slice-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", - "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.0", - "astral-regex": "^1.0.0", - "is-fullwidth-code-point": "^2.0.0" - } - }, - "smart-buffer": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.0.2.tgz", - "integrity": "sha512-JDhEpTKzXusOqXZ0BUIdH+CjFdO/CR3tLlf5CN34IypI+xMmXW1uB16OOY8z3cICbJlDAVJzNbwBhNO0wt9OAw==", - "dev": true - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -5149,26 +3937,6 @@ } } }, - "socks": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.3.2.tgz", - "integrity": "sha512-pCpjxQgOByDHLlNqlnh/mNSAxIUkyBBuwwhTcV+enZGbDaClPvHdvm6uvOwZfFJkam7cGhBNbb4JxiP8UZkRvQ==", - "dev": true, - "requires": { - "ip": "^1.1.5", - "smart-buffer": "4.0.2" - } - }, - "socks-proxy-agent": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz", - "integrity": "sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg==", - "dev": true, - "requires": { - "agent-base": "~4.2.1", - "socks": "~2.3.2" - } - }, "source-map": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", @@ -5261,15 +4029,6 @@ "tweetnacl": "~0.14.0" } }, - "ssri": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.1.tgz", - "integrity": "sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==", - "dev": true, - "requires": { - "figgy-pudding": "^3.5.1" - } - }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -5291,55 +4050,12 @@ } } }, - "stream-each": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz", - "integrity": "sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "stream-shift": "^1.0.0" - } - }, - "stream-shift": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", - "dev": true - }, "string-template": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz", "integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=", "dev": true }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } - } - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -5376,12 +4092,6 @@ "get-stdin": "^4.0.1" } }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -5391,83 +4101,6 @@ "has-flag": "^3.0.0" } }, - "table": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.0.tgz", - "integrity": "sha512-nHFDrxmbrkU7JAFKqKbDJXfzrX2UBsWmrieXFTGxiI5e4ncg3VqsZeI4EzNmX0ncp4XNGVeoxIWJXfCIXwrsvw==", - "dev": true, - "requires": { - "ajv": "^6.9.1", - "lodash": "^4.17.11", - "slice-ansi": "^2.1.0", - "string-width": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "string-width": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", - "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", - "dev": true, - "requires": { - "emoji-regex": "^7.0.1", - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^5.1.0" - } - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, - "tar": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", - "integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", - "dev": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "through2": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", - "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", - "dev": true, - "requires": { - "readable-stream": "~2.3.6", - "xtend": "~4.0.1" - } - }, "tiny-lr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/tiny-lr/-/tiny-lr-1.1.1.tgz", @@ -5493,14 +4126,11 @@ } } }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true }, "to-object-path": { "version": "0.3.0", @@ -5568,10 +4198,10 @@ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", "dev": true }, - "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, "tunnel-agent": { @@ -5589,51 +4219,18 @@ "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, "type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, "typescript": { - "version": "3.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", - "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", + "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", "dev": true }, - "uglify-js": { - "version": "3.5.15", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.15.tgz", - "integrity": "sha512-fe7aYFotptIddkwcm6YuA0HmknBZ52ZzOsUxZEdhhkSsz7RfjHDX2QDxwKTiv4JQ5t5NhfmpgAK+J7LiDhKSqg==", - "dev": true, - "requires": { - "commander": "~2.20.0", - "source-map": "~0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, "underscore.string": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.5.tgz", @@ -5679,24 +4276,6 @@ } } }, - "unique-filename": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", - "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", - "dev": true, - "requires": { - "unique-slug": "^2.0.0" - } - }, - "unique-slug": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.1.tgz", - "integrity": "sha512-n9cU6+gITaVu7VGj1Z8feKMmfAjEAQGhwD9fE3zvpRRa0wEIx8ODYkVGfSc94M2OX00tUFV8wH3zYbm1I8mxFg==", - "dev": true, - "requires": { - "imurmurhash": "^0.1.4" - } - }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -5792,15 +4371,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "validate-npm-package-name": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz", - "integrity": "sha1-X6kS2B630MdK/BQN5zF/DKffQ34=", - "dev": true, - "requires": { - "builtins": "^1.0.3" - } - }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -5837,27 +4407,12 @@ "isexe": "^2.0.0" } }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, - "write": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", - "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", - "dev": true, - "requires": { - "mkdirp": "^0.5.1" - } - }, "xml2js": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", @@ -5879,27 +4434,6 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true - }, - "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", - "dev": true - }, - "yallist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", - "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true - }, - "yauzl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", - "dev": true, - "requires": { - "fd-slicer": "~1.0.1" - } } } } diff --git a/package.json b/package.json index 13a7476..9e2cd63 100644 --- a/package.json +++ b/package.json @@ -22,26 +22,28 @@ "danmu" ], "main": "dist/CommentCoreLibrary.js", - "version": "0.11.1", + "version": "1.0.0", "devDependencies": { + "@babel/core": "^7.4.5", + "@babel/plugin-proposal-class-properties": "^7.4.4", + "@babel/plugin-proposal-object-rest-spread": "^7.4.4", + "@babel/preset-typescript": "^7.3.3", "coveralls": "^3.0.3", "grunt": "^1.0.4", "grunt-autoprefixer": "^3.0.4", + "grunt-babel": "^8.0.0", "grunt-contrib-clean": "^2.0.0", "grunt-contrib-coffee": "^2.1.0", "grunt-contrib-concat": "^1.0.1", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-cssmin": "^3.0.0", - "grunt-contrib-jasmine": "^2.0.3", - "grunt-contrib-jshint": "^2.1.0", - "grunt-contrib-uglify": "^4.0.1", "grunt-contrib-watch": "^1.1.0", "grunt-ts": "^6.0.0-beta.22", "jasmine-sinon": "^0.4.0", "jquery": "^3.4.1", "load-grunt-tasks": "^5.0.0", "sinon": "^7.3.2", - "typescript": "^3.4.5" + "typescript": "^3.5.2" }, "scripts": { "build": "npm install && grunt", diff --git a/src/Array.js b/src/Array.js deleted file mode 100644 index 935c4dd..0000000 --- a/src/Array.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Binary Search Stubs for JS Arrays - * @license MIT - * @author Jim Chen - */ -var BinArray = (function () { - - var BinArray = {}; - - /** - * Performs binary search on the array - * Note: The array MUST ALREADY BE SORTED. Some cases will fail but we don't - * guarantee that we can catch all cases. - * - * @param arr - array to search on - * @param what - element to search for (may not be present) - * @param how - function comparator (a, b). Returns positive value if a > b - * @return index of the element (or index of the element if it were in the array) - **/ - BinArray.bsearch = function (arr, what, how) { - if (!Array.isArray(arr)) { - throw new Error('Bsearch can only be run on arrays'); - } - if (arr.length === 0) { - return 0; - } - if (how(what,arr[0]) < 0) { - return 0; - } - if (how(what,arr[arr.length - 1]) >= 0) { - return arr.length; - } - var low = 0; - var i = 0; - var count = 0; - var high = arr.length - 1; - while (low <= high) { - i = Math.floor((high + low + 1)/2); - count++; - if (how(what,arr[i-1]) >= 0 && how(what,arr[i]) < 0) { - return i; - } else if (how(what,arr[i-1]) < 0) { - high = i-1; - } else if (how(what,arr[i]) >= 0) { - low = i; - } else { - throw new Error('Program Error. Inconsistent comparator or unsorted array!'); - } - if (count > 1500) { - throw new Error('Iteration depth exceeded. Inconsistent comparator or astronomical dataset!'); - } - } - return -1; - }; - - /** - * Insert an element into its position in the array signified by bsearch - * - * @param arr - array to insert into - * @param what - element to insert - * @param how - comparator (see bsearch) - * @return index that the element was inserted to. - **/ - BinArray.binsert = function (arr, what, how) { - var index = BinArray.bsearch(arr,what,how); - arr.splice(index,0,what); - return index; - }; - - return BinArray; -})(); diff --git a/src/CommentManager.js b/src/CommentManager.js deleted file mode 100644 index 12c3562..0000000 --- a/src/CommentManager.js +++ /dev/null @@ -1,304 +0,0 @@ -/*! - * Comment Core Library CommentManager - * @license MIT - * @author Jim Chen - * - * Copyright (c) 2014 Jim Chen - */ -var CommentManager = (function() { - var _defaultComparator = function (a,b) { - if (a.stime > b.stime) { - return 2; - } else if (a.stime < b.stime) { - return -2; - } else { - if (a.date > b.date) { - return 1; - } else if (a.date < b.date) { - return -1; - } else if (a.dbid != null && b.dbid != null) { - if (a.dbid > b.dbid) { - return 1; - } else if (a.dbid < b.dbid) { - return -1; - } - return 0; - } else { - return 0; - } - } - }; - - function CommentManager(stageObject){ - var __timer = 0; - - this._listeners = {}; - this._lastPosition = 0; - - this.stage = stageObject; - this.options = { - global:{ - opacity:1, - scale:1, - className:"cmt" - }, - scroll:{ - opacity:1, - scale:1 - }, - limit: 0, - seekTrigger: 2000 - }; - this.timeline = []; - this.runline = []; - this.position = 0; - - this.factory = null; - this.filter = null; - this.csa = { - scroll: new CommentSpaceAllocator(0,0), - top: new AnchorCommentSpaceAllocator(0,0), - bottom: new AnchorCommentSpaceAllocator(0,0), - reverse: new CommentSpaceAllocator(0,0), - scrollbtm: new CommentSpaceAllocator(0,0) - }; - - /** Precompute the offset width **/ - this.width = this.stage.offsetWidth; - this.height = this.stage.offsetHeight; - this._startTimer = function () { - if (__timer > 0) { - return; - } - var lastTPos = new Date().getTime(); - var cmMgr = this; - __timer = window.setInterval(function () { - var elapsed = new Date().getTime() - lastTPos; - lastTPos = new Date().getTime(); - cmMgr.onTimerEvent(elapsed,cmMgr); - },10); - }; - this._stopTimer = function () { - window.clearInterval(__timer); - __timer = 0; - }; - } - - /** Public **/ - CommentManager.prototype.stop = function(){ - this._stopTimer(); - // Send stop signal to all comments - this.runline.forEach(function (c) { c.stop(); }); - }; - - CommentManager.prototype.start = function(){ - this._startTimer(); - }; - - CommentManager.prototype.seek = function(time){ - this.position = BinArray.bsearch(this.timeline, time, function(a,b){ - if (a < b.stime) { - return -1 - } else if(a > b.stime) { - return 1; - } else { - return 0; - } - }); - }; - - CommentManager.prototype.validate = function(cmt){ - if (cmt == null) { - return false; - } - return this.filter.doValidate(cmt); - }; - - CommentManager.prototype.load = function(a){ - this.timeline = a; - this.timeline.sort(_defaultComparator); - this.dispatchEvent("load"); - }; - - CommentManager.prototype.insert = function(c){ - var index = BinArray.binsert(this.timeline, c, _defaultComparator); - if (index <= this.position) { - this.position++; - } - this.dispatchEvent("insert"); - }; - - CommentManager.prototype.clear = function () { - while (this.runline.length > 0) { - this.runline[0].finish(); - } - this.dispatchEvent("clear"); - }; - - CommentManager.prototype.setBounds = function () { - this.width = this.stage.offsetWidth; - this.height= this.stage.offsetHeight; - this.dispatchEvent("resize"); - for (var comAlloc in this.csa) { - this.csa[comAlloc].setBounds(this.width,this.height); - } - // Update 3d perspective - this.stage.style.perspective = this.width / Math.tan(55 * Math.PI/180) / 2 + "px"; - this.stage.style.webkitPerspective = this.width / Math.tan(55 * Math.PI/180) / 2 + "px"; - }; - - CommentManager.prototype.init = function (renderer) { - this.setBounds(); - if (this.filter == null) { - this.filter = new CommentFilter(); //Only create a filter if none exist - } - if (this.factory == null) { - switch (renderer) { - case 'legacy': - this.factory = CommentFactory.defaultFactory(); - break; - default: - case 'css': - this.factory = CommentFactory.defaultCssRenderFactory(); - break; - } - } - }; - - CommentManager.prototype.time = function (time) { - time = time - 1; - if (this.position >= this.timeline.length || - Math.abs(this._lastPosition - time) >= this.options.seekTrigger) { - - this.seek(time); - this._lastPosition = time; - if (this.timeline.length <= this.position) { - return; - } - } else { - this._lastPosition = time; - } - var batch = []; - for (;this.position < this.timeline.length;this.position++) { - if (this.timeline[this.position]['stime'] <= time) { - if (this.options.limit > 0 && - this.runline.length + batch.length >= this.options.limit) { - - continue; // Skip comments but still move the position pointer - } else if (this.validate(this.timeline[this.position])) { - batch.push(this.timeline[this.position]); - } - } else { - break; - } - } - if (batch.length > 0) { - this.send(batch); - } - }; - - CommentManager.prototype.rescale = function () { - // TODO: Implement rescaling - }; - - CommentManager.prototype._preprocess = function (data) { - if (data.mode === 8) { - // This comment is not managed by the comment manager - console.log(data); - if (this.scripting) { - console.log(this.scripting.eval(data.code)); - } - return null; - } - if (this.filter != null) { - data = this.filter.doModify(data); - } - return data; - } - - CommentManager.prototype._allocateSpace = function (cmt) { - switch (cmt.mode) { - default: - case 1: { this.csa.scroll.add(cmt); } break; - case 2: { this.csa.scrollbtm.add(cmt); } break; - case 4: { this.csa.bottom.add(cmt); } break; - case 5: { this.csa.top.add(cmt); } break; - case 6: { this.csa.reverse.add(cmt); } break; - case 7: - case 17: {/* Do NOT manage these comments! */} break; - } - } - - CommentManager.prototype.send = function (data) { - if (!Array.isArray(data)) { - data = [ data ]; - } - // Validate all the comments - data = data.map( - this._preprocess.bind(this)).filter(function (item) { - return item !== null; - }); - if (data.length === 0) { - return; - } - data.map((function (item) { - // Create and insert the comments into the DOM - return this.factory.create(this, item); - }).bind(this)).map((function (cmt) { - this._allocateSpace(cmt); - return cmt; - }).bind(this)).forEach((function (cmt) { - cmt.y = cmt.y; - this.dispatchEvent("enterComment", cmt); - this.runline.push(cmt); - }).bind(this)); - }; - - CommentManager.prototype.finish = function (cmt) { - this.dispatchEvent("exitComment", cmt); - this.stage.removeChild(cmt.dom); - var index = this.runline.indexOf(cmt); - if (index >= 0) { - this.runline.splice(index, 1); - } - switch (cmt.mode) { - default: - case 1: {this.csa.scroll.remove(cmt);} break; - case 2: {this.csa.scrollbtm.remove(cmt);} break; - case 4: {this.csa.bottom.remove(cmt);} break; - case 5: {this.csa.top.remove(cmt);} break; - case 6: {this.csa.reverse.remove(cmt);} break; - case 7: break; - } - }; - - CommentManager.prototype.addEventListener = function (event, listener) { - if (typeof this._listeners[event] !== "undefined") { - this._listeners[event].push(listener); - } else { - this._listeners[event] = [listener]; - } - }; - - CommentManager.prototype.dispatchEvent = function (event, data) { - if (typeof this._listeners[event] !== "undefined") { - for (var i = 0; i < this._listeners[event].length; i++) { - try { - this._listeners[event][i](data); - } catch (e) { - console.error(e.stack); - } - } - } - }; - - /** Static Functions **/ - CommentManager.prototype.onTimerEvent = function (timePassed,cmObj) { - for (var i= 0;i < cmObj.runline.length; i++) { - var cmt = cmObj.runline[i]; - cmt.time(timePassed); - } - }; - - return CommentManager; -})(); diff --git a/src/CommentProvider.js b/src/CommentProvider.js deleted file mode 100644 index e019970..0000000 --- a/src/CommentProvider.js +++ /dev/null @@ -1,351 +0,0 @@ -/** - * Comment Provider - * Provides functionality to send or receive danmaku - * @license MIT - * @author Jim Chen -**/ - -var CommentProvider = (function () { - - function CommentProvider () { - this._started = false; - this._destroyed = false; - this._staticSources = {}; - this._dynamicSources = {}; - this._parsers = {} - this._targets = []; - } - - CommentProvider.SOURCE_JSON = 'JSON'; - CommentProvider.SOURCE_XML = 'XML'; - CommentProvider.SOURCE_TEXT = 'TEXT'; - - /** - * Provider for HTTP content. This returns a promise that resolves to TEXT. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {string} responseType - type of response expected. - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.BaseHttpProvider = function (method, url, responseType, args, body) { - return new Promise(function (resolve, reject) { - var xhr = new XMLHttpRequest(); - var uri = url; - if (args && (method === 'POST' || method === 'PUT')) { - uri += '?'; - var argsArray = []; - for (var key in args) { - if (args.hasOwnProperty(key)) { - argsArray.push(encodeURIComponent(key) + - '=' + encodeURIComponent(args[key])); - } - } - uri += argsArray.join('&'); - } - - xhr.onload = function () { - if (this.status >= 200 && this.status < 300) { - resolve(this.response); - } else { - reject(new Error(this.status + " " + this.statusText)); - } - }; - - xhr.onerror = function () { - reject(new Error(this.status + " " + this.statusText)); - }; - - xhr.open(method, uri); - - // Limit the response type based on input - xhr.responseType = typeof responseType === "string" ? - responseType : ""; - - if (typeof body !== 'undefined') { - xhr.send(body); - } else { - xhr.send(); - } - }); - }; - - /** - * Provider for JSON content. This returns a promise that resolves to JSON. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.JSONProvider = function (method, url, args, body) { - return CommentProvider.BaseHttpProvider( - method, url, "json", args, body).then(function (response) { - return response; - }); - }; - - /** - * Provider for XML content. This returns a promise that resolves to Document. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.XMLProvider = function (method, url, args, body) { - return CommentProvider.BaseHttpProvider( - method, url, "document", args, body).then(function (response) { - return response; - }); - }; - - /** - * Provider for text content. This returns a promise that resolves to Text. - * - * @param {string} method - HTTP method to use - * @param {string} url - Base URL - * @param {Object} args - Arguments for query string. Note: This is only used when - * method is POST or PUT - * @param {any} body - Text body content. If not provided will omit a body - * @return {Promise} that resolves or rejects based on the success or failure - * of the request - **/ - CommentProvider.TextProvider = function (method, url, args, body) { - return CommentProvider.BaseHttpProvider( - method, url, "text", args, body).then(function (response) { - return response; - }); - }; - - /** - * Attaches a static source to the corresponding type. - * NOTE: Multiple static sources will race to determine the initial comment - * list so it is imperative that they all parse to the SAME content. - * - * @param {Provider} source - Promise that resolves to one of the supported types - * @param {Type} type - Type that the provider resolves to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addStaticSource = function (source, type) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' + - 'cannot attach more sources.'); - } - if (!(type in this._staticSources)) { - this._staticSources[type] = []; - } - this._staticSources[type].push(source); - return this; - }; - - /** - * Attaches a dynamic source to the corresponding type - * NOTE: Multiple dynamic sources will collectively provide comment data. - * - * @param {DynamicProvider} source - Listenable that resolves to one of the supported types - * @param {Type} type - Type that the provider resolves to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addDynamicSource = function (source, type) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' + - 'cannot attach more sources.'); - } - if (!(type in this._dynamicSources)) { - this._dynamicSources[type] = []; - } - this._dynamicSources[type].push(source); - return this; - }; - - /** - * Attaches a target comment manager so that we can stream comments to it - * - * @param {CommentManager} commentManager - Comment Manager instance to attach to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addTarget = function (commentManager) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' - +'cannot attach more targets.'); - } - if (!(commentManager instanceof CommentManager)) { - throw new Error( - 'Expected the target to be an instance of CommentManager.'); - } - this._targets.push(commentManager); - return this; - }; - - /** - * Adds a parser for an incoming data type. If multiple parsers are added, - * parsers added later take precedence. - * - * @param {CommentParser} parser - Parser spec compliant parser - * @param {Type} type - Type that the provider resolves to - * @return {CommentProvider} this - **/ - CommentProvider.prototype.addParser = function (parser, type) { - if (this._destroyed) { - throw new Error( - 'Comment provider has been destroyed, ' + - 'cannot attach more parsers.'); - } - if (!(type in this._parsers)) { - this._parsers[type] = []; - } - this._parsers[type].unshift(parser); - return this; - }; - - CommentProvider.prototype.applyParsersOne = function (data, type) { - return new Promise(function (resolve, reject) { - if (!(type in this._parsers)) { - reject(new Error('No parsers defined for "' + type + '"')); - return; - } - for (var i = 0; i < this._parsers[type].length; i++) { - var output = null; - try { - output = this._parsers[type][i].parseOne(data); - } catch (e) { - // TODO: log this failure - console.error(e); - } - if (output !== null) { - resolve(output); - return; - } - } - reject(new Error("Ran out of parsers for they target type")); - }.bind(this)); - }; - - CommentProvider.prototype.applyParsersList = function (data, type) { - return new Promise(function (resolve, reject) { - if (!(type in this._parsers)) { - reject(new Error('No parsers defined for "' + type + '"')); - return; - } - for (var i = 0; i < this._parsers[type].length; i++) { - var output = null; - try { - output = this._parsers[type][i].parseMany(data); - } catch (e) { - // TODO: log this failure - console.error(e); - } - if (output !== null) { - resolve(output); - return; - } - } - reject(new Error("Ran out of parsers for the target type")); - }.bind(this)); - }; - - /** - * (Re)loads static comments - * - * @return {Promise} that is resolved when the static sources have been - * loaded - */ - CommentProvider.prototype.load = function () { - if (this._destroyed) { - throw new Error('Cannot load sources on a destroyed provider.'); - } - var promises = []; - // TODO: This race logic needs to be rethought to provide redundancy - for (var type in this._staticSources) { - promises.push(Promises.any(this._staticSources[type]) - .then(function (data) { - return this.applyParsersList(data, type); - }.bind(this))); - } - if (promises.length === 0) { - // No static loaders - return Promise.resolve([]); - } - return Promises.any(promises).then(function (commentList) { - for (var i = 0; i < this._targets.length; i++) { - this._targets[i].load(commentList); - } - return Promise.resolve(commentList); - }.bind(this)); - }; - - /** - * Commit the changes and boot up the provider - * - * @return {Promise} that is resolved when all the static sources are loaded - * and all the dynamic sources are hooked up - **/ - CommentProvider.prototype.start = function () { - if (this._destroyed) { - throw new Error('Cannot start a provider that has been destroyed.'); - } - this._started = true; - return this.load().then(function (commentList) { - // Bind the dynamic sources - for (var type in this._dynamicSources) { - this._dynamicSources[type].forEach(function (source) { - source.addEventListener('receive', function (data) { - for (var i = 0; i < this._targets.length; i++) { - this._targets[i].send( - this.applyParserOne(data, type)); - } - }.bind(this)); - }.bind(this)); - } - return Promise.resolve(commentList); - }.bind(this)); - }; - - /** - * Send out comments to both dynamic sources and POST targets. - * - * @param commentData - commentData to be sent to the server. Object. - * @param requireAll - Do we require that all servers to accept the comment - * for the promise to resolve. Defaults to true. If - * false, the returned promise will resolve as long as a - * single target accepts. - * @return Promise that is resolved when the server accepts or rejects the - * comment. Dynamic sources will decide based on their promise while - * POST targets are considered accepted if they return a successful - * HTTP response code. - **/ - CommentProvider.prototype.send = function (commentData, requireAll) { - throw new Error('Not implemented'); - }; - - /** - * Stop providing dynamic comments to the targets - * - * @return Promise that is resolved when all bindings between dynamic - * sources have been successfully unloaded. - **/ - CommentProvider.prototype.destroy = function () { - if (this._destroyed) { - return Promise.resolve(); - } - // TODO: implement debinding for sources - this._destroyed = true; - return Promise.resolve(); - }; - - return CommentProvider; -})(); diff --git a/src/Promises.js b/src/Promises.js deleted file mode 100644 index 53b3dfa..0000000 --- a/src/Promises.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Promises extra functionality - * @license MIT - * @author Jim Chen - */ -var Promises = (function( ) { - - var Promises = {}; - - /** - * Resolves as soon as any promise resolves in the order of the input array - * - * @param arr - array of promises - * @return promise that resolves if any one promise resolves and rejects - * if otherwise - **/ - Promises.any = function (promises) { - if (!Array.isArray(promises)) { - // Is raw object or promise, resolve it directly - return Promise.resolve(promises); - } - if (promises.length === 0) { - // No promises to resolve so we think it failed - return Promise.reject(); - } - return new Promise(function (resolve, reject) { - var hasResolved = false; - var hasCompleted = 0; - var errors = []; - for (var i = 0; i < promises.length; i++) { - promises[i].then(function (value) { - hasCompleted++; - if (!hasResolved) { - hasResolved = true; - resolve(value); - } - }).catch((function (i) { - return function (e) { - hasCompleted++; - errors[i] = e; - if (hasCompleted === promises.length) { - // All promises have completed and we are in rejecting case - if (!hasResolved) { - reject(errors); - } - } - } - })(i)); - } - }); - }; - - return Promises; -})(); diff --git a/src/core/Comment.ts b/src/core/Comment.ts deleted file mode 100644 index d5e811e..0000000 --- a/src/core/Comment.ts +++ /dev/null @@ -1,527 +0,0 @@ -/** - * Basic Comment Abstraction - * - * @author Jim Chen - * @license MIT License - * @description Comment abstraction based on DOM implementation - */ -/// -/// -class CoreComment implements IComment { - public static LINEAR:Function = function (t:number, b:number, c:number, d:number):number { - return t * c / d + b; - }; - - public mode:number = 1; - public stime:number = 0; - public text:string = ''; - public ttl:number = 4000; - public dur:number = 4000; - public cindex:number = -1; - - public motion:Array = []; - public movable:boolean = true; - - private _curMotion:number; - private _motionStart:Array; - private _motionEnd:Array; - private _alphaMotion:Object = null; - - public _x:number; - public _y:number; - - /** - * Absolute coordinates. Use absolute coordinates if true otherwise use percentages. - * @type {boolean} use absolute coordinates or not (default true) - */ - public absolute:boolean = true; - /** - * Alignment - * @type {number} 0=tl, 2=bl, 1=tr, 3=br - */ - public align:number = 0; - /** - * Axis - * @type {number} 0=dr, 1=dl, 2=ur, 3=ul - */ - public axis:number = 0; - - public _alpha:number = 1; - public _size:number = 25; - private _width:number; - private _height:number; - private _color:number = 0xffffff; - private _border:boolean = false; - private _shadow:boolean = true; - private _font:string = ''; - private _transform:CommentUtils.Matrix3D = null; - - public parent:ICommentManager; - public dom:HTMLDivElement; - - constructor(parent:ICommentManager, init:Object = {}) { - if (!parent) { - throw new Error('Comment not bound to comment manager.'); - } else { - this.parent = parent; - } - if (init.hasOwnProperty('stime')) { - this.stime = init['stime']; - } - if (init.hasOwnProperty('mode')) { - this.mode = init['mode']; - } else { - this.mode = 1; - } - if (init.hasOwnProperty('dur')) { - this.dur = init['dur']; - this.ttl = this.dur; - } - this.dur *= this.parent.options.global.scale; - this.ttl *= this.parent.options.global.scale; - if (init.hasOwnProperty('text')) { - this.text = init['text']; - } - if (init.hasOwnProperty('motion')) { - this._motionStart = []; - this._motionEnd = []; - this.motion = init['motion']; - var head = 0; - for (var i = 0; i < init['motion'].length; i++) { - this._motionStart.push(head); - var maxDur = 0; - for (var k in init['motion'][i]) { - var m = init['motion'][i][k]; - maxDur = Math.max(m.dur + m.delay, maxDur); - if (m.easing === null || m.easing === undefined) { - init['motion'][i][k]['easing'] = CoreComment.LINEAR; - } - } - head += maxDur; - this._motionEnd.push(head); - } - this._curMotion = 0; - } - if (init.hasOwnProperty('color')) { - this._color = init['color']; - } - if (init.hasOwnProperty('size')) { - this._size = init['size']; - } - if (init.hasOwnProperty('border')) { - this._border = init['border']; - } - if (init.hasOwnProperty('opacity')) { - this._alpha = init['opacity']; - } - if (init.hasOwnProperty('alpha')) { - this._alphaMotion = init['alpha']; - } - if (init.hasOwnProperty('font')) { - this._font = init['font']; - } - if (init.hasOwnProperty('x')) { - this._x = init['x']; - } - if (init.hasOwnProperty('y')) { - this._y = init['y']; - } - if (init.hasOwnProperty('shadow')) { - this._shadow = init['shadow']; - } - if (init.hasOwnProperty('align')) { - this.align = init['align']; - } - if (init.hasOwnProperty('axis')) { - this.axis = init['axis']; - } - if (init.hasOwnProperty('transform')) { - this._transform = new CommentUtils.Matrix3D(init['transform']); - } - if (init.hasOwnProperty('position')) { - if (init['position'] === 'relative') { - this.absolute = false; - if (this.mode < 7) { - console.warn('Using relative position for CSA comment.'); - } - } - } - } - - protected _toggleClass(className:string, toggle:boolean = false):void { - if (!this.dom) { - return; - } - if (this.dom.classList) { - this.dom.classList.toggle(className, toggle); - } else { - // Fallback to traditional method - var classList:string[] = this.dom.className.split(' '); - var index = classList.indexOf(className); - if (index >= 0 && !toggle) { - classList.splice(index, 1); - this.dom.className = classList.join(' '); - } else if (index < 0 && toggle) { - classList.push(className) - this.dom.className = classList.join(' '); - } - } - } - - /** - * Initializes the DOM element (or canvas) backing the comment - * This method takes the place of 'initCmt' in the old CCL - */ - public init(recycle:IComment = null):void { - if (recycle !== null) { - this.dom = recycle.dom; - } else { - this.dom = document.createElement('div'); - } - this.dom.className = this.parent.options.global.className; - this.dom.appendChild(document.createTextNode(this.text)); - this.dom.textContent = this.text; - this.dom.innerText = this.text; - this.size = this._size; - if (this._color != 0xffffff) { - this.color = this._color; - } - this.shadow = this._shadow; - if (this._border) { - this.border = this._border; - } - if (this._font !== '') { - this.font = this._font; - } - if (this._x !== undefined) { - this.x = this._x; - } - if (this._y !== undefined) { - this.y = this._y; - } - if (this._alpha !== 1 || this.parent.options.global.opacity < 1) { - this.alpha = this._alpha; - } - if (this._transform !== null && ! this._transform.isIdentity()) { - this.transform = this._transform.flatArray; - } - if (this.motion.length > 0) { - // Force a position update before doing anything - this.animate(); - } - } - - get x():number { - if (this._x === null || this._x === undefined) { - if (this.axis % 2 === 0) { - if (this.align % 2 === 0) { - this._x = this.dom.offsetLeft; - } else { - this._x = this.dom.offsetLeft + this.width; - } - } else { - if (this.align % 2 === 0) { - this._x = this.parent.width - this.dom.offsetLeft; - } else { - this._x = this.parent.width - this.dom.offsetLeft - this.width; - } - } - } - if (!this.absolute) { - return this._x / this.parent.width; - } - return this._x; - } - - get y():number { - if (this._y === null || this._y === undefined) { - if (this.axis < 2) { - if (this.align < 2) { - this._y = this.dom.offsetTop; - } else { - this._y = this.dom.offsetTop + this.height; - } - } else { - if (this.align < 2) { - this._y = this.parent.height - this.dom.offsetTop; - } else { - this._y = this.parent.height - this.dom.offsetTop - this.height; - } - } - } - if (!this.absolute) { - return this._y / this.parent.height; - } - return this._y; - } - - get bottom():number { - var sameDirection = Math.floor(this.axis / 2) === Math.floor(this.align / 2); - return this.y + (sameDirection ? this.height : 0); - } - - get right():number { - var sameDirection = this.axis % 2 === this.align % 2; - return this.x + (sameDirection ? this.width : 0); - } - - get width():number { - if (this._width === null || this._width === undefined) { - this._width = this.dom.offsetWidth; - } - return this._width; - } - - get height():number { - if (this._height === null || this._height === undefined) { - this._height = this.dom.offsetHeight; - } - return this._height; - } - - get size():number { - return this._size; - } - - get color():number { - return this._color; - } - - get alpha():number { - return this._alpha; - } - - get border():boolean { - return this._border; - } - - get shadow():boolean { - return this._shadow; - } - - get font():string { - return this._font; - } - - get transform():Array { - return this._transform.flatArray; - } - - set x(x:number) { - this._x = x; - if (!this.absolute) { - this._x *= this.parent.width; - } - if (this.axis % 2 === 0) { - this.dom.style.left = (this._x + (this.align % 2 === 0 ? 0 : -this.width)) + 'px'; - } else { - this.dom.style.right = (this._x + (this.align % 2 === 0 ? -this.width : 0)) + 'px'; - } - } - - set y(y:number) { - this._y = y; - if (!this.absolute) { - this._y *= this.parent.height; - } - if (this.axis < 2) { - this.dom.style.top = (this._y + (this.align < 2 ? 0 : -this.height)) + 'px'; - } else { - this.dom.style.bottom = (this._y + (this.align < 2 ? -this.height : 0)) + 'px'; - } - } - - set width(w:number) { - this._width = w; - this.dom.style.width = this._width + 'px'; - } - - set height(h:number) { - this._height = h; - this.dom.style.height = this._height + 'px'; - } - - set size(s:number) { - this._size = s; - this.dom.style.fontSize = this._size + 'px'; - } - - set color(c:number) { - this._color = c; - var color:string = c.toString(16); - color = color.length >= 6 ? color : new Array(6 - color.length + 1).join('0') + color; - this.dom.style.color = '#' + color; - if (this._color === 0) { - this._toggleClass('reverse-shadow', true); - } - } - - set alpha(a:number) { - this._alpha = a; - this.dom.style.opacity = Math.min(this._alpha, this.parent.options.global.opacity) + ''; - } - - set border(b:boolean) { - this._border = b; - if (this._border) { - this.dom.style.border = '1px solid #00ffff'; - } else { - this.dom.style.border = 'none'; - } - } - - set shadow(s:boolean) { - this._shadow = s; - if (!this._shadow) { - this._toggleClass('no-shadow', true); - } - } - - set font(f:string) { - this._font = f; - if (this._font.length > 0) { - this.dom.style.fontFamily = this._font; - } else { - this.dom.style.fontFamily = ''; - } - } - - set transform(array:Array) { - this._transform = new CommentUtils.Matrix3D(array); - if (this.dom !== null) { - this.dom.style.transform = this._transform.toCss(); - } - } - - /** - * Moves the comment by a number of milliseconds. When - * the given parameter is greater than 0 the comment moves - * forward. Otherwise it moves backwards. - * @param time - elapsed time in ms - */ - public time(time:number):void { - this.ttl -= time; - if (this.ttl < 0) { - this.ttl = 0; - } - if (this.movable) { - this.update(); - } - if (this.ttl <= 0) { - this.finish(); - } - } - - /** - * Update the comment's position depending on its mode and - * the current ttl/dur values. - */ - public update():void { - this.animate(); - } - - /** - * Invalidate the comment position. - */ - public invalidate():void { - this._x = null; - this._y = null; - this._width = null; - this._height = null; - } - - /** - * Executes a motion object - * @param currentMotion - motion object - * @private - */ - private _execMotion(currentMotion:Object, time:number):void { - for (var prop in currentMotion) { - if (currentMotion.hasOwnProperty(prop)) { - var m = currentMotion[prop]; - this[prop] = m.easing( - Math.min(Math.max(time - m.delay, 0), m.dur), - m.from, - m.to - m.from, - m.dur); - } - } - } - - /** - * Update the comment's position depending on the applied motion - * groups. - */ - public animate():void { - if (this._alphaMotion) { - this.alpha = - (this.dur - this.ttl) * - (this._alphaMotion['to'] - this._alphaMotion['from']) / - this.dur + - this._alphaMotion['from']; - } - if (this.motion.length === 0) { - return; - } - var ttl:number = Math.max(this.ttl, 0); - var time:number = (this.dur - ttl) - this._motionStart[this._curMotion]; - this._execMotion(this.motion[this._curMotion], time); - if (this.dur - ttl > this._motionEnd[this._curMotion]) { - this._curMotion++; - if (this._curMotion >= this.motion.length) { - this._curMotion = this.motion.length - 1; - } - return; - } - } - - /** - * Notify the comment to stop. This has no effect if the comment - * is driven by a timer. - */ - public stop():void { - // Do nothing - } - - /** - * Remove the comment and do some cleanup. - */ - public finish():void { - this.parent.finish(this); - } - - /** - * Returns string representation of comment - * @returns {string} - */ - public toString():string { - return ['[', this.stime, '|', this.ttl, '/', this.dur, ']', '(', this.mode, ')', this.text].join(''); - } -} - -class ScrollComment extends CoreComment { - constructor(parent:ICommentManager, data:Object) { - super(parent, data); - this.dur *= this.parent.options.scroll.scale; - this.ttl *= this.parent.options.scroll.scale; - } - - set alpha(a:number) { - this._alpha = a; - this.dom.style.opacity = Math.min(Math.min(this._alpha, this.parent.options.global.opacity), - this.parent.options.scroll.opacity) + ''; - } - - public init(recycle:IComment = null):void { - super.init(recycle); - this.x = this.parent.width; - if (this.parent.options.scroll.opacity < 1) { - this.alpha = this._alpha; - } - this.absolute = true; - } - - public update():void { - this.x = (this.ttl / this.dur) * (this.parent.width + this.width) - this.width; - } -} diff --git a/src/core/CommentFactory.ts b/src/core/CommentFactory.ts deleted file mode 100644 index b5a34d1..0000000 --- a/src/core/CommentFactory.ts +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Comment Factory Abstraction - * - * @author Jim Chen - * @license MIT License - * @description Factory to allow creation of different kinds of comments with - * different underlying abstractions. - */ -/// -/// -/// - -class CommentFactory implements ICommentFactory { - private _bindings:{[key:number]:Function;} = {}; - - private static _simpleCssScrollingInitializer (manager:ICommentManager, data:Object):IComment { - var cmt = new CssScrollComment(manager, data); - switch (cmt.mode) { - case 1: { - cmt.align = 0; - cmt.axis = 0; - break; - } - case 2: { - cmt.align = 2; - cmt.axis = 2; - break; - } - case 6: { - cmt.align = 1; - cmt.axis = 1; - break; - } - } - cmt.init(); - manager.stage.appendChild(cmt.dom); - return cmt; - } - - private static _simpleScrollingInitializer (manager:ICommentManager, data:Object):IComment { - var cmt = new ScrollComment(manager, data); - switch (cmt.mode) { - case 1: { - cmt.align = 0; - cmt.axis = 0; - break; - } - case 2: { - cmt.align = 2; - cmt.axis = 2; - break; - } - case 6: { - cmt.align = 1; - cmt.axis = 1; - break; - } - } - cmt.init(); - manager.stage.appendChild(cmt.dom); - return cmt; - } - - private static _simpleAnchoredInitializer (manager:ICommentManager, data:Object):IComment { - var cmt = new CoreComment(manager, data); - switch (cmt.mode) { - case 4: { - cmt.align = 2; - cmt.axis = 2; - break; - } - case 5: { - cmt.align = 0; - cmt.axis = 0; - break; - } - } - cmt.init(); - manager.stage.appendChild(cmt.dom); - return cmt; - }; - - private static _advancedCoreInitializer (manager:ICommentManager, data:Object):IComment { - var cmt = new CoreComment(manager, data); - cmt.init(); - cmt.transform = CommentUtils.Matrix3D.createRotationMatrix(0, data['rY'], data['rZ']).flatArray; - manager.stage.appendChild(cmt.dom); - return cmt; - } - - public static defaultFactory ():ICommentFactory { - var factory = new CommentFactory(); - factory.bind(1, CommentFactory._simpleScrollingInitializer); - factory.bind(2, CommentFactory._simpleScrollingInitializer); - factory.bind(6, CommentFactory._simpleScrollingInitializer); - factory.bind(4, CommentFactory._simpleAnchoredInitializer); - factory.bind(5, CommentFactory._simpleAnchoredInitializer); - factory.bind(7, CommentFactory._advancedCoreInitializer); - factory.bind(17, CommentFactory._advancedCoreInitializer); - return factory; - } - - public static defaultCssRenderFactory ():ICommentFactory { - var factory = new CommentFactory(); - factory.bind(1, CommentFactory._simpleCssScrollingInitializer); - factory.bind(2, CommentFactory._simpleCssScrollingInitializer); - factory.bind(6, CommentFactory._simpleCssScrollingInitializer); - factory.bind(4, CommentFactory._simpleAnchoredInitializer); - factory.bind(5, CommentFactory._simpleAnchoredInitializer); - factory.bind(7, CommentFactory._advancedCoreInitializer); - factory.bind(17, CommentFactory._advancedCoreInitializer); - return factory; - } - - public static defaultCanvasRenderFactory ():ICommentFactory { - throw new Error('Not implemented'); - } - - public static defaultSvgRenderFactory ():ICommentFactory { - throw new Error('Not implemented'); - } - - public bind (mode:number, factory:Function):void { - this._bindings[mode] = factory; - } - - public canCreate (comment:Object):boolean { - // Tests if a certain binding is available - return this._bindings.hasOwnProperty(comment['mode']); - } - - public create (manager:ICommentManager, comment:Object):IComment { - if (comment === null || !comment.hasOwnProperty('mode')) { - throw new Error('Comment format incorrect'); - } - if (!this._bindings.hasOwnProperty(comment['mode'])) { - throw new Error('No binding for comment type ' + comment['mode']); - } - return this._bindings[comment['mode']](manager, comment); - } -} diff --git a/src/core/CommentManager.ts b/src/core/CommentManager.ts deleted file mode 100644 index 921208d..0000000 --- a/src/core/CommentManager.ts +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Comment Core Library - * - * @author Jim Chen - * @license MIT License - * @description Comment management unit for CCL - */ -/// -/// -/// -/// - -class CommentManager implements ICommentManager { - private _width:number = 0; - private _height:number = 0; - private _status:string = "stopped"; - private _stage:HTMLDivElement; - private _listeners:{[name: string]:Array} = {}; - private _csa:Object = {}; - - public options:CCLOptions = { - "global": { - "scale": 1, - "opacity": 1, - "className": "cmt" - }, - "scroll": { - "scale": 1, - "opacity": 1 - }, - "scripting":{ - "mode": [8], - "engine": null - } - }; - public timeline:Array = []; - public runline:Array = []; - public position:number = 0; - public factory:ICommentFactory; - - get width():number { - return this._width; - } - - get height():number { - return this._height; - } - - get stage():HTMLDivElement { - return this._stage; - } - - get status():string { - return this._status; - } - - constructor(stage:HTMLDivElement) { - this._stage = stage; - } - - public init():void { - this.factory = CommentFactory.defaultCssRenderFactory(); - } - - /** - * Start the comment manager - */ - public start():void { - this._status = "running"; - } - - /** - * Stop the comment manager - */ - public stop():void { - this._status = "stopped"; - // Go through the comment runline and stop stuff - for (var i = 0; i < this.runline.length; i++) { - this.runline[i].stop(); - } - } - - /** - * Load a list of comments into the time line - * @param data - list of abstract comment data - */ - public load(data:Array):void { - this.timeline = data; - } - - /** - * Inserts an abstract comment data into the time line - * @param data - abstract comment data - */ - public insert(data:Object):void { - } - - /** - * Clears all comments managed from the stage - */ - public clear():void { - while(this.runline.length > 0){ - this.runline[0].finish(); - } - } - - /** - * Sends a comment onto the stage - * @param data - abstract comment data - */ - public send(data:Object):void { - if (!data.hasOwnProperty("mode")) { - data["mode"] = 1; - } - if (this.options.scripting.mode.indexOf(data["mode"]) >= 0) { - /** Scripting comment **/ - if (this.options.scripting.engine !== null) { - this.options.scripting.engine.eval(data["code"]); - } - return; - } - this.runline.push(this.factory.create(this, data)); - } - - /** - * Set the bounds for the comment manager - * @param width - width value px - * @param height - height value px - */ - public setBounds(width:number = this.stage.offsetWidth, height:number = this.stage.offsetHeight):void { - this._width = width; - this._height = height; - this.dispatchEvent("resize"); - for(var allocator in this._csa){ - if(this._csa.hasOwnProperty(allocator)){ - var csa:CommentSpaceAllocator = this._csa[allocator]; - csa.setBounds(this._width, this._height); - } - } - this.stage.style.perspective = this.width * Math.tan(40 * Math.PI/180) / 2 + "px"; - // TODO: Remove webkit prefix - this.stage.style["webkitPerspective"] = this.width * Math.tan(40 * Math.PI/180) / 2 + "px"; - } - - /** - * Dispatches an event - * @param name - event name - * @param data - corresponding data - */ - public dispatchEvent(name:string, data:Object = null):void { - if (this._listeners.hasOwnProperty(name)) { - var listenerList:Array = this._listeners[name]; - for (var i = 0; i < listenerList.length; i++) { - try { - listenerList[i](data); - } catch (e) { - console.warn(e); - } - } - } - } - - /** - * Add an event listener - * @param name - event name - * @param listener - listener function - */ - public addEventListener(name:string, listener:Function):void { - if (this._listeners.hasOwnProperty(name)) { - this._listeners[name].push(listener); - } else { - this._listeners[name] = [listener]; - } - } - - public finish(cmt:IComment):void { - var index:number = this.runline.indexOf(cmt); - if(index >= 0){ - this.runline.splice(index, 1); - } - } - -} diff --git a/src/core/CommentSpaceAllocator.ts b/src/core/CommentSpaceAllocator.ts deleted file mode 100644 index ab24425..0000000 --- a/src/core/CommentSpaceAllocator.ts +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Basic Space Allocation Unit - * - * @author Jim Chen (jabbany) - * @license MIT License - * @description Comment space allocation units for static and movable comments - */ -/// -interface ISpaceAllocator { - add(c:IComment):void; - remove(c:IComment):void; - setBounds(w:number, h:number):void; -} - -class CommentSpaceAllocator implements ISpaceAllocator { - public _width:number; - public _height:number; - private _pools:Array> = [ - [] - ]; - /** - * Number of pixels to avoid from last possible y-offset - * @type {number} - */ - public avoid:number = 1; - - /** - * Constructs a space allocator - * @param width - allocator width pixels (default 0) - * @param height - allocator height pixels (default 0) - */ - constructor(width:number = 0, height:number = 0) { - this._width = width; - this._height = height; - } - - /** - * Logic to determine if checked comment collides with existing comment - * We say that comments collide if the existing comment finishes later - * than the checked comment is halfway through - * - * @param existing - Existing comment; - * @param check - Checked comment - * @returns {boolean} checked collides with exisiting - */ - public willCollide(existing:IComment, check:IComment):boolean { - return existing.stime + existing.ttl >= check.stime + check.ttl / 2; - } - - /** - * Validates sufficient space for a "bullet path" for the comment. - * - * @param y - Path starting at y offset (path height is the comment height) - * @param comment - Comment instance to test - * @param pool - The pool to test in. - * @returns {boolean} whether or not a valid path exists in the tested pool. - */ - public pathCheck(y:number, comment:IComment, pool:Array):boolean { - var bottom = y + comment.height; - var right = comment.right; - for (var i = 0; i < pool.length; i++) { - if (pool[i].y > bottom || pool[i].bottom < y) { - // This comment is not in the path bounds - continue; - } else if (pool[i].right < comment.x || pool[i].x > right) { - - if (this.willCollide(pool[i], comment)) { - return false; - } else { - continue; - } - } else { - return false; - } - } - return true; - } - - /** - * Finds a good y-coordinate for comment such that minimal collision happens. - * This method will also add the comment to the allocated pool and assign a proper cindex - * - * @param comment - Comment - * @param cindex - Pool index - * @returns {number} Y offset assigned - */ - public assign(comment:IComment, cindex:number):number { - while (this._pools.length <= cindex) { - this._pools.push([]); - } - var pool = this._pools[cindex]; - if (pool.length === 0) { - comment.cindex = cindex; - return 0; - } else if (this.pathCheck(0, comment, pool)) { - // Has a path in the current pool - comment.cindex = cindex; - return 0; - } - var y:number = 0; - for (var k = 0; k < pool.length; k++) { - y = pool[k].bottom + this.avoid; - if (y + comment.height > this._height) { - break; - } - if (this.pathCheck(y, comment, pool)) { - // Has a path in the current pool - comment.cindex = cindex; - return y; - } - } - // Assign one pool deeper - return this.assign(comment, cindex + 1); - } - - /** - * Adds a comment to the space allocator. Will also assign the - * comment's y values. Note that added comments may not be actually - * recorded, check the cindex value. - * @param comment - */ - public add(comment:IComment):void { - if (comment.height > this._height) { - comment.cindex = -2; - comment.y = 0; - } else { - comment.y = this.assign(comment, 0); - BinArray.binsert(this._pools[comment.cindex], comment, function (a, b) { - if (a.bottom < b.bottom) { - return -1; - } else if (a.bottom > b.bottom) { - return 1; - } else { - return 0; - } - }); - } - } - - /** - * Remove the comment from the space allocator. Will silently fail - * if the comment is not found - * @param comment - */ - public remove(comment:IComment):void { - if (comment.cindex < 0) { - return; - } - if (comment.cindex >= this._pools.length) { - throw new Error('cindex out of bounds'); - } - var index = this._pools[comment.cindex].indexOf(comment); - if (index < 0) - return; - this._pools[comment.cindex].splice(index, 1); - } - - /** - * Set the bounds (width, height) of the allocator. Normally this - * should be as big as the stage DOM object. But you can manually set - * this to another smaller value too. - * - * @param width - * @param height - */ - public setBounds(width:number, height:number):void { - this._width = width; - this._height = height; - } -} - -class AnchorCommentSpaceAllocator extends CommentSpaceAllocator { - public add(comment:IComment):void { - super.add(comment); - comment.x = (this._width - comment.width) / 2; - } - - public willCollide(a:IComment, b:IComment):boolean { - return true; - } - - public pathCheck(y:number, comment:IComment, pool:Array):boolean { - var bottom = y + comment.height; - for (var i = 0; i < pool.length; i++) { - if (pool[i].y > bottom || pool[i].bottom < y) { - continue; - } else { - return false; - } - } - return true; - } -} diff --git a/src/core/CommentUtils.ts b/src/core/CommentUtils.ts deleted file mode 100644 index 65b20b1..0000000 --- a/src/core/CommentUtils.ts +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Some Utility Classes - * - * @author Jim Chen - * @license MIT License - * @description Useful utility classes - */ -module CommentUtils { - export class Matrix3D { - private _internalArray:Array = null; - - public static identity:Function = function ():Matrix3D { - return new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); - }; - - public static createScaleMatrix:Function = function (xscale:number, yscale:number, zscale:number):Matrix3D { - return new Matrix3D([xscale, 0, 0, 0, 0, yscale, 0, 0, 0, 0, zscale, 0, 0, 0, 0, 1]); - }; - - public static createRotationMatrix:Function = function (xrot:number, yrot:number, zrot:number):Matrix3D { - // Courtesy of @StarBrilliant, re-adapted for general case - // TODO: add support for xrot - var DEG2RAD = Math.PI/180; - var yr = yrot * DEG2RAD; - var zr = zrot * DEG2RAD; - var COS = Math.cos; - var SIN = Math.sin; - var matrix = [ - COS(yr) * COS(zr) , COS(yr) * SIN(zr) , SIN(yr) , 0, - (-SIN(zr)) , COS(zr) , 0 , 0, - (-SIN(yr) * COS(zr)) , (-SIN(yr) * SIN(zr)) , COS(yr) , 0, - 0 , 0 , 0 , 1 - ]; - // Do some rounding - return new Matrix3D(matrix.map(v => Math.round(v * 1e10) * 1e-10)); - }; - - /** - * Constructs a Matrix3D (4x4 matrix) - * @constructor - * @param {Array} input array ofs 16 elements corresponding to rows of the matrix - */ - constructor(array:Array) { - if (!Array.isArray(array)) { - throw new Error('Not an array. Cannot construct matrix.'); - } - if (array.length != 16) { - throw new Error('Illegal Dimensions. Matrix3D should be 4x4 matrix.'); - } - this._internalArray = array; - } - - get flatArray():Array { - return this._internalArray.slice(0); - } - - set flatArray(array:Array) { - throw new Error('Not permitted. Matrices are immutable.'); - } - - /** - * Check equality to identity matrix - * @returns {boolean} indicates whether this is the identity matrix - */ - public isIdentity():boolean { - return this.equals(Matrix3D.identity()); - } - - /** - * Computes dot product of two Matrix3D objects - * @param {Matrix3D} input matrix b to compute dot product on - * @returns {Matrix3D} dot product - */ - public dot(matrix:Matrix3D):Matrix3D { - var a = this._internalArray.slice(0); - var b = matrix._internalArray.slice(0); - var res:Array = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (var i = 0; i < 4; i++) { - for (var j = 0; j < 4; j++) { - for (var k = 0; k < 4; k++) { - res[i * 4 + j] += a[i * 4 + k] * b[k * 4 + j]; - } - } - } - return new Matrix3D(res); - } - - /** - * Check to see if two matrices are the same - * @param {Matrix3D} input matrix b to compare to - * @returns {boolean} indicator of whether two matrices are the same - */ - public equals(matrix:Matrix3D):boolean { - for (var i = 0; i < 16; i++) { - if (this._internalArray[i] !== matrix._internalArray[i]) { - return false; - } - } - return true; - } - - /** - * Writes the matrix out to CSS compatible format - * @returns {string} representation of matrix - */ - public toCss():string { - var matrix = this._internalArray.slice(0); - for (var i = 0; i < matrix.length;i++) { - if (Math.abs(matrix[i]) < 0.000001) { - matrix[i] = 0; - } - } - return 'matrix3d(' + matrix.join(',') + ')'; - } - } -} diff --git a/src/core/Core.d.ts b/src/core/Core.d.ts deleted file mode 100644 index 8bcaab8..0000000 --- a/src/core/Core.d.ts +++ /dev/null @@ -1,147 +0,0 @@ -/** - * Core Definitions file - * - * @author Jim Chen - * @description Definitions file for interfaces used in CCL - */ - -/** - * Definintions for binary array tools - */ -interface IBinArray { - /** - * Binary insert into array - * @param arr - target array - * @param inserted - element to be inserted - * @param how - comparison function - */ - binsert(arr:Array, inserted:any, how:Function):number; - /** - * Binary loose search - * @param arr - array to look in - * @param what - object to try to find - * @param how - comparison function - */ - bsearch(arr:Array, what:any, how:Function):number; -} -declare var BinArray:IBinArray; - -interface IScriptingEngine { - eval(code:String); -} - -/** - * Options for CommentCoreLibrary - */ -interface CCLOptions { - global: { - scale: number; - opacity: number; - className: string; - } - scroll: { - scale:number; - opacity:number; - } - scripting:{ - mode:Array; - engine:IScriptingEngine; - } -} - -interface ICommentManager { - stage:any; - width:number; - height:number; - options:CCLOptions; - /** - * Start the comment manager comments - */ - start():void; - /** - * Stop the running comments - */ - stop():void; - /** - * Remove all current running comments - */ - clear():void; - /** - * Set the bounds for the CommentManager stage - * @param w width - * @param h height - */ - setBounds(w?:number, h?:number):void; - /** - * Cleanup the given comment since it has finished - * @param c - IComment - */ - finish(c:IComment):void; -} - -interface ICommentFactory { - create(manager:ICommentManager, comment:Object):IComment; -} - -/** - * Easable motion on a certain parameter - */ -interface IMotion { - from:number; - to:number; - delay:number; - dur:number; - ttl:number; - easing:Function; -} - -interface IComment { - dom:any; - stime:number; - dur:number; - ttl:number; - cindex:number; - align:number; - axis:number; - x:number; - y:number; - bottom:number; - right:number; - width:number; - height:number; - movable:boolean; - border:boolean; - shadow:boolean; - font:string; - color:number; - alpha:number; - size:number; - /** - * Updates the comment life by subtracting t from ttl - * @param t - difference in time - */ - time(t:number):void; - /** - * Update the comment's position based on the time. - * This is called by time() - */ - update():void; - /** - * Invalidate the coordinates and dimensions of the - * current comment object - */ - invalidate():void; - /** - * Perform an animation alongside the update - */ - animate():void; - /** - * Remove the comment from display - */ - finish():void; - - /** - * Called when the outside container stops - */ - stop():void; -} diff --git a/src/core/canvas-renderer/CanvasComment.ts b/src/core/canvas-renderer/CanvasComment.ts deleted file mode 100644 index ea71278..0000000 --- a/src/core/canvas-renderer/CanvasComment.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Basic Canvas Comment Abstraction - * - * @author Jim Chen - * @license MIT License - * @description Comment abstraction based on CANVAS implementation - */ -/// \ No newline at end of file diff --git a/src/core/comment-manager.ts b/src/core/comment-manager.ts new file mode 100644 index 0000000..5c05a7e --- /dev/null +++ b/src/core/comment-manager.ts @@ -0,0 +1,186 @@ +/** + * Comment Core Library + * + * @author Jim Chen + * @license MIT License + * @description Comment management unit for CCL + */ +import { Options, UpdateableCommentData, CommentData, SpaceAllocator } + from './interfaces'; +import { Renderer } from '../renderer'; +import { binaryInsert } from '../lib'; + + +type Status = 'running' | 'stopped'; +type Listener = (data?:object) => void; +type ListenerPool = {[name:string]:Listener[]}; + +export class CommentManager { + private _status:Status; + private _renderer:Renderer; + + private _listeners:ListenerPool = {}; + private _csa:{[name:string]:SpaceAllocator} = {}; + public options:Options = { + global: { + scale: 1, + opacity: 1, + classNames: ['cmt'] + }, + fixed: { + scale: 1, + opacity: 1, + classNames: [] + }, + scroll: { + scale: 1, + opacity: 1, + classNames: [] + }, + scripting: { + modes: [8], + engine: null + } + }; + public timeline:CommentData[] = []; + public runline:T[] = []; + public position:number = 0; + + get status():string { + return this._status; + } + + constructor(renderer:Renderer) { + this._renderer = renderer; + this._status = 'stopped'; + } + + public init():void { + // Create the space allocators + } + + /** + * Start the comment manager + */ + public start():void { + this._status = 'running'; + this._status = 'stopped'; + this.runline.forEach((item) => { + this._renderer.track(item).start(); + }) + } + + /** + * Stop the comment manager + */ + public stop():void { + this._status = 'stopped'; + this.runline.forEach((item) => { + this._renderer.track(item).stop(); + }) + } + + /** + * Load a list of comments into the time line + * @param data - list of abstract comment data + */ + public load(timeline:CommentData[]):void { + this.timeline = timeline; + } + + /** + * Inserts an abstract comment data into the time line + * @param data - abstract comment data + */ + public insert(data:CommentData):void { + // Find this data + binaryInsert(this.timeline, data, (a, b) => { + if (a.startTime > b.startTime) { + return 1; + } else if (a.startTime < b.startTime) { + return -1; + } else { + if (typeof a.date !== 'undefined' && typeof b.date !== 'undefined' && + a.date !== b.date) { + return a.date > b.date ? 1 : -1; + } + if (typeof a.id !== 'undefined' && typeof b.id !== 'undefined' && + a.id !== b.id) { + + return a.id > b.id ? 1 : -1; + } + return 0; + } + }); + } + + /** + * Clears all comments managed from the stage + */ + public clear():void { + this.runline.forEach((item) => { + this._renderer.destroy(item); + }); + this.runline = []; + } + + /** + * Sends a comment onto the stage + * @param data - abstract comment data + */ + public send(data:CommentData):void { + let comment = this._renderer.create(data); + // Try to allocate the comment; + + // Start the comment moving + this._renderer.track(comment).start(); + + this.runline.push(comment); + } + + /** + * Set the bounds for the comment manager + * @param width - width value px + * @param height - height value px + */ + public setBounds(width:number, height:number):void { + this.dispatchEvent("resize"); + for (let allocator in this._csa){ + if (this._csa.hasOwnProperty(allocator)){ + let csa = this._csa[allocator]; + csa.setBounds(width, height); + } + } + } + + /** + * Dispatches an event + * @param name - event name + * @param data - corresponding data + */ + public dispatchEvent(name:string, data?:object):void { + if (this._listeners.hasOwnProperty(name)) { + let listenerList = this._listeners[name]; + for (var i = 0; i < listenerList.length; i++) { + try { + listenerList[i](data); + } catch (e) { + console.warn(e); + } + } + } + } + + /** + * Add an event listener + * @param name - event name + * @param listener - listener function + */ + public addEventListener(name:string, listener:Listener):void { + if (this._listeners.hasOwnProperty(name)) { + this._listeners[name].push(listener); + } else { + this._listeners[name] = [listener]; + } + } +} diff --git a/src/core/comment-space-allocator.ts b/src/core/comment-space-allocator.ts new file mode 100644 index 0000000..6462063 --- /dev/null +++ b/src/core/comment-space-allocator.ts @@ -0,0 +1,212 @@ +/** + * Basic Space Allocation Unit + * + * @author Jim Chen (jabbany) + * @license MIT License + * @description Comment space allocation units for static and movable comments + */ +import { SpaceAllocator, AllocationResult, UpdateableCommentData, CommentData } + from './interfaces'; +import { Renderer } from '../renderer/interfaces'; +import { binaryInsert } from '../lib'; + +export class CommentSpaceAllocator implements SpaceAllocator { + protected _renderer:Renderer; + protected _width:number; + protected _height:number; + private _pools:T[][]; + /** + * Number of pixels to avoid from last possible y-offset + * @type {number} + */ + public avoid:number = 1; + + /** + * Constructs a space allocator + * @param width - allocator width pixels (default 0) + * @param height - allocator height pixels (default 0) + */ + constructor(renderer:Renderer, + width:number = 0, height:number = 0) { + + this._renderer = renderer; + this._width = width; + this._height = height; + this._pools = []; + } + + /** + * Logic to determine if checked comment collides with existing comment + * We only use time and not positional measurements to reduce DOM throttling + * + * @param existing - Existing comment; + * @param target - Comment we are checkng a collision for + * @returns {boolean} checked collides with exisiting + */ + public willCollide(existing:T, target:T):boolean { + let trackerExisting = this._renderer.track(existing), + trackerTarget = this._renderer.track(target); + let existingTtl = trackerExisting.duration - trackerExisting.time; + return trackerTarget.time + existingTtl <= trackerTarget.duration / 2; + } + + /** + * Validates sufficient space for a "bullet path" for the comment. + * + * @param y - Path starting at y offset (path height is the comment height) + * @param measurement - Measurement to check + * @param pool - The pool to test in. + * @returns {boolean} whether or not a valid path exists in the tested pool. + */ + protected pathCheck(y:number, comment:T, pool:T[]):boolean { + // Measure the comment + let measurement = this._renderer.measure(comment); + let bottom = y + measurement.height, + right = measurement.right; + for (let i = 0; i < pool.length; i++) { + let refMeasurement = this._renderer.measure(pool[i]); + if (refMeasurement.y > bottom || refMeasurement.bottom < y) { + // This comment is not in the path bounds + continue; + } else if (refMeasurement.right < measurement.x || + refMeasurement.x > right) { + + if (this.willCollide(pool[i], comment)) { + return false; + } else { + continue; + } + } else { + return false; + } + } + return true; + } + + /** + * Finds a good y-coordinate for comment such that minimal collision happens. + * This method will also add the comment to the allocated pool and assign a + * proper pool index + * + * @param comment - Comment + * @param poolIndex - Pool index + * @returns {number} Y offset assigned + */ + public provision(comment:T, + poolIndex:number = 0):AllocationResult { + // Measure the comment first + while (this._pools.length <= poolIndex) { + this._pools.push([]); + } + let pool = this._pools[poolIndex]; + if (pool.length === 0 || this.pathCheck(0, comment, pool)) { + return { + y: 0, + poolIndex: poolIndex + }; + } + + let y:number = 0; + let measurement = this._renderer.measure(comment); + for (let k = 0; k < pool.length; k++) { + y = this._renderer.measure(pool[k]).bottom + this.avoid; + if (y + measurement.height > this._height) { + break; + } + if (this.pathCheck(y, comment, pool)) { + // Has a path in the current pool + return { + x: measurement.x, + y: y, + poolIndex: poolIndex + }; + } + } + // Assign one pool deeper + return this.provision(comment, poolIndex + 1); + } + + /** + * Adds a comment to the space allocator. Will also assign the + * comment's y values. Note that added comments may not be actually + * recorded, check the cindex value. + * @param comment + */ + public add(comment:T):void { + let measurements = this._renderer.measure(comment); + if (measurements.height > this._height) { + this._renderer.update(comment, { + position: { + x: measurements.x, + y: 0 + } + }); + } else { + let assignedPosition = this.provision(comment, 0); + binaryInsert(this._pools[assignedPosition.poolIndex], comment, (a, b) => { + let bottomA = this._renderer.measure(a).bottom, + bottomB = this._renderer.measure(b).bottom; + if (bottomA < bottomB) { + return -1; + } else if (bottomA > bottomB) { + return 1; + } else { + return 0; + } + }); + } + } + + /** + * Remove the comment from the space allocator. Will silently fail + * if the comment is not found + * @param comment + */ + public remove(comment:T):void { + for (let poolId = 0; poolId < this._pools.length; poolId ++) { + let index = this._pools[poolId].indexOf(comment); + if (index >= 0) { + this._pools[poolId].splice(index, 1); + return; + } + } + } + + /** + * Set the bounds (width, height) of the allocator. Normally this + * should be as big as the stage DOM object. But you can manually set + * this to another smaller value too. + * + * @param width + * @param height + */ + public setBounds(width:number, height:number):void { + this._width = width; + this._height = height; + } +} + +export class AnchorCommentSpaceAllocator extends CommentSpaceAllocator { + public assign(comment:T, poolIndex:number = 0):AllocationResult { + let result = super.provision(comment, poolIndex); + result.x = (this._width - this._renderer.measure(comment).width) / 2; + return result; + } + + public willCollide(_a:T, _b:T):boolean { + return true; + } + + public pathCheck(y:number, comment:T, pool:T[]):boolean { + let bottom = y + this._renderer.measure(comment).height; + for (var i = 0; i < pool.length; i++) { + let m = this._renderer.measure(pool[i]); + if (m.y > bottom || m.bottom < y) { + continue; + } else { + return false; + } + } + return true; + } +} diff --git a/src/core/css-renderer/CssComment.ts b/src/core/css-renderer/CssComment.ts deleted file mode 100644 index 38bd28e..0000000 --- a/src/core/css-renderer/CssComment.ts +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Basic CSS Accelerated Comment Abstraction - * - * @author Jim Chen - * @license MIT License - * @description Comment abstraction based on CSS3 implementation - */ -/// -class CssCompatLayer { - public static transform(dom:HTMLDivElement, trans:string):void{ - dom.style.transform = trans; - dom.style["webkitTransform"] = trans; - dom.style["msTransform"] = trans; - dom.style["oTransform"] = trans; - } -} - -/** - * An add-in class to support CSS-based scrolling comments - */ -class CssScrollComment extends ScrollComment { - // Marker for whether we need to re-create the CSS or not - private _dirtyCSS:boolean = true; - - public init(recycle:IComment = null):void { - super.init(recycle); - this._toggleClass('css-optimize', true); - } - - set x(x:number) { - if (this._x !== null && typeof this._x === "number") { - // This is run when starting - var dx:number = x - this._x; - this._x = x; - CssCompatLayer.transform(this.dom, "translateX(" + - (this.axis % 2 === 0 ? dx : -dx) + "px)"); - } else { - // This is run when stopping - this._x = x; - if (!this.absolute) { - this._x *= this.parent.width; - } - // Got the x-value, now figure out where things are - if (this.axis % 2 === 0) { - // x-axis towards right - this.dom.style.left = - (this._x + (this.align % 2 === 0 ? 0 : -this.width)) + 'px'; - } else { - // x-axis towards left - this.dom.style.right = - (this._x + (this.align % 2 === 0 ? -this.width : 0)) + 'px'; - } - } - } - - get x():number{ - // X always goes from {parent.width to -this.width} - return (this.ttl / this.dur) * (this.parent.width + this.width) - this.width; - } - - public update():void{ - if (this._dirtyCSS) { - // Start moving - this.dom.style.transition = "transform " + this.ttl + "ms linear"; - this.x = - this.width; - this._dirtyCSS = false; - } - } - - public invalidate():void{ - super.invalidate(); - this._dirtyCSS = true; - } - - /** - * Override the toplevel stop to actually stop the CSS. - */ - public stop():void{ - super.stop(); - this.dom.style.transition = ''; - // This clears translation (sets translate to 0px) - this.x = this._x; - // Set to null to force writing an absolute x position - this._x = null; - // Write down the current expected x as absolute - this.x = this.x; - // Make the CSS dirty so that next update will start the movement - this._dirtyCSS = true; - } -} diff --git a/src/core/index.ts b/src/core/index.ts new file mode 100644 index 0000000..9eb3b6e --- /dev/null +++ b/src/core/index.ts @@ -0,0 +1,3 @@ + +export * from './comment-manager'; +export * from './comment-space-allocator'; diff --git a/src/core/interfaces/Options.d.ts b/src/core/interfaces/Options.d.ts new file mode 100644 index 0000000..c1fabbb --- /dev/null +++ b/src/core/interfaces/Options.d.ts @@ -0,0 +1,17 @@ +import { ScriptingEngine } from './scripting-engine'; + +export interface TypeOptions { + scale: number; + opacity: number; + classNames: string[]; +} + +export interface Options { + global: TypeOptions; + fixed: TypeOptions; + scroll: TypeOptions; + scripting:{ + modes: number[]; + engine: ScriptingEngine|null; + } +} diff --git a/src/core/interfaces/comment-data.d.ts b/src/core/interfaces/comment-data.d.ts new file mode 100644 index 0000000..5b6fcf3 --- /dev/null +++ b/src/core/interfaces/comment-data.d.ts @@ -0,0 +1,82 @@ +export type CoordinateMode = 'absolute'|'relative'; +export type Axis = 'top-left'|'top-right'|'bottom-left'|'bottom-right'; + +export interface UpdateablePosition { + x?:number; + y?:number; + z?:number; + mode?:CoordinateMode; + axis?:Axis; +} + +export interface Position extends UpdateablePosition { + x:number; + y:number; + mode:CoordinateMode; + axis:Axis; +} + +export interface Orientation { + rx?:number; + ry?:number; + rz?:number; +} + +export interface Anchor { + vertical:number; + horizontal:number; +} + +export interface Scale { + x:number; + y:number; + z?:number; +} + +export interface Animatable { + position?:UpdateablePosition, + orientation?:Orientation, + scale?:Scale, + color?:number; + alpha?:number; + size?:number; +} + +export interface Waypoint extends Animatable { + duration:number; + interpolation:'none'|'linear'; +} + +export type AnimationMode = + 'scroll-left'|'scroll-right'|'fixed'|'single'|'path'; + +export interface AnimationData { + duration:number; + mode:AnimationMode; + path?:Waypoint[]; +} + +export interface UpdateableCommentData extends Animatable { + text?:string; + font?:string | null; + border?:boolean; + outline?:boolean; +} + +export interface CommentData extends UpdateableCommentData { + startTime:number; + text:string; + font:string | null; + size:number; + color:number; + alpha:number; + border:boolean; + outline:boolean; + position:Position; + orientation:Orientation; + anchor:Anchor; + scale:Scale; + animation:AnimationData; + date?:number; + id?:string; +} diff --git a/src/core/interfaces/index.d.ts b/src/core/interfaces/index.d.ts new file mode 100644 index 0000000..00ff455 --- /dev/null +++ b/src/core/interfaces/index.d.ts @@ -0,0 +1,4 @@ +export * from './comment-data'; +export * from './options'; +export * from './scripting-engine'; +export * from './space-allocator'; diff --git a/src/core/interfaces/scripting-engine.d.ts b/src/core/interfaces/scripting-engine.d.ts new file mode 100644 index 0000000..1e95b6e --- /dev/null +++ b/src/core/interfaces/scripting-engine.d.ts @@ -0,0 +1,3 @@ +export interface ScriptingEngine { + eval(code:string):void; +} diff --git a/src/core/interfaces/space-allocator.d.ts b/src/core/interfaces/space-allocator.d.ts new file mode 100644 index 0000000..82f69ac --- /dev/null +++ b/src/core/interfaces/space-allocator.d.ts @@ -0,0 +1,15 @@ +import { Measurement } from '../../renderer/interfaces'; +import { UpdateablePosition } from './comment-data'; + +export interface SpaceAllocator { + provision(item:T):AllocationResult; + add(item:T):void; + remove(item:T):void; + setBounds(w:number, h:number):void; +} + +export interface AllocationResult extends UpdateablePosition { + x?:number; + y?:number; + poolIndex:number; +} diff --git a/src/core/svg-renderer/SvgComment.ts b/src/core/svg-renderer/SvgComment.ts deleted file mode 100644 index 6c95ce7..0000000 --- a/src/core/svg-renderer/SvgComment.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Basic SVG based Comment Abstraction - * - * @author Jim Chen - * @license MIT License - * @description Comment abstraction based on SVG implementation - */ -/// diff --git a/src/filter/StandardFilter.ts b/src/filter/StandardFilter.ts new file mode 100644 index 0000000..3300d4a --- /dev/null +++ b/src/filter/StandardFilter.ts @@ -0,0 +1,5 @@ +import { Filter } from './interfaces'; + +export class StandardFilter implements Filter { + +} diff --git a/src/filter/index.ts b/src/filter/index.ts new file mode 100644 index 0000000..f73c62c --- /dev/null +++ b/src/filter/index.ts @@ -0,0 +1 @@ +export * from './StandardFilter'; diff --git a/src/filter/interfaces/Filter.d.ts b/src/filter/interfaces/Filter.d.ts new file mode 100644 index 0000000..a0abde2 --- /dev/null +++ b/src/filter/interfaces/Filter.d.ts @@ -0,0 +1,3 @@ +export interface Filter { + +} diff --git a/src/filter/interfaces/Rule.d.ts b/src/filter/interfaces/Rule.d.ts new file mode 100644 index 0000000..a67aefb --- /dev/null +++ b/src/filter/interfaces/Rule.d.ts @@ -0,0 +1,5 @@ +export interface Rule { + subject:string; + op:string; + value:object; +} diff --git a/src/filter/interfaces/index.d.ts b/src/filter/interfaces/index.d.ts new file mode 100644 index 0000000..d91ea73 --- /dev/null +++ b/src/filter/interfaces/index.d.ts @@ -0,0 +1,2 @@ +export * from './filter'; +export * from './rule'; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..d09874a --- /dev/null +++ b/src/index.ts @@ -0,0 +1,6 @@ +/*** + * Comment Core Library Master Export file + * @description A TypeScript library to render + **/ +export { DOMRenderer } from './renderer'; +export { CommentManager } from './core'; diff --git a/src/lib/bsearch.ts b/src/lib/bsearch.ts new file mode 100644 index 0000000..0b56560 --- /dev/null +++ b/src/lib/bsearch.ts @@ -0,0 +1,68 @@ +/** + * Comparator type + * @param T type of list item to be compared + * @param U type of reference object to compare against list items + */ +export type Comparator = (target:U, current:T) => number; + +/** + * Performs binary search on the array + * Note: The array MUST ALREADY BE SORTED. + * + * @param arr - array to search on + * @param what - element to search for (may not be present) + * @param how - function comparator (a, b). Returns positive value if a > b + * @return index of the element (or index of the element if it were in the array) + */ +export function binarySearch(arr:T[], what:U, how:Comparator):number { + if (!Array.isArray(arr)) { + throw new Error('Input must be an array'); + } + // Empty array or before first element + if (arr.length === 0 || how(what, arr[0]) < 0) { + return 0; + } + // After last element + if (how(what, arr[arr.length - 1]) >= 0) { + return arr.length; + } + var low = 0, + high = arr.length - 1, + i = 0, + count = 0; + while (low <= high) { + i = Math.floor((high + low + 1)/2); + count++; + if (how(what, arr[i-1]) >= 0 && how(what, arr[i]) < 0) { + return i; + } else if (how(what, arr[i-1]) < 0) { + high = i-1; + } else if (how(what, arr[i]) >= 0) { + low = i; + } else { + throw new Error('Program Error:' + + ' Inconsistent comparator or unsorted array?'); + } + if (count > 1500) { + throw new Error('Iteration depth exceeded:' + + ' Inconsistent comparator or astronomical dataset!'); + } + } + return -1; +} + +/** + * Insert an element into its position in the array signified by bsearch + * + * @param arr - array to insert into + * @param what - element to insert + * @param how - comparator (see bsearch) + * @return index that the element was inserted to. + */ +export function binaryInsert(arr:T[], + what:U, how:Comparator):number { + + const index = binarySearch(arr,what,how); + arr.splice(index, 0, what); + return index; +} diff --git a/src/lib/color.ts b/src/lib/color.ts new file mode 100644 index 0000000..e35a101 --- /dev/null +++ b/src/lib/color.ts @@ -0,0 +1,7 @@ +export function toCssColor(color:number):string { + var cssColor:string = color.toString(16); + if (cssColor.length < 6) { + cssColor = new Array(6 - cssColor.length + 1).join('0') + cssColor; + } + return '#' + color; +} diff --git a/src/lib/index.ts b/src/lib/index.ts new file mode 100644 index 0000000..c3f6ad9 --- /dev/null +++ b/src/lib/index.ts @@ -0,0 +1,6 @@ +/** + * Common place for utility functions to reside + */ +export * from './bsearch'; +export * from './timer'; +export * from './color'; diff --git a/src/lib/matrix.ts b/src/lib/matrix.ts new file mode 100644 index 0000000..15c6ea7 --- /dev/null +++ b/src/lib/matrix.ts @@ -0,0 +1,122 @@ +/** + * Some Utility Classes + * + * @author Jim Chen + * @license MIT License + * @description Useful utility classes + */ +export class Matrix3D { + private _internalArray:number[] = []; + + public static identity:Function = function ():Matrix3D { + return new Matrix3D([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); + }; + + public static createScaleMatrix:Function = function ( + xscale:number, yscale:number, zscale:number):Matrix3D { + + return new Matrix3D([ + xscale, 0, 0, 0, + 0, yscale, 0, 0, + 0, 0, zscale, 0, + 0, 0, 0, 1]); + }; + + public static createRotationMatrix:Function = function ( + xrot:number, yrot:number, zrot:number):Matrix3D { + + // Courtesy of @StarBrilliant, re-adapted for general case + // TODO: add support for xrot + const COS = Math.cos, SIN = Math.sin; + const DEG2RAD = Math.PI/180, + xr = xrot * DEG2RAD, + yr = yrot * DEG2RAD, + zr = zrot * DEG2RAD; + const matrix = [ + COS(yr) * COS(zr) , COS(yr) * SIN(zr) , SIN(yr) , 0, + (-SIN(zr)) , COS(zr) , 0 , 0, + (-SIN(yr) * COS(zr)) , (-SIN(yr) * SIN(zr)) , COS(yr) , 0, + 0 , 0 , 0 , 1 + ]; + + if (xr !== 0) { + throw new Error('Not implemented'); + } + // Do some rounding + return new Matrix3D(matrix.map(v => Math.round(v * 1e10) * 1e-10)); + }; + + /** + * Constructs a Matrix3D (4x4 matrix) + * @constructor + * @param {number[]} input array ofs 16 elements corresponding to rows of the matrix + */ + constructor(array:number[]) { + if (!Array.isArray(array)) { + throw new Error('Not an array. Cannot construct matrix.'); + } + if (array.length != 16) { + throw new Error('Illegal Dimensions. Matrix3D should be 4x4 matrix.'); + } + this._internalArray = array; + } + + get flatArray():number[] { + return this._internalArray.slice(0); + } + + /** + * Check equality to identity matrix + * @returns {boolean} indicates whether this is the identity matrix + */ + public isIdentity():boolean { + return this.equals(Matrix3D.identity()); + } + + /** + * Computes dot product of two Matrix3D objects + * @param {Matrix3D} input matrix b to compute dot product on + * @returns {Matrix3D} dot product + */ + public dot(matrix:Matrix3D):Matrix3D { + var a = this._internalArray.slice(0); + var b = matrix._internalArray.slice(0); + var res:number[] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + for (var k = 0; k < 4; k++) { + res[i * 4 + j] += a[i * 4 + k] * b[k * 4 + j]; + } + } + } + return new Matrix3D(res); + } + + /** + * Check to see if two matrices are the same + * @param {Matrix3D} input matrix b to compare to + * @returns {boolean} indicator of whether two matrices are the same + */ + public equals(matrix:Matrix3D):boolean { + for (var i = 0; i < 16; i++) { + if (this._internalArray[i] !== matrix._internalArray[i]) { + return false; + } + } + return true; + } + + /** + * Writes the matrix out to CSS compatible format + * @returns {string} representation of matrix + */ + public toCss():string { + var matrix = this._internalArray.slice(0); + for (var i = 0; i < matrix.length;i++) { + if (Math.abs(matrix[i]) < 0.000001) { + matrix[i] = 0; + } + } + return 'matrix3d(' + matrix.join(',') + ')'; + } +} diff --git a/src/lib/timer.ts b/src/lib/timer.ts new file mode 100644 index 0000000..3342c72 --- /dev/null +++ b/src/lib/timer.ts @@ -0,0 +1,61 @@ +/** + * Generic timer-ish thing to keep track of accurate absolute time in millis. + */ +export class Timer { + private _ref:number; + private _time:number; + private _isStarted:boolean; + + constructor() { + this._ref = 0; + this._time = 0; + this._isStarted = false; + } + + set time(t:number) { + this._time = t; + if (this._isStarted) { + this._ref = Date.now() - this._time; + } + } + + get time():number { + if (this._isStarted) { + // Calculate a time + return Date.now() - this._ref; + } else { + // Read the time + return this._time; + } + } + + get running():boolean { + return this._isStarted; + } + + /** + * Start the timer. If the timer already has time ticked, it will continue + */ + public start():void { + if (!this._isStarted) { + this._ref = Date.now() - this._time; + this._isStarted = true; + } + } + + /** + * Reset the timer setting the ticked time to 0. + */ + public reset():void { + this._time = 0; + this._ref = Date.now(); + } + + /** + * Stop the timer. The time no longer updates but is preserved. + */ + public stop():void { + this._time = this.time; + this._isStarted = false; + } +} diff --git a/src/parsers/acfun.ts b/src/parsers/acfun.ts new file mode 100644 index 0000000..a1c3666 --- /dev/null +++ b/src/parsers/acfun.ts @@ -0,0 +1,225 @@ +import { CommentData, AnimationMode, UpdateablePosition, Waypoint } + from '../core/interfaces'; +import { Parser, ParserConfig, ParserTypes, Format } from './interfaces'; + +interface CommentSingle { + /** + * Configuration for the comment + */ + c?:string; + /** + * Message for the comment + */ + m?:string; +} + +interface MovementParams { + l?:number; + x?:number; + y?:number; +} + +interface CommentParams { + n:string; + a?:number; + p?:{x:number, y:number}; + c?:number; + b?:boolean; + l?:number; + z?:MovementParams[]; + w?:{f:string, l:any[]}, + r?:number; + k?:number; +} + +class AcFunJsonParser implements Parser { + private defaultDuration:number = 4000; + private config:ParserConfig; + + constructor(config:ParserConfig) { + this.config = config; + } + + private modeToType(mode:number):AnimationMode { + if (mode === 1 || mode === 2) { + return 'scroll-left'; + } else if (mode === 6) { + return 'scroll-right'; + } else if (mode === 4 || mode == 5) { + return 'fixed'; + } else if (mode === 7) { + return 'path'; + } + return 'fixed'; + } + + public parseOne(input:CommentSingle):CommentData { + // Temporary item to + if (input == null || !input.hasOwnProperty('c') || + typeof input.c === 'undefined') { + + throw new Error('Format Error: Expects "c" parameter!'); + } + let config = input['c'].split(','); + if (config.length >= 6) { + // Start up with a basic info object + var mode = parseInt(config[2]); + let data:CommentData = { + startTime: parseFloat(config[0]) * 1000, + text: '', + alpha: 1, + border: false, + color: parseInt(config[1]), + size: parseInt(config[3]), + outline: true, + font: null, + id: `u:${config[4]},t:${config[5]}`, + date: parseInt(config[5]), + position: { + x: 0, + y: 0, + axis: 'top-left', + mode: 'absolute' + }, + orientation: { + rx:0, + ry:0, + rz:0 + }, + scale: { + x:1, + y:1, + z:1 + }, + anchor: { + vertical: 0, + horizontal: 0 + }, + animation: { + duration: this.defaultDuration, + mode: this.modeToType(mode) + } + }; + if (mode !== 7) { + if (typeof input.m === 'string') { + data.text = input.m.replace(/(\/n|\\n|\n|\r\n|\\r)/g,"\n"); + data.text = data.text.replace(/\r/g,"\n"); + data.text = data.text.replace(/\s/g,"\u00a0"); + } else { + throw new Error('Format Error: Text field "m" does not exist.'); + } + return data; + } else { + // There is extra data in the comment + if (typeof input.m === 'undefined') { + throw new Error('Format Error: Complex field "m" does not exist.'); + } + try { + var params = JSON.parse(input.m) as CommentParams; + } catch (e) { + throw new Error('Advanced mode JSON parse failed: ' + input.m); + } + // Mode 7 in acfun uses relative positioning + data.position.mode = 'relative'; + data.text = params.n; + data.text = data.text.replace(/\ /g,"\u00a0"); + + if (typeof params.a === 'number') { + data.alpha = Math.max(Math.min(params.a, 1), 0); + } + + if (typeof params.p === 'object') { + data.position.x = params.p.x / 1000; + data.position.y = params.p.y / 1000; + } + + if (typeof params.c === 'number') { + if (params.c < 3) { + data.anchor.vertical = 0; + } else if (params.c >= 3 && params.c < 6) { + data.anchor.vertical = 0.5; + } else if (params.c >= 6 && params.c < 9) { + data.anchor.vertical = 1; + } else { + throw new Error('Data error: Anchor out of bounds'); + } + if (params.c % 3 === 0) { + data.anchor.horizontal = 0; + } else if (params.c % 3 === 1) { + data.anchor.horizontal = 0.5; + } else if (params.c % 3 === 2) { + data.anchor.horizontal = 1; + } + } + + data.outline = params.b !== false; + if (typeof params.l === 'number') { + data.animation.duration = params.l * 1000; + } + + if (typeof params.z !== 'undefined' && Array.isArray(params.z)) { + data.animation.mode = 'path'; + data.animation.path = []; + for (let m = 0; m < params.z.length; m++) { + let movement = params.z[m]; + let duration = (typeof movement.l === 'number') ? + (movement.l * 1000) : 500; + // Create the current waypoint + let point:Waypoint = { + duration: duration, + interpolation:'linear' + }; + + if (movement.x !== null || movement.y !== null) { + // We moved + let newPos:UpdateablePosition = {}; + if (movement.x !== null) { + newPos.x = movement.x; + } + if (movement.y !== null) { + newPos.y = movement.y; + } + point.position = newPos; + } + + data.animation.path.push(point); + } + } + + if (typeof params.r === 'number') { + data.orientation.rx = params.r; + } + if (typeof params.k === 'number') { + data.orientation.ry = params.k; + } + return data; + } + } else { + throw new Error('Underspecified: Insufficient config parameters, ' + + 'expecting at least 6.'); + } + } + public parseMany(input:CommentSingle[]):CommentData[] { + input.map((data) => { + try { + return this.parseOne(data); + } catch (e) { + if (!this.config.bestEffort) { + throw e; + } + return null; + } + }).filter((value) => value === null); + return []; + } +} + +export class AcFunFormat implements Format { + private _config:ParserConfig; + constructor(config:ParserConfig) { + this._config = config; + } + public getParser(_type:ParserTypes):Parser { + return new AcFunJsonParser(this._config); + } +} diff --git a/src/parsers/bilibili.ts b/src/parsers/bilibili.ts new file mode 100644 index 0000000..7a11513 --- /dev/null +++ b/src/parsers/bilibili.ts @@ -0,0 +1,24 @@ +import { CommentData } from '../core/interfaces'; +import { Parser, ParserConfig, ParserTypes, Format } from './interfaces'; + +class BilibiliXmlParser implements Parser { + constructor(_config:ParserConfig) { + + } + public parseOne(_elem:Element):CommentData { + throw new Error('Not Implemented'); + } + public parseMany(_doc:Document):CommentData[] { + return []; + } +} + +export class BilibiliFormat implements Format { + private _config:ParserConfig; + constructor(config:ParserConfig) { + this._config = config; + } + public getParser(_type:ParserTypes):Parser { + return new BilibiliXmlParser(this._config); + } +} diff --git a/src/parsers/index.ts b/src/parsers/index.ts new file mode 100644 index 0000000..7671cf1 --- /dev/null +++ b/src/parsers/index.ts @@ -0,0 +1,2 @@ +export * from './bilibili'; +export * from './acfun'; diff --git a/src/parsers/interfaces/format.d.ts b/src/parsers/interfaces/format.d.ts new file mode 100644 index 0000000..42ff34b --- /dev/null +++ b/src/parsers/interfaces/format.d.ts @@ -0,0 +1,3 @@ +export interface Format { + +} diff --git a/src/parsers/interfaces/index.d.ts b/src/parsers/interfaces/index.d.ts new file mode 100644 index 0000000..5c3288b --- /dev/null +++ b/src/parsers/interfaces/index.d.ts @@ -0,0 +1,2 @@ +export * from './format'; +export * from './parser'; diff --git a/src/parsers/interfaces/parser.d.ts b/src/parsers/interfaces/parser.d.ts new file mode 100644 index 0000000..861d503 --- /dev/null +++ b/src/parsers/interfaces/parser.d.ts @@ -0,0 +1,19 @@ +import { CommentData } from '../../core/interfaces'; + +/** + * Interface for a generic parser + * @param T + */ +export interface Parser { + parseOne(input:T):CommentData; + parseMany(input:U):CommentData[]; +} + +export interface ParserConfig { + strictSafety:boolean; + bestEffort:boolean; +} + +export enum ParserTypes { + 'JSON', 'XML', 'Text' +} diff --git a/src/parsers/native.ts b/src/parsers/native.ts new file mode 100644 index 0000000..b2e98ff --- /dev/null +++ b/src/parsers/native.ts @@ -0,0 +1,3 @@ +export class NativeParser { + +} diff --git a/src/renderer/dom-renderer.ts b/src/renderer/dom-renderer.ts new file mode 100644 index 0000000..6511f5d --- /dev/null +++ b/src/renderer/dom-renderer.ts @@ -0,0 +1,79 @@ +/** + * This is a renderer based on CSS + the DOM. The old timer-based system has + * been deprecated. + */ +import { UpdateableCommentData, CommentData } from '../core/interfaces'; + +import { Renderer, Measurement, AnimationTracker } from './interfaces'; +import { CSSAnimationTracker, RafAnimationTracker, LazyMeasurement, setProps } + from './lib'; + +type TrackerType = 'css' | 'raf'; + +class DOMItem { + private _props:CommentData; + public readonly dom:HTMLDivElement; + public readonly animation:AnimationTracker; + public measurement:LazyMeasurement; + + constructor(comment:CommentData, tracker:TrackerType = 'css', stage:HTMLDivElement) { + this._props = comment; + this.dom = document.createElement('div'); + this.measurement = new LazyMeasurement(stage, this.dom, + this._props.position.axis, + this._props.position.mode, + this._props.anchor); + this.animation = tracker === 'css' ? + new CSSAnimationTracker(this.dom, this.measurement, comment) : + new RafAnimationTracker(this.dom, this.measurement, comment); + } +} + +export class DOMRenderer implements Renderer { + private stage:HTMLDivElement; + private _trackerType:TrackerType; + + constructor(stage:HTMLDivElement, trackerType:TrackerType = 'css') { + this.stage = stage; + this._trackerType = trackerType; + + // Bind the resize event + window.addEventListener('resize', () => { + this.onResize(); + }) + } + + public create(props:CommentData) { + const item:DOMItem = new DOMItem(props, this._trackerType, this.stage); + return item; + } + + public update(item:DOMItem, props:UpdateableCommentData):void { + setProps(item.dom, props); + } + + public destroy(item:DOMItem):void { + if (this.stage.contains(item.dom)) { + this.stage.removeChild(item.dom); + } + } + + public measure(item:DOMItem):Measurement { + if (this.stage.contains(item.dom)) { + return item.measurement; + } else { + throw Error('Item not managed by this renderer!'); + } + } + + public track(item:DOMItem):AnimationTracker { + return item.animation; + } + + private onResize() { + this.stage.style.perspective = this.stage.offsetWidth * + Math.tan(40 * Math.PI/180) / 2 + "px"; + this.stage.style["webkitPerspective"] = this.stage.offsetWidth * + Math.tan(40 * Math.PI/180) / 2 + "px"; + } +} diff --git a/src/renderer/index.ts b/src/renderer/index.ts new file mode 100644 index 0000000..03bf647 --- /dev/null +++ b/src/renderer/index.ts @@ -0,0 +1,2 @@ +export * from './interfaces'; +export * from './dom-renderer'; diff --git a/src/renderer/interfaces/Measurement.d.ts b/src/renderer/interfaces/Measurement.d.ts new file mode 100644 index 0000000..cb2b2cd --- /dev/null +++ b/src/renderer/interfaces/Measurement.d.ts @@ -0,0 +1,15 @@ +export interface Offset { + readonly x:number; + readonly y:number; +} + +export interface Measurement { + readonly width:number; + readonly height:number; + readonly x:number; + readonly y:number; + readonly top:number; + readonly bottom:number; + readonly left:number; + readonly right:number; +} diff --git a/src/renderer/interfaces/Renderer.d.ts b/src/renderer/interfaces/Renderer.d.ts new file mode 100644 index 0000000..9cc2407 --- /dev/null +++ b/src/renderer/interfaces/Renderer.d.ts @@ -0,0 +1,13 @@ +/** + * Interfaces for defining a renderer + */ +import { Measurement } from './measurement'; +import { AnimationTracker } from './animation-tracker'; + +export interface Renderer { + create(props:V):T; + update(item:T, props:U):void; + destroy(item:T):void; + measure(item:T):Measurement; + track(item:T):AnimationTracker; +} diff --git a/src/renderer/interfaces/animation-tracker.d.ts b/src/renderer/interfaces/animation-tracker.d.ts new file mode 100644 index 0000000..da3159d --- /dev/null +++ b/src/renderer/interfaces/animation-tracker.d.ts @@ -0,0 +1,9 @@ +import { Measurement } from './measurement'; + +export interface AnimationTracker { + readonly duration:number; + readonly time:number; + stop():void; + start(time?:number):void; + measure(time?:number):Measurement; +} diff --git a/src/renderer/interfaces/index.d.ts b/src/renderer/interfaces/index.d.ts new file mode 100644 index 0000000..7e7c813 --- /dev/null +++ b/src/renderer/interfaces/index.d.ts @@ -0,0 +1,3 @@ +export * from './animation-tracker'; +export * from './measurement'; +export * from './renderer'; diff --git a/src/renderer/lib/css-animation-tracker.ts b/src/renderer/lib/css-animation-tracker.ts new file mode 100644 index 0000000..30db4a1 --- /dev/null +++ b/src/renderer/lib/css-animation-tracker.ts @@ -0,0 +1,56 @@ +import { Timer } from '../../lib/timer'; +import { CommentData } from '../../core/interfaces'; + +import { AnimationTracker, Measurement, Offset } from '../interfaces'; +import { LazyFutureMeasurement } from './lazy-dom-measurement'; + +export class CSSAnimationTracker implements AnimationTracker { + private _item:HTMLDivElement; + private _measurement:Measurement; + private _initial:CommentData; + private _timer:Timer; + + constructor(item:HTMLDivElement, + measurement:Measurement, + comment:CommentData) { + + this._item = item; + this._measurement = measurement; + this._initial = comment; + this._timer = new Timer(); + } + + get duration():number { + return this._initial.animation.duration; + } + + get time():number { + return this._timer.time; + } + + private getOffsetAt(time:number = 0):Offset { + let timeDiff = time - this._timer.time; + if (timeDiff === 0) { + return {'x': 0, 'y': 0}; + } + return {'x': 0, 'y': 0}; + } + + public stop():void { + this._timer.stop(); + } + + public start(time?:number):void { + if (typeof time !== 'undefined') { + this._timer.time = time; + } + this._timer.start(); + // Render the spec + this._item.style.transform = ''; + } + + public measure(time?:number):Measurement { + return new LazyFutureMeasurement(this._measurement, + this.getOffsetAt(time)); + } +} diff --git a/src/renderer/lib/index.ts b/src/renderer/lib/index.ts new file mode 100644 index 0000000..da17ca0 --- /dev/null +++ b/src/renderer/lib/index.ts @@ -0,0 +1,4 @@ +export * from './css-animation-tracker'; +export * from './raf-animation-tracker'; +export * from './lazy-dom-measurement'; +export { setProps } from './util'; diff --git a/src/renderer/lib/lazy-dom-measurement.ts b/src/renderer/lib/lazy-dom-measurement.ts new file mode 100644 index 0000000..03bb88e --- /dev/null +++ b/src/renderer/lib/lazy-dom-measurement.ts @@ -0,0 +1,138 @@ +import { Axis, Anchor, CoordinateMode } from '../../core/interfaces'; +import { Measurement, Offset } from '../interfaces'; + +export class LazyMeasurement implements Measurement { + private _stage:HTMLDivElement; + private _item:HTMLDivElement; + private _axis:Axis; + private _coord:CoordinateMode; + private _anchor:Anchor; + + constructor(stage:HTMLDivElement, + item:HTMLDivElement, axis:Axis, coord:CoordinateMode, anchor:Anchor) { + + this._stage = stage; + this._item = item; + this._axis = axis; + this._coord = coord; + this._anchor = anchor; + } + private _convertCoords(value:number, reference:'width'|'height') { + if (this._coord === 'absolute') { + return value; + } + if (reference === 'width') { + if (this._stage.offsetWidth === 0) { + return 0; + } + return value / this._stage.offsetWidth; + } else { + if (this._stage.offsetHeight === 0) { + return 0; + } + return value / this._stage.offsetHeight; + } + } + + get width():number { + return this._convertCoords(this._item.offsetWidth, 'width'); + } + get height():number { + return this._convertCoords(this._item.offsetHeight, 'height'); + } + get x():number { + if (this._axis === 'top-left' || this._axis === 'bottom-left') { + return this._convertCoords(this._item.offsetLeft, 'width'); + } else { + return this._convertCoords( + this._stage.offsetWidth - this._item.offsetLeft, 'width'); + } + } + get y():number { + if (this._axis === 'top-left' || this._axis === 'top-right') { + return this._convertCoords(this._item.offsetTop, 'height'); + } else { + return this._convertCoords( + this._stage.offsetHeight - this._item.offsetTop, 'height'); + } + } + get top():number { + let offset = this.height * this._anchor.vertical; + if (this._axis === 'top-left' || this._axis === 'top-right') { + return this.y - offset; + } else { + return this.y + offset; + } + } + get bottom():number { + if (this._axis === 'top-left' || this._axis === 'top-right') { + return this.top + this.height; + } else { + return this.top - this.height; + } + } + get left():number { + let offset = this.width * this._anchor.horizontal; + if (this._axis === 'top-left' || this._axis === 'bottom-left') { + return this.x - offset; + } else { + return this.x + offset; + } + } + get right():number { + if (this._axis === 'top-left' || this._axis === 'bottom-left') { + return this.left + this.width; + } else { + return this.left - this.width; + } + } +} + +export class LazyFutureMeasurement implements Measurement { + private _source:Measurement; + private _futurePosition:Offset; + private _axis:Axis|null = null; + constructor(sourceMeasurement:Measurement, + offset:Offset) { + + this._source = sourceMeasurement; + this._futurePosition = offset; + } + private _inferAxis():Axis { + if (this._axis === null) { + let vAxis = (this.top < this.bottom) ? 'top' : 'bottom'; + let hAxis = (this.left < this.right) ? 'left' : 'right'; + return `${vAxis}-${hAxis}` as Axis; + } else { + return this._axis; + } + } + get width():number { + return this._source.width; + } + get height():number { + return this._source.height; + } + get x():number { + return this._source.x + this._futurePosition.x; + } + get y():number { + return this._source.y + this._futurePosition.y; + } + get top():number { + this._axis = this._inferAxis(); + return 0; + } + get bottom():number { + this._axis = this._inferAxis(); + return 0; + } + get left():number { + this._axis = this._inferAxis(); + return 0; + } + get right():number { + this._axis = this._inferAxis(); + return 0; + } +} diff --git a/src/renderer/lib/raf-animation-tracker.ts b/src/renderer/lib/raf-animation-tracker.ts new file mode 100644 index 0000000..48de48d --- /dev/null +++ b/src/renderer/lib/raf-animation-tracker.ts @@ -0,0 +1,77 @@ +import { Timer } from '../../lib/timer'; +import { CommentData } from '../../core/interfaces'; + +import { AnimationTracker, Measurement, Offset } from '../interfaces'; +import { LazyFutureMeasurement } from './lazy-dom-measurement'; + +export class RafAnimationTracker implements AnimationTracker { + private _item:HTMLDivElement; + private _measurement:Measurement; + private _initial:CommentData; + private _timer:Timer; + + constructor(item:HTMLDivElement, + measurement:Measurement, + comment:CommentData) { + + this._item = item; + this._measurement = measurement; + this._initial = comment; + + this._timer = new Timer(); + } + + get duration():number { + return this._initial.animation.duration; + } + + get time():number { + return this._timer.time; + } + + private getOffsetAt(time:number = 0):Offset { + let timeDiff = time - this._timer.time; + if (timeDiff === 0) { + return {'x': 0, 'y': 0}; + } + return { + 'x': 0, + 'y': 0 + } + } + + public stop():void { + this._timer.stop(); + } + + public start(time?:number):void { + if (typeof time !== 'undefined') { + this._timer.time = time; + } + this._timer.start(); + // Tick on the next frame + window.requestAnimationFrame(this._tick.bind(this)); + } + + public measure(time:number = 0):Measurement { + return new LazyFutureMeasurement(this._measurement, + this.getOffsetAt(time)); + } + + private _tick() { + // Do rendering stuff here + if (this._initial.animation.mode === 'scroll-left') { + let x = this._item.offsetLeft; + this._item.style.left = `${x + 1}`; + } + + if (this._timer.time >= this.duration) { + this.stop(); + this._timer.time = this.duration; + } + if (this._timer.running) { + // Schedule the next tick + window.requestAnimationFrame(this._tick.bind(this)); + } + } +} diff --git a/src/renderer/lib/util.ts b/src/renderer/lib/util.ts new file mode 100644 index 0000000..0bef3fe --- /dev/null +++ b/src/renderer/lib/util.ts @@ -0,0 +1,74 @@ +import { Scale, Position, Orientation, UpdateableCommentData } + from '../../core/interfaces'; +import { toCssColor } from '../../lib/color'; + +export function setProps(dom:HTMLDivElement, props:UpdateableCommentData) { + if (typeof props.text !== 'undefined') { + dom.innerText = props.text; + } + if (typeof props.border !== 'undefined') { + dom.classList.toggle('border', props.border); + } + if (typeof props.outline !== 'undefined') { + dom.classList.toggle('shadow', props.outline); + } + if (typeof props.color !== 'undefined') { + dom.style.color = toCssColor(props.color); + } + if (typeof props.size !== 'undefined') { + dom.style.fontSize = `${props.size}px`; + } + if (typeof props.font !== 'undefined') { + dom.style.fontFamily = props.font; + } + if (typeof props.alpha !== 'undefined') { + let alpha = Math.min(Math.max(props.alpha, 0), 1) + dom.style.opacity = `${alpha}`; + } + if (typeof props.position !== 'undefined') { + dom.style.left = `${props.position.x}px`; + dom.style.top = `${props.position.y}px`; + } +} + +export function transform(offset?:Position, + scale?:Scale, orientation?:Orientation) { + + let transforms = []; + if (typeof offset !== 'undefined') { + if (typeof offset.z === 'number') { + transforms.push( + `translate3d(${offset.x}, ${offset.y}, ${offset.z})`); + } else { + transforms.push(`translate(${offset.x}, ${offset.y})`); + } + } + if (typeof scale !== 'undefined') { + if (typeof scale.z === 'number') { + transforms.push( + `scale3d(${scale.x}, ${scale.y}, ${scale.z})`); + } else { + transforms.push(`scale(${scale.x}, ${scale.y})`); + } + } + if (typeof scale !== 'undefined') { + if (typeof scale.z === 'number') { + transforms.push( + `scale3d(${scale.x}, ${scale.y}, ${scale.z})`); + } else { + transforms.push(`scale(${scale.x}, ${scale.y})`); + } + } + if (typeof orientation !== 'undefined') { + if (typeof orientation.rx === 'number') { + transforms.push(`rotateX(${orientation.rx})`) + } + if (typeof orientation.ry === 'number') { + transforms.push(`rotateY(${orientation.ry})`) + } + if (typeof orientation.rz === 'number') { + transforms.push(`rotateZ(${orientation.rz})`) + } + } + return transforms.join(' '); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b6d83d8 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "umd", + "moduleResolution": "node", + "allowJs": false, + "rootDir": "src/", + "outDir": "compiled_src/", + "strict": true, + "isolatedModules": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + ".git", + "node_modules", + "src/css/**/*", + "src/scripting/**/*" + ] +}