@modern-js/plugin 1.21.2-beta.0 → 1.21.2-beta.2
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/dist/js/modern/farrow-pipeline/context.js +38 -0
 - package/dist/js/modern/farrow-pipeline/counter.js +18 -0
 - package/dist/js/modern/farrow-pipeline/index.js +5 -0
 - package/dist/js/modern/farrow-pipeline/pipeline.js +76 -0
 - package/dist/js/modern/index.js +4 -0
 - package/dist/js/modern/manager/async.js +112 -0
 - package/dist/js/modern/manager/index.js +3 -0
 - package/dist/js/modern/manager/shared.js +44 -0
 - package/dist/js/modern/manager/sync.js +188 -0
 - package/dist/js/modern/manager/types.js +0 -0
 - package/dist/js/modern/waterfall/async.js +47 -0
 - package/dist/js/modern/waterfall/index.js +2 -0
 - package/dist/js/modern/waterfall/sync.js +47 -0
 - package/dist/js/modern/workflow/async.js +43 -0
 - package/dist/js/modern/workflow/index.js +3 -0
 - package/dist/js/modern/workflow/parallel.js +31 -0
 - package/dist/js/modern/workflow/sync.js +34 -0
 - package/dist/js/node/farrow-pipeline/context.js +47 -0
 - package/dist/js/node/farrow-pipeline/counter.js +27 -0
 - package/dist/js/node/farrow-pipeline/index.js +18 -0
 - package/dist/js/node/farrow-pipeline/pipeline.js +94 -0
 - package/dist/js/node/index.js +57 -0
 - package/dist/js/node/manager/async.js +124 -0
 - package/dist/js/node/manager/index.js +44 -0
 - package/dist/js/node/manager/shared.js +64 -0
 - package/dist/js/node/manager/sync.js +212 -0
 - package/dist/js/node/manager/types.js +0 -0
 - package/dist/js/node/waterfall/async.js +64 -0
 - package/dist/js/node/waterfall/index.js +31 -0
 - package/dist/js/node/waterfall/sync.js +64 -0
 - package/dist/js/node/workflow/async.js +57 -0
 - package/dist/js/node/workflow/index.js +44 -0
 - package/dist/js/node/workflow/parallel.js +45 -0
 - package/dist/js/node/workflow/sync.js +48 -0
 - package/dist/js/treeshaking/farrow-pipeline/context.js +42 -0
 - package/dist/js/treeshaking/farrow-pipeline/counter.js +23 -0
 - package/dist/js/treeshaking/farrow-pipeline/index.js +5 -0
 - package/dist/js/treeshaking/farrow-pipeline/pipeline.js +81 -0
 - package/dist/js/treeshaking/index.js +4 -0
 - package/dist/js/treeshaking/manager/async.js +146 -0
 - package/dist/js/treeshaking/manager/index.js +3 -0
 - package/dist/js/treeshaking/manager/shared.js +79 -0
 - package/dist/js/treeshaking/manager/sync.js +216 -0
 - package/dist/js/treeshaking/manager/types.js +0 -0
 - package/dist/js/treeshaking/waterfall/async.js +84 -0
 - package/dist/js/treeshaking/waterfall/index.js +2 -0
 - package/dist/js/treeshaking/waterfall/sync.js +59 -0
 - package/dist/js/treeshaking/workflow/async.js +108 -0
 - package/dist/js/treeshaking/workflow/index.js +3 -0
 - package/dist/js/treeshaking/workflow/parallel.js +62 -0
 - package/dist/js/treeshaking/workflow/sync.js +42 -0
 - package/dist/types/farrow-pipeline/context.d.ts +13 -0
 - package/dist/types/farrow-pipeline/counter.d.ts +11 -0
 - package/dist/types/farrow-pipeline/index.d.ts +5 -0
 - package/dist/types/farrow-pipeline/pipeline.d.ts +29 -0
 - package/dist/types/index.d.ts +4 -0
 - package/dist/types/manager/async.d.ts +63 -0
 - package/dist/types/manager/index.d.ts +3 -0
 - package/dist/types/manager/shared.d.ts +12 -0
 - package/dist/types/manager/sync.d.ts +75 -0
 - package/dist/types/manager/types.d.ts +36 -0
 - package/dist/types/waterfall/async.d.ts +21 -0
 - package/dist/types/waterfall/index.d.ts +2 -0
 - package/dist/types/waterfall/sync.d.ts +20 -0
 - package/dist/types/workflow/async.d.ts +12 -0
 - package/dist/types/workflow/index.d.ts +3 -0
 - package/dist/types/workflow/parallel.d.ts +10 -0
 - package/dist/types/workflow/sync.d.ts +11 -0
 - package/package.json +2 -2
 
| 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            /**
         
     | 
| 
      
 6 
     | 
    
         
            +
             * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
         
     | 
| 
      
 7 
     | 
    
         
            +
             * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
         
     | 
| 
      
 8 
     | 
    
         
            +
             */
         
     | 
| 
      
 9 
     | 
    
         
            +
            import { createContext } from "./context";
         
     | 
| 
      
 10 
     | 
    
         
            +
            import { createCounter } from "./counter";
         
     | 
| 
      
 11 
     | 
    
         
            +
            export { createContext };
         
     | 
| 
      
 12 
     | 
    
         
            +
            export var isPipeline = function isPipeline(input) {
         
     | 
| 
      
 13 
     | 
    
         
            +
              return Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
         
     | 
| 
      
 14 
     | 
    
         
            +
            };
         
     | 
