@modern-js/plugin-v2 2.63.7 → 2.63.8-alpha.1
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/cli/run/create.js +25 -14
- package/dist/cjs/hooks.js +74 -2
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/manager.js +3 -5
- package/dist/cjs/runtime/api.js +79 -0
- package/dist/cjs/runtime/context.js +51 -0
- package/dist/cjs/runtime/hooks.js +36 -0
- package/dist/cjs/runtime/index.js +39 -0
- package/dist/cjs/runtime/run/create.js +74 -0
- package/dist/cjs/runtime/run/index.js +29 -0
- package/dist/cjs/runtime/run/types.js +16 -0
- package/dist/cjs/types/runtime/api.js +16 -0
- package/dist/cjs/types/runtime/context.js +16 -0
- package/dist/cjs/types/runtime/hooks.js +16 -0
- package/dist/cjs/types/runtime/index.js +16 -0
- package/dist/cjs/types/runtime/plugin.js +16 -0
- package/dist/esm/cli/api.js +103 -0
- package/dist/esm/cli/context.js +53 -0
- package/dist/esm/cli/hooks.js +42 -0
- package/dist/esm/cli/index.js +14 -0
- package/dist/esm/cli/run/config/createLoadedConfig.js +190 -0
- package/dist/esm/cli/run/config/createResolvedConfig.js +30 -0
- package/dist/esm/cli/run/config/loadConfig.js +210 -0
- package/dist/esm/cli/run/create.js +300 -0
- package/dist/esm/cli/run/index.js +10 -0
- package/dist/esm/cli/run/run.js +60 -0
- package/dist/esm/cli/run/types.js +0 -0
- package/dist/esm/cli/run/utils/checkIsDuplicationPlugin.js +24 -0
- package/dist/esm/cli/run/utils/commander.js +42 -0
- package/dist/esm/cli/run/utils/createFileWatcher.js +110 -0
- package/dist/esm/cli/run/utils/debug.js +5 -0
- package/dist/esm/cli/run/utils/initAppDir.js +36 -0
- package/dist/esm/cli/run/utils/loadEnv.js +24 -0
- package/dist/esm/cli/run/utils/mergeConfig.js +43 -0
- package/dist/esm/hooks.js +378 -0
- package/dist/esm/index.js +6 -357
- package/dist/esm/manager.js +161 -0
- package/dist/esm/runtime/api.js +59 -0
- package/dist/esm/runtime/context.js +25 -0
- package/dist/esm/runtime/hooks.js +12 -0
- package/dist/esm/runtime/index.js +11 -0
- package/dist/esm/runtime/run/create.js +72 -0
- package/dist/esm/runtime/run/index.js +5 -0
- package/dist/esm/runtime/run/types.js +0 -0
- package/dist/esm/types/cli/api.js +0 -0
- package/dist/esm/types/cli/context.js +0 -0
- package/dist/esm/types/cli/hooks.js +0 -0
- package/dist/esm/types/cli/index.js +0 -0
- package/dist/esm/types/cli/plugin.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/types/plugin.js +0 -0
- package/dist/esm/types/runtime/api.js +0 -0
- package/dist/esm/types/runtime/context.js +0 -0
- package/dist/esm/types/runtime/hooks.js +0 -0
- package/dist/esm/types/runtime/index.js +0 -0
- package/dist/esm/types/runtime/plugin.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm-node/cli/run/create.js +26 -15
- package/dist/esm-node/hooks.js +70 -1
- package/dist/esm-node/index.js +5 -2
- package/dist/esm-node/manager.js +2 -4
- package/dist/esm-node/runtime/api.js +55 -0
- package/dist/esm-node/runtime/context.js +26 -0
- package/dist/esm-node/runtime/hooks.js +12 -0
- package/dist/esm-node/runtime/index.js +11 -0
- package/dist/esm-node/runtime/run/create.js +50 -0
- package/dist/esm-node/runtime/run/index.js +5 -0
- package/dist/esm-node/runtime/run/types.js +0 -0
- package/dist/esm-node/types/runtime/api.js +0 -0
- package/dist/esm-node/types/runtime/context.js +0 -0
- package/dist/esm-node/types/runtime/hooks.js +0 -0
- package/dist/esm-node/types/runtime/index.js +0 -0
- package/dist/esm-node/types/runtime/plugin.js +0 -0
- package/dist/types/cli/hooks.d.ts +3 -3
- package/dist/types/cli/run/create.d.ts +2 -1
- package/dist/types/cli/run/index.d.ts +4 -4
- package/dist/types/hooks.d.ts +4 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/manager.d.ts +3 -0
- package/dist/types/runtime/api.d.ts +9 -0
- package/dist/types/runtime/context.d.ts +11 -0
- package/dist/types/runtime/hooks.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/run/create.d.ts +7 -0
- package/dist/types/runtime/run/index.d.ts +5 -0
- package/dist/types/runtime/run/types.d.ts +6 -0
- package/dist/types/types/cli/api.d.ts +2 -2
- package/dist/types/types/cli/context.d.ts +1 -1
- package/dist/types/types/cli/hooks.d.ts +3 -3
- package/dist/types/types/cli/plugin.d.ts +2 -1
- package/dist/types/types/hooks.d.ts +14 -2
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/plugin.d.ts +1 -1
- package/dist/types/types/runtime/api.d.ts +15 -0
- package/dist/types/types/runtime/context.d.ts +13 -0
- package/dist/types/types/runtime/hooks.d.ts +12 -0
- package/dist/types/types/runtime/index.d.ts +4 -0
- package/dist/types/types/runtime/plugin.d.ts +14 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/package.json +13 -9
|
@@ -33,9 +33,27 @@ var import_commander2 = require("./utils/commander");
|
|
|
33
33
|
var import_createFileWatcher = require("./utils/createFileWatcher");
|
|
34
34
|
var import_initAppDir = require("./utils/initAppDir");
|
|
35
35
|
var import_loadEnv = require("./utils/loadEnv");
|
|
36
|
+
const debug = (0, import_utils.createDebugger)("plugin-v2");
|
|
36
37
|
const createCli = () => {
|
|
37
38
|
let initOptions;
|
|
38
39
|
const pluginManager = (0, import_manager.createPluginManager)();
|
|
40
|
+
const existListenerMap = /* @__PURE__ */ new Map();
|
|
41
|
+
function createExistListener(event, context) {
|
|
42
|
+
return async function(err) {
|
|
43
|
+
await context.hooks.onBeforeExit.call();
|
|
44
|
+
let hasError = false;
|
|
45
|
+
if (err instanceof Error) {
|
|
46
|
+
import_utils.logger.error(err.stack);
|
|
47
|
+
hasError = true;
|
|
48
|
+
} else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
|
|
49
|
+
console.trace("Unknown Error", err);
|
|
50
|
+
hasError = true;
|
|
51
|
+
}
|
|
52
|
+
process.nextTick(() => {
|
|
53
|
+
process.exit(hasError ? 1 : 0);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
39
57
|
async function init(options) {
|
|
40
58
|
var _context_hooks_onAfterPrepare, _context_hooks;
|
|
41
59
|
pluginManager.clear();
|
|
@@ -53,6 +71,7 @@ const createCli = () => {
|
|
|
53
71
|
(0, import_checkIsDuplicationPlugin.checkIsDuplicationPlugin)(allPlugins.map((plugin) => plugin.name), loaded.config.autoLoadPlugins);
|
|
54
72
|
pluginManager.addPlugins(allPlugins);
|
|
55
73
|
const plugins = await pluginManager.getPlugins();
|
|
74
|
+
debug("CLI Plugins:", plugins.map((p) => p.name));
|
|
56
75
|
const context = await (0, import_context.createContext)({
|
|
57
76
|
appContext: (0, import_context.initAppContext)({
|
|
58
77
|
packageName: loaded.packageName,
|
|
@@ -82,20 +101,12 @@ const createCli = () => {
|
|
|
82
101
|
"unhandledRejection",
|
|
83
102
|
"uncaughtException"
|
|
84
103
|
].forEach((event) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} else if (err && (event === "unhandledRejection" || event === "uncaughtException")) {
|
|
92
|
-
console.trace("Unknown Error", err);
|
|
93
|
-
hasError = true;
|
|
94
|
-
}
|
|
95
|
-
process.nextTick(() => {
|
|
96
|
-
process.exit(hasError ? 1 : 0);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
104
|
+
if (existListenerMap.get(event)) {
|
|
105
|
+
process.off(event, existListenerMap.get(event));
|
|
106
|
+
}
|
|
107
|
+
const existListener = createExistListener(event, context);
|
|
108
|
+
existListenerMap.set(event, existListener);
|
|
109
|
+
process.on(event, existListener);
|
|
99
110
|
});
|
|
100
111
|
const extraConfigs = await context.hooks.config.call();
|
|
101
112
|
const normalizedConfig = await (0, import_createResolvedConfig.createResolveConfig)(loaded, extraConfigs);
|
package/dist/cjs/hooks.js
CHANGED
|
@@ -19,9 +19,58 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var hooks_exports = {};
|
|
20
20
|
__export(hooks_exports, {
|
|
21
21
|
createAsyncHook: () => createAsyncHook,
|
|
22
|
-
|
|
22
|
+
createAsyncInterruptHook: () => createAsyncInterruptHook,
|
|
23
|
+
createCollectAsyncHook: () => createCollectAsyncHook,
|
|
24
|
+
createCollectSyncHook: () => createCollectSyncHook,
|
|
25
|
+
createSyncHook: () => createSyncHook
|
|
23
26
|
});
|
|
24
27
|
module.exports = __toCommonJS(hooks_exports);
|
|
28
|
+
function createAsyncInterruptHook() {
|
|
29
|
+
const callbacks = [];
|
|
30
|
+
const tap = (cb) => {
|
|
31
|
+
callbacks.push(cb);
|
|
32
|
+
};
|
|
33
|
+
const call = async (...params) => {
|
|
34
|
+
let interrupted = false;
|
|
35
|
+
let interruptResult;
|
|
36
|
+
const interrupt = (info) => {
|
|
37
|
+
interrupted = true;
|
|
38
|
+
interruptResult = info;
|
|
39
|
+
};
|
|
40
|
+
for (const callback of callbacks) {
|
|
41
|
+
if (interrupted)
|
|
42
|
+
break;
|
|
43
|
+
const result = await callback(...params, interrupt);
|
|
44
|
+
if (result !== void 0) {
|
|
45
|
+
params[0] = result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return interrupted ? interruptResult : params[0] || [];
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
tap,
|
|
52
|
+
call
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function createSyncHook() {
|
|
56
|
+
const callbacks = [];
|
|
57
|
+
const tap = (cb) => {
|
|
58
|
+
callbacks.push(cb);
|
|
59
|
+
};
|
|
60
|
+
const call = (...params) => {
|
|
61
|
+
for (const callback of callbacks) {
|
|
62
|
+
const result = callback(...params);
|
|
63
|
+
if (result !== void 0) {
|
|
64
|
+
params[0] = result;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return params[0];
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
tap,
|
|
71
|
+
call
|
|
72
|
+
};
|
|
73
|
+
}
|
|
25
74
|
function createAsyncHook() {
|
|
26
75
|
const callbacks = [];
|
|
27
76
|
const tap = (cb) => {
|
|
@@ -61,8 +110,31 @@ function createCollectAsyncHook() {
|
|
|
61
110
|
call
|
|
62
111
|
};
|
|
63
112
|
}
|
|
113
|
+
function createCollectSyncHook() {
|
|
114
|
+
const callbacks = [];
|
|
115
|
+
const tap = (cb) => {
|
|
116
|
+
callbacks.push(cb);
|
|
117
|
+
};
|
|
118
|
+
const call = (...params) => {
|
|
119
|
+
const results = [];
|
|
120
|
+
for (const callback of callbacks) {
|
|
121
|
+
const result = callback(params);
|
|
122
|
+
if (result !== void 0) {
|
|
123
|
+
results.push(result);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return results;
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
tap,
|
|
130
|
+
call
|
|
131
|
+
};
|
|
132
|
+
}
|
|
64
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
134
|
0 && (module.exports = {
|
|
66
135
|
createAsyncHook,
|
|
67
|
-
|
|
136
|
+
createAsyncInterruptHook,
|
|
137
|
+
createCollectAsyncHook,
|
|
138
|
+
createCollectSyncHook,
|
|
139
|
+
createSyncHook
|
|
68
140
|
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,8 +19,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
21
|
createAsyncHook: () => import_hooks.createAsyncHook,
|
|
22
|
+
createAsyncInterruptHook: () => import_hooks.createAsyncInterruptHook,
|
|
22
23
|
createCollectAsyncHook: () => import_hooks.createCollectAsyncHook,
|
|
23
|
-
|
|
24
|
+
createCollectSyncHook: () => import_hooks.createCollectSyncHook,
|
|
25
|
+
createPluginManager: () => import_manager.createPluginManager,
|
|
26
|
+
createSyncHook: () => import_hooks.createSyncHook
|
|
24
27
|
});
|
|
25
28
|
module.exports = __toCommonJS(src_exports);
|
|
26
29
|
var import_manager = require("./manager");
|
|
@@ -28,6 +31,9 @@ var import_hooks = require("./hooks");
|
|
|
28
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
32
|
0 && (module.exports = {
|
|
30
33
|
createAsyncHook,
|
|
34
|
+
createAsyncInterruptHook,
|
|
31
35
|
createCollectAsyncHook,
|
|
32
|
-
|
|
36
|
+
createCollectSyncHook,
|
|
37
|
+
createPluginManager,
|
|
38
|
+
createSyncHook
|
|
33
39
|
});
|
package/dist/cjs/manager.js
CHANGED
|
@@ -21,8 +21,7 @@ __export(manager_exports, {
|
|
|
21
21
|
createPluginManager: () => createPluginManager
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(manager_exports);
|
|
24
|
-
|
|
25
|
-
var import_debug = require("./cli/run/utils/debug");
|
|
24
|
+
const isFunction = (obj) => typeof obj === "function";
|
|
26
25
|
function validatePlugin(plugin) {
|
|
27
26
|
const type = typeof plugin;
|
|
28
27
|
if (type !== "object" || plugin === null) {
|
|
@@ -30,7 +29,7 @@ function validatePlugin(plugin) {
|
|
|
30
29
|
}
|
|
31
30
|
if (!plugin.setup)
|
|
32
31
|
return;
|
|
33
|
-
if (
|
|
32
|
+
if (isFunction(plugin.setup)) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
36
35
|
throw new Error(`Expect CLI Plugin plugin.setup to be a function, but got ${type}.`);
|
|
@@ -70,7 +69,7 @@ function createPluginManager() {
|
|
|
70
69
|
validatePlugin(newPlugin);
|
|
71
70
|
const { name, usePlugins = [], pre = [], post = [] } = newPlugin;
|
|
72
71
|
if (plugins.has(name)) {
|
|
73
|
-
|
|
72
|
+
console.warn(`Plugin ${name} already exists.`);
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
76
75
|
plugins.set(name, newPlugin);
|
|
@@ -135,7 +134,6 @@ function createPluginManager() {
|
|
|
135
134
|
visit(name);
|
|
136
135
|
});
|
|
137
136
|
result = result.filter((result2) => result2);
|
|
138
|
-
(0, import_debug.debug)("CLI Plugins:", result.map((p) => p.name));
|
|
139
137
|
return result;
|
|
140
138
|
};
|
|
141
139
|
const clear = () => {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var api_exports = {};
|
|
20
|
+
__export(api_exports, {
|
|
21
|
+
initPluginAPI: () => initPluginAPI
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(api_exports);
|
|
24
|
+
var import_merge = require("@modern-js/runtime-utils/merge");
|
|
25
|
+
function initPluginAPI({ context, plugins }) {
|
|
26
|
+
const { hooks, extendsHooks } = context;
|
|
27
|
+
function getRuntimeContext() {
|
|
28
|
+
if (context) {
|
|
29
|
+
const { hooks: hooks2, extendsHooks: extendsHooks2, config, pluginAPI, ...runtimeContext } = context;
|
|
30
|
+
runtimeContext._internalContext = context;
|
|
31
|
+
return runtimeContext;
|
|
32
|
+
}
|
|
33
|
+
throw new Error("Cannot access context");
|
|
34
|
+
}
|
|
35
|
+
function updateRuntimeContext(updateContext) {
|
|
36
|
+
context = (0, import_merge.merge)(context, updateContext);
|
|
37
|
+
}
|
|
38
|
+
function getHooks() {
|
|
39
|
+
return {
|
|
40
|
+
...hooks,
|
|
41
|
+
...extendsHooks
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function getRuntimeConfig() {
|
|
45
|
+
if (context.config) {
|
|
46
|
+
return context.config;
|
|
47
|
+
}
|
|
48
|
+
throw new Error("Cannot access config");
|
|
49
|
+
}
|
|
50
|
+
const extendsPluginApi = {};
|
|
51
|
+
plugins.forEach((plugin) => {
|
|
52
|
+
const { _registryApi } = plugin;
|
|
53
|
+
if (_registryApi) {
|
|
54
|
+
const apis = _registryApi(getRuntimeContext, updateRuntimeContext);
|
|
55
|
+
Object.keys(apis).forEach((apiName) => {
|
|
56
|
+
extendsPluginApi[apiName] = apis[apiName];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (extendsHooks) {
|
|
61
|
+
Object.keys(extendsHooks).forEach((hookName) => {
|
|
62
|
+
extendsPluginApi[hookName] = extendsHooks[hookName].tap;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
updateRuntimeContext,
|
|
67
|
+
getHooks,
|
|
68
|
+
getRuntimeConfig,
|
|
69
|
+
modifyRuntimeConfig: hooks.modifyRuntimeConfig.tap,
|
|
70
|
+
onBeforeRender: hooks.onBeforeRender.tap,
|
|
71
|
+
wrapRoot: hooks.wrapRoot.tap,
|
|
72
|
+
pickContext: hooks.pickContext.tap,
|
|
73
|
+
...extendsPluginApi
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
initPluginAPI
|
|
79
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var context_exports = {};
|
|
20
|
+
__export(context_exports, {
|
|
21
|
+
createRuntimeContext: () => createRuntimeContext,
|
|
22
|
+
initRuntimeContext: () => initRuntimeContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(context_exports);
|
|
25
|
+
var import_hooks = require("./hooks");
|
|
26
|
+
function initRuntimeContext() {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
function createRuntimeContext({ runtimeContext, config, plugins }) {
|
|
30
|
+
const extendsHooks = {};
|
|
31
|
+
plugins.forEach((plugin) => {
|
|
32
|
+
const { registryHooks = {} } = plugin;
|
|
33
|
+
Object.keys(registryHooks).forEach((hookName) => {
|
|
34
|
+
extendsHooks[hookName] = registryHooks[hookName];
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
...runtimeContext,
|
|
39
|
+
hooks: {
|
|
40
|
+
...(0, import_hooks.initHooks)(),
|
|
41
|
+
...extendsHooks
|
|
42
|
+
},
|
|
43
|
+
extendsHooks,
|
|
44
|
+
config
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
createRuntimeContext,
|
|
50
|
+
initRuntimeContext
|
|
51
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var hooks_exports = {};
|
|
20
|
+
__export(hooks_exports, {
|
|
21
|
+
initHooks: () => initHooks
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
24
|
+
var import_hooks = require("../hooks");
|
|
25
|
+
function initHooks() {
|
|
26
|
+
return {
|
|
27
|
+
onBeforeRender: (0, import_hooks.createAsyncInterruptHook)(),
|
|
28
|
+
wrapRoot: (0, import_hooks.createSyncHook)(),
|
|
29
|
+
pickContext: (0, import_hooks.createSyncHook)(),
|
|
30
|
+
modifyRuntimeConfig: (0, import_hooks.createCollectSyncHook)()
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
initHooks
|
|
36
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var runtime_exports = {};
|
|
20
|
+
__export(runtime_exports, {
|
|
21
|
+
createRuntimeContext: () => import_context.createRuntimeContext,
|
|
22
|
+
initHooks: () => import_hooks.initHooks,
|
|
23
|
+
initPluginAPI: () => import_api.initPluginAPI,
|
|
24
|
+
initRuntimeContext: () => import_context.initRuntimeContext,
|
|
25
|
+
runtime: () => import_run.runtime
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
28
|
+
var import_api = require("./api");
|
|
29
|
+
var import_context = require("./context");
|
|
30
|
+
var import_hooks = require("./hooks");
|
|
31
|
+
var import_run = require("./run");
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
createRuntimeContext,
|
|
35
|
+
initHooks,
|
|
36
|
+
initPluginAPI,
|
|
37
|
+
initRuntimeContext,
|
|
38
|
+
runtime
|
|
39
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var create_exports = {};
|
|
20
|
+
__export(create_exports, {
|
|
21
|
+
createRuntime: () => createRuntime
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(create_exports);
|
|
24
|
+
var import_merge = require("@modern-js/runtime-utils/merge");
|
|
25
|
+
var import_manager = require("../../manager");
|
|
26
|
+
var import_api = require("../../runtime/api");
|
|
27
|
+
var import_context = require("../../runtime/context");
|
|
28
|
+
const createRuntime = () => {
|
|
29
|
+
let initOptions;
|
|
30
|
+
const pluginManager = (0, import_manager.createPluginManager)();
|
|
31
|
+
function init(options) {
|
|
32
|
+
pluginManager.clear();
|
|
33
|
+
initOptions = options;
|
|
34
|
+
const { plugins: allPlugins, handleSetupResult } = options;
|
|
35
|
+
pluginManager.addPlugins(allPlugins);
|
|
36
|
+
const plugins = pluginManager.getPlugins();
|
|
37
|
+
const context = (0, import_context.createRuntimeContext)({
|
|
38
|
+
runtimeContext: (0, import_context.initRuntimeContext)(),
|
|
39
|
+
config: initOptions.config,
|
|
40
|
+
plugins
|
|
41
|
+
});
|
|
42
|
+
const pluginAPI = (0, import_api.initPluginAPI)({
|
|
43
|
+
context,
|
|
44
|
+
pluginManager,
|
|
45
|
+
plugins
|
|
46
|
+
});
|
|
47
|
+
context.pluginAPI = pluginAPI;
|
|
48
|
+
for (const plugin of plugins) {
|
|
49
|
+
var _plugin_setup;
|
|
50
|
+
const setupResult = (_plugin_setup = plugin.setup) === null || _plugin_setup === void 0 ? void 0 : _plugin_setup.call(plugin, pluginAPI);
|
|
51
|
+
if (handleSetupResult) {
|
|
52
|
+
handleSetupResult(setupResult, pluginAPI);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
runtimeContext: context
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function run(options) {
|
|
60
|
+
const { runtimeContext } = init(options);
|
|
61
|
+
const configs = runtimeContext.hooks.modifyRuntimeConfig.call(runtimeContext.config).filter((config) => Boolean(config));
|
|
62
|
+
runtimeContext.config = (0, import_merge.merge)({}, ...configs);
|
|
63
|
+
return {
|
|
64
|
+
runtimeContext
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
run
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
createRuntime
|
|
74
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
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 });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var run_exports = {};
|
|
20
|
+
__export(run_exports, {
|
|
21
|
+
runtime: () => runtime
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(run_exports);
|
|
24
|
+
var import_create = require("./create");
|
|
25
|
+
const runtime = (0, import_create.createRuntime)();
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
runtime
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
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);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
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 api_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(api_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
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 context_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(context_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
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 hooks_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
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 runtime_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
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 plugin_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(plugin_exports);
|