diff --git a/.gitignore b/.gitignore index 94a30937..ae99498d 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ .baseDir.ts .baseDir.js .baseDir.js.map + +# Ignore typescript tmp files +*.tmp.txt diff --git a/.npmrc b/.npmrc deleted file mode 100644 index c1ca392f..00000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock = false diff --git a/.travis.yml b/.travis.yml index 97b4a3fe..c7369da8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,10 @@ dist: trusty addons: chrome: stable node_js: - - "10.3.0" + - "12.2.0" before_install: - npm install npm -g before_script: - npm install -g grunt-cli script: - - grunt ci + - npm run-script ci diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 96f1e8e8..26dac396 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -220,10 +220,11 @@ module.exports = (grunt) -> grunt.registerTask 'compile:ts-kagerou', CMP_KAGEROU_NAME # Register our tasks - grunt.registerTask 'test', ['coffee', 'jasmine:coverage'] 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 'ci', ['build', 'coffee', 'jasmine:ci'] + grunt.registerTask 'test', ['coffee', 'jasmine:coverage'] - grunt.registerTask 'default', ['clean', 'build', 'build:scripting', 'watch'] + grunt.registerTask 'default', ['clean', 'build', 'build:scripting'] diff --git a/README.md b/README.md index 67d877b3..0d0a04d1 100644 --- a/README.md +++ b/README.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) @@ -56,5 +55,3 @@ We encourage any contributions to this project, please read Also, feel free to have a look at our sister project [ABPlayerHTML5](https://github.com/jabbany/ABPlayerHTML5) for a reference implementation of a video player with CommentCoreLibrary. - - diff --git a/demo/debugger.js b/demo/debugger.js index 56bc243b..7ca9bd7f 100644 --- a/demo/debugger.js +++ b/demo/debugger.js @@ -1,622 +1,647 @@ // Debugger for demo $ = function(a) { - return document.getElementById(a); + return document.getElementById(a); }; var tests = { - "test-1": "test/test.xml", - "test-2": "test/test2.xml", - "test-3": "test/rokubunnoichi.xml", - "test-4": "test/mikunoshoushitsu.xml", - "test-5": "test/unowen.xml", - "test-6": "test/comment.xml", - "test-7": "test/extended.xml", - "test-8": "test/boss.xml", - "test-9": "test/utsukushiki_mono.xml", - "test-s": "test/scripting/kanpai.xml", - "test-ac-1": { - "f": 'test/ACFun.json', - "p": "acfun" - }, - "test-ac-2": { - "f": 'test/ac940133.json', - "p": "acfun" - }, - "test-ts-1": { - "f": "test/invalid/no_closing.xml", - "p": "bilibili-text" - }, - "test-ts-2": { - "f": "test/invalid/syntax_error.xml", - "p": "bilibili-text" - }, - "test-ts-3": { - "f": "test/invalid/xss.xml", - "p": "bilibili-text" - } + "test-1": "test/test.xml", + "test-2": "test/test2.xml", + "test-3": "test/rokubunnoichi.xml", + "test-4": "test/mikunoshoushitsu.xml", + "test-5": "test/unowen.xml", + "test-6": "test/comment.xml", + "test-7": "test/extended.xml", + "test-8": "test/boss.xml", + "test-9": "test/utsukushiki_mono.xml", + "test-s": "test/scripting/kanpai.xml", + "test-ac-1": { + "f": 'test/ACFun.json', + "p": "acfun" + }, + "test-ac-2": { + "f": 'test/ac940133.json', + "p": "acfun" + }, + "test-ts-1": { + "f": "test/invalid/no_closing.xml", + "p": "bilibili-text" + }, + "test-ts-2": { + "f": "test/invalid/syntax_error.xml", + "p": "bilibili-text" + }, + "test-ts-3": { + "f": "test/invalid/xss.xml", + "p": "bilibili-text" + } }; var debugs = { - "preset-1-run": "cm.filter.addModifier(function(cmt){if(cmt.pool === 0) return null; return cmt;})", - "preset-2-run": "cm.filter.setRuntimeFilter(function(cmt){if(cmt.hasSet) return cmt; cmt.hasSet = true; cmt.onclick = function(){if(!this.hold){this.hold = true;this.style.border=\"1px solid #ff0\";this.style.zIndex =\"9999\"; this.style.backgroundColor=\"#000\";}else{this.hold = false;this.style.border=\"0px\";this.style.backgroundColor=\"\";}}; return cmt;});", - "preset-3-run": "cm.filter.addModifier(function(cmt){cmt.border = true; return cmt;})", + "preset-1-run": "cm.filter.addModifier(function(cmt){if(cmt.pool === 0) return null; return cmt;})", + "preset-2-run": "cm.filter.setRuntimeFilter(function(cmt){if(cmt.hasSet) return cmt; cmt.hasSet = true; cmt.onclick = function(){if(!this.hold){this.hold = true;this.style.border=\"1px solid #ff0\";this.style.zIndex =\"9999\"; this.style.backgroundColor=\"#000\";}else{this.hold = false;this.style.border=\"0px\";this.style.backgroundColor=\"\";}}; return cmt;});", + "preset-3-run": "cm.filter.addModifier(function(cmt){cmt.border = true; return cmt;})", }; var state = { - "format": "hrf", - "cw": "p-main", - "mode": "timer", + "format": "hrf", + "cw": "p-main", + "mode": "timer", }; var windowbinds = { - "p-main": { - "id": "w-main", - "opacityOnly": true - }, - "p-code": { - "id": "w-code" - }, - "p-help": { - "id": "w-help" - } + "p-main": { + "id": "w-main", + "opacityOnly": true + }, + "p-code": { + "id": "w-code" + }, + "p-help": { + "id": "w-help" + } }; var CCLDBG = new function() { - var x = 0; - var profiles = []; - var pmax = 0; - var smax = 0; - var sample = 0; - var avg = 0; - this.reset = function() { - profiles = []; - x = 0; - pmax = 0; - avg = 0; - sample = 0; - }; - this.profiler = function() { - var t = (new Date()).getTime(); - var tdiff = t - x; - if (tdiff < 10) { - return; - } - sample++; - if (sample % 100 == 0) { - sample = 0; - profiles.push(-1); - } - if (tdiff < 5000) { - avg += tdiff / 300; - profiles.push(tdiff); - if (tdiff> pmax) { - pmax = tdiff; - } - if (tdiff> smax) { - smax = tdiff; - } - if (profiles.length> 300) { - var del = profiles.shift(); - avg -= del / 300; - } + var x = 0; + var profiles = []; + var pmax = 0; + var smax = 0; + var sample = 0; + var avg = 0; + this.reset = function() { + profiles = []; + x = 0; + pmax = 0; + avg = 0; + sample = 0; + }; + this.profiler = function() { + var t = (new Date()).getTime(); + var tdiff = t - x; + if (tdiff < 10) { + return; + } + sample++; + if (sample % 100 == 0) { + sample = 0; + profiles.push(-1); + } + if (tdiff < 5000) { + avg += tdiff / 300; + profiles.push(tdiff); + if (tdiff> pmax) { + pmax = tdiff; + } + if (tdiff> smax) { + smax = tdiff; + } + if (profiles.length> 300) { + var del = profiles.shift(); + avg -= del / 300; + } + } + x = t; + }; + this.render = function() { + if (smax> avg * 4) { + smax = Math.round(avg * 4) + } + var ctx = $("profiler").getContext("2d"); + if (ctx != null) { + ctx.fillStyle = "#00FFFF"; + ctx.clearRect(0, 0, 300, 40); + for (var i = 0; i < profiles.length; i++) { + if (profiles[i] < 0) { + ctx.fillStyle = "#FF00FF"; + ctx.fillRect(i, 0, 1, 40); + ctx.fillStyle = "#00FFFF"; + continue; } - x = t; - }; - this.render = function() { - if (smax> avg * 4) { - smax = Math.round(avg * 4) + var barh = Math.round((profiles[i] / (smax + 5)) * 40); + if (barh <= 40) { + ctx.fillRect(i, 40 - barh, 1, barh); + } else { + ctx.fillStyle = "#FFFF00"; + ctx.fillRect(i, 40 - barh, 1, barh); + ctx.fillStyle = "#00FFFF"; } - var ctx = $("profiler").getContext("2d"); - if (ctx != null) { - ctx.fillStyle = "#00FFFF"; - ctx.clearRect(0, 0, 300, 40); - for (var i = 0; i < profiles.length; i++) { - if (profiles[i] < 0) { - ctx.fillStyle = "#FF00FF"; - ctx.fillRect(i, 0, 1, 40); - ctx.fillStyle = "#00FFFF"; - continue; - } - var barh = Math.round((profiles[i] / (smax + 5)) * 40); - if (barh <= 40) { - ctx.fillRect(i, 40 - barh, 1, barh); - } else { - ctx.fillStyle = "#FFFF00"; - ctx.fillRect(i, 40 - barh, 1, barh); - ctx.fillStyle = "#00FFFF"; - } - } - ctx.fillStyle = "#FF0000"; - ctx.fillRect(0, 40 - Math.round(avg / (smax + 5) * 40), 300, 1); - ctx.fillStyle = "#00FFFF"; - }; - $("pf-stats").innerHTML = "AVG:" + Math.round(avg) + "
" + "MAX:" + pmax + "
FPS:" + (avg> 0 ? Math.round(1000 / avg) : 0); - }; - this.getProfiles = function() { - return profiles; - }; - var self = this; - var t = -1;; - this.on = function() { - if (t> 0) - return; - t = setInterval(function() { - self.render(); - }, 150); - $("profiler-start").style.color = "#0ff"; - }; - this.off = function() { - if (t < 0) - return; - clearInterval(t); - t = -1; - $("profiler-start").style.color = ""; - $("pf-stats").innerHTML = "PF:OFF"; - }; - this.isOn = function() { - return t>= 0; + } + ctx.fillStyle = "#FF0000"; + ctx.fillRect(0, 40 - Math.round(avg / (smax + 5) * 40), 300, 1); + ctx.fillStyle = "#00FFFF"; }; + $("pf-stats").innerHTML = "AVG:" + Math.round(avg) + "
" + "MAX:" + pmax + "
FPS:" + (avg> 0 ? Math.round(1000 / avg) : 0); + }; + this.getProfiles = function() { + return profiles; + }; + var self = this; + var t = -1;; + this.on = function() { + if (t> 0) + return; + t = setInterval(function() { + self.render(); + }, 150); + $("profiler-start").style.color = "#0ff"; + }; + this.off = function() { + if (t < 0) + return; + clearInterval(t); + t = -1; + $("profiler-start").style.color = ""; + $("pf-stats").innerHTML = "PF:OFF"; + }; + this.isOn = function() { + return t>= 0; + }; }; function bind() { - window.cm = new CommentManager($('commentCanvas')); - cm.init(); - - var tmr = -1; - var start = 0; - var playhead = 0; - - $("control-stop").addEventListener("click", function(e) { - if (e && e.preventDefault) - e.preventDefault(); - stop(); - }); + window.cm = new CommentManager($('commentCanvas')); + cm.init(); - $("control-resume").addEventListener("click", function(e) { - if (e && e.preventDefault) - e.preventDefault(); - resume(); - }); + var tmr = -1; + var start = 0; + var playhead = 0; - $("control-reset").addEventListener("click", function(e) { - if (e && e.preventDefault) - e.preventDefault(); - playhead = 0; - start = (new Date()).getTime(); - cm.clear(); - }); + $("control-stop").addEventListener("click", function(e) { + if (e && e.preventDefault) + e.preventDefault(); + stop(); + }); - $("w-main").addEventListener("keydown", function(k) { - if (k) { - if (k.keyCode === 70) { - state.format = (state.format === "hrf" ? "std" : "hrf"); - } else if (k.keyCode === 32) { - if (tmr < 0) { - resume(); - } else { - stop(); - } - } else if (k.keyCode === 66) { - $("player").style.backgroundColor = "#000"; //b - $("c-region").style.color = "#fff"; - } else if (k.keyCode === 87) { - $("player").style.backgroundColor = "#fff"; //w - $("c-region").style.color = "#000"; - } else if (k.keyCode === 82) { - var x = prompt("Resize player window (WxH or 'old','new')"); - if (x) { - if (x === "new") - x = "672x438"; - if (x === "old") - x = "512x384"; - var wh = x.split("x"); - var w = parseInt(wh[0]); - var h = parseInt(wh[1]); - if (w> 0 && h> 0) { - $("player").style.height = h + "px"; - $("player-unit").style.width = w + "px"; - if (cm) - cm.setBounds(); - } - } - } else if (k.keyCode === 80) { //p - if (CCLDBG.isOn()) { - CCLDBG.off(); - cm.filter.setRuntimeFilter(null); - } else { - CCLDBG.on(); - cm.filter.setRuntimeFilter(function(cmt) { - CCLDBG.profiler(); - return cmt; - }); - } - } - } - }); + $("control-resume").addEventListener("click", function(e) { + if (e && e.preventDefault) + e.preventDefault(); + resume(); + }); - window.isDebugRunning = function() { - return tmr>= 0 || !$("abpVideo").paused; - }; + $("control-reset").addEventListener("click", function(e) { + if (e && e.preventDefault) + e.preventDefault(); + playhead = 0; + start = (new Date()).getTime(); + cm.clear(); + }); - window.displayTime = function(playhead) { - if (state.format === "hrf") { - var sec = Math.floor(playhead / 1000); - var millis = playhead % 1000; - var millisText = (millis> 99 ? millis : ("0" + (millis> 9 ? millis : "0" + millis))); - $("control-status").textContent = Math.floor(sec / 60) + ":" + - ((sec % 60)> 9 ? (sec % 60) : "0" + (sec % 60)) + ":" + millisText; + $("w-main").addEventListener("keydown", function(k) { + if (k) { + if (k.keyCode === 70) { + state.format = (state.format === "hrf" ? "std" : "hrf"); + } else if (k.keyCode === 32) { + if (tmr < 0) { + resume(); } else { - $("control-status").textContent = playhead; + stop(); } - }; - - $("control-status").addEventListener("dblclick", function(e) { - var x = prompt("Please input time (" + (state.format === "hrf" ? "xx:xx:xxx" : "xxx") + "):"); - if (!x || x === "") - return; - if (state.format === "hrf") { - var y = x.split(":"); - var m = parseInt(y[0]); - var s = parseInt(y[1]); - var ml = parseInt(y[2]); - playhead = m * 60000 + s * 1000 + ml; - } else { - try { - playhead = parseInt(x); - } catch (e) {} + } else if (k.keyCode === 66) { + $("player").style.backgroundColor = "#000"; //b + $("c-region").style.color = "#fff"; + } else if (k.keyCode === 87) { + $("player").style.backgroundColor = "#fff"; //w + $("c-region").style.color = "#000"; + } else if (k.keyCode === 82) { + var x = prompt("Resize player window (WxH or 'old','new')"); + if (x) { + if (x === "new") + x = "672x438"; + if (x === "old") + x = "512x384"; + var wh = x.split("x"); + var w = parseInt(wh[0]); + var h = parseInt(wh[1]); + if (w> 0 && h> 0) { + $("player").style.height = h + "px"; + $("player-unit").style.width = w + "px"; + if (cm) + cm.setBounds(); + } } - }); - - function stop() { - if (state.mode === "timer") { - cm.stop(); - $("control-status").className = "status"; - clearInterval(tmr); - tmr = -1; + } else if (k.keyCode === 80) { //p + if (CCLDBG.isOn()) { + CCLDBG.off(); + cm.filter.setRuntimeFilter(null); } else { - $("abpVideo").pause(); + CCLDBG.on(); + cm.filter.setRuntimeFilter(function(cmt) { + CCLDBG.profiler(); + return cmt; + }); } + } } + }); - function resume() { - if (state.mode !== "timer") { - $("abpVideo").play(); - return; - } - if (tmr !== -1) - return; - $("control-status").className = "status active"; - cm.start(); - start = new Date().getTime() - playhead; - tmr = setInterval(function() { - playhead = new Date().getTime() - start; - displayTime(playhead); - cm.time(playhead); - }, 42); - } + window.isDebugRunning = function() { + return tmr>= 0 || !$("abpVideo").paused; + }; - /** Load **/ - window.loadDM = function(dmf, provider) { - if (window._provider && window._provider instanceof CommentProvider) { - window._provider.destroy(); - } - window._provider = new CommentProvider(); - cm.clear(); - dmf = "../" + dmf; - window._provider.addTarget(cm); - start = 0; + window.displayTime = function(playhead) { + requestAnimationFrame(function () { + if (state.format === "hrf") { + var sec = Math.floor(playhead / 1000); + var millis = playhead % 1000; + var millisText = (millis> 99 ? millis : ("0" + (millis> 9 ? millis : "0" + millis))); + $("control-status").textContent = Math.floor(sec / 60) + ":" + + ((sec % 60)> 9 ? (sec % 60) : "0" + (sec % 60)) + ":" + millisText; + } else { + $("control-status").textContent = playhead; + } + }) + }; - try { - clearTimeout(tmr); - } catch (e) {} - if (trace) { - trace("Loading " + dmf + " : " + provider); - } - switch (provider) { - case "acfun": - window._provider.addStaticSource( - CommentProvider.JSONProvider('GET', dmf), - CommentProvider.SOURCE_JSON).addParser( - new AcfunFormat.JSONParser(), - CommentProvider.SOURCE_JSON); - break; - case "cdf": - window._provider.addStaticSource( - CommentProvider.JSONProvider('GET', dmf), - CommentProvider.SOURCE_JSON).addParser( - new CommonDanmakuFormat.JSONParser(), - CommentProvider.SOURCE_JSON); - break; - case "bilibili-text": - window._provider.addStaticSource( - CommentProvider.TextProvider('GET', dmf), - CommentProvider.SOURCE_TEXT).addParser( - new BilibiliFormat.TextParser(), - CommentProvider.SOURCE_TEXT); - break; - case "bilibili": - default: - window._provider.addStaticSource( - CommentProvider.XMLProvider('GET', dmf), - CommentProvider.SOURCE_XML).addParser( - new BilibiliFormat.XMLParser(), - CommentProvider.SOURCE_XML); - break; - } - window._provider.start().then(function() { - cm.start(); - $("control-status").className = "status active"; - if (state.mode !== "timer") { - $("abpVideo").play(); - return; - } - start = new Date().getTime(); - tmr = setInterval(function() { - playhead = new Date().getTime() - start; - cm.time(playhead); - displayTime(playhead); - }, 42); - }).catch(function(e) { - alert(e); - }); - }; + $("control-status").addEventListener("dblclick", function(e) { + var x = prompt("Please input time (" + (state.format === "hrf" ? "xx:xx:xxx" : "xxx") + "):"); + if (!x || x === "") + return; + if (state.format === "hrf") { + var y = x.split(":"); + var m = parseInt(y[0]); + var s = parseInt(y[1]); + var ml = parseInt(y[2]); + playhead = m * 60000 + s * 1000 + ml; + } else { + try { + playhead = parseInt(x); + } catch (e) {} + } + }); - var isWindowedFullscreen = false; + function stop() { + if (state.mode === "timer") { + cm.stop(); + $("control-status").className = "status"; + clearInterval(tmr); + tmr = -1; + } else { + $("abpVideo").pause(); + } + } - function launchFullScreen(element) { - cm.setBounds(); - if (element.requestFullscreen) { - element.requestFullscreen(); - } else if (element.mozRequestFullscreen) { - element.mozRequestFullscreen(); - } else if (element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } + function resume() { + if (state.mode !== "timer") { + $("abpVideo").play(); + return; } + if (tmr !== -1) + return; + $("control-status").className = "status active"; + cm.start(); + start = new Date().getTime() - playhead; + tmr = setInterval(function() { + playhead = new Date().getTime() - start; + displayTime(playhead); + cm.time(playhead); + }, 42); + } - function launchWindowFull(element, e2) { - if (!isWindowedFullscreen) { - element.style.position = "fixed"; - element.style.top = "0"; - element.style.bottom = "0"; - element.style.left = "0"; - element.style.right = "0"; - element.style.width = "auto"; - element.style.height = "auto"; - e2.style.height = "100%"; - } else { - element.style.position = ""; - element.style.top = ""; - element.style.bottom = ""; - element.style.left = ""; - element.style.right = ""; - } - isWindowedFullscreen = !isWindowedFullscreen; + /** Load **/ + window.loadDM = function(dmf, provider) { + if (window._provider && window._provider instanceof CommentProvider) { + window._provider.destroy(); } - // Add Fullscreen Handlers - var fs = function() { - cm.setBounds(); - }; - document.addEventListener("fullscreenchange", fs); - document.addEventListener("webkitfullscreenchange", fs); - document.addEventListener("mozfullscreenchange", fs); + window._provider = new CommentProvider(); + cm.clear(); + dmf = "../" + dmf; + window._provider.addTarget(cm); + start = 0; - $("fs-all").addEventListener("click", function(e) { - if (e && e.preventDefault) - e.preventDefault(); - launchFullScreen($("player-unit")); - }); - $("fs-win").addEventListener("click", function(e) { - if (e && e.preventDefault) - e.preventDefault(); - launchWindowFull($("player-unit"), $("player")); + try { + clearTimeout(tmr); + } catch (e) {} + if (trace) { + trace("Loading " + dmf + " : " + provider); + } + switch (provider) { + case "acfun": + window._provider.addStaticSource( + CommentProvider.JSONProvider('GET', dmf), + CommentProvider.SOURCE_JSON).addParser( + new AcfunFormat.JSONParser(), + CommentProvider.SOURCE_JSON); + break; + case "cdf": + window._provider.addStaticSource( + CommentProvider.JSONProvider('GET', dmf), + CommentProvider.SOURCE_JSON).addParser( + new CommonDanmakuFormat.JSONParser(), + CommentProvider.SOURCE_JSON); + break; + case "bilibili-text": + window._provider.addStaticSource( + CommentProvider.TextProvider('GET', dmf), + CommentProvider.SOURCE_TEXT).addParser( + new BilibiliFormat.TextParser(), + CommentProvider.SOURCE_TEXT); + break; + case "bilibili": + default: + window._provider.addStaticSource( + CommentProvider.XMLProvider('GET', dmf), + CommentProvider.SOURCE_XML).addParser( + new BilibiliFormat.XMLParser(), + CommentProvider.SOURCE_XML); + break; + } + window._provider.start().then(function() { + cm.start(); + $("control-status").className = "status active"; + if (state.mode !== "timer") { + $("abpVideo").play(); + return; + } + start = new Date().getTime(); + tmr = setInterval(function() { + playhead = new Date().getTime() - start; + cm.time(playhead); + displayTime(playhead); + }, 42); + }).catch(function(e) { + alert(e); }); -} + }; -function bindWindow() { - for (var w in windowbinds) { - $(w).addEventListener("click", function(e) { - if (state.cw === this.id) - return; - if (window.isDebugRunning()) { + var isWindowedFullscreen = false; - } - state.cw = this.id; - for (var win in windowbinds) { - $(win).className = "button"; - if ($(windowbinds[win].id) && !windowbinds[win].opacityOnly) { - $(windowbinds[win].id).style.display = "none"; - } else if ($(windowbinds[win].id) && windowbinds[win].opacityOnly) { - $(windowbinds[win].id).style.opacity = "0"; - } - } - this.className = "button active"; - try { - $(windowbinds[this.id].id).style.display = ""; - $(windowbinds[this.id].id).style.opacity = "1"; - } catch (e) { - console.log(e); - } - }); + function launchFullScreen(element) { + cm.setBounds(); + if (element.requestFullscreen) { + element.requestFullscreen(); + } else if (element.mozRequestFullscreen) { + element.mozRequestFullscreen(); + } else if (element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); } -}; + } -function bindTests() { - for (var test in tests) { - try { - $(test).addEventListener("click", (function() { - var url = tests[test]; - return function() { - if (typeof url === "string") { - loadDM(url); - } else { - loadDM(url.f, url.p); - } - } - })()); - } catch (e) {} + function launchWindowFull(element, e2) { + if (!isWindowedFullscreen) { + element.style.position = "fixed"; + element.style.top = "0"; + element.style.bottom = "0"; + element.style.left = "0"; + element.style.right = "0"; + element.style.width = "auto"; + element.style.height = "auto"; + e2.style.height = "100%"; + } else { + element.style.position = ""; + element.style.top = ""; + element.style.bottom = ""; + element.style.left = ""; + element.style.right = ""; } - $("profiler-start").addEventListener("click", function(e) { - CCLDBG.reset(); - CCLDBG.on(); - cm.filter.setRuntimeFilter(function(cmt) { - CCLDBG.profiler(); - return cmt; - }); - e.preventDefault(); - }); - $("video-demo").addEventListener("click", function(e) { - var x = prompt("Please give video URL"); - if (!x) { - return; - } - if (x == "") { - $("abpVideo").innerHTML = '' + - ''; - } else { - $("abpVideo").innerHTML = ''; + isWindowedFullscreen = !isWindowedFullscreen; + } + // Add Fullscreen Handlers + var fs = function() { + cm.setBounds(); + }; + document.addEventListener("fullscreenchange", fs); + document.addEventListener("webkitfullscreenchange", fs); + document.addEventListener("mozfullscreenchange", fs); + + $("fs-all").addEventListener("click", function(e) { + if (e && e.preventDefault) + e.preventDefault(); + launchFullScreen($("player-unit")); + }); + $("fs-win").addEventListener("click", function(e) { + if (e && e.preventDefault) + e.preventDefault(); + launchWindowFull($("player-unit"), $("player")); + }); +} + +function bindWindow() { + for (var w in windowbinds) { + $(w).addEventListener("click", function(e) { + if (state.cw === this.id) + return; + if (window.isDebugRunning()) { + + } + state.cw = this.id; + for (var win in windowbinds) { + $(win).className = "button"; + if ($(windowbinds[win].id) && !windowbinds[win].opacityOnly) { + $(windowbinds[win].id).style.display = "none"; + } else if ($(windowbinds[win].id) && windowbinds[win].opacityOnly) { + $(windowbinds[win].id).style.opacity = "0"; } - bindVideo($("abpVideo"), cm); - state.mode = 'video'; - loadDM(tests['test-6']); + } + this.className = "button active"; + try { + $(windowbinds[this.id].id).style.display = ""; + $(windowbinds[this.id].id).style.opacity = "1"; + } catch (e) { + console.log(e); + } }); - $("load-cmt-file").addEventListener("click", function(e) { - var x = prompt("Please give comment file URL"); - if (!x) { - return; + } +}; + +function bindTests() { + for (var test in tests) { + try { + $(test).addEventListener("click", (function() { + var url = tests[test]; + return function() { + if (typeof url === "string") { + loadDM(url); + } else { + loadDM(url.f, url.p); + } } - loadDM(x); + })()); + } catch (e) {} + } + $("profiler-start").addEventListener("click", function(e) { + CCLDBG.reset(); + CCLDBG.on(); + cm.filter.setRuntimeFilter(function(cmt) { + CCLDBG.profiler(); + return cmt; }); + e.preventDefault(); + }); + $("video-demo").addEventListener("click", function(e) { + var x = prompt("Please give video URL"); + if (!x) { + return; + } + if (x == "") { + $("abpVideo").innerHTML = '' + + ''; + } else { + $("abpVideo").innerHTML = ''; + } + bindVideo($("abpVideo"), cm); + state.mode = 'video'; + loadDM(tests['test-6']); + }); + $("load-cmt-file").addEventListener("click", function(e) { + var x = prompt("Please give comment file URL"); + if (!x) { + return; + } + loadDM(x); + }); } function bindResize() { - var sX = 0, - sY = 0; - var iX = 0, - iY = 0; - var isDownTB = false; - var isDownLR = false; - document.addEventListener("dblclick", function() { - isDownTB = false; - isDownLR = false; - }); - $("control-resize-lr").addEventListener("mousedown", function(e) { - sX = e.clientX; - iX = $("player-unit").offsetWidth; - iY = $("player").offsetHeight; - $("commentCanvas").style.border = "1px solid #0ff"; - isDownLR = true; - $("c-region").style.display = ""; - }); - $("control-resize-tb").addEventListener("mousedown", function(e) { - sY = e.clientY; - iX = $("player-unit").offsetWidth; - iY = $("player").offsetHeight; - $("commentCanvas").style.border = "1px solid #0ff"; - isDownTB = true; - $("c-region").style.display = ""; - }); - document.addEventListener("mousemove", function(e) { - if (isDownTB) { - var yDelta = e.clientY - sY; - $("player").style.height = (iY + yDelta) + "px"; - $("c-region").innerHTML = iX + "x" + (iY + yDelta); - } else if (isDownLR) { - var xDelta = e.clientX - sX; - $("player-unit").style.width = (iX + xDelta) + "px"; - $("c-region").innerHTML = (iX + xDelta) + "x" + iY; - } - }); - document.addEventListener("mouseup", function(e) { - if ((isDownTB || isDownLR)) { - if (trace) { - trace("Resize to " + $("commentCanvas").offsetWidth + "x" + $("commentCanvas").offsetHeight); - } - cm.setBounds(); - $("commentCanvas").style.border = "0px"; - $("c-region").style.display = "none"; - cm.setBounds(); - } - isDownTB = false; - isDownLR = false; - }); + var sX = 0, + sY = 0; + var iX = 0, + iY = 0; + var isDownTB = false; + var isDownLR = false; + document.addEventListener("dblclick", function() { + isDownTB = false; + isDownLR = false; + }); + $("control-resize-lr").addEventListener("mousedown", function(e) { + sX = e.clientX; + iX = $("player-unit").offsetWidth; + iY = $("player").offsetHeight; + $("commentCanvas").style.border = "1px solid #0ff"; + isDownLR = true; + $("c-region").style.display = ""; + }); + $("control-resize-tb").addEventListener("mousedown", function(e) { + sY = e.clientY; + iX = $("player-unit").offsetWidth; + iY = $("player").offsetHeight; + $("commentCanvas").style.border = "1px solid #0ff"; + isDownTB = true; + $("c-region").style.display = ""; + }); + document.addEventListener("mousemove", function(e) { + if (isDownTB) { + var yDelta = e.clientY - sY; + $("player").style.height = (iY + yDelta) + "px"; + $("c-region").innerHTML = iX + "x" + (iY + yDelta); + } else if (isDownLR) { + var xDelta = e.clientX - sX; + $("player-unit").style.width = (iX + xDelta) + "px"; + $("c-region").innerHTML = (iX + xDelta) + "x" + iY; + } + }); + document.addEventListener("mouseup", function(e) { + if ((isDownTB || isDownLR)) { + if (trace) { + trace("Resize to " + $("commentCanvas").offsetWidth + "x" + $("commentCanvas").offsetHeight); + } + cm.setBounds(); + $("commentCanvas").style.border = "0px"; + $("c-region").style.display = "none"; + cm.setBounds(); + } + isDownTB = false; + isDownLR = false; + }); }; function bindDebugger() { - var output = $("debugger-output"); + var output = $("debugger-output"); - function trace(msg) { - if (typeof msg === "object") { - var obj = {}; - for (var field in msg) { - if (typeof msg[field] !== "function") { - obj[field] = msg[field].toString(); - } else { - obj[field] = "[function Function]"; - } - } - msg = JSON.stringify(obj, undefined, 2); - } else if (msg === undefined) { - msg = "[undefined]"; - } else if (typeof msg !== "string") { - msg = msg.toString(); - } - var lines = msg.replace(/&/g, "&").replace(//g, ">").replace(/ /g, " ").split("\n"); - output.innerHTML = lines.join("
") + "
" + output.innerHTML; - }; - window.trace = trace; - $("debugger-input-area").addEventListener("keydown", function(e) { - if (e.keyCode == 9) e.preventDefault() - }); - $("debugger-input-area").addEventListener("keyup", function(e) { - if (e.keyCode == 9) { - e.preventDefault(); - this.innerHTML += "\t"; - } - }); - $("debugger-run").addEventListener("click", function() { - try { - var cm = window.cm; - eval($("debugger-input-area").innerText); - } catch (e) { - trace(e); - console.log(e); + function trace(msg) { + if (typeof msg === "object") { + var obj = {}; + for (var field in msg) { + if (typeof msg[field] !== "function") { + obj[field] = msg[field].toString(); + } else { + obj[field] = "[function Function]"; } - }); - for (var x in debugs) { - $(x).addEventListener('click', function() { - $("debugger-input-area").innerHTML = debugs[this.id]; - }); + } + msg = JSON.stringify(obj, undefined, 2); + } else if (msg === undefined) { + msg = "[undefined]"; + } else if (typeof msg !== "string") { + msg = msg.toString(); } + var lines = msg.replace(/&/g, "&").replace(//g, ">").replace(/ /g, " ").split("\n"); + output.innerHTML = lines.join("
") + "
" + output.innerHTML; + }; + window.trace = trace; + $("debugger-input-area").addEventListener("keydown", function(e) { + if (e.keyCode == 9) e.preventDefault() + }); + $("debugger-input-area").addEventListener("keyup", function(e) { + if (e.keyCode == 9) { + e.preventDefault(); + this.innerHTML += "\t"; + } + }); + $("debugger-run").addEventListener("click", function() { + try { + var cm = window.cm; + eval($("debugger-input-area").innerText); + } catch (e) { + trace(e); + console.log(e); + } + }); + for (var x in debugs) { + $(x).addEventListener('click', function() { + $("debugger-input-area").innerHTML = debugs[this.id]; + }); + } }; function bindVideo(video, cm) { - video.addEventListener("timeupdate", function() { - if (cm.display === false) return; - if (video.hasStalled) { - cm.start(); - video.hasStalled = false; - } - cm.time(Math.floor(video.currentTime * 1000)); - displayTime(Math.floor(video.currentTime * 1000)); - }); - video.addEventListener("play", function() { - cm.start(); - }); - video.addEventListener("pause", function() { - cm.stop(); - }); - video.addEventListener("waiting", function() { - cm.stop(); - }); - video.addEventListener("playing", function() { - cm.start(); - }); + video.addEventListener("timeupdate", function() { + if (cm.display === false) return; + if (video.hasStalled) { + cm.start(); + video.hasStalled = false; + } + cm.time(Math.floor(video.currentTime * 1000)); + displayTime(Math.floor(video.currentTime * 1000)); + }); + video.addEventListener("play", function() { + cm.start(); + }); + video.addEventListener("pause", function() { + cm.stop(); + }); + video.addEventListener("waiting", function() { + cm.stop(); + }); + video.addEventListener("playing", function() { + cm.start(); + }); }; +function bindLiveTests(){ + $('test-live-1').addEventListener('click', function(){ + window.cm.start(); + var comment = { + 'text': "common danmaku", + 'mode': 1, + 'color': 0xffffff, + }; + window.cm.send(comment); + }) + $('test-live-2').addEventListener('click', function(){ + window.cm.start(); + var comment = { + 'text': "blue background danmaku", + 'mode': 1, + 'color': 0xffffff, + 'className': 'blue-background' + }; + window.cm.send(comment); + }) +} + window.addEventListener("load", function() { - bind(); - bindWindow(); - bindTests(); - bindResize(); - bindDebugger(); + bind(); + bindWindow(); + bindTests(); + bindLiveTests(); + bindResize(); + bindDebugger(); }); diff --git a/demo/default.css b/demo/default.css index 29f3635a..ba2c4d0b 100644 --- a/demo/default.css +++ b/demo/default.css @@ -1,4 +1,4 @@ -body{ +body { padding:0; margin:0; font-family: "open-sans", Verdana, sans-serif; diff --git a/demo/index.htm b/demo/index.htm index 6988ee05..4ff1377e 100644 --- a/demo/index.htm +++ b/demo/index.htm @@ -8,6 +8,12 @@ + @@ -52,6 +58,12 @@

