@voidzero-dev/vite-plus-core 0.0.0-0bfcc90f.20260209-0731

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