@rolldown/browser 1.0.0-beta.49 → 1.0.0-beta.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/cli.mjs +12 -8
  2. package/dist/config.d.mts +3 -3
  3. package/dist/config.mjs +9 -5
  4. package/dist/constructors-DoUEJY6G.js +65 -0
  5. package/dist/experimental-index.browser.mjs +17 -11
  6. package/dist/experimental-index.d.mts +52 -15
  7. package/dist/experimental-index.mjs +21 -13
  8. package/dist/filter-index.d.mts +3 -3
  9. package/dist/filter-index.mjs +2 -1
  10. package/dist/index.browser.mjs +161 -2
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +36 -4
  13. package/dist/normalize-string-or-regex-BXFT9GiS.js +830 -0
  14. package/dist/parallel-plugin-worker.mjs +5 -4
  15. package/dist/parallel-plugin.d.mts +3 -3
  16. package/dist/parse-ast-index.d.mts +1 -1
  17. package/dist/parse-ast-index.mjs +1 -1
  18. package/dist/plugins-index.browser.mjs +2 -2
  19. package/dist/plugins-index.d.mts +3 -3
  20. package/dist/plugins-index.mjs +3 -2
  21. package/dist/rolldown-binding.wasi-browser.js +5 -2
  22. package/dist/rolldown-binding.wasi.cjs +5 -2
  23. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  24. package/dist/{src-CnMyHYgB.js → rolldown-build-C0UB1WZy.js} +32 -756
  25. package/dist/shared/{binding-B4uTNiw2.d.mts → binding-lSvYApx7.d.mts} +198 -89
  26. package/dist/shared/bindingify-input-options-CSdAtTcQ.mjs +1568 -0
  27. package/dist/shared/{composable-filters-CBpK2Fbc.mjs → composable-filters-DZ5ToxRJ.mjs} +1 -22
  28. package/dist/shared/constructors-DF6M1PTb.mjs +65 -0
  29. package/dist/shared/constructors-DgFF472b.d.mts +31 -0
  30. package/dist/shared/{define-config-BAQ9c-hh.d.mts → define-config-BKu-xa_0.d.mts} +10 -49
  31. package/dist/shared/define-config-DfeZGBEt.mjs +7 -0
  32. package/dist/shared/{load-config-DQI-2sfE.mjs → load-config-Beo_LOwd.mjs} +1 -1
  33. package/dist/shared/misc-5GYLGQ20.mjs +22 -0
  34. package/dist/shared/normalize-string-or-regex-DvECZN2V.mjs +629 -0
  35. package/dist/shared/{parse-ast-index-D9jH_38U.mjs → parse-ast-index-C_M-Y4oC.mjs} +3 -3
  36. package/dist/shared/{prompt-Ckjl2FdJ.mjs → prompt-pmGBC3ws.mjs} +1 -1
  37. package/dist/shared/rolldown-BhV7L6Kg.mjs +10 -0
  38. package/dist/shared/rolldown-build-DYR94CyF.mjs +2121 -0
  39. package/dist/shared/utils-BJWI2OzT.d.mts +62 -0
  40. package/dist/shared/watch-Cjxo-3u4.mjs +338 -0
  41. package/package.json +1 -1
  42. package/dist/constructors-EhfoQfqh.js +0 -68
  43. package/dist/normalize-string-or-regex-d47jXr3r.js +0 -231
  44. package/dist/shared/constructors-CaN9lKj2.d.mts +0 -32
  45. package/dist/shared/constructors-DcEzB0nc.mjs +0 -68
  46. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +0 -46
  47. package/dist/shared/src-CZ_U2fML.mjs +0 -4597
  48. package/dist/shared/utils-CduIqa7h.d.mts +0 -18
@@ -0,0 +1,830 @@
1
+ import { BindingCallableBuiltinPlugin } from "./rolldown-binding.wasi-browser.js";
2
+
3
+ //#region src/utils/code-frame.ts
4
+ function spaces(index) {
5
+ let result = "";
6
+ while (index--) result += " ";
7
+ return result;
8
+ }
9
+ function tabsToSpaces(value) {
10
+ return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
11
+ }
12
+ const LINE_TRUNCATE_LENGTH = 120;
13
+ const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
14
+ const ELLIPSIS = "...";
15
+ function getCodeFrame(source, line, column) {
16
+ let lines = source.split("\n");
17
+ if (line > lines.length) return "";
18
+ const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
19
+ const frameStart = Math.max(0, line - 3);
20
+ let frameEnd = Math.min(line + 2, lines.length);
21
+ lines = lines.slice(frameStart, frameEnd);
22
+ while (!/\S/.test(lines[lines.length - 1])) {
23
+ lines.pop();
24
+ frameEnd -= 1;
25
+ }
26
+ const digits = String(frameEnd).length;
27
+ return lines.map((sourceLine, index) => {
28
+ const isErrorLine = frameStart + index + 1 === line;
29
+ let lineNumber = String(index + frameStart + 1);
30
+ while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
31
+ let displayedLine = tabsToSpaces(sourceLine);
32
+ if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
33
+ if (isErrorLine) {
34
+ const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
35
+ return `${lineNumber}: ${displayedLine}\n${indicator}`;
36
+ }
37
+ return `${lineNumber}: ${displayedLine}`;
38
+ }).join("\n");
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/log/locate-character/index.js
43
+ /** @typedef {import('./types').Location} Location */
44
+ /**
45
+ * @param {import('./types').Range} range
46
+ * @param {number} index
47
+ */
48
+ function rangeContains(range, index) {
49
+ return range.start <= index && index < range.end;
50
+ }
51
+ /**
52
+ * @param {string} source
53
+ * @param {import('./types').Options} [options]
54
+ */
55
+ function getLocator(source, options = {}) {
56
+ const { offsetLine = 0, offsetColumn = 0 } = options;
57
+ let start = 0;
58
+ const ranges = source.split("\n").map((line, i$1) => {
59
+ const end = start + line.length + 1;
60
+ /** @type {import('./types').Range} */
61
+ const range = {
62
+ start,
63
+ end,
64
+ line: i$1
65
+ };
66
+ start = end;
67
+ return range;
68
+ });
69
+ let i = 0;
70
+ /**
71
+ * @param {string | number} search
72
+ * @param {number} [index]
73
+ * @returns {Location | undefined}
74
+ */
75
+ function locator(search, index) {
76
+ if (typeof search === "string") search = source.indexOf(search, index ?? 0);
77
+ if (search === -1) return void 0;
78
+ let range = ranges[i];
79
+ const d = search >= range.end ? 1 : -1;
80
+ while (range) {
81
+ if (rangeContains(range, search)) return {
82
+ line: offsetLine + range.line,
83
+ column: offsetColumn + search - range.start,
84
+ character: search
85
+ };
86
+ i += d;
87
+ range = ranges[i];
88
+ }
89
+ }
90
+ return locator;
91
+ }
92
+ /**
93
+ * @param {string} source
94
+ * @param {string | number} search
95
+ * @param {import('./types').Options} [options]
96
+ * @returns {Location | undefined}
97
+ */
98
+ function locate(source, search, options) {
99
+ return getLocator(source, options)(search, options && options.startIndex);
100
+ }
101
+
102
+ //#endregion
103
+ //#region src/log/logs.ts
104
+ const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER";
105
+ function logParseError(message) {
106
+ return {
107
+ code: PARSE_ERROR,
108
+ message
109
+ };
110
+ }
111
+ function logInvalidLogPosition(pluginName) {
112
+ return {
113
+ code: INVALID_LOG_POSITION,
114
+ message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
115
+ };
116
+ }
117
+ function logInputHookInOutputPlugin(pluginName, hookName) {
118
+ return {
119
+ code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
120
+ message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
121
+ };
122
+ }
123
+ function logCycleLoading(pluginName, moduleId) {
124
+ return {
125
+ code: CYCLE_LOADING,
126
+ message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
127
+ };
128
+ }
129
+ function logMultiplyNotifyOption() {
130
+ return {
131
+ code: MULTIPLY_NOTIFY_OPTION,
132
+ message: `Found multiply notify option at watch options, using first one to start notify watcher.`
133
+ };
134
+ }
135
+ function logNoFileSystemInBrowser(method) {
136
+ return {
137
+ code: NO_FS_IN_BROWSER,
138
+ message: `Cannot access the file system (via "${method}") when using the browser build of Rolldown.`
139
+ };
140
+ }
141
+ function logPluginError(error$1, plugin, { hook, id } = {}) {
142
+ try {
143
+ const code = error$1.code;
144
+ if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
145
+ error$1.code = PLUGIN_ERROR;
146
+ error$1.plugin = plugin;
147
+ if (hook) error$1.hook = hook;
148
+ if (id) error$1.id = id;
149
+ } catch (_) {} finally {
150
+ return error$1;
151
+ }
152
+ }
153
+ function error(base) {
154
+ if (!(base instanceof Error)) {
155
+ base = Object.assign(new Error(base.message), base);
156
+ Object.defineProperty(base, "name", {
157
+ value: "RollupError",
158
+ writable: true
159
+ });
160
+ }
161
+ throw base;
162
+ }
163
+ function augmentCodeLocation(properties, pos, source, id) {
164
+ if (typeof pos === "object") {
165
+ const { line, column } = pos;
166
+ properties.loc = {
167
+ column,
168
+ file: id,
169
+ line
170
+ };
171
+ } else {
172
+ properties.pos = pos;
173
+ const location = locate(source, pos, { offsetLine: 1 });
174
+ if (!location) return;
175
+ const { line, column } = location;
176
+ properties.loc = {
177
+ column,
178
+ file: id,
179
+ line
180
+ };
181
+ }
182
+ if (properties.frame === void 0) {
183
+ const { line, column } = properties.loc;
184
+ properties.frame = getCodeFrame(source, line, column);
185
+ }
186
+ }
187
+
188
+ //#endregion
189
+ //#region src/utils/misc.ts
190
+ function arraify(value) {
191
+ return Array.isArray(value) ? value : [value];
192
+ }
193
+ function unimplemented(info) {
194
+ if (info) throw new Error(`unimplemented: ${info}`);
195
+ throw new Error("unimplemented");
196
+ }
197
+ function unreachable(info) {
198
+ if (info) throw new Error(`unreachable: ${info}`);
199
+ throw new Error("unreachable");
200
+ }
201
+ function unsupported(info) {
202
+ throw new Error(`UNSUPPORTED: ${info}`);
203
+ }
204
+ function noop(..._args) {}
205
+
206
+ //#endregion
207
+ //#region src/log/logging.ts
208
+ const LOG_LEVEL_SILENT = "silent";
209
+ const LOG_LEVEL_ERROR = "error";
210
+ const LOG_LEVEL_WARN = "warn";
211
+ const LOG_LEVEL_INFO = "info";
212
+ const LOG_LEVEL_DEBUG = "debug";
213
+ const logLevelPriority = {
214
+ [LOG_LEVEL_DEBUG]: 0,
215
+ [LOG_LEVEL_INFO]: 1,
216
+ [LOG_LEVEL_WARN]: 2,
217
+ [LOG_LEVEL_SILENT]: 3
218
+ };
219
+
220
+ //#endregion
221
+ //#region src/log/log-handler.ts
222
+ const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
223
+ function getLogHandler(level, code, logger, pluginName, logLevel) {
224
+ if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
225
+ return (log, pos) => {
226
+ if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
227
+ log = normalizeLog(log);
228
+ if (log.code && !log.pluginCode) log.pluginCode = log.code;
229
+ log.code = code;
230
+ log.plugin = pluginName;
231
+ logger(level, log);
232
+ };
233
+ }
234
+
235
+ //#endregion
236
+ //#region package.json
237
+ var version = "1.0.0-beta.51";
238
+
239
+ //#endregion
240
+ //#region src/version.ts
241
+ const VERSION = version;
242
+
243
+ //#endregion
244
+ //#region src/plugin/minimal-plugin-context.ts
245
+ var MinimalPluginContextImpl = class {
246
+ info;
247
+ warn;
248
+ debug;
249
+ meta;
250
+ constructor(onLog, logLevel, pluginName, watchMode, hookName) {
251
+ this.pluginName = pluginName;
252
+ this.hookName = hookName;
253
+ this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
254
+ this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
255
+ this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
256
+ this.meta = {
257
+ rollupVersion: "4.23.0",
258
+ rolldownVersion: VERSION,
259
+ watchMode
260
+ };
261
+ }
262
+ error(e) {
263
+ return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
264
+ }
265
+ };
266
+
267
+ //#endregion
268
+ //#region src/types/plain-object-like.ts
269
+ const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
270
+ /**
271
+ * Base class for classes that use `@lazyProp` decorated properties.
272
+ *
273
+ * **Design Pattern in Rolldown:**
274
+ * This is a common pattern in Rolldown due to its three-layer architecture:
275
+ * TypeScript API → NAPI Bindings → Rust Core
276
+ *
277
+ * **Why we use getters:**
278
+ * For performance - to lazily fetch data from Rust bindings only when needed,
279
+ * rather than eagerly fetching all data during object construction.
280
+ *
281
+ * **The problem:**
282
+ * Getters defined on class prototypes are non-enumerable by default, which breaks:
283
+ * - Object spread operators ({...obj})
284
+ * - Object.keys() and similar methods
285
+ * - Standard JavaScript object semantics
286
+ *
287
+ * **The solution:**
288
+ * This base class automatically converts `@lazyProp` decorated getters into
289
+ * own enumerable getters on each instance during construction.
290
+ *
291
+ * **Result:**
292
+ * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
293
+ *
294
+ * @example
295
+ * ```typescript
296
+ * class MyClass extends PlainObjectLike {
297
+ * @lazyProp
298
+ * get myProp() {
299
+ * return fetchFromRustBinding();
300
+ * }
301
+ * }
302
+ * ```
303
+ */
304
+ var PlainObjectLike = class {
305
+ constructor() {
306
+ setupLazyProperties(this);
307
+ }
308
+ };
309
+ /**
310
+ * Set up lazy properties as own getters on an instance.
311
+ * This is called automatically by the `PlainObjectLike` base class constructor.
312
+ *
313
+ * @param instance - The instance to set up lazy properties on
314
+ * @internal
315
+ */
316
+ function setupLazyProperties(instance) {
317
+ const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
318
+ if (!lazyFields) return;
319
+ for (const [propertyKey, originalGetter] of lazyFields.entries()) {
320
+ let cachedValue;
321
+ let hasValue = false;
322
+ Object.defineProperty(instance, propertyKey, {
323
+ get() {
324
+ if (!hasValue) {
325
+ cachedValue = originalGetter.call(this);
326
+ hasValue = true;
327
+ }
328
+ return cachedValue;
329
+ },
330
+ enumerable: true,
331
+ configurable: true
332
+ });
333
+ }
334
+ }
335
+ /**
336
+ * Get all lazy field names from a class instance.
337
+ *
338
+ * @param instance - Instance to inspect
339
+ * @returns Set of lazy property names
340
+ */
341
+ function getLazyFields(instance) {
342
+ const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
343
+ return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
344
+ }
345
+
346
+ //#endregion
347
+ //#region src/decorators/lazy.ts
348
+ /**
349
+ * Decorator that marks a getter as lazy-evaluated and cached.
350
+ *
351
+ * **What "lazy" means here:**
352
+ * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
353
+ * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
354
+ * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
355
+ *
356
+ * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
357
+ * properties on each instance (not on the prototype). This ensures they:
358
+ * - Appear in Object.keys() and Object.getOwnPropertyNames()
359
+ * - Are included in object spreads ({...obj})
360
+ * - Are enumerable in for...in loops
361
+ *
362
+ * Classes using this decorator must extend `PlainObjectLike` base class.
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * class MyClass extends PlainObjectLike {
367
+ * @lazyProp
368
+ * get expensiveValue() {
369
+ * return someExpensiveComputation();
370
+ * }
371
+ * }
372
+ * ```
373
+ */
374
+ function lazyProp(target, propertyKey, descriptor) {
375
+ if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
376
+ const originalGetter = descriptor.get;
377
+ target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
378
+ return {
379
+ enumerable: false,
380
+ configurable: true
381
+ };
382
+ }
383
+
384
+ //#endregion
385
+ //#region src/utils/asset-source.ts
386
+ function transformAssetSource(bindingAssetSource$1) {
387
+ return bindingAssetSource$1.inner;
388
+ }
389
+ function bindingAssetSource(source) {
390
+ return { inner: source };
391
+ }
392
+
393
+ //#endregion
394
+ //#region \0@oxc-project+runtime@0.98.0/helpers/decorate.js
395
+ function __decorate(decorators, target, key, desc) {
396
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
397
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
398
+ 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;
399
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
400
+ }
401
+
402
+ //#endregion
403
+ //#region src/types/output-asset-impl.ts
404
+ var OutputAssetImpl = class extends PlainObjectLike {
405
+ type = "asset";
406
+ constructor(bindingAsset) {
407
+ super();
408
+ this.bindingAsset = bindingAsset;
409
+ }
410
+ get fileName() {
411
+ return this.bindingAsset.getFileName();
412
+ }
413
+ get originalFileName() {
414
+ return this.bindingAsset.getOriginalFileName() || null;
415
+ }
416
+ get originalFileNames() {
417
+ return this.bindingAsset.getOriginalFileNames();
418
+ }
419
+ get name() {
420
+ return this.bindingAsset.getName() ?? void 0;
421
+ }
422
+ get names() {
423
+ return this.bindingAsset.getNames();
424
+ }
425
+ get source() {
426
+ return transformAssetSource(this.bindingAsset.getSource());
427
+ }
428
+ __rolldown_external_memory_handle__(keepDataAlive) {
429
+ if (keepDataAlive) this.#evaluateAllLazyFields();
430
+ return this.bindingAsset.dropInner();
431
+ }
432
+ #evaluateAllLazyFields() {
433
+ for (const field of getLazyFields(this)) this[field];
434
+ }
435
+ };
436
+ __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
437
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
438
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
439
+ __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
440
+ __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
441
+ __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
442
+
443
+ //#endregion
444
+ //#region src/utils/transform-rendered-module.ts
445
+ function transformToRenderedModule(bindingRenderedModule) {
446
+ return {
447
+ get code() {
448
+ return bindingRenderedModule.code;
449
+ },
450
+ get renderedLength() {
451
+ return bindingRenderedModule.code?.length || 0;
452
+ },
453
+ get renderedExports() {
454
+ return bindingRenderedModule.renderedExports;
455
+ }
456
+ };
457
+ }
458
+
459
+ //#endregion
460
+ //#region src/utils/transform-rendered-chunk.ts
461
+ function transformRenderedChunk(chunk) {
462
+ let modules = null;
463
+ return {
464
+ type: "chunk",
465
+ get name() {
466
+ return chunk.name;
467
+ },
468
+ get isEntry() {
469
+ return chunk.isEntry;
470
+ },
471
+ get isDynamicEntry() {
472
+ return chunk.isDynamicEntry;
473
+ },
474
+ get facadeModuleId() {
475
+ return chunk.facadeModuleId;
476
+ },
477
+ get moduleIds() {
478
+ return chunk.moduleIds;
479
+ },
480
+ get exports() {
481
+ return chunk.exports;
482
+ },
483
+ get fileName() {
484
+ return chunk.fileName;
485
+ },
486
+ get imports() {
487
+ return chunk.imports;
488
+ },
489
+ get dynamicImports() {
490
+ return chunk.dynamicImports;
491
+ },
492
+ get modules() {
493
+ if (!modules) modules = transformChunkModules(chunk.modules);
494
+ return modules;
495
+ }
496
+ };
497
+ }
498
+ function transformChunkModules(modules) {
499
+ const result = {};
500
+ for (let i = 0; i < modules.values.length; i++) {
501
+ let key = modules.keys[i];
502
+ const mod = modules.values[i];
503
+ result[key] = transformToRenderedModule(mod);
504
+ }
505
+ return result;
506
+ }
507
+
508
+ //#endregion
509
+ //#region src/types/output-chunk-impl.ts
510
+ var OutputChunkImpl = class extends PlainObjectLike {
511
+ type = "chunk";
512
+ constructor(bindingChunk) {
513
+ super();
514
+ this.bindingChunk = bindingChunk;
515
+ }
516
+ get fileName() {
517
+ return this.bindingChunk.getFileName();
518
+ }
519
+ get name() {
520
+ return this.bindingChunk.getName();
521
+ }
522
+ get exports() {
523
+ return this.bindingChunk.getExports();
524
+ }
525
+ get isEntry() {
526
+ return this.bindingChunk.getIsEntry();
527
+ }
528
+ get facadeModuleId() {
529
+ return this.bindingChunk.getFacadeModuleId() || null;
530
+ }
531
+ get isDynamicEntry() {
532
+ return this.bindingChunk.getIsDynamicEntry();
533
+ }
534
+ get sourcemapFileName() {
535
+ return this.bindingChunk.getSourcemapFileName() || null;
536
+ }
537
+ get preliminaryFileName() {
538
+ return this.bindingChunk.getPreliminaryFileName();
539
+ }
540
+ get code() {
541
+ return this.bindingChunk.getCode();
542
+ }
543
+ get modules() {
544
+ return transformChunkModules(this.bindingChunk.getModules());
545
+ }
546
+ get imports() {
547
+ return this.bindingChunk.getImports();
548
+ }
549
+ get dynamicImports() {
550
+ return this.bindingChunk.getDynamicImports();
551
+ }
552
+ get moduleIds() {
553
+ return this.bindingChunk.getModuleIds();
554
+ }
555
+ get map() {
556
+ const mapString = this.bindingChunk.getMap();
557
+ return mapString ? transformToRollupSourceMap(mapString) : null;
558
+ }
559
+ __rolldown_external_memory_handle__(keepDataAlive) {
560
+ if (keepDataAlive) this.#evaluateAllLazyFields();
561
+ return this.bindingChunk.dropInner();
562
+ }
563
+ #evaluateAllLazyFields() {
564
+ for (const field of getLazyFields(this)) this[field];
565
+ }
566
+ };
567
+ __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
568
+ __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
569
+ __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
570
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
571
+ __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
572
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
573
+ __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
574
+ __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
575
+ __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
576
+ __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
577
+ __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
578
+ __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
579
+ __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
580
+ __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
581
+
582
+ //#endregion
583
+ //#region src/types/sourcemap.ts
584
+ function bindingifySourcemap(map) {
585
+ if (map == null) return;
586
+ return { inner: typeof map === "string" ? map : {
587
+ file: map.file ?? void 0,
588
+ mappings: map.mappings,
589
+ sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
590
+ sources: map.sources?.map((s) => s ?? void 0),
591
+ sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
592
+ names: map.names,
593
+ x_google_ignoreList: map.x_google_ignoreList,
594
+ debugId: "debugId" in map ? map.debugId : void 0
595
+ } };
596
+ }
597
+
598
+ //#endregion
599
+ //#region src/utils/transform-to-rollup-output.ts
600
+ function transformToRollupSourceMap(map) {
601
+ const obj = {
602
+ ...JSON.parse(map),
603
+ toString() {
604
+ return JSON.stringify(obj);
605
+ },
606
+ toUrl() {
607
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
608
+ }
609
+ };
610
+ return obj;
611
+ }
612
+ function transformToRollupOutputChunk(bindingChunk) {
613
+ return new OutputChunkImpl(bindingChunk);
614
+ }
615
+ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
616
+ const chunk = {
617
+ type: "chunk",
618
+ get code() {
619
+ return bindingChunk.getCode();
620
+ },
621
+ fileName: bindingChunk.getFileName(),
622
+ name: bindingChunk.getName(),
623
+ get modules() {
624
+ return transformChunkModules(bindingChunk.getModules());
625
+ },
626
+ get imports() {
627
+ return bindingChunk.getImports();
628
+ },
629
+ get dynamicImports() {
630
+ return bindingChunk.getDynamicImports();
631
+ },
632
+ exports: bindingChunk.getExports(),
633
+ isEntry: bindingChunk.getIsEntry(),
634
+ facadeModuleId: bindingChunk.getFacadeModuleId() || null,
635
+ isDynamicEntry: bindingChunk.getIsDynamicEntry(),
636
+ get moduleIds() {
637
+ return bindingChunk.getModuleIds();
638
+ },
639
+ get map() {
640
+ const map = bindingChunk.getMap();
641
+ return map ? transformToRollupSourceMap(map) : null;
642
+ },
643
+ sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
644
+ preliminaryFileName: bindingChunk.getPreliminaryFileName()
645
+ };
646
+ const cache = {};
647
+ return new Proxy(chunk, {
648
+ get(target, p) {
649
+ if (p in cache) return cache[p];
650
+ const value = target[p];
651
+ cache[p] = value;
652
+ return value;
653
+ },
654
+ set(_target, p, newValue) {
655
+ cache[p] = newValue;
656
+ changed.updated.add(bindingChunk.getFileName());
657
+ return true;
658
+ },
659
+ has(target, p) {
660
+ if (p in cache) return true;
661
+ return p in target;
662
+ }
663
+ });
664
+ }
665
+ function transformToRollupOutputAsset(bindingAsset) {
666
+ return new OutputAssetImpl(bindingAsset);
667
+ }
668
+ function transformToMutableRollupOutputAsset(bindingAsset, changed) {
669
+ const asset = {
670
+ type: "asset",
671
+ fileName: bindingAsset.getFileName(),
672
+ originalFileName: bindingAsset.getOriginalFileName() || null,
673
+ originalFileNames: bindingAsset.getOriginalFileNames(),
674
+ get source() {
675
+ return transformAssetSource(bindingAsset.getSource());
676
+ },
677
+ name: bindingAsset.getName() ?? void 0,
678
+ names: bindingAsset.getNames()
679
+ };
680
+ const cache = {};
681
+ return new Proxy(asset, {
682
+ get(target, p) {
683
+ if (p in cache) return cache[p];
684
+ const value = target[p];
685
+ cache[p] = value;
686
+ return value;
687
+ },
688
+ set(_target, p, newValue) {
689
+ cache[p] = newValue;
690
+ changed.updated.add(bindingAsset.getFileName());
691
+ return true;
692
+ }
693
+ });
694
+ }
695
+ function transformToRollupOutput(output) {
696
+ const { chunks, assets } = output;
697
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
698
+ }
699
+ function transformToMutableRollupOutput(output, changed) {
700
+ const { chunks, assets } = output;
701
+ return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
702
+ }
703
+ function transformToOutputBundle(context, output, changed) {
704
+ const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
705
+ return new Proxy(bundle, {
706
+ set(_target, _p, _newValue, _receiver) {
707
+ const originalStackTraceLimit = Error.stackTraceLimit;
708
+ Error.stackTraceLimit = 2;
709
+ 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.";
710
+ const stack = new Error(message).stack ?? message;
711
+ Error.stackTraceLimit = originalStackTraceLimit;
712
+ context.warn({
713
+ message: stack,
714
+ code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
715
+ });
716
+ return true;
717
+ },
718
+ deleteProperty(target, property) {
719
+ if (typeof property === "string") changed.deleted.add(property);
720
+ return true;
721
+ }
722
+ });
723
+ }
724
+ function collectChangedBundle(changed, bundle) {
725
+ const changes = {};
726
+ for (const key in bundle) {
727
+ if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
728
+ const item = bundle[key];
729
+ if (item.type === "asset") changes[key] = {
730
+ filename: item.fileName,
731
+ originalFileNames: item.originalFileNames,
732
+ source: bindingAssetSource(item.source),
733
+ names: item.names
734
+ };
735
+ else changes[key] = {
736
+ code: item.code,
737
+ filename: item.fileName,
738
+ name: item.name,
739
+ isEntry: item.isEntry,
740
+ exports: item.exports,
741
+ modules: {},
742
+ imports: item.imports,
743
+ dynamicImports: item.dynamicImports,
744
+ facadeModuleId: item.facadeModuleId || void 0,
745
+ isDynamicEntry: item.isDynamicEntry,
746
+ moduleIds: item.moduleIds,
747
+ map: bindingifySourcemap(item.map),
748
+ sourcemapFilename: item.sourcemapFileName || void 0,
749
+ preliminaryFilename: item.preliminaryFileName
750
+ };
751
+ }
752
+ return {
753
+ changes,
754
+ deleted: changed.deleted
755
+ };
756
+ }
757
+
758
+ //#endregion
759
+ //#region src/builtin-plugin/utils.ts
760
+ var BuiltinPlugin = class {
761
+ constructor(name, _options) {
762
+ this.name = name;
763
+ this._options = _options;
764
+ }
765
+ };
766
+ function makeBuiltinPluginCallable(plugin) {
767
+ let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
768
+ const wrappedPlugin = plugin;
769
+ for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
770
+ try {
771
+ return await callablePlugin[key](...args);
772
+ } catch (e) {
773
+ if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
774
+ return error(logPluginError(e, plugin.name, {
775
+ hook: key,
776
+ id: key === "transform" ? args[2] : void 0
777
+ }));
778
+ }
779
+ };
780
+ return wrappedPlugin;
781
+ }
782
+ function bindingifyBuiltInPlugin(plugin) {
783
+ return {
784
+ __name: plugin.name,
785
+ options: plugin._options
786
+ };
787
+ }
788
+ function bindingifyViteHtmlPlugin(plugin, onLog, logLevel, watchMode) {
789
+ const { preHooks, normalHooks, postHooks, applyHtmlTransforms, ...options } = plugin._options;
790
+ if (preHooks.length + normalHooks.length + postHooks.length > 0) return {
791
+ __name: plugin.name,
792
+ options: {
793
+ ...options,
794
+ transformIndexHtml: async (html, path, filename, hook, output, chunk) => {
795
+ const pluginContext = new MinimalPluginContextImpl(onLog, logLevel, plugin.name, watchMode, "transformIndexHtml");
796
+ const context = {
797
+ path,
798
+ filename,
799
+ bundle: output ? transformToOutputBundle(pluginContext, output, {
800
+ updated: /* @__PURE__ */ new Set(),
801
+ deleted: /* @__PURE__ */ new Set()
802
+ }) : void 0,
803
+ chunk: chunk ? transformToRollupOutputChunk(chunk) : void 0
804
+ };
805
+ switch (hook) {
806
+ case "transform": return await applyHtmlTransforms(html, preHooks, pluginContext, context);
807
+ case "generateBundle": return await applyHtmlTransforms(html, [...normalHooks, ...postHooks], pluginContext, context);
808
+ }
809
+ }
810
+ }
811
+ };
812
+ return {
813
+ __name: plugin.name,
814
+ options: plugin._options
815
+ };
816
+ }
817
+
818
+ //#endregion
819
+ //#region src/utils/normalize-string-or-regex.ts
820
+ function normalizedStringOrRegex(pattern) {
821
+ if (!pattern) return;
822
+ if (!isReadonlyArray(pattern)) return [pattern];
823
+ return pattern;
824
+ }
825
+ function isReadonlyArray(input) {
826
+ return Array.isArray(input);
827
+ }
828
+
829
+ //#endregion
830
+ export { logCycleLoading as A, logLevelPriority as C, unsupported as D, unreachable as E, logPluginError as F, locate as I, getCodeFrame as L, logMultiplyNotifyOption as M, logNoFileSystemInBrowser as N, augmentCodeLocation as O, logParseError as P, LOG_LEVEL_WARN as S, unimplemented as T, VERSION as _, makeBuiltinPluginCallable as a, LOG_LEVEL_ERROR as b, transformToRollupOutput as c, __decorate as d, bindingAssetSource as f, MinimalPluginContextImpl as g, PlainObjectLike as h, bindingifyViteHtmlPlugin as i, logInputHookInOutputPlugin as j, error as k, bindingifySourcemap as l, lazyProp as m, BuiltinPlugin as n, collectChangedBundle as o, transformAssetSource as p, bindingifyBuiltInPlugin as r, transformToOutputBundle as s, normalizedStringOrRegex as t, transformRenderedChunk as u, normalizeLog as v, arraify as w, LOG_LEVEL_INFO as x, LOG_LEVEL_DEBUG as y };