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