@rolldown/browser 1.0.0-beta.50 → 1.0.0-beta.52

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.
Files changed (48) hide show
  1. package/dist/cli.mjs +11 -7
  2. package/dist/config.d.mts +3 -3
  3. package/dist/config.mjs +9 -5
  4. package/dist/constructors-DW3R_Jog.js +68 -0
  5. package/dist/experimental-index.browser.mjs +19 -13
  6. package/dist/experimental-index.d.mts +63 -16
  7. package/dist/experimental-index.mjs +23 -15
  8. package/dist/filter-index.d.mts +3 -3
  9. package/dist/filter-index.mjs +2 -1
  10. package/dist/index.browser.mjs +161 -2
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +36 -4
  13. package/dist/normalize-string-or-regex-BcbPUrYo.js +830 -0
  14. package/dist/parallel-plugin-worker.mjs +5 -4
  15. package/dist/parallel-plugin.d.mts +3 -3
  16. package/dist/parse-ast-index.d.mts +1 -1
  17. package/dist/parse-ast-index.mjs +1 -1
  18. package/dist/plugins-index.browser.mjs +2 -2
  19. package/dist/plugins-index.d.mts +3 -3
  20. package/dist/plugins-index.mjs +3 -2
  21. package/dist/rolldown-binding.wasi-browser.js +5 -2
  22. package/dist/rolldown-binding.wasi.cjs +5 -2
  23. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  24. package/dist/{src-dUoCuQap.js → rolldown-build-CUYnBV3u.js} +44 -754
  25. package/dist/shared/{binding-BTup3pHG.d.mts → binding-BKL2JHoJ.d.mts} +173 -94
  26. package/dist/shared/bindingify-input-options-D4i1DYzt.mjs +1568 -0
  27. package/dist/shared/{composable-filters-CBpK2Fbc.mjs → composable-filters-DZ5ToxRJ.mjs} +1 -22
  28. package/dist/shared/constructors-BvaMwihu.d.mts +32 -0
  29. package/dist/shared/constructors-XFp0WhK3.mjs +68 -0
  30. package/dist/shared/{define-config-DiSv-kgF.d.mts → define-config-Buedmg9e.d.mts} +31 -57
  31. package/dist/shared/define-config-DfeZGBEt.mjs +7 -0
  32. package/dist/shared/{load-config-BqnLKlUM.mjs → load-config-C9CjEv2m.mjs} +1 -1
  33. package/dist/shared/misc-5GYLGQ20.mjs +22 -0
  34. package/dist/shared/normalize-string-or-regex-D1mB67Iy.mjs +629 -0
  35. package/dist/shared/{parse-ast-index-DtI4JSVR.mjs → parse-ast-index-BSDTTjWT.mjs} +20 -6
  36. package/dist/shared/rolldown-0ID0Q4xL.mjs +10 -0
  37. package/dist/shared/rolldown-build-BWJGpMD0.mjs +2121 -0
  38. package/dist/shared/utils-DKydZ4iH.d.mts +62 -0
  39. package/dist/shared/watch-CwnSQOS4.mjs +338 -0
  40. package/package.json +5 -1
  41. package/dist/constructors-EhfoQfqh.js +0 -68
  42. package/dist/normalize-string-or-regex-d47jXr3r.js +0 -231
  43. package/dist/shared/constructors-B7IHT8j4.d.mts +0 -32
  44. package/dist/shared/constructors-DcEzB0nc.mjs +0 -68
  45. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +0 -46
  46. package/dist/shared/src-D0x2a_iO.mjs +0 -4597
  47. package/dist/shared/utils-BKVJO2vQ.d.mts +0 -18
  48. /package/dist/shared/{prompt-CjFmA1DF.mjs → prompt-pmGBC3ws.mjs} +0 -0
