rolldown 0.14.0 → 0.15.0-commit.ac58858

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 (101) hide show
  1. package/dist/cjs/cli.cjs +902 -960
  2. package/dist/cjs/experimental-index.cjs +68 -26
  3. package/dist/cjs/index.cjs +6 -8
  4. package/dist/cjs/parallel-plugin-worker.cjs +20 -14
  5. package/dist/cjs/parallel-plugin.cjs +1 -3
  6. package/dist/esm/cli.mjs +855 -915
  7. package/dist/esm/experimental-index.mjs +44 -7
  8. package/dist/esm/index.mjs +2 -4
  9. package/dist/esm/parallel-plugin-worker.mjs +15 -10
  10. package/dist/esm/parallel-plugin.mjs +1 -3
  11. package/dist/shared/{chunk-JoMxl5V2.cjs → chunk-BFvIen8E.cjs} +13 -11
  12. package/dist/shared/{consola.36c0034f-HcmWcfPe.cjs → consola_36c0034f-B7L-radJ.cjs} +249 -295
  13. package/dist/shared/{consola.36c0034f-Xyw7SC_7.mjs → consola_36c0034f-D9ce-831.mjs} +221 -286
  14. package/dist/shared/{prompt-9Ij3R3TG.cjs → prompt-BiXtYIJ2.cjs} +157 -204
  15. package/dist/shared/{prompt-hoPhcrA-.mjs → prompt-DlQ-08lk.mjs} +125 -174
  16. package/dist/shared/src-Bs7g4_us.cjs +2985 -0
  17. package/dist/shared/src-C-NQjnqV.mjs +2851 -0
  18. package/dist/tsconfig.dts.tsbuildinfo +1 -0
  19. package/dist/types/api/build.d.ts +16 -0
  20. package/dist/types/api/experimental.d.ts +7 -0
  21. package/dist/types/api/rolldown/index.d.ts +3 -0
  22. package/dist/types/api/rolldown/rolldown-build.d.ts +12 -0
  23. package/dist/types/api/watch/index.d.ts +3 -0
  24. package/dist/types/{watcher.d.ts → api/watch/watch-emitter.d.ts} +17 -17
  25. package/dist/types/api/watch/watcher.d.ts +13 -0
  26. package/dist/types/binding.d.ts +273 -49
  27. package/dist/types/builtin-plugin/alias-plugin.d.ts +10 -0
  28. package/dist/types/builtin-plugin/constructors.d.ts +16 -0
  29. package/dist/types/builtin-plugin/replace-plugin.d.ts +28 -0
  30. package/dist/types/{options/normalized-ecma-transform-plugin-config.d.ts → builtin-plugin/transform-plugin.d.ts} +2 -1
  31. package/dist/types/builtin-plugin/utils.d.ts +8 -0
  32. package/dist/types/cli/arguments/index.d.ts +5 -3
  33. package/dist/types/cli/arguments/normalize.d.ts +2 -6
  34. package/dist/types/cli/arguments/schema.d.ts +10 -309
  35. package/dist/types/cli/colors.d.ts +11 -1
  36. package/dist/types/cli/utils.d.ts +2 -1
  37. package/dist/types/constants/plugin.d.ts +10 -1
  38. package/dist/types/experimental-index.d.ts +5 -2
  39. package/dist/types/index.d.ts +13 -10
  40. package/dist/types/log/logger.d.ts +2 -16
  41. package/dist/types/log/logging.d.ts +11 -8
  42. package/dist/types/log/logs.d.ts +3 -0
  43. package/dist/types/options/input-options-schema.d.ts +4 -0
  44. package/dist/types/options/input-options.d.ts +89 -430
  45. package/dist/types/options/normalized-input-options.d.ts +17 -11
  46. package/dist/types/options/normalized-output-options.d.ts +60 -21
  47. package/dist/types/options/output-options-schema.d.ts +3 -0
  48. package/dist/types/options/output-options.d.ts +73 -265
  49. package/dist/types/options/watch-options.d.ts +5 -0
  50. package/dist/types/plugin/bindingify-build-hooks.d.ts +9 -11
  51. package/dist/types/plugin/bindingify-hook-filter.d.ts +5 -5
  52. package/dist/types/plugin/bindingify-output-hooks.d.ts +13 -16
  53. package/dist/types/plugin/bindingify-plugin.d.ts +12 -3
  54. package/dist/types/plugin/bindingify-watch-hooks.d.ts +3 -5
  55. package/dist/types/plugin/hook-filter.d.ts +1 -1
  56. package/dist/types/plugin/index.d.ts +21 -18
  57. package/dist/types/plugin/minimal-plugin-context.d.ts +15 -0
  58. package/dist/types/plugin/plugin-context-data.d.ts +4 -4
  59. package/dist/types/plugin/plugin-context.d.ts +9 -4
  60. package/dist/types/plugin/plugin-driver.d.ts +4 -5
  61. package/dist/types/plugin/transform-plugin-context.d.ts +4 -3
  62. package/dist/types/rollup-types.d.ts +1 -1
  63. package/dist/types/rollup.d.ts +4 -0
  64. package/dist/types/treeshake/index.d.ts +0 -12
  65. package/dist/types/treeshake/module-side-effects.d.ts +14 -15
  66. package/dist/types/types/rolldown-output.d.ts +17 -2
  67. package/dist/types/types/utils.d.ts +1 -0
  68. package/dist/types/utils/bindingify-input-options.d.ts +7 -0
  69. package/dist/types/utils/bindingify-output-options.d.ts +3 -0
  70. package/dist/types/utils/create-bundler-option.d.ts +11 -0
  71. package/dist/types/utils/define-config.d.ts +3 -0
  72. package/dist/types/utils/error.d.ts +2 -0
  73. package/dist/types/utils/misc.d.ts +1 -0
  74. package/dist/types/utils/normalize-hook.d.ts +1 -1
  75. package/dist/types/utils/normalize-plugin-option.d.ts +8 -3
  76. package/dist/types/{options/utils.d.ts → utils/normalize-string-or-regex.d.ts} +1 -1
  77. package/dist/types/utils/transform-rendered-chunk.d.ts +4 -0
  78. package/dist/types/utils/transform-rendered-module.d.ts +3 -0
  79. package/dist/types/utils/transform-sourcemap.d.ts +2 -0
  80. package/dist/types/utils/transform-to-rollup-output.d.ts +1 -0
  81. package/dist/types/utils/zod-ext.d.ts +6 -5
  82. package/package.json +31 -23
  83. package/dist/shared/rolldown-binding.wasi.cjs +0 -187
  84. package/dist/shared/src_index-3pqhEViJ.cjs +0 -2785
  85. package/dist/shared/src_index-ywYMd4vB.mjs +0 -2786
  86. package/dist/shared/wasi-worker-browser.mjs +0 -39
  87. package/dist/shared/wasi-worker.mjs +0 -63
  88. package/dist/shared/watcher-worker.js +0 -1
  89. package/dist/types/constants/types.d.ts +0 -1
  90. package/dist/types/options/bindingify-input-options.d.ts +0 -4
  91. package/dist/types/options/bindingify-output-options.d.ts +0 -3
  92. package/dist/types/options/normalized-alias-plugin-config.d.ts +0 -8
  93. package/dist/types/options/watch-option.d.ts +0 -5
  94. package/dist/types/plugin/builtin-plugin.d.ts +0 -81
  95. package/dist/types/rolldown-build.d.ts +0 -10
  96. package/dist/types/rolldown.d.ts +0 -12
  97. package/dist/types/types/rendered-module.d.ts +0 -2
  98. package/dist/types/utils/normalize-input-options.d.ts +0 -3
  99. package/dist/types/utils/normalize-output-options.d.ts +0 -3
  100. package/dist/types/utils/normalize-tree-shake.d.ts +0 -3
  101. /package/dist/types/{utils/type-assert.d.ts → types/assert.d.ts} +0 -0
package/dist/esm/cli.mjs CHANGED
@@ -1,127 +1,32 @@
1
- import __node_module__ from 'node:module';
2
- const require = __node_module__.createRequire(import.meta.url)
3
- import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, __export, arraify, description, rolldown, version, watch } from "../shared/src_index-ywYMd4vB.mjs";
4
- import { createConsola } from "../shared/consola.36c0034f-Xyw7SC_7.mjs";
5
- import { default as nodePath, default as path } from "node:path";
6
- import { ZodFirstPartyTypeKind, ZodFirstPartyTypeKind as ZodFirstPartyTypeKind$1, ZodFirstPartyTypeKind as ZodFirstPartyTypeKind$2, z, z as z$1, z as z$2, z as z$3 } from "zod";
7
- import { default as process$1, env } from "node:process";
1
+ import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, TreeshakingOptionsSchema, arraify, description, rolldown, version, watch } from "../shared/src-C-NQjnqV.mjs";
2
+ import { createConsola } from "../shared/consola_36c0034f-D9ce-831.mjs";
3
+ import { ZodFirstPartyTypeKind, z } from "zod";
4
+ import nodePath, { default as path } from "node:path";
5
+ import process$1, { env } from "node:process";
8
6
  import { performance } from "node:perf_hooks";
7
+ import * as tty from "tty";
9
8
  import { pathToFileURL } from "node:url";
10
9
  import { parseArgs } from "node:util";
11
- import * as tty from "node:tty";
12
10
 
13
- //#region src/cli/utils.ts
14
- const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({formatOptions: {date: false}});
15
- function createTestingLogger() {
16
- const types = ["silent", "fatal", "error", "warn", "log", "info", "success", "fail", "ready", "start", "box", "debug", "trace", "verbose",];
17
- const ret = Object.create(null);
18
- for (const type of types) {
19
- ret[type] = console.log;
20
- }
21
- return ret;
22
- }
23
- async function ensureConfig(configPath) {
24
- if (!isSupportedFormat(configPath)) {
25
- throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${nodePath.extname(configPath)}\``);
26
- }
27
- const fileUrl = (pathToFileURL(configPath)).toString();
28
- const configExports = await import(fileUrl);
29
- return configExports.default;
30
- }
31
- const SUPPORTED_CONFIG_FORMATS = [".js", ".mjs", ".cjs"];
32
- function isSupportedFormat(configPath) {
33
- const ext = nodePath.extname(configPath);
34
- return SUPPORTED_CONFIG_FORMATS.includes(ext);
35
- }
36
-
37
- //#endregion
38
- //#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
39
- const { env: env$1 = {}, argv: argv = [], platform: platform = "" } = typeof process === "undefined" ? {} : process;
40
- const isDisabled = "NO_COLOR"in env$1 || argv.includes("--no-color");
41
- const isForced = "FORCE_COLOR"in env$1 || argv.includes("--color");
42
- const isWindows = platform === "win32";
43
- const isDumbTerminal = env$1.TERM === "dumb";
44
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
45
- const isCI = "CI"in env$1 && ("GITHUB_ACTIONS"in env$1 || "GITLAB_CI"in env$1 || "CIRCLECI"in env$1);
46
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
47
- const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
48
- const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
49
- const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
50
- const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
51
- const colors = {
52
- reset: init(0, 0),
53
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
54
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
55
- italic: init(3, 23),
56
- underline: init(4, 24),
57
- inverse: init(7, 27),
58
- hidden: init(8, 28),
59
- strikethrough: init(9, 29),
60
- black: init(30, 39),
61
- red: init(31, 39),
62
- green: init(32, 39),
63
- yellow: init(33, 39),
64
- blue: init(34, 39),
65
- magenta: init(35, 39),
66
- cyan: init(36, 39),
67
- white: init(37, 39),
68
- gray: init(90, 39),
69
- bgBlack: init(40, 49),
70
- bgRed: init(41, 49),
71
- bgGreen: init(42, 49),
72
- bgYellow: init(43, 49),
73
- bgBlue: init(44, 49),
74
- bgMagenta: init(45, 49),
75
- bgCyan: init(46, 49),
76
- bgWhite: init(47, 49),
77
- blackBright: init(90, 39),
78
- redBright: init(91, 39),
79
- greenBright: init(92, 39),
80
- yellowBright: init(93, 39),
81
- blueBright: init(94, 39),
82
- magentaBright: init(95, 39),
83
- cyanBright: init(96, 39),
84
- whiteBright: init(97, 39),
85
- bgBlackBright: init(100, 49),
86
- bgRedBright: init(101, 49),
87
- bgGreenBright: init(102, 49),
88
- bgYellowBright: init(103, 49),
89
- bgBlueBright: init(104, 49),
90
- bgMagentaBright: init(105, 49),
91
- bgCyanBright: init(106, 49),
92
- bgWhiteBright: init(107, 49)
93
- };
94
- const createColors = ({ useColor: useColor = isColorSupported } = {}) => useColor ? colors : (Object.keys(colors)).reduce((colors$1, key) => ({
95
- ...colors$1,
96
- [key]: String
97
- }), {});
98
- const { reset: reset, bold: bold$1, dim: dim$1, italic: italic, underline: underline$1, inverse: inverse, hidden: hidden, strikethrough: strikethrough, black: black, red: red$1, green: green$1, yellow: yellow$1, blue: blue, magenta: magenta, cyan: cyan$1, white: white, gray: gray$1, bgBlack: bgBlack, bgRed: bgRed, bgGreen: bgGreen, bgYellow: bgYellow, bgBlue: bgBlue, bgMagenta: bgMagenta, bgCyan: bgCyan, bgWhite: bgWhite, blackBright: blackBright, redBright: redBright, greenBright: greenBright, yellowBright: yellowBright, blueBright: blueBright, magentaBright: magentaBright, cyanBright: cyanBright, whiteBright: whiteBright, bgBlackBright: bgBlackBright, bgRedBright: bgRedBright, bgGreenBright: bgGreenBright, bgYellowBright: bgYellowBright, bgBlueBright: bgBlueBright, bgMagentaBright: bgMagentaBright, bgCyanBright: bgCyanBright, bgWhiteBright: bgWhiteBright } = createColors();
99
-
100
- //#endregion
101
- //#region src/cli/colors.ts
102
- var colors_ns = {};
103
- __export(colors_ns, {
104
- bold: () => bold,
105
- cyan: () => cyan,
106
- dim: () => dim,
107
- gray: () => gray,
108
- green: () => green,
109
- red: () => red,
110
- underline: () => underline,
111
- yellow: () => yellow
112
- });
113
- const { bold: bold, cyan: cyan, dim: dim, gray: gray, green: green, red: red, underline: underline, yellow: yellow } = createColors({useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR});
114
-
115
- //#endregion
116
11
  //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
117
12
  const signals = [];
118
13
  signals.push("SIGHUP", "SIGINT", "SIGTERM");
119
- if (process.platform !== "win32") {
120
- signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
121
- }
122
- if (process.platform === "linux") {
123
- signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
124
- }
14
+ if (process.platform !== "win32") signals.push(
15
+ "SIGALRM",
16
+ "SIGABRT",
17
+ "SIGVTALRM",
18
+ "SIGXCPU",
19
+ "SIGXFSZ",
20
+ "SIGUSR2",
21
+ "SIGTRAP",
22
+ "SIGSYS",
23
+ "SIGQUIT",
24
+ "SIGIOT"
25
+ // should detect profiler and enable/disable accordingly.
26
+ // see #21
27
+ // 'SIGPROF'
28
+ );
29
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
125
30
 