| 
      
 15 
     | 
    
         
            +
            var PipelineSymbol = Symbol["for"]('MODERN_PIPELINE');
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            var getMiddleware = function getMiddleware(input) {
         
     | 
| 
      
 18 
     | 
    
         
            +
              if (typeof input === 'function') {
         
     | 
| 
      
 19 
     | 
    
         
            +
                return input;
         
     | 
| 
      
 20 
     | 
    
         
            +
              } else if (input && typeof input.middleware === 'function') {
         
     | 
| 
      
 21 
     | 
    
         
            +
                return input.middleware;
         
     | 
| 
      
 22 
     | 
    
         
            +
              }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              throw new Error("".concat(input, " is not a Middleware"));
         
     | 
| 
      
 25 
     | 
    
         
            +
            };
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            export var createPipeline = function createPipeline() {
         
     | 
| 
      
 28 
     | 
    
         
            +
              var _pipeline;
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              var middlewares = [];
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              var use = function use() {
         
     | 
| 
      
 33 
     | 
    
         
            +
                for (var _len = arguments.length, inputs = new Array(_len), _key = 0; _key < _len; _key++) {
         
     | 
| 
      
 34 
     | 
    
         
            +
                  inputs[_key] = arguments[_key];
         
     | 
| 
      
 35 
     | 
    
         
            +
                }
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                middlewares.push.apply(middlewares, _toConsumableArray(inputs.map(getMiddleware)));
         
     | 
| 
      
 38 
     | 
    
         
            +
                return pipeline;
         
     | 
| 
      
 39 
     | 
    
         
            +
              };
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              var createCurrentCounter = function createCurrentCounter(onLast) {
         
     | 
| 
      
 42 
     | 
    
         
            +
                return createCounter(function (index, input, next) {
         
     | 
| 
      
 43 
     | 
    
         
            +
                  if (index >= middlewares.length) {
         
     | 
| 
      
 44 
     | 
    
         
            +
                    if (onLast) {
         
     | 
| 
      
 45 
     | 
    
         
            +
                      return onLast(input);
         
     | 
| 
      
 46 
     | 
    
         
            +
                    }
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                    throw new Error("Expect returning a value, but all middlewares just calling next()");
         
     | 
| 
      
 49 
     | 
    
         
            +
                  }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  return middlewares[index](input, next);
         
     | 
| 
      
 52 
     | 
    
         
            +
                });
         
     | 
| 
      
 53 
     | 
    
         
            +
              };
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              var currentCounter = createCurrentCounter();
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              var getCounter = function getCounter(options) {
         
     | 
| 
      
 58 
     | 
    
         
            +
                if (!options) {
         
     | 
| 
      
 59 
     | 
    
         
            +
                  return currentCounter;
         
     | 
| 
      
 60 
     | 
    
         
            +
                }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                return createCurrentCounter(options === null || options === void 0 ? void 0 : options.onLast);
         
     | 
| 
      
 63 
     | 
    
         
            +
              };
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              var run = function run(input, options) {
         
     | 
| 
      
 66 
     | 
    
         
            +
                return getCounter(options).start(input);
         
     | 
| 
      
 67 
     | 
    
         
            +
              };
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              var middleware = function middleware(input, next) {
         
     | 
| 
      
 70 
     | 
    
         
            +
                return run(input, {
         
     | 
| 
      
 71 
     | 
    
         
            +
                  onLast: next
         
     | 
| 
      
 72 
     | 
    
         
            +
                });
         
     | 
| 
      
 73 
     | 
    
         
            +
              };
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
              var pipeline = (_pipeline = {}, _defineProperty(_pipeline, PipelineSymbol, true), _defineProperty(_pipeline, "use", use), _defineProperty(_pipeline, "run", run), _defineProperty(_pipeline, "middleware", middleware), _pipeline);
         
     | 
| 
      
 76 
     | 
    
         
            +
              return pipeline;
         
     | 
| 
      
 77 
     | 
    
         
            +
            };
         
     | 
| 
      
 78 
     | 
    
         
            +
            export var createAsyncPipeline = function createAsyncPipeline() {
         
     | 
| 
      
 79 
     | 
    
         
            +
              var pipeline = createPipeline();
         
     | 
| 
      
 80 
     | 
    
         
            +
              return _objectSpread({}, pipeline);
         
     | 
| 
      
 81 
     | 
    
         
            +
            };
         
     | 
| 
         @@ -0,0 +1,146 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { generateRunner, DEFAULT_OPTIONS } from "./sync";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { checkPlugins, isObject, hasOwnProperty, sortPlugins, includePlugin } from "./shared";
         
     | 
| 
      
 6 
     | 
    
         
            +
            var ASYNC_PLUGIN_SYMBOL = 'ASYNC_PLUGIN_SYMBOL';
         
     | 
