@rolldown/browser 1.0.0-beta.9-commit.ca4e9dd → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/cli-setup.mjs +16 -0
  2. package/dist/cli.mjs +1084 -1281
  3. package/dist/config.d.mts +1 -3
  4. package/dist/config.mjs +7 -5
  5. package/dist/constructors-B8gqcrFr.js +61 -0
  6. package/dist/experimental-index.browser.mjs +225 -50
  7. package/dist/experimental-index.d.mts +164 -76
  8. package/dist/experimental-index.mjs +220 -60
  9. package/dist/experimental-runtime-types.d.ts +98 -0
  10. package/dist/filter-index.d.mts +104 -2
  11. package/dist/filter-index.mjs +123 -3
  12. package/dist/get-log-filter.d.mts +7 -0
  13. package/dist/get-log-filter.mjs +48 -0
  14. package/dist/index.browser.mjs +242 -2
  15. package/dist/index.d.mts +4 -3
  16. package/dist/index.mjs +54 -5
  17. package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-CL-PJZI7.js} +70 -137
  18. package/dist/parallel-plugin-worker.mjs +26 -33
  19. package/dist/parallel-plugin.d.mts +7 -7
  20. package/dist/parse-ast-index.d.mts +5 -6
  21. package/dist/parse-ast-index.mjs +1 -2
  22. package/dist/plugins-index.browser.mjs +39 -0
  23. package/dist/plugins-index.d.mts +30 -0
  24. package/dist/plugins-index.mjs +39 -0
  25. package/dist/rolldown-binding.wasi-browser.js +41 -24
  26. package/dist/rolldown-binding.wasi.cjs +62 -24
  27. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  28. package/dist/rolldown-build-C4tDS_XC.js +5055 -0
  29. package/dist/shared/bindingify-input-options-Bp2kpiI8.mjs +2231 -0
  30. package/dist/shared/composable-filters-CIxSuZSM.mjs +227 -0
  31. package/dist/shared/constructors-5bt5oBhE.d.mts +28 -0
  32. package/dist/shared/constructors-BTW-c3jX.mjs +61 -0
  33. package/dist/shared/define-config-CDlEOpr1.d.mts +3531 -0
  34. package/dist/shared/define-config-Dlptvz3X.mjs +7 -0
  35. package/dist/shared/{load-config-vRugYmJ3.mjs → load-config-BBZgIUGN.mjs} +23 -33
  36. package/dist/shared/logging-Nvu645a7.d.mts +50 -0
  37. package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-B2CASPcx.mjs} +21 -116
  38. package/dist/shared/normalize-string-or-regex-DIwprzLy.mjs +60 -0
  39. package/dist/shared/parse-ast-index-2ahkCVK6.mjs +98 -0
  40. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-B6NrDD1-.mjs} +301 -308
  41. package/dist/shared/rolldown-C0_W0QdY.mjs +42 -0
  42. package/dist/shared/rolldown-build-DLuUhuNw.mjs +2368 -0
  43. package/dist/shared/types-CIYK49jr.d.mts +1300 -0
  44. package/dist/shared/utils-CqMTwlsR.d.mts +22 -0
  45. package/dist/shared/watch-eIop0yN6.mjs +378 -0
  46. package/package.json +33 -38
  47. package/dist/cli.cjs +0 -1748
  48. package/dist/config.cjs +0 -12
  49. package/dist/config.d.cts +0 -11
  50. package/dist/experimental-index.cjs +0 -129
  51. package/dist/experimental-index.d.cts +0 -96
  52. package/dist/filter-index.cjs +0 -53
  53. package/dist/filter-index.d.cts +0 -3
  54. package/dist/index.cjs +0 -9
  55. package/dist/index.d.cts +0 -3
  56. package/dist/parallel-plugin-worker.cjs +0 -33
  57. package/dist/parallel-plugin-worker.d.cts +0 -1
  58. package/dist/parallel-plugin.cjs +0 -8
  59. package/dist/parallel-plugin.d.cts +0 -14
  60. package/dist/parse-ast-index.cjs +0 -4
  61. package/dist/parse-ast-index.d.cts +0 -9
  62. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  63. package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
  64. package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
  65. package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
  66. package/dist/shared/dist-BMVjvV-v.cjs +0 -249
  67. package/dist/shared/dist-CAn6dxW6.mjs +0 -153
  68. package/dist/shared/load-config-42uI5RSv.cjs +0 -125
  69. package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
  70. package/dist/shared/src-Cu4_wKhx.mjs +0 -4691
  71. package/dist/shared/src-CzdOBfDC.cjs +0 -4647
  72. package/dist/src-DQ33eKZS.js +0 -4333
  73. /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
