@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/js/modern/farrow-pipeline/context.js +8 -10
  3. package/dist/js/modern/farrow-pipeline/counter.js +6 -8
  4. package/dist/js/modern/farrow-pipeline/index.js +1 -5
  5. package/dist/js/modern/farrow-pipeline/pipeline.js +37 -21
  6. package/dist/js/modern/index.js +1 -1
  7. package/dist/js/modern/manager/async.js +77 -38
  8. package/dist/js/modern/manager/index.js +1 -1
  9. package/dist/js/modern/manager/shared.js +20 -11
  10. package/dist/js/modern/manager/sync.js +80 -49
  11. package/dist/js/modern/utils/pluginDagSort.js +28 -21
  12. package/dist/js/modern/waterfall/async.js +63 -20
  13. package/dist/js/modern/waterfall/index.js +1 -1
  14. package/dist/js/modern/waterfall/sync.js +35 -18
  15. package/dist/js/modern/workflow/async.js +59 -17
  16. package/dist/js/modern/workflow/index.js +1 -1
  17. package/dist/js/modern/workflow/parallel.js +53 -11
  18. package/dist/js/modern/workflow/sync.js +30 -12
  19. package/dist/js/node/farrow-pipeline/context.js +29 -15
  20. package/dist/js/node/farrow-pipeline/counter.js +27 -13
  21. package/dist/js/node/farrow-pipeline/index.js +17 -16
  22. package/dist/js/node/farrow-pipeline/pipeline.js +59 -30
  23. package/dist/js/node/index.js +20 -49
  24. package/dist/js/node/manager/async.js +94 -47
  25. package/dist/js/node/manager/index.js +19 -38
  26. package/dist/js/node/manager/shared.js +46 -21
  27. package/dist/js/node/manager/sync.js +98 -71
  28. package/dist/js/node/manager/types.js +15 -0
  29. package/dist/js/node/utils/pluginDagSort.js +49 -26
  30. package/dist/js/node/waterfall/async.js +83 -28
  31. package/dist/js/node/waterfall/index.js +18 -27
  32. package/dist/js/node/waterfall/sync.js +58 -27
  33. package/dist/js/node/workflow/async.js +78 -24
  34. package/dist/js/node/workflow/index.js +19 -38
  35. package/dist/js/node/workflow/parallel.js +75 -19
  36. package/dist/js/node/workflow/sync.js +52 -20
  37. package/dist/js/treeshaking/farrow-pipeline/context.js +30 -34
  38. package/dist/js/treeshaking/farrow-pipeline/counter.js +16 -20
  39. package/dist/js/treeshaking/farrow-pipeline/index.js +1 -5
  40. package/dist/js/treeshaking/farrow-pipeline/pipeline.js +106 -59
  41. package/dist/js/treeshaking/index.js +1 -1
  42. package/dist/js/treeshaking/manager/async.js +297 -115
  43. package/dist/js/treeshaking/manager/index.js +1 -1
  44. package/dist/js/treeshaking/manager/shared.js +29 -29
  45. package/dist/js/treeshaking/manager/sync.js +213 -168
  46. package/dist/js/treeshaking/manager/types.js +1 -0
  47. package/dist/js/treeshaking/utils/pluginDagSort.js +67 -72
  48. package/dist/js/treeshaking/waterfall/async.js +266 -68
  49. package/dist/js/treeshaking/waterfall/index.js +1 -1
  50. package/dist/js/treeshaking/waterfall/sync.js +122 -46
  51. package/dist/js/treeshaking/workflow/async.js +285 -84
  52. package/dist/js/treeshaking/workflow/index.js +1 -1
  53. package/dist/js/treeshaking/workflow/parallel.js +244 -49
  54. package/dist/js/treeshaking/workflow/sync.js +110 -32
  55. package/dist/types/manager/async.d.ts +9 -0
  56. package/dist/types/manager/sync.d.ts +9 -0
  57. package/dist/types/manager/types.d.ts +9 -2
  58. package/package.json +3 -3
