@qds.dev/code 0.9.1 → 0.10.0

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