@@ -0,0 +1,2231 @@
1
+ import { a as logInvalidLogPosition, c as logPluginError, n as error, r as logCycleLoading, t as augmentCodeLocation } from "./logs-B2CASPcx.mjs";
2
+ import { i as bindingifyManifestPlugin, n as BuiltinPlugin, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-DIwprzLy.mjs";
3
+ import { _ as noop, a as id, b as unsupported, f as or, h as arraify, n as code, r as exclude, s as include, t as and, u as moduleType, y as unreachable } from "./composable-filters-CIxSuZSM.mjs";
4
+ import { t as parseAst } from "./parse-ast-index-2ahkCVK6.mjs";
5
+ import { BindingAttachDebugInfo, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects } from "../rolldown-binding.wasi.cjs";
6
+ import path from "node:path";
7
+ import fsp from "node:fs/promises";
8
+
9
+ //#region package.json
10
+ var version = "1.0.0-rc.1";
11
+ var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
12
+
13
+ //#endregion
14
+ //#region src/version.ts
15
+ /**
16
+ * The version of Rolldown.
17
+ * @example `'1.0.0'`
18
+ *
19
+ * @category Plugin APIs
20
+ */
21
+ const VERSION = version;
22
+
23
+ //#endregion
24
+ //#region src/log/logging.ts
25
+ const LOG_LEVEL_SILENT = "silent";
26
+ const LOG_LEVEL_ERROR = "error";
27
+ const LOG_LEVEL_WARN = "warn";
28
+ const LOG_LEVEL_INFO = "info";
29
+ const LOG_LEVEL_DEBUG = "debug";
30
+ const logLevelPriority = {
31
+ [LOG_LEVEL_DEBUG]: 0,
32
+ [LOG_LEVEL_INFO]: 1,
33
+ [LOG_LEVEL_WARN]: 2,
34
+ [LOG_LEVEL_SILENT]: 3
35
+ };
36
+
37
+ //#endregion
38
+ //#region src/log/log-handler.ts
39
+ const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
40
+ function getLogHandler(level, code, logger, pluginName, logLevel) {
41
+ if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
42
+ return (log, pos) => {
43
+ if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
44
+ log = normalizeLog(log);
45
+ if (log.code && !log.pluginCode) log.pluginCode = log.code;
46
+ log.code = code;
47
+ log.plugin = pluginName;
48
+ logger(level, log);
49
+ };
50
+ }
51
+
52
+ //#endregion
53
+ //#region src/utils/normalize-hook.ts
54
+ function normalizeHook(hook) {
55
+ if (typeof hook === "function" || typeof hook === "string") return {
56
+ handler: hook,
57
+ options: {},
58
+ meta: {}
59
+ };
60
+ if (typeof hook === "object" && hook !== null) {
61
+ const { handler, order, ...options } = hook;
62
+ return {
63
+ handler,
64
+ options,
65
+ meta: { order }
66
+ };
67
+ }
68
+ unreachable("Invalid hook type");
69
+ }
70
+
71
+ //#endregion
72
+ //#region src/plugin/minimal-plugin-context.ts
73
+ var MinimalPluginContextImpl = class {
74
+ info;
75
+ warn;
76
+ debug;
77
+ meta;
78
+ constructor(onLog, logLevel, pluginName, watchMode, hookName) {
79
+ this.pluginName = pluginName;
80
+ this.hookName = hookName;
81
+ this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
82
+ this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
83
+ this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
84
+ this.meta = {
85
+ rollupVersion: "4.23.0",
86
+ rolldownVersion: VERSION,
87
+ watchMode
88
+ };
89
+ }
90
+ error(e) {
91
+ return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
92
+ }
93
+ };
94
+
95
+ //#endregion
96
+ //#region src/types/plain-object-like.ts
97
+ const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
98
+ /**
99
+ * Base class for classes that use `@lazyProp` decorated properties.
100
+ *
101
+ * **Design Pattern in Rolldown:**
102
+ * This is a common pattern in Rolldown due to its three-layer architecture:
103
+ * TypeScript API → NAPI Bindings → Rust Core
104
+ *
105
+ * **Why we use getters:**
106
+ * For performance - to lazily fetch data from Rust bindings only when needed,
107
+ * rather than eagerly fetching all data during object construction.
108
+ *
109
+ * **The problem:**
110
+ * Getters defined on class prototypes are non-enumerable by default, which breaks:
111
+ * - Object spread operators ({...obj})
112
+ * - Object.keys() and similar methods
113
+ * - Standard JavaScript object semantics
114
+ *
115
+ * **The solution:**
116
+ * This base class automatically converts `@lazyProp` decorated getters into
117
+ * own enumerable getters on each instance during construction.
118
+ *
119
+ * **Result:**
120
+ * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * class MyClass extends PlainObjectLike {
125
+ * @lazyProp
126
+ * get myProp() {
127
+ * return fetchFromRustBinding();
128
+ * }
129
+ * }
130
+ * ```
131
+ */
132
+ var PlainObjectLike = class {
133
+ constructor() {
134
+ setupLazyProperties(this);
135
+ }
136
+ };
137
+ /**
138
+ * Set up lazy properties as own getters on an instance.
139
+ * This is called automatically by the `PlainObjectLike` base class constructor.
140
+ *
141
+ * @param instance - The instance to set up lazy properties on
142
+ * @internal
143
+ */
144
+ function setupLazyProperties(instance) {
145
+ const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
146
+ if (!lazyFields) return;
147
+ for (const [propertyKey, originalGetter] of lazyFields.entries()) {
148
+ let cachedValue;
149
+ let hasValue = false;
150
+ Object.defineProperty(instance, propertyKey, {
151
+ get() {
152
+ if (!hasValue) {
153
+ cachedValue = originalGetter.call(this);
154
+ hasValue = true;
155
+ }
156
+ return cachedValue;
157
+ },
158
+ enumerable: true,
159
+ configurable: true
160
+ });
161
+ }
162
+ }
163
+ /**
164
+ * Get all lazy field names from a class instance.
165
+ *
166
+ * @param instance - Instance to inspect
167
+ * @returns Set of lazy property names
168
+ */
169
+ function getLazyFields(instance) {
170
+ const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
171
+ return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
172
+ }
173
+
174
+ //#endregion
175
+ //#region src/decorators/lazy.ts
176
+ /**
177
+ * Decorator that marks a getter as lazy-evaluated and cached.
178
+ *
179
+ * **What "lazy" means here:**
180
+ * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
181
+ * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
182
+ * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
183
+ *
184
+ * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
185
+ * properties on each instance (not on the prototype). This ensures they:
186
+ * - Appear in Object.keys() and Object.getOwnPropertyNames()
187
+ * - Are included in object spreads ({...obj})
188
+ * - Are enumerable in for...in loops
189
+ *
190
+ * Classes using this decorator must extend `PlainObjectLike` base class.
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * class MyClass extends PlainObjectLike {
195
+ * @lazyProp
196
+ * get expensiveValue() {
197
+ * return someExpensiveComputation();
198
+ * }
199
+ * }
200
+ * ```
201
+ */
202
+ function lazyProp(target, propertyKey, descriptor) {
203
+ if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
204
+ const originalGetter = descriptor.get;
205
+ target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
206
+ return {
207
+ enumerable: false,
208
+ configurable: true
209
+ };
210
+ }
211
+
212
+ //#endregion
213
+ //#region src/utils/asset-source.ts
214
+ function transformAssetSource(bindingAssetSource) {
215
+ return bindingAssetSource.inner;
216
+ }
217
+ function bindingAssetSource(source) {
218
+ return { inner: source };
219
+ }
220
+
221
+ //#endregion
222
+ //#region \0@oxc-project+runtime@0.110.0/helpers/decorate.js
223
+ function __decorate(decorators, target, key, desc) {
224
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
225
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
226
+ 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;
227
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
228
+ }
229
+
230
+ //#endregion
231
+ //#region src/types/output-asset-impl.ts
232
+ var OutputAssetImpl = class extends PlainObjectLike {
233
+ type = "asset";
234
+ constructor(bindingAsset) {
235
+ super();
236
+ this.bindingAsset = bindingAsset;
237
+ }
238
+ get fileName() {
239
+ return this.bindingAsset.getFileName();
240
+ }
241
+ get originalFileName() {
242
+ return this.bindingAsset.getOriginalFileName() || null;
243
+ }
244
+ get originalFileNames() {
245
+ return this.bindingAsset.getOriginalFileNames();
246
+ }
247
+ get name() {
248
+ return this.bindingAsset.getName() ?? void 0;
249
+ }
250
+ get names() {
251
+ return this.bindingAsset.getNames();
252
+ }
253
+ get source() {
254
+ return transformAssetSource(this.bindingAsset.getSource());
255
+ }
256
+ __rolldown_external_memory_handle__(keepDataAlive) {
257
+ if (keepDataAlive) this.#evaluateAllLazyFields();
258
+ return this.bindingAsset.dropInner();
259
+ }
260
+ #evaluateAllLazyFields() {
261
+ for (const field of getLazyFields(this)) this[field];
262
+ }
263
+ };
264
+ __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
265
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
266
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
267
+ __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
268
+ __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
269
+ __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
270
+
271
+ //#endregion
272
+ //#region src/utils/transform-rendered-module.ts
273
+ function transformToRenderedModule(bindingRenderedModule) {
274
+ return {
275
+ get code() {
276
+ return bindingRenderedModule.code;
277
+ },
278
+ get renderedLength() {
279
+ return bindingRenderedModule.code?.length || 0;
280
+ },
281
+ get renderedExports() {
282
+ return bindingRenderedModule.renderedExports;
283
+ }
284
+ };
285
+ }
286
+
287
+ //#endregion
288
+ //#region src/utils/transform-rendered-chunk.ts
289
+ function transformRenderedChunk(chunk) {
290
+ let modules = null;
291
+ return {
292
+ type: "chunk",
293
+ get name() {
294
+ return chunk.name;
295
+ },
296
+ get isEntry() {
297
+ return chunk.isEntry;
298
+ },
299
+ get isDynamicEntry() {
300
+ return chunk.isDynamicEntry;
301
+ },
302
+ get facadeModuleId() {
303
+ return chunk.facadeModuleId;
304
+ },
305
+ get moduleIds() {
306
+ return chunk.moduleIds;
307
+ },
308
+ get exports() {
309
+ return chunk.exports;
310
+ },
311
+ get fileName() {
312
+ return chunk.fileName;
313
+ },
314
+ get imports() {
315
+ return chunk.imports;
316
+ },
317
+ get dynamicImports() {
318
+ return chunk.dynamicImports;
319
+ },
320
+ get modules() {
321
+ if (!modules) modules = transformChunkModules(chunk.modules);
322
+ return modules;
323
+ }
324
+ };
325
+ }
326
+ function transformChunkModules(modules) {
327
+ const result = {};
328
+ for (let i = 0; i < modules.values.length; i++) {
329
+ let key = modules.keys[i];
330
+ const mod = modules.values[i];
331
+ result[key] = transformToRenderedModule(mod);
332
+ }
333
+ return result;
334
+ }
335
+
336
+ //#endregion
337
+ //#region src/types/output-chunk-impl.ts
338
+ var OutputChunkImpl = class extends PlainObjectLike {
339
+ type = "chunk";
340
+ constructor(bindingChunk) {
341
+ super();
342
+ this.bindingChunk = bindingChunk;
343
+ }
344
+ get fileName() {
345
+ return this.bindingChunk.getFileName();
346
+ }
347
+ get name() {
348
+ return this.bindingChunk.getName();
349
+ }
350
+ get exports() {
351
+ return this.bindingChunk.getExports();
352
+ }
353
+ get isEntry() {
354
+ return this.bindingChunk.getIsEntry();
355
+ }
356
+ get facadeModuleId() {
357
+ return this.bindingChunk.getFacadeModuleId() || null;
358
+ }
359
+ get isDynamicEntry() {
360
+ return this.bindingChunk.getIsDynamicEntry();
361
+ }
362
+ get sourcemapFileName() {
363
+ return this.bindingChunk.getSourcemapFileName() || null;
364
+ }
365
+ get preliminaryFileName() {
366
+ return this.bindingChunk.getPreliminaryFileName();
367
+ }
368
+ get code() {
369
+ return this.bindingChunk.getCode();
370
+ }
371
+ get modules() {
372
+ return transformChunkModules(this.bindingChunk.getModules());
373
+ }
374
+ get imports() {
375
+ return this.bindingChunk.getImports();
376
+ }
377
+ get dynamicImports() {
378
+ return this.bindingChunk.getDynamicImports();
379
+ }
380
+ get moduleIds() {
381
+ return this.bindingChunk.getModuleIds();
382
+ }
383
+ get map() {
384
+ const mapString = this.bindingChunk.getMap();
385
+ return mapString ? transformToRollupSourceMap(mapString) : null;
386
+ }
387
+ __rolldown_external_memory_handle__(keepDataAlive) {
388
+ if (keepDataAlive) this.#evaluateAllLazyFields();
389
+ return this.bindingChunk.dropInner();
390
+ }
391
+ #evaluateAllLazyFields() {
392
+ for (const field of getLazyFields(this)) this[field];
393
+ }
394
+ };
395
+ __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
396
+ __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
397
+ __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
398
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
399
+ __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
400
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
401
+ __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
402
+ __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
403
+ __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
404
+ __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
405
+ __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
406
+ __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
407
+ __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
408
+ __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
409
+
410
+ //#endregion
411
+ //#region src/types/sourcemap.ts
412
+ function bindingifySourcemap(map) {
413
+ if (map == null) return;
414
+ return { inner: typeof map === "string" ? map : {
415
+ file: map.file ?? void 0,
416
+ mappings: map.mappings,
417
+ sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
418
+ sources: map.sources?.map((s) => s ?? void 0),
419
+ sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
420
+ names: map.names,
421
+ x_google_ignoreList: map.x_google_ignoreList,
422
+ debugId: "debugId" in map ? map.debugId : void 0
423
+ } };
424
+ }
425
+
426
+ //#endregion
427
+ //#region src/utils/transform-to-rollup-output.ts
428
+ function transformToRollupSourceMap(map) {
429
+ const obj = {
430
+ ...JSON.parse(map),
431
+ toString() {
432
+ return JSON.stringify(obj);
433
+ },
434
+ toUrl() {
435
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
436
+ }
437
+ };
438
+ return obj;
439
+ }
440
+ function transformToRollupOutputChunk(bindingChunk) {
441
+ return new OutputChunkImpl(bindingChunk);
442
+ }
443
+ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
444
+ const chunk = {
445
+ type: "chunk",
446
+ get code() {
447
+ return bindingChunk.getCode();
448
+ },
449
+ fileName: bindingChunk.getFileName(),
450
+ name: bindingChunk.getName(),
451
+ get modules() {
452
+ return transformChunkModules(bindingChunk.getModules());
453
+ },
454
+ get imports() {
455
+ return bindingChunk.getImports();
456
+ },
457
+ get dynamicImports() {
458
+ return bindingChunk.getDynamicImports();
459
+ },
460
+ exports: bindingChunk.getExports(),
461
+ isEntry: bindingChunk.getIsEntry(),
462
+ facadeModuleId: bindingChunk.getFacadeModuleId() || null,
463
+ isDynamicEntry: bindingChunk.getIsDynamicEntry(),
464
+ get moduleIds() {
465
+ return bindingChunk.getModuleIds();
466
+ },
467
+ get map() {
468
+ const map = bindingChunk.getMap();
469
+ return map ? transformToRollupSourceMap(map) : null;
470
+ },
471
+ sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
472
+ preliminaryFileName: bindingChunk.getPreliminaryFileName()
473
+ };
474
+ const cache = {};
475
+ return new Proxy(chunk, {
476
+ get(target, p) {
477
+ if (p in cache) return cache[p];
478
+ const value = target[p];
479
+ cache[p] = value;
480
+ return value;
481
+ },
482
+ set(_target, p, newValue) {
483
+ cache[p] = newValue;
484
+ changed.updated.add(bindingChunk.getFileName());
485
+ return true;
486
+ },
487
+ has(target, p) {
488
+ if (p in cache) return true;
489
+ return p in target;
490
+ }
491
+ });
492
+ }
493
+ function transformToRollupOutputAsset(bindingAsset) {
494
+ return new OutputAssetImpl(bindingAsset);
495
+ }
496
+ function transformToMutableRollupOutputAsset(bindingAsset, changed) {
497
+ const asset = {
498
+ type: "asset",
499
+ fileName: bindingAsset.getFileName(),
500
+ originalFileName: bindingAsset.getOriginalFileName() || null,
501
+ originalFileNames: bindingAsset.getOriginalFileNames(),
502
+ get source() {
503
+ return transformAssetSource(bindingAsset.getSource());
504
+ },
505
+ name: bindingAsset.getName() ?? void 0,
506
+ names: bindingAsset.getNames()
507
+ };
508
+ const cache = {};
509
+ return new Proxy(asset, {
510
+ get(target, p) {
511
+ if (p in cache) return cache[p];
512
+ const value = target[p];
513
+ cache[p] = value;
514
+ return value;
515
+ },
516
+ set(_target, p, newValue) {
517
+ cache[p] = newValue;
518
+ changed.updated.add(bindingAsset.getFileName());
519
+ return true;
520
+ }
521
+ });
522
+ }
523
+ function transformToRollupOutput(output) {
524
+ const { chunks, assets } = output;
525
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
526
+ }
527
+ function transformToMutableRollupOutput(output, changed) {
528
+ const { chunks, assets } = output;
529
+ return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
530
+ }
531
+ function transformToOutputBundle(context, output, changed) {
532
+ const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
533
+ return new Proxy(bundle, {
534
+ set(_target, _p, _newValue, _receiver) {
535
+ const originalStackTraceLimit = Error.stackTraceLimit;
536
+ Error.stackTraceLimit = 2;
537
+ 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.";
538
+ const stack = new Error(message).stack ?? message;
539
+ Error.stackTraceLimit = originalStackTraceLimit;
540
+ context.warn({
541
+ message: stack,
542
+ code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
543
+ });
544
+ return true;
545
+ },
546
+ deleteProperty(target, property) {
547
+ if (typeof property === "string") changed.deleted.add(property);
548
+ return true;
549
+ }
550
+ });
551
+ }
552
+ function collectChangedBundle(changed, bundle) {
553
+ const changes = {};
554
+ for (const key in bundle) {
555
+ if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
556
+ const item = bundle[key];
557
+ if (item.type === "asset") changes[key] = {
558
+ filename: item.fileName,
559
+ originalFileNames: item.originalFileNames,
560
+ source: bindingAssetSource(item.source),
561
+ names: item.names
562
+ };
563
+ else changes[key] = {
564
+ code: item.code,
565
+ filename: item.fileName,
566
+ name: item.name,
567
+ isEntry: item.isEntry,
568
+ exports: item.exports,
569
+ modules: {},
570
+ imports: item.imports,
571
+ dynamicImports: item.dynamicImports,
572
+ facadeModuleId: item.facadeModuleId || void 0,
573
+ isDynamicEntry: item.isDynamicEntry,
574
+ moduleIds: item.moduleIds,
575
+ map: bindingifySourcemap(item.map),
576
+ sourcemapFilename: item.sourcemapFileName || void 0,
577
+ preliminaryFilename: item.preliminaryFileName
578
+ };
579
+ }
580
+ return {
581
+ changes,
582
+ deleted: changed.deleted
583
+ };
584
+ }
585
+
586
+ //#endregion
587
+ //#region src/utils/error.ts
588
+ function unwrapBindingResult(container) {
589
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
590
+ return container;
591
+ }
592
+ function normalizeBindingResult(container) {
593
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
594
+ return container;
595
+ }
596
+ function normalizeBindingError(e) {
597
+ return e.type === "JsError" ? e.field0 : Object.assign(/* @__PURE__ */ new Error(), {
598
+ code: e.field0.kind,
599
+ kind: e.field0.kind,
600
+ message: e.field0.message,
601
+ id: e.field0.id,
602
+ exporter: e.field0.exporter,
603
+ loc: e.field0.loc,
604
+ pos: e.field0.pos,
605
+ stack: void 0
606
+ });
607
+ }
608
+ function aggregateBindingErrorsIntoJsError(rawErrors) {
609
+ const errors = rawErrors.map(normalizeBindingError);
610
+ let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
611
+ for (let i = 0; i < errors.length; i++) {
612
+ summary += "\n";
613
+ if (i >= 5) {
614
+ summary += "...";
615
+ break;
616
+ }
617
+ summary += getErrorMessage(errors[i]);
618
+ }
619
+ const wrapper = new Error(summary);
620
+ Object.defineProperty(wrapper, "errors", {
621
+ configurable: true,
622
+ enumerable: true,
623
+ get: () => errors,
624
+ set: (value) => Object.defineProperty(wrapper, "errors", {
625
+ configurable: true,
626
+ enumerable: true,
627
+ value
628
+ })
629
+ });
630
+ return wrapper;
631
+ }
632
+ function getErrorMessage(e) {
633
+ if (Object.hasOwn(e, "kind")) return e.message;
634
+ let s = "";
635
+ if (e.plugin) s += `[plugin ${e.plugin}]`;
636
+ const id = e.id ?? e.loc?.file;
637
+ if (id) {
638
+ s += " " + id;
639
+ if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
640
+ }
641
+ if (s) s += "\n";
642
+ const message = `${e.name ?? "Error"}: ${e.message}`;
643
+ s += message;
644
+ if (e.frame) s = joinNewLine(s, e.frame);
645
+ if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
646
+ if (e.cause) {
647
+ s = joinNewLine(s, "Caused by:");
648
+ s = joinNewLine(s, getErrorMessage(e.cause).split("\n").map((line) => " " + line).join("\n"));
649
+ }
650
+ return s;
651
+ }
652
+ function joinNewLine(s1, s2) {
653
+ return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
654
+ }
655
+
656
+ //#endregion
657
+ //#region src/utils/transform-module-info.ts
658
+ function transformModuleInfo(info, option) {
659
+ return {
660
+ get ast() {
661
+ return unsupported("ModuleInfo#ast");
662
+ },
663
+ get code() {
664
+ return info.code;
665
+ },
666
+ id: info.id,
667
+ importers: info.importers,
668
+ dynamicImporters: info.dynamicImporters,
669
+ importedIds: info.importedIds,
670
+ dynamicallyImportedIds: info.dynamicallyImportedIds,
671
+ exports: info.exports,
672
+ isEntry: info.isEntry,
673
+ ...option
674
+ };
675
+ }
676
+
677
+ //#endregion
678
+ //#region src/utils/transform-sourcemap.ts
679
+ function isEmptySourcemapFiled(array) {
680
+ if (!array) return true;
681
+ if (array.length === 0 || !array[0]) return true;
682
+ return false;
683
+ }
684
+ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
685
+ if (!rawMap) return;
686
+ let map = typeof rawMap === "object" ? rawMap : JSON.parse(rawMap);
687
+ if (isEmptySourcemapFiled(map.sourcesContent)) map.sourcesContent = [originalCode];
688
+ if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
689
+ return map;
690
+ }
691
+
692
+ //#endregion
693
+ //#region ../../node_modules/.pnpm/remeda@2.33.4/node_modules/remeda/dist/lazyDataLastImpl-DtF3cihj.js
694
+ function e(e, t, n) {
695
+ let r = (n) => e(n, ...t);
696
+ return n === void 0 ? r : Object.assign(r, {
697
+ lazy: n,
698
+ lazyArgs: t
699
+ });
700
+ }
701
+
702
+ //#endregion
703
+ //#region ../../node_modules/.pnpm/remeda@2.33.4/node_modules/remeda/dist/purry-GjwKKIlp.js
704
+ function t$1(t, n, r) {
705
+ let i = t.length - n.length;
706
+ if (i === 0) return t(...n);
707
+ if (i === 1) return e(t, n, r);
708
+ throw Error(`Wrong number of arguments`);
709
+ }
710
+
711
+ //#endregion
712
+ //#region ../../node_modules/.pnpm/remeda@2.33.4/node_modules/remeda/dist/partition.js
713
+ function t(...t) {
714
+ return t$1(n, t);
715
+ }
716
+ const n = (e, t) => {
717
+ let n = [[], []];
718
+ for (let [r, i] of e.entries()) t(i, r, e) ? n[0].push(i) : n[1].push(i);
719
+ return n;
720
+ };
721
+
722
+ //#endregion
723
+ //#region src/plugin/bindingify-hook-filter.ts
724
+ function generalHookFilterMatcherToFilterExprs(matcher, stringKind) {
725
+ if (typeof matcher === "string" || matcher instanceof RegExp) return [include(generateAtomMatcher(stringKind, matcher))];
726
+ if (Array.isArray(matcher)) return matcher.map((m) => include(generateAtomMatcher(stringKind, m)));
727
+ let ret = [];
728
+ if (matcher.exclude) ret.push(...arraify(matcher.exclude).map((m) => exclude(generateAtomMatcher(stringKind, m))));
729
+ if (matcher.include) ret.push(...arraify(matcher.include).map((m) => include(generateAtomMatcher(stringKind, m))));
730
+ return ret;
731
+ }
732
+ function generateAtomMatcher(kind, matcher) {
733
+ return kind === "code" ? code(matcher) : id(matcher);
734
+ }
735
+ function transformFilterMatcherToFilterExprs(filterOption) {
736
+ if (!filterOption) return;
737
+ if (Array.isArray(filterOption)) return filterOption;
738
+ const { id, code, moduleType: moduleType$1 } = filterOption;
739
+ let ret = [];
740
+ let idIncludes = [];
741
+ let idExcludes = [];
742
+ let codeIncludes = [];
743
+ let codeExcludes = [];
744
+ if (id) [idIncludes, idExcludes] = t(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
745
+ if (code) [codeIncludes, codeExcludes] = t(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
746
+ ret.push(...idExcludes);
747
+ ret.push(...codeExcludes);
748
+ let andExprList = [];
749
+ if (moduleType$1) {
750
+ let moduleTypes = Array.isArray(moduleType$1) ? moduleType$1 : moduleType$1.include ?? [];
751
+ andExprList.push(or(...moduleTypes.map((m) => moduleType(m))));
752
+ }
753
+ if (idIncludes.length) andExprList.push(or(...idIncludes.map((item) => item.expr)));
754
+ if (codeIncludes.length) andExprList.push(or(...codeIncludes.map((item) => item.expr)));
755
+ if (andExprList.length) ret.push(include(and(...andExprList)));
756
+ return ret;
757
+ }
758
+ function bindingifyGeneralHookFilter(stringKind, pattern) {
759
+ let filterExprs = generalHookFilterMatcherToFilterExprs(pattern, stringKind);
760
+ let ret = [];
761
+ if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
762
+ return ret.length > 0 ? { value: ret } : void 0;
763
+ }
764
+ function bindingifyFilterExpr(expr) {
765
+ let list = [];
766
+ bindingifyFilterExprImpl(expr, list);
767
+ return list;
768
+ }
769
+ function containsImporterId(expr) {
770
+ switch (expr.kind) {
771
+ case "and":
772
+ case "or": return expr.args.some(containsImporterId);
773
+ case "not":
774
+ case "include":
775
+ case "exclude": return containsImporterId(expr.expr);
776
+ case "importerId": return true;
777
+ default: return false;
778
+ }
779
+ }
780
+ function assertNoImporterId(filterExprs, hookName) {
781
+ if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
782
+ }
783
+ function bindingifyFilterExprImpl(expr, list) {
784
+ switch (expr.kind) {
785
+ case "and": {
786
+ let args = expr.args;
787
+ for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
788
+ list.push({
789
+ kind: "And",
790
+ payload: args.length
791
+ });
792
+ break;
793
+ }
794
+ case "or": {
795
+ let args = expr.args;
796
+ for (let i = args.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args[i], list);
797
+ list.push({
798
+ kind: "Or",
799
+ payload: args.length
800
+ });
801
+ break;
802
+ }
803
+ case "not":
804
+ bindingifyFilterExprImpl(expr.expr, list);
805
+ list.push({ kind: "Not" });
806
+ break;
807
+ case "id":
808
+ list.push({
809
+ kind: "Id",
810
+ payload: expr.pattern
811
+ });
812
+ if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
813
+ break;
814
+ case "importerId":
815
+ list.push({
816
+ kind: "ImporterId",
817
+ payload: expr.pattern
818
+ });
819
+ if (expr.params.cleanUrl) list.push({ kind: "CleanUrl" });
820
+ break;
821
+ case "moduleType":
822
+ list.push({
823
+ kind: "ModuleType",
824
+ payload: expr.pattern
825
+ });
826
+ break;
827
+ case "code":
828
+ list.push({
829
+ kind: "Code",
830
+ payload: expr.pattern
831
+ });
832
+ break;
833
+ case "include":
834
+ bindingifyFilterExprImpl(expr.expr, list);
835
+ list.push({ kind: "Include" });
836
+ break;
837
+ case "exclude":
838
+ bindingifyFilterExprImpl(expr.expr, list);
839
+ list.push({ kind: "Exclude" });
840
+ break;
841
+ case "query":
842
+ list.push({
843
+ kind: "QueryKey",
844
+ payload: expr.key
845
+ });
846
+ list.push({
847
+ kind: "QueryValue",
848
+ payload: expr.pattern
849
+ });
850
+ break;
851
+ default: throw new Error(`Unknown filter expression: ${expr}`);
852
+ }
853
+ }
854
+ function bindingifyResolveIdFilter(filterOption) {
855
+ if (!filterOption) return;
856
+ if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
857
+ return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
858
+ }
859
+ function bindingifyLoadFilter(filterOption) {
860
+ if (!filterOption) return;
861
+ if (Array.isArray(filterOption)) {
862
+ assertNoImporterId(filterOption, "load");
863
+ return { value: filterOption.map(bindingifyFilterExpr) };
864
+ }
865
+ return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
866
+ }
867
+ function bindingifyTransformFilter(filterOption) {
868
+ if (!filterOption) return;
869
+ let filterExprs = transformFilterMatcherToFilterExprs(filterOption);
870
+ assertNoImporterId(filterExprs, "transform");
871
+ let ret = [];
872
+ if (filterExprs) ret = filterExprs.map(bindingifyFilterExpr);
873
+ return { value: ret.length > 0 ? ret : void 0 };
874
+ }
875
+ function bindingifyRenderChunkFilter(filterOption) {
876
+ if (!filterOption) return;
877
+ if (Array.isArray(filterOption)) {
878
+ assertNoImporterId(filterOption, "renderChunk");
879
+ return { value: filterOption.map(bindingifyFilterExpr) };
880
+ }
881
+ return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
882
+ }
883
+
884
+ //#endregion
885
+ //#region src/plugin/bindingify-plugin-hook-meta.ts
886
+ function bindingifyPluginHookMeta(options) {
887
+ return { order: bindingPluginOrder(options.order) };
888
+ }
889
+ function bindingPluginOrder(order) {
890
+ switch (order) {
891
+ case "post": return BindingPluginOrder.Post;
892
+ case "pre": return BindingPluginOrder.Pre;
893
+ case null:
894
+ case void 0: return;
895
+ default: throw new Error(`Unknown plugin order: ${order}`);
896
+ }
897
+ }
898
+
899
+ //#endregion
900
+ //#region src/plugin/fs.ts
901
+ const fsModule = {
902
+ appendFile: fsp.appendFile,
903
+ copyFile: fsp.copyFile,
904
+ mkdir: fsp.mkdir,
905
+ mkdtemp: fsp.mkdtemp,
906
+ readdir: fsp.readdir,
907
+ readFile: fsp.readFile,
908
+ realpath: fsp.realpath,
909
+ rename: fsp.rename,
910
+ rmdir: fsp.rmdir,
911
+ stat: fsp.stat,
912
+ lstat: fsp.lstat,
913
+ unlink: fsp.unlink,
914
+ writeFile: fsp.writeFile
915
+ };
916
+
917
+ //#endregion
918
+ //#region src/plugin/plugin-context.ts
919
+ var PluginContextImpl = class extends MinimalPluginContextImpl {
920
+ fs = fsModule;
921
+ getModuleInfo;
922
+ constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
923
+ super(onLog, logLevel, plugin.name, watchMode);
924
+ this.outputOptions = outputOptions;
925
+ this.context = context;
926
+ this.data = data;
927
+ this.onLog = onLog;
928
+ this.currentLoadingModule = currentLoadingModule;
929
+ this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
930
+ }
931
+ async load(options) {
932
+ const id = options.id;
933
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
934
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
935
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
936
+ const rawOptions = {
937
+ meta: options.meta || {},
938
+ moduleSideEffects: options.moduleSideEffects || null,
939
+ invalidate: false
940
+ };
941
+ this.data.updateModuleOption(id, rawOptions);
942
+ let loadPromise = this.data.loadModulePromiseMap.get(id);
943
+ if (!loadPromise) {
944
+ loadPromise = this.context.load(id, options.moduleSideEffects ?? void 0, options.packageJsonPath ?? void 0).catch(() => {
945
+ this.data.loadModulePromiseMap.delete(id);
946
+ });
947
+ this.data.loadModulePromiseMap.set(id, loadPromise);
948
+ }
949
+ await loadPromise;
950
+ return this.data.getModuleInfo(id, this.context);
951
+ }
952
+ async resolve(source, importer, options) {
953
+ let receipt = void 0;
954
+ if (options != null) receipt = this.data.saveResolveOptions(options);
955
+ const vitePluginCustom = Object.entries(options?.custom ?? {}).reduce((acc, [key, value]) => {
956
+ if (key.startsWith("vite:")) (acc ??= {})[key] = value;
957
+ return acc;
958
+ }, void 0);
959
+ const res = await this.context.resolve(source, importer, {
960
+ importKind: options?.kind,
961
+ custom: receipt,
962
+ isEntry: options?.isEntry,
963
+ skipSelf: options?.skipSelf,
964
+ vitePluginCustom
965
+ });
966
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
967
+ if (res == null) return null;
968
+ const info = this.data.getModuleOption(res.id) || {};
969
+ return {
970
+ ...res,
971
+ external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
972
+ ...info,
973
+ moduleSideEffects: info.moduleSideEffects ?? res.moduleSideEffects ?? null,
974
+ packageJsonPath: res.packageJsonPath
975
+ };
976
+ }
977
+ emitFile = (file) => {
978
+ if (file.type === "prebuilt-chunk") return this.context.emitPrebuiltChunk({
979
+ fileName: file.fileName,
980
+ code: file.code,
981
+ exports: file.exports,
982
+ map: bindingifySourcemap(file.map),
983
+ sourcemapFileName: file.sourcemapFileName
984
+ });
985
+ if (file.type === "chunk") return this.context.emitChunk({
986
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
987
+ ...file
988
+ });
989
+ const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
990
+ const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
991
+ return this.context.emitFile({
992
+ ...file,
993
+ originalFileName: file.originalFileName || void 0,
994
+ source: bindingAssetSource(file.source)
995
+ }, filename, fnSanitizedFileName);
996
+ };
997
+ getAssetFileNames(file) {
998
+ if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
999
+ type: "asset",
1000
+ name: file.name,
1001
+ names: file.name ? [file.name] : [],
1002
+ originalFileName: file.originalFileName,
1003
+ originalFileNames: file.originalFileName ? [file.originalFileName] : [],
1004
+ source: file.source
1005
+ });
1006
+ }
1007
+ getFileName(referenceId) {
1008
+ return this.context.getFileName(referenceId);
1009
+ }
1010
+ getModuleIds() {
1011
+ return this.data.getModuleIds(this.context);
1012
+ }
1013
+ addWatchFile(id) {
1014
+ this.context.addWatchFile(id);
1015
+ }
1016
+ parse(input, options) {
1017
+ return parseAst(input, options);
1018
+ }
1019
+ };
1020
+
1021
+ //#endregion
1022
+ //#region src/plugin/transform-plugin-context.ts
1023
+ var TransformPluginContextImpl = class extends PluginContextImpl {
1024
+ constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
1025
+ super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
1026
+ this.inner = inner;
1027
+ this.moduleId = moduleId;
1028
+ this.moduleSource = moduleSource;
1029
+ const getLogHandler = (handler) => (log, pos) => {
1030
+ log = normalizeLog(log);
1031
+ if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
1032
+ log.id = moduleId;
1033
+ log.hook = "transform";
1034
+ handler(log);
1035
+ };
1036
+ this.debug = getLogHandler(this.debug);
1037
+ this.warn = getLogHandler(this.warn);
1038
+ this.info = getLogHandler(this.info);
1039
+ }
1040
+ error(e, pos) {
1041
+ if (typeof e === "string") e = { message: e };
1042
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
1043
+ e.id = this.moduleId;
1044
+ e.hook = "transform";
1045
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1046
+ }
1047
+ getCombinedSourcemap() {
1048
+ return JSON.parse(this.inner.getCombinedSourcemap());
1049
+ }
1050
+ addWatchFile(id) {
1051
+ this.inner.addWatchFile(id);
1052
+ }
1053
+ sendMagicString(s) {
1054
+ this.inner.sendMagicString(s);
1055
+ }
1056
+ };
1057
+
1058
+ //#endregion
1059
+ //#region src/plugin/bindingify-build-hooks.ts
1060
+ function bindingifyBuildStart(args) {
1061
+ const hook = args.plugin.buildStart;
1062
+ if (!hook) return {};
1063
+ const { handler, meta } = normalizeHook(hook);
1064
+ return {
1065
+ plugin: async (ctx, opts) => {
1066
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getInputOptions(opts));
1067
+ },
1068
+ meta: bindingifyPluginHookMeta(meta)
1069
+ };
1070
+ }
1071
+ function bindingifyBuildEnd(args) {
1072
+ const hook = args.plugin.buildEnd;
1073
+ if (!hook) return {};
1074
+ const { handler, meta } = normalizeHook(hook);
1075
+ return {
1076
+ plugin: async (ctx, err) => {
1077
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1078
+ },
1079
+ meta: bindingifyPluginHookMeta(meta)
1080
+ };
1081
+ }
1082
+ function bindingifyResolveId(args) {
1083
+ const hook = args.plugin.resolveId;
1084
+ if (!hook) return {};
1085
+ const { handler, meta, options } = normalizeHook(hook);
1086
+ return {
1087
+ plugin: async (ctx, specifier, importer, extraOptions) => {
1088
+ const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
1089
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0, {
1090
+ ...extraOptions,
1091
+ custom: contextResolveOptions?.custom
1092
+ });
1093
+ if (ret == null) return;
1094
+ if (ret === false) return {
1095
+ id: specifier,
1096
+ external: true,
1097
+ normalizeExternalId: true
1098
+ };
1099
+ if (typeof ret === "string") return {
1100
+ id: ret,
1101
+ normalizeExternalId: false
1102
+ };
1103
+ let exist = args.pluginContextData.updateModuleOption(ret.id, {
1104
+ meta: ret.meta || {},
1105
+ moduleSideEffects: ret.moduleSideEffects ?? null,
1106
+ invalidate: false
1107
+ });
1108
+ return {
1109
+ id: ret.id,
1110
+ external: ret.external,
1111
+ normalizeExternalId: false,
1112
+ moduleSideEffects: exist.moduleSideEffects ?? void 0,
1113
+ packageJsonPath: ret.packageJsonPath
1114
+ };
1115
+ },
1116
+ meta: bindingifyPluginHookMeta(meta),
1117
+ filter: bindingifyResolveIdFilter(options.filter)
1118
+ };
1119
+ }
1120
+ function bindingifyResolveDynamicImport(args) {
1121
+ const hook = args.plugin.resolveDynamicImport;
1122
+ if (!hook) return {};
1123
+ const { handler, meta } = normalizeHook(hook);
1124
+ return {
1125
+ plugin: async (ctx, specifier, importer) => {
1126
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), specifier, importer ?? void 0);
1127
+ if (ret == null) return;
1128
+ if (ret === false) return {
1129
+ id: specifier,
1130
+ external: true
1131
+ };
1132
+ if (typeof ret === "string") return { id: ret };
1133
+ const result = {
1134
+ id: ret.id,
1135
+ external: ret.external,
1136
+ packageJsonPath: ret.packageJsonPath
1137
+ };
1138
+ if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
1139
+ args.pluginContextData.updateModuleOption(ret.id, {
1140
+ meta: ret.meta || {},
1141
+ moduleSideEffects: ret.moduleSideEffects || null,
1142
+ invalidate: false
1143
+ });
1144
+ return result;
1145
+ },
1146
+ meta: bindingifyPluginHookMeta(meta)
1147
+ };
1148
+ }
1149
+ function bindingifyTransform(args) {
1150
+ const hook = args.plugin.transform;
1151
+ if (!hook) return {};
1152
+ const { handler, meta, options } = normalizeHook(hook);
1153
+ return {
1154
+ plugin: async (ctx, code, id, meta) => {
1155
+ let magicStringInstance, astInstance;
1156
+ Object.defineProperties(meta, {
1157
+ magicString: { get() {
1158
+ if (magicStringInstance) return magicStringInstance;
1159
+ magicStringInstance = new BindingMagicString(code);
1160
+ return magicStringInstance;
1161
+ } },
1162
+ ast: { get() {
1163
+ if (astInstance) return astInstance;
1164
+ let lang = "js";
1165
+ switch (meta.moduleType) {
1166
+ case "js":
1167
+ case "jsx":
1168
+ case "ts":
1169
+ case "tsx":
1170
+ lang = meta.moduleType;
1171
+ break;
1172
+ default: break;
1173
+ }
1174
+ astInstance = parseAst(code, {
1175
+ astType: meta.moduleType.includes("ts") ? "ts" : "js",
1176
+ lang
1177
+ });
1178
+ return astInstance;
1179
+ } }
1180
+ });
1181
+ const transformCtx = new TransformPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel, args.watchMode);
1182
+ const ret = await handler.call(transformCtx, code, id, meta);
1183
+ if (ret == null) return;
1184
+ if (typeof ret === "string") return { code: ret };
1185
+ let moduleOption = args.pluginContextData.updateModuleOption(id, {
1186
+ meta: ret.meta ?? {},
1187
+ moduleSideEffects: ret.moduleSideEffects ?? null,
1188
+ invalidate: false
1189
+ });
1190
+ let normalizedCode = void 0;
1191
+ let map = ret.map;
1192
+ if (typeof ret.code === "string") normalizedCode = ret.code;
1193
+ else if (ret.code instanceof BindingMagicString) {
1194
+ let magicString = ret.code;
1195
+ normalizedCode = magicString.toString();
1196
+ let fallbackSourcemap = ctx.sendMagicString(magicString);
1197
+ if (fallbackSourcemap != void 0) map = fallbackSourcemap;
1198
+ }
1199
+ return {
1200
+ code: normalizedCode,
1201
+ map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, map)),
1202
+ moduleSideEffects: moduleOption.moduleSideEffects ?? void 0,
1203
+ moduleType: ret.moduleType
1204
+ };
1205
+ },
1206
+ meta: bindingifyPluginHookMeta(meta),
1207
+ filter: bindingifyTransformFilter(options.filter)
1208
+ };
1209
+ }
1210
+ function bindingifyLoad(args) {
1211
+ const hook = args.plugin.load;
1212
+ if (!hook) return {};
1213
+ const { handler, meta, options } = normalizeHook(hook);
1214
+ return {
1215
+ plugin: async (ctx, id) => {
1216
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode, id), id);
1217
+ if (ret == null) return;
1218
+ if (typeof ret === "string") return { code: ret };
1219
+ let moduleOption = args.pluginContextData.updateModuleOption(id, {
1220
+ meta: ret.meta || {},
1221
+ moduleSideEffects: ret.moduleSideEffects ?? null,
1222
+ invalidate: false
1223
+ });
1224
+ let map = preProcessSourceMap(ret, id);
1225
+ return {
1226
+ code: ret.code,
1227
+ map: bindingifySourcemap(map),
1228
+ moduleType: ret.moduleType,
1229
+ moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
1230
+ };
1231
+ },
1232
+ meta: bindingifyPluginHookMeta(meta),
1233
+ filter: bindingifyLoadFilter(options.filter)
1234
+ };
1235
+ }
1236
+ function preProcessSourceMap(ret, id) {
1237
+ if (!ret.map) return;
1238
+ let map = typeof ret.map === "object" ? ret.map : JSON.parse(ret.map);
1239
+ if (!isEmptySourcemapFiled(map.sources)) {
1240
+ const directory = path.dirname(id) || ".";
1241
+ const sourceRoot = map.sourceRoot || ".";
1242
+ map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
1243
+ }
1244
+ return map;
1245
+ }
1246
+ function bindingifyModuleParsed(args) {
1247
+ const hook = args.plugin.moduleParsed;
1248
+ if (!hook) return {};
1249
+ const { handler, meta } = normalizeHook(hook);
1250
+ return {
1251
+ plugin: async (ctx, moduleInfo) => {
1252
+ 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)));
1253
+ },
1254
+ meta: bindingifyPluginHookMeta(meta)
1255
+ };
1256
+ }
1257
+
1258
+ //#endregion
1259
+ //#region src/plugin/bindingify-output-hooks.ts
1260
+ function bindingifyRenderStart(args) {
1261
+ const hook = args.plugin.renderStart;
1262
+ if (!hook) return {};
1263
+ const { handler, meta } = normalizeHook(hook);
1264
+ return {
1265
+ plugin: async (ctx, opts) => {
1266
+ 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));
1267
+ },
1268
+ meta: bindingifyPluginHookMeta(meta)
1269
+ };
1270
+ }
1271
+ function bindingifyRenderChunk(args) {
1272
+ const hook = args.plugin.renderChunk;
1273
+ if (!hook) return {};
1274
+ const { handler, meta, options } = normalizeHook(hook);
1275
+ return {
1276
+ plugin: async (ctx, code, chunk, opts, meta) => {
1277
+ if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
1278
+ const renderChunkMeta = args.pluginContextData.getRenderChunkMeta();
1279
+ let magicStringInstance;
1280
+ if (args.options.experimental?.nativeMagicString) Object.defineProperty(renderChunkMeta, "magicString", {
1281
+ get() {
1282
+ if (magicStringInstance) return magicStringInstance;
1283
+ magicStringInstance = new BindingMagicString(code);
1284
+ return magicStringInstance;
1285
+ },
1286
+ configurable: true
1287
+ });
1288
+ const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), renderChunkMeta);
1289
+ if (ret == null) return;
1290
+ if (ret instanceof BindingMagicString) {
1291
+ const normalizedCode = ret.toString();
1292
+ const generatedMap = ret.generateMap();
1293
+ return {
1294
+ code: normalizedCode,
1295
+ map: bindingifySourcemap({
1296
+ file: generatedMap.file,
1297
+ mappings: generatedMap.mappings,
1298
+ names: generatedMap.names,
1299
+ sources: generatedMap.sources,
1300
+ sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
1301
+ })
1302
+ };
1303
+ }
1304
+ if (typeof ret === "string") return { code: ret };
1305
+ if (ret.code instanceof BindingMagicString) {
1306
+ const magicString = ret.code;
1307
+ const normalizedCode = magicString.toString();
1308
+ if (ret.map === null) return { code: normalizedCode };
1309
+ if (ret.map === void 0) {
1310
+ const generatedMap = magicString.generateMap();
1311
+ return {
1312
+ code: normalizedCode,
1313
+ map: bindingifySourcemap({
1314
+ file: generatedMap.file,
1315
+ mappings: generatedMap.mappings,
1316
+ names: generatedMap.names,
1317
+ sources: generatedMap.sources,
1318
+ sourcesContent: generatedMap.sourcesContent.map((s) => s ?? null)
1319
+ })
1320
+ };
1321
+ }
1322
+ return {
1323
+ code: normalizedCode,
1324
+ map: bindingifySourcemap(ret.map)
1325
+ };
1326
+ }
1327
+ if (!ret.map) return { code: ret.code };
1328
+ return {
1329
+ code: ret.code,
1330
+ map: bindingifySourcemap(ret.map)
1331
+ };
1332
+ },
1333
+ meta: bindingifyPluginHookMeta(meta),
1334
+ filter: bindingifyRenderChunkFilter(options.filter)
1335
+ };
1336
+ }
1337
+ function bindingifyAugmentChunkHash(args) {
1338
+ const hook = args.plugin.augmentChunkHash;
1339
+ if (!hook) return {};
1340
+ const { handler, meta } = normalizeHook(hook);
1341
+ return {
1342
+ plugin: async (ctx, chunk) => {
1343
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1344
+ },
1345
+ meta: bindingifyPluginHookMeta(meta)
1346
+ };
1347
+ }
1348
+ function bindingifyRenderError(args) {
1349
+ const hook = args.plugin.renderError;
1350
+ if (!hook) return {};
1351
+ const { handler, meta } = normalizeHook(hook);
1352
+ return {
1353
+ plugin: async (ctx, err) => {
1354
+ handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
1355
+ },
1356
+ meta: bindingifyPluginHookMeta(meta)
1357
+ };
1358
+ }
1359
+ function bindingifyGenerateBundle(args) {
1360
+ const hook = args.plugin.generateBundle;
1361
+ if (!hook) return {};
1362
+ const { handler, meta } = normalizeHook(hook);
1363
+ return {
1364
+ plugin: async (ctx, bundle, isWrite, opts) => {
1365
+ const changed = {
1366
+ updated: /* @__PURE__ */ new Set(),
1367
+ deleted: /* @__PURE__ */ new Set()
1368
+ };
1369
+ const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1370
+ const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
1371
+ await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
1372
+ return collectChangedBundle(changed, output);
1373
+ },
1374
+ meta: bindingifyPluginHookMeta(meta)
1375
+ };
1376
+ }
1377
+ function bindingifyWriteBundle(args) {
1378
+ const hook = args.plugin.writeBundle;
1379
+ if (!hook) return {};
1380
+ const { handler, meta } = normalizeHook(hook);
1381
+ return {
1382
+ plugin: async (ctx, bundle, opts) => {
1383
+ const changed = {
1384
+ updated: /* @__PURE__ */ new Set(),
1385
+ deleted: /* @__PURE__ */ new Set()
1386
+ };
1387
+ const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1388
+ const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
1389
+ await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
1390
+ return collectChangedBundle(changed, output);
1391
+ },
1392
+ meta: bindingifyPluginHookMeta(meta)
1393
+ };
1394
+ }
1395
+ function bindingifyCloseBundle(args) {
1396
+ const hook = args.plugin.closeBundle;
1397
+ if (!hook) return {};
1398
+ const { handler, meta } = normalizeHook(hook);
1399
+ return {
1400
+ plugin: async (ctx, err) => {
1401
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1402
+ },
1403
+ meta: bindingifyPluginHookMeta(meta)
1404
+ };
1405
+ }
1406
+ function bindingifyBanner(args) {
1407
+ const hook = args.plugin.banner;
1408
+ if (!hook) return {};
1409
+ const { handler, meta } = normalizeHook(hook);
1410
+ return {
1411
+ plugin: async (ctx, chunk) => {
1412
+ if (typeof handler === "string") return handler;
1413
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1414
+ },
1415
+ meta: bindingifyPluginHookMeta(meta)
1416
+ };
1417
+ }
1418
+ function bindingifyFooter(args) {
1419
+ const hook = args.plugin.footer;
1420
+ if (!hook) return {};
1421
+ const { handler, meta } = normalizeHook(hook);
1422
+ return {
1423
+ plugin: async (ctx, chunk) => {
1424
+ if (typeof handler === "string") return handler;
1425
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1426
+ },
1427
+ meta: bindingifyPluginHookMeta(meta)
1428
+ };
1429
+ }
1430
+ function bindingifyIntro(args) {
1431
+ const hook = args.plugin.intro;
1432
+ if (!hook) return {};
1433
+ const { handler, meta } = normalizeHook(hook);
1434
+ return {
1435
+ plugin: async (ctx, chunk) => {
1436
+ if (typeof handler === "string") return handler;
1437
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1438
+ },
1439
+ meta: bindingifyPluginHookMeta(meta)
1440
+ };
1441
+ }
1442
+ function bindingifyOutro(args) {
1443
+ const hook = args.plugin.outro;
1444
+ if (!hook) return {};
1445
+ const { handler, meta } = normalizeHook(hook);
1446
+ return {
1447
+ plugin: async (ctx, chunk) => {
1448
+ if (typeof handler === "string") return handler;
1449
+ return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1450
+ },
1451
+ meta: bindingifyPluginHookMeta(meta)
1452
+ };
1453
+ }
1454
+
1455
+ //#endregion
1456
+ //#region src/plugin/bindingify-watch-hooks.ts
1457
+ function bindingifyWatchChange(args) {
1458
+ const hook = args.plugin.watchChange;
1459
+ if (!hook) return {};
1460
+ const { handler, meta } = normalizeHook(hook);
1461
+ return {
1462
+ plugin: async (ctx, id, event) => {
1463
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
1464
+ },
1465
+ meta: bindingifyPluginHookMeta(meta)
1466
+ };
1467
+ }
1468
+ function bindingifyCloseWatcher(args) {
1469
+ const hook = args.plugin.closeWatcher;
1470
+ if (!hook) return {};
1471
+ const { handler, meta } = normalizeHook(hook);
1472
+ return {
1473
+ plugin: async (ctx) => {
1474
+ await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
1475
+ },
1476
+ meta: bindingifyPluginHookMeta(meta)
1477
+ };
1478
+ }
1479
+
1480
+ //#endregion
1481
+ //#region src/plugin/generated/hook-usage.ts
1482
+ let HookUsageKind = /* @__PURE__ */ function(HookUsageKind) {
1483
+ HookUsageKind[HookUsageKind["buildStart"] = 1] = "buildStart";
1484
+ HookUsageKind[HookUsageKind["resolveId"] = 2] = "resolveId";
1485
+ HookUsageKind[HookUsageKind["resolveDynamicImport"] = 4] = "resolveDynamicImport";
1486
+ HookUsageKind[HookUsageKind["load"] = 8] = "load";
1487
+ HookUsageKind[HookUsageKind["transform"] = 16] = "transform";
1488
+ HookUsageKind[HookUsageKind["moduleParsed"] = 32] = "moduleParsed";
1489
+ HookUsageKind[HookUsageKind["buildEnd"] = 64] = "buildEnd";
1490
+ HookUsageKind[HookUsageKind["renderStart"] = 128] = "renderStart";
1491
+ HookUsageKind[HookUsageKind["renderError"] = 256] = "renderError";
1492
+ HookUsageKind[HookUsageKind["renderChunk"] = 512] = "renderChunk";
1493
+ HookUsageKind[HookUsageKind["augmentChunkHash"] = 1024] = "augmentChunkHash";
1494
+ HookUsageKind[HookUsageKind["generateBundle"] = 2048] = "generateBundle";
1495
+ HookUsageKind[HookUsageKind["writeBundle"] = 4096] = "writeBundle";
1496
+ HookUsageKind[HookUsageKind["closeBundle"] = 8192] = "closeBundle";
1497
+ HookUsageKind[HookUsageKind["watchChange"] = 16384] = "watchChange";
1498
+ HookUsageKind[HookUsageKind["closeWatcher"] = 32768] = "closeWatcher";
1499
+ HookUsageKind[HookUsageKind["transformAst"] = 65536] = "transformAst";
1500
+ HookUsageKind[HookUsageKind["banner"] = 131072] = "banner";
1501
+ HookUsageKind[HookUsageKind["footer"] = 262144] = "footer";
1502
+ HookUsageKind[HookUsageKind["intro"] = 524288] = "intro";
1503
+ HookUsageKind[HookUsageKind["outro"] = 1048576] = "outro";
1504
+ return HookUsageKind;
1505
+ }({});
1506
+ var HookUsage = class {
1507
+ bitflag = BigInt(0);
1508
+ constructor() {}
1509
+ union(kind) {
1510
+ this.bitflag |= BigInt(kind);
1511
+ }
1512
+ inner() {
1513
+ return Number(this.bitflag);
1514
+ }
1515
+ };
1516
+ function extractHookUsage(plugin) {
1517
+ let hookUsage = new HookUsage();
1518
+ if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
1519
+ if (plugin.resolveId) hookUsage.union(HookUsageKind.resolveId);
1520
+ if (plugin.resolveDynamicImport) hookUsage.union(HookUsageKind.resolveDynamicImport);
1521
+ if (plugin.load) hookUsage.union(HookUsageKind.load);
1522
+ if (plugin.transform) hookUsage.union(HookUsageKind.transform);
1523
+ if (plugin.moduleParsed) hookUsage.union(HookUsageKind.moduleParsed);
1524
+ if (plugin.buildEnd) hookUsage.union(HookUsageKind.buildEnd);
1525
+ if (plugin.renderStart) hookUsage.union(HookUsageKind.renderStart);
1526
+ if (plugin.renderError) hookUsage.union(HookUsageKind.renderError);
1527
+ if (plugin.renderChunk) hookUsage.union(HookUsageKind.renderChunk);
1528
+ if (plugin.augmentChunkHash) hookUsage.union(HookUsageKind.augmentChunkHash);
1529
+ if (plugin.generateBundle) hookUsage.union(HookUsageKind.generateBundle);
1530
+ if (plugin.writeBundle) hookUsage.union(HookUsageKind.writeBundle);
1531
+ if (plugin.closeBundle) hookUsage.union(HookUsageKind.closeBundle);
1532
+ if (plugin.watchChange) hookUsage.union(HookUsageKind.watchChange);
1533
+ if (plugin.closeWatcher) hookUsage.union(HookUsageKind.closeWatcher);
1534
+ if (plugin.banner) hookUsage.union(HookUsageKind.banner);
1535
+ if (plugin.footer) hookUsage.union(HookUsageKind.footer);
1536
+ if (plugin.intro) hookUsage.union(HookUsageKind.intro);
1537
+ if (plugin.outro) hookUsage.union(HookUsageKind.outro);
1538
+ return hookUsage;
1539
+ }
1540
+
1541
+ //#endregion
1542
+ //#region src/plugin/bindingify-plugin.ts
1543
+ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
1544
+ const args = {
1545
+ plugin,
1546
+ options,
1547
+ outputOptions,
1548
+ pluginContextData,
1549
+ onLog,
1550
+ logLevel,
1551
+ watchMode,
1552
+ normalizedOutputPlugins
1553
+ };
1554
+ const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
1555
+ const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
1556
+ const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
1557
+ const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
1558
+ const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
1559
+ const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
1560
+ const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
1561
+ const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
1562
+ const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
1563
+ const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
1564
+ const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
1565
+ const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
1566
+ const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
1567
+ const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
1568
+ const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
1569
+ const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
1570
+ const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
1571
+ const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
1572
+ const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
1573
+ const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
1574
+ let hookUsage = extractHookUsage(plugin).inner();
1575
+ return wrapHandlers({
1576
+ name: plugin.name,
1577
+ buildStart,
1578
+ buildStartMeta,
1579
+ resolveId,
1580
+ resolveIdMeta,
1581
+ resolveIdFilter,
1582
+ resolveDynamicImport,
1583
+ resolveDynamicImportMeta,
1584
+ buildEnd,
1585
+ buildEndMeta,
1586
+ transform,
1587
+ transformMeta,
1588
+ transformFilter,
1589
+ moduleParsed,
1590
+ moduleParsedMeta,
1591
+ load,
1592
+ loadMeta,
1593
+ loadFilter,
1594
+ renderChunk,
1595
+ renderChunkMeta,
1596
+ renderChunkFilter,
1597
+ augmentChunkHash,
1598
+ augmentChunkHashMeta,
1599
+ renderStart,
1600
+ renderStartMeta,
1601
+ renderError,
1602
+ renderErrorMeta,
1603
+ generateBundle,
1604
+ generateBundleMeta,
1605
+ writeBundle,
1606
+ writeBundleMeta,
1607
+ closeBundle,
1608
+ closeBundleMeta,
1609
+ banner,
1610
+ bannerMeta,
1611
+ footer,
1612
+ footerMeta,
1613
+ intro,
1614
+ introMeta,
1615
+ outro,
1616
+ outroMeta,
1617
+ watchChange,
1618
+ watchChangeMeta,
1619
+ closeWatcher,
1620
+ closeWatcherMeta,
1621
+ hookUsage
1622
+ });
1623
+ }
1624
+ function wrapHandlers(plugin) {
1625
+ for (const hookName of [
1626
+ "buildStart",
1627
+ "resolveId",
1628
+ "resolveDynamicImport",
1629
+ "buildEnd",
1630
+ "transform",
1631
+ "moduleParsed",
1632
+ "load",
1633
+ "renderChunk",
1634
+ "augmentChunkHash",
1635
+ "renderStart",
1636
+ "renderError",
1637
+ "generateBundle",
1638
+ "writeBundle",
1639
+ "closeBundle",
1640
+ "banner",
1641
+ "footer",
1642
+ "intro",
1643
+ "outro",
1644
+ "watchChange",
1645
+ "closeWatcher"
1646
+ ]) {
1647
+ const handler = plugin[hookName];
1648
+ if (handler) plugin[hookName] = async (...args) => {
1649
+ try {
1650
+ return await handler(...args);
1651
+ } catch (e) {
1652
+ return error(logPluginError(e, plugin.name, {
1653
+ hook: hookName,
1654
+ id: hookName === "transform" ? args[2] : void 0
1655
+ }));
1656
+ }
1657
+ };
1658
+ }
1659
+ return plugin;
1660
+ }
1661
+
1662
+ //#endregion
1663
+ //#region src/options/normalized-input-options.ts
1664
+ var NormalizedInputOptionsImpl = class extends PlainObjectLike {
1665
+ inner;
1666
+ constructor(inner, onLog) {
1667
+ super();
1668
+ this.onLog = onLog;
1669
+ this.inner = inner;
1670
+ }
1671
+ get shimMissingExports() {
1672
+ return this.inner.shimMissingExports;
1673
+ }
1674
+ get input() {
1675
+ return this.inner.input;
1676
+ }
1677
+ get cwd() {
1678
+ return this.inner.cwd;
1679
+ }
1680
+ get platform() {
1681
+ return this.inner.platform;
1682
+ }
1683
+ get context() {
1684
+ return this.inner.context;
1685
+ }
1686
+ };
1687
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
1688
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
1689
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
1690
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
1691
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
1692
+
1693
+ //#endregion
1694
+ //#region src/options/normalized-output-options.ts
1695
+ var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
1696
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
1697
+ super();
1698
+ this.inner = inner;
1699
+ this.outputOptions = outputOptions;
1700
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
1701
+ }
1702
+ get dir() {
1703
+ return this.inner.dir ?? void 0;
1704
+ }
1705
+ get entryFileNames() {
1706
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
1707
+ }
1708
+ get chunkFileNames() {
1709
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
1710
+ }
1711
+ get assetFileNames() {
1712
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
1713
+ }
1714
+ get format() {
1715
+ return this.inner.format;
1716
+ }
1717
+ get exports() {
1718
+ return this.inner.exports;
1719
+ }
1720
+ get sourcemap() {
1721
+ return this.inner.sourcemap;
1722
+ }
1723
+ get sourcemapBaseUrl() {
1724
+ return this.inner.sourcemapBaseUrl ?? void 0;
1725
+ }
1726
+ get cssEntryFileNames() {
1727
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
1728
+ }
1729
+ get cssChunkFileNames() {
1730
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
1731
+ }
1732
+ get shimMissingExports() {
1733
+ return this.inner.shimMissingExports;
1734
+ }
1735
+ get name() {
1736
+ return this.inner.name ?? void 0;
1737
+ }
1738
+ get file() {
1739
+ return this.inner.file ?? void 0;
1740
+ }
1741
+ get codeSplitting() {
1742
+ return this.inner.codeSplitting;
1743
+ }
1744
+ /**
1745
+ * @deprecated Use `codeSplitting` instead.
1746
+ */
1747
+ get inlineDynamicImports() {
1748
+ return !this.inner.codeSplitting;
1749
+ }
1750
+ get dynamicImportInCjs() {
1751
+ return this.inner.dynamicImportInCjs;
1752
+ }
1753
+ get externalLiveBindings() {
1754
+ return this.inner.externalLiveBindings;
1755
+ }
1756
+ get banner() {
1757
+ return normalizeAddon(this.outputOptions.banner);
1758
+ }
1759
+ get footer() {
1760
+ return normalizeAddon(this.outputOptions.footer);
1761
+ }
1762
+ get postBanner() {
1763
+ return normalizeAddon(this.outputOptions.postBanner);
1764
+ }
1765
+ get postFooter() {
1766
+ return normalizeAddon(this.outputOptions.postFooter);
1767
+ }
1768
+ get intro() {
1769
+ return normalizeAddon(this.outputOptions.intro);
1770
+ }
1771
+ get outro() {
1772
+ return normalizeAddon(this.outputOptions.outro);
1773
+ }
1774
+ get esModule() {
1775
+ return this.inner.esModule;
1776
+ }
1777
+ get extend() {
1778
+ return this.inner.extend;
1779
+ }
1780
+ get globals() {
1781
+ return this.inner.globals || this.outputOptions.globals;
1782
+ }
1783
+ get paths() {
1784
+ return this.outputOptions.paths;
1785
+ }
1786
+ get hashCharacters() {
1787
+ return this.inner.hashCharacters;
1788
+ }
1789
+ get sourcemapDebugIds() {
1790
+ return this.inner.sourcemapDebugIds;
1791
+ }
1792
+ get sourcemapIgnoreList() {
1793
+ return this.outputOptions.sourcemapIgnoreList;
1794
+ }
1795
+ get sourcemapPathTransform() {
1796
+ return this.outputOptions.sourcemapPathTransform;
1797
+ }
1798
+ get minify() {
1799
+ let ret = this.inner.minify;
1800
+ if (typeof ret === "object" && ret !== null) {
1801
+ delete ret["codegen"];
1802
+ delete ret["module"];
1803
+ delete ret["sourcemap"];
1804
+ }
1805
+ return ret;
1806
+ }
1807
+ get legalComments() {
1808
+ return this.inner.legalComments;
1809
+ }
1810
+ get polyfillRequire() {
1811
+ return this.inner.polyfillRequire;
1812
+ }
1813
+ get plugins() {
1814
+ return this.normalizedOutputPlugins;
1815
+ }
1816
+ get preserveModules() {
1817
+ return this.inner.preserveModules;
1818
+ }
1819
+ get preserveModulesRoot() {
1820
+ return this.inner.preserveModulesRoot;
1821
+ }
1822
+ get virtualDirname() {
1823
+ return this.inner.virtualDirname;
1824
+ }
1825
+ get topLevelVar() {
1826
+ return this.inner.topLevelVar ?? false;
1827
+ }
1828
+ get minifyInternalExports() {
1829
+ return this.inner.minifyInternalExports ?? false;
1830
+ }
1831
+ };
1832
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
1833
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
1834
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
1835
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
1836
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
1837
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
1838
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
1839
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
1840
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssEntryFileNames", null);
1841
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssChunkFileNames", null);
1842
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
1843
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
1844
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
1845
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "codeSplitting", null);
1846
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
1847
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dynamicImportInCjs", null);
1848
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
1849
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
1850
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
1851
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postBanner", null);
1852
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "postFooter", null);
1853
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
1854
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
1855
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
1856
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
1857
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
1858
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
1859
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
1860
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
1861
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
1862
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
1863
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
1864
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
1865
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
1866
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
1867
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
1868
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
1869
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
1870
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
1871
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
1872
+ function normalizeAddon(value) {
1873
+ if (typeof value === "function") return value;
1874
+ return () => value || "";
1875
+ }
1876
+
1877
+ //#endregion
1878
+ //#region src/plugin/plugin-context-data.ts
1879
+ var PluginContextData = class {
1880
+ moduleOptionMap = /* @__PURE__ */ new Map();
1881
+ resolveOptionsMap = /* @__PURE__ */ new Map();
1882
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
1883
+ renderedChunkMeta = null;
1884
+ normalizedInputOptions = null;
1885
+ normalizedOutputOptions = null;
1886
+ constructor(onLog, outputOptions, normalizedOutputPlugins) {
1887
+ this.onLog = onLog;
1888
+ this.outputOptions = outputOptions;
1889
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
1890
+ }
1891
+ updateModuleOption(id, option) {
1892
+ const existing = this.moduleOptionMap.get(id);
1893
+ if (existing) {
1894
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
1895
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
1896
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
1897
+ } else {
1898
+ this.moduleOptionMap.set(id, option);
1899
+ return option;
1900
+ }
1901
+ return existing;
1902
+ }
1903
+ getModuleOption(id) {
1904
+ const option = this.moduleOptionMap.get(id);
1905
+ if (!option) {
1906
+ const raw = {
1907
+ moduleSideEffects: null,
1908
+ meta: {}
1909
+ };
1910
+ this.moduleOptionMap.set(id, raw);
1911
+ return raw;
1912
+ }
1913
+ return option;
1914
+ }
1915
+ getModuleInfo(id, context) {
1916
+ const bindingInfo = context.getModuleInfo(id);
1917
+ if (bindingInfo) {
1918
+ const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
1919
+ return this.proxyModuleInfo(id, info);
1920
+ }
1921
+ return null;
1922
+ }
1923
+ proxyModuleInfo(id, info) {
1924
+ let moduleSideEffects = info.moduleSideEffects;
1925
+ Object.defineProperty(info, "moduleSideEffects", {
1926
+ get() {
1927
+ return moduleSideEffects;
1928
+ },
1929
+ set: (v) => {
1930
+ this.updateModuleOption(id, {
1931
+ moduleSideEffects: v,
1932
+ meta: info.meta,
1933
+ invalidate: true
1934
+ });
1935
+ moduleSideEffects = v;
1936
+ }
1937
+ });
1938
+ return info;
1939
+ }
1940
+ getModuleIds(context) {
1941
+ return context.getModuleIds().values();
1942
+ }
1943
+ saveResolveOptions(options) {
1944
+ const index = this.resolveOptionsMap.size;
1945
+ this.resolveOptionsMap.set(index, options);
1946
+ return index;
1947
+ }
1948
+ getSavedResolveOptions(receipt) {
1949
+ return this.resolveOptionsMap.get(receipt);
1950
+ }
1951
+ removeSavedResolveOptions(receipt) {
1952
+ this.resolveOptionsMap.delete(receipt);
1953
+ }
1954
+ setRenderChunkMeta(meta) {
1955
+ this.renderedChunkMeta = meta;
1956
+ }
1957
+ getRenderChunkMeta() {
1958
+ return this.renderedChunkMeta;
1959
+ }
1960
+ getInputOptions(opts) {
1961
+ this.normalizedInputOptions ??= new NormalizedInputOptionsImpl(opts, this.onLog);
1962
+ return this.normalizedInputOptions;
1963
+ }
1964
+ getOutputOptions(opts) {
1965
+ this.normalizedOutputOptions ??= new NormalizedOutputOptionsImpl(opts, this.outputOptions, this.normalizedOutputPlugins);
1966
+ return this.normalizedOutputOptions;
1967
+ }
1968
+ clear() {
1969
+ this.renderedChunkMeta = null;
1970
+ this.loadModulePromiseMap.clear();
1971
+ }
1972
+ };
1973
+
1974
+ //#endregion
1975
+ //#region src/utils/normalize-transform-options.ts
1976
+ /**
1977
+ * Normalizes transform options by extracting `define`, `inject`, and `dropLabels` separately from OXC transform options.
1978
+ *
1979
+ * Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
1980
+ */
1981
+ function normalizeTransformOptions(inputOptions) {
1982
+ const transform = inputOptions.transform;
1983
+ const define = transform?.define ? Object.entries(transform.define) : void 0;
1984
+ const inject = transform?.inject;
1985
+ const dropLabels = transform?.dropLabels;
1986
+ let oxcTransformOptions;
1987
+ if (transform) {
1988
+ const { define: _define, inject: _inject, dropLabels: _dropLabels, ...rest } = transform;
1989
+ if (Object.keys(rest).length > 0) {
1990
+ if (rest.jsx === false) rest.jsx = "disable";
1991
+ oxcTransformOptions = rest;
1992
+ }
1993
+ }
1994
+ return {
1995
+ define,
1996
+ inject,
1997
+ dropLabels,
1998
+ oxcTransformOptions
1999
+ };
2000
+ }
2001
+
2002
+ //#endregion
2003
+ //#region src/utils/bindingify-input-options.ts
2004
+ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
2005
+ const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
2006
+ const plugins = rawPlugins.map((plugin) => {
2007
+ if ("_parallel" in plugin) return;
2008
+ if (plugin instanceof BuiltinPlugin) switch (plugin.name) {
2009
+ case "builtin:vite-manifest": return bindingifyManifestPlugin(plugin, pluginContextData);
2010
+ default: return bindingifyBuiltInPlugin(plugin);
2011
+ }
2012
+ return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
2013
+ });
2014
+ const normalizedTransform = normalizeTransformOptions(inputOptions);
2015
+ return {
2016
+ input: bindingifyInput(inputOptions.input),
2017
+ plugins,
2018
+ cwd: inputOptions.cwd ?? process.cwd(),
2019
+ external: bindingifyExternal(inputOptions.external),
2020
+ resolve: bindingifyResolve(inputOptions.resolve),
2021
+ platform: inputOptions.platform,
2022
+ shimMissingExports: inputOptions.shimMissingExports,
2023
+ logLevel: bindingifyLogLevel(logLevel),
2024
+ onLog: async (level, log) => onLog(level, log),
2025
+ treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
2026
+ moduleTypes: inputOptions.moduleTypes,
2027
+ define: normalizedTransform.define,
2028
+ inject: bindingifyInject(normalizedTransform.inject),
2029
+ experimental: bindingifyExperimental(inputOptions.experimental),
2030
+ profilerNames: outputOptions.generatedCode?.profilerNames,
2031
+ transform: normalizedTransform.oxcTransformOptions,
2032
+ watch: bindingifyWatch(inputOptions.watch),
2033
+ dropLabels: normalizedTransform.dropLabels,
2034
+ keepNames: outputOptions.keepNames,
2035
+ checks: inputOptions.checks,
2036
+ deferSyncScanData: () => {
2037
+ let ret = [];
2038
+ pluginContextData.moduleOptionMap.forEach((value, key) => {
2039
+ if (value.invalidate) ret.push({
2040
+ id: key,
2041
+ sideEffects: value.moduleSideEffects ?? void 0
2042
+ });
2043
+ });
2044
+ return ret;
2045
+ },
2046
+ makeAbsoluteExternalsRelative: bindingifyMakeAbsoluteExternalsRelative(inputOptions.makeAbsoluteExternalsRelative),
2047
+ devtools: inputOptions.devtools,
2048
+ invalidateJsSideCache: pluginContextData.clear.bind(pluginContextData),
2049
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(inputOptions.preserveEntrySignatures),
2050
+ optimization: inputOptions.optimization,
2051
+ context: inputOptions.context,
2052
+ tsconfig: inputOptions.resolve?.tsconfigFilename ?? inputOptions.tsconfig
2053
+ };
2054
+ }
2055
+ function bindingifyDevMode(devMode) {
2056
+ if (devMode) {
2057
+ if (typeof devMode === "boolean") return devMode ? {} : void 0;
2058
+ return devMode;
2059
+ }
2060
+ }
2061
+ function bindingifyAttachDebugInfo(attachDebugInfo) {
2062
+ switch (attachDebugInfo) {
2063
+ case void 0: return;
2064
+ case "full": return BindingAttachDebugInfo.Full;
2065
+ case "simple": return BindingAttachDebugInfo.Simple;
2066
+ case "none": return BindingAttachDebugInfo.None;
2067
+ }
2068
+ }
2069
+ function bindingifyExternal(external) {
2070
+ if (external) {
2071
+ if (typeof external === "function") return (id, importer, isResolved) => {
2072
+ if (id.startsWith("\0")) return false;
2073
+ return external(id, importer, isResolved) ?? false;
2074
+ };
2075
+ return arraify(external);
2076
+ }
2077
+ }
2078
+ function bindingifyExperimental(experimental) {
2079
+ let chunkModulesOrder = BindingChunkModuleOrderBy.ExecOrder;
2080
+ if (experimental?.chunkModulesOrder) switch (experimental.chunkModulesOrder) {
2081
+ case "exec-order":
2082
+ chunkModulesOrder = BindingChunkModuleOrderBy.ExecOrder;
2083
+ break;
2084
+ case "module-id":
2085
+ chunkModulesOrder = BindingChunkModuleOrderBy.ModuleId;
2086
+ break;
2087
+ default: throw new Error(`Unexpected chunkModulesOrder: ${experimental.chunkModulesOrder}`);
2088
+ }
2089
+ return {
2090
+ viteMode: experimental?.viteMode,
2091
+ resolveNewUrlToAsset: experimental?.resolveNewUrlToAsset,
2092
+ devMode: bindingifyDevMode(experimental?.devMode),
2093
+ attachDebugInfo: bindingifyAttachDebugInfo(experimental?.attachDebugInfo),
2094
+ chunkModulesOrder,
2095
+ chunkImportMap: experimental?.chunkImportMap,
2096
+ onDemandWrapping: experimental?.onDemandWrapping,
2097
+ incrementalBuild: experimental?.incrementalBuild,
2098
+ nativeMagicString: experimental?.nativeMagicString,
2099
+ chunkOptimization: experimental?.chunkOptimization
2100
+ };
2101
+ }
2102
+ function bindingifyResolve(resolve) {
2103
+ const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
2104
+ if (resolve) {
2105
+ const { alias, extensionAlias, ...rest } = resolve;
2106
+ return {
2107
+ alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
2108
+ find: name,
2109
+ replacements: replacement === false ? [void 0] : arraify(replacement)
2110
+ })) : void 0,
2111
+ extensionAlias: extensionAlias ? Object.entries(extensionAlias).map(([name, value]) => ({
2112
+ target: name,
2113
+ replacements: value
2114
+ })) : void 0,
2115
+ yarnPnp,
2116
+ ...rest
2117
+ };
2118
+ } else return { yarnPnp };
2119
+ }
2120
+ function bindingifyInject(inject) {
2121
+ if (inject) return Object.entries(inject).map(([alias, item]) => {
2122
+ if (Array.isArray(item)) {
2123
+ if (item[1] === "*") return {
2124
+ tagNamespace: true,
2125
+ alias,
2126
+ from: item[0]
2127
+ };
2128
+ return {
2129
+ tagNamed: true,
2130
+ alias,
2131
+ from: item[0],
2132
+ imported: item[1]
2133
+ };
2134
+ } else return {
2135
+ tagNamed: true,
2136
+ imported: "default",
2137
+ alias,
2138
+ from: item
2139
+ };
2140
+ });
2141
+ }
2142
+ function bindingifyLogLevel(logLevel) {
2143
+ switch (logLevel) {
2144
+ case "silent": return BindingLogLevel.Silent;
2145
+ case "debug": return BindingLogLevel.Debug;
2146
+ case "warn": return BindingLogLevel.Warn;
2147
+ case "info": return BindingLogLevel.Info;
2148
+ default: throw new Error(`Unexpected log level: ${logLevel}`);
2149
+ }
2150
+ }
2151
+ function bindingifyInput(input) {
2152
+ if (input === void 0) return [];
2153
+ if (typeof input === "string") return [{ import: input }];
2154
+ if (Array.isArray(input)) return input.map((src) => ({ import: src }));
2155
+ return Object.entries(input).map(([name, import_path]) => {
2156
+ return {
2157
+ name,
2158
+ import: import_path
2159
+ };
2160
+ });
2161
+ }
2162
+ function bindingifyWatch(watch) {
2163
+ if (watch) return {
2164
+ buildDelay: watch.buildDelay,
2165
+ skipWrite: watch.skipWrite,
2166
+ include: normalizedStringOrRegex(watch.include),
2167
+ exclude: normalizedStringOrRegex(watch.exclude),
2168
+ onInvalidate: (...args) => watch.onInvalidate?.(...args)
2169
+ };
2170
+ }
2171
+ function bindingifyTreeshakeOptions(config) {
2172
+ if (config === false) return;
2173
+ if (config === true || config === void 0) return { moduleSideEffects: true };
2174
+ let normalizedConfig = {
2175
+ moduleSideEffects: true,
2176
+ annotations: config.annotations,
2177
+ manualPureFunctions: config.manualPureFunctions,
2178
+ unknownGlobalSideEffects: config.unknownGlobalSideEffects,
2179
+ invalidImportSideEffects: config.invalidImportSideEffects,
2180
+ commonjs: config.commonjs
2181
+ };
2182
+ switch (config.propertyReadSideEffects) {
2183
+ case "always":
2184
+ normalizedConfig.propertyReadSideEffects = BindingPropertyReadSideEffects.Always;
2185
+ break;
2186
+ case false:
2187
+ normalizedConfig.propertyReadSideEffects = BindingPropertyReadSideEffects.False;
2188
+ break;
2189
+ default:
2190
+ }
2191
+ switch (config.propertyWriteSideEffects) {
2192
+ case "always":
2193
+ normalizedConfig.propertyWriteSideEffects = BindingPropertyWriteSideEffects.Always;
2194
+ break;
2195
+ case false:
2196
+ normalizedConfig.propertyWriteSideEffects = BindingPropertyWriteSideEffects.False;
2197
+ break;
2198
+ default:
2199
+ }
2200
+ if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
2201
+ else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
2202
+ external: true,
2203
+ sideEffects: false
2204
+ }, {
2205
+ external: false,
2206
+ sideEffects: true
2207
+ }];
2208
+ else normalizedConfig.moduleSideEffects = config.moduleSideEffects;
2209
+ return normalizedConfig;
2210
+ }
2211
+ function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative) {
2212
+ if (makeAbsoluteExternalsRelative === "ifRelativeSource") return { type: "IfRelativeSource" };
2213
+ if (typeof makeAbsoluteExternalsRelative === "boolean") return {
2214
+ type: "Bool",
2215
+ field0: makeAbsoluteExternalsRelative
2216
+ };
2217
+ }
2218
+ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
2219
+ if (preserveEntrySignatures == void 0) return;
2220
+ else if (typeof preserveEntrySignatures === "string") return {
2221
+ type: "String",
2222
+ field0: preserveEntrySignatures
2223
+ };
2224
+ else return {
2225
+ type: "Bool",
2226
+ field0: preserveEntrySignatures
2227
+ };
2228
+ }
2229
+
2230
+ //#endregion
2231
+ export { description as C, VERSION as S, LOG_LEVEL_DEBUG as _, aggregateBindingErrorsIntoJsError as a, LOG_LEVEL_WARN as b, transformToRollupOutput as c, transformAssetSource as d, lazyProp as f, normalizeLog as g, normalizeHook as h, transformModuleInfo as i, transformRenderedChunk as l, MinimalPluginContextImpl as m, PluginContextData as n, normalizeBindingResult as o, PlainObjectLike as p, bindingifyPlugin as r, unwrapBindingResult as s, bindingifyInputOptions as t, __decorate as u, LOG_LEVEL_ERROR as v, version as w, logLevelPriority as x, LOG_LEVEL_INFO as y };