@webiny/plugins 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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.
@@ -0,0 +1,9 @@
1
+ import type { PluginCollection } from "./types";
2
+ import { PluginsContainer } from "./types";
3
+ export declare class AsyncPluginsContainer {
4
+ private readonly plugins;
5
+ private pluginsContainer;
6
+ constructor(plugins: PluginCollection | PluginsContainer);
7
+ init(): Promise<PluginsContainer>;
8
+ private traverseAndLoadPlugins;
9
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AsyncPluginsContainer = void 0;
7
+ var _types = require("./types");
8
+ const isPluginLoader = value => {
9
+ return typeof value === "function";
10
+ };
11
+ class AsyncPluginsContainer {
12
+ constructor(plugins) {
13
+ this.plugins = plugins instanceof _types.PluginsContainer ? plugins.all() : plugins;
14
+ }
15
+ async init() {
16
+ if (this.pluginsContainer) {
17
+ return this.pluginsContainer;
18
+ }
19
+ const plugins = await this.traverseAndLoadPlugins(this.plugins);
20
+ this.pluginsContainer = new _types.PluginsContainer(plugins);
21
+ return this.pluginsContainer;
22
+ }
23
+ async traverseAndLoadPlugins(plugins) {
24
+ if (!Array.isArray(plugins)) {
25
+ return [plugins];
26
+ }
27
+ return plugins.reduce((acc, item) => {
28
+ return acc.then(async plugins => {
29
+ if (isPluginLoader(item)) {
30
+ const lazyPlugins = await item();
31
+ return [...plugins, ...(await this.traverseAndLoadPlugins(lazyPlugins))];
32
+ }
33
+ return [...plugins, ...(await this.traverseAndLoadPlugins(item))];
34
+ });
35
+ }, Promise.resolve([]));
36
+ }
37
+ }
38
+ exports.AsyncPluginsContainer = AsyncPluginsContainer;
39
+
40
+ //# sourceMappingURL=AsyncPluginsContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","isPluginLoader","value","AsyncPluginsContainer","constructor","plugins","PluginsContainer","all","init","pluginsContainer","traverseAndLoadPlugins","Array","isArray","reduce","acc","item","then","lazyPlugins","Promise","resolve","exports"],"sources":["AsyncPluginsContainer.ts"],"sourcesContent":["import type { Plugin, PluginCollection, PluginFactory } from \"~/types\";\nimport { PluginsContainer } from \"~/types\";\n\nconst isPluginLoader = (value: unknown): value is PluginFactory => {\n return typeof value === \"function\";\n};\n\nexport class AsyncPluginsContainer {\n private readonly plugins: PluginCollection;\n private pluginsContainer: PluginsContainer | undefined;\n\n constructor(plugins: PluginCollection | PluginsContainer) {\n this.plugins = plugins instanceof PluginsContainer ? plugins.all() : plugins;\n }\n\n async init() {\n if (this.pluginsContainer) {\n return this.pluginsContainer;\n }\n\n const plugins = await this.traverseAndLoadPlugins(this.plugins);\n this.pluginsContainer = new PluginsContainer(plugins);\n\n return this.pluginsContainer;\n }\n\n private async traverseAndLoadPlugins(plugins: Plugin | PluginCollection): Promise<Plugin[]> {\n if (!Array.isArray(plugins)) {\n return [plugins];\n }\n\n return plugins.reduce<Promise<Plugin[]>>((acc, item) => {\n return acc.then(async plugins => {\n if (isPluginLoader(item)) {\n const lazyPlugins = await item();\n return [...plugins, ...(await this.traverseAndLoadPlugins(lazyPlugins))];\n }\n\n return [...plugins, ...(await this.traverseAndLoadPlugins(item))];\n });\n }, Promise.resolve([]));\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAIC,KAAc,IAA6B;EAC/D,OAAO,OAAOA,KAAK,KAAK,UAAU;AACtC,CAAC;AAEM,MAAMC,qBAAqB,CAAC;EAI/BC,WAAWA,CAACC,OAA4C,EAAE;IACtD,IAAI,CAACA,OAAO,GAAGA,OAAO,YAAYC,uBAAgB,GAAGD,OAAO,CAACE,GAAG,CAAC,CAAC,GAAGF,OAAO;EAChF;EAEA,MAAMG,IAAIA,CAAA,EAAG;IACT,IAAI,IAAI,CAACC,gBAAgB,EAAE;MACvB,OAAO,IAAI,CAACA,gBAAgB;IAChC;IAEA,MAAMJ,OAAO,GAAG,MAAM,IAAI,CAACK,sBAAsB,CAAC,IAAI,CAACL,OAAO,CAAC;IAC/D,IAAI,CAACI,gBAAgB,GAAG,IAAIH,uBAAgB,CAACD,OAAO,CAAC;IAErD,OAAO,IAAI,CAACI,gBAAgB;EAChC;EAEA,MAAcC,sBAAsBA,CAACL,OAAkC,EAAqB;IACxF,IAAI,CAACM,KAAK,CAACC,OAAO,CAACP,OAAO,CAAC,EAAE;MACzB,OAAO,CAACA,OAAO,CAAC;IACpB;IAEA,OAAOA,OAAO,CAACQ,MAAM,CAAoB,CAACC,GAAG,EAAEC,IAAI,KAAK;MACpD,OAAOD,GAAG,CAACE,IAAI,CAAC,MAAMX,OAAO,IAAI;QAC7B,IAAIJ,cAAc,CAACc,IAAI,CAAC,EAAE;UACtB,MAAME,WAAW,GAAG,MAAMF,IAAI,CAAC,CAAC;UAChC,OAAO,CAAC,GAAGV,OAAO,EAAE,IAAI,MAAM,IAAI,CAACK,sBAAsB,CAACO,WAAW,CAAC,CAAC,CAAC;QAC5E;QAEA,OAAO,CAAC,GAAGZ,OAAO,EAAE,IAAI,MAAM,IAAI,CAACK,sBAAsB,CAACK,IAAI,CAAC,CAAC,CAAC;MACrE,CAAC,CAAC;IACN,CAAC,EAAEG,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC,CAAC;EAC3B;AACJ;AAACC,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
package/Plugin.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare abstract class Plugin {
2
2
  static readonly type: string;
3
- name: string;
3
+ name?: string;
4
4
  constructor();
5
5
  get type(): string;
6
6
  }
package/Plugin.js CHANGED
@@ -1,28 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.Plugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  class Plugin {
13
8
  constructor() {
14
- (0, _defineProperty2.default)(this, "name", void 0);
15
-
16
9
  if (!this.constructor.type) {
17
10
  throw Error(`Missing "type" definition in "${this.constructor.name}"!`);
18
11
  }
19
12
  }
20
-
21
13
  get type() {
22
14
  return this.constructor.type;
23
15
  }
24
-
25
16
  }
26
-
27
17
  exports.Plugin = Plugin;
28
- (0, _defineProperty2.default)(Plugin, "type", void 0);
18
+
19
+ //# sourceMappingURL=Plugin.js.map
package/Plugin.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Plugin","constructor","type","Error","name","exports"],"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,MAAM,CAAC;EAIzBC,WAAWA,CAAA,EAAG;IACV,IAAI,CAAE,IAAI,CAACA,WAAW,CAAmBC,IAAI,EAAE;MAC3C,MAAMC,KAAK,CAAC,iCAAiC,IAAI,CAACF,WAAW,CAACG,IAAI,IAAI,CAAC;IAC3E;EACJ;EAEA,IAAIF,IAAIA,CAAA,EAAG;IACP,OAAQ,IAAI,CAACD,WAAW,CAAmBC,IAAI;EACnD;AACJ;AAACG,OAAA,CAAAL,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -1,12 +1,17 @@
1
- import { Plugin } from "./types";
1
+ import type { Plugin, PluginCollection } from "./types";
2
+ export type WithName<T extends Plugin> = T & {
3
+ name: string;
4
+ };
2
5
  export declare class PluginsContainer {
3
6
  private plugins;
4
7
  private _byTypeCache;
5
- constructor(...args: any[]);
6
- byName<T extends Plugin>(name: T["name"]): T;
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;
8
+ constructor(...args: PluginCollection);
9
+ byName<T extends Plugin>(name: T["name"]): WithName<T> | null;
10
+ byType<T extends Plugin>(type: T["type"]): WithName<T>[];
11
+ atLeastOneByType<T extends Plugin>(type: T["type"]): WithName<T>[];
12
+ oneByType<T extends Plugin>(type: T["type"]): WithName<T>;
13
+ merge(input: PluginsContainer | PluginCollection): void;
14
+ mergeByType(container: PluginsContainer, type: string): void;
10
15
  all<T extends Plugin>(): T[];
11
16
  register(...args: any): void;
12
17
  unregister(name: string): void;
@@ -1,113 +1,114 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.PluginsContainer = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
8
  var _uniqid = _interopRequireDefault(require("uniqid"));
13
-
14
9
  const isOptionsObject = item => item && !Array.isArray(item) && !item.type && !item.name;
15
-
16
10
  const normalizeArgs = args => {
17
- let options = {}; // Check if last item in the plugins array is actually an options object.
11
+ let options = {};
18
12
 
13
+ // Check if last item in the plugins array is actually an options object.
19
14
  if (isOptionsObject(args[args.length - 1])) {
20
15
  [options] = args.splice(-1, 1);
21
16
  }
22
-
23
17
  return [args, options];
24
18
  };
25
-
26
19
  const assign = (plugins, options, target) => {
27
- for (let i = 0; i < plugins.length; i++) {
28
- const plugin = plugins[i];
29
-
20
+ for (const plugin of plugins) {
30
21
  if (Array.isArray(plugin)) {
31
22
  assign(plugin, options, target);
32
23
  continue;
33
24
  }
34
-
25
+ if (typeof plugin !== "object") {
26
+ throw new Error(`Could not register plugin. Expected an object, but got ${typeof plugin}.`);
27
+ }
28
+ if (!plugin.type) {
29
+ let name = "";
30
+ if (plugin.name) {
31
+ name = ` "${plugin.name}"`;
32
+ }
33
+ throw new Error(`Could not register plugin${name}. Missing "type" definition.`);
34
+ }
35
35
  let name = plugin._name || plugin.name;
36
-
37
36
  if (!name) {
38
37
  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
-
38
+ }
41
39
 
40
+ // If skip existing was set to true, and a plugin with the same name was already registered, skip registration.
42
41
  if (!options.skipExisting || !target[name]) {
43
42
  target[name] = plugin;
44
43
  plugin.init && plugin.init();
45
44
  }
46
45
  }
47
46
  };
48
-
49
47
  class PluginsContainer {
48
+ plugins = {};
49
+ _byTypeCache = {};
50
50
  constructor(...args) {
51
- (0, _defineProperty2.default)(this, "plugins", {});
52
- (0, _defineProperty2.default)(this, "_byTypeCache", {});
53
51
  this.register(...args);
54
52
  }
55
-
56
53
  byName(name) {
54
+ if (!name) {
55
+ return null;
56
+ }
57
+ /**
58
+ * We can safely cast name as string, we know it is so.
59
+ */
57
60
  return this.plugins[name];
58
61
  }
59
-
60
62
  byType(type) {
61
63
  if (this._byTypeCache[type]) {
62
64
  return Array.from(this._byTypeCache[type]);
63
65
  }
64
-
65
66
  const plugins = this.findByType(type);
66
67
  this._byTypeCache[type] = plugins;
67
68
  return Array.from(plugins);
68
69
  }
69
-
70
70
  atLeastOneByType(type) {
71
71
  const list = this.byType(type);
72
-
73
72
  if (list.length === 0) {
74
73
  throw new Error(`There are no plugins by type "${type}".`);
75
74
  }
76
-
77
75
  return list;
78
76
  }
79
-
80
77
  oneByType(type) {
81
78
  const list = this.atLeastOneByType(type);
82
-
83
79
  if (list.length > 1) {
84
80
  throw new Error(`There is a requirement for plugin of type "${type}" to be only one registered.`);
85
81
  }
86
-
87
82
  return list[0];
88
83
  }
89
-
84
+ merge(input) {
85
+ if (input instanceof PluginsContainer) {
86
+ this.register(...input.all());
87
+ return;
88
+ }
89
+ this.register(input);
90
+ }
91
+ mergeByType(container, type) {
92
+ this.register(...container.byType(type));
93
+ }
90
94
  all() {
91
95
  return Object.values(this.plugins);
92
96
  }
93
-
94
97
  register(...args) {
95
98
  // reset the cache when adding new plugins
96
99
  this._byTypeCache = {};
97
100
  const [plugins, options] = normalizeArgs(args);
98
101
  assign(plugins, options, this.plugins);
99
102
  }
100
-
101
103
  unregister(name) {
102
104
  // reset the cache when removing a plugin
103
105
  this._byTypeCache = {};
104
106
  delete this.plugins[name];
105
107
  }
106
-
107
108
  findByType(type) {
108
109
  return Object.values(this.plugins).filter(pl => pl.type === type);
109
110
  }
110
-
111
111
  }
112
+ exports.PluginsContainer = PluginsContainer;
112
113
 
113
- exports.PluginsContainer = PluginsContainer;
114
+ //# sourceMappingURL=PluginsContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_uniqid","_interopRequireDefault","require","isOptionsObject","item","Array","isArray","type","name","normalizeArgs","args","options","length","splice","assign","plugins","target","plugin","Error","_name","uniqid","skipExisting","init","PluginsContainer","_byTypeCache","constructor","register","byName","byType","from","findByType","atLeastOneByType","list","oneByType","merge","input","all","mergeByType","container","Object","values","unregister","filter","pl","exports"],"sources":["PluginsContainer.ts"],"sourcesContent":["import type { Plugin, PluginCollection } from \"./types\";\nimport uniqid from \"uniqid\";\n\nexport type WithName<T extends Plugin> = T & { name: string };\n\nconst isOptionsObject = (item?: any) => item && !Array.isArray(item) && !item.type && !item.name;\nconst normalizeArgs = (args: any[]): [Plugin[], 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 = (\n plugins: Plugin[] | Plugin[][],\n options: any,\n target: Record<string, any>\n): void => {\n for (const plugin of plugins) {\n if (Array.isArray(plugin)) {\n assign(plugin, options, target);\n continue;\n }\n\n if (typeof plugin !== \"object\") {\n throw new Error(\n `Could not register plugin. Expected an object, but got ${typeof plugin}.`\n );\n }\n\n if (!plugin.type) {\n let name = \"\";\n if (plugin.name) {\n name = ` \"${plugin.name}\"`;\n }\n throw new Error(`Could not register plugin${name}. Missing \"type\" definition.`);\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, WithName<Plugin>[]> = {};\n\n constructor(...args: PluginCollection) {\n this.register(...args);\n }\n\n public byName<T extends Plugin>(name: T[\"name\"]) {\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 WithName<T>;\n }\n\n public byType<T extends Plugin>(type: T[\"type\"]) {\n if (this._byTypeCache[type]) {\n return Array.from(this._byTypeCache[type]) as WithName<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\"]) {\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\"]) {\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 merge(input: PluginsContainer | PluginCollection): void {\n if (input instanceof PluginsContainer) {\n this.register(...input.all());\n return;\n }\n this.register(input);\n }\n\n public mergeByType(container: PluginsContainer, type: string): void {\n this.register(...container.byType(type));\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\"]) {\n return Object.values(this.plugins).filter(\n (pl): pl is T => pl.type === type\n ) as WithName<T>[];\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,MAAMC,eAAe,GAAIC,IAAU,IAAKA,IAAI,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,IAAI,CAAC,IAAI,CAACA,IAAI,CAACG,IAAI,IAAI,CAACH,IAAI,CAACI,IAAI;AAChG,MAAMC,aAAa,GAAIC,IAAW,IAAsB;EACpD,IAAIC,OAAO,GAAG,CAAC,CAAC;;EAEhB;EACA,IAAIR,eAAe,CAACO,IAAI,CAACA,IAAI,CAACE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE;IACxC,CAACD,OAAO,CAAC,GAAGD,IAAI,CAACG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;EAClC;EAEA,OAAO,CAACH,IAAI,EAAEC,OAAO,CAAC;AAC1B,CAAC;AAED,MAAMG,MAAM,GAAGA,CACXC,OAA8B,EAC9BJ,OAAY,EACZK,MAA2B,KACpB;EACP,KAAK,MAAMC,MAAM,IAAIF,OAAO,EAAE;IAC1B,IAAIV,KAAK,CAACC,OAAO,CAACW,MAAM,CAAC,EAAE;MACvBH,MAAM,CAACG,MAAM,EAAEN,OAAO,EAAEK,MAAM,CAAC;MAC/B;IACJ;IAEA,IAAI,OAAOC,MAAM,KAAK,QAAQ,EAAE;MAC5B,MAAM,IAAIC,KAAK,CACX,0DAA0D,OAAOD,MAAM,GAC3E,CAAC;IACL;IAEA,IAAI,CAACA,MAAM,CAACV,IAAI,EAAE;MACd,IAAIC,IAAI,GAAG,EAAE;MACb,IAAIS,MAAM,CAACT,IAAI,EAAE;QACbA,IAAI,GAAG,KAAKS,MAAM,CAACT,IAAI,GAAG;MAC9B;MACA,MAAM,IAAIU,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CAAC,CAAC;IACtB,OAAO,IAAI,CAACT,OAAO,CAACP,IAAI,CAAC;EAC7B;EAEQsB,UAAUA,CAAmBvB,IAAe,EAAE;IAClD,OAAOgC,MAAM,CAACC,MAAM,CAAC,IAAI,CAACzB,OAAO,CAAC,CAAC2B,MAAM,CACpCC,EAAE,IAAcA,EAAE,CAACpC,IAAI,KAAKA,IACjC,CAAC;EACL;AACJ;AAACqC,OAAA,CAAArB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { PluginsContainer } from "./PluginsContainer";
2
+ import { AsyncPluginsContainer } from "./AsyncPluginsContainer";
2
3
  import { Plugin } from "./Plugin";
3
4
  declare const plugins: PluginsContainer;
4
- export { Plugin, PluginsContainer, plugins };
5
+ export { Plugin, PluginsContainer, plugins, AsyncPluginsContainer };
package/index.js CHANGED
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "AsyncPluginsContainer", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _AsyncPluginsContainer.AsyncPluginsContainer;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "Plugin", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -16,10 +22,9 @@ Object.defineProperty(exports, "PluginsContainer", {
16
22
  }
17
23
  });
18
24
  exports.plugins = void 0;
19
-
20
25
  var _PluginsContainer = require("./PluginsContainer");
21
-
26
+ var _AsyncPluginsContainer = require("./AsyncPluginsContainer");
22
27
  var _Plugin = require("./Plugin");
28
+ const plugins = exports.plugins = new _PluginsContainer.PluginsContainer();
23
29
 
24
- const plugins = new _PluginsContainer.PluginsContainer();
25
- exports.plugins = plugins;
30
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_PluginsContainer","require","_AsyncPluginsContainer","_Plugin","plugins","exports","PluginsContainer"],"sources":["index.ts"],"sourcesContent":["import { PluginsContainer } from \"./PluginsContainer\";\nimport { AsyncPluginsContainer } from \"./AsyncPluginsContainer\";\nimport { Plugin } from \"./Plugin\";\n\nconst plugins = new PluginsContainer();\n\nexport { Plugin, PluginsContainer, plugins, AsyncPluginsContainer };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,IAAIE,kCAAgB,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/plugins",
3
- "version": "0.0.0-mt-2",
3
+ "version": "0.0.0-unstable.06b2ede40f",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,24 +13,21 @@
13
13
  ],
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@babel/runtime": "7.15.4",
17
16
  "uniqid": "5.4.0"
18
17
  },
