mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-22 22:12:28 -05:00
1 line
No EOL
14 KiB
JavaScript
1 line
No EOL
14 KiB
JavaScript
!function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(){var e=this;i.call(e),e.runtime=new s,e.blockListener=function(t){if("object"==typeof t&&"string"==typeof t.blockId){switch(t.type){case"create":e.runtime.createBlock({id:t.blockId,opcode:t.xml.attributes.type.value});break;case"move":e.runtime.moveBlock({id:t.blockId,oldParent:t.oldParentId,oldInput:t.oldInputName,newParent:t.newParentId,newInput:t.newInputName});break;case"change":e.runtime.changeBlock({id:t.blockId});break;case"delete":e.runtime.deleteBlock({id:t.blockId})}if("undefined"!=typeof t.element)switch(t.element){case"click":e.runtime.runStack({id:t.blockId})}}}}var i=n(1),o=n(2),s=n(6);o.inherits(r,i),r.prototype.start=function(){},r.prototype.stop=function(){},r.prototype.save=function(){},r.prototype.load=function(){},e.exports=r,"undefined"!=typeof window&&(window.VirtualMachine=e.exports)},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,u,c,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:u=Array.prototype.slice.call(arguments,1),n.apply(this,u)}else if(o(n))for(u=Array.prototype.slice.call(arguments,1),l=n.slice(),i=l.length,c=0;i>c;c++)l[c].apply(this,u);return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-- >0;)if(n[u]===t||n[u].listener&&n[u].listener===t){i=u;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){(function(e,r){function i(e,n){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),v(n)?r.showHidden=n:n&&t._extend(r,n),w(r.showHidden)&&(r.showHidden=!1),w(r.depth)&&(r.depth=2),w(r.colors)&&(r.colors=!1),w(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),c(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e,t){return e}function u(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function c(e,n,r){if(e.customInspect&&n&&E(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return b(i)||(i=c(e,i,r)),i}var o=l(e,n);if(o)return o;var s=Object.keys(n),v=u(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),L(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return a(n);if(0===s.length){if(E(n)){var y=n.name?": "+n.name:"";return e.stylize("[Function"+y+"]","special")}if(_(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(S(n))return e.stylize(Date.prototype.toString.call(n),"date");if(L(n))return a(n)}var g="",m=!1,k=["{","}"];if(d(n)&&(m=!0,k=["[","]"]),E(n)){var w=n.name?": "+n.name:"";g=" [Function"+w+"]"}if(_(n)&&(g=" "+RegExp.prototype.toString.call(n)),S(n)&&(g=" "+Date.prototype.toUTCString.call(n)),L(n)&&(g=" "+a(n)),0===s.length&&(!m||0==n.length))return k[0]+g+k[1];if(0>r)return _(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special");e.seen.push(n);var x;return x=m?p(e,n,r,v,s):s.map(function(t){return f(e,n,r,v,t,m)}),e.seen.pop(),h(x,g,k)}function l(e,t){if(w(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return m(t)?e.stylize(""+t,"number"):v(t)?e.stylize(""+t,"boolean"):y(t)?e.stylize("null","null"):void 0}function a(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,n,r,i){for(var o=[],s=0,u=t.length;u>s;++s)z(t,String(s))?o.push(f(e,t,n,r,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(f(e,t,n,r,i,!0))}),o}function f(e,t,n,r,i,o){var s,u,l;if(l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},l.get?u=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(u=e.stylize("[Setter]","special")),z(r,i)||(s="["+i+"]"),u||(e.seen.indexOf(l.value)<0?(u=y(n)?c(e,l.value,null):c(e,l.value,n-1),u.indexOf("\n")>-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n"))):u=e.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return u;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function h(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function d(e){return Array.isArray(e)}function v(e){return"boolean"==typeof e}function y(e){return null===e}function g(e){return null==e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function k(e){return"symbol"==typeof e}function w(e){return void 0===e}function _(e){return x(e)&&"[object RegExp]"===O(e)}function x(e){return"object"==typeof e&&null!==e}function S(e){return x(e)&&"[object Date]"===O(e)}function L(e){return x(e)&&("[object Error]"===O(e)||e instanceof Error)}function E(e){return"function"==typeof e}function j(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function O(e){return Object.prototype.toString.call(e)}function T(e){return 10>e?"0"+e.toString(10):e.toString(10)}function I(){var e=new Date,t=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function z(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var B=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(i(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(e).replace(B,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),u=r[n];o>n;u=r[++n])s+=y(u)||!x(u)?" "+u:" "+i(u);return s},t.deprecate=function(n,i){function o(){if(!s){if(r.throwDeprecation)throw new Error(i);r.traceDeprecation?console.trace(i):console.error(i),s=!0}return n.apply(this,arguments)}if(w(e.process))return function(){return t.deprecate(n,i).apply(this,arguments)};if(r.noDeprecation===!0)return n;var s=!1;return o};var A,D={};t.debuglog=function(e){if(w(A)&&(A=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!D[e])if(new RegExp("\\b"+e+"\\b","i").test(A)){var n=r.pid;D[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else D[e]=function(){};return D[e]},t.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=v,t.isNull=y,t.isNullOrUndefined=g,t.isNumber=m,t.isString=b,t.isSymbol=k,t.isUndefined=w,t.isRegExp=_,t.isObject=x,t.isDate=S,t.isError=L,t.isFunction=E,t.isPrimitive=j,t.isBuffer=n(4);var P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(){console.log("%s - %s",I(),t.format.apply(t,arguments))},t.inherits=n(5),t._extend=function(e,t){if(!t||!x(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(t,function(){return this}(),n(3))},function(e,t){function n(){l=!1,s.length?c=s.concat(c):a=-1,c.length&&r()}function r(){if(!l){var e=setTimeout(n);l=!0;for(var t=c.length;t;){for(s=c,c=[];++a<t;)s&&s[a].run();a=-1,t=c.length}s=null,l=!1,clearTimeout(e)}}function i(e,t){this.fun=e,this.array=t}function o(){}var s,u=e.exports={},c=[],l=!1,a=-1;u.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new i(e,t)),1!==c.length||l||setTimeout(r,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=o,u.addListener=o,u.once=o,u.off=o,u.removeListener=o,u.removeAllListeners=o,u.emit=o,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){function r(){i.call(instance),this.sequencer=new u(this),this.primitives=new s,this.blocks={},this.stacks=[]}var i=n(1),o=n(2),s=n(7),u=n(8);n(10);o.inherits(r,i),r.prototype.createBlock=function(e){this.blocks[e.id]={id:e.id,opcode:e.opcode,next:null,inputs:{}},this.stacks.push(e.id)},r.prototype.moveBlock=function(e){var t=this;void 0===e.oldParent&&void 0!==e.newParent&&(t._deleteStack(e.id),void 0===e.newInput?t.blocks[e.newParent].next=e.id:t.blocks[e.newParent].inputs[e.newInput]=e.id),void 0===e.newParentId&&void 0!==e.oldParent&&(t.stacks.push(e.id),void 0===e.oldInput?t.blocks[e.oldParent].next=null:delete t.blocks[e.oldParent].inputs[e.oldInput])},r.prototype.changeBlock=function(e){},r.prototype.deleteBlock=function(e){var t=this.blocks[e.id];null!==t.next&&this.deleteBlock({id:t.next});for(var n in t.inputs)this.deleteBlock({id:t.inputs[n]});this._deleteStack(e.id),delete this.blocks[e.id]},r.prototype.runAllStacks=function(){},r.prototype.runStack=function(e){console.dir(e)},r.prototype.stopAllStacks=function(){},r.prototype._deleteStack=function(e){var t=this.stacks.indexOf(e);t>-1&&this.stacks.splice(t,1)},r.prototype._getNextBlock=function(e){return"undefined"==typeof this.blocks[e]?null:this.blocks[e].next},r.prototype._getSubstack=function(e){return"undefined"==typeof this.blocks[e]?null:this.blocks[e].inputs.SUBSTACK},e.exports=r},function(e,t){function n(){}n.prototype.event_whenflagclicked=function(e,t){return Date.now()-e.blockFirstTime<300?void(e["yield"]=!0):void 0},n.prototype.control_repeat=function(e,t){return Date.now()-e.blockFirstTime<300?void(e["yield"]=!0):(-1==e.repeatCounter&&(e.repeatCounter=10),void(e.repeatCounter>0?(e.repeatCounter-=1,t.interpreter.startSubstack(e)):(e.repeatCounter=-1,e.nextBlock=t.getNextBlock(e.blockPointer))))},n.prototype.control_forever=function(e,t){return Date.now()-e.blockFirstTime<300?void(e["yield"]=!0):void t.interpreter.startSubstack(e)},e.exports=n},function(e,t,n){function r(e){this.runtime=e,this.runningThreads=[],this.workTime=30,this.timer=new i,this.currentTime=0}var i=n(9);r.prototype.stepAllThreads=function(){},r.prototype.stepThread=function(e){},r.prototype.startSubstack=function(e){},e.exports=r},function(e,t){function n(){this.startTime=0}n.prototype.time=function(){return Date.now()},n.prototype.start=function(){this.startTime=this.time()},n.prototype.stop=function(){return this.startTime-this.time()},e.exports=n},function(e,t){function n(e){this.topBlockId=e,this.blockPointer=e,this.blockFirstTime=-1,this.nextBlock=null,this.waiting=null,this.runningDeviceBlock=!1,this.stack=[],this.repeatCounter=-1}e.exports=n}]); |