UNPKG

gluebert

Version:

gluebert.js is a tiny helper orchestrating interactive html elements with on demand dynamic import Edit

1 lines 3.32 kB
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.ModuleSignature=void 0;var _typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_module=require('./module.dependency');function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}var ModuleSignature=function(){function a(b){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;_classCallCheck(this,a),this.validateName(b),this.validateSelector(c),this.name=b,this.selector=c,this.importController=null,this.importStyles=null,this.elements=new Set,this.isLazy=!0,this.dependencyManager=new _module.DependencyManager}return _createClass(a,[{key:'validateName',value:function validateName(a){if('string'!=typeof a)throw new Error('Signature name must be string. Given '+a+' ('+('undefined'==typeof a?'undefined':_typeof(a))+')');return!0}},{key:'validateSelector',value:function validateSelector(a){if(null!==a&&'string'!=typeof a)throw new Error('Signature selector must be css selector as string. Given '+a+' ('+('undefined'==typeof a?'undefined':_typeof(a))+')');return!0}},{key:'validateController',value:function validateController(a){if('function'!=typeof a)throw new Error('\n Signature controller must be a function returning a promise.\n Given '+a+' ('+('undefined'==typeof a?'undefined':_typeof(a))+')\n ');return!0}},{key:'validateImportStyles',value:function validateImportStyles(a){if('function'!=typeof a)throw new Error('\n Signature styles must be a function returning a promise.\n Given '+a+' ('+('undefined'==typeof a?'undefined':_typeof(a))+')\n ');return!0}},{key:'setSelector',value:function setSelector(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return this.validateSelector(a),this.selector=a,this}},{key:'getSelector',value:function getSelector(){return this.selector}},{key:'setImportController',value:function setImportController(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return this.validateController(a),this.importController=a,this}},{key:'getImportController',value:function getImportController(){return this.importController}},{key:'setImportStyles',value:function setImportStyles(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;return this.validateImportStyles(a),this.importStyles=a,this}},{key:'getImportStyles',value:function getImportStyles(){return this.importStyles}},{key:'addElementSignature',value:function addElementSignature(a){return this.elements.add(a),this}},{key:'getElementSignatures',value:function getElementSignatures(){return this.elements}},{key:'addDependency',value:function addDependency(a,b){return this.dependencyManager.add(a,b),this}},{key:'disableLazy',value:function disableLazy(){return this.isLazy=!1,this}}]),a}();exports.ModuleSignature=ModuleSignature;