126
31
  //#endregion
127
32
  //#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
@@ -129,7 +34,7 @@ const processOk = (process$3) => !!process$3 && typeof process$3 === "object" &&
129
34
  const kExitEmitter = Symbol.for("signal-exit emitter");
130
35
  const global = globalThis;
131
36
  const ObjectDefineProperty = Object.defineProperty.bind(Object);
132
- class Emitter {
37
+ var Emitter = class {
133
38
  emitted = {
134
39
  afterExit: false,
135
40
  exit: false
@@ -141,9 +46,7 @@ class Emitter {
141
46
  count = 0;
142
47
  id = Math.random();
143
48
  constructor() {
144
- if (global[kExitEmitter]) {
145
- return global[kExitEmitter];
146
- }
49
+ if (global[kExitEmitter]) return global[kExitEmitter];
147
50
  ObjectDefineProperty(global, kExitEmitter, {
148
51
  value: this,
149
52
  writable: false,
@@ -157,31 +60,20 @@ class Emitter {
157
60
  removeListener(ev, fn) {
158
61
  const list = this.listeners[ev];
159
62
  const i = list.indexOf(fn);
160
- if (i === -1) {
161
- return;
162
- }
163
- if (i === 0 && list.length === 1) {
164
- list.length = 0;
165
- } else {
166
- list.splice(i, 1);
167
- }
63
+ if (i === -1) return;
64
+ if (i === 0 && list.length === 1) list.length = 0;
65
+ else list.splice(i, 1);
168
66
  }
169
67
  emit(ev, code, signal) {
170
- if (this.emitted[ev]) {
171
- return false;
172
- }
68
+ if (this.emitted[ev]) return false;
173
69
  this.emitted[ev] = true;
174
70
  let ret = false;
175
- for (const fn of this.listeners[ev]) {
176
- ret = fn(code, signal) === true || ret;
177
- }
178
- if (ev === "exit") {
179
- ret = this.emit("afterExit", code, signal) || ret;
180
- }
71
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
72
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
181
73
  return ret;
182
74
  }
183
- }
184
- class SignalExitBase {}
75
+ };
76
+ var SignalExitBase = class {};
185
77
  const signalExitWrap = (handler) => {
186
78
  return {
187
79
  onExit(cb, opts) {
@@ -195,14 +87,14 @@ const signalExitWrap = (handler) => {
195
87
  }
196
88
  };
197
89
  };
198
- class SignalExitFallback extends SignalExitBase {
90
+ var SignalExitFallback = class extends SignalExitBase {
199
91
  onExit() {
200
92
  return () => {};
201
93
  }
202
94
  load() {}
203
95
  unload() {}
204
- }
205
- class SignalExit extends SignalExitBase {
96
+ };
97
+ var SignalExit = class extends SignalExitBase {
206
98
  #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
207
99
  #emitter = new Emitter();
208
100
  #process;
@@ -214,53 +106,39 @@ class SignalExit extends SignalExitBase {
214
106
  super();
215
107
  this.#process = process$3;
216
108
  this.#sigListeners = {};
217
- for (const sig of signals) {
218
- this.#sigListeners[sig] = () => {
219
- const listeners = this.#process.listeners(sig);
220
- let { count: count } = this.#emitter;
221
- const p = process$3;
222
- if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
223
- count += p.__signal_exit_emitter__.count;
224
- }
225
- if (listeners.length === count) {
226
- this.unload();
227
- const ret = this.#emitter.emit("exit", null, sig);
228
- const s = sig === "SIGHUP" ? this.#hupSig : sig;
229
- if (!ret) process$3.kill(process$3.pid, s);
230
- }
231
- };
232
- }
109
+ for (const sig of signals) this.#sigListeners[sig] = () => {
110
+ const listeners = this.#process.listeners(sig);
111
+ let { count } = this.#emitter;
112
+ const p = process$3;
113
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
114
+ if (listeners.length === count) {
115
+ this.unload();
116
+ const ret = this.#emitter.emit("exit", null, sig);
117
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
118
+ if (!ret) process$3.kill(process$3.pid, s);
119
+ }
120
+ };
233
121
  this.#originalProcessReallyExit = process$3.reallyExit;
234
122
  this.#originalProcessEmit = process$3.emit;
235
123
  }
236
124
  onExit(cb, opts) {
237
- if (!processOk(this.#process)) {
238
- return () => {};
239
- }
240
- if (this.#loaded === false) {
241
- this.load();
242
- }
125
+ if (!processOk(this.#process)) return () => {};
126
+ if (this.#loaded === false) this.load();
243
127
  const ev = opts?.alwaysLast ? "afterExit" : "exit";
244
128
  this.#emitter.on(ev, cb);
245
129
  return () => {
246
130
  this.#emitter.removeListener(ev, cb);
247
- if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) {
248
- this.unload();
249
- }
131
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
250
132
  };
251
133
  }
252
134
  load() {
253
- if (this.#loaded) {
254
- return;
255
- }
135
+ if (this.#loaded) return;
256
136
  this.#loaded = true;
257
137
  this.#emitter.count += 1;
258
- for (const sig of signals) {
259
- try {
260
- const fn = this.#sigListeners[sig];
261
- if (fn) this.#process.on(sig, fn);
262
- } catch (_) {}
263
- }
138
+ for (const sig of signals) try {
139
+ const fn = this.#sigListeners[sig];
140
+ if (fn) this.#process.on(sig, fn);
141
+ } catch (_) {}
264
142
  this.#process.emit = (ev, ...a) => {
265
143
  return this.#processEmit(ev, ...a);
266
144
  };
@@ -269,15 +147,11 @@ class SignalExit extends SignalExitBase {
269
147
  };
270
148
  }
271
149
  unload() {
272
- if (!this.#loaded) {
273
- return;
274
- }
150
+ if (!this.#loaded) return;
275
151
  this.#loaded = false;
276
152
  signals.forEach((sig) => {
277
153
  const listener = this.#sigListeners[sig];
278
- if (!listener) {
279
- throw new Error("Listener not defined for signal: " + sig);
280
- }
154
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
281
155
  try {
282
156
  this.#process.removeListener(sig, listener);
283
157
  } catch (_) {}
@@ -287,9 +161,7 @@ class SignalExit extends SignalExitBase {
287
161
  this.#emitter.count -= 1;
288
162
  }
289
163
  #processReallyExit(code) {
290
- if (!processOk(this.#process)) {
291
- return 0;
292
- }
164
+ if (!processOk(this.#process)) return 0;
293
165
  this.#process.exitCode = code || 0;
294
166
  this.#emitter.emit("exit", this.#process.exitCode, null);
295
167
  return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
@@ -297,19 +169,141 @@ class SignalExit extends SignalExitBase {
297
169
  #processEmit(ev, ...args) {
298
170
  const og = this.#originalProcessEmit;
299
171
  if (ev === "exit" && processOk(this.#process)) {
300
- if (typeof args[0] === "number") {
301
- this.#process.exitCode = args[0];
302
- }
172
+ if (typeof args[0] === "number") this.#process.exitCode = args[0];
303
173
  const ret = og.call(this.#process, ev, ...args);
304
174
  this.#emitter.emit("exit", this.#process.exitCode, null);
305
175
  return ret;
306
- } else {
307
- return og.call(this.#process, ev, ...args);
308
- }
176
+ } else return og.call(this.#process, ev, ...args);
309
177
  }
310
- }
178
+ };
311
179
  const process$2 = globalThis.process;
312
- const { onExit: onExit, load: load, unload: unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
180
+ const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
181
+
182
+ //#endregion
183
+ //#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
184
+ const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
185
+ const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
186
+ const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
187
+ const isWindows = platform === "win32";
188
+ const isDumbTerminal = env$1.TERM === "dumb";
189
+ const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
190
+ const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
191
+ const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
192
+ const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
193
+ const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
194
+ const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
195
+ const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
196
+ const colors$1 = {
197
+ reset: init(0, 0),
198
+ bold: init(1, 22, "\x1B[22m\x1B[1m"),
199
+ dim: init(2, 22, "\x1B[22m\x1B[2m"),
200
+ italic: init(3, 23),
201
+ underline: init(4, 24),
202
+ inverse: init(7, 27),
203
+ hidden: init(8, 28),
204
+ strikethrough: init(9, 29),
205
+ black: init(30, 39),
206
+ red: init(31, 39),
207
+ green: init(32, 39),
208
+ yellow: init(33, 39),
209
+ blue: init(34, 39),
210
+ magenta: init(35, 39),
211
+ cyan: init(36, 39),
212
+ white: init(37, 39),
213
+ gray: init(90, 39),
214
+ bgBlack: init(40, 49),
215
+ bgRed: init(41, 49),
216
+ bgGreen: init(42, 49),
217
+ bgYellow: init(43, 49),
218
+ bgBlue: init(44, 49),
219
+ bgMagenta: init(45, 49),
220
+ bgCyan: init(46, 49),
221
+ bgWhite: init(47, 49),
222
+ blackBright: init(90, 39),
223
+ redBright: init(91, 39),
224
+ greenBright: init(92, 39),
225
+ yellowBright: init(93, 39),
226
+ blueBright: init(94, 39),
227
+ magentaBright: init(95, 39),
228
+ cyanBright: init(96, 39),
229
+ whiteBright: init(97, 39),
230
+ bgBlackBright: init(100, 49),
231
+ bgRedBright: init(101, 49),
232
+ bgGreenBright: init(102, 49),
233
+ bgYellowBright: init(103, 49),
234
+ bgBlueBright: init(104, 49),
235
+ bgMagentaBright: init(105, 49),
236
+ bgCyanBright: init(106, 49),
237
+ bgWhiteBright: init(107, 49)
238
+ };
239
+ const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
240
+ ...colors$2,
241
+ [key]: String
242
+ }), {});
243
+ const { reset, bold: bold$1, dim: dim$1, italic, underline: underline$1, inverse, hidden, strikethrough, black, red: red$1, green: green$1, yellow: yellow$1, blue, magenta, cyan: cyan$1, white, gray: gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
244
+
245
+ //#endregion
246
+ //#region src/cli/colors.ts
247
+ const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR });
248
+ const colors = {
249
+ bold,
250
+ cyan,
251
+ dim,
252
+ gray,
253
+ green,
254
+ red,
255
+ underline,
256
+ yellow
257
+ };
258
+
259
+ //#endregion
260
+ //#region src/cli/utils.ts
261
+ const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
262
+ function createTestingLogger() {
263
+ const types = [
264
+ "silent",
265
+ "fatal",
266
+ "error",
267
+ "warn",
268
+ "log",
269
+ "info",
270
+ "success",
271
+ "fail",
272
+ "ready",
273
+ "start",
274
+ "box",
275
+ "debug",
276
+ "trace",
277
+ "verbose"
278
+ ];
279
+ const ret = Object.create(null);
280
+ for (const type of types) ret[type] = console.log;
281
+ return ret;
282
+ }
283
+ async function ensureConfig(configPath) {
284
+ const fileUrl = pathToFileURL(configPath).toString();
285
+ let configExports;
286
+ try {
287
+ configExports = await import(fileUrl);
288
+ } catch (err) {
289
+ let errorMessage = "Error happened while loading config.";
290
+ if (!isSupportedFormat(configPath)) errorMessage += ` Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${nodePath.extname(configPath)}\``;
291
+ throw new Error(errorMessage, { cause: err });
292
+ }
293
+ return configExports.default;
294
+ }
295
+ const SUPPORTED_CONFIG_FORMATS = [
296
+ ".js",
297
+ ".mjs",
298
+ ".cjs"
299
+ ];
300
+ /**
301
+ * Check whether the configuration file is supported
302
+ */
303
+ function isSupportedFormat(configPath) {
304
+ const ext = nodePath.extname(configPath);
305
+ return SUPPORTED_CONFIG_FORMATS.includes(ext);
306
+ }
313
307
 
314
308
  //#endregion
315
309
  //#region src/cli/commands/bundle.ts
@@ -320,28 +314,32 @@ async function bundleWithConfig(configPath, cliOptions) {
320
314
  process.exit(1);
321
315
  }
322
316
  const configList = arraify(config);
323
- for (const config$1 of configList) {
324
- cliOptions.watch ? await watchInner(config$1, cliOptions) : bundleInner(config$1, cliOptions);
325
- }
317
+ const operation = cliOptions.watch ? watchInner : bundleInner;
318
+ for (const config$1 of configList) await operation(config$1, cliOptions);
326
319
  }
327
320
  async function bundleWithCliOptions(cliOptions) {
328
321
  if (cliOptions.output.dir) {
329
- cliOptions.watch ? await watchInner({}, cliOptions) : await bundleInner({}, cliOptions);
330
- } else if (!cliOptions.watch) {
331
- const build = await rolldown(cliOptions.input);
332
- const { output: output } = await build.generate(cliOptions.output);
333
- if (output.length > 1) {
334
- logger.error("Multiple chunks are not supported to display in stdout");
335
- process.exit(1);
336
- } else if (output.length === 0) {
322
+ const operation = cliOptions.watch ? watchInner : bundleInner;
323
+ await operation({}, cliOptions);
324
+ return;
325
+ }
326
+ if (cliOptions.watch) {
327
+ logger.error("You must specify `output.dir` to use watch mode");
328
+ process.exit(1);
329
+ }
330
+ const build = await rolldown(cliOptions.input);
331
+ try {
332
+ const { output: outputs } = await build.generate(cliOptions.output);
333
+ if (outputs.length === 0) {
337
334
  logger.error("No output generated");
338
335
  process.exit(1);
339
- } else {
340
- logger.log(output[0].code);
341
336
  }
342
- } else {
343
- logger.error("You must specify `output.dir` to use watch mode");
344
- process.exit(1);
337
+ for (const file of outputs) {
338
+ if (outputs.length > 1) logger.log(`\n${colors.cyan(colors.bold(`|→ ${file.fileName}:`))}\n`);
339
+ logger.log(file.type === "asset" ? file.source : file.code);
340
+ }
341
+ } finally {
342
+ await build.close();
345
343
  }
346
344
  }
347
345
  async function watchInner(options$1, cliOptions) {
@@ -350,25 +348,26 @@ async function watchInner(options$1, cliOptions) {
350
348
  ...cliOptions.input
351
349
  });
352
350
  onExit((code) => {
353
- (Promise.resolve(watcher.close())).finally(() => {
351
+ Promise.resolve(watcher.close()).finally(() => {
354
352
  process.exit(typeof code === "number" ? code : 0);
355
353
  });
356
354
  return true;
357
355
  });
358
356
  const changedFile = [];
359
357
  watcher.on("change", (id, event) => {
360
- if (event.event === "update") {
361
- changedFile.push(id);
362
- }
358
+ if (event.event === "update") changedFile.push(id);
363
359
  });
364
360
  watcher.on("event", (event) => {
365
361
  switch (event.code) {
366
362
  case "BUNDLE_START":
367
- logger.log(`Found ${bold((changedFile.map(relativeId)).join(", "))} changed, rebuilding...`);
363
+ if (changedFile.length > 0) logger.log(`Found ${colors.bold(changedFile.map(relativeId).join(", "))} changed, rebuilding...`);
368
364
  changedFile.length = 0;
369
365
  break;
370
366
  case "BUNDLE_END":
371
- logger.success(`Rebuilt ${bold(relativeId(event.output[0]))} in ${bold(ms(event.duration))}.`);
367
+ logger.success(`Rebuilt ${colors.bold(relativeId(event.output[0]))} in ${colors.bold(ms(event.duration))}.`);
368
+ break;
369
+ case "ERROR":
370
+ logger.error(event.error);
372
371
  break;
373
372
  default: break;
374
373
  }
@@ -381,15 +380,19 @@ async function bundleInner(options$1, cliOptions) {
381
380
  ...options$1,
382
381
  ...cliOptions.input
383
382
  });
384
- const bundleOutput = await build.write({
385
- ...options$1?.output,
386
- ...cliOptions.output
387
- });
388
- const endTime = performance.now();
389
- printBundleOutputPretty(bundleOutput);
390
- logger.log(``);
391
- const duration = endTime - startTime;
392
- logger.success(`Finished in ${bold(ms(duration))}`);
383
+ try {
384
+ const bundleOutput = await build.write({
385
+ ...options$1?.output,
386
+ ...cliOptions.output
387
+ });
388
+ const endTime = performance.now();
389
+ printBundleOutputPretty(bundleOutput);
390
+ logger.log(``);
391
+ const duration = endTime - startTime;
392
+ logger.success(`Finished in ${colors.bold(ms(duration))}`);
393
+ } finally {
394
+ await build.close();
395
+ }
393
396
  }
394
397
  function printBundleOutputPretty(output) {
395
398
  const outputEntries = collectOutputEntries(output.output);
@@ -407,14 +410,10 @@ function collectOutputLayoutAdjustmentSizes(entries) {
407
410
  let longest = 0;
408
411
  let biggestSize = 0;
409
412
  for (const entry of entries) {
410
- if (entry.fileName.length > longest) {
411
- longest = entry.fileName.length;
412
- }
413
- if (entry.size > biggestSize) {
414
- biggestSize = entry.size;
415
- }
413
+ if (entry.fileName.length > longest) longest = entry.fileName.length;
414
+ if (entry.size > biggestSize) biggestSize = entry.size;
416
415
  }
417
- const sizePad = (displaySize(biggestSize)).length;
416
+ const sizePad = displaySize(biggestSize).length;
418
417
  return {
419
418
  longest,
420
419
  biggestSize,
@@ -426,7 +425,7 @@ const numberFormatter = new Intl.NumberFormat("en", {
426
425
  minimumFractionDigits: 2
427
426
  });
428
427
  function displaySize(bytes) {
429
- return `${numberFormatter.format(bytes / 1000)} kB`;
428
+ return `${numberFormatter.format(bytes / 1e3)} kB`;
430
429
  }
431
430
  const CHUNK_GROUPS = [{
432
431
  type: "asset",
@@ -434,30 +433,26 @@ const CHUNK_GROUPS = [{
434
433
  }, {
435
434
  type: "chunk",
436
435
  color: "cyan"
437
- },];
436
+ }];
438
437
  function printOutputEntries(entries, sizeAdjustment, distPath) {
439
438
  for (const group of CHUNK_GROUPS) {
440
439
  const filtered = entries.filter((e) => e.type === group.type);
441
- if (!filtered.length) {
442
- continue;
443
- }
444
- for (const entry of filtered.sort((a, z$4) => a.size - z$4.size)) {
445
- let log = dim(withTrailingSlash(distPath));
446
- log += colors_ns[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
447
- log += dim(entry.type);
448
- log += dim(` │ size: ${(displaySize(entry.size)).padStart(sizeAdjustment.sizePad)}`);
440
+ if (!filtered.length) continue;
441
+ for (const entry of filtered.sort((a, z$1) => a.size - z$1.size)) {
442
+ let log = colors.dim(withTrailingSlash(distPath));
443
+ log += colors[group.color](entry.fileName.padEnd(sizeAdjustment.longest + 2));
444
+ log += colors.dim(entry.type);
445
+ log += colors.dim(` │ size: ${displaySize(entry.size).padStart(sizeAdjustment.sizePad)}`);
449
446
  logger.log(log);
450
447
  }
451
448
  }
452
449
  }
453
450
  function withTrailingSlash(path$1) {
454
- if (path$1[path$1.length - 1] !== "/") {
455
- return `${path$1}/`;
456
- }
451
+ if (path$1[path$1.length - 1] !== "/") return `${path$1}/`;
457
452
  return path$1;
458
453
  }
459
454
  function ms(duration) {
460
- return duration < 1000 ? `${duration.toFixed(2)} ms` : `${(duration / 1000).toFixed(2)} s`;
455
+ return duration < 1e3 ? `${duration.toFixed(2)} ms` : `${(duration / 1e3).toFixed(2)} s`;
461
456
  }
462
457
  function relativeId(id) {
463
458
  if (!path.isAbsolute(id)) return id;
@@ -500,16 +495,24 @@ const getDefaultOptions = (options$1) => typeof options$1 === "string" ? {
500
495
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/Refs.js
501
496
  const getRefs = (options$1) => {
502
497
  const _options = getDefaultOptions(options$1);
503
- const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
498
+ const currentPath = _options.name !== undefined ? [
499
+ ..._options.basePath,
500
+ _options.definitionPath,
501
+ _options.name
502
+ ] : _options.basePath;
504
503
  return {
505
504
  ..._options,
506
- currentPath: currentPath,
505
+ currentPath,
507
506
  propertyPath: undefined,
508
- seen: new Map((Object.entries(_options.definitions)).map(([name, def]) => [def._def, {
507
+ seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
509
508
  def: def._def,
510
- path: [..._options.basePath, _options.definitionPath, name],
509
+ path: [
510
+ ..._options.basePath,
511
+ _options.definitionPath,
512
+ name
513
+ ],
511
514
  jsonSchema: undefined
512
- },]))
515
+ }]))
513
516
  };
514
517
  };
515
518
 
@@ -517,12 +520,10 @@ const getRefs = (options$1) => {
517
520
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
518
521
  function addErrorMessage(res, key, errorMessage, refs) {
519
522
  if (!refs?.errorMessages) return;
520
- if (errorMessage) {
521
- res.errorMessage = {
522
- ...res.errorMessage,
523
- [key]: errorMessage
524
- };
525
- }
523
+ if (errorMessage) res.errorMessage = {
524
+ ...res.errorMessage,
525
+ [key]: errorMessage
526
+ };
526
527
  }
527
528
  function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
528
529
  res[key] = value;
@@ -538,19 +539,13 @@ function parseAnyDef() {
538
539
  //#endregion
539
540
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
540
541
  function parseArrayDef(def, refs) {
541
- const res = {type: "array"};
542
- if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind$2.ZodAny) {
543
- res.items = parseDef(def.type._def, {
544
- ...refs,
545
- currentPath: [...refs.currentPath, "items"]
546
- });
547
- }
548
- if (def.minLength) {
549
- setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
550
- }
551
- if (def.maxLength) {
552
- setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
553
- }
542
+ const res = { type: "array" };
543
+ if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
544
+ ...refs,
545
+ currentPath: [...refs.currentPath, "items"]
546
+ });
547
+ if (def.minLength) setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
548
+ if (def.maxLength) setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
554
549
  if (def.exactLength) {
555
550
  setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
556
551
  setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
@@ -566,40 +561,26 @@ function parseBigintDef(def, refs) {
566
561
  format: "int64"
567
562
  };
568
563
  if (!def.checks) return res;
569
- for (const check of def.checks) {
570
- switch (check.kind) {
571
- case "min":
572
- if (refs.target === "jsonSchema7") {
573
- if (check.inclusive) {
574
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
575
- } else {
576
- setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
577
- }
578
- } else {
579
- if (!check.inclusive) {
580
- res.exclusiveMinimum = true;
581
- }
582
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
583
- }
584
- break;
585
- case "max":
586
- if (refs.target === "jsonSchema7") {
587
- if (check.inclusive) {
588
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
589
- } else {
590
- setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
591
- }
592
- } else {
593
- if (!check.inclusive) {
594
- res.exclusiveMaximum = true;
595
- }
596
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
597
- }
598
- break;
599
- case "multipleOf":
600
- setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
601
- break;
602
- }
564
+ for (const check of def.checks) switch (check.kind) {
565
+ case "min":
566
+ if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
567
+ else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
568
+ else {
569
+ if (!check.inclusive) res.exclusiveMinimum = true;
570
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
571
+ }
572
+ break;
573
+ case "max":
574
+ if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
575
+ else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
576
+ else {
577
+ if (!check.inclusive) res.exclusiveMaximum = true;
578
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
579
+ }
580
+ break;
581
+ case "multipleOf":
582
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
583
+ break;
603
584
  }
604
585
  return res;
605
586
  }
@@ -607,7 +588,7 @@ function parseBigintDef(def, refs) {
607
588
  //#endregion
608
589
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
609
590
  function parseBooleanDef() {
610
- return {type: "boolean"};
591
+ return { type: "boolean" };
611
592
  }
612
593
 
613
594
  //#endregion
@@ -626,9 +607,7 @@ const parseCatchDef = (def, refs) => {
626
607
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
627
608
  function parseDateDef(def, refs, overrideDateStrategy) {
628
609
  const strategy = overrideDateStrategy ?? refs.dateStrategy;
629
- if (Array.isArray(strategy)) {
630
- return {anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))};
631
- }
610
+ if (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };
632
611
  switch (strategy) {
633
612
  case "string":
634
613
  case "format:date-time": return {
@@ -647,18 +626,14 @@ const integerDateParser = (def, refs) => {
647
626
  type: "integer",
648
627
  format: "unix-time"
649
628
  };
650
- if (refs.target === "openApi3") {
651
- return res;
652
- }
653
- for (const check of def.checks) {
654
- switch (check.kind) {
655
- case "min":
656
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
657
- break;
658
- case "max":
659
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
660
- break;
661
- }
629
+ if (refs.target === "openApi3") return res;
630
+ for (const check of def.checks) switch (check.kind) {
631
+ case "min":
632
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
633
+ break;
634
+ case "max":
635
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
636
+ break;
662
637
  }
663
638
  return res;
664
639
  };
@@ -690,33 +665,37 @@ function parseEnumDef(def) {
690
665
  //#endregion
691
666
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
692
667
  const isJsonSchema7AllOfType = (type) => {
693
- if ("type"in type && type.type === "string") return false;
694
- return "allOf"in type;
668
+ if ("type" in type && type.type === "string") return false;
669
+ return "allOf" in type;
695
670
  };
696
671
  function parseIntersectionDef(def, refs) {
697
672
  const allOf = [parseDef(def.left._def, {
698
673
  ...refs,
699
- currentPath: [...refs.currentPath, "allOf", "0"]
674
+ currentPath: [
675
+ ...refs.currentPath,
676
+ "allOf",
677
+ "0"
678
+ ]
700
679
  }), parseDef(def.right._def, {
701
680
  ...refs,
702
- currentPath: [...refs.currentPath, "allOf", "1"]
703
- }),].filter((x) => !!x);
704
- let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? {unevaluatedProperties: false} : undefined;
681
+ currentPath: [
682
+ ...refs.currentPath,
683
+ "allOf",
684
+ "1"
685
+ ]
686
+ })].filter((x) => !!x);
687
+ let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : undefined;
705
688
  const mergedAllOf = [];
706
689
  allOf.forEach((schema$1) => {
707
690
  if (isJsonSchema7AllOfType(schema$1)) {
708
691
  mergedAllOf.push(...schema$1.allOf);
709
- if (schema$1.unevaluatedProperties === undefined) {
710
- unevaluatedProperties = undefined;
711
- }
692
+ if (schema$1.unevaluatedProperties === undefined) unevaluatedProperties = undefined;
712
693
  } else {
713
694
  let nestedSchema = schema$1;
714
- if ("additionalProperties"in schema$1 && schema$1.additionalProperties === false) {
715
- const { additionalProperties: additionalProperties,...rest } = schema$1;
695
+ if ("additionalProperties" in schema$1 && schema$1.additionalProperties === false) {
696
+ const { additionalProperties,...rest } = schema$1;
716
697
  nestedSchema = rest;
717
- } else {
718
- unevaluatedProperties = undefined;
719
- }
698
+ } else unevaluatedProperties = undefined;
720
699
  mergedAllOf.push(nestedSchema);
721
700
  }
722
701
  });
@@ -730,15 +709,11 @@ function parseIntersectionDef(def, refs) {
730
709
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
731
710
  function parseLiteralDef(def, refs) {
732
711
  const parsedType = typeof def.value;
733
- if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
734
- return {type: Array.isArray(def.value) ? "array" : "object"};
735
- }
736
- if (refs.target === "openApi3") {
737
- return {
738
- type: parsedType === "bigint" ? "integer" : parsedType,
739
- enum: [def.value]
740
- };
741
- }
712
+ if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") return { type: Array.isArray(def.value) ? "array" : "object" };
713
+ if (refs.target === "openApi3") return {
714
+ type: parsedType === "bigint" ? "integer" : parsedType,
715
+ enum: [def.value]
716
+ };
742
717
  return {
743
718
  type: parsedType === "bigint" ? "integer" : parsedType,
744
719
  const: def.value
@@ -754,9 +729,7 @@ const zodPatterns = {
754
729
  ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
755
730
  email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
756
731
  emoji: () => {
757
- if (emojiRegex === undefined) {
758
- emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
759
- }
732
+ if (emojiRegex === undefined) emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
760
733
  return emojiRegex;
761
734
  },
762
735
  uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
@@ -766,170 +739,148 @@ const zodPatterns = {
766
739
  nanoid: /^[a-zA-Z0-9_-]{21}$/
767
740
  };
768
741
  function parseStringDef(def, refs) {
769
- const res = {type: "string"};
742
+ const res = { type: "string" };
770
743
  function processPattern(value) {
771
744
  return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(value) : value;
772
745
  }
773
- if (def.checks) {
774
- for (const check of def.checks) {
775
- switch (check.kind) {
776
- case "min":
777
- setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
778
- break;
779
- case "max":
780
- setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
781
- break;
782
- case "email":
783
- switch (refs.emailStrategy) {
784
- case "format:email":
785
- addFormat(res, "email", check.message, refs);
786
- break;
787
- case "format:idn-email":
788
- addFormat(res, "idn-email", check.message, refs);
789
- break;
790
- case "pattern:zod":
791
- addPattern(res, zodPatterns.email, check.message, refs);
792
- break;
793
- }
794
- break;
795
- case "url":
796
- addFormat(res, "uri", check.message, refs);
797
- break;
798
- case "uuid":
799
- addFormat(res, "uuid", check.message, refs);
800
- break;
801
- case "regex":
802
- addPattern(res, check.regex, check.message, refs);
746
+ if (def.checks) for (const check of def.checks) switch (check.kind) {
747
+ case "min":
748
+ setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
749
+ break;
750
+ case "max":
751
+ setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
752
+ break;
753
+ case "email":
754
+ switch (refs.emailStrategy) {
755
+ case "format:email":
756
+ addFormat(res, "email", check.message, refs);
803
757
  break;
804
- case "cuid":
805
- addPattern(res, zodPatterns.cuid, check.message, refs);
758
+ case "format:idn-email":
759
+ addFormat(res, "idn-email", check.message, refs);
806
760
  break;
807
- case "cuid2":
808
- addPattern(res, zodPatterns.cuid2, check.message, refs);
761
+ case "pattern:zod":
762
+ addPattern(res, zodPatterns.email, check.message, refs);
809
763
  break;
810
- case "startsWith":
811
- addPattern(res, RegExp(`^${processPattern(check.value)}`), check.message, refs);
812
- break;
813
- case "endsWith":
814
- addPattern(res, RegExp(`${processPattern(check.value)}$`), check.message, refs);
815
- break;
816
- case "datetime":
817
- addFormat(res, "date-time", check.message, refs);
818
- break;
819
- case "date":
820
- addFormat(res, "date", check.message, refs);
821
- break;
822
- case "time":
823
- addFormat(res, "time", check.message, refs);
824
- break;
825
- case "duration":
826
- addFormat(res, "duration", check.message, refs);
827
- break;
828
- case "length":
829
- setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
830
- setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
831
- break;
832
- case "includes": {
833
- addPattern(res, RegExp(processPattern(check.value)), check.message, refs);
834
- break;
835
- }
836
- case "ip": {
837
- if (check.version !== "v6") {
838
- addFormat(res, "ipv4", check.message, refs);
839
- }
840
- if (check.version !== "v4") {
841
- addFormat(res, "ipv6", check.message, refs);
842
- }
764
+ }
765
+ break;
766
+ case "url":
767
+ addFormat(res, "uri", check.message, refs);
768
+ break;
769
+ case "uuid":
770
+ addFormat(res, "uuid", check.message, refs);
771
+ break;
772
+ case "regex":
773
+ addPattern(res, check.regex, check.message, refs);
774
+ break;
775
+ case "cuid":
776
+ addPattern(res, zodPatterns.cuid, check.message, refs);
777
+ break;
778
+ case "cuid2":
779
+ addPattern(res, zodPatterns.cuid2, check.message, refs);
780
+ break;
781
+ case "startsWith":
782
+ addPattern(res, RegExp(`^${processPattern(check.value)}`), check.message, refs);
783
+ break;
784
+ case "endsWith":
785
+ addPattern(res, RegExp(`${processPattern(check.value)}$`), check.message, refs);
786
+ break;
787
+ case "datetime":
788
+ addFormat(res, "date-time", check.message, refs);
789
+ break;
790
+ case "date":
791
+ addFormat(res, "date", check.message, refs);
792
+ break;
793
+ case "time":
794
+ addFormat(res, "time", check.message, refs);
795
+ break;
796
+ case "duration":
797
+ addFormat(res, "duration", check.message, refs);
798
+ break;
799
+ case "length":
800
+ setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
801
+ setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
802
+ break;
803
+ case "includes": {
804
+ addPattern(res, RegExp(processPattern(check.value)), check.message, refs);
805
+ break;
806
+ }
807
+ case "ip": {
808
+ if (check.version !== "v6") addFormat(res, "ipv4", check.message, refs);
809
+ if (check.version !== "v4") addFormat(res, "ipv6", check.message, refs);
810
+ break;
811
+ }
812
+ case "emoji":
813
+ addPattern(res, zodPatterns.emoji, check.message, refs);
814
+ break;
815
+ case "ulid": {
816
+ addPattern(res, zodPatterns.ulid, check.message, refs);
817
+ break;
818
+ }
819
+ case "base64": {
820
+ switch (refs.base64Strategy) {
821
+ case "format:binary": {
822
+ addFormat(res, "binary", check.message, refs);
843
823
  break;
844
824
  }
845
- case "emoji":
846
- addPattern(res, zodPatterns.emoji, check.message, refs);
847
- break;
848
- case "ulid": {
849
- addPattern(res, zodPatterns.ulid, check.message, refs);
825
+ case "contentEncoding:base64": {
826
+ setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
850
827
  break;
851
828
  }
852
- case "base64": {
853
- switch (refs.base64Strategy) {
854
- case "format:binary": {
855
- addFormat(res, "binary", check.message, refs);
856
- break;
857
- }
858
- case "contentEncoding:base64": {
859
- setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
860
- break;
861
- }
862
- case "pattern:zod": {
863
- addPattern(res, zodPatterns.base64, check.message, refs);
864
- break;
865
- }
866
- }
829
+ case "pattern:zod": {
830
+ addPattern(res, zodPatterns.base64, check.message, refs);
867
831
  break;
868
832
  }
869
- case "nanoid": {
870
- addPattern(res, zodPatterns.nanoid, check.message, refs);
871
- }
872
- case "toLowerCase":
873
- case "toUpperCase":
874
- case "trim": break;
875
- default: ((_) => {})(check);
876
833
  }
834
+ break;
877
835
  }
836
+ case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
837
+ case "toLowerCase":
838
+ case "toUpperCase":
839
+ case "trim": break;
840
+ default: ((_) => {})(check);
878
841
  }
879
842
  return res;
880
843
  }
881
- const escapeNonAlphaNumeric = (value) => ((Array.from(value)).map((c) => /[a-zA-Z0-9]/.test(c) ? c : `\\${c}`)).join("");
844
+ const escapeNonAlphaNumeric = (value) => Array.from(value).map((c) => /[a-zA-Z0-9]/.test(c) ? c : `\\${c}`).join("");
882
845
  const addFormat = (schema$1, value, message, refs) => {
883
846
  if (schema$1.format || schema$1.anyOf?.some((x) => x.format)) {
884
- if (!schema$1.anyOf) {
885
- schema$1.anyOf = [];
886
- }
847
+ if (!schema$1.anyOf) schema$1.anyOf = [];
887
848
  if (schema$1.format) {
888
849
  schema$1.anyOf.push({
889
850
  format: schema$1.format,
890
- ...schema$1.errorMessage && refs.errorMessages && {errorMessage: {format: schema$1.errorMessage.format}}
851
+ ...schema$1.errorMessage && refs.errorMessages && { errorMessage: { format: schema$1.errorMessage.format } }
891
852
  });
892
853
  delete schema$1.format;
893
854
  if (schema$1.errorMessage) {
894
855
  delete schema$1.errorMessage.format;
895
- if ((Object.keys(schema$1.errorMessage)).length === 0) {
896
- delete schema$1.errorMessage;
897
- }
856
+ if (Object.keys(schema$1.errorMessage).length === 0) delete schema$1.errorMessage;
898
857
  }
899
858
  }
900
859
  schema$1.anyOf.push({
901
860
  format: value,
902
- ...message && refs.errorMessages && {errorMessage: {format: message}}
861
+ ...message && refs.errorMessages && { errorMessage: { format: message } }
903
862
  });
904
- } else {
905
- setResponseValueAndErrors(schema$1, "format", value, message, refs);
906
- }
863
+ } else setResponseValueAndErrors(schema$1, "format", value, message, refs);
907
864
  };
908
865
  const addPattern = (schema$1, regex, message, refs) => {
909
866
  if (schema$1.pattern || schema$1.allOf?.some((x) => x.pattern)) {
910
- if (!schema$1.allOf) {
911
- schema$1.allOf = [];
912
- }
867
+ if (!schema$1.allOf) schema$1.allOf = [];
913
868
  if (schema$1.pattern) {
914
869
  schema$1.allOf.push({
915
870
  pattern: schema$1.pattern,
916
- ...schema$1.errorMessage && refs.errorMessages && {errorMessage: {pattern: schema$1.errorMessage.pattern}}
871
+ ...schema$1.errorMessage && refs.errorMessages && { errorMessage: { pattern: schema$1.errorMessage.pattern } }
917
872
  });
918
873
  delete schema$1.pattern;
919
874
  if (schema$1.errorMessage) {
920
875
  delete schema$1.errorMessage.pattern;
921
- if ((Object.keys(schema$1.errorMessage)).length === 0) {
922
- delete schema$1.errorMessage;
923
- }
876
+ if (Object.keys(schema$1.errorMessage).length === 0) delete schema$1.errorMessage;
924
877
  }
925
878
  }
926
879
  schema$1.allOf.push({
927
880
  pattern: processRegExp(regex, refs),
928
- ...message && refs.errorMessages && {errorMessage: {pattern: message}}
881
+ ...message && refs.errorMessages && { errorMessage: { pattern: message } }
929
882
  });
930
- } else {
931
- setResponseValueAndErrors(schema$1, "pattern", processRegExp(regex, refs), message, refs);
932
- }
883
+ } else setResponseValueAndErrors(schema$1, "pattern", processRegExp(regex, refs), message, refs);
933
884
  };
934
885
  const processRegExp = (regexOrFunction, refs) => {
935
886
  const regex = typeof regexOrFunction === "function" ? regexOrFunction() : regexOrFunction;
@@ -960,9 +911,7 @@ const processRegExp = (regexOrFunction, refs) => {
960
911
  } else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
961
912
  pattern += source[i];
962
913
  inCharRange = true;
963
- } else {
964
- pattern += `${source[i]}${source[i].toUpperCase()}`;
965
- }
914
+ } else pattern += `${source[i]}${source[i].toUpperCase()}`;
966
915
  continue;
967
916
  }
968
917
  } else if (source[i].match(/[a-z]/)) {
@@ -984,13 +933,9 @@ const processRegExp = (regexOrFunction, refs) => {
984
933
  continue;
985
934
  }
986
935
  pattern += source[i];
987
- if (source[i] === "\\") {
988
- isEscaped = true;
989
- } else if (inCharGroup && source[i] === "]") {
990
- inCharGroup = false;
991
- } else if (!inCharGroup && source[i] === "[") {
992
- inCharGroup = true;
993
- }
936
+ if (source[i] === "\\") isEscaped = true;
937
+ else if (inCharGroup && source[i] === "]") inCharGroup = false;
938
+ else if (!inCharGroup && source[i] === "[") inCharGroup = true;
994
939
  }
995
940
  try {
996
941
  const regexTest = new RegExp(pattern);
@@ -1004,20 +949,22 @@ const processRegExp = (regexOrFunction, refs) => {
1004
949
  //#endregion
1005
950
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
1006
951
  function parseRecordDef(def, refs) {
1007
- if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodEnum) {
1008
- return {
1009
- type: "object",
1010
- required: def.keyType._def.values,
1011
- properties: def.keyType._def.values.reduce((acc, key) => ({
1012
- ...acc,
1013
- [key]: parseDef(def.valueType._def, {
1014
- ...refs,
1015
- currentPath: [...refs.currentPath, "properties", key]
1016
- }) ?? {}
1017
- }), {}),
1018
- additionalProperties: false
1019
- };
1020
- }
952
+ if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
953
+ type: "object",
954
+ required: def.keyType._def.values,
955
+ properties: def.keyType._def.values.reduce((acc, key) => ({
956
+ ...acc,
957
+ [key]: parseDef(def.valueType._def, {
958
+ ...refs,
959
+ currentPath: [
960
+ ...refs.currentPath,
961
+ "properties",
962
+ key
963
+ ]
964
+ }) ?? {}
965
+ }), {}),
966
+ additionalProperties: false
967
+ };
1021
968
  const schema$1 = {
1022
969
  type: "object",
1023
970
  additionalProperties: parseDef(def.valueType._def, {
@@ -1025,22 +972,19 @@ function parseRecordDef(def, refs) {
1025
972
  currentPath: [...refs.currentPath, "additionalProperties"]
1026
973
  }) ?? {}
1027
974
  };
1028
- if (refs.target === "openApi3") {
1029
- return schema$1;
1030
- }
1031
- if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodString && def.keyType._def.checks?.length) {
1032
- const { type: type,...keyType } = parseStringDef(def.keyType._def, refs);
975
+ if (refs.target === "openApi3") return schema$1;
976
+ if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
977
+ const { type,...keyType } = parseStringDef(def.keyType._def, refs);
1033
978
  return {
1034
979
  ...schema$1,
1035
980
  propertyNames: keyType
1036
981
  };
1037
- } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodEnum) {
1038
- return {
1039
- ...schema$1,
1040
- propertyNames: {enum: def.keyType._def.values}
1041
- };
1042
- } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind$1.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind$1.ZodString && def.keyType._def.type._def.checks?.length) {
1043
- const { type: type,...keyType } = parseBrandedDef(def.keyType._def, refs);
982
+ } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
983
+ ...schema$1,
984
+ propertyNames: { enum: def.keyType._def.values }
985
+ };
986
+ else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
987
+ const { type,...keyType } = parseBrandedDef(def.keyType._def, refs);
1044
988
  return {
1045
989
  ...schema$1,
1046
990
  propertyNames: keyType
@@ -1052,16 +996,24 @@ function parseRecordDef(def, refs) {
1052
996
  //#endregion
1053
997
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
1054
998
  function parseMapDef(def, refs) {
1055
- if (refs.mapStrategy === "record") {
1056
- return parseRecordDef(def, refs);
1057
- }
999
+ if (refs.mapStrategy === "record") return parseRecordDef(def, refs);
1058
1000
  const keys = parseDef(def.keyType._def, {
1059
1001
  ...refs,
1060
- currentPath: [...refs.currentPath, "items", "items", "0"]
1002
+ currentPath: [
1003
+ ...refs.currentPath,
1004
+ "items",
1005
+ "items",
1006
+ "0"
1007
+ ]
1061
1008
  }) || {};
1062
1009
  const values = parseDef(def.valueType._def, {
1063
1010
  ...refs,
1064
- currentPath: [...refs.currentPath, "items", "items", "1"]
1011
+ currentPath: [
1012
+ ...refs.currentPath,
1013
+ "items",
1014
+ "items",
1015
+ "1"
1016
+ ]
1065
1017
  }) || {};
1066
1018
  return {
1067
1019
  type: "array",
@@ -1079,7 +1031,7 @@ function parseMapDef(def, refs) {
1079
1031
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
1080
1032
  function parseNativeEnumDef(def) {
1081
1033
  const object = def.values;
1082
- const actualKeys = (Object.keys(def.values)).filter((key) => {
1034
+ const actualKeys = Object.keys(def.values).filter((key) => {
1083
1035
  return typeof object[object[key]] !== "number";
1084
1036
  });
1085
1037
  const actualValues = actualKeys.map((key) => object[key]);
@@ -1093,7 +1045,7 @@ function parseNativeEnumDef(def) {
1093
1045
  //#endregion
1094
1046
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
1095
1047
  function parseNeverDef() {
1096
- return {not: {}};
1048
+ return { not: {} };
1097
1049
  }
1098
1050
 
1099
1051
  //#endregion
@@ -1102,7 +1054,7 @@ function parseNullDef(refs) {
1102
1054
  return refs.target === "openApi3" ? {
1103
1055
  enum: ["null"],
1104
1056
  nullable: true
1105
- } : {type: "null"};
1057
+ } : { type: "null" };
1106
1058
  }
1107
1059
 
1108
1060
  //#endregion
@@ -1122,7 +1074,7 @@ function parseUnionDef(def, refs) {
1122
1074
  const type = primitiveMappings[x._def.typeName];
1123
1075
  return type && !types$1.includes(type) ? [...types$1, type] : types$1;
1124
1076
  }, []);
1125
- return {type: types.length > 1 ? types : types[0]};
1077
+ return { type: types.length > 1 ? types : types[0] };
1126
1078
  } else if (options$1.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
1127
1079
  const types = options$1.reduce((acc, x) => {
1128
1080
  const type = typeof x._def.value;
@@ -1147,40 +1099,46 @@ function parseUnionDef(def, refs) {
1147
1099
  }, [])
1148
1100
  };
1149
1101
  }
1150
- } else if (options$1.every((x) => x._def.typeName === "ZodEnum")) {
1151
- return {
1152
- type: "string",
1153
- enum: options$1.reduce((acc, x) => [...acc, ...x._def.values.filter((x$1) => !acc.includes(x$1)),], [])
1154
- };
1155
- }
1102
+ } else if (options$1.every((x) => x._def.typeName === "ZodEnum")) return {
1103
+ type: "string",
1104
+ enum: options$1.reduce((acc, x) => [...acc, ...x._def.values.filter((x$1) => !acc.includes(x$1))], [])
1105
+ };
1156
1106
  return asAnyOf(def, refs);
1157
1107
  }
1158
1108
  const asAnyOf = (def, refs) => {
1159
- const anyOf = ((def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
1109
+ const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
1160
1110
  ...refs,
1161
- currentPath: [...refs.currentPath, "anyOf", `${i}`]
1162
- }))).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && (Object.keys(x)).length > 0));
1163
- return anyOf.length ? {anyOf} : undefined;
1111
+ currentPath: [
1112
+ ...refs.currentPath,
1113
+ "anyOf",
1114
+ `${i}`
1115
+ ]
1116
+ })).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
1117
+ return anyOf.length ? { anyOf } : undefined;
1164
1118
  };
1165
1119
 
1166
1120
  //#endregion
1167
1121
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
1168
1122
  function parseNullableDef(def, refs) {
1169
- if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
1170
- if (refs.target === "openApi3") {
1171
- return {
1172
- type: primitiveMappings[def.innerType._def.typeName],
1173
- nullable: true
1174
- };
1175
- }
1176
- return {type: [primitiveMappings[def.innerType._def.typeName], "null",]};
1123
+ if ([
1124
+ "ZodString",
1125
+ "ZodNumber",
1126
+ "ZodBigInt",
1127
+ "ZodBoolean",
1128
+ "ZodNull"
1129
+ ].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
1130
+ if (refs.target === "openApi3") return {
1131
+ type: primitiveMappings[def.innerType._def.typeName],
1132
+ nullable: true
1133
+ };
1134
+ return { type: [primitiveMappings[def.innerType._def.typeName], "null"] };
1177
1135
  }
1178
1136
  if (refs.target === "openApi3") {
1179
1137
  const base$1 = parseDef(def.innerType._def, {
1180
1138
  ...refs,
1181
1139
  currentPath: [...refs.currentPath]
1182
1140
  });
1183
- if (base$1 && "$ref"in base$1) return {
1141
+ if (base$1 && "$ref" in base$1) return {
1184
1142
  allOf: [base$1],
1185
1143
  nullable: true
1186
1144
  };
@@ -1191,54 +1149,44 @@ function parseNullableDef(def, refs) {
1191
1149
  }
1192
1150
  const base = parseDef(def.innerType._def, {
1193
1151
  ...refs,
1194
- currentPath: [...refs.currentPath, "anyOf", "0"]
1152
+ currentPath: [
1153
+ ...refs.currentPath,
1154
+ "anyOf",
1155
+ "0"
1156
+ ]
1195
1157
  });
1196
- return base && {anyOf: [base, {type: "null"}]};
1158
+ return base && { anyOf: [base, { type: "null" }] };
1197
1159
  }
1198
1160
 
1199
1161
  //#endregion
1200
1162
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
1201
1163
  function parseNumberDef(def, refs) {
1202
- const res = {type: "number"};
1164
+ const res = { type: "number" };
1203
1165
  if (!def.checks) return res;
1204
- for (const check of def.checks) {
1205
- switch (check.kind) {
1206
- case "int":
1207
- res.type = "integer";
1208
- addErrorMessage(res, "type", check.message, refs);
1209
- break;
1210
- case "min":
1211
- if (refs.target === "jsonSchema7") {
1212
- if (check.inclusive) {
1213
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
1214
- } else {
1215
- setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
1216
- }
1217
- } else {
1218
- if (!check.inclusive) {
1219
- res.exclusiveMinimum = true;
1220
- }
1221
- setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
1222
- }
1223
- break;
1224
- case "max":
1225
- if (refs.target === "jsonSchema7") {
1226
- if (check.inclusive) {
1227
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
1228
- } else {
1229
- setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
1230
- }
1231
- } else {
1232
- if (!check.inclusive) {
1233
- res.exclusiveMaximum = true;
1234
- }
1235
- setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
1236
- }
1237
- break;
1238
- case "multipleOf":
1239
- setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
1240
- break;
1241
- }
1166
+ for (const check of def.checks) switch (check.kind) {
1167
+ case "int":
1168
+ res.type = "integer";
1169
+ addErrorMessage(res, "type", check.message, refs);
1170
+ break;
1171
+ case "min":
1172
+ if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
1173
+ else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
1174
+ else {
1175
+ if (!check.inclusive) res.exclusiveMinimum = true;
1176
+ setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
1177
+ }
1178
+ break;
1179
+ case "max":
1180
+ if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
1181
+ else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
1182
+ else {
1183
+ if (!check.inclusive) res.exclusiveMaximum = true;
1184
+ setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
1185
+ }
1186
+ break;
1187
+ case "multipleOf":
1188
+ setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
1189
+ break;
1242
1190
  }
1243
1191
  return res;
1244
1192
  }
@@ -1246,27 +1194,32 @@ function parseNumberDef(def, refs) {
1246
1194
  //#endregion
1247
1195
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
1248
1196
  function decideAdditionalProperties(def, refs) {
1249
- if (refs.removeAdditionalStrategy === "strict") {
1250
- return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys !== "strict" : parseDef(def.catchall._def, {
1251
- ...refs,
1252
- currentPath: [...refs.currentPath, "additionalProperties"]
1253
- }) ?? true;
1254
- } else {
1255
- return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : parseDef(def.catchall._def, {
1256
- ...refs,
1257
- currentPath: [...refs.currentPath, "additionalProperties"]
1258
- }) ?? true;
1259
- }
1197
+ if (refs.removeAdditionalStrategy === "strict") return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys !== "strict" : parseDef(def.catchall._def, {
1198
+ ...refs,
1199
+ currentPath: [...refs.currentPath, "additionalProperties"]
1200
+ }) ?? true;
1201
+ else return def.catchall._def.typeName === "ZodNever" ? def.unknownKeys === "passthrough" : parseDef(def.catchall._def, {
1202
+ ...refs,
1203
+ currentPath: [...refs.currentPath, "additionalProperties"]
1204
+ }) ?? true;
1260
1205
  }
1261
1206
  function parseObjectDef(def, refs) {
1262
1207
  const result = {
1263
1208
  type: "object",
1264
- ...(Object.entries(def.shape())).reduce((acc, [propName, propDef]) => {
1209
+ ...Object.entries(def.shape()).reduce((acc, [propName, propDef]) => {
1265
1210
  if (propDef === undefined || propDef._def === undefined) return acc;
1266
1211
  const parsedDef = parseDef(propDef._def, {
1267
1212
  ...refs,
1268
- currentPath: [...refs.currentPath, "properties", propName],
1269
- propertyPath: [...refs.currentPath, "properties", propName]
1213
+ currentPath: [
1214
+ ...refs.currentPath,
1215
+ "properties",
1216
+ propName
1217
+ ],
1218
+ propertyPath: [
1219
+ ...refs.currentPath,
1220
+ "properties",
1221
+ propName
1222
+ ]
1270
1223
  });
1271
1224
  if (parsedDef === undefined) return acc;
1272
1225
  return {
@@ -1289,33 +1242,40 @@ function parseObjectDef(def, refs) {
1289
1242
  //#endregion
1290
1243
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
1291
1244
  const parseOptionalDef = (def, refs) => {
1292
- if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
1293
- return parseDef(def.innerType._def, refs);
1294
- }
1245
+ if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
1295
1246
  const innerSchema = parseDef(def.innerType._def, {
1296
1247
  ...refs,
1297
- currentPath: [...refs.currentPath, "anyOf", "1"]
1248
+ currentPath: [
1249
+ ...refs.currentPath,
1250
+ "anyOf",
1251
+ "1"
1252
+ ]
1298
1253
  });
1299
- return innerSchema ? {anyOf: [{not: {}}, innerSchema,]} : {};
1254
+ return innerSchema ? { anyOf: [{ not: {} }, innerSchema] } : {};
1300
1255
  };
1301
1256
 
1302
1257
  //#endregion
1303
1258
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
1304
1259
  const parsePipelineDef = (def, refs) => {
1305
- if (refs.pipeStrategy === "input") {
1306
- return parseDef(def.in._def, refs);
1307
- } else if (refs.pipeStrategy === "output") {
1308
- return parseDef(def.out._def, refs);
1309
- }
1260
+ if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
1261
+ else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
1310
1262
  const a = parseDef(def.in._def, {
1311
1263
  ...refs,
1312
- currentPath: [...refs.currentPath, "allOf", "0"]
1264
+ currentPath: [
1265
+ ...refs.currentPath,
1266
+ "allOf",
1267
+ "0"
1268
+ ]
1313
1269
  });
1314
1270
  const b = parseDef(def.out._def, {
1315
1271
  ...refs,
1316
- currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
1272
+ currentPath: [
1273
+ ...refs.currentPath,
1274
+ "allOf",
1275
+ a ? "1" : "0"
1276
+ ]
1317
1277
  });
1318
- return {allOf: [a, b].filter((x) => x !== undefined)};
1278
+ return { allOf: [a, b].filter((x) => x !== undefined) };
1319
1279
  };
1320
1280
 
1321
1281
  //#endregion
@@ -1336,48 +1296,49 @@ function parseSetDef(def, refs) {
1336
1296
  uniqueItems: true,
1337
1297
  items
1338
1298
  };
1339
- if (def.minSize) {
1340
- setResponseValueAndErrors(schema$1, "minItems", def.minSize.value, def.minSize.message, refs);
1341
- }
1342
- if (def.maxSize) {
1343
- setResponseValueAndErrors(schema$1, "maxItems", def.maxSize.value, def.maxSize.message, refs);
1344
- }
1299
+ if (def.minSize) setResponseValueAndErrors(schema$1, "minItems", def.minSize.value, def.minSize.message, refs);
1300
+ if (def.maxSize) setResponseValueAndErrors(schema$1, "maxItems", def.maxSize.value, def.maxSize.message, refs);
1345
1301
  return schema$1;
1346
1302
  }
1347
1303
 
1348
1304
  //#endregion
1349
1305
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
1350
1306
  function parseTupleDef(def, refs) {
1351
- if (def.rest) {
1352
- return {
1353
- type: "array",
1354
- minItems: def.items.length,
1355
- items: (def.items.map((x, i) => parseDef(x._def, {
1356
- ...refs,
1357
- currentPath: [...refs.currentPath, "items", `${i}`]
1358
- }))).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
1359
- additionalItems: parseDef(def.rest._def, {
1360
- ...refs,
1361
- currentPath: [...refs.currentPath, "additionalItems"]
1362
- })
1363
- };
1364
- } else {
1365
- return {
1366
- type: "array",
1367
- minItems: def.items.length,
1368
- maxItems: def.items.length,
1369
- items: (def.items.map((x, i) => parseDef(x._def, {
1370
- ...refs,
1371
- currentPath: [...refs.currentPath, "items", `${i}`]
1372
- }))).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
1373
- };
1374
- }
1307
+ if (def.rest) return {
1308
+ type: "array",
1309
+ minItems: def.items.length,
1310
+ items: def.items.map((x, i) => parseDef(x._def, {
1311
+ ...refs,
1312
+ currentPath: [
1313
+ ...refs.currentPath,
1314
+ "items",
1315
+ `${i}`
1316
+ ]
1317
+ })).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
1318
+ additionalItems: parseDef(def.rest._def, {
1319
+ ...refs,
1320
+ currentPath: [...refs.currentPath, "additionalItems"]
1321
+ })
1322
+ };
1323
+ else return {
1324
+ type: "array",
1325
+ minItems: def.items.length,
1326
+ maxItems: def.items.length,
1327
+ items: def.items.map((x, i) => parseDef(x._def, {
1328
+ ...refs,
1329
+ currentPath: [
1330
+ ...refs.currentPath,
1331
+ "items",
1332
+ `${i}`
1333
+ ]
1334
+ })).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
1335
+ };
1375
1336
  }
1376
1337
 
1377
1338
  //#endregion
1378
1339
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
1379
1340
  function parseUndefinedDef() {
1380
- return {not: {}};
1341
+ return { not: {} };
1381
1342
  }
1382
1343
 
1383
1344
  //#endregion
@@ -1398,15 +1359,11 @@ function parseDef(def, refs, forceResolution = false) {
1398
1359
  const seenItem = refs.seen.get(def);
1399
1360
  if (refs.override) {
1400
1361
  const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
1401
- if (overrideResult !== ignoreOverride) {
1402
- return overrideResult;
1403
- }
1362
+ if (overrideResult !== ignoreOverride) return overrideResult;
1404
1363
  }
1405
1364
  if (seenItem && !forceResolution) {
1406
1365
  const seenSchema = get$ref(seenItem, refs);
1407
- if (seenSchema !== undefined) {
1408
- return seenSchema;
1409
- }
1366
+ if (seenSchema !== undefined) return seenSchema;
1410
1367
  }
1411
1368
  const newItem = {
1412
1369
  def,
@@ -1415,16 +1372,14 @@ function parseDef(def, refs, forceResolution = false) {
1415
1372
  };
1416
1373
  refs.seen.set(def, newItem);
1417
1374
  const jsonSchema = selectParser(def, def.typeName, refs);
1418
- if (jsonSchema) {
1419
- addMeta(def, refs, jsonSchema);
1420
- }
1375
+ if (jsonSchema) addMeta(def, refs, jsonSchema);
1421
1376
  newItem.jsonSchema = jsonSchema;
1422
1377
  return jsonSchema;
1423
1378
  }
1424
1379
  const get$ref = (item, refs) => {
1425
1380
  switch (refs.$refStrategy) {
1426
- case "root": return {$ref: item.path.join("/")};
1427
- case "relative": return {$ref: getRelativePath(refs.currentPath, item.path)};
1381
+ case "root": return { $ref: item.path.join("/") };
1382
+ case "relative": return { $ref: getRelativePath(refs.currentPath, item.path) };
1428
1383
  case "none":
1429
1384
  case "seen": {
1430
1385
  if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
@@ -1437,9 +1392,7 @@ const get$ref = (item, refs) => {
1437
1392
  };
1438
1393
  const getRelativePath = (pathA, pathB) => {
1439
1394
  let i = 0;
1440
- for (; i < pathA.length && i < pathB.length; i++) {
1441
- if (pathA[i] !== pathB[i]) break;
1442
- }
1395
+ for (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;
1443
1396
  return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
1444
1397
  };
1445
1398
  const selectParser = (def, typeName, refs) => {
@@ -1465,7 +1418,7 @@ const selectParser = (def, typeName, refs) => {
1465
1418
  case ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);
1466
1419
  case ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);
1467
1420
  case ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);
1468
- case ZodFirstPartyTypeKind.ZodLazy: return parseDef((def.getter())._def, refs);
1421
+ case ZodFirstPartyTypeKind.ZodLazy: return parseDef(def.getter()._def, refs);
1469
1422
  case ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);
1470
1423
  case ZodFirstPartyTypeKind.ZodNaN:
1471
1424
  case ZodFirstPartyTypeKind.ZodNever: return parseNeverDef();
@@ -1486,9 +1439,7 @@ const selectParser = (def, typeName, refs) => {
1486
1439
  const addMeta = (def, refs, jsonSchema) => {
1487
1440
  if (def.description) {
1488
1441
  jsonSchema.description = def.description;
1489
- if (refs.markdownDescription) {
1490
- jsonSchema.markdownDescription = def.description;
1491
- }
1442
+ if (refs.markdownDescription) jsonSchema.markdownDescription = def.description;
1492
1443
  }
1493
1444
  return jsonSchema;
1494
1445
  };
@@ -1497,119 +1448,130 @@ const addMeta = (def, refs, jsonSchema) => {
1497
1448
  //#region ../../node_modules/.pnpm/zod-to-json-schema@3.23.5_zod@3.23.8/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
1498
1449
  const zodToJsonSchema = (schema$1, options$1) => {
1499
1450
  const refs = getRefs(options$1);
1500
- const definitions = typeof options$1 === "object" && options$1.definitions ? (Object.entries(options$1.definitions)).reduce((acc, [name$1, schema$2]) => ({
1451
+ const definitions = typeof options$1 === "object" && options$1.definitions ? Object.entries(options$1.definitions).reduce((acc, [name$1, schema$2]) => ({
1501
1452
  ...acc,
1502
1453
  [name$1]: parseDef(schema$2._def, {
1503
1454
  ...refs,
1504
- currentPath: [...refs.basePath, refs.definitionPath, name$1]
1455
+ currentPath: [
1456
+ ...refs.basePath,
1457
+ refs.definitionPath,
1458
+ name$1
1459
+ ]
1505
1460
  }, true) ?? {}
1506
1461
  }), {}) : undefined;
1507
1462
  const name = typeof options$1 === "string" ? options$1 : options$1?.nameStrategy === "title" ? undefined : options$1?.name;
1508
1463
  const main$1 = parseDef(schema$1._def, name === undefined ? refs : {
1509
1464
  ...refs,
1510
- currentPath: [...refs.basePath, refs.definitionPath, name]
1465
+ currentPath: [
1466
+ ...refs.basePath,
1467
+ refs.definitionPath,
1468
+ name
1469
+ ]
1511
1470
  }, false) ?? {};
1512
1471
  const title = typeof options$1 === "object" && options$1.name !== undefined && options$1.nameStrategy === "title" ? options$1.name : undefined;
1513
- if (title !== undefined) {
1514
- main$1.title = title;
1515
- }
1472
+ if (title !== undefined) main$1.title = title;
1516
1473
  const combined = name === undefined ? definitions ? {
1517
1474
  ...main$1,
1518
1475
  [refs.definitionPath]: definitions
1519
1476
  } : main$1 : {
1520
- $ref: [...refs.$refStrategy === "relative" ? [] : refs.basePath, refs.definitionPath, name,].join("/"),
1477
+ $ref: [
1478
+ ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1479
+ refs.definitionPath,
1480
+ name
1481
+ ].join("/"),
1521
1482
  [refs.definitionPath]: {
1522
1483
  ...definitions,
1523
1484
  [name]: main$1
1524
1485
  }
1525
1486
  };
1526
- if (refs.target === "jsonSchema7") {
1527
- combined.$schema = "http://json-schema.org/draft-07/schema#";
1528
- } else if (refs.target === "jsonSchema2019-09") {
1529
- combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
1530
- }
1487
+ if (refs.target === "jsonSchema7") combined.$schema = "http://json-schema.org/draft-07/schema#";
1488
+ else if (refs.target === "jsonSchema2019-09") combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
1531
1489
  return combined;
1532
1490
  };
1533
1491
 
1534
1492
  //#endregion
1535
1493
  //#region src/utils/zod-ext.ts
1536
- const stringOrRegExp = () => (z$3.string()).or(z$3.instanceof(RegExp));
1537
- const optionalStringArray = () => ((z$3.string()).array()).optional();
1494
+ const stringOrRegExp = () => z.string().or(z.instanceof(RegExp));
1495
+ const optionalStringArray = () => z.string().array().optional();
1538
1496
  const returnTrue = () => true;
1539
- const phantom = () => z$3.custom(returnTrue);
1497
+ const phantom = () => z.custom(returnTrue);
1540
1498
  const voidNullableWith = (t) => {
1541
- return (voidNullable()).or(t);
1499
+ return voidNullable().or(t);
1542
1500
  };
1543
1501
  const voidNullable = () => {
1544
- return ((z$3.void()).or(z$3.null())).or(z$3.undefined());
1502
+ return z.void().or(z.null()).or(z.undefined());
1545
1503
  };
1546
1504
 
1547
1505
  //#endregion
1548
- //#region src/options/input-options.ts
1549
- const inputOptionSchema = ((z$2.string()).or((z$2.string()).array())).or(z$2.record(z$2.string()));
1550
- const externalSchema = ((stringOrRegExp()).or((stringOrRegExp()).array())).or(((z$2.function()).args(z$2.string(), (z$2.string()).optional(), z$2.boolean())).returns(voidNullableWith(z$2.boolean())));
1551
- const moduleTypesSchema = z$2.record(((((((((((z$2.literal("js")).or(z$2.literal("jsx"))).or(z$2.literal("ts"))).or(z$2.literal("tsx"))).or(z$2.literal("json"))).or(z$2.literal("text"))).or(z$2.literal("base64"))).or(z$2.literal("dataurl"))).or(z$2.literal("binary"))).or(z$2.literal("empty"))).or(z$2.literal("css")));
1552
- const jsxOptionsSchema = z$2.strictObject({
1553
- mode: (((z$2.literal("classic")).or(z$2.literal("automatic"))).describe("Jsx transformation mode")).optional(),
1554
- factory: ((z$2.string()).describe("Jsx element transformation")).optional(),
1555
- fragment: ((z$2.string()).describe("Jsx fragment transformation")).optional(),
1556
- importSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is classic")).optional(),
1557
- jsxImportSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is automatic")).optional(),
1558
- refresh: ((z$2.boolean()).describe("React refresh transformation")).optional(),
1559
- development: ((z$2.boolean()).describe("Development specific information")).optional()
1506
+ //#region src/options/input-options-schema.ts
1507
+ const inputOptionSchema = z.string().or(z.string().array()).or(z.record(z.string()));
1508
+ const externalSchema = stringOrRegExp().or(stringOrRegExp().array()).or(z.function().args(z.string(), z.string().optional(), z.boolean()).returns(voidNullableWith(z.boolean())));
1509
+ const moduleTypesSchema = z.record(z.literal("js").or(z.literal("jsx")).or(z.literal("ts")).or(z.literal("tsx")).or(z.literal("json")).or(z.literal("text")).or(z.literal("base64")).or(z.literal("dataurl")).or(z.literal("binary")).or(z.literal("empty")).or(z.literal("css")));
1510
+ const jsxOptionsSchema = z.strictObject({
1511
+ mode: z.literal("classic").or(z.literal("automatic")).describe("Jsx transformation mode").optional(),
1512
+ factory: z.string().describe("Jsx element transformation").optional(),
1513
+ fragment: z.string().describe("Jsx fragment transformation").optional(),
1514
+ importSource: z.string().describe("Import the factory of element and fragment if mode is classic").optional(),
1515
+ jsxImportSource: z.string().describe("Import the factory of element and fragment if mode is automatic").optional(),
1516
+ refresh: z.boolean().describe("React refresh transformation").optional(),
1517
+ development: z.boolean().describe("Development specific information").optional()
1560
1518
  });
1561
- const stringOrRegExpSchema = (stringOrRegExp()).or((stringOrRegExp()).array());
1562
- const watchOptionsSchema = z$2.strictObject({
1563
- skipWrite: ((z$2.boolean()).describe("Skip the bundle.write() step")).optional(),
1564
- notify: ((z$2.strictObject({
1565
- pollInterval: (z$2.number()).optional(),
1566
- compareContents: (z$2.boolean()).optional()
1567
- })).describe("Notify options")).optional(),
1519
+ const stringOrRegExpSchema = stringOrRegExp().or(stringOrRegExp().array());
1520
+ const watchOptionsSchema = z.strictObject({
1521
+ skipWrite: z.boolean().describe("Skip the bundle.write() step").optional(),
1522
+ notify: z.strictObject({
1523
+ pollInterval: z.number().optional(),
1524
+ compareContents: z.boolean().optional()
1525
+ }).describe("Notify options").optional(),
1568
1526
  include: stringOrRegExpSchema.optional(),
1569
1527
  exclude: stringOrRegExpSchema.optional(),
1570
- chokidar: (z$2.any()).optional()
1528
+ chokidar: z.any().optional()
1571
1529
  });
1572
- const inputOptionsSchema = z$2.strictObject({
1530
+ const checksOptionsSchema = z.strictObject({ circularDependency: z.boolean().describe("Wether to emit warnings when detecting circular dependencies").optional() });
1531
+ const inputOptionsSchema = z.strictObject({
1573
1532
  input: inputOptionSchema.optional(),
1574
- plugins: ((phantom()).array()).optional(),
1533
+ plugins: phantom().optional(),
1575
1534
  external: externalSchema.optional(),
1576
- resolve: (z$2.strictObject({
1577
- alias: (z$2.record(z$2.string())).optional(),
1578
- aliasFields: (z$2.array(z$2.array(z$2.string()))).optional(),
1535
+ resolve: z.strictObject({
1536
+ alias: z.record(z.array(z.string()).or(z.string())).optional(),
1537
+ aliasFields: z.array(z.array(z.string())).optional(),
1579
1538
  conditionNames: optionalStringArray(),
1580
- extensionAlias: (z$2.record(z$2.string(), z$2.array(z$2.string()))).optional(),
1581
- exportsFields: (z$2.array(z$2.array(z$2.string()))).optional(),
1539
+ extensionAlias: z.record(z.string(), z.array(z.string())).optional(),
1540
+ exportsFields: z.array(z.array(z.string())).optional(),
1582
1541
  extensions: optionalStringArray(),
1583
1542
  mainFields: optionalStringArray(),
1584
1543
  mainFiles: optionalStringArray(),
1585
1544
  modules: optionalStringArray(),
1586
- symlinks: (z$2.boolean()).optional(),
1587
- tsconfigFilename: (z$2.string()).optional()
1588
- })).optional(),
1589
- cwd: ((z$2.string()).describe("current working directory.")).optional(),
1590
- platform: ((((z$2.literal("node")).or(z$2.literal("browser"))).or(z$2.literal("neutral"))).describe(`platform for which the code should be generated (node, ${underline("browser")}, neutral).`)).optional(),
1591
- shimMissingExports: (z$2.boolean()).optional(),
1592
- treeshake: (phantom()).optional(),
1593
- logLevel: (LogLevelOptionSchema.describe(`log level (${dim("silent")}, ${underline(gray("info"))}, debug, ${yellow("warn")})`)).optional(),
1594
- onLog: ((z$2.function()).args(LogLevelSchema, RollupLogSchema, (z$2.function()).args(LogLevelWithErrorSchema, RollupLogWithStringSchema))).optional(),
1595
- onwarn: ((z$2.function()).args(RollupLogSchema, (z$2.function()).args(RollupLogWithStringSchema.or((z$2.function()).returns(RollupLogWithStringSchema))))).optional(),
1596
- moduleTypes: (moduleTypesSchema.describe("module types for customized extensions.")).optional(),
1597
- experimental: (z$2.strictObject({
1598
- enableComposingJsPlugins: (z$2.boolean()).optional(),
1599
- strictExecutionOrder: (z$2.boolean()).optional(),
1600
- disableLiveBindings: (z$2.boolean()).optional()
1601
- })).optional(),
1602
- define: ((z$2.record(z$2.string())).describe("define global variables")).optional(),
1603
- inject: (z$2.record((z$2.string()).or(z$2.tuple([z$2.string(), z$2.string()])))).optional(),
1604
- profilerNames: (z$2.boolean()).optional(),
1545
+ symlinks: z.boolean().optional(),
1546
+ tsconfigFilename: z.string().optional()
1547
+ }).optional(),
1548
+ cwd: z.string().describe("Current working directory").optional(),
1549
+ platform: z.literal("node").or(z.literal("browser")).or(z.literal("neutral")).describe(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`).optional(),
1550
+ shimMissingExports: z.boolean().describe(`Create shim variables for missing exports`).optional(),
1551
+ treeshake: TreeshakingOptionsSchema.optional(),
1552
+ logLevel: LogLevelOptionSchema.describe(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`).optional(),
1553
+ onLog: z.function().args(LogLevelSchema, RollupLogSchema, z.function().args(LogLevelWithErrorSchema, RollupLogWithStringSchema)).optional(),
1554
+ onwarn: z.function().args(RollupLogSchema, z.function().args(RollupLogWithStringSchema.or(z.function().returns(RollupLogWithStringSchema)))).optional(),
1555
+ moduleTypes: moduleTypesSchema.describe("Module types for customized extensions").optional(),
1556
+ experimental: z.strictObject({
1557
+ enableComposingJsPlugins: z.boolean().optional(),
1558
+ strictExecutionOrder: z.boolean().optional(),
1559
+ disableLiveBindings: z.boolean().optional(),
1560
+ resolveNewUrlToAsset: z.boolean().optional()
1561
+ }).optional(),
1562
+ define: z.record(z.string()).describe("Define global variables").optional(),
1563
+ inject: z.record(z.string().or(z.tuple([z.string(), z.string()]))).optional(),
1564
+ profilerNames: z.boolean().optional(),
1605
1565
  jsx: jsxOptionsSchema.optional(),
1606
- watch: (watchOptionsSchema.or(z$2.literal(false))).optional()
1566
+ watch: watchOptionsSchema.or(z.literal(false)).optional(),
1567
+ dropLabels: z.array(z.string()).describe("Remove labeled statements with these label names").optional(),
1568
+ checks: checksOptionsSchema.optional()
1607
1569
  });
1608
- const inputCliOptionsSchema = (inputOptionsSchema.extend({
1609
- external: ((z$2.array(z$2.string())).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")).optional(),
1610
- inject: ((z$2.record(z$2.string())).describe("inject import statements on demand")).optional(),
1611
- treeshake: (((z$2.boolean()).describe("enable treeshaking")).default(true)).optional()
1612
- })).omit({
1570
+ const inputCliOptionsSchema = inputOptionsSchema.extend({
1571
+ external: z.array(z.string()).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`").optional(),
1572
+ inject: z.record(z.string()).describe("Inject import statements on demand").optional(),
1573
+ treeshake: z.boolean().describe("enable treeshaking").default(true).optional()
1574
+ }).omit({
1613
1575
  input: true,
1614
1576
  plugins: true,
1615
1577
  onwarn: true,
@@ -1621,70 +1583,76 @@ const inputCliOptionsSchema = (inputOptionsSchema.extend({
1621
1583
  });
1622
1584
 
1623
1585
  //#endregion
1624
- //#region src/options/output-options.ts
1625
- const ModuleFormatSchema = ((((((((z$1.literal("es")).or(z$1.literal("cjs"))).or(z$1.literal("esm"))).or(z$1.literal("module"))).or(z$1.literal("commonjs"))).or(z$1.literal("iife"))).or(z$1.literal("umd"))).describe(`output format of the generated bundle (supports ${underline("esm")}, cjs, and iife).`)).optional();
1626
- const addonFunctionSchema = ((z$1.function()).args(phantom())).returns((z$1.string()).or(z$1.promise(z$1.string())));
1627
- const chunkFileNamesFunctionSchema = ((z$1.function()).args(phantom())).returns(z$1.string());
1628
- const outputOptionsSchema = z$1.strictObject({
1629
- dir: ((z$1.string()).describe("Output directory, defaults to `dist` if `file` is not set.")).optional(),
1630
- file: ((z$1.string()).describe("Single output file")).optional(),
1631
- exports: (((((z$1.literal("auto")).or(z$1.literal("named"))).or(z$1.literal("default"))).or(z$1.literal("none"))).describe(`specify a export mode (${underline("auto")}, named, default, none)`)).optional(),
1632
- format: ModuleFormatSchema,
1633
- sourcemap: ((((z$1.boolean()).or(z$1.literal("inline"))).or(z$1.literal("hidden"))).describe(`generate sourcemap (\`-s inline\` for inline, or ${bold("pass the `-s` on the last argument if you want to generate `.map` file")}).`)).optional(),
1634
- sourcemapIgnoreList: ((z$1.boolean()).or(phantom())).optional(),
1635
- sourcemapPathTransform: (phantom()).optional(),
1636
- banner: ((z$1.string()).or(addonFunctionSchema)).optional(),
1637
- footer: ((z$1.string()).or(addonFunctionSchema)).optional(),
1638
- intro: ((z$1.string()).or(addonFunctionSchema)).optional(),
1639
- outro: ((z$1.string()).or(addonFunctionSchema)).optional(),
1640
- extend: ((z$1.boolean()).describe("extend global variable defined by name in IIFE / UMD formats")).optional(),
1641
- esModule: ((z$1.literal("if-default-prop")).or(z$1.boolean())).optional(),
1642
- entryFileNames: ((z$1.string()).or(chunkFileNamesFunctionSchema)).optional(),
1643
- chunkFileNames: ((z$1.string()).or(chunkFileNamesFunctionSchema)).optional(),
1644
- assetFileNames: (z$1.string()).optional(),
1645
- minify: ((z$1.boolean()).describe("minify the bundled file.")).optional(),
1646
- name: ((z$1.string()).describe("name for UMD / IIFE format outputs")).optional(),
1647
- globals: ((z$1.record(z$1.string())).describe("global variable of UMD / IIFE dependencies (syntax: `key=value`)")).optional(),
1648
- externalLiveBindings: (((z$1.boolean()).describe("external live bindings")).default(true)).optional(),
1649
- inlineDynamicImports: (((z$1.boolean()).describe("inline dynamic imports")).default(false)).optional(),
1650
- advancedChunks: (z$1.strictObject({
1651
- minSize: (z$1.number()).optional(),
1652
- minShareCount: (z$1.number()).optional(),
1653
- groups: (z$1.array(z$1.strictObject({
1654
- name: z$1.string(),
1655
- test: ((z$1.string()).or(z$1.instanceof(RegExp))).optional(),
1656
- priority: (z$1.number()).optional(),
1657
- minSize: (z$1.number()).optional(),
1658
- minShareCount: (z$1.number()).optional()
1659
- }))).optional()
1660
- })).optional()
1586
+ //#region src/options/output-options-schema.ts
1587
+ const ModuleFormatSchema = z.literal("es").or(z.literal("cjs")).or(z.literal("esm")).or(z.literal("module")).or(z.literal("commonjs")).or(z.literal("iife")).or(z.literal("umd")).describe(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`);
1588
+ const addonFunctionSchema = z.function().args(phantom()).returns(z.string().or(z.promise(z.string())));
1589
+ const chunkFileNamesFunctionSchema = z.function().args(phantom()).returns(z.string());
1590
+ const GlobalsFunctionSchema = z.function().args(z.string()).returns(z.string());
1591
+ const outputOptionsSchema = z.strictObject({
1592
+ dir: z.string().describe("Output directory, defaults to `dist` if `file` is not set").optional(),
1593
+ file: z.string().describe("Single output file").optional(),
1594
+ exports: z.literal("auto").or(z.literal("named")).or(z.literal("default")).or(z.literal("none")).describe(`Specify a export mode (${colors.underline("auto")}, named, default, none)`).optional(),
1595
+ hashCharacters: z.literal("base64").or(z.literal("base36")).or(z.literal("hex")).describe("Use the specified character set for file hashes").optional(),
1596
+ format: ModuleFormatSchema.optional(),
1597
+ sourcemap: z.boolean().or(z.literal("inline")).or(z.literal("hidden")).describe(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`).optional(),
1598
+ sourcemapIgnoreList: z.boolean().or(phantom()).optional(),
1599
+ sourcemapPathTransform: phantom().optional(),
1600
+ banner: z.string().or(addonFunctionSchema).optional(),
1601
+ footer: z.string().or(addonFunctionSchema).optional(),
1602
+ intro: z.string().or(addonFunctionSchema).optional(),
1603
+ outro: z.string().or(addonFunctionSchema).optional(),
1604
+ extend: z.boolean().describe("Extend global variable defined by name in IIFE / UMD formats").optional(),
1605
+ esModule: z.literal("if-default-prop").or(z.boolean()).optional(),
1606
+ assetFileNames: z.string().describe("Name pattern for asset files").optional(),
1607
+ entryFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted entry chunks").optional(),
1608
+ chunkFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted secondary chunks").optional(),
1609
+ cssEntryFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css entry chunks").optional(),
1610
+ cssChunkFileNames: z.string().or(chunkFileNamesFunctionSchema).describe("Name pattern for emitted css secondary chunks").optional(),
1611
+ minify: z.boolean().describe("Minify the bundled file.").optional(),
1612
+ name: z.string().describe("Name for UMD / IIFE format outputs").optional(),
1613
+ globals: z.record(z.string()).or(GlobalsFunctionSchema).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
1614
+ externalLiveBindings: z.boolean().describe("external live bindings").default(true).optional(),
1615
+ inlineDynamicImports: z.boolean().describe("Inline dynamic imports").default(false).optional(),
1616
+ advancedChunks: z.strictObject({
1617
+ minSize: z.number().optional(),
1618
+ minShareCount: z.number().optional(),
1619
+ groups: z.array(z.strictObject({
1620
+ name: z.string(),
1621
+ test: z.string().or(z.instanceof(RegExp)).optional(),
1622
+ priority: z.number().optional(),
1623
+ minSize: z.number().optional(),
1624
+ minShareCount: z.number().optional()
1625
+ })).optional()
1626
+ }).optional(),
1627
+ comments: z.enum(["none", "preserve-legal"]).describe("Control comments in the output").optional()
1661
1628
  });
1662
1629
  const getAddonDescription = (placement, wrapper) => {
1663
- return `code to insert the ${bold(placement)} of the bundled file (${bold(wrapper)} the wrapper function).`;
1630
+ return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
1664
1631
  };
1665
- const outputCliOptionsSchema = (outputOptionsSchema.extend({
1666
- banner: ((z$1.string()).describe(getAddonDescription("top", "outside"))).optional(),
1667
- footer: ((z$1.string()).describe(getAddonDescription("bottom", "outside"))).optional(),
1668
- intro: ((z$1.string()).describe(getAddonDescription("top", "inside"))).optional(),
1669
- outro: ((z$1.string()).describe(getAddonDescription("bottom", "inside"))).optional(),
1670
- esModule: ((z$1.boolean()).describe("always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable).")).optional(),
1671
- advancedChunks: (z$1.strictObject({
1672
- minSize: ((z$1.number()).describe("minimum size of the chunk")).optional(),
1673
- minShareCount: ((z$1.number()).describe("minimum share count of the chunk")).optional()
1674
- })).optional()
1675
- })).omit({
1632
+ const outputCliOptionsSchema = outputOptionsSchema.extend({
1633
+ banner: z.string().describe(getAddonDescription("top", "outside")).optional(),
1634
+ footer: z.string().describe(getAddonDescription("bottom", "outside")).optional(),
1635
+ intro: z.string().describe(getAddonDescription("top", "inside")).optional(),
1636
+ outro: z.string().describe(getAddonDescription("bottom", "inside")).optional(),
1637
+ esModule: z.boolean().describe("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)").optional(),
1638
+ globals: z.record(z.string()).describe("Global variable of UMD / IIFE dependencies (syntax: `key=value`)").optional(),
1639
+ advancedChunks: z.strictObject({
1640
+ minSize: z.number().describe("Minimum size of the chunk").optional(),
1641
+ minShareCount: z.number().describe("Minimum share count of the chunk").optional()
1642
+ }).optional()
1643
+ }).omit({
1676
1644
  sourcemapPathTransform: true,
1677
1645
  sourcemapIgnoreList: true
1678
1646
  });
1679
1647
 
1680
1648
  //#endregion
1681
1649
  //#region src/cli/arguments/schema.ts
1682
- const cliOptionsSchema = ((z.strictObject({
1683
- config: (((z.string()).or(z.boolean())).describe("Path to the config file (default: `rolldown.config.js`)")).optional(),
1684
- help: ((z.boolean()).describe("Show help")).optional(),
1685
- version: ((z.boolean()).describe("Show version number")).optional(),
1686
- watch: ((z.boolean()).describe("Watch files in bundle and rebuild on changes")).optional()
1687
- })).merge(inputCliOptionsSchema)).merge(outputCliOptionsSchema);
1650
+ const cliOptionsSchema = z.strictObject({
1651
+ config: z.string().or(z.boolean()).describe("Path to the config file (default: `rolldown.config.js`)").optional(),
1652
+ help: z.boolean().describe("Show help").optional(),
1653
+ version: z.boolean().describe("Show version number").optional(),
1654
+ watch: z.boolean().describe("Watch files in bundle and rebuild on changes").optional()
1655
+ }).merge(inputCliOptionsSchema).merge(outputCliOptionsSchema);
1688
1656
  const schema = zodToJsonSchema(cliOptionsSchema);
1689
1657
 
1690
1658
  //#endregion
@@ -1695,23 +1663,24 @@ const alias = {
1695
1663
  hint: "filename",
1696
1664
  default: "rolldown.config.js"
1697
1665
  },
1698
- help: {abbreviation: "h"},
1699
- version: {abbreviation: "v"},
1700
- watch: {abbreviation: "w"},
1701
- dir: {abbreviation: "d"},
1702
- external: {abbreviation: "e"},
1703
- format: {abbreviation: "f"},
1704
- name: {abbreviation: "n"},
1705
- globals: {abbreviation: "g"},
1666
+ help: { abbreviation: "h" },
1667
+ version: { abbreviation: "v" },
1668
+ watch: { abbreviation: "w" },
1669
+ dir: { abbreviation: "d" },
1670
+ file: { abbreviation: "o" },
1671
+ external: { abbreviation: "e" },
1672
+ format: { abbreviation: "f" },
1673
+ name: { abbreviation: "n" },
1674
+ globals: { abbreviation: "g" },
1706
1675
  sourcemap: {
1707
1676
  abbreviation: "s",
1708
1677
  default: true
1709
1678
  },
1710
- minify: {abbreviation: "m"},
1711
- platform: {abbreviation: "p"},
1712
- assetFileNames: {hint: "name"},
1713
- chunkFileNames: {hint: "name"},
1714
- entryFileNames: {hint: "name"},
1679
+ minify: { abbreviation: "m" },
1680
+ platform: { abbreviation: "p" },
1681
+ assetFileNames: { hint: "name" },
1682
+ chunkFileNames: { hint: "name" },
1683
+ entryFileNames: { hint: "name" },
1715
1684
  externalLiveBindings: {
1716
1685
  default: true,
1717
1686
  reverse: true
@@ -1720,13 +1689,13 @@ const alias = {
1720
1689
  default: true,
1721
1690
  reverse: true
1722
1691
  },
1723
- moduleTypes: {hint: "types"}
1692
+ moduleTypes: { hint: "types" }
1724
1693
  };
1725
1694
 
1726
1695
  //#endregion
1727
1696
  //#region src/cli/arguments/utils.ts
1728
1697
  function getSchemaType(schema$1) {
1729
- if ("anyOf"in schema$1) {
1698
+ if ("anyOf" in schema$1) {
1730
1699
  const types = schema$1.anyOf.map((s) => getSchemaType(s));
1731
1700
  if (types.includes("object")) return "object";
1732
1701
  else if (types.includes("array")) return "array";
@@ -1734,23 +1703,15 @@ else if (types.includes("string")) return "string";
1734
1703
  else if (types.includes("number")) return "number";
1735
1704
  else if (types.includes("boolean")) return "boolean";
1736
1705
  }
1737
- if ("type"in schema$1) {
1738
- return schema$1.type;
1739
- }
1706
+ if ("type" in schema$1) return schema$1.type;
1740
1707
  return "object";
1741
1708
  }
1742
1709
  function flattenSchema(schema$1, base = {}, parent = "") {
1743
1710
  for (const [k, value] of Object.entries(schema$1)) {
1744
1711
  const key = parent ? `${parent}.${k}` : k;
1745
- if (getSchemaType(value) === "object") {
1746
- if ("properties"in value) {
1747
- flattenSchema(value.properties, base, key);
1748
- } else {
1749
- base[key] = value;
1750
- }
1751
- } else {
1752
- base[key] = value;
1753
- }
1712
+ if (getSchemaType(value) === "object") if ("properties" in value) flattenSchema(value.properties, base, key);
1713
+ else base[key] = value;
1714
+ else base[key] = value;
1754
1715
  }
1755
1716
  return base;
1756
1717
  }
@@ -1758,14 +1719,12 @@ function setNestedProperty(obj, path$1, value) {
1758
1719
  const keys = path$1.split(".");
1759
1720
  let current = obj;
1760
1721
  for (let i = 0; i < keys.length - 1; i++) {
1761
- if (!current[keys[i]]) {
1762
- current[keys[i]] = {};
1763
- }
1722
+ if (!current[keys[i]]) current[keys[i]] = {};
1764
1723
  current = current[keys[i]];
1765
1724
  }
1766
1725
  const finalKey = keys[keys.length - 1];
1767
1726
  Object.defineProperty(current, finalKey, {
1768
- value: value,
1727
+ value,
1769
1728
  writable: true,
1770
1729
  enumerable: true,
1771
1730
  configurable: true
@@ -1796,62 +1755,54 @@ function normalizeCliOptions(cliOptions, positionals) {
1796
1755
  version: options$1.version ?? false,
1797
1756
  watch: options$1.watch ?? false
1798
1757
  };
1799
- if (typeof options$1.config === "string") {
1800
- result.config = options$1.config ? options$1.config : "rolldown.config.js";
1801
- }
1802
- const reservedKeys = ["help", "version", "config", "watch"];
1803
- const keysOfInput = (inputCliOptionsSchema.keyof())._def.values;
1804
- const keysOfOutput = (outputCliOptionsSchema.keyof())._def.values;
1758
+ if (typeof options$1.config === "string") result.config = options$1.config ? options$1.config : "rolldown.config.js";
1759
+ const reservedKeys = [
1760
+ "help",
1761
+ "version",
1762
+ "config",
1763
+ "watch"
1764
+ ];
1765
+ const keysOfInput = inputCliOptionsSchema.keyof()._def.values;
1766
+ const keysOfOutput = outputCliOptionsSchema.keyof()._def.values;
1805
1767
  for (let [key, value] of Object.entries(options$1)) {
1806
1768
  const keys = key.split(".");
1807
1769
  const [primary] = keys;
1808
- if (keysOfInput.includes(primary)) {
1809
- setNestedProperty(result.input, key, value);
1810
- } else if (keysOfOutput.includes(primary)) {
1811
- setNestedProperty(result.output, key, value);
1812
- } else if (!reservedKeys.includes(key)) {
1770
+ if (keysOfInput.includes(primary)) setNestedProperty(result.input, key, value);
1771
+ else if (keysOfOutput.includes(primary)) setNestedProperty(result.output, key, value);
1772
+ else if (!reservedKeys.includes(key)) {
1813
1773
  logger.error(`Unknown option: ${key}`);
1814
1774
  process.exit(1);
1815
1775
  }
1816
1776
  }
1817
- if (!result.config && positionals.length > 0) {
1818
- result.input.input = positionals;
1819
- }
1777
+ if (!result.config && positionals.length > 0) result.input.input = positionals;
1820
1778
  return result;
1821
1779
  }
1822
1780
 
1823
1781
  //#endregion
1824
1782
  //#region src/cli/arguments/index.ts
1825
1783
  const flattenedSchema = flattenSchema(schema.properties);
1826
- const options = Object.fromEntries((Object.entries(flattenedSchema)).map(([key, schema$1]) => {
1827
- const config = (Object.getOwnPropertyDescriptor(alias, key))?.value;
1784
+ const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, schema$1]) => {
1785
+ const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
1828
1786
  const type = getSchemaType(schema$1);
1829
1787
  const result = {
1830
1788
  type: type === "boolean" ? "boolean" : "string",
1831
1789
  description: schema$1?.description ?? config?.description ?? "",
1832
1790
  hint: config?.hint
1833
1791
  };
1834
- if (config && config?.abbreviation) {
1835
- result.short = config?.abbreviation;
1836
- }
1837
- if (config && config.reverse) {
1838
- if (result.description.startsWith("enable")) {
1839
- result.description = result.description.replace("enable", "disable");
1840
- } else {
1841
- result.description = `disable ${result.description}`;
1842
- }
1843
- }
1792
+ if (config && config?.abbreviation) result.short = config?.abbreviation;
1793
+ if (config && config.reverse) if (result.description.startsWith("enable")) result.description = result.description.replace("enable", "disable");
1794
+ else result.description = `disable ${result.description}`;
1844
1795
  key = camelCaseToKebabCase(key);
1845
1796
  return [config?.reverse ? `no-${key}` : key, result];
1846
1797
  }));
1847
1798
  function parseCliArguments() {
1848
- const { values: values, tokens: tokens, positionals: positionals } = parseArgs({
1799
+ const { values, tokens, positionals } = parseArgs({
1849
1800
  options,
1850
1801
  tokens: true,
1851
1802
  allowPositionals: true,
1852
1803
  strict: false
1853
1804
  });
1854
- (tokens.filter((token) => token.kind === "option")).forEach((option) => {
1805
+ tokens.filter((token) => token.kind === "option").forEach((option) => {
1855
1806
  let negative = false;
1856
1807
  if (option.name.startsWith("no-")) {
1857
1808
  const name = kebabCaseToCamelCase(option.name.substring(3));
@@ -1871,7 +1822,7 @@ function parseCliArguments() {
1871
1822
  let type = getSchemaType(originalType);
1872
1823
  if (type === "string" && typeof option.value !== "string") {
1873
1824
  let opt = option;
1874
- let defaultValue = (Object.getOwnPropertyDescriptor(alias, opt.name))?.value;
1825
+ let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)?.value;
1875
1826
  Object.defineProperty(values, opt.name, {
1876
1827
  value: defaultValue.default ?? "",
1877
1828
  enumerable: true,
@@ -1879,117 +1830,106 @@ function parseCliArguments() {
1879
1830
  writable: true
1880
1831
  });
1881
1832
  } else if (type === "object" && typeof option.value === "string") {
1882
- const [key, value] = ((option.value.split(",")).map((x) => x.split("=")))[0];
1883
- if (!values[option.name]) {
1884
- Object.defineProperty(values, option.name, {
1885
- value: {},
1886
- enumerable: true,
1887
- configurable: true,
1888
- writable: true
1889
- });
1890
- }
1891
- if (key && value) {
1892
- Object.defineProperty(values[option.name], key, {
1893
- value,
1894
- enumerable: true,
1895
- configurable: true,
1896
- writable: true
1897
- });
1898
- }
1899
- } else if (type === "array" && typeof option.value === "string") {
1900
- if (!values[option.name]) {
1901
- Object.defineProperty(values, option.name, {
1902
- value: [],
1903
- enumerable: true,
1904
- configurable: true,
1905
- writable: true
1906
- });
1907
- }
1908
- ;
1909
- values[option.name].push(option.value);
1910
- } else if (type === "boolean") {
1911
- Object.defineProperty(values, option.name, {
1912
- value: !negative,
1833
+ const [key, value] = option.value.split(",").map((x) => x.split("="))[0];
1834
+ if (!values[option.name]) Object.defineProperty(values, option.name, {
1835
+ value: {},
1913
1836
  enumerable: true,
1914
1837
  configurable: true,
1915
1838
  writable: true
1916
1839
  });
1917
- } else {
1918
- Object.defineProperty(values, option.name, {
1919
- value: option.value ?? "",
1840
+ if (key && value) Object.defineProperty(values[option.name], key, {
1841
+ value,
1920
1842
  enumerable: true,
1921
1843
  configurable: true,
1922
1844
  writable: true
1923
1845
  });
1924
- }
1846
+ } else if (type === "array" && typeof option.value === "string") {
1847
+ if (!values[option.name]) Object.defineProperty(values, option.name, {
1848
+ value: [],
1849
+ enumerable: true,
1850
+ configurable: true,
1851
+ writable: true
1852
+ });
1853
+ values[option.name].push(option.value);
1854
+ } else if (type === "boolean") Object.defineProperty(values, option.name, {
1855
+ value: !negative,
1856
+ enumerable: true,
1857
+ configurable: true,
1858
+ writable: true
1859
+ });
1860
+ else Object.defineProperty(values, option.name, {
1861
+ value: option.value ?? "",
1862
+ enumerable: true,
1863
+ configurable: true,
1864
+ writable: true
1865
+ });
1925
1866
  });
1926
1867
  return normalizeCliOptions(values, positionals);
1927
1868
  }
1928
1869
 
1929
1870
  //#endregion
1930
1871
  //#region src/cli/commands/help.ts
1931
- const introduction = `${gray(`${description} (rolldown v${version})`)}
1872
+ const introduction = `${colors.gray(`${description} (rolldown v${version})`)}
1932
1873
 
1933
- ${bold(underline("USAGE"))} ${cyan("rolldown -c <config>")} or ${cyan("rolldown <input> <options>")}`;
1934
- const examples = [{
1935
- title: "Bundle with a config file `rolldown.config.mjs`",
1936
- command: "rolldown -c rolldown.config.mjs"
1937
- }, {
1938
- title: "Bundle the `src/main.ts` to `dist` with `cjs` format",
1939
- command: "rolldown src/main.ts -d dist -f cjs"
1940
- }, {
1941
- title: "Bundle the `src/main.ts` and handle the `.png` assets to Data URL",
1942
- command: "rolldown src/main.ts -d dist --moduleTypes .png=dataurl"
1943
- }, {
1944
- title: "Bundle the `src/main.tsx` and minify the output with sourcemap",
1945
- command: "rolldown src/main.tsx -d dist -m -s"
1946
- }, {
1947
- title: "Create self-executing IIFE using external jQuery as `$` and `_`",
1948
- command: "rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$"
1949
- },];
1950
- const notes = ["Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.", "If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.", "CLI options will override the configuration file.", "For more information, please visit https://rolldown.rs/.",];
1874
+ ${colors.bold(colors.underline("USAGE"))} ${colors.cyan("rolldown -c <config>")} or ${colors.cyan("rolldown <input> <options>")}`;
1875
+ const examples = [
1876
+ {
1877
+ title: "Bundle with a config file `rolldown.config.mjs`",
1878
+ command: "rolldown -c rolldown.config.mjs"
1879
+ },
1880
+ {
1881
+ title: "Bundle the `src/main.ts` to `dist` with `cjs` format",
1882
+ command: "rolldown src/main.ts -d dist -f cjs"
1883
+ },
1884
+ {
1885
+ title: "Bundle the `src/main.ts` and handle the `.png` assets to Data URL",
1886
+ command: "rolldown src/main.ts -d dist --moduleTypes .png=dataurl"
1887
+ },
1888
+ {
1889
+ title: "Bundle the `src/main.tsx` and minify the output with sourcemap",
1890
+ command: "rolldown src/main.tsx -d dist -m -s"
1891
+ },
1892
+ {
1893
+ title: "Create self-executing IIFE using external jQuery as `$` and `_`",
1894
+ command: "rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$"
1895
+ }
1896
+ ];
1897
+ const notes = [
1898
+ "Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.",
1899
+ "If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.",
1900
+ "CLI options will override the configuration file.",
1901
+ "For more information, please visit https://rolldown.rs/."
1902
+ ];
1951
1903
  function showHelp() {
1952
1904
  logger.log(introduction);
1953
1905
  logger.log("");
1954
- logger.log(`${bold(underline("OPTIONS"))}`);
1906
+ logger.log(`${colors.bold(colors.underline("OPTIONS"))}`);
1955
1907
  logger.log("");
1956
- logger.log((((Object.entries(options)).sort(([a], [b]) => {
1957
- if (options[a].short && !options[b].short) {
1958
- return -1;
1959
- }
1960
- if (!options[a].short && options[b].short) {
1961
- return 1;
1962
- }
1963
- if (options[a].short && options[b].short) {
1964
- return options[a].short.localeCompare(options[b].short);
1965
- }
1908
+ logger.log(Object.entries(options).sort(([a], [b]) => {
1909
+ if (options[a].short && !options[b].short) return -1;
1910
+ if (!options[a].short && options[b].short) return 1;
1911
+ if (options[a].short && options[b].short) return options[a].short.localeCompare(options[b].short);
1966
1912
  return a.localeCompare(b);
1967
- })).map(([option, { type: type, short: short, hint: hint, description: description$1 }]) => {
1913
+ }).map(([option, { type, short, hint, description: description$1 }]) => {
1968
1914
  let optionStr = ` --${option} `;
1969
1915
  option = camelCaseToKebabCase(option);
1970
- if (short) {
1971
- optionStr += `-${short}, `;
1972
- }
1973
- if (type === "string") {
1974
- optionStr += `<${hint ?? option}>`;
1975
- }
1976
- if (description$1 && description$1.length > 0) {
1977
- description$1 = description$1[0].toUpperCase() + description$1.slice(1);
1978
- }
1979
- return cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1980
- })).join("\n"));
1916
+ if (short) optionStr += `-${short}, `;
1917
+ if (type === "string") optionStr += `<${hint ?? option}>`;
1918
+ if (description$1 && description$1.length > 0) description$1 = description$1[0].toUpperCase() + description$1.slice(1);
1919
+ return colors.cyan(optionStr.padEnd(30)) + description$1 + (description$1 && description$1?.endsWith(".") ? "" : ".");
1920
+ }).join("\n"));
1981
1921
  logger.log("");
1982
- logger.log(`${bold(underline("EXAMPLES"))}`);
1922
+ logger.log(`${colors.bold(colors.underline("EXAMPLES"))}`);
1983
1923
  logger.log("");
1984
- examples.forEach(({ title: title, command: command }, ord) => {
1924
+ examples.forEach(({ title, command }, ord) => {
1985
1925
  logger.log(` ${ord + 1}. ${title}:`);
1986
- logger.log(` ${cyan(command)}`);
1926
+ logger.log(` ${colors.cyan(command)}`);
1987
1927
  logger.log("");
1988
1928
  });
1989
- logger.log(`${bold(underline("NOTES"))}`);
1929
+ logger.log(`${colors.bold(colors.underline("NOTES"))}`);
1990
1930
  logger.log("");
1991
1931
  notes.forEach((note) => {
1992
- logger.log(` * ${gray(note)}`);
1932
+ logger.log(` * ${colors.gray(note)}`);
1993
1933
  });
1994
1934
  }
1995
1935
 
@@ -2001,7 +1941,7 @@ async function main() {
2001
1941
  await bundleWithConfig(cliOptions.config, cliOptions);
2002
1942
  return;
2003
1943
  }
2004
- if ("input"in cliOptions.input) {
1944
+ if ("input" in cliOptions.input) {
2005
1945
  await bundleWithCliOptions(cliOptions);
2006
1946
  return;
2007
1947
  }
@@ -2011,9 +1951,9 @@ async function main() {
2011
1951
  }
2012
1952
  showHelp();
2013
1953
  }
2014
- (main()).catch((err) => {
2015
- logger.error(err);
1954
+ main().catch((err) => {
1955
+ console.error(err);
2016
1956
  process$1.exit(1);
2017
1957
  });
2018
1958
 
2019
- //#endregion
1959
+ //#endregion