| 
      
 7 
     | 
    
         
            +
            export var createAsyncManager = function createAsyncManager(hooks, api) {
         
     | 
| 
      
 8 
     | 
    
         
            +
              var index = 0;
         
     | 
| 
      
 9 
     | 
    
         
            +
              var runners;
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              var currentHooks = _objectSpread({}, hooks);
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              var useRunner = function useRunner() {
         
     | 
| 
      
 14 
     | 
    
         
            +
                return runners;
         
     | 
| 
      
 15 
     | 
    
         
            +
              };
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              var registerHook = function registerHook(extraHooks) {
         
     | 
| 
      
 18 
     | 
    
         
            +
                currentHooks = _objectSpread(_objectSpread({}, extraHooks), currentHooks);
         
     | 
| 
      
 19 
     | 
    
         
            +
              };
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              var isPlugin = function isPlugin(input) {
         
     | 
| 
      
 22 
     | 
    
         
            +
                return isObject(input) && hasOwnProperty(input, ASYNC_PLUGIN_SYMBOL) && input[ASYNC_PLUGIN_SYMBOL] === ASYNC_PLUGIN_SYMBOL;
         
     | 
| 
      
 23 
     | 
    
         
            +
              };
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              var pluginAPI = _objectSpread(_objectSpread({}, api), {}, {
         
     | 
| 
      
 26 
     | 
    
         
            +
                useHookRunners: useRunner
         
     | 
| 
      
 27 
     | 
    
         
            +
              });
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              var clone = function clone(overrideAPI) {
         
     | 
| 
      
 30 
     | 
    
         
            +
                var plugins = [];
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                var addPlugin = function addPlugin(plugin) {
         
     | 
| 
      
 33 
     | 
    
         
            +
                  if (!includePlugin(plugins, plugin)) {
         
     | 
| 
      
 34 
     | 
    
         
            +
                    plugins.push(_objectSpread({}, plugin));
         
     | 
| 
      
 35 
     | 
    
         
            +
                  }
         
     | 
| 
      
 36 
     | 
    
         
            +
                };
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                var usePlugin = function usePlugin() {
         
     | 
| 
      
 39 
     | 
    
         
            +
                  for (var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++) {
         
     | 
| 
      
 40 
     | 
    
         
            +
                    input[_key] = arguments[_key];
         
     | 
| 
      
 41 
     | 
    
         
            +
                  }
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  for (var _i = 0, _input = input; _i < _input.length; _i++) {
         
     | 
| 
      
 44 
     | 
    
         
            +
                    var plugin = _input[_i];
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    // already created by createPlugin
         
     | 
| 
      
 47 
     | 
    
         
            +
                    if (isPlugin(plugin)) {
         
     | 
| 
      
 48 
     | 
    
         
            +
                      addPlugin(plugin);
         
     | 
| 
      
 49 
     | 
    
         
            +
                    } // using function to return plugin options
         
     | 
| 
      
 50 
     | 
    
         
            +
                    else if (typeof plugin === 'function') {
         
     | 
| 
      
 51 
     | 
    
         
            +
                      var _options = plugin();
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                      addPlugin(createPlugin(_options.setup, _options));
         
     | 
| 
      
 54 
     | 
    
         
            +
                    } // plain plugin object
         
     | 
| 
      
 55 
     | 
    
         
            +
                    else if (isObject(plugin)) {
         
     | 
| 
      
 56 
     | 
    
         
            +
                      addPlugin(createPlugin(plugin.setup, plugin));
         
     | 
| 
      
 57 
     | 
    
         
            +
                    } // unknown plugin
         
     | 
| 
      
 58 
     | 
    
         
            +
                    else {
         
     | 
| 
      
 59 
     | 
    
         
            +
                      console.warn("Unknown plugin: ".concat(JSON.stringify(plugin)));
         
     | 
| 
      
 60 
     | 
    
         
            +
                    }
         
     | 
| 
      
 61 
     | 
    
         
            +
                  }
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  return manager;
         
     | 
| 
      
 64 
     | 
    
         
            +
                };
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                var createPlugin = function createPlugin() {
         
     | 
| 
      
 67 
     | 
    
         
            +
                  var _options$usePlugins;
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                  var setup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
         
     | 
| 
      
 70 
     | 
    
         
            +
                  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                  if ((_options$usePlugins = options.usePlugins) !== null && _options$usePlugins !== void 0 && _options$usePlugins.length) {
         
     | 
| 
      
 73 
     | 
    
         
            +
                    options.usePlugins.forEach(function (plugin) {
         
     | 
| 
      
 74 
     | 
    
         
            +
                      usePlugin(createPlugin(plugin.setup, plugin));
         
     | 
| 
      
 75 
     | 
    
         
            +
                    });
         
     | 
| 
      
 76 
     | 
    
         
            +
                  }
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                  if (options.registerHook) {
         
     | 
| 
      
 79 
     | 
    
         
            +
                    registerHook(options.registerHook);
         
     | 
| 
      
 80 
     | 
    
         
            +
                  }
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), {}, {
         
     | 
| 
      
 83 
     | 
    
         
            +
                    name: "No.".concat(index++, " plugin")
         
     | 
| 
      
 84 
     | 
    
         
            +
                  }, options), {}, {
         
     | 
| 
      
 85 
     | 
    
         
            +
                    ASYNC_PLUGIN_SYMBOL: ASYNC_PLUGIN_SYMBOL,
         
     | 
| 
      
 86 
     | 
    
         
            +
                    setup: setup
         
     | 
| 
      
 87 
     | 
    
         
            +
                  });
         
     | 
| 
      
 88 
     | 
    
         
            +
                };
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                var clear = function clear() {
         
     | 
| 
      
 91 
     | 
    
         
            +
                  plugins = [];
         
     | 
| 
      
 92 
     | 
    
         
            +
                };
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                var init = /*#__PURE__*/function () {
         
     | 
| 
      
 95 
     | 
    
         
            +
                  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
         
     | 
| 
      
 96 
     | 
    
         
            +
                    var sortedPlugins, mergedPluginAPI, hooksList;
         
     | 
| 
      
 97 
     | 
    
         
            +
                    return _regeneratorRuntime().wrap(function _callee$(_context) {
         
     | 
| 
      
 98 
     | 
    
         
            +
                      while (1) {
         
     | 
| 
      
 99 
     | 
    
         
            +
                        switch (_context.prev = _context.next) {
         
     | 
| 
      
 100 
     | 
    
         
            +
                          case 0:
         
     | 
| 
      
 101 
     | 
    
         
            +
                            sortedPlugins = sortPlugins(plugins);
         
     | 
| 
      
 102 
     | 
    
         
            +
                            mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
         
     | 
| 
      
 103 
     | 
    
         
            +
                            checkPlugins(sortedPlugins);
         
     | 
| 
      
 104 
     | 
    
         
            +
                            _context.next = 5;
         
     | 
| 
      
 105 
     | 
    
         
            +
                            return Promise.all(sortedPlugins.map(function (plugin) {
         
     | 
| 
      
 106 
     | 
    
         
            +
                              return plugin.setup(mergedPluginAPI);
         
     | 
| 
      
 107 
     | 
    
         
            +
                            }));
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                          case 5:
         
     | 
| 
      
 110 
     | 
    
         
            +
                            hooksList = _context.sent;
         
     | 
| 
      
 111 
     | 
    
         
            +
                            runners = generateRunner(hooksList, currentHooks);
         
     | 
| 
      
 112 
     | 
    
         
            +
                            return _context.abrupt("return", runners);
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                          case 8:
         
     | 
| 
      
 115 
     | 
    
         
            +
                          case "end":
         
     | 
| 
      
 116 
     | 
    
         
            +
                            return _context.stop();
         
     | 
| 
      
 117 
     | 
    
         
            +
                        }
         
     | 
| 
      
 118 
     | 
    
         
            +
                      }
         
     | 
| 
      
 119 
     | 
    
         
            +
                    }, _callee);
         
     | 
| 
      
 120 
     | 
    
         
            +
                  }));
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                  return function init() {
         
     | 
| 
      
 123 
     | 
    
         
            +
                    return _ref.apply(this, arguments);
         
     | 
| 
      
 124 
     | 
    
         
            +
                  };
         
     | 
| 
      
 125 
     | 
    
         
            +
                }();
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                var run = function run(cb) {
         
     | 
| 
      
 128 
     | 
    
         
            +
                  return cb();
         
     | 
| 
      
 129 
     | 
    
         
            +
                };
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
                var manager = {
         
     | 
| 
      
 132 
     | 
    
         
            +
                  createPlugin: createPlugin,
         
     | 
| 
      
 133 
     | 
    
         
            +
                  isPlugin: isPlugin,
         
     | 
| 
      
 134 
     | 
    
         
            +
                  usePlugin: usePlugin,
         
     | 
| 
      
 135 
     | 
    
         
            +
                  init: init,
         
     | 
| 
      
 136 
     | 
    
         
            +
                  run: run,
         
     | 
| 
      
 137 
     | 
    
         
            +
                  clear: clear,
         
     | 
| 
      
 138 
     | 
    
         
            +
                  clone: clone,
         
     | 
| 
      
 139 
     | 
    
         
            +
                  registerHook: registerHook,
         
     | 
| 
      
 140 
     | 
    
         
            +
                  useRunner: useRunner
         
     | 
| 
      
 141 
     | 
    
         
            +
                };
         
     | 
