dragonbones-tools
Version:
Dragonbones tools.
1 lines • 30.4 kB
JavaScript
"use strict";var __reflect=this&&this.__reflect||function(t,e,n){t.__class__=e,n?n.push(e):n=[e],t.__types__=t.__types__?n.concat(t.__types__):n},__extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n},__awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(a,o){function i(t){try{l(r.next(t))}catch(e){o(e)}}function s(t){try{l(r["throw"](t))}catch(e){o(e)}}function l(t){t.done?a(t.value):new n(function(e){e(t.value)}).then(i,s)}l((r=r.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){function n(t){return function(e){return r([t,e])}}function r(n){if(a)throw new TypeError("Generator is already executing.");for(;l;)try{if(a=1,o&&(i=o[2&n[0]?"return":n[0]?"throw":"next"])&&!(i=i.call(o,n[1])).done)return i;switch(o=0,i&&(n=[0,i.value]),n[0]){case 0:case 1:i=n;break;case 4:return l.label++,{value:n[1],done:!1};case 5:l.label++,o=n[1],n=[0];continue;case 7:n=l.ops.pop(),l.trys.pop();continue;default:if(i=l.trys,!(i=i.length>0&&i[i.length-1])&&(6===n[0]||2===n[0])){l=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]<i[3])){l.label=n[1];break}if(6===n[0]&&l.label<i[1]){l.label=i[1],i=n;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(n);break}i[2]&&l.ops.pop(),l.trys.pop();continue}n=e.call(t,l)}catch(r){n=[6,r],o=0}finally{a=i=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var a,o,i,s,l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:n(0),"throw":n(1),"return":n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s},common;!function(t){function e(t){for(var e in t)delete t[e]}function n(t){var e=String(t),n=l[e];return n||(n=l[e]=r(t)),n}function r(t){var e=c[String(t)];if(e&&e.length>0){var n=e.pop();return n}var r=new t;return r._onClear(),r}function a(t,e){if((0>e||e!==e)&&(e=0),t){var n=String(t),r=c[n];u[n]=e,r&&r.length>e&&(r.length=e)}else{i=e;for(var n in c){var r=c[n];r.length>e&&(r.length=e),n in u&&(u[n]=e)}}}function o(t){if(t){var e=c[String(t)];e&&e.length&&(e.length=0)}else for(var n in c){var e=c[n];e.length=0}}var i=3e3,s=0,l={},u={},c={};t.clearMap=e,t.getInstance=n,t.create=r,t.setMaxCount=a,t.clear=o;var p=function(){function t(){this.hashCode=s++}return t.toString=function(){throw new Error},t.prototype.release=function(){this._onClear();var t=String(this.constructor),e=t in u?i:u[t],n=c[t]=c[t]||[];n.length<e&&(console.assert(n.indexOf(this)<0),n.push(this))},t.prototype.dispose=function(){this._onClear()},t}();t.BaseObject=p,__reflect(p.prototype,"common.BaseObject")}(common||(common={}));var common;!function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.data=null,e}return __extends(e,t),e.toString=function(){return"[class common.Event]"},e.prototype._onClear=function(){this.type="",this.target=null,this.currentTarget=null,this.data=null},e.prototype.copyFrom=function(t){return this.type=t.type,this.target=t.target,this.currentTarget=t.currentTarget,this.data=t.data,this},e}(t.BaseObject);t.Event=e,__reflect(e.prototype,"common.Event");var n=function(n){function r(){var t=null!==n&&n.apply(this,arguments)||this;return t._listenerBins={},t}return __extends(r,n),r.toString=function(){return"[class common.EventDispatcher]"},r.prototype._onClear=function(){this.enabled=!0,this._dipatchLevel=0,t.clearMap(this._listenerBins)},r.prototype._sortListeners=function(t,e){return t.priority>e.priority?1:-1},r.prototype._isSameListener=function(t,e){return t===e},r.prototype.hasEventListener=function(t){return t in this._listenerBins[t]},r.prototype.addEventListener=function(t,e,n,r,a){void 0===r&&(r=null),void 0===a&&(a=0),this.removeEventListener(t,e);var o=this._listenerBins[t];o?0!==this._dipatchLevel&&(this._listenerBins[t]=o=o.concat()):this._listenerBins[t]=o=[],o.push({listener:e,thisTarget:n,data:r,priority:a}),o.sort(this._sortListeners)},r.prototype.removeEventListener=function(t,e,n){void 0===n&&(n=null);var r=this._listenerBins[t];if(r){0!==this._dipatchLevel&&(this._listenerBins[t]=r=r.concat());for(var a=0,o=r.length;o>a;++a){var i=r[a];if(i.listener===e&&this._isSameListener(i.data,n)){r.splice(a,1);break}}}},r.prototype.removeEventListeners=function(t){if(t)delete this._listenerBins[t];else for(var e in this._listenerBins)delete this._listenerBins[e]},r.prototype.dispatchEvent=function(t){var e=t.type,n=this._listenerBins[e];if(n){t.target=this,t.currentTarget||(t.currentTarget=t.target),this._dipatchLevel++;for(var r=0,a=n;r<a.length;r++){var o=a[r];o.listener.call(o.thisTarget,t,o.data)}this._dipatchLevel--}},r.prototype.dispatchEventWith=function(n,r){if(this.enabled){var a=t.create(e);a.type=n,a.data=r,this.dispatchEvent(a),a.release()}},r}(t.BaseObject);t.EventDispatcher=n,__reflect(n.prototype,"common.EventDispatcher",["common.IEventDispatcher"])}(common||(common={}));var common;!function(t){function e(t,e){for(var n=0,r=e;n<r.length;n++){var a=r[n];if(a.component===t)return a}return null}t.getViewByComponent=e;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.toString=function(){return"[class common.Notification]"},e.prototype._onClear=function(){this.type="",this.target=null,this.data=null},e}(t.BaseObject);t.Notification=n,__reflect(n.prototype,"common.Notification");var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype._onClear=function(){this._context=null},e.prototype.sendNotification=function(t,e){this._context.sendNotification(t,e,this)},Object.defineProperty(e.prototype,"controller",{get:function(){return this._context.controller},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"application",{get:function(){return this._context.application},enumerable:!0,configurable:!0}),e}(t.BaseObject);t.Model=r,__reflect(r.prototype,"common.Model");var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.model=null,this.component=null,this._context=null},e.prototype._notificationListenerHandler=function(t,e){e.call(this,t.data)},e.prototype.addNotification=function(t,e,n){void 0===n&&(n=1),this._context.addEventListener(t,this._notificationListenerHandler,this,e,n)},e.prototype.removeNotification=function(t,e){this._context.removeEventListener(t,this._notificationListenerHandler,e)},e.prototype.sendNotification=function(t,e){this._context.sendNotification(t,e,this)},e.prototype.initialize=function(t,e,n){this.model=t,this.component=e,this._onInitialize(n),this.update()},e.prototype.update=function(){},Object.defineProperty(e.prototype,"controller",{get:function(){return this._context.controller},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"application",{get:function(){return this._context.application},enumerable:!0,configurable:!0}),e}(t.EventDispatcher);t.View=a,__reflect(a.prototype,"common.View");var o=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.result=null,t}return __extends(r,e),r.prototype._onClear=function(){this.success=null,this.result=null,this._guard=null,this._hook=null},r.prototype.execute=function(e,r,a){return void 0===r&&(r=null),void 0===a&&(a=null),__awaiter(this,void 0,void 0,function(){return __generator(this,function(o){switch(o.label){case 0:return e instanceof n?this.notification=e:(this.notification=t.create(n),this.notification.data=e),this._guard=r,this._hook=a,null!==this._guard&&this._guard(this)===!1?[3,2]:[4,this._onExecute()];case 1:return o.sent(),null===this.success&&(this.success=!0),null!==this._hook&&this._hook(this),[3,3];case 2:this.success=!0,o.label=3;case 3:return[2,this.result]}})})},Object.defineProperty(r.prototype,"data",{get:function(){return this.notification.data},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"application",{get:function(){return this._context.application},enumerable:!0,configurable:!0}),r}(t.BaseObject);t.Command=o,__reflect(o.prototype,"common.Command");var i=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._commandBins=[],t}return __extends(n,e),n.prototype._onExecute=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this._next(this.notification.data)];case 1:return t.sent(),[2]}})})},n.prototype._next=function(e){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(r){switch(r.label){case 0:return this._commandBins.length>0?(n=this._commandBins.shift())?(this.notification.data=e,this._currentCommand=t.create(n.commandClass),[4,this._currentCommand.execute(this.notification,n.guard,n.hook)]):[3,4]:[3,5];case 1:return r.sent(),this._currentCommand.success?[4,this._next(this._currentCommand.result)]:[3,3];case 2:return r.sent(),[3,4];case 3:this._fail(this._currentCommand.result),r.label=4;case 4:return[3,6];case 5:this.result=this._currentCommand.result,r.label=6;case 6:return[2]}})})},n.prototype._fail=function(t){this.result=t},n.prototype.addCommand=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null);var r={commandClass:t,guard:e,hook:n};this._commandBins.push(r)},n.prototype.insertCommand=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null);var r={commandClass:t,guard:e,hook:n};this._commandBins.unshift(r)},n}(o);t.QueueCommand=i,__reflect(i.prototype,"common.QueueCommand");var s=function(e){function r(){var n=null!==e&&e.apply(this,arguments)||this;return n.controller=t.create(l),n._application=null,n}return __extends(r,e),r.toString=function(){return"[class common.Context]"},r.prototype.release=function(){throw new Error},r.prototype._isSameListener=function(t,n){return t&&t.commandClass&&n?t.commandClass===n:e.prototype._isSameListener.call(this,t,n)},r.prototype.initialize=function(t){this._application=t,this.controller._context=this},r.prototype.sendNotification=function(e,r,a){if(void 0===a&&(a=null),this.enabled){var o=t.create(n);o.type=e,o.target=a,o.data=r,this.dispatchEventWith(e,o),o.release()}},r.prototype.getInstance=function(e){var n=t.getInstance(e);return n._context=this,n},r.prototype.create=function(e){var n=t.create(e);return n._context=this,n},Object.defineProperty(r.prototype,"application",{get:function(){return this._application},enumerable:!0,configurable:!0}),r}(t.EventDispatcher);t.Context=s,__reflect(s.prototype,"common.Context");var l=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.toString=function(){return"[class common.Controller]"},n.prototype._notificationHandler=function(t,e){this.execute(e.commandClass,t.data,e.guard,e.hook)},n.prototype._onClear=function(){this._context=null},n.prototype.register=function(t,e,n,r){void 0===n&&(n=null),void 0===r&&(r=null);var a={commandClass:e,guard:n,hook:r};this._context.addEventListener(t,this._notificationHandler,this,a)},n.prototype.unregister=function(t,e){var n={commandClass:e,guard:null,hook:null};this._context.removeEventListener(t,this._notificationHandler,n)},n.prototype.execute=function(e,n,r,a){return void 0===r&&(r=null),void 0===a&&(a=null),__awaiter(this,void 0,void 0,function(){var o;return __generator(this,function(i){switch(i.label){case 0:return o=t.create(e),[4,o.execute(n,r,a)];case 1:return[2,i.sent()]}})})},n}(t.BaseObject);__reflect(l.prototype,"Controller")}(common||(common={}));var player;!function(t){t.NotificationType={VOChange:"VOChange",ArmatureAdd:"ArmatureAdd",ArmatureRemove:"ArmatureRemove",ArmatureChange:"ArmatureChange",ArmatureReplace:"ArmatureReplace",AnimationStart:"AnimationStart",AnimationComplete:"AnimationComplete",AnimationChange:"AnimationChange"};var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(common.Model);t.BaseModel=e,__reflect(e.prototype,"player.BaseModel");var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(common.View);t.BaseView=n,__reflect(n.prototype,"player.BaseView");var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(common.Command);t.BaseCommand=r,__reflect(r.prototype,"player.BaseCommand");var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.toString=function(){return"[class dragonBones.QueueCommand]"},e}(common.QueueCommand);t.QueueCommand=a,__reflect(a.prototype,"player.QueueCommand")}(player||(player={}));var player;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.toString=function(){return"[class player.GetLocalFiles]"},e.prototype._onExecute=function(){return __awaiter(this,void 0,void 0,function(){var t=this;return __generator(this,function(e){return this.result=[],[2,new Promise(function(e){var n=t.data.dataTransfer;if(n&&(n.files||n.items))if(n.items)for(var r=0,a=function(n,o){n.isDirectory?n.createReader().readEntries(function(t){for(var e=0;e<t.length;++e)a(t[e],o?o+"/"+n.name:n.name)}):(r++,n.file(function(n){setTimeout(function(){n.modifyName=o?o+"/"+n.name:n.name,t.result.push(n),r--,0===r&&e()},30)}))},o=0;o<n.items.length;++o){var i=n.items[o];if(i.webkitGetAsEntry){var s=i.webkitGetAsEntry();s&&a(s,null)}}else{for(var o=0;o<n.files.length;++o)t.result.push(n.files[o]);e()}else e()})]})})},e}(t.BaseCommand);t.GetLocalFiles=e,__reflect(e.prototype,"player.GetLocalFiles")}(player||(player={}));var player;!function(t){var e=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.armatures=[],t.factory=dragonBones.EgretFactory.factory,t._armature=null,t}return __extends(r,e),r.toString=function(){return"[class player.ApplicationModel]"},r.prototype.createArmature=function(e){var r=this.factory.buildArmatureDisplay(e.name,e.parent.name);if(r){var a=this._context.create(n);return a.initialize(null,r,null),this.armatures.push(a),this.sendNotification(t.NotificationType.ArmatureAdd,a),a}return null},r.prototype.removeArmature=function(e){this.armature===e&&(this.armature=null);var n=this.armatures.indexOf(e);console.assert(n>=0),this.armatures.splice(n,1),this.sendNotification(t.NotificationType.ArmatureRemove,e),e.release()},r.prototype.clearAllArmature=function(){for(var t=this.armatures.length;t--;){var e=this.armatures[t];this.removeArmature(e)}},r.prototype.replaceArmature=function(e){var n=this.armature,r=this.createArmature(e);n&&r&&(r.component.x=n.component.x,r.component.y=n.component.y),this.armature=r,this.sendNotification(t.NotificationType.ArmatureReplace,n),n&&this.removeArmature(n)},Object.defineProperty(r.prototype,"vo",{set:function(e){if(e){this.clearAllArmature(),this.factory.clear(!0);for(var n=0,r=e;n<r.length;n++){var a=r[n],o=this.factory.parseDragonBonesData(a.data);if(o)if(a.textureAtlasDatas.length>0)for(var i=0,s=0,l=a.textureAtlasDatas;s<l.length;s++){var u=l[s],c=a.textureAtlases[i];c?this.factory.parseTextureAtlasData(u,c):this.factory.parseTextureAtlasData(u,null)}else this.factory.updateTextureAtlasData(o.name,a.textureAtlases)}this.sendNotification(t.NotificationType.VOChange,null)}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"armature",{get:function(){return this._armature},set:function(e){if(this._armature!==e){var n=this._armature;this._armature=e,this.sendNotification(t.NotificationType.ArmatureChange,n)}},enumerable:!0,configurable:!0}),r}(t.BaseModel);t.ApplicationModel=e,__reflect(e.prototype,"player.ApplicationModel");var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.toString=function(){return"[class player.ArmatureView]"},n.prototype._componentHandler=function(e){var n=e.eventObject;switch(e.type){case dragonBones.EventObject.FADE_IN:if(this._animation===n.animationState)return;var r=this._animation;this._animation=n.animationState,r&&this._animation&&r.name===this._animation.name||this.sendNotification(t.NotificationType.AnimationChange,r),this.sendNotification(t.NotificationType.AnimationStart,this._animation);break;case dragonBones.EventObject.COMPLETE:this.sendNotification(t.NotificationType.AnimationComplete,this._animation)}},n.prototype._onClear=function(){this.component&&(this.component.removeDBEventListener(dragonBones.EventObject.FADE_IN,this._componentHandler,this),this.component.removeDBEventListener(dragonBones.EventObject.COMPLETE,this._componentHandler,this),this.component.dispose(!0)),e.prototype._onClear.call(this),this._animation=null},n.prototype._onInitialize=function(t){this.component.addEventListener(dragonBones.EventObject.FADE_IN,this._componentHandler,this),this.component.addEventListener(dragonBones.EventObject.COMPLETE,this._componentHandler,this)},n.prototype.changeAnimation=function(t){var e=this.component.armature.armatureData.animationNames;t%=e.length,0>t&&(t=e.length+t),this.component.animation.fadeIn(e[t])},n.prototype.playAnimation=function(t){void 0===t&&(t=null),t?this.component.animation.fadeIn(t):!this.component.animation.lastAnimationState||this.component.animation.lastAnimationState.isCompleted?this.component.animation.play():this.component.animation.lastAnimationState.play()},n.prototype.stopAnimation=function(){this.component.animation.lastAnimationState&&this.component.animation.lastAnimationState.stop()},n.prototype.prevAnimation=function(){if(this._animation){var t=this.component.armature.armatureData.animationNames;this.changeAnimation(t.indexOf(this._animation.name)-1)}else this.playAnimation()},n.prototype.nextAnimation=function(){if(this._animation){var t=this.component.armature.armatureData.animationNames;this.changeAnimation(t.indexOf(this._animation.name)+1)}else this.playAnimation()},Object.defineProperty(n.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),n}(t.BaseView);t.ArmatureView=n,__reflect(n.prototype,"player.ArmatureView")}(player||(player={}));var Main=function(t){function e(){var e=t.call(this)||this;return e.armatureContainer=new egret.DisplayObjectContainer,e._context=common.create(common.Context),e.addChild(e.armatureContainer),e.addEventListener(egret.Event.ADDED_TO_STAGE,function(){var t=e._context.getInstance(player.Application),n=e._context.getInstance(player.ApplicationModel);if(e._context.initialize(t),t.queryConfig=player.getQueryConfig(window.location.search),t.initialize(n,e,null),t.queryConfig&&t.queryConfig.sources)t.controller.execute(player.LoadRemoteFiles,t.queryConfig).then(function(e){t.model.vo=e});else{var r=document.getElementById("data");r&&t.controller.execute(player.LoadInlineFiles,r.innerHTML).then(function(e){t.model.vo=e})}t.queryConfig&&t.queryConfig.scaleMode&&(t.component.stage.scaleMode=t.queryConfig.scaleMode)},e),e}return __extends(e,t),e}(egret.DisplayObjectContainer);__reflect(Main.prototype,"Main");var player;!function(t){var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.queryConfig=null,t}return __extends(n,e),n.toString=function(){return"[class player.Application]"},n.prototype._notificationHandler=function(e){switch(e.type){case t.NotificationType.VOChange:for(var n in this.model.factory.getAllDragonBonesData()){var r=this.model.factory.getDragonBonesData(n);if(r&&r.armatureNames.length>0){var a=null;a=r.stage?r.stage:r.getArmature(r.armatureNames[0]),a&&(this.model.armature=this.model.createArmature(a));break}}break;case t.NotificationType.ArmatureAdd:var o=e.data;o&&this.component.armatureContainer.addChild(o.component);break;case t.NotificationType.ArmatureRemove:var o=e.data;o&&this.component.armatureContainer.removeChild(o.component);break;case t.NotificationType.ArmatureChange:var o=this.model.armature;if(o){var a=o.component.armature.armatureData;if(a.canvas){if(this.component.stage.setContentSize(a.canvas.width,a.canvas.height),o.component.x=-a.canvas.x,o.component.y=-a.canvas.y,a.canvas.hasBackground){var i=document.getElementById("dragonBonesPlayer");i&&(i.style.backgroundColor="#"+a.canvas.color.toString(16))}}else this.component.stage.setContentSize(a.aabb.width,a.aabb.height),o.component.x=-(.5*a.aabb.width+a.aabb.x),o.component.y=-(.5*a.aabb.height+a.aabb.y);o.playAnimation()}break;case t.NotificationType.AnimationComplete:var o=this.model.armature;if(o&&o.animation){var s=o.component.armature.armatureData.animationNames;s.indexOf(o.animation.name)<s.length-1&&o.nextAnimation()}}},n.prototype._componentHandler=function(t){switch(t.type){case egret.Event.RESIZE:this.component.armatureContainer.x=.5*this.component.stage.stageWidth,this.component.armatureContainer.y=.5*this.component.stage.stageHeight;break;case egret.TouchEvent.TOUCH_END:var e=this.model.armature;e&&e.animation&&0===e.animation.playTimes&&e.nextAnimation()}},n.prototype._documentHandler=function(t){switch(t.type){case"dragenter":case"dragover":t.stopPropagation(),t.preventDefault();break;case"drop":this._loadLocalFiles(t),t.stopPropagation(),t.preventDefault()}},n.prototype._loadLocalFiles=function(e){return __awaiter(this,void 0,void 0,function(){var n,r;return __generator(this,function(a){switch(a.label){case 0:return[4,this.controller.execute(t.GetLocalFiles,e)];case 1:return n=a.sent(),[4,this.controller.execute(t.LoadLocalFiles,n)];case 2:return r=a.sent(),this.model.vo=r,[2]}})})},n.prototype._onInitialize=function(){if(console.log("DragonBones Player: 0.2.0"),this.addNotification(t.NotificationType.VOChange,this._notificationHandler),this.addNotification(t.NotificationType.ArmatureAdd,this._notificationHandler),this.addNotification(t.NotificationType.ArmatureRemove,this._notificationHandler),this.addNotification(t.NotificationType.ArmatureChange,this._notificationHandler),this.addNotification(t.NotificationType.AnimationComplete,this._notificationHandler),this.component.stage.addEventListener(egret.Event.RESIZE,this._componentHandler,this),this.component.stage.addEventListener(egret.TouchEvent.TOUCH_END,this._componentHandler,this),!egret.Capabilities.isMobile){var e=document.body;e.addEventListener("dragenter",this._documentHandler),e.addEventListener("dragover",this._documentHandler),e.addEventListener("drop",this._documentHandler)}},n}(t.BaseView);t.Application=e,__reflect(e.prototype,"player.Application")}(player||(player={}));var player;!function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.toString=function(){return"[class player.loadInlineFiles]"},n.prototype._onExecute=function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(n){return this.result=[],[2,new Promise(function(n){for(var r=0,a=JSON.parse(e.data),o=0,i=a;o<i.length;o++){var s=i[o],l={data:t.base64ToArrayBuffer(s.data),textureAtlasDatas:[],textureAtlases:[]};r+=s.textureAtlases.length;for(var u=0,c=s.textureAtlases;u<c.length;u++){var p=c[u],f=document.createElement("img");l.textureAtlases.push(f),f.onload=function(){r--,0>=r&&n()},f.src="data:image/png;base64,"+p}e.result.push(l)}})]})})},n}(t.BaseCommand);t.LoadInlineFiles=e,__reflect(e.prototype,"player.LoadInlineFiles")}(player||(player={}));var player;!function(t){var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._loadCount=0,t._dragonBonesConfigs={},t._textureAtlasConfigs={},t._textureAtlasTextures={},t}return __extends(n,e),n.toString=function(){return"[class player.LoadLocalFiles]"},n.prototype._onExecute=function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(n){return this.result=[],[2,new Promise(function(n){for(var r=function(t){var n=t.target;switch(t.type){case"load":var o=n.file,i=n.result,s=o.modifyName||o.name,l=o.baseName;"image/png"===o.type?(l=o.baseName=e._modifyName(s),e._textureAtlasTextures[l]=o,console.log("Load complete:",o.type,s),n.removeEventListener("load",r),n.removeEventListener("error",r),e._loadCount--,0===e._loadCount&&a()):l?(console.log("Load complete:",o.type,s),n.removeEventListener("load",r),n.removeEventListener("error",r),e._loadCount--,0===e._loadCount&&a()):(l=o.baseName=e._modifyName(s),0===i.indexOf("DBDT")?(e._dragonBonesConfigs[l]=o,n.readAsArrayBuffer(o),console.log("Load:",o.type,s)):i.indexOf("armature")>0||i.indexOf("textureAtlas")>0?(e._dragonBonesConfigs[l]=o,n.readAsText(o),console.log("Load:",o.type,s)):i.indexOf("SubTexture")>0?(e._textureAtlasConfigs[l]=o,n.readAsText(o),console.log("Load:",o.type,s)):(n.removeEventListener("load",r),n.removeEventListener("error",r),e._loadCount--,0===e._loadCount&&a()));break;default:n.removeEventListener("load",r),n.removeEventListener("error",r),e._loadCount--,0===e._loadCount&&a()}},a=(function(){var r=0;for(var a in e._dragonBonesConfigs){var o=e._dragonBonesConfigs[a],i=o.loader,s="string"==typeof i.result?JSON.parse(i.result):i.result,l={data:s,textureAtlasDatas:[],textureAtlases:[]},u=null;if(s instanceof ArrayBuffer){var c=new Uint32Array(s,8,1)[0],p=new Uint8Array(s,12,c),f=t.utf8ArrayToString(p),h=JSON.parse(f);u=h.textureAtlas}else u=s.textureAtlas;if(u&&u.length>0)for(var m=0,d=u;m<d.length;m++){var _=d[m],y=_.imagePath;if(y in e._textureAtlasTextures){var v=e._textureAtlasTextures[y],g=v.loader,x=document.createElement("img");x.src=g.result,x.onload=function(){r--,0===r&&n()},r++,l.textureAtlases.push(x)}else l.textureAtlasDatas.push(null),l.textureAtlases.push(null)}else for(var A=a.split(".").shift(),C=e._getTextureAtlases(A),b=0,E=C;b<E.length;b++){var L=E[b],w=L.loader,y=L.baseName.split(".").shift()+".png",T=JSON.parse(w.result);if(y in e._textureAtlasTextures){var v=e._textureAtlasTextures[y],g=v.loader,x=document.createElement("img");x.src=g.result,x.onload=function(){r--,0===r&&n()},r++,l.textureAtlasDatas.push(T),l.textureAtlases.push(x)}else l.textureAtlasDatas.push(T),l.textureAtlases.push(null)}e.result.push(l)}0===r&&n()}),o=0,i=e.data.length;i>o;++o){var s=e.data[o],l=new FileReader;switch(s.loader=l,l.file=s,l.addEventListener("load",r),l.addEventListener("error",r),e._loadCount++,s.type){case"image/png":l.readAsDataURL(s),console.log("Load:",s.type,s.modifyName||s.name);break;default:l.readAsText(s.slice(0,Math.min(200,s.size)))}}})]})})},n.prototype._modifyName=function(t){return t.indexOf("_ske.")>0?t=t.replace("_ske.","."):t.indexOf("_tex.")>0?t=t.replace("_tex.","_texture."):t.indexOf("_tex_")>0&&(t=t.replace("_tex_","_texture_")),t},n.prototype._getTextureAtlases=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n="texture");var r=0,a=null!==e?e:t,o=(a.length>0?a+(n?"_"+n:n):n)+".json",i=new Array;if(o in this._textureAtlasConfigs)return i.push(this._textureAtlasConfigs[o]),i;for(;;){if(a.length>0&&n.length>0)o=a+"_"+n+"_"+r++ +".json";else if(n.length>0)o=n+"_"+r++ +".json";else{if(!(a.length>0)){console.assert(!1);break}o=a+"_"+r++ +".json"}if(o in this._textureAtlasConfigs)i.push(this._textureAtlasConfigs[o]);else if(r>1)break}if(i.length>0||null!==e)return i;if(i=this._getTextureAtlases(t,"",n),i.length>0)return i;if(r=t.lastIndexOf("_"),r>=0){if(e=t.substring(0,r),i=this._getTextureAtlases(t,e,n),i.length>0)return i;if(i=this._getTextureAtlases(t,e,""),i.length>0)return i}return"atlas"!==n&&(i=this._getTextureAtlases(t,null,"atlas")),i},n}(t.BaseCommand);t.LoadLocalFiles=e,__reflect(e.prototype,"player.LoadLocalFiles")}(player||(player={}));var player;!function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.toString=function(){return"[class player.LoadRemoteFiles]"},n.prototype._onExecute=function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(n){return this.result=[],[2,new Promise(function(n){if(e.data.sources&&e.data.sources instanceof Array){var r,a=e.data.sources,o=null,i=new XMLHttpRequest,s=function(){if(o){if(null===r.data)i.response instanceof ArrayBuffer?r.data=i.response:r.data=JSON.parse(i.response);else if(r.textureAtlasDatas.length===r.textureAtlases.length)r.textureAtlasDatas.push(JSON.parse(i.response));else{var e=document.createElement("img");if(e.src="data:image/png;base64,"+t.arrayBufferToBase64(i.response),r.textureAtlases.push(e),r.textureAtlases.length===o.textureAtlases.length)return void l()}if(r.textureAtlasDatas.length===r.textureAtlases.length){var n=o.root+o.textureAtlasDatas[r.textureAtlasDatas.length];n?(i.open("GET",n,!0),i.responseType="text",i.send()):r.textureAtlasDatas.push("")}else{var n=o.root+o.textureAtlases[r.textureAtlases.length];n?(i.open("GET",n,!0),i.responseType="arraybuffer",i.send()):r.textureAtlases.push(null)}}},l=function(){return 0===a.length?void n():(o=a.pop(),void(o?(o.root=o.root||"",r={data:null,textureAtlasDatas:[],textureAtlases:[]},e.result.push(r),i.open("GET",o.root+o.data,!0),o.data.indexOf(".json")<0?i.responseType="arraybuffer":i.responseType="text",i.send()):l()))};i.addEventListener("loadend",s),l()}})]})})},n}(t.BaseCommand);t.LoadRemoteFiles=e,__reflect(e.prototype,"player.LoadRemoteFiles")}(player||(player={}));var player;!function(t){function e(t){if(t.indexOf("?")>=0){for(var e={},n=void 0,r=/\+/g,a=/([^&=]+)=?([^&]*)/g,o=function(t){return decodeURIComponent(t.replace(r," "))},i=t.substring(1);n=a.exec(i);){var s=o(n[2]),l=Number(s);l===l?e[o(n[1])]=l:e[o(n[1])]=s}return e.sources&&"string"==typeof e.sources&&(e.sources=JSON.parse(e.sources)),e.armature&&"string"==typeof e.armature&&e.armature.indexOf(",")>0&&(e.armature=e.armature.split(",")),e.skin&&"string"==typeof e.skin&&e.skin.indexOf(",")>0&&(e.skin=e.skin.split(",")),e}return null}function n(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];if(0===r)break;var a=0;if(r>224)a=(15&r)<<12,r=t[++n],a|=(63&r)<<6,r=t[++n],a|=63&r,e.push(String.fromCharCode(a));else if(r>192)a=(31&r)<<6,r=t[++n],a|=(63&r)<<6,e.push(String.fromCharCode(a));else{if(r>128)throw new Error("InvalidCharacterError");e.push(String.fromCharCode(t[n]))}}return e.join("")}function r(t){for(var e=window.atob(t),n=e.length,r=new Uint8Array(n),a=0;n>a;++a)r[a]=e.charCodeAt(a);return r.buffer}function a(t){for(var e="",n=new Uint8Array(t),r=n.byteLength,a=0;r>a;a++)e+=String.fromCharCode(n[a]);return window.btoa(e)}t.getQueryConfig=e,t.utf8ArrayToString=n,t.base64ToArrayBuffer=r,t.arrayBufferToBase64=a}(player||(player={}));