@@ -1,48 +1,55 @@
1
- export const dagSort = (plugins, key = 'name', preKey = 'pre', postKey = 'post') => {
1
+ const dagSort = (plugins, key = "name", preKey = "pre", postKey = "post") => {
2
2
  let allLines = [];
3
3
  function getPluginByAny(q) {
4
- const target = plugins.find(item => typeof q === 'string' ? item[key] === q : item[key] === q[key]);
5
- // current plugin design can't guarantee the plugins in pre/post existed
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
- // compatibility: do not add the plugin-name that plugins not have
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
- // compatibility: do not add the plugin-name that plugins not have
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
- // search the zero input plugin
27
- let zeroEndPoints = plugins.filter(item => !allLines.find(l => l[1] === item[key]));
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(item => !sortedPoint.find(sp => sp[key] === item[key]));
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
- // eslint-disable-next-line @typescript-eslint/no-loop-func
36
- item => !allLines.find(l => l[1] === item[key]));
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(`plugins dependences has loop: ${Object.keys(restInRingPoints).join(',')}`);
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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- 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; }
3
- 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; }
4
- import { createAsyncPipeline } from "../farrow-pipeline";
5
- const ASYNC_WATERFALL_SYMBOL = Symbol.for('MODERN_ASYNC_WATERFALL');
6
- export const getAsyncBrook = input => {
7
- if (typeof input === 'function') {
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 === 'function') {
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
- export const createAsyncWaterfall = () => {
52
+ const createAsyncWaterfall = () => {
15
53
  const pipeline = createAsyncPipeline();
16
54
  const use = (...input) => {
17
- pipeline.use(...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware));
55
+ pipeline.use(
56
+ ...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware)
57
+ );
18
58
  return waterfall;
19
59
  };
20
- const run = (input, options) => pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
21
- onLast: input => input
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 = _objectSpread(_objectSpread({}, pipeline), {}, {
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
- export const isAsyncWaterfall = input => Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WATERFALL_SYMBOL]);
37
- const mapAsyncBrookToAsyncMiddleware = brook => async (input, next) => next(await brook(input));
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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- 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; }
3
- 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; }
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('MODERN_WATERFALL');
6
- export const getBrook = input => {
7
- if (typeof input === 'function') {
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 === 'function') {
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
- export const createWaterfall = () => {
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, _objectSpread(_objectSpread({}, options), {}, {
21
- onLast: input => input
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 = _objectSpread(_objectSpread({}, pipeline), {}, {
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
- export const isWaterfall = input => Boolean(input === null || input === void 0 ? void 0 : input[WATERFALL_SYMBOL]);
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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- 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; }
3
- 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; }
4
- import { createAsyncPipeline } from "../farrow-pipeline";
5
- const ASYNC_WORKFLOW_SYMBOL = Symbol.for('MODERN_ASYNC_WORKFLOW');
6
- export const isAsyncWorkflow = input => Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
7
- export const createAsyncWorkflow = () => {
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 = async input => {
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(result => result.filter(Boolean));
54
+ return result.then((result2) => result2.filter(Boolean));
19
55
  } else {
20
56
  return result.filter(Boolean);
21
57
  }
22
- };
23
- const workflow = _objectSpread(_objectSpread({}, pipeline), {}, {
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 => async (input, next) => [await worker(input), ...(await next(input))];
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 === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
33
- }
70
+ return Boolean(obj) && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
71
+ }
72
+ export {
73
+ createAsyncWorkflow,
74
+ isAsyncWorkflow
75
+ };
@@ -1,3 +1,3 @@
1
1
  export * from "./sync";
2
2
  export * from "./parallel";
3
- export * from "./async";
3
+ export * from "./async";
@@ -1,23 +1,65 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- 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; }
3
- 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; }
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('MODERN_PARALLEL_WORKFLOW');
6
- export const isParallelWorkflow = input => Boolean(input === null || input === void 0 ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
7
- export const createParallelWorkflow = () => {
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 = async input => Promise.all(pipeline.run(input, {
14
- onLast: () => []
15
- })).then(result => result.filter(Boolean));
16
- const workflow = _objectSpread(_objectSpread({}, pipeline), {}, {
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
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
- 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; }
3
- 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; }
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('MODERN_WORKFLOW');
6
- export const createWorkflow = () => {
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 = _objectSpread(_objectSpread({}, pipeline), {}, {
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
- export const isWorkflow = input => Boolean(input === null || input === void 0 ? void 0 : input[WORKFLOW_SYMBOL]);
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 context_exports = {};
19
+ __export(context_exports, {
20
+ createContext: () => createContext
5
21
  });
6
- exports.createContext = void 0;
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(context_exports);
23
+ const createContext = (value) => {
13
24
  let currentValue;
14
- const create = value => {
15
- currentValue = value;
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,7 @@ const createContext = value => {
35
46
  };
36
47
  return create(value);
37
48
  };
38
- exports.createContext = createContext;
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ createContext
52
+ });
@@ -1,23 +1,37 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 counter_exports = {};
19
+ __export(counter_exports, {
20
+ createCounter: () => createCounter
5
21
  });
6
- exports.createCounter = void 0;
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(counter_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;
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ createCounter
37
+ });
@@ -1,16 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _pipeline = require("./pipeline");
7
- Object.keys(_pipeline).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _pipeline[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _pipeline[key];
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 farrow_pipeline_exports = {};
16
+ module.exports = __toCommonJS(farrow_pipeline_exports);
17
+ __reExport(farrow_pipeline_exports, require("./pipeline"), module.exports);