@@ -0,0 +1,1568 @@
1
+ import { c as logPluginError, n as error, r as logCycleLoading, t as augmentCodeLocation } from "./logs-CPsamAuj.mjs";
2
+ import { a as unreachable, i as unimplemented, o as unsupported, t as arraify } from "./misc-5GYLGQ20.mjs";
3
+ import { b as normalizeLog, d as __decorate, f as bindingAssetSource, g as MinimalPluginContextImpl, h as PlainObjectLike, i as bindingifyViteHtmlPlugin, l as bindingifySourcemap, m as lazyProp, n as BuiltinPlugin, o as collectChangedBundle, r as bindingifyBuiltInPlugin, s as transformToOutputBundle, t as normalizedStringOrRegex, u as transformRenderedChunk, w as LOG_LEVEL_WARN } from "./normalize-string-or-regex-D1mB67Iy.mjs";
4
+ import { t as parseAst } from "./parse-ast-index-BSDTTjWT.mjs";
5
+ import { a as include, c as or, i as id, n as code, o as moduleType, r as exclude, t as and } from "./composable-filters-DZ5ToxRJ.mjs";
6
+ import { BindingAttachDebugInfo, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects } from "../rolldown-binding.wasi.cjs";
7
+ import path from "node:path";
8
+ import fsp from "node:fs/promises";
9
+
10
+ //#region src/utils/normalize-hook.ts
11
+ function normalizeHook(hook) {
12
+ if (typeof hook === "function" || typeof hook === "string") return {
13
+ handler: hook,
14
+ options: {},
15
+ meta: {}
16
+ };
17
+ if (typeof hook === "object" && hook !== null) {
18
+ const { handler, order, ...options } = hook;
19
+ return {
20
+ handler,
21
+ options,
22
+ meta: { order }
23
+ };
24
+ }
25
+ unreachable("Invalid hook type");
26
+ }
27
+
28
+ //#endregion
29
+ //#region src/utils/error.ts
30
+ function unwrapBindingResult(container) {
31
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
32
+ return container;
33
+ }
34
+ function normalizeBindingResult(container) {
35
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
36
+ return container;
37
+ }
38
+ function normalizeBindingError(e$1) {
39
+ return e$1.type === "JsError" ? e$1.field0 : Object.assign(/* @__PURE__ */ new Error(), {
40
+ kind: e$1.field0.kind,
41
+ message: e$1.field0.message,
42
+ stack: void 0
43
+ });
44
+ }
45
+ function aggregateBindingErrorsIntoJsError(rawErrors) {
46
+ const errors = rawErrors.map(normalizeBindingError);
47
+ let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
48
+ for (let i = 0; i < errors.length; i++) {
49
+ summary += "\n";
50
+ if (i >= 5) {
51
+ summary += "...";
52
+ break;
53
+ }
54
+ summary += getErrorMessage(errors[i]);
55
+ }
56
+ const wrapper = new Error(summary);
57
+ Object.defineProperty(wrapper, "errors", {
58
+ configurable: true,
59
+ enumerable: true,
60
+ get: () => errors,
61
+ set: (value) => Object.defineProperty(wrapper, "errors", {
62
+ configurable: true,
63
+ enumerable: true,
64
+ value
65
+ })
66
+ });
67
+ return wrapper;
68
+ }
69
+ function getErrorMessage(e$1) {
70
+ if (Object.hasOwn(e$1, "kind")) return e$1.message;
71
+ let s = "";
72
+ if (e$1.plugin) s += `[plugin ${e$1.plugin}]`;
73
+ const id$1 = e$1.id ?? e$1.loc?.file;
74
+ if (id$1) {
75
+ s += " " + id$1;
76
+ if (e$1.loc) s += `:${e$1.loc.line}:${e$1.loc.column}`;
77
+ }
78
+ if (s) s += "\n";
79
+ const message = `${e$1.name ?? "Error"}: ${e$1.message}`;
80
+ s += message;
81
+ if (e$1.frame) s = joinNewLine(s, e$1.frame);
82
+ if (e$1.stack) s = joinNewLine(s, e$1.stack.replace(message, ""));
83
+ if (e$1.cause) {
84
+ s = joinNewLine(s, "Caused by:");
85
+ s = joinNewLine(s, getErrorMessage(e$1.cause).split("\n").map((line) => " " + line).join("\n"));
86
+ }
87
+ return s;
88
+ }
89
+ function joinNewLine(s1, s2) {
90
+ return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
91
+ }
92
+
93
+ //#endregion
94
+ //#region src/utils/transform-module-info.ts
95
+ function transformModuleInfo(info, option) {
96
+ return {
97
+ get ast() {
98
+ return unsupported("ModuleInfo#ast");
99
+ },
100
+ get code() {
101
+ return info.code;
102
+ },
103
+ id: info.id,
104
+ importers: info.importers,
105
+ dynamicImporters: info.dynamicImporters,
106
+ importedIds: info.importedIds,
107
+ dynamicallyImportedIds: info.dynamicallyImportedIds,
108
+ exports: info.exports,
109
+ isEntry: info.isEntry,
110
+ ...option
111
+ };
112
+ }
113
+
114
+ //#endregion
115
+ //#region src/utils/transform-sourcemap.ts
116
+ function isEmptySourcemapFiled(array) {
117
+ if (!array) return true;
118
+ if (array.length === 0 || !array[0]) return true;
119
+ return false;
120
+ }
121
+ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
122
+ if (!rawMap) return;
123
+ let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
124
+ if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
125
+ if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id$1) map.sources = [id$1];
126
+ return map;
127
+ }
128
+
129
+ //#endregion
130
+ //#region ../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/lazyDataLastImpl-BDhrIOwR.js
131
+ function e(e$1, t$2, n$1) {
132
+ let r = (n$2) => e$1(n$2, ...t$2);
133
+ return n$1 === void 0 ? r : Object.assign(r, {
134
+ lazy: n$1,
135
+ lazyArgs: t$2
136
+ });
137
+ }
138
+
139
+ //#endregion
140
+ //#region ../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purry-DH9cw9sy.js
141
+ function t(t$2, n$1, r) {
142
+ let i = t$2.length - n$1.length;
143
+ if (i === 0) return t$2(...n$1);
144
+ if (i === 1) return e(t$2, n$1, r);
145
+ throw Error(`Wrong number of arguments`);
146
+ }
147
+
148
+ //#endregion
149
+ //#region ../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/partition-DAu403JQ.js
150
+ function t$1(...t$2) {
151
+ return t(n, t$2);
152
+ }
153
+ const n = (e$1, t$2) => {
154
+ let n$1 = [[], []];
155
+ for (let [r, i] of e$1.entries()) t$2(i, r, e$1) ? n$1[0].push(i) : n$1[1].push(i);
156
+ return n$1;
157
+ };
158
+
159
+ //#endregion
160
+ //#region src/plugin/bindingify-hook-filter.ts
161
+ function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
162
+ if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
163
+ if (Array.isArray(matcher)) return matcher.map((m) => include(generateAtomMatcher(stringKind, m)));
164
+ let ret = [];
165
+ if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => exclude(generateAtomMatcher(stringKind, m))));
166
+ if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(generateAtomMatcher(stringKind, m))));
167
+ return ret;
168
+ }
169
+ function generateAtomMatcher(kind, matcher) {
170
+ return kind === "code" ? code(matcher) : id(matcher);
171
+ }
172
+ function transformFilterMatcherToFilterExprs(filterOption) {
173
+ if (!filterOption) return;
174
+ if (Array.isArray(filterOption)) return filterOption;
175
+ const { id: id$1, code: code$1, moduleType: moduleType$1 } = filterOption;
176
+ let ret = [];
177
+ let idIncludes = [];
178
+ let idExcludes = [];
179
+ let codeIncludes = [];
180
+ let codeExcludes = [];
181
+ if (id$1) [idIncludes, idExcludes] = t$1(generalHookFilterMatcherToFilterExprs(id$1, "id") ?? [], (m) => m.kind === "include");
182
+ if (code$1) [codeIncludes, codeExcludes] = t$1(generalHookFilterMatcherToFilterExprs(code$1, "code") ?? [], (m) => m.kind === "include");
183
+ ret.push(...idExcludes);
184
+ ret.push(...codeExcludes);
185
+ let andExprList = [];
186
+ if (moduleType$1) {
187
+ let moduleTypes = Array.isArray(moduleType$1) ? moduleType$1 : moduleType$1.include ?? [];
188
+ andExprList.push(or(...moduleTypes.map((m) => moduleType(m))));
189
+ }
190
+ if (idIncludes.length) andExprList.push(or(...idIncludes.map((item) => item.expr)));
191
+ if (codeIncludes.length) andExprList.push(or(...codeIncludes.map((item) => item.expr)));
192
+ if (andExprList.length) ret.push(include(and(...andExprList)));
193
+ return ret;
194
+ }
195
+ function bindingifyGeneralHookFilter(stringKind, pattern) {
196
+ let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
197
+ let ret = [];
198
+ if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
199
+ return ret.length > 0 ? { value: ret } : void 0;
200
+ }
201
+ function bindingifyFilterExpr(expr) {
202
+ let list = [];
203
+ bindingifyFilterExprImpl(expr, list);
204
+ return list;
205
+ }
206
+ function bindingifyFilterExprImpl(expr, list) {
207
+ switch (expr.kind) {
208
+ case "and": {
209
+ let args = expr.args;
210
+ for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
211
+ list.push({
212
+ kind: "And",
213
+ payload: args.length
214
+ });
215
+ break;
216
+ }
217
+ case "or": {
218
+ let args = expr.args;
219
+ for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
220
+ list.push({
221
+ kind: "Or",
222
+ payload: args.length
223
+ });
224
+ break;
225
+ }
226
+ case "not":
227
+ bindingifyFilterExprImpl(expr.expr, list);
228
+ list.push({ kind: "Not" });
229
+ break;
230
+ case "id":
231
+ list.push({
232
+ kind: "Id",
233
+ payload: expr.pattern
234
+ });
235
+ if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
236
+ break;
237
+ case "moduleType":
238
+ list.push({
239
+ kind: "ModuleType",
240
+ payload: expr.pattern
241
+ });
242
+ break;
243
+ case "code":
244
+ list.push({
245
+ kind: "Code",
246
+ payload: expr.pattern
247
+ });
248
+ break;
249
+ case "include":
250
+ bindingifyFilterExprImpl(expr.expr, list);
251
+ list.push({ kind: "Include" });
252
+ break;
253
+ case "exclude":
254
+ bindingifyFilterExprImpl(expr.expr, list);
255
+ list.push({ kind: "Exclude" });
256
+ break;
257
+ case "query":
258
+ list.push({
259
+ kind: "QueryKey",
260
+ payload: expr.key
261
+ });
262
+ list.push({
263
+ kind: "QueryValue",
264
+ payload: expr.pattern
265
+ });
266
+ break;
267
+ default: throw new Error(`Unknown filter expression: ${expr}`);
268
+ }
269
+ }
270
+ function bindingifyResolveIdFilter(filterOption) {
271
+ if (!filterOption) return;
272
+ if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
273
+ return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
274
+ }
275
+ function bindingifyLoadFilter(filterOption) {
276
+ if (!filterOption) return;
277
+ if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
278
+ return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
279
+ }
280
+ function bindingifyTransformFilter(filterOption) {
281
+ if (!filterOption) return;
282
+ let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
283
+ let ret = [];
284
+ if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
285
+ return { value: ret.length > 0 ? ret : void 0 };
286
+ }
287
+ function bindingifyRenderChunkFilter(filterOption) {
288
+ if (!filterOption) return;
289
+ if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
290
+ return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
291
+ }
292
+
293
+ //#endregion
294
+ //#region src/plugin/bindingify-plugin-hook-meta.ts
295
+ function bindingifyPluginHookMeta(options) {
296
+ return { order: bindingPluginOrder(options.order) };
297
+ }
298
+ function bindingPluginOrder(order) {
299
+ switch (order) {
300
+ case "post": return BindingPluginOrder.Post;
301
+ case "pre": return BindingPluginOrder.Pre;
302
+ case null:
303
+ case void 0: return;
304
+ default: throw new Error(`Unknown plugin order: ${order}`);
305
+ }
306
+ }
307
+
308
+ //#endregion
309
+ //#region src/plugin/fs.ts
310
+ const fsModule = {
311
+ appendFile: fsp.appendFile,
312
+ copyFile: fsp.copyFile,
313
+ mkdir: fsp.mkdir,
314
+ mkdtemp: fsp.mkdtemp,
315
+ readdir: fsp.readdir,
316
+ readFile: fsp.readFile,
317
+ realpath: fsp.realpath,
318
+ rename: fsp.rename,
319
+ rmdir: fsp.rmdir,
320
+ stat: fsp.stat,
321
+ lstat: fsp.lstat,
322
+ unlink: fsp.unlink,
323
+ writeFile: fsp.writeFile
324
+ };
325
+
326
+ //#endregion
327
+ //#region src/plugin/plugin-context.ts
328
+ var PluginContextImpl = class extends MinimalPluginContextImpl {
329
+ fs = fsModule;
330
+ getModuleInfo;
331
+ constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
332
+ super(onLog, logLevel, plugin.name, watchMode);
333
+ this.outputOptions = outputOptions;
334
+ this.context = context;
335
+ this.data = data;
336
+ this.onLog = onLog;
337
+ this.currentLoadingModule = currentLoadingModule;
338
+ this.getModuleInfo = (id$1) => this.data.getModuleInfo(id$1, context);
339
+ }
340
+ async load(options) {
341
+ const id$1 = options.id;
342
+ if (id$1 === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
343
+ const moduleInfo = this.data.getModuleInfo(id$1, this.context);
344
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
345
+ const rawOptions = {
346
+ meta: options.meta || {},
347
+ moduleSideEffects: options.moduleSideEffects || null,
348
+ invalidate: false
349
+ };
350
+ this.data.updateModuleOption(id$1, rawOptions);
351
+ let loadPromise = this.data.loadModulePromiseMap.get(id$1);
352
+ if (!loadPromise) {
353
+ loadPromise = this.context.load(id$1, options.moduleSideEffects ?? void 0, options.packageJsonPath ?? void 0).catch(() => {
354
+ this.data.loadModulePromiseMap.delete(id$1);
355
+ });
356
+ this.data.loadModulePromiseMap.set(id$1, loadPromise);
357
+ }
358
+ await loadPromise;
359
+ return this.data.getModuleInfo(id$1, this.context);
360
+ }
361
+ async resolve(source, importer, options) {
362
+ let receipt = void 0;
363
+ if (options != null) receipt = this.data.saveResolveOptions(options);
364
+ const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
365
+ if (key.startsWith("vite:")) (acc ??= {})[key] = value;
366
+ return acc;
367
+ }, void 0);
368
+ const res = await this.context.resolve(source, importer, {
369
+ custom: receipt,
370
+ isEntry: options?.isEntry,
371
+ skipSelf: options?.skipSelf,
372
+ vitePluginCustom
373
+ });
374
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
375
+ if (res == null) return null;
376
+ const info = this.data.getModuleOption(res.id) || {};
377
+ return {
378
+ ...res,
379
+ external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
380
+ ...info,
381
+ moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
382
+ packageJsonPath: res.packageJsonPath
383
+ };
384
+ }
385
+ emitFile = (file) => {
386
+ if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
387
+ if (file.type === "chunk") return this.context.emitChunk({
388
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
389
+ ...file
390
+ });
391
+ const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
392
+ const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
393
+ return this.context.emitFile({
394
+ ...file,
395
+ originalFileName: file.originalFileName || void 0,
396
+ source: bindingAssetSource(file.source)
397
+ }, filename, fnSanitizedFileName);
398
+ };
399
+ getAssetFileNames(file) {
400
+ if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
401
+ type: "asset",
402
+ name: file.name,
403
+ names: file.name ? [file.name] : [],
404
+ originalFileName: file.originalFileName,
405
+ originalFileNames: file.originalFileName ? [file.originalFileName] : [],
406
+ source: file.source
407
+ });
408
+ }
409
+ getFileName(referenceId) {
410
+ return this.context.getFileName(referenceId);
411
+ }
412
+ getModuleIds() {
413
+ return this.data.getModuleIds(this.context);
414
+ }
415
+ addWatchFile(id$1) {
416
+ this.context.addWatchFile(id$1);
417
+ }
418
+ parse(input, options) {
419
+ return parseAst(input, options);
420
+ }
421
+ };
422
+
423
+ //#endregion
424
+ //#region src/plugin/transform-plugin-context.ts
425
+ var TransformPluginContextImpl = class extends PluginContextImpl {
426
+ constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
427
+ super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
428
+ this.inner = inner;
429
+ this.moduleId = moduleId;
430
+ this.moduleSource = moduleSource;
431
+ const getLogHandler = (handler) => (log, pos) => {
432
+ log = normalizeLog(log);
433
+ if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
434
+ log.id = moduleId;
435
+ log.hook = "transform";
436
+ handler(log);
437
+ };
438
+ this.debug = getLogHandler(this.debug);
439
+ this.warn = getLogHandler(this.warn);
440
+ this.info = getLogHandler(this.info);
441
+ }
442
+ error(e$1, pos) {
443
+ if (typeof e$1 === "string") e$1 = { message: e$1 };
444
+ if (pos) augmentCodeLocation(e$1, pos, this.moduleSource, this.moduleId);
445
+ e$1.id = this.moduleId;
446
+ e$1.hook = "transform";
447
+ return error(logPluginError(normalizeLog(e$1), this.pluginName));
448
+ }
449
+ getCombinedSourcemap() {
450
+ return JSON.parse(this.inner.getCombinedSourcemap());
451
+ }
452
+ addWatchFile(id$1) {
453
+ this.inner.addWatchFile(id$1);
454
+ }
455
+ sendMagicString(s) {
456
+ this.inner.sendMagicString(s);
457
+ }
458
+ };
459
+
460
+ //#endregion
461
+ //#region src/plugin/bindingify-build-hooks.ts
462
+ function bindingifyBuildStart(args) {
463
+ const hook = args.plugin.buildStart;
464
+ if (!hook) return {};
465
+ const { handler, meta } = normalizeHook(hook);
466
+ return {
467
+ plugin: async (ctx, opts) => {
468
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getInputOptions(opts));
469
+ },
470
+ meta: bindingifyPluginHookMeta(meta)
471
+ };
472
+ }
473
+ function bindingifyBuildEnd(args) {
474
+ const hook = args.plugin.buildEnd;
475
+ if (!hook) return {};
476
+ const { handler, meta } = normalizeHook(hook);
477
+ return {
478
+ plugin: async (ctx, err) => {
479
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
480
+ },
481
+ meta: bindingifyPluginHookMeta(meta)
482
+ };
483
+ }
484
+ function bindingifyResolveId(args) {
485
+ const hook = args.plugin.resolveId;
486
+ if (!hook) return {};
487
+ const { handler, meta, options } = normalizeHook(hook);
488
+ return {
489
+ plugin: async (ctx, specifier, importer, extraOptions) => {
490
+ const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
491
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0, {
492
+ ...extraOptions,
493
+ custom: contextResolveOptions?.custom
494
+ });
495
+ if (ret == null) return;
496
+ if (ret === false) return {
497
+ id: specifier,
498
+ external: true,
499
+ normalizeExternalId: true
500
+ };
501
+ if (typeof ret === "string") return {
502
+ id: ret,
503
+ normalizeExternalId: false
504
+ };
505
+ let exist = args.pluginContextData.updateModuleOption(ret.id, {
506
+ meta: ret.meta || {},
507
+ moduleSideEffects: ret.moduleSideEffects ?? null,
508
+ invalidate: false
509
+ });
510
+ return {
511
+ id: ret.id,
512
+ external: ret.external,
513
+ normalizeExternalId: false,
514
+ moduleSideEffects: exist.moduleSideEffects ?? void 0,
515
+ packageJsonPath: ret.packageJsonPath
516
+ };
517
+ },
518
+ meta: bindingifyPluginHookMeta(meta),
519
+ filter: bindingifyResolveIdFilter(options.filter)
520
+ };
521
+ }
522
+ function bindingifyResolveDynamicImport(args) {
523
+ const hook = args.plugin.resolveDynamicImport;
524
+ if (!hook) return {};
525
+ const { handler, meta } = normalizeHook(hook);
526
+ return {
527
+ plugin: async (ctx, specifier, importer) => {
528
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0);
529
+ if (ret == null) return;
530
+ if (ret === false) return {
531
+ id: specifier,
532
+ external: true
533
+ };
534
+ if (typeof ret === "string") return { id: ret };
535
+ const result = {
536
+ id: ret.id,
537
+ external: ret.external,
538
+ packageJsonPath: ret.packageJsonPath
539
+ };
540
+ if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
541
+ args.pluginContextData.updateModuleOption(ret.id, {
542
+ meta: ret.meta || {},
543
+ moduleSideEffects: ret.moduleSideEffects || null,
544
+ invalidate: false
545
+ });
546
+ return result;
547
+ },
548
+ meta: bindingifyPluginHookMeta(meta)
549
+ };
550
+ }
551
+ function bindingifyTransform(args) {
552
+ const hook = args.plugin.transform;
553
+ if (!hook) return {};
554
+ const { handler, meta, options } = normalizeHook(hook);
555
+ return {
556
+ plugin: async (ctx, code$1, id$1, meta$1) => {
557
+ let magicStringInstance, astInstance;
558
+ Object.defineProperties(meta$1, {
559
+ magicString: { get() {
560
+ if (magicStringInstance) return magicStringInstance;
561
+ magicStringInstance = new BindingMagicString(code$1);
562
+ return magicStringInstance;
563
+ } },
564
+ ast: { get() {
565
+ if (astInstance) return astInstance;
566
+ let lang = "js";
567
+ switch (meta$1.moduleType) {
568
+ case "js":
569
+ case "jsx":
570
+ case "ts":
571
+ case "tsx":
572
+ lang = meta$1.moduleType;
573
+ break;
574
+ default: break;
575
+ }
576
+ astInstance = parseAst(code$1, {
577
+ astType: meta$1.moduleType.includes("ts") ? "ts" : "js",
578
+ lang
579
+ });
580
+ return astInstance;
581
+ } }
582
+ });
583
+ const transformCtx = new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id$1, code$1, args.onLog, args.logLevel, args.watchMode);
584
+ const ret = await handler.call(transformCtx, code$1, id$1, meta$1);
585
+ if (ret == null) return;
586
+ if (typeof ret === "string") return { code: ret };
587
+ let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
588
+ meta: ret.meta ?? {},
589
+ moduleSideEffects: ret.moduleSideEffects ?? null,
590
+ invalidate: false
591
+ });
592
+ let normalizedCode = void 0;
593
+ let map = ret.map;
594
+ if (typeof ret.code === "string") normalizedCode = ret.code;
595
+ else if (ret.code instanceof BindingMagicString) {
596
+ let magicString = ret.code;
597
+ normalizedCode = magicString.toString();
598
+ let fallbackSourcemap = ctx.sendMagicString(magicString);
599
+ if (fallbackSourcemap != void 0) map = fallbackSourcemap;
600
+ }
601
+ return {
602
+ code: normalizedCode,
603
+ map: bindingifySourcemap(normalizeTransformHookSourcemap(id$1, code$1, map)),
604
+ moduleSideEffects: moduleOption.moduleSideEffects ?? void 0,
605
+ moduleType: ret.moduleType
606
+ };
607
+ },
608
+ meta: bindingifyPluginHookMeta(meta),
609
+ filter: bindingifyTransformFilter(options.filter)
610
+ };
611
+ }
612
+ function bindingifyLoad(args) {
613
+ const hook = args.plugin.load;
614
+ if (!hook) return {};
615
+ const { handler, meta, options } = normalizeHook(hook);
616
+ return {
617
+ plugin: async (ctx, id$1) => {
618
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id$1), id$1);
619
+ if (ret == null) return;
620
+ if (typeof ret === "string") return { code: ret };
621
+ let moduleOption = args.pluginContextData.updateModuleOption(id$1, {
622
+ meta: ret.meta || {},
623
+ moduleSideEffects: ret.moduleSideEffects ?? null,
624
+ invalidate: false
625
+ });
626
+ let map = preProcessSourceMap(ret, id$1);
627
+ return {
628
+ code: ret.code,
629
+ map: bindingifySourcemap(map),
630
+ moduleType: ret.moduleType,
631
+ moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
632
+ };
633
+ },
634
+ meta: bindingifyPluginHookMeta(meta),
635
+ filter: bindingifyLoadFilter(options.filter)
636
+ };
637
+ }
638
+ function preProcessSourceMap(ret, id$1) {
639
+ if (!ret.map) return;
640
+ let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
641
+ if (!isEmptySourcemapFiled(map.sources)) {
642
+ const directory = path.dirname(id$1) || ".";
643
+ const sourceRoot = map.sourceRoot || ".";
644
+ map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
645
+ }
646
+ return map;
647
+ }
648
+ function bindingifyModuleParsed(args) {
649
+ const hook = args.plugin.moduleParsed;
650
+ if (!hook) return {};
651
+ const { handler, meta } = normalizeHook(hook);
652
+ return {
653
+ plugin: async (ctx, moduleInfo) => {
654
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
655
+ },
656
+ meta: bindingifyPluginHookMeta(meta)
657
+ };
658
+ }
659
+
660
+ //#endregion
661
+ //#region src/plugin/bindingify-output-hooks.ts
662
+ function bindingifyRenderStart(args) {
663
+ const hook = args.plugin.renderStart;
664
+ if (!hook) return {};
665
+ const { handler, meta } = normalizeHook(hook);
666
+ return {
667
+ plugin: async (ctx, opts) => {
668
+ handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getInputOptions(opts));
669
+ },
670
+ meta: bindingifyPluginHookMeta(meta)
671
+ };
672
+ }
673
+ function bindingifyRenderChunk(args) {
674
+ const hook = args.plugin.renderChunk;
675
+ if (!hook) return {};
676
+ const { handler, meta, options } = normalizeHook(hook);
677
+ return {
678
+ plugin: async (ctx, code$1, chunk, opts, meta$1) => {
679
+ if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta$1.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
680
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code$1, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getRenderChunkMeta());
681
+ if (ret == null) return;
682
+ if (typeof ret === "string") return { code: ret };
683
+ if (!ret.map) return { code: ret.code };
684
+ return {
685
+ code: ret.code,
686
+ map: bindingifySourcemap(ret.map)
687
+ };
688
+ },
689
+ meta: bindingifyPluginHookMeta(meta),
690
+ filter: bindingifyRenderChunkFilter(options.filter)
691
+ };
692
+ }
693
+ function bindingifyAugmentChunkHash(args) {
694
+ const hook = args.plugin.augmentChunkHash;
695
+ if (!hook) return {};
696
+ const { handler, meta } = normalizeHook(hook);
697
+ return {
698
+ plugin: async (ctx, chunk) => {
699
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
700
+ },
701
+ meta: bindingifyPluginHookMeta(meta)
702
+ };
703
+ }
704
+ function bindingifyRenderError(args) {
705
+ const hook = args.plugin.renderError;
706
+ if (!hook) return {};
707
+ const { handler, meta } = normalizeHook(hook);
708
+ return {
709
+ plugin: async (ctx, err) => {
710
+ handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
711
+ },
712
+ meta: bindingifyPluginHookMeta(meta)
713
+ };
714
+ }
715
+ function bindingifyGenerateBundle(args) {
716
+ const hook = args.plugin.generateBundle;
717
+ if (!hook) return {};
718
+ const { handler, meta } = normalizeHook(hook);
719
+ return {
720
+ plugin: async (ctx, bundle, isWrite, opts) => {
721
+ const changed = {
722
+ updated: /* @__PURE__ */ new Set(),
723
+ deleted: /* @__PURE__ */ new Set()
724
+ };
725
+ const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
726
+ const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
727
+ await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
728
+ return collectChangedBundle(changed, output);
729
+ },
730
+ meta: bindingifyPluginHookMeta(meta)
731
+ };
732
+ }
733
+ function bindingifyWriteBundle(args) {
734
+ const hook = args.plugin.writeBundle;
735
+ if (!hook) return {};
736
+ const { handler, meta } = normalizeHook(hook);
737
+ return {
738
+ plugin: async (ctx, bundle, opts) => {
739
+ const changed = {
740
+ updated: /* @__PURE__ */ new Set(),
741
+ deleted: /* @__PURE__ */ new Set()
742
+ };
743
+ const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
744
+ const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
745
+ await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
746
+ return collectChangedBundle(changed, output);
747
+ },
748
+ meta: bindingifyPluginHookMeta(meta)
749
+ };
750
+ }
751
+ function bindingifyCloseBundle(args) {
752
+ const hook = args.plugin.closeBundle;
753
+ if (!hook) return {};
754
+ const { handler, meta } = normalizeHook(hook);
755
+ return {
756
+ plugin: async (ctx) => {
757
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
758
+ },
759
+ meta: bindingifyPluginHookMeta(meta)
760
+ };
761
+ }
762
+ function bindingifyBanner(args) {
763
+ const hook = args.plugin.banner;
764
+ if (!hook) return {};
765
+ const { handler, meta } = normalizeHook(hook);
766
+ return {
767
+ plugin: async (ctx, chunk) => {
768
+ if (typeof handler === "string") return handler;
769
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
770
+ },
771
+ meta: bindingifyPluginHookMeta(meta)
772
+ };
773
+ }
774
+ function bindingifyFooter(args) {
775
+ const hook = args.plugin.footer;
776
+ if (!hook) return {};
777
+ const { handler, meta } = normalizeHook(hook);
778
+ return {
779
+ plugin: async (ctx, chunk) => {
780
+ if (typeof handler === "string") return handler;
781
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
782
+ },
783
+ meta: bindingifyPluginHookMeta(meta)
784
+ };
785
+ }
786
+ function bindingifyIntro(args) {
787
+ const hook = args.plugin.intro;
788
+ if (!hook) return {};
789
+ const { handler, meta } = normalizeHook(hook);
790
+ return {
791
+ plugin: async (ctx, chunk) => {
792
+ if (typeof handler === "string") return handler;
793
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
794
+ },
795
+ meta: bindingifyPluginHookMeta(meta)
796
+ };
797
+ }
798
+ function bindingifyOutro(args) {
799
+ const hook = args.plugin.outro;
800
+ if (!hook) return {};
801
+ const { handler, meta } = normalizeHook(hook);
802
+ return {
803
+ plugin: async (ctx, chunk) => {
804
+ if (typeof handler === "string") return handler;
805
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
806
+ },
807
+ meta: bindingifyPluginHookMeta(meta)
808
+ };
809
+ }
810
+
811
+ //#endregion
812
+ //#region src/plugin/bindingify-watch-hooks.ts
813
+ function bindingifyWatchChange(args) {
814
+ const hook = args.plugin.watchChange;
815
+ if (!hook) return {};
816
+ const { handler, meta } = normalizeHook(hook);
817
+ return {
818
+ plugin: async (ctx, id$1, event) => {
819
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id$1, { event });
820
+ },
821
+ meta: bindingifyPluginHookMeta(meta)
822
+ };
823
+ }
824
+ function bindingifyCloseWatcher(args) {
825
+ const hook = args.plugin.closeWatcher;
826
+ if (!hook) return {};
827
+ const { handler, meta } = normalizeHook(hook);
828
+ return {
829
+ plugin: async (ctx) => {
830
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
831
+ },
832
+ meta: bindingifyPluginHookMeta(meta)
833
+ };
834
+ }
835
+
836
+ //#endregion
837
+ //#region src/plugin/generated/hook-usage.ts
838
+ let HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
839
+ HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
840
+ HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
841
+ HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
842
+ HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
843
+ HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
844
+ HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
845
+ HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
846
+ HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
847
+ HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
848
+ HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
849
+ HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
850
+ HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
851
+ HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
852
+ HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
853
+ HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
854
+ HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
855
+ HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
856
+ HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
857
+ HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
858
+ HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
859
+ HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
860
+ return HookUsageKind$1;
861
+ }({});
862
+ var HookUsage = class {
863
+ bitflag = BigInt(0);
864
+ constructor() {}
865
+ union(kind) {
866
+ this.bitflag |= BigInt(kind);
867
+ }
868
+ inner() {
869
+ return Number(this.bitflag);
870
+ }
871
+ };
872
+ function extractHookUsage(plugin) {
873
+ let hookUsage = new HookUsage();
874
+ if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
875
+ if (plugin.resolveId) hookUsage.union(HookUsageKind.resolveId);
876
+ if (plugin.resolveDynamicImport) hookUsage.union(HookUsageKind.resolveDynamicImport);
877
+ if (plugin.load) hookUsage.union(HookUsageKind.load);
878
+ if (plugin.transform) hookUsage.union(HookUsageKind.transform);
879
+ if (plugin.moduleParsed) hookUsage.union(HookUsageKind.moduleParsed);
880
+ if (plugin.buildEnd) hookUsage.union(HookUsageKind.buildEnd);
881
+ if (plugin.renderStart) hookUsage.union(HookUsageKind.renderStart);
882
+ if (plugin.renderError) hookUsage.union(HookUsageKind.renderError);
883
+ if (plugin.renderChunk) hookUsage.union(HookUsageKind.renderChunk);
884
+ if (plugin.augmentChunkHash) hookUsage.union(HookUsageKind.augmentChunkHash);
885
+ if (plugin.generateBundle) hookUsage.union(HookUsageKind.generateBundle);
886
+ if (plugin.writeBundle) hookUsage.union(HookUsageKind.writeBundle);
887
+ if (plugin.closeBundle) hookUsage.union(HookUsageKind.closeBundle);
888
+ if (plugin.watchChange) hookUsage.union(HookUsageKind.watchChange);
889
+ if (plugin.closeWatcher) hookUsage.union(HookUsageKind.closeWatcher);
890
+ if (plugin.banner) hookUsage.union(HookUsageKind.banner);
891
+ if (plugin.footer) hookUsage.union(HookUsageKind.footer);
892
+ if (plugin.intro) hookUsage.union(HookUsageKind.intro);
893
+ if (plugin.outro) hookUsage.union(HookUsageKind.outro);
894
+ return hookUsage;
895
+ }
896
+
897
+ //#endregion
898
+ //#region src/plugin/bindingify-plugin.ts
899
+ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
900
+ const args = {
901
+ plugin,
902
+ options,
903
+ outputOptions,
904
+ pluginContextData,
905
+ onLog,
906
+ logLevel,
907
+ watchMode,
908
+ normalizedOutputPlugins
909
+ };
910
+ const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
911
+ const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
912
+ const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
913
+ const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
914
+ const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
915
+ const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
916
+ const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
917
+ const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
918
+ const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
919
+ const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
920
+ const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
921
+ const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
922
+ const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
923
+ const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
924
+ const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
925
+ const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
926
+ const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
927
+ const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
928
+ const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
929
+ const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
930
+ let hookUsage = extractHookUsage(plugin).inner();
931
+ return wrapHandlers({
932
+ name: plugin.name,
933
+ buildStart,
934
+ buildStartMeta,
935
+ resolveId,
936
+ resolveIdMeta,
937
+ resolveIdFilter,
938
+ resolveDynamicImport,
939
+ resolveDynamicImportMeta,
940
+ buildEnd,
941
+ buildEndMeta,
942
+ transform,
943
+ transformMeta,
944
+ transformFilter,
945
+ moduleParsed,
946
+ moduleParsedMeta,
947
+ load,
948
+ loadMeta,
949
+ loadFilter,
950
+ renderChunk,
951
+ renderChunkMeta,
952
+ renderChunkFilter,
953
+ augmentChunkHash,
954
+ augmentChunkHashMeta,
955
+ renderStart,
956
+ renderStartMeta,
957
+ renderError,
958
+ renderErrorMeta,
959
+ generateBundle,
960
+ generateBundleMeta,
961
+ writeBundle,
962
+ writeBundleMeta,
963
+ closeBundle,
964
+ closeBundleMeta,
965
+ banner,
966
+ bannerMeta,
967
+ footer,
968
+ footerMeta,
969
+ intro,
970
+ introMeta,
971
+ outro,
972
+ outroMeta,
973
+ watchChange,
974
+ watchChangeMeta,
975
+ closeWatcher,
976
+ closeWatcherMeta,
977
+ hookUsage
978
+ });
979
+ }
980
+ function wrapHandlers(plugin) {
981
+ for (const hookName of [
982
+ "buildStart",
983
+ "resolveId",
984
+ "resolveDynamicImport",
985
+ "buildEnd",
986
+ "transform",
987
+ "moduleParsed",
988
+ "load",
989
+ "renderChunk",
990
+ "augmentChunkHash",
991
+ "renderStart",
992
+ "renderError",
993
+ "generateBundle",
994
+ "writeBundle",
995
+ "closeBundle",
996
+ "banner",
997
+ "footer",
998
+ "intro",
999
+ "outro",
1000
+ "watchChange",
1001
+ "closeWatcher"
1002
+ ]) {
1003
+ const handler = plugin[hookName];
1004
+ if (handler) plugin[hookName] = async (...args) => {
1005
+ try {
1006
+ return await handler(...args);
1007
+ } catch (e$1) {
1008
+ return error(logPluginError(e$1, plugin.name, {
1009
+ hook: hookName,
1010
+ id: hookName === "transform" ? args[2] : void 0
1011
+ }));
1012
+ }
1013
+ };
1014
+ }
1015
+ return plugin;
1016
+ }
1017
+
1018
+ //#endregion
1019
+ //#region src/options/normalized-input-options.ts
1020
+ var NormalizedInputOptionsImpl = class extends PlainObjectLike {
1021
+ inner;
1022
+ constructor(inner, onLog) {
1023
+ super();
1024
+ this.onLog = onLog;
1025
+ this.inner = inner;
1026
+ }
1027
+ get shimMissingExports() {
1028
+ return this.inner.shimMissingExports;
1029
+ }
1030
+ get input() {
1031
+ return this.inner.input;
1032
+ }
1033
+ get cwd() {
1034
+ return this.inner.cwd ?? void 0;
1035
+ }
1036
+ get platform() {
1037
+ return this.inner.platform;
1038
+ }
1039
+ get context() {
1040
+ return this.inner.context;
1041
+ }
1042
+ };
1043
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
1044
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
1045
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
1046
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
1047
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
1048
+
1049
+ //#endregion
1050
+ //#region src/options/normalized-output-options.ts
1051
+ var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
1052
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
1053
+ super();
1054
+ this.inner = inner;
1055
+ this.outputOptions = outputOptions;
1056
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
1057
+ }
1058
+ get dir() {
1059
+ return this.inner.dir ?? void 0;
1060
+ }
1061
+ get entryFileNames() {
1062
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
1063
+ }
1064
+ get chunkFileNames() {
1065
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
1066
+ }
1067
+ get assetFileNames() {
1068
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
1069
+ }
1070
+ get format() {
1071
+ return this.inner.format;
1072
+ }
1073
+ get exports() {
1074
+ return this.inner.exports;
1075
+ }
1076
+ get sourcemap() {
1077
+ return this.inner.sourcemap;
1078
+ }
1079
+ get sourcemapBaseUrl() {
1080
+ return this.inner.sourcemapBaseUrl ?? void 0;
1081
+ }
1082
+ get cssEntryFileNames() {
1083
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
1084
+ }
1085
+ get cssChunkFileNames() {
1086
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
1087
+ }
1088
+ get shimMissingExports() {
1089
+ return this.inner.shimMissingExports;
1090
+ }
1091
+ get name() {
1092
+ return this.inner.name ?? void 0;
1093
+ }
1094
+ get file() {
1095
+ return this.inner.file ?? void 0;
1096
+ }
1097
+ get inlineDynamicImports() {
1098
+ return this.inner.inlineDynamicImports;
1099
+ }
1100
+ get externalLiveBindings() {
1101
+ return this.inner.externalLiveBindings;
1102
+ }
1103
+ get banner() {
1104
+ return normalizeAddon(this.outputOptions.banner);
1105
+ }
1106
+ get footer() {
1107
+ return normalizeAddon(this.outputOptions.footer);
1108
+ }
1109
+ get intro() {
1110
+ return normalizeAddon(this.outputOptions.intro);
1111
+ }
1112
+ get outro() {
1113
+ return normalizeAddon(this.outputOptions.outro);
1114
+ }
1115
+ get esModule() {
1116
+ return this.inner.esModule;
1117
+ }
1118
+ get extend() {
1119
+ return this.inner.extend;
1120
+ }
1121
+ get globals() {
1122
+ return this.inner.globals || this.outputOptions.globals;
1123
+ }
1124
+ get paths() {
1125
+ return this.outputOptions.paths;
1126
+ }
1127
+ get hashCharacters() {
1128
+ return this.inner.hashCharacters;
1129
+ }
1130
+ get sourcemapDebugIds() {
1131
+ return this.inner.sourcemapDebugIds;
1132
+ }
1133
+ get sourcemapIgnoreList() {
1134
+ return this.outputOptions.sourcemapIgnoreList;
1135
+ }
1136
+ get sourcemapPathTransform() {
1137
+ return this.outputOptions.sourcemapPathTransform;
1138
+ }
1139
+ get minify() {
1140
+ let ret = this.inner.minify;
1141
+ if (typeof ret === "object" && ret !== null) {
1142
+ delete ret["codegen"];
1143
+ delete ret["module"];
1144
+ delete ret["sourcemap"];
1145
+ }
1146
+ return ret;
1147
+ }
1148
+ get legalComments() {
1149
+ return this.inner.legalComments;
1150
+ }
1151
+ get polyfillRequire() {
1152
+ return this.inner.polyfillRequire;
1153
+ }
1154
+ get plugins() {
1155
+ return this.normalizedOutputPlugins;
1156
+ }
1157
+ get preserveModules() {
1158
+ return this.inner.preserveModules;
1159
+ }
1160
+ get preserveModulesRoot() {
1161
+ return this.inner.preserveModulesRoot;
1162
+ }
1163
+ get virtualDirname() {
1164
+ return this.inner.virtualDirname;
1165
+ }
1166
+ get topLevelVar() {
1167
+ return this.inner.topLevelVar ?? false;
1168
+ }
1169
+ get minifyInternalExports() {
1170
+ return this.inner.minifyInternalExports ?? false;
1171
+ }
1172
+ };
1173
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
1174
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
1175
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
1176
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
1177
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
1178
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
1179
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
1180
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
1181
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssEntryFileNames", null);
1182
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssChunkFileNames", null);
1183
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
1184
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
1185
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
1186
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
1187
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
1188
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
1189
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
1190
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
1191
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
1192
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
1193
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
1194
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
1195
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
1196
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
1197
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
1198
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
1199
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
1200
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
1201
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
1202
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
1203
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
1204
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
1205
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
1206
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
1207
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
1208
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
1209
+ function normalizeAddon(value) {
1210
+ if (typeof value === "function") return value;
1211
+ return () => value || "";
1212
+ }
1213
+
1214
+ //#endregion
1215
+ //#region src/plugin/plugin-context-data.ts
1216
+ var PluginContextData = class {
1217
+ moduleOptionMap = /* @__PURE__ */ new Map();
1218
+ resolveOptionsMap = /* @__PURE__ */ new Map();
1219
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
1220
+ renderedChunkMeta = null;
1221
+ normalizedInputOptions = null;
1222
+ normalizedOutputOptions = null;
1223
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
1224
+ this.onLog = onLog;
1225
+ this.outputOptions = outputOptions;
1226
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
1227
+ }
1228
+ updateModuleOption(id$1, option) {
1229
+ const existing = this.moduleOptionMap.get(id$1);
1230
+ if (existing) {
1231
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
1232
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
1233
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
1234
+ } else {
1235
+ this.moduleOptionMap.set(id$1, option);
1236
+ return option;
1237
+ }
1238
+ return existing;
1239
+ }
1240
+ getModuleOption(id$1) {
1241
+ const option = this.moduleOptionMap.get(id$1);
1242
+ if (!option) {
1243
+ const raw = {
1244
+ moduleSideEffects: null,
1245
+ meta: {}
1246
+ };
1247
+ this.moduleOptionMap.set(id$1, raw);
1248
+ return raw;
1249
+ }
1250
+ return option;
1251
+ }
1252
+ getModuleInfo(id$1, context) {
1253
+ const bindingInfo = context.getModuleInfo(id$1);
1254
+ if (bindingInfo) {
1255
+ const info = transformModuleInfo(bindingInfo, this.getModuleOption(id$1));
1256
+ return this.proxyModuleInfo(id$1, info);
1257
+ }
1258
+ return null;
1259
+ }
1260
+ proxyModuleInfo(id$1, info) {
1261
+ let moduleSideEffects = info.moduleSideEffects;
1262
+ Object.defineProperty(info, "moduleSideEffects", {
1263
+ get() {
1264
+ return moduleSideEffects;
1265
+ },
1266
+ set: (v) => {
1267
+ this.updateModuleOption(id$1, {
1268
+ moduleSideEffects: v,
1269
+ meta: info.meta,
1270
+ invalidate: true
1271
+ });
1272
+ moduleSideEffects = v;
1273
+ }
1274
+ });
1275
+ return info;
1276
+ }
1277
+ getModuleIds(context) {
1278
+ return context.getModuleIds().values();
1279
+ }
1280
+ saveResolveOptions(options) {
1281
+ const index = this.resolveOptionsMap.size;
1282
+ this.resolveOptionsMap.set(index, options);
1283
+ return index;
1284
+ }
1285
+ getSavedResolveOptions(receipt) {
1286
+ return this.resolveOptionsMap.get(receipt);
1287
+ }
1288
+ removeSavedResolveOptions(receipt) {
1289
+ this.resolveOptionsMap.delete(receipt);
1290
+ }
1291
+ setRenderChunkMeta(meta) {
1292
+ this.renderedChunkMeta = meta;
1293
+ }
1294
+ getRenderChunkMeta() {
1295
+ return this.renderedChunkMeta;
1296
+ }
1297
+ getInputOptions(opts) {
1298
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
1299
+ return this.normalizedInputOptions;
1300
+ }
1301
+ getOutputOptions(opts) {
1302
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
1303
+ return this.normalizedOutputOptions;
1304
+ }
1305
+ clear() {
1306
+ this.renderedChunkMeta = null;
1307
+ this.loadModulePromiseMap.clear();
1308
+ }
1309
+ };
1310
+
1311
+ //#endregion
1312
+ //#region src/utils/normalize-transform-options.ts
1313
+ /**
1314
+ * Normalizes transform options by extracting `define`, `inject`, and `dropLabels` separately from OXC transform options.
1315
+ *
1316
+ * Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
1317
+ */
1318
+ function normalizeTransformOptions(inputOptions) {
1319
+ const transform = inputOptions.transform;
1320
+ const define = transform?.define ? Object.entries(transform.define) : void 0;
1321
+ const inject = transform?.inject;
1322
+ const dropLabels = transform?.dropLabels;
1323
+ let oxcTransformOptions;
1324
+ if (transform) {
1325
+ const { define: _define, inject: _inject, dropLabels: _dropLabels, ...rest } = transform;
1326
+ if (Object.keys(rest).length > 0) {
1327
+ if (rest.jsx === false) rest.jsx = "disable";
1328
+ oxcTransformOptions = rest;
1329
+ }
1330
+ }
1331
+ return {
1332
+ define,
1333
+ inject,
1334
+ dropLabels,
1335
+ oxcTransformOptions
1336
+ };
1337
+ }
1338
+
1339
+ //#endregion
1340
+ //#region src/utils/bindingify-input-options.ts
1341
+ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
1342
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
1343
+ const plugins = rawPlugins.map((plugin) => {
1344
+ if ("_parallel" in plugin) return;
1345
+ if (plugin instanceof BuiltinPlugin) {
1346
+ if (plugin.name === "builtin:vite-html") return bindingifyViteHtmlPlugin(plugin, onLog, logLevel, watchMode);
1347
+ return bindingifyBuiltInPlugin(plugin);
1348
+ }
1349
+ return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
1350
+ });
1351
+ const normalizedTransform = normalizeTransformOptions(inputOptions);
1352
+ return {
1353
+ input: bindingifyInput(inputOptions.input),
1354
+ plugins,
1355
+ cwd: inputOptions.cwd ?? process.cwd(),
1356
+ external: bindingifyExternal(inputOptions.external),
1357
+ resolve: bindingifyResolve(inputOptions.resolve),
1358
+ platform: inputOptions.platform,
1359
+ shimMissingExports: inputOptions.shimMissingExports,
1360
+ logLevel: bindingifyLogLevel(logLevel),
1361
+ onLog: async (level, log) => onLog(level, log),
1362
+ treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
1363
+ moduleTypes: inputOptions.moduleTypes,
1364
+ define: normalizedTransform.define,
1365
+ inject: bindingifyInject(normalizedTransform.inject),
1366
+ experimental: bindingifyExperimental(inputOptions.experimental),
1367
+ profilerNames: outputOptions.generatedCode?.profilerNames,
1368
+ transform: normalizedTransform.oxcTransformOptions,
1369
+ watch: bindingifyWatch(inputOptions.watch),
1370
+ dropLabels: normalizedTransform.dropLabels,
1371
+ keepNames: outputOptions.keepNames,
1372
+ checks: inputOptions.checks,
1373
+ deferSyncScanData: () => {
1374
+ let ret = [];
1375
+ pluginContextData.moduleOptionMap.forEach((value, key) => {
1376
+ if (value.invalidate) ret.push({
1377
+ id: key,
1378
+ sideEffects: value.moduleSideEffects ?? void 0
1379
+ });
1380
+ });
1381
+ return ret;
1382
+ },
1383
+ makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
1384
+ debug: inputOptions.debug,
1385
+ invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
1386
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
1387
+ optimization: inputOptions.optimization,
1388
+ context: inputOptions.context,
1389
+ tsconfig: inputOptions.resolve?.tsconfigFilename ?? inputOptions.tsconfig
1390
+ };
1391
+ }
1392
+ function bindingifyHmr(hmr) {
1393
+ if (hmr) {
1394
+ if (typeof hmr === "boolean") return hmr ? {} : void 0;
1395
+ return hmr;
1396
+ }
1397
+ }
1398
+ function bindingifyAttachDebugInfo(attachDebugInfo) {
1399
+ switch (attachDebugInfo) {
1400
+ case void 0: return;
1401
+ case "full": return BindingAttachDebugInfo.Full;
1402
+ case "simple": return BindingAttachDebugInfo.Simple;
1403
+ case "none": return BindingAttachDebugInfo.None;
1404
+ }
1405
+ }
1406
+ function bindingifyExternal(external) {
1407
+ if (external) {
1408
+ if (typeof external === "function") return (id$1, importer, isResolved) => {
1409
+ if (id$1.startsWith("\0")) return false;
1410
+ return external(id$1, importer, isResolved) ?? false;
1411
+ };
1412
+ return arraify(external);
1413
+ }
1414
+ }
1415
+ function bindingifyExperimental(experimental) {
1416
+ let chunkModulesOrder = BindingChunkModuleOrderBy.ExecOrder;
1417
+ if (experimental?.chunkModulesOrder) switch (experimental.chunkModulesOrder) {
1418
+ case "exec-order":
1419
+ chunkModulesOrder = BindingChunkModuleOrderBy.ExecOrder;
1420
+ break;
1421
+ case "module-id":
1422
+ chunkModulesOrder = BindingChunkModuleOrderBy.ModuleId;
1423
+ break;
1424
+ default: throw new Error(`Unexpected chunkModulesOrder: ${experimental.chunkModulesOrder}`);
1425
+ }
1426
+ return {
1427
+ strictExecutionOrder: experimental?.strictExecutionOrder,
1428
+ disableLiveBindings: experimental?.disableLiveBindings,
1429
+ viteMode: experimental?.viteMode,
1430
+ resolveNewUrlToAsset: experimental?.resolveNewUrlToAsset,
1431
+ hmr: bindingifyHmr(experimental?.hmr),
1432
+ attachDebugInfo: bindingifyAttachDebugInfo(experimental?.attachDebugInfo),
1433
+ chunkModulesOrder,
1434
+ chunkImportMap: experimental?.chunkImportMap,
1435
+ onDemandWrapping: experimental?.onDemandWrapping,
1436
+ incrementalBuild: experimental?.incrementalBuild,
1437
+ nativeMagicString: experimental?.nativeMagicString
1438
+ };
1439
+ }
1440
+ function bindingifyResolve(resolve) {
1441
+ const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
1442
+ if (resolve) {
1443
+ const { alias, extensionAlias, ...rest } = resolve;
1444
+ return {
1445
+ alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
1446
+ find: name,
1447
+ replacements: replacement === false ? [void 0] : arraify(replacement)
1448
+ })) : void 0,
1449
+ extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
1450
+ target: name,
1451
+ replacements: value
1452
+ })) : void 0,
1453
+ yarnPnp,
1454
+ ...rest
1455
+ };
1456
+ } else return { yarnPnp };
1457
+ }
1458
+ function bindingifyInject(inject) {
1459
+ if (inject) return Object.entries(inject).map(([alias, item]) => {
1460
+ if (Array.isArray(item)) {
1461
+ if (item[1] === "*") return {
1462
+ tagNamespace: true,
1463
+ alias,
1464
+ from: item[0]
1465
+ };
1466
+ return {
1467
+ tagNamed: true,
1468
+ alias,
1469
+ from: item[0],
1470
+ imported: item[1]
1471
+ };
1472
+ } else return {
1473
+ tagNamed: true,
1474
+ imported: "default",
1475
+ alias,
1476
+ from: item
1477
+ };
1478
+ });
1479
+ }
1480
+ function bindingifyLogLevel(logLevel) {
1481
+ switch (logLevel) {
1482
+ case "silent": return BindingLogLevel.Silent;
1483
+ case "debug": return BindingLogLevel.Debug;
1484
+ case "warn": return BindingLogLevel.Warn;
1485
+ case "info": return BindingLogLevel.Info;
1486
+ default: throw new Error(`Unexpected log level: ${logLevel}`);
1487
+ }
1488
+ }
1489
+ function bindingifyInput(input) {
1490
+ if (input === void 0) return [];
1491
+ if (typeof input === "string") return [{ import: input }];
1492
+ if (Array.isArray(input)) return input.map((src) => ({ import: src }));
1493
+ return Object.entries(input).map(([name, import_path]) => {
1494
+ return {
1495
+ name,
1496
+ import: import_path
1497
+ };
1498
+ });
1499
+ }
1500
+ function bindingifyWatch(watch) {
1501
+ if (watch) return {
1502
+ buildDelay: watch.buildDelay,
1503
+ skipWrite: watch.skipWrite,
1504
+ include: normalizedStringOrRegex(watch.include),
1505
+ exclude: normalizedStringOrRegex(watch.exclude),
1506
+ onInvalidate: (...args) => watch.onInvalidate?.(...args)
1507
+ };
1508
+ }
1509
+ function bindingifyTreeshakeOptions(config) {
1510
+ if (config === false) return;
1511
+ if (config === true || config === void 0) return { moduleSideEffects: true };
1512
+ let normalizedConfig = {
1513
+ moduleSideEffects: true,
1514
+ annotations: config.annotations,
1515
+ manualPureFunctions: config.manualPureFunctions,
1516
+ unknownGlobalSideEffects: config.unknownGlobalSideEffects,
1517
+ commonjs: config.commonjs
1518
+ };
1519
+ switch (config.propertyReadSideEffects) {
1520
+ case "always":
1521
+ normalizedConfig.propertyReadSideEffects = BindingPropertyReadSideEffects.Always;
1522
+ break;
1523
+ case false:
1524
+ normalizedConfig.propertyReadSideEffects = BindingPropertyReadSideEffects.False;
1525
+ break;
1526
+ default:
1527
+ }
1528
+ switch (config.propertyWriteSideEffects) {
1529
+ case "always":
1530
+ normalizedConfig.propertyWriteSideEffects = BindingPropertyWriteSideEffects.Always;
1531
+ break;
1532
+ case false:
1533
+ normalizedConfig.propertyWriteSideEffects = BindingPropertyWriteSideEffects.False;
1534
+ break;
1535
+ default:
1536
+ }
1537
+ if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
1538
+ else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
1539
+ external: true,
1540
+ sideEffects: false
1541
+ }, {
1542
+ external: false,
1543
+ sideEffects: true
1544
+ }];
1545
+ else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
1546
+ return normalizedConfig;
1547
+ }
1548
+ function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative) {
1549
+ if (makeAbsoluteExternalsRelative === "ifRelativeSource") return { type: "IfRelativeSource" };
1550
+ if (typeof makeAbsoluteExternalsRelative === "boolean") return {
1551
+ type: "Bool",
1552
+ field0: makeAbsoluteExternalsRelative
1553
+ };
1554
+ }
1555
+ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
1556
+ if (preserveEntrySignatures == void 0) return;
1557
+ else if (typeof preserveEntrySignatures === "string") return {
1558
+ type: "String",
1559
+ field0: preserveEntrySignatures
1560
+ };
1561
+ else return {
1562
+ type: "Bool",
1563
+ field0: preserveEntrySignatures
1564
+ };
1565
+ }
1566
+
1567
+ //#endregion
1568
+ export { aggregateBindingErrorsIntoJsError as a, normalizeHook as c, transformModuleInfo as i, PluginContextData as n, normalizeBindingResult as o, bindingifyPlugin as r, unwrapBindingResult as s, bindingifyInputOptions as t };