rolldown 0.14.0-snapshot-f1bd92f-20241126015006 → 0.14.0-snapshot-3009016-20241127042951

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