@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.
Files changed (57) hide show
  1. package/CHANGELOG.md +14 -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 +25 -15
  20. package/dist/js/node/farrow-pipeline/counter.js +23 -13
  21. package/dist/js/node/farrow-pipeline/index.js +17 -16
  22. package/dist/js/node/farrow-pipeline/pipeline.js +54 -30
  23. package/dist/js/node/index.js +20 -49
  24. package/dist/js/node/manager/async.js +92 -47
  25. package/dist/js/node/manager/index.js +19 -38
  26. package/dist/js/node/manager/shared.js +38 -21
  27. package/dist/js/node/manager/sync.js +92 -71
  28. package/dist/js/node/utils/pluginDagSort.js +45 -26
  29. package/dist/js/node/waterfall/async.js +79 -28
  30. package/dist/js/node/waterfall/index.js +18 -27
  31. package/dist/js/node/waterfall/sync.js +54 -27
  32. package/dist/js/node/workflow/async.js +75 -24
  33. package/dist/js/node/workflow/index.js +19 -38
  34. package/dist/js/node/workflow/parallel.js +72 -19
  35. package/dist/js/node/workflow/sync.js +49 -20
  36. package/dist/js/treeshaking/farrow-pipeline/context.js +30 -34
  37. package/dist/js/treeshaking/farrow-pipeline/counter.js +16 -20
  38. package/dist/js/treeshaking/farrow-pipeline/index.js +1 -5
  39. package/dist/js/treeshaking/farrow-pipeline/pipeline.js +106 -59
  40. package/dist/js/treeshaking/index.js +1 -1
  41. package/dist/js/treeshaking/manager/async.js +297 -115
  42. package/dist/js/treeshaking/manager/index.js +1 -1
  43. package/dist/js/treeshaking/manager/shared.js +29 -29
  44. package/dist/js/treeshaking/manager/sync.js +213 -168
  45. package/dist/js/treeshaking/manager/types.js +1 -0
  46. package/dist/js/treeshaking/utils/pluginDagSort.js +67 -72
  47. package/dist/js/treeshaking/waterfall/async.js +266 -68
  48. package/dist/js/treeshaking/waterfall/index.js +1 -1
  49. package/dist/js/treeshaking/waterfall/sync.js +122 -46
  50. package/dist/js/treeshaking/workflow/async.js +285 -84
  51. package/dist/js/treeshaking/workflow/index.js +1 -1
  52. package/dist/js/treeshaking/workflow/parallel.js +244 -49
  53. package/dist/js/treeshaking/workflow/sync.js +110 -32
  54. package/dist/types/manager/async.d.ts +9 -0
  55. package/dist/types/manager/sync.d.ts +9 -0
  56. package/dist/types/manager/types.d.ts +9 -2
  57. package/package.json +3 -3
@@ -1,19 +1,55 @@
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 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
- exports.generateRunner = exports.createManager = exports.cloneHooksMap = exports.cloneHook = exports.DEFAULT_OPTIONS = void 0;
7
- var _farrowPipeline = require("../farrow-pipeline");
8
- var _waterfall = require("../waterfall");
9
- var _workflow = require("../workflow");
10
- var _shared = require("./shared");
11
- 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; }
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';
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: 'untitled',
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 = _objectSpread({}, hooks);
63
+ let currentHooks = __spreadValues({}, hooks);
29
64
  const useRunner = () => runners;
