@superset-ui/core
Advanced tools
Comparing version 0.12.5 to 0.12.8
@@ -1,1 +0,11 @@ | ||
export{default as ExtensibleFunction}from"./models/ExtensibleFunction";export{default as Plugin}from"./models/Plugin";export{default as Preset}from"./models/Preset";export{default as Registry}from"./models/Registry";export{default as RegistryWithDefaultKey}from"./models/RegistryWithDefaultKey";export{default as convertKeysToCamelCase}from"./utils/convertKeysToCamelCase";export{default as isDefined}from"./utils/isDefined";export{default as isRequired}from"./utils/isRequired";export{default as makeSingleton}from"./utils/makeSingleton";export{default as promiseTimeout}from"./utils/promiseTimeout";export*from"./types"; | ||
export { default as ExtensibleFunction } from './models/ExtensibleFunction'; | ||
export { default as Plugin } from './models/Plugin'; | ||
export { default as Preset } from './models/Preset'; | ||
export { default as Registry } from './models/Registry'; | ||
export { default as RegistryWithDefaultKey } from './models/RegistryWithDefaultKey'; | ||
export { default as convertKeysToCamelCase } from './utils/convertKeysToCamelCase'; | ||
export { default as isDefined } from './utils/isDefined'; | ||
export { default as isRequired } from './utils/isRequired'; | ||
export { default as makeSingleton } from './utils/makeSingleton'; | ||
export { default as promiseTimeout } from './utils/promiseTimeout'; | ||
export * from './types'; |
@@ -1,3 +0,11 @@ | ||
function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _construct(){return _construct=isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}/** | ||
/** | ||
* From https://stackoverflow.com/questions/36871299/how-to-extend-function-with-es6-classes | ||
*/var ExtensibleFunction=/*#__PURE__*/function(a){function b(c){var d;return d=a.call(this)||this,Object.setPrototypeOf(c,(this instanceof b?this.constructor:void 0).prototype)||_assertThisInitialized(d)}return _inheritsLoose(b,a),b}(_wrapNativeSuper(Function));export{ExtensibleFunction as default}; | ||
*/ | ||
export default class ExtensibleFunction extends Function { | ||
constructor(fn) { | ||
super(); // eslint-disable-next-line no-constructor-return | ||
return Object.setPrototypeOf(fn, new.target.prototype); | ||
} | ||
} |
@@ -1,1 +0,36 @@ | ||
function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Plugin=/*#__PURE__*/function(){function a(){_defineProperty(this,"config",void 0),this.config={}}var b=a.prototype;return b.resetConfig=function resetConfig(){return this.config={},this},b.configure=function configure(a,b){return void 0===b&&(b=!1),this.config=b?a:_extends({},this.config,{},a),this},b.register=function register(){return this},b.unregister=function unregister(){return this},a}();export{Plugin as default}; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
export default class Plugin { | ||
constructor() { | ||
_defineProperty(this, "config", void 0); | ||
this.config = {}; | ||
} | ||
resetConfig() { | ||
// The child class can set default config | ||
// by overriding this function. | ||
this.config = {}; | ||
return this; | ||
} | ||
configure(config, replace) { | ||
if (replace === void 0) { | ||
replace = false; | ||
} | ||
this.config = replace ? config : _extends({}, this.config, {}, config); | ||
return this; | ||
} | ||
register() { | ||
return this; | ||
} | ||
unregister() { | ||
return this; | ||
} | ||
} |
@@ -1,1 +0,39 @@ | ||
function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Preset=/*#__PURE__*/function(){function a(a){void 0===a&&(a={}),_defineProperty(this,"name",void 0),_defineProperty(this,"description",void 0),_defineProperty(this,"presets",void 0),_defineProperty(this,"plugins",void 0);var b=a,c=b.name,d=void 0===c?"":c,e=b.description,f=void 0===e?"":e,g=b.presets,h=void 0===g?[]:g,i=b.plugins,j=void 0===i?[]:i;this.name=d,this.description=f,this.presets=h,this.plugins=j}var b=a.prototype;return b.register=function register(){return this.presets.forEach(function(a){a.register()}),this.plugins.forEach(function(a){a.register()}),this},a}();export{Preset as default}; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
export default class Preset { | ||
constructor(config) { | ||
if (config === void 0) { | ||
config = {}; | ||
} | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "description", void 0); | ||
_defineProperty(this, "presets", void 0); | ||
_defineProperty(this, "plugins", void 0); | ||
const { | ||
name = '', | ||
description = '', | ||
presets = [], | ||
plugins = [] | ||
} = config; | ||
this.name = name; | ||
this.description = description; | ||
this.presets = presets; | ||
this.plugins = plugins; | ||
} | ||
register() { | ||
this.presets.forEach(preset => { | ||
preset.register(); | ||
}); | ||
this.plugins.forEach(plugin => { | ||
plugin.register(); | ||
}); | ||
return this; | ||
} | ||
} |
@@ -1,2 +0,7 @@ | ||
function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}/* eslint no-console: 0 */import{OverwritePolicy}from"../types";/** | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/* eslint no-console: 0 */ | ||
import { OverwritePolicy } from '../types'; | ||
/** | ||
* Registry class | ||
@@ -11,2 +16,164 @@ * | ||
* both synchronous and asynchronous loaders. | ||
*/var Registry=/*#__PURE__*/function(){function a(a){void 0===a&&(a={}),_defineProperty(this,"name",void 0),_defineProperty(this,"overwritePolicy",void 0),_defineProperty(this,"items",void 0),_defineProperty(this,"promises",void 0);var b=a,c=b.name,d=void 0===c?"":c,e=b.overwritePolicy,f=void 0===e?OverwritePolicy.ALLOW:e;this.name=d,this.overwritePolicy=f,this.items={},this.promises={}}var b=a.prototype;return b.clear=function clear(){return this.items={},this.promises={},this},b.has=function has(a){var b=this.items[a];return null!==b&&void 0!==b},b.registerValue=function registerValue(a,b){var c=this.items[a],d=this.has(a)&&("value"in c&&c.value!==b||"loader"in c);if(d)if(this.overwritePolicy===OverwritePolicy.WARN)console.warn("Item with key \""+a+"\" already exists. You are assigning a new value.");else if(this.overwritePolicy===OverwritePolicy.PROHIBIT)throw new Error("Item with key \""+a+"\" already exists. Cannot overwrite.");return(!c||d)&&(this.items[a]={value:b},delete this.promises[a]),this},b.registerLoader=function registerLoader(a,b){var c=this.items[a],d=this.has(a)&&("loader"in c&&c.loader!==b||"value"in c);if(d)if(this.overwritePolicy===OverwritePolicy.WARN)console.warn("Item with key \""+a+"\" already exists. You are assigning a new value.");else if(this.overwritePolicy===OverwritePolicy.PROHIBIT)throw new Error("Item with key \""+a+"\" already exists. Cannot overwrite.");return(!c||d)&&(this.items[a]={loader:b},delete this.promises[a]),this},b.get=function get(a){var b=this.items[a];return void 0===b?void 0:"loader"in b?b.loader&&b.loader():b.value},b.getAsPromise=function getAsPromise(a){var b=this.promises[a];if(b)return b;var c=this.get(a);if(void 0!==c){var d=Promise.resolve(c);return this.promises[a]=d,d}return Promise.reject(new Error("Item with key \""+a+"\" is not registered."))},b.getMap=function getMap(){var a=this;return this.keys().reduce(function(b,c){var d=b;return d[c]=a.get(c),d},{})},b.getMapAsPromise=function getMapAsPromise(){var a=this,b=this.keys();return Promise.all(b.map(function(b){return a.getAsPromise(b)})).then(function(a){return a.reduce(function(a,c,d){var e=a;return e[b[d]]=c,e},{})})},b.keys=function keys(){return Object.keys(this.items)},b.values=function values(){var a=this;return this.keys().map(function(b){return a.get(b)})},b.valuesAsPromise=function valuesAsPromise(){var a=this;return Promise.all(this.keys().map(function(b){return a.getAsPromise(b)}))},b.entries=function entries(){var a=this;return this.keys().map(function(b){return{key:b,value:a.get(b)}})},b.entriesAsPromise=function entriesAsPromise(){var a=this,b=this.keys();return Promise.all(b.map(function(b){return a.getAsPromise(b)})).then(function(a){return a.map(function(a,c){return{key:b[c],value:a}})})},b.remove=function remove(a){return delete this.items[a],delete this.promises[a],this},a}();export{Registry as default}; | ||
*/ | ||
export default class Registry { | ||
constructor(config) { | ||
if (config === void 0) { | ||
config = {}; | ||
} | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "overwritePolicy", void 0); | ||
_defineProperty(this, "items", void 0); | ||
_defineProperty(this, "promises", void 0); | ||
const { | ||
name = '', | ||
overwritePolicy = OverwritePolicy.ALLOW | ||
} = config; | ||
this.name = name; | ||
this.overwritePolicy = overwritePolicy; | ||
this.items = {}; | ||
this.promises = {}; | ||
} | ||
clear() { | ||
this.items = {}; | ||
this.promises = {}; | ||
return this; | ||
} | ||
has(key) { | ||
const item = this.items[key]; | ||
return item !== null && item !== undefined; | ||
} | ||
registerValue(key, value) { | ||
const item = this.items[key]; | ||
const willOverwrite = this.has(key) && ('value' in item && item.value !== value || 'loader' in item); | ||
if (willOverwrite) { | ||
if (this.overwritePolicy === OverwritePolicy.WARN) { | ||
console.warn("Item with key \"" + key + "\" already exists. You are assigning a new value."); | ||
} else if (this.overwritePolicy === OverwritePolicy.PROHIBIT) { | ||
throw new Error("Item with key \"" + key + "\" already exists. Cannot overwrite."); | ||
} | ||
} | ||
if (!item || willOverwrite) { | ||
this.items[key] = { | ||
value | ||
}; | ||
delete this.promises[key]; | ||
} | ||
return this; | ||
} | ||
registerLoader(key, loader) { | ||
const item = this.items[key]; | ||
const willOverwrite = this.has(key) && ('loader' in item && item.loader !== loader || 'value' in item); | ||
if (willOverwrite) { | ||
if (this.overwritePolicy === OverwritePolicy.WARN) { | ||
console.warn("Item with key \"" + key + "\" already exists. You are assigning a new value."); | ||
} else if (this.overwritePolicy === OverwritePolicy.PROHIBIT) { | ||
throw new Error("Item with key \"" + key + "\" already exists. Cannot overwrite."); | ||
} | ||
} | ||
if (!item || willOverwrite) { | ||
this.items[key] = { | ||
loader | ||
}; | ||
delete this.promises[key]; | ||
} | ||
return this; | ||
} | ||
get(key) { | ||
const item = this.items[key]; | ||
if (item !== undefined) { | ||
if ('loader' in item) { | ||
return item.loader && item.loader(); | ||
} | ||
return item.value; | ||
} | ||
return undefined; | ||
} | ||
getAsPromise(key) { | ||
const promise = this.promises[key]; | ||
if (typeof promise !== 'undefined') { | ||
return promise; | ||
} | ||
const item = this.get(key); | ||
if (item !== undefined) { | ||
const newPromise = Promise.resolve(item); | ||
this.promises[key] = newPromise; | ||
return newPromise; | ||
} | ||
return Promise.reject(new Error("Item with key \"" + key + "\" is not registered.")); | ||
} | ||
getMap() { | ||
return this.keys().reduce((prev, key) => { | ||
const map = prev; | ||
map[key] = this.get(key); | ||
return map; | ||
}, {}); | ||
} | ||
getMapAsPromise() { | ||
const keys = this.keys(); | ||
return Promise.all(keys.map(key => this.getAsPromise(key))).then(values => values.reduce((prev, value, i) => { | ||
const map = prev; | ||
map[keys[i]] = value; | ||
return map; | ||
}, {})); | ||
} | ||
keys() { | ||
return Object.keys(this.items); | ||
} | ||
values() { | ||
return this.keys().map(key => this.get(key)); | ||
} | ||
valuesAsPromise() { | ||
return Promise.all(this.keys().map(key => this.getAsPromise(key))); | ||
} | ||
entries() { | ||
return this.keys().map(key => ({ | ||
key, | ||
value: this.get(key) | ||
})); | ||
} | ||
entriesAsPromise() { | ||
const keys = this.keys(); | ||
return Promise.all(keys.map(key => this.getAsPromise(key))).then(values => values.map((value, i) => ({ | ||
key: keys[i], | ||
value | ||
}))); | ||
} | ||
remove(key) { | ||
delete this.items[key]; | ||
delete this.promises[key]; | ||
return this; | ||
} | ||
} |
@@ -1,1 +0,72 @@ | ||
function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}import Registry from"./Registry";var RegistryWithDefaultKey=/*#__PURE__*/function(a){function b(b){var c;void 0===b&&(b={}),c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"initialDefaultKey",void 0),_defineProperty(_assertThisInitialized(c),"defaultKey",void 0),_defineProperty(_assertThisInitialized(c),"setFirstItemAsDefault",void 0);var d=b,e=d.initialDefaultKey,f=void 0===e?void 0:e,g=d.setFirstItemAsDefault;return c.initialDefaultKey=f,c.defaultKey=f,c.setFirstItemAsDefault=void 0!==g&&g,c}_inheritsLoose(b,a);var c=b.prototype;return c.clear=function clear(){return a.prototype.clear.call(this),this.defaultKey=this.initialDefaultKey,this},c.get=function get(b){var c=b||this.defaultKey;return c?a.prototype.get.call(this,c):void 0},c.registerValue=function registerValue(b,c){return a.prototype.registerValue.call(this,b,c),this.setFirstItemAsDefault&&!this.defaultKey&&(this.defaultKey=b),this},c.registerLoader=function registerLoader(b,c){return a.prototype.registerLoader.call(this,b,c),this.setFirstItemAsDefault&&!this.defaultKey&&(this.defaultKey=b),this},c.getDefaultKey=function getDefaultKey(){return this.defaultKey},c.setDefaultKey=function setDefaultKey(a){return this.defaultKey=a,this},c.clearDefaultKey=function clearDefaultKey(){return this.defaultKey=void 0,this},b}(Registry);export{RegistryWithDefaultKey as default}; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import Registry from './Registry'; | ||
export default class RegistryWithDefaultKey extends Registry { | ||
constructor(config) { | ||
if (config === void 0) { | ||
config = {}; | ||
} | ||
super(config); | ||
_defineProperty(this, "initialDefaultKey", void 0); | ||
_defineProperty(this, "defaultKey", void 0); | ||
_defineProperty(this, "setFirstItemAsDefault", void 0); | ||
const { | ||
initialDefaultKey = undefined, | ||
setFirstItemAsDefault = false | ||
} = config; | ||
this.initialDefaultKey = initialDefaultKey; | ||
this.defaultKey = initialDefaultKey; | ||
this.setFirstItemAsDefault = setFirstItemAsDefault; | ||
} | ||
clear() { | ||
super.clear(); | ||
this.defaultKey = this.initialDefaultKey; | ||
return this; | ||
} | ||
get(key) { | ||
const targetKey = key != null ? key : this.defaultKey; | ||
return targetKey ? super.get(targetKey) : undefined; | ||
} | ||
registerValue(key, value) { | ||
super.registerValue(key, value); // If there is no default, set as default | ||
if (this.setFirstItemAsDefault && !this.defaultKey) { | ||
this.defaultKey = key; | ||
} | ||
return this; | ||
} | ||
registerLoader(key, loader) { | ||
super.registerLoader(key, loader); // If there is no default, set as default | ||
if (this.setFirstItemAsDefault && !this.defaultKey) { | ||
this.defaultKey = key; | ||
} | ||
return this; | ||
} | ||
getDefaultKey() { | ||
return this.defaultKey; | ||
} | ||
setDefaultKey(key) { | ||
this.defaultKey = key; | ||
return this; | ||
} | ||
clearDefaultKey() { | ||
this.defaultKey = undefined; | ||
return this; | ||
} | ||
} |
@@ -1,1 +0,8 @@ | ||
/* eslint-disable import/prefer-default-export, no-unused-vars */export var OverwritePolicy;(function(a){a.ALLOW="ALLOW",a.PROHIBIT="PROHIBIT",a.WARN="WARN"})(OverwritePolicy||(OverwritePolicy={})); | ||
/* eslint-disable import/prefer-default-export */ | ||
export let OverwritePolicy; | ||
(function (OverwritePolicy) { | ||
OverwritePolicy["ALLOW"] = "ALLOW"; | ||
OverwritePolicy["PROHIBIT"] = "PROHIBIT"; | ||
OverwritePolicy["WARN"] = "WARN"; | ||
})(OverwritePolicy || (OverwritePolicy = {})); |
@@ -1,1 +0,14 @@ | ||
import camelCase from"lodash/camelCase";import isPlainObject from"lodash/isPlainObject";import mapKeys from"lodash/mapKeys";export default function convertKeysToCamelCase(a){if(null===a||a===void 0)return a;if(isPlainObject(a))return mapKeys(a,function(a,b){return camelCase(b)});throw new Error("Cannot convert input that is not a plain object: "+a)} | ||
import camelCase from 'lodash/camelCase'; | ||
import isPlainObject from 'lodash/isPlainObject'; | ||
import mapKeys from 'lodash/mapKeys'; | ||
export default function convertKeysToCamelCase(object) { | ||
if (object === null || object === undefined) { | ||
return object; | ||
} | ||
if (isPlainObject(object)) { | ||
return mapKeys(object, (_, k) => camelCase(k)); | ||
} | ||
throw new Error("Cannot convert input that is not a plain object: " + object); | ||
} |
@@ -1,1 +0,3 @@ | ||
export default function isDefined(a){return null!==a&&a!==void 0} | ||
export default function isDefined(x) { | ||
return x !== null && x !== undefined; | ||
} |
@@ -1,1 +0,3 @@ | ||
export default function isRequired(a){throw new Error(a+" is required.")} | ||
export default function isRequired(field) { | ||
throw new Error(field + " is required."); | ||
} |
@@ -1,1 +0,14 @@ | ||
function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _construct(){return _construct=isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}export default function makeSingleton(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];var e;return function(){return e||(e=_construct(a,c)),e}} | ||
export default function makeSingleton(BaseClass) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
let singleton; | ||
return function getInstance() { | ||
if (!singleton) { | ||
singleton = new BaseClass(...args); | ||
} | ||
return singleton; | ||
}; | ||
} |
@@ -1,1 +0,12 @@ | ||
/** setTimeout that returns a promise */export default function promiseTimeout(/** A function to be executed after the timer expires. */a,/** The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. */b){return new Promise(function(c){setTimeout(function(){c(a())},b)})} | ||
/** setTimeout that returns a promise */ | ||
export default function promiseTimeout( | ||
/** A function to be executed after the timer expires. */ | ||
func, | ||
/** The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. */ | ||
delay) { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(func()); | ||
}, delay); | ||
}); | ||
} |
@@ -12,1 +12,2 @@ export { default as ExtensibleFunction } from './models/ExtensibleFunction'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,66 @@ | ||
"use strict";var _exportNames={ExtensibleFunction:!0,Plugin:!0,Preset:!0,Registry:!0,RegistryWithDefaultKey:!0,convertKeysToCamelCase:!0,isDefined:!0,isRequired:!0,makeSingleton:!0,promiseTimeout:!0};var _ExtensibleFunction=_interopRequireDefault(require("./models/ExtensibleFunction"));var _Plugin=_interopRequireDefault(require("./models/Plugin"));var _Preset=_interopRequireDefault(require("./models/Preset"));var _Registry=_interopRequireDefault(require("./models/Registry"));var _RegistryWithDefaultKey=_interopRequireDefault(require("./models/RegistryWithDefaultKey"));var _convertKeysToCamelCase=_interopRequireDefault(require("./utils/convertKeysToCamelCase"));var _isDefined=_interopRequireDefault(require("./utils/isDefined"));var _isRequired=_interopRequireDefault(require("./utils/isRequired"));var _makeSingleton=_interopRequireDefault(require("./utils/makeSingleton"));var _promiseTimeout=_interopRequireDefault(require("./utils/promiseTimeout"));var _types=require("./types");exports.__esModule=!0;exports.promiseTimeout=exports.makeSingleton=exports.isRequired=exports.isDefined=exports.convertKeysToCamelCase=exports.RegistryWithDefaultKey=exports.Registry=exports.Preset=exports.Plugin=exports.ExtensibleFunction=void 0;exports.ExtensibleFunction=_ExtensibleFunction.default;exports.Plugin=_Plugin.default;exports.Preset=_Preset.default;exports.Registry=_Registry.default;exports.RegistryWithDefaultKey=_RegistryWithDefaultKey.default;exports.convertKeysToCamelCase=_convertKeysToCamelCase.default;exports.isDefined=_isDefined.default;exports.isRequired=_isRequired.default;exports.makeSingleton=_makeSingleton.default;exports.promiseTimeout=_promiseTimeout.default;Object.keys(_types).forEach(function(a){"default"===a||"__esModule"===a||Object.prototype.hasOwnProperty.call(_exportNames,a)||(exports[a]=_types[a])});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
ExtensibleFunction: true, | ||
Plugin: true, | ||
Preset: true, | ||
Registry: true, | ||
RegistryWithDefaultKey: true, | ||
convertKeysToCamelCase: true, | ||
isDefined: true, | ||
isRequired: true, | ||
makeSingleton: true, | ||
promiseTimeout: true | ||
}; | ||
exports.promiseTimeout = exports.makeSingleton = exports.isRequired = exports.isDefined = exports.convertKeysToCamelCase = exports.RegistryWithDefaultKey = exports.Registry = exports.Preset = exports.Plugin = exports.ExtensibleFunction = void 0; | ||
var _ExtensibleFunction = _interopRequireDefault(require("./models/ExtensibleFunction")); | ||
exports.ExtensibleFunction = _ExtensibleFunction.default; | ||
var _Plugin = _interopRequireDefault(require("./models/Plugin")); | ||
exports.Plugin = _Plugin.default; | ||
var _Preset = _interopRequireDefault(require("./models/Preset")); | ||
exports.Preset = _Preset.default; | ||
var _Registry = _interopRequireDefault(require("./models/Registry")); | ||
exports.Registry = _Registry.default; | ||
var _RegistryWithDefaultKey = _interopRequireDefault(require("./models/RegistryWithDefaultKey")); | ||
exports.RegistryWithDefaultKey = _RegistryWithDefaultKey.default; | ||
var _convertKeysToCamelCase = _interopRequireDefault(require("./utils/convertKeysToCamelCase")); | ||
exports.convertKeysToCamelCase = _convertKeysToCamelCase.default; | ||
var _isDefined = _interopRequireDefault(require("./utils/isDefined")); | ||
exports.isDefined = _isDefined.default; | ||
var _isRequired = _interopRequireDefault(require("./utils/isRequired")); | ||
exports.isRequired = _isRequired.default; | ||
var _makeSingleton = _interopRequireDefault(require("./utils/makeSingleton")); | ||
exports.makeSingleton = _makeSingleton.default; | ||
var _promiseTimeout = _interopRequireDefault(require("./utils/promiseTimeout")); | ||
exports.promiseTimeout = _promiseTimeout.default; | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
exports[key] = _types[key]; | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -7,1 +7,2 @@ /** | ||
} | ||
//# sourceMappingURL=ExtensibleFunction.d.ts.map |
@@ -1,3 +0,18 @@ | ||
"use strict";exports.__esModule=!0,exports.default=void 0;function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _wrapNativeSuper(a){var b="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(a){function c(){return _construct(a,arguments,_getPrototypeOf(this).constructor)}if(null===a||!_isNativeFunction(a))return a;if("function"!=typeof a)throw new TypeError("Super expression must either be null or a function");if("undefined"!=typeof b){if(b.has(a))return b.get(a);b.set(a,c)}return c.prototype=Object.create(a.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(c,a)},_wrapNativeSuper(a)}function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _construct(){return _construct=isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _isNativeFunction(a){return-1!==Function.toString.call(a).indexOf("[native code]")}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}/** | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
/** | ||
* From https://stackoverflow.com/questions/36871299/how-to-extend-function-with-es6-classes | ||
*/var ExtensibleFunction=/*#__PURE__*/function(a){function b(c){var d;return d=a.call(this)||this,Object.setPrototypeOf(c,(this instanceof b?this.constructor:void 0).prototype)||_assertThisInitialized(d)}return _inheritsLoose(b,a),b}(_wrapNativeSuper(Function));exports.default=ExtensibleFunction; | ||
*/ | ||
class ExtensibleFunction extends Function { | ||
constructor(fn) { | ||
super(); // eslint-disable-next-line no-constructor-return | ||
return Object.setPrototypeOf(fn, new.target.prototype); | ||
} | ||
} | ||
exports.default = ExtensibleFunction; |
@@ -13,1 +13,2 @@ interface PlainObject { | ||
export {}; | ||
//# sourceMappingURL=Plugin.d.ts.map |
@@ -1,1 +0,43 @@ | ||
"use strict";exports.__esModule=!0,exports.default=void 0;function _extends(){return _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_extends.apply(this,arguments)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Plugin=/*#__PURE__*/function(){function a(){_defineProperty(this,"config",void 0),this.config={}}var b=a.prototype;return b.resetConfig=function resetConfig(){return this.config={},this},b.configure=function configure(a,b){return void 0===b&&(b=!1),this.config=b?a:_extends({},this.config,{},a),this},b.register=function register(){return this},b.unregister=function unregister(){return this},a}();exports.default=Plugin; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class Plugin { | ||
constructor() { | ||
_defineProperty(this, "config", void 0); | ||
this.config = {}; | ||
} | ||
resetConfig() { | ||
// The child class can set default config | ||
// by overriding this function. | ||
this.config = {}; | ||
return this; | ||
} | ||
configure(config, replace) { | ||
if (replace === void 0) { | ||
replace = false; | ||
} | ||
this.config = replace ? config : _extends({}, this.config, {}, config); | ||
return this; | ||
} | ||
register() { | ||
return this; | ||
} | ||
unregister() { | ||
return this; | ||
} | ||
} | ||
exports.default = Plugin; |
@@ -15,1 +15,2 @@ import Plugin from './Plugin'; | ||
} | ||
//# sourceMappingURL=Preset.d.ts.map |
@@ -1,1 +0,46 @@ | ||
"use strict";exports.__esModule=!0,exports.default=void 0;function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var Preset=/*#__PURE__*/function(){function a(a){void 0===a&&(a={}),_defineProperty(this,"name",void 0),_defineProperty(this,"description",void 0),_defineProperty(this,"presets",void 0),_defineProperty(this,"plugins",void 0);var b=a,c=b.name,d=void 0===c?"":c,e=b.description,f=void 0===e?"":e,g=b.presets,h=void 0===g?[]:g,i=b.plugins,j=void 0===i?[]:i;this.name=d,this.description=f,this.presets=h,this.plugins=j}var b=a.prototype;return b.register=function register(){return this.presets.forEach(function(a){a.register()}),this.plugins.forEach(function(a){a.register()}),this},a}();exports.default=Preset; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class Preset { | ||
constructor(config) { | ||
if (config === void 0) { | ||
config = {}; | ||
} | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "description", void 0); | ||
_defineProperty(this, "presets", void 0); | ||
_defineProperty(this, "plugins", void 0); | ||
const { | ||
name = '', | ||
description = '', | ||
presets = [], | ||
plugins = [] | ||
} = config; | ||
this.name = name; | ||
this.description = description; | ||
this.presets = presets; | ||
this.plugins = plugins; | ||
} | ||
register() { | ||
this.presets.forEach(preset => { | ||
preset.register(); | ||
}); | ||
this.plugins.forEach(plugin => { | ||
plugin.register(); | ||
}); | ||
return this; | ||
} | ||
} | ||
exports.default = Preset; |
@@ -59,1 +59,2 @@ import { OverwritePolicy } from '../types'; | ||
export {}; | ||
//# sourceMappingURL=Registry.d.ts.map |
@@ -1,2 +0,11 @@ | ||
"use strict";var _types=require("../types");exports.__esModule=!0,exports.default=void 0;function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}/** | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _types = require("../types"); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
* Registry class | ||
@@ -11,2 +20,166 @@ * | ||
* both synchronous and asynchronous loaders. | ||
*/var Registry=/*#__PURE__*/function(){function a(a){void 0===a&&(a={}),_defineProperty(this,"name",void 0),_defineProperty(this,"overwritePolicy",void 0),_defineProperty(this,"items",void 0),_defineProperty(this,"promises",void 0);var b=a,c=b.name,d=void 0===c?"":c,e=b.overwritePolicy,f=void 0===e?_types.OverwritePolicy.ALLOW:e;this.name=d,this.overwritePolicy=f,this.items={},this.promises={}}var b=a.prototype;return b.clear=function clear(){return this.items={},this.promises={},this},b.has=function has(a){var b=this.items[a];return null!==b&&void 0!==b},b.registerValue=function registerValue(a,b){var c=this.items[a],d=this.has(a)&&("value"in c&&c.value!==b||"loader"in c);if(d)if(this.overwritePolicy===_types.OverwritePolicy.WARN)console.warn("Item with key \""+a+"\" already exists. You are assigning a new value.");else if(this.overwritePolicy===_types.OverwritePolicy.PROHIBIT)throw new Error("Item with key \""+a+"\" already exists. Cannot overwrite.");return(!c||d)&&(this.items[a]={value:b},delete this.promises[a]),this},b.registerLoader=function registerLoader(a,b){var c=this.items[a],d=this.has(a)&&("loader"in c&&c.loader!==b||"value"in c);if(d)if(this.overwritePolicy===_types.OverwritePolicy.WARN)console.warn("Item with key \""+a+"\" already exists. You are assigning a new value.");else if(this.overwritePolicy===_types.OverwritePolicy.PROHIBIT)throw new Error("Item with key \""+a+"\" already exists. Cannot overwrite.");return(!c||d)&&(this.items[a]={loader:b},delete this.promises[a]),this},b.get=function get(a){var b=this.items[a];return void 0===b?void 0:"loader"in b?b.loader&&b.loader():b.value},b.getAsPromise=function getAsPromise(a){var b=this.promises[a];if(b)return b;var c=this.get(a);if(void 0!==c){var d=Promise.resolve(c);return this.promises[a]=d,d}return Promise.reject(new Error("Item with key \""+a+"\" is not registered."))},b.getMap=function getMap(){var a=this;return this.keys().reduce(function(b,c){var d=b;return d[c]=a.get(c),d},{})},b.getMapAsPromise=function getMapAsPromise(){var a=this,b=this.keys();return Promise.all(b.map(function(b){return a.getAsPromise(b)})).then(function(a){return a.reduce(function(a,c,d){var e=a;return e[b[d]]=c,e},{})})},b.keys=function keys(){return Object.keys(this.items)},b.values=function values(){var a=this;return this.keys().map(function(b){return a.get(b)})},b.valuesAsPromise=function valuesAsPromise(){var a=this;return Promise.all(this.keys().map(function(b){return a.getAsPromise(b)}))},b.entries=function entries(){var a=this;return this.keys().map(function(b){return{key:b,value:a.get(b)}})},b.entriesAsPromise=function entriesAsPromise(){var a=this,b=this.keys();return Promise.all(b.map(function(b){return a.getAsPromise(b)})).then(function(a){return a.map(function(a,c){return{key:b[c],value:a}})})},b.remove=function remove(a){return delete this.items[a],delete this.promises[a],this},a}();exports.default=Registry; | ||
*/ | ||
class Registry { | ||
constructor(config) { | ||
if (config === void 0) { | ||
config = {}; | ||
} | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "overwritePolicy", void 0); | ||
_defineProperty(this, "items", void 0); | ||
_defineProperty(this, "promises", void 0); | ||
const { | ||
name = '', | ||
overwritePolicy = _types.OverwritePolicy.ALLOW | ||
} = config; | ||
this.name = name; | ||
this.overwritePolicy = overwritePolicy; | ||
this.items = {}; | ||
this.promises = {}; | ||
} | ||
clear() { | ||
this.items = {}; | ||
this.promises = {}; | ||
return this; | ||
} | ||
has(key) { | ||
const item = this.items[key]; | ||
return item !== null && item !== undefined; | ||
} | ||
registerValue(key, value) { | ||
const item = this.items[key]; | ||
const willOverwrite = this.has(key) && ('value' in item && item.value !== value || 'loader' in item); | ||
if (willOverwrite) { | ||
if (this.overwritePolicy === _types.OverwritePolicy.WARN) { | ||
console.warn("Item with key \"" + key + "\" already exists. You are assigning a new value."); | ||
} else if (this.overwritePolicy === _types.OverwritePolicy.PROHIBIT) { | ||
throw new Error("Item with key \"" + key + "\" already exists. Cannot overwrite."); | ||
} | ||
} | ||
if (!item || willOverwrite) { | ||
this.items[key] = { | ||
value | ||
}; | ||
delete this.promises[key]; | ||
} | ||
return this; | ||
} | ||
registerLoader(key, loader) { | ||
const item = this.items[key]; | ||
const willOverwrite = this.has(key) && ('loader' in item && item.loader !== loader || 'value' in item); | ||
if (willOverwrite) { | ||
if (this.overwritePolicy === _types.OverwritePolicy.WARN) { | ||
console.warn("Item with key \"" + key + "\" already exists. You are assigning a new value."); | ||
} else if (this.overwritePolicy === _types.OverwritePolicy.PROHIBIT) { | ||
throw new Error("Item with key \"" + key + "\" already exists. Cannot overwrite."); | ||
} | ||
} | ||
if (!item || willOverwrite) { | ||
this.items[key] = { | ||
loader | ||
}; | ||
delete this.promises[key]; | ||
} | ||
return this; | ||
} | ||
get(key) { | ||
const item = this.items[key]; | ||
if (item !== undefined) { | ||
if ('loader' in item) { | ||
return item.loader && item.loader(); | ||
} | ||
return item.value; | ||
} | ||
return undefined; | ||
} | ||
getAsPromise(key) { | ||
const promise = this.promises[key]; | ||
if (typeof promise !== 'undefined') { | ||
return promise; | ||
} | ||
const item = this.get(key); | ||
if (item !== undefined) { | ||
const newPromise = Promise.resolve(item); | ||
this.promises[key] = newPromise; | ||
return newPromise; | ||
} | ||
return Promise.reject(new Error("Item with key \"" + key + "\" is not registered.")); | ||
} | ||
getMap() { | ||
return this.keys().reduce((prev, key) => { | ||
const map = prev; | ||
map[key] = this.get(key); | ||
return map; | ||
}, {}); | ||
} | ||
getMapAsPromise() { | ||
const keys = this.keys(); | ||
return Promise.all(keys.map(key => this.getAsPromise(key))).then(values => values.reduce((prev, value, i) => { | ||
const map = prev; | ||
map[keys[i]] = value; | ||
return map; | ||
}, {})); | ||
} | ||
keys() { | ||
return Object.keys(this.items); | ||
} | ||
values() { | ||
return this.keys().map(key => this.get(key)); | ||
} | ||
valuesAsPromise() { | ||
return Promise.all(this.keys().map(key => this.getAsPromise(key))); | ||
} | ||
entries() { | ||
return this.keys().map(key => ({ | ||
key, | ||
value: this.get(key) | ||
})); | ||
} | ||
entriesAsPromise() { | ||
const keys = this.keys(); | ||
return Promise.all(keys.map(key => this.getAsPromise(key))).then(values => values.map((value, i) => ({ | ||
key: keys[i], | ||
value | ||
}))); | ||
} | ||
remove(key) { | ||
delete this.items[key]; | ||
delete this.promises[key]; | ||
return this; | ||
} | ||
} | ||
exports.default = Registry; |
@@ -20,1 +20,2 @@ import Registry, { RegistryConfig } from './Registry'; | ||
export {}; | ||
//# sourceMappingURL=RegistryWithDefaultKey.d.ts.map |
@@ -1,1 +0,82 @@ | ||
"use strict";var _Registry2=_interopRequireDefault(require("./Registry"));exports.__esModule=!0,exports.default=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _inheritsLoose(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var RegistryWithDefaultKey=/*#__PURE__*/function(a){function b(b){var c;void 0===b&&(b={}),c=a.call(this,b)||this,_defineProperty(_assertThisInitialized(c),"initialDefaultKey",void 0),_defineProperty(_assertThisInitialized(c),"defaultKey",void 0),_defineProperty(_assertThisInitialized(c),"setFirstItemAsDefault",void 0);var d=b,e=d.initialDefaultKey,f=void 0===e?void 0:e,g=d.setFirstItemAsDefault;return c.initialDefaultKey=f,c.defaultKey=f,c.setFirstItemAsDefault=void 0!==g&&g,c}_inheritsLoose(b,a);var c=b.prototype;return c.clear=function clear(){return a.prototype.clear.call(this),this.defaultKey=this.initialDefaultKey,this},c.get=function get(b){var c=b||this.defaultKey;return c?a.prototype.get.call(this,c):void 0},c.registerValue=function registerValue(b,c){return a.prototype.registerValue.call(this,b,c),this.setFirstItemAsDefault&&!this.defaultKey&&(this.defaultKey=b),this},c.registerLoader=function registerLoader(b,c){return a.prototype.registerLoader.call(this,b,c),this.setFirstItemAsDefault&&!this.defaultKey&&(this.defaultKey=b),this},c.getDefaultKey=function getDefaultKey(){return this.defaultKey},c.setDefaultKey=function setDefaultKey(a){return this.defaultKey=a,this},c.clearDefaultKey=function clearDefaultKey(){return this.defaultKey=void 0,this},b}(_Registry2.default);exports.default=RegistryWithDefaultKey; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = void 0; | ||
var _Registry = _interopRequireDefault(require("./Registry")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
class RegistryWithDefaultKey extends _Registry.default { | ||
constructor(config) { | ||
if (config === void 0) { | ||
config = {}; | ||
} | ||
super(config); | ||
_defineProperty(this, "initialDefaultKey", void 0); | ||
_defineProperty(this, "defaultKey", void 0); | ||
_defineProperty(this, "setFirstItemAsDefault", void 0); | ||
const { | ||
initialDefaultKey = undefined, | ||
setFirstItemAsDefault = false | ||
} = config; | ||
this.initialDefaultKey = initialDefaultKey; | ||
this.defaultKey = initialDefaultKey; | ||
this.setFirstItemAsDefault = setFirstItemAsDefault; | ||
} | ||
clear() { | ||
super.clear(); | ||
this.defaultKey = this.initialDefaultKey; | ||
return this; | ||
} | ||
get(key) { | ||
const targetKey = key != null ? key : this.defaultKey; | ||
return targetKey ? super.get(targetKey) : undefined; | ||
} | ||
registerValue(key, value) { | ||
super.registerValue(key, value); // If there is no default, set as default | ||
if (this.setFirstItemAsDefault && !this.defaultKey) { | ||
this.defaultKey = key; | ||
} | ||
return this; | ||
} | ||
registerLoader(key, loader) { | ||
super.registerLoader(key, loader); // If there is no default, set as default | ||
if (this.setFirstItemAsDefault && !this.defaultKey) { | ||
this.defaultKey = key; | ||
} | ||
return this; | ||
} | ||
getDefaultKey() { | ||
return this.defaultKey; | ||
} | ||
setDefaultKey(key) { | ||
this.defaultKey = key; | ||
return this; | ||
} | ||
clearDefaultKey() { | ||
this.defaultKey = undefined; | ||
return this; | ||
} | ||
} | ||
exports.default = RegistryWithDefaultKey; |
@@ -6,1 +6,2 @@ export declare enum OverwritePolicy { | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,1 +0,14 @@ | ||
"use strict";exports.__esModule=!0,exports.OverwritePolicy=void 0;/* eslint-disable import/prefer-default-export, no-unused-vars */var OverwritePolicy;exports.OverwritePolicy=OverwritePolicy,function(a){a.ALLOW="ALLOW",a.PROHIBIT="PROHIBIT",a.WARN="WARN"}(OverwritePolicy||(exports.OverwritePolicy=OverwritePolicy={})); | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.OverwritePolicy = void 0; | ||
/* eslint-disable import/prefer-default-export */ | ||
let OverwritePolicy; | ||
exports.OverwritePolicy = OverwritePolicy; | ||
(function (OverwritePolicy) { | ||
OverwritePolicy["ALLOW"] = "ALLOW"; | ||
OverwritePolicy["PROHIBIT"] = "PROHIBIT"; | ||
OverwritePolicy["WARN"] = "WARN"; | ||
})(OverwritePolicy || (exports.OverwritePolicy = OverwritePolicy = {})); |
export default function convertKeysToCamelCase(object: any): any; | ||
//# sourceMappingURL=convertKeysToCamelCase.d.ts.map |
@@ -1,1 +0,24 @@ | ||
"use strict";exports.__esModule=!0,exports.default=convertKeysToCamelCase;var _camelCase=_interopRequireDefault(require("lodash/camelCase")),_isPlainObject=_interopRequireDefault(require("lodash/isPlainObject")),_mapKeys=_interopRequireDefault(require("lodash/mapKeys"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function convertKeysToCamelCase(a){if(null===a||a===void 0)return a;if((0,_isPlainObject.default)(a))return(0,_mapKeys.default)(a,function(a,b){return(0,_camelCase.default)(b)});throw new Error("Cannot convert input that is not a plain object: "+a)} | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = convertKeysToCamelCase; | ||
var _camelCase = _interopRequireDefault(require("lodash/camelCase")); | ||
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject")); | ||
var _mapKeys = _interopRequireDefault(require("lodash/mapKeys")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function convertKeysToCamelCase(object) { | ||
if (object === null || object === undefined) { | ||
return object; | ||
} | ||
if ((0, _isPlainObject.default)(object)) { | ||
return (0, _mapKeys.default)(object, (_, k) => (0, _camelCase.default)(k)); | ||
} | ||
throw new Error("Cannot convert input that is not a plain object: " + object); | ||
} |
export default function isDefined(x: any): boolean; | ||
//# sourceMappingURL=isDefined.d.ts.map |
@@ -1,1 +0,8 @@ | ||
"use strict";exports.__esModule=!0,exports.default=isDefined;function isDefined(a){return null!==a&&a!==void 0} | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = isDefined; | ||
function isDefined(x) { | ||
return x !== null && x !== undefined; | ||
} |
export default function isRequired(field: string): never; | ||
//# sourceMappingURL=isRequired.d.ts.map |
@@ -1,1 +0,8 @@ | ||
"use strict";exports.__esModule=!0,exports.default=isRequired;function isRequired(a){throw new Error(a+" is required.")} | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = isRequired; | ||
function isRequired(field) { | ||
throw new Error(field + " is required."); | ||
} |
@@ -6,1 +6,2 @@ interface ClassInterface<T> { | ||
export {}; | ||
//# sourceMappingURL=makeSingleton.d.ts.map |
@@ -1,1 +0,19 @@ | ||
"use strict";exports.__esModule=!0,exports.default=makeSingleton;function isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(a){return!1}}function _construct(){return _construct=isNativeReflectConstruct()?Reflect.construct:function(b,c,d){var e=[null];e.push.apply(e,c);var a=Function.bind.apply(b,e),f=new a;return d&&_setPrototypeOf(f,d.prototype),f},_construct.apply(null,arguments)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function makeSingleton(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];var e;return function(){return e||(e=_construct(a,c)),e}} | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = makeSingleton; | ||
function makeSingleton(BaseClass) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
let singleton; | ||
return function getInstance() { | ||
if (!singleton) { | ||
singleton = new BaseClass(...args); | ||
} | ||
return singleton; | ||
}; | ||
} |
@@ -7,1 +7,2 @@ /** setTimeout that returns a promise */ | ||
delay?: number): Promise<unknown>; | ||
//# sourceMappingURL=promiseTimeout.d.ts.map |
@@ -1,1 +0,17 @@ | ||
"use strict";exports.__esModule=!0,exports.default=promiseTimeout;/** setTimeout that returns a promise */function promiseTimeout(/** A function to be executed after the timer expires. */a,/** The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. */b){return new Promise(function(c){setTimeout(function(){c(a())},b)})} | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.default = promiseTimeout; | ||
/** setTimeout that returns a promise */ | ||
function promiseTimeout( | ||
/** A function to be executed after the timer expires. */ | ||
func, | ||
/** The time, in milliseconds (thousandths of a second), the timer should wait before the specified function or code is executed. If this parameter is omitted, a value of 0 is used, meaning execute "immediately", or more accurately, as soon as possible. */ | ||
delay) { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(func()); | ||
}, delay); | ||
}); | ||
} |
{ | ||
"name": "@superset-ui/core", | ||
"version": "0.12.5", | ||
"version": "0.12.8", | ||
"description": "Superset UI core", | ||
@@ -32,6 +32,6 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@types/lodash": "4.14.149", | ||
"@types/lodash": "^4.14.149", | ||
"lodash": "^4.17.11" | ||
}, | ||
"gitHead": "5b6f4a5bd2cb70089d429c9f635f1d0fbc40973f" | ||
"gitHead": "9bb5c471e0e3d05da38929feb00ade7d0ecdc474" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
47100
51
836
1
3309
1
+ Added@types/lodash@4.17.13(transitive)
- Removed@types/lodash@4.14.149(transitive)
Updated@types/lodash@^4.14.149