@modern-js/plugin 1.3.6 → 1.4.0-alpha.0

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/js/modern/farrow-pipeline/context.js +14 -75
  3. package/dist/js/modern/farrow-pipeline/index.js +0 -14
  4. package/dist/js/modern/farrow-pipeline/pipeline.js +12 -29
  5. package/dist/js/modern/manager/async.js +9 -69
  6. package/dist/js/modern/manager/runner.js +1 -9
  7. package/dist/js/modern/manager/shared.js +44 -0
  8. package/dist/js/modern/manager/sync.js +12 -77
  9. package/dist/js/modern/waterfall/async.js +1 -3
  10. package/dist/js/modern/waterfall/sync.js +1 -3
  11. package/dist/js/modern/workflow/async.js +3 -3
  12. package/dist/js/modern/workflow/parallel.js +2 -2
  13. package/dist/js/modern/workflow/sync.js +3 -3
  14. package/dist/js/node/farrow-pipeline/context.js +15 -88
  15. package/dist/js/node/farrow-pipeline/pipeline.js +10 -45
  16. package/dist/js/node/manager/async.js +12 -72
  17. package/dist/js/node/manager/runner.js +1 -9
  18. package/dist/js/node/manager/shared.js +64 -0
  19. package/dist/js/node/manager/sync.js +19 -87
  20. package/dist/js/node/waterfall/async.js +0 -2
  21. package/dist/js/node/waterfall/sync.js +0 -2
  22. package/dist/js/node/workflow/async.js +3 -3
  23. package/dist/js/node/workflow/parallel.js +2 -2
  24. package/dist/js/node/workflow/sync.js +3 -3
  25. package/dist/js/treeshaking/farrow-pipeline/context.js +14 -75
  26. package/dist/js/treeshaking/farrow-pipeline/index.js +0 -14
  27. package/dist/js/treeshaking/farrow-pipeline/pipeline.js +10 -29
  28. package/dist/js/treeshaking/manager/async.js +15 -160
  29. package/dist/js/treeshaking/manager/runner.js +1 -7
  30. package/dist/js/treeshaking/manager/shared.js +79 -0
  31. package/dist/js/treeshaking/manager/sync.js +12 -168
  32. package/dist/js/treeshaking/waterfall/async.js +1 -3
  33. package/dist/js/treeshaking/waterfall/sync.js +1 -3
  34. package/dist/js/treeshaking/workflow/async.js +6 -6
  35. package/dist/js/treeshaking/workflow/parallel.js +5 -5
  36. package/dist/js/treeshaking/workflow/sync.js +8 -28
  37. package/dist/types/farrow-pipeline/context.d.ts +5 -20
  38. package/dist/types/farrow-pipeline/index.d.ts +0 -14
  39. package/dist/types/farrow-pipeline/pipeline.d.ts +5 -14
  40. package/dist/types/manager/async.d.ts +4 -7
  41. package/dist/types/manager/shared.d.ts +12 -0
  42. package/dist/types/manager/sync.d.ts +5 -11
  43. package/dist/types/manager/types.d.ts +1 -6
  44. package/dist/types/waterfall/async.d.ts +1 -7
  45. package/dist/types/waterfall/sync.d.ts +0 -7
  46. package/dist/types/workflow/async.d.ts +1 -7
  47. package/dist/types/workflow/parallel.d.ts +2 -9
  48. package/dist/types/workflow/sync.d.ts +1 -10
  49. package/package.json +1 -12
  50. package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +0 -74
  51. package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +0 -12
  52. package/dist/js/modern/farrow-pipeline/hook.js +0 -42
  53. package/dist/js/node/farrow-pipeline/asyncHooks.node.js +0 -93
  54. package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +0 -26
  55. package/dist/js/node/farrow-pipeline/hook.js +0 -52
  56. package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +0 -74
  57. package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +0 -12
  58. package/dist/js/treeshaking/farrow-pipeline/hook.js +0 -46
  59. package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +0 -2
  60. package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +0 -19
  61. package/dist/types/farrow-pipeline/hook.d.ts +0 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @modern-js/plugin
2
2
 
3
+ ## 1.4.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f29e9bacf: feat(plugin): simplify context usage, no longer depend on containers
8
+
9
+ ## 1.3.8
10
+
11
+ ### Patch Changes
12
+
13
+ - b7302f781: Export some required types
14
+ - e0e708f83: perf(app-tools): speed up modern start command
15
+
16
+ ## 1.3.7
17
+
18
+ ### Patch Changes
19
+
20
+ - 1ac68424f: chore(plugin): extract same utils to shared
21
+
3
22
  ## 1.3.6