| 
      
 142 
     | 
    
         
            +
                return manager;
         
     | 
| 
      
 143 
     | 
    
         
            +
              };
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              return clone();
         
     | 
| 
      
 146 
     | 
    
         
            +
            };
         
     | 
| 
         @@ -0,0 +1,79 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import _typeof from "@babel/runtime/helpers/esm/typeof";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
         
     | 
| 
      
 4 
     | 
    
         
            +
            export var checkPlugins = function checkPlugins(plugins) {
         
     | 
| 
      
 5 
     | 
    
         
            +
              plugins.forEach(function (origin) {
         
     | 
| 
      
 6 
     | 
    
         
            +
                origin.rivals.forEach(function (rival) {
         
     | 
| 
      
 7 
     | 
    
         
            +
                  plugins.forEach(function (plugin) {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    if (rival === plugin.name) {
         
     | 
| 
      
 9 
     | 
    
         
            +
                      throw new Error("".concat(origin.name, " has rival ").concat(plugin.name));
         
     | 
| 
      
 10 
     | 
    
         
            +
                    }
         
     | 
| 
      
 11 
     | 
    
         
            +
                  });
         
     | 
| 
      
 12 
     | 
    
         
            +
                });
         
     | 
| 
      
 13 
     | 
    
         
            +
                origin.required.forEach(function (required) {
         
     | 
| 
      
 14 
     | 
    
         
            +
                  if (!plugins.some(function (plugin) {
         
     | 
| 
      
 15 
     | 
    
         
            +
                    return plugin.name === required;
         
     | 
| 
      
 16 
     | 
    
         
            +
                  })) {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    throw new Error("The plugin: ".concat(required, " is required when plugin: ").concat(origin.name, " is exist."));
         
     | 
| 
      
 18 
     | 
    
         
            +
                  }
         
     | 
| 
      
 19 
     | 
    
         
            +
                });
         
     | 
| 
      
 20 
     | 
    
         
            +
              });
         
     | 
| 
      
 21 
     | 
    
         
            +
            };
         
     | 
| 
      
 22 
     | 
    
         
            +
            export function sortPlugins(input) {
         
     | 
| 
      
 23 
     | 
    
         
            +
              var plugins = input.slice();
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              for (var i = 0; i < plugins.length; i++) {
         
     | 
| 
      
 26 
     | 
    
         
            +
                var plugin = plugins[i];
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                var _iterator = _createForOfIteratorHelper(plugin.pre),
         
     | 
| 
      
 29 
     | 
    
         
            +
                    _step;
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                try {
         
     | 
| 
      
 32 
     | 
    
         
            +
                  for (_iterator.s(); !(_step = _iterator.n()).done;) {
         
     | 
| 
      
 33 
     | 
    
         
            +
                    var pre = _step.value;
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    for (var j = i + 1; j < plugins.length; j++) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                      if (plugins[j].name === pre) {
         
     | 
| 
      
 37 
     | 
    
         
            +
                        plugins = [].concat(_toConsumableArray(plugins.slice(0, i)), [plugins[j]], _toConsumableArray(plugins.slice(i, j)), _toConsumableArray(plugins.slice(j + 1, plugins.length)));
         
     | 
| 
      
 38 
     | 
    
         
            +
                      }
         
     | 
| 
      
 39 
     | 
    
         
            +
                    }
         
     | 
| 
      
 40 
     | 
    
         
            +
                  }
         
     | 
| 
      
 41 
     | 
    
         
            +
                } catch (err) {
         
     | 
| 
      
 42 
     | 
    
         
            +
                  _iterator.e(err);
         
     | 
| 
      
 43 
     | 
    
         
            +
                } finally {
         
     | 
| 
      
 44 
     | 
    
         
            +
                  _iterator.f();
         
     | 
| 
      
 45 
     | 
    
         
            +
                }
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                var _iterator2 = _createForOfIteratorHelper(plugin.post),
         
     | 
| 
      
 48 
     | 
    
         
            +
                    _step2;
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                try {
         
     | 
| 
      
 51 
     | 
    
         
            +
                  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
         
     | 
| 
      
 52 
     | 
    
         
            +
                    var post = _step2.value;
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    for (var _j = 0; _j < i; _j++) {
         
     | 
| 
      
 55 
     | 
    
         
            +
                      if (plugins[_j].name === post) {
         
     | 
| 
      
 56 
     | 
    
         
            +
                        plugins = [].concat(_toConsumableArray(plugins.slice(0, _j)), _toConsumableArray(plugins.slice(_j + 1, i + 1)), [plugins[_j]], _toConsumableArray(plugins.slice(i + 1, plugins.length)));
         
     | 
| 
      
 57 
     | 
    
         
            +
                      }
         
     | 
| 
      
 58 
     | 
    
         
            +
                    }
         
     | 
| 
      
 59 
     | 
    
         
            +
                  }
         
     | 
| 
      
 60 
     | 
    
         
            +
                } catch (err) {
         
     | 
| 
      
 61 
     | 
    
         
            +
                  _iterator2.e(err);
         
     | 
| 
      
 62 
     | 
    
         
            +
                } finally {
         
     | 
| 
      
 63 
     | 
    
         
            +
                  _iterator2.f();
         
     | 
| 
      
 64 
     | 
    
         
            +
                }
         
     | 
| 
      
 65 
     | 
    
         
            +
              }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              return plugins;
         
     | 
| 
      
 68 
     | 
    
         
            +
            }
         
     | 
| 
      
 69 
     | 
    
         
            +
            export var includePlugin = function includePlugin(plugins, input) {
         
     | 
| 
      
 70 
     | 
    
         
            +
              return plugins.some(function (plugin) {
         
     | 
| 
      
 71 
     | 
    
         
            +
                return plugin.name === input.name;
         
     | 
| 
      
 72 
     | 
    
         
            +
              });
         
     | 
| 
      
 73 
     | 
    
         
            +
            };
         
     | 
