@modern-js/plugin 1.3.1 → 1.3.4

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 (90) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +74 -0
  3. package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +12 -0
  4. package/dist/js/modern/farrow-pipeline/context.js +99 -0
  5. package/dist/js/modern/farrow-pipeline/counter.js +18 -0
  6. package/dist/js/modern/farrow-pipeline/hook.js +42 -0
  7. package/dist/js/modern/farrow-pipeline/index.js +19 -0
  8. package/dist/js/modern/farrow-pipeline/pipeline.js +93 -0
  9. package/dist/js/modern/index.js +1 -1
  10. package/dist/js/modern/manager/async.js +4 -4
  11. package/dist/js/modern/manager/runner.js +1 -1
  12. package/dist/js/modern/manager/sync.js +5 -6
  13. package/dist/js/modern/waterfall/async.js +4 -8
  14. package/dist/js/modern/waterfall/sync.js +4 -8
  15. package/dist/js/modern/workflow/async.js +1 -4
  16. package/dist/js/modern/workflow/parallel.js +2 -3
  17. package/dist/js/modern/workflow/sync.js +1 -1
  18. package/dist/js/node/farrow-pipeline/asyncHooks.node.js +93 -0
  19. package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +26 -0
  20. package/dist/js/node/farrow-pipeline/context.js +120 -0
  21. package/dist/js/node/farrow-pipeline/counter.js +27 -0
  22. package/dist/js/node/farrow-pipeline/hook.js +52 -0
  23. package/dist/js/node/farrow-pipeline/index.js +18 -0
  24. package/dist/js/node/farrow-pipeline/pipeline.js +129 -0
  25. package/dist/js/node/index.js +1 -1
  26. package/dist/js/node/manager/async.js +4 -4
  27. package/dist/js/node/manager/runner.js +1 -1
  28. package/dist/js/node/manager/sync.js +5 -6
  29. package/dist/js/node/waterfall/async.js +4 -8
  30. package/dist/js/node/waterfall/sync.js +4 -8
  31. package/dist/js/node/workflow/async.js +1 -4
  32. package/dist/js/node/workflow/parallel.js +2 -3
  33. package/dist/js/node/workflow/sync.js +1 -1
  34. package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +74 -0
  35. package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +12 -0
  36. package/dist/js/treeshaking/farrow-pipeline/context.js +103 -0
  37. package/dist/js/treeshaking/farrow-pipeline/counter.js +23 -0
  38. package/dist/js/treeshaking/farrow-pipeline/hook.js +46 -0
  39. package/dist/js/treeshaking/farrow-pipeline/index.js +19 -0
  40. package/dist/js/treeshaking/farrow-pipeline/pipeline.js +100 -0
  41. package/dist/js/treeshaking/index.js +1 -1
  42. package/dist/js/treeshaking/manager/async.js +8 -29
  43. package/dist/js/treeshaking/manager/runner.js +1 -1
  44. package/dist/js/treeshaking/manager/sync.js +9 -28
  45. package/dist/js/treeshaking/waterfall/async.js +12 -36
  46. package/dist/js/treeshaking/waterfall/sync.js +11 -31
  47. package/dist/js/treeshaking/workflow/async.js +6 -28
  48. package/dist/js/treeshaking/workflow/parallel.js +6 -26
  49. package/dist/js/treeshaking/workflow/sync.js +5 -24
  50. package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +2 -0
  51. package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +19 -0
  52. package/dist/types/farrow-pipeline/context.d.ts +28 -0
  53. package/dist/types/farrow-pipeline/counter.d.ts +11 -0
  54. package/dist/types/farrow-pipeline/hook.d.ts +9 -0
  55. package/dist/types/farrow-pipeline/index.d.ts +19 -0
  56. package/dist/types/farrow-pipeline/pipeline.d.ts +38 -0
  57. package/dist/types/index.d.ts +1 -1
  58. package/dist/types/manager/runner.d.ts +1 -1
  59. package/dist/types/manager/sync.d.ts +1 -1
  60. package/dist/types/manager/types.d.ts +1 -1
  61. package/dist/types/waterfall/async.d.ts +1 -1
  62. package/dist/types/waterfall/sync.d.ts +1 -1
  63. package/dist/types/workflow/async.d.ts +1 -1
  64. package/dist/types/workflow/sync.d.ts +1 -1
  65. package/package.json +37 -10
  66. package/jest.config.js +0 -8
  67. package/modern.config.js +0 -2
  68. package/node.d.ts +0 -1
  69. package/node.js +0 -1
  70. package/tests/.eslintrc.js +0 -6
  71. package/tests/async.test.ts +0 -715
  72. package/tests/fixtures/async/base/bar.ts +0 -22
  73. package/tests/fixtures/async/base/foo.ts +0 -20
  74. package/tests/fixtures/async/base/fooManager.ts +0 -47
  75. package/tests/fixtures/async/core/index.ts +0 -174
  76. package/tests/fixtures/async/dynamic/bar.ts +0 -18
  77. package/tests/fixtures/async/dynamic/foo.ts +0 -27
  78. package/tests/fixtures/sync/base/bar.ts +0 -21
  79. package/tests/fixtures/sync/base/foo.ts +0 -20
  80. package/tests/fixtures/sync/base/fooManager.ts +0 -47
  81. package/tests/fixtures/sync/core/index.ts +0 -171
  82. package/tests/fixtures/sync/dynamic/bar.ts +0 -22
  83. package/tests/fixtures/sync/dynamic/foo.ts +0 -27
  84. package/tests/helpers.ts +0 -4
  85. package/tests/pipeline.test.ts +0 -607
  86. package/tests/sync.test.ts +0 -679
  87. package/tests/tsconfig.json +0 -13
  88. package/tests/waterfall.test.ts +0 -172
  89. package/tests/workflow.test.ts +0 -111
  90. package/tsconfig.json +0 -14
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.enable = exports.disable = void 0;
7
+
8
+ var _async_hooks = _interopRequireDefault(require("async_hooks"));
9
+
10
+ var asyncHooksInterface = _interopRequireWildcard(require("./asyncHooksInterface"));
11
+
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ /**
19
+ * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
20
+ * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
21
+ */
22
+ const createAsyncHooks = () => {
23
+ const store = new Map(); // eslint-disable-next-line node/no-unsupported-features/node-builtins
24
+
25
+ const hooks = _async_hooks.default.createHook({
26
+ init: (asyncId, _, triggerAsyncId) => {
27
+ if (store.has(triggerAsyncId)) {
28
+ const value = store.get(triggerAsyncId);
29
+
30
+ if (value) {
31
+ store.set(asyncId, value);
32
+ }
33
+ }
34
+ },
35
+ destroy: asyncId => {
36
+ if (store.has(asyncId)) {
37
+ store.delete(asyncId);
38
+ }
39
+ }
40
+ });
41
+
42
+ const set = value => {
43
+ store.set(_async_hooks.default.executionAsyncId(), value);
44
+ };
45
+
46
+ const get = () => {
47
+ return store.get(_async_hooks.default.executionAsyncId());
48
+ };
49
+
50
+ const clear = () => {
51
+ store.clear();
52
+ };
53
+
54
+ const enable = () => {
55
+ hooks.enable();
56
+ };
57
+
58
+ const disable = () => {
59
+ hooks.disable();
60
+ store.clear();
61
+ };
62
+
63
+ const entries = () => {
64
+ return store.entries();
65
+ };
66
+
67
+ return {
68
+ enable,
69
+ disable,
70
+ set,
71
+ get,
72
+ clear,
73
+ entries
74
+ };
75
+ };
76
+
77
+ const enable = () => {
78
+ const hooks = createAsyncHooks();
79
+ disable();
80
+ asyncHooksInterface.impl(hooks);
81
+ hooks.enable();
82
+ };
83
+
84
+ exports.enable = enable;
85
+
86
+ const disable = () => {
87
+ var _asyncHooksInterface$;
88
+
89
+ (_asyncHooksInterface$ = asyncHooksInterface.asyncHooks) === null || _asyncHooksInterface$ === void 0 ? void 0 : _asyncHooksInterface$.disable();
90
+ asyncHooksInterface.reset();
91
+ };
92
+
93
+ exports.disable = disable;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.reset = exports.impl = exports.asyncHooks = void 0;
7
+
8
+ /**
9
+ * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
10
+ * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
11
+ */
12
+ // eslint-disable-next-line import/no-mutable-exports
13
+ let asyncHooks;
14
+ exports.asyncHooks = asyncHooks;
15
+
16
+ const impl = implimentations => {
17
+ exports.asyncHooks = asyncHooks = implimentations;
18
+ };
19
+
20
+ exports.impl = impl;
21
+
22
+ const reset = () => {
23
+ exports.asyncHooks = asyncHooks = undefined;
24
+ };
25
+
26
+ exports.reset = reset;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useContainer = exports.runWithContainer = exports.runHooks = exports.fromContainer = exports.createContext = exports.createContainer = void 0;
7
+
8
+ var _hook = require("./hook");
9
+
10
+ /**
11
+ * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
12
+ * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
13
+ */
14
+ const ContextSymbol = Symbol('Context');
15
+
16
+ const createContext = value => {
17
+ const id = Symbol('ContextID');
18
+
19
+ const create = value => {
20
+ const use = () => {
21
+ const container = useContainer();
22
+ return Object.seal({
23
+ get value() {
24
+ return container.read(Context);
25
+ },
26
+
27
+ set value(v) {
28
+ container.write(Context, v);
29
+ }
30
+
31
+ });
32
+ };
33
+
34
+ const get = () => {
35
+ const container = useContainer();
36
+ return container.read(Context);
37
+ };
38
+
39
+ const set = v => {
40
+ const container = useContainer();
41
+ container.write(Context, v);
42
+ };
43
+
44
+ const Context = {
45
+ id,
46
+ [ContextSymbol]: value,
47
+ create,
48
+ use,
49
+ get,
50
+ set
51
+ };
52
+ return Context;
53
+ };
54
+
55
+ return create(value);
56
+ };
57
+
58
+ exports.createContext = createContext;
59
+
60
+ const createContextMap = storage => {
61
+ const contextMap = new Map();
62
+ const contexts = Object.values(storage); // eslint-disable-next-line @typescript-eslint/prefer-for-of
63
+
64
+ for (let i = 0; i < contexts.length; i++) {
65
+ contextMap.set(contexts[i].id, contexts[i]);
66
+ }
67
+
68
+ return contextMap;
69
+ };
70
+
71
+ const createContainer = (ContextStorage = {}) => {
72
+ const contextMap = createContextMap(ContextStorage);
73
+
74
+ const read = context => {
75
+ const target = contextMap.get(context.id);
76
+
77
+ if (target) {
78
+ return target[ContextSymbol];
79
+ }
80
+
81
+ return context[ContextSymbol];
82
+ };
83
+
84
+ const write = (context, value) => {
85
+ contextMap.set(context.id, context.create(value));
86
+ };
87
+
88
+ return Object.freeze({
89
+ read,
90
+ write
91
+ });
92
+ };
93
+
94
+ exports.createContainer = createContainer;
95
+ const {
96
+ run,
97
+ hooks
98
+ } = (0, _hook.createHooks)({
99
+ useContainer: () => {
100
+ throw new Error(`Can't call useContainer out of scope, it should be placed on top of the function`);
101
+ }
102
+ });
103
+ const runHooks = run;
104
+ exports.runHooks = runHooks;
105
+ const {
106
+ useContainer
107
+ } = hooks;
108
+ exports.useContainer = useContainer;
109
+
110
+ const fromContainer = container => ({
111
+ useContainer: () => {
112
+ return container;
113
+ }
114
+ });
115
+
116
+ exports.fromContainer = fromContainer;
117
+
118
+ const runWithContainer = (f, container) => runHooks(f, fromContainer(container));
119
+
120
+ exports.runWithContainer = runWithContainer;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCounter = void 0;
7
+
8
+ /**
9
+ * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
10
+ * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
11
+ */
12
+ const createCounter = callback => {
13
+ const dispatch = (index, input) => {
14
+ const next = (nextInput = input) => dispatch(index + 1, nextInput);
15
+
16
+ return callback(index, input, next);
17
+ };
18
+
19
+ const start = input => dispatch(0, input);
20
+
21
+ return {
22
+ start,
23
+ dispatch
24
+ };
25
+ };
26
+
27
+ exports.createCounter = createCounter;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createHooks = void 0;
7
+
8
+ var _asyncHooksInterface = require("./asyncHooksInterface");
9
+
10
+ /**
11
+ * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
12
+ * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
13
+ */
14
+ const createHooks = defaultHooks => {
15
+ let currentHooks = {};
16
+ const hooks = {};
17
+
18
+ for (const key in defaultHooks) {
19
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
20
+ const f = (...args) => {
21
+ var _asyncHooks$get;
22
+
23
+ const hooks = currentHooks === defaultHooks ? (_asyncHooks$get = _asyncHooksInterface.asyncHooks === null || _asyncHooksInterface.asyncHooks === void 0 ? void 0 : _asyncHooksInterface.asyncHooks.get()) !== null && _asyncHooks$get !== void 0 ? _asyncHooks$get : defaultHooks : currentHooks;
24
+ let handler = hooks[key];
25
+
26
+ if (typeof handler !== 'function') {
27
+ handler = defaultHooks[key];
28
+ }
29
+
30
+ return handler(...args);
31
+ };
32
+
33
+ hooks[key] = f;
34
+ }
35
+
36
+ const run = (f, implementations) => {
37
+ try {
38
+ currentHooks = implementations || defaultHooks;
39
+ _asyncHooksInterface.asyncHooks === null || _asyncHooksInterface.asyncHooks === void 0 ? void 0 : _asyncHooksInterface.asyncHooks.set(currentHooks);
40
+ return f();
41
+ } finally {
42
+ currentHooks = defaultHooks;
43
+ }
44
+ };
45
+
46
+ return {
47
+ run,
48
+ hooks
49
+ };
50
+ };
51
+
52
+ exports.createHooks = createHooks;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _pipeline = require("./pipeline");
8
+
9
+ Object.keys(_pipeline).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _pipeline[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _pipeline[key];
16
+ }
17
+ });
18
+ });
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createAsyncPipeline = void 0;
7
+ Object.defineProperty(exports, "createContainer", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _context.createContainer;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "createContext", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _context.createContext;
17
+ }
18
+ });
19
+ exports.isPipeline = exports.createPipeline = void 0;
20
+ Object.defineProperty(exports, "runWithContainer", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _context.runWithContainer;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "useContainer", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _context.useContainer;
30
+ }
31
+ });
32
+
33
+ var _context = require("./context");
34
+
35
+ var _counter = require("./counter");
36
+
37
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
38
+
39
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
40
+
41
+ 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; }
42
+
43
+ const isPipeline = input => Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
44
+
45
+ exports.isPipeline = isPipeline;
46
+ const PipelineSymbol = Symbol('pipeline');
47
+
48
+ const getMiddleware = input => {
49
+ if (typeof input === 'function') {
50
+ return input;
51
+ } else if (input && typeof input.middleware === 'function') {
52
+ return input.middleware;
53
+ }
54
+
55
+ throw new Error(`${input} is not a Middleware`);
56
+ };
57
+
58
+ const createPipeline = options => {
59
+ const config = _objectSpread({}, options);
60
+
61
+ const middlewares = [];
62
+
63
+ const use = (...inputs) => {
64
+ middlewares.push(...inputs.map(getMiddleware));
65
+ return pipeline;
66
+ };
67
+
68
+ const createCurrentCounter = (hooks, onLast, onLastWithContext) => {
69
+ return (0, _counter.createCounter)((index, input, next) => {
70
+ if (index >= middlewares.length) {
71
+ if (onLast) {
72
+ if (onLastWithContext) {
73
+ return (0, _context.runHooks)(() => onLast(input), hooks);
74
+ }
75
+
76
+ return onLast(input);
77
+ }
78
+
79
+ throw new Error(`Expect returning a value, but all middlewares just calling next()`);
80
+ }
81
+
82
+ return (0, _context.runHooks)(() => middlewares[index](input, next), hooks);
83
+ });
84
+ };
85
+
86
+ const currentContainer = (0, _context.createContainer)(config.contexts);
87
+ const currentHooks = (0, _context.fromContainer)(currentContainer);
88
+ const currentCounter = createCurrentCounter(currentHooks);
89
+
90
+ const getCounter = options => {
91
+ if (!options) {
92
+ return currentCounter;
93
+ }
94
+
95
+ if (options !== null && options !== void 0 && options.container) {
96
+ const hooks = (0, _context.fromContainer)(options === null || options === void 0 ? void 0 : options.container);
97
+ return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(hooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(hooks);
98
+ }
99
+
100
+ return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(currentHooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(currentHooks);
101
+ };
102
+
103
+ const run = (input, options) => getCounter(options).start(input);
104
+
105
+ const middleware = (input, next) => {
106
+ const container = (0, _context.useContainer)();
107
+ return run(input, {
108
+ container,
109
+ onLast: next
110
+ });
111
+ };
112
+
113
+ const pipeline = {
114
+ [PipelineSymbol]: true,
115
+ use,
116
+ run,
117
+ middleware
118
+ };
119
+ return pipeline;
120
+ };
121
+
122
+ exports.createPipeline = createPipeline;
123
+
124
+ const createAsyncPipeline = options => {
125
+ const pipeline = createPipeline(options);
126
+ return _objectSpread({}, pipeline);
127
+ };
128
+
129
+ exports.createAsyncPipeline = createAsyncPipeline;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _farrowPipeline = require("farrow-pipeline");
7
+ var _farrowPipeline = require("./farrow-pipeline");
8
8
 
9
9
  Object.keys(_farrowPipeline).forEach(function (key) {
10
10
  if (key === "default" || key === "__esModule") return;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createAsyncManager = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  var _sync = require("./sync");
11
11
 
@@ -52,12 +52,12 @@ const createAsyncManager = (hooks, api) => {
52
52
  else if (typeof plugin === 'function') {
53
53
  const options = plugin();
54
54
  addPlugin(createPlugin(options.setup, options));
55
- } // plain plugin options with `setup` param
56
- else if (plugin.setup) {
55
+ } // plain plugin object
56
+ else if ((0, _sync.isObject)(plugin)) {
57
57
  addPlugin(createPlugin(plugin.setup, plugin));
58
58
  } // unknown plugin
59
59
  else {
60
- console.warn(`Unknown plugin: ${plugin.name || ''}`);
60
+ console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
61
61
  }
62
62
  }
63
63
 
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useRunner = exports.RunnerContext = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  const RunnerContext = (0, _farrowPipeline.createContext)(null);
11
11
  exports.RunnerContext = RunnerContext;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isObject = exports.hasOwnProperty = exports.generateRunner = exports.createManager = exports.closeHooksMap = exports.cloneHook = exports.DEFAULT_OPTIONS = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  var _waterfall = require("../waterfall");
11
11
 
@@ -64,12 +64,12 @@ const createManager = (hooks, api) => {
64
64
  else if (typeof plugin === 'function') {
65
65
  const options = plugin();
66
66
  addPlugin(createPlugin(options.setup, options));
67
- } // plain plugin options with `setup` param
68
- else if (plugin.setup) {
67
+ } // plain plugin object
68
+ else if (isObject(plugin)) {
69
69
  addPlugin(createPlugin(plugin.setup, plugin));
70
70
  } // unknown plugin
71
71
  else {
72
- console.warn(`Unknown plugin: ${plugin.name || ''}`);
72
+ console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
73
73
  }
74
74
  }
75
75
 
@@ -192,8 +192,7 @@ const cloneHook = hook => {
192
192
 
193
193
  if ((0, _farrowPipeline.isPipeline)(hook)) {
194
194
  return (0, _farrowPipeline.createPipeline)();
195
- } // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
196
-
195
+ }
197
196
 
198
197
  throw new Error(`Unknown hook: ${hook}`);
199
198
  };
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isAsyncWaterfall = exports.getAsyncBrook = exports.createAsyncWaterfall = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
11
 
@@ -20,8 +20,7 @@ const getAsyncBrook = input => {
20
20
  return input;
21
21
  } else if (input && typeof input.middleware === 'function') {
22
22
  return input.middleware;
23
- } // eslint-disable-next-line @typescript-eslint/no-base-to-string,@typescript-eslint/restrict-template-expressions
24
-
23
+ }
25
24
 
26
25
  throw new Error(`${input} is not a AsyncBrook or { brook: AsyncBrook }`);
27
26
  };
@@ -36,15 +35,12 @@ const createAsyncWaterfall = () => {
36
35
  return waterfall;
37
36
  };
38
37
 
39
- const run = (input, options) => // eslint-disable-next-line @typescript-eslint/no-shadow
40
- pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
38
+ const run = (input, options) => pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
41
39
  onLast: input => input
42
40
  }));
