@rolldown/browser 1.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +25 -0
  2. package/bin/cli.mjs +2 -0
  3. package/dist/cli.cjs +1748 -0
  4. package/dist/cli.d.cts +1 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.mjs +1771 -0
  7. package/dist/config.cjs +12 -0
  8. package/dist/config.d.cts +11 -0
  9. package/dist/config.d.mts +11 -0
  10. package/dist/config.mjs +10 -0
  11. package/dist/experimental-index.browser.mjs +76 -0
  12. package/dist/experimental-index.cjs +129 -0
  13. package/dist/experimental-index.d.cts +96 -0
  14. package/dist/experimental-index.d.mts +96 -0
  15. package/dist/experimental-index.mjs +84 -0
  16. package/dist/filter-index.cjs +53 -0
  17. package/dist/filter-index.d.cts +3 -0
  18. package/dist/filter-index.d.mts +3 -0
  19. package/dist/filter-index.mjs +43 -0
  20. package/dist/index.browser.mjs +3 -0
  21. package/dist/index.cjs +9 -0
  22. package/dist/index.d.cts +3 -0
  23. package/dist/index.d.mts +3 -0
  24. package/dist/index.mjs +5 -0
  25. package/dist/parallel-plugin-worker.cjs +33 -0
  26. package/dist/parallel-plugin-worker.d.cts +1 -0
  27. package/dist/parallel-plugin-worker.d.mts +1 -0
  28. package/dist/parallel-plugin-worker.mjs +32 -0
  29. package/dist/parallel-plugin.cjs +8 -0
  30. package/dist/parallel-plugin.d.cts +14 -0
  31. package/dist/parallel-plugin.d.mts +14 -0
  32. package/dist/parallel-plugin.mjs +7 -0
  33. package/dist/parse-ast-index.cjs +4 -0
  34. package/dist/parse-ast-index.d.cts +9 -0
  35. package/dist/parse-ast-index.d.mts +9 -0
  36. package/dist/parse-ast-index.mjs +3 -0
  37. package/dist/rolldown-binding.wasi-browser.js +111 -0
  38. package/dist/rolldown-binding.wasi.cjs +135 -0
  39. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  40. package/dist/shared/chunk-DDkG_k5U.cjs +39 -0
  41. package/dist/shared/define-config.d-BBxr6_Bs.d.mts +1167 -0
  42. package/dist/shared/define-config.d-DII1FzpF.d.cts +1167 -0
  43. package/dist/shared/dist-BMVjvV-v.cjs +249 -0
  44. package/dist/shared/dist-JdACkHJM.mjs +147 -0
  45. package/dist/shared/load-config-CS9U8pRI.cjs +125 -0
  46. package/dist/shared/load-config-MCu-vRGz.mjs +119 -0
  47. package/dist/shared/parse-ast-index-BuelS_NF.cjs +314 -0
  48. package/dist/shared/parse-ast-index-C31FpvkE.mjs +260 -0
  49. package/dist/shared/prompt-8EeOGx1_.cjs +854 -0
  50. package/dist/shared/prompt-C3zHEaSG.mjs +852 -0
  51. package/dist/shared/src-AQQVsE86.mjs +4449 -0
  52. package/dist/shared/src-DKImwtxN.cjs +4647 -0
  53. package/dist/src-8Q9XjZLd.js +4329 -0
  54. package/dist/wasi-worker-browser.mjs +39 -0
  55. package/dist/wasi-worker.mjs +63 -0
  56. package/package.json +71 -0
