@modern-js/plugin 1.3.8 → 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.
- package/CHANGELOG.md +6 -0
- package/dist/js/modern/farrow-pipeline/context.js +14 -75
- package/dist/js/modern/farrow-pipeline/index.js +0 -14
- package/dist/js/modern/farrow-pipeline/pipeline.js +12 -29
- package/dist/js/modern/manager/async.js +4 -11
- package/dist/js/modern/manager/runner.js +1 -9
- package/dist/js/modern/manager/sync.js +8 -16
- package/dist/js/modern/waterfall/async.js +1 -3
- package/dist/js/modern/waterfall/sync.js +1 -3
- package/dist/js/modern/workflow/async.js +3 -3
- package/dist/js/modern/workflow/parallel.js +2 -2
- package/dist/js/modern/workflow/sync.js +3 -3
- package/dist/js/node/farrow-pipeline/context.js +15 -88
- package/dist/js/node/farrow-pipeline/pipeline.js +10 -45
- package/dist/js/node/manager/async.js +4 -12
- package/dist/js/node/manager/runner.js +1 -9
- package/dist/js/node/manager/sync.js +8 -15
- package/dist/js/node/waterfall/async.js +0 -2
- package/dist/js/node/waterfall/sync.js +0 -2
- package/dist/js/node/workflow/async.js +3 -3
- package/dist/js/node/workflow/parallel.js +2 -2
- package/dist/js/node/workflow/sync.js +3 -3
- package/dist/js/treeshaking/farrow-pipeline/context.js +14 -75
- package/dist/js/treeshaking/farrow-pipeline/index.js +0 -14
- package/dist/js/treeshaking/farrow-pipeline/pipeline.js +10 -29
- package/dist/js/treeshaking/manager/async.js +10 -17
- package/dist/js/treeshaking/manager/runner.js +1 -7
- package/dist/js/treeshaking/manager/sync.js +9 -17
- package/dist/js/treeshaking/waterfall/async.js +1 -3
- package/dist/js/treeshaking/waterfall/sync.js +1 -3
- package/dist/js/treeshaking/workflow/async.js +6 -6
- package/dist/js/treeshaking/workflow/parallel.js +5 -5
- package/dist/js/treeshaking/workflow/sync.js +3 -3
- package/dist/types/farrow-pipeline/context.d.ts +5 -20
- package/dist/types/farrow-pipeline/index.d.ts +0 -14
- package/dist/types/farrow-pipeline/pipeline.d.ts +5 -14
- package/dist/types/manager/async.d.ts +4 -7
- package/dist/types/manager/runner.d.ts +0 -1
- package/dist/types/manager/sync.d.ts +5 -9
- package/dist/types/manager/types.d.ts +1 -6
- package/dist/types/waterfall/async.d.ts +1 -7
- package/dist/types/waterfall/sync.d.ts +0 -7
- package/dist/types/workflow/async.d.ts +1 -7
- package/dist/types/workflow/parallel.d.ts +2 -9
- package/dist/types/workflow/sync.d.ts +1 -10
- package/package.json +1 -12
- package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +0 -80
- package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +0 -12
- package/dist/js/modern/farrow-pipeline/hook.js +0 -42
- package/dist/js/node/farrow-pipeline/asyncHooks.node.js +0 -100
- package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +0 -26
- package/dist/js/node/farrow-pipeline/hook.js +0 -52
- package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +0 -80
- package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +0 -12
- package/dist/js/treeshaking/farrow-pipeline/hook.js +0 -46
- package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +0 -2
- package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +0 -19
- package/dist/types/farrow-pipeline/hook.d.ts +0 -9
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.createAsyncManager = void 0;
|
7
7
|
|
8
|
-
var _farrowPipeline = require("../farrow-pipeline");
|
9
|
-
|
10
8
|
var _sync = require("./sync");
|
11
9
|
|
12
10
|
var _runner = require("./runner");
|
@@ -92,23 +90,17 @@ const createAsyncManager = (hooks, api) => {
|
|
92
90
|
plugins = [];
|
93
91
|
};
|
94
92
|
|
95
|
-
const
|
96
|
-
|
97
|
-
const init = async options => {
|
98
|
-
const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
93
|
+
const init = async () => {
|
99
94
|
const sortedPlugins = (0, _shared.sortPlugins)(plugins);
|
100
95
|
|
101
96
|
const mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
|
102
97
|
|
103
98
|
(0, _shared.checkPlugins)(sortedPlugins);
|
104
|
-
const hooksList = await Promise.all(sortedPlugins.map(plugin =>
|
105
|
-
return (0, _sync.generateRunner)(hooksList,
|
99
|
+
const hooksList = await Promise.all(sortedPlugins.map(plugin => plugin.setup(mergedPluginAPI)));
|
100
|
+
return (0, _sync.generateRunner)(hooksList, currentHooks);
|
106
101
|
};
|
107
102
|
|
108
|
-
const run =
|
109
|
-
const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
110
|
-
return (0, _farrowPipeline.runWithContainer)(cb, container);
|
111
|
-
};
|
103
|
+
const run = cb => cb();
|
112
104
|
|
113
105
|
const manager = {
|
114
106
|
createPlugin,
|
@@ -10,14 +10,6 @@ var _farrowPipeline = require("../farrow-pipeline");
|
|
10
10
|
const RunnerContext = (0, _farrowPipeline.createContext)(null);
|
11
11
|
exports.RunnerContext = RunnerContext;
|
12
12
|
|
13
|
-
const useRunner = () =>
|
14
|
-
const runner = RunnerContext.use().value;
|
15
|
-
|
16
|
-
if (!runner) {
|
17
|
-
throw new Error(`Can't call useRunner out of scope, it should be placed in hooks of plugin`);
|
18
|
-
}
|
19
|
-
|
20
|
-
return runner;
|
21
|
-
};
|
13
|
+
const useRunner = () => RunnerContext.get();
|
22
14
|
|
23
15
|
exports.useRunner = useRunner;
|
@@ -103,23 +103,17 @@ const createManager = (hooks, api) => {
|
|
103
103
|
plugins = [];
|
104
104
|
};
|
105
105
|
|
106
|
-
const
|
107
|
-
|
108
|
-
const init = options => {
|
109
|
-
const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
106
|
+
const init = () => {
|
110
107
|
const sortedPlugins = (0, _shared.sortPlugins)(plugins);
|
111
108
|
|
112
109
|
const mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
|
113
110
|
|
114
111
|
(0, _shared.checkPlugins)(sortedPlugins);
|
115
|
-
const hooksList = sortedPlugins.map(plugin =>
|
116
|
-
return generateRunner(hooksList,
|
112
|
+
const hooksList = sortedPlugins.map(plugin => plugin.setup(mergedPluginAPI));
|
113
|
+
return generateRunner(hooksList, currentHooks);
|
117
114
|
};
|
118
115
|
|
119
|
-
const run =
|
120
|
-
const container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
121
|
-
return (0, _farrowPipeline.runWithContainer)(cb, container);
|
122
|
-
};
|
116
|
+
const run = cb => cb();
|
123
117
|
|
124
118
|
const manager = {
|
125
119
|
createPlugin,
|
@@ -140,7 +134,7 @@ const createManager = (hooks, api) => {
|
|
140
134
|
|
141
135
|
exports.createManager = createManager;
|
142
136
|
|
143
|
-
const generateRunner = (hooksList,
|
137
|
+
const generateRunner = (hooksList, hooksMap) => {
|
144
138
|
const runner = {};
|
145
139
|
const cloneShape = closeHooksMap(hooksMap);
|
146
140
|
|
@@ -158,13 +152,12 @@ const generateRunner = (hooksList, container, hooksMap) => {
|
|
158
152
|
// @ts-expect-error
|
159
153
|
|
160
154
|
|
161
|
-
runner[key] = (input, options) => cloneShape[key].run(input, _objectSpread({
|
162
|
-
container
|
163
|
-
}, options));
|
155
|
+
runner[key] = (input, options) => cloneShape[key].run(input, _objectSpread({}, options));
|
164
156
|
}
|
165
157
|
}
|
166
158
|
|
167
|
-
|
159
|
+
_runner.RunnerContext.set(runner);
|
160
|
+
|
168
161
|
return runner;
|
169
162
|
};
|
170
163
|
|
@@ -27,10 +27,10 @@ const createAsyncWorkflow = () => {
|
|
27
27
|
return workflow;
|
28
28
|
};
|
29
29
|
|
30
|
-
const run = async
|
31
|
-
const result = pipeline.run(input,
|
30
|
+
const run = async input => {
|
31
|
+
const result = pipeline.run(input, {
|
32
32
|
onLast: () => []
|
33
|
-
})
|
33
|
+
});
|
34
34
|
|
35
35
|
if (isPromise(result)) {
|
36
36
|
return result.then(result => result.filter(Boolean));
|
@@ -27,9 +27,9 @@ const createParallelWorkflow = () => {
|
|
27
27
|
return workflow;
|
28
28
|
};
|
29
29
|
|
30
|
-
const run = async
|
30
|
+
const run = async input => Promise.all(pipeline.run(input, {
|
31
31
|
onLast: () => []
|
32
|
-
}))
|
32
|
+
})).then(result => result.filter(Boolean));
|
33
33
|
|
34
34
|
const workflow = _objectSpread(_objectSpread({}, pipeline), {}, {
|
35
35
|
run,
|
@@ -23,10 +23,10 @@ const createWorkflow = () => {
|
|
23
23
|
return workflow;
|
24
24
|
};
|
25
25
|
|
26
|
-
const run =
|
27
|
-
const result = pipeline.run(input,
|
26
|
+
const run = input => {
|
27
|
+
const result = pipeline.run(input, {
|
28
28
|
onLast: () => []
|
29
|
-
})
|
29
|
+
});
|
30
30
|
return result.filter(Boolean);
|
31
31
|
};
|
32
32
|
|
@@ -1,103 +1,42 @@
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
-
|
3
1
|
/**
|
4
2
|
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
5
3
|
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
6
4
|
*/
|
7
|
-
import { createHooks } from "./hook";
|
8
|
-
var ContextSymbol = Symbol["for"]('MODERN_CONTEXT');
|
9
5
|
export var createContext = function createContext(value) {
|
10
|
-
var
|
6
|
+
var currentValue;
|
11
7
|
|
12
8
|
var create = function create(value) {
|
13
|
-
|
9
|
+
currentValue = value;
|
14
10
|
|
15
11
|
var use = function use() {
|
16
|
-
|
17
|
-
return Object.seal({
|
12
|
+
return {
|
18
13
|
get value() {
|
19
|
-
return
|
14
|
+
return currentValue;
|
20
15
|
},
|
21
16
|
|
22
17
|
set value(v) {
|
23
|
-
|
18
|
+
currentValue = v;
|
24
19
|
}
|
25
20
|
|
26
|
-
}
|
21
|
+
};
|
27
22
|
};
|
28
23
|
|
29
24
|
var get = function get() {
|
30
|
-
|
31
|
-
return container.read(Context);
|
25
|
+
return currentValue;
|
32
26
|
};
|
33
27
|
|
34
28
|
var set = function set(v) {
|
35
|
-
|
36
|
-
container.write(Context, v);
|
29
|
+
currentValue = v;
|
37
30
|
};
|
38
31
|
|
39
|
-
var Context =
|
40
|
-
|
41
|
-
|
32
|
+
var Context = {
|
33
|
+
create: create,
|
34
|
+
use: use,
|
35
|
+
get: get,
|
36
|
+
set: set
|
37
|
+
};
|
42
38
|
return Context;
|
43
39
|
};
|
44
40
|
|
45
41
|
return create(value);
|
46
|
-
};
|
47
|
-
|
48
|
-
var createContextMap = function createContextMap(storage) {
|
49
|
-
var contextMap = new Map();
|
50
|
-
var contexts = Object.values(storage); // eslint-disable-next-line @typescript-eslint/prefer-for-of
|
51
|
-
|
52
|
-
for (var i = 0; i < contexts.length; i++) {
|
53
|
-
contextMap.set(contexts[i].id, contexts[i]);
|
54
|
-
}
|
55
|
-
|
56
|
-
return contextMap;
|
57
|
-
};
|
58
|
-
|
59
|
-
export var createContainer = function createContainer() {
|
60
|
-
var ContextStorage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
61
|
-
var contextMap = createContextMap(ContextStorage);
|
62
|
-
|
63
|
-
var read = function read(context) {
|
64
|
-
var target = contextMap.get(context.id);
|
65
|
-
|
66
|
-
if (target) {
|
67
|
-
return target[ContextSymbol];
|
68
|
-
}
|
69
|
-
|
70
|
-
return context[ContextSymbol];
|
71
|
-
};
|
72
|
-
|
73
|
-
var write = function write(context, value) {
|
74
|
-
contextMap.set(context.id, context.create(value));
|
75
|
-
};
|
76
|
-
|
77
|
-
return Object.freeze({
|
78
|
-
read: read,
|
79
|
-
write: write
|
80
|
-
});
|
81
|
-
};
|
82
|
-
|
83
|
-
var _createHooks = createHooks({
|
84
|
-
useContainer: function useContainer() {
|
85
|
-
throw new Error("Can't call useContainer out of scope, it should be placed on top of the function");
|
86
|
-
}
|
87
|
-
}),
|
88
|
-
run = _createHooks.run,
|
89
|
-
hooks = _createHooks.hooks;
|
90
|
-
|
91
|
-
export var runHooks = run;
|
92
|
-
var useContainer = hooks.useContainer;
|
93
|
-
export { useContainer };
|
94
|
-
export var fromContainer = function fromContainer(container) {
|
95
|
-
return {
|
96
|
-
useContainer: function useContainer() {
|
97
|
-
return container;
|
98
|
-
}
|
99
|
-
};
|
100
|
-
};
|
101
|
-
export var runWithContainer = function runWithContainer(f, container) {
|
102
|
-
return runHooks(f, fromContainer(container));
|
103
42
|
};
|
@@ -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";
|
@@ -1,14 +1,14 @@
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
4
|
|
5
5
|
/**
|
6
6
|
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
7
7
|
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
8
8
|
*/
|
9
|
-
import { createContext
|
9
|
+
import { createContext } from "./context";
|
10
10
|
import { createCounter } from "./counter";
|
11
|
-
export { createContext
|
11
|
+
export { createContext };
|
12
12
|
export var isPipeline = function isPipeline(input) {
|
13
13
|
return Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
|
14
14
|
};
|
@@ -24,11 +24,9 @@ var getMiddleware = function getMiddleware(input) {
|
|
24
24
|
throw new Error("".concat(input, " is not a Middleware"));
|
25
25
|
};
|
26
26
|
|
27
|
-
export var createPipeline = function createPipeline(
|
27
|
+
export var createPipeline = function createPipeline() {
|
28
28
|
var _pipeline;
|
29
29
|
|
30
|
-
var config = _objectSpread({}, options);
|
31
|
-
|
32
30
|
var middlewares = [];
|
33
31
|
|
34
32
|
var use = function use() {
|
@@ -40,43 +38,28 @@ export var createPipeline = function createPipeline(options) {
|
|
40
38
|
return pipeline;
|
41
39
|
};
|
42
40
|
|
43
|
-
var createCurrentCounter = function createCurrentCounter(
|
41
|
+
var createCurrentCounter = function createCurrentCounter(onLast) {
|
44
42
|
return createCounter(function (index, input, next) {
|
45
43
|
if (index >= middlewares.length) {
|
46
44
|
if (onLast) {
|
47
|
-
if (onLastWithContext) {
|
48
|
-
return runHooks(function () {
|
49
|
-
return onLast(input);
|
50
|
-
}, hooks);
|
51
|
-
}
|
52
|
-
|
53
45
|
return onLast(input);
|
54
46
|
}
|
55
47
|
|
56
48
|
throw new Error("Expect returning a value, but all middlewares just calling next()");
|
57
49
|
}
|
58
50
|
|
59
|
-
return
|
60
|
-
return middlewares[index](input, next);
|
61
|
-
}, hooks);
|
51
|
+
return middlewares[index](input, next);
|
62
52
|
});
|
63
53
|
};
|
64
54
|
|
65
|
-
var
|
66
|
-
var currentHooks = fromContainer(currentContainer);
|
67
|
-
var currentCounter = createCurrentCounter(currentHooks);
|
55
|
+
var currentCounter = createCurrentCounter();
|
68
56
|
|
69
57
|
var getCounter = function getCounter(options) {
|
70
58
|
if (!options) {
|
71
59
|
return currentCounter;
|
72
60
|
}
|
73
61
|
|
74
|
-
|
75
|
-
var hooks = fromContainer(options === null || options === void 0 ? void 0 : options.container);
|
76
|
-
return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(hooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(hooks);
|
77
|
-
}
|
78
|
-
|
79
|
-
return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(currentHooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(currentHooks);
|
62
|
+
return createCurrentCounter(options === null || options === void 0 ? void 0 : options.onLast);
|
80
63
|
};
|
81
64
|
|
82
65
|
var run = function run(input, options) {
|
@@ -84,9 +67,7 @@ export var createPipeline = function createPipeline(options) {
|
|
84
67
|
};
|
85
68
|
|
86
69
|
var middleware = function middleware(input, next) {
|
87
|
-
var container = useContainer();
|
88
70
|
return run(input, {
|
89
|
-
container: container,
|
90
71
|
onLast: next
|
91
72
|
});
|
92
73
|
};
|
@@ -94,7 +75,7 @@ export var createPipeline = function createPipeline(options) {
|
|
94
75
|
var pipeline = (_pipeline = {}, _defineProperty(_pipeline, PipelineSymbol, true), _defineProperty(_pipeline, "use", use), _defineProperty(_pipeline, "run", run), _defineProperty(_pipeline, "middleware", middleware), _pipeline);
|
95
76
|
return pipeline;
|
96
77
|
};
|
97
|
-
export var createAsyncPipeline = function createAsyncPipeline(
|
98
|
-
var pipeline = createPipeline(
|
78
|
+
export var createAsyncPipeline = function createAsyncPipeline() {
|
79
|
+
var pipeline = createPipeline();
|
99
80
|
return _objectSpread({}, pipeline);
|
100
81
|
};
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
-
import { runWithContainer, createContainer } from "../farrow-pipeline";
|
5
4
|
import { generateRunner, DEFAULT_OPTIONS } from "./sync";
|
6
5
|
import { useRunner } from "./runner";
|
7
6
|
import { checkPlugins, isObject, hasOwnProperty, sortPlugins, includePlugin } from "./shared";
|
@@ -88,31 +87,26 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
|
|
88
87
|
plugins = [];
|
89
88
|
};
|
90
89
|
|
91
|
-
var currentContainer = createContainer();
|
92
|
-
|
93
90
|
var init = /*#__PURE__*/function () {
|
94
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
95
|
-
var
|
91
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
92
|
+
var sortedPlugins, mergedPluginAPI, hooksList;
|
96
93
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
97
94
|
while (1) {
|
98
95
|
switch (_context.prev = _context.next) {
|
99
96
|
case 0:
|
100
|
-
container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
101
97
|
sortedPlugins = sortPlugins(plugins);
|
102
98
|
mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
|
103
99
|
checkPlugins(sortedPlugins);
|
104
|
-
_context.next =
|
100
|
+
_context.next = 5;
|
105
101
|
return Promise.all(sortedPlugins.map(function (plugin) {
|
106
|
-
return
|
107
|
-
return plugin.setup(mergedPluginAPI);
|
108
|
-
}, container);
|
102
|
+
return plugin.setup(mergedPluginAPI);
|
109
103
|
}));
|
110
104
|
|
111
|
-
case
|
105
|
+
case 5:
|
112
106
|
hooksList = _context.sent;
|
113
|
-
return _context.abrupt("return", generateRunner(hooksList,
|
107
|
+
return _context.abrupt("return", generateRunner(hooksList, currentHooks));
|
114
108
|
|
115
|
-
case
|
109
|
+
case 7:
|
116
110
|
case "end":
|
117
111
|
return _context.stop();
|
118
112
|
}
|
@@ -120,14 +114,13 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
|
|
120
114
|
}, _callee);
|
121
115
|
}));
|
122
116
|
|
123
|
-
return function init(
|
117
|
+
return function init() {
|
124
118
|
return _ref.apply(this, arguments);
|
125
119
|
};
|
126
120
|
}();
|
127
121
|
|
128
|
-
var run = function run(cb
|
129
|
-
|
130
|
-
return runWithContainer(cb, container);
|
122
|
+
var run = function run(cb) {
|
123
|
+
return cb();
|
131
124
|
};
|
132
125
|
|
133
126
|
var manager = {
|
@@ -1,11 +1,5 @@
|
|
1
1
|
import { createContext } from "../farrow-pipeline";
|
2
2
|
export var RunnerContext = createContext(null);
|
3
3
|
export var useRunner = function useRunner() {
|
4
|
-
|
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;
|
4
|
+
return RunnerContext.get();
|
11
5
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
-
import { isPipeline, createPipeline
|
3
|
+
import { isPipeline, createPipeline } from "../farrow-pipeline";
|
4
4
|
import { isWaterfall, createWaterfall, isAsyncWaterfall, createAsyncWaterfall } from "../waterfall";
|
5
5
|
import { isWorkflow, createWorkflow, isAsyncWorkflow, createAsyncWorkflow, isParallelWorkflow, createParallelWorkflow } from "../workflow";
|
6
6
|
import { RunnerContext, useRunner } from "./runner";
|
@@ -94,26 +94,20 @@ export var createManager = function createManager(hooks, api) {
|
|
94
94
|
plugins = [];
|
95
95
|
};
|
96
96
|
|
97
|
-
var
|
98
|
-
|
99
|
-
var init = function init(options) {
|
100
|
-
var container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
97
|
+
var init = function init() {
|
101
98
|
var sortedPlugins = sortPlugins(plugins);
|
102
99
|
|
103
100
|
var mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
|
104
101
|
|
105
102
|
checkPlugins(sortedPlugins);
|
106
103
|
var hooksList = sortedPlugins.map(function (plugin) {
|
107
|
-
return
|
108
|
-
return plugin.setup(mergedPluginAPI);
|
109
|
-
}, container);
|
104
|
+
return plugin.setup(mergedPluginAPI);
|
110
105
|
});
|
111
|
-
return generateRunner(hooksList,
|
106
|
+
return generateRunner(hooksList, currentHooks);
|
112
107
|
};
|
113
108
|
|
114
|
-
var run = function run(cb
|
115
|
-
|
116
|
-
return runWithContainer(cb, container);
|
109
|
+
var run = function run(cb) {
|
110
|
+
return cb();
|
117
111
|
};
|
118
112
|
|
119
113
|
var manager = {
|
@@ -132,7 +126,7 @@ export var createManager = function createManager(hooks, api) {
|
|
132
126
|
|
133
127
|
return clone();
|
134
128
|
};
|
135
|
-
export var generateRunner = function generateRunner(hooksList,
|
129
|
+
export var generateRunner = function generateRunner(hooksList, hooksMap) {
|
136
130
|
var runner = {};
|
137
131
|
var cloneShape = closeHooksMap(hooksMap);
|
138
132
|
|
@@ -162,9 +156,7 @@ export var generateRunner = function generateRunner(hooksList, container, hooksM
|
|
162
156
|
}
|
163
157
|
|
164
158
|
runner[key] = function (input, options) {
|
165
|
-
return cloneShape[key].run(input, _objectSpread({
|
166
|
-
container: container
|
167
|
-
}, options));
|
159
|
+
return cloneShape[key].run(input, _objectSpread({}, options));
|
168
160
|
};
|
169
161
|
};
|
170
162
|
|
@@ -173,7 +165,7 @@ export var generateRunner = function generateRunner(hooksList, container, hooksM
|
|
173
165
|
}
|
174
166
|
}
|
175
167
|
|
176
|
-
|
168
|
+
RunnerContext.set(runner);
|
177
169
|
return runner;
|
178
170
|
};
|
179
171
|
export var cloneHook = function cloneHook(hook) {
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
5
5
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
6
|
-
import { createAsyncPipeline
|
6
|
+
import { createAsyncPipeline } from "../farrow-pipeline";
|
7
7
|
var ASYNC_WATERFALL_SYMBOL = Symbol["for"]('MODERN_ASYNC_WATERFALL');
|
8
8
|
export var getAsyncBrook = function getAsyncBrook(input) {
|
9
9
|
if (typeof input === 'function') {
|
@@ -35,9 +35,7 @@ export var createAsyncWaterfall = function createAsyncWaterfall() {
|
|
35
35
|
};
|
36
36
|
|
37
37
|
var middleware = function middleware(input) {
|
38
|
-
var container = useContainer();
|
39
38
|
return pipeline.run(input, {
|
40
|
-
container: container,
|
41
39
|
onLast: function onLast(input) {
|
42
40
|
return input;
|
43
41
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
4
|
-
import {
|
4
|
+
import { createPipeline } from "../farrow-pipeline";
|
5
5
|
var WATERFALL_SYMBOL = Symbol["for"]('MODERN_WATERFALL');
|
6
6
|
export var getBrook = function getBrook(input) {
|
7
7
|
if (typeof input === 'function') {
|
@@ -33,9 +33,7 @@ export var createWaterfall = function createWaterfall() {
|
|
33
33
|
};
|
34
34
|
|
35
35
|
var middleware = function middleware(input) {
|
36
|
-
var container = useContainer();
|
37
36
|
return pipeline.run(input, {
|
38
|
-
container: container,
|
39
37
|
onLast: function onLast(input) {
|
40
38
|
return input;
|
41
39
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
4
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
5
5
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
6
6
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
7
7
|
import { createAsyncPipeline } from "../farrow-pipeline";
|
@@ -22,17 +22,17 @@ export var createAsyncWorkflow = function createAsyncWorkflow() {
|
|
22
22
|
};
|
23
23
|
|
24
24
|
var run = /*#__PURE__*/function () {
|
25
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input
|
25
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
26
26
|
var result;
|
27
27
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
28
28
|
while (1) {
|
29
29
|
switch (_context.prev = _context.next) {
|
30
30
|
case 0:
|
31
|
-
result = pipeline.run(input,
|
31
|
+
result = pipeline.run(input, {
|
32
32
|
onLast: function onLast() {
|
33
33
|
return [];
|
34
34
|
}
|
35
|
-
})
|
35
|
+
});
|
36
36
|
|
37
37
|
if (!isPromise(result)) {
|
38
38
|
_context.next = 5;
|
@@ -54,7 +54,7 @@ export var createAsyncWorkflow = function createAsyncWorkflow() {
|
|
54
54
|
}, _callee);
|
55
55
|
}));
|
56
56
|
|
57
|
-
return function run(_x
|
57
|
+
return function run(_x) {
|
58
58
|
return _ref.apply(this, arguments);
|
59
59
|
};
|
60
60
|
}();
|
@@ -97,7 +97,7 @@ var mapAsyncWorkerToAsyncMiddleware = function mapAsyncWorkerToAsyncMiddleware(w
|
|
97
97
|
}, _callee2);
|
98
98
|
}));
|
99
99
|
|
100
|
-
return function (
|
100
|
+
return function (_x2, _x3) {
|
101
101
|
return _ref2.apply(this, arguments);
|
102
102
|
};
|
103
103
|
}();
|