| 
      
 74 
     | 
    
         
            +
            export var isObject = function isObject(obj) {
         
     | 
| 
      
 75 
     | 
    
         
            +
              return obj !== null && _typeof(obj) === 'object';
         
     | 
| 
      
 76 
     | 
    
         
            +
            };
         
     | 
| 
      
 77 
     | 
    
         
            +
            export var hasOwnProperty = function hasOwnProperty(obj, prop) {
         
     | 
| 
      
 78 
     | 
    
         
            +
              return obj.hasOwnProperty(prop);
         
     | 
| 
      
 79 
     | 
    
         
            +
            };
         
     | 
| 
         @@ -0,0 +1,216 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import { isPipeline, createPipeline } from "../farrow-pipeline";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { isWaterfall, createWaterfall, isAsyncWaterfall, createAsyncWaterfall } from "../waterfall";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { isWorkflow, createWorkflow, isAsyncWorkflow, createAsyncWorkflow, isParallelWorkflow, createParallelWorkflow } from "../workflow";
         
     | 
| 
      
 6 
     | 
    
         
            +
            import { checkPlugins, hasOwnProperty, includePlugin, isObject, sortPlugins } from "./shared";
         
     | 
| 
      
 7 
     | 
    
         
            +
            var SYNC_PLUGIN_SYMBOL = 'SYNC_PLUGIN_SYMBOL';
         
     | 
| 
      
 8 
     | 
    
         
            +
            export var DEFAULT_OPTIONS = {
         
     | 
| 
      
 9 
     | 
    
         
            +
              name: 'untitled',
         
     | 
| 
      
 10 
     | 
    
         
            +
              pre: [],
         
     | 
| 
      
 11 
     | 
    
         
            +
              post: [],
         
     | 
| 
      
 12 
     | 
    
         
            +
              rivals: [],
         
     | 
| 
      
 13 
     | 
    
         
            +
              required: [],
         
     | 
| 
      
 14 
     | 
    
         
            +
              usePlugins: [],
         
     | 
| 
      
 15 
     | 
    
         
            +
              registerHook: {}
         
     | 
| 
      
 16 
     | 
    
         
            +
            };
         
     | 
| 
      
 17 
     | 
    
         
            +
            export var createManager = function createManager(hooks, api) {
         
     | 
| 
      
 18 
     | 
    
         
            +
              var index = 0;
         
     | 
| 
      
 19 
     | 
    
         
            +
              var runners;
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              var currentHooks = _objectSpread({}, hooks);
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              var useRunner = function useRunner() {
         
     | 
| 
      
 24 
     | 
    
         
            +
                return runners;
         
     | 
| 
      
 25 
     | 
    
         
            +
              };
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              var registerHook = function registerHook(extraHooks) {
         
     | 
| 
      
 28 
     | 
    
         
            +
                currentHooks = _objectSpread(_objectSpread({}, extraHooks), currentHooks);
         
     | 
| 
      
 29 
     | 
    
         
            +
              };
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              var isPlugin = function isPlugin(input) {
         
     | 
| 
      
 32 
     | 
    
         
            +
                return isObject(input) && hasOwnProperty(input, SYNC_PLUGIN_SYMBOL) && input[SYNC_PLUGIN_SYMBOL] === SYNC_PLUGIN_SYMBOL;
         
     | 
| 
      
 33 
     | 
    
         
            +
              };
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              var pluginAPI = _objectSpread(_objectSpread({}, api), {}, {
         
     | 
| 
      
 36 
     | 
    
         
            +
                useHookRunners: useRunner
         
     | 
| 
      
 37 
     | 
    
         
            +
              });
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              var clone = function clone(overrideAPI) {
         
     | 
| 
      
 40 
     | 
    
         
            +
                var plugins = [];
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                var addPlugin = function addPlugin(plugin) {
         
     | 
| 
      
 43 
     | 
    
         
            +
                  if (!includePlugin(plugins, plugin)) {
         
     | 
| 
      
 44 
     | 
    
         
            +
                    plugins.push(_objectSpread({}, plugin));
         
     | 
| 
      
 45 
     | 
    
         
            +
                  }
         
     | 
| 
      
 46 
     | 
    
         
            +
                };
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                var usePlugin = function usePlugin() {
         
     | 
| 
      
 49 
     | 
    
         
            +
                  for (var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++) {
         
     | 
| 
      
 50 
     | 
    
         
            +
                    input[_key] = arguments[_key];
         
     | 
| 
      
 51 
     | 
    
         
            +
                  }
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  input.forEach(function (plugin) {
         
     | 
| 
      
 54 
     | 
    
         
            +
                    // already created by createPlugin
         
     | 
| 
      
 55 
     | 
    
         
            +
                    if (isPlugin(plugin)) {
         
     | 
| 
      
 56 
     | 
    
         
            +
                      addPlugin(plugin);
         
     | 
| 
      
 57 
     | 
    
         
            +
                    } // using function to return plugin options
         
     | 
| 
      
 58 
     | 
    
         
            +
                    else if (typeof plugin === 'function') {
         
     | 
| 
      
 59 
     | 
    
         
            +
                      var _options = plugin();
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                      addPlugin(createPlugin(_options.setup, _options));
         
     | 
| 
      
 62 
     | 
    
         
            +
                    } // plain plugin object
         
     | 
| 
      
 63 
     | 
    
         
            +
                    else if (isObject(plugin)) {
         
     | 
| 
      
 64 
     | 
    
         
            +
                      addPlugin(createPlugin(plugin.setup, plugin));
         
     | 
| 
      
 65 
     | 
    
         
            +
                    } // unknown plugin
         
     | 
| 
      
 66 
     | 
    
         
            +
                    else {
         
     | 
| 
      
 67 
     | 
    
         
            +
                      console.warn("Unknown plugin: ".concat(JSON.stringify(plugin)));
         
     | 
| 
      
 68 
     | 
    
         
            +
                    }
         
     | 
| 
      
 69 
     | 
    
         
            +
                  });
         
     | 
| 
      
 70 
     | 
    
         
            +
                  return manager;
         
     | 
| 
      
 71 
     | 
    
         
            +
                };
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                var createPlugin = function createPlugin() {
         
     | 
| 
      
 74 
     | 
    
         
            +
                  var _options$usePlugins;
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                  var setup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {};
         
     | 
| 
      
 77 
     | 
    
         
            +
                  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  if ((_options$usePlugins = options.usePlugins) !== null && _options$usePlugins !== void 0 && _options$usePlugins.length) {
         
     | 
| 
      
 80 
     | 
    
         
            +
                    options.usePlugins.forEach(function (plugin) {
         
     | 
| 
      
 81 
     | 
    
         
            +
                      usePlugin(createPlugin(plugin.setup, plugin));
         
     | 
| 
      
 82 
     | 
    
         
            +
                    });
         
     | 
| 
      
 83 
     | 
    
         
            +
                  }
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                  if (options.registerHook) {
         
     | 
| 
      
 86 
     | 
    
         
            +
                    registerHook(options.registerHook);
         
     | 
| 
      
 87 
     | 
    
         
            +
                  }
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                  return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_OPTIONS), {}, {
         
     | 
| 
      
 90 
     | 
    
         
            +
                    name: "No.".concat(index++, " plugin")
         
     | 
| 
      
 91 
     | 
    
         
            +
                  }, options), {}, {
         
     | 
| 
      
 92 
     | 
    
         
            +
                    SYNC_PLUGIN_SYMBOL: SYNC_PLUGIN_SYMBOL,
         
     | 
| 
      
 93 
     | 
    
         
            +
                    setup: setup
         
     | 
| 
      
 94 
     | 
    
         
            +
                  });
         
     | 
