@modern-js/plugin 1.3.7 → 1.4.0
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 +13 -0
- package/dist/js/modern/farrow-pipeline/context.js +14 -75
- package/dist/js/modern/farrow-pipeline/index.js +0 -14
- package/dist/js/modern/farrow-pipeline/pipeline.js +12 -29
- package/dist/js/modern/manager/async.js +4 -11
- package/dist/js/modern/manager/runner.js +1 -9
- package/dist/js/modern/manager/sync.js +8 -16
- package/dist/js/modern/waterfall/async.js +1 -3
- package/dist/js/modern/waterfall/sync.js +1 -3
- package/dist/js/modern/workflow/async.js +3 -3
- package/dist/js/modern/workflow/parallel.js +2 -2
- package/dist/js/modern/workflow/sync.js +3 -3
- package/dist/js/node/farrow-pipeline/context.js +15 -88
- package/dist/js/node/farrow-pipeline/pipeline.js +10 -45
- package/dist/js/node/manager/async.js +4 -12
- package/dist/js/node/manager/runner.js +1 -9
- package/dist/js/node/manager/sync.js +8 -15
- package/dist/js/node/waterfall/async.js +0 -2
- package/dist/js/node/waterfall/sync.js +0 -2
- package/dist/js/node/workflow/async.js +3 -3
- package/dist/js/node/workflow/parallel.js +2 -2
- package/dist/js/node/workflow/sync.js +3 -3
- package/dist/js/treeshaking/farrow-pipeline/context.js +14 -75
- package/dist/js/treeshaking/farrow-pipeline/index.js +0 -14
- package/dist/js/treeshaking/farrow-pipeline/pipeline.js +10 -29
- package/dist/js/treeshaking/manager/async.js +10 -17
- package/dist/js/treeshaking/manager/runner.js +1 -7
- package/dist/js/treeshaking/manager/sync.js +9 -17
- package/dist/js/treeshaking/waterfall/async.js +1 -3
- package/dist/js/treeshaking/waterfall/sync.js +1 -3
- package/dist/js/treeshaking/workflow/async.js +6 -6
- package/dist/js/treeshaking/workflow/parallel.js +5 -5
- package/dist/js/treeshaking/workflow/sync.js +3 -3
- package/dist/types/farrow-pipeline/context.d.ts +5 -20
- package/dist/types/farrow-pipeline/index.d.ts +0 -14
- package/dist/types/farrow-pipeline/pipeline.d.ts +5 -14
- package/dist/types/manager/async.d.ts +4 -7
- package/dist/types/manager/sync.d.ts +5 -9
- package/dist/types/manager/types.d.ts +1 -6
- package/dist/types/waterfall/async.d.ts +1 -7
- package/dist/types/waterfall/sync.d.ts +0 -7
- package/dist/types/workflow/async.d.ts +1 -7
- package/dist/types/workflow/parallel.d.ts +2 -9
- package/dist/types/workflow/sync.d.ts +1 -10
- package/package.json +1 -12
- package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +0 -74
- package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +0 -12
- package/dist/js/modern/farrow-pipeline/hook.js +0 -42
- package/dist/js/node/farrow-pipeline/asyncHooks.node.js +0 -93
- package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +0 -26
- package/dist/js/node/farrow-pipeline/hook.js +0 -52
- package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +0 -74
- package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +0 -12
- package/dist/js/treeshaking/farrow-pipeline/hook.js +0 -46
- package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +0 -2
- package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +0 -19
- package/dist/types/farrow-pipeline/hook.d.ts +0 -9
@@ -1,52 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.createHooks = void 0;
|
7
|
-
|
8
|
-
var _asyncHooksInterface = require("./asyncHooksInterface");
|
9
|
-
|
10
|
-
/**
|
11
|
-
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
12
|
-
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
13
|
-
*/
|
14
|
-
const createHooks = defaultHooks => {
|
15
|
-
let currentHooks = {};
|
16
|
-
const hooks = {};
|
17
|
-
|
18
|
-
for (const key in defaultHooks) {
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
20
|
-
const f = (...args) => {
|
21
|
-
var _asyncHooks$get;
|
22
|
-
|
23
|
-
const hooks = currentHooks === defaultHooks ? (_asyncHooks$get = _asyncHooksInterface.asyncHooks === null || _asyncHooksInterface.asyncHooks === void 0 ? void 0 : _asyncHooksInterface.asyncHooks.get()) !== null && _asyncHooks$get !== void 0 ? _asyncHooks$get : defaultHooks : currentHooks;
|
24
|
-
let handler = hooks[key];
|
25
|
-
|
26
|
-
if (typeof handler !== 'function') {
|
27
|
-
handler = defaultHooks[key];
|
28
|
-
}
|
29
|
-
|
30
|
-
return handler(...args);
|
31
|
-
};
|
32
|
-
|
33
|
-
hooks[key] = f;
|
34
|
-
}
|
35
|
-
|
36
|
-
const run = (f, implementations) => {
|
37
|
-
try {
|
38
|
-
currentHooks = implementations || defaultHooks;
|
39
|
-
_asyncHooksInterface.asyncHooks === null || _asyncHooksInterface.asyncHooks === void 0 ? void 0 : _asyncHooksInterface.asyncHooks.set(currentHooks);
|
40
|
-
return f();
|
41
|
-
} finally {
|
42
|
-
currentHooks = defaultHooks;
|
43
|
-
}
|
44
|
-
};
|
45
|
-
|
46
|
-
return {
|
47
|
-
run,
|
48
|
-
hooks
|
49
|
-
};
|
50
|
-
};
|
51
|
-
|
52
|
-
exports.createHooks = createHooks;
|
@@ -1,74 +0,0 @@
|
|
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 NodeAsyncHooks from 'async_hooks';
|
6
|
-
import * as asyncHooksInterface from "./asyncHooksInterface";
|
7
|
-
|
8
|
-
var createAsyncHooks = function createAsyncHooks() {
|
9
|
-
var store = new Map(); // eslint-disable-next-line node/no-unsupported-features/node-builtins
|
10
|
-
|
11
|
-
var hooks = NodeAsyncHooks.createHook({
|
12
|
-
init: function init(asyncId, _, triggerAsyncId) {
|
13
|
-
if (store.has(triggerAsyncId)) {
|
14
|
-
var value = store.get(triggerAsyncId);
|
15
|
-
|
16
|
-
if (value) {
|
17
|
-
store.set(asyncId, value);
|
18
|
-
}
|
19
|
-
}
|
20
|
-
},
|
21
|
-
destroy: function destroy(asyncId) {
|
22
|
-
if (store.has(asyncId)) {
|
23
|
-
store["delete"](asyncId);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
});
|
27
|
-
|
28
|
-
var set = function set(value) {
|
29
|
-
store.set(NodeAsyncHooks.executionAsyncId(), value);
|
30
|
-
};
|
31
|
-
|
32
|
-
var get = function get() {
|
33
|
-
return store.get(NodeAsyncHooks.executionAsyncId());
|
34
|
-
};
|
35
|
-
|
36
|
-
var clear = function clear() {
|
37
|
-
store.clear();
|
38
|
-
};
|
39
|
-
|
40
|
-
var enable = function enable() {
|
41
|
-
hooks.enable();
|
42
|
-
};
|
43
|
-
|
44
|
-
var disable = function disable() {
|
45
|
-
hooks.disable();
|
46
|
-
store.clear();
|
47
|
-
};
|
48
|
-
|
49
|
-
var entries = function entries() {
|
50
|
-
return store.entries();
|
51
|
-
};
|
52
|
-
|
53
|
-
return {
|
54
|
-
enable: enable,
|
55
|
-
disable: disable,
|
56
|
-
set: set,
|
57
|
-
get: get,
|
58
|
-
clear: clear,
|
59
|
-
entries: entries
|
60
|
-
};
|
61
|
-
};
|
62
|
-
|
63
|
-
export var enable = function enable() {
|
64
|
-
var hooks = createAsyncHooks();
|
65
|
-
disable();
|
66
|
-
asyncHooksInterface.impl(hooks);
|
67
|
-
hooks.enable();
|
68
|
-
};
|
69
|
-
export var disable = function disable() {
|
70
|
-
var _asyncHooksInterface$;
|
71
|
-
|
72
|
-
(_asyncHooksInterface$ = asyncHooksInterface.asyncHooks) === null || _asyncHooksInterface$ === void 0 ? void 0 : _asyncHooksInterface$.disable();
|
73
|
-
asyncHooksInterface.reset();
|
74
|
-
};
|
@@ -1,12 +0,0 @@
|
|
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
|
-
// eslint-disable-next-line import/no-mutable-exports
|
6
|
-
export var asyncHooks;
|
7
|
-
export var impl = function impl(implimentations) {
|
8
|
-
asyncHooks = implimentations;
|
9
|
-
};
|
10
|
-
export var reset = function reset() {
|
11
|
-
asyncHooks = undefined;
|
12
|
-
};
|
@@ -1,46 +0,0 @@
|
|
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 { asyncHooks } from "./asyncHooksInterface";
|
6
|
-
export var createHooks = function createHooks(defaultHooks) {
|
7
|
-
var currentHooks = {};
|
8
|
-
var hooks = {};
|
9
|
-
|
10
|
-
var _loop = function _loop(key) {
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
12
|
-
var f = function f() {
|
13
|
-
var _asyncHooks$get;
|
14
|
-
|
15
|
-
var hooks = currentHooks === defaultHooks ? (_asyncHooks$get = asyncHooks === null || asyncHooks === void 0 ? void 0 : asyncHooks.get()) !== null && _asyncHooks$get !== void 0 ? _asyncHooks$get : defaultHooks : currentHooks;
|
16
|
-
var handler = hooks[key];
|
17
|
-
|
18
|
-
if (typeof handler !== 'function') {
|
19
|
-
handler = defaultHooks[key];
|
20
|
-
}
|
21
|
-
|
22
|
-
return handler.apply(void 0, arguments);
|
23
|
-
};
|
24
|
-
|
25
|
-
hooks[key] = f;
|
26
|
-
};
|
27
|
-
|
28
|
-
for (var key in defaultHooks) {
|
29
|
-
_loop(key);
|
30
|
-
}
|
31
|
-
|
32
|
-
var run = function run(f, implementations) {
|
33
|
-
try {
|
34
|
-
currentHooks = implementations || defaultHooks;
|
35
|
-
asyncHooks === null || asyncHooks === void 0 ? void 0 : asyncHooks.set(currentHooks);
|
36
|
-
return f();
|
37
|
-
} finally {
|
38
|
-
currentHooks = defaultHooks;
|
39
|
-
}
|
40
|
-
};
|
41
|
-
|
42
|
-
return {
|
43
|
-
run: run,
|
44
|
-
hooks: hooks
|
45
|
-
};
|
46
|
-
};
|
@@ -1,19 +0,0 @@
|
|
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;
|
@@ -1,9 +0,0 @@
|
|
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
|
-
};
|