Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@easepick/base-plugin

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@easepick/base-plugin - npm Package Compare versions

Comparing version 1.1.0 to 1.1.2

87

dist/index.esm.js

@@ -1,1 +0,86 @@

class e{picker;options;priority=0;dependencies=[];attach(e){const t=this.getName(),s={...this.options};this.options={...this.options,...e.options[t]||{}};for(const i of Object.keys(s))if(null!==s[i]&&"object"==typeof s[i]&&Object.keys(s[i]).length){const n={...e.options[t][i]};null!==n&&"object"==typeof n&&Object.keys(n).length&&Object.keys(n).every((e=>Object.keys(s[i]).includes(e)))&&(this.options[i]={...s[i],...n})}if(this.picker=e,this.dependenciesNotFound()){const e=this.dependencies.filter((e=>!this.pluginsAsStringArray().includes(e)));return void console.warn(`${this.getName()}: required dependencies (${e.join(", ")}).`)}const i=this.camelCaseToKebab(this.getName());this.picker.ui.container.classList.add(i),this.onAttach()}detach(){const e=this.camelCaseToKebab(this.getName());this.picker.ui.container.classList.remove(e),"function"==typeof this.onDetach&&this.onDetach()}dependenciesNotFound(){return this.dependencies.length&&!this.dependencies.every((e=>this.pluginsAsStringArray().includes(e)))}pluginsAsStringArray(){return this.picker.options.plugins.map((e=>"function"==typeof e?(new e).getName():e))}camelCaseToKebab(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}}export{e as BasePlugin};
class BasePlugin {
picker;
options;
priority = 0;
dependencies = [];
/**
* - Called automatically via PluginManager.initialize() or PluginManager.addInstance() -
* Add plugin to the picker
*
* @param picker
*/
attach(picker) {
const pluginName = this['getName']();
const optionsOriginal = { ...this.options };
this.options = {
...this.options,
...(picker.options[pluginName] || {}),
};
// copy deep object options
for (const objName of Object.keys(optionsOriginal)) {
if (optionsOriginal[objName] !== null
&& typeof optionsOriginal[objName] === 'object'
&& Object.keys(optionsOriginal[objName]).length
&& pluginName in picker.options
&& objName in picker.options[pluginName]) {
const optionValue = { ...picker.options[pluginName][objName] };
if (optionValue !== null
&& typeof optionValue === 'object'
&& Object.keys(optionValue).length
&& Object.keys(optionValue).every(opt => Object.keys(optionsOriginal[objName]).includes(opt))) {
this.options[objName] = { ...optionsOriginal[objName], ...optionValue };
}
}
}
this.picker = picker;
if (this.dependenciesNotFound()) {
const deps = this.dependencies.filter(x => !this.pluginsAsStringArray().includes(x));
console.warn(`${this['getName']()}: required dependencies (${deps.join(', ')}).`);
return;
}
const pluginClass = this.camelCaseToKebab(this['getName']());
this.picker.ui.container.classList.add(pluginClass);
this['onAttach']();
}
/**
* - Called automatically via PluginManager.removeInstance() -
* Remove plugin from the picker
*/
detach() {
const pluginClass = this.camelCaseToKebab(this['getName']());
this.picker.ui.container.classList.remove(pluginClass);
if (typeof this['onDetach'] === 'function') {
this['onDetach']();
}
}
/**
* Check dependencies for plugin
*
* @returns Boolean
*/
dependenciesNotFound() {
return this.dependencies.length
&& !this.dependencies.every(v => this.pluginsAsStringArray().includes(v));
}
/**
* Return plugins list as string array
*
* @returns []
*/
pluginsAsStringArray() {
return this.picker.options.plugins
.map(x => typeof x === 'function' ? (new x).getName() : x);
}
/**
* Return camelCase in kebab-case
* Eg.: `userName` -> `user-name`
*
* @param str
* @returns String
*/
camelCaseToKebab(str) {
return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase();
}
}
export { BasePlugin };