| 
      
 95 
     | 
    
         
            +
                };
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                var clear = function clear() {
         
     | 
| 
      
 98 
     | 
    
         
            +
                  plugins = [];
         
     | 
| 
      
 99 
     | 
    
         
            +
                };
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                var init = function init() {
         
     | 
| 
      
 102 
     | 
    
         
            +
                  var sortedPlugins = sortPlugins(plugins);
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  var mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                  checkPlugins(sortedPlugins);
         
     | 
| 
      
 107 
     | 
    
         
            +
                  var hooksList = sortedPlugins.map(function (plugin) {
         
     | 
| 
      
 108 
     | 
    
         
            +
                    return plugin.setup(mergedPluginAPI);
         
     | 
| 
      
 109 
     | 
    
         
            +
                  });
         
     | 
| 
      
 110 
     | 
    
         
            +
                  runners = generateRunner(hooksList, currentHooks);
         
     | 
| 
      
 111 
     | 
    
         
            +
                  return runners;
         
     | 
| 
      
 112 
     | 
    
         
            +
                };
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                var run = function run(cb) {
         
     | 
| 
      
 115 
     | 
    
         
            +
                  return cb();
         
     | 
| 
      
 116 
     | 
    
         
            +
                };
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                var manager = {
         
     | 
| 
      
 119 
     | 
    
         
            +
                  createPlugin: createPlugin,
         
     | 
| 
      
 120 
     | 
    
         
            +
                  isPlugin: isPlugin,
         
     | 
| 
      
 121 
     | 
    
         
            +
                  usePlugin: usePlugin,
         
     | 
| 
      
 122 
     | 
    
         
            +
                  init: init,
         
     | 
| 
      
 123 
     | 
    
         
            +
                  clear: clear,
         
     | 
| 
      
 124 
     | 
    
         
            +
                  run: run,
         
     | 
| 
      
 125 
     | 
    
         
            +
                  registerHook: registerHook,
         
     | 
| 
      
 126 
     | 
    
         
            +
                  useRunner: useRunner,
         
     | 
| 
      
 127 
     | 
    
         
            +
                  clone: clone
         
     | 
| 
      
 128 
     | 
    
         
            +
                };
         
     | 
| 
      
 129 
     | 
    
         
            +
                return manager;
         
     | 
| 
      
 130 
     | 
    
         
            +
              };
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
              return clone();
         
     | 
| 
      
 133 
     | 
    
         
            +
            };
         
     | 
| 
      
 134 
     | 
    
         
            +
            export var generateRunner = function generateRunner(hooksList, hooksMap) {
         
     | 
| 
      
 135 
     | 
    
         
            +
              var runner = {};
         
     | 
| 
      
 136 
     | 
    
         
            +
              var cloneShape = cloneHooksMap(hooksMap);
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
              if (hooksMap) {
         
     | 
| 
      
 139 
     | 
    
         
            +
                var _loop = function _loop(key) {
         
     | 
| 
      
 140 
     | 
    
         
            +
                  var _iterator = _createForOfIteratorHelper(hooksList),
         
     | 
| 
      
 141 
     | 
    
         
            +
                      _step;
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                  try {
         
     | 
| 
      
 144 
     | 
    
         
            +
                    for (_iterator.s(); !(_step = _iterator.n()).done;) {
         
     | 
| 
      
 145 
     | 
    
         
            +
                      var hooks = _step.value;
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                      if (!hooks) {
         
     | 
| 
      
 148 
     | 
    
         
            +
                        continue;
         
     | 
| 
      
 149 
     | 
    
         
            +
                      }
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
                      if (hooks[key]) {
         
     | 
| 
      
 152 
     | 
    
         
            +
                        cloneShape[key].use(hooks[key]);
         
     | 
| 
      
 153 
     | 
    
         
            +
                      }
         
     | 
| 
      
 154 
     | 
    
         
            +
                    } // eslint-disable-next-line @typescript-eslint/ban-ts-comment
         
     | 
| 
      
 155 
     | 
    
         
            +
                    // @ts-expect-error
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                  } catch (err) {
         
     | 
| 
      
 158 
     | 
    
         
            +
                    _iterator.e(err);
         
     | 
| 
      
 159 
     | 
    
         
            +
                  } finally {
         
     | 
| 
      
 160 
     | 
    
         
            +
                    _iterator.f();
         
     | 
| 
      
 161 
     | 
    
         
            +
                  }
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                  runner[key] = function (input, options) {
         
     | 
| 
      
 164 
     | 
    
         
            +
                    return cloneShape[key].run(input, _objectSpread({}, options));
         
     | 
| 
      
 165 
     | 
    
         
            +
                  };
         
     | 
| 
      
 166 
     | 
    
         
            +
                };
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                for (var key in cloneShape) {
         
     | 
| 
      
 169 
     | 
    
         
            +
                  _loop(key);
         
     | 
| 
      
 170 
     | 
    
         
            +
                }
         
     | 
| 
      
 171 
     | 
    
         
            +
              }
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
              return runner;
         
     | 
| 
      
 174 
     | 
    
         
            +
            };
         
     | 
