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