@rolldown/browser 1.0.0-beta.9-commit.ca4e9dd → 1.0.0-rc.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/cli-setup.mjs +16 -0
- package/dist/cli.mjs +1084 -1281
- package/dist/config.d.mts +1 -3
- package/dist/config.mjs +7 -5
- package/dist/constructors-B8gqcrFr.js +61 -0
- package/dist/experimental-index.browser.mjs +225 -50
- package/dist/experimental-index.d.mts +164 -76
- package/dist/experimental-index.mjs +220 -60
- package/dist/experimental-runtime-types.d.ts +98 -0
- package/dist/filter-index.d.mts +104 -2
- package/dist/filter-index.mjs +123 -3
- package/dist/get-log-filter.d.mts +7 -0
- package/dist/get-log-filter.mjs +48 -0
- package/dist/index.browser.mjs +242 -2
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +54 -5
- package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-CL-PJZI7.js} +70 -137
- package/dist/parallel-plugin-worker.mjs +26 -33
- package/dist/parallel-plugin.d.mts +7 -7
- package/dist/parse-ast-index.d.mts +5 -6
- package/dist/parse-ast-index.mjs +1 -2
- package/dist/plugins-index.browser.mjs +39 -0
- package/dist/plugins-index.d.mts +30 -0
- package/dist/plugins-index.mjs +39 -0
- package/dist/rolldown-binding.wasi-browser.js +41 -24
- package/dist/rolldown-binding.wasi.cjs +62 -24
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/rolldown-build-C4tDS_XC.js +5055 -0
- package/dist/shared/bindingify-input-options-Bp2kpiI8.mjs +2231 -0
- package/dist/shared/composable-filters-CIxSuZSM.mjs +227 -0
- package/dist/shared/constructors-5bt5oBhE.d.mts +28 -0
- package/dist/shared/constructors-BTW-c3jX.mjs +61 -0
- package/dist/shared/define-config-CDlEOpr1.d.mts +3531 -0
- package/dist/shared/define-config-Dlptvz3X.mjs +7 -0
- package/dist/shared/{load-config-vRugYmJ3.mjs → load-config-BBZgIUGN.mjs} +23 -33
- package/dist/shared/logging-Nvu645a7.d.mts +50 -0
- package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-B2CASPcx.mjs} +21 -116
- package/dist/shared/normalize-string-or-regex-DIwprzLy.mjs +60 -0
- package/dist/shared/parse-ast-index-2ahkCVK6.mjs +98 -0
- package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-B6NrDD1-.mjs} +301 -308
- package/dist/shared/rolldown-C0_W0QdY.mjs +42 -0
- package/dist/shared/rolldown-build-DLuUhuNw.mjs +2368 -0
- package/dist/shared/types-CIYK49jr.d.mts +1300 -0
- package/dist/shared/utils-CqMTwlsR.d.mts +22 -0
- package/dist/shared/watch-eIop0yN6.mjs +378 -0
- package/package.json +33 -38
- package/dist/cli.cjs +0 -1748
- package/dist/config.cjs +0 -12
- package/dist/config.d.cts +0 -11
- package/dist/experimental-index.cjs +0 -129
- package/dist/experimental-index.d.cts +0 -96
- package/dist/filter-index.cjs +0 -53
- package/dist/filter-index.d.cts +0 -3
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -3
- package/dist/parallel-plugin-worker.cjs +0 -33
- package/dist/parallel-plugin-worker.d.cts +0 -1
- package/dist/parallel-plugin.cjs +0 -8
- package/dist/parallel-plugin.d.cts +0 -14
- package/dist/parse-ast-index.cjs +0 -4
- package/dist/parse-ast-index.d.cts +0 -9
- package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
- package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
- package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
- package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
- package/dist/shared/dist-BMVjvV-v.cjs +0 -249
- package/dist/shared/dist-CAn6dxW6.mjs +0 -153
- package/dist/shared/load-config-42uI5RSv.cjs +0 -125
- package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
- package/dist/shared/src-Cu4_wKhx.mjs +0 -4691
- package/dist/shared/src-CzdOBfDC.cjs +0 -4647
- package/dist/src-DQ33eKZS.js +0 -4333
- /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
|
@@ -1,4691 +0,0 @@
|
|
|
1
|
-
import { __esm } from "./chunk-DSsiIF1Z.mjs";
|
|
2
|
-
import { and$1 as and, arraify, code$1 as code, exclude$1 as exclude, id$1 as id, include$1 as include, init_dist, init_misc, isNullish, moduleType$1 as moduleType, noop, or$1 as or, unimplemented, unreachable, unsupported } from "./dist-CAn6dxW6.mjs";
|
|
3
|
-
import { augmentCodeLocation, error, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-vu376yZ1.mjs";
|
|
4
|
-
import { BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, Bundler, ParallelJsPluginRegistry, shutdownAsyncRuntime, startAsyncRuntime } from "../rolldown-binding.wasi.cjs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import colors from "ansis";
|
|
8
|
-
import os from "node:os";
|
|
9
|
-
import { Worker } from "node:worker_threads";
|
|
10
|
-
|
|
11
|
-
//#region package.json
|
|
12
|
-
var version = "1.0.0-beta.9-commit.ca4e9dd";
|
|
13
|
-
var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/builtin-plugin/utils.ts
|
|
17
|
-
function makeBuiltinPluginCallable(plugin) {
|
|
18
|
-
let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
19
|
-
const wrappedPlugin = plugin;
|
|
20
|
-
for (const key in callablePlugin) wrappedPlugin[key] = function(...args$1) {
|
|
21
|
-
return callablePlugin[key](...args$1);
|
|
22
|
-
};
|
|
23
|
-
return wrappedPlugin;
|
|
24
|
-
}
|
|
25
|
-
function bindingifyBuiltInPlugin(plugin) {
|
|
26
|
-
return {
|
|
27
|
-
__name: plugin.name,
|
|
28
|
-
options: plugin._options
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
var init_utils = __esm({ "src/builtin-plugin/utils.ts"() {} });
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/builtin-plugin/constructors.ts
|
|
35
|
-
function modulePreloadPolyfillPlugin() {
|
|
36
|
-
return new BuiltinPlugin("builtin:module-preload-polyfill");
|
|
37
|
-
}
|
|
38
|
-
function dynamicImportVarsPlugin(config) {
|
|
39
|
-
return new BuiltinPlugin("builtin:dynamic-import-vars", config);
|
|
40
|
-
}
|
|
41
|
-
function importGlobPlugin(config) {
|
|
42
|
-
return new BuiltinPlugin("builtin:import-glob", config);
|
|
43
|
-
}
|
|
44
|
-
function reporterPlugin(config) {
|
|
45
|
-
return new BuiltinPlugin("builtin:reporter", config);
|
|
46
|
-
}
|
|
47
|
-
function manifestPlugin(config) {
|
|
48
|
-
return new BuiltinPlugin("builtin:manifest", config);
|
|
49
|
-
}
|
|
50
|
-
function wasmHelperPlugin() {
|
|
51
|
-
return new BuiltinPlugin("builtin:wasm-helper");
|
|
52
|
-
}
|
|
53
|
-
function wasmFallbackPlugin() {
|
|
54
|
-
return new BuiltinPlugin("builtin:wasm-fallback");
|
|
55
|
-
}
|
|
56
|
-
function loadFallbackPlugin() {
|
|
57
|
-
return new BuiltinPlugin("builtin:load-fallback");
|
|
58
|
-
}
|
|
59
|
-
function jsonPlugin(config) {
|
|
60
|
-
return new BuiltinPlugin("builtin:json", config);
|
|
61
|
-
}
|
|
62
|
-
function buildImportAnalysisPlugin(config) {
|
|
63
|
-
return new BuiltinPlugin("builtin:build-import-analysis", config);
|
|
64
|
-
}
|
|
65
|
-
function viteResolvePlugin(config) {
|
|
66
|
-
const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", config);
|
|
67
|
-
return makeBuiltinPluginCallable(builtinPlugin);
|
|
68
|
-
}
|
|
69
|
-
function moduleFederationPlugin(config) {
|
|
70
|
-
return new BuiltinPlugin("builtin:module-federation", {
|
|
71
|
-
...config,
|
|
72
|
-
remotes: config.remotes && Object.entries(config.remotes).map(([name, remote]) => {
|
|
73
|
-
if (typeof remote === "string") {
|
|
74
|
-
const [entryGlobalName] = remote.split("@");
|
|
75
|
-
const entry = remote.replace(entryGlobalName + "@", "");
|
|
76
|
-
return {
|
|
77
|
-
entry,
|
|
78
|
-
name,
|
|
79
|
-
entryGlobalName
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
...remote,
|
|
84
|
-
name: remote.name ?? name
|
|
85
|
-
};
|
|
86
|
-
}),
|
|
87
|
-
manifest: config.manifest === false ? void 0 : config.manifest === true ? {} : config.manifest
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function isolatedDeclarationPlugin(config) {
|
|
91
|
-
return new BuiltinPlugin("builtin:isolated-declaration", config);
|
|
92
|
-
}
|
|
93
|
-
function assetPlugin(config) {
|
|
94
|
-
return new BuiltinPlugin("builtin:asset", config);
|
|
95
|
-
}
|
|
96
|
-
function webWorkerPostPlugin() {
|
|
97
|
-
return new BuiltinPlugin("builtin:web-worker-post");
|
|
98
|
-
}
|
|
99
|
-
function oxcRuntimePlugin(config) {
|
|
100
|
-
return new BuiltinPlugin("builtin:oxc-runtime", config);
|
|
101
|
-
}
|
|
102
|
-
var BuiltinPlugin;
|
|
103
|
-
var init_constructors = __esm({ "src/builtin-plugin/constructors.ts"() {
|
|
104
|
-
init_utils();
|
|
105
|
-
BuiltinPlugin = class {
|
|
106
|
-
constructor(name, _options) {
|
|
107
|
-
this.name = name;
|
|
108
|
-
this._options = _options;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
} });
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
//#region src/log/logging.ts
|
|
115
|
-
var LOG_LEVEL_SILENT, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, logLevelPriority;
|
|
116
|
-
var init_logging = __esm({ "src/log/logging.ts"() {
|
|
117
|
-
LOG_LEVEL_SILENT = "silent";
|
|
118
|
-
LOG_LEVEL_ERROR = "error";
|
|
119
|
-
LOG_LEVEL_WARN = "warn";
|
|
120
|
-
LOG_LEVEL_INFO = "info";
|
|
121
|
-
LOG_LEVEL_DEBUG = "debug";
|
|
122
|
-
logLevelPriority = {
|
|
123
|
-
[LOG_LEVEL_DEBUG]: 0,
|
|
124
|
-
[LOG_LEVEL_INFO]: 1,
|
|
125
|
-
[LOG_LEVEL_WARN]: 2,
|
|
126
|
-
[LOG_LEVEL_SILENT]: 3
|
|
127
|
-
};
|
|
128
|
-
} });
|
|
129
|
-
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/log/log-handler.ts
|
|
132
|
-
function getLogHandler(level, code$1, logger, pluginName, logLevel) {
|
|
133
|
-
if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
|
|
134
|
-
return (log, pos) => {
|
|
135
|
-
if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
136
|
-
log = normalizeLog(log);
|
|
137
|
-
if (log.code && !log.pluginCode) log.pluginCode = log.code;
|
|
138
|
-
log.code = code$1;
|
|
139
|
-
log.plugin = pluginName;
|
|
140
|
-
logger(level, log);
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
var normalizeLog;
|
|
144
|
-
var init_log_handler = __esm({ "src/log/log-handler.ts"() {
|
|
145
|
-
init_misc();
|
|
146
|
-
init_logging();
|
|
147
|
-
init_logs();
|
|
148
|
-
normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
|
|
149
|
-
} });
|
|
150
|
-
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/log/logger.ts
|
|
153
|
-
function getLogger(plugins, onLog, logLevel, watchMode) {
|
|
154
|
-
const minimalPriority = logLevelPriority[logLevel];
|
|
155
|
-
const logger = (level, log, skipped = new Set()) => {
|
|
156
|
-
const logPriority = logLevelPriority[level];
|
|
157
|
-
if (logPriority < minimalPriority) return;
|
|
158
|
-
for (const plugin of getSortedPlugins("onLog", plugins)) {
|
|
159
|
-
if (skipped.has(plugin)) continue;
|
|
160
|
-
const { onLog: pluginOnLog } = plugin;
|
|
161
|
-
if (pluginOnLog) {
|
|
162
|
-
const getLogHandler$1 = (level$1) => {
|
|
163
|
-
if (logLevelPriority[level$1] < minimalPriority) return () => {};
|
|
164
|
-
return (log$1) => logger(level$1, normalizeLog(log$1), new Set(skipped).add(plugin));
|
|
165
|
-
};
|
|
166
|
-
const handler = "handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
167
|
-
if (handler.call({
|
|
168
|
-
debug: getLogHandler$1(LOG_LEVEL_DEBUG),
|
|
169
|
-
error: (log$1) => error(normalizeLog(log$1)),
|
|
170
|
-
info: getLogHandler$1(LOG_LEVEL_INFO),
|
|
171
|
-
meta: {
|
|
172
|
-
rollupVersion: "4.23.0",
|
|
173
|
-
rolldownVersion: VERSION,
|
|
174
|
-
watchMode
|
|
175
|
-
},
|
|
176
|
-
warn: getLogHandler$1(LOG_LEVEL_WARN),
|
|
177
|
-
pluginName: plugin.name || "unknown"
|
|
178
|
-
}, level, log) === false) return;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
onLog(level, log);
|
|
182
|
-
};
|
|
183
|
-
return logger;
|
|
184
|
-
}
|
|
185
|
-
function relativeId(id$1) {
|
|
186
|
-
if (!path.isAbsolute(id$1)) return id$1;
|
|
187
|
-
return path.relative(path.resolve(), id$1);
|
|
188
|
-
}
|
|
189
|
-
var getOnLog, getDefaultOnLog, addLogToString, defaultPrintLog, getExtendedLogMessage;
|
|
190
|
-
var init_logger = __esm({ "src/log/logger.ts"() {
|
|
191
|
-
init_src();
|
|
192
|
-
init_plugin_driver();
|
|
193
|
-
init_log_handler();
|
|
194
|
-
init_logging();
|
|
195
|
-
init_logs();
|
|
196
|
-
getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
197
|
-
const { onwarn, onLog } = config;
|
|
198
|
-
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
199
|
-
if (onLog) {
|
|
200
|
-
const minimalPriority = logLevelPriority[logLevel];
|
|
201
|
-
return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
|
|
202
|
-
if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
|
|
203
|
-
if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return defaultOnLog;
|
|
207
|
-
};
|
|
208
|
-
getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
|
|
209
|
-
if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
210
|
-
else printLog(level, log);
|
|
211
|
-
} : printLog;
|
|
212
|
-
addLogToString = (log) => {
|
|
213
|
-
Object.defineProperty(log, "toString", {
|
|
214
|
-
value: () => getExtendedLogMessage(log),
|
|
215
|
-
writable: true
|
|
216
|
-
});
|
|
217
|
-
return log;
|
|
218
|
-
};
|
|
219
|
-
defaultPrintLog = (level, log) => {
|
|
220
|
-
const message = getExtendedLogMessage(log);
|
|
221
|
-
switch (level) {
|
|
222
|
-
case LOG_LEVEL_WARN: return console.warn(message);
|
|
223
|
-
case LOG_LEVEL_DEBUG: return console.debug(message);
|
|
224
|
-
default: return console.info(message);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
getExtendedLogMessage = (log) => {
|
|
228
|
-
let prefix = "";
|
|
229
|
-
if (log.plugin) prefix += `(${log.plugin} plugin) `;
|
|
230
|
-
if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
231
|
-
return prefix + log.message;
|
|
232
|
-
};
|
|
233
|
-
} });
|
|
234
|
-
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/utils/normalize-hook.ts
|
|
237
|
-
function normalizeHook(hook) {
|
|
238
|
-
if (typeof hook === "function" || typeof hook === "string") return {
|
|
239
|
-
handler: hook,
|
|
240
|
-
options: {},
|
|
241
|
-
meta: {}
|
|
242
|
-
};
|
|
243
|
-
if (typeof hook === "object" && hook !== null) {
|
|
244
|
-
const { handler, order,...options } = hook;
|
|
245
|
-
return {
|
|
246
|
-
handler,
|
|
247
|
-
options,
|
|
248
|
-
meta: { order }
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
unreachable("Invalid hook type");
|
|
252
|
-
}
|
|
253
|
-
var init_normalize_hook = __esm({ "src/utils/normalize-hook.ts"() {
|
|
254
|
-
init_misc();
|
|
255
|
-
} });
|
|
256
|
-
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region src/constants/plugin.ts
|
|
259
|
-
var ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, ENUMERATED_PLUGIN_HOOK_NAMES, DEFINED_HOOK_NAMES;
|
|
260
|
-
var init_plugin$1 = __esm({ "src/constants/plugin.ts"() {
|
|
261
|
-
ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
|
|
262
|
-
"options",
|
|
263
|
-
"buildStart",
|
|
264
|
-
"resolveId",
|
|
265
|
-
"load",
|
|
266
|
-
"transform",
|
|
267
|
-
"moduleParsed",
|
|
268
|
-
"buildEnd",
|
|
269
|
-
"onLog",
|
|
270
|
-
"resolveDynamicImport",
|
|
271
|
-
"closeBundle",
|
|
272
|
-
"closeWatcher",
|
|
273
|
-
"watchChange"
|
|
274
|
-
];
|
|
275
|
-
ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
|
|
276
|
-
"augmentChunkHash",
|
|
277
|
-
"outputOptions",
|
|
278
|
-
"renderChunk",
|
|
279
|
-
"renderStart",
|
|
280
|
-
"renderError",
|
|
281
|
-
"writeBundle",
|
|
282
|
-
"generateBundle"
|
|
283
|
-
];
|
|
284
|
-
ENUMERATED_PLUGIN_HOOK_NAMES = [
|
|
285
|
-
...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
|
|
286
|
-
...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
|
|
287
|
-
"footer",
|
|
288
|
-
"banner",
|
|
289
|
-
"intro",
|
|
290
|
-
"outro"
|
|
291
|
-
];
|
|
292
|
-
DEFINED_HOOK_NAMES = {
|
|
293
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
|
|
294
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
|
|
295
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
|
|
296
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
|
|
297
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
|
|
298
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
|
|
299
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
|
|
300
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
|
|
301
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
|
|
302
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
|
|
303
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
|
|
304
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
|
|
305
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
|
|
306
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
|
|
307
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
|
|
308
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
|
|
309
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
|
|
310
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
|
|
311
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
|
|
312
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
|
|
313
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
|
|
314
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
|
|
315
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
|
|
316
|
-
};
|
|
317
|
-
} });
|
|
318
|
-
|
|
319
|
-
//#endregion
|
|
320
|
-
//#region src/utils/async-flatten.ts
|
|
321
|
-
async function asyncFlatten(array$1) {
|
|
322
|
-
do
|
|
323
|
-
array$1 = (await Promise.all(array$1)).flat(Infinity);
|
|
324
|
-
while (array$1.some((v) => v?.then));
|
|
325
|
-
return array$1;
|
|
326
|
-
}
|
|
327
|
-
var init_async_flatten = __esm({ "src/utils/async-flatten.ts"() {} });
|
|
328
|
-
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region src/utils/normalize-plugin-option.ts
|
|
331
|
-
function checkOutputPluginOption(plugins, onLog) {
|
|
332
|
-
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
|
|
333
|
-
delete plugin[hook];
|
|
334
|
-
onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
|
|
335
|
-
}
|
|
336
|
-
return plugins;
|
|
337
|
-
}
|
|
338
|
-
function normalizePlugins(plugins, anonymousPrefix) {
|
|
339
|
-
for (const [index, plugin] of plugins.entries()) {
|
|
340
|
-
if ("_parallel" in plugin) continue;
|
|
341
|
-
if (plugin instanceof BuiltinPlugin) continue;
|
|
342
|
-
if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
|
|
343
|
-
}
|
|
344
|
-
return plugins;
|
|
345
|
-
}
|
|
346
|
-
var normalizePluginOption, ANONYMOUS_PLUGIN_PREFIX, ANONYMOUS_OUTPUT_PLUGIN_PREFIX, BUILTIN_PLUGINS;
|
|
347
|
-
var init_normalize_plugin_option = __esm({ "src/utils/normalize-plugin-option.ts"() {
|
|
348
|
-
init_constructors();
|
|
349
|
-
init_plugin$1();
|
|
350
|
-
init_logging();
|
|
351
|
-
init_logs();
|
|
352
|
-
init_async_flatten();
|
|
353
|
-
normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
354
|
-
ANONYMOUS_PLUGIN_PREFIX = "at position ";
|
|
355
|
-
ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
|
|
356
|
-
BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
|
|
357
|
-
} });
|
|
358
|
-
|
|
359
|
-
//#endregion
|
|
360
|
-
//#region src/plugin/minimal-plugin-context.ts
|
|
361
|
-
var MinimalPluginContextImpl;
|
|
362
|
-
var init_minimal_plugin_context = __esm({ "src/plugin/minimal-plugin-context.ts"() {
|
|
363
|
-
init_src();
|
|
364
|
-
init_log_handler();
|
|
365
|
-
init_logging();
|
|
366
|
-
init_logs();
|
|
367
|
-
MinimalPluginContextImpl = class {
|
|
368
|
-
info;
|
|
369
|
-
warn;
|
|
370
|
-
debug;
|
|
371
|
-
meta;
|
|
372
|
-
constructor(onLog, logLevel, pluginName, watchMode, hookName) {
|
|
373
|
-
this.pluginName = pluginName;
|
|
374
|
-
this.hookName = hookName;
|
|
375
|
-
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
376
|
-
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
377
|
-
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
378
|
-
this.meta = {
|
|
379
|
-
rollupVersion: "4.23.0",
|
|
380
|
-
rolldownVersion: VERSION,
|
|
381
|
-
watchMode
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
error(e) {
|
|
385
|
-
return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
} });
|
|
389
|
-
|
|
390
|
-
//#endregion
|
|
391
|
-
//#region src/plugin/plugin-driver.ts
|
|
392
|
-
function getObjectPlugins(plugins) {
|
|
393
|
-
return plugins.filter((plugin) => {
|
|
394
|
-
if (!plugin) return void 0;
|
|
395
|
-
if ("_parallel" in plugin) return void 0;
|
|
396
|
-
if (plugin instanceof BuiltinPlugin) return void 0;
|
|
397
|
-
return plugin;
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
function getSortedPlugins(hookName, plugins) {
|
|
401
|
-
const pre = [];
|
|
402
|
-
const normal = [];
|
|
403
|
-
const post = [];
|
|
404
|
-
for (const plugin of plugins) {
|
|
405
|
-
const hook = plugin[hookName];
|
|
406
|
-
if (hook) {
|
|
407
|
-
if (typeof hook === "object") {
|
|
408
|
-
if (hook.order === "pre") {
|
|
409
|
-
pre.push(plugin);
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
if (hook.order === "post") {
|
|
413
|
-
post.push(plugin);
|
|
414
|
-
continue;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
normal.push(plugin);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return [
|
|
421
|
-
...pre,
|
|
422
|
-
...normal,
|
|
423
|
-
...post
|
|
424
|
-
];
|
|
425
|
-
}
|
|
426
|
-
var PluginDriver;
|
|
427
|
-
var init_plugin_driver = __esm({ "src/plugin/plugin-driver.ts"() {
|
|
428
|
-
init_constructors();
|
|
429
|
-
init_logger();
|
|
430
|
-
init_logging();
|
|
431
|
-
init_normalize_hook();
|
|
432
|
-
init_normalize_plugin_option();
|
|
433
|
-
init_minimal_plugin_context();
|
|
434
|
-
PluginDriver = class {
|
|
435
|
-
static async callOptionsHook(inputOptions, watchMode = false) {
|
|
436
|
-
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
437
|
-
const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
|
|
438
|
-
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
|
|
439
|
-
for (const plugin of plugins) {
|
|
440
|
-
const name = plugin.name || "unknown";
|
|
441
|
-
const options = plugin.options;
|
|
442
|
-
if (options) {
|
|
443
|
-
const { handler } = normalizeHook(options);
|
|
444
|
-
const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
|
|
445
|
-
if (result) inputOptions = result;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
return inputOptions;
|
|
449
|
-
}
|
|
450
|
-
static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
|
|
451
|
-
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
|
|
452
|
-
for (const plugin of sortedPlugins) {
|
|
453
|
-
const name = plugin.name || "unknown";
|
|
454
|
-
const options = plugin.outputOptions;
|
|
455
|
-
if (options) {
|
|
456
|
-
const { handler } = normalizeHook(options);
|
|
457
|
-
const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
|
|
458
|
-
if (result) outputOptions = result;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return outputOptions;
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
} });
|
|
465
|
-
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
|
|
468
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
469
|
-
function getGlobalConfig(config2) {
|
|
470
|
-
return {
|
|
471
|
-
lang: config2?.lang ?? store$1?.lang,
|
|
472
|
-
message: config2?.message,
|
|
473
|
-
abortEarly: config2?.abortEarly ?? store$1?.abortEarly,
|
|
474
|
-
abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
478
|
-
function getGlobalMessage(lang) {
|
|
479
|
-
return store2?.get(lang);
|
|
480
|
-
}
|
|
481
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
482
|
-
function getSchemaMessage(lang) {
|
|
483
|
-
return store3?.get(lang);
|
|
484
|
-
}
|
|
485
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
486
|
-
function getSpecificMessage(reference, lang) {
|
|
487
|
-
return store4?.get(reference)?.get(lang);
|
|
488
|
-
}
|
|
489
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
490
|
-
function _stringify(input) {
|
|
491
|
-
const type = typeof input;
|
|
492
|
-
if (type === "string") return `"${input}"`;
|
|
493
|
-
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
494
|
-
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
495
|
-
return type;
|
|
496
|
-
}
|
|
497
|
-
function _addIssue(context, label, dataset, config2, other) {
|
|
498
|
-
const input = other && "input" in other ? other.input : dataset.value;
|
|
499
|
-
const expected = other?.expected ?? context.expects ?? null;
|
|
500
|
-
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
501
|
-
const issue = {
|
|
502
|
-
kind: context.kind,
|
|
503
|
-
type: context.type,
|
|
504
|
-
input,
|
|
505
|
-
expected,
|
|
506
|
-
received,
|
|
507
|
-
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
508
|
-
requirement: context.requirement,
|
|
509
|
-
path: other?.path,
|
|
510
|
-
issues: other?.issues,
|
|
511
|
-
lang: config2.lang,
|
|
512
|
-
abortEarly: config2.abortEarly,
|
|
513
|
-
abortPipeEarly: config2.abortPipeEarly
|
|
514
|
-
};
|
|
515
|
-
const isSchema = context.kind === "schema";
|
|
516
|
-
const message2 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
517
|
-
if (message2 !== void 0) issue.message = typeof message2 === "function" ? message2(issue) : message2;
|
|
518
|
-
if (isSchema) dataset.typed = false;
|
|
519
|
-
if (dataset.issues) dataset.issues.push(issue);
|
|
520
|
-
else dataset.issues = [issue];
|
|
521
|
-
}
|
|
522
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
523
|
-
function _getStandardProps(context) {
|
|
524
|
-
return {
|
|
525
|
-
version: 1,
|
|
526
|
-
vendor: "valibot",
|
|
527
|
-
validate(value2) {
|
|
528
|
-
return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
533
|
-
function _isValidObjectKey(object2, key) {
|
|
534
|
-
return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
535
|
-
}
|
|
536
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
537
|
-
function _joinExpects(values2, separator) {
|
|
538
|
-
const list = [...new Set(values2)];
|
|
539
|
-
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
540
|
-
return list[0] ?? "never";
|
|
541
|
-
}
|
|
542
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
543
|
-
function args(schema) {
|
|
544
|
-
return {
|
|
545
|
-
kind: "transformation",
|
|
546
|
-
type: "args",
|
|
547
|
-
reference: args,
|
|
548
|
-
async: false,
|
|
549
|
-
schema,
|
|
550
|
-
"~run"(dataset, config2) {
|
|
551
|
-
const func = dataset.value;
|
|
552
|
-
dataset.value = (...args_) => {
|
|
553
|
-
const argsDataset = this.schema["~run"]({ value: args_ }, config2);
|
|
554
|
-
if (argsDataset.issues) throw new ValiError(argsDataset.issues);
|
|
555
|
-
return func(...argsDataset.value);
|
|
556
|
-
};
|
|
557
|
-
return dataset;
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
562
|
-
function awaitAsync() {
|
|
563
|
-
return {
|
|
564
|
-
kind: "transformation",
|
|
565
|
-
type: "await",
|
|
566
|
-
reference: awaitAsync,
|
|
567
|
-
async: true,
|
|
568
|
-
async "~run"(dataset) {
|
|
569
|
-
dataset.value = await dataset.value;
|
|
570
|
-
return dataset;
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
575
|
-
function description(description_) {
|
|
576
|
-
return {
|
|
577
|
-
kind: "metadata",
|
|
578
|
-
type: "description",
|
|
579
|
-
reference: description,
|
|
580
|
-
description: description_
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
584
|
-
function returns(schema) {
|
|
585
|
-
return {
|
|
586
|
-
kind: "transformation",
|
|
587
|
-
type: "returns",
|
|
588
|
-
reference: returns,
|
|
589
|
-
async: false,
|
|
590
|
-
schema,
|
|
591
|
-
"~run"(dataset, config2) {
|
|
592
|
-
const func = dataset.value;
|
|
593
|
-
dataset.value = (...args_) => {
|
|
594
|
-
const returnsDataset = this.schema["~run"]({ value: func(...args_) }, config2);
|
|
595
|
-
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
|
|
596
|
-
return returnsDataset.value;
|
|
597
|
-
};
|
|
598
|
-
return dataset;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
603
|
-
function returnsAsync(schema) {
|
|
604
|
-
return {
|
|
605
|
-
kind: "transformation",
|
|
606
|
-
type: "returns",
|
|
607
|
-
reference: returnsAsync,
|
|
608
|
-
async: false,
|
|
609
|
-
schema,
|
|
610
|
-
"~run"(dataset, config2) {
|
|
611
|
-
const func = dataset.value;
|
|
612
|
-
dataset.value = async (...args_) => {
|
|
613
|
-
const returnsDataset = await this.schema["~run"]({ value: await func(...args_) }, config2);
|
|
614
|
-
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
|
|
615
|
-
return returnsDataset.value;
|
|
616
|
-
};
|
|
617
|
-
return dataset;
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
622
|
-
function getFallback(schema, dataset, config2) {
|
|
623
|
-
return typeof schema.fallback === "function" ? schema.fallback(dataset, config2) : schema.fallback;
|
|
624
|
-
}
|
|
625
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
626
|
-
function getDefault(schema, dataset, config2) {
|
|
627
|
-
return typeof schema.default === "function" ? schema.default(dataset, config2) : schema.default;
|
|
628
|
-
}
|
|
629
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
630
|
-
function any() {
|
|
631
|
-
return {
|
|
632
|
-
kind: "schema",
|
|
633
|
-
type: "any",
|
|
634
|
-
reference: any,
|
|
635
|
-
expects: "any",
|
|
636
|
-
async: false,
|
|
637
|
-
get "~standard"() {
|
|
638
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
639
|
-
},
|
|
640
|
-
"~run"(dataset) {
|
|
641
|
-
dataset.typed = true;
|
|
642
|
-
return dataset;
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
647
|
-
function array(item, message2) {
|
|
648
|
-
return {
|
|
649
|
-
kind: "schema",
|
|
650
|
-
type: "array",
|
|
651
|
-
reference: array,
|
|
652
|
-
expects: "Array",
|
|
653
|
-
async: false,
|
|
654
|
-
item,
|
|
655
|
-
message: message2,
|
|
656
|
-
get "~standard"() {
|
|
657
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
658
|
-
},
|
|
659
|
-
"~run"(dataset, config2) {
|
|
660
|
-
const input = dataset.value;
|
|
661
|
-
if (Array.isArray(input)) {
|
|
662
|
-
dataset.typed = true;
|
|
663
|
-
dataset.value = [];
|
|
664
|
-
for (let key = 0; key < input.length; key++) {
|
|
665
|
-
const value2 = input[key];
|
|
666
|
-
const itemDataset = this.item["~run"]({ value: value2 }, config2);
|
|
667
|
-
if (itemDataset.issues) {
|
|
668
|
-
const pathItem = {
|
|
669
|
-
type: "array",
|
|
670
|
-
origin: "value",
|
|
671
|
-
input,
|
|
672
|
-
key,
|
|
673
|
-
value: value2
|
|
674
|
-
};
|
|
675
|
-
for (const issue of itemDataset.issues) {
|
|
676
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
677
|
-
else issue.path = [pathItem];
|
|
678
|
-
dataset.issues?.push(issue);
|
|
679
|
-
}
|
|
680
|
-
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
681
|
-
if (config2.abortEarly) {
|
|
682
|
-
dataset.typed = false;
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
if (!itemDataset.typed) dataset.typed = false;
|
|
687
|
-
dataset.value.push(itemDataset.value);
|
|
688
|
-
}
|
|
689
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
690
|
-
return dataset;
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
695
|
-
function boolean(message2) {
|
|
696
|
-
return {
|
|
697
|
-
kind: "schema",
|
|
698
|
-
type: "boolean",
|
|
699
|
-
reference: boolean,
|
|
700
|
-
expects: "boolean",
|
|
701
|
-
async: false,
|
|
702
|
-
message: message2,
|
|
703
|
-
get "~standard"() {
|
|
704
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
705
|
-
},
|
|
706
|
-
"~run"(dataset, config2) {
|
|
707
|
-
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
708
|
-
else _addIssue(this, "type", dataset, config2);
|
|
709
|
-
return dataset;
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
714
|
-
function custom(check2, message2) {
|
|
715
|
-
return {
|
|
716
|
-
kind: "schema",
|
|
717
|
-
type: "custom",
|
|
718
|
-
reference: custom,
|
|
719
|
-
expects: "unknown",
|
|
720
|
-
async: false,
|
|
721
|
-
check: check2,
|
|
722
|
-
message: message2,
|
|
723
|
-
get "~standard"() {
|
|
724
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
725
|
-
},
|
|
726
|
-
"~run"(dataset, config2) {
|
|
727
|
-
if (this.check(dataset.value)) dataset.typed = true;
|
|
728
|
-
else _addIssue(this, "type", dataset, config2);
|
|
729
|
-
return dataset;
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
734
|
-
function function_(message2) {
|
|
735
|
-
return {
|
|
736
|
-
kind: "schema",
|
|
737
|
-
type: "function",
|
|
738
|
-
reference: function_,
|
|
739
|
-
expects: "Function",
|
|
740
|
-
async: false,
|
|
741
|
-
message: message2,
|
|
742
|
-
get "~standard"() {
|
|
743
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
744
|
-
},
|
|
745
|
-
"~run"(dataset, config2) {
|
|
746
|
-
if (typeof dataset.value === "function") dataset.typed = true;
|
|
747
|
-
else _addIssue(this, "type", dataset, config2);
|
|
748
|
-
return dataset;
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
753
|
-
function instance(class_, message2) {
|
|
754
|
-
return {
|
|
755
|
-
kind: "schema",
|
|
756
|
-
type: "instance",
|
|
757
|
-
reference: instance,
|
|
758
|
-
expects: class_.name,
|
|
759
|
-
async: false,
|
|
760
|
-
class: class_,
|
|
761
|
-
message: message2,
|
|
762
|
-
get "~standard"() {
|
|
763
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
764
|
-
},
|
|
765
|
-
"~run"(dataset, config2) {
|
|
766
|
-
if (dataset.value instanceof this.class) dataset.typed = true;
|
|
767
|
-
else _addIssue(this, "type", dataset, config2);
|
|
768
|
-
return dataset;
|
|
769
|
-
}
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
773
|
-
function literal(literal_, message2) {
|
|
774
|
-
return {
|
|
775
|
-
kind: "schema",
|
|
776
|
-
type: "literal",
|
|
777
|
-
reference: literal,
|
|
778
|
-
expects: /* @__PURE__ */ _stringify(literal_),
|
|
779
|
-
async: false,
|
|
780
|
-
literal: literal_,
|
|
781
|
-
message: message2,
|
|
782
|
-
get "~standard"() {
|
|
783
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
784
|
-
},
|
|
785
|
-
"~run"(dataset, config2) {
|
|
786
|
-
if (dataset.value === this.literal) dataset.typed = true;
|
|
787
|
-
else _addIssue(this, "type", dataset, config2);
|
|
788
|
-
return dataset;
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
}
|
|
792
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
793
|
-
function looseObject(entries2, message2) {
|
|
794
|
-
return {
|
|
795
|
-
kind: "schema",
|
|
796
|
-
type: "loose_object",
|
|
797
|
-
reference: looseObject,
|
|
798
|
-
expects: "Object",
|
|
799
|
-
async: false,
|
|
800
|
-
entries: entries2,
|
|
801
|
-
message: message2,
|
|
802
|
-
get "~standard"() {
|
|
803
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
804
|
-
},
|
|
805
|
-
"~run"(dataset, config2) {
|
|
806
|
-
const input = dataset.value;
|
|
807
|
-
if (input && typeof input === "object") {
|
|
808
|
-
dataset.typed = true;
|
|
809
|
-
dataset.value = {};
|
|
810
|
-
for (const key in this.entries) {
|
|
811
|
-
const valueSchema = this.entries[key];
|
|
812
|
-
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
813
|
-
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
814
|
-
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
815
|
-
if (valueDataset.issues) {
|
|
816
|
-
const pathItem = {
|
|
817
|
-
type: "object",
|
|
818
|
-
origin: "value",
|
|
819
|
-
input,
|
|
820
|
-
key,
|
|
821
|
-
value: value2
|
|
822
|
-
};
|
|
823
|
-
for (const issue of valueDataset.issues) {
|
|
824
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
825
|
-
else issue.path = [pathItem];
|
|
826
|
-
dataset.issues?.push(issue);
|
|
827
|
-
}
|
|
828
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
829
|
-
if (config2.abortEarly) {
|
|
830
|
-
dataset.typed = false;
|
|
831
|
-
break;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
if (!valueDataset.typed) dataset.typed = false;
|
|
835
|
-
dataset.value[key] = valueDataset.value;
|
|
836
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
837
|
-
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
838
|
-
_addIssue(this, "key", dataset, config2, {
|
|
839
|
-
input: void 0,
|
|
840
|
-
expected: `"${key}"`,
|
|
841
|
-
path: [{
|
|
842
|
-
type: "object",
|
|
843
|
-
origin: "key",
|
|
844
|
-
input,
|
|
845
|
-
key,
|
|
846
|
-
value: input[key]
|
|
847
|
-
}]
|
|
848
|
-
});
|
|
849
|
-
if (config2.abortEarly) break;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
if (!dataset.issues || !config2.abortEarly) {
|
|
853
|
-
for (const key in input) if (/* @__PURE__ */ _isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
|
|
854
|
-
}
|
|
855
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
856
|
-
return dataset;
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
}
|
|
860
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
861
|
-
function never(message2) {
|
|
862
|
-
return {
|
|
863
|
-
kind: "schema",
|
|
864
|
-
type: "never",
|
|
865
|
-
reference: never,
|
|
866
|
-
expects: "never",
|
|
867
|
-
async: false,
|
|
868
|
-
message: message2,
|
|
869
|
-
get "~standard"() {
|
|
870
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
871
|
-
},
|
|
872
|
-
"~run"(dataset, config2) {
|
|
873
|
-
_addIssue(this, "type", dataset, config2);
|
|
874
|
-
return dataset;
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
879
|
-
function nullish(wrapped, default_) {
|
|
880
|
-
return {
|
|
881
|
-
kind: "schema",
|
|
882
|
-
type: "nullish",
|
|
883
|
-
reference: nullish,
|
|
884
|
-
expects: `(${wrapped.expects} | null | undefined)`,
|
|
885
|
-
async: false,
|
|
886
|
-
wrapped,
|
|
887
|
-
default: default_,
|
|
888
|
-
get "~standard"() {
|
|
889
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
890
|
-
},
|
|
891
|
-
"~run"(dataset, config2) {
|
|
892
|
-
if (dataset.value === null || dataset.value === void 0) {
|
|
893
|
-
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
894
|
-
if (dataset.value === null || dataset.value === void 0) {
|
|
895
|
-
dataset.typed = true;
|
|
896
|
-
return dataset;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
return this.wrapped["~run"](dataset, config2);
|
|
900
|
-
}
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
904
|
-
function number(message2) {
|
|
905
|
-
return {
|
|
906
|
-
kind: "schema",
|
|
907
|
-
type: "number",
|
|
908
|
-
reference: number,
|
|
909
|
-
expects: "number",
|
|
910
|
-
async: false,
|
|
911
|
-
message: message2,
|
|
912
|
-
get "~standard"() {
|
|
913
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
914
|
-
},
|
|
915
|
-
"~run"(dataset, config2) {
|
|
916
|
-
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
917
|
-
else _addIssue(this, "type", dataset, config2);
|
|
918
|
-
return dataset;
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
923
|
-
function object(entries2, message2) {
|
|
924
|
-
return {
|
|
925
|
-
kind: "schema",
|
|
926
|
-
type: "object",
|
|
927
|
-
reference: object,
|
|
928
|
-
expects: "Object",
|
|
929
|
-
async: false,
|
|
930
|
-
entries: entries2,
|
|
931
|
-
message: message2,
|
|
932
|
-
get "~standard"() {
|
|
933
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
934
|
-
},
|
|
935
|
-
"~run"(dataset, config2) {
|
|
936
|
-
const input = dataset.value;
|
|
937
|
-
if (input && typeof input === "object") {
|
|
938
|
-
dataset.typed = true;
|
|
939
|
-
dataset.value = {};
|
|
940
|
-
for (const key in this.entries) {
|
|
941
|
-
const valueSchema = this.entries[key];
|
|
942
|
-
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
943
|
-
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
944
|
-
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
945
|
-
if (valueDataset.issues) {
|
|
946
|
-
const pathItem = {
|
|
947
|
-
type: "object",
|
|
948
|
-
origin: "value",
|
|
949
|
-
input,
|
|
950
|
-
key,
|
|
951
|
-
value: value2
|
|
952
|
-
};
|
|
953
|
-
for (const issue of valueDataset.issues) {
|
|
954
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
955
|
-
else issue.path = [pathItem];
|
|
956
|
-
dataset.issues?.push(issue);
|
|
957
|
-
}
|
|
958
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
959
|
-
if (config2.abortEarly) {
|
|
960
|
-
dataset.typed = false;
|
|
961
|
-
break;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
if (!valueDataset.typed) dataset.typed = false;
|
|
965
|
-
dataset.value[key] = valueDataset.value;
|
|
966
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
967
|
-
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
968
|
-
_addIssue(this, "key", dataset, config2, {
|
|
969
|
-
input: void 0,
|
|
970
|
-
expected: `"${key}"`,
|
|
971
|
-
path: [{
|
|
972
|
-
type: "object",
|
|
973
|
-
origin: "key",
|
|
974
|
-
input,
|
|
975
|
-
key,
|
|
976
|
-
value: input[key]
|
|
977
|
-
}]
|
|
978
|
-
});
|
|
979
|
-
if (config2.abortEarly) break;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
983
|
-
return dataset;
|
|
984
|
-
}
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
988
|
-
function optional(wrapped, default_) {
|
|
989
|
-
return {
|
|
990
|
-
kind: "schema",
|
|
991
|
-
type: "optional",
|
|
992
|
-
reference: optional,
|
|
993
|
-
expects: `(${wrapped.expects} | undefined)`,
|
|
994
|
-
async: false,
|
|
995
|
-
wrapped,
|
|
996
|
-
default: default_,
|
|
997
|
-
get "~standard"() {
|
|
998
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
999
|
-
},
|
|
1000
|
-
"~run"(dataset, config2) {
|
|
1001
|
-
if (dataset.value === void 0) {
|
|
1002
|
-
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
|
|
1003
|
-
if (dataset.value === void 0) {
|
|
1004
|
-
dataset.typed = true;
|
|
1005
|
-
return dataset;
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
return this.wrapped["~run"](dataset, config2);
|
|
1009
|
-
}
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1013
|
-
function picklist(options, message2) {
|
|
1014
|
-
return {
|
|
1015
|
-
kind: "schema",
|
|
1016
|
-
type: "picklist",
|
|
1017
|
-
reference: picklist,
|
|
1018
|
-
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
|
|
1019
|
-
async: false,
|
|
1020
|
-
options,
|
|
1021
|
-
message: message2,
|
|
1022
|
-
get "~standard"() {
|
|
1023
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1024
|
-
},
|
|
1025
|
-
"~run"(dataset, config2) {
|
|
1026
|
-
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
1027
|
-
else _addIssue(this, "type", dataset, config2);
|
|
1028
|
-
return dataset;
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1033
|
-
function promise(message2) {
|
|
1034
|
-
return {
|
|
1035
|
-
kind: "schema",
|
|
1036
|
-
type: "promise",
|
|
1037
|
-
reference: promise,
|
|
1038
|
-
expects: "Promise",
|
|
1039
|
-
async: false,
|
|
1040
|
-
message: message2,
|
|
1041
|
-
get "~standard"() {
|
|
1042
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1043
|
-
},
|
|
1044
|
-
"~run"(dataset, config2) {
|
|
1045
|
-
if (dataset.value instanceof Promise) dataset.typed = true;
|
|
1046
|
-
else _addIssue(this, "type", dataset, config2);
|
|
1047
|
-
return dataset;
|
|
1048
|
-
}
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1052
|
-
function record(key, value2, message2) {
|
|
1053
|
-
return {
|
|
1054
|
-
kind: "schema",
|
|
1055
|
-
type: "record",
|
|
1056
|
-
reference: record,
|
|
1057
|
-
expects: "Object",
|
|
1058
|
-
async: false,
|
|
1059
|
-
key,
|
|
1060
|
-
value: value2,
|
|
1061
|
-
message: message2,
|
|
1062
|
-
get "~standard"() {
|
|
1063
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1064
|
-
},
|
|
1065
|
-
"~run"(dataset, config2) {
|
|
1066
|
-
const input = dataset.value;
|
|
1067
|
-
if (input && typeof input === "object") {
|
|
1068
|
-
dataset.typed = true;
|
|
1069
|
-
dataset.value = {};
|
|
1070
|
-
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
1071
|
-
const entryValue = input[entryKey];
|
|
1072
|
-
const keyDataset = this.key["~run"]({ value: entryKey }, config2);
|
|
1073
|
-
if (keyDataset.issues) {
|
|
1074
|
-
const pathItem = {
|
|
1075
|
-
type: "object",
|
|
1076
|
-
origin: "key",
|
|
1077
|
-
input,
|
|
1078
|
-
key: entryKey,
|
|
1079
|
-
value: entryValue
|
|
1080
|
-
};
|
|
1081
|
-
for (const issue of keyDataset.issues) {
|
|
1082
|
-
issue.path = [pathItem];
|
|
1083
|
-
dataset.issues?.push(issue);
|
|
1084
|
-
}
|
|
1085
|
-
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
1086
|
-
if (config2.abortEarly) {
|
|
1087
|
-
dataset.typed = false;
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
const valueDataset = this.value["~run"]({ value: entryValue }, config2);
|
|
1092
|
-
if (valueDataset.issues) {
|
|
1093
|
-
const pathItem = {
|
|
1094
|
-
type: "object",
|
|
1095
|
-
origin: "value",
|
|
1096
|
-
input,
|
|
1097
|
-
key: entryKey,
|
|
1098
|
-
value: entryValue
|
|
1099
|
-
};
|
|
1100
|
-
for (const issue of valueDataset.issues) {
|
|
1101
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
1102
|
-
else issue.path = [pathItem];
|
|
1103
|
-
dataset.issues?.push(issue);
|
|
1104
|
-
}
|
|
1105
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1106
|
-
if (config2.abortEarly) {
|
|
1107
|
-
dataset.typed = false;
|
|
1108
|
-
break;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
1112
|
-
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
1113
|
-
}
|
|
1114
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
1115
|
-
return dataset;
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
}
|
|
1119
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1120
|
-
function strictObject(entries2, message2) {
|
|
1121
|
-
return {
|
|
1122
|
-
kind: "schema",
|
|
1123
|
-
type: "strict_object",
|
|
1124
|
-
reference: strictObject,
|
|
1125
|
-
expects: "Object",
|
|
1126
|
-
async: false,
|
|
1127
|
-
entries: entries2,
|
|
1128
|
-
message: message2,
|
|
1129
|
-
get "~standard"() {
|
|
1130
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1131
|
-
},
|
|
1132
|
-
"~run"(dataset, config2) {
|
|
1133
|
-
const input = dataset.value;
|
|
1134
|
-
if (input && typeof input === "object") {
|
|
1135
|
-
dataset.typed = true;
|
|
1136
|
-
dataset.value = {};
|
|
1137
|
-
for (const key in this.entries) {
|
|
1138
|
-
const valueSchema = this.entries[key];
|
|
1139
|
-
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
1140
|
-
const value2 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
1141
|
-
const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
|
|
1142
|
-
if (valueDataset.issues) {
|
|
1143
|
-
const pathItem = {
|
|
1144
|
-
type: "object",
|
|
1145
|
-
origin: "value",
|
|
1146
|
-
input,
|
|
1147
|
-
key,
|
|
1148
|
-
value: value2
|
|
1149
|
-
};
|
|
1150
|
-
for (const issue of valueDataset.issues) {
|
|
1151
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
1152
|
-
else issue.path = [pathItem];
|
|
1153
|
-
dataset.issues?.push(issue);
|
|
1154
|
-
}
|
|
1155
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1156
|
-
if (config2.abortEarly) {
|
|
1157
|
-
dataset.typed = false;
|
|
1158
|
-
break;
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
if (!valueDataset.typed) dataset.typed = false;
|
|
1162
|
-
dataset.value[key] = valueDataset.value;
|
|
1163
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
1164
|
-
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
1165
|
-
_addIssue(this, "key", dataset, config2, {
|
|
1166
|
-
input: void 0,
|
|
1167
|
-
expected: `"${key}"`,
|
|
1168
|
-
path: [{
|
|
1169
|
-
type: "object",
|
|
1170
|
-
origin: "key",
|
|
1171
|
-
input,
|
|
1172
|
-
key,
|
|
1173
|
-
value: input[key]
|
|
1174
|
-
}]
|
|
1175
|
-
});
|
|
1176
|
-
if (config2.abortEarly) break;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
if (!dataset.issues || !config2.abortEarly) {
|
|
1180
|
-
for (const key in input) if (!(key in this.entries)) {
|
|
1181
|
-
_addIssue(this, "key", dataset, config2, {
|
|
1182
|
-
input: key,
|
|
1183
|
-
expected: "never",
|
|
1184
|
-
path: [{
|
|
1185
|
-
type: "object",
|
|
1186
|
-
origin: "key",
|
|
1187
|
-
input,
|
|
1188
|
-
key,
|
|
1189
|
-
value: input[key]
|
|
1190
|
-
}]
|
|
1191
|
-
});
|
|
1192
|
-
break;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
1196
|
-
return dataset;
|
|
1197
|
-
}
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1201
|
-
function string(message2) {
|
|
1202
|
-
return {
|
|
1203
|
-
kind: "schema",
|
|
1204
|
-
type: "string",
|
|
1205
|
-
reference: string,
|
|
1206
|
-
expects: "string",
|
|
1207
|
-
async: false,
|
|
1208
|
-
message: message2,
|
|
1209
|
-
get "~standard"() {
|
|
1210
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1211
|
-
},
|
|
1212
|
-
"~run"(dataset, config2) {
|
|
1213
|
-
if (typeof dataset.value === "string") dataset.typed = true;
|
|
1214
|
-
else _addIssue(this, "type", dataset, config2);
|
|
1215
|
-
return dataset;
|
|
1216
|
-
}
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1220
|
-
function tuple(items, message2) {
|
|
1221
|
-
return {
|
|
1222
|
-
kind: "schema",
|
|
1223
|
-
type: "tuple",
|
|
1224
|
-
reference: tuple,
|
|
1225
|
-
expects: "Array",
|
|
1226
|
-
async: false,
|
|
1227
|
-
items,
|
|
1228
|
-
message: message2,
|
|
1229
|
-
get "~standard"() {
|
|
1230
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1231
|
-
},
|
|
1232
|
-
"~run"(dataset, config2) {
|
|
1233
|
-
const input = dataset.value;
|
|
1234
|
-
if (Array.isArray(input)) {
|
|
1235
|
-
dataset.typed = true;
|
|
1236
|
-
dataset.value = [];
|
|
1237
|
-
for (let key = 0; key < this.items.length; key++) {
|
|
1238
|
-
const value2 = input[key];
|
|
1239
|
-
const itemDataset = this.items[key]["~run"]({ value: value2 }, config2);
|
|
1240
|
-
if (itemDataset.issues) {
|
|
1241
|
-
const pathItem = {
|
|
1242
|
-
type: "array",
|
|
1243
|
-
origin: "value",
|
|
1244
|
-
input,
|
|
1245
|
-
key,
|
|
1246
|
-
value: value2
|
|
1247
|
-
};
|
|
1248
|
-
for (const issue of itemDataset.issues) {
|
|
1249
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
1250
|
-
else issue.path = [pathItem];
|
|
1251
|
-
dataset.issues?.push(issue);
|
|
1252
|
-
}
|
|
1253
|
-
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
1254
|
-
if (config2.abortEarly) {
|
|
1255
|
-
dataset.typed = false;
|
|
1256
|
-
break;
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
if (!itemDataset.typed) dataset.typed = false;
|
|
1260
|
-
dataset.value.push(itemDataset.value);
|
|
1261
|
-
}
|
|
1262
|
-
} else _addIssue(this, "type", dataset, config2);
|
|
1263
|
-
return dataset;
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
}
|
|
1267
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1268
|
-
function _subIssues(datasets) {
|
|
1269
|
-
let issues;
|
|
1270
|
-
if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
|
|
1271
|
-
else issues = dataset.issues;
|
|
1272
|
-
return issues;
|
|
1273
|
-
}
|
|
1274
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1275
|
-
function union(options, message2) {
|
|
1276
|
-
return {
|
|
1277
|
-
kind: "schema",
|
|
1278
|
-
type: "union",
|
|
1279
|
-
reference: union,
|
|
1280
|
-
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1281
|
-
async: false,
|
|
1282
|
-
options,
|
|
1283
|
-
message: message2,
|
|
1284
|
-
get "~standard"() {
|
|
1285
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1286
|
-
},
|
|
1287
|
-
"~run"(dataset, config2) {
|
|
1288
|
-
let validDataset;
|
|
1289
|
-
let typedDatasets;
|
|
1290
|
-
let untypedDatasets;
|
|
1291
|
-
for (const schema of this.options) {
|
|
1292
|
-
const optionDataset = schema["~run"]({ value: dataset.value }, config2);
|
|
1293
|
-
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
1294
|
-
else typedDatasets = [optionDataset];
|
|
1295
|
-
else {
|
|
1296
|
-
validDataset = optionDataset;
|
|
1297
|
-
break;
|
|
1298
|
-
}
|
|
1299
|
-
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
1300
|
-
else untypedDatasets = [optionDataset];
|
|
1301
|
-
}
|
|
1302
|
-
if (validDataset) return validDataset;
|
|
1303
|
-
if (typedDatasets) {
|
|
1304
|
-
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1305
|
-
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
1306
|
-
dataset.typed = true;
|
|
1307
|
-
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1308
|
-
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1309
|
-
return dataset;
|
|
1310
|
-
}
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1314
|
-
function unionAsync(options, message2) {
|
|
1315
|
-
return {
|
|
1316
|
-
kind: "schema",
|
|
1317
|
-
type: "union",
|
|
1318
|
-
reference: unionAsync,
|
|
1319
|
-
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
|
|
1320
|
-
async: true,
|
|
1321
|
-
options,
|
|
1322
|
-
message: message2,
|
|
1323
|
-
get "~standard"() {
|
|
1324
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1325
|
-
},
|
|
1326
|
-
async "~run"(dataset, config2) {
|
|
1327
|
-
let validDataset;
|
|
1328
|
-
let typedDatasets;
|
|
1329
|
-
let untypedDatasets;
|
|
1330
|
-
for (const schema of this.options) {
|
|
1331
|
-
const optionDataset = await schema["~run"]({ value: dataset.value }, config2);
|
|
1332
|
-
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
|
|
1333
|
-
else typedDatasets = [optionDataset];
|
|
1334
|
-
else {
|
|
1335
|
-
validDataset = optionDataset;
|
|
1336
|
-
break;
|
|
1337
|
-
}
|
|
1338
|
-
else if (untypedDatasets) untypedDatasets.push(optionDataset);
|
|
1339
|
-
else untypedDatasets = [optionDataset];
|
|
1340
|
-
}
|
|
1341
|
-
if (validDataset) return validDataset;
|
|
1342
|
-
if (typedDatasets) {
|
|
1343
|
-
if (typedDatasets.length === 1) return typedDatasets[0];
|
|
1344
|
-
_addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
|
|
1345
|
-
dataset.typed = true;
|
|
1346
|
-
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1347
|
-
else _addIssue(this, "type", dataset, config2, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
|
|
1348
|
-
return dataset;
|
|
1349
|
-
}
|
|
1350
|
-
};
|
|
1351
|
-
}
|
|
1352
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1353
|
-
function keyof(schema, message2) {
|
|
1354
|
-
return /* @__PURE__ */ picklist(Object.keys(schema.entries), message2);
|
|
1355
|
-
}
|
|
1356
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1357
|
-
function omit(schema, keys) {
|
|
1358
|
-
const entries2 = { ...schema.entries };
|
|
1359
|
-
for (const key of keys) delete entries2[key];
|
|
1360
|
-
return {
|
|
1361
|
-
...schema,
|
|
1362
|
-
entries: entries2,
|
|
1363
|
-
get "~standard"() {
|
|
1364
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1365
|
-
}
|
|
1366
|
-
};
|
|
1367
|
-
}
|
|
1368
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1369
|
-
function pipe(...pipe2) {
|
|
1370
|
-
return {
|
|
1371
|
-
...pipe2[0],
|
|
1372
|
-
pipe: pipe2,
|
|
1373
|
-
get "~standard"() {
|
|
1374
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1375
|
-
},
|
|
1376
|
-
"~run"(dataset, config2) {
|
|
1377
|
-
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
1378
|
-
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
1379
|
-
dataset.typed = false;
|
|
1380
|
-
break;
|
|
1381
|
-
}
|
|
1382
|
-
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = item["~run"](dataset, config2);
|
|
1383
|
-
}
|
|
1384
|
-
return dataset;
|
|
1385
|
-
}
|
|
1386
|
-
};
|
|
1387
|
-
}
|
|
1388
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1389
|
-
function pipeAsync(...pipe2) {
|
|
1390
|
-
return {
|
|
1391
|
-
...pipe2[0],
|
|
1392
|
-
pipe: pipe2,
|
|
1393
|
-
async: true,
|
|
1394
|
-
get "~standard"() {
|
|
1395
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
1396
|
-
},
|
|
1397
|
-
async "~run"(dataset, config2) {
|
|
1398
|
-
for (const item of pipe2) if (item.kind !== "metadata") {
|
|
1399
|
-
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
|
|
1400
|
-
dataset.typed = false;
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) dataset = await item["~run"](dataset, config2);
|
|
1404
|
-
}
|
|
1405
|
-
return dataset;
|
|
1406
|
-
}
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1410
|
-
function safeParse(schema, input, config2) {
|
|
1411
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config2));
|
|
1412
|
-
return {
|
|
1413
|
-
typed: dataset.typed,
|
|
1414
|
-
success: !dataset.issues,
|
|
1415
|
-
output: dataset.value,
|
|
1416
|
-
issues: dataset.issues
|
|
1417
|
-
};
|
|
1418
|
-
}
|
|
1419
|
-
var store$1, store2, store3, store4, ValiError;
|
|
1420
|
-
var init_dist$3 = __esm({ "../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js"() {
|
|
1421
|
-
ValiError = class extends Error {
|
|
1422
|
-
/**
|
|
1423
|
-
* Creates a Valibot error with useful information.
|
|
1424
|
-
*
|
|
1425
|
-
* @param issues The error issues.
|
|
1426
|
-
*/
|
|
1427
|
-
constructor(issues) {
|
|
1428
|
-
super(issues[0].message);
|
|
1429
|
-
this.name = "ValiError";
|
|
1430
|
-
this.issues = issues;
|
|
1431
|
-
}
|
|
1432
|
-
};
|
|
1433
|
-
} });
|
|
1434
|
-
|
|
1435
|
-
//#endregion
|
|
1436
|
-
//#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.2.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
|
|
1437
|
-
function getGlobalDefs() {
|
|
1438
|
-
return store;
|
|
1439
|
-
}
|
|
1440
|
-
function addError(errors, message) {
|
|
1441
|
-
if (errors) {
|
|
1442
|
-
errors.push(message);
|
|
1443
|
-
return errors;
|
|
1444
|
-
}
|
|
1445
|
-
return [message];
|
|
1446
|
-
}
|
|
1447
|
-
function handleError(message, config) {
|
|
1448
|
-
switch (config?.errorMode) {
|
|
1449
|
-
case "ignore": break;
|
|
1450
|
-
case "warn": {
|
|
1451
|
-
console.warn(message);
|
|
1452
|
-
break;
|
|
1453
|
-
}
|
|
1454
|
-
default: throw new Error(message);
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
function convertAction(jsonSchema, valibotAction, config) {
|
|
1458
|
-
let errors;
|
|
1459
|
-
switch (valibotAction.type) {
|
|
1460
|
-
case "base64": {
|
|
1461
|
-
jsonSchema.contentEncoding = "base64";
|
|
1462
|
-
break;
|
|
1463
|
-
}
|
|
1464
|
-
case "bic":
|
|
1465
|
-
case "cuid2":
|
|
1466
|
-
case "decimal":
|
|
1467
|
-
case "digits":
|
|
1468
|
-
case "emoji":
|
|
1469
|
-
case "hexadecimal":
|
|
1470
|
-
case "hex_color":
|
|
1471
|
-
case "nanoid":
|
|
1472
|
-
case "octal":
|
|
1473
|
-
case "ulid": {
|
|
1474
|
-
jsonSchema.pattern = valibotAction.requirement.source;
|
|
1475
|
-
break;
|
|
1476
|
-
}
|
|
1477
|
-
case "description": {
|
|
1478
|
-
jsonSchema.description = valibotAction.description;
|
|
1479
|
-
break;
|
|
1480
|
-
}
|
|
1481
|
-
case "email": {
|
|
1482
|
-
jsonSchema.format = "email";
|
|
1483
|
-
break;
|
|
1484
|
-
}
|
|
1485
|
-
case "empty": {
|
|
1486
|
-
if (jsonSchema.type === "array") jsonSchema.maxItems = 0;
|
|
1487
|
-
else {
|
|
1488
|
-
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
1489
|
-
jsonSchema.maxLength = 0;
|
|
1490
|
-
}
|
|
1491
|
-
break;
|
|
1492
|
-
}
|
|
1493
|
-
case "entries": {
|
|
1494
|
-
jsonSchema.minProperties = valibotAction.requirement;
|
|
1495
|
-
jsonSchema.maxProperties = valibotAction.requirement;
|
|
1496
|
-
break;
|
|
1497
|
-
}
|
|
1498
|
-
case "integer": {
|
|
1499
|
-
jsonSchema.type = "integer";
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
case "ipv4": {
|
|
1503
|
-
jsonSchema.format = "ipv4";
|
|
1504
|
-
break;
|
|
1505
|
-
}
|
|
1506
|
-
case "ipv6": {
|
|
1507
|
-
jsonSchema.format = "ipv6";
|
|
1508
|
-
break;
|
|
1509
|
-
}
|
|
1510
|
-
case "iso_date": {
|
|
1511
|
-
jsonSchema.format = "date";
|
|
1512
|
-
break;
|
|
1513
|
-
}
|
|
1514
|
-
case "iso_date_time":
|
|
1515
|
-
case "iso_timestamp": {
|
|
1516
|
-
jsonSchema.format = "date-time";
|
|
1517
|
-
break;
|
|
1518
|
-
}
|
|
1519
|
-
case "iso_time": {
|
|
1520
|
-
jsonSchema.format = "time";
|
|
1521
|
-
break;
|
|
1522
|
-
}
|
|
1523
|
-
case "length": {
|
|
1524
|
-
if (jsonSchema.type === "array") {
|
|
1525
|
-
jsonSchema.minItems = valibotAction.requirement;
|
|
1526
|
-
jsonSchema.maxItems = valibotAction.requirement;
|
|
1527
|
-
} else {
|
|
1528
|
-
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
1529
|
-
jsonSchema.minLength = valibotAction.requirement;
|
|
1530
|
-
jsonSchema.maxLength = valibotAction.requirement;
|
|
1531
|
-
}
|
|
1532
|
-
break;
|
|
1533
|
-
}
|
|
1534
|
-
case "max_entries": {
|
|
1535
|
-
jsonSchema.maxProperties = valibotAction.requirement;
|
|
1536
|
-
break;
|
|
1537
|
-
}
|
|
1538
|
-
case "max_length": {
|
|
1539
|
-
if (jsonSchema.type === "array") jsonSchema.maxItems = valibotAction.requirement;
|
|
1540
|
-
else {
|
|
1541
|
-
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
1542
|
-
jsonSchema.maxLength = valibotAction.requirement;
|
|
1543
|
-
}
|
|
1544
|
-
break;
|
|
1545
|
-
}
|
|
1546
|
-
case "max_value": {
|
|
1547
|
-
if (jsonSchema.type !== "number") errors = addError(errors, `The "max_value" action is not supported on type "${jsonSchema.type}".`);
|
|
1548
|
-
jsonSchema.maximum = valibotAction.requirement;
|
|
1549
|
-
break;
|
|
1550
|
-
}
|
|
1551
|
-
case "metadata": {
|
|
1552
|
-
if (typeof valibotAction.metadata.title === "string") jsonSchema.title = valibotAction.metadata.title;
|
|
1553
|
-
if (typeof valibotAction.metadata.description === "string") jsonSchema.description = valibotAction.metadata.description;
|
|
1554
|
-
if (Array.isArray(valibotAction.metadata.examples)) jsonSchema.examples = valibotAction.metadata.examples;
|
|
1555
|
-
break;
|
|
1556
|
-
}
|
|
1557
|
-
case "min_entries": {
|
|
1558
|
-
jsonSchema.minProperties = valibotAction.requirement;
|
|
1559
|
-
break;
|
|
1560
|
-
}
|
|
1561
|
-
case "min_length": {
|
|
1562
|
-
if (jsonSchema.type === "array") jsonSchema.minItems = valibotAction.requirement;
|
|
1563
|
-
else {
|
|
1564
|
-
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
1565
|
-
jsonSchema.minLength = valibotAction.requirement;
|
|
1566
|
-
}
|
|
1567
|
-
break;
|
|
1568
|
-
}
|
|
1569
|
-
case "min_value": {
|
|
1570
|
-
if (jsonSchema.type !== "number") errors = addError(errors, `The "min_value" action is not supported on type "${jsonSchema.type}".`);
|
|
1571
|
-
jsonSchema.minimum = valibotAction.requirement;
|
|
1572
|
-
break;
|
|
1573
|
-
}
|
|
1574
|
-
case "multiple_of": {
|
|
1575
|
-
jsonSchema.multipleOf = valibotAction.requirement;
|
|
1576
|
-
break;
|
|
1577
|
-
}
|
|
1578
|
-
case "non_empty": {
|
|
1579
|
-
if (jsonSchema.type === "array") jsonSchema.minItems = 1;
|
|
1580
|
-
else {
|
|
1581
|
-
if (jsonSchema.type !== "string") errors = addError(errors, `The "${valibotAction.type}" action is not supported on type "${jsonSchema.type}".`);
|
|
1582
|
-
jsonSchema.minLength = 1;
|
|
1583
|
-
}
|
|
1584
|
-
break;
|
|
1585
|
-
}
|
|
1586
|
-
case "regex": {
|
|
1587
|
-
if (valibotAction.requirement.flags) errors = addError(errors, "RegExp flags are not supported by JSON Schema.");
|
|
1588
|
-
jsonSchema.pattern = valibotAction.requirement.source;
|
|
1589
|
-
break;
|
|
1590
|
-
}
|
|
1591
|
-
case "title": {
|
|
1592
|
-
jsonSchema.title = valibotAction.title;
|
|
1593
|
-
break;
|
|
1594
|
-
}
|
|
1595
|
-
case "url": {
|
|
1596
|
-
jsonSchema.format = "uri";
|
|
1597
|
-
break;
|
|
1598
|
-
}
|
|
1599
|
-
case "uuid": {
|
|
1600
|
-
jsonSchema.format = "uuid";
|
|
1601
|
-
break;
|
|
1602
|
-
}
|
|
1603
|
-
case "value": {
|
|
1604
|
-
jsonSchema.const = valibotAction.requirement;
|
|
1605
|
-
break;
|
|
1606
|
-
}
|
|
1607
|
-
default: errors = addError(errors, `The "${valibotAction.type}" action cannot be converted to JSON Schema.`);
|
|
1608
|
-
}
|
|
1609
|
-
if (config?.overrideAction) {
|
|
1610
|
-
const actionOverride = config.overrideAction({
|
|
1611
|
-
valibotAction,
|
|
1612
|
-
jsonSchema,
|
|
1613
|
-
errors
|
|
1614
|
-
});
|
|
1615
|
-
if (actionOverride) return { ...actionOverride };
|
|
1616
|
-
}
|
|
1617
|
-
if (errors) for (const message of errors) handleError(message, config);
|
|
1618
|
-
return jsonSchema;
|
|
1619
|
-
}
|
|
1620
|
-
function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
|
|
1621
|
-
if (!skipRef) {
|
|
1622
|
-
const referenceId = context.referenceMap.get(valibotSchema);
|
|
1623
|
-
if (referenceId) {
|
|
1624
|
-
jsonSchema.$ref = `#/$defs/${referenceId}`;
|
|
1625
|
-
if (config?.overrideRef) {
|
|
1626
|
-
const refOverride = config.overrideRef({
|
|
1627
|
-
...context,
|
|
1628
|
-
referenceId,
|
|
1629
|
-
valibotSchema,
|
|
1630
|
-
jsonSchema
|
|
1631
|
-
});
|
|
1632
|
-
if (refOverride) jsonSchema.$ref = refOverride;
|
|
1633
|
-
}
|
|
1634
|
-
return jsonSchema;
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
if ("pipe" in valibotSchema) {
|
|
1638
|
-
for (let index = 0; index < valibotSchema.pipe.length; index++) {
|
|
1639
|
-
const valibotPipeItem = valibotSchema.pipe[index];
|
|
1640
|
-
if (valibotPipeItem.kind === "schema") {
|
|
1641
|
-
if (index > 0) handleError("A \"pipe\" with multiple schemas cannot be converted to JSON Schema.", config);
|
|
1642
|
-
jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
|
|
1643
|
-
} else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
|
|
1644
|
-
}
|
|
1645
|
-
return jsonSchema;
|
|
1646
|
-
}
|
|
1647
|
-
let errors;
|
|
1648
|
-
switch (valibotSchema.type) {
|
|
1649
|
-
case "boolean": {
|
|
1650
|
-
jsonSchema.type = "boolean";
|
|
1651
|
-
break;
|
|
1652
|
-
}
|
|
1653
|
-
case "null": {
|
|
1654
|
-
jsonSchema.type = "null";
|
|
1655
|
-
break;
|
|
1656
|
-
}
|
|
1657
|
-
case "number": {
|
|
1658
|
-
jsonSchema.type = "number";
|
|
1659
|
-
break;
|
|
1660
|
-
}
|
|
1661
|
-
case "string": {
|
|
1662
|
-
jsonSchema.type = "string";
|
|
1663
|
-
break;
|
|
1664
|
-
}
|
|
1665
|
-
case "array": {
|
|
1666
|
-
jsonSchema.type = "array";
|
|
1667
|
-
jsonSchema.items = convertSchema({}, valibotSchema.item, config, context);
|
|
1668
|
-
break;
|
|
1669
|
-
}
|
|
1670
|
-
case "tuple":
|
|
1671
|
-
case "tuple_with_rest":
|
|
1672
|
-
case "loose_tuple":
|
|
1673
|
-
case "strict_tuple": {
|
|
1674
|
-
jsonSchema.type = "array";
|
|
1675
|
-
jsonSchema.items = [];
|
|
1676
|
-
jsonSchema.minItems = valibotSchema.items.length;
|
|
1677
|
-
for (const item of valibotSchema.items) jsonSchema.items.push(convertSchema({}, item, config, context));
|
|
1678
|
-
if (valibotSchema.type === "tuple_with_rest") jsonSchema.additionalItems = convertSchema({}, valibotSchema.rest, config, context);
|
|
1679
|
-
else if (valibotSchema.type === "strict_tuple") jsonSchema.additionalItems = false;
|
|
1680
|
-
break;
|
|
1681
|
-
}
|
|
1682
|
-
case "object":
|
|
1683
|
-
case "object_with_rest":
|
|
1684
|
-
case "loose_object":
|
|
1685
|
-
case "strict_object": {
|
|
1686
|
-
jsonSchema.type = "object";
|
|
1687
|
-
jsonSchema.properties = {};
|
|
1688
|
-
jsonSchema.required = [];
|
|
1689
|
-
for (const key in valibotSchema.entries) {
|
|
1690
|
-
const entry = valibotSchema.entries[key];
|
|
1691
|
-
jsonSchema.properties[key] = convertSchema({}, entry, config, context);
|
|
1692
|
-
if (entry.type !== "nullish" && entry.type !== "optional") jsonSchema.required.push(key);
|
|
1693
|
-
}
|
|
1694
|
-
if (valibotSchema.type === "object_with_rest") jsonSchema.additionalProperties = convertSchema({}, valibotSchema.rest, config, context);
|
|
1695
|
-
else if (valibotSchema.type === "strict_object") jsonSchema.additionalProperties = false;
|
|
1696
|
-
break;
|
|
1697
|
-
}
|
|
1698
|
-
case "record": {
|
|
1699
|
-
if ("pipe" in valibotSchema.key) errors = addError(errors, "The \"record\" schema with a schema for the key that contains a \"pipe\" cannot be converted to JSON Schema.");
|
|
1700
|
-
if (valibotSchema.key.type !== "string") errors = addError(errors, `The "record" schema with the "${valibotSchema.key.type}" schema for the key cannot be converted to JSON Schema.`);
|
|
1701
|
-
jsonSchema.type = "object";
|
|
1702
|
-
jsonSchema.additionalProperties = convertSchema({}, valibotSchema.value, config, context);
|
|
1703
|
-
break;
|
|
1704
|
-
}
|
|
1705
|
-
case "any":
|
|
1706
|
-
case "unknown": break;
|
|
1707
|
-
case "nullable":
|
|
1708
|
-
case "nullish": {
|
|
1709
|
-
jsonSchema.anyOf = [convertSchema({}, valibotSchema.wrapped, config, context), { type: "null" }];
|
|
1710
|
-
if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
|
|
1711
|
-
break;
|
|
1712
|
-
}
|
|
1713
|
-
case "exact_optional":
|
|
1714
|
-
case "optional":
|
|
1715
|
-
case "undefinedable": {
|
|
1716
|
-
jsonSchema = convertSchema(jsonSchema, valibotSchema.wrapped, config, context);
|
|
1717
|
-
if (valibotSchema.default !== void 0) jsonSchema.default = getDefault(valibotSchema);
|
|
1718
|
-
break;
|
|
1719
|
-
}
|
|
1720
|
-
case "literal": {
|
|
1721
|
-
if (typeof valibotSchema.literal !== "boolean" && typeof valibotSchema.literal !== "number" && typeof valibotSchema.literal !== "string") errors = addError(errors, "The value of the \"literal\" schema is not JSON compatible.");
|
|
1722
|
-
jsonSchema.const = valibotSchema.literal;
|
|
1723
|
-
break;
|
|
1724
|
-
}
|
|
1725
|
-
case "enum": {
|
|
1726
|
-
jsonSchema.enum = valibotSchema.options;
|
|
1727
|
-
break;
|
|
1728
|
-
}
|
|
1729
|
-
case "picklist": {
|
|
1730
|
-
if (valibotSchema.options.some((option) => typeof option !== "number" && typeof option !== "string")) errors = addError(errors, "An option of the \"picklist\" schema is not JSON compatible.");
|
|
1731
|
-
jsonSchema.enum = valibotSchema.options;
|
|
1732
|
-
break;
|
|
1733
|
-
}
|
|
1734
|
-
case "union":
|
|
1735
|
-
case "variant": {
|
|
1736
|
-
jsonSchema.anyOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
1737
|
-
break;
|
|
1738
|
-
}
|
|
1739
|
-
case "intersect": {
|
|
1740
|
-
jsonSchema.allOf = valibotSchema.options.map((option) => convertSchema({}, option, config, context));
|
|
1741
|
-
break;
|
|
1742
|
-
}
|
|
1743
|
-
case "lazy": {
|
|
1744
|
-
let wrappedValibotSchema = context.getterMap.get(valibotSchema.getter);
|
|
1745
|
-
if (!wrappedValibotSchema) {
|
|
1746
|
-
wrappedValibotSchema = valibotSchema.getter(void 0);
|
|
1747
|
-
context.getterMap.set(valibotSchema.getter, wrappedValibotSchema);
|
|
1748
|
-
}
|
|
1749
|
-
let referenceId = context.referenceMap.get(wrappedValibotSchema);
|
|
1750
|
-
if (!referenceId) {
|
|
1751
|
-
referenceId = `${refCount++}`;
|
|
1752
|
-
context.referenceMap.set(wrappedValibotSchema, referenceId);
|
|
1753
|
-
context.definitions[referenceId] = convertSchema({}, wrappedValibotSchema, config, context, true);
|
|
1754
|
-
}
|
|
1755
|
-
jsonSchema.$ref = `#/$defs/${referenceId}`;
|
|
1756
|
-
if (config?.overrideRef) {
|
|
1757
|
-
const refOverride = config.overrideRef({
|
|
1758
|
-
...context,
|
|
1759
|
-
referenceId,
|
|
1760
|
-
valibotSchema,
|
|
1761
|
-
jsonSchema
|
|
1762
|
-
});
|
|
1763
|
-
if (refOverride) jsonSchema.$ref = refOverride;
|
|
1764
|
-
}
|
|
1765
|
-
break;
|
|
1766
|
-
}
|
|
1767
|
-
default: errors = addError(errors, `The "${valibotSchema.type}" schema cannot be converted to JSON Schema.`);
|
|
1768
|
-
}
|
|
1769
|
-
if (config?.overrideSchema) {
|
|
1770
|
-
const schemaOverride = config.overrideSchema({
|
|
1771
|
-
...context,
|
|
1772
|
-
referenceId: context.referenceMap.get(valibotSchema),
|
|
1773
|
-
valibotSchema,
|
|
1774
|
-
jsonSchema,
|
|
1775
|
-
errors
|
|
1776
|
-
});
|
|
1777
|
-
if (schemaOverride) return { ...schemaOverride };
|
|
1778
|
-
}
|
|
1779
|
-
if (errors) for (const message of errors) handleError(message, config);
|
|
1780
|
-
return jsonSchema;
|
|
1781
|
-
}
|
|
1782
|
-
function toJsonSchema(schema, config) {
|
|
1783
|
-
const context = {
|
|
1784
|
-
definitions: {},
|
|
1785
|
-
referenceMap: /* @__PURE__ */ new Map(),
|
|
1786
|
-
getterMap: /* @__PURE__ */ new Map()
|
|
1787
|
-
};
|
|
1788
|
-
const definitions = config?.definitions ?? getGlobalDefs();
|
|
1789
|
-
if (definitions) {
|
|
1790
|
-
for (const key in definitions) context.referenceMap.set(definitions[key], key);
|
|
1791
|
-
for (const key in definitions) context.definitions[key] = convertSchema({}, definitions[key], config, context, true);
|
|
1792
|
-
}
|
|
1793
|
-
const jsonSchema = convertSchema({ $schema: "http://json-schema.org/draft-07/schema#" }, schema, config, context);
|
|
1794
|
-
if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
|
|
1795
|
-
return jsonSchema;
|
|
1796
|
-
}
|
|
1797
|
-
var store, refCount;
|
|
1798
|
-
var init_dist$2 = __esm({ "../../node_modules/.pnpm/@valibot+to-json-schema@1.2.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js"() {
|
|
1799
|
-
init_dist$3();
|
|
1800
|
-
refCount = 0;
|
|
1801
|
-
} });
|
|
1802
|
-
|
|
1803
|
-
//#endregion
|
|
1804
|
-
//#region src/utils/validator.ts
|
|
1805
|
-
function validateCliOptions(options) {
|
|
1806
|
-
let parsed = safeParse(CliOptionsSchema, options);
|
|
1807
|
-
return [parsed.output, parsed.issues?.map((issue) => {
|
|
1808
|
-
const option = issue.path?.map((pathItem) => pathItem.key).join(" ");
|
|
1809
|
-
return `Invalid value for option ${option}: ${issue.message}`;
|
|
1810
|
-
})];
|
|
1811
|
-
}
|
|
1812
|
-
function validateOption(key, options) {
|
|
1813
|
-
if (globalThis.process?.env?.ROLLUP_TEST) return;
|
|
1814
|
-
let parsed = safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
|
|
1815
|
-
if (!parsed.success) {
|
|
1816
|
-
const errors = parsed.issues.map((issue) => {
|
|
1817
|
-
const issuePaths = issue.path.map((path$1) => path$1.key);
|
|
1818
|
-
let issueMsg = issue.message;
|
|
1819
|
-
if (issue.type === "union") {
|
|
1820
|
-
const subIssue = issue.issues?.find((i$1) => !(i$1.type !== issue.received && i$1.input === issue.input));
|
|
1821
|
-
if (subIssue) {
|
|
1822
|
-
if (subIssue.path) issuePaths.push(subIssue.path.map((path$1) => path$1.key));
|
|
1823
|
-
issueMsg = subIssue.message;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
const stringPath = issuePaths.join(".");
|
|
1827
|
-
const helper = key === "input" ? inputHelperMsgRecord[stringPath] : outputHelperMsgRecord[stringPath];
|
|
1828
|
-
if (helper && helper.ignored) return "";
|
|
1829
|
-
return `- For the "${stringPath}". ${issueMsg}. ${helper ? helper.msg : ""}`;
|
|
1830
|
-
}).filter(Boolean);
|
|
1831
|
-
if (errors.length) console.warn(`Warning validate ${key} options.\n` + errors.join("\n"));
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
function getInputCliKeys() {
|
|
1835
|
-
return keyof(InputCliOptionsSchema).options;
|
|
1836
|
-
}
|
|
1837
|
-
function getOutputCliKeys() {
|
|
1838
|
-
return keyof(OutputCliOptionsSchema).options;
|
|
1839
|
-
}
|
|
1840
|
-
function getJsonSchema() {
|
|
1841
|
-
return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
|
|
1842
|
-
}
|
|
1843
|
-
var StringOrRegExpSchema, LogLevelSchema, LogLevelOptionSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, InputOptionSchema, ExternalSchema, ModuleTypesSchema, JsxOptionsSchema, HelperModeSchema, DecoratorOptionSchema, HelpersSchema, RewriteImportExtensionsSchema, TypescriptSchema, AssumptionsSchema, TransformOptionsSchema, WatchOptionsSchema, ChecksOptionsSchema, MinifyOptionsSchema, ResolveOptionsSchema, TreeshakingOptionsSchema, OnLogSchema, OnwarnSchema, HmrSchema, InputOptionsSchema, InputCliOverrideSchema, InputCliOptionsSchema, ModuleFormatSchema, AddonFunctionSchema, ChunkFileNamesSchema, AssetFileNamesSchema, SanitizeFileNameSchema, GlobalsFunctionSchema, AdvancedChunksSchema, OutputOptionsSchema, getAddonDescription, OutputCliOverrideSchema, OutputCliOptionsSchema, CliOptionsSchema, inputHelperMsgRecord, outputHelperMsgRecord;
|
|
1844
|
-
var init_validator = __esm({ "src/utils/validator.ts"() {
|
|
1845
|
-
init_dist$2();
|
|
1846
|
-
init_dist$3();
|
|
1847
|
-
StringOrRegExpSchema = union([string(), instance(RegExp)]);
|
|
1848
|
-
LogLevelSchema = union([
|
|
1849
|
-
literal("debug"),
|
|
1850
|
-
literal("info"),
|
|
1851
|
-
literal("warn")
|
|
1852
|
-
]);
|
|
1853
|
-
LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
|
|
1854
|
-
LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
|
|
1855
|
-
RollupLogSchema = any();
|
|
1856
|
-
RollupLogWithStringSchema = union([RollupLogSchema, string()]);
|
|
1857
|
-
InputOptionSchema = union([
|
|
1858
|
-
string(),
|
|
1859
|
-
array(string()),
|
|
1860
|
-
record(string(), string())
|
|
1861
|
-
]);
|
|
1862
|
-
ExternalSchema = union([
|
|
1863
|
-
StringOrRegExpSchema,
|
|
1864
|
-
array(StringOrRegExpSchema),
|
|
1865
|
-
pipe(function_(), args(tuple([
|
|
1866
|
-
string(),
|
|
1867
|
-
optional(string()),
|
|
1868
|
-
boolean()
|
|
1869
|
-
])), returns(nullish(boolean())))
|
|
1870
|
-
]);
|
|
1871
|
-
ModuleTypesSchema = record(string(), union([
|
|
1872
|
-
literal("asset"),
|
|
1873
|
-
literal("base64"),
|
|
1874
|
-
literal("binary"),
|
|
1875
|
-
literal("css"),
|
|
1876
|
-
literal("dataurl"),
|
|
1877
|
-
literal("empty"),
|
|
1878
|
-
literal("js"),
|
|
1879
|
-
literal("json"),
|
|
1880
|
-
literal("jsx"),
|
|
1881
|
-
literal("text"),
|
|
1882
|
-
literal("ts"),
|
|
1883
|
-
literal("tsx")
|
|
1884
|
-
]));
|
|
1885
|
-
JsxOptionsSchema = strictObject({
|
|
1886
|
-
runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
|
|
1887
|
-
development: pipe(optional(boolean()), description("Development specific information")),
|
|
1888
|
-
throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
|
|
1889
|
-
importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
|
|
1890
|
-
pragma: pipe(optional(string()), description("Jsx element transformation")),
|
|
1891
|
-
pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
|
|
1892
|
-
refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
|
|
1893
|
-
});
|
|
1894
|
-
HelperModeSchema = union([literal("Runtime"), literal("External")]);
|
|
1895
|
-
DecoratorOptionSchema = object({
|
|
1896
|
-
legacy: optional(boolean()),
|
|
1897
|
-
emitDecoratorMetadata: optional(boolean())
|
|
1898
|
-
});
|
|
1899
|
-
HelpersSchema = object({ mode: optional(HelperModeSchema) });
|
|
1900
|
-
RewriteImportExtensionsSchema = union([
|
|
1901
|
-
literal("rewrite"),
|
|
1902
|
-
literal("remove"),
|
|
1903
|
-
boolean()
|
|
1904
|
-
]);
|
|
1905
|
-
TypescriptSchema = object({
|
|
1906
|
-
jsxPragma: optional(string()),
|
|
1907
|
-
jsxPragmaFrag: optional(string()),
|
|
1908
|
-
onlyRemoveTypeImports: optional(boolean()),
|
|
1909
|
-
allowNamespaces: optional(boolean()),
|
|
1910
|
-
allowDeclareFields: optional(boolean()),
|
|
1911
|
-
declaration: optional(object({
|
|
1912
|
-
stripInternal: optional(boolean()),
|
|
1913
|
-
sourcemap: optional(boolean())
|
|
1914
|
-
})),
|
|
1915
|
-
rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
|
|
1916
|
-
});
|
|
1917
|
-
AssumptionsSchema = object({
|
|
1918
|
-
ignoreFunctionLength: optional(boolean()),
|
|
1919
|
-
noDocumentAll: optional(boolean()),
|
|
1920
|
-
objectRestNoSymbols: optional(boolean()),
|
|
1921
|
-
pureGetters: optional(boolean()),
|
|
1922
|
-
setPublicClassFields: optional(boolean())
|
|
1923
|
-
});
|
|
1924
|
-
TransformOptionsSchema = object({
|
|
1925
|
-
assumptions: optional(AssumptionsSchema),
|
|
1926
|
-
typescript: optional(TypescriptSchema),
|
|
1927
|
-
helpers: optional(HelpersSchema),
|
|
1928
|
-
decorators: optional(DecoratorOptionSchema),
|
|
1929
|
-
jsx: optional(JsxOptionsSchema),
|
|
1930
|
-
target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
|
|
1931
|
-
});
|
|
1932
|
-
WatchOptionsSchema = strictObject({
|
|
1933
|
-
chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
|
|
1934
|
-
exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
|
|
1935
|
-
include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
|
|
1936
|
-
notify: pipe(optional(strictObject({
|
|
1937
|
-
compareContents: optional(boolean()),
|
|
1938
|
-
pollInterval: optional(number())
|
|
1939
|
-
})), description("Notify options")),
|
|
1940
|
-
skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
|
|
1941
|
-
buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
|
|
1942
|
-
});
|
|
1943
|
-
ChecksOptionsSchema = strictObject({
|
|
1944
|
-
circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
|
|
1945
|
-
eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
|
|
1946
|
-
missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
|
|
1947
|
-
missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
|
|
1948
|
-
mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
|
|
1949
|
-
unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
|
|
1950
|
-
unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
|
|
1951
|
-
filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
|
|
1952
|
-
commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
|
|
1953
|
-
importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
|
|
1954
|
-
configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
|
|
1955
|
-
});
|
|
1956
|
-
MinifyOptionsSchema = strictObject({
|
|
1957
|
-
mangle: optional(boolean()),
|
|
1958
|
-
compress: optional(boolean()),
|
|
1959
|
-
removeWhitespace: optional(boolean())
|
|
1960
|
-
});
|
|
1961
|
-
ResolveOptionsSchema = strictObject({
|
|
1962
|
-
alias: optional(record(string(), union([string(), array(string())]))),
|
|
1963
|
-
aliasFields: optional(array(array(string()))),
|
|
1964
|
-
conditionNames: optional(array(string())),
|
|
1965
|
-
extensionAlias: optional(record(string(), array(string()))),
|
|
1966
|
-
exportsFields: optional(array(array(string()))),
|
|
1967
|
-
extensions: optional(array(string())),
|
|
1968
|
-
mainFields: optional(array(string())),
|
|
1969
|
-
mainFiles: optional(array(string())),
|
|
1970
|
-
modules: optional(array(string())),
|
|
1971
|
-
symlinks: optional(boolean()),
|
|
1972
|
-
tsconfigFilename: optional(string())
|
|
1973
|
-
});
|
|
1974
|
-
TreeshakingOptionsSchema = union([boolean(), looseObject({
|
|
1975
|
-
annotations: optional(boolean()),
|
|
1976
|
-
manualPureFunctions: optional(array(string())),
|
|
1977
|
-
unknownGlobalSideEffects: optional(boolean())
|
|
1978
|
-
})]);
|
|
1979
|
-
OnLogSchema = pipe(function_(), args(tuple([
|
|
1980
|
-
LogLevelSchema,
|
|
1981
|
-
RollupLogSchema,
|
|
1982
|
-
pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
|
|
1983
|
-
])));
|
|
1984
|
-
OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
|
|
1985
|
-
HmrSchema = union([boolean(), strictObject({
|
|
1986
|
-
port: optional(number()),
|
|
1987
|
-
host: optional(string()),
|
|
1988
|
-
implement: optional(string())
|
|
1989
|
-
})]);
|
|
1990
|
-
InputOptionsSchema = strictObject({
|
|
1991
|
-
input: optional(InputOptionSchema),
|
|
1992
|
-
plugins: optional(custom(() => true)),
|
|
1993
|
-
external: optional(ExternalSchema),
|
|
1994
|
-
resolve: optional(ResolveOptionsSchema),
|
|
1995
|
-
cwd: pipe(optional(string()), description("Current working directory")),
|
|
1996
|
-
platform: pipe(optional(union([
|
|
1997
|
-
literal("browser"),
|
|
1998
|
-
literal("neutral"),
|
|
1999
|
-
literal("node")
|
|
2000
|
-
])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
|
|
2001
|
-
shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
|
|
2002
|
-
treeshake: optional(TreeshakingOptionsSchema),
|
|
2003
|
-
logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
|
|
2004
|
-
onLog: optional(OnLogSchema),
|
|
2005
|
-
onwarn: optional(OnwarnSchema),
|
|
2006
|
-
moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
|
|
2007
|
-
experimental: optional(strictObject({
|
|
2008
|
-
disableLiveBindings: optional(boolean()),
|
|
2009
|
-
enableComposingJsPlugins: optional(boolean()),
|
|
2010
|
-
resolveNewUrlToAsset: optional(boolean()),
|
|
2011
|
-
strictExecutionOrder: optional(boolean()),
|
|
2012
|
-
hmr: optional(HmrSchema),
|
|
2013
|
-
attachDebugInfo: optional(boolean())
|
|
2014
|
-
})),
|
|
2015
|
-
define: pipe(optional(record(string(), string())), description("Define global variables")),
|
|
2016
|
-
inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
|
|
2017
|
-
profilerNames: optional(boolean()),
|
|
2018
|
-
jsx: pipe(optional(union([
|
|
2019
|
-
literal(false),
|
|
2020
|
-
literal("react"),
|
|
2021
|
-
literal("react-jsx"),
|
|
2022
|
-
literal("preserve")
|
|
2023
|
-
])), description("Jsx options preset")),
|
|
2024
|
-
transform: optional(TransformOptionsSchema),
|
|
2025
|
-
watch: optional(union([WatchOptionsSchema, literal(false)])),
|
|
2026
|
-
dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
|
|
2027
|
-
checks: optional(ChecksOptionsSchema),
|
|
2028
|
-
keepNames: pipe(optional(boolean()), description("Keep function/class name")),
|
|
2029
|
-
debug: pipe(optional(object({ sessionId: pipe(optional(string()), description("Used to name the build.")) })), description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly."))
|
|
2030
|
-
});
|
|
2031
|
-
InputCliOverrideSchema = strictObject({
|
|
2032
|
-
input: pipe(optional(array(string())), description("Entry file")),
|
|
2033
|
-
external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
|
|
2034
|
-
inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
|
|
2035
|
-
treeshake: pipe(optional(boolean()), description("enable treeshaking"))
|
|
2036
|
-
});
|
|
2037
|
-
InputCliOptionsSchema = omit(strictObject({
|
|
2038
|
-
...InputOptionsSchema.entries,
|
|
2039
|
-
...InputCliOverrideSchema.entries
|
|
2040
|
-
}), [
|
|
2041
|
-
"plugins",
|
|
2042
|
-
"onwarn",
|
|
2043
|
-
"onLog",
|
|
2044
|
-
"resolve",
|
|
2045
|
-
"experimental",
|
|
2046
|
-
"profilerNames",
|
|
2047
|
-
"watch"
|
|
2048
|
-
]);
|
|
2049
|
-
ModuleFormatSchema = union([
|
|
2050
|
-
literal("es"),
|
|
2051
|
-
literal("cjs"),
|
|
2052
|
-
literal("esm"),
|
|
2053
|
-
literal("module"),
|
|
2054
|
-
literal("commonjs"),
|
|
2055
|
-
literal("iife"),
|
|
2056
|
-
literal("umd")
|
|
2057
|
-
]);
|
|
2058
|
-
AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
|
|
2059
|
-
ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
|
|
2060
|
-
AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
|
|
2061
|
-
SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
|
|
2062
|
-
GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
|
|
2063
|
-
AdvancedChunksSchema = strictObject({
|
|
2064
|
-
minSize: optional(number()),
|
|
2065
|
-
maxSize: optional(number()),
|
|
2066
|
-
minModuleSize: optional(number()),
|
|
2067
|
-
maxModuleSize: optional(number()),
|
|
2068
|
-
minShareCount: optional(number()),
|
|
2069
|
-
groups: optional(array(strictObject({
|
|
2070
|
-
name: string(),
|
|
2071
|
-
test: optional(union([string(), instance(RegExp)])),
|
|
2072
|
-
priority: optional(number()),
|
|
2073
|
-
minSize: optional(number()),
|
|
2074
|
-
minShareCount: optional(number()),
|
|
2075
|
-
maxSize: optional(number()),
|
|
2076
|
-
minModuleSize: optional(number()),
|
|
2077
|
-
maxModuleSize: optional(number())
|
|
2078
|
-
})))
|
|
2079
|
-
});
|
|
2080
|
-
OutputOptionsSchema = strictObject({
|
|
2081
|
-
dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
|
|
2082
|
-
file: pipe(optional(string()), description("Single output file")),
|
|
2083
|
-
exports: pipe(optional(union([
|
|
2084
|
-
literal("auto"),
|
|
2085
|
-
literal("named"),
|
|
2086
|
-
literal("default"),
|
|
2087
|
-
literal("none")
|
|
2088
|
-
])), description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
|
|
2089
|
-
hashCharacters: pipe(optional(union([
|
|
2090
|
-
literal("base64"),
|
|
2091
|
-
literal("base36"),
|
|
2092
|
-
literal("hex")
|
|
2093
|
-
])), description("Use the specified character set for file hashes")),
|
|
2094
|
-
format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
|
|
2095
|
-
sourcemap: pipe(optional(union([
|
|
2096
|
-
boolean(),
|
|
2097
|
-
literal("inline"),
|
|
2098
|
-
literal("hidden")
|
|
2099
|
-
])), description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
|
|
2100
|
-
sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
|
|
2101
|
-
sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
|
|
2102
|
-
sourcemapPathTransform: optional(custom(() => true)),
|
|
2103
|
-
banner: optional(union([string(), AddonFunctionSchema])),
|
|
2104
|
-
footer: optional(union([string(), AddonFunctionSchema])),
|
|
2105
|
-
intro: optional(union([string(), AddonFunctionSchema])),
|
|
2106
|
-
outro: optional(union([string(), AddonFunctionSchema])),
|
|
2107
|
-
extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
|
|
2108
|
-
esModule: optional(union([boolean(), literal("if-default-prop")])),
|
|
2109
|
-
assetFileNames: optional(AssetFileNamesSchema),
|
|
2110
|
-
entryFileNames: optional(ChunkFileNamesSchema),
|
|
2111
|
-
chunkFileNames: optional(ChunkFileNamesSchema),
|
|
2112
|
-
cssEntryFileNames: optional(ChunkFileNamesSchema),
|
|
2113
|
-
cssChunkFileNames: optional(ChunkFileNamesSchema),
|
|
2114
|
-
sanitizeFileName: optional(SanitizeFileNameSchema),
|
|
2115
|
-
minify: pipe(optional(union([
|
|
2116
|
-
boolean(),
|
|
2117
|
-
string("dce-only"),
|
|
2118
|
-
MinifyOptionsSchema
|
|
2119
|
-
])), description("Minify the bundled file")),
|
|
2120
|
-
name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
|
|
2121
|
-
globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
2122
|
-
externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
|
|
2123
|
-
inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
|
|
2124
|
-
manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
|
|
2125
|
-
advancedChunks: optional(AdvancedChunksSchema),
|
|
2126
|
-
legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
|
|
2127
|
-
plugins: optional(custom(() => true)),
|
|
2128
|
-
polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
|
|
2129
|
-
hoistTransitiveImports: optional(custom((input) => {
|
|
2130
|
-
if (input) return false;
|
|
2131
|
-
return true;
|
|
2132
|
-
}, () => `The 'true' value is not supported`)),
|
|
2133
|
-
preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
|
|
2134
|
-
preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
|
|
2135
|
-
virtualDirname: optional(string())
|
|
2136
|
-
});
|
|
2137
|
-
getAddonDescription = (placement, wrapper) => {
|
|
2138
|
-
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
2139
|
-
};
|
|
2140
|
-
OutputCliOverrideSchema = strictObject({
|
|
2141
|
-
assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
|
|
2142
|
-
entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
|
|
2143
|
-
chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
|
|
2144
|
-
cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
|
|
2145
|
-
cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
|
|
2146
|
-
sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
|
|
2147
|
-
banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
|
|
2148
|
-
footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
|
|
2149
|
-
intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
|
|
2150
|
-
outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
|
|
2151
|
-
esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
|
|
2152
|
-
globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
2153
|
-
advancedChunks: pipe(optional(strictObject({
|
|
2154
|
-
minSize: pipe(optional(number()), description("Minimum size of the chunk")),
|
|
2155
|
-
minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
|
|
2156
|
-
})), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
|
|
2157
|
-
minify: pipe(optional(boolean()), description("Minify the bundled file"))
|
|
2158
|
-
});
|
|
2159
|
-
OutputCliOptionsSchema = omit(strictObject({
|
|
2160
|
-
...OutputOptionsSchema.entries,
|
|
2161
|
-
...OutputCliOverrideSchema.entries
|
|
2162
|
-
}), [
|
|
2163
|
-
"sourcemapIgnoreList",
|
|
2164
|
-
"sourcemapPathTransform",
|
|
2165
|
-
"plugins",
|
|
2166
|
-
"hoistTransitiveImports"
|
|
2167
|
-
]);
|
|
2168
|
-
CliOptionsSchema = strictObject({
|
|
2169
|
-
config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
|
|
2170
|
-
help: pipe(optional(boolean()), description("Show help")),
|
|
2171
|
-
version: pipe(optional(boolean()), description("Show version number")),
|
|
2172
|
-
watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
|
|
2173
|
-
...InputCliOptionsSchema.entries,
|
|
2174
|
-
...OutputCliOptionsSchema.entries
|
|
2175
|
-
});
|
|
2176
|
-
inputHelperMsgRecord = { output: { ignored: true } };
|
|
2177
|
-
outputHelperMsgRecord = {};
|
|
2178
|
-
} });
|
|
2179
|
-
|
|
2180
|
-
//#endregion
|
|
2181
|
-
//#region src/constants/plugin-context.ts
|
|
2182
|
-
var SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF;
|
|
2183
|
-
var init_plugin_context$1 = __esm({ "src/constants/plugin-context.ts"() {
|
|
2184
|
-
SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
|
|
2185
|
-
} });
|
|
2186
|
-
|
|
2187
|
-
//#endregion
|
|
2188
|
-
//#region src/options/normalized-input-options.ts
|
|
2189
|
-
var NormalizedInputOptionsImpl;
|
|
2190
|
-
var init_normalized_input_options = __esm({ "src/options/normalized-input-options.ts"() {
|
|
2191
|
-
NormalizedInputOptionsImpl = class {
|
|
2192
|
-
inner;
|
|
2193
|
-
constructor(inner, onLog) {
|
|
2194
|
-
this.onLog = onLog;
|
|
2195
|
-
this.inner = inner;
|
|
2196
|
-
}
|
|
2197
|
-
get shimMissingExports() {
|
|
2198
|
-
return this.inner.shimMissingExports;
|
|
2199
|
-
}
|
|
2200
|
-
get input() {
|
|
2201
|
-
return this.inner.input;
|
|
2202
|
-
}
|
|
2203
|
-
get cwd() {
|
|
2204
|
-
return this.inner.cwd ?? void 0;
|
|
2205
|
-
}
|
|
2206
|
-
get platform() {
|
|
2207
|
-
return this.inner.platform;
|
|
2208
|
-
}
|
|
2209
|
-
};
|
|
2210
|
-
} });
|
|
2211
|
-
|
|
2212
|
-
//#endregion
|
|
2213
|
-
//#region src/types/sourcemap.ts
|
|
2214
|
-
function bindingifySourcemap(map) {
|
|
2215
|
-
if (map == null) return;
|
|
2216
|
-
return { inner: typeof map === "string" ? map : {
|
|
2217
|
-
file: map.file ?? void 0,
|
|
2218
|
-
mappings: map.mappings,
|
|
2219
|
-
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
|
|
2220
|
-
sources: map.sources?.map((s) => s ?? void 0),
|
|
2221
|
-
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
|
|
2222
|
-
names: map.names,
|
|
2223
|
-
x_google_ignoreList: map.x_google_ignoreList,
|
|
2224
|
-
debugId: "debugId" in map ? map.debugId : void 0
|
|
2225
|
-
} };
|
|
2226
|
-
}
|
|
2227
|
-
var init_sourcemap = __esm({ "src/types/sourcemap.ts"() {} });
|
|
2228
|
-
|
|
2229
|
-
//#endregion
|
|
2230
|
-
//#region src/utils/error.ts
|
|
2231
|
-
function normalizeErrors(rawErrors) {
|
|
2232
|
-
const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
|
|
2233
|
-
kind: e.kind,
|
|
2234
|
-
message: e.message,
|
|
2235
|
-
stack: void 0
|
|
2236
|
-
}));
|
|
2237
|
-
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
2238
|
-
for (let i$1 = 0; i$1 < errors.length; i$1++) {
|
|
2239
|
-
summary += "\n";
|
|
2240
|
-
if (i$1 >= 5) {
|
|
2241
|
-
summary += "...";
|
|
2242
|
-
break;
|
|
2243
|
-
}
|
|
2244
|
-
summary += getErrorMessage(errors[i$1]);
|
|
2245
|
-
}
|
|
2246
|
-
const wrapper = new Error(summary);
|
|
2247
|
-
Object.defineProperty(wrapper, "errors", {
|
|
2248
|
-
configurable: true,
|
|
2249
|
-
enumerable: true,
|
|
2250
|
-
get: () => errors,
|
|
2251
|
-
set: (value) => Object.defineProperty(wrapper, "errors", {
|
|
2252
|
-
configurable: true,
|
|
2253
|
-
enumerable: true,
|
|
2254
|
-
value
|
|
2255
|
-
})
|
|
2256
|
-
});
|
|
2257
|
-
return wrapper;
|
|
2258
|
-
}
|
|
2259
|
-
function getErrorMessage(e) {
|
|
2260
|
-
if (Object.hasOwn(e, "kind")) return e.message;
|
|
2261
|
-
let s = "";
|
|
2262
|
-
if (e.plugin) s += `[plugin ${e.plugin}]`;
|
|
2263
|
-
const id$1 = e.id ?? e.loc?.file;
|
|
2264
|
-
if (id$1) {
|
|
2265
|
-
s += " " + id$1;
|
|
2266
|
-
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
|
|
2267
|
-
}
|
|
2268
|
-
if (s) s += "\n";
|
|
2269
|
-
const message = `${e.name ?? "Error"}: ${e.message}`;
|
|
2270
|
-
s += message;
|
|
2271
|
-
if (e.frame) s = joinNewLine(s, e.frame);
|
|
2272
|
-
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
|
|
2273
|
-
return s;
|
|
2274
|
-
}
|
|
2275
|
-
function joinNewLine(s1, s2) {
|
|
2276
|
-
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
|
|
2277
|
-
}
|
|
2278
|
-
var init_error = __esm({ "src/utils/error.ts"() {} });
|
|
2279
|
-
|
|
2280
|
-
//#endregion
|
|
2281
|
-
//#region src/utils/transform-module-info.ts
|
|
2282
|
-
function transformModuleInfo(info, option) {
|
|
2283
|
-
return {
|
|
2284
|
-
get ast() {
|
|
2285
|
-
return unsupported("ModuleInfo#ast");
|
|
2286
|
-
},
|
|
2287
|
-
get code() {
|
|
2288
|
-
return info.code;
|
|
2289
|
-
},
|
|
2290
|
-
id: info.id,
|
|
2291
|
-
importers: info.importers,
|
|
2292
|
-
dynamicImporters: info.dynamicImporters,
|
|
2293
|
-
importedIds: info.importedIds,
|
|
2294
|
-
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
2295
|
-
exports: info.exports,
|
|
2296
|
-
isEntry: info.isEntry,
|
|
2297
|
-
...option
|
|
2298
|
-
};
|
|
2299
|
-
}
|
|
2300
|
-
var init_transform_module_info = __esm({ "src/utils/transform-module-info.ts"() {
|
|
2301
|
-
init_misc();
|
|
2302
|
-
} });
|
|
2303
|
-
|
|
2304
|
-
//#endregion
|
|
2305
|
-
//#region src/utils/transform-side-effects.ts
|
|
2306
|
-
function bindingifySideEffects(sideEffects) {
|
|
2307
|
-
switch (sideEffects) {
|
|
2308
|
-
case true: return BindingHookSideEffects.True;
|
|
2309
|
-
case false: return BindingHookSideEffects.False;
|
|
2310
|
-
case "no-treeshake": return BindingHookSideEffects.NoTreeshake;
|
|
2311
|
-
case null:
|
|
2312
|
-
case void 0: return void 0;
|
|
2313
|
-
default: throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
var init_transform_side_effects = __esm({ "src/utils/transform-side-effects.ts"() {} });
|
|
2317
|
-
|
|
2318
|
-
//#endregion
|
|
2319
|
-
//#region src/utils/transform-sourcemap.ts
|
|
2320
|
-
function isEmptySourcemapFiled(array$1) {
|
|
2321
|
-
if (!array$1) return true;
|
|
2322
|
-
if (array$1.length === 0 || !array$1[0]) return true;
|
|
2323
|
-
return false;
|
|
2324
|
-
}
|
|
2325
|
-
function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
|
|
2326
|
-
if (!rawMap) return;
|
|
2327
|
-
let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
|
|
2328
|
-
if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
|
|
2329
|
-
if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id$1) map.sources = [id$1];
|
|
2330
|
-
return map;
|
|
2331
|
-
}
|
|
2332
|
-
var init_transform_sourcemap = __esm({ "src/utils/transform-sourcemap.ts"() {} });
|
|
2333
|
-
|
|
2334
|
-
//#endregion
|
|
2335
|
-
//#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-D6FCK2GA.js
|
|
2336
|
-
function u$1(o, n, a) {
|
|
2337
|
-
let t$1 = (r) => o(r, ...n);
|
|
2338
|
-
return a === void 0 ? t$1 : Object.assign(t$1, {
|
|
2339
|
-
lazy: a,
|
|
2340
|
-
lazyArgs: n
|
|
2341
|
-
});
|
|
2342
|
-
}
|
|
2343
|
-
var init_chunk_D6FCK2GA = __esm({ "../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-D6FCK2GA.js"() {} });
|
|
2344
|
-
|
|
2345
|
-
//#endregion
|
|
2346
|
-
//#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-WIMGWYZL.js
|
|
2347
|
-
function u(r, n, o) {
|
|
2348
|
-
let a = r.length - n.length;
|
|
2349
|
-
if (a === 0) return r(...n);
|
|
2350
|
-
if (a === 1) return u$1(r, n, o);
|
|
2351
|
-
throw new Error("Wrong number of arguments");
|
|
2352
|
-
}
|
|
2353
|
-
var init_chunk_WIMGWYZL = __esm({ "../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-WIMGWYZL.js"() {
|
|
2354
|
-
init_chunk_D6FCK2GA();
|
|
2355
|
-
} });
|
|
2356
|
-
|
|
2357
|
-
//#endregion
|
|
2358
|
-
//#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-3IFJP4R5.js
|
|
2359
|
-
function d(...r) {
|
|
2360
|
-
return u(i, r);
|
|
2361
|
-
}
|
|
2362
|
-
var i;
|
|
2363
|
-
var init_chunk_3IFJP4R5 = __esm({ "../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-3IFJP4R5.js"() {
|
|
2364
|
-
init_chunk_WIMGWYZL();
|
|
2365
|
-
i = (r, t$1) => {
|
|
2366
|
-
let a = [[], []];
|
|
2367
|
-
for (let [o, e] of r.entries()) t$1(e, o, r) ? a[0].push(e) : a[1].push(e);
|
|
2368
|
-
return a;
|
|
2369
|
-
};
|
|
2370
|
-
} });
|
|
2371
|
-
|
|
2372
|
-
//#endregion
|
|
2373
|
-
//#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-5NQBDF4H.js
|
|
2374
|
-
function t(...n) {
|
|
2375
|
-
return u(Object.keys, n);
|
|
2376
|
-
}
|
|
2377
|
-
var init_chunk_5NQBDF4H = __esm({ "../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-5NQBDF4H.js"() {
|
|
2378
|
-
init_chunk_WIMGWYZL();
|
|
2379
|
-
} });
|
|
2380
|
-
|
|
2381
|
-
//#endregion
|
|
2382
|
-
//#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/index.js
|
|
2383
|
-
var init_dist$1 = __esm({ "../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/index.js"() {
|
|
2384
|
-
init_chunk_3IFJP4R5();
|
|
2385
|
-
init_chunk_5NQBDF4H();
|
|
2386
|
-
} });
|
|
2387
|
-
|
|
2388
|
-
//#endregion
|
|
2389
|
-
//#region src/plugin/bindingify-hook-filter.ts
|
|
2390
|
-
function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
|
|
2391
|
-
if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
|
|
2392
|
-
if (Array.isArray(matcher)) return matcher.map((m) => include(generateAtomMatcher(stringKind, m)));
|
|
2393
|
-
let ret = [];
|
|
2394
|
-
if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => exclude(generateAtomMatcher(stringKind, m))));
|
|
2395
|
-
if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(generateAtomMatcher(stringKind, m))));
|
|
2396
|
-
return ret;
|
|
2397
|
-
}
|
|
2398
|
-
function generateAtomMatcher(kind, matcher) {
|
|
2399
|
-
return kind === "code" ? code(matcher) : id(matcher);
|
|
2400
|
-
}
|
|
2401
|
-
function transformFilterMatcherToFilterExprs(filterOption) {
|
|
2402
|
-
if (!filterOption) return void 0;
|
|
2403
|
-
if (Array.isArray(filterOption)) return filterOption;
|
|
2404
|
-
const { id: id$1, code: code$1, moduleType: moduleType$1 } = filterOption;
|
|
2405
|
-
let ret = [];
|
|
2406
|
-
let idIncludes = [];
|
|
2407
|
-
let idExcludes = [];
|
|
2408
|
-
let codeIncludes = [];
|
|
2409
|
-
let codeExcludes = [];
|
|
2410
|
-
if (id$1) [idIncludes, idExcludes] = d(generalHookFilterMatcherToFilterExprs(id$1, "id") ?? [], (m) => m.kind === "include");
|
|
2411
|
-
if (code$1) [codeIncludes, codeExcludes] = d(generalHookFilterMatcherToFilterExprs(code$1, "code") ?? [], (m) => m.kind === "include");
|
|
2412
|
-
ret.push(...idExcludes);
|
|
2413
|
-
ret.push(...codeExcludes);
|
|
2414
|
-
let andExprList = [];
|
|
2415
|
-
if (moduleType$1) {
|
|
2416
|
-
let moduleTypes = Array.isArray(moduleType$1) ? moduleType$1 : moduleType$1.include ?? [];
|
|
2417
|
-
andExprList.push(or(...moduleTypes.map((m) => moduleType(m))));
|
|
2418
|
-
}
|
|
2419
|
-
if (idIncludes.length) andExprList.push(or(...idIncludes.map((item) => item.expr)));
|
|
2420
|
-
if (codeIncludes.length) andExprList.push(or(...codeIncludes.map((item) => item.expr)));
|
|
2421
|
-
if (andExprList.length) ret.push(include(and(...andExprList)));
|
|
2422
|
-
return ret;
|
|
2423
|
-
}
|
|
2424
|
-
function bindingifyGeneralHookFilter(stringKind, pattern) {
|
|
2425
|
-
let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
|
|
2426
|
-
let ret = [];
|
|
2427
|
-
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
2428
|
-
return ret.length > 0 ? { value: ret } : void 0;
|
|
2429
|
-
}
|
|
2430
|
-
function bindingifyFilterExpr(expr) {
|
|
2431
|
-
let list = [];
|
|
2432
|
-
bindingifyFilterExprImpl(expr, list);
|
|
2433
|
-
return list;
|
|
2434
|
-
}
|
|
2435
|
-
function bindingifyFilterExprImpl(expr, list) {
|
|
2436
|
-
switch (expr.kind) {
|
|
2437
|
-
case "and": {
|
|
2438
|
-
let args$1 = expr.args;
|
|
2439
|
-
for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
|
|
2440
|
-
list.push({
|
|
2441
|
-
kind: "And",
|
|
2442
|
-
payload: args$1.length
|
|
2443
|
-
});
|
|
2444
|
-
break;
|
|
2445
|
-
}
|
|
2446
|
-
case "or": {
|
|
2447
|
-
let args$1 = expr.args;
|
|
2448
|
-
for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
|
|
2449
|
-
list.push({
|
|
2450
|
-
kind: "Or",
|
|
2451
|
-
payload: args$1.length
|
|
2452
|
-
});
|
|
2453
|
-
break;
|
|
2454
|
-
}
|
|
2455
|
-
case "not": {
|
|
2456
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
2457
|
-
list.push({ kind: "Not" });
|
|
2458
|
-
break;
|
|
2459
|
-
}
|
|
2460
|
-
case "id": {
|
|
2461
|
-
list.push({
|
|
2462
|
-
kind: "Id",
|
|
2463
|
-
payload: expr.pattern
|
|
2464
|
-
});
|
|
2465
|
-
if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
|
|
2466
|
-
break;
|
|
2467
|
-
}
|
|
2468
|
-
case "moduleType": {
|
|
2469
|
-
list.push({
|
|
2470
|
-
kind: "ModuleType",
|
|
2471
|
-
payload: expr.pattern
|
|
2472
|
-
});
|
|
2473
|
-
break;
|
|
2474
|
-
}
|
|
2475
|
-
case "code": {
|
|
2476
|
-
list.push({
|
|
2477
|
-
kind: "Code",
|
|
2478
|
-
payload: expr.pattern
|
|
2479
|
-
});
|
|
2480
|
-
break;
|
|
2481
|
-
}
|
|
2482
|
-
case "include": {
|
|
2483
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
2484
|
-
list.push({ kind: "Include" });
|
|
2485
|
-
break;
|
|
2486
|
-
}
|
|
2487
|
-
case "exclude": {
|
|
2488
|
-
bindingifyFilterExprImpl(expr.expr, list);
|
|
2489
|
-
list.push({ kind: "Exclude" });
|
|
2490
|
-
break;
|
|
2491
|
-
}
|
|
2492
|
-
case "query": {
|
|
2493
|
-
list.push({
|
|
2494
|
-
kind: "QueryKey",
|
|
2495
|
-
payload: expr.key
|
|
2496
|
-
});
|
|
2497
|
-
list.push({
|
|
2498
|
-
kind: "QueryValue",
|
|
2499
|
-
payload: expr.pattern
|
|
2500
|
-
});
|
|
2501
|
-
break;
|
|
2502
|
-
}
|
|
2503
|
-
default: throw new Error(`Unknown filter expression: ${expr}`);
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
function bindingifyResolveIdFilter(filterOption) {
|
|
2507
|
-
if (!filterOption) return void 0;
|
|
2508
|
-
if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
|
|
2509
|
-
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
2510
|
-
}
|
|
2511
|
-
function bindingifyLoadFilter(filterOption) {
|
|
2512
|
-
if (!filterOption) return void 0;
|
|
2513
|
-
if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
|
|
2514
|
-
return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
|
|
2515
|
-
}
|
|
2516
|
-
function bindingifyTransformFilter(filterOption) {
|
|
2517
|
-
if (!filterOption) return void 0;
|
|
2518
|
-
let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
|
|
2519
|
-
let ret = [];
|
|
2520
|
-
if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
|
|
2521
|
-
return { value: ret.length > 0 ? ret : void 0 };
|
|
2522
|
-
}
|
|
2523
|
-
function bindingifyRenderChunkFilter(filterOption) {
|
|
2524
|
-
if (!filterOption) return void 0;
|
|
2525
|
-
if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
|
|
2526
|
-
return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
|
|
2527
|
-
}
|
|
2528
|
-
var init_bindingify_hook_filter = __esm({ "src/plugin/bindingify-hook-filter.ts"() {
|
|
2529
|
-
init_dist();
|
|
2530
|
-
init_dist$1();
|
|
2531
|
-
init_misc();
|
|
2532
|
-
} });
|
|
2533
|
-
|
|
2534
|
-
//#endregion
|
|
2535
|
-
//#region src/plugin/bindingify-plugin-hook-meta.ts
|
|
2536
|
-
function bindingifyPluginHookMeta(options) {
|
|
2537
|
-
return { order: bindingPluginOrder(options.order) };
|
|
2538
|
-
}
|
|
2539
|
-
function bindingPluginOrder(order) {
|
|
2540
|
-
switch (order) {
|
|
2541
|
-
case "post": return BindingPluginOrder.Post;
|
|
2542
|
-
case "pre": return BindingPluginOrder.Pre;
|
|
2543
|
-
case null:
|
|
2544
|
-
case void 0: return void 0;
|
|
2545
|
-
default: throw new Error(`Unknown plugin order: ${order}`);
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
|
-
var init_bindingify_plugin_hook_meta = __esm({ "src/plugin/bindingify-plugin-hook-meta.ts"() {} });
|
|
2549
|
-
|
|
2550
|
-
//#endregion
|
|
2551
|
-
//#region src/utils/asset-source.ts
|
|
2552
|
-
function transformAssetSource(bindingAssetSource$1) {
|
|
2553
|
-
return bindingAssetSource$1.inner;
|
|
2554
|
-
}
|
|
2555
|
-
function bindingAssetSource(source) {
|
|
2556
|
-
return { inner: source };
|
|
2557
|
-
}
|
|
2558
|
-
var init_asset_source = __esm({ "src/utils/asset-source.ts"() {} });
|
|
2559
|
-
|
|
2560
|
-
//#endregion
|
|
2561
|
-
//#region src/plugin/plugin-context.ts
|
|
2562
|
-
var PluginContextImpl;
|
|
2563
|
-
var init_plugin_context = __esm({ "src/plugin/plugin-context.ts"() {
|
|
2564
|
-
init_logging();
|
|
2565
|
-
init_logs();
|
|
2566
|
-
init_parse_ast_index();
|
|
2567
|
-
init_minimal_plugin_context();
|
|
2568
|
-
init_asset_source();
|
|
2569
|
-
init_misc();
|
|
2570
|
-
init_transform_side_effects();
|
|
2571
|
-
PluginContextImpl = class extends MinimalPluginContextImpl {
|
|
2572
|
-
getModuleInfo;
|
|
2573
|
-
constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
|
|
2574
|
-
super(onLog, logLevel, plugin.name, watchMode);
|
|
2575
|
-
this.outputOptions = outputOptions;
|
|
2576
|
-
this.context = context;
|
|
2577
|
-
this.data = data;
|
|
2578
|
-
this.onLog = onLog;
|
|
2579
|
-
this.currentLoadingModule = currentLoadingModule;
|
|
2580
|
-
this.getModuleInfo = (id$1) => this.data.getModuleInfo(id$1, context);
|
|
2581
|
-
}
|
|
2582
|
-
async load(options) {
|
|
2583
|
-
const id$1 = options.id;
|
|
2584
|
-
if (id$1 === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
2585
|
-
const moduleInfo = this.data.getModuleInfo(id$1, this.context);
|
|
2586
|
-
if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
|
|
2587
|
-
const rawOptions = {
|
|
2588
|
-
meta: options.meta || {},
|
|
2589
|
-
moduleSideEffects: options.moduleSideEffects || null,
|
|
2590
|
-
invalidate: false
|
|
2591
|
-
};
|
|
2592
|
-
this.data.updateModuleOption(id$1, rawOptions);
|
|
2593
|
-
async function createLoadModulePromise(context, data) {
|
|
2594
|
-
const loadPromise = data.loadModulePromiseMap.get(id$1);
|
|
2595
|
-
if (loadPromise) return loadPromise;
|
|
2596
|
-
const promise$1 = new Promise((resolve, _) => {
|
|
2597
|
-
data.loadModulePromiseResolveFnMap.set(id$1, resolve);
|
|
2598
|
-
});
|
|
2599
|
-
data.loadModulePromiseMap.set(id$1, promise$1);
|
|
2600
|
-
try {
|
|
2601
|
-
await context.load(id$1, bindingifySideEffects(options.moduleSideEffects));
|
|
2602
|
-
} catch (e) {
|
|
2603
|
-
data.loadModulePromiseMap.delete(id$1);
|
|
2604
|
-
data.loadModulePromiseResolveFnMap.delete(id$1);
|
|
2605
|
-
throw e;
|
|
2606
|
-
}
|
|
2607
|
-
return promise$1;
|
|
2608
|
-
}
|
|
2609
|
-
await createLoadModulePromise(this.context, this.data);
|
|
2610
|
-
return this.data.getModuleInfo(id$1, this.context);
|
|
2611
|
-
}
|
|
2612
|
-
async resolve(source, importer, options) {
|
|
2613
|
-
let receipt = void 0;
|
|
2614
|
-
if (options != null) receipt = this.data.saveResolveOptions(options);
|
|
2615
|
-
const res = await this.context.resolve(source, importer, {
|
|
2616
|
-
custom: receipt,
|
|
2617
|
-
skipSelf: options?.skipSelf
|
|
2618
|
-
});
|
|
2619
|
-
if (receipt != null) this.data.removeSavedResolveOptions(receipt);
|
|
2620
|
-
if (res == null) return null;
|
|
2621
|
-
const info = this.data.getModuleOption(res.id) || {};
|
|
2622
|
-
return {
|
|
2623
|
-
...res,
|
|
2624
|
-
external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
|
|
2625
|
-
...info
|
|
2626
|
-
};
|
|
2627
|
-
}
|
|
2628
|
-
emitFile = (file) => {
|
|
2629
|
-
if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
|
|
2630
|
-
if (file.type === "chunk") return this.context.emitChunk(file);
|
|
2631
|
-
const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
|
|
2632
|
-
const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
|
|
2633
|
-
return this.context.emitFile({
|
|
2634
|
-
...file,
|
|
2635
|
-
originalFileName: file.originalFileName || void 0,
|
|
2636
|
-
source: bindingAssetSource(file.source)
|
|
2637
|
-
}, filename, fnSanitizedFileName);
|
|
2638
|
-
};
|
|
2639
|
-
getAssetFileNames(file) {
|
|
2640
|
-
if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
|
|
2641
|
-
names: file.name ? [file.name] : [],
|
|
2642
|
-
originalFileNames: file.originalFileName ? [file.originalFileName] : [],
|
|
2643
|
-
source: file.source,
|
|
2644
|
-
type: "asset"
|
|
2645
|
-
});
|
|
2646
|
-
}
|
|
2647
|
-
getFileName(referenceId) {
|
|
2648
|
-
return this.context.getFileName(referenceId);
|
|
2649
|
-
}
|
|
2650
|
-
getModuleIds() {
|
|
2651
|
-
return this.data.getModuleIds(this.context);
|
|
2652
|
-
}
|
|
2653
|
-
addWatchFile(id$1) {
|
|
2654
|
-
this.context.addWatchFile(id$1);
|
|
2655
|
-
}
|
|
2656
|
-
parse(input, options) {
|
|
2657
|
-
return parseAst(input, options);
|
|
2658
|
-
}
|
|
2659
|
-
};
|
|
2660
|
-
} });
|
|
2661
|
-
|
|
2662
|
-
//#endregion
|
|
2663
|
-
//#region src/plugin/transform-plugin-context.ts
|
|
2664
|
-
var TransformPluginContextImpl;
|
|
2665
|
-
var init_transform_plugin_context = __esm({ "src/plugin/transform-plugin-context.ts"() {
|
|
2666
|
-
init_log_handler();
|
|
2667
|
-
init_logs();
|
|
2668
|
-
init_plugin_context();
|
|
2669
|
-
TransformPluginContextImpl = class extends PluginContextImpl {
|
|
2670
|
-
constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
|
|
2671
|
-
super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
|
|
2672
|
-
this.inner = inner;
|
|
2673
|
-
this.moduleId = moduleId;
|
|
2674
|
-
this.moduleSource = moduleSource;
|
|
2675
|
-
const getLogHandler$1 = (handler) => (log, pos) => {
|
|
2676
|
-
log = normalizeLog(log);
|
|
2677
|
-
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
2678
|
-
log.id = moduleId;
|
|
2679
|
-
log.hook = "transform";
|
|
2680
|
-
handler(log);
|
|
2681
|
-
};
|
|
2682
|
-
this.debug = getLogHandler$1(this.debug);
|
|
2683
|
-
this.warn = getLogHandler$1(this.warn);
|
|
2684
|
-
this.info = getLogHandler$1(this.info);
|
|
2685
|
-
}
|
|
2686
|
-
error(e, pos) {
|
|
2687
|
-
if (typeof e === "string") e = { message: e };
|
|
2688
|
-
if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
2689
|
-
e.id = this.moduleId;
|
|
2690
|
-
e.hook = "transform";
|
|
2691
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
2692
|
-
}
|
|
2693
|
-
getCombinedSourcemap() {
|
|
2694
|
-
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
2695
|
-
}
|
|
2696
|
-
};
|
|
2697
|
-
} });
|
|
2698
|
-
|
|
2699
|
-
//#endregion
|
|
2700
|
-
//#region src/plugin/bindingify-build-hooks.ts
|
|
2701
|
-
function bindingifyBuildStart(args$1) {
|
|
2702
|
-
const hook = args$1.plugin.buildStart;
|
|
2703
|
-
if (!hook) return {};
|
|
2704
|
-
const { handler, meta } = normalizeHook(hook);
|
|
2705
|
-
return {
|
|
2706
|
-
plugin: async (ctx, opts) => {
|
|
2707
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedInputOptionsImpl(opts, args$1.onLog));
|
|
2708
|
-
},
|
|
2709
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
2710
|
-
};
|
|
2711
|
-
}
|
|
2712
|
-
function bindingifyBuildEnd(args$1) {
|
|
2713
|
-
const hook = args$1.plugin.buildEnd;
|
|
2714
|
-
if (!hook) return {};
|
|
2715
|
-
const { handler, meta } = normalizeHook(hook);
|
|
2716
|
-
return {
|
|
2717
|
-
plugin: async (ctx, err) => {
|
|
2718
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), err ? normalizeErrors(err) : void 0);
|
|
2719
|
-
},
|
|
2720
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
2721
|
-
};
|
|
2722
|
-
}
|
|
2723
|
-
function bindingifyResolveId(args$1) {
|
|
2724
|
-
const hook = args$1.plugin.resolveId;
|
|
2725
|
-
if (!hook) return {};
|
|
2726
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
2727
|
-
return {
|
|
2728
|
-
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
2729
|
-
const contextResolveOptions = extraOptions.custom != null ? args$1.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
|
|
2730
|
-
const newExtraOptions = {
|
|
2731
|
-
...extraOptions,
|
|
2732
|
-
custom: contextResolveOptions?.custom,
|
|
2733
|
-
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
|
|
2734
|
-
};
|
|
2735
|
-
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0, newExtraOptions);
|
|
2736
|
-
if (ret == null) return;
|
|
2737
|
-
if (ret === false) return {
|
|
2738
|
-
id: specifier,
|
|
2739
|
-
external: true,
|
|
2740
|
-
normalizeExternalId: true
|
|
2741
|
-
};
|
|
2742
|
-
if (typeof ret === "string") return {
|
|
2743
|
-
id: ret,
|
|
2744
|
-
normalizeExternalId: true
|
|
2745
|
-
};
|
|
2746
|
-
let exist = args$1.pluginContextData.updateModuleOption(ret.id, {
|
|
2747
|
-
meta: ret.meta || {},
|
|
2748
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
2749
|
-
invalidate: false
|
|
2750
|
-
});
|
|
2751
|
-
return {
|
|
2752
|
-
id: ret.id,
|
|
2753
|
-
external: ret.external,
|
|
2754
|
-
normalizeExternalId: false,
|
|
2755
|
-
sideEffects: bindingifySideEffects(exist.moduleSideEffects)
|
|
2756
|
-
};
|
|
2757
|
-
},
|
|
2758
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
2759
|
-
filter: bindingifyResolveIdFilter(options.filter)
|
|
2760
|
-
};
|
|
2761
|
-
}
|
|
2762
|
-
function bindingifyResolveDynamicImport(args$1) {
|
|
2763
|
-
const hook = args$1.plugin.resolveDynamicImport;
|
|
2764
|
-
if (!hook) return {};
|
|
2765
|
-
const { handler, meta } = normalizeHook(hook);
|
|
2766
|
-
return {
|
|
2767
|
-
plugin: async (ctx, specifier, importer) => {
|
|
2768
|
-
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), specifier, importer ?? void 0);
|
|
2769
|
-
if (ret == null) return;
|
|
2770
|
-
if (ret === false) return {
|
|
2771
|
-
id: specifier,
|
|
2772
|
-
external: true
|
|
2773
|
-
};
|
|
2774
|
-
if (typeof ret === "string") return { id: ret };
|
|
2775
|
-
const result = {
|
|
2776
|
-
id: ret.id,
|
|
2777
|
-
external: ret.external
|
|
2778
|
-
};
|
|
2779
|
-
if (ret.moduleSideEffects !== null) result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
2780
|
-
args$1.pluginContextData.updateModuleOption(ret.id, {
|
|
2781
|
-
meta: ret.meta || {},
|
|
2782
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
2783
|
-
invalidate: false
|
|
2784
|
-
});
|
|
2785
|
-
return result;
|
|
2786
|
-
},
|
|
2787
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
2788
|
-
};
|
|
2789
|
-
}
|
|
2790
|
-
function bindingifyTransform(args$1) {
|
|
2791
|
-
const hook = args$1.plugin.transform;
|
|
2792
|
-
if (!hook) return {};
|
|
2793
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
2794
|
-
return {
|
|
2795
|
-
plugin: async (ctx, code$1, id$1, meta$1) => {
|
|
2796
|
-
const ret = await handler.call(new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id$1, code$1, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, id$1, meta$1);
|
|
2797
|
-
if (ret == null) return void 0;
|
|
2798
|
-
if (typeof ret === "string") return { code: ret };
|
|
2799
|
-
let moduleOption = args$1.pluginContextData.updateModuleOption(id$1, {
|
|
2800
|
-
meta: ret.meta ?? {},
|
|
2801
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
2802
|
-
invalidate: false
|
|
2803
|
-
});
|
|
2804
|
-
return {
|
|
2805
|
-
code: ret.code,
|
|
2806
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, ret.map)),
|
|
2807
|
-
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects),
|
|
2808
|
-
moduleType: ret.moduleType
|
|
2809
|
-
};
|
|
2810
|
-
},
|
|
2811
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
2812
|
-
filter: bindingifyTransformFilter(options.filter)
|
|
2813
|
-
};
|
|
2814
|
-
}
|
|
2815
|
-
function bindingifyLoad(args$1) {
|
|
2816
|
-
const hook = args$1.plugin.load;
|
|
2817
|
-
if (!hook) return {};
|
|
2818
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
2819
|
-
return {
|
|
2820
|
-
plugin: async (ctx, id$1) => {
|
|
2821
|
-
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode, id$1), id$1);
|
|
2822
|
-
if (ret == null) return;
|
|
2823
|
-
if (typeof ret === "string") return { code: ret };
|
|
2824
|
-
let moduleOption = args$1.pluginContextData.updateModuleOption(id$1, {
|
|
2825
|
-
meta: ret.meta || {},
|
|
2826
|
-
moduleSideEffects: ret.moduleSideEffects ?? null,
|
|
2827
|
-
invalidate: false
|
|
2828
|
-
});
|
|
2829
|
-
let map = preProcessSourceMap(ret, id$1);
|
|
2830
|
-
return {
|
|
2831
|
-
code: ret.code,
|
|
2832
|
-
map: bindingifySourcemap(map),
|
|
2833
|
-
moduleType: ret.moduleType,
|
|
2834
|
-
sideEffects: bindingifySideEffects(moduleOption.moduleSideEffects)
|
|
2835
|
-
};
|
|
2836
|
-
},
|
|
2837
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
2838
|
-
filter: bindingifyLoadFilter(options.filter)
|
|
2839
|
-
};
|
|
2840
|
-
}
|
|
2841
|
-
function preProcessSourceMap(ret, id$1) {
|
|
2842
|
-
if (!ret.map) return;
|
|
2843
|
-
let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
|
|
2844
|
-
if (!isEmptySourcemapFiled(map.sources)) {
|
|
2845
|
-
const directory = path.dirname(id$1) || ".";
|
|
2846
|
-
const sourceRoot = map.sourceRoot || ".";
|
|
2847
|
-
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
2848
|
-
}
|
|
2849
|
-
return map;
|
|
2850
|
-
}
|
|
2851
|
-
function bindingifyModuleParsed(args$1) {
|
|
2852
|
-
const hook = args$1.plugin.moduleParsed;
|
|
2853
|
-
if (!hook) return {};
|
|
2854
|
-
const { handler, meta } = normalizeHook(hook);
|
|
2855
|
-
return {
|
|
2856
|
-
plugin: async (ctx, moduleInfo) => {
|
|
2857
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformModuleInfo(moduleInfo, args$1.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
2858
|
-
},
|
|
2859
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
2860
|
-
};
|
|
2861
|
-
}
|
|
2862
|
-
var init_bindingify_build_hooks = __esm({ "src/plugin/bindingify-build-hooks.ts"() {
|
|
2863
|
-
init_normalize_hook();
|
|
2864
|
-
init_plugin_context$1();
|
|
2865
|
-
init_normalized_input_options();
|
|
2866
|
-
init_sourcemap();
|
|
2867
|
-
init_error();
|
|
2868
|
-
init_transform_module_info();
|
|
2869
|
-
init_transform_side_effects();
|
|
2870
|
-
init_transform_sourcemap();
|
|
2871
|
-
init_bindingify_hook_filter();
|
|
2872
|
-
init_bindingify_plugin_hook_meta();
|
|
2873
|
-
init_plugin_context();
|
|
2874
|
-
init_transform_plugin_context();
|
|
2875
|
-
} });
|
|
2876
|
-
|
|
2877
|
-
//#endregion
|
|
2878
|
-
//#region src/utils/transform-rendered-module.ts
|
|
2879
|
-
function transformToRenderedModule(bindingRenderedModule) {
|
|
2880
|
-
return {
|
|
2881
|
-
get code() {
|
|
2882
|
-
return bindingRenderedModule.code;
|
|
2883
|
-
},
|
|
2884
|
-
get renderedLength() {
|
|
2885
|
-
return bindingRenderedModule.code?.length || 0;
|
|
2886
|
-
},
|
|
2887
|
-
get renderedExports() {
|
|
2888
|
-
return bindingRenderedModule.renderedExports;
|
|
2889
|
-
}
|
|
2890
|
-
};
|
|
2891
|
-
}
|
|
2892
|
-
var init_transform_rendered_module = __esm({ "src/utils/transform-rendered-module.ts"() {} });
|
|
2893
|
-
|
|
2894
|
-
//#endregion
|
|
2895
|
-
//#region src/utils/transform-rendered-chunk.ts
|
|
2896
|
-
function transformRenderedChunk(chunk) {
|
|
2897
|
-
let modules = null;
|
|
2898
|
-
return {
|
|
2899
|
-
type: "chunk",
|
|
2900
|
-
get name() {
|
|
2901
|
-
return chunk.name;
|
|
2902
|
-
},
|
|
2903
|
-
get isEntry() {
|
|
2904
|
-
return chunk.isEntry;
|
|
2905
|
-
},
|
|
2906
|
-
get isDynamicEntry() {
|
|
2907
|
-
return chunk.isDynamicEntry;
|
|
2908
|
-
},
|
|
2909
|
-
get facadeModuleId() {
|
|
2910
|
-
return chunk.facadeModuleId;
|
|
2911
|
-
},
|
|
2912
|
-
get moduleIds() {
|
|
2913
|
-
return chunk.moduleIds;
|
|
2914
|
-
},
|
|
2915
|
-
get exports() {
|
|
2916
|
-
return chunk.exports;
|
|
2917
|
-
},
|
|
2918
|
-
get fileName() {
|
|
2919
|
-
return chunk.fileName;
|
|
2920
|
-
},
|
|
2921
|
-
get imports() {
|
|
2922
|
-
return chunk.imports;
|
|
2923
|
-
},
|
|
2924
|
-
get dynamicImports() {
|
|
2925
|
-
return chunk.dynamicImports;
|
|
2926
|
-
},
|
|
2927
|
-
get modules() {
|
|
2928
|
-
if (!modules) modules = transformChunkModules(chunk.modules);
|
|
2929
|
-
return modules;
|
|
2930
|
-
}
|
|
2931
|
-
};
|
|
2932
|
-
}
|
|
2933
|
-
function transformChunkModules(modules) {
|
|
2934
|
-
const result = {};
|
|
2935
|
-
for (let i$1 = 0; i$1 < modules.values.length; i$1++) {
|
|
2936
|
-
let key = modules.keys[i$1];
|
|
2937
|
-
const mod = modules.values[i$1];
|
|
2938
|
-
result[key] = transformToRenderedModule(mod);
|
|
2939
|
-
}
|
|
2940
|
-
return result;
|
|
2941
|
-
}
|
|
2942
|
-
var init_transform_rendered_chunk = __esm({ "src/utils/transform-rendered-chunk.ts"() {
|
|
2943
|
-
init_transform_rendered_module();
|
|
2944
|
-
} });
|
|
2945
|
-
|
|
2946
|
-
//#endregion
|
|
2947
|
-
//#region src/utils/bindingify-output-options.ts
|
|
2948
|
-
function bindingifyOutputOptions(outputOptions) {
|
|
2949
|
-
const { dir, format, exports, hashCharacters, sourcemap, sourcemapDebugIds, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, preserveModulesRoot } = outputOptions;
|
|
2950
|
-
return {
|
|
2951
|
-
dir,
|
|
2952
|
-
file: file == null ? void 0 : file,
|
|
2953
|
-
format: bindingifyFormat(format),
|
|
2954
|
-
exports,
|
|
2955
|
-
hashCharacters,
|
|
2956
|
-
sourcemap: bindingifySourcemap$1(sourcemap),
|
|
2957
|
-
sourcemapDebugIds,
|
|
2958
|
-
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
2959
|
-
sourcemapPathTransform,
|
|
2960
|
-
banner: bindingifyAddon(banner),
|
|
2961
|
-
footer: bindingifyAddon(footer),
|
|
2962
|
-
intro: bindingifyAddon(intro),
|
|
2963
|
-
outro: bindingifyAddon(outro),
|
|
2964
|
-
extend: outputOptions.extend,
|
|
2965
|
-
globals,
|
|
2966
|
-
esModule,
|
|
2967
|
-
name,
|
|
2968
|
-
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
2969
|
-
entryFileNames,
|
|
2970
|
-
chunkFileNames,
|
|
2971
|
-
cssEntryFileNames,
|
|
2972
|
-
cssChunkFileNames,
|
|
2973
|
-
plugins: [],
|
|
2974
|
-
minify: outputOptions.minify,
|
|
2975
|
-
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
2976
|
-
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
2977
|
-
advancedChunks: outputOptions.advancedChunks,
|
|
2978
|
-
polyfillRequire: outputOptions.polyfillRequire,
|
|
2979
|
-
sanitizeFileName,
|
|
2980
|
-
preserveModules,
|
|
2981
|
-
virtualDirname,
|
|
2982
|
-
legalComments,
|
|
2983
|
-
preserveModulesRoot
|
|
2984
|
-
};
|
|
2985
|
-
}
|
|
2986
|
-
function bindingifyAddon(configAddon) {
|
|
2987
|
-
return async (chunk) => {
|
|
2988
|
-
if (typeof configAddon === "function") return configAddon(transformRenderedChunk(chunk));
|
|
2989
|
-
return configAddon || "";
|
|
2990
|
-
};
|
|
2991
|
-
}
|
|
2992
|
-
function bindingifyFormat(format) {
|
|
2993
|
-
switch (format) {
|
|
2994
|
-
case void 0:
|
|
2995
|
-
case "es":
|
|
2996
|
-
case "esm":
|
|
2997
|
-
case "module": return "es";
|
|
2998
|
-
case "cjs":
|
|
2999
|
-
case "commonjs": return "cjs";
|
|
3000
|
-
case "iife": return "iife";
|
|
3001
|
-
case "umd": return "umd";
|
|
3002
|
-
case "experimental-app": return "app";
|
|
3003
|
-
default: unimplemented(`output.format: ${format}`);
|
|
3004
|
-
}
|
|
3005
|
-
}
|
|
3006
|
-
function bindingifySourcemap$1(sourcemap) {
|
|
3007
|
-
switch (sourcemap) {
|
|
3008
|
-
case true: return "file";
|
|
3009
|
-
case "inline": return "inline";
|
|
3010
|
-
case false:
|
|
3011
|
-
case void 0: return void 0;
|
|
3012
|
-
case "hidden": return "hidden";
|
|
3013
|
-
default: throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
3017
|
-
return typeof sourcemapIgnoreList === "function" ? sourcemapIgnoreList : sourcemapIgnoreList === false ? () => false : (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes("node_modules");
|
|
3018
|
-
}
|
|
3019
|
-
function bindingifyAssetFilenames(assetFileNames) {
|
|
3020
|
-
if (typeof assetFileNames === "function") return (asset) => {
|
|
3021
|
-
return assetFileNames({
|
|
3022
|
-
names: asset.names,
|
|
3023
|
-
originalFileNames: asset.originalFileNames,
|
|
3024
|
-
source: transformAssetSource(asset.source),
|
|
3025
|
-
type: "asset"
|
|
3026
|
-
});
|
|
3027
|
-
};
|
|
3028
|
-
return assetFileNames;
|
|
3029
|
-
}
|
|
3030
|
-
var init_bindingify_output_options = __esm({ "src/utils/bindingify-output-options.ts"() {
|
|
3031
|
-
init_asset_source();
|
|
3032
|
-
init_misc();
|
|
3033
|
-
init_transform_rendered_chunk();
|
|
3034
|
-
} });
|
|
3035
|
-
|
|
3036
|
-
//#endregion
|
|
3037
|
-
//#region src/options/normalized-output-options.ts
|
|
3038
|
-
function normalizeAddon(value) {
|
|
3039
|
-
if (typeof value === "function") return value;
|
|
3040
|
-
return () => value || "";
|
|
3041
|
-
}
|
|
3042
|
-
var NormalizedOutputOptionsImpl;
|
|
3043
|
-
var init_normalized_output_options = __esm({ "src/options/normalized-output-options.ts"() {
|
|
3044
|
-
init_bindingify_output_options();
|
|
3045
|
-
NormalizedOutputOptionsImpl = class {
|
|
3046
|
-
constructor(inner, outputOptions, normalizedOutputPlugins) {
|
|
3047
|
-
this.inner = inner;
|
|
3048
|
-
this.outputOptions = outputOptions;
|
|
3049
|
-
this.normalizedOutputPlugins = normalizedOutputPlugins;
|
|
3050
|
-
}
|
|
3051
|
-
get dir() {
|
|
3052
|
-
return this.inner.dir ?? void 0;
|
|
3053
|
-
}
|
|
3054
|
-
get entryFileNames() {
|
|
3055
|
-
return this.inner.entryFilenames || this.outputOptions.entryFileNames;
|
|
3056
|
-
}
|
|
3057
|
-
get chunkFileNames() {
|
|
3058
|
-
return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
|
|
3059
|
-
}
|
|
3060
|
-
get assetFileNames() {
|
|
3061
|
-
return this.inner.assetFilenames || this.outputOptions.assetFileNames;
|
|
3062
|
-
}
|
|
3063
|
-
get format() {
|
|
3064
|
-
return this.inner.format;
|
|
3065
|
-
}
|
|
3066
|
-
get exports() {
|
|
3067
|
-
return this.inner.exports;
|
|
3068
|
-
}
|
|
3069
|
-
get sourcemap() {
|
|
3070
|
-
return this.inner.sourcemap;
|
|
3071
|
-
}
|
|
3072
|
-
get cssEntryFileNames() {
|
|
3073
|
-
return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
|
|
3074
|
-
}
|
|
3075
|
-
get cssChunkFileNames() {
|
|
3076
|
-
return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
|
|
3077
|
-
}
|
|
3078
|
-
get shimMissingExports() {
|
|
3079
|
-
return this.inner.shimMissingExports;
|
|
3080
|
-
}
|
|
3081
|
-
get name() {
|
|
3082
|
-
return this.inner.name ?? void 0;
|
|
3083
|
-
}
|
|
3084
|
-
get file() {
|
|
3085
|
-
return this.inner.file ?? void 0;
|
|
3086
|
-
}
|
|
3087
|
-
get inlineDynamicImports() {
|
|
3088
|
-
return this.inner.inlineDynamicImports;
|
|
3089
|
-
}
|
|
3090
|
-
get externalLiveBindings() {
|
|
3091
|
-
return this.inner.externalLiveBindings;
|
|
3092
|
-
}
|
|
3093
|
-
get banner() {
|
|
3094
|
-
return normalizeAddon(this.outputOptions.banner);
|
|
3095
|
-
}
|
|
3096
|
-
get footer() {
|
|
3097
|
-
return normalizeAddon(this.outputOptions.footer);
|
|
3098
|
-
}
|
|
3099
|
-
get intro() {
|
|
3100
|
-
return normalizeAddon(this.outputOptions.intro);
|
|
3101
|
-
}
|
|
3102
|
-
get outro() {
|
|
3103
|
-
return normalizeAddon(this.outputOptions.outro);
|
|
3104
|
-
}
|
|
3105
|
-
get esModule() {
|
|
3106
|
-
return this.inner.esModule;
|
|
3107
|
-
}
|
|
3108
|
-
get extend() {
|
|
3109
|
-
return this.inner.extend;
|
|
3110
|
-
}
|
|
3111
|
-
get globals() {
|
|
3112
|
-
return this.inner.globals || this.outputOptions.globals;
|
|
3113
|
-
}
|
|
3114
|
-
get hashCharacters() {
|
|
3115
|
-
return this.inner.hashCharacters;
|
|
3116
|
-
}
|
|
3117
|
-
get sourcemapDebugIds() {
|
|
3118
|
-
return this.inner.sourcemapDebugIds;
|
|
3119
|
-
}
|
|
3120
|
-
get sourcemapIgnoreList() {
|
|
3121
|
-
return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
|
|
3122
|
-
}
|
|
3123
|
-
get sourcemapPathTransform() {
|
|
3124
|
-
return this.outputOptions.sourcemapPathTransform;
|
|
3125
|
-
}
|
|
3126
|
-
get minify() {
|
|
3127
|
-
return this.inner.minify;
|
|
3128
|
-
}
|
|
3129
|
-
get legalComments() {
|
|
3130
|
-
return this.inner.legalComments;
|
|
3131
|
-
}
|
|
3132
|
-
get polyfillRequire() {
|
|
3133
|
-
return this.inner.polyfillRequire;
|
|
3134
|
-
}
|
|
3135
|
-
get plugins() {
|
|
3136
|
-
return this.normalizedOutputPlugins;
|
|
3137
|
-
}
|
|
3138
|
-
get preserveModules() {
|
|
3139
|
-
return this.preserveModules;
|
|
3140
|
-
}
|
|
3141
|
-
get preserveModulesRoot() {
|
|
3142
|
-
return this.preserveModulesRoot;
|
|
3143
|
-
}
|
|
3144
|
-
get virtualDirname() {
|
|
3145
|
-
return this.virtualDirname;
|
|
3146
|
-
}
|
|
3147
|
-
};
|
|
3148
|
-
} });
|
|
3149
|
-
|
|
3150
|
-
//#endregion
|
|
3151
|
-
//#region src/utils/transform-to-rollup-output.ts
|
|
3152
|
-
function transformToRollupSourceMap(map) {
|
|
3153
|
-
const parsed = JSON.parse(map);
|
|
3154
|
-
const obj = {
|
|
3155
|
-
...parsed,
|
|
3156
|
-
toString() {
|
|
3157
|
-
return JSON.stringify(obj);
|
|
3158
|
-
},
|
|
3159
|
-
toUrl() {
|
|
3160
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
|
|
3161
|
-
}
|
|
3162
|
-
};
|
|
3163
|
-
return obj;
|
|
3164
|
-
}
|
|
3165
|
-
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
3166
|
-
const chunk = {
|
|
3167
|
-
type: "chunk",
|
|
3168
|
-
get code() {
|
|
3169
|
-
return bindingChunk.code;
|
|
3170
|
-
},
|
|
3171
|
-
fileName: bindingChunk.fileName,
|
|
3172
|
-
name: bindingChunk.name,
|
|
3173
|
-
get modules() {
|
|
3174
|
-
return transformChunkModules(bindingChunk.modules);
|
|
3175
|
-
},
|
|
3176
|
-
get imports() {
|
|
3177
|
-
return bindingChunk.imports;
|
|
3178
|
-
},
|
|
3179
|
-
get dynamicImports() {
|
|
3180
|
-
return bindingChunk.dynamicImports;
|
|
3181
|
-
},
|
|
3182
|
-
exports: bindingChunk.exports,
|
|
3183
|
-
isEntry: bindingChunk.isEntry,
|
|
3184
|
-
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
3185
|
-
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
3186
|
-
get moduleIds() {
|
|
3187
|
-
return bindingChunk.moduleIds;
|
|
3188
|
-
},
|
|
3189
|
-
get map() {
|
|
3190
|
-
return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
|
|
3191
|
-
},
|
|
3192
|
-
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
3193
|
-
preliminaryFileName: bindingChunk.preliminaryFileName
|
|
3194
|
-
};
|
|
3195
|
-
const cache = {};
|
|
3196
|
-
return new Proxy(chunk, {
|
|
3197
|
-
get(target, p) {
|
|
3198
|
-
if (p in cache) return cache[p];
|
|
3199
|
-
const value = target[p];
|
|
3200
|
-
cache[p] = value;
|
|
3201
|
-
return value;
|
|
3202
|
-
},
|
|
3203
|
-
set(target, p, newValue) {
|
|
3204
|
-
cache[p] = newValue;
|
|
3205
|
-
changed?.updated.add(bindingChunk.fileName);
|
|
3206
|
-
return true;
|
|
3207
|
-
},
|
|
3208
|
-
has(target, p) {
|
|
3209
|
-
if (p in cache) return true;
|
|
3210
|
-
return p in target;
|
|
3211
|
-
}
|
|
3212
|
-
});
|
|
3213
|
-
}
|
|
3214
|
-
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
3215
|
-
const asset = {
|
|
3216
|
-
type: "asset",
|
|
3217
|
-
fileName: bindingAsset.fileName,
|
|
3218
|
-
originalFileName: bindingAsset.originalFileName || null,
|
|
3219
|
-
originalFileNames: bindingAsset.originalFileNames,
|
|
3220
|
-
get source() {
|
|
3221
|
-
return transformAssetSource(bindingAsset.source);
|
|
3222
|
-
},
|
|
3223
|
-
name: bindingAsset.name ?? void 0,
|
|
3224
|
-
names: bindingAsset.names
|
|
3225
|
-
};
|
|
3226
|
-
const cache = {};
|
|
3227
|
-
return new Proxy(asset, {
|
|
3228
|
-
get(target, p) {
|
|
3229
|
-
if (p in cache) return cache[p];
|
|
3230
|
-
const value = target[p];
|
|
3231
|
-
cache[p] = value;
|
|
3232
|
-
return value;
|
|
3233
|
-
},
|
|
3234
|
-
set(target, p, newValue) {
|
|
3235
|
-
cache[p] = newValue;
|
|
3236
|
-
changed?.updated.add(bindingAsset.fileName);
|
|
3237
|
-
return true;
|
|
3238
|
-
}
|
|
3239
|
-
});
|
|
3240
|
-
}
|
|
3241
|
-
function transformToRollupOutput(output, changed) {
|
|
3242
|
-
handleOutputErrors(output);
|
|
3243
|
-
const { chunks, assets } = output;
|
|
3244
|
-
return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
|
|
3245
|
-
}
|
|
3246
|
-
function handleOutputErrors(output) {
|
|
3247
|
-
const rawErrors = output.errors;
|
|
3248
|
-
if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
|
|
3249
|
-
}
|
|
3250
|
-
function transformToOutputBundle(output, changed) {
|
|
3251
|
-
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
|
|
3252
|
-
return new Proxy(bundle, { deleteProperty(target, property) {
|
|
3253
|
-
if (typeof property === "string") changed.deleted.add(property);
|
|
3254
|
-
return true;
|
|
3255
|
-
} });
|
|
3256
|
-
}
|
|
3257
|
-
function collectChangedBundle(changed, bundle) {
|
|
3258
|
-
const assets = [];
|
|
3259
|
-
const chunks = [];
|
|
3260
|
-
for (const key in bundle) {
|
|
3261
|
-
if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
|
|
3262
|
-
const item = bundle[key];
|
|
3263
|
-
if (item.type === "asset") assets.push({
|
|
3264
|
-
filename: item.fileName,
|
|
3265
|
-
originalFileNames: item.originalFileNames,
|
|
3266
|
-
source: bindingAssetSource(item.source),
|
|
3267
|
-
names: item.names
|
|
3268
|
-
});
|
|
3269
|
-
else chunks.push({
|
|
3270
|
-
code: item.code,
|
|
3271
|
-
filename: item.fileName,
|
|
3272
|
-
name: item.name,
|
|
3273
|
-
isEntry: item.isEntry,
|
|
3274
|
-
exports: item.exports,
|
|
3275
|
-
modules: {},
|
|
3276
|
-
imports: item.imports,
|
|
3277
|
-
dynamicImports: item.dynamicImports,
|
|
3278
|
-
facadeModuleId: item.facadeModuleId || void 0,
|
|
3279
|
-
isDynamicEntry: item.isDynamicEntry,
|
|
3280
|
-
moduleIds: item.moduleIds,
|
|
3281
|
-
map: bindingifySourcemap(item.map),
|
|
3282
|
-
sourcemapFilename: item.sourcemapFileName || void 0,
|
|
3283
|
-
preliminaryFilename: item.preliminaryFileName
|
|
3284
|
-
});
|
|
3285
|
-
}
|
|
3286
|
-
return {
|
|
3287
|
-
assets,
|
|
3288
|
-
chunks,
|
|
3289
|
-
deleted: Array.from(changed.deleted)
|
|
3290
|
-
};
|
|
3291
|
-
}
|
|
3292
|
-
var init_transform_to_rollup_output = __esm({ "src/utils/transform-to-rollup-output.ts"() {
|
|
3293
|
-
init_sourcemap();
|
|
3294
|
-
init_asset_source();
|
|
3295
|
-
init_error();
|
|
3296
|
-
init_transform_rendered_chunk();
|
|
3297
|
-
} });
|
|
3298
|
-
|
|
3299
|
-
//#endregion
|
|
3300
|
-
//#region src/plugin/bindingify-output-hooks.ts
|
|
3301
|
-
function bindingifyRenderStart(args$1) {
|
|
3302
|
-
const hook = args$1.plugin.renderStart;
|
|
3303
|
-
if (!hook) return {};
|
|
3304
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3305
|
-
return {
|
|
3306
|
-
plugin: async (ctx, opts) => {
|
|
3307
|
-
handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), new NormalizedInputOptionsImpl(opts, args$1.onLog));
|
|
3308
|
-
},
|
|
3309
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3310
|
-
};
|
|
3311
|
-
}
|
|
3312
|
-
function bindingifyRenderChunk(args$1) {
|
|
3313
|
-
const hook = args$1.plugin.renderChunk;
|
|
3314
|
-
if (!hook) return {};
|
|
3315
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
3316
|
-
return {
|
|
3317
|
-
plugin: async (ctx, code$1, chunk, opts, meta$1) => {
|
|
3318
|
-
if (args$1.pluginContextData.getRenderChunkMeta() == null) args$1.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
|
|
3319
|
-
const ret = await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), code$1, transformRenderedChunk(chunk), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), args$1.pluginContextData.getRenderChunkMeta());
|
|
3320
|
-
if (ret == null) return;
|
|
3321
|
-
if (typeof ret === "string") return { code: ret };
|
|
3322
|
-
if (!ret.map) return { code: ret.code };
|
|
3323
|
-
return {
|
|
3324
|
-
code: ret.code,
|
|
3325
|
-
map: bindingifySourcemap(ret.map)
|
|
3326
|
-
};
|
|
3327
|
-
},
|
|
3328
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
3329
|
-
filter: bindingifyRenderChunkFilter(options.filter)
|
|
3330
|
-
};
|
|
3331
|
-
}
|
|
3332
|
-
function bindingifyAugmentChunkHash(args$1) {
|
|
3333
|
-
const hook = args$1.plugin.augmentChunkHash;
|
|
3334
|
-
if (!hook) return {};
|
|
3335
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3336
|
-
return {
|
|
3337
|
-
plugin: async (ctx, chunk) => {
|
|
3338
|
-
return await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
3339
|
-
},
|
|
3340
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3341
|
-
};
|
|
3342
|
-
}
|
|
3343
|
-
function bindingifyRenderError(args$1) {
|
|
3344
|
-
const hook = args$1.plugin.renderError;
|
|
3345
|
-
if (!hook) return {};
|
|
3346
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3347
|
-
return {
|
|
3348
|
-
plugin: async (ctx, err) => {
|
|
3349
|
-
handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), normalizeErrors(err));
|
|
3350
|
-
},
|
|
3351
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3352
|
-
};
|
|
3353
|
-
}
|
|
3354
|
-
function bindingifyGenerateBundle(args$1) {
|
|
3355
|
-
const hook = args$1.plugin.generateBundle;
|
|
3356
|
-
if (!hook) return {};
|
|
3357
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3358
|
-
return {
|
|
3359
|
-
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
3360
|
-
const changed = {
|
|
3361
|
-
updated: new Set(),
|
|
3362
|
-
deleted: new Set()
|
|
3363
|
-
};
|
|
3364
|
-
const output = transformToOutputBundle(bundle, changed);
|
|
3365
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output, isWrite);
|
|
3366
|
-
return collectChangedBundle(changed, output);
|
|
3367
|
-
},
|
|
3368
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3369
|
-
};
|
|
3370
|
-
}
|
|
3371
|
-
function bindingifyWriteBundle(args$1) {
|
|
3372
|
-
const hook = args$1.plugin.writeBundle;
|
|
3373
|
-
if (!hook) return {};
|
|
3374
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3375
|
-
return {
|
|
3376
|
-
plugin: async (ctx, bundle, opts) => {
|
|
3377
|
-
const changed = {
|
|
3378
|
-
updated: new Set(),
|
|
3379
|
-
deleted: new Set()
|
|
3380
|
-
};
|
|
3381
|
-
const output = transformToOutputBundle(bundle, changed);
|
|
3382
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), new NormalizedOutputOptionsImpl(opts, args$1.outputOptions, args$1.normalizedOutputPlugins), output);
|
|
3383
|
-
return collectChangedBundle(changed, output);
|
|
3384
|
-
},
|
|
3385
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3386
|
-
};
|
|
3387
|
-
}
|
|
3388
|
-
function bindingifyCloseBundle(args$1) {
|
|
3389
|
-
const hook = args$1.plugin.closeBundle;
|
|
3390
|
-
if (!hook) return {};
|
|
3391
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3392
|
-
return {
|
|
3393
|
-
plugin: async (ctx) => {
|
|
3394
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode));
|
|
3395
|
-
},
|
|
3396
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3397
|
-
};
|
|
3398
|
-
}
|
|
3399
|
-
function bindingifyBanner(args$1) {
|
|
3400
|
-
const hook = args$1.plugin.banner;
|
|
3401
|
-
if (!hook) return {};
|
|
3402
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3403
|
-
return {
|
|
3404
|
-
plugin: async (ctx, chunk) => {
|
|
3405
|
-
if (typeof handler === "string") return handler;
|
|
3406
|
-
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
3407
|
-
},
|
|
3408
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3409
|
-
};
|
|
3410
|
-
}
|
|
3411
|
-
function bindingifyFooter(args$1) {
|
|
3412
|
-
const hook = args$1.plugin.footer;
|
|
3413
|
-
if (!hook) return {};
|
|
3414
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3415
|
-
return {
|
|
3416
|
-
plugin: async (ctx, chunk) => {
|
|
3417
|
-
if (typeof handler === "string") return handler;
|
|
3418
|
-
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
3419
|
-
},
|
|
3420
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3421
|
-
};
|
|
3422
|
-
}
|
|
3423
|
-
function bindingifyIntro(args$1) {
|
|
3424
|
-
const hook = args$1.plugin.intro;
|
|
3425
|
-
if (!hook) return {};
|
|
3426
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3427
|
-
return {
|
|
3428
|
-
plugin: async (ctx, chunk) => {
|
|
3429
|
-
if (typeof handler === "string") return handler;
|
|
3430
|
-
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
3431
|
-
},
|
|
3432
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3433
|
-
};
|
|
3434
|
-
}
|
|
3435
|
-
function bindingifyOutro(args$1) {
|
|
3436
|
-
const hook = args$1.plugin.outro;
|
|
3437
|
-
if (!hook) return {};
|
|
3438
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3439
|
-
return {
|
|
3440
|
-
plugin: async (ctx, chunk) => {
|
|
3441
|
-
if (typeof handler === "string") return handler;
|
|
3442
|
-
return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
|
|
3443
|
-
},
|
|
3444
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3445
|
-
};
|
|
3446
|
-
}
|
|
3447
|
-
var init_bindingify_output_hooks = __esm({ "src/plugin/bindingify-output-hooks.ts"() {
|
|
3448
|
-
init_normalized_input_options();
|
|
3449
|
-
init_normalized_output_options();
|
|
3450
|
-
init_sourcemap();
|
|
3451
|
-
init_error();
|
|
3452
|
-
init_normalize_hook();
|
|
3453
|
-
init_transform_rendered_chunk();
|
|
3454
|
-
init_transform_to_rollup_output();
|
|
3455
|
-
init_bindingify_hook_filter();
|
|
3456
|
-
init_bindingify_plugin_hook_meta();
|
|
3457
|
-
init_plugin_context();
|
|
3458
|
-
} });
|
|
3459
|
-
|
|
3460
|
-
//#endregion
|
|
3461
|
-
//#region src/plugin/bindingify-watch-hooks.ts
|
|
3462
|
-
function bindingifyWatchChange(args$1) {
|
|
3463
|
-
const hook = args$1.plugin.watchChange;
|
|
3464
|
-
if (!hook) return {};
|
|
3465
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3466
|
-
return {
|
|
3467
|
-
plugin: async (ctx, id$1, event) => {
|
|
3468
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), id$1, { event });
|
|
3469
|
-
},
|
|
3470
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3471
|
-
};
|
|
3472
|
-
}
|
|
3473
|
-
function bindingifyCloseWatcher(args$1) {
|
|
3474
|
-
const hook = args$1.plugin.closeWatcher;
|
|
3475
|
-
if (!hook) return {};
|
|
3476
|
-
const { handler, meta } = normalizeHook(hook);
|
|
3477
|
-
return {
|
|
3478
|
-
plugin: async (ctx) => {
|
|
3479
|
-
await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode));
|
|
3480
|
-
},
|
|
3481
|
-
meta: bindingifyPluginHookMeta(meta)
|
|
3482
|
-
};
|
|
3483
|
-
}
|
|
3484
|
-
var init_bindingify_watch_hooks = __esm({ "src/plugin/bindingify-watch-hooks.ts"() {
|
|
3485
|
-
init_normalize_hook();
|
|
3486
|
-
init_bindingify_plugin_hook_meta();
|
|
3487
|
-
init_plugin_context();
|
|
3488
|
-
} });
|
|
3489
|
-
|
|
3490
|
-
//#endregion
|
|
3491
|
-
//#region src/plugin/generated/hook-usage.ts
|
|
3492
|
-
function extractHookUsage(plugin) {
|
|
3493
|
-
let hookUsage = new HookUsage();
|
|
3494
|
-
if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
|
|
3495
|
-
if (plugin.resolveId) hookUsage.union(HookUsageKind.resolveId);
|
|
3496
|
-
if (plugin.resolveDynamicImport) hookUsage.union(HookUsageKind.resolveDynamicImport);
|
|
3497
|
-
if (plugin.load) hookUsage.union(HookUsageKind.load);
|
|
3498
|
-
if (plugin.transform) hookUsage.union(HookUsageKind.transform);
|
|
3499
|
-
if (plugin.moduleParsed) hookUsage.union(HookUsageKind.moduleParsed);
|
|
3500
|
-
if (plugin.buildEnd) hookUsage.union(HookUsageKind.buildEnd);
|
|
3501
|
-
if (plugin.renderStart) hookUsage.union(HookUsageKind.renderStart);
|
|
3502
|
-
if (plugin.renderError) hookUsage.union(HookUsageKind.renderError);
|
|
3503
|
-
if (plugin.renderChunk) hookUsage.union(HookUsageKind.renderChunk);
|
|
3504
|
-
if (plugin.augmentChunkHash) hookUsage.union(HookUsageKind.augmentChunkHash);
|
|
3505
|
-
if (plugin.generateBundle) hookUsage.union(HookUsageKind.generateBundle);
|
|
3506
|
-
if (plugin.writeBundle) hookUsage.union(HookUsageKind.writeBundle);
|
|
3507
|
-
if (plugin.closeBundle) hookUsage.union(HookUsageKind.closeBundle);
|
|
3508
|
-
if (plugin.watchChange) hookUsage.union(HookUsageKind.watchChange);
|
|
3509
|
-
if (plugin.closeWatcher) hookUsage.union(HookUsageKind.closeWatcher);
|
|
3510
|
-
if (plugin.banner) hookUsage.union(HookUsageKind.banner);
|
|
3511
|
-
if (plugin.footer) hookUsage.union(HookUsageKind.footer);
|
|
3512
|
-
if (plugin.intro) hookUsage.union(HookUsageKind.intro);
|
|
3513
|
-
if (plugin.outro) hookUsage.union(HookUsageKind.outro);
|
|
3514
|
-
return hookUsage;
|
|
3515
|
-
}
|
|
3516
|
-
var HookUsageKind, HookUsage;
|
|
3517
|
-
var init_hook_usage = __esm({ "src/plugin/generated/hook-usage.ts"() {
|
|
3518
|
-
HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
|
|
3519
|
-
HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
|
|
3520
|
-
HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
|
|
3521
|
-
HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
|
|
3522
|
-
HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
|
|
3523
|
-
HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
|
|
3524
|
-
HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
|
|
3525
|
-
HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
|
|
3526
|
-
HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
|
|
3527
|
-
HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
|
|
3528
|
-
HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
|
|
3529
|
-
HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
|
|
3530
|
-
HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
|
|
3531
|
-
HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
|
|
3532
|
-
HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
|
|
3533
|
-
HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
|
|
3534
|
-
HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
|
|
3535
|
-
HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
|
|
3536
|
-
HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
|
|
3537
|
-
HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
|
|
3538
|
-
HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
|
|
3539
|
-
HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
|
|
3540
|
-
return HookUsageKind$1;
|
|
3541
|
-
}({});
|
|
3542
|
-
HookUsage = class {
|
|
3543
|
-
bitflag = BigInt(0);
|
|
3544
|
-
constructor() {}
|
|
3545
|
-
union(kind) {
|
|
3546
|
-
this.bitflag |= BigInt(kind);
|
|
3547
|
-
}
|
|
3548
|
-
inner() {
|
|
3549
|
-
return Number(this.bitflag);
|
|
3550
|
-
}
|
|
3551
|
-
};
|
|
3552
|
-
} });
|
|
3553
|
-
|
|
3554
|
-
//#endregion
|
|
3555
|
-
//#region src/plugin/bindingify-plugin.ts
|
|
3556
|
-
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
3557
|
-
const args$1 = {
|
|
3558
|
-
plugin,
|
|
3559
|
-
options,
|
|
3560
|
-
outputOptions,
|
|
3561
|
-
pluginContextData,
|
|
3562
|
-
onLog,
|
|
3563
|
-
logLevel,
|
|
3564
|
-
watchMode,
|
|
3565
|
-
normalizedOutputPlugins
|
|
3566
|
-
};
|
|
3567
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args$1);
|
|
3568
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args$1);
|
|
3569
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args$1);
|
|
3570
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args$1);
|
|
3571
|
-
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args$1);
|
|
3572
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args$1);
|
|
3573
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args$1);
|
|
3574
|
-
const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args$1);
|
|
3575
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args$1);
|
|
3576
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args$1);
|
|
3577
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args$1);
|
|
3578
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args$1);
|
|
3579
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args$1);
|
|
3580
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args$1);
|
|
3581
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args$1);
|
|
3582
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args$1);
|
|
3583
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args$1);
|
|
3584
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args$1);
|
|
3585
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args$1);
|
|
3586
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args$1);
|
|
3587
|
-
let hookUsage = extractHookUsage(plugin).inner();
|
|
3588
|
-
const result = {
|
|
3589
|
-
name: plugin.name,
|
|
3590
|
-
buildStart,
|
|
3591
|
-
buildStartMeta,
|
|
3592
|
-
resolveId,
|
|
3593
|
-
resolveIdMeta,
|
|
3594
|
-
resolveIdFilter,
|
|
3595
|
-
resolveDynamicImport,
|
|
3596
|
-
resolveDynamicImportMeta,
|
|
3597
|
-
buildEnd,
|
|
3598
|
-
buildEndMeta,
|
|
3599
|
-
transform,
|
|
3600
|
-
transformMeta,
|
|
3601
|
-
transformFilter,
|
|
3602
|
-
moduleParsed,
|
|
3603
|
-
moduleParsedMeta,
|
|
3604
|
-
load,
|
|
3605
|
-
loadMeta,
|
|
3606
|
-
loadFilter,
|
|
3607
|
-
renderChunk,
|
|
3608
|
-
renderChunkMeta,
|
|
3609
|
-
renderChunkFilter,
|
|
3610
|
-
augmentChunkHash,
|
|
3611
|
-
augmentChunkHashMeta,
|
|
3612
|
-
renderStart,
|
|
3613
|
-
renderStartMeta,
|
|
3614
|
-
renderError,
|
|
3615
|
-
renderErrorMeta,
|
|
3616
|
-
generateBundle,
|
|
3617
|
-
generateBundleMeta,
|
|
3618
|
-
writeBundle,
|
|
3619
|
-
writeBundleMeta,
|
|
3620
|
-
closeBundle,
|
|
3621
|
-
closeBundleMeta,
|
|
3622
|
-
banner,
|
|
3623
|
-
bannerMeta,
|
|
3624
|
-
footer,
|
|
3625
|
-
footerMeta,
|
|
3626
|
-
intro,
|
|
3627
|
-
introMeta,
|
|
3628
|
-
outro,
|
|
3629
|
-
outroMeta,
|
|
3630
|
-
watchChange,
|
|
3631
|
-
watchChangeMeta,
|
|
3632
|
-
closeWatcher,
|
|
3633
|
-
closeWatcherMeta,
|
|
3634
|
-
hookUsage
|
|
3635
|
-
};
|
|
3636
|
-
return wrapHandlers(result);
|
|
3637
|
-
}
|
|
3638
|
-
function wrapHandlers(plugin) {
|
|
3639
|
-
for (const hookName of [
|
|
3640
|
-
"buildStart",
|
|
3641
|
-
"resolveId",
|
|
3642
|
-
"resolveDynamicImport",
|
|
3643
|
-
"buildEnd",
|
|
3644
|
-
"transform",
|
|
3645
|
-
"moduleParsed",
|
|
3646
|
-
"load",
|
|
3647
|
-
"renderChunk",
|
|
3648
|
-
"augmentChunkHash",
|
|
3649
|
-
"renderStart",
|
|
3650
|
-
"renderError",
|
|
3651
|
-
"generateBundle",
|
|
3652
|
-
"writeBundle",
|
|
3653
|
-
"closeBundle",
|
|
3654
|
-
"banner",
|
|
3655
|
-
"footer",
|
|
3656
|
-
"intro",
|
|
3657
|
-
"outro",
|
|
3658
|
-
"watchChange",
|
|
3659
|
-
"closeWatcher"
|
|
3660
|
-
]) {
|
|
3661
|
-
const handler = plugin[hookName];
|
|
3662
|
-
if (handler) plugin[hookName] = async (...args$1) => {
|
|
3663
|
-
try {
|
|
3664
|
-
return await handler(...args$1);
|
|
3665
|
-
} catch (e) {
|
|
3666
|
-
return error(logPluginError(e, plugin.name, {
|
|
3667
|
-
hook: hookName,
|
|
3668
|
-
id: hookName === "transform" ? args$1[2] : void 0
|
|
3669
|
-
}));
|
|
3670
|
-
}
|
|
3671
|
-
};
|
|
3672
|
-
}
|
|
3673
|
-
return plugin;
|
|
3674
|
-
}
|
|
3675
|
-
var init_bindingify_plugin = __esm({ "src/plugin/bindingify-plugin.ts"() {
|
|
3676
|
-
init_bindingify_build_hooks();
|
|
3677
|
-
init_bindingify_output_hooks();
|
|
3678
|
-
init_logs();
|
|
3679
|
-
init_bindingify_watch_hooks();
|
|
3680
|
-
init_hook_usage();
|
|
3681
|
-
} });
|
|
3682
|
-
|
|
3683
|
-
//#endregion
|
|
3684
|
-
//#region src/plugin/plugin-context-data.ts
|
|
3685
|
-
var PluginContextData;
|
|
3686
|
-
var init_plugin_context_data = __esm({ "src/plugin/plugin-context-data.ts"() {
|
|
3687
|
-
init_transform_module_info();
|
|
3688
|
-
PluginContextData = class {
|
|
3689
|
-
moduleOptionMap = new Map();
|
|
3690
|
-
resolveOptionsMap = new Map();
|
|
3691
|
-
loadModulePromiseMap = new Map();
|
|
3692
|
-
loadModulePromiseResolveFnMap = new Map();
|
|
3693
|
-
renderedChunkMeta = null;
|
|
3694
|
-
updateModuleOption(id$1, option) {
|
|
3695
|
-
const existing = this.moduleOptionMap.get(id$1);
|
|
3696
|
-
if (existing) {
|
|
3697
|
-
if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
|
|
3698
|
-
if (option.meta != null) Object.assign(existing.meta, option.meta);
|
|
3699
|
-
if (option.invalidate != null) existing.invalidate = option.invalidate;
|
|
3700
|
-
} else {
|
|
3701
|
-
this.moduleOptionMap.set(id$1, option);
|
|
3702
|
-
return option;
|
|
3703
|
-
}
|
|
3704
|
-
return existing;
|
|
3705
|
-
}
|
|
3706
|
-
getModuleOption(id$1) {
|
|
3707
|
-
const option = this.moduleOptionMap.get(id$1);
|
|
3708
|
-
if (!option) {
|
|
3709
|
-
const raw = {
|
|
3710
|
-
moduleSideEffects: null,
|
|
3711
|
-
meta: {}
|
|
3712
|
-
};
|
|
3713
|
-
this.moduleOptionMap.set(id$1, raw);
|
|
3714
|
-
return raw;
|
|
3715
|
-
}
|
|
3716
|
-
return option;
|
|
3717
|
-
}
|
|
3718
|
-
getModuleInfo(id$1, context) {
|
|
3719
|
-
const bindingInfo = context.getModuleInfo(id$1);
|
|
3720
|
-
if (bindingInfo) {
|
|
3721
|
-
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id$1));
|
|
3722
|
-
return this.proxyModuleInfo(id$1, info);
|
|
3723
|
-
}
|
|
3724
|
-
return null;
|
|
3725
|
-
}
|
|
3726
|
-
proxyModuleInfo(id$1, info) {
|
|
3727
|
-
let moduleSideEffects = info.moduleSideEffects;
|
|
3728
|
-
Object.defineProperty(info, "moduleSideEffects", {
|
|
3729
|
-
get() {
|
|
3730
|
-
return moduleSideEffects;
|
|
3731
|
-
},
|
|
3732
|
-
set: (v) => {
|
|
3733
|
-
this.updateModuleOption(id$1, {
|
|
3734
|
-
moduleSideEffects: v,
|
|
3735
|
-
meta: info.meta,
|
|
3736
|
-
invalidate: true
|
|
3737
|
-
});
|
|
3738
|
-
moduleSideEffects = v;
|
|
3739
|
-
}
|
|
3740
|
-
});
|
|
3741
|
-
return info;
|
|
3742
|
-
}
|
|
3743
|
-
getModuleIds(context) {
|
|
3744
|
-
const moduleIds = context.getModuleIds();
|
|
3745
|
-
return moduleIds.values();
|
|
3746
|
-
}
|
|
3747
|
-
saveResolveOptions(options) {
|
|
3748
|
-
const index = this.resolveOptionsMap.size;
|
|
3749
|
-
this.resolveOptionsMap.set(index, options);
|
|
3750
|
-
return index;
|
|
3751
|
-
}
|
|
3752
|
-
getSavedResolveOptions(receipt) {
|
|
3753
|
-
return this.resolveOptionsMap.get(receipt);
|
|
3754
|
-
}
|
|
3755
|
-
removeSavedResolveOptions(receipt) {
|
|
3756
|
-
this.resolveOptionsMap.delete(receipt);
|
|
3757
|
-
}
|
|
3758
|
-
setRenderChunkMeta(meta) {
|
|
3759
|
-
this.renderedChunkMeta = meta;
|
|
3760
|
-
}
|
|
3761
|
-
getRenderChunkMeta() {
|
|
3762
|
-
return this.renderedChunkMeta;
|
|
3763
|
-
}
|
|
3764
|
-
markModuleLoaded(id$1, _success) {
|
|
3765
|
-
const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
|
|
3766
|
-
if (resolve) resolve();
|
|
3767
|
-
}
|
|
3768
|
-
clear() {
|
|
3769
|
-
this.renderedChunkMeta = null;
|
|
3770
|
-
this.loadModulePromiseMap.clear();
|
|
3771
|
-
this.loadModulePromiseResolveFnMap.clear();
|
|
3772
|
-
}
|
|
3773
|
-
};
|
|
3774
|
-
} });
|
|
3775
|
-
|
|
3776
|
-
//#endregion
|
|
3777
|
-
//#region src/utils/normalize-string-or-regex.ts
|
|
3778
|
-
function normalizedStringOrRegex(pattern) {
|
|
3779
|
-
if (!pattern) return void 0;
|
|
3780
|
-
if (!isReadonlyArray(pattern)) return [pattern];
|
|
3781
|
-
return pattern;
|
|
3782
|
-
}
|
|
3783
|
-
function isReadonlyArray(input) {
|
|
3784
|
-
return Array.isArray(input);
|
|
3785
|
-
}
|
|
3786
|
-
var init_normalize_string_or_regex = __esm({ "src/utils/normalize-string-or-regex.ts"() {} });
|
|
3787
|
-
|
|
3788
|
-
//#endregion
|
|
3789
|
-
//#region src/utils/bindingify-input-options.ts
|
|
3790
|
-
function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
|
|
3791
|
-
const pluginContextData = new PluginContextData();
|
|
3792
|
-
const plugins = rawPlugins.map((plugin) => {
|
|
3793
|
-
if ("_parallel" in plugin) return void 0;
|
|
3794
|
-
if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
|
|
3795
|
-
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
3796
|
-
});
|
|
3797
|
-
return {
|
|
3798
|
-
input: bindingifyInput(inputOptions.input),
|
|
3799
|
-
plugins,
|
|
3800
|
-
cwd: inputOptions.cwd ?? process.cwd(),
|
|
3801
|
-
external: bindingifyExternal(inputOptions.external),
|
|
3802
|
-
resolve: bindingifyResolve(inputOptions.resolve),
|
|
3803
|
-
platform: inputOptions.platform,
|
|
3804
|
-
shimMissingExports: inputOptions.shimMissingExports,
|
|
3805
|
-
logLevel: bindingifyLogLevel(logLevel),
|
|
3806
|
-
onLog,
|
|
3807
|
-
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
3808
|
-
moduleTypes: inputOptions.moduleTypes,
|
|
3809
|
-
define: inputOptions.define ? Object.entries(inputOptions.define) : void 0,
|
|
3810
|
-
inject: bindingifyInject(inputOptions.inject),
|
|
3811
|
-
experimental: {
|
|
3812
|
-
strictExecutionOrder: inputOptions.experimental?.strictExecutionOrder,
|
|
3813
|
-
disableLiveBindings: inputOptions.experimental?.disableLiveBindings,
|
|
3814
|
-
viteMode: inputOptions.experimental?.viteMode,
|
|
3815
|
-
resolveNewUrlToAsset: inputOptions.experimental?.resolveNewUrlToAsset,
|
|
3816
|
-
hmr: bindingifyHmr(inputOptions.experimental?.hmr),
|
|
3817
|
-
attachDebugInfo: inputOptions.experimental?.attachDebugInfo
|
|
3818
|
-
},
|
|
3819
|
-
profilerNames: inputOptions?.profilerNames,
|
|
3820
|
-
jsx: bindingifyJsx(inputOptions.jsx),
|
|
3821
|
-
transform: inputOptions.transform,
|
|
3822
|
-
watch: bindingifyWatch(inputOptions.watch),
|
|
3823
|
-
dropLabels: inputOptions.dropLabels,
|
|
3824
|
-
keepNames: inputOptions.keepNames,
|
|
3825
|
-
checks: inputOptions.checks,
|
|
3826
|
-
deferSyncScanData: () => {
|
|
3827
|
-
let ret = [];
|
|
3828
|
-
pluginContextData.moduleOptionMap.forEach((value, key) => {
|
|
3829
|
-
if (value.invalidate) ret.push({
|
|
3830
|
-
id: key,
|
|
3831
|
-
sideEffects: bindingifySideEffects(value.moduleSideEffects)
|
|
3832
|
-
});
|
|
3833
|
-
});
|
|
3834
|
-
return ret;
|
|
3835
|
-
},
|
|
3836
|
-
makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
|
|
3837
|
-
debug: inputOptions.debug,
|
|
3838
|
-
invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
|
|
3839
|
-
markModuleLoaded: pluginContextData.markModuleLoaded.bind(pluginContextData)
|
|
3840
|
-
};
|
|
3841
|
-
}
|
|
3842
|
-
function bindingifyHmr(hmr) {
|
|
3843
|
-
if (hmr) {
|
|
3844
|
-
if (typeof hmr === "boolean") return hmr ? {} : void 0;
|
|
3845
|
-
return hmr;
|
|
3846
|
-
}
|
|
3847
|
-
}
|
|
3848
|
-
function bindingifyExternal(external) {
|
|
3849
|
-
if (external) {
|
|
3850
|
-
if (typeof external === "function") return (id$1, importer, isResolved) => {
|
|
3851
|
-
if (id$1.startsWith("\0")) return false;
|
|
3852
|
-
return external(id$1, importer, isResolved) ?? false;
|
|
3853
|
-
};
|
|
3854
|
-
const externalArr = arraify(external);
|
|
3855
|
-
return (id$1, _importer, _isResolved) => {
|
|
3856
|
-
return externalArr.some((pat) => {
|
|
3857
|
-
if (pat instanceof RegExp) return pat.test(id$1);
|
|
3858
|
-
return id$1 === pat;
|
|
3859
|
-
});
|
|
3860
|
-
};
|
|
3861
|
-
}
|
|
3862
|
-
}
|
|
3863
|
-
function bindingifyResolve(resolve) {
|
|
3864
|
-
if (resolve) {
|
|
3865
|
-
const { alias, extensionAlias,...rest } = resolve;
|
|
3866
|
-
return {
|
|
3867
|
-
alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
|
|
3868
|
-
find: name,
|
|
3869
|
-
replacements: arraify(replacement)
|
|
3870
|
-
})) : void 0,
|
|
3871
|
-
extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
|
|
3872
|
-
target: name,
|
|
3873
|
-
replacements: value
|
|
3874
|
-
})) : void 0,
|
|
3875
|
-
...rest
|
|
3876
|
-
};
|
|
3877
|
-
}
|
|
3878
|
-
}
|
|
3879
|
-
function bindingifyInject(inject) {
|
|
3880
|
-
if (inject) return Object.entries(inject).map(([alias, item]) => {
|
|
3881
|
-
if (Array.isArray(item)) {
|
|
3882
|
-
if (item[1] === "*") return {
|
|
3883
|
-
tagNamespace: true,
|
|
3884
|
-
alias,
|
|
3885
|
-
from: item[0]
|
|
3886
|
-
};
|
|
3887
|
-
return {
|
|
3888
|
-
tagNamed: true,
|
|
3889
|
-
alias,
|
|
3890
|
-
from: item[0],
|
|
3891
|
-
imported: item[1]
|
|
3892
|
-
};
|
|
3893
|
-
} else return {
|
|
3894
|
-
tagNamed: true,
|
|
3895
|
-
imported: "default",
|
|
3896
|
-
alias,
|
|
3897
|
-
from: item
|
|
3898
|
-
};
|
|
3899
|
-
});
|
|
3900
|
-
}
|
|
3901
|
-
function bindingifyLogLevel(logLevel) {
|
|
3902
|
-
switch (logLevel) {
|
|
3903
|
-
case "silent": return BindingLogLevel.Silent;
|
|
3904
|
-
case "debug": return BindingLogLevel.Debug;
|
|
3905
|
-
case "warn": return BindingLogLevel.Warn;
|
|
3906
|
-
case "info": return BindingLogLevel.Info;
|
|
3907
|
-
default: throw new Error(`Unexpected log level: ${logLevel}`);
|
|
3908
|
-
}
|
|
3909
|
-
}
|
|
3910
|
-
function bindingifyInput(input) {
|
|
3911
|
-
if (input === void 0) return [];
|
|
3912
|
-
if (typeof input === "string") return [{ import: input }];
|
|
3913
|
-
if (Array.isArray(input)) return input.map((src) => ({ import: src }));
|
|
3914
|
-
return Object.entries(input).map(([name, import_path]) => {
|
|
3915
|
-
return {
|
|
3916
|
-
name,
|
|
3917
|
-
import: import_path
|
|
3918
|
-
};
|
|
3919
|
-
});
|
|
3920
|
-
}
|
|
3921
|
-
function bindingifyJsx(input) {
|
|
3922
|
-
switch (input) {
|
|
3923
|
-
case false: return BindingJsx.Disable;
|
|
3924
|
-
case "react": return BindingJsx.React;
|
|
3925
|
-
case "react-jsx": return BindingJsx.ReactJsx;
|
|
3926
|
-
case "preserve": return BindingJsx.Preserve;
|
|
3927
|
-
default: return void 0;
|
|
3928
|
-
}
|
|
3929
|
-
}
|
|
3930
|
-
function bindingifyWatch(watch$1) {
|
|
3931
|
-
if (watch$1) return {
|
|
3932
|
-
buildDelay: watch$1.buildDelay,
|
|
3933
|
-
skipWrite: watch$1.skipWrite,
|
|
3934
|
-
include: normalizedStringOrRegex(watch$1.include),
|
|
3935
|
-
exclude: normalizedStringOrRegex(watch$1.exclude)
|
|
3936
|
-
};
|
|
3937
|
-
}
|
|
3938
|
-
function bindingifyTreeshakeOptions(config) {
|
|
3939
|
-
if (config === false) return void 0;
|
|
3940
|
-
if (config === true || config === void 0) return { moduleSideEffects: true };
|
|
3941
|
-
let normalizedConfig = {
|
|
3942
|
-
moduleSideEffects: true,
|
|
3943
|
-
annotations: config.annotations,
|
|
3944
|
-
manualPureFunctions: config.manualPureFunctions,
|
|
3945
|
-
unknownGlobalSideEffects: config.unknownGlobalSideEffects
|
|
3946
|
-
};
|
|
3947
|
-
if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
|
|
3948
|
-
else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
|
|
3949
|
-
external: true,
|
|
3950
|
-
sideEffects: false
|
|
3951
|
-
}, {
|
|
3952
|
-
external: false,
|
|
3953
|
-
sideEffects: true
|
|
3954
|
-
}];
|
|
3955
|
-
else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
3956
|
-
return normalizedConfig;
|
|
3957
|
-
}
|
|
3958
|
-
function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative) {
|
|
3959
|
-
if (makeAbsoluteExternalsRelative === "ifRelativeSource") return { type: "IfRelativeSource" };
|
|
3960
|
-
if (typeof makeAbsoluteExternalsRelative === "boolean") return {
|
|
3961
|
-
type: "Bool",
|
|
3962
|
-
field0: makeAbsoluteExternalsRelative
|
|
3963
|
-
};
|
|
3964
|
-
}
|
|
3965
|
-
var init_bindingify_input_options = __esm({ "src/utils/bindingify-input-options.ts"() {
|
|
3966
|
-
init_constructors();
|
|
3967
|
-
init_utils();
|
|
3968
|
-
init_bindingify_plugin();
|
|
3969
|
-
init_plugin_context_data();
|
|
3970
|
-
init_misc();
|
|
3971
|
-
init_normalize_string_or_regex();
|
|
3972
|
-
init_transform_side_effects();
|
|
3973
|
-
} });
|
|
3974
|
-
|
|
3975
|
-
//#endregion
|
|
3976
|
-
//#region src/utils/plugin/index.ts
|
|
3977
|
-
var isPluginHookName;
|
|
3978
|
-
var init_plugin = __esm({ "src/utils/plugin/index.ts"() {
|
|
3979
|
-
init_plugin$1();
|
|
3980
|
-
isPluginHookName = function() {
|
|
3981
|
-
const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
|
|
3982
|
-
return function isPluginHookName$1(hookName) {
|
|
3983
|
-
return PLUGIN_HOOK_NAMES_SET.has(hookName);
|
|
3984
|
-
};
|
|
3985
|
-
}();
|
|
3986
|
-
} });
|
|
3987
|
-
|
|
3988
|
-
//#endregion
|
|
3989
|
-
//#region src/utils/compose-js-plugins.ts
|
|
3990
|
-
function isUnsupportedHooks(hookName) {
|
|
3991
|
-
return unsupportedHooks.has(hookName);
|
|
3992
|
-
}
|
|
3993
|
-
function createComposedPlugin(plugins) {
|
|
3994
|
-
const names = [];
|
|
3995
|
-
const batchedHooks = {};
|
|
3996
|
-
plugins.forEach((plugin, index) => {
|
|
3997
|
-
const pluginName = plugin.name || `Anonymous(index: ${index})`;
|
|
3998
|
-
names.push(pluginName);
|
|
3999
|
-
t(plugin).forEach((pluginProp) => {
|
|
4000
|
-
if (isUnsupportedHooks(pluginProp)) throw new Error(`Failed to compose js plugins. Plugin ${pluginName} has an unsupported hook: ${pluginProp}`);
|
|
4001
|
-
if (!isPluginHookName(pluginProp)) return;
|
|
4002
|
-
switch (pluginProp) {
|
|
4003
|
-
case "buildStart": {
|
|
4004
|
-
const handlers = batchedHooks.buildStart ?? [];
|
|
4005
|
-
batchedHooks.buildStart = handlers;
|
|
4006
|
-
if (plugin.buildStart) handlers.push([plugin.buildStart, plugin]);
|
|
4007
|
-
break;
|
|
4008
|
-
}
|
|
4009
|
-
case "load": {
|
|
4010
|
-
const handlers = batchedHooks.load ?? [];
|
|
4011
|
-
batchedHooks.load = handlers;
|
|
4012
|
-
if (plugin.load) handlers.push([plugin.load, plugin]);
|
|
4013
|
-
break;
|
|
4014
|
-
}
|
|
4015
|
-
case "transform": {
|
|
4016
|
-
const handlers = batchedHooks.transform ?? [];
|
|
4017
|
-
batchedHooks.transform = handlers;
|
|
4018
|
-
if (plugin.transform) handlers.push([plugin.transform, plugin]);
|
|
4019
|
-
break;
|
|
4020
|
-
}
|
|
4021
|
-
case "resolveId": {
|
|
4022
|
-
const handlers = batchedHooks.resolveId ?? [];
|
|
4023
|
-
batchedHooks.resolveId = handlers;
|
|
4024
|
-
if (plugin.resolveId) handlers.push([plugin.resolveId, plugin]);
|
|
4025
|
-
break;
|
|
4026
|
-
}
|
|
4027
|
-
case "buildEnd": {
|
|
4028
|
-
const handlers = batchedHooks.buildEnd ?? [];
|
|
4029
|
-
batchedHooks.buildEnd = handlers;
|
|
4030
|
-
if (plugin.buildEnd) handlers.push([plugin.buildEnd, plugin]);
|
|
4031
|
-
break;
|
|
4032
|
-
}
|
|
4033
|
-
case "renderChunk": {
|
|
4034
|
-
const handlers = batchedHooks.renderChunk ?? [];
|
|
4035
|
-
batchedHooks.renderChunk = handlers;
|
|
4036
|
-
if (plugin.renderChunk) handlers.push([plugin.renderChunk, plugin]);
|
|
4037
|
-
break;
|
|
4038
|
-
}
|
|
4039
|
-
case "banner":
|
|
4040
|
-
case "footer":
|
|
4041
|
-
case "intro":
|
|
4042
|
-
case "outro": {
|
|
4043
|
-
const hook = plugin[pluginProp];
|
|
4044
|
-
if (hook) (batchedHooks[pluginProp] ??= []).push([hook, plugin]);
|
|
4045
|
-
break;
|
|
4046
|
-
}
|
|
4047
|
-
case "closeBundle": {
|
|
4048
|
-
const handlers = batchedHooks.closeBundle ?? [];
|
|
4049
|
-
batchedHooks.closeBundle = handlers;
|
|
4050
|
-
if (plugin.closeBundle) handlers.push([plugin.closeBundle, plugin]);
|
|
4051
|
-
break;
|
|
4052
|
-
}
|
|
4053
|
-
case "watchChange": {
|
|
4054
|
-
const handlers = batchedHooks.watchChange ?? [];
|
|
4055
|
-
batchedHooks.watchChange = handlers;
|
|
4056
|
-
if (plugin.watchChange) handlers.push([plugin.watchChange, plugin]);
|
|
4057
|
-
break;
|
|
4058
|
-
}
|
|
4059
|
-
case "closeWatcher": {
|
|
4060
|
-
const handlers = batchedHooks.closeWatcher ?? [];
|
|
4061
|
-
batchedHooks.closeWatcher = handlers;
|
|
4062
|
-
if (plugin.closeWatcher) handlers.push([plugin.closeWatcher, plugin]);
|
|
4063
|
-
break;
|
|
4064
|
-
}
|
|
4065
|
-
default: {}
|
|
4066
|
-
}
|
|
4067
|
-
});
|
|
4068
|
-
});
|
|
4069
|
-
const composed = { name: `Composed(${names.join(", ")})` };
|
|
4070
|
-
const createFixedPluginResolveFnMap = new Map();
|
|
4071
|
-
function applyFixedPluginResolveFn(ctx, plugin) {
|
|
4072
|
-
const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
|
|
4073
|
-
if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
|
|
4074
|
-
return ctx;
|
|
4075
|
-
}
|
|
4076
|
-
if (batchedHooks.resolveId) {
|
|
4077
|
-
const batchedHandlers = batchedHooks.resolveId;
|
|
4078
|
-
const handlerSymbols = batchedHandlers.map(([_handler, plugin]) => Symbol(plugin.name ?? `Anonymous`));
|
|
4079
|
-
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
4080
|
-
const [_handler, plugin] = batchedHandlers[handlerIdx];
|
|
4081
|
-
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
4082
|
-
const createFixedPluginResolveFn = (ctx, resolve) => {
|
|
4083
|
-
return (source, importer, rawContextResolveOptions) => {
|
|
4084
|
-
const contextResolveOptions = rawContextResolveOptions ?? {};
|
|
4085
|
-
if (contextResolveOptions.skipSelf) {
|
|
4086
|
-
contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
|
|
4087
|
-
contextResolveOptions.skipSelf = false;
|
|
4088
|
-
}
|
|
4089
|
-
return resolve(source, importer, contextResolveOptions);
|
|
4090
|
-
};
|
|
4091
|
-
};
|
|
4092
|
-
createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
|
|
4093
|
-
}
|
|
4094
|
-
composed.resolveId = async function(source, importer, rawHookResolveIdOptions) {
|
|
4095
|
-
const hookResolveIdOptions = rawHookResolveIdOptions;
|
|
4096
|
-
const symbolForCallerThatSkipSelf = hookResolveIdOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF];
|
|
4097
|
-
for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
|
|
4098
|
-
const [handler, plugin] = batchedHandlers[handlerIdx];
|
|
4099
|
-
const handlerSymbol = handlerSymbols[handlerIdx];
|
|
4100
|
-
if (symbolForCallerThatSkipSelf === handlerSymbol) continue;
|
|
4101
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4102
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), source, importer, rawHookResolveIdOptions);
|
|
4103
|
-
if (!isNullish(result)) return result;
|
|
4104
|
-
}
|
|
4105
|
-
};
|
|
4106
|
-
}
|
|
4107
|
-
t(batchedHooks).forEach((hookName) => {
|
|
4108
|
-
switch (hookName) {
|
|
4109
|
-
case "resolveId": break;
|
|
4110
|
-
case "buildStart": {
|
|
4111
|
-
if (batchedHooks.buildStart) {
|
|
4112
|
-
const batchedHandlers = batchedHooks.buildStart;
|
|
4113
|
-
composed.buildStart = async function(options) {
|
|
4114
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4115
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4116
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), options);
|
|
4117
|
-
}));
|
|
4118
|
-
};
|
|
4119
|
-
}
|
|
4120
|
-
break;
|
|
4121
|
-
}
|
|
4122
|
-
case "load": {
|
|
4123
|
-
if (batchedHooks.load) {
|
|
4124
|
-
const batchedHandlers = batchedHooks.load;
|
|
4125
|
-
composed.load = async function(id$1) {
|
|
4126
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4127
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4128
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1);
|
|
4129
|
-
if (!isNullish(result)) return result;
|
|
4130
|
-
}
|
|
4131
|
-
};
|
|
4132
|
-
}
|
|
4133
|
-
break;
|
|
4134
|
-
}
|
|
4135
|
-
case "transform": {
|
|
4136
|
-
if (batchedHooks.transform) {
|
|
4137
|
-
const batchedHandlers = batchedHooks.transform;
|
|
4138
|
-
composed.transform = async function(initialCode, id$1, moduleType$1) {
|
|
4139
|
-
let code$1 = initialCode;
|
|
4140
|
-
let moduleSideEffects = void 0;
|
|
4141
|
-
function updateOutput(newCode, newModuleSideEffects) {
|
|
4142
|
-
code$1 = newCode;
|
|
4143
|
-
moduleSideEffects = newModuleSideEffects ?? void 0;
|
|
4144
|
-
}
|
|
4145
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4146
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4147
|
-
this.getCombinedSourcemap = () => {
|
|
4148
|
-
throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
|
|
4149
|
-
};
|
|
4150
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, id$1, moduleType$1);
|
|
4151
|
-
if (!isNullish(result)) {
|
|
4152
|
-
if (typeof result === "string") updateOutput(result);
|
|
4153
|
-
else if (result.code) updateOutput(result.code, result.moduleSideEffects);
|
|
4154
|
-
}
|
|
4155
|
-
}
|
|
4156
|
-
return {
|
|
4157
|
-
code: code$1,
|
|
4158
|
-
moduleSideEffects
|
|
4159
|
-
};
|
|
4160
|
-
};
|
|
4161
|
-
}
|
|
4162
|
-
break;
|
|
4163
|
-
}
|
|
4164
|
-
case "buildEnd": {
|
|
4165
|
-
if (batchedHooks.buildEnd) {
|
|
4166
|
-
const batchedHandlers = batchedHooks.buildEnd;
|
|
4167
|
-
composed.buildEnd = async function(err) {
|
|
4168
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4169
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4170
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), err);
|
|
4171
|
-
}));
|
|
4172
|
-
};
|
|
4173
|
-
}
|
|
4174
|
-
break;
|
|
4175
|
-
}
|
|
4176
|
-
case "renderChunk": {
|
|
4177
|
-
if (batchedHooks.renderChunk) {
|
|
4178
|
-
const batchedHandlers = batchedHooks.renderChunk;
|
|
4179
|
-
composed.renderChunk = async function(code$1, chunk, options, meta) {
|
|
4180
|
-
for (const [handler, plugin] of batchedHandlers) {
|
|
4181
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4182
|
-
const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code$1, chunk, options, meta);
|
|
4183
|
-
if (!isNullish(result)) return result;
|
|
4184
|
-
}
|
|
4185
|
-
};
|
|
4186
|
-
}
|
|
4187
|
-
break;
|
|
4188
|
-
}
|
|
4189
|
-
case "banner":
|
|
4190
|
-
case "footer":
|
|
4191
|
-
case "intro":
|
|
4192
|
-
case "outro": {
|
|
4193
|
-
const hooks = batchedHooks[hookName];
|
|
4194
|
-
if (hooks?.length) composed[hookName] = async function(chunk) {
|
|
4195
|
-
const ret = [];
|
|
4196
|
-
for (const [hook, plugin] of hooks) {
|
|
4197
|
-
const { handler } = normalizeHook(hook);
|
|
4198
|
-
ret.push(typeof handler === "string" ? handler : await handler.call(applyFixedPluginResolveFn(this, plugin), chunk));
|
|
4199
|
-
}
|
|
4200
|
-
return ret.join("\n");
|
|
4201
|
-
};
|
|
4202
|
-
break;
|
|
4203
|
-
}
|
|
4204
|
-
case "closeBundle": {
|
|
4205
|
-
if (batchedHooks.closeBundle) {
|
|
4206
|
-
const batchedHandlers = batchedHooks.closeBundle;
|
|
4207
|
-
composed.closeBundle = async function() {
|
|
4208
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4209
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4210
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
4211
|
-
}));
|
|
4212
|
-
};
|
|
4213
|
-
}
|
|
4214
|
-
break;
|
|
4215
|
-
}
|
|
4216
|
-
case "watchChange": {
|
|
4217
|
-
if (batchedHooks.watchChange) {
|
|
4218
|
-
const batchedHandlers = batchedHooks.watchChange;
|
|
4219
|
-
composed.watchChange = async function(id$1, event) {
|
|
4220
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4221
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4222
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin), id$1, event);
|
|
4223
|
-
}));
|
|
4224
|
-
};
|
|
4225
|
-
}
|
|
4226
|
-
break;
|
|
4227
|
-
}
|
|
4228
|
-
case "closeWatcher": {
|
|
4229
|
-
if (batchedHooks.closeWatcher) {
|
|
4230
|
-
const batchedHandlers = batchedHooks.closeWatcher;
|
|
4231
|
-
composed.closeWatcher = async function() {
|
|
4232
|
-
await Promise.all(batchedHandlers.map(([handler, plugin]) => {
|
|
4233
|
-
const { handler: handlerFn } = normalizeHook(handler);
|
|
4234
|
-
return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
|
|
4235
|
-
}));
|
|
4236
|
-
};
|
|
4237
|
-
}
|
|
4238
|
-
break;
|
|
4239
|
-
}
|
|
4240
|
-
default: {}
|
|
4241
|
-
}
|
|
4242
|
-
});
|
|
4243
|
-
return composed;
|
|
4244
|
-
}
|
|
4245
|
-
function isComposablePlugin(plugin) {
|
|
4246
|
-
if (plugin instanceof BuiltinPlugin) return false;
|
|
4247
|
-
if ("_parallel" in plugin) return false;
|
|
4248
|
-
const hasNotComposablePattern = t(plugin).some((hookName) => {
|
|
4249
|
-
if (!isPluginHookName(hookName)) return false;
|
|
4250
|
-
const OK_TO_COMPOSE = false;
|
|
4251
|
-
if (isUnsupportedHooks(hookName)) return !OK_TO_COMPOSE;
|
|
4252
|
-
if (plugin[hookName]) {
|
|
4253
|
-
const { meta } = normalizeHook(plugin[hookName]);
|
|
4254
|
-
if (meta.order === "pre" || meta.order === "post") return !OK_TO_COMPOSE;
|
|
4255
|
-
}
|
|
4256
|
-
return OK_TO_COMPOSE;
|
|
4257
|
-
});
|
|
4258
|
-
if (hasNotComposablePattern) return false;
|
|
4259
|
-
return true;
|
|
4260
|
-
}
|
|
4261
|
-
function composeJsPlugins(plugins) {
|
|
4262
|
-
const newPlugins = [];
|
|
4263
|
-
const toBeComposed = [];
|
|
4264
|
-
plugins.forEach((plugin) => {
|
|
4265
|
-
if (isComposablePlugin(plugin)) toBeComposed.push(plugin);
|
|
4266
|
-
else {
|
|
4267
|
-
if (toBeComposed.length > 0) {
|
|
4268
|
-
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
4269
|
-
else newPlugins.push(toBeComposed[0]);
|
|
4270
|
-
toBeComposed.length = 0;
|
|
4271
|
-
}
|
|
4272
|
-
newPlugins.push(plugin);
|
|
4273
|
-
}
|
|
4274
|
-
});
|
|
4275
|
-
if (toBeComposed.length > 0) {
|
|
4276
|
-
if (toBeComposed.length > 1) newPlugins.push(createComposedPlugin(toBeComposed));
|
|
4277
|
-
else newPlugins.push(toBeComposed[0]);
|
|
4278
|
-
toBeComposed.length = 0;
|
|
4279
|
-
}
|
|
4280
|
-
return newPlugins;
|
|
4281
|
-
}
|
|
4282
|
-
var unsupportedHookName, unsupportedHooks;
|
|
4283
|
-
var init_compose_js_plugins = __esm({ "src/utils/compose-js-plugins.ts"() {
|
|
4284
|
-
init_dist$1();
|
|
4285
|
-
init_constructors();
|
|
4286
|
-
init_plugin_context$1();
|
|
4287
|
-
init_misc();
|
|
4288
|
-
init_normalize_hook();
|
|
4289
|
-
init_plugin();
|
|
4290
|
-
unsupportedHookName = [
|
|
4291
|
-
"augmentChunkHash",
|
|
4292
|
-
"generateBundle",
|
|
4293
|
-
"moduleParsed",
|
|
4294
|
-
"onLog",
|
|
4295
|
-
"options",
|
|
4296
|
-
"outputOptions",
|
|
4297
|
-
"renderError",
|
|
4298
|
-
"renderStart",
|
|
4299
|
-
"resolveDynamicImport",
|
|
4300
|
-
"writeBundle"
|
|
4301
|
-
];
|
|
4302
|
-
unsupportedHooks = new Set(unsupportedHookName);
|
|
4303
|
-
} });
|
|
4304
|
-
|
|
4305
|
-
//#endregion
|
|
4306
|
-
//#region src/utils/initialize-parallel-plugins.ts
|
|
4307
|
-
async function initializeParallelPlugins(plugins) {
|
|
4308
|
-
const pluginInfos = [];
|
|
4309
|
-
for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
|
|
4310
|
-
const { fileUrl, options } = plugin._parallel;
|
|
4311
|
-
pluginInfos.push({
|
|
4312
|
-
index,
|
|
4313
|
-
fileUrl,
|
|
4314
|
-
options
|
|
4315
|
-
});
|
|
4316
|
-
}
|
|
4317
|
-
if (pluginInfos.length <= 0) return void 0;
|
|
4318
|
-
const count = availableParallelism();
|
|
4319
|
-
const parallelJsPluginRegistry = new ParallelJsPluginRegistry(count);
|
|
4320
|
-
const registryId = parallelJsPluginRegistry.id;
|
|
4321
|
-
const workers = await initializeWorkers(registryId, count, pluginInfos);
|
|
4322
|
-
const stopWorkers = async () => {
|
|
4323
|
-
await Promise.all(workers.map((worker) => worker.terminate()));
|
|
4324
|
-
};
|
|
4325
|
-
return {
|
|
4326
|
-
registry: parallelJsPluginRegistry,
|
|
4327
|
-
stopWorkers
|
|
4328
|
-
};
|
|
4329
|
-
}
|
|
4330
|
-
function initializeWorkers(registryId, count, pluginInfos) {
|
|
4331
|
-
return Promise.all(Array.from({ length: count }, (_, i$1) => initializeWorker(registryId, pluginInfos, i$1)));
|
|
4332
|
-
}
|
|
4333
|
-
async function initializeWorker(registryId, pluginInfos, threadNumber) {
|
|
4334
|
-
const urlString = import.meta.resolve("#parallel-plugin-worker");
|
|
4335
|
-
const workerData$1 = {
|
|
4336
|
-
registryId,
|
|
4337
|
-
pluginInfos,
|
|
4338
|
-
threadNumber
|
|
4339
|
-
};
|
|
4340
|
-
let worker;
|
|
4341
|
-
try {
|
|
4342
|
-
worker = new Worker(new URL(urlString), { workerData: workerData$1 });
|
|
4343
|
-
worker.unref();
|
|
4344
|
-
await new Promise((resolve, reject) => {
|
|
4345
|
-
worker.once("message", async (message) => {
|
|
4346
|
-
if (message.type === "error") reject(message.error);
|
|
4347
|
-
else resolve();
|
|
4348
|
-
});
|
|
4349
|
-
});
|
|
4350
|
-
return worker;
|
|
4351
|
-
} catch (e) {
|
|
4352
|
-
worker?.terminate();
|
|
4353
|
-
throw e;
|
|
4354
|
-
}
|
|
4355
|
-
}
|
|
4356
|
-
var availableParallelism;
|
|
4357
|
-
var init_initialize_parallel_plugins = __esm({ "src/utils/initialize-parallel-plugins.ts"() {
|
|
4358
|
-
availableParallelism = () => {
|
|
4359
|
-
let availableParallelism$1 = 1;
|
|
4360
|
-
try {
|
|
4361
|
-
availableParallelism$1 = os.availableParallelism();
|
|
4362
|
-
} catch {
|
|
4363
|
-
const cpus = os.cpus();
|
|
4364
|
-
if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
|
|
4365
|
-
}
|
|
4366
|
-
return Math.min(availableParallelism$1, 8);
|
|
4367
|
-
};
|
|
4368
|
-
} });
|
|
4369
|
-
|
|
4370
|
-
//#endregion
|
|
4371
|
-
//#region src/utils/create-bundler-option.ts
|
|
4372
|
-
async function createBundlerOptions(inputOptions, outputOptions, watchMode, isClose) {
|
|
4373
|
-
const inputPlugins = await normalizePluginOption(inputOptions.plugins);
|
|
4374
|
-
const outputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
4375
|
-
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
4376
|
-
const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
|
|
4377
|
-
if (!isClose) outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
|
|
4378
|
-
const normalizedOutputPlugins = await normalizePluginOption(outputOptions.plugins);
|
|
4379
|
-
let plugins = [
|
|
4380
|
-
...BUILTIN_PLUGINS,
|
|
4381
|
-
...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
|
|
4382
|
-
...checkOutputPluginOption(normalizePlugins(normalizedOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)
|
|
4383
|
-
];
|
|
4384
|
-
if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
|
|
4385
|
-
const parallelPluginInitResult = await initializeParallelPlugins(plugins);
|
|
4386
|
-
try {
|
|
4387
|
-
const bindingInputOptions = bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode);
|
|
4388
|
-
const bindingOutputOptions = bindingifyOutputOptions(outputOptions);
|
|
4389
|
-
return {
|
|
4390
|
-
bundlerOptions: {
|
|
4391
|
-
inputOptions: bindingInputOptions,
|
|
4392
|
-
outputOptions: bindingOutputOptions,
|
|
4393
|
-
parallelPluginsRegistry: parallelPluginInitResult?.registry
|
|
4394
|
-
},
|
|
4395
|
-
inputOptions,
|
|
4396
|
-
onLog,
|
|
4397
|
-
stopWorkers: parallelPluginInitResult?.stopWorkers
|
|
4398
|
-
};
|
|
4399
|
-
} catch (e) {
|
|
4400
|
-
await parallelPluginInitResult?.stopWorkers();
|
|
4401
|
-
throw e;
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
var init_create_bundler_option = __esm({ "src/utils/create-bundler-option.ts"() {
|
|
4405
|
-
init_logger();
|
|
4406
|
-
init_logging();
|
|
4407
|
-
init_plugin_driver();
|
|
4408
|
-
init_bindingify_input_options();
|
|
4409
|
-
init_bindingify_output_options();
|
|
4410
|
-
init_compose_js_plugins();
|
|
4411
|
-
init_initialize_parallel_plugins();
|
|
4412
|
-
init_normalize_plugin_option();
|
|
4413
|
-
} });
|
|
4414
|
-
|
|
4415
|
-
//#endregion
|
|
4416
|
-
//#region src/utils/create-bundler.ts
|
|
4417
|
-
async function createBundler(inputOptions, outputOptions, isClose) {
|
|
4418
|
-
const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
|
|
4419
|
-
if (asyncRuntimeShutdown) startAsyncRuntime();
|
|
4420
|
-
try {
|
|
4421
|
-
return {
|
|
4422
|
-
bundler: new Bundler(option.bundlerOptions),
|
|
4423
|
-
stopWorkers: option.stopWorkers,
|
|
4424
|
-
shutdown: () => {
|
|
4425
|
-
shutdownAsyncRuntime();
|
|
4426
|
-
asyncRuntimeShutdown = true;
|
|
4427
|
-
}
|
|
4428
|
-
};
|
|
4429
|
-
} catch (e) {
|
|
4430
|
-
await option.stopWorkers?.();
|
|
4431
|
-
throw e;
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
var asyncRuntimeShutdown;
|
|
4435
|
-
var init_create_bundler = __esm({ "src/utils/create-bundler.ts"() {
|
|
4436
|
-
init_create_bundler_option();
|
|
4437
|
-
asyncRuntimeShutdown = false;
|
|
4438
|
-
} });
|
|
4439
|
-
|
|
4440
|
-
//#endregion
|
|
4441
|
-
//#region src/api/rolldown/rolldown-build.ts
|
|
4442
|
-
var RolldownBuild;
|
|
4443
|
-
var init_rolldown_build = __esm({ "src/api/rolldown/rolldown-build.ts"() {
|
|
4444
|
-
init_create_bundler();
|
|
4445
|
-
init_transform_to_rollup_output();
|
|
4446
|
-
init_validator();
|
|
4447
|
-
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
4448
|
-
RolldownBuild = class {
|
|
4449
|
-
#inputOptions;
|
|
4450
|
-
#bundler;
|
|
4451
|
-
constructor(inputOptions) {
|
|
4452
|
-
this.#inputOptions = inputOptions;
|
|
4453
|
-
}
|
|
4454
|
-
get closed() {
|
|
4455
|
-
return this.#bundler?.bundler.closed ?? false;
|
|
4456
|
-
}
|
|
4457
|
-
async #getBundlerWithStopWorker(outputOptions, isClose) {
|
|
4458
|
-
if (this.#bundler) await this.#bundler.stopWorkers?.();
|
|
4459
|
-
return this.#bundler = await createBundler(this.#inputOptions, outputOptions, isClose);
|
|
4460
|
-
}
|
|
4461
|
-
async generate(outputOptions = {}) {
|
|
4462
|
-
validateOption("output", outputOptions);
|
|
4463
|
-
const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
|
|
4464
|
-
const output = await bundler.generate();
|
|
4465
|
-
return transformToRollupOutput(output);
|
|
4466
|
-
}
|
|
4467
|
-
async write(outputOptions = {}) {
|
|
4468
|
-
validateOption("output", outputOptions);
|
|
4469
|
-
const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
|
|
4470
|
-
const output = await bundler.write();
|
|
4471
|
-
return transformToRollupOutput(output);
|
|
4472
|
-
}
|
|
4473
|
-
async close() {
|
|
4474
|
-
const { bundler, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
|
|
4475
|
-
await stopWorkers?.();
|
|
4476
|
-
await bundler.close();
|
|
4477
|
-
shutdown();
|
|
4478
|
-
}
|
|
4479
|
-
async [Symbol.asyncDispose]() {
|
|
4480
|
-
await this.close();
|
|
4481
|
-
}
|
|
4482
|
-
async generateHmrPatch(changedFiles) {
|
|
4483
|
-
return this.#bundler?.bundler.generateHmrPatch(changedFiles);
|
|
4484
|
-
}
|
|
4485
|
-
async hmrInvalidate(file, firstInvalidatedBy) {
|
|
4486
|
-
return this.#bundler?.bundler.hmrInvalidate(file, firstInvalidatedBy);
|
|
4487
|
-
}
|
|
4488
|
-
get watchFiles() {
|
|
4489
|
-
return this.#bundler?.bundler.getWatchFiles() ?? Promise.resolve([]);
|
|
4490
|
-
}
|
|
4491
|
-
};
|
|
4492
|
-
} });
|
|
4493
|
-
|
|
4494
|
-
//#endregion
|
|
4495
|
-
//#region src/api/rolldown/index.ts
|
|
4496
|
-
var rolldown;
|
|
4497
|
-
var init_rolldown = __esm({ "src/api/rolldown/index.ts"() {
|
|
4498
|
-
init_plugin_driver();
|
|
4499
|
-
init_validator();
|
|
4500
|
-
init_rolldown_build();
|
|
4501
|
-
rolldown = async (input) => {
|
|
4502
|
-
validateOption("input", input);
|
|
4503
|
-
const inputOptions = await PluginDriver.callOptionsHook(input);
|
|
4504
|
-
return new RolldownBuild(inputOptions);
|
|
4505
|
-
};
|
|
4506
|
-
} });
|
|
4507
|
-
|
|
4508
|
-
//#endregion
|
|
4509
|
-
//#region src/api/build.ts
|
|
4510
|
-
async function build(options) {
|
|
4511
|
-
if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
|
|
4512
|
-
else {
|
|
4513
|
-
const { output, write = true,...inputOptions } = options;
|
|
4514
|
-
const build$1 = await rolldown(inputOptions);
|
|
4515
|
-
try {
|
|
4516
|
-
if (write) return await build$1.write(output);
|
|
4517
|
-
else return await build$1.generate(output);
|
|
4518
|
-
} finally {
|
|
4519
|
-
await build$1.close();
|
|
4520
|
-
}
|
|
4521
|
-
}
|
|
4522
|
-
}
|
|
4523
|
-
var init_build = __esm({ "src/api/build.ts"() {
|
|
4524
|
-
init_rolldown();
|
|
4525
|
-
} });
|
|
4526
|
-
|
|
4527
|
-
//#endregion
|
|
4528
|
-
//#region src/api/watch/watch-emitter.ts
|
|
4529
|
-
var WatcherEmitter;
|
|
4530
|
-
var init_watch_emitter = __esm({ "src/api/watch/watch-emitter.ts"() {
|
|
4531
|
-
init_error();
|
|
4532
|
-
WatcherEmitter = class {
|
|
4533
|
-
listeners = new Map();
|
|
4534
|
-
timer;
|
|
4535
|
-
constructor() {
|
|
4536
|
-
this.timer = setInterval(() => {}, 1e9);
|
|
4537
|
-
}
|
|
4538
|
-
on(event, listener) {
|
|
4539
|
-
const listeners = this.listeners.get(event);
|
|
4540
|
-
if (listeners) listeners.push(listener);
|
|
4541
|
-
else this.listeners.set(event, [listener]);
|
|
4542
|
-
return this;
|
|
4543
|
-
}
|
|
4544
|
-
off(event, listener) {
|
|
4545
|
-
const listeners = this.listeners.get(event);
|
|
4546
|
-
if (listeners) {
|
|
4547
|
-
const index = listeners.indexOf(listener);
|
|
4548
|
-
if (index !== -1) listeners.splice(index, 1);
|
|
4549
|
-
}
|
|
4550
|
-
return this;
|
|
4551
|
-
}
|
|
4552
|
-
async onEvent(event) {
|
|
4553
|
-
const listeners = this.listeners.get(event.eventKind());
|
|
4554
|
-
if (listeners) switch (event.eventKind()) {
|
|
4555
|
-
case "close":
|
|
4556
|
-
case "restart":
|
|
4557
|
-
for (const listener of listeners) await listener();
|
|
4558
|
-
break;
|
|
4559
|
-
case "event":
|
|
4560
|
-
for (const listener of listeners) {
|
|
4561
|
-
const code$1 = event.bundleEventKind();
|
|
4562
|
-
switch (code$1) {
|
|
4563
|
-
case "BUNDLE_END":
|
|
4564
|
-
const { duration, output, result } = event.bundleEndData();
|
|
4565
|
-
await listener({
|
|
4566
|
-
code: "BUNDLE_END",
|
|
4567
|
-
duration,
|
|
4568
|
-
output: [output],
|
|
4569
|
-
result
|
|
4570
|
-
});
|
|
4571
|
-
break;
|
|
4572
|
-
case "ERROR":
|
|
4573
|
-
const data = event.bundleErrorData();
|
|
4574
|
-
await listener({
|
|
4575
|
-
code: "ERROR",
|
|
4576
|
-
error: normalizeErrors(data.error),
|
|
4577
|
-
result: data.result
|
|
4578
|
-
});
|
|
4579
|
-
break;
|
|
4580
|
-
default:
|
|
4581
|
-
await listener({ code: code$1 });
|
|
4582
|
-
break;
|
|
4583
|
-
}
|
|
4584
|
-
}
|
|
4585
|
-
break;
|
|
4586
|
-
case "change":
|
|
4587
|
-
for (const listener of listeners) {
|
|
4588
|
-
const { path: path$1, kind } = event.watchChangeData();
|
|
4589
|
-
await listener(path$1, { event: kind });
|
|
4590
|
-
}
|
|
4591
|
-
break;
|
|
4592
|
-
default: throw new Error(`Unknown event: ${event}`);
|
|
4593
|
-
}
|
|
4594
|
-
}
|
|
4595
|
-
async close() {
|
|
4596
|
-
clearInterval(this.timer);
|
|
4597
|
-
}
|
|
4598
|
-
};
|
|
4599
|
-
} });
|
|
4600
|
-
|
|
4601
|
-
//#endregion
|
|
4602
|
-
//#region src/api/watch/watcher.ts
|
|
4603
|
-
async function createWatcher(emitter, input) {
|
|
4604
|
-
const options = arraify(input);
|
|
4605
|
-
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
4606
|
-
const inputOptions = await PluginDriver.callOptionsHook(option, true);
|
|
4607
|
-
return createBundlerOptions(inputOptions, output, true);
|
|
4608
|
-
})).flat());
|
|
4609
|
-
const notifyOptions = getValidNotifyOption(bundlerOptions);
|
|
4610
|
-
const bindingWatcher = new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
|
|
4611
|
-
const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
|
|
4612
|
-
watcher.start();
|
|
4613
|
-
}
|
|
4614
|
-
function getValidNotifyOption(bundlerOptions) {
|
|
4615
|
-
let result;
|
|
4616
|
-
for (const option of bundlerOptions) if (option.inputOptions.watch) {
|
|
4617
|
-
const notifyOption = option.inputOptions.watch.notify;
|
|
4618
|
-
if (notifyOption) if (result) {
|
|
4619
|
-
option.onLog(LOG_LEVEL_WARN, logMultiplyNotifyOption());
|
|
4620
|
-
return result;
|
|
4621
|
-
} else result = notifyOption;
|
|
4622
|
-
}
|
|
4623
|
-
}
|
|
4624
|
-
var Watcher;
|
|
4625
|
-
var init_watcher = __esm({ "src/api/watch/watcher.ts"() {
|
|
4626
|
-
init_logging();
|
|
4627
|
-
init_logs();
|
|
4628
|
-
init_plugin_driver();
|
|
4629
|
-
init_create_bundler_option();
|
|
4630
|
-
init_misc();
|
|
4631
|
-
Watcher = class {
|
|
4632
|
-
closed;
|
|
4633
|
-
inner;
|
|
4634
|
-
emitter;
|
|
4635
|
-
stopWorkers;
|
|
4636
|
-
constructor(emitter, inner, stopWorkers) {
|
|
4637
|
-
this.closed = false;
|
|
4638
|
-
this.inner = inner;
|
|
4639
|
-
this.emitter = emitter;
|
|
4640
|
-
const originClose = emitter.close.bind(emitter);
|
|
4641
|
-
emitter.close = async () => {
|
|
4642
|
-
await this.close();
|
|
4643
|
-
originClose();
|
|
4644
|
-
};
|
|
4645
|
-
this.stopWorkers = stopWorkers;
|
|
4646
|
-
}
|
|
4647
|
-
async close() {
|
|
4648
|
-
if (this.closed) return;
|
|
4649
|
-
this.closed = true;
|
|
4650
|
-
for (const stop of this.stopWorkers) await stop?.();
|
|
4651
|
-
await this.inner.close();
|
|
4652
|
-
shutdownAsyncRuntime();
|
|
4653
|
-
}
|
|
4654
|
-
start() {
|
|
4655
|
-
process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
|
|
4656
|
-
}
|
|
4657
|
-
};
|
|
4658
|
-
} });
|
|
4659
|
-
|
|
4660
|
-
//#endregion
|
|
4661
|
-
//#region src/api/watch/index.ts
|
|
4662
|
-
var watch;
|
|
4663
|
-
var init_watch = __esm({ "src/api/watch/index.ts"() {
|
|
4664
|
-
init_watch_emitter();
|
|
4665
|
-
init_watcher();
|
|
4666
|
-
watch = (input) => {
|
|
4667
|
-
const emitter = new WatcherEmitter();
|
|
4668
|
-
createWatcher(emitter, input);
|
|
4669
|
-
return emitter;
|
|
4670
|
-
};
|
|
4671
|
-
} });
|
|
4672
|
-
|
|
4673
|
-
//#endregion
|
|
4674
|
-
//#region src/utils/define-config.ts
|
|
4675
|
-
function defineConfig(config) {
|
|
4676
|
-
return config;
|
|
4677
|
-
}
|
|
4678
|
-
var init_define_config = __esm({ "src/utils/define-config.ts"() {} });
|
|
4679
|
-
|
|
4680
|
-
//#endregion
|
|
4681
|
-
//#region src/index.ts
|
|
4682
|
-
var VERSION;
|
|
4683
|
-
var init_src = __esm({ "src/index.ts"() {
|
|
4684
|
-
init_build();
|
|
4685
|
-
init_rolldown();
|
|
4686
|
-
init_watch();
|
|
4687
|
-
VERSION = version;
|
|
4688
|
-
} });
|
|
4689
|
-
|
|
4690
|
-
//#endregion
|
|
4691
|
-
export { BuiltinPlugin, PluginContextData, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, init_bindingify_plugin, init_compose_js_plugins, init_constructors, init_create_bundler, init_normalize_string_or_regex, init_plugin_context_data, init_rolldown, init_src, init_transform_to_rollup_output, init_validator, init_watch, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };
|