| 
      
 175 
     | 
    
         
            +
            export var cloneHook = function cloneHook(hook) {
         
     | 
| 
      
 176 
     | 
    
         
            +
              if (isWaterfall(hook)) {
         
     | 
| 
      
 177 
     | 
    
         
            +
                return createWaterfall();
         
     | 
| 
      
 178 
     | 
    
         
            +
              }
         
     | 
| 
      
 179 
     | 
    
         
            +
             
     | 
| 
      
 180 
     | 
    
         
            +
              if (isAsyncWaterfall(hook)) {
         
     | 
| 
      
 181 
     | 
    
         
            +
                return createAsyncWaterfall();
         
     | 
| 
      
 182 
     | 
    
         
            +
              }
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
              if (isWorkflow(hook)) {
         
     | 
| 
      
 185 
     | 
    
         
            +
                return createWorkflow();
         
     | 
| 
      
 186 
     | 
    
         
            +
              }
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
      
 188 
     | 
    
         
            +
              if (isAsyncWorkflow(hook)) {
         
     | 
| 
      
 189 
     | 
    
         
            +
                return createAsyncWorkflow();
         
     | 
| 
      
 190 
     | 
    
         
            +
              }
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
              if (isParallelWorkflow(hook)) {
         
     | 
| 
      
 193 
     | 
    
         
            +
                return createParallelWorkflow();
         
     | 
| 
      
 194 
     | 
    
         
            +
              }
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
              if (isPipeline(hook)) {
         
     | 
| 
      
 197 
     | 
    
         
            +
                return createPipeline();
         
     | 
| 
      
 198 
     | 
    
         
            +
              }
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              throw new Error("Unknown hook: ".concat(hook));
         
     | 
| 
      
 201 
     | 
    
         
            +
            };
         
     | 
| 
      
 202 
     | 
    
         
            +
            export var cloneHooksMap = function cloneHooksMap(record) {
         
     | 
| 
      
 203 
     | 
    
         
            +
              if (!record) {
         
     | 
| 
      
 204 
     | 
    
         
            +
                return record;
         
     | 
| 
      
 205 
     | 
    
         
            +
              }
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
              var result = {};
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
              for (var key in record) {
         
     | 
| 
      
 210 
     | 
    
         
            +
                // eslint-disable-next-line @typescript-eslint/ban-ts-comment
         
     | 
| 
      
 211 
     | 
    
         
            +
                // @ts-expect-error
         
     | 
| 
      
 212 
     | 
    
         
            +
                result[key] = cloneHook(record[key]);
         
     | 
| 
      
 213 
     | 
    
         
            +
              }
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
              return result;
         
     | 
| 
      
 216 
     | 
    
         
            +
            };
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1,84 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
         
     | 
| 
      
 6 
     | 
    
         
            +
            import { createAsyncPipeline } from "../farrow-pipeline";
         
     | 
| 
      
 7 
     | 
    
         
            +
            var ASYNC_WATERFALL_SYMBOL = Symbol["for"]('MODERN_ASYNC_WATERFALL');
         
     | 
| 
      
 8 
     | 
    
         
            +
            export var getAsyncBrook = function getAsyncBrook(input) {
         
     | 
| 
      
 9 
     | 
    
         
            +
              if (typeof input === 'function') {
         
     | 
| 
      
 10 
     | 
    
         
            +
                return input;
         
     | 
| 
      
 11 
     | 
    
         
            +
              } else if (input && typeof input.middleware === 'function') {
         
     | 
| 
      
 12 
     | 
    
         
            +
                return input.middleware;
         
     | 
| 
      
 13 
     | 
    
         
            +
              }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              throw new Error("".concat(input, " is not a AsyncBrook or { brook: AsyncBrook }"));
         
     | 
| 
      
 16 
     | 
    
         
            +
            };
         
     | 
| 
      
 17 
     | 
    
         
            +
            export var createAsyncWaterfall = function createAsyncWaterfall() {
         
     | 
| 
      
 18 
     | 
    
         
            +
              var pipeline = createAsyncPipeline();
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              var use = function use() {
         
     | 
| 
      
 21 
     | 
    
         
            +
                for (var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++) {
         
     | 
| 
      
 22 
     | 
    
         
            +
                  input[_key] = arguments[_key];
         
     | 
| 
      
 23 
     | 
    
         
            +
                }
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                pipeline.use.apply(pipeline, _toConsumableArray(input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware)));
         
     | 
| 
      
 26 
     | 
    
         
            +
                return waterfall;
         
     | 
| 
      
 27 
     | 
    
         
            +
              };
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              var run = function run(input, options) {
         
     | 
| 
      
 30 
     | 
    
         
            +
                return pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
         
     | 
| 
      
 31 
     | 
    
         
            +
                  onLast: function onLast(input) {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    return input;
         
     | 
| 
      
 33 
     | 
    
         
            +
                  }
         
     | 
| 
      
 34 
     | 
    
         
            +
                }));
         
     | 
| 
      
 35 
     | 
    
         
            +
              };
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              var middleware = function middleware(input) {
         
     | 
| 
      
 38 
     | 
    
         
            +
                return pipeline.run(input, {
         
     | 
| 
      
 39 
     | 
    
         
            +
                  onLast: function onLast(input) {
         
     | 
| 
      
 40 
     | 
    
         
            +
                    return input;
         
     | 
| 
      
 41 
     | 
    
         
            +
                  }
         
     | 
| 
      
 42 
     | 
    
         
            +
                });
         
     | 
| 
      
 43 
     | 
    
         
            +
              };
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              var waterfall = _objectSpread(_objectSpread({}, pipeline), {}, _defineProperty({
         
     | 
| 
      
 46 
     | 
    
         
            +
                use: use,
         
     | 
| 
      
 47 
     | 
    
         
            +
                run: run,
         
     | 
| 
      
 48 
     | 
    
         
            +
                middleware: middleware
         
     | 
| 
      
 49 
     | 
    
         
            +
              }, ASYNC_WATERFALL_SYMBOL, true));
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              return waterfall;
         
     | 
| 
      
 52 
     | 
    
         
            +
            };
         
     | 
| 
      
 53 
     | 
    
         
            +
            export var isAsyncWaterfall = function isAsyncWaterfall(input) {
         
     | 
| 
      
 54 
     | 
    
         
            +
              return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WATERFALL_SYMBOL]);
         
     | 
