mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
v2.0.1
This commit is contained in:
+23
-13
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -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: {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user