This commit is contained in:
2024-06-26 00:48:19 +03:00
parent 69c8e0e86c
commit 3228b3cb49
14 changed files with 42 additions and 39 deletions
+23 -13
View File
@@ -33,6 +33,7 @@ kit.config = kit.config || {};
ES: 'ES', // CMAScript2020 or ES11
UMD: 'UMD', // https://github.com/umdjs/umd
HMD: 'HMD', // HandlerMD - function(require, exports, module, global){module.exports = {}; return {};}
default: 'default',
};
/**
* @memberOf kit
@@ -54,7 +55,7 @@ kit.config = kit.config || {};
isSetTimestamp: true,
path: '',
module: '', // file.js
type: 'ES',
type: 'default',
handler: undefined,
onRegister: function(plugin){},
onLoad: function(plugin){},
@@ -190,7 +191,7 @@ kit.config = kit.config || {};
config.autoRequire = config.hasOwnProperty('autoRequire')?!!config.autoRequire:false;
config.loadJsAfterModule = config.hasOwnProperty('loadJsAfterModule')?!!config.loadJsAfterModule:false;
config.isSetTimestamp = config.hasOwnProperty('isSetTimestamp')?!!config.isSetTimestamp:true;
config.type = config.type || 'ES';
config.type = config.type || 'default';
if(typeof config.deps === 'string') {
config.deps = [config.deps];
@@ -321,6 +322,16 @@ kit.config = kit.config || {};
return function (){
return self.getScriptPromise(src);
};
} else if(typeof config.module === 'string' && config.module !== '' && config.type === 'default') {
if (isAssetLoaded(src)) {
self.config.debug && console.warn(`Plugin ${self.id}: Скрипт ${src} уже загружен!`);
return;
}
else {
return function (){
return self.getScriptPromise(src);
};
}
}
return;
};
@@ -420,29 +431,28 @@ kit.config = kit.config || {};
};
var module = self.module;
var exports = self.module.exports;
var installer = function(){
var __exports = undefined;
if(self.config.type === 'ES' && typeof self.config.module === 'string' && self.config.module !== '') {
__exports = (typeof exports === 'object' && exports.default !== undefined)
?exports.default
:exports;
__exports = (typeof self.module.exports === 'object' && self.module.exports.default !== undefined)
?self.module.exports.default
:self.module.exports;
} else if(self.config.type === 'UMD' && typeof self.config.module === 'string' && self.config.module !== '') {
(function(require, exports, module, global){
var self = global;
eval(module.code);
}.bind(global))
.call(global, require, exports, module, global);
__exports = (typeof exports === 'object' && exports.default !== undefined)
?exports.default
:exports;
.call(global, require, self.module.exports, module, global);
__exports = (typeof self.module.exports === 'object' && self.module.exports.default !== undefined)
?self.module.exports.default
:self.module.exports;
} else if(self.config.type === 'HMD' && typeof self.config.handler === 'function') {
__exports = self.config.handler.bind(global)
.call(global, require, exports, module, global);
if(__exports === undefined && exports){
__exports = exports;
.call(global, require, self.module.exports, module, global);
if(__exports === undefined && self.module.exports){
__exports = self.module.exports;
}
}
+1 -1
View File
File diff suppressed because one or more lines are too long
+10 -11
View File
@@ -27,7 +27,7 @@ var __PluginManagerConfigHandler__ = function() {
},
support: {
path: root + '/support',
module: '/support.js',
module: '/support.min.js',
type: 'HMD',
},
jqueryIniter: {
@@ -87,7 +87,6 @@ var __PluginManagerConfigHandler__ = function() {
type: 'UMD',
alias: ['$', 'jQuery'],
onRegister: function (plugin) {
console.log('reg jq');
var initer = kit.require('jqueryIniter');
initer.onRegister(plugin);
},
@@ -105,7 +104,7 @@ var __PluginManagerConfigHandler__ = function() {
},
bsCore: {
path: root + '/bsCore',
module: '/bsCore.js',
module: '/bsCore.min.js',
type: 'HMD',
css: [
'/bsCore.css'
@@ -198,7 +197,7 @@ var __PluginManagerConfigHandler__ = function() {
},
Modal: {
path: root + '/modal',
module: '/modal.js',
module: '/modal.min.js',
type: 'HMD',
css: [
'/modal.css',
@@ -223,7 +222,7 @@ var __PluginManagerConfigHandler__ = function() {
},
collapse: {
path: root + '/collapse',
module: '/collapse.js',
module: '/collapse.min.js',
type: 'HMD',
css: [
'/collapse.css',
@@ -241,7 +240,7 @@ var __PluginManagerConfigHandler__ = function() {
},
cookie: {
path: root + '/cookie',
module: '/cookie.js',
module: '/cookie.min.js',
type: 'HMD',
},
animations: {
@@ -258,7 +257,7 @@ var __PluginManagerConfigHandler__ = function() {
},
dataStructures: {
path: root + '/dataStructures',
module: '/dataStructures.js',
module: '/dataStructures.min.js',
type: 'HMD',
},
userAction: {
@@ -382,7 +381,7 @@ var __PluginManagerConfigHandler__ = function() {
css: [
'/jquery.bxslider.min.css',
],
type: 'import',
type: 'default',
deps: ['jQuery'],
},
selectric: {
@@ -391,7 +390,7 @@ var __PluginManagerConfigHandler__ = function() {
css: [
'/selectric.css',
],
type: 'import',
type: 'UMD',
alias: ['jquerySelectric'],
deps: ['jQuery'],
},
@@ -401,7 +400,7 @@ var __PluginManagerConfigHandler__ = function() {
css: [
'/jBox.min.css',
],
type: 'import',
type: 'UMD',
deps: ['jQuery'],
},
intlTelInput: {
@@ -410,7 +409,7 @@ var __PluginManagerConfigHandler__ = function() {
css: [
'/css/intlTelInput.min.css',
],
type: 'import',
type: 'UMD',
alias: ['intl-tel-input'],
},
autoComplete: {
File diff suppressed because one or more lines are too long