@rolldown/browser 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 (39) hide show
  1. package/dist/cli-setup.mjs +3 -4
  2. package/dist/cli.mjs +22 -10
  3. package/dist/config.d.mts +3 -2
  4. package/dist/config.mjs +6 -5
  5. package/dist/constructors-EhfoQfqh.js +68 -0
  6. package/dist/experimental-index.browser.mjs +38 -117
  7. package/dist/experimental-index.d.mts +18 -58
  8. package/dist/experimental-index.mjs +41 -120
  9. package/dist/filter-index.d.mts +3 -2
  10. package/dist/filter-index.mjs +1 -1
  11. package/dist/index.browser.mjs +2 -2
  12. package/dist/index.d.mts +3 -2
  13. package/dist/index.mjs +5 -5
  14. package/dist/{shared/parse-ast-index-DMI5m8Lk.mjs → normalize-string-or-regex-d47jXr3r.js} +38 -110
  15. package/dist/parallel-plugin-worker.mjs +7 -6
  16. package/dist/parallel-plugin.d.mts +3 -2
  17. package/dist/parse-ast-index.d.mts +1 -1
  18. package/dist/parse-ast-index.mjs +2 -2
  19. package/dist/plugins-index.browser.mjs +39 -0
  20. package/dist/plugins-index.d.mts +31 -0
  21. package/dist/plugins-index.mjs +40 -0
  22. package/dist/rolldown-binding.wasi-browser.js +1 -1
  23. package/dist/rolldown-binding.wasi.cjs +1 -1
  24. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  25. package/dist/shared/{binding-CCMrV5an.d.mts → binding-B4uTNiw2.d.mts} +49 -58
  26. package/dist/shared/constructors-CaN9lKj2.d.mts +32 -0
  27. package/dist/shared/constructors-DcEzB0nc.mjs +68 -0
  28. package/dist/shared/{define-config-Bj-neIhz.d.mts → define-config-Dv3i4cxM.d.mts} +4 -62
  29. package/dist/shared/{load-config-DnUAKl9P.mjs → load-config-B-QIvCpC.mjs} +2 -2
  30. package/dist/shared/logs-CPsamAuj.mjs +181 -0
  31. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +46 -0
  32. package/dist/shared/parse-ast-index-D9jH_38U.mjs +81 -0
  33. package/dist/shared/{prompt-YGfbLmz5.mjs → prompt-Ckjl2FdJ.mjs} +1 -1
  34. package/dist/shared/{src-B8saaB3b.mjs → src-CvsuRKGv.mjs} +247 -224
  35. package/dist/shared/utils-CduIqa7h.d.mts +18 -0
  36. package/dist/{src-B-7Hrt6w.js → src-DLQqj5Wo.js} +234 -994
  37. package/package.json +1 -1
  38. package/dist/shared/binding-BeWSOIj5.mjs +0 -578
  39. /package/dist/shared/{composable-filters-CgRsnfr3.mjs → composable-filters-CBpK2Fbc.mjs} +0 -0
@@ -0,0 +1,46 @@
1
+ import { c as logPluginError, n as error } from "./logs-CPsamAuj.mjs";
2
+ import { BindingCallableBuiltinPlugin } from "../rolldown-binding.wasi.cjs";
3
+
4
+ //#region src/builtin-plugin/utils.ts
5
+ var BuiltinPlugin = class {
6
+ constructor(name, _options) {
7
+ this.name = name;
8
+ this._options = _options;
9
+ }
10
+ };
11
+ function makeBuiltinPluginCallable(plugin) {
12
+ let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
13
+ const wrappedPlugin = plugin;
14
+ for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
15
+ try {
16
+ return await callablePlugin[key](...args);
17
+ } catch (e) {
18
+ if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
19
+ return error(logPluginError(e, plugin.name, {
20
+ hook: key,
21
+ id: key === "transform" ? args[2] : void 0
22
+ }));
23
+ }
24
+ };
25
+ return wrappedPlugin;
26
+ }
27
+ function bindingifyBuiltInPlugin(plugin) {
28
+ return {
29
+ __name: plugin.name,
30
+ options: plugin._options
31
+ };
32
+ }
33
+
34
+ //#endregion
35
+ //#region src/utils/normalize-string-or-regex.ts
36
+ function normalizedStringOrRegex(pattern) {
37
+ if (!pattern) return;
38
+ if (!isReadonlyArray(pattern)) return [pattern];
39
+ return pattern;
40
+ }
41
+ function isReadonlyArray(input) {
42
+ return Array.isArray(input);
43
+ }
44
+
45
+ //#endregion
46
+ export { makeBuiltinPluginCallable as i, BuiltinPlugin as n, bindingifyBuiltInPlugin as r, normalizedStringOrRegex as t };
@@ -0,0 +1,81 @@
1
+ import { l as locate, n as error, s as logParseError, u as getCodeFrame } from "./logs-CPsamAuj.mjs";
2
+ import { parseAsync, parseSync } from "../rolldown-binding.wasi.cjs";
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
+ function wrap(result, sourceText) {
43
+ result = wrap$1(result);
44
+ if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
45
+ return result.program;
46
+ }
47
+ function normalizeParseError(sourceText, errors) {
48
+ let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
49
+ for (let i = 0; i < errors.length; i++) {
50
+ if (i >= 5) {
51
+ message += "\n...";
52
+ break;
53
+ }
54
+ const e = errors[i];
55
+ message += e.message + "\n" + e.labels.map((label) => {
56
+ const location = locate(sourceText, label.start, { offsetLine: 1 });
57
+ if (!location) return;
58
+ return getCodeFrame(sourceText, location.line, location.column);
59
+ }).filter(Boolean).join("\n");
60
+ }
61
+ return error(logParseError(message));
62
+ }
63
+ const defaultParserOptions = {
64
+ lang: "js",
65
+ preserveParens: false
66
+ };
67
+ function parseAst(sourceText, options, filename) {
68
+ return wrap(parseSync(filename ?? "file.js", sourceText, {
69
+ ...defaultParserOptions,
70
+ ...options
71
+ }), sourceText);
72
+ }
73
+ async function parseAstAsync(sourceText, options, filename) {
74
+ return wrap(await parseAsync(filename ?? "file.js", sourceText, {
75
+ ...defaultParserOptions,
76
+ ...options
77
+ }), sourceText);
78
+ }
79
+
80
+ //#endregion
81
+ 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 };