@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.10

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