@@ -10,2 +10,97 @@ /**

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).easepick=e.easepick||{})}(this,(function(e){"use strict";e.BasePlugin=class{picker;options;priority=0;dependencies=[];attach(e){const t=this.getName(),i={...this.options};this.options={...this.options,...e.options[t]||{}};for(const s of Object.keys(i))if(null!==i[s]&&"object"==typeof i[s]&&Object.keys(i[s]).length){const n={...e.options[t][s]};null!==n&&"object"==typeof n&&Object.keys(n).length&&Object.keys(n).every((e=>Object.keys(i[s]).includes(e)))&&(this.options[s]={...i[s],...n})}if(this.picker=e,this.dependenciesNotFound()){const e=this.dependencies.filter((e=>!this.pluginsAsStringArray().includes(e)));return void console.warn(`${this.getName()}: required dependencies (${e.join(", ")}).`)}const s=this.camelCaseToKebab(this.getName());this.picker.ui.container.classList.add(s),this.onAttach()}detach(){const e=this.camelCaseToKebab(this.getName());this.picker.ui.container.classList.remove(e),"function"==typeof this.onDetach&&this.onDetach()}dependenciesNotFound(){return this.dependencies.length&&!this.dependencies.every((e=>this.pluginsAsStringArray().includes(e)))}pluginsAsStringArray(){return this.picker.options.plugins.map((e=>"function"==typeof e?(new e).getName():e))}camelCaseToKebab(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}},Object.defineProperty(e,"__esModule",{value:!0})}));
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.easepick = global.easepick || {}));
})(this, (function (exports) { 'use strict';
class BasePlugin {
picker;
options;
priority = 0;
dependencies = [];
/**
* - Called automatically via PluginManager.initialize() or PluginManager.addInstance() -
* Add plugin to the picker
*
* @param picker
*/
attach(picker) {
const pluginName = this['getName']();
const optionsOriginal = { ...this.options };
this.options = {
...this.options,
...(picker.options[pluginName] || {}),
};
// copy deep object options
for (const objName of Object.keys(optionsOriginal)) {
if (optionsOriginal[objName] !== null
&& typeof optionsOriginal[objName] === 'object'
&& Object.keys(optionsOriginal[objName]).length
&& pluginName in picker.options
&& objName in picker.options[pluginName]) {
const optionValue = { ...picker.options[pluginName][objName] };
if (optionValue !== null
&& typeof optionValue === 'object'
&& Object.keys(optionValue).length
&& Object.keys(optionValue).every(opt => Object.keys(optionsOriginal[objName]).includes(opt))) {
this.options[objName] = { ...optionsOriginal[objName], ...optionValue };
}
}
}
this.picker = picker;
if (this.dependenciesNotFound()) {
const deps = this.dependencies.filter(x => !this.pluginsAsStringArray().includes(x));
console.warn(`${this['getName']()}: required dependencies (${deps.join(', ')}).`);
return;
}
const pluginClass = this.camelCaseToKebab(this['getName']());
this.picker.ui.container.classList.add(pluginClass);
this['onAttach']();
}
/**
* - Called automatically via PluginManager.removeInstance() -
* Remove plugin from the picker
*/
detach() {
const pluginClass = this.camelCaseToKebab(this['getName']());
this.picker.ui.container.classList.remove(pluginClass);
if (typeof this['onDetach'] === 'function') {
this['onDetach']();
}
}
/**
* Check dependencies for plugin
*
* @returns Boolean
*/
dependenciesNotFound() {
return this.dependencies.length
&& !this.dependencies.every(v => this.pluginsAsStringArray().includes(v));
}
/**
* Return plugins list as string array
*
* @returns []
*/
pluginsAsStringArray() {
return this.picker.options.plugins
.map(x => typeof x === 'function' ? (new x).getName() : x);
}
/**
* Return camelCase in kebab-case
* Eg.: `userName` -> `user-name`
*
* @param str
* @returns String
*/
camelCaseToKebab(str) {
return str.replace(/([a-zA-Z])(?=[A-Z])/g, '$1-').toLowerCase();
}
}
exports.BasePlugin = BasePlugin;
Object.defineProperty(exports, '__esModule', { value: true });
}));

2

package.json
{
"name": "@easepick/base-plugin",
"description": "Base plugin for easepick.",
"version": "1.1.0",
"version": "1.1.2",
"main": "dist/index.umd.js",

@@ -6,0 +6,0 @@ "module": "dist/index.esm.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc