@modern-js/plugin 0.0.0-next-20221214061501 → 0.0.0-next-20221214100720
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 +4 -4
- package/dist/types/farrow-pipeline/context.d.ts +1 -1
- package/dist/types/farrow-pipeline/counter.d.ts +3 -3
- package/dist/types/farrow-pipeline/pipeline.d.ts +7 -7
- package/dist/types/manager/async.d.ts +3 -3
- package/dist/types/manager/sync.d.ts +3 -3
- package/dist/types/manager/types.d.ts +8 -8
- package/dist/types/waterfall/async.d.ts +6 -6
- package/dist/types/waterfall/sync.d.ts +6 -6
- package/dist/types/workflow/async.d.ts +3 -3
- package/dist/types/workflow/parallel.d.ts +1 -1
- package/dist/types/workflow/sync.d.ts +3 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# @modern-js/plugin
|
2
2
|
|
3
|
-
## 0.0.0-next-
|
3
|
+
## 0.0.0-next-20221214100720
|
4
4
|
|
5
5
|
### Major Changes
|
6
6
|
|
7
|
-
-
|
7
|
+
- dda38c9c3e: chore: v2
|
8
8
|
|
9
9
|
### Patch Changes
|
10
10
|
|
11
|
-
-
|
11
|
+
- b8bbe036c7: feat: change type logic
|
12
12
|
feat: 修改类型相关的逻辑
|
13
|
-
-
|
13
|
+
- f179749375: fix: the sortPlugins api not work
|
14
14
|
|
15
15
|
fix: sortPlugins 没有真实生效
|
16
16
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
3
|
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
4
|
*/
|
5
|
-
export type Context<T = any> = {
|
5
|
+
export declare type Context<T = any> = {
|
6
6
|
create: (value: T) => Context<T>;
|
7
7
|
use: () => {
|
8
8
|
value: T;
|
@@ -2,9 +2,9 @@
|
|
2
2
|
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
3
|
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
4
|
*/
|
5
|
-
export type Next<I = unknown, O = unknown> = (input?: I) => O;
|
6
|
-
export type CounterCallback<I = unknown, O = unknown> = (index: number, input: I, next: Next<I, O>) => O;
|
7
|
-
export type Counter<I = unknown, O = unknown> = {
|
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
8
|
start: (input: I) => O;
|
9
9
|
dispatch: (index: number, input: I) => O;
|
10
10
|
};
|
@@ -7,23 +7,23 @@ import { Next } from './counter';
|
|
7
7
|
export type { Next };
|
8
8
|
export { createContext };
|
9
9
|
export type { Context };
|
10
|
-
export type Middleware<I = unknown, O = unknown> = (input: I, next: Next<I, O>) => O;
|
11
|
-
export type Middlewares<I = unknown, O = unknown> = Middleware<I, O>[];
|
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
12
|
export declare const isPipeline: (input: any) => input is Pipeline<unknown, unknown>;
|
13
13
|
declare const PipelineSymbol: unique symbol;
|
14
|
-
export type RunPipelineOptions<I = unknown, O = unknown> = {
|
14
|
+
export declare type RunPipelineOptions<I = unknown, O = unknown> = {
|
15
15
|
onLast?: (input: I) => O;
|
16
16
|
};
|
17
|
-
export type MiddlewareInput<I = unknown, O = unknown> = Middleware<I, O> | {
|
17
|
+
export declare type MiddlewareInput<I = unknown, O = unknown> = Middleware<I, O> | {
|
18
18
|
middleware: Middleware<I, O>;
|
19
19
|
};
|
20
|
-
export type Pipeline<I = unknown, O = unknown> = {
|
20
|
+
export declare type Pipeline<I = unknown, O = unknown> = {
|
21
21
|
[PipelineSymbol]: true;
|
22
22
|
use: (...inputs: MiddlewareInput<I, O>[]) => Pipeline<I, O>;
|
23
23
|
run: (input: I, options?: RunPipelineOptions<I, O>) => O;
|
24
24
|
middleware: Middleware<I, O>;
|
25
25
|
};
|
26
26
|
export declare const createPipeline: <I, O>() => Pipeline<I, O>;
|
27
|
-
export type MaybeAsync<T> = T | Promise<T>;
|
28
|
-
export type AsyncPipeline<I = unknown, O = unknown> = Pipeline<I, MaybeAsync<O>>;
|
27
|
+
export declare type MaybeAsync<T> = T | Promise<T>;
|
28
|
+
export declare type AsyncPipeline<I = unknown, O = unknown> = Pipeline<I, MaybeAsync<O>>;
|
29
29
|
export declare const createAsyncPipeline: <I, O>() => AsyncPipeline<I, O>;
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { ToRunners, ToThreads, CommonAPI, PluginOptions } from './types';
|
2
2
|
/** Setup function of async plugin. */
|
3
3
|
|
4
|
-
export type AsyncSetup<Hooks, API = Record<string, never>> = (api: API & CommonAPI<Hooks>) => Partial<ToThreads<Hooks>> | Promise<Partial<ToThreads<Hooks>> | void> | void;
|
4
|
+
export declare type AsyncSetup<Hooks, API = Record<string, never>> = (api: API & CommonAPI<Hooks>) => Partial<ToThreads<Hooks>> | Promise<Partial<ToThreads<Hooks>> | void> | void;
|
5
5
|
declare const ASYNC_PLUGIN_SYMBOL = "ASYNC_PLUGIN_SYMBOL";
|
6
|
-
export type AsyncPlugin<Hooks, API> = {
|
6
|
+
export declare type AsyncPlugin<Hooks, API> = {
|
7
7
|
ASYNC_PLUGIN_SYMBOL: typeof ASYNC_PLUGIN_SYMBOL;
|
8
8
|
} & Required<PluginOptions<Hooks, AsyncSetup<Hooks, API>>>;
|
9
|
-
export type AsyncManager<Hooks, API> = {
|
9
|
+
export declare type AsyncManager<Hooks, API> = {
|
10
10
|
/**
|
11
11
|
* Create a sync plugin.
|
12
12
|
* @param setup the setup function.
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { Hook, CommonAPI, ToRunners, ToThreads, PluginOptions } from './types';
|
2
2
|
/** Setup function of sync plugin. */
|
3
3
|
|
4
|
-
export type Setup<Hooks, API = Record<string, never>> = (api: API) => Partial<ToThreads<Hooks>> | void;
|
4
|
+
export declare type Setup<Hooks, API = Record<string, never>> = (api: API) => Partial<ToThreads<Hooks>> | void;
|
5
5
|
declare const SYNC_PLUGIN_SYMBOL = "SYNC_PLUGIN_SYMBOL";
|
6
|
-
export type Plugin<Hooks, API> = {
|
6
|
+
export declare type Plugin<Hooks, API> = {
|
7
7
|
SYNC_PLUGIN_SYMBOL: typeof SYNC_PLUGIN_SYMBOL;
|
8
8
|
} & Required<PluginOptions<Hooks, Setup<Hooks, API>>>;
|
9
|
-
export type Manager<Hooks, API> = {
|
9
|
+
export declare type Manager<Hooks, API> = {
|
10
10
|
/**
|
11
11
|
* Create a sync plugin.
|
12
12
|
* @param setup the setup function.
|
@@ -3,23 +3,23 @@ import type { Brook, Waterfall, AsyncBrook, AsyncWaterfall } from '../waterfall'
|
|
3
3
|
import type { Worker, Workflow, AsyncWorker, AsyncWorkflow, ParallelWorkflow } from '../workflow';
|
4
4
|
/** All hook types. */
|
5
5
|
|
6
|
-
export type Hook = Waterfall<any> | AsyncWaterfall<any> | Workflow<any, any> | AsyncWorkflow<any, any> | ParallelWorkflow<any> | Pipeline<any, any> | AsyncPipeline<any, any>;
|
7
|
-
export type HooksMap = Record<string, Hook>;
|
6
|
+
export declare type Hook = Waterfall<any> | AsyncWaterfall<any> | Workflow<any, any> | AsyncWorkflow<any, any> | ParallelWorkflow<any> | Pipeline<any, any> | AsyncPipeline<any, any>;
|
7
|
+
export declare type HooksMap = Record<string, Hook>;
|
8
8
|
/** Extract the type of callback function from a hook. */
|
9
9
|
|
10
|
-
export type ToThread<P extends Hook> = P extends Workflow<infer I, infer O> ? Worker<I, O> : P extends AsyncWorkflow<infer I, infer O> ? AsyncWorker<I, O> : P extends ParallelWorkflow<infer I, infer O> ? AsyncWorker<I, O> : P extends Waterfall<infer I> ? Brook<I> : P extends AsyncWaterfall<infer I> ? AsyncBrook<I> : P extends Pipeline<infer I, infer O> ? Middleware<I, O> : P extends AsyncPipeline<infer I, infer O> ? Middleware<I, MaybeAsync<O>> : never;
|
10
|
+
export declare type ToThread<P extends Hook> = P extends Workflow<infer I, infer O> ? Worker<I, O> : P extends AsyncWorkflow<infer I, infer O> ? AsyncWorker<I, O> : P extends ParallelWorkflow<infer I, infer O> ? AsyncWorker<I, O> : P extends Waterfall<infer I> ? Brook<I> : P extends AsyncWaterfall<infer I> ? AsyncBrook<I> : P extends Pipeline<infer I, infer O> ? Middleware<I, O> : P extends AsyncPipeline<infer I, infer O> ? Middleware<I, MaybeAsync<O>> : never;
|
11
11
|
/** Extract types of callback function from hooks. */
|
12
12
|
|
13
|
-
export type ToThreads<PS> = { [K in keyof PS]: PS[K] extends Hook ? ToThread<PS[K]> : PS[K] extends void ? void : never };
|
13
|
+
export declare type ToThreads<PS> = { [K in keyof PS]: PS[K] extends Hook ? ToThread<PS[K]> : PS[K] extends void ? void : never };
|
14
14
|
/** Extract run method from a hook. */
|
15
15
|
|
16
|
-
export type RunnerFromHook<P extends Hook> = P extends Waterfall<infer I> ? Waterfall<I>['run'] : P extends AsyncWaterfall<infer I> ? AsyncWaterfall<I>['run'] : P extends Workflow<infer I, infer O> ? Workflow<I, O>['run'] : P extends AsyncWorkflow<infer I, infer O> ? AsyncWorkflow<I, O>['run'] : P extends ParallelWorkflow<infer I, infer O> ? ParallelWorkflow<I, O>['run'] : P extends Pipeline<infer I, infer O> ? Pipeline<I, O>['run'] : P extends AsyncPipeline<infer I, infer O> ? AsyncPipeline<I, O>['run'] : never;
|
16
|
+
export declare type RunnerFromHook<P extends Hook> = P extends Waterfall<infer I> ? Waterfall<I>['run'] : P extends AsyncWaterfall<infer I> ? AsyncWaterfall<I>['run'] : P extends Workflow<infer I, infer O> ? Workflow<I, O>['run'] : P extends AsyncWorkflow<infer I, infer O> ? AsyncWorkflow<I, O>['run'] : P extends ParallelWorkflow<infer I, infer O> ? ParallelWorkflow<I, O>['run'] : P extends Pipeline<infer I, infer O> ? Pipeline<I, O>['run'] : P extends AsyncPipeline<infer I, infer O> ? AsyncPipeline<I, O>['run'] : never;
|
17
17
|
/** Extract all run methods from hooks. */
|
18
18
|
|
19
|
-
export type ToRunners<PS> = { [K in keyof PS]: PS[K] extends Hook ? RunnerFromHook<PS[K]> : PS[K] extends void ? void : never };
|
19
|
+
export declare type ToRunners<PS> = { [K in keyof PS]: PS[K] extends Hook ? RunnerFromHook<PS[K]> : PS[K] extends void ? void : never };
|
20
20
|
/** All options to define a plugin. */
|
21
21
|
|
22
|
-
export type PluginOptions<Hooks, Setup = undefined, ExtendHooks = Record<string, unknown>> = {
|
22
|
+
export declare type PluginOptions<Hooks, Setup = undefined, ExtendHooks = Record<string, unknown>> = {
|
23
23
|
name?: string;
|
24
24
|
pre?: string[];
|
25
25
|
post?: string[];
|
@@ -31,6 +31,6 @@ export type PluginOptions<Hooks, Setup = undefined, ExtendHooks = Record<string,
|
|
31
31
|
};
|
32
32
|
/** Common api of setup function. */
|
33
33
|
|
34
|
-
export type CommonAPI<Hooks> = {
|
34
|
+
export declare type CommonAPI<Hooks> = {
|
35
35
|
useHookRunners: () => ToRunners<Hooks>;
|
36
36
|
};
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import { MaybeAsync } from '../farrow-pipeline';
|
2
2
|
declare const ASYNC_WATERFALL_SYMBOL: unique symbol;
|
3
|
-
export type AsyncBrook<I = unknown> = (I: I) => MaybeAsync<I>;
|
4
|
-
export type AsyncBrookInput<I = unknown> = AsyncBrook<I> | {
|
3
|
+
export declare type AsyncBrook<I = unknown> = (I: I) => MaybeAsync<I>;
|
4
|
+
export declare type AsyncBrookInput<I = unknown> = AsyncBrook<I> | {
|
5
5
|
middleware: AsyncBrook<I>;
|
6
6
|
};
|
7
|
-
export type AsyncBrooks<I = unknown> = AsyncBrook<I>[];
|
8
|
-
export type AsyncBrookInputs<I = unknown> = AsyncBrookInput<I>[];
|
7
|
+
export declare type AsyncBrooks<I = unknown> = AsyncBrook<I>[];
|
8
|
+
export declare type AsyncBrookInputs<I = unknown> = AsyncBrookInput<I>[];
|
9
9
|
export declare const getAsyncBrook: <I>(input: AsyncBrookInput<I>) => AsyncBrook<I>;
|
10
|
-
export type RunAsyncWaterfallOptions<I = unknown> = {
|
10
|
+
export declare type RunAsyncWaterfallOptions<I = unknown> = {
|
11
11
|
onLast?: AsyncBrook<I>;
|
12
12
|
};
|
13
|
-
export type AsyncWaterfall<I> = {
|
13
|
+
export declare type AsyncWaterfall<I> = {
|
14
14
|
run: (input: I, options?: RunAsyncWaterfallOptions<I>) => MaybeAsync<I>;
|
15
15
|
use: (...I: AsyncBrookInputs<I>) => AsyncWaterfall<I>;
|
16
16
|
middleware: AsyncBrook<I>;
|
@@ -1,15 +1,15 @@
|
|
1
1
|
declare const WATERFALL_SYMBOL: unique symbol;
|
2
|
-
export type Brook<I = unknown> = (I: I) => I;
|
3
|
-
export type BrookInput<I = unknown> = Brook<I> | {
|
2
|
+
export declare type Brook<I = unknown> = (I: I) => I;
|
3
|
+
export declare type BrookInput<I = unknown> = Brook<I> | {
|
4
4
|
middleware: Brook<I>;
|
5
5
|
};
|
6
|
-
export type Brooks<I = unknown> = Brook<I>[];
|
7
|
-
export type BrookInputs<I = unknown> = BrookInput<I>[];
|
6
|
+
export declare type Brooks<I = unknown> = Brook<I>[];
|
7
|
+
export declare type BrookInputs<I = unknown> = BrookInput<I>[];
|
8
8
|
export declare const getBrook: <I>(input: BrookInput<I>) => Brook<I>;
|
9
|
-
export type RunWaterfallOptions<I = unknown> = {
|
9
|
+
export declare type RunWaterfallOptions<I = unknown> = {
|
10
10
|
onLast?: Brook<I>;
|
11
11
|
};
|
12
|
-
export type Waterfall<I = void> = {
|
12
|
+
export declare type Waterfall<I = void> = {
|
13
13
|
run: (input: I, options?: RunWaterfallOptions<I>) => I;
|
14
14
|
use: (...I: BrookInputs<I>) => Waterfall<I>;
|
15
15
|
middleware: Brook<I>;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { MaybeAsync } from '../farrow-pipeline';
|
2
2
|
declare const ASYNC_WORKFLOW_SYMBOL: unique symbol;
|
3
|
-
export type AsyncWorker<I, O> = (I: I) => MaybeAsync<O>;
|
4
|
-
export type AsyncWorkers<I, O> = AsyncWorker<I, O>[];
|
5
|
-
export type AsyncWorkflow<I, O> = {
|
3
|
+
export declare type AsyncWorker<I, O> = (I: I) => MaybeAsync<O>;
|
4
|
+
export declare type AsyncWorkers<I, O> = AsyncWorker<I, O>[];
|
5
|
+
export declare type AsyncWorkflow<I, O> = {
|
6
6
|
run: (input: I) => MaybeAsync<O[]>;
|
7
7
|
use: (...I: AsyncWorkers<I, O>) => AsyncWorkflow<I, O>;
|
8
8
|
[ASYNC_WORKFLOW_SYMBOL]: true;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AsyncWorkers } from './async';
|
2
2
|
declare const PARALLEL_WORKFLOW_SYMBOL: unique symbol;
|
3
|
-
export type ParallelWorkflow<I, O = any> = {
|
3
|
+
export declare type ParallelWorkflow<I, O = any> = {
|
4
4
|
run: (input: I) => Promise<O[]>;
|
5
5
|
use: (...I: AsyncWorkers<I, O>) => ParallelWorkflow<I, O>;
|
6
6
|
[PARALLEL_WORKFLOW_SYMBOL]: true;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
declare const WORKFLOW_SYMBOL: unique symbol;
|
2
|
-
export type Worker<I, O> = (I: I) => O;
|
3
|
-
export type Workers<I, O> = Worker<I, O>[];
|
4
|
-
export type Workflow<I, O> = {
|
2
|
+
export declare type Worker<I, O> = (I: I) => O;
|
3
|
+
export declare type Workers<I, O> = Worker<I, O>[];
|
4
|
+
export declare type Workflow<I, O> = {
|
5
5
|
run: (input: I) => O[];
|
6
6
|
use: (...I: Workers<I, O>) => Workflow<I, O>;
|
7
7
|
[WORKFLOW_SYMBOL]: true;
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "0.0.0-next-
|
14
|
+
"version": "0.0.0-next-20221214100720",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -36,8 +36,8 @@
|
|
36
36
|
"@types/node": "^14",
|
37
37
|
"typescript": "^4",
|
38
38
|
"jest": "^27",
|
39
|
-
"@scripts/build": "0.0.0-next-
|
40
|
-
"@scripts/jest-config": "0.0.0-next-
|
39
|
+
"@scripts/build": "0.0.0-next-20221214100720",
|
40
|
+
"@scripts/jest-config": "0.0.0-next-20221214100720"
|
41
41
|
},
|
42
42
|
"sideEffects": false,
|
43
43
|
"publishConfig": {
|