@modern-js/plugin 2.35.0 → 2.36.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/dist/cjs/farrow-pipeline/context.js +24 -7
- package/dist/cjs/farrow-pipeline/counter.js +24 -7
- package/dist/cjs/farrow-pipeline/index.js +34 -30
- package/dist/cjs/index.js +26 -7
- package/dist/cjs/manager/async.js +39 -20
- package/dist/cjs/manager/index.js +24 -6
- package/dist/cjs/manager/shared.js +33 -26
- package/dist/cjs/manager/sync.js +53 -47
- package/dist/cjs/manager/types.js +15 -3
- package/dist/cjs/waterfall/async.js +30 -24
- package/dist/cjs/waterfall/index.js +22 -5
- package/dist/cjs/waterfall/sync.js +30 -24
- package/dist/cjs/workflow/async.js +29 -24
- package/dist/cjs/workflow/index.js +24 -6
- package/dist/cjs/workflow/parallel.js +28 -21
- package/dist/cjs/workflow/sync.js +28 -21
- package/dist/esm/index.js +129 -63
- package/dist/esm-node/farrow-pipeline/context.js +4 -1
- package/dist/esm-node/farrow-pipeline/counter.js +4 -1
- package/dist/esm-node/farrow-pipeline/index.js +10 -9
- package/dist/esm-node/manager/async.js +11 -6
- package/dist/esm-node/manager/shared.js +12 -5
- package/dist/esm-node/manager/sync.js +13 -7
- package/dist/esm-node/manager/types.js +0 -1
- package/dist/esm-node/waterfall/async.js +8 -6
- package/dist/esm-node/waterfall/sync.js +8 -6
- package/dist/esm-node/workflow/async.js +7 -8
- package/dist/esm-node/workflow/parallel.js +6 -5
- package/dist/esm-node/workflow/sync.js +6 -5
- package/package.json +4 -4
@@ -1,13 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var context_exports = {};
|
20
|
+
__export(context_exports, {
|
21
|
+
createContext: () => createContext
|
10
22
|
});
|
23
|
+
module.exports = __toCommonJS(context_exports);
|
11
24
|
const createContext = (value) => {
|
12
25
|
let currentValue = value;
|
13
26
|
return {
|
@@ -25,3 +38,7 @@ const createContext = (value) => {
|
|
25
38
|
}
|
26
39
|
};
|
27
40
|
};
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
42
|
+
0 && (module.exports = {
|
43
|
+
createContext
|
44
|
+
});
|
@@ -1,13 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var counter_exports = {};
|
20
|
+
__export(counter_exports, {
|
21
|
+
createCounter: () => createCounter
|
10
22
|
});
|
23
|
+
module.exports = __toCommonJS(counter_exports);
|
11
24
|
const createCounter = (callback) => {
|
12
25
|
const dispatch = (index, input) => {
|
13
26
|
const next = (nextInput = input) => dispatch(index + 1, nextInput);
|
@@ -18,3 +31,7 @@ const createCounter = (callback) => {
|
|
18
31
|
dispatch
|
19
32
|
};
|
20
33
|
};
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
35
|
+
0 && (module.exports = {
|
36
|
+
createCounter
|
37
|
+
});
|
@@ -1,34 +1,32 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return _context.createContext;
|
15
|
-
},
|
16
|
-
isPipeline: function() {
|
17
|
-
return isPipeline;
|
18
|
-
},
|
19
|
-
createPipeline: function() {
|
20
|
-
return createPipeline;
|
21
|
-
},
|
22
|
-
createAsyncPipeline: function() {
|
23
|
-
return createAsyncPipeline;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
24
15
|
}
|
25
|
-
|
26
|
-
const _context = require("./context");
|
27
|
-
const _counter = require("./counter");
|
28
|
-
const isPipeline = (input) => {
|
29
|
-
var _input;
|
30
|
-
return Boolean((_input = input) === null || _input === void 0 ? void 0 : _input[PipelineSymbol]);
|
16
|
+
return to;
|
31
17
|
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var farrow_pipeline_exports = {};
|
20
|
+
__export(farrow_pipeline_exports, {
|
21
|
+
createAsyncPipeline: () => createAsyncPipeline,
|
22
|
+
createContext: () => import_context.createContext,
|
23
|
+
createPipeline: () => createPipeline,
|
24
|
+
isPipeline: () => isPipeline
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(farrow_pipeline_exports);
|
27
|
+
var import_context = require("./context");
|
28
|
+
var import_counter = require("./counter");
|
29
|
+
const isPipeline = (input) => Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
|
32
30
|
const PipelineSymbol = Symbol.for("MODERN_PIPELINE");
|
33
31
|
const getMiddleware = (input) => {
|
34
32
|
if (typeof input === "function") {
|
@@ -45,7 +43,7 @@ const createPipeline = () => {
|
|
45
43
|
return pipeline;
|
46
44
|
};
|
47
45
|
const createCurrentCounter = (onLast) => {
|
48
|
-
return (0,
|
46
|
+
return (0, import_counter.createCounter)((index, input, next) => {
|
49
47
|
if (index >= middlewares.length) {
|
50
48
|
if (onLast) {
|
51
49
|
return onLast(input);
|
@@ -57,11 +55,10 @@ const createPipeline = () => {
|
|
57
55
|
};
|
58
56
|
const currentCounter = createCurrentCounter();
|
59
57
|
const getCounter = (options) => {
|
60
|
-
var _options;
|
61
58
|
if (!options) {
|
62
59
|
return currentCounter;
|
63
60
|
}
|
64
|
-
return createCurrentCounter(
|
61
|
+
return createCurrentCounter(options === null || options === void 0 ? void 0 : options.onLast);
|
65
62
|
};
|
66
63
|
const run = (input, options) => getCounter(options).start(input);
|
67
64
|
const middleware = (input, next) => run(input, {
|
@@ -81,3 +78,10 @@ const createAsyncPipeline = () => {
|
|
81
78
|
...pipeline
|
82
79
|
};
|
83
80
|
};
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
82
|
+
0 && (module.exports = {
|
83
|
+
createAsyncPipeline,
|
84
|
+
createContext,
|
85
|
+
createPipeline,
|
86
|
+
isPipeline
|
87
|
+
});
|
package/dist/cjs/index.js
CHANGED
@@ -1,9 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
16
|
+
var src_exports = {};
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
18
|
+
__reExport(src_exports, require("./farrow-pipeline"), module.exports);
|
19
|
+
__reExport(src_exports, require("./waterfall"), module.exports);
|
20
|
+
__reExport(src_exports, require("./workflow"), module.exports);
|
21
|
+
__reExport(src_exports, require("./manager"), module.exports);
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
23
|
+
0 && (module.exports = {
|
24
|
+
...require("./farrow-pipeline"),
|
25
|
+
...require("./waterfall"),
|
26
|
+
...require("./workflow"),
|
27
|
+
...require("./manager")
|
4
28
|
});
|
5
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
-
_export_star._(require("./farrow-pipeline"), exports);
|
7
|
-
_export_star._(require("./waterfall"), exports);
|
8
|
-
_export_star._(require("./workflow"), exports);
|
9
|
-
_export_star._(require("./manager"), exports);
|
@@ -1,15 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
Object.
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
9
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var async_exports = {};
|
20
|
+
__export(async_exports, {
|
21
|
+
createAsyncManager: () => createAsyncManager
|
10
22
|
});
|
11
|
-
|
12
|
-
|
23
|
+
module.exports = __toCommonJS(async_exports);
|
24
|
+
var import_sync = require("./sync");
|
25
|
+
var import_shared = require("./shared");
|
13
26
|
const ASYNC_PLUGIN_SYMBOL = "ASYNC_PLUGIN_SYMBOL";
|
14
27
|
const createAsyncManager = (hooks, api) => {
|
15
28
|
let index = 0;
|
@@ -24,7 +37,7 @@ const createAsyncManager = (hooks, api) => {
|
|
24
37
|
...currentHooks
|
25
38
|
};
|
26
39
|
};
|
27
|
-
const isPlugin = (input) => (0,
|
40
|
+
const isPlugin = (input) => (0, import_shared.isObject)(input) && (0, import_shared.hasOwnProperty)(input, ASYNC_PLUGIN_SYMBOL) && input[ASYNC_PLUGIN_SYMBOL] === ASYNC_PLUGIN_SYMBOL;
|
28
41
|
const pluginAPI = {
|
29
42
|
...api,
|
30
43
|
useHookRunners: useRunner
|
@@ -32,7 +45,7 @@ const createAsyncManager = (hooks, api) => {
|
|
32
45
|
const clone = (overrideAPI) => {
|
33
46
|
let plugins = [];
|
34
47
|
const addPlugin = (plugin) => {
|
35
|
-
if (!(0,
|
48
|
+
if (!(0, import_shared.includePlugin)(plugins, plugin)) {
|
36
49
|
plugins.push({
|
37
50
|
...plugin
|
38
51
|
});
|
@@ -45,7 +58,7 @@ const createAsyncManager = (hooks, api) => {
|
|
45
58
|
} else if (typeof plugin === "function") {
|
46
59
|
const options = plugin();
|
47
60
|
addPlugin(createPlugin(options.setup, options));
|
48
|
-
} else if ((0,
|
61
|
+
} else if ((0, import_shared.isObject)(plugin)) {
|
49
62
|
addPlugin(createPlugin(plugin.setup, plugin));
|
50
63
|
} else if (process.env.NODE_ENV !== "production") {
|
51
64
|
console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
|
@@ -65,7 +78,7 @@ const createAsyncManager = (hooks, api) => {
|
|
65
78
|
registerHook(options.registerHook);
|
66
79
|
}
|
67
80
|
return {
|
68
|
-
...
|
81
|
+
...import_sync.DEFAULT_OPTIONS,
|
69
82
|
name: `No.${index++} plugin`,
|
70
83
|
...options,
|
71
84
|
ASYNC_PLUGIN_SYMBOL,
|
@@ -75,17 +88,19 @@ const createAsyncManager = (hooks, api) => {
|
|
75
88
|
const clear = () => {
|
76
89
|
plugins = [];
|
77
90
|
};
|
78
|
-
const init = () => {
|
79
|
-
const sortedPlugins = (0,
|
91
|
+
const init = async () => {
|
92
|
+
const sortedPlugins = (0, import_shared.sortPlugins)(plugins);
|
80
93
|
const mergedPluginAPI = {
|
81
94
|
...pluginAPI,
|
82
95
|
...overrideAPI
|
83
96
|
};
|
84
|
-
(0,
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
}
|
97
|
+
(0, import_shared.checkPlugins)(sortedPlugins);
|
98
|
+
const hooksList = [];
|
99
|
+
for (const plugin of sortedPlugins) {
|
100
|
+
hooksList.push(await plugin.setup(mergedPluginAPI));
|
101
|
+
}
|
102
|
+
runners = (0, import_sync.generateRunner)(hooksList, currentHooks);
|
103
|
+
return runners;
|
89
104
|
};
|
90
105
|
const run = (cb) => cb();
|
91
106
|
const manager = {
|
@@ -103,3 +118,7 @@ const createAsyncManager = (hooks, api) => {
|
|
103
118
|
};
|
104
119
|
return clone();
|
105
120
|
};
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
122
|
+
0 && (module.exports = {
|
123
|
+
createAsyncManager
|
124
|
+
});
|
@@ -1,8 +1,26 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
16
|
+
var manager_exports = {};
|
17
|
+
module.exports = __toCommonJS(manager_exports);
|
18
|
+
__reExport(manager_exports, require("./sync"), module.exports);
|
19
|
+
__reExport(manager_exports, require("./async"), module.exports);
|
20
|
+
__reExport(manager_exports, require("./types"), module.exports);
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
22
|
+
0 && (module.exports = {
|
23
|
+
...require("./sync"),
|
24
|
+
...require("./async"),
|
25
|
+
...require("./types")
|
4
26
|
});
|
5
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
-
_export_star._(require("./sync"), exports);
|
7
|
-
_export_star._(require("./async"), exports);
|
8
|
-
_export_star._(require("./types"), exports);
|
@@ -1,32 +1,31 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return checkPlugins;
|
15
|
-
},
|
16
|
-
sortPlugins: function() {
|
17
|
-
return sortPlugins;
|
18
|
-
},
|
19
|
-
includePlugin: function() {
|
20
|
-
return includePlugin;
|
21
|
-
},
|
22
|
-
isObject: function() {
|
23
|
-
return isObject;
|
24
|
-
},
|
25
|
-
hasOwnProperty: function() {
|
26
|
-
return hasOwnProperty;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
27
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var shared_exports = {};
|
20
|
+
__export(shared_exports, {
|
21
|
+
checkPlugins: () => checkPlugins,
|
22
|
+
hasOwnProperty: () => hasOwnProperty,
|
23
|
+
includePlugin: () => includePlugin,
|
24
|
+
isObject: () => isObject,
|
25
|
+
sortPlugins: () => sortPlugins
|
28
26
|
});
|
29
|
-
|
27
|
+
module.exports = __toCommonJS(shared_exports);
|
28
|
+
var import_plugin_dag_sort = require("@modern-js/utils/universal/plugin-dag-sort");
|
30
29
|
const checkPlugins = (plugins) => {
|
31
30
|
if (process.env.NODE_ENV !== "production") {
|
32
31
|
plugins.forEach((origin) => {
|
@@ -46,8 +45,16 @@ const checkPlugins = (plugins) => {
|
|
46
45
|
}
|
47
46
|
};
|
48
47
|
function sortPlugins(input) {
|
49
|
-
return (0,
|
48
|
+
return (0, import_plugin_dag_sort.pluginDagSort)(input.slice());
|
50
49
|
}
|
51
50
|
const includePlugin = (plugins, input) => plugins.some((plugin) => plugin.name === input.name);
|
52
51
|
const isObject = (obj) => obj !== null && typeof obj === "object";
|
53
52
|
const hasOwnProperty = (obj, prop) => obj.hasOwnProperty(prop);
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
54
|
+
0 && (module.exports = {
|
55
|
+
checkPlugins,
|
56
|
+
hasOwnProperty,
|
57
|
+
includePlugin,
|
58
|
+
isObject,
|
59
|
+
sortPlugins
|
60
|
+
});
|
package/dist/cjs/manager/sync.js
CHANGED
@@ -1,35 +1,34 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return DEFAULT_OPTIONS;
|
15
|
-
},
|
16
|
-
createManager: function() {
|
17
|
-
return createManager;
|
18
|
-
},
|
19
|
-
generateRunner: function() {
|
20
|
-
return generateRunner;
|
21
|
-
},
|
22
|
-
cloneHook: function() {
|
23
|
-
return cloneHook;
|
24
|
-
},
|
25
|
-
cloneHooksMap: function() {
|
26
|
-
return cloneHooksMap;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
27
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var sync_exports = {};
|
20
|
+
__export(sync_exports, {
|
21
|
+
DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
|
22
|
+
cloneHook: () => cloneHook,
|
23
|
+
cloneHooksMap: () => cloneHooksMap,
|
24
|
+
createManager: () => createManager,
|
25
|
+
generateRunner: () => generateRunner
|
28
26
|
});
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
module.exports = __toCommonJS(sync_exports);
|
28
|
+
var import_farrow_pipeline = require("../farrow-pipeline");
|
29
|
+
var import_waterfall = require("../waterfall");
|
30
|
+
var import_workflow = require("../workflow");
|
31
|
+
var import_shared = require("./shared");
|
33
32
|
const SYNC_PLUGIN_SYMBOL = "SYNC_PLUGIN_SYMBOL";
|
34
33
|
const DEFAULT_OPTIONS = {
|
35
34
|
name: "untitled",
|
@@ -53,7 +52,7 @@ const createManager = (hooks, api) => {
|
|
53
52
|
...currentHooks
|
54
53
|
};
|
55
54
|
};
|
56
|
-
const isPlugin = (input) => (0,
|
55
|
+
const isPlugin = (input) => (0, import_shared.isObject)(input) && (0, import_shared.hasOwnProperty)(input, SYNC_PLUGIN_SYMBOL) && input[SYNC_PLUGIN_SYMBOL] === SYNC_PLUGIN_SYMBOL;
|
57
56
|
const pluginAPI = {
|
58
57
|
...api,
|
59
58
|
useHookRunners: useRunner
|
@@ -61,7 +60,7 @@ const createManager = (hooks, api) => {
|
|
61
60
|
const clone = (overrideAPI) => {
|
62
61
|
let plugins = [];
|
63
62
|
const addPlugin = (plugin) => {
|
64
|
-
if (!(0,
|
63
|
+
if (!(0, import_shared.includePlugin)(plugins, plugin)) {
|
65
64
|
plugins.push({
|
66
65
|
...plugin
|
67
66
|
});
|
@@ -74,7 +73,7 @@ const createManager = (hooks, api) => {
|
|
74
73
|
} else if (typeof plugin === "function") {
|
75
74
|
const options = plugin();
|
76
75
|
addPlugin(createPlugin(options.setup, options));
|
77
|
-
} else if ((0,
|
76
|
+
} else if ((0, import_shared.isObject)(plugin)) {
|
78
77
|
addPlugin(createPlugin(plugin.setup, plugin));
|
79
78
|
} else if (process.env.NODE_ENV !== "production") {
|
80
79
|
console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
|
@@ -105,12 +104,12 @@ const createManager = (hooks, api) => {
|
|
105
104
|
plugins = [];
|
106
105
|
};
|
107
106
|
const init = () => {
|
108
|
-
const sortedPlugins = (0,
|
107
|
+
const sortedPlugins = (0, import_shared.sortPlugins)(plugins);
|
109
108
|
const mergedPluginAPI = {
|
110
109
|
...pluginAPI,
|
111
110
|
...overrideAPI
|
112
111
|
};
|
113
|
-
(0,
|
112
|
+
(0, import_shared.checkPlugins)(sortedPlugins);
|
114
113
|
const hooksList = sortedPlugins.map((plugin) => plugin.setup(mergedPluginAPI));
|
115
114
|
runners = generateRunner(hooksList, currentHooks);
|
116
115
|
return runners;
|
@@ -137,8 +136,7 @@ const generateRunner = (hooksList, hooksMap) => {
|
|
137
136
|
if (hooksMap) {
|
138
137
|
for (const key in cloneShape) {
|
139
138
|
hooksList.forEach((hooks) => {
|
140
|
-
|
141
|
-
if ((_hooks = hooks) === null || _hooks === void 0 ? void 0 : _hooks[key]) {
|
139
|
+
if (hooks === null || hooks === void 0 ? void 0 : hooks[key]) {
|
142
140
|
cloneShape[key].use(hooks[key]);
|
143
141
|
}
|
144
142
|
});
|
@@ -150,23 +148,23 @@ const generateRunner = (hooksList, hooksMap) => {
|
|
150
148
|
return runner;
|
151
149
|
};
|
152
150
|
const cloneHook = (hook) => {
|
153
|
-
if ((0,
|
154
|
-
return (0,
|
151
|
+
if ((0, import_waterfall.isWaterfall)(hook)) {
|
152
|
+
return (0, import_waterfall.createWaterfall)();
|
155
153
|
}
|
156
|
-
if ((0,
|
157
|
-
return (0,
|
154
|
+
if ((0, import_waterfall.isAsyncWaterfall)(hook)) {
|
155
|
+
return (0, import_waterfall.createAsyncWaterfall)();
|
158
156
|
}
|
159
|
-
if ((0,
|
160
|
-
return (0,
|
157
|
+
if ((0, import_workflow.isWorkflow)(hook)) {
|
158
|
+
return (0, import_workflow.createWorkflow)();
|
161
159
|
}
|
162
|
-
if ((0,
|
163
|
-
return (0,
|
160
|
+
if ((0, import_workflow.isAsyncWorkflow)(hook)) {
|
161
|
+
return (0, import_workflow.createAsyncWorkflow)();
|
164
162
|
}
|
165
|
-
if ((0,
|
166
|
-
return (0,
|
163
|
+
if ((0, import_workflow.isParallelWorkflow)(hook)) {
|
164
|
+
return (0, import_workflow.createParallelWorkflow)();
|
167
165
|
}
|
168
|
-
if ((0,
|
169
|
-
return (0,
|
166
|
+
if ((0, import_farrow_pipeline.isPipeline)(hook)) {
|
167
|
+
return (0, import_farrow_pipeline.createPipeline)();
|
170
168
|
}
|
171
169
|
throw new Error(`Unknown hook: ${hook}`);
|
172
170
|
};
|
@@ -180,3 +178,11 @@ const cloneHooksMap = (record) => {
|
|
180
178
|
}
|
181
179
|
return result;
|
182
180
|
};
|
181
|
+
// Annotate the CommonJS export names for ESM import in node:
|
182
|
+
0 && (module.exports = {
|
183
|
+
DEFAULT_OPTIONS,
|
184
|
+
cloneHook,
|
185
|
+
cloneHooksMap,
|
186
|
+
createManager,
|
187
|
+
generateRunner
|
188
|
+
});
|
@@ -1,4 +1,16 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var types_exports = {};
|
16
|
+
module.exports = __toCommonJS(types_exports);
|