19
18
  "devDependencies": {
20
- "@babel/cli": "^7.5.5",
21
- "@babel/core": "^7.5.5",
22
- "@webiny/cli": "^0.0.0-mt-2",
23
- "@webiny/project-utils": "^0.0.0-mt-2",
24
- "rimraf": "^3.0.2",
25
- "typescript": "^4.1.3"
19
+ "@types/uniqid": "5.3.2",
20
+ "@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
21
+ "rimraf": "6.0.1",
22
+ "typescript": "5.3.3"
26
23
  },
27
24
  "publishConfig": {
28
25
  "access": "public",
29
26
  "directory": "dist"
30
27
  },
31
28
  "scripts": {
32
- "build": "yarn webiny run build",
33
- "watch": "yarn webiny run watch"
29
+ "build": "node ../cli/bin.js run build",
30
+ "watch": "node ../cli/bin.js run watch"
34
31
  },
35
- "gitHead": "3c0dcfb3c22c9f83107fdb97b25014cd03d9db7d"
32
+ "gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
36
33
  }
package/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { PluginsContainer } from "./PluginsContainer";
2
- export declare type Plugin<T = Record<string, any>> = {
2
+ export type Plugin<T = Record<string, any>> = {
3
3
  type: string;
4
4
  name?: string;
5
5
  init?: () => void;
6
6
  [key: string]: any;
7
7
  } & T;
8
- export declare type PluginCollection = (Plugin | PluginCollection)[];
8
+ export type PluginCollection = (Plugin | PluginFactory | PluginCollection)[];
9
+ export type PluginFactory = () => Promise<Plugin | PluginCollection>;
package/types.js CHANGED
@@ -9,5 +9,6 @@ Object.defineProperty(exports, "PluginsContainer", {
9
9
  return _PluginsContainer.PluginsContainer;
10
10
  }
11
11
  });
12
+ var _PluginsContainer = require("./PluginsContainer");
12
13
 
13
- var _PluginsContainer = require("./PluginsContainer");
14
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_PluginsContainer","require"],"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 | PluginFactory | PluginCollection)[];\n\nexport type PluginFactory = () => Promise<Plugin | PluginCollection>;\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA","ignoreList":[]}