From b9e441075f333879082aee80c8f3bcb3f7e501e7 Mon Sep 17 00:00:00 2001 From: bellord13 Date: Wed, 26 Jun 2024 18:27:24 +0300 Subject: [PATCH] fix --- assets/core/core.js | 5 +++-- assets/core/core.min.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/assets/core/core.js b/assets/core/core.js index 54080e6..161e3d2 100644 --- a/assets/core/core.js +++ b/assets/core/core.js @@ -84,13 +84,14 @@ kit.config = kit.config || {}; document.querySelector('meta[property="kit:file-load"][content="'+src+'"]'); } function getUrlWithTimestamp(url){ + var t = ((new Date()).getTime() / 3600 >> 0) * 3600; try { var uri = new URL(url); - uri.searchParams.append('__pm', (new Date()).getTime()); + uri.searchParams.append('__pm', String(t)); url = uri.toString(); } catch (e) { url = String(url).split('?')[0]; - url = '' + url + '?__pm' + (new Date()).getTime(); + url = '' + url + '?__pm' + t; } return url; } diff --git a/assets/core/core.min.js b/assets/core/core.min.js index 2a90506..56e5d44 100644 --- a/assets/core/core.min.js +++ b/assets/core/core.min.js @@ -1 +1 @@ -window.kit=window.kit||{},kit.service=kit.service||{},kit.config=kit.config||{},!function(global){var defaultConfig={version:"2.0",assetsPath:"",requiredDependencies:[],autoloadPluginList:[],debug:!0},stateList={undefined:0,registered:1,loading:3,loaded:4,installing:5,installed:6},MD_TYPE={ES:"ES",UMD:"UMD",HMD:"HMD",default:"default"};function Plugin(e,t={}){this.id=e,this.state=stateList.undefined,this.state2=stateList.undefined,this.module={code:"",exports:{}},this.config={autoRequire:!1,loadJsAfterModule:!1,isSetTimestamp:!0,path:"",module:"",type:"default",handler:void 0,onRegister:function(e){},onLoad:function(e){},onInstall:function(e){},js:[],css:[],alias:[],deps:[],debug:!1},this.pluginManager=void 0,this.promise=new Promise(function(e,t){e()}),this.errors=[],this.register(t)}function isAssetLoaded(e){return e=e.match(/^[^#?]*/)[0],document.querySelector('script[src^="'+e+'"]')||document.querySelector('link[href^="'+e+'"]')||document.querySelector('meta[property="kit:file-load"][content="'+e+'"]')}function getUrlWithTimestamp(t){try{var e=new URL(t);e.searchParams.append("__pm",(new Date).getTime()),t=e.toString()}catch(e){t=(t=String(t).split("?")[0])+"?__pm"+(new Date).getTime()}return t}Plugin.prototype.setPluginManager=function(e){this.pluginManager=e},Plugin.prototype.queuePush=function(n,i=[]){"function"==typeof n&&(this.promise=this.promise.then(function(e){var t=n.apply(this,i);if(t)return t}))},Plugin.prototype.__queue=function(e,n,i=[],o=void 0){var t=this;void 0===o&&(o=t),t.__checkState(e)?n.apply(o,i):t.promise=t.promise.then(function(){return new Promise(function(e,t){n.apply(o,i),e()})}.bind(t))},Plugin.prototype.__exec=function(e,t,n=[],i=void 0){var o=this;void 0===i&&(i=o),o.__checkState(e)?t.apply(i,n):o.promise=o.promise.then(function(){t.apply(i,n)}.bind(o))},Plugin.prototype.__checkState=function(e,t=void 0){return void 0===t?this.state>=e:this.state>=e&&this.state<=t},Plugin.prototype.__check2State=function(e,t=void 0){return void 0===t?this.state2>=e:this.state2>=e&&this.state2<=t},Plugin.prototype.__getValidConfig=function(e={}){e=Object.assign({},e);return"function"!=typeof e.onLoad&&(e.onLoad=function(e){}),"function"!=typeof e.onInstall&&(e.onInstall=function(e){}),"function"!=typeof e.onRegister&&(e.onRegister=function(e){}),"string"!=typeof e.path&&(e.path=""),"string"==typeof e.js?e.js=[e.js]:Array.isArray(e.js)||(e.js=[]),"string"==typeof e.css?e.css=[e.css]:Array.isArray(e.css)||(e.css=[]),"string"==typeof e.alias?e.alias=[e.alias]:Array.isArray(e.alias)||(e.alias=[]),e.autoRequire=!!e.hasOwnProperty("autoRequire")&&!!e.autoRequire,e.loadJsAfterModule=!!e.hasOwnProperty("loadJsAfterModule")&&!!e.loadJsAfterModule,e.isSetTimestamp=!e.hasOwnProperty("isSetTimestamp")||!!e.isSetTimestamp,e.type=e.type||"default","string"==typeof e.deps?e.deps=[e.deps]:Array.isArray(e.deps)||(e.deps=[]),e},Plugin.prototype.__setState=function(e,t=!1){var n=this;(t||n.__checkState(e))&&(n.state=e)},Plugin.prototype.register=function(e={}){var t,n=this,i=n.id;if(this.__checkState(stateList.installed))throw new Error("Plugin "+i+" уже невозможно конфигурировать ("+n.state+"/"+n.state2+")");if("function"==typeof e)t=e,(e=this.config).handler=t,e.type=MD_TYPE.HMD;else{if(this.__checkState(stateList.loaded)||this.__check2State(stateList.loading))throw new Error("Plugin "+i+" уже невозможно конфигурировать ("+n.state+")");if("object"!=typeof e)throw new Error("Plugin.register: plugin "+i+" is not a valid format");e=this.__getValidConfig(e),Object.assign(this.config,e)}this.__checkState(stateList.registered)||(n.config.debug&&console.log(`Plugin ${n.id}: onRegister + event.`),this.state=stateList.registered,this.config.onRegister(this),t=new CustomEvent("onRegister"+this.id+"Plugin",{detail:{plugin:this}}),document.dispatchEvent(t)),e.autoRequire},Plugin.prototype.load=function(e){var i,t,n,o,s,r=this,l=("function"!=typeof e&&(e=function(){}),r.id);return r.__checkState(stateList.registered)?r.__checkState(stateList.loaded)?e():r.__check2State(stateList.loading)?r.__exec(stateList.loaded,e):(r.state2=stateList.loading,(i=r.config).css.forEach(function(e,t,n){r.getStylePromise(i.path+e)}),r.pluginManager&&(t=r.pluginManager.__getDepsPromiseCallback(r.config.deps),r.queuePush(t)),o=i.path+i.module,n="string"==typeof i.module&&""!==i.module&&"ES"===i.type?function(){return r.getESModulePromise(o).then(function(e){e.__esModule=!0,r.module.exports=e}.bind(r))}:"string"==typeof i.module&&""!==i.module&&"UMD"===i.type?isAssetLoaded(o)?void(r.config.debug&&console.warn(`Plugin ${r.id}: Скрипт ${o} уже загружен!`)):function(){return r.httpGet(o).then(function(e){r.module.code=e}.bind(r))}:"HMD"!==i.type||i.hasOwnProperty("handler")&&"function"==typeof i.handler?"string"==typeof i.module&&""!==i.module&&"default"===i.type?isAssetLoaded(o)?void(r.config.debug&&console.warn(`Plugin ${r.id}: Скрипт ${o} уже загружен!`)):function(){return r.getScriptPromise(o)}:void 0:function(){return r.getScriptPromise(o)},s=r.getJsAssetsPromiseCallback(i.js),i.loadJsAfterModule?(r.queuePush(n),r.queuePush(s)):(r.queuePush(s),r.queuePush(n)),t||n||s||(r.state=stateList.loaded),r.__queue(stateList.loaded,function(){r.config.debug&&console.log(`Plugin ${r.id}: onLoad + event.`),r.isLoaded()||(r.state=stateList.loaded),i.onLoad.call(r,r);var e=new CustomEvent("onLoad"+r.id+"Plugin",{detail:{plugin:r}});document.dispatchEvent(e)}),r.__exec(stateList.loaded,function(){e()}.bind(r))):console.warn(`Plugin.load(${l}): is not register!.`),r},Plugin.prototype.install=function(callback){var self=this,global=self.pluginManager.global,require=self.pluginManager.require.bind(self.pluginManager),pluginId=("function"!=typeof callback&&(callback=function(){}),self.id),setGlobals,module,installer;return self.__checkState(stateList.registered)?self.__checkState(stateList.installed)?callback():self.__check2State(stateList.installing)?self.__exec(stateList.installed,callback):(self.__checkState(stateList.loaded)||this.load(),self.state2=stateList.installing,setGlobals=function(t,n){var e,i;void 0!==n&&(e=self.id,i=self.config.alias,t.hasOwnProperty(e)||(t[e]=n),Array.isArray(i))&&i.length&&i.forEach(function(e){t.hasOwnProperty(e)||(t[e]=n)})},module=self.module,installer=function(){var __exports=void 0,event=("ES"===self.config.type&&"string"==typeof self.config.module&&""!==self.config.module?__exports="object"==typeof self.module.exports&&void 0!==self.module.exports.default?self.module.exports.default:self.module.exports:"UMD"===self.config.type&&"string"==typeof self.config.module&&""!==self.config.module?(function(require,exports,module,global){var self=global;eval(module.code)}.bind(global).call(global,require,self.module.exports,module,global),__exports="object"==typeof self.module.exports&&void 0!==self.module.exports.default?self.module.exports.default:self.module.exports):"HMD"===self.config.type&&"function"==typeof self.config.handler&&(__exports=self.config.handler.bind(global).call(global,require,self.module.exports,module,global),void 0===__exports)&&self.module.exports&&(__exports=self.module.exports),"object"==typeof global&&setGlobals(global,__exports),self.state=stateList.installed,console.log(`%cPlugin ${pluginId}: installed.`,"color: green;"),self.config.onInstall.call(self,self),new CustomEvent("onInstall"+self.id+"Plugin",{detail:{plugin:self}}));return document.dispatchEvent(event),!0}.bind(this),this.__queue(stateList.loaded,installer),this.__exec(stateList.loaded,function(){callback()})):console.warn(`Plugin ${pluginId}: is not register!`),self},Plugin.prototype.exec=function(e,t=[],n=void 0){var i=this;void 0===n&&(n=i),i.__checkState(stateList.installed)||(i.load(),i.install()),i.__exec(stateList.installed,e,t,n)},Plugin.prototype.getESModulePromise=function(e){var i=this;return new Promise(function(t,n){import(e).then(function(e){t(e)},function(e){i.errors.push(e),console.log(`%cPlugin ${i.id}: error import module!`,"color: red;"),n(e)})})},Plugin.prototype.httpGet=function(i){var o=this;return new Promise(function(t,n){o.config.debug&&console.log(`Plugin ${o.id}: httpGet `+i);var e=new XMLHttpRequest;e.open("GET",i,!0),e.onload=function(){var e;200==this.status?t(this.response):(console.log(`%cPlugin.load(${o.id}): error load file!`,"color: red;"),(e=new Error(this.statusText)).code=this.status,n(e))},e.onerror=function(){console.log(`%cPlugin.load(${o.id}): error load file!`,"color: red;"),n(new Error("Network Error"))},e.send()})},Plugin.prototype.getScriptPromise=function(i){var o=this;if(!isAssetLoaded(i))return new Promise(function(e,t){o.config.debug&&console.log(`Plugin ${o.id}: load script `+i);var n=document.createElement("script");n.src=i,o.config.isSetTimestamp&&(n.src=getUrlWithTimestamp(i)),n.onload=function(){e(n)},n.onerror=function(){var e=new Error("Ошибка загрузки скрипта "+i);o.errors.push(e),console.log(`%cPlugin.load(${o.id}): error load script!`,"color: red;"),t(e)},document.head.append(n)});o.config.debug&&console.warn(`Plugin ${o.id}: Скрипт ${i} уже загружен!`)},Plugin.prototype.getStylePromise=function(i){var o=this;return new Promise(function(e,t){var n;isAssetLoaded(i)?(o.config.debug&&console.warn(`Plugin ${o.id}: Стиль ${i} уже загружен`),e()):((n=document.createElement("link")).rel="stylesheet",n.type="text/css",n.media="all",n.href=i,o.config.isSetTimestamp&&(n.href=getUrlWithTimestamp(i)),document.head.append(n),e(n))})},Plugin.prototype.getAsyncScriptListPromise=function(e){e=e.map(this.getScriptPromise.bind(this)).filter(e=>void 0!==e);if(e.length)return Promise.all(e)},Plugin.prototype.getJsAssetsPromiseCallback=function(e=[]){var o=this;if(e.length)return function(){var i=new Promise(function(e,t){e()});return e.forEach(function(e,t,n){i=Array.isArray(e)?i.then(function(){return o.getAsyncScriptListPromise(e)}):i.then(function(){return o.getScriptPromise(o.config.path+e)})}),i}},Plugin.prototype.__getRealId=function(e){var t,n=e.toLowerCase();if(this.id.toLowerCase()===n)return this.id;for(t of this.config.alias)if(n===t.toLowerCase())return this.id},Plugin.prototype.__is=function(e){return this.id===this.__getRealId(e)},Plugin.prototype.isLoaded=function(){return this.__checkState(stateList.loaded)},Plugin.prototype.isInstalled=function(){return this.__checkState(stateList.installed)},Plugin.prototype.require=function(){return this.isInstalled()||this.config.debug&&console.warn(`Plugin ${this.id}: not instaled!`),this.module.exports};var PluginManager=function(e){this.plugins={},this.global=e};function init(e){var o=new PluginManager(e);e.ready=o.ready.bind(o),e.exec=o.exec.bind(o),e.require=o.require.bind(o),o.register("pluginManager",{alias:"pm",type:MD_TYPE.HMD,handler:function(e,t,n,i){return i.PluginManagerClass=PluginManager,"object"==typeof window&&(window.__PluginManager__=o,window.__pmGlobal__=i),n.exports=o},onInstall:function(e){}}),o.install("pluginManager"),o.register("config",{type:MD_TYPE.HMD,handler:function(e,t,n,i){var o=document.currentScript;if(o)try{var s=new URL(o.src);defaultConfig.assetsPath=s.pathname.split("/").slice(0,-2).join("/")}catch(e){s=o.src.split("?")[0];defaultConfig.assetsPath=s.split("/").slice(0,-2).join("/")}o=i.config||{},o=Object.assign({},defaultConfig,o);"object"==typeof window&&(window.__pmConfig__=i.config=o),document.addEventListener("DOMContentLoaded",function(){console.log("%cDOMContentLoaded","color:#2053ff")})},onInstall:function(e){"object"==typeof window&&window.hasOwnProperty("__PluginManagerConfigHandler__")&&"function"==typeof __PluginManagerConfigHandler__&&o.registerPlugins(__PluginManagerConfigHandler__())}}),o.install("config")}PluginManager.prototype.registerPlugins=function(e){for(var t in e)e.hasOwnProperty(t)&&this.register(t,e[t]);return this},PluginManager.prototype.register=function(e,t={}){var n;"string"!=typeof e||""===e?console.warn("Invalid pluginId!",e):(n=this.__getPlugin(e))?n.register(t):((n=new Plugin(e,t)).setPluginManager(this),this.plugins[e]=n)},PluginManager.prototype.__getPlugin=function(e){var t,n;for(t in this.plugins)if(this.plugins.hasOwnProperty(t)&&(n=this.plugins[t]).__is(e))return n},PluginManager.prototype.__getDepsPromiseCallback=function(e=[]){var n=this,t=e.map(function(e){var t=n.__getPlugin(e);if(t)return t.install(),t.isInstalled()?void 0:t.promise;console.log(`%cPluginManager: plugin ${e} not found!`,"color: red;")}).filter(e=>void 0!==e);if(t.length)return function(){return Promise.all(t)}},PluginManager.prototype.__getRealIdList=function(e=[]){var t=this;return e.map(function(e){e=t.__getPlugin(e);if(e)return e.id})},PluginManager.prototype.exec=function(e,t,n=[],i=void 0){"function"==typeof e&&(i=n,n=t,t=e,e=[]),"string"==typeof e&&(e=[e]),void 0===i&&(i=this),void 0===n&&(n=[]),"function"==typeof t&&(global.config&&global.config.requiredDependencies&&(e=Array.from(new Set(e.concat(global.config.requiredDependencies)))),(e=this.__getDepsPromiseCallback(e))?e().then(function(){t.apply(i,n)}):t.apply(i,n))},PluginManager.prototype.exec2=function(e,t){var n=this,i=this,o=n.__getDepsPromiseCallback(e),s=function(){var t=[];return e.forEach(function(e){n.__getPlugin(e)?t.push(n.require(e)):t.push(void 0)}.bind(n)),t}.bind(n);o?o().then(function(){t.apply(i,s())}):t.apply(i,s())},PluginManager.prototype.ready=function(e,t=void 0){"function"==typeof e&&(t=e,e=[]),this.__ready(this.exec,[e,t="function"!=typeof t?function(){}:t],this)},PluginManager.prototype.__ready=function(e,t=[],n=window){n=n||this,/complete|interactive|loaded/.test(document.readyState)?e.apply(n,t):document.addEventListener("DOMContentLoaded",function(){e.apply(n,t)}.bind(this))},PluginManager.prototype.require=function(e,t){var n,i=this.__getPlugin(e);if(i)return e=i.id,n=i.module,i.install(t="function"!=typeof t?function(){}:t),n.exports;console.warn("PluginManager.require: plugin "+e+" not found!")},PluginManager.prototype.install=function(e,t){var n=this.__getPlugin(e);n?(e=n.id,n.module,n.install(t)):console.warn("PluginManager.install: plugin "+e+" not found!")},init(global)}(kit); \ No newline at end of file +window.kit=window.kit||{},kit.service=kit.service||{},kit.config=kit.config||{},!function(global){var defaultConfig={version:"2.0",assetsPath:"",requiredDependencies:[],autoloadPluginList:[],debug:!0},stateList={undefined:0,registered:1,loading:3,loaded:4,installing:5,installed:6},MD_TYPE={ES:"ES",UMD:"UMD",HMD:"HMD",default:"default"};function Plugin(e,t={}){this.id=e,this.state=stateList.undefined,this.state2=stateList.undefined,this.module={code:"",exports:{}},this.config={autoRequire:!1,loadJsAfterModule:!1,isSetTimestamp:!0,path:"",module:"",type:"default",handler:void 0,onRegister:function(e){},onLoad:function(e){},onInstall:function(e){},js:[],css:[],alias:[],deps:[],debug:!1},this.pluginManager=void 0,this.promise=new Promise(function(e,t){e()}),this.errors=[],this.register(t)}function isAssetLoaded(e){return e=e.match(/^[^#?]*/)[0],document.querySelector('script[src^="'+e+'"]')||document.querySelector('link[href^="'+e+'"]')||document.querySelector('meta[property="kit:file-load"][content="'+e+'"]')}function getUrlWithTimestamp(t){var n=3600*((new Date).getTime()/3600>>0);try{var e=new URL(t);e.searchParams.append("__pm",String(n)),t=e.toString()}catch(e){t=(t=String(t).split("?")[0])+"?__pm"+n}return t}Plugin.prototype.setPluginManager=function(e){this.pluginManager=e},Plugin.prototype.queuePush=function(n,i=[]){"function"==typeof n&&(this.promise=this.promise.then(function(e){var t=n.apply(this,i);if(t)return t}))},Plugin.prototype.__queue=function(e,n,i=[],o=void 0){var t=this;void 0===o&&(o=t),t.__checkState(e)?n.apply(o,i):t.promise=t.promise.then(function(){return new Promise(function(e,t){n.apply(o,i),e()})}.bind(t))},Plugin.prototype.__exec=function(e,t,n=[],i=void 0){var o=this;void 0===i&&(i=o),o.__checkState(e)?t.apply(i,n):o.promise=o.promise.then(function(){t.apply(i,n)}.bind(o))},Plugin.prototype.__checkState=function(e,t=void 0){return void 0===t?this.state>=e:this.state>=e&&this.state<=t},Plugin.prototype.__check2State=function(e,t=void 0){return void 0===t?this.state2>=e:this.state2>=e&&this.state2<=t},Plugin.prototype.__getValidConfig=function(e={}){e=Object.assign({},e);return"function"!=typeof e.onLoad&&(e.onLoad=function(e){}),"function"!=typeof e.onInstall&&(e.onInstall=function(e){}),"function"!=typeof e.onRegister&&(e.onRegister=function(e){}),"string"!=typeof e.path&&(e.path=""),"string"==typeof e.js?e.js=[e.js]:Array.isArray(e.js)||(e.js=[]),"string"==typeof e.css?e.css=[e.css]:Array.isArray(e.css)||(e.css=[]),"string"==typeof e.alias?e.alias=[e.alias]:Array.isArray(e.alias)||(e.alias=[]),e.autoRequire=!!e.hasOwnProperty("autoRequire")&&!!e.autoRequire,e.loadJsAfterModule=!!e.hasOwnProperty("loadJsAfterModule")&&!!e.loadJsAfterModule,e.isSetTimestamp=!e.hasOwnProperty("isSetTimestamp")||!!e.isSetTimestamp,e.type=e.type||"default","string"==typeof e.deps?e.deps=[e.deps]:Array.isArray(e.deps)||(e.deps=[]),e},Plugin.prototype.__setState=function(e,t=!1){var n=this;(t||n.__checkState(e))&&(n.state=e)},Plugin.prototype.register=function(e={}){var t,n=this,i=n.id;if(this.__checkState(stateList.installed))throw new Error("Plugin "+i+" уже невозможно конфигурировать ("+n.state+"/"+n.state2+")");if("function"==typeof e)t=e,(e=this.config).handler=t,e.type=MD_TYPE.HMD;else{if(this.__checkState(stateList.loaded)||this.__check2State(stateList.loading))throw new Error("Plugin "+i+" уже невозможно конфигурировать ("+n.state+")");if("object"!=typeof e)throw new Error("Plugin.register: plugin "+i+" is not a valid format");e=this.__getValidConfig(e),Object.assign(this.config,e)}this.__checkState(stateList.registered)||(n.config.debug&&console.log(`Plugin ${n.id}: onRegister + event.`),this.state=stateList.registered,this.config.onRegister(this),t=new CustomEvent("onRegister"+this.id+"Plugin",{detail:{plugin:this}}),document.dispatchEvent(t)),e.autoRequire},Plugin.prototype.load=function(e){var i,t,n,o,s,r=this,l=("function"!=typeof e&&(e=function(){}),r.id);return r.__checkState(stateList.registered)?r.__checkState(stateList.loaded)?e():r.__check2State(stateList.loading)?r.__exec(stateList.loaded,e):(r.state2=stateList.loading,(i=r.config).css.forEach(function(e,t,n){r.getStylePromise(i.path+e)}),r.pluginManager&&(t=r.pluginManager.__getDepsPromiseCallback(r.config.deps),r.queuePush(t)),o=i.path+i.module,n="string"==typeof i.module&&""!==i.module&&"ES"===i.type?function(){return r.getESModulePromise(o).then(function(e){e.__esModule=!0,r.module.exports=e}.bind(r))}:"string"==typeof i.module&&""!==i.module&&"UMD"===i.type?isAssetLoaded(o)?void(r.config.debug&&console.warn(`Plugin ${r.id}: Скрипт ${o} уже загружен!`)):function(){return r.httpGet(o).then(function(e){r.module.code=e}.bind(r))}:"HMD"!==i.type||i.hasOwnProperty("handler")&&"function"==typeof i.handler?"string"==typeof i.module&&""!==i.module&&"default"===i.type?isAssetLoaded(o)?void(r.config.debug&&console.warn(`Plugin ${r.id}: Скрипт ${o} уже загружен!`)):function(){return r.getScriptPromise(o)}:void 0:function(){return r.getScriptPromise(o)},s=r.getJsAssetsPromiseCallback(i.js),i.loadJsAfterModule?(r.queuePush(n),r.queuePush(s)):(r.queuePush(s),r.queuePush(n)),t||n||s||(r.state=stateList.loaded),r.__queue(stateList.loaded,function(){r.config.debug&&console.log(`Plugin ${r.id}: onLoad + event.`),r.isLoaded()||(r.state=stateList.loaded),i.onLoad.call(r,r);var e=new CustomEvent("onLoad"+r.id+"Plugin",{detail:{plugin:r}});document.dispatchEvent(e)}),r.__exec(stateList.loaded,function(){e()}.bind(r))):console.warn(`Plugin.load(${l}): is not register!.`),r},Plugin.prototype.install=function(callback){var self=this,global=self.pluginManager.global,require=self.pluginManager.require.bind(self.pluginManager),pluginId=("function"!=typeof callback&&(callback=function(){}),self.id),setGlobals,module,installer;return self.__checkState(stateList.registered)?self.__checkState(stateList.installed)?callback():self.__check2State(stateList.installing)?self.__exec(stateList.installed,callback):(self.__checkState(stateList.loaded)||this.load(),self.state2=stateList.installing,setGlobals=function(t,n){var e,i;void 0!==n&&(e=self.id,i=self.config.alias,t.hasOwnProperty(e)||(t[e]=n),Array.isArray(i))&&i.length&&i.forEach(function(e){t.hasOwnProperty(e)||(t[e]=n)})},module=self.module,installer=function(){var __exports=void 0,event=("ES"===self.config.type&&"string"==typeof self.config.module&&""!==self.config.module?__exports="object"==typeof self.module.exports&&void 0!==self.module.exports.default?self.module.exports.default:self.module.exports:"UMD"===self.config.type&&"string"==typeof self.config.module&&""!==self.config.module?(function(require,exports,module,global){var self=global;eval(module.code)}.bind(global).call(global,require,self.module.exports,module,global),__exports="object"==typeof self.module.exports&&void 0!==self.module.exports.default?self.module.exports.default:self.module.exports):"HMD"===self.config.type&&"function"==typeof self.config.handler&&(__exports=self.config.handler.bind(global).call(global,require,self.module.exports,module,global),void 0===__exports)&&self.module.exports&&(__exports=self.module.exports),"object"==typeof global&&setGlobals(global,__exports),self.state=stateList.installed,console.log(`%cPlugin ${pluginId}: installed.`,"color: green;"),self.config.onInstall.call(self,self),new CustomEvent("onInstall"+self.id+"Plugin",{detail:{plugin:self}}));return document.dispatchEvent(event),!0}.bind(this),this.__queue(stateList.loaded,installer),this.__exec(stateList.loaded,function(){callback()})):console.warn(`Plugin ${pluginId}: is not register!`),self},Plugin.prototype.exec=function(e,t=[],n=void 0){var i=this;void 0===n&&(n=i),i.__checkState(stateList.installed)||(i.load(),i.install()),i.__exec(stateList.installed,e,t,n)},Plugin.prototype.getESModulePromise=function(e){var i=this;return new Promise(function(t,n){import(e).then(function(e){t(e)},function(e){i.errors.push(e),console.log(`%cPlugin ${i.id}: error import module!`,"color: red;"),n(e)})})},Plugin.prototype.httpGet=function(i){var o=this;return new Promise(function(t,n){o.config.debug&&console.log(`Plugin ${o.id}: httpGet `+i);var e=new XMLHttpRequest;e.open("GET",i,!0),e.onload=function(){var e;200==this.status?t(this.response):(console.log(`%cPlugin.load(${o.id}): error load file!`,"color: red;"),(e=new Error(this.statusText)).code=this.status,n(e))},e.onerror=function(){console.log(`%cPlugin.load(${o.id}): error load file!`,"color: red;"),n(new Error("Network Error"))},e.send()})},Plugin.prototype.getScriptPromise=function(i){var o=this;if(!isAssetLoaded(i))return new Promise(function(e,t){o.config.debug&&console.log(`Plugin ${o.id}: load script `+i);var n=document.createElement("script");n.src=i,o.config.isSetTimestamp&&(n.src=getUrlWithTimestamp(i)),n.onload=function(){e(n)},n.onerror=function(){var e=new Error("Ошибка загрузки скрипта "+i);o.errors.push(e),console.log(`%cPlugin.load(${o.id}): error load script!`,"color: red;"),t(e)},document.head.append(n)});o.config.debug&&console.warn(`Plugin ${o.id}: Скрипт ${i} уже загружен!`)},Plugin.prototype.getStylePromise=function(i){var o=this;return new Promise(function(e,t){var n;isAssetLoaded(i)?(o.config.debug&&console.warn(`Plugin ${o.id}: Стиль ${i} уже загружен`),e()):((n=document.createElement("link")).rel="stylesheet",n.type="text/css",n.media="all",n.href=i,o.config.isSetTimestamp&&(n.href=getUrlWithTimestamp(i)),document.head.append(n),e(n))})},Plugin.prototype.getAsyncScriptListPromise=function(e){e=e.map(this.getScriptPromise.bind(this)).filter(e=>void 0!==e);if(e.length)return Promise.all(e)},Plugin.prototype.getJsAssetsPromiseCallback=function(e=[]){var o=this;if(e.length)return function(){var i=new Promise(function(e,t){e()});return e.forEach(function(e,t,n){i=Array.isArray(e)?i.then(function(){return o.getAsyncScriptListPromise(e)}):i.then(function(){return o.getScriptPromise(o.config.path+e)})}),i}},Plugin.prototype.__getRealId=function(e){var t,n=e.toLowerCase();if(this.id.toLowerCase()===n)return this.id;for(t of this.config.alias)if(n===t.toLowerCase())return this.id},Plugin.prototype.__is=function(e){return this.id===this.__getRealId(e)},Plugin.prototype.isLoaded=function(){return this.__checkState(stateList.loaded)},Plugin.prototype.isInstalled=function(){return this.__checkState(stateList.installed)},Plugin.prototype.require=function(){return this.isInstalled()||this.config.debug&&console.warn(`Plugin ${this.id}: not instaled!`),this.module.exports};var PluginManager=function(e){this.plugins={},this.global=e};function init(e){var o=new PluginManager(e);e.ready=o.ready.bind(o),e.exec=o.exec.bind(o),e.require=o.require.bind(o),o.register("pluginManager",{alias:"pm",type:MD_TYPE.HMD,handler:function(e,t,n,i){return i.PluginManagerClass=PluginManager,"object"==typeof window&&(window.__PluginManager__=o,window.__pmGlobal__=i),n.exports=o},onInstall:function(e){}}),o.install("pluginManager"),o.register("config",{type:MD_TYPE.HMD,handler:function(e,t,n,i){var o=document.currentScript;if(o)try{var s=new URL(o.src);defaultConfig.assetsPath=s.pathname.split("/").slice(0,-2).join("/")}catch(e){s=o.src.split("?")[0];defaultConfig.assetsPath=s.split("/").slice(0,-2).join("/")}o=i.config||{},o=Object.assign({},defaultConfig,o);"object"==typeof window&&(window.__pmConfig__=i.config=o),document.addEventListener("DOMContentLoaded",function(){console.log("%cDOMContentLoaded","color:#2053ff")})},onInstall:function(e){"object"==typeof window&&window.hasOwnProperty("__PluginManagerConfigHandler__")&&"function"==typeof __PluginManagerConfigHandler__&&o.registerPlugins(__PluginManagerConfigHandler__())}}),o.install("config")}PluginManager.prototype.registerPlugins=function(e){for(var t in e)e.hasOwnProperty(t)&&this.register(t,e[t]);return this},PluginManager.prototype.register=function(e,t={}){var n;"string"!=typeof e||""===e?console.warn("Invalid pluginId!",e):(n=this.__getPlugin(e))?n.register(t):((n=new Plugin(e,t)).setPluginManager(this),this.plugins[e]=n)},PluginManager.prototype.__getPlugin=function(e){var t,n;for(t in this.plugins)if(this.plugins.hasOwnProperty(t)&&(n=this.plugins[t]).__is(e))return n},PluginManager.prototype.__getDepsPromiseCallback=function(e=[]){var n=this,t=e.map(function(e){var t=n.__getPlugin(e);if(t)return t.install(),t.isInstalled()?void 0:t.promise;console.log(`%cPluginManager: plugin ${e} not found!`,"color: red;")}).filter(e=>void 0!==e);if(t.length)return function(){return Promise.all(t)}},PluginManager.prototype.__getRealIdList=function(e=[]){var t=this;return e.map(function(e){e=t.__getPlugin(e);if(e)return e.id})},PluginManager.prototype.exec=function(e,t,n=[],i=void 0){"function"==typeof e&&(i=n,n=t,t=e,e=[]),"string"==typeof e&&(e=[e]),void 0===i&&(i=this),void 0===n&&(n=[]),"function"==typeof t&&(global.config&&global.config.requiredDependencies&&(e=Array.from(new Set(e.concat(global.config.requiredDependencies)))),(e=this.__getDepsPromiseCallback(e))?e().then(function(){t.apply(i,n)}):t.apply(i,n))},PluginManager.prototype.exec2=function(e,t){var n=this,i=this,o=n.__getDepsPromiseCallback(e),s=function(){var t=[];return e.forEach(function(e){n.__getPlugin(e)?t.push(n.require(e)):t.push(void 0)}.bind(n)),t}.bind(n);o?o().then(function(){t.apply(i,s())}):t.apply(i,s())},PluginManager.prototype.ready=function(e,t=void 0){"function"==typeof e&&(t=e,e=[]),this.__ready(this.exec,[e,t="function"!=typeof t?function(){}:t],this)},PluginManager.prototype.__ready=function(e,t=[],n=window){n=n||this,/complete|interactive|loaded/.test(document.readyState)?e.apply(n,t):document.addEventListener("DOMContentLoaded",function(){e.apply(n,t)}.bind(this))},PluginManager.prototype.require=function(e,t){var n,i=this.__getPlugin(e);if(i)return e=i.id,n=i.module,i.install(t="function"!=typeof t?function(){}:t),n.exports;console.warn("PluginManager.require: plugin "+e+" not found!")},PluginManager.prototype.install=function(e,t){var n=this.__getPlugin(e);n?(e=n.id,n.module,n.install(t)):console.warn("PluginManager.install: plugin "+e+" not found!")},init(global)}(kit); \ No newline at end of file