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