30
- const registerHook = extraHooks => {
31
- currentHooks = _objectSpread(_objectSpread({}, extraHooks), currentHooks);
65
+ const registerHook = (extraHooks) => {
66
+ currentHooks = __spreadValues(__spreadValues({}, extraHooks), currentHooks);
32
67
  };
33
- const isPlugin = input => (0, _shared.isObject)(input) && (0, _shared.hasOwnProperty)(input, SYNC_PLUGIN_SYMBOL) && input[SYNC_PLUGIN_SYMBOL] === SYNC_PLUGIN_SYMBOL;
34
- const pluginAPI = _objectSpread(_objectSpread({}, api), {}, {
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, _shared.includePlugin)(plugins, plugin)) {
41
- plugins.push(_objectSpread({}, plugin));
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
- // eslint-disable-next-line @typescript-eslint/no-empty-function
68
- setup = () => {}, options = {}) => {
69
- var _options$usePlugins;
70
- if ((_options$usePlugins = options.usePlugins) !== null && _options$usePlugins !== void 0 && _options$usePlugins.length) {
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 _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), {}, {
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, _shared.sortPlugins)(plugins);
90
- const mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
91
- (0, _shared.checkPlugins)(sortedPlugins);
92
- const hooksList = sortedPlugins.map(plugin => plugin.setup(mergedPluginAPI));
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
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
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
- exports.generateRunner = generateRunner;
134
- const cloneHook = hook => {
135
- if ((0, _waterfall.isWaterfall)(hook)) {
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, _waterfall.isAsyncWaterfall)(hook)) {
139
- return (0, _waterfall.createAsyncWaterfall)();
163
+ if ((0, import_waterfall.isAsyncWaterfall)(hook)) {
164
+ return (0, import_waterfall.createAsyncWaterfall)();
140
165
  }
141
- if ((0, _workflow.isWorkflow)(hook)) {
142
- return (0, _workflow.createWorkflow)();
166
+ if ((0, import_workflow.isWorkflow)(hook)) {
167
+ return (0, import_workflow.createWorkflow)();
143
168
  }
144
- if ((0, _workflow.isAsyncWorkflow)(hook)) {
145
- return (0, _workflow.createAsyncWorkflow)();
169
+ if ((0, import_workflow.isAsyncWorkflow)(hook)) {
170
+ return (0, import_workflow.createAsyncWorkflow)();
146
171
  }
147
- if ((0, _workflow.isParallelWorkflow)(hook)) {
148
- return (0, _workflow.createParallelWorkflow)();
172
+ if ((0, import_workflow.isParallelWorkflow)(hook)) {
173
+ return (0, import_workflow.createParallelWorkflow)();
149
174
  }
150
- if ((0, _farrowPipeline.isPipeline)(hook)) {
151
- return (0, _farrowPipeline.createPipeline)();
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
- exports.cloneHook = cloneHook;
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
- "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 stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ dagSort: () => dagSort
5
21
  });
6
- exports.dagSort = void 0;
7
- const dagSort = (plugins, key = 'name', preKey = 'pre', postKey = 'post') => {
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(item => typeof q === 'string' ? item[key] === q : item[key] === q[key]);
11
- // current plugin design can't guarantee the plugins in pre/post existed
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
- // compatibility: do not add the plugin-name that plugins not have
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
- // compatibility: do not add the plugin-name that plugins not have
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
- // search the zero input plugin
33
- let zeroEndPoints = plugins.filter(item => !allLines.find(l => l[1] === item[key]));
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(item => !sortedPoint.find(sp => sp[key] === item[key]));
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
- // eslint-disable-next-line @typescript-eslint/no-loop-func
42
- item => !allLines.find(l => l[1] === item[key]));
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(`plugins dependences has loop: ${Object.keys(restInRingPoints).join(',')}`);
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
- "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 stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ createAsyncWaterfall: () => createAsyncWaterfall,
21
+ getAsyncBrook: () => getAsyncBrook,
22
+ isAsyncWaterfall: () => isAsyncWaterfall
5
23
  });
6
- exports.isAsyncWaterfall = exports.getAsyncBrook = exports.createAsyncWaterfall = void 0;
7
- var _farrowPipeline = require("../farrow-pipeline");
8
- 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; }
9
- 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; }
10
- 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; }
11
- const ASYNC_WATERFALL_SYMBOL = Symbol.for('MODERN_ASYNC_WATERFALL');
12
- const getAsyncBrook = input => {
13
- if (typeof input === 'function') {
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 === 'function') {
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, _farrowPipeline.createAsyncPipeline)();
75
+ const pipeline = (0, import_farrow_pipeline.createAsyncPipeline)();
23
76
  const use = (...input) => {
24
- pipeline.use(...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware));
77
+ pipeline.use(
78
+ ...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware)
79
+ );
25
80
  return waterfall;
26
81
  };
27
- const run = (input, options) => pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
28
- onLast: input => input
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 = _objectSpread(_objectSpread({}, pipeline), {}, {
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
- exports.createAsyncWaterfall = createAsyncWaterfall;
44
- const isAsyncWaterfall = input => Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WATERFALL_SYMBOL]);
45
- exports.isAsyncWaterfall = isAsyncWaterfall;
46
- const mapAsyncBrookToAsyncMiddleware = brook => async (input, next) => next(await brook(input));
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _sync = require("./sync");
7
- Object.keys(_sync).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _sync[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _sync[key];
14
- }
15
- });
16
- });
17
- var _async = require("./async");
18
- Object.keys(_async).forEach(function (key) {
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
- "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 stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ createWaterfall: () => createWaterfall,
21
+ getBrook: () => getBrook,
22
+ isWaterfall: () => isWaterfall
5
23
  });
6
- exports.isWaterfall = exports.getBrook = exports.createWaterfall = void 0;
7
- var _farrowPipeline = require("../farrow-pipeline");
8
- 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; }
9
- 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; }
10
- 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; }
11
- const WATERFALL_SYMBOL = Symbol.for('MODERN_WATERFALL');
12
- const getBrook = input => {
13
- if (typeof input === 'function') {
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 === 'function') {
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, _farrowPipeline.createPipeline)();
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, _objectSpread(_objectSpread({}, options), {}, {
28
- onLast: input => input
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 = _objectSpread(_objectSpread({}, pipeline), {}, {
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
- exports.createWaterfall = createWaterfall;
44
- const isWaterfall = input => Boolean(input === null || input === void 0 ? void 0 : input[WATERFALL_SYMBOL]);
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));