43
41
 
44
42
  const middleware = input => {
45
- // eslint-disable-next-line react-hooks/rules-of-hooks
46
- const container = (0, _farrowPipeline.useContainer)(); // eslint-disable-next-line @typescript-eslint/no-shadow
47
-
43
+ const container = (0, _farrowPipeline.useContainer)();
48
44
  return pipeline.run(input, {
49
45
  container,
50
46
  onLast: input => input
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isWaterfall = exports.getBrook = exports.createWaterfall = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
11
 
@@ -20,8 +20,7 @@ const getBrook = input => {
20
20
  return input;
21
21
  } else if (input && typeof input.middleware === 'function') {
22
22
  return input.middleware;
23
- } // eslint-disable-next-line @typescript-eslint/no-base-to-string,@typescript-eslint/restrict-template-expressions
24
-
23
+ }
25
24
 
26
25
  throw new Error(`${input} is not a Brook or { brook: Brook }`);
27
26
  };
@@ -36,15 +35,12 @@ const createWaterfall = () => {
36
35
  return waterfall;
37
36
  };
38
37
 
39
- const run = (input, options) => // eslint-disable-next-line @typescript-eslint/no-shadow
40
- pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
38
+ const run = (input, options) => pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
41
39
  onLast: input => input
42
40
  }));