@@ -0,0 +1,314 @@
1
+ const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
+ const src_rolldown_binding_wasi_cjs = require_chunk.__toESM(require("../rolldown-binding.wasi.cjs"));
3
+
4
+ //#region src/utils/code-frame.ts
5
+ function spaces(index) {
6
+ let result = "";
7
+ while (index--) result += " ";
8
+ return result;
9
+ }
10
+ function tabsToSpaces(value) {
11
+ return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
12
+ }
13
+ const LINE_TRUNCATE_LENGTH = 120;
14
+ const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
15
+ const ELLIPSIS = "...";
16
+ function getCodeFrame(source, line, column) {
17
+ let lines = source.split("\n");
18
+ if (line > lines.length) return "";
19
+ const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
20
+ const frameStart = Math.max(0, line - 3);
21
+ let frameEnd = Math.min(line + 2, lines.length);
22
+ lines = lines.slice(frameStart, frameEnd);
23
+ while (!/\S/.test(lines[lines.length - 1])) {
24
+ lines.pop();
25
+ frameEnd -= 1;
26
+ }
27
+ const digits = String(frameEnd).length;
28
+ return lines.map((sourceLine, index) => {
29
+ const isErrorLine = frameStart + index + 1 === line;
30
+ let lineNumber = String(index + frameStart + 1);
31
+ while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
32
+ let displayedLine = tabsToSpaces(sourceLine);
33
+ if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
34
+ if (isErrorLine) {
35
+ const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
36
+ return `${lineNumber}: ${displayedLine}\n${indicator}`;
37
+ }
38
+ return `${lineNumber}: ${displayedLine}`;
39
+ }).join("\n");
40
+ }
41
+
42
+ //#endregion
43
+ //#region src/log/locate-character/index.js
44
+ /** @typedef {import('./types').Location} Location */
45
+ /**
46
+ * @param {import('./types').Range} range
47
+ * @param {number} index
48
+ */
49
+ function rangeContains(range, index) {
50
+ return range.start <= index && index < range.end;
51
+ }
52
+ /**
53
+ * @param {string} source
54
+ * @param {import('./types').Options} [options]
55
+ */
56
+ function getLocator(source, options = {}) {
57
+ const { offsetLine = 0, offsetColumn = 0 } = options;
58
+ let start = 0;
59
+ const ranges = source.split("\n").map((line, i$1) => {
60
+ const end = start + line.length + 1;
61
+ /** @type {import('./types').Range} */
62
+ const range = {
63
+ start,
64
+ end,
65
+ line: i$1
66
+ };
67
+ start = end;
68
+ return range;
69
+ });
70
+ let i = 0;
71
+ /**
72
+ * @param {string | number} search
73
+ * @param {number} [index]
74
+ * @returns {Location | undefined}
75
+ */
76
+ function locator(search, index) {
77
+ if (typeof search === "string") search = source.indexOf(search, index ?? 0);
78
+ if (search === -1) return void 0;
79
+ let range = ranges[i];
80
+ const d = search >= range.end ? 1 : -1;
81
+ while (range) {
82
+ if (rangeContains(range, search)) return {
83
+ line: offsetLine + range.line,
84
+ column: offsetColumn + search - range.start,
85
+ character: search
86
+ };
87
+ i += d;
88
+ range = ranges[i];
89
+ }
90
+ }
91
+ return locator;
92
+ }
93
+ /**
94
+ * @param {string} source
95
+ * @param {string | number} search
96
+ * @param {import('./types').Options} [options]
97
+ * @returns {Location | undefined}
98
+ */
99
+ function locate(source, search, options) {
100
+ return getLocator(source, options)(search, options && options.startIndex);
101
+ }
102
+
103
+ //#endregion
104
+ //#region src/log/logs.ts
105
+ 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";
106
+ function logParseError(message) {
107
+ return {
108
+ code: PARSE_ERROR,
109
+ message
110
+ };
111
+ }
112
+ function logInvalidLogPosition(pluginName) {
113
+ return {
114
+ code: INVALID_LOG_POSITION,
115
+ 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.`
116
+ };
117
+ }
118
+ function logInputHookInOutputPlugin(pluginName, hookName) {
119
+ return {
120
+ code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
121
+ 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.`
122
+ };
123
+ }
124
+ function logCycleLoading(pluginName, moduleId) {
125
+ return {
126
+ code: CYCLE_LOADING,
127
+ message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
128
+ };
129
+ }
130
+ function logMultiplyNotifyOption() {
131
+ return {
132
+ code: MULTIPLY_NOTIFY_OPTION,
133
+ message: `Found multiply notify option at watch options, using first one to start notify watcher.`
134
+ };
135
+ }
136
+ function logPluginError(error$1, plugin, { hook, id } = {}) {
137
+ try {
138
+ const code = error$1.code;
139
+ if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
140
+ error$1.code = PLUGIN_ERROR;
141
+ error$1.plugin = plugin;
142
+ if (hook) error$1.hook = hook;
143
+ if (id) error$1.id = id;
144
+ } catch (_) {} finally {
145
+ return error$1;
146
+ }
147
+ }
148
+ function error(base) {
149
+ if (!(base instanceof Error)) {
150
+ base = Object.assign(new Error(base.message), base);
151
+ Object.defineProperty(base, "name", {
152
+ value: "RollupError",
153
+ writable: true
154
+ });
155
+ }
156
+ throw base;
157
+ }
158
+ function augmentCodeLocation(properties, pos, source, id) {
159
+ if (typeof pos === "object") {
160
+ const { line, column } = pos;
161
+ properties.loc = {
162
+ column,
163
+ file: id,
164
+ line
165
+ };
166
+ } else {
167
+ properties.pos = pos;
168
+ const location = locate(source, pos, { offsetLine: 1 });
169
+ if (!location) return;
170
+ const { line, column } = location;
171
+ properties.loc = {
172
+ column,
173
+ file: id,
174
+ line
175
+ };
176
+ }
177
+ if (properties.frame === void 0) {
178
+ const { line, column } = properties.loc;
179
+ properties.frame = getCodeFrame(source, line, column);
180
+ }
181
+ }
182
+
183
+ //#endregion
184
+ //#region ../../node_modules/.pnpm/oxc-parser@0.72.1/node_modules/oxc-parser/wrap.mjs
185
+ function wrap$1(result) {
186
+ let program, module$1, comments, errors;
187
+ return {
188
+ get program() {
189
+ if (!program) program = jsonParseAst(result.program);
190
+ return program;
191
+ },
192
+ get module() {
193
+ if (!module$1) module$1 = result.module;
194
+ return module$1;
195
+ },
196
+ get comments() {
197
+ if (!comments) comments = result.comments;
198
+ return comments;
199
+ },
200
+ get errors() {
201
+ if (!errors) errors = result.errors;
202
+ return errors;
203
+ }
204
+ };
205
+ }
206
+ function jsonParseAst(programJson) {
207
+ const { node: program, fixes } = JSON.parse(programJson);
208
+ for (const fixPath of fixes) applyFix(program, fixPath);
209
+ return program;
210
+ }
211
+ function applyFix(program, fixPath) {
212
+ let node = program;
213
+ for (const key of fixPath) node = node[key];
214
+ if (node.bigint) node.value = BigInt(node.bigint);
215
+ else try {
216
+ node.value = RegExp(node.regex.pattern, node.regex.flags);
217
+ } catch (_err) {}
218
+ }
219
+
220
+ //#endregion
221
+ //#region src/parse-ast-index.ts
222
+ function wrap(result, sourceText) {
223
+ result = wrap$1(result);
224
+ if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
225
+ return result.program;
226
+ }
227
+ function normalizeParseError(sourceText, errors) {
228
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
229
+ for (let i = 0; i < errors.length; i++) {
230
+ if (i >= 5) {
231
+ message += "\n...";
232
+ break;
233
+ }
234
+ const e = errors[i];
235
+ message += e.message + "\n" + e.labels.map((label) => {
236
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
237
+ if (!location) return;
238
+ return getCodeFrame(sourceText, location.line, location.column);
239
+ }).filter(Boolean).join("\n");
240
+ }
241
+ return error(logParseError(message));
242
+ }
243
+ const defaultParserOptions = {
244
+ lang: "js",
245
+ preserveParens: false
246
+ };
247
+ function parseAst(sourceText, options, filename) {
248
+ return wrap((0, src_rolldown_binding_wasi_cjs.parseSync)(filename ?? "file.js", sourceText, {
249
+ ...defaultParserOptions,
250
+ ...options
251
+ }), sourceText);
252
+ }
253
+ async function parseAstAsync(sourceText, options, filename) {
254
+ return wrap(await (0, src_rolldown_binding_wasi_cjs.parseAsync)(filename ?? "file.js", sourceText, {
255
+ ...defaultParserOptions,
256
+ ...options
257
+ }), sourceText);
258
+ }
259
+
260
+ //#endregion
261
+ Object.defineProperty(exports, 'augmentCodeLocation', {
262
+ enumerable: true,
263
+ get: function () {
264
+ return augmentCodeLocation;
265
+ }
266
+ });
267
+ Object.defineProperty(exports, 'error', {
268
+ enumerable: true,
269
+ get: function () {
270
+ return error;
271
+ }
272
+ });
273
+ Object.defineProperty(exports, 'logCycleLoading', {
274
+ enumerable: true,
275
+ get: function () {
276
+ return logCycleLoading;
277
+ }
278
+ });
279
+ Object.defineProperty(exports, 'logInputHookInOutputPlugin', {
280
+ enumerable: true,
281
+ get: function () {
282
+ return logInputHookInOutputPlugin;
283
+ }
284
+ });
285
+ Object.defineProperty(exports, 'logInvalidLogPosition', {
286
+ enumerable: true,
287
+ get: function () {
288
+ return logInvalidLogPosition;
289
+ }
290
+ });
291
+ Object.defineProperty(exports, 'logMultiplyNotifyOption', {
292
+ enumerable: true,
293
+ get: function () {
294
+ return logMultiplyNotifyOption;
295
+ }
296
+ });
297
+ Object.defineProperty(exports, 'logPluginError', {
298
+ enumerable: true,
299
+ get: function () {
300
+ return logPluginError;
301
+ }
302
+ });
303
+ Object.defineProperty(exports, 'parseAst', {
304
+ enumerable: true,
305
+ get: function () {
306
+ return parseAst;
307
+ }
308
+ });
309
+ Object.defineProperty(exports, 'parseAstAsync', {
310
+ enumerable: true,
311
+ get: function () {
312
+ return parseAstAsync;
313
+ }
314
+ });
@@ -0,0 +1,260 @@
1
+ import { parseAsync, parseSync } from "../rolldown-binding.wasi.cjs";
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 + ELLIPSIS.length, 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 - ELLIPSIS.length)}${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";
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 logPluginError(error$1, plugin, { hook, id } = {}) {
136
+ try {
137
+ const code = error$1.code;
138
+ if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
139
+ error$1.code = PLUGIN_ERROR;
140
+ error$1.plugin = plugin;
141
+ if (hook) error$1.hook = hook;
142
+ if (id) error$1.id = id;
143
+ } catch (_) {} finally {
144
+ return error$1;
145
+ }
146
+ }
147
+ function error(base) {
148
+ if (!(base instanceof Error)) {
149
+ base = Object.assign(new Error(base.message), base);
150
+ Object.defineProperty(base, "name", {
151
+ value: "RollupError",
152
+ writable: true
153
+ });
154
+ }
155
+ throw base;
156
+ }
157
+ function augmentCodeLocation(properties, pos, source, id) {
158
+ if (typeof pos === "object") {
159
+ const { line, column } = pos;
160
+ properties.loc = {
161
+ column,
162
+ file: id,
163
+ line
164
+ };
165
+ } else {
166
+ properties.pos = pos;
167
+ const location = locate(source, pos, { offsetLine: 1 });
168
+ if (!location) return;
169
+ const { line, column } = location;
170
+ properties.loc = {
171
+ column,
172
+ file: id,
173
+ line
174
+ };
175
+ }
176
+ if (properties.frame === void 0) {
177
+ const { line, column } = properties.loc;
178
+ properties.frame = getCodeFrame(source, line, column);
179
+ }
180
+ }
181
+
182
+ //#endregion
183
+ //#region ../../node_modules/.pnpm/oxc-parser@0.72.1/node_modules/oxc-parser/wrap.mjs
184
+ function wrap$1(result) {
185
+ let program, module, comments, errors;
186
+ return {
187
+ get program() {
188
+ if (!program) program = jsonParseAst(result.program);
189
+ return program;
190
+ },
191
+ get module() {
192
+ if (!module) module = result.module;
193
+ return module;
194
+ },
195
+ get comments() {
196
+ if (!comments) comments = result.comments;
197
+ return comments;
198
+ },
199
+ get errors() {
200
+ if (!errors) errors = result.errors;
201
+ return errors;
202
+ }
203
+ };
204
+ }
205
+ function jsonParseAst(programJson) {
206
+ const { node: program, fixes } = JSON.parse(programJson);
207
+ for (const fixPath of fixes) applyFix(program, fixPath);
208
+ return program;
209
+ }
210
+ function applyFix(program, fixPath) {
211
+ let node = program;
212
+ for (const key of fixPath) node = node[key];
213
+ if (node.bigint) node.value = BigInt(node.bigint);
214
+ else try {
215
+ node.value = RegExp(node.regex.pattern, node.regex.flags);
216
+ } catch (_err) {}
217
+ }
218
+
219
+ //#endregion
220
+ //#region src/parse-ast-index.ts
221
+ function wrap(result, sourceText) {
222
+ result = wrap$1(result);
223
+ if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
224
+ return result.program;
225
+ }
226
+ function normalizeParseError(sourceText, errors) {
227
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
228
+ for (let i = 0; i < errors.length; i++) {
229
+ if (i >= 5) {
230
+ message += "\n...";
231
+ break;
232
+ }
233
+ const e = errors[i];
234
+ message += e.message + "\n" + e.labels.map((label) => {
235
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
236
+ if (!location) return;
237
+ return getCodeFrame(sourceText, location.line, location.column);
238
+ }).filter(Boolean).join("\n");
239
+ }
240
+ return error(logParseError(message));
241
+ }
242
+ const defaultParserOptions = {
243
+ lang: "js",
244
+ preserveParens: false
245
+ };
246
+ function parseAst(sourceText, options, filename) {
247
+ return wrap(parseSync(filename ?? "file.js", sourceText, {
248
+ ...defaultParserOptions,
249
+ ...options
250
+ }), sourceText);
251
+ }
252
+ async function parseAstAsync(sourceText, options, filename) {
253
+ return wrap(await parseAsync(filename ?? "file.js", sourceText, {
254
+ ...defaultParserOptions,
255
+ ...options
256
+ }), sourceText);
257
+ }
258
+
259
+ //#endregion
260
+ export { augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, parseAstAsync };