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

@webiny/plugins

Package Overview
Dependencies
Maintainers
1
Versions
527
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webiny/plugins - npm Package Compare versions

Comparing version 4.11.0 to 4.12.0-beta.0

4

package.json
{
"name": "@webiny/plugins",
"version": "4.11.0",
"version": "4.12.0-beta.0",
"main": "index.js",

@@ -32,3 +32,3 @@ "repository": {

},
"gitHead": "0c48579d37956130d7672d13747250edb22021b3"
"gitHead": "335cbb074d745f73795e4a5d507f9687aafe6f82"
}
import { Plugin } from "./types";
export declare class PluginsContainer {
plugins: Record<string, Plugin>;
constructor(plugins?: any);
constructor(...args: any[]);
byName<T extends Plugin = Plugin>(name: string): T;
byType<T extends Plugin>(type?: string): T[];
register(...plugins: any): void;
register(...args: any): void;
unregister(name: string): void;
}

@@ -14,3 +14,15 @@ "use strict";

const assign = (plugins, target) => {
const isOptionsObject = item => item && !Array.isArray(item) && !item.type && !item.name;
const normalizeArgs = args => {
let options = {}; // Check if last item in the plugins array is actually an options object.
if (isOptionsObject(args[args.length - 1])) {
[options] = args.splice(-1, 1);
}
return [args, options];
};
const assign = (plugins, options, target) => {
for (let i = 0; i < plugins.length; i++) {

@@ -20,3 +32,3 @@ const plugin = plugins[i];

if (Array.isArray(plugin)) {
assign(plugin, target);
assign(plugin, options, target);
continue;

@@ -29,6 +41,9 @@ }

plugin.name = name = (0, _uniqid.default)(plugin.type + "-");
} // If skip existing was set to true, and a plugin with the same name was already registered, skip registration.
if (!options.skipExisting || !target[name]) {
target[name] = plugin;
plugin.init && plugin.init();
}
target[name] = plugin;
plugin.init && plugin.init();
}

@@ -38,5 +53,5 @@ };

class PluginsContainer {
constructor(plugins = []) {
constructor(...args) {
(0, _defineProperty2.default)(this, "plugins", {});
assign(plugins, this.plugins);
this.register(...args);
}

@@ -56,4 +71,5 @@

register(...plugins) {
assign(plugins, this.plugins);
register(...args) {
const [plugins, options] = normalizeArgs(args);
assign(plugins, options, this.plugins);
}

@@ -60,0 +76,0 @@

@@ -8,1 +8,2 @@ export { PluginsContainer } from "./PluginsContainer";

};
export declare type PluginCollection = (Plugin | PluginCollection)[];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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