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