rolldown 1.0.0-beta.46 → 1.0.0-beta.48

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 (30) hide show
  1. package/dist/cli-setup.mjs +2 -2
  2. package/dist/cli.mjs +23 -10
  3. package/dist/config.d.mts +3 -2
  4. package/dist/config.mjs +7 -5
  5. package/dist/experimental-index.d.mts +18 -58
  6. package/dist/experimental-index.mjs +47 -112
  7. package/dist/filter-index.d.mts +3 -2
  8. package/dist/filter-index.mjs +1 -1
  9. package/dist/index.d.mts +3 -2
  10. package/dist/index.mjs +6 -4
  11. package/dist/parallel-plugin-worker.mjs +7 -5
  12. package/dist/parallel-plugin.d.mts +3 -2
  13. package/dist/parse-ast-index.d.mts +1 -1
  14. package/dist/parse-ast-index.mjs +3 -2
  15. package/dist/plugins-index.d.mts +31 -0
  16. package/dist/plugins-index.mjs +41 -0
  17. package/dist/shared/{binding-DOZoR4bu.mjs → binding-Drb7x8Xk.mjs} +28 -47
  18. package/dist/shared/{binding-CCMrV5an.d.mts → binding-TAvxYaaL.d.mts} +49 -58
  19. package/dist/shared/constructors-CPzYu5kE.mjs +68 -0
  20. package/dist/shared/constructors-DlLr_UMo.d.mts +32 -0
  21. package/dist/shared/{define-config-Czc1YEBi.d.mts → define-config-De0wBOd9.d.mts} +4 -62
  22. package/dist/shared/{load-config-Brje6-4J.mjs → load-config-CgaGIE8O.mjs} +1 -1
  23. package/dist/shared/{parse-ast-index-oPgrkdqc.mjs → logs-CSQ_UMWp.mjs} +2 -124
  24. package/dist/shared/normalize-string-or-regex-C20xiVob.mjs +47 -0
  25. package/dist/shared/parse-ast-index-khff6py4.mjs +82 -0
  26. package/dist/shared/{prompt-YGfbLmz5.mjs → prompt-sxF8x3Tv.mjs} +1 -1
  27. package/dist/shared/{src-D1weNlnG.mjs → src-cg9B-h5W.mjs} +234 -203
  28. package/dist/shared/utils-CzdPrevI.d.mts +18 -0
  29. package/package.json +18 -18
  30. /package/dist/shared/{misc-usdOVIou.mjs → misc-DpQNcSw4.mjs} +0 -0
@@ -1,4 +1,5 @@
1
- import { B as TransformOptions$1, I as ParserOptions, L as PreRenderedChunk, M as JsxOptions, N as MinifyOptions$1, O as BindingWatcherEvent, _ as BindingRenderedChunk, b as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, f as BindingMagicString, i as BindingBundlerImpl, k as ExternalMemoryStatus, r as BindingBuiltinPluginName } from "./binding-CCMrV5an.mjs";
1
+ import { D as BindingWatcherBundler, L as ParserOptions, M as JsxOptions, N as MinifyOptions$1, O as BindingWatcherEvent, R as PreRenderedChunk, V as TransformOptions$1, d as BindingMagicString, g as BindingRenderedChunk, k as ExternalMemoryStatus, s as BindingHookResolveIdExtraArgs, y as BindingTransformHookExtraArgs } from "./binding-TAvxYaaL.mjs";
2
+ import { a as NullValue, i as MaybePromise, n as MakeAsync, o as PartialNull, r as MaybeArray, s as StringOrRegExp, t as BuiltinPlugin } from "./utils-CzdPrevI.mjs";
2
3
  import { TopLevelFilterExpression } from "@rolldown/pluginutils";
3
4
  import { Program } from "@oxc-project/types";
4
5
 
@@ -179,14 +180,6 @@ interface RolldownOutput extends ExternalMemoryHandle {
179
180
  output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
180
181
  }
181
182
  //#endregion
182
- //#region src/types/utils.d.ts
183
- type MaybePromise<T> = T | Promise<T>;
184
- type NullValue<T = void> = T | undefined | null | void;
185
- type PartialNull<T> = { [P in keyof T]: T[P] | null };
186
- type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
187
- type MaybeArray<T> = T | T[];
188
- type StringOrRegExp = string | RegExp;
189
- //#endregion
190
183
  //#region src/options/output-options.d.ts