AcFun (Experimental)

+

Live Danmaku

+
+ + + +

TagSoup:
, , @@ -68,7 +80,7 @@

AcFun (Experimental)

APIs:

-

+

Links:


diff --git a/demo/scripting/index.htm b/demo/scripting/index.htm index 97e9e365..3578b9c1 100644 --- a/demo/scripting/index.htm +++ b/demo/scripting/index.htm @@ -16,9 +16,10 @@

CCL Scripting Demo

- - - + + + +
diff --git a/demo/scripting/sandbox.js b/demo/scripting/sandbox.js index ecb993e2..83ac7fda 100644 --- a/demo/scripting/sandbox.js +++ b/demo/scripting/sandbox.js @@ -63,6 +63,9 @@ window.addEventListener('load',function(){ $("debug-3dsphere").addEventListener("click", function(){ fetchFile("../../test/scripting/3dsphere.biliscript"); }); + $("debug-mc4k").addEventListener("click", function(){ + fetchFile("../../test/scripting/minecraft4k.biliscript"); + }); $("debug-custom").addEventListener("click", function(){ var file = prompt("Please input test file name:"); if(file !== null && file !== ""){ diff --git a/dist/CommentCoreLibrary.js b/dist/CommentCoreLibrary.js index c9f7ffa6..d36d8531 100644 --- a/dist/CommentCoreLibrary.js +++ b/dist/CommentCoreLibrary.js @@ -4,72 +4,71 @@ * @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; + 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 @@ -78,1367 +77,1421 @@ var BinArray = (function () { * 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; - } - for (;this.position < this.timeline.length;this.position++) { - if (this.timeline[this.position]['stime']<=time) { - if (this.options.limit> 0 && this.runline.length>= this.options.limit) { - continue; // Skip comments but still move the position pointer - } else if (this.validate(this.timeline[this.position])) { - this.send(this.timeline[this.position]); - } - } else { - break; - } - } - }; - - CommentManager.prototype.rescale = function () { - // TODO: Implement rescaling - }; - - CommentManager.prototype.send = function (data) { - if (data.mode === 8) { - console.log(data); - if (this.scripting) { - console.log(this.scripting.eval(data.code)); - } - return; - } - if (this.filter != null) { - data = this.filter.doModify(data); - if (data == null) { - return; - } - } - var cmt = this.factory.create(this, data); - 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; - } - cmt.y = cmt.y; - this.dispatchEvent("enterComment", cmt); - this.runline.push(cmt); - }; - - 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 = 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 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.'); - } - } - } + 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; + } } - 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, "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 + }; + + 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; + } }); - 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.dom.className = this.parent.options.global.className + ' rshadow'; - } - }, - 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.dom.className = this.parent.options.global.className + ' noshadow'; - } - }, - 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 = 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 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 = 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 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; - } - 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 () { + 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"); + }; - /** - * 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; - } + 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; + } + } - /** - * 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); - }; + 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; + } + }; - /** - * 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; - }; + CommentManager.prototype.addEventListener = function (event, listener) { + if (typeof this._listeners[event] !== "undefined") { + this._listeners[event].push(listener); + } else { + this._listeners[event] = [listener]; + } + }; - /** - * 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; + 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); } - 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); - }; + /** 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 = 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 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; + this._className = ''; + 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.'); + } + } + } + if (init.hasOwnProperty('className')) { + this._className = init['className']; + } + } + 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.appendChild(document.createTextNode(this.text)); + this.dom.textContent = this.text; + this.dom.innerText = this.text; + this.size = this._size; + this.className = this._className; + 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, "undefined' || this._width === null) { + 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 (typeof this._height === 'undefined' || this._height === null) { + 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 + }); + Object.defineProperty(CoreComment.prototype, "className", { + get: function () { + return this._className; + }, + set: function (className) { + this._className = className; + this.dom.className = this.parent.options.global.className + ' ' + className; + }, + 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 = 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 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 COS = Math.cos; + var SIN = Math.sin; + var DEG2RAD = Math.PI / 180; + var xr = xrot * DEG2RAD; + var yr = yrot * DEG2RAD; + var zr = zrot * DEG2RAD; + var matrix = [ + COS(yr) * COS(zr), COS(yr) * SIN(zr), -SIN(yr), 0, + SIN(xr) * SIN(yr) * COS(zr) - COS(xr) * SIN(zr), SIN(xr) * SIN(yr) * SIN(zr) + COS(xr) * COS(zr), SIN(xr) * COS(yr), 0, + COS(xr) * SIN(yr) * COS(zr) + SIN(xr) * SIN(zr), COS(xr) * SIN(yr) * SIN(zr) - SIN(xr) * COS(zr), COS(xr) * COS(yr), 0, + 0, 0, 0, 1 + ]; + return new Matrix3D(matrix); + }; + return Matrix3D; + }()); + CommentUtils.Matrix3D = Matrix3D; +})(CommentUtils || (CommentUtils = {})); + +var __extends = (this && this.__extends) || (function () { + var 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 function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +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); + }; + CssScrollComment.prototype._calculateX = function () { + var width = (typeof this._width === 'undefined') ? 0 : this.width; + var x = (this.ttl / this.dur) * (this.parent.width + width) - width; + return (!this.absolute) ? (x / this.parent.width) : x; + }; + Object.defineProperty(CssScrollComment.prototype, "x", { + get: function () { + return this._calculateX(); + }, + set: function (x) { + if (!this.absolute) { + x *= this.parent.width; + } + var dx = x - this._calculateX(); + this.dom.style.transform = + "translateX(" + (this.axis % 2 === 0 ? dx : -dx) + "px)" + + (this._transform === null || this._transform.isIdentity() ? + '' : (' ' + this._transform.toCss())); + if (this.axis % 2 === 0) { + this.dom.style.left = this._calculateX() + 'px'; + } + else { + this.dom.style.right = this._calculateX() + 'px'; + } + }, + enumerable: true, + configurable: true + }); + CssScrollComment.prototype.update = function () { + if (this._dirtyCSS) { + this.dom.style.transition = "transform " + this.ttl + "ms linear"; + this.x = -this.dom.offsetWidth; + this._dirtyCSS = false; + } + }; + CssScrollComment.prototype.invalidate = function () { + _super.prototype.invalidate.call(this); + this._dirtyCSS = true; + if (!this.dom) { + return; + } + else { + this.dom.style.transition = ''; + this.x = this.x; + } + }; + CssScrollComment.prototype.stop = function () { + _super.prototype.stop.call(this); + this.invalidate(); + }; + return CssScrollComment; +}(ScrollComment)); + +/** + * Comment Filters Module Simplified + * @license MIT + * @author Jim Chen + */ +var CommentFilter = (function () { - /** - * 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; + /** + * 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; } - }; - - /** - * 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.'); + case '||': + case 'or': + if (Array.isArray(rule.value)) { + return rule.value.some(function (r) { + return _match(r, extracted); + }); + } else { + return false; } - this.modifiers.push(f); - }; + 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; + return CommentFilter; })(); - + /** * Comment Provider * Provides functionality to send or receive danmaku @@ -1448,349 +1501,349 @@ var CommentFilter = (function () { 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.'); + 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)); } - 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; - }; + xhr.onerror = function () { + reject(new Error(this.status + " " + this.statusText)); + }; - 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)); - }; + xhr.open(method, uri); - 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)); - }; + // Limit the response type based on input + xhr.responseType = typeof responseType === "string" ? + responseType : ""; - /** - * (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) { + 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].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)); + this._targets[i].send( + this.applyParserOne(data, type)); } - return Promise.resolve(commentList); + }.bind(this)); }.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 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; + return CommentProvider; })(); - + /** * Promises extra functionality * @license MIT @@ -1798,584 +1851,584 @@ var CommentProvider = (function () { */ 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)); - } - }); - }; + 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; + 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); + if (this._attemptFix) { + text = _format(_formatmode7(text)); + } + var extendedParams = JSON.parse(text); + comment.shadow = true; + comment.x = parseFloat(extendedParams[0]); + comment.y = parseFloat(extendedParams[1]); + if (Math.floor(comment.x) < comment.x || Math.floor(comment.y) < comment.y) { + comment.position = 'relative'; + } + comment.text = extendedParams[4].replace(/(\/n|\\n|\n|\r\n)/g, "\n"); + comment.rZ = 0; + comment.rY = 0; + if (extendedParams.length>= 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); } - 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 - }; + 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); } - } 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); + break; + } + m = regex.exec(path); } - } - } - 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'); + 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) { - // 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.'); - } - }; + 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; + 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); + 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.TextParser.prototype.parseOne = function (comment) { + }; + + 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 { - return this._jsonParser.parseOne(JSON.parse(comment)); + var x = JSON.parse(comment.m); } catch (e) { - console.warn(e); - return null; + 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.TextParser.prototype.parseMany = function (comment) { - try { - return this._jsonParser.parseMany(JSON.parse(comment)); - } catch (e) { - console.warn(e); - 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; + return AcfunFormat; })(); - + /** * CommonDanmakuFormat Parser * Example parser for parsing comments that the CCL can accept directly. @@ -2384,62 +2437,62 @@ var AcfunFormat = (function () { **/ 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; - }; + 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; + return CommonDanmakuFormat; })(); diff --git a/dist/CommentCoreLibrary.min.js b/dist/CommentCoreLibrary.min.js index 20707ba6..bb9c1a7b 100644 --- a/dist/CommentCoreLibrary.min.js +++ b/dist/CommentCoreLibrary.min.js @@ -1,2 +1,2 @@ -/*!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(;this.position=this.options.limit||this.validate(this.timeline[this.position])&&this.send(this.timeline[this.position])},t.prototype.rescale=function(){},t.prototype.send=function(t){if(8===t.mode)return console.log(t),void(this.scripting&&console.log(this.scripting.eval(t.code)));if(null==this.filter||null!=(t=this.filter.doModify(t))){var e=this.factory.create(this,t);switch(e.mode){default:case 1:this.csa.scroll.add(e);break;case 2:this.csa.scrollbtm.add(e);break;case 4:this.csa.bottom.add(e);break;case 5:this.csa.top.add(e);break;case 6:this.csa.reverse.add(e);break;case 7:case 17:}e.y=e.y,this.dispatchEvent("enterComment",e),this.runline.push(e)}},t.prototype.finish=function(t){this.dispatchEvent("exitComment",t),this.stage.removeChild(t.dom);var e=this.runline.indexOf(t);switch(0<=e&&this.runline.splice(e,1),t.mode){default:case 1:this.csa.scroll.remove(t);break;case 2:this.csa.scrollbtm.remove(t);break;case 4:this.csa.bottom.remove(t);break;case 5:this.csa.top.remove(t);break;case 6:this.csa.reverse.remove(t);break;case 7:}},t.prototype.addEventListener=function(t,e){void 0!==this._listeners[t]?this._listeners[t].push(e):this._listeners[t]=[e]},t.prototype.dispatchEvent=function(t,e){if(void 0!==this._listeners[t])for(var r=0;rthis._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. 2:r. 6:r. 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. 2:r. 6:r. 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. 5:r. 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=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])};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._ 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._ 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_,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. 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.add 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;re.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. 2:r. 6:r. 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. 2:r. 6:r. 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. 5:r. 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=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])};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._ 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._ 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_,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. 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.add 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> 16) & 0xff, + g = (color>> 8) & 0xff, + b = color & 0xff, + a = (color>> 24) & 0xff; + for (var y = 0; y < this._data.height; y++) { + for (var x = 0; x < this._data.width; x++) { + var i = 4 * (y * this._data.width + x); + this._data.data[i] = r; + this._data.data[i + 1] = g; + this._data.data[i + 2] = b; + this._data.data[i + 3] = a; + } + } + } + + this._registerNotify = function (bitmap) { + if (this._notifyList.indexOf(bitmap) < 0) { + this._notifyList.push(bitmap); + // Also notify immediately + bitmap._draw(this._data); + } + }; + + this._deregisterNotify = function (bitmap) { + var index = this._notifyList.indexOf(bitmap); + if (index>= 0) { + this._notifyList.splice(index, 1); + } + }; + + this.updateBox = function (update) { + var box = update.box; + for (var y = box.y; y < box.y + box.height; y++) { + for (var x = box.x; x < box.x + box.width; x++) { + // Unpack ARGB + var color = update.values[y * box.width + x]; + var r = (color>> 16) & 0xff, + g = (color>> 8) & 0xff, + b = color & 0xff, + a = (color>> 24) & 0xff; + var i = 4 * (y * this._data.width + x); + this._data.data[i] = r; + this._data.data[i + 1] = g; + this._data.data[i + 2] = b; + this._data.data[i + 3] = a; + } + } + + // Update all relevant images + this._notifyList.forEach((function (image) { + image._draw(this._data); + }).bind(this)); + }; + + this.unload = function () { + this._data = null; + // Make sure this is null so future uses will error out + }; + // No need to hook anywhere + } + + ScriptingContext.prototype.Unpack.Bitmap = function (stage, data, ctx) { + this._bitmapDataId = null; + this.DOM = _('canvas', { + 'style': { + 'position': 'absolute', + "top": data.y ? data.y + "px" : "0px", + "left": data.x ? data.x + "px" : "0px", + "transformOrigin":"0 0 0" + } + }); + 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.__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){ + data.x = f; + this.DOM.style.left = data.x + 'px'; + }); + this.__defineSetter__("y", function(f){ + data.y = f; + this.DOM.style.top = data.y + 'px'; + }); + this.__defineGetter__("x", function(f){ + return 0; + }); + this.__defineGetter__("y", function(f){ + return 0; + }); + + this._draw = function (imageData) { + this.DOM.setAttribute('width', imageData.width); + this.DOM.setAttribute('height', imageData.height); + var ctx = this.DOM.getContext('2d'); + ctx.putImageData(imageData, 0, 0); + }; + + this.setBitmapData = function (id) { + var bitmapData = ctx.getObject(id); + if (this._bitmapDataId !== null) { + ctx.getObject(this._bitmapDataId)._deregisterNotify(this); + } + bitmapData._registerNotify(this); + this._bitmapDataId = id; + }; + + this.unload = function () { + try { + stage.removeChild(this.DOM); + } catch (e) {}; + }; + // Set bitmap data + if ('bitmapData' in data) { + this.setBitmapData(data['bitmapData']); + } + // Hook DOM + stage.appendChild(this.DOM); + } + // Load all the getClass Prototypes - for(var cl in ScriptingContext.prototype.Unpack){ + 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 index 4f724856..91455424 100644 --- a/dist/scripting/OOAPI.js +++ b/dist/scripting/OOAPI.js @@ -1,140 +1,140 @@ -/** - * 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 - })); -}; +/** + * 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 index b85f0707..d6cb892f 100644 --- a/dist/scripting/Worker.js +++ b/dist/scripting/Worker.js @@ -1,55 +1,55 @@ -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"); +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 index e7ed1ea9..b7eca9ed 100644 --- a/dist/scripting/api/Display.js +++ b/dist/scripting/api/Display.js @@ -1,2927 +1,3155 @@ -var __extends = (this && this.__extends) || (function () { - var 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 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', 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, "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; +var __extends = (this && this.__extends) || (function () { + var 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 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; + } + 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 () { + if (typeof this._perspectiveProjection === 'undefined') { + this._perspectiveProjection = new PerspectiveProjection(this._parent); + } + return this._perspectiveProjection; + }, + set: function (projection) { + this._perspectiveProjection = projection; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Transform.prototype, "colorTransform", { + get: function () { + if (typeof this._colorTransform === 'undefined') { + this._colorTransform = new Display.ColorTransform(); + } + return this._colorTransform; + }, + set: function (colorTransform) { + this._colorTransform = colorTransform; + }, + 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', 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() { + var _this = _super.call(this, '__root') || this; + _this._metaRoot = Runtime.getObject('__root'); + return _this; + } + Object.defineProperty(RootSprite.prototype, "parent", { + get: function () { + __trace('SecurityError: No access above root sprite.', 'err'); + return null; + }, + enumerable: true, + configurable: true + }); + RootSprite.prototype.addEventListener = function (eventName, listener) { + __trace('Listener[' + eventName + '] on root sprite inadvisible', 'warn'); + this._metaRoot.addEventListener(eventName, listener); + }; + RootSprite.prototype.removeEventListener = function (eventName, listener) { + this._metaRoot.removeEventListener(eventName, listener, false); + }; + 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 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; + try { + Object['setPrototypeOf'](_this, ByteArray.prototype); + } + catch (e) { } + 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 + }); + Object.defineProperty(ByteArray.prototype, "position", { + get: function () { + return this._readPosition; + }, + set: function (p) { + this._readPosition = p; + }, + 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[' + algorithm + '] not implemented', 'warn'); + this._readPosition = 0; + }; + ByteArray.prototype.uncompress = function (algorithm) { + if (algorithm === void 0) { algorithm = 'zlib'; } + __trace('ByteArray.uncompress[' + algorithm + + '] not implemented', 'warn'); + this._readPosition = 0; + }; + 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.readUnsignedByte = function () { + return this[this._readPosition] & 0xff; + }; + ByteArray.prototype.readUnsignedShort = function () { + var top = this.readUnsignedByte(), bottom = this.readUnsignedByte(); + return ((top << 8) + bottom) & 0xffff; + }; + ByteArray.prototype.readUnsignedInt = function () { + var a = this.readUnsignedByte(), b = this.readUnsignedByte(), c = this.readUnsignedByte(), d = this.readUnsignedByte(); + return ((a << 24) + (b << 16) + (c << 8) + d) & 0xffffffff; + }; + ByteArray.prototype.readByte = function () { + return this.readUnsignedByte() - 128; + }; + ByteArray.prototype.readShort = function () { + return this.readUnsignedShort() - 0x7fff; + }; + ByteArray.prototype.readBoolean = function () { + return this.readUnsignedByte() !== 0; + }; + ByteArray.prototype.readFloat = function () { + var source = this.readUnsignedInt(); + var fval = 0.0; + var x = (source & 0x80000000) ? -1 : 1; + var m = ((source>> 23) & 0xff); + var s = (source & 0x7fffff); + switch (x) { + case 0: + break; + case 0xFF: + if (m) { + fval = NaN; + } + else if (s> 0) { + fval = Number.POSITIVE_INFINITY; + } + else { + fval = Number.NEGATIVE_INFINITY; + } + break; + default: + x -= 127; + m += 0x800000; + fval = s * (m / 8388608.0) * Math.pow(2, x); + break; + } + return fval; + }; + ByteArray.prototype.writeByte = function (value) { + this.push(value & 0xff); + }; + ByteArray.prototype.writeBytes = function (bytes, offset, length) { + if (offset === void 0) { offset = 0; } + if (length === void 0) { length = 0; } + for (var i = offset; i < Math.min(bytes.length - offset, length); i++) { + this.writeByte(bytes[i]); + } + }; + ByteArray.prototype.writeUTFBytes = function (value) { + var bytesString = unescape(encodeURIComponent(value)); + for (var i = 0; i < value.length; i++) { + this.push(bytesString.charCodeAt(i)); + } + }; + ByteArray.prototype.clone = function () { + var cloned = new ByteArray(); + this.forEach(function (item) { cloned.push(item); }); + return cloned; + }; + return ByteArray; + }(Array)); + Display.ByteArray = ByteArray; +})(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(bitmapData) { + if (bitmapData === void 0) { bitmapData = null; } + var _this = _super.call(this, Runtime.generateId('obj-bmp')) || this; + _this._bitmapData = null; + _this._bitmapData = bitmapData; + return _this; + } + Object.defineProperty(Bitmap.prototype, "width", { + get: function () { + console.log(this._bitmapData); + return this._bitmapData !== null ? + this._bitmapData.width * this.scaleX : 0; + }, + set: function (w) { + if (this._bitmapData !== null && this._bitmapData.width> 0) { + this.scaleX = w / this._bitmapData.width; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bitmap.prototype, "height", { + get: function () { + return this._bitmapData !== null ? + this._bitmapData.height * this.scaleY : 0; + }, + set: function (h) { + if (this._bitmapData !== null && this._bitmapData.height> 0) { + this.scaleY = h / this._bitmapData.height; + } + }, + enumerable: true, + configurable: true + }); + Bitmap.prototype.getBitmapData = function () { + return this._bitmapData; + }; + Bitmap.prototype.setBitmapData = function (bitmapData) { + if (typeof bitmapData !== 'undefined') { + this._bitmapData = bitmapData; + this.methodCall('setBitmapData', bitmapData.getId()); + } + }; + Bitmap.prototype.serialize = function () { + var serialized = _super.prototype.serialize.call(this); + serialized["class"] = 'Bitmap'; + if (this._bitmapData !== null) { + serialized["bitmapData"] = this._bitmapData.getId(); + } + return serialized; + }; + return Bitmap; + }(Display.DisplayObject)); + Display.Bitmap = Bitmap; + 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('obj-bmp-data'); } + this._locked = false; + this._id = id; + this._rect = new Display.Rectangle(0, 0, width, height); + this._transparent = transparent; + this._fillColor = fillColor; + this._dirtyArea = new DirtyArea(); + this._fill(); + Runtime.registerObject(this); + } + 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._methodCall('updateBox', { + 'box': change.serialize(), + 'values': region + }); + this._dirtyArea.reset(); + }; + BitmapData.prototype._methodCall = function (methodName, params) { + __pchannel("Runtime:CallMethod", { + "id": this._id, + "method": methodName, + "params": params + }); + }; + Object.defineProperty(BitmapData.prototype, "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.draw = function (source, matrix, colorTransform, blendMode, clipRect, smoothing) { + if (matrix === void 0) { matrix = null; } + if (colorTransform === void 0) { colorTransform = null; } + if (blendMode === void 0) { blendMode = null; } + if (clipRect === void 0) { clipRect = null; } + if (smoothing === void 0) { smoothing = false; } + if (!(source instanceof BitmapData)) { + __trace('Drawing non BitmapData is not supported!', 'err'); + return; + } + if (matrix !== null) { + __trace('Matrix transforms not supported yet.', 'warn'); + } + if (colorTransform !== null) { + __trace('Color transforms not supported yet.', 'warn'); + } + if (blendMode !== null && blendMode !== 'normal') { + __trace('Blend mode [' + blendMode + '] not supported yet.', 'warn'); + } + if (smoothing !== false) { + __trace('Smoothign not supported!', 'warn'); + } + this.lock(); + if (clipRect === null) { + clipRect = new Display.Rectangle(0, 0, source.width, source.height); + } + this.setPixels(clipRect, source.getPixels(clipRect)); + this.unlock(); + }; + 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] & 0x00ffffff) + 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 Display.ByteArray(); + } + var region = new Display.ByteArray(); + for (var i = 0; i < rect.height; i++) { + this._byteArray.slice((rect.y + i) * this._rect.width + rect.x, (rect.y + i) * this._rect.width + rect.x + rect.width).forEach(function (v) { + region.push(v); + }); + } + return region; + }; + BitmapData.prototype.setPixel = function (x, y, color) { + this.setPixel32(x, y, (color & 0x00ffffff) + 0xff000000); + }; + BitmapData.prototype.setPixel32 = function (x, y, color) { + if (!this._transparent) { + color = (color & 0x00ffffff) + 0xff000000; + } + this._byteArray[y * this._rect.width + x] = color; + this._dirtyArea.expand(x, y); + this._updateBox(); + }; + 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); + } + if (!this._transparent) { + input = input.map(function (color) { + return (color & 0x00ffffff) + 0xff000000; + }); + } + 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); + } + } + this._updateBox(); + }; + BitmapData.prototype.getVector = function (rect) { + if (this._rect.equals(rect)) { + return this._byteArray; + } + var vector = []; + for (var j = rect.y; j < rect.y + rect.height; j++) { + for (var i = rect.x; i < rect.x + rect.width; i++) { + vector.push(rect[j * this._rect.width + i]); + } + } + return vector; + }; + 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.dispatchEvent = function (_event, _data) { + }; + BitmapData.prototype.getId = function () { + return this._id; + }; + BitmapData.prototype.serialize = function () { + return { + 'class': 'BitmapData', + 'height': this._rect.height, + 'fill': this._fillColor + }; + }; + BitmapData.prototype.unload = function () { + this._methodCall('unload', null); + }; + BitmapData.prototype.clone = function () { + var data = new BitmapData(this.width, this.height, this._transparent, this._fillColor); + data._byteArray = this._byteArray.slice(0); + data._updateBox(data._rect); + return data; + }; + 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; + } + if (this._dur === 0) { + 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, 'bitmapData' in params ? params['bitmapData'] : undefined) || 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) { + if (typeof style === 'undefined' || style === null) { + style = {}; + } + if ("lifeTime" in style) { + this._mM.dur = style["lifeTime"] * 1000; + } + }; + 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, Runtime.generateId('obj-textfield')) || 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 index cd229a02..271c5697 100644 --- a/dist/scripting/api/Function.js +++ b/dist/scripting/api/Function.js @@ -4,88 +4,88 @@ **/ function trace (msg) { - if (typeof msg === 'object') { - __trace(JSON.stringify(msg), 'log'); - } else { - __trace(msg, 'log'); - } + 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(); - } - } - }); - } + 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; - } + 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 (typeof target['clone'] === 'function') { + return target.clone(); + } - // Call the object's own clone method if possible - if (target.hasOwnProperty('clone') || typeof target['clone'] === 'function') { - return target.clone(); - } + // Clone an array + if (Array.isArray(target)) { + return target.slice(0); + } - // 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; + // 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; - } + 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]); - } + for (var x in enumerable) { + if (enumerable.hasOwnProperty(x)) { + f(x, enumerable[x]); } - return; + } + return; } var none = null; diff --git a/dist/scripting/api/Global.js b/dist/scripting/api/Global.js index 08dc230a..8c9bbb90 100644 --- a/dist/scripting/api/Global.js +++ b/dist/scripting/api/Global.js @@ -1,22 +1,22 @@ -/** - * 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; +/** + * 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 index 74b09461..a5e73f11 100644 --- a/dist/scripting/api/Player.js +++ b/dist/scripting/api/Player.js @@ -1,220 +1,254 @@ -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 = {})); +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._id = Runtime.generateId('obj-snd'); + this.onload = onload; + this._source = type; + } + Sound.prototype.createFromURL = function (url) { + this._source = url; + }; + Sound.prototype.play = function () { + if (this._isPlaying) { + return; + } + }; + Sound.prototype.remove = function () { + }; + Sound.prototype.stop = function () { + if (!this._isPlaying) { + return; + } + }; + Sound.prototype.loadPercent = function () { + return 0; + }; + Sound.prototype.getId = function () { + return this._id; + }; + Sound.prototype.dispatchEvent = function (_eventName, _params) { + }; + Sound.prototype.unload = function () { + this.stop(); + }; + Sound.prototype.serialize = function () { + return { + 'class': 'Sound', + 'url': this._source + }; + }; + return Sound; + }()); + function createSound(sample, onload) { + if (onload === void 0) { onload = null; } + return new Sound(sample, onload); + } + Player.createSound = createSound; +})(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.', 'err'); + return; + } + if (timeout < 0) { + return; + } + var listener = function (comment) { + callback(comment); + }; + var player = Runtime.getObject('__player'); + player.addEventListener('comment', listener); + } + Player.commentTrigger = commentTrigger; + function keyTrigger(callback, timeout, triggerOnUp) { + if (timeout === void 0) { timeout = 1000; } + if (triggerOnUp === void 0) { triggerOnUp = false; } + if (!Runtime.hasObject('__player')) { + __trace('Your environment does not support key triggers.', 'err'); + return; + } + if (timeout < 0) { + return; + } + var eventName = 'key' + (triggerOnUp ? 'up' : 'down'); + var listener = function (key) { + callback(key.keyCode); + }; + var player = Runtime.getObject('__player'); + player.addEventListener(eventName, listener); + } + 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["stagestageHeight"]; + 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 index 52eeeb23..56b6c2e9 100644 --- a/dist/scripting/api/Runtime.js +++ b/dist/scripting/api/Runtime.js @@ -1,673 +1,676 @@ -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 = {})); +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) === '__' && object !== '__root') { + 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 may not be properly implemented.", "warn"); + Runtime.clear(); + }; + ScriptManagerImpl.prototype.clearTrigger = function () { + __trace("ScriptManager.clearTrigger not implemented.", "warn"); + }; + ScriptManagerImpl.prototype.pushEl = function (el) { + __trace("ScriptManager.pushEl is not properly implemented.", "warn"); + if (el['motionManager']) { + el['motionManager'].start(); + } + el['visible'] = true; + }; + ScriptManagerImpl.prototype.popEl = function (el) { + __trace("ScriptManager.popEl is not properly implemented.", "warn"); + if (el['motionManager']) { + el['motionManager'].play(); + } + el['visible'] = false; + }; + 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 _makeId(type) { + if (type === void 0) { type = "obj"; } + return type + ":" + Date.now() + "|" + + Runtime.NotCrypto.random(16) + ":" + objCount; + } + function generateId(type) { + if (type === void 0) { type = "obj"; } + var id = _makeId(type); + while (Runtime.hasObject(id)) { + id = _makeId(type); + } + 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 index a4d31a04..a2c40a7b 100644 --- a/dist/scripting/api/Tween.js +++ b/dist/scripting/api/Tween.js @@ -1,453 +1,453 @@ -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 = {})); +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 index 96fb5c33..b4b70529 100644 --- a/dist/scripting/api/Utils.js +++ b/dist/scripting/api/Utils.js @@ -1,114 +1,114 @@ -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; +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/docs/CommentManager.md b/docs/CommentManager.md index d9c901a0..d5e39d42 100644 --- a/docs/CommentManager.md +++ b/docs/CommentManager.md @@ -2,6 +2,9 @@ 弹幕管理器自 `v1.0` 后将改成支持多种多层渲染的模式了,在此之前请先参考一些 [不完整的API实现](CommentCoreLibraryAPI.md)。 +## Overview 工作模式概览 +![overview diagram](https://github.com/jabbany/CommentCoreLibrary/blob/master/docs/diagrams/CommentManager.png?raw=true) + ## Properties 属性 ### options <Object> diff --git a/docs/CommentObject.md b/docs/CommentObject.md index 5d76339e..6a62575e 100644 --- a/docs/CommentObject.md +++ b/docs/CommentObject.md @@ -119,6 +119,9 @@ Parent: 此弹幕归属的上层管理器 ### dom <HTMLDivElement/Canvas/etc.> DOM Correspondance: 对应的渲染元素,根据不同情况是不一样的。默认是 DIV 元素。 +### className <String> +CSS Class: 渲染元素的css类,可指定多个类名,用空格分隔。 + ## Methods 方法 ### constructor(cm:CommentManager, data:Object) diff --git a/docs/CommentProperties.md b/docs/CommentProperties.md index 3eca6494..cbff4341 100644 --- a/docs/CommentProperties.md +++ b/docs/CommentProperties.md @@ -74,7 +74,7 @@ Object 进行实现。 一些可选参数项将变为必选参数。原则上 `mode` 为正整数。 ### stime -开始时间,开始时间按微秒(千分之一秒 0.001s)的倍数记录,如:在视频播放1s后进入的弹幕, +开始时间,开始时间按毫秒(千分之一秒 0.001s)的倍数记录,如:在视频播放1s后进入的弹幕, 对应的`stime`属性是`1000`。原则上`stime`的值应该是非负整数。请注意:有些特殊类型的弹幕将会 定义 `0` 作为`stime`起始值,但弹幕并不会渲染,而可能全程参与改变弹幕属性。 diff --git a/docs/PoweredByCCL.md b/docs/PoweredByCCL.md index 1ff925e1..5d887e10 100644 --- a/docs/PoweredByCCL.md +++ b/docs/PoweredByCCL.md @@ -11,7 +11,11 @@ - [AcFun HTML5弹幕播放器](http://www.acfun.tv) AcFun的HTML5弹幕播放器弹幕呈现库采用CCL - + +- [阿里云播放器SDK AliyunPlayer Web](https://github.com/aliyunvideo/AliyunPlayer_Web/blob/master/customComponents/src/components/AliplayerDanmuComponent/) + + 阿里云视频点播(ApsaraVideo VoD)是集音视频采集、编辑、上传、自动化转码处理、媒体资源管理、高效云剪辑处理、分发加速、视频播放于一体的一站式音视频点播解决方案。 + - [Missevan M站 弹幕音频](http://www.missevan.cn) 采用CCL为音频(而非视频)配上弹幕轨道,在开放页面上滚动弹幕 diff --git a/docs/diagrams/CommentManager.png b/docs/diagrams/CommentManager.png new file mode 100644 index 00000000..d9bc5669 Binary files /dev/null and b/docs/diagrams/CommentManager.png differ diff --git a/docs/diagrams/CommentManager.svg b/docs/diagrams/CommentManager.svg new file mode 100644 index 00000000..fe0d3ea1 --- /dev/null +++ b/docs/diagrams/CommentManager.svg @@ -0,0 +1,644 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + 我是弹幕 + + + + + + + 我是弹幕 + + + + + + 我是弹幕 + + + + + + cm.start() + cm.stop() + cm.finish() + + cm.send() + + cm.validate() + + + + + (1) Direct invocation of send to immediately display comment外部直接调用send来立即显示弹幕 + + + + + + + + + + + + + + + + cm.time() + (2) Comments managed by CM.timeline are sent or skipped based on playhead time.If the playhead was fast forwarded or reversed no comments will be sent.每次播放时间更新时,时间轴会派发上次更新的播放时间和目前播放器时间期间内的弹幕。时间跨度太大(快进)或者新时间更早(回看)时则不会派发弹幕。 + + + + + 0:00 + XX:XX + + + + + + + + + + + + cm.load()cm.insert() + cm.runline + cm.timeline + CommentManager OperationalDiagram + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..ae8e9825 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6153 @@ +{ + "name": "comment-core-library", + "version": "0.11.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, + "@sinonjs/commons": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", + "integrity": "sha512-9jHK3YF/8HtJ9wCAbG+j8cD0i0+ATS9A7gXFqS36TblLPNy6rEEc+SB0imo91eCboGaBYGV/MT1/br/J+EE7Tw==", + "dev": true, + "requires": { + "type-detect": "4.0.8" + } + }, + "@sinonjs/formatio": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-3.2.1.tgz", + "integrity": "sha512-tsHvOB24rvyvV2+zKMmPkZ7dXX6LSLKZ7aOtXY6Edklp0uRcgGpOsQTTGTcWViFyx4uhWc6GV8QdnALbIbIdeQ==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1", + "@sinonjs/samsam": "^3.1.0" + } + }, + "@sinonjs/samsam": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.1.tgz", + "integrity": "sha512-wRSfmyd81swH0hA1bxJZJ57xr22kC07a1N4zuIL47yTS04bDk6AoCkczcqHEjcRPmJ+FruGJ9WBQiJwMtIElFw==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.0.2", + "array-from": "^2.1.1", + "lodash": "^4.17.11" + } + }, + "@sinonjs/text-encoding": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz", + "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", + "dev": true + }, + "@types/minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", + "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.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==", + "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.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "dependencies": { + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + } + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "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", + "integrity": "sha1-QchHGUZGN15qGl0Qw8oFTvn8mA0=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "anymatch": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", + "dev": true, + "requires": { + "micromatch": "^3.1.4", + "normalize-path": "^2.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } + } + }, + "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", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", + "dev": true + }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, + "array-differ": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz", + "integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==", + "dev": true + }, + "array-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==", + "dev": true + }, + "array-from": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", + "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", + "dev": true + }, + "array-slice": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", + "dev": true + }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, + "array-unique": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", + "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "dev": true + }, + "arrify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==", + "dev": true + }, + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "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": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", + "dev": true + }, + "async-each": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "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", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "atob": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", + "dev": true + }, + "autoprefixer-core": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/autoprefixer-core/-/autoprefixer-core-5.2.1.tgz", + "integrity": "sha1-5kDEFK5Bmq4hwa1DyOoPPbgqVm0=", + "dev": true, + "requires": { + "browserslist": "~0.4.0", + "caniuse-db": "^1.0.30000214", + "num2fraction": "^1.1.0", + "postcss": "~4.1.12" + } + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "base": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "dev": true, + "requires": { + "cache-base": "^1.0.1", + "class-utils": "^0.3.5", + "component-emitter": "^1.2.1", + "define-property": "^1.0.0", + "isobject": "^3.0.1", + "mixin-deep": "^1.2.0", + "pascalcase": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "binary-extensions": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "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", + "integrity": "sha1-5LoM5BCkaTYyM2dgnstOZVMSUGk=", + "dev": true, + "requires": { + "continuable-cache": "^0.3.1", + "error": "^7.0.0", + "raw-body": "~1.1.0", + "safe-json-parse": "~1.0.1" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", + "dev": true, + "requires": { + "arr-flatten": "^1.1.0", + "array-unique": "^0.3.2", + "extend-shallow": "^2.0.1", + "fill-range": "^4.0.0", + "isobject": "^3.0.1", + "repeat-element": "^1.1.2", + "snapdragon": "^0.8.1", + "snapdragon-node": "^2.0.1", + "split-string": "^3.0.2", + "to-regex": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "browserslist": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-0.4.0.tgz", + "integrity": "sha1-O9SrkZncG5FQ1NbbpNnTqrvIbdQ=", + "dev": true, + "requires": { + "caniuse-db": "^1.0.30000153" + } + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true + }, + "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" + } + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + } + } + }, + "cache-base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "dev": true, + "requires": { + "collection-visit": "^1.0.0", + "component-emitter": "^1.2.1", + "get-value": "^2.0.6", + "has-value": "^1.0.0", + "isobject": "^3.0.1", + "set-value": "^2.0.0", + "to-object-path": "^0.3.0", + "union-value": "^1.0.0", + "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 + }, + "caniuse-db": { + "version": "1.0.30000971", + "resolved": "https://registry.npmjs.org/caniuse-db/-/caniuse-db-1.0.30000971.tgz", + "integrity": "sha512-ubSZfYXO2KMYtCVmDez82mjodeZa+mBYWAnBMAmFBPAn4C2PY4SD0eC/diYQD4Rj1K+WNdp0vr0JDtm0SQ6GNg==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "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", + "integrity": "sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g==", + "dev": true, + "requires": { + "anymatch": "^2.0.0", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", + "glob-parent": "^3.1.0", + "inherits": "^2.0.3", + "is-binary-path": "^1.0.0", + "is-glob": "^4.0.0", + "normalize-path": "^3.0.0", + "path-is-absolute": "^1.0.0", + "readdirp": "^2.2.1", + "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", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "define-property": "^0.2.5", + "isobject": "^3.0.0", + "static-extend": "^0.1.1" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "clean-css": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz", + "integrity": "sha512-4ZxI6dy4lrY6FHzfiy1aEOXgu4LIsW2MhwG0VBKdcoGoH/XLFgaHSdLTGr4O8Be6A8r3MOphEiI8Gc1n0ecf3g==", + "dev": true, + "requires": { + "source-map": "~0.6.0" + }, + "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 + } + } + }, + "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-version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "collection-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", + "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "dev": true, + "requires": { + "map-visit": "^1.0.0", + "object-visit": "^1.0.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "colors": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", + "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", + "dev": true + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "requires": { + "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", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "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==", + "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" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + } + } + }, + "copy-descriptor": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", + "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "coveralls": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.3.tgz", + "integrity": "sha512-viNfeGlda2zJr8Gj1zqXpDMRjw9uM54p7wzZdvLRyOgnAfCe974Dq4veZkjJdxQXbmdppu6flEajFYseHYaUhg==", + "dev": true, + "requires": { + "growl": "~> 1.10.0", + "js-yaml": "^3.11.0", + "lcov-parse": "^0.0.10", + "log-driver": "^1.2.7", + "minimist": "^1.2.0", + "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", + "integrity": "sha512-sk0RTT51t4lUNQ7UfZrqjQx7q4g0m3iwNA6mvyh7gLsgQYvwKzfdyoAgicC9GqJvkoIkU0UmndV9c7VZ8pJ45Q==", + "dev": true, + "requires": { + "es6-promise": "^4.1.1", + "lodash": "^4.17.4", + "semver": "^5.4.1", + "xml2js": "^0.4.19" + }, + "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 + } + } + }, + "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", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "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": "3.0.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", + "integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==", + "dev": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "decode-uri-component": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", + "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", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "dev": true, + "requires": { + "is-descriptor": "^1.0.2", + "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", + "dev": true + }, + "detect-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", + "dev": true, + "requires": { + "repeating": "^2.0.0" + } + }, + "detect-newline": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz", + "integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=", + "dev": true + }, + "diff": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.3.2.tgz", + "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", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "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", + "integrity": "sha1-pfdf/02ZJhJt2sDqXcOOaJFTywI=", + "dev": true, + "requires": { + "string-template": "~0.2.1", + "xtend": "~4.0.0" + } + }, + "es6-promise": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-2.3.0.tgz", + "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" + } + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "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.4.2", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", + "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.0.0" + } + }, + "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", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "eventemitter2": { + "version": "0.4.14", + "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", + "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", + "dev": true + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, + "expand-brackets": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", + "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "dev": true, + "requires": { + "debug": "^2.3.3", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "posix-character-classes": "^0.1.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.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" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "dev": true, + "requires": { + "assign-symbols": "^1.0.0", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "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", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", + "dev": true, + "requires": { + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "extract-zip": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.7.0.tgz", + "integrity": "sha512-xoh5G1W/PB0/27lXgMQyIhP5DSY/LhoCsOyZgb+6iMmRtCwVBo55uKaMoEYrDCKQhWvqEip5ZPKAc6eFNyf/MA==", + "dev": true, + "requires": { + "concat-stream": "^1.6.2", + "debug": "^2.6.9", + "mkdirp": "^0.5.4", + "yauzl": "^2.10.0" + }, + "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" + } + }, + "fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "requires": { + "pend": "~1.2.0" + } + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "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", + "integrity": "sha1-TkkvjQTftviQA1B/btvy1QHnxvQ=", + "dev": true, + "requires": { + "websocket-driver": ">=0.5.1" + } + }, + "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", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "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", + "integrity": "sha1-peeo/7+kk7Q7kju9TKiaU7Y7YSs=", + "dev": true + }, + "fill-range": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", + "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-number": "^3.0.0", + "repeat-string": "^1.6.1", + "to-regex-range": "^2.1.0" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "findup-sync": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", + "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", + "dev": true, + "requires": { + "glob": "~5.0.0" + }, + "dependencies": { + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "2 || 3", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "fined": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fined/-/fined-1.2.0.tgz", + "integrity": "sha512-ZYDqPLGxDkDhDZBjZBb+oD1+j0rA4E0pXY50eplAAOPg2N/gUBSSk5IM1/QhPfyVo19lJ+CvXpqfvk+b2p/8Ng==", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^2.0.3", + "object.defaults": "^1.1.0", + "object.pick": "^1.2.0", + "parse-filepath": "^1.0.1" + } + }, + "flagged-respawn": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", + "integrity": "sha512-lNaHNVymajmk0OJMBn8fVUAU1BtDeKIqKoVhk4xAALB57aALg6b4W0MfJ/cUE0g9YBXy5XhSlPIpYIJ7HaY/3Q==", + "dev": true + }, + "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", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "dev": true + }, + "for-own": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "dev": true, + "requires": { + "for-in": "^1.0.1" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "fragment-cache": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", + "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "dev": true, + "requires": { + "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-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", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "dev": true, + "optional": true, + "requires": { + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" + }, + "dependencies": { + "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, + "optional": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true, + "optional": true + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "dev": true, + "optional": true + }, + "are-we-there-yet": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", + "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==", + "dev": true, + "optional": true, + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^2.0.6" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "optional": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "chownr": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true, + "optional": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "optional": true + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", + "dev": true, + "optional": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true, + "optional": true + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "optional": true, + "requires": { + "ms": "^2.1.1" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "dev": true, + "optional": true + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", + "dev": true, + "optional": true + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "dev": true, + "optional": true + }, + "fs-minipass": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", + "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", + "requires": { + "minipass": "^2.2.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true, + "optional": true + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "dev": true, + "optional": true, + "requires": { + "aproba": "^1.0.3", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.0", + "object-assign": "^4.1.0", + "signal-exit": "^3.0.0", + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wide-align": "^1.1.0" + } + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "optional": 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" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", + "dev": true, + "optional": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "optional": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "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, + "optional": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "optional": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true, + "optional": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "optional": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true, + "optional": true + }, + "minipass": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", + "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", + "optional": 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==", + "requires": { + "minipass": "^2.2.1" + } + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "optional": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true, + "optional": true + }, + "needle": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-2.3.0.tgz", + "integrity": "sha512-QBZu7aAFR0522EyaXZM0FZ9GLpq6lvQ3uq8gteiDUp7wKdy0lSd2hPlgFwVuW1CBkfEs9PfDQsQzZghLs/psdg==", + "dev": true, + "optional": true, + "requires": { + "debug": "^4.1.0", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, + "node-pre-gyp": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.12.0.tgz", + "integrity": "sha512-4KghwV8vH5k+g2ylT+sLTjy5wmUOb9vPhnM8NHvRf9dHmnW/CndrFXy2aRPaPST6dugXSdHXfeaHQm77PIz/1A==", + "dev": true, + "optional": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "dev": true, + "optional": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "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, + "optional": true + }, + "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, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "dev": true, + "optional": true, + "requires": { + "are-we-there-yet": "~1.1.2", + "console-control-strings": "~1.1.0", + "gauge": "~2.7.3", + "set-blocking": "~2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true, + "optional": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "optional": true, + "requires": { + "wrappy": "1" + } + }, + "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, + "optional": 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, + "optional": true + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "dev": true, + "optional": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "optional": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true, + "optional": true + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dev": true, + "optional": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "optional": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "optional": true, + "requires": { + "glob": "^7.1.3" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "optional": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true, + "optional": true + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "dev": true, + "optional": true + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true, + "optional": true + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true, + "optional": true + }, + "string-version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "optional": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "optional": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "optional": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "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, + "optional": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true, + "optional": true + }, + "wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "optional": true, + "requires": { + "string-width": "^1.0.2 || 2" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true, + "optional": 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==", + "optional": true + } + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "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", + "integrity": "sha512-BRdNm8hbWzFzWHERTrejLqwHDfS4GibPoq5wjTPIoJHoBtKGPg3xAFfxmM+9ztbXelxcf2hwQcaz1PtmFeue8g==", + "dev": true, + "requires": { + "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", + "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "dev": true + }, + "getobject": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/getobject/-/getobject-1.0.2.tgz", + "integrity": "sha512-2zblDBaFcb3rB4rF77XVnuINOE2h2k/OnqXAiy0IrTxUfV1iFp3la33oAQVY9pCpWU268WFYVt2t71hlMuLsOg==", + "dev": true + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "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" + } + }, + "glob-parent": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", + "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "dev": true, + "requires": { + "is-glob": "^3.1.0", + "path-dirname": "^1.0.0" + }, + "dependencies": { + "is-glob": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", + "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "dev": true, + "requires": { + "is-extglob": "^2.1.0" + } + } + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "dev": true, + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "globule": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz", + "integrity": "sha512-g7QtgWF4uYSL5/dn71WxubOrS7JVGCnFPEnoeChJmBnyR9Mw8nGoEwOgJL/RC2Te0WhbsEUCejfH8SZNJ+adYQ==", + "dev": true, + "requires": { + "glob": "~7.1.1", + "lodash": "~4.17.10", + "minimatch": "~3.0.2" + }, + "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" + } + } + } + }, + "graceful-fs": { + "version": "4.1.15", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "dev": true + }, + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true + }, + "grunt": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/grunt/-/grunt-1.5.3.tgz", + "integrity": "sha512-mKwmo4X2d8/4c/BmcOETHek675uOqw0RuA/zy12jaspWqvTp4+ZeQF1W+OTpcbncnaBsfbQJ6l0l4j+Sn/GmaQ==", + "dev": true, + "requires": { + "dateformat": "~3.0.3", + "eventemitter2": "~0.4.13", + "exit": "~0.1.2", + "findup-sync": "~0.3.0", + "glob": "~7.1.6", + "grunt-cli": "~1.4.3", + "grunt-known-options": "~2.0.0", + "grunt-legacy-log": "~3.0.0", + "grunt-legacy-util": "~2.0.1", + "iconv-lite": "~0.4.13", + "js-yaml": "~3.14.0", + "minimatch": "~3.0.4", + "mkdirp": "~1.0.4", + "nopt": "~3.0.6", + "rimraf": "~3.0.2" + }, + "dependencies": { + "grunt-cli": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.4.3.tgz", + "integrity": "sha512-9Dtx/AhVeB4LYzsViCjUQkd0Kw0McN2gYpdmGYKtE2a5Yt7v1Q+HYZVWhqXc/kGnxlMtqKDxSwotiGeFmkrCoQ==", + "dev": true, + "requires": { + "grunt-known-options": "~2.0.0", + "interpret": "~1.1.0", + "liftup": "~3.0.1", + "nopt": "~4.0.1", + "v8flags": "~3.2.0" + }, + "dependencies": { + "nopt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", + "dev": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + } + } + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "grunt-autoprefixer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/grunt-autoprefixer/-/grunt-autoprefixer-3.0.4.tgz", + "integrity": "sha1-/kLiR7z6ucKSoSwGLa1PNb3pAsU=", + "dev": true, + "requires": { + "autoprefixer-core": "^5.1.7", + "chalk": "~1.0.0", + "diff": "~1.3.0", + "postcss": "^4.1.11" + }, + "dependencies": { + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.0.0.tgz", + "integrity": "sha1-s89O0P9Tl8mcdbj2edsvUoMfltw=", + "dev": true, + "requires": { + "ansi-styles": "^2.0.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^1.0.3", + "strip-ansi": "^2.0.1", + "supports-color": "^1.3.0" + } + }, + "supports-color": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", + "integrity": "sha1-FXWN8J2P87SswwdTn6vicJXhBC0=", + "dev": true + } + } + }, + "grunt-contrib-clean": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-clean/-/grunt-contrib-clean-2.0.0.tgz", + "integrity": "sha512-g5ZD3ORk6gMa5ugZosLDQl3dZO7cI3R14U75hTM+dVLVxdMNJCPVmwf9OUt4v4eWgpKKWWoVK9DZc1amJp4nQw==", + "dev": true, + "requires": { + "async": "^2.6.1", + "rimraf": "^2.6.2" + }, + "dependencies": { + "async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + } + } + }, + "grunt-contrib-coffee": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-coffee/-/grunt-contrib-coffee-2.1.0.tgz", + "integrity": "sha512-lgP+pPY3mHl+gqAU0T+7BcocBWu0FyeeJnAG/iIp2I0GPa5LvZJ7Wqga6QwKQtQCTs+1gPEa12nuap9Lj08lhw==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "coffeescript": "^2.3.2", + "lodash": "^4.17.11", + "uri-path": "^1.0.0" + }, + "dependencies": { + "coffeescript": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-2.4.1.tgz", + "integrity": "sha512-34GV1aHrsMpTaO3KfMJL40ZNuvKDR/g98THHnE9bQj8HjMaZvSrLik99WWqyMhRtbe8V5hpx5iLgdcSvM/S2wg==", + "dev": true + } + } + }, + "grunt-contrib-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/grunt-contrib-concat/-/grunt-contrib-concat-1.0.1.tgz", + "integrity": "sha1-YVCYYwhOhx1+ht5IwBUlntl3Rb0=", + "dev": true, + "requires": { + "chalk": "^1.0.0", + "source-map": "^0.5.3" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "grunt-contrib-copy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-copy/-/grunt-contrib-copy-1.0.0.tgz", + "integrity": "sha1-cGDGWB6QS4qw0A8HbgqPbj58NXM=", + "dev": true, + "requires": { + "chalk": "^1.1.1", + "file-sync-cmp": "^0.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "grunt-contrib-cssmin": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/grunt-contrib-cssmin/-/grunt-contrib-cssmin-3.0.0.tgz", + "integrity": "sha512-eXpooYmVGKMs/xV7DzTLgJFPVOfMuawPD3x0JwhlH0mumq2NtH3xsxaHxp1Y3NKxp0j0tRhFS6kSBRsz6TuTGg==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "clean-css": "~4.2.1", + "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 + } + } + }, + "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", + "integrity": "sha512-yGweN+0DW5yM+oo58fRu/XIRrPcn3r4tQx+nL7eMRwjpvk+rQY6R8o94BPK0i2UhTg9FN21hS+m8vR8v9vXfeg==", + "dev": true, + "requires": { + "async": "^2.6.0", + "gaze": "^1.1.0", + "lodash": "^4.17.10", + "tiny-lr": "^1.1.1" + }, + "dependencies": { + "async": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + } + } + }, + "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": "2.0.0", + "resolved": "https://registry.npmjs.org/grunt-known-options/-/grunt-known-options-2.0.0.tgz", + "integrity": "sha512-GD7cTz0I4SAede1/+pAbmJRG44zFLPipVtdL9o3vqx9IEyb7b4/Y3s7r6ofI3CchR5GvYJ+8buCSioDv5dQLiA==", + "dev": true + }, + "grunt-legacy-log": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-3.0.0.tgz", + "integrity": "sha512-GHZQzZmhyq0u3hr7aHW4qUH0xDzwp2YXldLPZTCjlOeGscAOWWPftZG3XioW8MasGp+OBRIu39LFx14SLjXRcA==", + "dev": true, + "requires": { + "colors": "~1.1.2", + "grunt-legacy-log-utils": "~2.1.0", + "hooker": "~0.2.3", + "lodash": "~4.17.19" + } + }, + "grunt-legacy-log-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-2.1.0.tgz", + "integrity": "sha512-lwquaPXJtKQk0rUM1IQAop5noEpwFqOXasVoedLeNzaibf/OPWjKYvvdqnEHNmU+0T0CaReAXIbGo747ZD+Aaw==", + "dev": true, + "requires": { + "chalk": "~4.1.0", + "lodash": "~4.17.19" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "grunt-legacy-util": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-2.0.1.tgz", + "integrity": "sha512-2bQiD4fzXqX8rhNdXkAywCadeqiPiay0oQny77wA2F3WF4grPJXCvAcyoWUJV+po/b15glGkxuSiQCK299UC2w==", + "dev": true, + "requires": { + "async": "~3.2.0", + "exit": "~0.1.2", + "getobject": "~1.0.0", + "hooker": "~0.2.3", + "lodash": "~4.17.21", + "underscore.string": "~3.3.5", + "which": "~2.0.2" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "grunt-ts": { + "version": "6.0.0-beta.22", + "resolved": "https://registry.npmjs.org/grunt-ts/-/grunt-ts-6.0.0-beta.22.tgz", + "integrity": "sha512-g9e+ZImQ7W38dfpwhp0+GUltXWidy3YGPfIA/IyGL5HMv6wmVmMMoSgscI5swhs2HSPf8yAvXAAJbwrouijoRg==", + "dev": true, + "requires": { + "chokidar": "^2.0.4", + "csproj2ts": "^1.1.0", + "detect-indent": "^4.0.0", + "detect-newline": "^2.1.0", + "es6-promise": "~0.1.1", + "jsmin2": "^1.2.1", + "lodash": "~4.17.10", + "ncp": "0.5.1", + "rimraf": "2.2.6", + "semver": "^5.3.0", + "strip-bom": "^2.0.0" + }, + "dependencies": { + "es6-promise": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-0.1.2.tgz", + "integrity": "sha1-8RLCn+paCZhTn8tqL9IUQ9KPBfc=", + "dev": true + }, + "rimraf": { + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz", + "integrity": "sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w=", + "dev": true + } + } + }, + "gzip-size": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz", + "integrity": "sha1-VGGI6b3DN/Zzdy+BZgRks4nc5SA=", + "dev": true, + "requires": { + "duplexer": "^0.1.1" + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-ansi": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-1.0.3.tgz", + "integrity": "sha1-wLWxYV2eOCsP9nFp2We0JeSMpTg=", + "dev": true, + "requires": { + "ansi-regex": "^1.1.0", + "get-stdin": "^4.0.1" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "has-value": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", + "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "dev": true, + "requires": { + "get-value": "^2.0.6", + "has-values": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "has-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", + "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "kind-of": "^4.0.0" + }, + "dependencies": { + "kind-of": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", + "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "dev": true, + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "hooker": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", + "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", + "dev": true + }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "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==", + "dev": true + }, + "http-parser-js": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.0.tgz", + "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", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + } + }, + "https-proxy-agent": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", + "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", + "dev": true, + "requires": { + "agent-base": "^4.3.0", + "debug": "^3.1.0" + }, + "dependencies": { + "agent-base": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", + "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", + "dev": true, + "requires": { + "es6-promisify": "^5.0.0" + } + }, + "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", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "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 + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ini": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", + "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-^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" + } + } + } + }, + "interpret": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", + "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", + "dev": true + }, + "ip": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", + "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "dev": true + }, + "is-absolute": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "dev": true, + "requires": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + } + }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "^1.0.0" + } + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-core-module": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } + } + }, + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "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", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", + "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "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-relative": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "dev": true, + "requires": { + "is-unc-path": "^1.0.0" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-unc-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "dev": true, + "requires": { + "unc-path-regex": "^0.1.2" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "jasmine-sinon": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/jasmine-sinon/-/jasmine-sinon-0.4.0.tgz", + "integrity": "sha1-gECheaAa4DSbI0ruQ4wkGRI5rpg=", + "dev": true, + "requires": { + "sinon": ">= 1.7.1" + } + }, + "jquery": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.0.tgz", + "integrity": "sha512-Xb7SVYMvygPxbFMpTFQiHh1J7HClEaThguL15N/Gg37Lri/qKyhRGZYzHRyLH8Stq3Aow0LsHO2O2ci86fCrNQ==", + "dev": true + }, + "js-base64": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.1.9.tgz", + "integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "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 + } + } + }, + "jsmin2": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/jsmin2/-/jsmin2-1.2.1.tgz", + "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.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "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 + }, + "jsprim": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.4.0", + "verror": "1.10.0" + } + }, + "just-extend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", + "integrity": "sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + }, + "lcov-parse": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.10.tgz", + "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" + } + }, + "liftup": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/liftup/-/liftup-3.0.1.tgz", + "integrity": "sha512-yRHaiQDizWSzoXk3APcA71eOI/UuhEkNN9DiW2Tt44mhYzX4joFoCZlxsSOF7RyeLlfqzFLQI1ngFq3ggMPhOw==", + "dev": true, + "requires": { + "extend": "^3.0.2", + "findup-sync": "^4.0.0", + "fined": "^1.2.0", + "flagged-respawn": "^1.0.1", + "is-plain-object": "^2.0.4", + "object.map": "^1.0.1", + "rechoir": "^0.7.0", + "resolve": "^1.19.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "findup-sync": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-4.0.0.tgz", + "integrity": "sha512-6jvvn/12IC4quLBL1KNokxC7wWTvYncaVUYSoxWw7YykPLuRrnv4qdHcSOywOI5RpkOVGeQRtWM8/q+G6W6qfQ==", + "dev": true, + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.0", + "micromatch": "^4.0.2", + "resolve-dir": "^1.0.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "resolve": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "dev": true, + "requires": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, + "livereload-js": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.4.0.tgz", + "integrity": "sha512-XPQH8Z2GDP/Hwz2PCDrh2mth4yFejwA1OZ/81Ti3LgKyhDcEjsSsqFWZojHG0va/duGd+WyosY7eXLDoOyqcPw==", + "dev": true + }, + "load-grunt-tasks": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/load-grunt-tasks/-/load-grunt-tasks-5.0.0.tgz", + "integrity": "sha512-ga8vBA/+JVUB0Q/De9Id75maCIAzSgELWisBkBwxfDpU03fgYH5Ae1Do35hvfothsLWQCjPaTeG1Nya/CQr3gw==", + "dev": true, + "requires": { + "arrify": "^2.0.1", + "multimatch": "^4.0.0", + "pkg-up": "^3.1.0", + "resolve-pkg": "^2.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "dependencies": { + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true + } + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "log-driver": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", + "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", + "dev": true + }, + "lolex": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-4.0.1.tgz", + "integrity": "sha512-UHuOBZ5jjsKuzbB/gRNNW8Vg8f00Emgskdq2kvZxgBJCS0aqquAuXai/SkWORlKeZEiNQWZjFZOqIUcH9LqKCw==", + "dev": true + }, + "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" + } + }, + "make-iterator": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "dev": true + }, + "map-visit": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", + "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "dev": true, + "requires": { + "object-visit": "^1.0.0" + } + }, + "maxmin": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/maxmin/-/maxmin-2.1.0.tgz", + "integrity": "sha1-TTsiCQPZXu5+t6x/qGTnLcCaMWY=", + "dev": true, + "requires": { + "chalk": "^1.0.0", + "figures": "^1.0.1", + "gzip-size": "^3.0.0", + "pretty-bytes": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "micromatch": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "braces": "^2.3.1", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "extglob": "^2.0.4", + "fragment-cache": "^0.2.1", + "kind-of": "^6.0.2", + "nanomatch": "^1.2.9", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "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", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "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.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.8.tgz", + "integrity": "sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "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" + } + }, + "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.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", + "dev": true, + "requires": { + "for-in": "^1.0.2", + "is-extendable": "^1.0.1" + }, + "dependencies": { + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4" + } + } + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true + }, + "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" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + } + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "multimatch": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-4.0.0.tgz", + "integrity": "sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==", + "dev": true, + "requires": { + "@types/minimatch": "^3.0.3", + "array-differ": "^3.0.0", + "array-union": "^2.1.0", + "arrify": "^2.0.1", + "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", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, + "nanomatch": { + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", + "dev": true, + "requires": { + "arr-diff": "^4.0.0", + "array-unique": "^0.3.2", + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "fragment-cache": "^0.2.1", + "is-windows": "^1.0.2", + "kind-of": "^6.0.2", + "object.pick": "^1.3.0", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "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", + "integrity": "sha512-sa0RRbj53dovjc7wombHmVli9ZihXbXCQ2uH3TNm03DyvOSIQbxg+pbqDKrk2oxMK1rtLGVlKxcB9rrc6X5YjA==", + "dev": true, + "requires": { + "@sinonjs/formatio": "^3.1.0", + "@sinonjs/text-encoding": "^0.7.1", + "just-extend": "^4.0.2", + "lolex": "^2.3.2", + "path-to-regexp": "^1.7.0" + }, + "dependencies": { + "lolex": { + "version": "2.7.5", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.7.5.tgz", + "integrity": "sha512-l9x0+1offnKKIzYVjyXU2SiwhXDLekRzKyhnbyldPHvC7BvLPVpdNUNR2KeMAiCN2D/kLNttZgQD5WjSxuBx3Q==", + "dev": true + } + } + }, + "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", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "1" + } + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "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", + "integrity": "sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4=", + "dev": true + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-copy": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", + "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "dev": true, + "requires": { + "copy-descriptor": "^0.1.0", + "define-property": "^0.2.5", + "kind-of": "^3.0.3" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "object-visit": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", + "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "dev": true, + "requires": { + "isobject": "^3.0.0" + } + }, + "object.defaults": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "dev": true, + "requires": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "object.map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "dev": true, + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "once": { + "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" + } + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + } + } + }, + "parallel-transform": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", + "integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", + "dev": true, + "requires": { + "cyclist": "~0.2.2", + "inherits": "^2.0.3", + "readable-stream": "^2.1.5" + } + }, + "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==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-filepath": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "dev": true, + "requires": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, + "pascalcase": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", + "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "dev": true + }, + "path-dirname": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", + "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "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.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "dev": true, + "requires": { + "path-root-regex": "^0.1.0" + } + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", + "dev": true + }, + "path-to-regexp": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "dev": true, + "requires": { + "isarray": "0.0.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 + } + } + }, + "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", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, + "pkg-up": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", + "integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + } + } + }, + "posix-character-classes": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", + "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "dev": true + }, + "postcss": { + "version": "4.1.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-4.1.16.tgz", + "integrity": "sha1-TESbTIr53zyvbTf44eV10DYXWNw=", + "dev": true, + "requires": { + "es6-promise": "~2.3.0", + "js-base64": "~2.1.8", + "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", + "integrity": "sha1-J9AAjXeAY6C0gRuzXHnxvV1fvM8=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "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", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "qs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "dev": true + }, + "raw-body": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.7.tgz", + "integrity": "sha1-HQJ8K/oRasxmI7yo8AAWVyqH1CU=", + "dev": true, + "requires": { + "bytes": "1", + "string_decoder": "0.10" + }, + "dependencies": { + "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 + } + } + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "readdirp": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" + } + }, + "rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", + "dev": true, + "requires": { + "resolve": "^1.9.0" + } + }, + "regex-not": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.2", + "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", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "repeat-element": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "^1.0.0" + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + } + }, + "resolve": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.0.tgz", + "integrity": "sha512-WL2pBDjqT6pGUNSUzMw00o4T7If+z4H2x3Gz893WoUQ5KW8Vr9txp00ykiP16VBaZF5+j/OcXJHZ9+PCvdiDKw==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "dev": true, + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "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", + "integrity": "sha512-+1lzwXehGCXSeryaISr6WujZzowloigEofRB+dj75y9RRa/obVcYgbHJd53tdYw8pvZj8GojXaaENws8Ktw/hQ==", + "dev": true, + "requires": { + "resolve-from": "^5.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + } + } + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "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", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + }, + "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" + } + } + } + }, + "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", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "safe-json-parse": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-1.0.1.tgz", + "integrity": "sha1-PnZyPjjf3aE8mx0poeB//uSzC1c=", + "dev": true + }, + "safe-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "dev": true, + "requires": { + "ret": "~0.1.10" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", + "dev": true + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "dev": true + }, + "set-value": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", + "dev": true, + "requires": { + "extend-shallow": "^2.0.1", + "is-extendable": "^0.1.1", + "is-plain-object": "^2.0.3", + "split-string": "^3.0.1" + }, + "dependencies": { + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + } + } + }, + "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", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "sinon": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-7.3.2.tgz", + "integrity": "sha512-thErC1z64BeyGiPvF8aoSg0LEnptSaWE7YhdWWbWXgelOyThent7uKOnnEh9zBxDbKixtr5dEko+ws1sZMuFMA==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.4.0", + "@sinonjs/formatio": "^3.2.1", + "@sinonjs/samsam": "^3.3.1", + "diff": "^3.5.0", + "lolex": "^4.0.1", + "nise": "^1.4.10", + "supports-color": "^5.5.0" + }, + "dependencies": { + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + } + } + }, + "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", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "dev": true, + "requires": { + "base": "^0.11.1", + "debug": "^2.2.0", + "define-property": "^0.2.5", + "extend-shallow": "^2.0.1", + "map-cache": "^0.2.2", + "source-map": "^0.5.6", + "source-map-resolve": "^0.5.0", + "use": "^3.1.0" + }, + "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" + } + }, + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "snapdragon-node": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "dev": true, + "requires": { + "define-property": "^1.0.0", + "isobject": "^3.0.0", + "snapdragon-util": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } + } + }, + "snapdragon-util": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "dev": true, + "requires": { + "kind-of": "^3.2.0" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "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", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "source-map-resolve": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "dev": true, + "requires": { + "atob": "^2.1.1", + "decode-uri-component": "^0.2.0", + "resolve-url": "^0.2.1", + "source-map-url": "^0.4.0", + "urix": "^0.1.0" + } + }, + "source-map-url": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", + "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "dev": true + }, + "spdx-correct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz", + "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", + "dev": true + }, + "split-string": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "dev": true, + "requires": { + "extend-shallow": "^3.0.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "sshpk": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", + "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + } + }, + "ssri": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-6.0.2.tgz", + "integrity": "sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==", + "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", + "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "dev": true, + "requires": { + "define-property": "^0.2.5", + "object-copy": "^0.1.0" + }, + "dependencies": { + "define-property": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", + "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "dev": true, + "requires": { + "is-descriptor": "^0.1.0" + } + } + } + }, + "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", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-2.0.1.tgz", + "integrity": "sha1-32LBqpTtLxFOHQ8h/R1QSCt5pg4=", + "dev": true, + "requires": { + "ansi-regex": "^1.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "^0.2.0" + } + }, + "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", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, + "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.19", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.19.tgz", + "integrity": "sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==", + "dev": true, + "requires": { + "chownr": "^1.1.4", + "fs-minipass": "^1.2.7", + "minipass": "^2.9.0", + "minizlib": "^1.3.3", + "mkdirp": "^0.5.5", + "safe-buffer": "^5.2.1", + "yallist": "^3.1.1" + }, + "dependencies": { + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "dev": true + }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "dev": true, + "requires": { + "minipass": "^2.6.0" + } + }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "dev": true, + "requires": { + "minipass": "^2.9.0" + } + }, + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + } + } + }, + "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", + "integrity": "sha512-44yhA3tsaRoMOjQQ+5v5mVdqef+kH6Qze9jTpqtVufgYjYt08zyZAwNwwVBj3i1rJMnR52IxOW0LK0vBzgAkuA==", + "dev": true, + "requires": { + "body": "^5.1.0", + "debug": "^3.1.0", + "faye-websocket": "~0.10.0", + "livereload-js": "^2.3.0", + "object-assign": "^4.1.0", + "qs": "^6.4.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" + } + } + } + }, + "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-object-path": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", + "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "dev": true, + "requires": { + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } + } + }, + "to-regex": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "dev": true, + "requires": { + "define-property": "^2.0.2", + "extend-shallow": "^3.0.2", + "regex-not": "^1.0.2", + "safe-regex": "^1.1.0" + } + }, + "to-regex-range": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", + "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "dev": true, + "requires": { + "is-number": "^3.0.0", + "repeat-string": "^1.6.1" + } + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } + } + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "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==", + "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 + } + } + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", + "dev": true + }, + "underscore.string": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.3.6.tgz", + "integrity": "sha512-VoC83HWXmCrF6rgkyxS9GHv8W9Q5nhMKho+OadDJGzL2oDYbYEppBaCMH6pFlwLeqj2QS+hhkw2kpXkSdD1JxQ==", + "dev": true, + "requires": { + "sprintf-js": "^1.1.1", + "util-deprecate": "^1.0.2" + }, + "dependencies": { + "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 + } + } + }, + "union-value": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", + "dev": true, + "requires": { + "arr-union": "^3.1.0", + "get-value": "^2.0.6", + "is-extendable": "^0.1.1", + "set-value": "^2.0.1" + } + }, + "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", + "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "dev": true, + "requires": { + "has-value": "^0.3.1", + "isobject": "^3.0.0" + }, + "dependencies": { + "has-value": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", + "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "dev": true, + "requires": { + "get-value": "^2.0.3", + "has-values": "^0.1.4", + "isobject": "^2.0.0" + }, + "dependencies": { + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "dev": true, + "requires": { + "isarray": "1.0.0" + } + } + } + }, + "has-values": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", + "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "dev": true + } + } + }, + "upath": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", + "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", + "dev": true + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "uri-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/uri-path/-/uri-path-1.0.0.tgz", + "integrity": "sha1-l0fwGDWJM8Md4PzP2C0TjmcmLjI=", + "dev": true + }, + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "dev": true + }, + "use": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + }, + "v8flags": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "dev": true, + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "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", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "websocket-driver": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz", + "integrity": "sha1-DK+dLXVdk67gSdS90NP+LMoqJOs=", + "dev": true, + "requires": { + "http-parser-js": ">=0.4.0", + "websocket-extensions": ">=0.1.1" + } + }, + "websocket-extensions": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", + "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", + "dev": true + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "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" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "requires": { + "minimist": "^1.2.6" + } + } + } + }, + "ws": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", + "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "dev": true, + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + }, + "y18n": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", + "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 + } + } +} diff --git a/package.json b/package.json index 2b412fe9..13a74767 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "type": "git", "url": "https://github.com/jabbany/CommentCoreLibrary.git" }, + "homepage": "https://github.com/jabbany/CommentCoreLibrary#readme", "author": "Jim Chen ", "license": "MIT", "keywords": [ @@ -21,25 +22,31 @@ "danmu" ], "main": "dist/CommentCoreLibrary.js", - "version": "0.11.0", + "version": "0.11.1", "devDependencies": { - "coveralls": "^3.0.1", - "grunt": "^1.0.3", + "coveralls": "^3.0.3", + "grunt": "^1.0.4", "grunt-autoprefixer": "^3.0.4", - "grunt-contrib-clean": "^1.0.0", - "grunt-contrib-coffee": "^2.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": "^2.2.1", - "grunt-contrib-jasmine": "^2.0.1", - "grunt-contrib-jshint": "^1.0.0", - "grunt-contrib-uglify": "^3.3.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.19", + "grunt-ts": "^6.0.0-beta.22", "jasmine-sinon": "^0.4.0", - "jquery": "^3.3.1", - "load-grunt-tasks": "^4.0.0", - "sinon": "^6.0.0", - "typescript": "^2.9.2" + "jquery": "^3.4.1", + "load-grunt-tasks": "^5.0.0", + "sinon": "^7.3.2", + "typescript": "^3.4.5" + }, + "scripts": { + "build": "npm install && grunt", + "start": "grunt watch", + "test": "grunt && grunt test", + "ci": "grunt ci" } } diff --git a/spec/CommentCoreLibrary_spec.coffee b/spec/CommentCoreLibrary_spec.coffee index 17fb66c1..2debd999 100644 --- a/spec/CommentCoreLibrary_spec.coffee +++ b/spec/CommentCoreLibrary_spec.coffee @@ -60,7 +60,7 @@ describe 'CommentManager', -> expect(manager.timeline).toEqual [c1, c2, c3, c4, c5] it 'smoking test', -> - sampleNormal = + sampleNormal = """ 关了弹幕瞬间好多了 @@ -89,14 +89,16 @@ describe 'CommentManager', -> spy = sinon.spy manager, 'send' manager.load [ c3, c4, c5 ] manager.time 3 - expect(spy).toHaveBeenCalledThrice() + expect(spy).toHaveBeenCalledOnce() + expect(spy).toHaveBeenCalledWith([ c3, c4, c5 ]) it 'limits based on limiter', -> spy = sinon.spy manager, 'send' manager.load [ c3, c4, c5 ] manager.options.limit = 2 manager.time 3 - expect(spy).toHaveBeenCalledTwice() + expect(spy).toHaveBeenCalledOnce() + expect(spy).toHaveBeenCalledWith([ c3, c4 ]) it 'seeks if seek threshold is passed', -> manager.load [ c1 ] diff --git a/src/Array.js b/src/Array.js index 935c4dd1..1d3b0ee2 100644 --- a/src/Array.js +++ b/src/Array.js @@ -4,68 +4,67 @@ * @author Jim Chen */ var BinArray = (function () { + var BinArray = {}; - 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; + }; - /** - * 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; + }; - /** - * 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; + return BinArray; })(); diff --git a/src/CommentManager.js b/src/CommentManager.js index afa693d5..12c35620 100644 --- a/src/CommentManager.js +++ b/src/CommentManager.js @@ -6,283 +6,299 @@ * 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; - } + 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; } - }; - - 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; + return 0; + } else { + return 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) - }; + function CommentManager(stageObject){ + var __timer = 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; - }; - } + this._listeners = {}; + this._lastPosition = 0; - /** Public **/ - CommentManager.prototype.stop = function(){ - this._stopTimer(); - // Send stop signal to all comments - this.runline.forEach(function (c) { c.stop(); }); + 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; - CommentManager.prototype.start = function(){ - this._startTimer(); + 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) }; - 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; - } - }); + /** 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); }; - - CommentManager.prototype.validate = function(cmt){ - if (cmt == null) { - return false; - } - return this.filter.doValidate(cmt); + this._stopTimer = function () { + window.clearInterval(__timer); + __timer = 0; }; + } - CommentManager.prototype.load = function(a){ - this.timeline = a; - this.timeline.sort(_defaultComparator); - this.dispatchEvent("load"); - }; + /** Public **/ + CommentManager.prototype.stop = function(){ + this._stopTimer(); + // Send stop signal to all comments + this.runline.forEach(function (c) { c.stop(); }); + }; - CommentManager.prototype.insert = function(c){ - var index = BinArray.binsert(this.timeline, c, _defaultComparator); - if (index <= this.position) { - this.position++; - } - this.dispatchEvent("insert"); - }; + CommentManager.prototype.start = function(){ + this._startTimer(); + }; - CommentManager.prototype.clear = function () { - while (this.runline.length> 0) { - this.runline[0].finish(); - } - this.dispatchEvent("clear"); - }; + 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.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.validate = function(cmt){ + if (cmt == null) { + return false; + } + return this.filter.doValidate(cmt); + }; - 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.load = function(a){ + this.timeline = a; + this.timeline.sort(_defaultComparator); + this.dispatchEvent("load"); + }; - CommentManager.prototype.time = function (time) { - time = time - 1; - if (this.position>= this.timeline.length || - Math.abs(this._lastPosition - time)>= this.options.seekTrigger) { + CommentManager.prototype.insert = function(c){ + var index = BinArray.binsert(this.timeline, c, _defaultComparator); + if (index <= this.position) { + this.position++; + } + this.dispatchEvent("insert"); + }; - this.seek(time); - this._lastPosition = time; - if (this.timeline.length <= this.position) { - return; - } - } else { - this._lastPosition = time; - } - for (;this.position < this.timeline.length;this.position++) { - if (this.timeline[this.position]['stime']<=time) { - if (this.options.limit> 0 && this.runline.length>= this.options.limit) { - continue; // Skip comments but still move the position pointer - } else if (this.validate(this.timeline[this.position])) { - this.send(this.timeline[this.position]); - } - } else { - break; - } - } - }; + CommentManager.prototype.clear = function () { + while (this.runline.length> 0) { + this.runline[0].finish(); + } + this.dispatchEvent("clear"); + }; - CommentManager.prototype.rescale = function () { - // TODO: Implement rescaling - }; + 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.send = function (data) { - if (data.mode === 8) { - console.log(data); - if (this.scripting) { - console.log(this.scripting.eval(data.code)); - } - return; - } - if (this.filter != null) { - data = this.filter.doModify(data); - if (data == null) { - return; - } - } - var cmt = this.factory.create(this, data); - 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; - } - cmt.y = cmt.y; - this.dispatchEvent("enterComment", cmt); - this.runline.push(cmt); - }; + 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.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.time = function (time) { + time = time - 1; + if (this.position>= this.timeline.length || + Math.abs(this._lastPosition - time)>= this.options.seekTrigger) { - CommentManager.prototype.addEventListener = function (event, listener) { - if (typeof this._listeners[event] !== "undefined") { - this._listeners[event].push(listener); - } else { - this._listeners[event] = [listener]; - } - }; + 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) { - 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); - } - } + 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); + } + }; - /** 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); + 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); } - }; + } + } + }; - return CommentManager; + /** 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 index e0199708..11af742a 100644 --- a/src/CommentProvider.js +++ b/src/CommentProvider.js @@ -7,345 +7,345 @@ var CommentProvider = (function () { - function CommentProvider () { - this._started = false; - this._destroyed = false; - this._staticSources = {}; - this._dynamicSources = {}; - this._parsers = {} - this._targets = []; - } + 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'; + 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('&'); - } + /** + * 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.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.onerror = function () { + reject(new Error(this.status + " " + this.statusText)); + }; - xhr.open(method, uri); + xhr.open(method, uri); - // Limit the response type based on input - xhr.responseType = typeof responseType === "string" ? - responseType : ""; + // Limit the response type based on input + xhr.responseType = typeof responseType === "string" ? + responseType : ""; - if (typeof body !== 'undefined') { - xhr.send(body); - } else { - xhr.send(); - } - }); - }; + 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 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 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; - }); - }; + /** + * 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 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 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; + }; - /** - * 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.'); + /** + * 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 (!(commentManager instanceof CommentManager)) { - throw new Error( - 'Expected the target to be an instance of CommentManager.'); + if (output !== null) { + resolve(output); + return; } - this._targets.push(commentManager); - return this; - }; + } + reject(new Error("Ran out of parsers for they target type")); + }.bind(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.'); + 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 (!(type in this._parsers)) { - this._parsers[type] = []; + if (output !== null) { + resolve(output); + return; } - this._parsers[type].unshift(parser); - return this; - }; + } + reject(new Error("Ran out of parsers for the target type")); + }.bind(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)); + }; - /** - * (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) { + /** + * 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].load(commentList); + this._targets[i].send( + this.applyParserOne(data, type)); } - return Promise.resolve(commentList); + }.bind(this)); }.bind(this)); - }; + } + 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'); - }; + /** + * 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(); - }; + /** + * 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; + return CommentProvider; })(); diff --git a/src/Promises.js b/src/Promises.js index 53b3dfa9..b45a8fef 100644 --- a/src/Promises.js +++ b/src/Promises.js @@ -5,50 +5,50 @@ */ var Promises = (function( ) { - var Promises = {}; + 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)); + /** + * 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; + return Promises; })(); diff --git a/src/core/Comment.ts b/src/core/Comment.ts index bead75e7..4f9b1972 100644 --- a/src/core/Comment.ts +++ b/src/core/Comment.ts @@ -27,8 +27,7 @@ class CoreComment implements IComment { private _motionEnd:Array; private _alphaMotion:Object = null; - public _x:number; - public _y:number; + /** * Absolute coordinates. Use absolute coordinates if true otherwise use percentages. @@ -46,15 +45,19 @@ class CoreComment implements IComment { */ 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; + protected _x:number; + protected _y:number; + + protected _alpha:number = 1; + protected _size:number = 25; + protected _width:number; + protected _height:number; + protected _color:number = 0xffffff; + protected _border:boolean = false; + protected _shadow:boolean = true; + protected _font:string = ''; + protected _transform:CommentUtils.Matrix3D = null; + protected _className:string = ''; public parent:ICommentManager; public dom:HTMLDivElement; @@ -146,6 +149,29 @@ class CoreComment implements IComment { } } } + if (init.hasOwnProperty('className')) { + this._className = init['className']; + } + } + + 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(' '); + } + } } /** @@ -158,11 +184,14 @@ class CoreComment implements IComment { } 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; + this.className = this._className; + if (this._color != 0xffffff) { this.color = this._color; } @@ -246,14 +275,14 @@ class CoreComment implements IComment { } get width():number { - if (this._width === null || this._width === undefined) { + if (typeof this._width === 'undefined' || this._width === null) { this._width = this.dom.offsetWidth; } return this._width; } get height():number { - if (this._height === null || this._height === undefined) { + if (typeof this._height === 'undefined' || this._height === null) { this._height = this.dom.offsetHeight; } return this._height; @@ -287,6 +316,10 @@ class CoreComment implements IComment { return this._transform.flatArray; } + get className():string { + return this._className; + } + set x(x:number) { this._x = x; if (!this.absolute) { @@ -332,13 +365,14 @@ class CoreComment implements IComment { color = color.length>= 6 ? color : new Array(6 - color.length + 1).join('0') + color; this.dom.style.color = '#' + color; if (this._color === 0) { - this.dom.className = this.parent.options.global.className + ' rshadow'; + 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) + ''; + this.dom.style.opacity = + Math.min(this._alpha, this.parent.options.global.opacity) + ''; } set border(b:boolean) { @@ -353,7 +387,7 @@ class CoreComment implements IComment { set shadow(s:boolean) { this._shadow = s; if (!this._shadow) { - this.dom.className = this.parent.options.global.className + ' noshadow'; + this._toggleClass('no-shadow', true); } } @@ -373,6 +407,11 @@ class CoreComment implements IComment { } } + set className(className:string) { + this._className = className; + this.dom.className = this.parent.options.global.className + ' ' + className; + } + /** * Moves the comment by a number of milliseconds. When * the given parameter is greater than 0 the comment moves @@ -419,7 +458,11 @@ class CoreComment implements IComment { 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); + this[prop] = m.easing( + Math.min(Math.max(time - m.delay, 0), m.dur), + m.from, + m.to - m.from, + m.dur); } } } @@ -430,7 +473,11 @@ class CoreComment implements IComment { */ public animate():void { if (this._alphaMotion) { - this.alpha = (this.dur - this.ttl) * (this._alphaMotion['to'] - this._alphaMotion['from']) / this.dur + this._alphaMotion['from']; + this.alpha = + (this.dur - this.ttl) * + (this._alphaMotion['to'] - this._alphaMotion['from']) / + this.dur + + this._alphaMotion['from']; } if (this.motion.length === 0) { return; diff --git a/src/core/CommentUtils.ts b/src/core/CommentUtils.ts index 65b20b1b..5e6ed429 100644 --- a/src/core/CommentUtils.ts +++ b/src/core/CommentUtils.ts @@ -17,22 +17,31 @@ module CommentUtils { return new Matrix3D([xscale, 0, 0, 0, 0, yscale, 0, 0, 0, 0, zscale, 0, 0, 0, 0, 1]); }; + /** + * Create a 3d rotation matrix from degrees of rotation specified + * This uses eulerAngles as the orientation + * + * @param {number} xrot Rotate along x-axis + * @param {number} yrot Rotate along y-axis + * @param {number} zrot Rotate along z-axis + * @return {Matrix3D} Rotation matrix + */ 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; + const COS = Math.cos; + const SIN = Math.sin; + const DEG2RAD = Math.PI/180; + + var xr = xrot * DEG2RAD; 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 + COS(yr) * COS(zr) , COS(yr) * SIN(zr) , - SIN(yr) , 0, + SIN(xr) * SIN(yr) * COS(zr) - COS(xr) * SIN(zr) , SIN(xr) * SIN(yr) * SIN(zr) + COS(xr) * COS(zr) , SIN(xr) * COS(yr) , 0, + COS(xr) * SIN(yr) * COS(zr) + SIN(xr) * SIN(zr) , COS(xr) * SIN(yr) * SIN(zr) - SIN(xr) * COS(zr) , COS(xr) * COS(yr) , 0, + 0 , 0 , 0 , 1 ]; - // Do some rounding - return new Matrix3D(matrix.map(v => Math.round(v * 1e10) * 1e-10)); + return new Matrix3D(matrix); }; /** @@ -54,7 +63,7 @@ module CommentUtils { return this._internalArray.slice(0); } - set flatArray(array:Array) { + set flatArray(_array:Array) { throw new Error('Not permitted. Matrices are immutable.'); } diff --git a/src/core/css-renderer/CssComment.ts b/src/core/css-renderer/CssComment.ts index 07bbec38..3bf96bee 100644 --- a/src/core/css-renderer/CssComment.ts +++ b/src/core/css-renderer/CssComment.ts @@ -6,56 +6,56 @@ * @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; - 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'; - } - } + public init(recycle:IComment = null):void { + super.init(recycle); + this._toggleClass('css-optimize', true); + } + + protected _calculateX():number { + var width = (typeof this._width === 'undefined') ? 0 : this.width; + var x = (this.ttl / this.dur) * (this.parent.width + width) - width; + return (!this.absolute) ? (x / this.parent.width) : x; } get x():number{ - // X always goes from {parent.width to -this.width} - return (this.ttl / this.dur) * (this.parent.width + this.width) - this.width; + return this._calculateX(); + } + + set x(x:number) { + /* + Re-pivot x to animate from the current _x location. + */ + // Convert to pixel space + if (!this.absolute) { + x *= this.parent.width; + } + var dx:number = x - this._calculateX(); + this.dom.style.transform = + "translateX(" + (this.axis % 2 === 0 ? dx : -dx) + "px)" + + (this._transform === null || this._transform.isIdentity() ? + '' : (' ' + this._transform.toCss())); + + if (this.axis % 2 === 0) { + // x-axis towards right + this.dom.style.left = this._calculateX() + 'px'; + } else { + // x-axis towards left + this.dom.style.right = this._calculateX() + 'px'; + } } public update():void{ + /* + This is called by the update manager + Since CSS updates are very different, super should not be called. + */ if (this._dirtyCSS) { - // Start moving + // Recreate the CSS this.dom.style.transition = "transform " + this.ttl + "ms linear"; this.x = - this.width; this._dirtyCSS = false; @@ -65,6 +65,14 @@ class CssScrollComment extends ScrollComment { public invalidate():void{ super.invalidate(); this._dirtyCSS = true; + + if (!this.dom) { + return; // DOM not created yet, do nothing + } else { + // Clear the transition to prepare for a rewrite + this.dom.style.transition = ''; + this.x = this.x; + } } /** @@ -72,14 +80,6 @@ class CssScrollComment extends ScrollComment { */ 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; + this.invalidate(); } } diff --git a/src/css/base.css b/src/css/base.css index a1bf2b4d..0553405c 100644 --- a/src/css/base.css +++ b/src/css/base.css @@ -36,10 +36,14 @@ word-break: keep-all; } -.abp .container .cmt.noshadow { +.abp .container .cmt.no-shadow { text-shadow: none; } -.abp .container .cmt.rshadow { +.abp .container .cmt.reverse-shadow { text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white; } + +.abp .container .cmt.css-optimize { + will-change: transform; +} diff --git a/src/filter/CommentFilter.js b/src/filter/CommentFilter.js index 7bedb125..80b9e7ff 100644 --- a/src/filter/CommentFilter.js +++ b/src/filter/CommentFilter.js @@ -5,186 +5,186 @@ */ 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; + /** + * 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; } - 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; + 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); + /** + * 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 }; + } - /** - * 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; - }; + /** + * 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); + }; - /** - * 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; - }); - }; + /** + * 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; + }; - /** - * 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); - }; + /** + * 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; + }); + }; - /** - * 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 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); + }; - /** - * 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); - }; + /** + * 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; + return CommentFilter; })(); diff --git a/src/parsers/AcfunFormat.js b/src/parsers/AcfunFormat.js index 42157ef7..609c7f51 100644 --- a/src/parsers/AcfunFormat.js +++ b/src/parsers/AcfunFormat.js @@ -4,225 +4,225 @@ * @license MIT License **/ var AcfunFormat = (function () { - var AcfunFormat = {}; + 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 = 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; + 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! } - 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; + 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 { - // 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; + data.opacity = 1; } - }; - - AcfunFormat.JSONParser.prototype.parseMany = function (comments) { - if (!Array.isArray(comments)) { - return null; + 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); } - var list = []; - for (var i = 0; i < comments.length; i++) { - var comment = this.parseOne(comments[i]); - if (comment !== null) { - list.push(comment); + 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 list; - }; - AcfunFormat.TextParser = function (param) { - this._jsonParser = new AcfunFormat.JSONParser(param); + } + 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.TextParser.prototype.parseOne = function (comment) { - try { - return this._jsonParser.parseOne(JSON.parse(comment)); - } catch (e) { - console.warn(e); - 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.prototype.parseMany = function (comment) { - try { - return this._jsonParser.parseMany(JSON.parse(comment)); - } catch (e) { - console.warn(e); - return null; - } + 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; + return AcfunFormat; })(); diff --git a/src/parsers/BilibiliFormat.js b/src/parsers/BilibiliFormat.js index dde27138..e8c9068d 100644 --- a/src/parsers/BilibiliFormat.js +++ b/src/parsers/BilibiliFormat.js @@ -1,300 +1,300 @@ -/** +/** * Bilibili Format Parser * Takes in an XMLDoc/LooseXMLDoc and parses that into a Generic Comment List * @license MIT License **/ var BilibiliFormat = (function () { - var BilibiliFormat = {}; + var BilibiliFormat = {}; - // Fix comments to be valid - var _format = function (text) { - return text.replace(/\t/,"\\t"); - }; + // 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; - } - }; + // 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); + if (this._attemptFix) { + text = _format(_formatmode7(text)); + } + var extendedParams = JSON.parse(text); + comment.shadow = true; + comment.x = parseFloat(extendedParams[0]); + comment.y = parseFloat(extendedParams[1]); + if (Math.floor(comment.x) < comment.x || Math.floor(comment.y) < comment.y) { + comment.position = 'relative'; + } + comment.text = extendedParams[4].replace(/(\/n|\\n|\n|\r\n)/g, "\n"); + comment.rZ = 0; + comment.rY = 0; + if (extendedParams.length>= 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); } - 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; + 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 } - 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); + }); + lastPoint.x = parseInt(m[2],10); + lastPoint.y = parseInt(m[3],10); } + break; + } + m = regex.exec(path); } - } 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); - } + 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 + }; } - } - 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 + if (this._logBadComments) { + console.warn('Error occurred in JSON parsing. Could not parse comment.'); + console.log('[DEBUG] ' + text); + } } - var commentList = []; - for (var i = 0; i < elements.length; i++) { - var comment = this.parseOne(elements[i]); - if (comment !== null) { - commentList.push(comment); - } + } 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); } - return commentList; - }; + } + } + if (comment.text !== null && typeof comment.text === 'string') { + comment.text = comment.text.replace(/\u25a0/g,"\u2588"); + } + return comment; + }; - 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.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.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 = 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.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.'); - } - }; + 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; + return BilibiliFormat; })(); diff --git a/src/parsers/CommonDanmakuFormat.js b/src/parsers/CommonDanmakuFormat.js index 8c5ea747..adf5acf6 100644 --- a/src/parsers/CommonDanmakuFormat.js +++ b/src/parsers/CommonDanmakuFormat.js @@ -6,62 +6,62 @@ **/ 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; - }; + 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 = 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.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 = 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; - }; + 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; + return CommonDanmakuFormat; })(); diff --git a/src/scripting/Host.js b/src/scripting/Host.js index 3ad53e15..6722b864 100644 --- a/src/scripting/Host.js +++ b/src/scripting/Host.js @@ -29,14 +29,14 @@ var CCLScripting = function(workerUrl){ return; } - CCLScripting.prototype.ScriptingContext = function(scripter, stage){ + CCLScripting.prototype.ScriptingContext = function (scripter, stage) { // Here in the Scripting Context we also have a objects var objects = {}; this.registerObject = function(objectId, serialized){ - if(typeof this.Unpack[serialized["class"]] === "function"){ + if(typeof this.Unpack[serialized["class"]] === "function") { objects[objectId] = new this.Unpack[serialized["class"]](stage, serialized, this); - }else{ + } else { scripter.logger.error("Cannot unpack class \"" + serialized["class"] + "\". No valid unpacker found"); return; diff --git a/src/scripting/Unpacker.js b/src/scripting/Unpacker.js index e511124d..a3569bfd 100644 --- a/src/scripting/Unpacker.js +++ b/src/scripting/Unpacker.js @@ -79,7 +79,7 @@ data.x = x; this.DOM.style.left = data.x + "px"; }; - + this.setY = function(y){ data.y = y; this.DOM.style.top = data.y + "px"; @@ -91,7 +91,7 @@ /** Load x,y **/ this.setX(data.x); this.setY(data.y); - + /** Other **/ this.setText = function(text){ this.DOM.innerHTML = ""; @@ -133,7 +133,7 @@ this.__defineSetter__("filters", function(f){ this.setFilters([f]); }); - + this.__defineGetter__("transform", function(f){ return {}; }); @@ -156,19 +156,19 @@ if(filter.type === "blur"){ //this.DOM.style.color = "transparent"; shadows.push([0,0, Math.max( - filter.params.blurX, filter.params.blurY) + - "px"].join(" ")); + 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(" ")); + filter.params.blurX, filter.params.blurY) + + "px", getColor(filter.params.color)].join(" ")); } } }; this.DOM.style.textShadow = shadows.join(","); }; - + /** Common **/ this.unload = function(){ try{ @@ -178,7 +178,7 @@ // Hook child stage.appendChild(this.DOM); }; - + ScriptingContext.prototype.Unpack.Shape = function(stage, data, ctx){ this.DOM = _("svg",{ ""; - + // Helpers var __ = function(e, attr){ if(typeof e === "string"){ - var elem = + var elem = document.createElementNS("http://www.w3.org/2000/svg",e); }else{ var elem = e; @@ -212,7 +212,7 @@ } return elem; }; - + var globalDefs = __('defs'); var defaultEffects = __("defs"); var defaultGroup = __("g",{ @@ -221,7 +221,7 @@ "transform":"translate(" + this._x + "," + this._y + ")", "opacity":this._alpha, }); - + defaultContainer.appendChild(defaultGroup); var defaultGroupWithEffects = defaultContainer; this.DOM.appendChild(globalDefs); @@ -281,7 +281,7 @@ } }); /** /PROPS **/ - + this.line = { width:0, color:"#ffffff", @@ -315,7 +315,7 @@ p.setAttribute("stroke-miterlimit", ref.line.miterLimit); } }; - + var applyFill = function(p, ref){ __(p, { "fill": ref.fill.fill, @@ -323,14 +323,14 @@ "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; @@ -545,7 +545,7 @@ applyStroke(c, this); defaultGroup.appendChild(c); }; - + this.drawEllipse = function(params){ var e = __("ellipse",{ "cx": params[0], @@ -557,7 +557,7 @@ 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."); @@ -575,7 +575,7 @@ } this.drawPath([commands,data,"evenOdd"]); }; - + this._clear = function(){ if(state.scheduleClear.length < 1) return; @@ -588,7 +588,7 @@ } state.scheduleClear = []; }; - + this.clear = function(){ var children = defaultGroup.children ? defaultGroup.children : defaultGroup.childNodes; for (var i = 0; i < children.length; i++) { @@ -600,7 +600,7 @@ state.scheduleTimer = -1; }, 60); }; - + this.__defineGetter__("filters", function(f){ return []; }); @@ -625,13 +625,13 @@ case "blur":{ dFilter.appendChild(__("feGaussianBlur",{ "in":"SourceGraphic", - "stdDeviation":filter.params.blurX + " " + "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), + 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, @@ -644,7 +644,7 @@ "values": cMatrix.join(" ") })); dFilter.appendChild(__("feGaussianBlur",{ - "stdDeviation":filter.params.blurX + " " + "stdDeviation":filter.params.blurX + " " + filter.params.blurY, "result":"coloredBlur" })); @@ -675,7 +675,7 @@ this.DOM.appendChild(tGroup); defaultGroupWithEffects = tGroup; }; - + this.unload = function(){ try{ stage.removeChild(this.DOM); @@ -684,7 +684,7 @@ // Hook Child stage.appendChild(this.DOM); }; - + ScriptingContext.prototype.Unpack.Sprite = function(stage, data, ctx){ this.DOM = _("div",{"style":{ "position":"absolute", @@ -695,9 +695,9 @@ "overflow":"visible", "transformOrigin":"0 0 0" }}); - + data.scaleX = 1; - data.scaleY = 1; + data.scaleY = 1; data.children = []; this.__defineSetter__("visible", function(f){ this.DOM.style.visibility = f ? "visible" : "hidden"; @@ -711,7 +711,7 @@ this.__defineGetter__("alpha", function(f){ return this.DOM.style.opacity; }); - + this.__defineSetter__("x", function(f){ this.setX(f); }); @@ -746,19 +746,19 @@ 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); @@ -776,7 +776,7 @@ ctx.invokeError("Sprite.addChild failed. Attempted to add non object","err"); } }; - + this.removeChild = function(childitem){ var child = ctx.getObject(childitem); if(!child) @@ -787,7 +787,7 @@ ctx.invokeError(e.stack, "err"); } }; - + this.unload = function(){ try{ stage.removeChild(this.DOM); @@ -796,8 +796,8 @@ // Hook child stage.appendChild(this.DOM); } - - ScriptingContext.prototype.Unpack.SpriteRoot = function(stage, data, ctx){ + + ScriptingContext.prototype.Unpack.SpriteRoot = function(stage, data, ctx) { this.DOM = stage; this.addChild = function(childitem){ var child = ctx.getObject(childitem); @@ -815,7 +815,7 @@ ctx.invokeError("Sprite.addChild failed. Attempted to add non object","err"); } }; - + this.removeChild = function(childitem){ var child = ctx.getObject(childitem); if(!child) @@ -827,8 +827,8 @@ } }; }; - - ScriptingContext.prototype.Unpack.Button = function(stage, data, ctx){ + + ScriptingContext.prototype.Unpack.Button = function (stage, data, ctx) { this.DOM = _("div",{ "className":"button", "style":{ @@ -837,9 +837,9 @@ "left": data.x ? data.x + "px" : "0px" } },[_("text", data.text)]); - + data.scaleX = 1; - data.scaleY = 1; + data.scaleY = 1; this.__defineSetter__("visible", function(f){ this.DOM.style.visibility = f ? "visible" : "hidden"; }); @@ -891,7 +891,7 @@ this.__defineGetter__("scaleY", function(f){ return data.scaleY; }); - + this.__defineSetter__("x", function(f){ this.setX(f); }); @@ -904,67 +904,208 @@ 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) + if (!child) { return; - if(child.DOM){ - if(child.getClass() === "Shape"){ + } + 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"); + } 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{ + try { this.DOM.removeChild(child.DOM); - }catch(e){ + } catch(e) { ctx.invokeError(e.stack, "err"); } }; - + this.unload = function(){ - try{ + try { stage.removeChild(this.DOM); - }catch(e){}; + } catch (e) {}; }; // Hook child stage.appendChild(this.DOM); } - + + ScriptingContext.prototype.Unpack.BitmapData = function (stage, data, ctx) { + this._notifyList = []; + this._data = new ImageData(data.width, data.height); + + // Fill the image + this._fill = function (color) { + var r = (color>> 16) & 0xff, + g = (color>> 8) & 0xff, + b = color & 0xff, + a = (color>> 24) & 0xff; + for (var y = 0; y < this._data.height; y++) { + for (var x = 0; x < this._data.width; x++) { + var i = 4 * (y * this._data.width + x); + this._data.data[i] = r; + this._data.data[i + 1] = g; + this._data.data[i + 2] = b; + this._data.data[i + 3] = a; + } + } + } + + this._registerNotify = function (bitmap) { + if (this._notifyList.indexOf(bitmap) < 0) { + this._notifyList.push(bitmap); + // Also notify immediately + bitmap._draw(this._data); + } + }; + + this._deregisterNotify = function (bitmap) { + var index = this._notifyList.indexOf(bitmap); + if (index>= 0) { + this._notifyList.splice(index, 1); + } + }; + + this.updateBox = function (update) { + var box = update.box; + for (var y = box.y; y < box.y + box.height; y++) { + for (var x = box.x; x < box.x + box.width; x++) { + // Unpack ARGB + var color = update.values[y * box.width + x]; + var r = (color>> 16) & 0xff, + g = (color>> 8) & 0xff, + b = color & 0xff, + a = (color>> 24) & 0xff; + var i = 4 * (y * this._data.width + x); + this._data.data[i] = r; + this._data.data[i + 1] = g; + this._data.data[i + 2] = b; + this._data.data[i + 3] = a; + } + } + + // Update all relevant images + this._notifyList.forEach((function (image) { + image._draw(this._data); + }).bind(this)); + }; + + this.unload = function () { + this._data = null; + // Make sure this is null so future uses will error out + }; + // No need to hook anywhere + } + + ScriptingContext.prototype.Unpack.Bitmap = function (stage, data, ctx) { + this._bitmapDataId = null; + this.DOM = _('canvas', { + 'style': { + 'position': 'absolute', + "top": data.y ? data.y + "px" : "0px", + "left": data.x ? data.x + "px" : "0px", + "transformOrigin":"0 0 0" + } + }); + 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.__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){ + data.x = f; + this.DOM.style.left = data.x + 'px'; + }); + this.__defineSetter__("y", function(f){ + data.y = f; + this.DOM.style.top = data.y + 'px'; + }); + this.__defineGetter__("x", function(f){ + return 0; + }); + this.__defineGetter__("y", function(f){ + return 0; + }); + + this._draw = function (imageData) { + this.DOM.setAttribute('width', imageData.width); + this.DOM.setAttribute('height', imageData.height); + var ctx = this.DOM.getContext('2d'); + ctx.putImageData(imageData, 0, 0); + }; + + this.setBitmapData = function (id) { + var bitmapData = ctx.getObject(id); + if (this._bitmapDataId !== null) { + ctx.getObject(this._bitmapDataId)._deregisterNotify(this); + } + bitmapData._registerNotify(this); + this._bitmapDataId = id; + }; + + this.unload = function () { + try { + stage.removeChild(this.DOM); + } catch (e) {}; + }; + // Set bitmap data + if ('bitmapData' in data) { + this.setBitmapData(data['bitmapData']); + } + // Hook DOM + stage.appendChild(this.DOM); + } + // Load all the getClass Prototypes - for(var cl in ScriptingContext.prototype.Unpack){ + for (var cl in ScriptingContext.prototype.Unpack) { ScriptingContext.prototype.Unpack[cl].prototype.getClass = (function(){ var n = cl; return function(){ return n; - } + } })(); } })(); diff --git a/src/scripting/api/Display/Bitmap.ts b/src/scripting/api/Display/Bitmap.ts index 479391f2..3b22bff9 100644 --- a/src/scripting/api/Display/Bitmap.ts +++ b/src/scripting/api/Display/Bitmap.ts @@ -1,5 +1,6 @@ /// /// +/// module Display { @@ -45,68 +46,63 @@ module Display { * @author Jim Chen */ export class Bitmap extends DisplayObject { + private _bitmapData:BitmapData | null = null; - } - - export class ByteArray extends Array { - private _readPosition:number = 0; - - constructor(...params) { - super(...params); + constructor(bitmapData:BitmapData | null = null) { + super(Runtime.generateId('obj-bmp')); + this._bitmapData = bitmapData; } - get bytesAvailable():number { - return this.length - this._readPosition; - } - - set bytesAvailable(n:number) { - __trace('ByteArray.bytesAvailable is read-only', 'warn'); - } - - public clear():void { - this.length = 0; - this._readPosition = 0; + get width():number { + console.log(this._bitmapData); + return this._bitmapData !== null ? + this._bitmapData.width * this.scaleX : 0; } - public compress(algorithm:string = 'zlib'):void { - __trace('ByteArray.compress not implemented', 'warn'); + get height():number { + return this._bitmapData !== null ? + this._bitmapData.height * this.scaleY : 0; } - public uncompress(algorithm:string = 'zlib'):void { - __trace('ByteArray.uncompress not implemented', 'warn'); + set width(w:number) { + if (this._bitmapData !== null && this._bitmapData.width> 0) { + this.scaleX = w / this._bitmapData.width; + } } - public deflate():void { - __trace('ByteArray.deflate not implemented', 'warn'); + set height(h:number) { + if (this._bitmapData !== null && this._bitmapData.height> 0) { + this.scaleY = h / this._bitmapData.height; + } } - public inflate():void { - __trace('ByteArray.inflate not implemented', 'warn'); + public getBitmapData():BitmapData { + return this._bitmapData; } - public readUTFBytes(length:number):string { - // Get length - var subArray:Array = this.slice(this._readPosition, length); - this._readPosition += Math.min(length, this.length - this._readPosition); - var str:string = ''; - subArray.forEach((cc) => { - str += String.fromCharCode(cc); - }) - return str; + public setBitmapData(bitmapData:BitmapData):void { + if (typeof bitmapData !== 'undefined') { + this._bitmapData = bitmapData; + // Propagate up + this.methodCall('setBitmapData', bitmapData.getId()); + } } - public writeUTFBytes(value:string):void { - for (var i = 0; i < value.length; i++) { - Array.prototype.push.apply(this, [value.charCodeAt(i)]); + public serialize():Object { + var serialized:Object = super.serialize(); + serialized["class"] = 'Bitmap'; + if (this._bitmapData !== null) { + serialized["bitmapData"] = this._bitmapData.getId(); } + return serialized; } - } + } /** * BitmapData Polyfill class * @author Jim Chen */ - export class BitmapData { + export class BitmapData implements Runtime.RegisterableObject { private _id:string; private _rect:Rectangle; private _locked:boolean = false; @@ -119,13 +115,19 @@ module Display { height:number, transparent:boolean = true, fillColor:number = 0xffffffff, - id:string = Runtime.generateId()) { + id:string = Runtime.generateId('obj-bmp-data')) { this._id = id; this._rect = new Rectangle(0, 0, width, height); this._transparent = transparent; this._fillColor = fillColor; + + this._dirtyArea = new DirtyArea(); + this._fill(); + + // Register this + Runtime.registerObject(this); } private _fill():void { @@ -161,17 +163,18 @@ module Display { change.x + j]); } } - this._call('updateBox', { + this._methodCall('updateBox', { 'box': change.serialize(), 'values': region }); + this._dirtyArea.reset(); } - private _call(method:string, args:any):void { - __pchannel('Runtime:CallMethod', { - 'id': this.getId(), - 'name': name, - 'value': args, + private _methodCall(methodName:string, params:any):void { + __pchannel("Runtime:CallMethod", { + "id": this._id, + "method": methodName, + "params": params }); } @@ -187,18 +190,48 @@ module Display { return this._rect; } - set height(height:number) { + set height(_height:number) { __trace('BitmapData.height is read-only', 'warn'); } - set width(width:number) { + set width(_width:number) { __trace('BitmapData.height is read-only', 'warn'); } - set rect(rect:Rectangle) { + set rect(_rect:Rectangle) { __trace('BitmapData.rect is read-only', 'warn'); } + public draw(source:DisplayObject|BitmapData, + matrix:Matrix = null, + colorTransform:ColorTransform = null, + blendMode:string = null, + clipRect:Rectangle = null, + smoothing:boolean = false):void { + if (!(source instanceof BitmapData)) { + __trace('Drawing non BitmapData is not supported!', 'err'); + return; + } + if (matrix !== null) { + __trace('Matrix transforms not supported yet.', 'warn'); + } + if (colorTransform !== null) { + __trace('Color transforms not supported yet.', 'warn'); + } + if (blendMode !== null && blendMode !== 'normal') { + __trace('Blend mode [' + blendMode + '] not supported yet.', 'warn'); + } + if (smoothing !== false) { + __trace('Smoothign not supported!', 'warn'); + } + this.lock(); + if (clipRect === null) { + clipRect = new Rectangle(0, 0, source.width, source.height); + } + this.setPixels(clipRect, source.getPixels(clipRect)); + this.unlock(); + } + public getPixel(x:number, y:number):number { return this.getPixel32(x, y) & 0x00ffffff; } @@ -210,7 +243,7 @@ module Display { } try { return this._transparent ? this._byteArray[y * this._rect.width + x] : - this._byteArray[y * this._rect.width + x] + 0xff000000; + (this._byteArray[y * this._rect.width + x] & 0x00ffffff) + 0xff000000; } catch (e) { return this._fillColor; } @@ -225,25 +258,27 @@ module Display { } var region:ByteArray = 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)); + this._byteArray.slice((rect.y + i) * this._rect.width + rect.x, + (rect.y + i) * this._rect.width + rect.x + rect.width).forEach(function (v) { + region.push(v) + }); } return region; } public setPixel(x:number, y:number, color:number):void { - this.setPixel32(x, y, color); + // Force alpha channel to be full + this.setPixel32(x, y, (color & 0x00ffffff) + 0xff000000); } public setPixel32(x:number, y:number, color:number):void { if (!this._transparent) { - color = color & 0x00ffffff; - } else { - color = color & 0xffffffff; + // Force alpha channel + color = (color & 0x00ffffff) + 0xff000000; } this._byteArray[y * this._rect.width + x] = color; this._dirtyArea.expand(x, y); + this._updateBox(); } public setPixels(rect:Rectangle, input:Array):void { @@ -255,6 +290,11 @@ module Display { throw new Error('setPixels expected ' + (rect.width * rect.height) + ' pixels, but actually got ' + input.length); } + if (!this._transparent) { + input = input.map(function (color) { + return (color & 0x00ffffff) + 0xff000000; + }); + } 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)] = @@ -262,6 +302,20 @@ module Display { this._dirtyArea.expand(i, j); } } + this._updateBox(); + } + + public getVector(rect:Rectangle):Array { + if (this._rect.equals(rect)) { + return this._byteArray; + } + var vector:Array = []; + for (var j = rect.y; j < rect.y + rect.height; j++) { + for (var i = rect.x; i < rect.x + rect.width; i++) { + vector.push(rect[j * this._rect.width + i]); + } + } + return vector; } public lock():void { @@ -277,14 +331,33 @@ module Display { } } + public dispatchEvent(_event:string, _data?:any):void { + + } + public getId():string { return this._id; } public serialize():Object { return { - 'class':'BitmapData' + 'class':'BitmapData', + 'height': this._rect.height, + 'fill': this._fillColor }; } + + public unload():void { + this._methodCall('unload', null); + } + + public clone():BitmapData { + var data = new BitmapData(this.width, this.height, + this._transparent, this._fillColor); + data._byteArray = this._byteArray.slice(0); + data._updateBox(data._rect); + return data; + } } } diff --git a/src/scripting/api/Display/ByteArray.ts b/src/scripting/api/Display/ByteArray.ts new file mode 100644 index 00000000..ae8b5e82 --- /dev/null +++ b/src/scripting/api/Display/ByteArray.ts @@ -0,0 +1,146 @@ +/// +/// + +module Display { + export class ByteArray extends Array { + private _readPosition:number = 0; + + constructor(...params) { + super(...params); + try { + Object['setPrototypeOf'](this, ByteArray.prototype); + } catch (e) {} + } + + get bytesAvailable():number { + return this.length - this._readPosition; + } + + set bytesAvailable(_n:number) { + __trace('ByteArray.bytesAvailable is read-only', 'warn'); + } + + get position():number { + return this._readPosition; + } + + set position(p:number) { + this._readPosition = p; + } + + public clear():void { + this.length = 0; + this._readPosition = 0; + } + + public compress(algorithm:string = 'zlib'):void { + __trace('ByteArray.compress[' + algorithm + '] not implemented', 'warn'); + this._readPosition = 0; + } + + public uncompress(algorithm:string = 'zlib'):void { + __trace('ByteArray.uncompress[' + algorithm + + '] not implemented', 'warn'); + this._readPosition = 0; + } + + public deflate():void { + __trace('ByteArray.deflate not implemented', 'warn'); + } + + public inflate():void { + __trace('ByteArray.inflate not implemented', 'warn'); + } + + public readUTFBytes(length:number):string { + // Get length + var subArray:Array = this.slice(this._readPosition, length); + this._readPosition += Math.min(length, this.length - this._readPosition); + var str:string = ''; + subArray.forEach((cc) => { + str += String.fromCharCode(cc); + }) + return str; + } + + public readUnsignedByte():number { + return this[this._readPosition] & 0xff; + } + + public readUnsignedShort():number { + var top:number = this.readUnsignedByte(), + bottom:number = this.readUnsignedByte(); + return ((top << 8) + bottom) & 0xffff; + } + + public readUnsignedInt():number { + var a:number = this.readUnsignedByte(), + b:number = this.readUnsignedByte(), + c:number = this.readUnsignedByte(), + d:number = this.readUnsignedByte(); + return ((a << 24) + (b << 16) + (c << 8) + d) & 0xffffffff; + } + + public readByte():number { + return this.readUnsignedByte() - 128; + } + + public readShort():number { + return this.readUnsignedShort() - 0x7fff; + } + + public readBoolean():boolean { + return this.readUnsignedByte() !== 0; + } + + public readFloat():number { + var source:number = this.readUnsignedInt(); + var fval = 0.0; + var x = (source & 0x80000000)?-1:1; + var m = ((source>> 23) & 0xff);//mantissa + var s = (source & 0x7fffff);//sign + switch(x) { + case 0: + break; + case 0xFF: + if (m) { + fval = NaN; + } else if (s> 0) { + fval = Number.POSITIVE_INFINITY; + } else { + fval = Number.NEGATIVE_INFINITY; + } + break; + default: + x -= 127; + m += 0x800000; + fval = s * (m / 8388608.0) * Math.pow(2, x); + break; + } + return fval; + } + + public writeByte(value:number):void { + this.push(value & 0xff); + } + + public writeBytes(bytes:number[], offset:number = 0, length:number = 0) { + for (var i = offset; i < Math.min(bytes.length - offset, length); i++) { + this.writeByte(bytes[i]); + } + } + + public writeUTFBytes(value:string):void { + var bytesString:string = unescape(encodeURIComponent(value)); + for (var i = 0; i < value.length; i++) { + this.push(bytesString.charCodeAt(i)); + } + } + + public clone():ByteArray { + var cloned:ByteArray = new ByteArray(); + this.forEach(function (item) { cloned.push(item) }); + return cloned; + } + } +} diff --git a/src/scripting/api/Display/CommentBitmap.ts b/src/scripting/api/Display/CommentBitmap.ts index cfe0461c..4a297efe 100644 --- a/src/scripting/api/Display/CommentBitmap.ts +++ b/src/scripting/api/Display/CommentBitmap.ts @@ -11,7 +11,7 @@ module Display { private _mM:MotionManager = new MotionManager(this); constructor(params:Object) { - super(); + super('bitmapData' in params ? params['bitmapData'] : undefined); this.initStyle(params); Runtime.registerObject(this); this.bindParent(params); @@ -22,7 +22,7 @@ module Display { return this._mM; } - set motionManager(m) { + set motionManager(_m) { __trace("IComment.motionManager is read-only", "warn"); } @@ -33,7 +33,12 @@ module Display { } public initStyle(style:Object):void { - + if (typeof style === 'undefined' || style === null) { + style = {}; + } + if ("lifeTime" in style) { + this._mM.dur = style["lifeTime"] * 1000; + } } } diff --git a/src/scripting/api/Display/CommentButton.ts b/src/scripting/api/Display/CommentButton.ts index d73439b1..17ff94ac 100644 --- a/src/scripting/api/Display/CommentButton.ts +++ b/src/scripting/api/Display/CommentButton.ts @@ -24,7 +24,7 @@ module Display { return this._mM; } - set motionManager(m:MotionManager) { + set motionManager(_m:MotionManager) { __trace("IComment.motionManager is read-only", "warn"); } diff --git a/src/scripting/api/Display/CommentCanvas.ts b/src/scripting/api/Display/CommentCanvas.ts index b5324e61..f83803b3 100644 --- a/src/scripting/api/Display/CommentCanvas.ts +++ b/src/scripting/api/Display/CommentCanvas.ts @@ -23,7 +23,7 @@ module Display { return this._mM; } - set motionManager(m:MotionManager) { + set motionManager(_m:MotionManager) { __trace("IComment.motionManager is read-only", "warn"); } diff --git a/src/scripting/api/Display/CommentField.ts b/src/scripting/api/Display/CommentField.ts index dd63ea24..89f738b5 100644 --- a/src/scripting/api/Display/CommentField.ts +++ b/src/scripting/api/Display/CommentField.ts @@ -63,7 +63,7 @@ module Display { return this._mM; } - set motionManager(m:MotionManager) { + set motionManager(_m:MotionManager) { __trace("IComment.motionManager is read-only", "warn"); } diff --git a/src/scripting/api/Display/CommentShape.ts b/src/scripting/api/Display/CommentShape.ts index 16fb392b..b638c5c4 100644 --- a/src/scripting/api/Display/CommentShape.ts +++ b/src/scripting/api/Display/CommentShape.ts @@ -23,7 +23,7 @@ module Display { return this._mM; } - set motionManager(m:MotionManager) { + set motionManager(_m:MotionManager) { __trace("IComment.motionManager is read-only", "warn"); } diff --git a/src/scripting/api/Display/Display.ts b/src/scripting/api/Display/Display.ts index 95c17444..80707e51 100644 --- a/src/scripting/api/Display/Display.ts +++ b/src/scripting/api/Display/Display.ts @@ -35,7 +35,7 @@ module Display { get: function () { return _root; }, - set: function (value) { + set: function (_value) { __trace("Display.root is read-only", "warn"); } }); @@ -43,7 +43,7 @@ module Display { get: function () { return {}; }, - set: function (value) { + set: function (_value) { __trace("Display.loaderInfo is disabled", "warn"); } }); @@ -51,7 +51,7 @@ module Display { get: function () { return _root; }, - set: function (value) { + set: function (_value) { __trace("Display.stage is read-only", "warn"); } }); @@ -59,7 +59,7 @@ module Display { get: function () { return "CCLDisplay/1.0 HTML5/* (bilibili, like BSE, like flash, AS3 compatible) KagerouEngine/v1"; }, - set: function (value) { + set: function (_value) { __trace("Display.version is read-only", "warn"); } }); @@ -67,7 +67,7 @@ module Display { get: function () { return _width; }, - set: function (value) { + set: function (_value) { __trace("Display.width is read-only", "warn"); } }); @@ -75,7 +75,7 @@ module Display { get: function () { return _height; }, - set: function (value) { + set: function (_value) { __trace("Display.height is read-only", "warn"); } }); @@ -83,7 +83,7 @@ module Display { get: function () { return _fullScreenWidth; }, - set: function (value) { + set: function (_value) { __trace("Display.fullScreenWidth is read-only", "warn"); } }); @@ -91,7 +91,7 @@ module Display { get: function () { return _fullScreenHeight; }, - set: function (value) { + set: function (_value) { __trace("Display.fullScreenHeight is read-only", "warn"); } }); diff --git a/src/scripting/api/Display/DisplayObject.ts b/src/scripting/api/Display/DisplayObject.ts index 1d3de131..0cf51692 100644 --- a/src/scripting/api/Display/DisplayObject.ts +++ b/src/scripting/api/Display/DisplayObject.ts @@ -358,7 +358,7 @@ module Display { return this._boundingBox; } - public set cacheAsBitmap(value:boolean) { + public set cacheAsBitmap(_value:boolean) { __trace("DisplayObject.cacheAsBitmap is not supported", "warn"); } @@ -386,7 +386,7 @@ module Display { return Display.root; } - public set root(s:DisplayObject) { + public set root(_s:DisplayObject) { __trace("DisplayObject.root is read-only.","warn"); } @@ -394,7 +394,7 @@ module Display { return Display.root; } - public set stage(s:DisplayObject) { + public set stage(_s:DisplayObject) { __trace("DisplayObject.stage is read-only.","warn"); } @@ -566,7 +566,7 @@ module Display { return this._name; } - public set loaderInfo(name:any) { + public set loaderInfo(_name:any) { __trace("DisplayObject.loaderInfo is read-only", "warn"); } @@ -575,7 +575,7 @@ module Display { return {}; } - public set parent(p:DisplayObject) { + public set parent(_p:DisplayObject) { __trace("DisplayObject.parent is read-only", "warn"); } diff --git a/src/scripting/api/Display/Matrix.ts b/src/scripting/api/Display/Matrix.ts index bb355980..19211d3a 100644 --- a/src/scripting/api/Display/Matrix.ts +++ b/src/scripting/api/Display/Matrix.ts @@ -13,7 +13,7 @@ module Display { this.y = y; } - set length(l:number) { + set length(_l:number) { __trace('Point.length is read-only', 'err'); } @@ -416,7 +416,7 @@ module Display { get: function () { return 'Vector'; }, - set: function (value) { + set: function (_value) { __trace('as3Type should not be set.', 'warn'); } }); @@ -435,7 +435,7 @@ module Display { get: function () { return 'Vector'; }, - set: function (value) { + set: function (_value) { __trace('as3Type should not be set.', 'warn'); } }); diff --git a/src/scripting/api/Display/MotionManager.ts b/src/scripting/api/Display/MotionManager.ts index 859897ed..3c9a2699 100644 --- a/src/scripting/api/Display/MotionManager.ts +++ b/src/scripting/api/Display/MotionManager.ts @@ -70,6 +70,10 @@ module Display { if (!this._isRunning) { return; } + // Ignore timer events if this has 0 duration (infinite) + if (this._dur === 0) { + return; + } this._ttl -= this._timeKeeper.elapsed; this._timeKeeper.reset(); if (this._ttl <= 0) { @@ -111,7 +115,7 @@ module Display { } } - public forecasting(time:number):boolean { + public forecasting(_time:number):boolean { __trace('MotionManager.forecasting always returns false', 'warn'); return false; } @@ -171,11 +175,11 @@ module Display { return Tween.parallel.apply(Tween, tweens); } - public initTween(motion:Object, repeat:boolean):void { + public initTween(motion:Object, _repeat:boolean):void { this._tween = this.motionSetToTween(motion); } - public initTweenGroup(motionGroup:Array, lifeTime:number):void { + public initTweenGroup(motionGroup:Array, _lifeTime:number):void { var tweens:Array = []; for (var i = 0; i < motionGroup.length; i++) { tweens.push(this.motionSetToTween(motionGroup[i])); diff --git a/src/scripting/api/Display/Sprite.ts b/src/scripting/api/Display/Sprite.ts index 41fbde01..6432dc1f 100644 --- a/src/scripting/api/Display/Sprite.ts +++ b/src/scripting/api/Display/Sprite.ts @@ -21,7 +21,7 @@ module Display { return this._graphics; } - set graphics(g:Graphics) { + set graphics(_g:Graphics) { __trace('Sprite.graphics is read-only.', 'warn'); } @@ -55,14 +55,25 @@ module Display { * @author Jim Chen */ export class RootSprite extends Sprite { + private _metaRoot:Runtime.IMetaObject; constructor() { super('__root'); + this._metaRoot = Runtime.getObject('__root'); } get parent():DisplayObject { __trace('SecurityError: No access above root sprite.','err'); return null; } + + public addEventListener(eventName:string, listener:Function):void { + __trace('Listener[' + eventName + '] on root sprite inadvisible', 'warn'); + this._metaRoot.addEventListener(eventName, listener); + } + + public removeEventListener(eventName:string, listener:Function):void { + this._metaRoot.removeEventListener(eventName, listener, false); + } } export class UIComponent extends Sprite { diff --git a/src/scripting/api/Display/TextField.ts b/src/scripting/api/Display/TextField.ts index 76783faa..82d27a43 100644 --- a/src/scripting/api/Display/TextField.ts +++ b/src/scripting/api/Display/TextField.ts @@ -20,13 +20,13 @@ module Display { bold:boolean = false, italic:boolean = false, underline:boolean = false, - url:string = "", - target:string = "", - align:string = "left", - leftMargin:number = 0, - rightMargin:number = 0, - indent:number = 0, - leading:number = 0) { + _url:string = "", + _target:string = "", + _align:string = "left", + _leftMargin:number = 0, + _rightMargin:number = 0, + _indent:number = 0, + _leading:number = 0) { this.font = font; this.size = size; @@ -62,7 +62,7 @@ module Display { private _borderColor:number = 0; constructor(text:string = "", color:number = 0) { - super(); + super(Runtime.generateId('obj-textfield')); this._text = text; this._textFormat = new TextFormat(); this._textFormat.color = color; @@ -85,7 +85,7 @@ module Display { return this.text.length; } - set length(l:number) { + set length(_l:number) { __trace("TextField.length is read-only.", "warn"); } @@ -98,11 +98,11 @@ module Display { this.text = text.replace(/<\/?[^>]+(>|$)/g, ''); } - set textWidth(w:number) { + set textWidth(_w:number) { __trace("TextField.textWidth is read-only", "warn"); } - set textHeight(h:number) { + set textHeight(_h:number) { __trace("TextField.textHeight is read-only", "warn"); } diff --git a/src/scripting/api/Display/Transform.ts b/src/scripting/api/Display/Transform.ts index 611afb96..d6ca2398 100644 --- a/src/scripting/api/Display/Transform.ts +++ b/src/scripting/api/Display/Transform.ts @@ -45,8 +45,6 @@ module Display { constructor(parent:Transformable) { this._parent = parent; - this._perspectiveProjection = new PerspectiveProjection(parent); - this._colorTransform = new ColorTransform(); } set parent(p:Transformable) { @@ -62,9 +60,23 @@ module Display { } get perspectiveProjection():PerspectiveProjection { + if (typeof this._perspectiveProjection === 'undefined') { + this._perspectiveProjection = new PerspectiveProjection(this._parent); + } return this._perspectiveProjection; } + set colorTransform(colorTransform:ColorTransform) { + this._colorTransform = colorTransform; + } + + get colorTransform():ColorTransform { + if (typeof this._colorTransform === 'undefined') { + this._colorTransform = new ColorTransform(); + } + return this._colorTransform; + } + set matrix3D(m:Display.Matrix3D) { if (m === null) { if (this._matrix3d === null) { diff --git a/src/scripting/api/Function.js b/src/scripting/api/Function.js index cd229a02..271c5697 100644 --- a/src/scripting/api/Function.js +++ b/src/scripting/api/Function.js @@ -4,88 +4,88 @@ **/ function trace (msg) { - if (typeof msg === 'object') { - __trace(JSON.stringify(msg), 'log'); - } else { - __trace(msg, 'log'); - } + 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(); - } - } - }); - } + 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; - } + 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 (typeof target['clone'] === 'function') { + return target.clone(); + } - // Call the object's own clone method if possible - if (target.hasOwnProperty('clone') || typeof target['clone'] === 'function') { - return target.clone(); - } + // Clone an array + if (Array.isArray(target)) { + return target.slice(0); + } - // 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; + // 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; - } + 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]); - } + for (var x in enumerable) { + if (enumerable.hasOwnProperty(x)) { + f(x, enumerable[x]); } - return; + } + return; } var none = null; diff --git a/src/scripting/api/Player/Player.ts b/src/scripting/api/Player/Player.ts index 19e991be..4233a429 100644 --- a/src/scripting/api/Player/Player.ts +++ b/src/scripting/api/Player/Player.ts @@ -31,7 +31,7 @@ module Player{ Object.defineProperty(Player, 'state', { get: function() { return _state; }, - set: function(value) { + set: function(_value) { __trace('Player.state is read-only', 'warn'); } }); @@ -43,7 +43,7 @@ module Player{ return _time + _lastUpdate.elapsed; } }, - set: function(value) { + set: function(_value) { __trace('Player.time is read-only', 'warn'); } }); @@ -51,7 +51,7 @@ module Player{ get: function() { return _commentList; }, - set: function(value) { + set: function(_value) { __trace('Player.commentData is read-only', 'warn'); } }); @@ -59,39 +59,39 @@ module Player{ get: function() { return _refreshRate; }, - set: function(value) { + set: function(_value) { __trace("Player.refreshRate deprecated. Please use Display.frameRate", "warn"); } }); Object.defineProperty(Player, 'width', { get: function() { return _width; }, - set: function(value) { + set: function(_value) { __trace("Player.width is read-only", "warn"); } }); Object.defineProperty(Player, 'height', { get: function() { return _height; }, - set: function(value) { + set: function(_value) { __trace("Player.height is read-only", "warn"); } }); Object.defineProperty(Player, 'videoWidth', { get: function() { return _videoWidth; }, - set: function(value) { + set: function(_value) { __trace("Player.videoWidth is read-only", "warn"); } }); Object.defineProperty(Player, 'videoHeight', { get: function() { return _videoHeight; }, - set: function(value) { + 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) { + set: function(_value) { __trace('Player.version is read-only', 'warn'); } }); @@ -150,25 +150,44 @@ module Player{ export function commentTrigger(callback:Function, timeout:number):void{ if (!Runtime.hasObject('__player')) { - __trace('Your environment does not support player triggers.', 'warn'); + __trace('Your environment does not support player triggers.', 'err'); return; } - __trace('Comment trigger: not implemented', 'warn'); + if (timeout < 0) { + return; + } + var listener = function (comment:CommentData) { + callback(comment); + }; + var player:Runtime.IMetaObject = + Runtime.getObject('__player'); + player.addEventListener('comment', listener); + //TODO: remove the listener after timeout + //player.removeEventListener('comment', listener); } - export function keyTrigger(callback:Function, timeout:number):void{ + export function keyTrigger(callback:Function, + timeout:number = 1000, + triggerOnUp:boolean = false):void{ if (!Runtime.hasObject('__player')) { - __trace('Your environment does not support key triggers.', 'warn'); + __trace('Your environment does not support key triggers.', 'err'); return; } + if (timeout < 0) { + return; + } + var eventName:string = 'key' + (triggerOnUp ? 'up' : 'down'); + var listener:(number)=>void = function (key) { + callback(key.keyCode); + }; var player:Runtime.IMetaObject = Runtime.getObject('__player'); - player.addEventListener('keydown', function (key) { - callback(key.keyCode); - }); + player.addEventListener(eventName, listener); + //TODO: remove the listener after the timeout + //player.removeEventListener(eventName, listener); } - export function setMask(mask:any):void{ + export function setMask(_mask:any):void{ __trace('Masking not supported yet', 'warn'); } diff --git a/src/scripting/api/Player/Sound.ts b/src/scripting/api/Player/Sound.ts index eeeb3ee7..8f0c995b 100644 --- a/src/scripting/api/Player/Sound.ts +++ b/src/scripting/api/Player/Sound.ts @@ -1,13 +1,16 @@ +/// module Player{ /** * Class for sound support */ - class Sound { + class Sound implements Runtime.RegisterableObject { + private _id:string; private _source:string; private _isPlaying:boolean = false; public onload:Function; constructor(type:string, onload:Function) { + this._id = Runtime.generateId('obj-snd'); this.onload = onload; this._source = type; } @@ -17,7 +20,9 @@ module Player{ } public play():void { - + if (this._isPlaying) { + return; + } } public remove():void { @@ -25,13 +30,27 @@ module Player{ } public stop():void { - + if (!this._isPlaying) { + return; + } } public loadPercent():number { return 0; } + public getId():string { + return this._id; + } + + public dispatchEvent(_eventName:string, _params:any):void { + + } + + public unload():void { + this.stop(); + } + public serialize():Object { return { 'class':'Sound', @@ -39,4 +58,8 @@ module Player{ }; } } + + export function createSound(sample:string, onload:Function = null):Sound { + return new Sound(sample, onload); + } } diff --git a/src/scripting/api/Runtime.d.ts b/src/scripting/api/Runtime.d.ts index dc649cd3..5d561790 100644 --- a/src/scripting/api/Runtime.d.ts +++ b/src/scripting/api/Runtime.d.ts @@ -64,7 +64,7 @@ declare module Runtime { removeEventListener( event:string, listener:Function, - useCapture:boolean + useCapture?:boolean ):void; hasEventListener(event:string):boolean; } diff --git a/src/scripting/api/Runtime/Runtime.ts b/src/scripting/api/Runtime/Runtime.ts index ddcae859..4963b71c 100644 --- a/src/scripting/api/Runtime/Runtime.ts +++ b/src/scripting/api/Runtime/Runtime.ts @@ -12,7 +12,7 @@ */ module Runtime { type ObjectRegistry = {[objectName: string]: RegisterableObject}; - type IMetaObject = RegisterableObject & Listenable; + export type IMetaObject = RegisterableObject & Listenable; /** * Global interface for Listenable objects */ @@ -25,7 +25,7 @@ module Runtime { removeEventListener( event:string, listener:Function, - useCapture:boolean + useCapture?:boolean ):void; hasEventListener(event:string):boolean; } @@ -43,7 +43,7 @@ module Runtime { /** * Meta object that serves only to receive and send events */ - class MetaObject implements RegisterableObject, Listenable { + class MetaObject implements IMetaObject { private _name:string; private _listeners:{[name:string]: Array} = {}; @@ -56,8 +56,8 @@ module Runtime { public addEventListener(event:string, listener:Function, - useCapture:boolean = false, - priority:number = 0):void { + _useCapture:boolean = false, + _priority:number = 0):void { if (!(event in this._listeners)) { this._listeners[event] = []; @@ -67,7 +67,7 @@ module Runtime { public removeEventListener(event:string, listener:Function, - useCapture:boolean = false):void { + _useCapture:boolean = false):void { if (!(event in this._listeners)) { return; @@ -120,7 +120,7 @@ module Runtime { get: function () { return _registeredObjects; }, - set: function (value) { + set: function (_value) { __trace('Runtime.registeredObjects is read-only', 'warn'); } }); @@ -222,10 +222,9 @@ module Runtime { } } - function _getId(type:string = 'obj', container:string = 'rt'):string { - var randomSeed:number = Math.random() - var randomSegment:string = ''; - return; + function _makeId (type:string = "obj"):string { + return type + ":" + Date.now() + "|" + + Runtime.NotCrypto.random(16) + ":" + objCount; } /** @@ -234,11 +233,9 @@ module Runtime { * @returns {string} - objectid that has not been registered */ export function generateId(type:string = "obj"):string { - var id:string = [type, ':', Date.now(), '|', - Runtime.NotCrypto.random(16), ':', objCount].join(); + var id:string = _makeId(type); while (Runtime.hasObject(id)) { - id = type + ":" + Date.now() + "|" + - Runtime.NotCrypto.random(16) + ":" + objCount; + id = _makeId(type); } return id; }; diff --git a/src/scripting/api/Runtime/ScriptManager.ts b/src/scripting/api/Runtime/ScriptManager.ts index 69efec68..a98070b8 100644 --- a/src/scripting/api/Runtime/ScriptManager.ts +++ b/src/scripting/api/Runtime/ScriptManager.ts @@ -1,5 +1,4 @@ /// - /// module Runtime { @@ -39,7 +38,9 @@ module Runtime { } public clearEl():void { - __trace("ScriptManager.clearEl not implemented.", "warn"); + // Remove all elements drawn + __trace("ScriptManager.clearEl may not be properly implemented.", "warn"); + Runtime.clear(); } public clearTrigger():void { @@ -47,15 +48,20 @@ module Runtime { } public pushEl(el:any):void { - __trace("ScriptManager.pushEl not implemented.", "warn"); + __trace("ScriptManager.pushEl is not properly implemented.", "warn"); + if (el['motionManager']) { + el['motionManager'].start(); + } + el['visible'] = true; } public popEl(el:any):void { __trace("ScriptManager.popEl is not properly implemented.", "warn"); // TODO: Create some kind of thing to register motion managers properly if (el['motionManager']) { - el['motionManager'].stop(); + el['motionManager'].play(); } + el['visible'] = false; } public pushTimer(t:Timer):void { diff --git a/src/scripting/api/Runtime/Supports.ts b/src/scripting/api/Runtime/Supports.ts index 5287414c..ed136b48 100644 --- a/src/scripting/api/Runtime/Supports.ts +++ b/src/scripting/api/Runtime/Supports.ts @@ -37,7 +37,8 @@ module Runtime{ 'type': 'noop' }); } else { - callback(new Error('Could not load unknown library [' + libraryName + ']'), null); + callback(new Error('Could not load unknown library [' + + libraryName + ']'), null); } } } diff --git a/src/scripting/api/Runtime/Timer.ts b/src/scripting/api/Runtime/Timer.ts index fc8f4abd..2cbc2186 100644 --- a/src/scripting/api/Runtime/Timer.ts +++ b/src/scripting/api/Runtime/Timer.ts @@ -155,7 +155,7 @@ module Runtime{ this._repeatCount = repeatCount; } - set isRunning(b:boolean) { + set isRunning(_b:boolean) { __trace('Timer.isRunning is read-only', 'warn'); } @@ -250,7 +250,7 @@ module Runtime{ var internalTimer:Timer = new Timer(40); var enterFrameDispatcher:Function = function () { for (var object in Runtime.registeredObjects) { - if (object.substring(0, 2) === '__') { + if (object.substring(0, 2) === '__' && object !== '__root') { continue; } try { diff --git a/src/scripting/host/OOAPIWorker.ts b/src/scripting/host/OOAPIWorker.ts index 8c29a0c5..e2658623 100644 --- a/src/scripting/host/OOAPIWorker.ts +++ b/src/scripting/host/OOAPIWorker.ts @@ -1,4 +1,4 @@ -import { OOAPIMessage } from './OOAPI.d.ts'; +import { OOAPIMessage } from './OOAPI'; export type ChannelListener = (e:OOAPIMessage) => void; diff --git a/src/scripting/host/ScriptingContext.ts b/src/scripting/host/ScriptingContext.ts index f056dbe0..ab1e6e08 100644 --- a/src/scripting/host/ScriptingContext.ts +++ b/src/scripting/host/ScriptingContext.ts @@ -4,7 +4,7 @@ * @author Jim Chen */ -import { StageElement, IScriptingContext } from "./IScripter.ts"; +import { StageElement, IScriptingContext } from "./IScripter"; export module KagerouScripting { interface IDimensions { diff --git a/test/invalid/xss.xml b/test/invalid/xss.xml index ede6f74b..56954efd 100644 --- a/test/invalid/xss.xml +++ b/test/invalid/xss.xml @@ -1 +1,3 @@ + + diff --git a/test/scripting/3dplane.biliscript b/test/scripting/3dplane.biliscript index ab85a46f..73555358 100644 --- a/test/scripting/3dplane.biliscript +++ b/test/scripting/3dplane.biliscript @@ -9,4 +9,3 @@ s.graphics.drawRect(10,10,50,100); var c = $.createShape({x:Player.width / 2,y:Player.height/2,lifeTime:100, motion:{rotationX:{fromValue:0, toValue:3600, lifeTime:10}, rotationY:{fromValue:0, toValue:360, lifeTime:5}}}); c.graphics.beginFill(0x00ff00); c.graphics.drawRect(-60,-110,50,100); - diff --git a/test/scripting/3dsphere.biliscript b/test/scripting/3dsphere.biliscript index d1591c9b..97b46eee 100644 --- a/test/scripting/3dsphere.biliscript +++ b/test/scripting/3dsphere.biliscript @@ -3,14 +3,14 @@ * MIT License ( http://www.opensource.org/licenses/mit-license.php ) * Downloaded from: http://wonderfl.net/c/qGQZ * Downloaded from: https://github.com/biliscript-syndicate/examples/blob/master/Sphere.as - * + * * --Modified slightly to remove unnecessary code & hardcode screen size/lifeTime * --Modified so that GlowFilter is added too. */ -/** +/** * // Updated script so that we are much more efficient! -* Works well with filters off at 200, 40, 9 +* Works well with filters off at 200, 40, 9 * or with filters on at 200, 40, 9 too! **/ /*** CONFIG ****/ @@ -45,7 +45,7 @@ var rules = [ {r:0, g:0xff, b:0xff, dr:0, dg: -1, db:0 }, {r:0, g:0, b:0xff, dr: +1, dg:0, db:0 }, {r:0xff, g:0, b:0xff, dr:0, dg:0, db: -1 } -]; +]; function getColor(value) { var d = (value = value % 0x5fa) % 0xff; var r = rules[(value / 0xff) | 0]; @@ -60,7 +60,7 @@ function init() { var frh = radius * 2 / (stripes * 2 +1); var yc = -radius; var rad, last, yUp, yDown, rUp, rDown, i; - + for (var s = 0; s < stripes; s++) { yUp = yc += frh ; yDown = yc += frh; @@ -125,7 +125,7 @@ function render() { screen.filters = [$.createGlowFilter(mrgb,1,40,40,20)]; } } - + if (wireframe) screen.graphics.lineStyle(0.4, fill?0xffffff:color,1); if (fill) diff --git a/test/scripting/madoka.biliscript b/test/scripting/madoka.biliscript index 23f19281..d5f32c41 100644 --- a/test/scripting/madoka.biliscript +++ b/test/scripting/madoka.biliscript @@ -27,7 +27,7 @@ alpha:{fromValue:0,toValue:0.2,lifeTime:1}} g.graphics.beginFill(0x996600); g.graphics.drawRect(0,0,540,383); g.graphics.endFill() - + /*马猴烧酒组*/ var s = $.createShape({lifeTime:10,motionGroup:[ {x:{fromValue:5,toValue:0,lifeTime:2},alpha:{fromValue:0,toValue:1,lifeTime:2}}, diff --git a/test/scripting/manzoku.biliscript b/test/scripting/manzoku.biliscript index 1d55bbc3..2237f5d2 100644 --- a/test/scripting/manzoku.biliscript +++ b/test/scripting/manzoku.biliscript @@ -1,6 +1,6 @@ var count = 0; var bar = $.createShape({lifeTime:11,x:14}); -bar.graphics.beginGradientFill("linear", [0x009e96,0x005752], [0.8,0.8], [0x00, 0xFF], $.createMatrix(), "pad"); +bar.graphics.beginGradientFill("linear", [0x009e96,0x005752], [0.8,0.8], [0x00, 0xFF], $.createMatrix(), "pad"); bar.graphics.drawRect(0,340,512,24); bar.graphics.endFill(); var mask = $.createShape({ @@ -10,7 +10,7 @@ motion:{ y:0, lifeTime:11 }); - mask.graphics.beginGradientFill("linear", [0x000000,0x000000], [1,1], [0x00, 0xFF], $.createMatrix(), "pad"); + mask.graphics.beginGradientFill("linear", [0x000000,0x000000], [1,1], [0x00, 0xFF], $.createMatrix(), "pad"); mask.graphics.drawRect(0,340,512,24); mask.graphics.endFill(); diff --git a/test/scripting/minecraft4k.biliscript b/test/scripting/minecraft4k.biliscript new file mode 100644 index 00000000..03d63af0 --- /dev/null +++ b/test/scripting/minecraft4k.biliscript @@ -0,0 +1,222 @@ +/** + * Copyright yonatan ( http://wonderfl.net/user/yonatan ) + * MIT License ( http://www.opensource.org/licenses/mit-license.php ) + * Downloaded from: http://wonderfl.net/c/sqL5 + */ + +// ported from notch's javascript version: http://jsdo.it/notch/dB1E +// An unoptimized flash port made in about 10 minutes +// (would have been 5 but I messed up and made 'var closest' an int at first) + +// 20201204 adapted from prev version, increased resolution +// 20121227 ported from http://jsfiddle.net/uzMPU/ to Biliscript - nekofs +// initial version (verbatim port), performance: 0.1 fps with 200x200; 0.3fps with 120x90 + +/* framebuffer dimension */ +var w = 240; +var h = 180; + +/* generate texture of 16 blocks, 3 surface each block, 16*16 pixel each surface */ +function initTexMap(texmap) { + for (var i = 1; i < 16; i++) { + var br = 255 - ((Math.random() * 96) | 0); + for (var y = 0; y < 16 * 3; y++) { + for (var x = 0; x < 16; x++) { + var color = 0x966C4A; + if (i == 4) color = 0x7F7F7F; + if (i != 4 || ((Math.random() * 3) | 0) == 0) { + br = 255 - ((Math.random() * 96) | 0); + } + if ((i == 1 && y < (((x * x * 3 + x * 81)>> 2) & 3) + 18)) { + color = 0x6AAA40; + } else if ((i == 1 && y < (((x * x * 3 + x * 81)>> 2) & 3) + 19)) { + br = br * 2 / 3; + } + if (i == 7) { + color = 0x675231; + if (x> 0 && x < 15 && ((y> 0 && y < 15) || (y> 32 && y < 47))) { + color = 0xBC9862; + var xd = (x - 7); + var yd = ((y & 15) - 7); + if (xd < 0) xd = 1 - xd; + if (yd < 0) yd = 1 - yd; + if (yd> xd) xd = yd; + + br = 196 - ((Math.random() * 32) | 0) + xd % 3 * 32; + } else if (((Math.random() * 2) | 0) == 0) { + br = br * (150 - (x & 1) * 100) / 100; + } + } + if (i == 5) { + color = 0xB53A15; + if ((x + (y>> 2) * 4) % 8 == 0 || y % 4 == 0) color = 0xBCAFA5; + } + if (i == 9) color = 0x4040ff; + var brr = br; + if (y>= 32) brr /= 2; + if (i == 8) { + color = 0x50D937; + if (((Math.random() * 2) | 0) == 0) { + color = 0; + brr = 255; + } + } + + var col = (((color>> 16) & 0xff) * brr / 255) << 16 | (((color>> 8) & 0xff) * brr / 255) << 8 | (((color) & 0xff) * brr / 255); + texmap[x + y * 16 + i * 256 * 3] = col; + //texmap.setPixel(x, i * 16 * 3 + y, col); + } + } + } +} + +/* generate scene map */ +function initMap(map) { + for (var x = 0; x < 64; x++) { + for (var y = 0; y < 64; y++) { + for (var z = 0; z < 64; z++) { + var i = (z << 12) | (y << 6) | x; + var yd = (y - 32.5) * 0.4; + var zd = (z - 32.5) * 0.4; + map[i] = (Math.random() * 16) | 0; + /* the tunnel at the center: */ + if (Math.random()> Math.sqrt(Math.sqrt(yd * yd + zd * zd)) - 0.8) map[i] = 0; + } + } + } +} + +/* render each frame */ +function renderMinecraft() { + var data = $G._('data'); + var bmd = data.bmd; + var texmap = data.texmap; + var map = data.map; + + var xRot = Math.sin(getTimer() % 10000 / 10000 * Math.PI * 2) * 0.4 + Math.PI / 2; + var yRot = Math.cos(getTimer() % 10000 / 10000 * Math.PI * 2) * 0.4; + var yCos = Math.cos(yRot); + var ySin = Math.sin(yRot); + var xCos = Math.cos(xRot); + var xSin = Math.sin(xRot); + + var ox = 32.5 + getTimer() % 10000 / 10000 * 64; + var oy = 32.5; + var oz = 32.5; + + var start = getTimer(); + bmd.lock(); + /* render every pixel w*h */ + for (var x = 0; x < w; x++) { + var ___xd = (x - w / 2) / h; + for (var y = 0; y < h; y++) { + var __yd = (y - h / 2) / h; + var __zd = 1; + + var ___zd = __zd * yCos + __yd * ySin; + var _yd = __yd * yCos - __zd * ySin; + + var _xd = ___xd * xCos + ___zd * xSin; + var _zd = ___zd * xCos - ___xd * xSin; + + var col = 0; + var br = 255; + var ddist = 0; + + /* manual ray casting. biliscript loop performance sucks */ + var closest = 32; + for (var d = 0; d < 3; d++) { + var dimLength = _xd; + if (d == 1) dimLength = _yd; + if (d == 2) dimLength = _zd; + + var ll = 1 / (dimLength < 0 ? -dimLength : dimLength); + var xd = (_xd) * ll; + var yd = (_yd) * ll; + var zd = (_zd) * ll; + + var initial = ox - (ox | 0); + if (d == 1) initial = oy - (oy | 0); + if (d == 2) initial = oz - (oz | 0); + if (dimLength> 0) initial = 1 - initial; + + var dist = ll * initial; + + var xp = ox + xd * initial; + var yp = oy + yd * initial; + var zp = oz + zd * initial; + + if (dimLength < 0) { + if (d == 0) xp--; + if (d == 1) yp--; + if (d == 2) zp--; + } + + while (dist < closest) { + var tex = map[(zp & 63) << 12 | (yp & 63) << 6 | (xp & 63)]; + + if (tex> 0) { + var u = ((xp + zp) * 16) & 15; + var v = ((yp * 16) & 15) + 16; + if (d == 1) { + u = (xp * 16) & 15; + v = ((zp * 16) & 15); + if (yd < 0) v += 32; + } + + var cc = texmap[u + v * 16 + tex * 256 * 3]; + //var cc = texmap.getPixel(u, tex * 16 * 3 + v); + if (cc> 0) { + col = cc; + ddist = 255 - ((dist / 32 * 255) | 0); + br = 255 * (255 - ((d + 2) % 3) * 50) / 255; + closest = dist; + } + } + xp += xd; + yp += yd; + zp += zd; + dist += ll; + } + } + + var r = ((col>> 16) & 0xff) * br * ddist / (255 * 255); + var g = ((col>> 8) & 0xff) * br * ddist / (255 * 255); + var b = ((col) & 0xff) * br * ddist / (255 * 255); + + bmd.setPixel(x, y, r << 16 | g << 8 | b); + } + } + bmd.unlock(); + fpscounter.text = 'rendering: ' + (getTimer() - start) + 'ms/frame'; +} + +function startApplication() { + //var map: Vector. < int> = new Vector. < int> (64 * 64 * 64, true); + var map = Bitmap.createBitmapData(512, 512, false, 0); + map = map.getVector(map.rect); //512*512=64*64*64 + //var texmap: Vector. < int> = new Vector. < int> (16 * 16 * 3 * 16, true); + var texmap = Bitmap.createBitmapData(16, 16 * 16 * 3, false, 0); + texmap = texmap.getVector(texmap.rect); + + initTexMap(texmap); + initMap(map); + var bmd = Bitmap.createBitmapData(w, h, false, 0); + var bmp = Bitmap.createBitmap({bitmapData: bmd, lifeTime: 0}); + bmp.scaleX = bmp.scaleY = 2; + bmp.x = ((Player.width - bmp.width) / 2) | 0; + bmp.y = ((Player.height - bmp.height) / 2) | 0; + $G._set('data', {bmd: bmd, texmap: texmap, map: map}); + bmp.addEventListener("enterFrame", renderMinecraft); +} + +loading = $.createComment('加载libBitmap,稍候...', {lifeTime: 0}); +fpscounter = $.createComment('', {lifeTime: 0}); +timerLoadTimeout = timer(function() { + trace('libBitmap load timeout'); +}, 3000); +load('libBitmap', function() { + loading.visible = false; + clearTimeout(timerLoadTimeout); + startApplication(); +});

AltStyle によって変換されたページ (->オリジナル) /