43
41
 
44
42
  const middleware = input => {
45
- // eslint-disable-next-line react-hooks/rules-of-hooks
46
- const container = (0, _farrowPipeline.useContainer)(); // eslint-disable-next-line @typescript-eslint/no-shadow
47
-
43
+ const container = (0, _farrowPipeline.useContainer)();
48
44
  return pipeline.run(input, {
49
45
  container,
50
46
  onLast: input => input
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isAsyncWorkflow = exports.createAsyncWorkflow = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
11
 
@@ -33,7 +33,6 @@ const createAsyncWorkflow = () => {
33
33
  }));
34
34
 
35
35
  if (isPromise(result)) {
36
- // eslint-disable-next-line @typescript-eslint/no-shadow,promise/prefer-await-to-then
37
36
  return result.then(result => result.filter(Boolean));
38
37
  } else {
39
38
  return result.filter(Boolean);
@@ -54,7 +53,5 @@ exports.createAsyncWorkflow = createAsyncWorkflow;
54
53
  const mapAsyncWorkerToAsyncMiddleware = worker => async (input, next) => [await worker(input), ...(await next(input))];
55
54
 
56
55
  function isPromise(obj) {
57
- /* eslint-disable promise/prefer-await-to-then */
58
56
  return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
59
- /* eslint-enable promise/prefer-await-to-then */
60
57
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isParallelWorkflow = exports.createParallelWorkflow = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
11
 
@@ -27,8 +27,7 @@ const createParallelWorkflow = () => {
27
27
  return workflow;
28
28
  };
29
29
 
30
- const run = async (input, options) => // eslint-disable-next-line promise/prefer-await-to-then
31
- Promise.all(pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
30
+ const run = async (input, options) => Promise.all(pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
32
31
  onLast: () => []
33
32
  }))).then(result => result.filter(Boolean));
34
33
 
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isWorkflow = exports.createWorkflow = void 0;
7
7
 
8
- var _farrowPipeline = require("farrow-pipeline");
8
+ var _farrowPipeline = require("../farrow-pipeline");
9
9
 
10
10
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
11