@modern-js/plugin 1.3.1 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +74 -0
- package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +12 -0
- package/dist/js/modern/farrow-pipeline/context.js +99 -0
- package/dist/js/modern/farrow-pipeline/counter.js +18 -0
- package/dist/js/modern/farrow-pipeline/hook.js +42 -0
- package/dist/js/modern/farrow-pipeline/index.js +19 -0
- package/dist/js/modern/farrow-pipeline/pipeline.js +93 -0
- package/dist/js/modern/index.js +1 -1
- package/dist/js/modern/manager/async.js +4 -4
- package/dist/js/modern/manager/runner.js +1 -1
- package/dist/js/modern/manager/sync.js +5 -6
- package/dist/js/modern/waterfall/async.js +4 -8
- package/dist/js/modern/waterfall/sync.js +4 -8
- package/dist/js/modern/workflow/async.js +1 -4
- package/dist/js/modern/workflow/parallel.js +2 -3
- package/dist/js/modern/workflow/sync.js +1 -1
- package/dist/js/node/farrow-pipeline/asyncHooks.node.js +93 -0
- package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +26 -0
- package/dist/js/node/farrow-pipeline/context.js +120 -0
- package/dist/js/node/farrow-pipeline/counter.js +27 -0
- package/dist/js/node/farrow-pipeline/hook.js +52 -0
- package/dist/js/node/farrow-pipeline/index.js +18 -0
- package/dist/js/node/farrow-pipeline/pipeline.js +129 -0
- package/dist/js/node/index.js +1 -1
- package/dist/js/node/manager/async.js +4 -4
- package/dist/js/node/manager/runner.js +1 -1
- package/dist/js/node/manager/sync.js +5 -6
- package/dist/js/node/waterfall/async.js +4 -8
- package/dist/js/node/waterfall/sync.js +4 -8
- package/dist/js/node/workflow/async.js +1 -4
- package/dist/js/node/workflow/parallel.js +2 -3
- package/dist/js/node/workflow/sync.js +1 -1
- package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +74 -0
- package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +12 -0
- package/dist/js/treeshaking/farrow-pipeline/context.js +103 -0
- package/dist/js/treeshaking/farrow-pipeline/counter.js +23 -0
- package/dist/js/treeshaking/farrow-pipeline/hook.js +46 -0
- package/dist/js/treeshaking/farrow-pipeline/index.js +19 -0
- package/dist/js/treeshaking/farrow-pipeline/pipeline.js +100 -0
- package/dist/js/treeshaking/index.js +1 -1
- package/dist/js/treeshaking/manager/async.js +8 -29
- package/dist/js/treeshaking/manager/runner.js +1 -1
- package/dist/js/treeshaking/manager/sync.js +9 -28
- package/dist/js/treeshaking/waterfall/async.js +12 -36
- package/dist/js/treeshaking/waterfall/sync.js +11 -31
- package/dist/js/treeshaking/workflow/async.js +6 -28
- package/dist/js/treeshaking/workflow/parallel.js +6 -26
- package/dist/js/treeshaking/workflow/sync.js +5 -24
- package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +2 -0
- package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +19 -0
- package/dist/types/farrow-pipeline/context.d.ts +28 -0
- package/dist/types/farrow-pipeline/counter.d.ts +11 -0
- package/dist/types/farrow-pipeline/hook.d.ts +9 -0
- package/dist/types/farrow-pipeline/index.d.ts +19 -0
- package/dist/types/farrow-pipeline/pipeline.d.ts +38 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/manager/runner.d.ts +1 -1
- package/dist/types/manager/sync.d.ts +1 -1
- package/dist/types/manager/types.d.ts +1 -1
- package/dist/types/waterfall/async.d.ts +1 -1
- package/dist/types/waterfall/sync.d.ts +1 -1
- package/dist/types/workflow/async.d.ts +1 -1
- package/dist/types/workflow/sync.d.ts +1 -1
- package/package.json +37 -10
- package/jest.config.js +0 -8
- package/modern.config.js +0 -2
- package/node.d.ts +0 -1
- package/node.js +0 -1
- package/tests/.eslintrc.js +0 -6
- package/tests/async.test.ts +0 -715
- package/tests/fixtures/async/base/bar.ts +0 -22
- package/tests/fixtures/async/base/foo.ts +0 -20
- package/tests/fixtures/async/base/fooManager.ts +0 -47
- package/tests/fixtures/async/core/index.ts +0 -174
- package/tests/fixtures/async/dynamic/bar.ts +0 -18
- package/tests/fixtures/async/dynamic/foo.ts +0 -27
- package/tests/fixtures/sync/base/bar.ts +0 -21
- package/tests/fixtures/sync/base/foo.ts +0 -20
- package/tests/fixtures/sync/base/fooManager.ts +0 -47
- package/tests/fixtures/sync/core/index.ts +0 -171
- package/tests/fixtures/sync/dynamic/bar.ts +0 -22
- package/tests/fixtures/sync/dynamic/foo.ts +0 -27
- package/tests/helpers.ts +0 -4
- package/tests/pipeline.test.ts +0 -607
- package/tests/sync.test.ts +0 -679
- package/tests/tsconfig.json +0 -13
- package/tests/waterfall.test.ts +0 -172
- package/tests/workflow.test.ts +0 -111
- package/tsconfig.json +0 -14
@@ -1,30 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
-
|
5
|
-
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; }
|
6
|
-
|
7
|
-
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; }
|
8
|
-
|
9
|
-
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; }
|
10
|
-
|
11
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
12
|
-
|
13
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
14
|
-
|
15
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
16
|
-
|
17
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
18
|
-
|
19
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
20
|
-
|
21
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
22
|
-
|
23
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
24
|
-
|
25
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
26
|
-
|
27
|
-
import { createAsyncPipeline } from 'farrow-pipeline';
|
7
|
+
import { createAsyncPipeline } from "../farrow-pipeline";
|
28
8
|
var ASYNC_WORKFLOW_SYMBOL = Symbol('ASYNC_WORKFLOW_SYMBOL');
|
29
9
|
export var isAsyncWorkflow = function isAsyncWorkflow(input) {
|
30
10
|
return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
|
@@ -124,7 +104,5 @@ var mapAsyncWorkerToAsyncMiddleware = function mapAsyncWorkerToAsyncMiddleware(w
|
|
124
104
|
};
|
125
105
|
|
126
106
|
function isPromise(obj) {
|
127
|
-
/* eslint-disable promise/prefer-await-to-then */
|
128
107
|
return Boolean(obj) && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
129
|
-
/* eslint-enable promise/prefer-await-to-then */
|
130
108
|
}
|
@@ -1,28 +1,9 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
1
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
|
3
|
-
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; }
|
4
|
-
|
5
|
-
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; }
|
6
|
-
|
7
|
-
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; }
|
8
|
-
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
10
|
-
|
11
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
12
|
-
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
|
-
|
15
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
16
|
-
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
-
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
20
|
-
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
22
|
-
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
24
|
-
|
25
|
-
import { createPipeline } from 'farrow-pipeline';
|
6
|
+
import { createPipeline } from "../farrow-pipeline";
|
26
7
|
var PARALLEL_WORKFLOW_SYMBOL = Symbol('PARALLEL_WORKFLOW_SYMBOL');
|
27
8
|
export var isParallelWorkflow = function isParallelWorkflow(input) {
|
28
9
|
return Boolean(input === null || input === void 0 ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
|
@@ -45,8 +26,7 @@ export var createParallelWorkflow = function createParallelWorkflow() {
|
|
45
26
|
while (1) {
|
46
27
|
switch (_context.prev = _context.next) {
|
47
28
|
case 0:
|
48
|
-
return _context.abrupt("return",
|
49
|
-
Promise.all(pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
|
29
|
+
return _context.abrupt("return", Promise.all(pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
|
50
30
|
onLast: function onLast() {
|
51
31
|
return [];
|
52
32
|
}
|
@@ -1,28 +1,9 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
1
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
|
3
|
-
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; }
|
4
|
-
|
5
|
-
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; }
|
6
|
-
|
7
|
-
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; }
|
8
|
-
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
10
|
-
|
11
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
12
|
-
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
|
-
|
15
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
16
|
-
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
-
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
20
|
-
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
22
|
-
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
24
|
-
|
25
|
-
import { createPipeline } from 'farrow-pipeline';
|
6
|
+
import { createPipeline } from "../farrow-pipeline";
|
26
7
|
var WORKFLOW_SYMBOL = Symbol('WORKFLOW_SYMBOL');
|
27
8
|
export var createWorkflow = function createWorkflow() {
|
28
9
|
var pipeline = createPipeline();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
export declare type AnyFn = (...args: any) => any;
|
6
|
+
export declare type Hooks = {
|
7
|
+
[key: string]: AnyFn;
|
8
|
+
};
|
9
|
+
export declare type AsyncHooks = {
|
10
|
+
enable: () => void;
|
11
|
+
disable: () => void;
|
12
|
+
set: (value: Hooks) => void;
|
13
|
+
get: () => Hooks | undefined;
|
14
|
+
clear: () => void;
|
15
|
+
entries: () => IterableIterator<[number, Hooks]>;
|
16
|
+
} | undefined;
|
17
|
+
export declare let asyncHooks: AsyncHooks;
|
18
|
+
export declare const impl: (implimentations: AsyncHooks) => void;
|
19
|
+
export declare const reset: () => void;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
declare const ContextSymbol: unique symbol;
|
2
|
+
export declare type Context<T = any> = {
|
3
|
+
id: symbol;
|
4
|
+
[ContextSymbol]: T;
|
5
|
+
create: (value: T) => Context<T>;
|
6
|
+
use: () => {
|
7
|
+
value: T;
|
8
|
+
};
|
9
|
+
get: () => T;
|
10
|
+
set: (value: T) => void;
|
11
|
+
};
|
12
|
+
export declare const createContext: <T>(value: T) => Context<T>;
|
13
|
+
export declare type ContextStorage = {
|
14
|
+
[key: string]: Context;
|
15
|
+
};
|
16
|
+
export declare type Container = {
|
17
|
+
read: <V>(Context: Context<V>) => V;
|
18
|
+
write: <V>(Context: Context<V>, value: V) => void;
|
19
|
+
};
|
20
|
+
export declare const createContainer: (ContextStorage?: ContextStorage) => Container;
|
21
|
+
export declare type Hooks = {
|
22
|
+
useContainer: () => Container;
|
23
|
+
};
|
24
|
+
export declare const runHooks: <F extends import("./asyncHooksInterface").AnyFn>(f: F, implementations: Hooks) => ReturnType<F>;
|
25
|
+
export declare const useContainer: () => Container;
|
26
|
+
export declare const fromContainer: (container: Container) => Hooks;
|
27
|
+
export declare const runWithContainer: <F extends (...args: any) => any>(f: F, container: Container) => ReturnType<F>;
|
28
|
+
export {};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
export declare type Next<I = unknown, O = unknown> = (input?: I) => O;
|
6
|
+
export declare type CounterCallback<I = unknown, O = unknown> = (index: number, input: I, next: Next<I, O>) => O;
|
7
|
+
export declare type Counter<I = unknown, O = unknown> = {
|
8
|
+
start: (input: I) => O;
|
9
|
+
dispatch: (index: number, input: I) => O;
|
10
|
+
};
|
11
|
+
export declare const createCounter: <I, O>(callback: CounterCallback<I, O>) => Counter<I, O>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
import { Hooks, AnyFn } from './asyncHooksInterface';
|
6
|
+
export declare const createHooks: <HS extends Hooks>(defaultHooks: HS) => {
|
7
|
+
run: <F extends AnyFn>(f: F, implementations: HS) => ReturnType<F>;
|
8
|
+
hooks: HS;
|
9
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*
|
5
|
+
* removed:
|
6
|
+
* - dependencies:
|
7
|
+
* - tslib
|
8
|
+
* - files
|
9
|
+
* - compose.ts
|
10
|
+
* - methods:
|
11
|
+
* - usePipeline
|
12
|
+
* - assertContainer
|
13
|
+
* - assertContext
|
14
|
+
* - isContext
|
15
|
+
* - isContainer
|
16
|
+
* - pipeline.useLazy
|
17
|
+
* - context.assert
|
18
|
+
*/
|
19
|
+
export * from './pipeline';
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
import { createContext, createContainer, ContextStorage, Context, Container, useContainer, runWithContainer } from './context';
|
6
|
+
import { Next } from './counter';
|
7
|
+
export type { Next };
|
8
|
+
export { createContext, createContainer, useContainer, runWithContainer };
|
9
|
+
export type { ContextStorage, Context, Container };
|
10
|
+
export declare type Middleware<I = unknown, O = unknown> = (input: I, next: Next<I, O>) => O;
|
11
|
+
export declare type Middlewares<I = unknown, O = unknown> = Middleware<I, O>[];
|
12
|
+
export declare const isPipeline: (input: any) => input is Pipeline<unknown, unknown>;
|
13
|
+
declare const PipelineSymbol: unique symbol;
|
14
|
+
export declare type PipelineOptions = {
|
15
|
+
contexts?: ContextStorage;
|
16
|
+
};
|
17
|
+
export declare type RunPipelineOptions<I = unknown, O = unknown> = {
|
18
|
+
container?: Container;
|
19
|
+
onLast?: (input: I) => O;
|
20
|
+
onLastWithContext?: boolean;
|
21
|
+
};
|
22
|
+
export declare type MiddlewareInput<I = unknown, O = unknown> = Middleware<I, O> | {
|
23
|
+
middleware: Middleware<I, O>;
|
24
|
+
};
|
25
|
+
export declare type MiddlewareType<T extends MiddlewareInput> = T extends MiddlewareInput<infer I, infer O> ? Middleware<I, O> : never;
|
26
|
+
export declare type Pipeline<I = unknown, O = unknown> = {
|
27
|
+
[PipelineSymbol]: true;
|
28
|
+
use: (...inputs: MiddlewareInput<I, O>[]) => Pipeline<I, O>;
|
29
|
+
run: (input: I, options?: RunPipelineOptions<I, O>) => O;
|
30
|
+
middleware: Middleware<I, O>;
|
31
|
+
};
|
32
|
+
export declare const createPipeline: <I, O>(options?: PipelineOptions | undefined) => Pipeline<I, O>;
|
33
|
+
export declare type PipelineInput<T extends Pipeline> = T extends Pipeline<infer I> ? I : never;
|
34
|
+
export declare type PipelineOutput<T extends Pipeline> = T extends Pipeline<any, infer O> ? O : never;
|
35
|
+
export declare type MaybeAsync<T> = T | Promise<T>;
|
36
|
+
export declare type ThunkMiddlewareInput<I, O> = () => MaybeAsync<MiddlewareInput<I, MaybeAsync<O>>>;
|
37
|
+
export declare type AsyncPipeline<I = unknown, O = unknown> = Pipeline<I, MaybeAsync<O>>;
|
38
|
+
export declare const createAsyncPipeline: <I, O>(options?: PipelineOptions | undefined) => AsyncPipeline<I, O>;
|
package/dist/types/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const RunnerContext: import("farrow-pipeline").Context<any>;
|
1
|
+
export declare const RunnerContext: import("../farrow-pipeline").Context<any>;
|
2
2
|
export declare const useRunner: () => any;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Pipeline, Container, MaybeAsync, Middleware, AsyncPipeline } from 'farrow-pipeline';
|
1
|
+
import type { Pipeline, Container, MaybeAsync, Middleware, AsyncPipeline } from '../farrow-pipeline';
|
2
2
|
import type { Brook, Waterfall, AsyncBrook, AsyncWaterfall } from '../waterfall';
|
3
3
|
import type { Worker, Workflow, AsyncWorker, AsyncWorkflow, ParallelWorkflow } from '../workflow';
|
4
4
|
/** All hook types. */
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MaybeAsync, Container } from 'farrow-pipeline';
|
1
|
+
import { MaybeAsync, Container } from '../farrow-pipeline';
|
2
2
|
declare const ASYNC_WATERFALL_SYMBOL: unique symbol;
|
3
3
|
export declare type AsyncBrook<I = unknown> = (I: I) => MaybeAsync<I>;
|
4
4
|
export declare type AsyncBrookInput<I = unknown> = AsyncBrook<I> | {
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.3.
|
14
|
+
"version": "1.3.4",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -27,16 +27,22 @@
|
|
27
27
|
"default": "./dist/js/treeshaking/index.js"
|
28
28
|
},
|
29
29
|
"./node": {
|
30
|
-
"jsnext:source": "./node.
|
31
|
-
"default": "./node.js"
|
30
|
+
"jsnext:source": "./src/farrow-pipeline/asyncHooks.node.ts",
|
31
|
+
"default": "./dist/js/node/farrow-pipeline/asyncHooks.node.js"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"typesVersions": {
|
35
|
+
"*": {
|
36
|
+
"node": [
|
37
|
+
"./dist/types/farrow-pipeline/asyncHooks.node.d.ts"
|
38
|
+
]
|
32
39
|
}
|
33
40
|
},
|
34
41
|
"dependencies": {
|
35
|
-
"@babel/runtime": "^7"
|
36
|
-
"farrow-pipeline": "^1.10.6"
|
42
|
+
"@babel/runtime": "^7"
|
37
43
|
},
|
38
44
|
"devDependencies": {
|
39
|
-
"@types/jest": "^
|
45
|
+
"@types/jest": "^27",
|
40
46
|
"@types/node": "^14",
|
41
47
|
"typescript": "^4",
|
42
48
|
"@scripts/build": "0.0.0",
|
@@ -46,14 +52,35 @@
|
|
46
52
|
"sideEffects": false,
|
47
53
|
"publishConfig": {
|
48
54
|
"registry": "https://registry.npmjs.org/",
|
49
|
-
"access": "public"
|
50
|
-
|
55
|
+
"access": "public"
|
56
|
+
},
|
57
|
+
"wireit": {
|
58
|
+
"build": {
|
59
|
+
"command": "modern build",
|
60
|
+
"files": [
|
61
|
+
"src/**/*",
|
62
|
+
"tsconfig.json",
|
63
|
+
"package.json"
|
64
|
+
],
|
65
|
+
"output": [
|
66
|
+
"dist/**/*"
|
67
|
+
]
|
68
|
+
},
|
69
|
+
"test": {
|
70
|
+
"command": "jest --passWithNoTests",
|
71
|
+
"files": [
|
72
|
+
"src/**/*",
|
73
|
+
"tsconfig.json",
|
74
|
+
"package.json"
|
75
|
+
],
|
76
|
+
"output": []
|
77
|
+
}
|
51
78
|
},
|
52
79
|
"scripts": {
|
53
80
|
"new": "modern new",
|
54
81
|
"dev": "modern build --watch",
|
55
|
-
"build": "
|
56
|
-
"test": "
|
82
|
+
"build": "wireit",
|
83
|
+
"test": "wireit"
|
57
84
|
},
|
58
85
|
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
59
86
|
}
|
package/jest.config.js
DELETED
package/modern.config.js
DELETED
package/node.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from 'farrow-pipeline/asyncHooks.node';
|
package/node.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
module.exports = require('farrow-pipeline/asyncHooks.node');
|