@webiny/plugins 0.0.0-ee-vpcs.549378cf03
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/Plugin.d.ts +6 -0
- package/Plugin.js +28 -0
- package/Plugin.js.map +1 -0
- package/PluginsContainer.d.ts +14 -0
- package/PluginsContainer.js +121 -0
- package/PluginsContainer.js.map +1 -0
- package/README.md +74 -0
- package/index.d.ts +4 -0
- package/index.js +25 -0
- package/index.js.map +1 -0
- package/package.json +38 -0
- package/types.d.ts +8 -0
- package/types.js +13 -0
- package/types.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/Plugin.d.ts
ADDED
package/Plugin.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Plugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
class Plugin {
|
|
13
|
+
constructor() {
|
|
14
|
+
(0, _defineProperty2.default)(this, "name", void 0);
|
|
15
|
+
|
|
16
|
+
if (!this.constructor.type) {
|
|
17
|
+
throw Error(`Missing "type" definition in "${this.constructor.name}"!`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get type() {
|
|
22
|
+
return this.constructor.type;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.Plugin = Plugin;
|
|
28
|
+
(0, _defineProperty2.default)(Plugin, "type", void 0);
|
package/Plugin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Plugin","constructor","type","Error","name"],"sources":["Plugin.ts"],"sourcesContent":["export abstract class Plugin {\n public static readonly type: string;\n public name?: string;\n\n constructor() {\n if (!(this.constructor as typeof Plugin).type) {\n throw Error(`Missing \"type\" definition in \"${this.constructor.name}\"!`);\n }\n }\n\n get type() {\n return (this.constructor as typeof Plugin).type;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAO,MAAeA,MAAf,CAAsB;EAIzBC,WAAW,GAAG;IAAA;;IACV,IAAI,CAAE,KAAKA,WAAN,CAAoCC,IAAzC,EAA+C;MAC3C,MAAMC,KAAK,CAAE,iCAAgC,KAAKF,WAAL,CAAiBG,IAAK,IAAxD,CAAX;IACH;EACJ;;EAEO,IAAJF,IAAI,GAAG;IACP,OAAQ,KAAKD,WAAN,CAAoCC,IAA3C;EACH;;AAZwB;;;8BAAPF,M"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin, PluginCollection } from "./types";
|
|
2
|
+
export declare class PluginsContainer {
|
|
3
|
+
private plugins;
|
|
4
|
+
private _byTypeCache;
|
|
5
|
+
constructor(...args: PluginCollection);
|
|
6
|
+
byName<T extends Plugin>(name: T["name"]): T | null;
|
|
7
|
+
byType<T extends Plugin>(type: T["type"]): T[];
|
|
8
|
+
atLeastOneByType<T extends Plugin>(type: T["type"]): T[];
|
|
9
|
+
oneByType<T extends Plugin>(type: T["type"]): T;
|
|
10
|
+
all<T extends Plugin>(): T[];
|
|
11
|
+
register(...args: any): void;
|
|
12
|
+
unregister(name: string): void;
|
|
13
|
+
private findByType;
|
|
14
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.PluginsContainer = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _uniqid = _interopRequireDefault(require("uniqid"));
|
|
13
|
+
|
|
14
|
+
const isOptionsObject = item => item && !Array.isArray(item) && !item.type && !item.name;
|
|
15
|
+
|
|
16
|
+
const normalizeArgs = args => {
|
|
17
|
+
let options = {}; // Check if last item in the plugins array is actually an options object.
|
|
18
|
+
|
|
19
|
+
if (isOptionsObject(args[args.length - 1])) {
|
|
20
|
+
[options] = args.splice(-1, 1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return [args, options];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const assign = (plugins, options, target) => {
|
|
27
|
+
for (let i = 0; i < plugins.length; i++) {
|
|
28
|
+
const plugin = plugins[i];
|
|
29
|
+
|
|
30
|
+
if (Array.isArray(plugin)) {
|
|
31
|
+
assign(plugin, options, target);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let name = plugin._name || plugin.name;
|
|
36
|
+
|
|
37
|
+
if (!name) {
|
|
38
|
+
plugin.name = name = (0, _uniqid.default)(plugin.type + "-");
|
|
39
|
+
} // If skip existing was set to true, and a plugin with the same name was already registered, skip registration.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if (!options.skipExisting || !target[name]) {
|
|
43
|
+
target[name] = plugin;
|
|
44
|
+
plugin.init && plugin.init();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
class PluginsContainer {
|
|
50
|
+
constructor(...args) {
|
|
51
|
+
(0, _defineProperty2.default)(this, "plugins", {});
|
|
52
|
+
(0, _defineProperty2.default)(this, "_byTypeCache", {});
|
|
53
|
+
this.register(...args);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
byName(name) {
|
|
57
|
+
if (!name) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* We can safely cast name as string, we know it is so.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
return this.plugins[name];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
byType(type) {
|
|
69
|
+
if (this._byTypeCache[type]) {
|
|
70
|
+
return Array.from(this._byTypeCache[type]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const plugins = this.findByType(type);
|
|
74
|
+
this._byTypeCache[type] = plugins;
|
|
75
|
+
return Array.from(plugins);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
atLeastOneByType(type) {
|
|
79
|
+
const list = this.byType(type);
|
|
80
|
+
|
|
81
|
+
if (list.length === 0) {
|
|
82
|
+
throw new Error(`There are no plugins by type "${type}".`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return list;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
oneByType(type) {
|
|
89
|
+
const list = this.atLeastOneByType(type);
|
|
90
|
+
|
|
91
|
+
if (list.length > 1) {
|
|
92
|
+
throw new Error(`There is a requirement for plugin of type "${type}" to be only one registered.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return list[0];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
all() {
|
|
99
|
+
return Object.values(this.plugins);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
register(...args) {
|
|
103
|
+
// reset the cache when adding new plugins
|
|
104
|
+
this._byTypeCache = {};
|
|
105
|
+
const [plugins, options] = normalizeArgs(args);
|
|
106
|
+
assign(plugins, options, this.plugins);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
unregister(name) {
|
|
110
|
+
// reset the cache when removing a plugin
|
|
111
|
+
this._byTypeCache = {};
|
|
112
|
+
delete this.plugins[name];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
findByType(type) {
|
|
116
|
+
return Object.values(this.plugins).filter(pl => pl.type === type);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.PluginsContainer = PluginsContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isOptionsObject","item","Array","isArray","type","name","normalizeArgs","args","options","length","splice","assign","plugins","target","i","plugin","_name","uniqid","skipExisting","init","PluginsContainer","constructor","register","byName","byType","_byTypeCache","from","findByType","atLeastOneByType","list","Error","oneByType","all","Object","values","unregister","filter","pl"],"sources":["PluginsContainer.ts"],"sourcesContent":["import { Plugin, PluginCollection } from \"./types\";\nimport uniqid from \"uniqid\";\n\nconst isOptionsObject = (item?: any) => item && !Array.isArray(item) && !item.type && !item.name;\nconst normalizeArgs = (args: any[]) => {\n let options = {};\n\n // Check if last item in the plugins array is actually an options object.\n if (isOptionsObject(args[args.length - 1])) {\n [options] = args.splice(-1, 1);\n }\n\n return [args, options];\n};\n\nconst assign = (plugins: any, options: any, target: Record<string, any>): void => {\n for (let i = 0; i < plugins.length; i++) {\n const plugin = plugins[i];\n if (Array.isArray(plugin)) {\n assign(plugin, options, target);\n continue;\n }\n\n let name = plugin._name || plugin.name;\n if (!name) {\n plugin.name = name = uniqid(plugin.type + \"-\");\n }\n\n // If skip existing was set to true, and a plugin with the same name was already registered, skip registration.\n if (!options.skipExisting || !target[name]) {\n target[name] = plugin;\n plugin.init && plugin.init();\n }\n }\n};\n\nexport class PluginsContainer {\n private plugins: Record<string, Plugin> = {};\n private _byTypeCache: Record<string, Plugin[]> = {};\n\n constructor(...args: PluginCollection) {\n this.register(...args);\n }\n\n public byName<T extends Plugin>(name: T[\"name\"]): T | null {\n if (!name) {\n return null;\n }\n /**\n * We can safely cast name as string, we know it is so.\n */\n return this.plugins[name as string] as T;\n }\n\n public byType<T extends Plugin>(type: T[\"type\"]): T[] {\n if (this._byTypeCache[type]) {\n return Array.from(this._byTypeCache[type]) as T[];\n }\n const plugins = this.findByType<T>(type);\n this._byTypeCache[type] = plugins;\n return Array.from(plugins);\n }\n\n public atLeastOneByType<T extends Plugin>(type: T[\"type\"]): T[] {\n const list = this.byType<T>(type);\n if (list.length === 0) {\n throw new Error(`There are no plugins by type \"${type}\".`);\n }\n return list;\n }\n\n public oneByType<T extends Plugin>(type: T[\"type\"]): T {\n const list = this.atLeastOneByType<T>(type);\n if (list.length > 1) {\n throw new Error(\n `There is a requirement for plugin of type \"${type}\" to be only one registered.`\n );\n }\n return list[0];\n }\n\n public all<T extends Plugin>(): T[] {\n return Object.values(this.plugins) as T[];\n }\n\n public register(...args: any): void {\n // reset the cache when adding new plugins\n this._byTypeCache = {};\n const [plugins, options] = normalizeArgs(args);\n assign(plugins, options, this.plugins);\n }\n\n public unregister(name: string): void {\n // reset the cache when removing a plugin\n this._byTypeCache = {};\n delete this.plugins[name];\n }\n\n private findByType<T extends Plugin>(type: T[\"type\"]): T[] {\n return (Object.values(this.plugins) as T[]).filter(pl => pl.type === type) as T[];\n }\n}\n"],"mappings":"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"}
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @webiny/plugins
|
|
2
|
+
[](https://www.npmjs.com/package/@webiny/plugins)
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/plugins)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
A simple registry that stores all plugins in a shared object.
|
|
8
|
+
The only requirement for a plugin is to have a `name` and a `type` properties.
|
|
9
|
+
The rest is entirely up to you.
|
|
10
|
+
|
|
11
|
+
There is nothing spectacular going on under the hood, just a simple
|
|
12
|
+
object for storing references and a few utility functions.
|
|
13
|
+
|
|
14
|
+
For more information, please visit [the official docs](https://docs.webiny.com/docs/developer-tutorials/plugins-crash-course).
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
```
|
|
18
|
+
npm install --save @webiny/plugins
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or if you prefer yarn:
|
|
22
|
+
```
|
|
23
|
+
yarn add @webiny/plugins
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Adding a plugin
|
|
29
|
+
```
|
|
30
|
+
import { plugins } from "@webiny/plugins";
|
|
31
|
+
|
|
32
|
+
// Add a plugin
|
|
33
|
+
plugins.register({
|
|
34
|
+
name: "my-plugin",
|
|
35
|
+
type: "say-hi",
|
|
36
|
+
salute: () => "Hi!"
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
plugins.register({
|
|
40
|
+
name: "my-second-plugin",
|
|
41
|
+
type: "say-hi",
|
|
42
|
+
salute: () => "Yo!"
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Getting plugins by type
|
|
47
|
+
```
|
|
48
|
+
// anywhere in your app
|
|
49
|
+
import { plugins } from "@webiny/plugins";
|
|
50
|
+
|
|
51
|
+
const pluginList = plugins.byType("say-hi");
|
|
52
|
+
pluginList.forEach(plugin => {
|
|
53
|
+
// Call "salute" function
|
|
54
|
+
plugin.salute();
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Getting a single plugin by name
|
|
59
|
+
```
|
|
60
|
+
// anywhere in your app
|
|
61
|
+
import { plugins } from "@webiny/plugins";
|
|
62
|
+
|
|
63
|
+
const plugin = plugins.byName("my-plugin");
|
|
64
|
+
// Call "salute" function
|
|
65
|
+
plugin.salute();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Removing a plugin
|
|
69
|
+
```
|
|
70
|
+
// anywhere in your app
|
|
71
|
+
import { plugins } from "@webiny/plugins";
|
|
72
|
+
|
|
73
|
+
plugins.unregister("my-plugin");
|
|
74
|
+
```
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Plugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Plugin.Plugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "PluginsContainer", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _PluginsContainer.PluginsContainer;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.plugins = void 0;
|
|
19
|
+
|
|
20
|
+
var _PluginsContainer = require("./PluginsContainer");
|
|
21
|
+
|
|
22
|
+
var _Plugin = require("./Plugin");
|
|
23
|
+
|
|
24
|
+
const plugins = new _PluginsContainer.PluginsContainer();
|
|
25
|
+
exports.plugins = plugins;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["plugins","PluginsContainer"],"sources":["index.ts"],"sourcesContent":["import { PluginsContainer } from \"./PluginsContainer\";\nimport { Plugin } from \"./Plugin\";\n\nconst plugins = new PluginsContainer();\n\nexport { Plugin, PluginsContainer, plugins };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA,MAAMA,OAAO,GAAG,IAAIC,kCAAJ,EAAhB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/plugins",
|
|
3
|
+
"version": "0.0.0-ee-vpcs.549378cf03",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "A simple registry that stores all plugins in a shared object.",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
|
12
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@babel/runtime": "7.19.0",
|
|
17
|
+
"uniqid": "5.4.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/cli": "^7.19.3",
|
|
21
|
+
"@babel/core": "^7.19.3",
|
|
22
|
+
"@types/uniqid": "^5.3.2",
|
|
23
|
+
"@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
|
|
24
|
+
"@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
|
|
25
|
+
"rimraf": "^3.0.2",
|
|
26
|
+
"ttypescript": "^1.5.13",
|
|
27
|
+
"typescript": "4.7.4"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"directory": "dist"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "yarn webiny run build",
|
|
35
|
+
"watch": "yarn webiny run watch"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
|
|
38
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { PluginsContainer } from "./PluginsContainer";
|
|
2
|
+
export declare type Plugin<T = Record<string, any>> = {
|
|
3
|
+
type: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
init?: () => void;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
} & T;
|
|
8
|
+
export declare type PluginCollection = (Plugin | PluginCollection)[];
|
package/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "PluginsContainer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _PluginsContainer.PluginsContainer;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _PluginsContainer = require("./PluginsContainer");
|
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export { PluginsContainer } from \"./PluginsContainer\";\n\nexport type Plugin<T = Record<string, any>> = {\n type: string;\n name?: string;\n init?: () => void;\n [key: string]: any;\n} & T;\n\nexport type PluginCollection = (Plugin | PluginCollection)[];\n"],"mappings":";;;;;;;;;;;;AAAA"}
|