191
184
  type GeneratedCodePreset = "es5" | "es2015";
192
185
  interface GeneratedCodeOptions {
@@ -650,7 +643,6 @@ declare class RolldownBuild {
650
643
  static asyncRuntimeShutdown: boolean;
651
644
  constructor(inputOptions: InputOptions);
652
645
  get closed(): boolean;
653
- scan(): Promise<void>;
654
646
  generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
655
647
  write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
656
648
  /**
@@ -672,7 +664,7 @@ interface WatchOptions extends InputOptions {
672
664
  //#region src/api/watch/watch-emitter.d.ts
673
665
  type WatcherEvent = "close" | "event" | "restart" | "change";
674
666
  type ChangeEvent$1 = "create" | "update" | "delete";
675
- type RolldownWatchBuild = BindingBundlerImpl;
667
+ type RolldownWatchBuild = BindingWatcherBundler;
676
668
  type RolldownWatcherEvent = {
677
669
  code: "START";
678
670
  } | {
@@ -992,13 +984,6 @@ type SourceMapInput = ExistingRawSourceMap | string | null;
992
984
  //#region src/index.d.ts
993
985
  declare const VERSION: string;
994
986
  //#endregion
995
- //#region src/builtin-plugin/utils.d.ts
996
- declare class BuiltinPlugin {
997
- name: BindingBuiltinPluginName;
998
- _options?: unknown;
999
- constructor(name: BindingBuiltinPluginName, _options?: unknown);
1000
- }
1001
- //#endregion
1002
987
  //#region src/constants/plugin.d.ts
1003
988
  declare const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "buildEnd", "onLog", "resolveDynamicImport", "closeBundle", "closeWatcher", "watchChange"];
1004
989
  declare const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES: readonly ["augmentChunkHash", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "generateBundle"];
@@ -1602,33 +1587,6 @@ interface InputOptions {
1602
1587
  nativeMagicString?: boolean;
1603
1588
  };
1604
1589
  /**
1605
- * Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
1606
- *
1607
- * @deprecated Use `transform.define` instead. This top-level option will be removed in a future release.
1608
- *
1609
- * See `transform.define` for detailed documentation and examples.
1610
- */
1611
- define?: Record<string, string>;
1612
- /**
1613
- * Inject import statements on demand.
1614
- *
1615
- * @deprecated Use `transform.inject` instead. This top-level option will be removed in a future release.
1616
- *
1617
- * See `transform.inject` for detailed documentation and examples.
1618
- */
1619
- inject?: Record<string, string | [string, string]>;
1620
- /**
1621
- * Whether to add readable names to internal variables for profiling purposes.
1622
- *
1623
- * When enabled, generated code will use descriptive variable names that correspond
1624
- * to the original module names, making it easier to profile and debug the bundled code.
1625
- *
1626
- * @default true when minification is disabled, false when minification is enabled
1627
- *
1628
- * @deprecated Use `output.generatedCode.profilerNames` instead. This top-level option will be removed in a future release.
1629
- */
1630
- profilerNames?: boolean;
1631
- /**
1632
1590
  * Configure how the code is transformed. This process happens after the `transform` hook.
1633
1591
  *
1634
1592
  * To transpile [legacy decorators](https://github.com/tc39/proposal-decorators/tree/4ac0f4cd31bd0f2e8170cb4c5136e51671e46c8d), you could use
@@ -1647,22 +1605,6 @@ interface InputOptions {
1647
1605
  */
1648
1606
  transform?: TransformOptions;
1649
1607
  watch?: WatcherOptions | false;
1650
- /**
1651
- * Remove labeled statements with these label names.
1652
- *
1653
- * @deprecated Use `transform.dropLabels` instead. This top-level option will be removed in a future release.
1654
- *
1655
- * See `transform.dropLabels` for detailed documentation and examples.
1656
- */
1657
- dropLabels?: string[];
1658
- /**
1659
- * Keep function and class names after bundling.
1660
- *
1661
- * @deprecated Use `output.keepNames` instead. This top-level option will be removed in a future release.
1662
- *
1663
- * See `output.keepNames` for detailed documentation.
1664
- */
1665
- keepNames?: boolean;
1666
1608
  checks?: ChecksOptions;
1667
1609
  makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
1668
1610
  debug?: {
@@ -1701,4 +1643,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
1701
1643
  declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
1702
1644
  declare function defineConfig(config: ConfigExport): ConfigExport;
1703
1645
  //#endregion
1704
- export { InternalModuleFormat as $, BuiltinPlugin as A, SourceMap as At, GetModuleInfo as B, ResolveIdResult as C, PartialNull as Ct, SourceDescription as D, RenderedChunk as Dt, RolldownPluginOption as E, OutputChunk as Et, OutputBundle as F, LogLevelOption as Ft, PluginContextMeta as G, DefineParallelPluginResult as H, TreeshakingOptions as I, LogOrStringHandler as It, ModuleTypeFilter as J, GeneralHookFilter as K, TransformPluginContext as L, RollupError as Lt, ExistingRawSourceMap as M, ModuleInfo as Mt, SourceMapInput as N, SourcemapIgnoreListOption as Nt, TransformResult as O, RenderedModule as Ot, RolldownOptionsFunction as P, LogLevel as Pt, RolldownFsModule as Q, EmittedAsset as R, RollupLog as Rt, ResolveIdExtraOptions as S, MaybePromise as St, RolldownPlugin as T, OutputAsset as Tt, defineParallelPlugin as U, PluginContext as V, MinimalPluginContext as W, RolldownDirectoryEntry as X, BufferEncoding as Y, RolldownFileStats as Z, ModuleType as _, GlobalsFunction as _t, InputOption as a, RolldownWatcher as at, PartialResolvedId as b, OutputOptions as bt, OptimizationOptions as c, rolldown as ct, CustomPluginOptions as d, build as dt, NormalizedOutputOptions as et, FunctionPluginHooks as f, AddonFunction as ft, ModuleOptions as g, GeneratedCodePreset as gt, LoadResult as h, GeneratedCodeOptions as ht, ExternalOption as i, watch as it, VERSION as j, freeExternalMemory as jt, withFilter as k, RolldownOutput as kt, WatcherOptions as l, RolldownBuild as lt, ImportKind as m, ChunkingContext as mt, ConfigExport as n, LoggingFunction as nt, InputOptions as o, RolldownWatcherEvent as ot, HookFilterExtension as p, ChunkFileNamesFunction as pt, HookFilter as q, RolldownOptions as r, WarningHandlerWithDefault as rt, ModuleTypes as s, WatchOptions as st, defineConfig as t, NormalizedInputOptions as tt, AsyncPluginHooks as u, BuildOptions as ut, ObjectHook as v, MinifyOptions as vt, ResolvedId as w, StringOrRegExp as wt, Plugin as x, PreRenderedAsset as xt, ParallelPluginHooks as y, ModuleFormat as yt, EmittedFile as z, RollupLogWithString as zt };
1646
+ export { NormalizedOutputOptions as $, VERSION as A, LogLevel as At, PluginContext as B, ResolveIdResult as C, RenderedChunk as Ct, SourceDescription as D, freeExternalMemory as Dt, RolldownPluginOption as E, SourceMap as Et, TreeshakingOptions as F, RollupLogWithString as Ft, GeneralHookFilter as G, defineParallelPlugin as H, TransformPluginContext as I, BufferEncoding as J, HookFilter as K, EmittedAsset as L, SourceMapInput as M, LogOrStringHandler as Mt, RolldownOptionsFunction as N, RollupError as Nt, TransformResult as O, ModuleInfo as Ot, OutputBundle as P, RollupLog as Pt, InternalModuleFormat as Q, EmittedFile as R, ResolveIdExtraOptions as S, OutputChunk as St, RolldownPlugin as T, RolldownOutput as Tt, MinimalPluginContext as U, DefineParallelPluginResult as V, PluginContextMeta as W, RolldownFileStats as X, RolldownDirectoryEntry as Y, RolldownFsModule as Z, ModuleType as _, MinifyOptions as _t, InputOption as a, RolldownWatcherEvent as at, PartialResolvedId as b, PreRenderedAsset as bt, OptimizationOptions as c, RolldownBuild as ct, CustomPluginOptions as d, AddonFunction as dt, NormalizedInputOptions as et, FunctionPluginHooks as f, ChunkFileNamesFunction as ft, ModuleOptions as g, GlobalsFunction as gt, LoadResult as h, GeneratedCodePreset as ht, ExternalOption as i, RolldownWatcher as it, ExistingRawSourceMap as j, LogLevelOption as jt, withFilter as k, SourcemapIgnoreListOption as kt, WatcherOptions as l, BuildOptions as lt, ImportKind as m, GeneratedCodeOptions as mt, ConfigExport as n, WarningHandlerWithDefault as nt, InputOptions as o, WatchOptions as ot, HookFilterExtension as p, ChunkingContext as pt, ModuleTypeFilter as q, RolldownOptions as r, watch as rt, ModuleTypes as s, rolldown as st, defineConfig as t, LoggingFunction as tt, AsyncPluginHooks as u, build as ut, ObjectHook as v, ModuleFormat as vt, ResolvedId as w, RenderedModule as wt, Plugin as x, OutputAsset as xt, ParallelPluginHooks as y, OutputOptions as yt, GetModuleInfo as z };
@@ -1,4 +1,4 @@
1
- import { o as rolldown } from "./src-D1weNlnG.mjs";
1
+ import { o as rolldown } from "./src-cg9B-h5W.mjs";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { readdir } from "node:fs/promises";
@@ -1,6 +1,3 @@
1
- import { n as __toESM, t as require_binding } from "./binding-DOZoR4bu.mjs";
2
- import { styleText } from "node:util";
3
-
4
1
  //#region src/utils/code-frame.ts
5
2
  function spaces(index) {
6
3
  let result = "";
@@ -39,17 +36,6 @@ function getCodeFrame(source, line, column) {
39
36
  }).join("\n");
40
37
  }
41
38
 
42
- //#endregion
43
- //#region src/utils/style-text.ts
44
- /**
45
- * Cross-platform styleText utility that works in both Node.js and browser environments
46
- * In Node.js, it uses the native `styleText` from `node:util`
47
- * In browser, it provides empty styling functions for compatibility
48
- */
49
- function styleText$1(...args) {
50
- return styleText(...args);
51
- }
52
-
53
39
  //#endregion
54
40
  //#region src/log/locate-character/index.js
55
41
  /** @typedef {import('./types').Location} Location */
@@ -113,7 +99,7 @@ function locate(source, search, options) {
113
99
 
114
100
  //#endregion
115
101
  //#region src/log/logs.ts
116
- 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", DEPRECATED_DEFINE = "DEPRECATED_DEFINE", DEPRECATED_INJECT = "DEPRECATED_INJECT", DEPRECATED_PROFILER_NAMES = "DEPRECATED_PROFILER_NAMES", DEPRECATED_KEEP_NAMES = "DEPRECATED_KEEP_NAMES", DEPRECATED_DROP_LABELS = "DEPRECATED_DROP_LABELS";
102
+ 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";
117
103
  function logParseError(message) {
118
104
  return {
119
105
  code: PARSE_ERROR,
@@ -144,36 +130,6 @@ function logMultiplyNotifyOption() {
144
130
  message: `Found multiply notify option at watch options, using first one to start notify watcher.`
145
131
  };
146
132
  }
147
- function logDeprecatedDefine() {
148
- return {
149
- code: DEPRECATED_DEFINE,
150
- message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "define" option is deprecated. Use "transform.define" instead.`
151
- };
152
- }
153
- function logDeprecatedInject() {
154
- return {
155
- code: DEPRECATED_INJECT,
156
- message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "inject" option is deprecated. Use "transform.inject" instead.`
157
- };
158
- }
159
- function logDeprecatedProfilerNames() {
160
- return {
161
- code: DEPRECATED_PROFILER_NAMES,
162
- message: "The top-level \"profilerNames\" option is deprecated. Use \"output.generatedCode.profilerNames\" instead."
163
- };
164
- }
165
- function logDeprecatedKeepNames() {
166
- return {
167
- code: DEPRECATED_KEEP_NAMES,
168
- message: "The top-level \"keepNames\" option is deprecated. Use \"output.keepNames\" instead."
169
- };
170
- }
171
- function logDeprecatedDropLabels() {
172
- return {
173
- code: DEPRECATED_DROP_LABELS,
174
- message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "dropLabels" option is deprecated. Use "transform.dropLabels" instead.`
175
- };
176
- }
177
133
  function logPluginError(error$1, plugin, { hook, id } = {}) {
178
134
  try {
179
135
  const code = error$1.code;
@@ -222,82 +178,4 @@ function augmentCodeLocation(properties, pos, source, id) {
222
178
  }
223
179
 
224
180
  //#endregion
225
- //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
226
- function wrap$1(result) {
227
- let program, module, comments, errors;
228
- return {
229
- get program() {
230
- if (!program) program = jsonParseAst(result.program);
231
- return program;
232
- },
233
- get module() {
234
- if (!module) module = result.module;
235
- return module;
236
- },
237
- get comments() {
238
- if (!comments) comments = result.comments;
239
- return comments;
240
- },
241
- get errors() {
242
- if (!errors) errors = result.errors;
243
- return errors;
244
- }
245
- };
246
- }
247
- function jsonParseAst(programJson) {
248
- const { node: program, fixes } = JSON.parse(programJson);
249
- for (const fixPath of fixes) applyFix(program, fixPath);
250
- return program;
251
- }
252
- function applyFix(program, fixPath) {
253
- let node = program;
254
- for (const key of fixPath) node = node[key];
255
- if (node.bigint) node.value = BigInt(node.bigint);
256
- else try {
257
- node.value = RegExp(node.regex.pattern, node.regex.flags);
258
- } catch {}
259
- }
260
-
261
- //#endregion
262
- //#region src/parse-ast-index.ts
263
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
264
- function wrap(result, sourceText) {
265
- result = wrap$1(result);
266
- if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
267
- return result.program;
268
- }
269
- function normalizeParseError(sourceText, errors) {
270
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
271
- for (let i = 0; i < errors.length; i++) {
272
- if (i >= 5) {
273
- message += "\n...";
274
- break;
275
- }
276
- const e = errors[i];
277
- message += e.message + "\n" + e.labels.map((label) => {
278
- const location = locate(sourceText, label.start, { offsetLine: 1 });
279
- if (!location) return;
280
- return getCodeFrame(sourceText, location.line, location.column);
281
- }).filter(Boolean).join("\n");
282
- }
283
- return error(logParseError(message));
284
- }
285
- const defaultParserOptions = {
286
- lang: "js",
287
- preserveParens: false
288
- };
289
- function parseAst(sourceText, options, filename) {
290
- return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
291
- ...defaultParserOptions,
292
- ...options
293
- }), sourceText);
294
- }
295
- async function parseAstAsync(sourceText, options, filename) {
296
- return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
297
- ...defaultParserOptions,
298
- ...options
299
- }), sourceText);
300
- }
301
-
302
- //#endregion
303
- export { logCycleLoading as a, logDeprecatedInject as c, logInputHookInOutputPlugin as d, logInvalidLogPosition as f, styleText$1 as h, error as i, logDeprecatedKeepNames as l, logPluginError as m, parseAstAsync as n, logDeprecatedDefine as o, logMultiplyNotifyOption as p, augmentCodeLocation as r, logDeprecatedDropLabels as s, parseAst as t, logDeprecatedProfilerNames as u };
181
+ export { logInvalidLogPosition as a, logPluginError as c, logInputHookInOutputPlugin as i, locate as l, error as n, logMultiplyNotifyOption as o, logCycleLoading as r, logParseError as s, augmentCodeLocation as t, getCodeFrame as u };
@@ -0,0 +1,47 @@
1
+ import { t as require_binding } from "./binding-Drb7x8Xk.mjs";
2
+ import { c as logPluginError, n as error } from "./logs-CSQ_UMWp.mjs";
3
+
4
+ //#region src/builtin-plugin/utils.ts
5
+ var import_binding = require_binding();
6
+ var BuiltinPlugin = class {
7
+ constructor(name, _options) {
8
+ this.name = name;
9
+ this._options = _options;
10
+ }
11
+ };
12
+ function makeBuiltinPluginCallable(plugin) {
13
+ let callablePlugin = new import_binding.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
14
+ const wrappedPlugin = plugin;
15
+ for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
16
+ try {
17
+ return await callablePlugin[key](...args);
18
+ } catch (e) {
19
+ if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
20
+ return error(logPluginError(e, plugin.name, {
21
+ hook: key,
22
+ id: key === "transform" ? args[2] : void 0
23
+ }));
24
+ }
25
+ };
26
+ return wrappedPlugin;
27
+ }
28
+ function bindingifyBuiltInPlugin(plugin) {
29
+ return {
30
+ __name: plugin.name,
31
+ options: plugin._options
32
+ };
33
+ }
34
+
35
+ //#endregion
36
+ //#region src/utils/normalize-string-or-regex.ts
37
+ function normalizedStringOrRegex(pattern) {
38
+ if (!pattern) return;
39
+ if (!isReadonlyArray(pattern)) return [pattern];
40
+ return pattern;
41
+ }
42
+ function isReadonlyArray(input) {
43
+ return Array.isArray(input);
44
+ }
45
+
46
+ //#endregion
47
+ export { makeBuiltinPluginCallable as i, BuiltinPlugin as n, bindingifyBuiltInPlugin as r, normalizedStringOrRegex as t };
@@ -0,0 +1,82 @@
1
+ import { t as require_binding } from "./binding-Drb7x8Xk.mjs";
2
+ import { l as locate, n as error, s as logParseError, u as getCodeFrame } from "./logs-CSQ_UMWp.mjs";
3
+
4
+ //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
5
+ function wrap$1(result) {
6
+ let program, module, comments, errors;
7
+ return {
8
+ get program() {
9
+ if (!program) program = jsonParseAst(result.program);
10
+ return program;
11
+ },
12
+ get module() {
13
+ if (!module) module = result.module;
14
+ return module;
15
+ },
16
+ get comments() {
17
+ if (!comments) comments = result.comments;
18
+ return comments;
19
+ },
20
+ get errors() {
21
+ if (!errors) errors = result.errors;
22
+ return errors;
23
+ }
24
+ };
25
+ }
26
+ function jsonParseAst(programJson) {
27
+ const { node: program, fixes } = JSON.parse(programJson);
28
+ for (const fixPath of fixes) applyFix(program, fixPath);
29
+ return program;
30
+ }
31
+ function applyFix(program, fixPath) {
32
+ let node = program;
33
+ for (const key of fixPath) node = node[key];
34
+ if (node.bigint) node.value = BigInt(node.bigint);
35
+ else try {
36
+ node.value = RegExp(node.regex.pattern, node.regex.flags);
37
+ } catch {}
38
+ }
39
+
40
+ //#endregion
41
+ //#region src/parse-ast-index.ts
42
+ var import_binding = require_binding();
43
+ function wrap(result, sourceText) {
44
+ result = wrap$1(result);
45
+ if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
46
+ return result.program;
47
+ }
48
+ function normalizeParseError(sourceText, errors) {
49
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
50
+ for (let i = 0; i < errors.length; i++) {
51
+ if (i >= 5) {
52
+ message += "\n...";
53
+ break;
54
+ }
55
+ const e = errors[i];
56
+ message += e.message + "\n" + e.labels.map((label) => {
57
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
58
+ if (!location) return;
59
+ return getCodeFrame(sourceText, location.line, location.column);
60
+ }).filter(Boolean).join("\n");
61
+ }
62
+ return error(logParseError(message));
63
+ }
64
+ const defaultParserOptions = {
65
+ lang: "js",
66
+ preserveParens: false
67
+ };
68
+ function parseAst(sourceText, options, filename) {
69
+ return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
70
+ ...defaultParserOptions,
71
+ ...options
72
+ }), sourceText);
73
+ }
74
+ async function parseAstAsync(sourceText, options, filename) {
75
+ return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
76
+ ...defaultParserOptions,
77
+ ...options
78
+ }), sourceText);
79
+ }
80
+
81
+ //#endregion
82
+ export { parseAstAsync as n, parseAst as t };
@@ -844,4 +844,4 @@ async function prompt(message, opts = {}) {
844
844
  }
845
845
 
846
846
  //#endregion
847
- export { kCancel, prompt };
847
+ export { prompt };