@scratch/scratch-vm 11.2.0-svg-sanitization.3 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VirtualMachine=t():e.VirtualMachine=t()}(global,()=>(()=>{var e={329:(e,t,r)=>{var n=r(92491),o=r(82216),i={debug:["cyan"],info:["purple"],warn:["yellow",!0],error:["red",!0]},s=new n;s.write=function(e,t,r){console.log;console[t]&&console[t].apply&&console[t].apply(console,["%c"+e+" %c"+t,o("gray"),o.apply(o,i[t])].concat(r))},s.pipe=function(){},e.exports=s},2203:e=>{"use strict";e.exports=require("stream")},4932:(e,t,r)=>{var n=r(92491),o=r(78589),i=new n,s=Array.prototype.slice;(t=e.exports=function(e){var r=function(){return i.write(e,void 0,s.call(arguments)),r};return r.debug=function(){return i.write(e,"debug",s.call(arguments)),r},r.info=function(){return i.write(e,"info",s.call(arguments)),r},r.warn=function(){return i.write(e,"warn",s.call(arguments)),r},r.error=function(){return i.write(e,"error",s.call(arguments)),r},r.log=r.debug,r.suggest=t.suggest,r.format=i.format,r}).defaultBackend=t.defaultFormatter=null,t.pipe=function(e){return i.pipe(e)},t.end=t.unpipe=t.disable=function(e){return i.unpipe(e)},t.Transform=n,t.Filter=o,t.suggest=new o,t.enable=function(){return t.defaultFormatter?i.pipe(t.suggest).pipe(t.defaultFormatter).pipe(t.defaultBackend):i.pipe(t.suggest).pipe(t.defaultBackend)}},9713:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(e,t,r){this.emit("item",(e?e+" ":"")+(t?t+" ":"")+r.join(" "))},e.exports=n},12859:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(){console.log.apply(console,arguments)};var o=new n;r(46770).R;o.filterEnv=function(){return console.error("Minilog.backends.console.filterEnv is deprecated in Minilog v2."),r(4932)},o.formatters=["formatClean","formatColor","formatNpm","formatLearnboost","formatMinilog","formatWithStack","formatTime"],o.formatClean=new(r(9713)),o.formatColor=new(r(90303)),o.formatNpm=new(r(36093)),o.formatLearnboost=new(r(83195)),o.formatMinilog=new(r(92391)),o.formatWithStack=new(r(61280)),o.formatTime=new(r(86139)),e.exports=o},27397:(e,t,r)=>{e.exports=r(4932);var n=r(12859);"undefined"!=typeof window&&window.process&&"renderer"===window.process.type&&(n=r(79925).minilog),e.exports.Stringifier=r(79403);var o=e.exports.pipe;e.exports.pipe=function(t){return t instanceof r(2203)?o.call(e.exports,new e.exports.Stringifier).pipe(t):o.call(e.exports,t)},e.exports.defaultBackend=n,e.exports.defaultFormatter=n.formatMinilog,e.exports.backends={redis:r(64373),nodeConsole:n,console:n}},36093:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(e,t,r){var n={debug:"[34;40mdebug[39m ",info:"[32minfo[39m ",warn:"[30;41mWARN[0m ",error:"[31;40mERR![0m "};this.emit("item",(e?"[37;40m"+e+"[0m ":"")+(t&&n[t]?n[t]:"")+r.join(" "))},e.exports=n},39023:e=>{"use strict";e.exports=require("util")},39274:e=>{e.exports={BOOLEAN:"Boolean",BUTTON:"button",COMMAND:"command",CONDITIONAL:"conditional",EVENT:"event",HAT:"hat",LOOP:"loop",REPORTER:"reporter"}},46770:(e,t)=>{var r={bold:["[1m","[22m"],italic:["[3m","[23m"],underline:["[4m","[24m"],inverse:["[7m","[27m"],white:["[37m","[39m"],grey:["[90m","[39m"],black:["[30m","[39m"],blue:["[34m","[39m"],cyan:["[36m","[39m"],green:["[32m","[39m"],magenta:["[35m","[39m"],red:["[31m","[39m"],yellow:["[33m","[39m"]};t.R={debug:1,info:2,warn:3,error:4},t.i=function(e,t){return r[t][0]+e+r[t][1]}},49432:e=>{e.exports={SPRITE:"sprite",STAGE:"stage"}},56342:e=>{e.exports={ANGLE:"angle",BOOLEAN:"Boolean",COLOR:"color",NUMBER:"number",STRING:"string",MATRIX:"matrix",NOTE:"note",IMAGE:"image"}},61280:(e,t,r)=>{var n=r(92491),o=r(46770).i;function i(){}function s(e){return e}n.mixin(i);var a={string:s,number:s,default:JSON.stringify.bind(JSON)};i.prototype.write=function(e,t,r){var n,s=function(){var e=Error.prepareStackTrace;Error.prepareStackTrace=function(e,t){return t};var t=new Error;Error.captureStackTrace(t,arguments.callee);var r=t.stack;return Error.prepareStackTrace=e,r}()[5],c=i.fullPath?s.getFileName():s.getFileName().replace(/^.*\/(.+)$/,"/$1");this.emit("item",(e?e+" ":"")+(t?o(4==(n=t).toString().length?" "+n:n,{debug:"magenta",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+o(c+":"+s.getLineNumber(),"grey")+" "+function(e){return e.map(function(e){return(a[typeof e]||a.default)(e)})}(r).join(" "))},i.fullPath=!0,e.exports=i},63260:(e,t,r)=>{const n=r(92589),o=r(73707);e.exports=new class extends n{constructor(){super(),this._connectionPromise=new Promise(e=>{this._onConnect=e}),this.services={},this._onMessage=this._onMessage.bind(this,self),"undefined"!=typeof self&&(self.onmessage=this._onMessage)}get waitForConnection(){return this._connectionPromise}setService(e,t){return Object.prototype.hasOwnProperty.call(this.services,e)&&o.warn("Worker dispatch replacing existing service provider for ".concat(e)),this.services[e]=t,this.waitForConnection.then(()=>this._remoteCall(self,"dispatch","setService",e))}_getServiceProvider(e){const t=this.services[e];return{provider:t||self,isRemote:!t}}_onDispatchMessage(e,t){let r;switch(t.method){case"handshake":r=this._onConnect();break;case"terminate":setTimeout(()=>self.close(),0),r=Promise.resolve();break;default:o.error("Worker dispatch received message for unknown method: ".concat(t.method))}return r}}},64373:e=>{function t(e){this.client=e.client,this.key=e.key}t.prototype.write=function(e){this.client.rpush(this.key,e)},t.prototype.end=function(){},t.prototype.clear=function(e){this.client.del(this.key,e)},e.exports=t},73707:(e,t,r)=>{const n=r(27397);n.enable(),e.exports=n("vm")},78589:(e,t,r)=>{var n=r(92491),o={debug:1,info:2,warn:3,error:4};function i(){this.enabled=!0,this.defaultResult=!0,this.clear()}function s(e,t){return e.n.test?e.n.test(t):e.n==t}n.mixin(i),i.prototype.allow=function(e,t){return this._white.push({n:e,l:o[t]}),this},i.prototype.deny=function(e,t){return this._black.push({n:e,l:o[t]}),this},i.prototype.clear=function(){return this._white=[],this._black=[],this},i.prototype.test=function(e,t){var r,n=Math.max(this._white.length,this._black.length);for(r=0;r<n;r++){if(this._white[r]&&s(this._white[r],e)&&o[t]>=this._white[r].l)return!0;if(this._black[r]&&s(this._black[r],e)&&o[t]<=this._black[r].l)return!1}return this.defaultResult},i.prototype.write=function(e,t,r){if(!this.enabled||this.test(e,t))return this.emit("item",e,t,r)},e.exports=i},79403:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(e,t,r){var n=[];e&&n.push(e),t&&n.push(t),n=n.concat(r);for(var o=0;o<n.length;o++)if(n[o]&&"object"==typeof n[o])if(n[o].constructor&&n[o].constructor.isBuffer)n[o]=n[o].toString();else try{n[o]=JSON.stringify(n[o])}catch(e){}else n[o]=n[o];this.emit("item",n.join(" ")+"\n")},e.exports=n},79925:(e,t,r)=>{var n=r(92491),o=/\n+$/,i=new n;i.write=function(e,t,r){var n=r.length-1;if("undefined"!=typeof console&&console.log){if(console.log.apply)return console.log.apply(console,[e,t].concat(r));if(JSON&&JSON.stringify){r[n]&&"string"==typeof r[n]&&(r[n]=r[n].replace(o,""));try{for(n=0;n<r.length;n++)r[n]=JSON.stringify(r[n])}catch(e){}console.log(r.join(" "))}}},i.formatters=["color","minilog"],i.color=r(329),i.minilog=r(88933),e.exports=i},81920:e=>{function t(){this._events={}}t.prototype={on:function(e,t){this._events||(this._events={});var r=this._events;return(r[e]||(r[e]=[])).push(t),this},removeListener:function(e,t){var r,n=this._events[e]||[];for(r=n.length-1;r>=0&&n[r];r--)n[r]!==t&&n[r].cb!==t||n.splice(r,1)},removeAllListeners:function(e){e?this._events[e]&&(this._events[e]=[]):this._events={}},listeners:function(e){return this._events&&this._events[e]||[]},emit:function(e){this._events||(this._events={});var t,r=Array.prototype.slice.call(arguments,1),n=this._events[e]||[];for(t=n.length-1;t>=0&&n[t];t--)n[t].apply(this,r);return this},when:function(e,t){return this.once(e,t,!0)},once:function(e,t,r){if(!t)return this;function n(){r||this.removeListener(e,n),t.apply(this,arguments)&&r&&this.removeListener(e,n)}return n.cb=t,this.on(e,n),this}},t.mixin=function(e){var r,n=t.prototype;for(r in n)n.hasOwnProperty(r)&&(e.prototype[r]=n[r])},e.exports=t},82216:e=>{var t={black:"#000",red:"#c23621",green:"#25bc26",yellow:"#bbbb00",blue:"#492ee1",magenta:"#d338d3",cyan:"#33bbc8",gray:"#808080",purple:"#708"};e.exports=function(e,r){return r?"color: #fff; background: "+t[e]+";":"color: "+t[e]+";"}},83195:(e,t,r)=>{var n=r(92491),o=r(46770).i;function i(){}n.mixin(i),i.prototype.write=function(e,t,r){this.emit("item",(e?o(e+" ","grey"):"")+(t?o(t,{debug:"grey",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.join(" "))},e.exports=i},86139:(e,t,r)=>{var n=r(92491),o=r(46770).i,i=r(39023);function s(){}n.mixin(s),s.prototype.write=function(e,t,r){var n;this.emit("item",o(("0"+(n=new Date).getDate()).slice(-2)+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+n.getFullYear()+" "+("0"+n.getHours()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+" ","grey")+(e?o(e+" ","grey"):"")+(t?o(t,{debug:"blue",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.map(function(e){return"string"==typeof e?e:i.inspect(e,null,3,!0)}).join(" "))},e.exports=s},88933:(e,t,r)=>{var n=r(92491),o=r(82216),i={debug:["gray"],info:["purple"],warn:["yellow",!0],error:["red",!0]},s=new n;s.write=function(e,t,r){var n=console.log;"debug"!=t&&console[t]&&(n=console[t]);var s=0;if("info"!=t){for(;s<r.length&&"string"==typeof r[s];s++);n.apply(console,["%c"+e+" "+r.slice(0,s).join(" "),o.apply(o,i[t])].concat(r.slice(s)))}else n.apply(console,["%c"+e,o.apply(o,i[t])].concat(r))},s.pipe=function(){},e.exports=s},90303:(e,t,r)=>{var n=r(92491),o=r(46770).i;function i(){}n.mixin(i),i.prototype.write=function(e,t,r){var n;this.emit("item",(e?e+" ":"")+(t?o("- "+((4==(n=t.toUpperCase()).toString().length?" "+n:n)+" -"),{debug:"magenta",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.join(" "))},e.exports=i},92391:(e,t,r)=>{var n=r(92491),o=r(46770).i,i=r(39023);function s(){}n.mixin(s),s.prototype.write=function(e,t,r){this.emit("item",(e?o(e+" ","grey"):"")+(t?o(t,{debug:"blue",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.map(function(e){return"string"==typeof e?e:i.inspect(e,null,3,!0)}).join(" "))},e.exports=s},92491:(e,t,r)=>{function n(){}r(81920).mixin(n),n.prototype.write=function(e,t,r){this.emit("item",e,t,r)},n.prototype.end=function(){this.emit("end"),this.removeAllListeners()},n.prototype.pipe=function(e){var t=this;function r(){e.write.apply(e,Array.prototype.slice.call(arguments))}function n(){!e._isStdio&&e.end()}return t.emit("unpipe",e),e.emit("pipe",t),t.on("item",r),t.on("end",n),t.when("unpipe",function(o){var i=o===e||void 0===o;return i&&(t.removeListener("item",r),t.removeListener("end",n),e.emit("unpipe")),i}),e},n.prototype.unpipe=function(e){return this.emit("unpipe",e),this},n.prototype.format=function(e){throw new Error(["Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:","var Minilog = require('minilog');","Minilog"," .pipe(Minilog.backends.console.formatClean)"," .pipe(Minilog.backends.console);"].join("\n"))},n.mixin=function(e){var t,r=n.prototype;for(t in r)r.hasOwnProperty(t)&&(e.prototype[t]=r[t])},e.exports=n},92589:(e,t,r)=>{const n=r(73707);e.exports=class{constructor(){this.callbacks=[],this.nextResponseId=0}call(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];return this.transferCall(e,t,null,...n)}transferCall(e,t,r){try{const{provider:s,isRemote:a}=this._getServiceProvider(e);if(s){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];if(a)return this._remoteTransferCall(s,e,t,r,...o);const c=s[t].apply(s,o);return Promise.resolve(c)}return Promise.reject(new Error("Service not found: ".concat(e)))}catch(e){return Promise.reject(e)}}_isRemoteService(e){return this._getServiceProvider(e).isRemote}_remoteCall(e,t,r){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];return this._remoteTransferCall(e,t,r,null,...o)}_remoteTransferCall(e,t,r,n){for(var o=arguments.length,i=new Array(o>4?o-4:0),s=4;s<o;s++)i[s-4]=arguments[s];return new Promise((o,s)=>{const a=this._storeCallbacks(o,s);i.length>0&&"function"==typeof i[i.length-1].yield&&i.pop(),n?e.postMessage({service:t,method:r,responseId:a,args:i},n):e.postMessage({service:t,method:r,responseId:a,args:i})})}_storeCallbacks(e,t){const r=this.nextResponseId++;return this.callbacks[r]=[e,t],r}_deliverResponse(e,t){try{const[r,n]=this.callbacks[e];delete this.callbacks[e],t.error?n(t.error):r(t.result)}catch(e){n.error("Dispatch callback failed: ".concat(JSON.stringify(e)))}}_onMessage(e,t){const r=t.data;let o;r.args=r.args||[],r.service?o="dispatch"===r.service?this._onDispatchMessage(e,r):this.call(r.service,r.method,...r.args):void 0===r.responseId?n.error("Dispatch caught malformed message from a worker: ".concat(JSON.stringify(t))):this._deliverResponse(r.responseId,r),o&&(void 0===r.responseId?n.error("Dispatch message missing required response ID: ".concat(JSON.stringify(t))):o.then(t=>e.postMessage({responseId:r.responseId,result:t}),t=>e.postMessage({responseId:r.responseId,error:t})))}_getServiceProvider(e){throw new Error("Could not get provider for ".concat(e,": _getServiceProvider not implemented"))}_onDispatchMessage(e,t){throw new Error("Unimplemented dispatch message handler cannot handle ".concat(t.method," method"))}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}const n=r(56342),o=r(39274),i=r(63260),s=r(49432);global.Scratch=global.Scratch||{},global.Scratch.ArgumentType=n,global.Scratch.BlockType=o,global.Scratch.TargetType=s;const a=new class{constructor(){this.nextExtensionId=0,this.initialRegistrations=[],i.waitForConnection.then(()=>{i.call("extensions","allocateWorker").then(e=>{const[t,r]=e;this.workerId=t;try{importScripts(r);const e=this.initialRegistrations;this.initialRegistrations=null,Promise.all(e).then(()=>i.call("extensions","onWorkerInit",t))}catch(e){i.call("extensions","onWorkerInit",t,e)}})}),this.extensions=[]}register(e){const t=this.nextExtensionId++;this.extensions.push(e);const r="extension.".concat(this.workerId,".").concat(t),n=i.setService(r,e).then(()=>i.call("extensions","registerExtensionService",r));return this.initialRegistrations&&this.initialRegistrations.push(n),n}};return global.Scratch.extensions={register:a.register.bind(a)},{}})());
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VirtualMachine=t():e.VirtualMachine=t()}(global,(()=>(()=>{var e={329:(e,t,r)=>{var n=r(92491),o=r(82216),i={debug:["cyan"],info:["purple"],warn:["yellow",!0],error:["red",!0]},s=new n;s.write=function(e,t,r){console.log;console[t]&&console[t].apply&&console[t].apply(console,["%c"+e+" %c"+t,o("gray"),o.apply(o,i[t])].concat(r))},s.pipe=function(){},e.exports=s},2203:e=>{"use strict";e.exports=require("stream")},4932:(e,t,r)=>{var n=r(92491),o=r(78589),i=new n,s=Array.prototype.slice;(t=e.exports=function(e){var r=function(){return i.write(e,void 0,s.call(arguments)),r};return r.debug=function(){return i.write(e,"debug",s.call(arguments)),r},r.info=function(){return i.write(e,"info",s.call(arguments)),r},r.warn=function(){return i.write(e,"warn",s.call(arguments)),r},r.error=function(){return i.write(e,"error",s.call(arguments)),r},r.log=r.debug,r.suggest=t.suggest,r.format=i.format,r}).defaultBackend=t.defaultFormatter=null,t.pipe=function(e){return i.pipe(e)},t.end=t.unpipe=t.disable=function(e){return i.unpipe(e)},t.Transform=n,t.Filter=o,t.suggest=new o,t.enable=function(){return t.defaultFormatter?i.pipe(t.suggest).pipe(t.defaultFormatter).pipe(t.defaultBackend):i.pipe(t.suggest).pipe(t.defaultBackend)}},9713:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(e,t,r){this.emit("item",(e?e+" ":"")+(t?t+" ":"")+r.join(" "))},e.exports=n},12859:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(){console.log.apply(console,arguments)};var o=new n;r(46770).R;o.filterEnv=function(){return console.error("Minilog.backends.console.filterEnv is deprecated in Minilog v2."),r(4932)},o.formatters=["formatClean","formatColor","formatNpm","formatLearnboost","formatMinilog","formatWithStack","formatTime"],o.formatClean=new(r(9713)),o.formatColor=new(r(90303)),o.formatNpm=new(r(36093)),o.formatLearnboost=new(r(83195)),o.formatMinilog=new(r(92391)),o.formatWithStack=new(r(61280)),o.formatTime=new(r(86139)),e.exports=o},27397:(e,t,r)=>{e.exports=r(4932);var n=r(12859);"undefined"!=typeof window&&window.process&&"renderer"===window.process.type&&(n=r(79925).minilog),e.exports.Stringifier=r(79403);var o=e.exports.pipe;e.exports.pipe=function(t){return t instanceof r(2203)?o.call(e.exports,new e.exports.Stringifier).pipe(t):o.call(e.exports,t)},e.exports.defaultBackend=n,e.exports.defaultFormatter=n.formatMinilog,e.exports.backends={redis:r(64373),nodeConsole:n,console:n}},36093:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(e,t,r){var n={debug:"[34;40mdebug[39m ",info:"[32minfo[39m ",warn:"[30;41mWARN[0m ",error:"[31;40mERR![0m "};this.emit("item",(e?"[37;40m"+e+"[0m ":"")+(t&&n[t]?n[t]:"")+r.join(" "))},e.exports=n},39023:e=>{"use strict";e.exports=require("util")},39274:e=>{e.exports={BOOLEAN:"Boolean",BUTTON:"button",COMMAND:"command",CONDITIONAL:"conditional",EVENT:"event",HAT:"hat",LOOP:"loop",REPORTER:"reporter"}},46770:(e,t)=>{var r={bold:["[1m","[22m"],italic:["[3m","[23m"],underline:["[4m","[24m"],inverse:["[7m","[27m"],white:["[37m","[39m"],grey:["[90m","[39m"],black:["[30m","[39m"],blue:["[34m","[39m"],cyan:["[36m","[39m"],green:["[32m","[39m"],magenta:["[35m","[39m"],red:["[31m","[39m"],yellow:["[33m","[39m"]};t.R={debug:1,info:2,warn:3,error:4},t.i=function(e,t){return r[t][0]+e+r[t][1]}},49432:e=>{e.exports={SPRITE:"sprite",STAGE:"stage"}},56342:e=>{e.exports={ANGLE:"angle",BOOLEAN:"Boolean",COLOR:"color",NUMBER:"number",STRING:"string",MATRIX:"matrix",NOTE:"note",IMAGE:"image"}},61280:(e,t,r)=>{var n=r(92491),o=r(46770).i;function i(){}function s(e){return e}n.mixin(i);var a={string:s,number:s,default:JSON.stringify.bind(JSON)};i.prototype.write=function(e,t,r){var n,s=function(){var e=Error.prepareStackTrace;Error.prepareStackTrace=function(e,t){return t};var t=new Error;Error.captureStackTrace(t,arguments.callee);var r=t.stack;return Error.prepareStackTrace=e,r}()[5],c=i.fullPath?s.getFileName():s.getFileName().replace(/^.*\/(.+)$/,"/$1");this.emit("item",(e?e+" ":"")+(t?o(4==(n=t).toString().length?" "+n:n,{debug:"magenta",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+o(c+":"+s.getLineNumber(),"grey")+" "+function(e){return e.map((function(e){return(a[typeof e]||a.default)(e)}))}(r).join(" "))},i.fullPath=!0,e.exports=i},63260:(e,t,r)=>{const n=r(92589),o=r(73707);e.exports=new class extends n{constructor(){super(),this._connectionPromise=new Promise((e=>{this._onConnect=e})),this.services={},this._onMessage=this._onMessage.bind(this,self),"undefined"!=typeof self&&(self.onmessage=this._onMessage)}get waitForConnection(){return this._connectionPromise}setService(e,t){return Object.prototype.hasOwnProperty.call(this.services,e)&&o.warn("Worker dispatch replacing existing service provider for ".concat(e)),this.services[e]=t,this.waitForConnection.then((()=>this._remoteCall(self,"dispatch","setService",e)))}_getServiceProvider(e){const t=this.services[e];return{provider:t||self,isRemote:!t}}_onDispatchMessage(e,t){let r;switch(t.method){case"handshake":r=this._onConnect();break;case"terminate":setTimeout((()=>self.close()),0),r=Promise.resolve();break;default:o.error("Worker dispatch received message for unknown method: ".concat(t.method))}return r}}},64373:e=>{function t(e){this.client=e.client,this.key=e.key}t.prototype.write=function(e){this.client.rpush(this.key,e)},t.prototype.end=function(){},t.prototype.clear=function(e){this.client.del(this.key,e)},e.exports=t},73707:(e,t,r)=>{const n=r(27397);n.enable(),e.exports=n("vm")},78589:(e,t,r)=>{var n=r(92491),o={debug:1,info:2,warn:3,error:4};function i(){this.enabled=!0,this.defaultResult=!0,this.clear()}function s(e,t){return e.n.test?e.n.test(t):e.n==t}n.mixin(i),i.prototype.allow=function(e,t){return this._white.push({n:e,l:o[t]}),this},i.prototype.deny=function(e,t){return this._black.push({n:e,l:o[t]}),this},i.prototype.clear=function(){return this._white=[],this._black=[],this},i.prototype.test=function(e,t){var r,n=Math.max(this._white.length,this._black.length);for(r=0;r<n;r++){if(this._white[r]&&s(this._white[r],e)&&o[t]>=this._white[r].l)return!0;if(this._black[r]&&s(this._black[r],e)&&o[t]<=this._black[r].l)return!1}return this.defaultResult},i.prototype.write=function(e,t,r){if(!this.enabled||this.test(e,t))return this.emit("item",e,t,r)},e.exports=i},79403:(e,t,r)=>{function n(){}r(92491).mixin(n),n.prototype.write=function(e,t,r){var n=[];e&&n.push(e),t&&n.push(t),n=n.concat(r);for(var o=0;o<n.length;o++)if(n[o]&&"object"==typeof n[o])if(n[o].constructor&&n[o].constructor.isBuffer)n[o]=n[o].toString();else try{n[o]=JSON.stringify(n[o])}catch(e){}else n[o]=n[o];this.emit("item",n.join(" ")+"\n")},e.exports=n},79925:(e,t,r)=>{var n=r(92491),o=/\n+$/,i=new n;i.write=function(e,t,r){var n=r.length-1;if("undefined"!=typeof console&&console.log){if(console.log.apply)return console.log.apply(console,[e,t].concat(r));if(JSON&&JSON.stringify){r[n]&&"string"==typeof r[n]&&(r[n]=r[n].replace(o,""));try{for(n=0;n<r.length;n++)r[n]=JSON.stringify(r[n])}catch(e){}console.log(r.join(" "))}}},i.formatters=["color","minilog"],i.color=r(329),i.minilog=r(88933),e.exports=i},81920:e=>{function t(){this._events={}}t.prototype={on:function(e,t){this._events||(this._events={});var r=this._events;return(r[e]||(r[e]=[])).push(t),this},removeListener:function(e,t){var r,n=this._events[e]||[];for(r=n.length-1;r>=0&&n[r];r--)n[r]!==t&&n[r].cb!==t||n.splice(r,1)},removeAllListeners:function(e){e?this._events[e]&&(this._events[e]=[]):this._events={}},listeners:function(e){return this._events&&this._events[e]||[]},emit:function(e){this._events||(this._events={});var t,r=Array.prototype.slice.call(arguments,1),n=this._events[e]||[];for(t=n.length-1;t>=0&&n[t];t--)n[t].apply(this,r);return this},when:function(e,t){return this.once(e,t,!0)},once:function(e,t,r){if(!t)return this;function n(){r||this.removeListener(e,n),t.apply(this,arguments)&&r&&this.removeListener(e,n)}return n.cb=t,this.on(e,n),this}},t.mixin=function(e){var r,n=t.prototype;for(r in n)n.hasOwnProperty(r)&&(e.prototype[r]=n[r])},e.exports=t},82216:e=>{var t={black:"#000",red:"#c23621",green:"#25bc26",yellow:"#bbbb00",blue:"#492ee1",magenta:"#d338d3",cyan:"#33bbc8",gray:"#808080",purple:"#708"};e.exports=function(e,r){return r?"color: #fff; background: "+t[e]+";":"color: "+t[e]+";"}},83195:(e,t,r)=>{var n=r(92491),o=r(46770).i;function i(){}n.mixin(i),i.prototype.write=function(e,t,r){this.emit("item",(e?o(e+" ","grey"):"")+(t?o(t,{debug:"grey",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.join(" "))},e.exports=i},86139:(e,t,r)=>{var n=r(92491),o=r(46770).i,i=r(39023);function s(){}n.mixin(s),s.prototype.write=function(e,t,r){var n;this.emit("item",o(("0"+(n=new Date).getDate()).slice(-2)+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+n.getFullYear()+" "+("0"+n.getHours()).slice(-2)+":"+("0"+n.getMinutes()).slice(-2)+":"+("0"+n.getSeconds()).slice(-2)+"."+("00"+n.getMilliseconds()).slice(-3)+" ","grey")+(e?o(e+" ","grey"):"")+(t?o(t,{debug:"blue",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.map((function(e){return"string"==typeof e?e:i.inspect(e,null,3,!0)})).join(" "))},e.exports=s},88933:(e,t,r)=>{var n=r(92491),o=r(82216),i={debug:["gray"],info:["purple"],warn:["yellow",!0],error:["red",!0]},s=new n;s.write=function(e,t,r){var n=console.log;"debug"!=t&&console[t]&&(n=console[t]);var s=0;if("info"!=t){for(;s<r.length&&"string"==typeof r[s];s++);n.apply(console,["%c"+e+" "+r.slice(0,s).join(" "),o.apply(o,i[t])].concat(r.slice(s)))}else n.apply(console,["%c"+e,o.apply(o,i[t])].concat(r))},s.pipe=function(){},e.exports=s},90303:(e,t,r)=>{var n=r(92491),o=r(46770).i;function i(){}n.mixin(i),i.prototype.write=function(e,t,r){var n;this.emit("item",(e?e+" ":"")+(t?o("- "+((4==(n=t.toUpperCase()).toString().length?" "+n:n)+" -"),{debug:"magenta",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.join(" "))},e.exports=i},92391:(e,t,r)=>{var n=r(92491),o=r(46770).i,i=r(39023);function s(){}n.mixin(s),s.prototype.write=function(e,t,r){this.emit("item",(e?o(e+" ","grey"):"")+(t?o(t,{debug:"blue",info:"cyan",warn:"yellow",error:"red"}[t])+" ":"")+r.map((function(e){return"string"==typeof e?e:i.inspect(e,null,3,!0)})).join(" "))},e.exports=s},92491:(e,t,r)=>{function n(){}r(81920).mixin(n),n.prototype.write=function(e,t,r){this.emit("item",e,t,r)},n.prototype.end=function(){this.emit("end"),this.removeAllListeners()},n.prototype.pipe=function(e){var t=this;function r(){e.write.apply(e,Array.prototype.slice.call(arguments))}function n(){!e._isStdio&&e.end()}return t.emit("unpipe",e),e.emit("pipe",t),t.on("item",r),t.on("end",n),t.when("unpipe",(function(o){var i=o===e||void 0===o;return i&&(t.removeListener("item",r),t.removeListener("end",n),e.emit("unpipe")),i})),e},n.prototype.unpipe=function(e){return this.emit("unpipe",e),this},n.prototype.format=function(e){throw new Error(["Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:","var Minilog = require('minilog');","Minilog"," .pipe(Minilog.backends.console.formatClean)"," .pipe(Minilog.backends.console);"].join("\n"))},n.mixin=function(e){var t,r=n.prototype;for(t in r)r.hasOwnProperty(t)&&(e.prototype[t]=r[t])},e.exports=n},92589:(e,t,r)=>{const n=r(73707);e.exports=class{constructor(){this.callbacks=[],this.nextResponseId=0}call(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];return this.transferCall(e,t,null,...n)}transferCall(e,t,r){try{const{provider:s,isRemote:a}=this._getServiceProvider(e);if(s){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];if(a)return this._remoteTransferCall(s,e,t,r,...o);const c=s[t].apply(s,o);return Promise.resolve(c)}return Promise.reject(new Error("Service not found: ".concat(e)))}catch(e){return Promise.reject(e)}}_isRemoteService(e){return this._getServiceProvider(e).isRemote}_remoteCall(e,t,r){for(var n=arguments.length,o=new Array(n>3?n-3:0),i=3;i<n;i++)o[i-3]=arguments[i];return this._remoteTransferCall(e,t,r,null,...o)}_remoteTransferCall(e,t,r,n){for(var o=arguments.length,i=new Array(o>4?o-4:0),s=4;s<o;s++)i[s-4]=arguments[s];return new Promise(((o,s)=>{const a=this._storeCallbacks(o,s);i.length>0&&"function"==typeof i[i.length-1].yield&&i.pop(),n?e.postMessage({service:t,method:r,responseId:a,args:i},n):e.postMessage({service:t,method:r,responseId:a,args:i})}))}_storeCallbacks(e,t){const r=this.nextResponseId++;return this.callbacks[r]=[e,t],r}_deliverResponse(e,t){try{const[r,n]=this.callbacks[e];delete this.callbacks[e],t.error?n(t.error):r(t.result)}catch(e){n.error("Dispatch callback failed: ".concat(JSON.stringify(e)))}}_onMessage(e,t){const r=t.data;let o;r.args=r.args||[],r.service?o="dispatch"===r.service?this._onDispatchMessage(e,r):this.call(r.service,r.method,...r.args):void 0===r.responseId?n.error("Dispatch caught malformed message from a worker: ".concat(JSON.stringify(t))):this._deliverResponse(r.responseId,r),o&&(void 0===r.responseId?n.error("Dispatch message missing required response ID: ".concat(JSON.stringify(t))):o.then((t=>e.postMessage({responseId:r.responseId,result:t})),(t=>e.postMessage({responseId:r.responseId,error:t}))))}_getServiceProvider(e){throw new Error("Could not get provider for ".concat(e,": _getServiceProvider not implemented"))}_onDispatchMessage(e,t){throw new Error("Unimplemented dispatch message handler cannot handle ".concat(t.method," method"))}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}const n=r(56342),o=r(39274),i=r(63260),s=r(49432);global.Scratch=global.Scratch||{},global.Scratch.ArgumentType=n,global.Scratch.BlockType=o,global.Scratch.TargetType=s;const a=new class{constructor(){this.nextExtensionId=0,this.initialRegistrations=[],i.waitForConnection.then((()=>{i.call("extensions","allocateWorker").then((e=>{const[t,r]=e;this.workerId=t;try{importScripts(r);const e=this.initialRegistrations;this.initialRegistrations=null,Promise.all(e).then((()=>i.call("extensions","onWorkerInit",t)))}catch(e){i.call("extensions","onWorkerInit",t,e)}}))})),this.extensions=[]}register(e){const t=this.nextExtensionId++;this.extensions.push(e);const r="extension.".concat(this.workerId,".").concat(t),n=i.setService(r,e).then((()=>i.call("extensions","registerExtensionService",r)));return this.initialRegistrations&&this.initialRegistrations.push(n),n}};return global.Scratch.extensions={register:a.register.bind(a)},{}})()));
|
|
2
2
|
//# sourceMappingURL=extension-worker.js.map
|