@modern-js/plugin 2.0.0-beta.3 → 2.0.0-beta.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.
- package/CHANGELOG.md +14 -0
- package/dist/js/modern/farrow-pipeline/context.js +8 -10
- package/dist/js/modern/farrow-pipeline/counter.js +6 -8
- package/dist/js/modern/farrow-pipeline/index.js +1 -5
- package/dist/js/modern/farrow-pipeline/pipeline.js +37 -21
- package/dist/js/modern/index.js +1 -1
- package/dist/js/modern/manager/async.js +77 -38
- package/dist/js/modern/manager/index.js +1 -1
- package/dist/js/modern/manager/shared.js +20 -11
- package/dist/js/modern/manager/sync.js +80 -49
- package/dist/js/modern/utils/pluginDagSort.js +28 -21
- package/dist/js/modern/waterfall/async.js +63 -20
- package/dist/js/modern/waterfall/index.js +1 -1
- package/dist/js/modern/waterfall/sync.js +35 -18
- package/dist/js/modern/workflow/async.js +59 -17
- package/dist/js/modern/workflow/index.js +1 -1
- package/dist/js/modern/workflow/parallel.js +53 -11
- package/dist/js/modern/workflow/sync.js +30 -12
- package/dist/js/node/farrow-pipeline/context.js +25 -15
- package/dist/js/node/farrow-pipeline/counter.js +23 -13
- package/dist/js/node/farrow-pipeline/index.js +17 -16
- package/dist/js/node/farrow-pipeline/pipeline.js +54 -30
- package/dist/js/node/index.js +20 -49
- package/dist/js/node/manager/async.js +92 -47
- package/dist/js/node/manager/index.js +19 -38
- package/dist/js/node/manager/shared.js +38 -21
- package/dist/js/node/manager/sync.js +92 -71
- package/dist/js/node/utils/pluginDagSort.js +45 -26
- package/dist/js/node/waterfall/async.js +79 -28
- package/dist/js/node/waterfall/index.js +18 -27
- package/dist/js/node/waterfall/sync.js +54 -27
- package/dist/js/node/workflow/async.js +75 -24
- package/dist/js/node/workflow/index.js +19 -38
- package/dist/js/node/workflow/parallel.js +72 -19
- package/dist/js/node/workflow/sync.js +49 -20
- package/dist/js/treeshaking/farrow-pipeline/context.js +30 -34
- package/dist/js/treeshaking/farrow-pipeline/counter.js +16 -20
- package/dist/js/treeshaking/farrow-pipeline/index.js +1 -5
- package/dist/js/treeshaking/farrow-pipeline/pipeline.js +106 -59
- package/dist/js/treeshaking/index.js +1 -1
- package/dist/js/treeshaking/manager/async.js +297 -115
- package/dist/js/treeshaking/manager/index.js +1 -1
- package/dist/js/treeshaking/manager/shared.js +29 -29
- package/dist/js/treeshaking/manager/sync.js +213 -168
- package/dist/js/treeshaking/manager/types.js +1 -0
- package/dist/js/treeshaking/utils/pluginDagSort.js +67 -72
- package/dist/js/treeshaking/waterfall/async.js +266 -68
- package/dist/js/treeshaking/waterfall/index.js +1 -1
- package/dist/js/treeshaking/waterfall/sync.js +122 -46
- package/dist/js/treeshaking/workflow/async.js +285 -84
- package/dist/js/treeshaking/workflow/index.js +1 -1
- package/dist/js/treeshaking/workflow/parallel.js +244 -49
- package/dist/js/treeshaking/workflow/sync.js +110 -32
- package/dist/types/manager/async.d.ts +9 -0
- package/dist/types/manager/sync.d.ts +9 -0
- package/dist/types/manager/types.d.ts +9 -2
- package/package.json +3 -3
@@ -1,19 +1,55 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
|
21
|
+
cloneHook: () => cloneHook,
|
22
|
+
cloneHooksMap: () => cloneHooksMap,
|
23
|
+
createManager: () => createManager,
|
24
|
+
generateRunner: () => generateRunner
|
5
25
|
});
|
6
|
-
|
7
|
-
var
|
8
|
-
var
|
9
|
-
var
|
10
|
-
var
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
26
|
+
module.exports = __toCommonJS(stdin_exports);
|
27
|
+
var import_farrow_pipeline = require("../farrow-pipeline");
|
28
|
+
var import_waterfall = require("../waterfall");
|
29
|
+
var import_workflow = require("../workflow");
|
30
|
+
var import_shared = require("./shared");
|
31
|
+
var __defProp2 = Object.defineProperty;
|
32
|
+
var __defProps = Object.defineProperties;
|
33
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
34
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
35
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
36
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
37
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
38
|
+
var __spreadValues = (a, b) => {
|
39
|
+
for (var prop in b || (b = {}))
|
40
|
+
if (__hasOwnProp2.call(b, prop))
|
41
|
+
__defNormalProp(a, prop, b[prop]);
|
42
|
+
if (__getOwnPropSymbols)
|
43
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
44
|
+
if (__propIsEnum.call(b, prop))
|
45
|
+
__defNormalProp(a, prop, b[prop]);
|
46
|
+
}
|
47
|
+
return a;
|
48
|
+
};
|
49
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
50
|
+
const SYNC_PLUGIN_SYMBOL = "SYNC_PLUGIN_SYMBOL";
|
15
51
|
const DEFAULT_OPTIONS = {
|
16
|
-
name:
|
52
|
+
name: "untitled",
|
17
53
|
pre: [],
|
18
54
|
post: [],
|
19
55
|
rivals: [],
|
@@ -21,63 +57,54 @@ const DEFAULT_OPTIONS = {
|
|
21
57
|
usePlugins: [],
|
22
58
|
registerHook: {}
|
23
59
|
};
|
24
|
-
exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
|
25
60
|
const createManager = (hooks, api) => {
|
26
61
|
let index = 0;
|
27
62
|
let runners;
|
28
|
-
let currentHooks =
|
63
|
+
let currentHooks = __spreadValues({}, hooks);
|
29
64
|
const useRunner = () => runners;
|
30
|
-
const registerHook = extraHooks => {
|
31
|
-
currentHooks =
|
65
|
+
const registerHook = (extraHooks) => {
|
66
|
+
currentHooks = __spreadValues(__spreadValues({}, extraHooks), currentHooks);
|
32
67
|
};
|
33
|
-
const isPlugin = input => (0,
|
34
|
-
const pluginAPI =
|
68
|
+
const isPlugin = (input) => (0, import_shared.isObject)(input) && (0, import_shared.hasOwnProperty)(input, SYNC_PLUGIN_SYMBOL) && input[SYNC_PLUGIN_SYMBOL] === SYNC_PLUGIN_SYMBOL;
|
69
|
+
const pluginAPI = __spreadProps(__spreadValues({}, api), {
|
35
70
|
useHookRunners: useRunner
|
36
71
|
});
|
37
|
-
const clone = overrideAPI => {
|
72
|
+
const clone = (overrideAPI) => {
|
38
73
|
let plugins = [];
|
39
|
-
const addPlugin = plugin => {
|
40
|
-
if (!(0,
|
41
|
-
plugins.push(
|
74
|
+
const addPlugin = (plugin) => {
|
75
|
+
if (!(0, import_shared.includePlugin)(plugins, plugin)) {
|
76
|
+
plugins.push(__spreadValues({}, plugin));
|
42
77
|
}
|
43
78
|
};
|
44
79
|
const usePlugin = (...input) => {
|
45
|
-
input.forEach(plugin => {
|
46
|
-
// already created by createPlugin
|
80
|
+
input.forEach((plugin) => {
|
47
81
|
if (isPlugin(plugin)) {
|
48
82
|
addPlugin(plugin);
|
49
|
-
}
|
50
|
-
// using function to return plugin options
|
51
|
-
else if (typeof plugin === 'function') {
|
83
|
+
} else if (typeof plugin === "function") {
|
52
84
|
const options = plugin();
|
53
85
|
addPlugin(createPlugin(options.setup, options));
|
54
|
-
}
|
55
|
-
// plain plugin object
|
56
|
-
else if ((0, _shared.isObject)(plugin)) {
|
86
|
+
} else if ((0, import_shared.isObject)(plugin)) {
|
57
87
|
addPlugin(createPlugin(plugin.setup, plugin));
|
58
|
-
}
|
59
|
-
// unknown plugin
|
60
|
-
else {
|
88
|
+
} else {
|
61
89
|
console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
|
62
90
|
}
|
63
91
|
});
|
64
92
|
return manager;
|
65
93
|
};
|
66
|
-
const createPlugin = (
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
options.usePlugins.forEach(plugin => {
|
94
|
+
const createPlugin = (setup = () => {
|
95
|
+
}, options = {}) => {
|
96
|
+
var _a;
|
97
|
+
if ((_a = options.usePlugins) == null ? void 0 : _a.length) {
|
98
|
+
options.usePlugins.forEach((plugin) => {
|
72
99
|
usePlugin(createPlugin(plugin.setup, plugin));
|
73
100
|
});
|
74
101
|
}
|
75
102
|
if (options.registerHook) {
|
76
103
|
registerHook(options.registerHook);
|
77
104
|
}
|
78
|
-
return
|
105
|
+
return __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, DEFAULT_OPTIONS), {
|
79
106
|
name: `No.${index++} plugin`
|
80
|
-
}, options), {
|
107
|
+
}), options), {
|
81
108
|
SYNC_PLUGIN_SYMBOL,
|
82
109
|
setup
|
83
110
|
});
|
@@ -86,14 +113,16 @@ const createManager = (hooks, api) => {
|
|
86
113
|
plugins = [];
|
87
114
|
};
|
88
115
|
const init = () => {
|
89
|
-
const sortedPlugins = (0,
|
90
|
-
const mergedPluginAPI =
|
91
|
-
(0,
|
92
|
-
const hooksList = sortedPlugins.map(
|
116
|
+
const sortedPlugins = (0, import_shared.sortPlugins)(plugins);
|
117
|
+
const mergedPluginAPI = __spreadValues(__spreadValues({}, pluginAPI), overrideAPI);
|
118
|
+
(0, import_shared.checkPlugins)(sortedPlugins);
|
119
|
+
const hooksList = sortedPlugins.map(
|
120
|
+
(plugin) => plugin.setup(mergedPluginAPI)
|
121
|
+
);
|
93
122
|
runners = generateRunner(hooksList, currentHooks);
|
94
123
|
return runners;
|
95
124
|
};
|
96
|
-
const run = cb => cb();
|
125
|
+
const run = (cb) => cb();
|
97
126
|
const manager = {
|
98
127
|
createPlugin,
|
99
128
|
isPlugin,
|
@@ -109,7 +138,6 @@ const createManager = (hooks, api) => {
|
|
109
138
|
};
|
110
139
|
return clone();
|
111
140
|
};
|
112
|
-
exports.createManager = createManager;
|
113
141
|
const generateRunner = (hooksList, hooksMap) => {
|
114
142
|
const runner = {};
|
115
143
|
const cloneShape = cloneHooksMap(hooksMap);
|
@@ -123,46 +151,39 @@ const generateRunner = (hooksList, hooksMap) => {
|
|
123
151
|
cloneShape[key].use(hooks[key]);
|
124
152
|
}
|
125
153
|
}
|
126
|
-
|
127
|
-
// @ts-expect-error
|
128
|
-
runner[key] = (input, options) => cloneShape[key].run(input, _objectSpread({}, options));
|
154
|
+
runner[key] = (input, options) => cloneShape[key].run(input, __spreadValues({}, options));
|
129
155
|
}
|
130
156
|
}
|
131
157
|
return runner;
|
132
158
|
};
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
return (0, _waterfall.createWaterfall)();
|
159
|
+
const cloneHook = (hook) => {
|
160
|
+
if ((0, import_waterfall.isWaterfall)(hook)) {
|
161
|
+
return (0, import_waterfall.createWaterfall)();
|
137
162
|
}
|
138
|
-
if ((0,
|
139
|
-
return (0,
|
163
|
+
if ((0, import_waterfall.isAsyncWaterfall)(hook)) {
|
164
|
+
return (0, import_waterfall.createAsyncWaterfall)();
|
140
165
|
}
|
141
|
-
if ((0,
|
142
|
-
return (0,
|
166
|
+
if ((0, import_workflow.isWorkflow)(hook)) {
|
167
|
+
return (0, import_workflow.createWorkflow)();
|
143
168
|
}
|
144
|
-
if ((0,
|
145
|
-
return (0,
|
169
|
+
if ((0, import_workflow.isAsyncWorkflow)(hook)) {
|
170
|
+
return (0, import_workflow.createAsyncWorkflow)();
|
146
171
|
}
|
147
|
-
if ((0,
|
148
|
-
return (0,
|
172
|
+
if ((0, import_workflow.isParallelWorkflow)(hook)) {
|
173
|
+
return (0, import_workflow.createParallelWorkflow)();
|
149
174
|
}
|
150
|
-
if ((0,
|
151
|
-
return (0,
|
175
|
+
if ((0, import_farrow_pipeline.isPipeline)(hook)) {
|
176
|
+
return (0, import_farrow_pipeline.createPipeline)();
|
152
177
|
}
|
153
178
|
throw new Error(`Unknown hook: ${hook}`);
|
154
179
|
};
|
155
|
-
|
156
|
-
const cloneHooksMap = record => {
|
180
|
+
const cloneHooksMap = (record) => {
|
157
181
|
if (!record) {
|
158
182
|
return record;
|
159
183
|
}
|
160
184
|
const result = {};
|
161
185
|
for (const key in record) {
|
162
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
163
|
-
// @ts-expect-error
|
164
186
|
result[key] = cloneHook(record[key]);
|
165
187
|
}
|
166
188
|
return result;
|
167
189
|
};
|
168
|
-
exports.cloneHooksMap = cloneHooksMap;
|
@@ -1,55 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
dagSort: () => dagSort
|
5
21
|
});
|
6
|
-
exports
|
7
|
-
const dagSort = (plugins, key =
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
23
|
+
const dagSort = (plugins, key = "name", preKey = "pre", postKey = "post") => {
|
8
24
|
let allLines = [];
|
9
25
|
function getPluginByAny(q) {
|
10
|
-
const target = plugins.find(
|
11
|
-
|
26
|
+
const target = plugins.find(
|
27
|
+
(item) => typeof q === "string" ? item[key] === q : item[key] === q[key]
|
28
|
+
);
|
12
29
|
if (!target) {
|
13
30
|
throw new Error(`plugin ${q} not existed`);
|
14
31
|
}
|
15
32
|
return target;
|
16
33
|
}
|
17
|
-
plugins.forEach(item => {
|
18
|
-
item[preKey].forEach(p => {
|
19
|
-
|
20
|
-
if (plugins.find(ap => ap.name === p)) {
|
34
|
+
plugins.forEach((item) => {
|
35
|
+
item[preKey].forEach((p) => {
|
36
|
+
if (plugins.find((ap) => ap.name === p)) {
|
21
37
|
allLines.push([getPluginByAny(p)[key], getPluginByAny(item)[key]]);
|
22
38
|
}
|
23
39
|
});
|
24
|
-
item[postKey].forEach(pt => {
|
25
|
-
|
26
|
-
if (plugins.find(ap => ap.name === pt)) {
|
40
|
+
item[postKey].forEach((pt) => {
|
41
|
+
if (plugins.find((ap) => ap.name === pt)) {
|
27
42
|
allLines.push([getPluginByAny(item)[key], getPluginByAny(pt)[key]]);
|
28
43
|
}
|
29
44
|
});
|
30
45
|
});
|
31
|
-
|
32
|
-
|
33
|
-
|
46
|
+
let zeroEndPoints = plugins.filter(
|
47
|
+
(item) => !allLines.find((l) => l[1] === item[key])
|
48
|
+
);
|
34
49
|
const sortedPoint = [];
|
35
50
|
while (zeroEndPoints.length) {
|
36
51
|
const zep = zeroEndPoints.shift();
|
37
52
|
sortedPoint.push(getPluginByAny(zep));
|
38
|
-
allLines = allLines.filter(l => l[0] !== getPluginByAny(zep)[key]);
|
39
|
-
const restPoints = plugins.filter(
|
53
|
+
allLines = allLines.filter((l) => l[0] !== getPluginByAny(zep)[key]);
|
54
|
+
const restPoints = plugins.filter(
|
55
|
+
(item) => !sortedPoint.find((sp) => sp[key] === item[key])
|
56
|
+
);
|
40
57
|
zeroEndPoints = restPoints.filter(
|
41
|
-
|
42
|
-
|
58
|
+
(item) => !allLines.find((l) => l[1] === item[key])
|
59
|
+
);
|
43
60
|
}
|
44
|
-
// if has ring, throw error
|
45
61
|
if (allLines.length) {
|
46
62
|
const restInRingPoints = {};
|
47
|
-
allLines.forEach(l => {
|
63
|
+
allLines.forEach((l) => {
|
48
64
|
restInRingPoints[l[0]] = true;
|
49
65
|
restInRingPoints[l[1]] = true;
|
50
66
|
});
|
51
|
-
throw new Error(
|
67
|
+
throw new Error(
|
68
|
+
`plugins dependences has loop: ${Object.keys(restInRingPoints).join(
|
69
|
+
","
|
70
|
+
)}`
|
71
|
+
);
|
52
72
|
}
|
53
73
|
return sortedPoint;
|
54
74
|
};
|
55
|
-
exports.dagSort = dagSort;
|
@@ -1,38 +1,89 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
createAsyncWaterfall: () => createAsyncWaterfall,
|
21
|
+
getAsyncBrook: () => getAsyncBrook,
|
22
|
+
isAsyncWaterfall: () => isAsyncWaterfall
|
5
23
|
});
|
6
|
-
|
7
|
-
var
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
24
|
+
module.exports = __toCommonJS(stdin_exports);
|
25
|
+
var import_farrow_pipeline = require("../farrow-pipeline");
|
26
|
+
var __defProp2 = Object.defineProperty;
|
27
|
+
var __defProps = Object.defineProperties;
|
28
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
29
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
30
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
31
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
32
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
33
|
+
var __spreadValues = (a, b) => {
|
34
|
+
for (var prop in b || (b = {}))
|
35
|
+
if (__hasOwnProp2.call(b, prop))
|
36
|
+
__defNormalProp(a, prop, b[prop]);
|
37
|
+
if (__getOwnPropSymbols)
|
38
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
39
|
+
if (__propIsEnum.call(b, prop))
|
40
|
+
__defNormalProp(a, prop, b[prop]);
|
41
|
+
}
|
42
|
+
return a;
|
43
|
+
};
|
44
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
45
|
+
var __async = (__this, __arguments, generator) => {
|
46
|
+
return new Promise((resolve, reject) => {
|
47
|
+
var fulfilled = (value) => {
|
48
|
+
try {
|
49
|
+
step(generator.next(value));
|
50
|
+
} catch (e) {
|
51
|
+
reject(e);
|
52
|
+
}
|
53
|
+
};
|
54
|
+
var rejected = (value) => {
|
55
|
+
try {
|
56
|
+
step(generator.throw(value));
|
57
|
+
} catch (e) {
|
58
|
+
reject(e);
|
59
|
+
}
|
60
|
+
};
|
61
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
62
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
63
|
+
});
|
64
|
+
};
|
65
|
+
const ASYNC_WATERFALL_SYMBOL = Symbol.for("MODERN_ASYNC_WATERFALL");
|
66
|
+
const getAsyncBrook = (input) => {
|
67
|
+
if (typeof input === "function") {
|
14
68
|
return input;
|
15
|
-
} else if (input && typeof input.middleware ===
|
69
|
+
} else if (input && typeof input.middleware === "function") {
|
16
70
|
return input.middleware;
|
17
71
|
}
|
18
72
|
throw new Error(`${input} is not a AsyncBrook or { brook: AsyncBrook }`);
|
19
73
|
};
|
20
|
-
exports.getAsyncBrook = getAsyncBrook;
|
21
74
|
const createAsyncWaterfall = () => {
|
22
|
-
const pipeline = (0,
|
75
|
+
const pipeline = (0, import_farrow_pipeline.createAsyncPipeline)();
|
23
76
|
const use = (...input) => {
|
24
|
-
pipeline.use(
|
77
|
+
pipeline.use(
|
78
|
+
...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware)
|
79
|
+
);
|
25
80
|
return waterfall;
|
26
81
|
};
|
27
|
-
const run = (input, options) => pipeline.run(input,
|
28
|
-
|
29
|
-
|
30
|
-
const middleware = input => {
|
31
|
-
return pipeline.run(input, {
|
32
|
-
onLast: input => input
|
33
|
-
});
|
82
|
+
const run = (input, options) => pipeline.run(input, __spreadProps(__spreadValues({}, options), { onLast: (input2) => input2 }));
|
83
|
+
const middleware = (input) => {
|
84
|
+
return pipeline.run(input, { onLast: (input2) => input2 });
|
34
85
|
};
|
35
|
-
const waterfall =
|
86
|
+
const waterfall = __spreadProps(__spreadValues({}, pipeline), {
|
36
87
|
use,
|
37
88
|
run,
|
38
89
|
middleware,
|
@@ -40,7 +91,7 @@ const createAsyncWaterfall = () => {
|
|
40
91
|
});
|
41
92
|
return waterfall;
|
42
93
|
};
|
43
|
-
|
44
|
-
const
|
45
|
-
|
46
|
-
|
94
|
+
const isAsyncWaterfall = (input) => Boolean(input == null ? void 0 : input[ASYNC_WATERFALL_SYMBOL]);
|
95
|
+
const mapAsyncBrookToAsyncMiddleware = (brook) => (input, next) => __async(void 0, null, function* () {
|
96
|
+
return next(yield brook(input));
|
97
|
+
});
|
@@ -1,27 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
20
|
-
if (key in exports && exports[key] === _async[key]) return;
|
21
|
-
Object.defineProperty(exports, key, {
|
22
|
-
enumerable: true,
|
23
|
-
get: function () {
|
24
|
-
return _async[key];
|
25
|
-
}
|
26
|
-
});
|
27
|
-
});
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
+
for (let key of __getOwnPropNames(from))
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
+
}
|
11
|
+
return to;
|
12
|
+
};
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var stdin_exports = {};
|
16
|
+
module.exports = __toCommonJS(stdin_exports);
|
17
|
+
__reExport(stdin_exports, require("./sync"), module.exports);
|
18
|
+
__reExport(stdin_exports, require("./async"), module.exports);
|
@@ -1,38 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var stdin_exports = {};
|
19
|
+
__export(stdin_exports, {
|
20
|
+
createWaterfall: () => createWaterfall,
|
21
|
+
getBrook: () => getBrook,
|
22
|
+
isWaterfall: () => isWaterfall
|
5
23
|
});
|
6
|
-
|
7
|
-
var
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
24
|
+
module.exports = __toCommonJS(stdin_exports);
|
25
|
+
var import_farrow_pipeline = require("../farrow-pipeline");
|
26
|
+
var __defProp2 = Object.defineProperty;
|
27
|
+
var __defProps = Object.defineProperties;
|
28
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
29
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
30
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
31
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
32
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
33
|
+
var __spreadValues = (a, b) => {
|
34
|
+
for (var prop in b || (b = {}))
|
35
|
+
if (__hasOwnProp2.call(b, prop))
|
36
|
+
__defNormalProp(a, prop, b[prop]);
|
37
|
+
if (__getOwnPropSymbols)
|
38
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
39
|
+
if (__propIsEnum.call(b, prop))
|
40
|
+
__defNormalProp(a, prop, b[prop]);
|
41
|
+
}
|
42
|
+
return a;
|
43
|
+
};
|
44
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
45
|
+
const WATERFALL_SYMBOL = Symbol.for("MODERN_WATERFALL");
|
46
|
+
const getBrook = (input) => {
|
47
|
+
if (typeof input === "function") {
|
14
48
|
return input;
|
15
|
-
} else if (input && typeof input.middleware ===
|
49
|
+
} else if (input && typeof input.middleware === "function") {
|
16
50
|
return input.middleware;
|
17
51
|
}
|
18
52
|
throw new Error(`${input} is not a Brook or { brook: Brook }`);
|
19
53
|
};
|
20
|
-
exports.getBrook = getBrook;
|
21
54
|
const createWaterfall = () => {
|
22
|
-
const pipeline = (0,
|
55
|
+
const pipeline = (0, import_farrow_pipeline.createPipeline)();
|
23
56
|
const use = (...brooks) => {
|
24
57
|
pipeline.use(...brooks.map(getBrook).map(mapBrookToMiddleware));
|
25
58
|
return waterfall;
|
26
59
|
};
|
27
|
-
const run = (input, options) => pipeline.run(input,
|
28
|
-
|
29
|
-
|
30
|
-
const middleware = input => {
|
31
|
-
return pipeline.run(input, {
|
32
|
-
onLast: input => input
|
33
|
-
});
|
60
|
+
const run = (input, options) => pipeline.run(input, __spreadProps(__spreadValues({}, options), { onLast: (input2) => input2 }));
|
61
|
+
const middleware = (input) => {
|
62
|
+
return pipeline.run(input, { onLast: (input2) => input2 });
|
34
63
|
};
|
35
|
-
const waterfall =
|
64
|
+
const waterfall = __spreadProps(__spreadValues({}, pipeline), {
|
36
65
|
use,
|
37
66
|
run,
|
38
67
|
middleware,
|
@@ -40,7 +69,5 @@ const createWaterfall = () => {
|
|
40
69
|
});
|
41
70
|
return waterfall;
|
42
71
|
};
|
43
|
-
|
44
|
-
const
|
45
|
-
exports.isWaterfall = isWaterfall;
|
46
|
-
const mapBrookToMiddleware = brook => (input, next) => next(brook(input));
|
72
|
+
const isWaterfall = (input) => Boolean(input == null ? void 0 : input[WATERFALL_SYMBOL]);
|
73
|
+
const mapBrookToMiddleware = (brook) => (input, next) => next(brook(input));
|