mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
+64
-25
@@ -1,4 +1,5 @@
|
||||
window.kit = window.kit || {};
|
||||
var kit;
|
||||
kit = window.kit = window.kit || {};
|
||||
kit.service = kit.service || {};
|
||||
kit.config = kit.config || {};
|
||||
|
||||
@@ -36,7 +37,6 @@ kit.config = kit.config || {};
|
||||
default: 'default',
|
||||
};
|
||||
/**
|
||||
* @memberOf kit
|
||||
* @param pluginId
|
||||
* @param config
|
||||
* @constructor
|
||||
@@ -606,7 +606,7 @@ kit.config = kit.config || {};
|
||||
list.forEach(function(item, i, array){
|
||||
if(Array.isArray(item)) {
|
||||
p = p.then(function () {
|
||||
return self.getAsyncScriptListPromise(item);
|
||||
return self.getAsyncScriptListPromise(item.map((src) => self.config.path + src));
|
||||
});
|
||||
} else {
|
||||
p = p.then(function () {
|
||||
@@ -666,6 +666,7 @@ kit.config = kit.config || {};
|
||||
this.global = global;
|
||||
};
|
||||
|
||||
var __proto = PluginManager.prototype;
|
||||
/**
|
||||
* @param plugins
|
||||
* @return {PluginManager}
|
||||
@@ -758,7 +759,13 @@ kit.config = kit.config || {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @memberOf kit
|
||||
* @typedef PluginManager.exec
|
||||
*
|
||||
* @param deps
|
||||
* @param callback
|
||||
* @param argArr
|
||||
* @param context
|
||||
* @returns {undefined}
|
||||
*/
|
||||
PluginManager.prototype.exec = function (deps, callback, argArr = [], context = undefined) {
|
||||
var self = this;
|
||||
@@ -796,7 +803,7 @@ kit.config = kit.config || {};
|
||||
}
|
||||
};
|
||||
|
||||
PluginManager.prototype.exec2 = function (deps, callback) {
|
||||
__proto.exec2 = function (deps, callback) {
|
||||
var self = this;
|
||||
var context = this;
|
||||
|
||||
@@ -825,12 +832,12 @@ kit.config = kit.config || {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef PluginManager.ready
|
||||
*
|
||||
* @param {(string|string[])} deps
|
||||
* @param {function} callback
|
||||
* @memberOf kit
|
||||
*/
|
||||
|
||||
PluginManager.prototype.ready = function(deps, callback = undefined) {
|
||||
__proto.ready = function(deps, callback = undefined) {
|
||||
var self = this;
|
||||
if(typeof deps === 'function') {
|
||||
callback = deps;
|
||||
@@ -841,7 +848,8 @@ kit.config = kit.config || {};
|
||||
}
|
||||
self.__ready(self.exec, [deps, callback], self);
|
||||
};
|
||||
PluginManager.prototype.__ready = function(fn, args = [], context = window) {
|
||||
|
||||
__proto.__ready = function(fn, args = [], context = window) {
|
||||
var self = this;
|
||||
context = context || this;
|
||||
if (/complete|interactive|loaded/.test(document.readyState)) {
|
||||
@@ -852,13 +860,14 @@ kit.config = kit.config || {};
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef PluginManager.loaded
|
||||
*
|
||||
* @param {(string|string[])} deps
|
||||
* @param {function} callback
|
||||
* @memberOf kit
|
||||
*/
|
||||
|
||||
PluginManager.prototype.loaded = function(deps, callback = undefined) {
|
||||
__proto.loaded = function(deps, callback = undefined) {
|
||||
var self = this;
|
||||
if(typeof deps === 'function') {
|
||||
callback = deps;
|
||||
@@ -869,7 +878,8 @@ kit.config = kit.config || {};
|
||||
}
|
||||
self.__loaded(self.exec, [deps, callback], self);
|
||||
};
|
||||
PluginManager.prototype.__loaded = function(fn, args = [], context = window) {
|
||||
|
||||
__proto.__loaded = function(fn, args = [], context = window) {
|
||||
var self = this;
|
||||
context = context || this;
|
||||
if (/complete|interactive|loaded/.test(document.readyState)) {
|
||||
@@ -881,7 +891,15 @@ kit.config = kit.config || {};
|
||||
}
|
||||
};
|
||||
|
||||
PluginManager.prototype.require = function (pluginId, callback) {
|
||||
/**
|
||||
* @typedef PluginManager.require
|
||||
*
|
||||
* @param pluginId
|
||||
* @param callback
|
||||
* @returns {undefined|*}
|
||||
*
|
||||
*/
|
||||
__proto.require = function (pluginId, callback) {
|
||||
|
||||
var plugin = this.__getPlugin(pluginId);
|
||||
if(!plugin) {
|
||||
@@ -900,7 +918,14 @@ kit.config = kit.config || {};
|
||||
return module.exports;
|
||||
};
|
||||
|
||||
PluginManager.prototype.install = function (pluginId, callback) {
|
||||
/**
|
||||
* @typedef PluginManager.install
|
||||
*
|
||||
* @param pluginId
|
||||
* @param callback
|
||||
* @returns {undefined}
|
||||
*/
|
||||
__proto.install = function (pluginId, callback) {
|
||||
|
||||
var plugin = this.__getPlugin(pluginId);
|
||||
if(!plugin) {
|
||||
@@ -916,9 +941,25 @@ kit.config = kit.config || {};
|
||||
function init(global){
|
||||
|
||||
var manager = new PluginManager(global);
|
||||
/**
|
||||
* @type {PluginManager.ready}
|
||||
* @memberOf kit
|
||||
*/
|
||||
global.ready = manager.ready.bind(manager);
|
||||
/**
|
||||
* @type {PluginManager.loaded}
|
||||
* @memberOf kit
|
||||
*/
|
||||
global.loaded = manager.loaded.bind(manager);
|
||||
/**
|
||||
* @type {PluginManager.exec}
|
||||
* @memberOf kit
|
||||
*/
|
||||
global.exec = manager.exec.bind(manager);
|
||||
/**
|
||||
* @type {PluginManager.require}
|
||||
* @memberOf kit
|
||||
*/
|
||||
global.require = manager.require.bind(manager);
|
||||
manager.register('pluginManager', {
|
||||
alias: 'pm',
|
||||
@@ -956,19 +997,17 @@ kit.config = kit.config || {};
|
||||
}
|
||||
|
||||
var config = global.config || {};
|
||||
config = Object.assign({}, defaultConfig, config);
|
||||
global.config = Object.assign({}, defaultConfig, config);
|
||||
if(typeof window === 'object'){
|
||||
window.__pmConfig__ = global.config = config;
|
||||
window.__pmConfig__ = global.config;
|
||||
}
|
||||
|
||||
(function(){
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
console.log('%cDOMContentLoaded', 'color:#2053ff');
|
||||
});
|
||||
window.addEventListener("load", (event) => {
|
||||
console.log('%cWindowLoaded', 'color:#2053ff');
|
||||
});
|
||||
}());
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
console.log('%cDOMContentLoaded', 'color:#2053ff');
|
||||
});
|
||||
window.addEventListener("load", (event) => {
|
||||
console.log('%cWindowLoaded', 'color:#2053ff');
|
||||
});
|
||||
},
|
||||
onInstall: function(plugin){
|
||||
if(typeof window === 'object'){
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user