@modern-js/plugin 1.3.8 → 1.4.1
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 +8 -12
- package/dist/js/modern/manager/index.js +0 -1
- package/dist/js/modern/manager/sync.js +13 -19
- 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 +10 -16
- package/dist/js/node/manager/index.js +0 -13
- package/dist/js/node/manager/sync.js +16 -23
- 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 +15 -17
- package/dist/js/treeshaking/manager/index.js +0 -1
- package/dist/js/treeshaking/manager/sync.js +16 -20
- 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/index.d.ts +0 -1
- package/dist/types/manager/sync.d.ts +6 -10
- 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/modern/manager/runner.js +0 -11
- 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/node/manager/runner.js +0 -23
- 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/js/treeshaking/manager/runner.js +0 -11
- 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
- package/dist/types/manager/runner.d.ts +0 -3
@@ -1,16 +1,19 @@
|
|
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
|
-
import { useRunner } from "./runner";
|
7
5
|
import { checkPlugins, isObject, hasOwnProperty, sortPlugins, includePlugin } from "./shared";
|
8
6
|
var ASYNC_PLUGIN_SYMBOL = 'ASYNC_PLUGIN_SYMBOL';
|
9
7
|
export var createAsyncManager = function createAsyncManager(hooks, api) {
|
10
8
|
var index = 0;
|
9
|
+
var runners;
|
11
10
|
|
12
11
|
var currentHooks = _objectSpread({}, hooks);
|
13
12
|
|
13
|
+
var useRunner = function useRunner() {
|
14
|
+
return runners;
|
15
|
+
};
|
16
|
+
|
14
17
|
var registerHook = function registerHook(extraHooks) {
|
15
18
|
currentHooks = _objectSpread(_objectSpread({}, extraHooks), currentHooks);
|
16
19
|
};
|
@@ -88,29 +91,25 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
|
|
88
91
|
plugins = [];
|
89
92
|
};
|
90
93
|
|
91
|
-
var currentContainer = createContainer();
|
92
|
-
|
93
94
|
var init = /*#__PURE__*/function () {
|
94
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
95
|
-
var
|
95
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
96
|
+
var sortedPlugins, mergedPluginAPI, hooksList;
|
96
97
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
97
98
|
while (1) {
|
98
99
|
switch (_context.prev = _context.next) {
|
99
100
|
case 0:
|
100
|
-
container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
101
101
|
sortedPlugins = sortPlugins(plugins);
|
102
102
|
mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
|
103
103
|
checkPlugins(sortedPlugins);
|
104
|
-
_context.next =
|
104
|
+
_context.next = 5;
|
105
105
|
return Promise.all(sortedPlugins.map(function (plugin) {
|
106
|
-
return
|
107
|
-
return plugin.setup(mergedPluginAPI);
|
108
|
-
}, container);
|
106
|
+
return plugin.setup(mergedPluginAPI);
|
109
107
|
}));
|
110
108
|
|
111
|
-
case
|
109
|
+
case 5:
|
112
110
|
hooksList = _context.sent;
|
113
|
-
|
111
|
+
runners = generateRunner(hooksList, currentHooks);
|
112
|
+
return _context.abrupt("return", runners);
|
114
113
|
|
115
114
|
case 8:
|
116
115
|
case "end":
|
@@ -120,14 +119,13 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
|
|
120
119
|
}, _callee);
|
121
120
|
}));
|
122
121
|
|
123
|
-
return function init(
|
122
|
+
return function init() {
|
124
123
|
return _ref.apply(this, arguments);
|
125
124
|
};
|
126
125
|
}();
|
127
126
|
|
128
|
-
var run = function run(cb
|
129
|
-
|
130
|
-
return runWithContainer(cb, container);
|
127
|
+
var run = function run(cb) {
|
128
|
+
return cb();
|
131
129
|
};
|
132
130
|
|
133
131
|
var manager = {
|
@@ -1,9 +1,8 @@
|
|
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
|
-
import { RunnerContext, useRunner } from "./runner";
|
7
6
|
import { checkPlugins, hasOwnProperty, includePlugin, isObject, sortPlugins } from "./shared";
|
8
7
|
var SYNC_PLUGIN_SYMBOL = 'SYNC_PLUGIN_SYMBOL';
|
9
8
|
export var DEFAULT_OPTIONS = {
|
@@ -17,9 +16,14 @@ export var DEFAULT_OPTIONS = {
|
|
17
16
|
};
|
18
17
|
export var createManager = function createManager(hooks, api) {
|
19
18
|
var index = 0;
|
19
|
+
var runners;
|
20
20
|
|
21
21
|
var currentHooks = _objectSpread({}, hooks);
|
22
22
|
|
23
|
+
var useRunner = function useRunner() {
|
24
|
+
return runners;
|
25
|
+
};
|
26
|
+
|
23
27
|
var registerHook = function registerHook(extraHooks) {
|
24
28
|
currentHooks = _objectSpread(_objectSpread({}, extraHooks), currentHooks);
|
25
29
|
};
|
@@ -94,26 +98,21 @@ export var createManager = function createManager(hooks, api) {
|
|
94
98
|
plugins = [];
|
95
99
|
};
|
96
100
|
|
97
|
-
var
|
98
|
-
|
99
|
-
var init = function init(options) {
|
100
|
-
var container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
|
101
|
+
var init = function init() {
|
101
102
|
var sortedPlugins = sortPlugins(plugins);
|
102
103
|
|
103
104
|
var mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
|
104
105
|
|
105
106
|
checkPlugins(sortedPlugins);
|
106
107
|
var hooksList = sortedPlugins.map(function (plugin) {
|
107
|
-
return
|
108
|
-
return plugin.setup(mergedPluginAPI);
|
109
|
-
}, container);
|
108
|
+
return plugin.setup(mergedPluginAPI);
|
110
109
|
});
|
111
|
-
|
110
|
+
runners = generateRunner(hooksList, currentHooks);
|
111
|
+
return runners;
|
112
112
|
};
|
113
113
|
|
114
|
-
var run = function run(cb
|
115
|
-
|
116
|
-
return runWithContainer(cb, container);
|
114
|
+
var run = function run(cb) {
|
115
|
+
return cb();
|
117
116
|
};
|
118
117
|
|
119
118
|
var manager = {
|
@@ -132,9 +131,9 @@ export var createManager = function createManager(hooks, api) {
|
|
132
131
|
|
133
132
|
return clone();
|
134
133
|
};
|
135
|
-
export var generateRunner = function generateRunner(hooksList,
|
134
|
+
export var generateRunner = function generateRunner(hooksList, hooksMap) {
|
136
135
|
var runner = {};
|
137
|
-
var cloneShape =
|
136
|
+
var cloneShape = cloneHooksMap(hooksMap);
|
138
137
|
|
139
138
|
if (hooksMap) {
|
140
139
|
var _loop = function _loop(key) {
|
@@ -162,9 +161,7 @@ export var generateRunner = function generateRunner(hooksList, container, hooksM
|
|
162
161
|
}
|
163
162
|
|
164
163
|
runner[key] = function (input, options) {
|
165
|
-
return cloneShape[key].run(input, _objectSpread({
|
166
|
-
container: container
|
167
|
-
}, options));
|
164
|
+
return cloneShape[key].run(input, _objectSpread({}, options));
|
168
165
|
};
|
169
166
|
};
|
170
167
|
|
@@ -173,7 +170,6 @@ export var generateRunner = function generateRunner(hooksList, container, hooksM
|
|
173
170
|
}
|
174
171
|
}
|
175
172
|
|
176
|
-
container.write(RunnerContext, runner);
|
177
173
|
return runner;
|
178
174
|
};
|
179
175
|
export var cloneHook = function cloneHook(hook) {
|
@@ -203,7 +199,7 @@ export var cloneHook = function cloneHook(hook) {
|
|
203
199
|
|
204
200
|
throw new Error("Unknown hook: ".concat(hook));
|
205
201
|
};
|
206
|
-
export var
|
202
|
+
export var cloneHooksMap = function cloneHooksMap(record) {
|
207
203
|
if (!record) {
|
208
204
|
return record;
|
209
205
|
}
|
@@ -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
|
}();
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
3
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
5
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
6
6
|
import { createPipeline } from "../farrow-pipeline";
|
@@ -21,16 +21,16 @@ export var createParallelWorkflow = function createParallelWorkflow() {
|
|
21
21
|
};
|
22
22
|
|
23
23
|
var run = /*#__PURE__*/function () {
|
24
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input
|
24
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
|
25
25
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
26
26
|
while (1) {
|
27
27
|
switch (_context.prev = _context.next) {
|
28
28
|
case 0:
|
29
|
-
return _context.abrupt("return", Promise.all(pipeline.run(input,
|
29
|
+
return _context.abrupt("return", Promise.all(pipeline.run(input, {
|
30
30
|
onLast: function onLast() {
|
31
31
|
return [];
|
32
32
|
}
|
33
|
-
}))
|
33
|
+
})).then(function (result) {
|
34
34
|
return result.filter(Boolean);
|
35
35
|
}));
|
36
36
|
|
@@ -42,7 +42,7 @@ export var createParallelWorkflow = function createParallelWorkflow() {
|
|
42
42
|
}, _callee);
|
43
43
|
}));
|
44
44
|
|
45
|
-
return function run(_x
|
45
|
+
return function run(_x) {
|
46
46
|
return _ref.apply(this, arguments);
|
47
47
|
};
|
48
48
|
}();
|
@@ -15,12 +15,12 @@ export var createWorkflow = function createWorkflow() {
|
|
15
15
|
return workflow;
|
16
16
|
};
|
17
17
|
|
18
|
-
var run = function run(input
|
19
|
-
var result = pipeline.run(input,
|
18
|
+
var run = function run(input) {
|
19
|
+
var result = pipeline.run(input, {
|
20
20
|
onLast: function onLast() {
|
21
21
|
return [];
|
22
22
|
}
|
23
|
-
})
|
23
|
+
});
|
24
24
|
return result.filter(Boolean);
|
25
25
|
};
|
26
26
|
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
2
5
|
export declare type Context<T = any> = {
|
3
|
-
id: symbol;
|
4
|
-
[ContextSymbol]: T;
|
5
6
|
create: (value: T) => Context<T>;
|
6
7
|
use: () => {
|
7
8
|
value: T;
|
@@ -9,20 +10,4 @@ export declare type Context<T = any> = {
|
|
9
10
|
get: () => T;
|
10
11
|
set: (value: T) => void;
|
11
12
|
};
|
12
|
-
export declare const createContext: <T>(value: T) => Context<T>;
|
13
|
-
export declare type ContextStorage = {
|
14
|
-
[key: string]: Context;
|
15
|
-
};
|
16
|
-
export declare type Container = {
|
17
|
-
read: <V>(Context: Context<V>) => V;
|
18
|
-
write: <V>(Context: Context<V>, value: V) => void;
|
19
|
-
};
|
20
|
-
export declare const createContainer: (ContextStorage?: ContextStorage) => Container;
|
21
|
-
export declare type Hooks = {
|
22
|
-
useContainer: () => Container;
|
23
|
-
};
|
24
|
-
export type { AnyFn } from './asyncHooksInterface';
|
25
|
-
export declare const runHooks: <F extends import("./asyncHooksInterface").AnyFn>(f: F, implementations: Hooks) => ReturnType<F>;
|
26
|
-
export declare const useContainer: () => Container;
|
27
|
-
export declare const fromContainer: (container: Container) => Hooks;
|
28
|
-
export declare const runWithContainer: <F extends (...args: any) => any>(f: F, container: Container) => ReturnType<F>;
|
13
|
+
export declare const createContext: <T>(value: T) => Context<T>;
|
@@ -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';
|
@@ -2,37 +2,28 @@
|
|
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 { createContext,
|
5
|
+
import { createContext, Context } from './context';
|
6
6
|
import { Next } from './counter';
|
7
7
|
export type { Next };
|
8
|
-
export { createContext
|
9
|
-
export type {
|
8
|
+
export { createContext };
|
9
|
+
export type { Context };
|
10
10
|
export declare type Middleware<I = unknown, O = unknown> = (input: I, next: Next<I, O>) => O;
|
11
11
|
export declare type Middlewares<I = unknown, O = unknown> = Middleware<I, O>[];
|
12
12
|
export declare const isPipeline: (input: any) => input is Pipeline<unknown, unknown>;
|
13
13
|
declare const PipelineSymbol: unique symbol;
|
14
|
-
export declare type PipelineOptions = {
|
15
|
-
contexts?: ContextStorage;
|
16
|
-
};
|
17
14
|
export declare type RunPipelineOptions<I = unknown, O = unknown> = {
|
18
|
-
container?: Container;
|
19
15
|
onLast?: (input: I) => O;
|
20
|
-
onLastWithContext?: boolean;
|
21
16
|
};
|
22
17
|
export declare type MiddlewareInput<I = unknown, O = unknown> = Middleware<I, O> | {
|
23
18
|
middleware: Middleware<I, O>;
|
24
19
|
};
|
25
|
-
export declare type MiddlewareType<T extends MiddlewareInput> = T extends MiddlewareInput<infer I, infer O> ? Middleware<I, O> : never;
|
26
20
|
export declare type Pipeline<I = unknown, O = unknown> = {
|
27
21
|
[PipelineSymbol]: true;
|
28
22
|
use: (...inputs: MiddlewareInput<I, O>[]) => Pipeline<I, O>;
|
29
23
|
run: (input: I, options?: RunPipelineOptions<I, O>) => O;
|
30
24
|
middleware: Middleware<I, O>;
|
31
25
|
};
|
32
|
-
export declare const createPipeline: <I, O>(
|
33
|
-
export declare type PipelineInput<T extends Pipeline> = T extends Pipeline<infer I> ? I : never;
|
34
|
-
export declare type PipelineOutput<T extends Pipeline> = T extends Pipeline<any, infer O> ? O : never;
|
26
|
+
export declare const createPipeline: <I, O>() => Pipeline<I, O>;
|
35
27
|
export declare type MaybeAsync<T> = T | Promise<T>;
|
36
|
-
export declare type ThunkMiddlewareInput<I, O> = () => MaybeAsync<MiddlewareInput<I, MaybeAsync<O>>>;
|
37
28
|
export declare type AsyncPipeline<I = unknown, O = unknown> = Pipeline<I, MaybeAsync<O>>;
|
38
|
-
export declare const createAsyncPipeline: <I, O>(
|
29
|
+
export declare const createAsyncPipeline: <I, O>() => AsyncPipeline<I, O>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ToRunners, ToThreads, CommonAPI,
|
1
|
+
import type { ToRunners, ToThreads, CommonAPI, PluginOptions } from './types';
|
2
2
|
/** Setup function of async plugin. */
|
3
3
|
|
4
4
|
export declare type AsyncSetup<Hooks, API = Record<string, never>> = (api: API & CommonAPI<Hooks>) => Partial<ToThreads<Hooks>> | Promise<Partial<ToThreads<Hooks>> | void> | void;
|
@@ -6,7 +6,6 @@ declare const ASYNC_PLUGIN_SYMBOL = "ASYNC_PLUGIN_SYMBOL";
|
|
6
6
|
export declare type AsyncPlugin<Hooks, API> = {
|
7
7
|
ASYNC_PLUGIN_SYMBOL: typeof ASYNC_PLUGIN_SYMBOL;
|
8
8
|
} & Required<PluginOptions<Hooks, AsyncSetup<Hooks, API>>>;
|
9
|
-
export declare type PluginFromAsyncManager<M extends AsyncManager<any, any>> = M extends AsyncManager<infer Hooks, infer API> ? AsyncPlugin<Hooks, API> : never;
|
10
9
|
export declare type AsyncManager<Hooks, API> = {
|
11
10
|
/**
|
12
11
|
* Create a sync plugin.
|
@@ -28,17 +27,15 @@ export declare type AsyncManager<Hooks, API> = {
|
|
28
27
|
usePlugin: (...plugins: Array<AsyncPlugin<Hooks, API> | PluginOptions<Hooks, AsyncSetup<Hooks, API>> | (() => PluginOptions<Hooks, AsyncSetup<Hooks, API>>)>) => AsyncManager<Hooks, API>;
|
29
28
|
/**
|
30
29
|
* Init manager, it will call the setup function of all registered plugins.
|
31
|
-
* @param options passing a custom container.
|
32
30
|
*/
|
33
31
|
|
34
|
-
init: (
|
32
|
+
init: () => Promise<ToRunners<Hooks>>;
|
35
33
|
/**
|
36
|
-
* Run callback function
|
34
|
+
* Run callback function.
|
37
35
|
* @param callback
|
38
|
-
* @param options passing a custom container.
|
39
36
|
*/
|
40
37
|
|
41
|
-
run: <O>(cb: () => O
|
38
|
+
run: <O>(cb: () => O) => O;
|
42
39
|
/**
|
43
40
|
* Register new hooks.
|
44
41
|
* @param newHooks
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import type { Hook, CommonAPI, ToRunners, ToThreads, InitOptions, PluginOptions } from './types';
|
1
|
+
import type { Hook, CommonAPI, ToRunners, ToThreads, PluginOptions } from './types';
|
3
2
|
/** Setup function of sync plugin. */
|
4
3
|
|
5
4
|
export declare type Setup<Hooks, API = Record<string, never>> = (api: API) => Partial<ToThreads<Hooks>> | void;
|
@@ -7,7 +6,6 @@ declare const SYNC_PLUGIN_SYMBOL = "SYNC_PLUGIN_SYMBOL";
|
|
7
6
|
export declare type Plugin<Hooks, API> = {
|
8
7
|
SYNC_PLUGIN_SYMBOL: typeof SYNC_PLUGIN_SYMBOL;
|
9
8
|
} & Required<PluginOptions<Hooks, Setup<Hooks, API>>>;
|
10
|
-
export declare type PluginFromManager<M extends Manager<any, any>> = M extends Manager<infer Hooks, infer API> ? Plugin<Hooks, API> : never;
|
11
9
|
export declare type Manager<Hooks, API> = {
|
12
10
|
/**
|
13
11
|
* Create a sync plugin.
|
@@ -29,17 +27,15 @@ export declare type Manager<Hooks, API> = {
|
|
29
27
|
usePlugin: (...plugins: Array<Plugin<Hooks, API> | PluginOptions<Hooks, Setup<Hooks, API>> | (() => PluginOptions<Hooks, Setup<Hooks, API>>)>) => Manager<Hooks, API>;
|
30
28
|
/**
|
31
29
|
* Init manager, it will call the setup function of all registered plugins.
|
32
|
-
* @param options passing a custom container.
|
33
30
|
*/
|
34
31
|
|
35
|
-
init: (
|
32
|
+
init: () => ToRunners<Hooks>;
|
36
33
|
/**
|
37
|
-
* Run callback function
|
34
|
+
* Run callback function.
|
38
35
|
* @param callback
|
39
|
-
* @param options passing a custom container.
|
40
36
|
*/
|
41
37
|
|
42
|
-
run: <O>(cb: () => O
|
38
|
+
run: <O>(cb: () => O) => O;
|
43
39
|
/**
|
44
40
|
* Register new hooks.
|
45
41
|
* @param newHooks
|
@@ -73,7 +69,7 @@ export declare const DEFAULT_OPTIONS: {
|
|
73
69
|
registerHook: {};
|
74
70
|
};
|
75
71
|
export declare const createManager: <Hooks, API extends Record<string, any> = Record<string, never>>(hooks?: Partial<Hooks> | undefined, api?: API | undefined) => Manager<Hooks, API>;
|
76
|
-
export declare const generateRunner: <Hooks extends Record<string, any>>(hooksList: (void | Partial<ToThreads<Hooks>>)[],
|
72
|
+
export declare const generateRunner: <Hooks extends Record<string, any>>(hooksList: (void | Partial<ToThreads<Hooks>>)[], hooksMap?: Hooks | undefined) => ToRunners<Hooks>;
|
77
73
|
export declare const cloneHook: (hook: Hook) => Hook;
|
78
|
-
export declare const
|
74
|
+
export declare const cloneHooksMap: <Hooks>(record: Hooks) => Hooks;
|
79
75
|
export {};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Pipeline,
|
1
|
+
import type { Pipeline, MaybeAsync, Middleware, AsyncPipeline } from '../farrow-pipeline';
|
2
2
|
import type { Brook, Waterfall, AsyncBrook, AsyncWaterfall } from '../waterfall';
|
3
3
|
import type { Worker, Workflow, AsyncWorker, AsyncWorkflow, ParallelWorkflow } from '../workflow';
|
4
4
|
/** All hook types. */
|
@@ -29,11 +29,6 @@ export declare type PluginOptions<Hooks, Setup = undefined> = {
|
|
29
29
|
usePlugins?: PluginOptions<Hooks, Setup>[];
|
30
30
|
registerHook?: Partial<Hooks>;
|
31
31
|
};
|
32
|
-
/** Options of manager.init method. */
|
33
|
-
|
34
|
-
export declare type InitOptions = {
|
35
|
-
container?: Container;
|
36
|
-
};
|
37
32
|
/** Common api of setup function. */
|
38
33
|
|
39
34
|
export declare type CommonAPI<Hooks> = {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MaybeAsync
|
1
|
+
import { MaybeAsync } from '../farrow-pipeline';
|
2
2
|
declare const ASYNC_WATERFALL_SYMBOL: unique symbol;
|
3
3
|
export declare type AsyncBrook<I = unknown> = (I: I) => MaybeAsync<I>;
|
4
4
|
export declare type AsyncBrookInput<I = unknown> = AsyncBrook<I> | {
|
@@ -8,7 +8,6 @@ export declare type AsyncBrooks<I = unknown> = AsyncBrook<I>[];
|
|
8
8
|
export declare type AsyncBrookInputs<I = unknown> = AsyncBrookInput<I>[];
|
9
9
|
export declare const getAsyncBrook: <I>(input: AsyncBrookInput<I>) => AsyncBrook<I>;
|
10
10
|
export declare type RunAsyncWaterfallOptions<I = unknown> = {
|
11
|
-
container?: Container;
|
12
11
|
onLast?: AsyncBrook<I>;
|
13
12
|
};
|
14
13
|
export declare type AsyncWaterfall<I> = {
|
@@ -17,11 +16,6 @@ export declare type AsyncWaterfall<I> = {
|
|
17
16
|
middleware: AsyncBrook<I>;
|
18
17
|
[ASYNC_WATERFALL_SYMBOL]: true;
|
19
18
|
};
|
20
|
-
export declare type AsyncWaterfall2AsyncBrook<P extends AsyncWaterfall<any>> = P extends AsyncWaterfall<infer I> ? AsyncBrook<I> : never;
|
21
|
-
export declare type AsyncWaterfallRecord = Record<string, AsyncWaterfall<any>>;
|
22
|
-
export declare type AsyncWaterfalls2Brooks<PS extends AsyncWaterfallRecord | void> = { [K in keyof PS]: PS[K] extends AsyncWaterfall<any> ? AsyncWaterfall2AsyncBrook<PS[K]> : PS[K] extends void ? void : never };
|
23
|
-
export declare type RunnerFromAsyncWaterfall<M extends AsyncWaterfall<any>> = M extends AsyncWaterfall<infer VS> ? AsyncWaterfall<VS>['run'] : never;
|
24
|
-
export declare type AsyncWaterfalls2Runners<PS extends AsyncWaterfallRecord | void> = { [K in keyof PS]: PS[K] extends AsyncWaterfall<any> ? RunnerFromAsyncWaterfall<PS[K]> : PS[K] extends void ? void : never };
|
25
19
|
export declare const createAsyncWaterfall: <I = void>() => AsyncWaterfall<I>;
|
26
20
|
export declare const isAsyncWaterfall: (input: any) => input is AsyncWaterfall<any>;
|
27
21
|
export {};
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { Container } from '../farrow-pipeline';
|
2
1
|
declare const WATERFALL_SYMBOL: unique symbol;
|
3
2
|
export declare type Brook<I = unknown> = (I: I) => I;
|
4
3
|
export declare type BrookInput<I = unknown> = Brook<I> | {
|
@@ -8,7 +7,6 @@ export declare type Brooks<I = unknown> = Brook<I>[];
|
|
8
7
|
export declare type BrookInputs<I = unknown> = BrookInput<I>[];
|
9
8
|
export declare const getBrook: <I>(input: BrookInput<I>) => Brook<I>;
|
10
9
|
export declare type RunWaterfallOptions<I = unknown> = {
|
11
|
-
container?: Container;
|
12
10
|
onLast?: Brook<I>;
|
13
11
|
};
|
14
12
|
export declare type Waterfall<I = void> = {
|
@@ -17,11 +15,6 @@ export declare type Waterfall<I = void> = {
|
|
17
15
|
middleware: Brook<I>;
|
18
16
|
[WATERFALL_SYMBOL]: true;
|
19
17
|
};
|
20
|
-
export declare type Waterfall2Brook<P extends Waterfall<any>> = P extends Waterfall<infer I> ? Brook<I> : never;
|
21
|
-
export declare type WaterfallRecord = Record<string, Waterfall<any>>;
|
22
|
-
export declare type Waterfalls2Brooks<PS extends WaterfallRecord | void> = { [K in keyof PS]: PS[K] extends Waterfall<any> ? Waterfall2Brook<PS[K]> : PS[K] extends void ? void : never };
|
23
|
-
export declare type RunnerFromWaterfall<M extends Waterfall<any>> = M extends Waterfall<infer VS> ? Waterfall<VS>['run'] : never;
|
24
|
-
export declare type Waterfalls2Runners<PS extends WaterfallRecord | void> = { [K in keyof PS]: PS[K] extends Waterfall<any> ? RunnerFromWaterfall<PS[K]> : PS[K] extends void ? void : never };
|
25
18
|
export declare const createWaterfall: <I = void>() => Waterfall<I>;
|
26
19
|
export declare const isWaterfall: (input: any) => input is Waterfall<any>;
|
27
20
|
export {};
|
@@ -1,18 +1,12 @@
|
|
1
1
|
import { MaybeAsync } from '../farrow-pipeline';
|
2
|
-
import type { RunWorkflowOptions } from './sync';
|
3
2
|
declare const ASYNC_WORKFLOW_SYMBOL: unique symbol;
|
4
3
|
export declare type AsyncWorker<I, O> = (I: I) => MaybeAsync<O>;
|
5
4
|
export declare type AsyncWorkers<I, O> = AsyncWorker<I, O>[];
|
6
5
|
export declare type AsyncWorkflow<I, O> = {
|
7
|
-
run: (input: I
|
6
|
+
run: (input: I) => MaybeAsync<O[]>;
|
8
7
|
use: (...I: AsyncWorkers<I, O>) => AsyncWorkflow<I, O>;
|
9
8
|
[ASYNC_WORKFLOW_SYMBOL]: true;
|
10
9
|
};
|
11
|
-
export declare type AsyncWorkflow2AsyncWorker<W extends AsyncWorkflow<any, any>> = W extends AsyncWorkflow<infer I, infer O> ? AsyncWorker<I, O> : never;
|
12
|
-
export declare type AsyncWorkflowRecord = Record<string, AsyncWorkflow<any, any>>;
|
13
|
-
export declare type AsyncWorkflows2AsyncWorkers<PS extends AsyncWorkflowRecord | void> = { [K in keyof PS]: PS[K] extends AsyncWorkflow<any, any> ? AsyncWorkflow2AsyncWorker<PS[K]> : PS[K] extends void ? void : never };
|
14
|
-
export declare type RunnerFromAsyncWorkflow<W extends AsyncWorkflow<any, any>> = W extends AsyncWorkflow<infer I, infer O> ? AsyncWorkflow<I, O>['run'] : never;
|
15
|
-
export declare type AsyncWorkflows2Runners<PS extends AsyncWorkflowRecord | void> = { [K in keyof PS]: PS[K] extends AsyncWorkflow<any, any> ? RunnerFromAsyncWorkflow<PS[K]> : PS[K] extends void ? void : never };
|
16
10
|
export declare const isAsyncWorkflow: (input: any) => input is AsyncWorkflow<any, any>;
|
17
11
|
export declare const createAsyncWorkflow: <I = void, O = unknown>() => AsyncWorkflow<I, O>;
|
18
12
|
export {};
|
@@ -1,17 +1,10 @@
|
|
1
|
-
import type {
|
2
|
-
import type { RunWorkflowOptions } from './sync';
|
1
|
+
import type { AsyncWorkers } from './async';
|
3
2
|
declare const PARALLEL_WORKFLOW_SYMBOL: unique symbol;
|
4
3
|
export declare type ParallelWorkflow<I, O = any> = {
|
5
|
-
run: (input: I
|
4
|
+
run: (input: I) => Promise<O[]>;
|
6
5
|
use: (...I: AsyncWorkers<I, O>) => ParallelWorkflow<I, O>;
|
7
6
|
[PARALLEL_WORKFLOW_SYMBOL]: true;
|
8
7
|
};
|
9
|
-
export declare type ParallelWorkflow2Worker<W extends ParallelWorkflow<any>> = W extends ParallelWorkflow<infer CS, infer O> ? AsyncWorker<CS, O> : never;
|
10
|
-
export declare type ParallelWorkflowRecord = Record<string, ParallelWorkflow<any>>;
|
11
|
-
export declare type ParallelWorkflows2Workers<PS extends ParallelWorkflowRecord | void> = { [K in keyof PS]: PS[K] extends ParallelWorkflow<any> ? ParallelWorkflow2Worker<PS[K]> : PS[K] extends void ? void : never };
|
12
|
-
export declare type ParallelWorkflows2AsyncWorkers<PS extends ParallelWorkflowRecord | void> = { [K in keyof PS]: PS[K] extends ParallelWorkflow<any> ? ParallelWorkflow2Worker<PS[K]> : PS[K] extends void ? void : never };
|
13
|
-
export declare type RunnerFromParallelWorkflow<W extends ParallelWorkflow<any>> = W extends ParallelWorkflow<infer CS, infer O> ? ParallelWorkflow<CS, O>['run'] : never;
|
14
|
-
export declare type ParallelWorkflows2Runners<PS extends ParallelWorkflowRecord | void> = { [K in keyof PS]: PS[K] extends ParallelWorkflow<any> ? RunnerFromParallelWorkflow<PS[K]> : PS[K] extends void ? void : never };
|
15
8
|
export declare const isParallelWorkflow: (input: any) => input is ParallelWorkflow<any, any>;
|
16
9
|
export declare const createParallelWorkflow: <I = void, O = unknown>() => ParallelWorkflow<I, O>;
|
17
10
|
export {};
|
@@ -1,20 +1,11 @@
|
|
1
|
-
import { Container } from '../farrow-pipeline';
|
2
1
|
declare const WORKFLOW_SYMBOL: unique symbol;
|
3
2
|
export declare type Worker<I, O> = (I: I) => O;
|
4
3
|
export declare type Workers<I, O> = Worker<I, O>[];
|
5
|
-
export declare type RunWorkflowOptions = {
|
6
|
-
container?: Container;
|
7
|
-
};
|
8
4
|
export declare type Workflow<I, O> = {
|
9
|
-
run: (input: I
|
5
|
+
run: (input: I) => void;
|
10
6
|
use: (...I: Workers<I, O>) => Workflow<I, O>;
|
11
7
|
[WORKFLOW_SYMBOL]: true;
|
12
8
|
};
|
13
|
-
export declare type Workflow2Worker<W extends Workflow<any, any>> = W extends Workflow<infer I, infer O> ? Worker<I, O> : never;
|
14
|
-
export declare type WorkflowRecord = Record<string, Workflow<any, any>>;
|
15
|
-
export declare type Workflows2Workers<PS extends WorkflowRecord | void> = { [K in keyof PS]: PS[K] extends Workflow<any, any> ? Workflow2Worker<PS[K]> : PS[K] extends void ? void : never };
|
16
|
-
export declare type RunnerFromWorkflow<W extends Workflow<any, any>> = W extends Workflow<infer I, infer O> ? Workflow<I, O>['run'] : never;
|
17
|
-
export declare type Workflows2Runners<PS extends WorkflowRecord | void> = { [K in keyof PS]: PS[K] extends Workflow<any, any> ? RunnerFromWorkflow<PS[K]> : PS[K] extends void ? void : never };
|
18
9
|
export declare const createWorkflow: <I = void, O = unknown>() => Workflow<I, O>;
|
19
10
|
export declare const isWorkflow: (input: any) => input is Workflow<unknown, unknown>;
|
20
11
|
export {};
|