phaser3-rex-plugins
Version:
2 lines (1 loc) • 3.31 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).rexawaitloaderplugin=t();}(undefined,(function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(o=n.key,i=void 0,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(o,"string"))?i:String(i)),n);}var o,i;}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t);}function o(e){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},o(e)}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function u(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return !1}}();return function(){var r,n=o(e);if(t){var i=o(this).constructor;r=Reflect.construct(n,arguments,i);}else r=n.apply(this,arguments);return u(this,r)}}var a=Phaser.Loader.FILE_POPULATED,f=Phaser.Utils.String.UUID,l=function(t){n(i,Phaser.Loader.File);var o=c(i);function i(t,r){return e(this,i),r.hasOwnProperty("type")||(r.type="await"),r.hasOwnProperty("url")||(r.url=""),r.hasOwnProperty("key")||(r.key=f()),o.call(this,t,r)}return r(i,[{key:"load",value:function(){if(this.state===a)this.loader.nextFile(this,!0);else {var e=this.config,t=e.callback,r=e.scope,n=this.onLoad.bind(this),o=this.onError.bind(this);t?r?t.call(r,n,o):t(n,o):this.onLoad();}}},{key:"onLoad",value:function(){this.loader.nextFile(this,!0);}},{key:"onError",value:function(){this.loader.nextFile(this,!1);}}]),i}(),s=Phaser.Utils.Objects.IsPlainObject,p=function(e,t){var r;(r=e)&&"function"==typeof r?t={config:{callback:e,scope:t}}:s(e)?(t=e).hasOwnProperty("config")||(t={config:t}):t={key:e,config:t};return this.addFile(new l(this,t)),this};return function(t){n(i,Phaser.Plugins.BasePlugin);var o=c(i);function i(t){var r;return e(this,i),r=o.call(this,t),t.registerFileType("rexAwait",p),r}return r(i,[{key:"addToScene",value:function(e){e.sys.load.rexAwait=p;}}]),i}()}));