@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,48 +1,55 @@
|
|
1
|
-
|
1
|
+
const dagSort = (plugins, key = "name", preKey = "pre", postKey = "post") => {
|
2
2
|
let allLines = [];
|
3
3
|
function getPluginByAny(q) {
|
4
|
-
const target = plugins.find(
|
5
|
-
|
4
|
+
const target = plugins.find(
|
5
|
+
(item) => typeof q === "string" ? item[key] === q : item[key] === q[key]
|
6
|
+
);
|
6
7
|
if (!target) {
|
7
8
|
throw new Error(`plugin ${q} not existed`);
|
8
9
|
}
|
9
10
|
return target;
|
10
11
|
}
|
11
|
-
plugins.forEach(item => {
|
12
|
-
item[preKey].forEach(p => {
|
13
|
-
|
14
|
-
if (plugins.find(ap => ap.name === p)) {
|
12
|
+
plugins.forEach((item) => {
|
13
|
+
item[preKey].forEach((p) => {
|
14
|
+
if (plugins.find((ap) => ap.name === p)) {
|
15
15
|
allLines.push([getPluginByAny(p)[key], getPluginByAny(item)[key]]);
|
16
16
|
}
|
17
17
|
});
|
18
|
-
item[postKey].forEach(pt => {
|
19
|
-
|
20
|
-
if (plugins.find(ap => ap.name === pt)) {
|
18
|
+
item[postKey].forEach((pt) => {
|
19
|
+
if (plugins.find((ap) => ap.name === pt)) {
|
21
20
|
allLines.push([getPluginByAny(item)[key], getPluginByAny(pt)[key]]);
|
22
21
|
}
|
23
22
|
});
|
24
23
|
});
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
let zeroEndPoints = plugins.filter(
|
25
|
+
(item) => !allLines.find((l) => l[1] === item[key])
|
26
|
+
);
|
28
27
|
const sortedPoint = [];
|
29
28
|
while (zeroEndPoints.length) {
|
30
29
|
const zep = zeroEndPoints.shift();
|
31
30
|
sortedPoint.push(getPluginByAny(zep));
|
32
|
-
allLines = allLines.filter(l => l[0] !== getPluginByAny(zep)[key]);
|
33
|
-
const restPoints = plugins.filter(
|
31
|
+
allLines = allLines.filter((l) => l[0] !== getPluginByAny(zep)[key]);
|
32
|
+
const restPoints = plugins.filter(
|
33
|
+
(item) => !sortedPoint.find((sp) => sp[key] === item[key])
|
34
|
+
);
|
34
35
|
zeroEndPoints = restPoints.filter(
|
35
|
-
|
36
|
-
|
36
|
+
(item) => !allLines.find((l) => l[1] === item[key])
|
37
|
+
);
|
37
38
|
}
|
38
|
-
// if has ring, throw error
|
39
39
|
if (allLines.length) {
|
40
40
|
const restInRingPoints = {};
|
41
|
-
allLines.forEach(l => {
|
41
|
+
allLines.forEach((l) => {
|
42
42
|
restInRingPoints[l[0]] = true;
|
43
43
|
restInRingPoints[l[1]] = true;
|
44
44
|
});
|
45
|
-
throw new Error(
|
45
|
+
throw new Error(
|
46
|
+
`plugins dependences has loop: ${Object.keys(restInRingPoints).join(
|
47
|
+
","
|
48
|
+
)}`
|
49
|
+
);
|
46
50
|
}
|
47
51
|
return sortedPoint;
|
48
|
-
};
|
52
|
+
};
|
53
|
+
export {
|
54
|
+
dagSort
|
55
|
+
};
|
@@ -1,31 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
var fulfilled = (value) => {
|
23
|
+
try {
|
24
|
+
step(generator.next(value));
|
25
|
+
} catch (e) {
|
26
|
+
reject(e);
|
27
|
+
}
|
28
|
+
};
|
29
|
+
var rejected = (value) => {
|
30
|
+
try {
|
31
|
+
step(generator.throw(value));
|
32
|
+
} catch (e) {
|
33
|
+
reject(e);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
38
|
+
});
|
39
|
+
};
|
40
|
+
import {
|
41
|
+
createAsyncPipeline
|
42
|
+
} from "../farrow-pipeline";
|
43
|
+
const ASYNC_WATERFALL_SYMBOL = Symbol.for("MODERN_ASYNC_WATERFALL");
|
44
|
+
const getAsyncBrook = (input) => {
|
45
|
+
if (typeof input === "function") {
|
8
46
|
return input;
|
9
|
-
} else if (input && typeof input.middleware ===
|
47
|
+
} else if (input && typeof input.middleware === "function") {
|
10
48
|
return input.middleware;
|
11
49
|
}
|
12
50
|
throw new Error(`${input} is not a AsyncBrook or { brook: AsyncBrook }`);
|
13
51
|
};
|
14
|
-
|
52
|
+
const createAsyncWaterfall = () => {
|
15
53
|
const pipeline = createAsyncPipeline();
|
16
54
|
const use = (...input) => {
|
17
|
-
pipeline.use(
|
55
|
+
pipeline.use(
|
56
|
+
...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware)
|
57
|
+
);
|
18
58
|
return waterfall;
|
19
59
|
};
|
20
|
-
const run = (input, options) => pipeline.run(input,
|
21
|
-
|
22
|
-
|
23
|
-
const middleware = input => {
|
24
|
-
return pipeline.run(input, {
|
25
|
-
onLast: input => input
|
26
|
-
});
|
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 });
|
27
63
|
};
|
28
|
-
const waterfall =
|
64
|
+
const waterfall = __spreadProps(__spreadValues({}, pipeline), {
|
29
65
|
use,
|
30
66
|
run,
|
31
67
|
middleware,
|
@@ -33,5 +69,12 @@ export const createAsyncWaterfall = () => {
|
|
33
69
|
});
|
34
70
|
return waterfall;
|
35
71
|
};
|
36
|
-
|
37
|
-
const mapAsyncBrookToAsyncMiddleware = brook =>
|
72
|
+
const isAsyncWaterfall = (input) => Boolean(input == null ? void 0 : input[ASYNC_WATERFALL_SYMBOL]);
|
73
|
+
const mapAsyncBrookToAsyncMiddleware = (brook) => (input, next) => __async(void 0, null, function* () {
|
74
|
+
return next(yield brook(input));
|
75
|
+
});
|
76
|
+
export {
|
77
|
+
createAsyncWaterfall,
|
78
|
+
getAsyncBrook,
|
79
|
+
isAsyncWaterfall
|
80
|
+
};
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export * from "./sync";
|
2
|
-
export * from "./async";
|
2
|
+
export * from "./async";
|
@@ -1,31 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
4
20
|
import { createPipeline } from "../farrow-pipeline";
|
5
|
-
const WATERFALL_SYMBOL = Symbol.for(
|
6
|
-
|
7
|
-
if (typeof input ===
|
21
|
+
const WATERFALL_SYMBOL = Symbol.for("MODERN_WATERFALL");
|
22
|
+
const getBrook = (input) => {
|
23
|
+
if (typeof input === "function") {
|
8
24
|
return input;
|
9
|
-
} else if (input && typeof input.middleware ===
|
25
|
+
} else if (input && typeof input.middleware === "function") {
|
10
26
|
return input.middleware;
|
11
27
|
}
|
12
28
|
throw new Error(`${input} is not a Brook or { brook: Brook }`);
|
13
29
|
};
|
14
|
-
|
30
|
+
const createWaterfall = () => {
|
15
31
|
const pipeline = createPipeline();
|
16
32
|
const use = (...brooks) => {
|
17
33
|
pipeline.use(...brooks.map(getBrook).map(mapBrookToMiddleware));
|
18
34
|
return waterfall;
|
19
35
|
};
|
20
|
-
const run = (input, options) => pipeline.run(input,
|
21
|
-
|
22
|
-
|
23
|
-
const middleware = input => {
|
24
|
-
return pipeline.run(input, {
|
25
|
-
onLast: input => input
|
26
|
-
});
|
36
|
+
const run = (input, options) => pipeline.run(input, __spreadProps(__spreadValues({}, options), { onLast: (input2) => input2 }));
|
37
|
+
const middleware = (input) => {
|
38
|
+
return pipeline.run(input, { onLast: (input2) => input2 });
|
27
39
|
};
|
28
|
-
const waterfall =
|
40
|
+
const waterfall = __spreadProps(__spreadValues({}, pipeline), {
|
29
41
|
use,
|
30
42
|
run,
|
31
43
|
middleware,
|
@@ -33,5 +45,10 @@ export const createWaterfall = () => {
|
|
33
45
|
});
|
34
46
|
return waterfall;
|
35
47
|
};
|
36
|
-
|
37
|
-
const mapBrookToMiddleware = brook => (input, next) => next(brook(input));
|
48
|
+
const isWaterfall = (input) => Boolean(input == null ? void 0 : input[WATERFALL_SYMBOL]);
|
49
|
+
const mapBrookToMiddleware = (brook) => (input, next) => next(brook(input));
|
50
|
+
export {
|
51
|
+
createWaterfall,
|
52
|
+
getBrook,
|
53
|
+
isWaterfall
|
54
|
+
};
|
@@ -1,33 +1,75 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
var fulfilled = (value) => {
|
23
|
+
try {
|
24
|
+
step(generator.next(value));
|
25
|
+
} catch (e) {
|
26
|
+
reject(e);
|
27
|
+
}
|
28
|
+
};
|
29
|
+
var rejected = (value) => {
|
30
|
+
try {
|
31
|
+
step(generator.throw(value));
|
32
|
+
} catch (e) {
|
33
|
+
reject(e);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
38
|
+
});
|
39
|
+
};
|
40
|
+
import {
|
41
|
+
createAsyncPipeline
|
42
|
+
} from "../farrow-pipeline";
|
43
|
+
const ASYNC_WORKFLOW_SYMBOL = Symbol.for("MODERN_ASYNC_WORKFLOW");
|
44
|
+
const isAsyncWorkflow = (input) => Boolean(input == null ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
|
45
|
+
const createAsyncWorkflow = () => {
|
8
46
|
const pipeline = createAsyncPipeline();
|
9
47
|
const use = (...input) => {
|
10
48
|
pipeline.use(...input.map(mapAsyncWorkerToAsyncMiddleware));
|
11
49
|
return workflow;
|
12
50
|
};
|
13
|
-
const run =
|
14
|
-
const result = pipeline.run(input, {
|
15
|
-
onLast: () => []
|
16
|
-
});
|
51
|
+
const run = (input) => __async(void 0, null, function* () {
|
52
|
+
const result = pipeline.run(input, { onLast: () => [] });
|
17
53
|
if (isPromise(result)) {
|
18
|
-
return result.then(
|
54
|
+
return result.then((result2) => result2.filter(Boolean));
|
19
55
|
} else {
|
20
56
|
return result.filter(Boolean);
|
21
57
|
}
|
22
|
-
};
|
23
|
-
const workflow =
|
58
|
+
});
|
59
|
+
const workflow = __spreadProps(__spreadValues({}, pipeline), {
|
24
60
|
use,
|
25
61
|
run,
|
26
62
|
[ASYNC_WORKFLOW_SYMBOL]: true
|
27
63
|
});
|
28
64
|
return workflow;
|
29
65
|
};
|
30
|
-
const mapAsyncWorkerToAsyncMiddleware = worker =>
|
66
|
+
const mapAsyncWorkerToAsyncMiddleware = (worker) => (input, next) => __async(void 0, null, function* () {
|
67
|
+
return [yield worker(input), ...yield next(input)];
|
68
|
+
});
|
31
69
|
function isPromise(obj) {
|
32
|
-
return Boolean(obj) && (typeof obj ===
|
33
|
-
}
|
70
|
+
return Boolean(obj) && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
71
|
+
}
|
72
|
+
export {
|
73
|
+
createAsyncWorkflow,
|
74
|
+
isAsyncWorkflow
|
75
|
+
};
|
@@ -1,23 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
21
|
+
return new Promise((resolve, reject) => {
|
22
|
+
var fulfilled = (value) => {
|
23
|
+
try {
|
24
|
+
step(generator.next(value));
|
25
|
+
} catch (e) {
|
26
|
+
reject(e);
|
27
|
+
}
|
28
|
+
};
|
29
|
+
var rejected = (value) => {
|
30
|
+
try {
|
31
|
+
step(generator.throw(value));
|
32
|
+
} catch (e) {
|
33
|
+
reject(e);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
38
|
+
});
|
39
|
+
};
|
4
40
|
import { createPipeline } from "../farrow-pipeline";
|
5
|
-
const PARALLEL_WORKFLOW_SYMBOL = Symbol.for(
|
6
|
-
|
7
|
-
|
41
|
+
const PARALLEL_WORKFLOW_SYMBOL = Symbol.for("MODERN_PARALLEL_WORKFLOW");
|
42
|
+
const isParallelWorkflow = (input) => Boolean(input == null ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
|
43
|
+
const createParallelWorkflow = () => {
|
8
44
|
const pipeline = createPipeline();
|
9
45
|
const use = (...input) => {
|
10
46
|
pipeline.use(...input.map(mapParallelWorkerToAsyncMiddleware));
|
11
47
|
return workflow;
|
12
48
|
};
|
13
|
-
const run =
|
14
|
-
onLast: () => []
|
15
|
-
|
16
|
-
|
49
|
+
const run = (input) => __async(void 0, null, function* () {
|
50
|
+
return Promise.all(pipeline.run(input, { onLast: () => [] })).then(
|
51
|
+
(result) => result.filter(Boolean)
|
52
|
+
);
|
53
|
+
});
|
54
|
+
const workflow = __spreadProps(__spreadValues({}, pipeline), {
|
17
55
|
run,
|
18
56
|
use,
|
19
57
|
[PARALLEL_WORKFLOW_SYMBOL]: true
|
20
58
|
});
|
21
59
|
return workflow;
|
22
60
|
};
|
23
|
-
const mapParallelWorkerToAsyncMiddleware = worker => (input, next) => [worker(input), ...next(input)];
|
61
|
+
const mapParallelWorkerToAsyncMiddleware = (worker) => (input, next) => [worker(input), ...next(input)];
|
62
|
+
export {
|
63
|
+
createParallelWorkflow,
|
64
|
+
isParallelWorkflow
|
65
|
+
};
|
@@ -1,26 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
4
20
|
import { createPipeline } from "../farrow-pipeline";
|
5
|
-
const WORKFLOW_SYMBOL = Symbol.for(
|
6
|
-
|
21
|
+
const WORKFLOW_SYMBOL = Symbol.for("MODERN_WORKFLOW");
|
22
|
+
const createWorkflow = () => {
|
7
23
|
const pipeline = createPipeline();
|
8
24
|
const use = (...input) => {
|
9
25
|
pipeline.use(...input.map(mapWorkerToMiddleware));
|
10
26
|
return workflow;
|
11
27
|
};
|
12
|
-
const run = input => {
|
13
|
-
const result = pipeline.run(input, {
|
14
|
-
onLast: () => []
|
15
|
-
});
|
28
|
+
const run = (input) => {
|
29
|
+
const result = pipeline.run(input, { onLast: () => [] });
|
16
30
|
return result.filter(Boolean);
|
17
31
|
};
|
18
|
-
const workflow =
|
32
|
+
const workflow = __spreadProps(__spreadValues({}, pipeline), {
|
19
33
|
use,
|
20
34
|
run,
|
21
35
|
[WORKFLOW_SYMBOL]: true
|
22
36
|
});
|
23
37
|
return workflow;
|
24
38
|
};
|
25
|
-
|
26
|
-
const mapWorkerToMiddleware = worker => (input, next) => [worker(input), ...next(input)];
|
39
|
+
const isWorkflow = (input) => Boolean(input == null ? void 0 : input[WORKFLOW_SYMBOL]);
|
40
|
+
const mapWorkerToMiddleware = (worker) => (input, next) => [worker(input), ...next(input)];
|
41
|
+
export {
|
42
|
+
createWorkflow,
|
43
|
+
isWorkflow
|
44
|
+
};
|
@@ -1,18 +1,29 @@
|
|
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
|
+
createContext: () => createContext
|
5
21
|
});
|
6
|
-
exports
|
7
|
-
|
8
|
-
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
9
|
-
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
10
|
-
*/
|
11
|
-
|
12
|
-
const createContext = value => {
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
23
|
+
const createContext = (value) => {
|
13
24
|
let currentValue;
|
14
|
-
const create =
|
15
|
-
currentValue =
|
25
|
+
const create = (value2) => {
|
26
|
+
currentValue = value2;
|
16
27
|
const use = () => ({
|
17
28
|
get value() {
|
18
29
|
return currentValue;
|
@@ -22,7 +33,7 @@ const createContext = value => {
|
|
22
33
|
}
|
23
34
|
});
|
24
35
|
const get = () => currentValue;
|
25
|
-
const set = v => {
|
36
|
+
const set = (v) => {
|
26
37
|
currentValue = v;
|
27
38
|
};
|
28
39
|
const Context = {
|
@@ -35,4 +46,3 @@ const createContext = value => {
|
|
35
46
|
};
|
36
47
|
return create(value);
|
37
48
|
};
|
38
|
-
exports.createContext = createContext;
|
@@ -1,23 +1,33 @@
|
|
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
|
+
createCounter: () => createCounter
|
5
21
|
});
|
6
|
-
exports
|
7
|
-
|
8
|
-
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
9
|
-
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
10
|
-
*/
|
11
|
-
|
12
|
-
const createCounter = callback => {
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
23
|
+
const createCounter = (callback) => {
|
13
24
|
const dispatch = (index, input) => {
|
14
25
|
const next = (nextInput = input) => dispatch(index + 1, nextInput);
|
15
26
|
return callback(index, input, next);
|
16
27
|
};
|
17
|
-
const start = input => dispatch(0, input);
|
28
|
+
const start = (input) => dispatch(0, input);
|
18
29
|
return {
|
19
30
|
start,
|
20
31
|
dispatch
|
21
32
|
};
|
22
33
|
};
|
23
|
-
exports.createCounter = createCounter;
|
@@ -1,16 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Object.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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("./pipeline"), module.exports);
|