4
23
 
5
24
  ### Patch Changes
@@ -2,39 +2,30 @@
2
2
  * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
3
3
  * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
4
4
  */
5
- import { createHooks } from "./hook";
6
- const ContextSymbol = Symbol.for('MODERN_CONTEXT');
7
5
  export const createContext = value => {
8
- const id = Symbol('MODERN_CONTEXT_ID');
6
+ let currentValue;
9
7
 
10
8
  const create = value => {
11
- const use = () => {
12
- const container = useContainer();
13
- return Object.seal({
14
- get value() {
15
- return container.read(Context);
16
- },
9
+ currentValue = value;
17
10
 
18
- set value(v) {
19
- container.write(Context, v);
20
- }
11
+ const use = () => ({
12
+ get value() {
13
+ return currentValue;
14
+ },
21
15
 
22
- });
23
- };
16
+ set value(v) {
17
+ currentValue = v;
18
+ }
24
19
 
25
- const get = () => {
26
- const container = useContainer();
27
- return container.read(Context);
28
- };
20
+ });
21
+
22
+ const get = () => currentValue;
29
23
 
30
24
  const set = v => {
31
- const container = useContainer();
32
- container.write(Context, v);
25
+ currentValue = v;
33
26
  };
34
27
 
35
28
  const Context = {
36
- id,
37
- [ContextSymbol]: value,
38
29
  create,
39
30
  use,
40
31
  get,
@@ -44,56 +35,4 @@ export const createContext = value => {
44
35
  };
45
36
 
46
37
  return create(value);
47
- };
48
-
49
- const createContextMap = storage => {
50
- const contextMap = new Map();
51
- const contexts = Object.values(storage); // eslint-disable-next-line @typescript-eslint/prefer-for-of
52
-
53
- for (let i = 0; i < contexts.length; i++) {
54
- contextMap.set(contexts[i].id, contexts[i]);
55
- }
56
-
57
- return contextMap;
58
- };
59
-
60
- export const createContainer = (ContextStorage = {}) => {
61
- const contextMap = createContextMap(ContextStorage);
62
-
63
- const read = context => {
64
- const target = contextMap.get(context.id);
65
-
66
- if (target) {
67
- return target[ContextSymbol];
68
- }
69
-
70
- return context[ContextSymbol];
71
- };
72
-
73
- const write = (context, value) => {
74
- contextMap.set(context.id, context.create(value));
75
- };
76
-
77
- return Object.freeze({
78
- read,
79
- write
80
- });
81
- };
82
- const {
83
- run,
84
- hooks
85
- } = createHooks({
86
- useContainer: () => {
87
- throw new Error(`Can't call useContainer out of scope, it should be placed on top of the function`);
88
- }
89
- });
90
- export const runHooks = run;
91
- export const {
92
- useContainer
93
- } = hooks;
94
- export const fromContainer = container => ({
95
- useContainer: () => {
96
- return container;
97
- }
98
- });
99
- export const runWithContainer = (f, container) => runHooks(f, fromContainer(container));
38
+ };
@@ -1,19 +1,5 @@
1
1
  /**
2
2
  * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
3
3
  * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
4
- *
5
- * removed:
6
- * - dependencies:
7
- * - tslib
8
- * - files
9
- * - compose.ts
10
- * - methods:
11
- * - usePipeline
12
- * - assertContainer
13
- * - assertContext
14
- * - isContext
15
- * - isContainer
16
- * - pipeline.useLazy
17
- * - context.assert
18
4
  */
19
5
  export * from "./pipeline";
@@ -8,9 +8,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
9
9
  * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
10
10
  */
11
- import { createContext, createContainer, fromContainer, runHooks, useContainer, runWithContainer } from "./context";
11
+ import { createContext } from "./context";
12
12
  import { createCounter } from "./counter";
13
- export { createContext, createContainer, useContainer, runWithContainer };
13
+ export { createContext };
14
14
  export const isPipeline = input => Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
15
15
  const PipelineSymbol = Symbol.for('MODERN_PIPELINE');
16
16
 
@@ -24,9 +24,7 @@ const getMiddleware = input => {
24
24
  throw new Error(`${input} is not a Middleware`);
25
25
  };
26
26
 
27
- export const createPipeline = options => {
28
- const config = _objectSpread({}, options);
29
-
27
+ export const createPipeline = () => {
30
28
  const middlewares = [];
31
29
 
32
30
  const use = (...inputs) => {
@@ -34,50 +32,35 @@ export const createPipeline = options => {
34
32
  return pipeline;
35
33
  };
36
34
 
37
- const createCurrentCounter = (hooks, onLast, onLastWithContext) => {
35
+ const createCurrentCounter = onLast => {
38
36
  return createCounter((index, input, next) => {
39
37
  if (index >= middlewares.length) {
40
38
  if (onLast) {
41
- if (onLastWithContext) {
42
- return runHooks(() => onLast(input), hooks);
43
- }
44
-
45
39
  return onLast(input);
46
40
  }
47
41
 
48
42
  throw new Error(`Expect returning a value, but all middlewares just calling next()`);
49
43
  }
50
44
 
51
- return runHooks(() => middlewares[index](input, next), hooks);
45
+ return middlewares[index](input, next);
52
46
  });
53
47
  };
54
48
 
55
- const currentContainer = createContainer(config.contexts);
56
- const currentHooks = fromContainer(currentContainer);
57
- const currentCounter = createCurrentCounter(currentHooks);
49
+ const currentCounter = createCurrentCounter();
58
50
 
59
51
  const getCounter = options => {
60
52
  if (!options) {
61
53
  return currentCounter;
62
54
  }
63
55
 
64
- if (options !== null && options !== void 0 && options.container) {
65
- const hooks = fromContainer(options === null || options === void 0 ? void 0 : options.container);
66
- return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(hooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(hooks);
67
- }
68
-
69
- return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(currentHooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(currentHooks);
56
+ return createCurrentCounter(options === null || options === void 0 ? void 0 : options.onLast);
70
57
  };
71
58
 
72
59
  const run = (input, options) => getCounter(options).start(input);
73
60
 
74
- const middleware = (input, next) => {
75
- const container = useContainer();
76
- return run(input, {
77
- container,
78
- onLast: next
79
- });
80
- };
61
+ const middleware = (input, next) => run(input, {
62
+ onLast: next
63
+ });
81
64
 
82
65
  const pipeline = {
83
66
  [PipelineSymbol]: true,
@@ -87,7 +70,7 @@ export const createPipeline = options => {
87
70
  };
88
71
  return pipeline;
89
72
  };
90
- export const createAsyncPipeline = options => {
91
- const pipeline = createPipeline(options);
73
+ export const createAsyncPipeline = () => {
74
+ const pipeline = createPipeline();
92
75
  return _objectSpread({}, pipeline);
93
76
  };
@@ -4,9 +4,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  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; }
6
6
 
7
- import { runWithContainer, createContainer } from "../farrow-pipeline";
8
- import { isObject, generateRunner, hasOwnProperty, DEFAULT_OPTIONS } from "./sync";
7
+ import { generateRunner, DEFAULT_OPTIONS } from "./sync";
9
8
  import { useRunner } from "./runner";
9
+ import { checkPlugins, isObject, hasOwnProperty, sortPlugins, includePlugin } from "./shared";
10
10
  const ASYNC_PLUGIN_SYMBOL = 'ASYNC_PLUGIN_SYMBOL';
11
11
  export const createAsyncManager = (hooks, api) => {
12
12
  let index = 0;
@@ -27,7 +27,7 @@ export const createAsyncManager = (hooks, api) => {
27
27
  let plugins = [];
28
28
 
29
29
  const addPlugin = plugin => {
30
- if (!includeAsyncPlugin(plugins, plugin)) {
30
+ if (!includePlugin(plugins, plugin)) {
31
31
  plugins.push(_objectSpread({}, plugin));
32
32
  }
33
33
  };
@@ -79,23 +79,17 @@ export const createAsyncManager = (hooks, api) => {
79
79
  plugins = [];
80
80
  };
81
81
 
82
- const currentContainer = createContainer();
83
-
84
- const init = async options => {
85
- const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
86
- const sortedPlugins = sortAsyncPlugins(plugins);
82
+ const init = async () => {
83
+ const sortedPlugins = sortPlugins(plugins);
87
84
 
88
85
  const mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
89
86
 
90
- checkAsyncPlugins(sortedPlugins);
91
- const hooksList = await Promise.all(sortedPlugins.map(plugin => runWithContainer(() => plugin.setup(mergedPluginAPI), container)));
92
- return generateRunner(hooksList, container, currentHooks);
87
+ checkPlugins(sortedPlugins);
88
+ const hooksList = await Promise.all(sortedPlugins.map(plugin => plugin.setup(mergedPluginAPI)));
89
+ return generateRunner(hooksList, currentHooks);
93
90
  };
94
91
 
95
- const run = (cb, options) => {
96
- const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
97
- return runWithContainer(cb, container);
98
- };
92
+ const run = cb => cb();
99
93
 
100
94
  const manager = {
101
95
  createPlugin,
@@ -112,58 +106,4 @@ export const createAsyncManager = (hooks, api) => {
112
106
  };
113
107
 
114
108
  return clone();
115
- };
116
-
117
- const includeAsyncPlugin = (plugins, input) => {
118
- for (const plugin of plugins) {
119
- if (plugin.name === input.name) {
120
- return true;
121
- }
122
- }
123
-
124
- return false;
125
- };
126
-
127
- const sortAsyncPlugins = input => {
128
- let plugins = input.slice();
129
-
130
- for (let i = 0; i < plugins.length; i++) {
131
- const plugin = plugins[i];
132
-
133
- for (const pre of plugin.pre) {
134
- for (let j = i + 1; j < plugins.length; j++) {
135
- if (plugins[j].name === pre) {
136
- plugins = [...plugins.slice(0, i), plugins[j], ...plugins.slice(i, j), ...plugins.slice(j + 1, plugins.length)];
137
- }
138
- }
139
- }
140
-
141
- for (const post of plugin.post) {
142
- for (let j = 0; j < i; j++) {
143
- if (plugins[j].name === post) {
144
- plugins = [...plugins.slice(0, j), ...plugins.slice(j + 1, i + 1), plugins[j], ...plugins.slice(i + 1, plugins.length)];
145
- }
146
- }
147
- }
148
- }
149
-
150
- return plugins;
151
- };
152
-
153
- const checkAsyncPlugins = plugins => {
154
- for (const origin of plugins) {
155
- for (const rival of origin.rivals) {
156
- for (const plugin of plugins) {
157
- if (rival === plugin.name) {
158
- throw new Error(`${origin.name} has rival ${plugin.name}`);
159
- }
160
- }
161
- }
162
-
163
- for (const required of origin.required) {
164
- if (!plugins.some(plugin => plugin.name === required)) {
165
- throw new Error(`The plugin: ${required} is required when plugin: ${origin.name} is exist.`);
166
- }
167
- }
168
- }
169
109
  };
@@ -1,11 +1,3 @@
1
1
  import { createContext } from "../farrow-pipeline";
2
2
  export const RunnerContext = createContext(null);
3
- export const useRunner = () => {
4
- const runner = RunnerContext.use().value;
5
-
6
- if (!runner) {
7
- throw new Error(`Can't call useRunner out of scope, it should be placed in hooks of plugin`);
8
- }
9
-
10
- return runner;
11
- };
3
+ export const useRunner = () => RunnerContext.get();
@@ -0,0 +1,44 @@
1
+ export const checkPlugins = plugins => {
2
+ plugins.forEach(origin => {
3
+ origin.rivals.forEach(rival => {
4
+ plugins.forEach(plugin => {
5
+ if (rival === plugin.name) {
6
+ throw new Error(`${origin.name} has rival ${plugin.name}`);
7
+ }
8
+ });
9
+ });
10
+ origin.required.forEach(required => {
11
+ if (!plugins.some(plugin => plugin.name === required)) {
12
+ throw new Error(`The plugin: ${required} is required when plugin: ${origin.name} is exist.`);
13
+ }
14
+ });
15
+ });
16
+ };
17
+ export function sortPlugins(input) {
18
+ let plugins = input.slice();
19
+
20
+ for (let i = 0; i < plugins.length; i++) {
21
+ const plugin = plugins[i];
22
+
23
+ for (const pre of plugin.pre) {
24
+ for (let j = i + 1; j < plugins.length; j++) {
25
+ if (plugins[j].name === pre) {
26
+ plugins = [...plugins.slice(0, i), plugins[j], ...plugins.slice(i, j), ...plugins.slice(j + 1, plugins.length)];
27
+ }
28
+ }
29
+ }
30
+
31
+ for (const post of plugin.post) {
32
+ for (let j = 0; j < i; j++) {
33
+ if (plugins[j].name === post) {
34
+ plugins = [...plugins.slice(0, j), ...plugins.slice(j + 1, i + 1), plugins[j], ...plugins.slice(i + 1, plugins.length)];
35
+ }
36
+ }
37
+ }
38
+ }
39
+
40
+ return plugins;
41
+ }
42
+ export const includePlugin = (plugins, input) => plugins.some(plugin => plugin.name === input.name);
43
+ export const isObject = obj => obj !== null && typeof obj === 'object';
44
+ export const hasOwnProperty = (obj, prop) => obj.hasOwnProperty(prop);
@@ -4,10 +4,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  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; }
6
6
 
7
- import { isPipeline, createPipeline, runWithContainer, createContainer } from "../farrow-pipeline";
7
+ import { isPipeline, createPipeline } from "../farrow-pipeline";
8
8
  import { isWaterfall, createWaterfall, isAsyncWaterfall, createAsyncWaterfall } from "../waterfall";
9
9
  import { isWorkflow, createWorkflow, isAsyncWorkflow, createAsyncWorkflow, isParallelWorkflow, createParallelWorkflow } from "../workflow";
10
10
  import { RunnerContext, useRunner } from "./runner";
11
+ import { checkPlugins, hasOwnProperty, includePlugin, isObject, sortPlugins } from "./shared";
11
12
  const SYNC_PLUGIN_SYMBOL = 'SYNC_PLUGIN_SYMBOL';
12
13
  export const DEFAULT_OPTIONS = {
13
14
  name: 'untitled',
@@ -43,7 +44,7 @@ export const createManager = (hooks, api) => {
43
44
  };
44
45
 
45
46
  const usePlugin = (...input) => {
46
- for (const plugin of input) {
47
+ input.forEach(plugin => {
47
48
  // already created by createPlugin
48
49
  if (isPlugin(plugin)) {
49
50
  addPlugin(plugin);
@@ -58,8 +59,7 @@ export const createManager = (hooks, api) => {
58
59
  else {
59
60
  console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
60
61
  }
61
- }
62
-
62
+ });
63
63
  return manager;
64
64
  };
65
65
 
@@ -89,23 +89,17 @@ export const createManager = (hooks, api) => {
89
89
  plugins = [];
90
90
  };
91
91
 
92
- const currentContainer = createContainer();
93
-
94
- const init = options => {
95
- const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
92
+ const init = () => {
96
93
  const sortedPlugins = sortPlugins(plugins);
97
94
 
98
95
  const mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
99
96
 
100
97
  checkPlugins(sortedPlugins);
101
- const hooksList = sortedPlugins.map(plugin => runWithContainer(() => plugin.setup(mergedPluginAPI), container));
102
- return generateRunner(hooksList, container, currentHooks);
98
+ const hooksList = sortedPlugins.map(plugin => plugin.setup(mergedPluginAPI));
99
+ return generateRunner(hooksList, currentHooks);
103
100
  };
104
101
 
105
- const run = (cb, options) => {
106
- const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
107
- return runWithContainer(cb, container);
108
- };
102
+ const run = cb => cb();
109
103
 
110
104
  const manager = {
111
105
  createPlugin,
@@ -123,7 +117,7 @@ export const createManager = (hooks, api) => {
123
117
 
124
118
  return clone();
125
119
  };
126
- export const generateRunner = (hooksList, container, hooksMap) => {
120
+ export const generateRunner = (hooksList, hooksMap) => {
127
121
  const runner = {};
128
122
  const cloneShape = closeHooksMap(hooksMap);
129
123
 
@@ -141,13 +135,11 @@ export const generateRunner = (hooksList, container, hooksMap) => {
141
135
  // @ts-expect-error
142
136
 
143
137
 
144
- runner[key] = (input, options) => cloneShape[key].run(input, _objectSpread({
145
- container
146
- }, options));
138
+ runner[key] = (input, options) => cloneShape[key].run(input, _objectSpread({}, options));
147
139
  }
148
140
  }
149
141
 
150
- container.write(RunnerContext, runner);
142
+ RunnerContext.set(runner);
151
143
  return runner;
152
144
  };
153
145
  export const cloneHook = hook => {
@@ -191,61 +183,4 @@ export const closeHooksMap = record => {
191
183
  }
192
184
 
193
185
  return result;
194
- };
195
-
196
- const includePlugin = (plugins, input) => {
197
- for (const plugin of plugins) {
198
- if (plugin.name === input.name) {
199
- return true;
200
- }
201
- }
202
-
203
- return false;
204
- };
205
-
206
- const sortPlugins = input => {
207
- let plugins = input.slice();
208
-
209
- for (let i = 0; i < plugins.length; i++) {
210
- const plugin = plugins[i];
211
-
212
- for (const pre of plugin.pre) {
213
- for (let j = i + 1; j < plugins.length; j++) {
214
- if (plugins[j].name === pre) {
215
- plugins = [...plugins.slice(0, i), plugins[j], ...plugins.slice(i, j), ...plugins.slice(j + 1, plugins.length)];
216
- }
217
- }
218
- }
219
-
220
- for (const post of plugin.post) {
221
- for (let j = 0; j < i; j++) {
222
- if (plugins[j].name === post) {
223
- plugins = [...plugins.slice(0, j), ...plugins.slice(j + 1, i + 1), plugins[j], ...plugins.slice(i + 1, plugins.length)];
224
- }
225
- }
226
- }
227
- }
228
-
229
- return plugins;
230
- };
231
-
232
- const checkPlugins = plugins => {
233
- for (const origin of plugins) {
234
- for (const rival of origin.rivals) {
235
- for (const plugin of plugins) {
236
- if (rival === plugin.name) {
237
- throw new Error(`${origin.name} has rival ${plugin.name}`);
238
- }
239
- }
240
- }
241
-
242
- for (const required of origin.required) {
243
- if (!plugins.some(plugin => plugin.name === required)) {
244
- throw new Error(`The plugin: ${required} is required when plugin: ${origin.name} is exist.`);
245
- }
246
- }
247
- }
248
- };
249
-
250
- export const isObject = obj => obj !== null && typeof obj === 'object';
251
- export const hasOwnProperty = (obj, prop) => obj.hasOwnProperty(prop);
186
+ };
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  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; }
6
6
 
7
- import { createAsyncPipeline, useContainer } from "../farrow-pipeline";
7
+ import { createAsyncPipeline } from "../farrow-pipeline";
8
8
  const ASYNC_WATERFALL_SYMBOL = Symbol.for('MODERN_ASYNC_WATERFALL');
9
9
  export const getAsyncBrook = input => {
10
10
  if (typeof input === 'function') {
@@ -28,9 +28,7 @@ export const createAsyncWaterfall = () => {
28
28
  }));
29
29
 
30
30
  const middleware = input => {
31
- const container = useContainer();
32
31
  return pipeline.run(input, {
33
- container,
34
32
  onLast: input => input
35
33
  });
36
34
  };
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  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; }
6
6
 
7
- import { useContainer, createPipeline } from "../farrow-pipeline";
7
+ import { createPipeline } from "../farrow-pipeline";
8
8
  const WATERFALL_SYMBOL = Symbol.for('MODERN_WATERFALL');
9
9
  export const getBrook = input => {
10
10
  if (typeof input === 'function') {
@@ -28,9 +28,7 @@ export const createWaterfall = () => {
28
28
  }));
29
29
 
30
30
  const middleware = input => {
31
- const container = useContainer();
32
31
  return pipeline.run(input, {
33
- container,
34
32
  onLast: input => input
35
33
  });
36
34
  };
@@ -15,10 +15,10 @@ export const createAsyncWorkflow = () => {
15
15
  return workflow;
16
16
  };
17
17
 
18
- const run = async (input, options) => {
19
- const result = pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
18
+ const run = async input => {
19
+ const result = pipeline.run(input, {
20
20
  onLast: () => []
21
- }));
21
+ });
22
22
 
23
23
  if (isPromise(result)) {
24
24
  return result.then(result => result.filter(Boolean));
@@ -15,9 +15,9 @@ export const createParallelWorkflow = () => {
15
15
  return workflow;
16
16
  };
17
17
 
18
- const run = async (input, options) => Promise.all(pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
18
+ const run = async input => Promise.all(pipeline.run(input, {
19
19
  onLast: () => []
20
- }))).then(result => result.filter(Boolean));
20
+ })).then(result => result.filter(Boolean));
21
21
 
22
22
  const workflow = _objectSpread(_objectSpread({}, pipeline), {}, {
23
23
  run,
@@ -14,10 +14,10 @@ export const createWorkflow = () => {
14
14
  return workflow;
15
15
  };
16
16
 
17
- const run = async (input, options) => {
18
- const result = pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
17
+ const run = input => {
18
+ const result = pipeline.run(input, {
19
19
  onLast: () => []
20
- }));
20
+ });
21
21
  return result.filter(Boolean);
22
22
  };
23
23