| 
      
 55 
     | 
    
         
            +
            };
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            var mapAsyncBrookToAsyncMiddleware = function mapAsyncBrookToAsyncMiddleware(brook) {
         
     | 
| 
      
 58 
     | 
    
         
            +
              return /*#__PURE__*/function () {
         
     | 
| 
      
 59 
     | 
    
         
            +
                var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input, next) {
         
     | 
| 
      
 60 
     | 
    
         
            +
                  return _regeneratorRuntime().wrap(function _callee$(_context) {
         
     | 
| 
      
 61 
     | 
    
         
            +
                    while (1) {
         
     | 
| 
      
 62 
     | 
    
         
            +
                      switch (_context.prev = _context.next) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                        case 0:
         
     | 
| 
      
 64 
     | 
    
         
            +
                          _context.t0 = next;
         
     | 
| 
      
 65 
     | 
    
         
            +
                          _context.next = 3;
         
     | 
| 
      
 66 
     | 
    
         
            +
                          return brook(input);
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                        case 3:
         
     | 
| 
      
 69 
     | 
    
         
            +
                          _context.t1 = _context.sent;
         
     | 
| 
      
 70 
     | 
    
         
            +
                          return _context.abrupt("return", (0, _context.t0)(_context.t1));
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                        case 5:
         
     | 
| 
      
 73 
     | 
    
         
            +
                        case "end":
         
     | 
| 
      
 74 
     | 
    
         
            +
                          return _context.stop();
         
     | 
| 
      
 75 
     | 
    
         
            +
                      }
         
     | 
| 
      
 76 
     | 
    
         
            +
                    }
         
     | 
| 
      
 77 
     | 
    
         
            +
                  }, _callee);
         
     | 
| 
      
 78 
     | 
    
         
            +
                }));
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                return function (_x, _x2) {
         
     | 
| 
      
 81 
     | 
    
         
            +
                  return _ref.apply(this, arguments);
         
     | 
| 
      
 82 
     | 
    
         
            +
                };
         
     | 
| 
      
 83 
     | 
    
         
            +
              }();
         
     | 
| 
      
 84 
     | 
    
         
            +
            };
         
     | 
| 
         @@ -0,0 +1,59 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import { createPipeline } from "../farrow-pipeline";
         
     | 
| 
      
 5 
     | 
    
         
            +
            var WATERFALL_SYMBOL = Symbol["for"]('MODERN_WATERFALL');
         
     | 
| 
      
 6 
     | 
    
         
            +
            export var getBrook = function getBrook(input) {
         
     | 
| 
      
 7 
     | 
    
         
            +
              if (typeof input === 'function') {
         
     | 
| 
      
 8 
     | 
    
         
            +
                return input;
         
     | 
| 
      
 9 
     | 
    
         
            +
              } else if (input && typeof input.middleware === 'function') {
         
     | 
| 
      
 10 
     | 
    
         
            +
                return input.middleware;
         
     | 
| 
      
 11 
     | 
    
         
            +
              }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              throw new Error("".concat(input, " is not a Brook or { brook: Brook }"));
         
     | 
| 
      
 14 
     | 
    
         
            +
            };
         
     | 
| 
      
 15 
     | 
    
         
            +
            export var createWaterfall = function createWaterfall() {
         
     | 
| 
      
 16 
     | 
    
         
            +
              var pipeline = createPipeline();
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              var use = function use() {
         
     | 
| 
      
 19 
     | 
    
         
            +
                for (var _len = arguments.length, brooks = new Array(_len), _key = 0; _key < _len; _key++) {
         
     | 
| 
      
 20 
     | 
    
         
            +
                  brooks[_key] = arguments[_key];
         
     | 
| 
      
 21 
     | 
    
         
            +
                }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                pipeline.use.apply(pipeline, _toConsumableArray(brooks.map(getBrook).map(mapBrookToMiddleware)));
         
     | 
| 
      
 24 
     | 
    
         
            +
                return waterfall;
         
     | 
| 
      
 25 
     | 
    
         
            +
              };
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              var run = function run(input, options) {
         
     | 
| 
      
 28 
     | 
    
         
            +
                return pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
         
     | 
| 
      
 29 
     | 
    
         
            +
                  onLast: function onLast(input) {
         
     | 
| 
      
 30 
     | 
    
         
            +
                    return input;
         
     | 
| 
      
 31 
     | 
    
         
            +
                  }
         
     | 
| 
      
 32 
     | 
    
         
            +
                }));
         
     | 
| 
      
 33 
     | 
    
         
            +
              };
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              var middleware = function middleware(input) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                return pipeline.run(input, {
         
     | 
| 
      
 37 
     | 
    
         
            +
                  onLast: function onLast(input) {
         
     | 
| 
      
 38 
     | 
    
         
            +
                    return input;
         
     | 
| 
      
 39 
     | 
    
         
            +
                  }
         
     | 
| 
      
 40 
     | 
    
         
            +
                });
         
     | 
| 
      
 41 
     | 
    
         
            +
              };
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              var waterfall = _objectSpread(_objectSpread({}, pipeline), {}, _defineProperty({
         
     | 
| 
      
 44 
     | 
    
         
            +
                use: use,
         
     | 
| 
      
 45 
     | 
    
         
            +
                run: run,
         
     | 
| 
      
 46 
     | 
    
         
            +
                middleware: middleware
         
     | 
| 
      
 47 
     | 
    
         
            +
              }, WATERFALL_SYMBOL, true));
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              return waterfall;
         
     | 
| 
      
 50 
     | 
    
         
            +
            };
         
     | 
| 
      
 51 
     | 
    
         
            +
            export var isWaterfall = function isWaterfall(input) {
         
     | 
| 
      
 52 
     | 
    
         
            +
              return Boolean(input === null || input === void 0 ? void 0 : input[WATERFALL_SYMBOL]);
         
     | 
| 
      
 53 
     | 
    
         
            +
            };
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            var mapBrookToMiddleware = function mapBrookToMiddleware(brook) {
         
     | 
| 
      
 56 
     | 
    
         
            +
              return function (input, next) {
         
     | 
| 
      
 57 
     | 
    
         
            +
                return next(brook(input));
         
     | 
| 
      
 58 
     | 
    
         
            +
              };
         
     | 
| 
      
 59 
     | 
    
         
            +
            };
         
     |