dsh-remote-control 1.0.0 → 1.1.0
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/cordis.patch.yml +6 -0
- package/dist/bundle/client.cjs +146 -0
- package/dist/bundle/index.js +667 -264
- package/package.json +13 -6
- package/dist/src/core/clock.d.ts +0 -45
- package/dist/src/core/clock.js +0 -83
- package/dist/src/core/clock.js.map +0 -1
- package/dist/src/core/keys.d.ts +0 -98
- package/dist/src/core/keys.js +0 -176
- package/dist/src/core/keys.js.map +0 -1
- package/dist/src/core/pairing-window.d.ts +0 -95
- package/dist/src/core/pairing-window.js +0 -92
- package/dist/src/core/pairing-window.js.map +0 -1
- package/dist/src/core/runtime.d.ts +0 -104
- package/dist/src/core/runtime.js +0 -491
- package/dist/src/core/runtime.js.map +0 -1
- package/dist/src/core/sleep-policy.d.ts +0 -81
- package/dist/src/core/sleep-policy.js +0 -134
- package/dist/src/core/sleep-policy.js.map +0 -1
- package/dist/src/core/window.d.ts +0 -88
- package/dist/src/core/window.js +0 -185
- package/dist/src/core/window.js.map +0 -1
- package/dist/src/index.d.ts +0 -70
- package/dist/src/index.js +0 -882
- package/dist/src/index.js.map +0 -1
- package/dist/src/platform/carrier-services.d.ts +0 -96
- package/dist/src/platform/carrier-services.js +0 -982
- package/dist/src/platform/carrier-services.js.map +0 -1
- package/dist/src/platform/guard.d.ts +0 -60
- package/dist/src/platform/guard.js +0 -124
- package/dist/src/platform/guard.js.map +0 -1
- package/dist/src/platform/mock-kernel.d.ts +0 -95
- package/dist/src/platform/mock-kernel.js +0 -180
- package/dist/src/platform/mock-kernel.js.map +0 -1
- package/dist/src/platform/qr.d.ts +0 -28
- package/dist/src/platform/qr.js +0 -80
- package/dist/src/platform/qr.js.map +0 -1
- package/dist/src/platform/sleep-posix.d.ts +0 -17
- package/dist/src/platform/sleep-posix.js +0 -91
- package/dist/src/platform/sleep-posix.js.map +0 -1
- package/dist/src/ports/index.d.ts +0 -246
- package/dist/src/ports/index.js +0 -2
- package/dist/src/ports/index.js.map +0 -1
- package/dist/src/shell/config.d.ts +0 -56
- package/dist/src/shell/config.js +0 -212
- package/dist/src/shell/config.js.map +0 -1
- package/dist/src/shell/pairing-text.d.ts +0 -38
- package/dist/src/shell/pairing-text.js +0 -22
- package/dist/src/shell/pairing-text.js.map +0 -1
- package/dist/src/shell/status.d.ts +0 -39
- package/dist/src/shell/status.js +0 -119
- package/dist/src/shell/status.js.map +0 -1
- package/dist/src/transport/relay.d.ts +0 -107
- package/dist/src/transport/relay.js +0 -359
- package/dist/src/transport/relay.js.map +0 -1
- package/dist/tests/carrier-events.test.d.ts +0 -1
- package/dist/tests/carrier-events.test.js +0 -88
- package/dist/tests/carrier-events.test.js.map +0 -1
- package/dist/tests/carrier-services.test.d.ts +0 -1
- package/dist/tests/carrier-services.test.js +0 -562
- package/dist/tests/carrier-services.test.js.map +0 -1
- package/dist/tests/carrier-vocabulary.test.d.ts +0 -1
- package/dist/tests/carrier-vocabulary.test.js +0 -149
- package/dist/tests/carrier-vocabulary.test.js.map +0 -1
- package/dist/tests/clock-probe-timers.test.d.ts +0 -1
- package/dist/tests/clock-probe-timers.test.js +0 -73
- package/dist/tests/clock-probe-timers.test.js.map +0 -1
- package/dist/tests/command-result.test.d.ts +0 -1
- package/dist/tests/command-result.test.js +0 -185
- package/dist/tests/command-result.test.js.map +0 -1
- package/dist/tests/config.test.d.ts +0 -1
- package/dist/tests/config.test.js +0 -223
- package/dist/tests/config.test.js.map +0 -1
- package/dist/tests/guard.test.d.ts +0 -1
- package/dist/tests/guard.test.js +0 -175
- package/dist/tests/guard.test.js.map +0 -1
- package/dist/tests/ids-and-keys.test.d.ts +0 -1
- package/dist/tests/ids-and-keys.test.js +0 -211
- package/dist/tests/ids-and-keys.test.js.map +0 -1
- package/dist/tests/pairing-text.test.d.ts +0 -1
- package/dist/tests/pairing-text.test.js +0 -62
- package/dist/tests/pairing-text.test.js.map +0 -1
- package/dist/tests/pairing-window.test.d.ts +0 -1
- package/dist/tests/pairing-window.test.js +0 -165
- package/dist/tests/pairing-window.test.js.map +0 -1
- package/dist/tests/relay-client.test.d.ts +0 -1
- package/dist/tests/relay-client.test.js +0 -557
- package/dist/tests/relay-client.test.js.map +0 -1
- package/dist/tests/runtime.test.d.ts +0 -1
- package/dist/tests/runtime.test.js +0 -963
- package/dist/tests/runtime.test.js.map +0 -1
- package/dist/tests/sleep.test.d.ts +0 -1
- package/dist/tests/sleep.test.js +0 -264
- package/dist/tests/sleep.test.js.map +0 -1
- package/dist/tests/status.test.d.ts +0 -1
- package/dist/tests/status.test.js +0 -238
- package/dist/tests/status.test.js.map +0 -1
- package/dist/tests/window.test.d.ts +0 -1
- package/dist/tests/window.test.js +0 -210
- package/dist/tests/window.test.js.map +0 -1
package/dist/bundle/index.js
CHANGED
|
@@ -4501,7 +4501,7 @@ var require_websocket = __commonJS({
|
|
|
4501
4501
|
var http = __require("http");
|
|
4502
4502
|
var net = __require("net");
|
|
4503
4503
|
var tls = __require("tls");
|
|
4504
|
-
var { randomBytes: randomBytes5, createHash:
|
|
4504
|
+
var { randomBytes: randomBytes5, createHash: createHash3 } = __require("crypto");
|
|
4505
4505
|
var { Duplex, Readable } = __require("stream");
|
|
4506
4506
|
var { URL: URL2 } = __require("url");
|
|
4507
4507
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -5182,7 +5182,7 @@ var require_websocket = __commonJS({
|
|
|
5182
5182
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
5183
5183
|
return;
|
|
5184
5184
|
}
|
|
5185
|
-
const digest =
|
|
5185
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
5186
5186
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
5187
5187
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
5188
5188
|
return;
|
|
@@ -5551,7 +5551,7 @@ var require_websocket_server = __commonJS({
|
|
|
5551
5551
|
var EventEmitter = __require("events");
|
|
5552
5552
|
var http = __require("http");
|
|
5553
5553
|
var { Duplex } = __require("stream");
|
|
5554
|
-
var { createHash:
|
|
5554
|
+
var { createHash: createHash3 } = __require("crypto");
|
|
5555
5555
|
var extension2 = require_extension();
|
|
5556
5556
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
5557
5557
|
var subprotocol2 = require_subprotocol();
|
|
@@ -5858,7 +5858,7 @@ var require_websocket_server = __commonJS({
|
|
|
5858
5858
|
);
|
|
5859
5859
|
}
|
|
5860
5860
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
5861
|
-
const digest =
|
|
5861
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
5862
5862
|
const headers = [
|
|
5863
5863
|
"HTTP/1.1 101 Switching Protocols",
|
|
5864
5864
|
"Upgrade: websocket",
|
|
@@ -7486,10 +7486,10 @@ var require_segments = __commonJS({
|
|
|
7486
7486
|
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
7487
7487
|
const nodes = buildNodes(segs);
|
|
7488
7488
|
const graph = buildGraph(nodes, version2);
|
|
7489
|
-
const
|
|
7489
|
+
const path5 = dijkstra.find_path(graph.map, "start", "end");
|
|
7490
7490
|
const optimizedSegs = [];
|
|
7491
|
-
for (let i = 1; i <
|
|
7492
|
-
optimizedSegs.push(graph.table[
|
|
7491
|
+
for (let i = 1; i < path5.length - 1; i++) {
|
|
7492
|
+
optimizedSegs.push(graph.table[path5[i]].node);
|
|
7493
7493
|
}
|
|
7494
7494
|
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
7495
7495
|
};
|
|
@@ -9966,7 +9966,7 @@ var require_png2 = __commonJS({
|
|
|
9966
9966
|
});
|
|
9967
9967
|
png.pack();
|
|
9968
9968
|
};
|
|
9969
|
-
exports.renderToFile = function renderToFile(
|
|
9969
|
+
exports.renderToFile = function renderToFile(path5, qrData, options, cb) {
|
|
9970
9970
|
if (typeof cb === "undefined") {
|
|
9971
9971
|
cb = options;
|
|
9972
9972
|
options = void 0;
|
|
@@ -9977,7 +9977,7 @@ var require_png2 = __commonJS({
|
|
|
9977
9977
|
called = true;
|
|
9978
9978
|
cb.apply(null, args);
|
|
9979
9979
|
};
|
|
9980
|
-
const stream = fs.createWriteStream(
|
|
9980
|
+
const stream = fs.createWriteStream(path5);
|
|
9981
9981
|
stream.on("error", done);
|
|
9982
9982
|
stream.on("close", done);
|
|
9983
9983
|
exports.renderToFileStream(stream, qrData, options);
|
|
@@ -10039,14 +10039,14 @@ var require_utf8 = __commonJS({
|
|
|
10039
10039
|
}
|
|
10040
10040
|
return output2;
|
|
10041
10041
|
};
|
|
10042
|
-
exports.renderToFile = function renderToFile(
|
|
10042
|
+
exports.renderToFile = function renderToFile(path5, qrData, options, cb) {
|
|
10043
10043
|
if (typeof cb === "undefined") {
|
|
10044
10044
|
cb = options;
|
|
10045
10045
|
options = void 0;
|
|
10046
10046
|
}
|
|
10047
10047
|
const fs = __require("fs");
|
|
10048
10048
|
const utf82 = exports.render(qrData, options);
|
|
10049
|
-
fs.writeFile(
|
|
10049
|
+
fs.writeFile(path5, utf82, cb);
|
|
10050
10050
|
};
|
|
10051
10051
|
}
|
|
10052
10052
|
});
|
|
@@ -10167,7 +10167,7 @@ var require_svg_tag = __commonJS({
|
|
|
10167
10167
|
return str;
|
|
10168
10168
|
}
|
|
10169
10169
|
function qrToPath(data, size, margin) {
|
|
10170
|
-
let
|
|
10170
|
+
let path5 = "";
|
|
10171
10171
|
let moveBy = 0;
|
|
10172
10172
|
let newRow = false;
|
|
10173
10173
|
let lineLength = 0;
|
|
@@ -10178,19 +10178,19 @@ var require_svg_tag = __commonJS({
|
|
|
10178
10178
|
if (data[i]) {
|
|
10179
10179
|
lineLength++;
|
|
10180
10180
|
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
10181
|
-
|
|
10181
|
+
path5 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
10182
10182
|
moveBy = 0;
|
|
10183
10183
|
newRow = false;
|
|
10184
10184
|
}
|
|
10185
10185
|
if (!(col + 1 < size && data[i + 1])) {
|
|
10186
|
-
|
|
10186
|
+
path5 += svgCmd("h", lineLength);
|
|
10187
10187
|
lineLength = 0;
|
|
10188
10188
|
}
|
|
10189
10189
|
} else {
|
|
10190
10190
|
moveBy++;
|
|
10191
10191
|
}
|
|
10192
10192
|
}
|
|
10193
|
-
return
|
|
10193
|
+
return path5;
|
|
10194
10194
|
}
|
|
10195
10195
|
exports.render = function render(qrData, options, cb) {
|
|
10196
10196
|
const opts = Utils.getOptions(options);
|
|
@@ -10198,10 +10198,10 @@ var require_svg_tag = __commonJS({
|
|
|
10198
10198
|
const data = qrData.modules.data;
|
|
10199
10199
|
const qrcodesize = size + opts.margin * 2;
|
|
10200
10200
|
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
|
|
10201
|
-
const
|
|
10201
|
+
const path5 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
10202
10202
|
const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
|
|
10203
10203
|
const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
10204
|
-
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg +
|
|
10204
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path5 + "</svg>\n";
|
|
10205
10205
|
if (typeof cb === "function") {
|
|
10206
10206
|
cb(null, svgTag);
|
|
10207
10207
|
}
|
|
@@ -10215,7 +10215,7 @@ var require_svg = __commonJS({
|
|
|
10215
10215
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports) {
|
|
10216
10216
|
var svgTagRenderer = require_svg_tag();
|
|
10217
10217
|
exports.render = svgTagRenderer.render;
|
|
10218
|
-
exports.renderToFile = function renderToFile(
|
|
10218
|
+
exports.renderToFile = function renderToFile(path5, qrData, options, cb) {
|
|
10219
10219
|
if (typeof cb === "undefined") {
|
|
10220
10220
|
cb = options;
|
|
10221
10221
|
options = void 0;
|
|
@@ -10223,7 +10223,7 @@ var require_svg = __commonJS({
|
|
|
10223
10223
|
const fs = __require("fs");
|
|
10224
10224
|
const svgTag = exports.render(qrData, options);
|
|
10225
10225
|
const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag;
|
|
10226
|
-
fs.writeFile(
|
|
10226
|
+
fs.writeFile(path5, xmlStr, cb);
|
|
10227
10227
|
};
|
|
10228
10228
|
}
|
|
10229
10229
|
});
|
|
@@ -10285,7 +10285,7 @@ var require_canvas = __commonJS({
|
|
|
10285
10285
|
var require_browser = __commonJS({
|
|
10286
10286
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(exports) {
|
|
10287
10287
|
var canPromise = require_can_promise();
|
|
10288
|
-
var
|
|
10288
|
+
var QRCode3 = require_qrcode();
|
|
10289
10289
|
var CanvasRenderer = require_canvas();
|
|
10290
10290
|
var SvgRenderer = require_svg_tag();
|
|
10291
10291
|
function renderCanvas(renderFunc, canvas, text, opts, cb) {
|
|
@@ -10328,7 +10328,7 @@ var require_browser = __commonJS({
|
|
|
10328
10328
|
}
|
|
10329
10329
|
return new Promise(function(resolve, reject) {
|
|
10330
10330
|
try {
|
|
10331
|
-
const data =
|
|
10331
|
+
const data = QRCode3.create(text, opts);
|
|
10332
10332
|
resolve(renderFunc(data, canvas, opts));
|
|
10333
10333
|
} catch (e) {
|
|
10334
10334
|
reject(e);
|
|
@@ -10336,13 +10336,13 @@ var require_browser = __commonJS({
|
|
|
10336
10336
|
});
|
|
10337
10337
|
}
|
|
10338
10338
|
try {
|
|
10339
|
-
const data =
|
|
10339
|
+
const data = QRCode3.create(text, opts);
|
|
10340
10340
|
cb(null, renderFunc(data, canvas, opts));
|
|
10341
10341
|
} catch (e) {
|
|
10342
10342
|
cb(e);
|
|
10343
10343
|
}
|
|
10344
10344
|
}
|
|
10345
|
-
exports.create =
|
|
10345
|
+
exports.create = QRCode3.create;
|
|
10346
10346
|
exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
|
|
10347
10347
|
exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
|
|
10348
10348
|
exports.toString = renderCanvas.bind(null, function(data, _, opts) {
|
|
@@ -10355,7 +10355,7 @@ var require_browser = __commonJS({
|
|
|
10355
10355
|
var require_server = __commonJS({
|
|
10356
10356
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js"(exports) {
|
|
10357
10357
|
var canPromise = require_can_promise();
|
|
10358
|
-
var
|
|
10358
|
+
var QRCode3 = require_qrcode();
|
|
10359
10359
|
var PngRenderer = require_png2();
|
|
10360
10360
|
var Utf8Renderer = require_utf8();
|
|
10361
10361
|
var TerminalRenderer = require_terminal2();
|
|
@@ -10381,8 +10381,8 @@ var require_server = __commonJS({
|
|
|
10381
10381
|
cb
|
|
10382
10382
|
};
|
|
10383
10383
|
}
|
|
10384
|
-
function getTypeFromFilename(
|
|
10385
|
-
return
|
|
10384
|
+
function getTypeFromFilename(path5) {
|
|
10385
|
+
return path5.slice((path5.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
|
|
10386
10386
|
}
|
|
10387
10387
|
function getRendererFromType(type) {
|
|
10388
10388
|
switch (type) {
|
|
@@ -10412,7 +10412,7 @@ var require_server = __commonJS({
|
|
|
10412
10412
|
if (!params.cb) {
|
|
10413
10413
|
return new Promise(function(resolve, reject) {
|
|
10414
10414
|
try {
|
|
10415
|
-
const data =
|
|
10415
|
+
const data = QRCode3.create(text, params.opts);
|
|
10416
10416
|
return renderFunc(data, params.opts, function(err, data2) {
|
|
10417
10417
|
return err ? reject(err) : resolve(data2);
|
|
10418
10418
|
});
|
|
@@ -10422,13 +10422,13 @@ var require_server = __commonJS({
|
|
|
10422
10422
|
});
|
|
10423
10423
|
}
|
|
10424
10424
|
try {
|
|
10425
|
-
const data =
|
|
10425
|
+
const data = QRCode3.create(text, params.opts);
|
|
10426
10426
|
return renderFunc(data, params.opts, params.cb);
|
|
10427
10427
|
} catch (e) {
|
|
10428
10428
|
params.cb(e);
|
|
10429
10429
|
}
|
|
10430
10430
|
}
|
|
10431
|
-
exports.create =
|
|
10431
|
+
exports.create = QRCode3.create;
|
|
10432
10432
|
exports.toCanvas = require_browser().toCanvas;
|
|
10433
10433
|
exports.toString = function toString(text, opts, cb) {
|
|
10434
10434
|
const params = checkParams(text, opts, cb);
|
|
@@ -10446,17 +10446,17 @@ var require_server = __commonJS({
|
|
|
10446
10446
|
const renderer = getRendererFromType(params.opts.type);
|
|
10447
10447
|
return render(renderer.renderToBuffer, text, params);
|
|
10448
10448
|
};
|
|
10449
|
-
exports.toFile = function toFile(
|
|
10450
|
-
if (typeof
|
|
10449
|
+
exports.toFile = function toFile(path5, text, opts, cb) {
|
|
10450
|
+
if (typeof path5 !== "string" || !(typeof text === "string" || typeof text === "object")) {
|
|
10451
10451
|
throw new Error("Invalid argument");
|
|
10452
10452
|
}
|
|
10453
10453
|
if (arguments.length < 3 && !canPromise()) {
|
|
10454
10454
|
throw new Error("Too few arguments provided");
|
|
10455
10455
|
}
|
|
10456
10456
|
const params = checkParams(text, opts, cb);
|
|
10457
|
-
const type = params.opts.type || getTypeFromFilename(
|
|
10457
|
+
const type = params.opts.type || getTypeFromFilename(path5);
|
|
10458
10458
|
const renderer = getRendererFromType(type);
|
|
10459
|
-
const renderToFile = renderer.renderToFile.bind(null,
|
|
10459
|
+
const renderToFile = renderer.renderToFile.bind(null, path5);
|
|
10460
10460
|
return render(renderToFile, text, params);
|
|
10461
10461
|
};
|
|
10462
10462
|
exports.toFileStream = function toFileStream(stream, text, opts) {
|
|
@@ -11594,10 +11594,10 @@ function mergeDefs(...defs) {
|
|
|
11594
11594
|
function cloneDef(schema) {
|
|
11595
11595
|
return mergeDefs(schema._zod.def);
|
|
11596
11596
|
}
|
|
11597
|
-
function getElementAtPath(obj,
|
|
11598
|
-
if (!
|
|
11597
|
+
function getElementAtPath(obj, path5) {
|
|
11598
|
+
if (!path5)
|
|
11599
11599
|
return obj;
|
|
11600
|
-
return
|
|
11600
|
+
return path5.reduce((acc, key) => acc?.[key], obj);
|
|
11601
11601
|
}
|
|
11602
11602
|
function promiseAllObject(promisesObj) {
|
|
11603
11603
|
const keys = Object.keys(promisesObj);
|
|
@@ -11937,11 +11937,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
11937
11937
|
}
|
|
11938
11938
|
return false;
|
|
11939
11939
|
}
|
|
11940
|
-
function prefixIssues(
|
|
11940
|
+
function prefixIssues(path5, issues) {
|
|
11941
11941
|
return issues.map((iss) => {
|
|
11942
11942
|
var _a3;
|
|
11943
11943
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
11944
|
-
iss.path.unshift(
|
|
11944
|
+
iss.path.unshift(path5);
|
|
11945
11945
|
return iss;
|
|
11946
11946
|
});
|
|
11947
11947
|
}
|
|
@@ -12391,16 +12391,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
12391
12391
|
}
|
|
12392
12392
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
12393
12393
|
const fieldErrors = { _errors: [] };
|
|
12394
|
-
const processError = (error63,
|
|
12394
|
+
const processError = (error63, path5 = []) => {
|
|
12395
12395
|
for (const issue2 of error63.issues) {
|
|
12396
12396
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
12397
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
12397
|
+
issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
|
|
12398
12398
|
} else if (issue2.code === "invalid_key") {
|
|
12399
|
-
processError({ issues: issue2.issues }, [...
|
|
12399
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
12400
12400
|
} else if (issue2.code === "invalid_element") {
|
|
12401
|
-
processError({ issues: issue2.issues }, [...
|
|
12401
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
12402
12402
|
} else {
|
|
12403
|
-
const fullpath = [...
|
|
12403
|
+
const fullpath = [...path5, ...issue2.path];
|
|
12404
12404
|
if (fullpath.length === 0) {
|
|
12405
12405
|
fieldErrors._errors.push(mapper(issue2));
|
|
12406
12406
|
} else {
|
|
@@ -12439,17 +12439,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
12439
12439
|
}
|
|
12440
12440
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
12441
12441
|
const result2 = { errors: [] };
|
|
12442
|
-
const processError = (error63,
|
|
12442
|
+
const processError = (error63, path5 = []) => {
|
|
12443
12443
|
var _a3;
|
|
12444
12444
|
for (const issue2 of error63.issues) {
|
|
12445
12445
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
12446
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
12446
|
+
issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
|
|
12447
12447
|
} else if (issue2.code === "invalid_key") {
|
|
12448
|
-
processError({ issues: issue2.issues }, [...
|
|
12448
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
12449
12449
|
} else if (issue2.code === "invalid_element") {
|
|
12450
|
-
processError({ issues: issue2.issues }, [...
|
|
12450
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
12451
12451
|
} else {
|
|
12452
|
-
const fullpath = [...
|
|
12452
|
+
const fullpath = [...path5, ...issue2.path];
|
|
12453
12453
|
if (fullpath.length === 0) {
|
|
12454
12454
|
result2.errors.push(mapper(issue2));
|
|
12455
12455
|
continue;
|
|
@@ -12488,8 +12488,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
12488
12488
|
}
|
|
12489
12489
|
function toDotPath(_path) {
|
|
12490
12490
|
const segs = [];
|
|
12491
|
-
const
|
|
12492
|
-
for (const seg of
|
|
12491
|
+
const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
12492
|
+
for (const seg of path5) {
|
|
12493
12493
|
if (typeof seg === "number")
|
|
12494
12494
|
segs.push(`[${seg}]`);
|
|
12495
12495
|
else if (typeof seg === "symbol")
|
|
@@ -26376,13 +26376,13 @@ function initializeContext(params) {
|
|
|
26376
26376
|
external: params?.external ?? void 0
|
|
26377
26377
|
};
|
|
26378
26378
|
}
|
|
26379
|
-
function handleUnrepresentable(schema, ctx,
|
|
26379
|
+
function handleUnrepresentable(schema, ctx, json3, params, message) {
|
|
26380
26380
|
const result2 = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
26381
26381
|
if (result2 === "any")
|
|
26382
26382
|
return false;
|
|
26383
26383
|
if (result2 === void 0 || result2 === "throw")
|
|
26384
26384
|
throw new Error(message);
|
|
26385
|
-
Object.assign(
|
|
26385
|
+
Object.assign(json3, result2);
|
|
26386
26386
|
return true;
|
|
26387
26387
|
}
|
|
26388
26388
|
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
@@ -26618,12 +26618,12 @@ function foldObjects(members2) {
|
|
|
26618
26618
|
}
|
|
26619
26619
|
return folded;
|
|
26620
26620
|
}
|
|
26621
|
-
function foldIntersection(
|
|
26622
|
-
const allOf =
|
|
26621
|
+
function foldIntersection(json3) {
|
|
26622
|
+
const allOf = json3.allOf;
|
|
26623
26623
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
26624
26624
|
return;
|
|
26625
26625
|
for (const key of FOLDABLE_KEYS)
|
|
26626
|
-
if (key in
|
|
26626
|
+
if (key in json3)
|
|
26627
26627
|
return;
|
|
26628
26628
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
26629
26629
|
let folded = null;
|
|
@@ -26642,8 +26642,8 @@ function foldIntersection(json2) {
|
|
|
26642
26642
|
}
|
|
26643
26643
|
if (!folded)
|
|
26644
26644
|
return;
|
|
26645
|
-
delete
|
|
26646
|
-
assignProps(
|
|
26645
|
+
delete json3.allOf;
|
|
26646
|
+
assignProps(json3, folded);
|
|
26647
26647
|
}
|
|
26648
26648
|
function finalize(ctx, schema) {
|
|
26649
26649
|
const root = ctx.seen.get(schema);
|
|
@@ -26725,20 +26725,20 @@ function finalize(ctx, schema) {
|
|
|
26725
26725
|
if (ctx.intersections.length) {
|
|
26726
26726
|
const carriers = /* @__PURE__ */ new Map();
|
|
26727
26727
|
for (const seen of ctx.seen.values()) {
|
|
26728
|
-
for (const
|
|
26729
|
-
const allOf =
|
|
26728
|
+
for (const json3 of [seen.schema, seen.def]) {
|
|
26729
|
+
const allOf = json3?.allOf;
|
|
26730
26730
|
if (!Array.isArray(allOf))
|
|
26731
26731
|
continue;
|
|
26732
26732
|
const existing = carriers.get(allOf);
|
|
26733
26733
|
if (existing)
|
|
26734
|
-
existing.push(
|
|
26734
|
+
existing.push(json3);
|
|
26735
26735
|
else
|
|
26736
|
-
carriers.set(allOf, [
|
|
26736
|
+
carriers.set(allOf, [json3]);
|
|
26737
26737
|
}
|
|
26738
26738
|
}
|
|
26739
26739
|
for (const allOf of ctx.intersections) {
|
|
26740
|
-
for (const
|
|
26741
|
-
foldIntersection(
|
|
26740
|
+
for (const json3 of carriers.get(allOf) ?? [])
|
|
26741
|
+
foldIntersection(json3);
|
|
26742
26742
|
}
|
|
26743
26743
|
}
|
|
26744
26744
|
}
|
|
@@ -26973,29 +26973,29 @@ var exactPatterns = /* @__PURE__ */ new Map([
|
|
|
26973
26973
|
]);
|
|
26974
26974
|
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
26975
26975
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
26976
|
-
const
|
|
26977
|
-
|
|
26976
|
+
const json3 = _json;
|
|
26977
|
+
json3.type = "string";
|
|
26978
26978
|
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
26979
26979
|
if (typeof minimum === "number")
|
|
26980
|
-
|
|
26980
|
+
json3.minLength = minimum;
|
|
26981
26981
|
if (typeof maximum === "number")
|
|
26982
|
-
|
|
26982
|
+
json3.maxLength = maximum;
|
|
26983
26983
|
if (format) {
|
|
26984
|
-
|
|
26985
|
-
if (
|
|
26986
|
-
delete
|
|
26984
|
+
json3.format = formatMap[format] ?? format;
|
|
26985
|
+
if (json3.format === "")
|
|
26986
|
+
delete json3.format;
|
|
26987
26987
|
if (format === "time" || laxFormat) {
|
|
26988
|
-
delete
|
|
26988
|
+
delete json3.format;
|
|
26989
26989
|
}
|
|
26990
26990
|
}
|
|
26991
26991
|
if (contentEncoding)
|
|
26992
|
-
|
|
26992
|
+
json3.contentEncoding = contentEncoding;
|
|
26993
26993
|
if (patterns && patterns.size > 0) {
|
|
26994
26994
|
const patternList = [...patterns].map(exactPattern);
|
|
26995
26995
|
if (patternList.length === 1)
|
|
26996
|
-
|
|
26996
|
+
json3.pattern = patternList[0].source;
|
|
26997
26997
|
else if (patternList.length > 1) {
|
|
26998
|
-
|
|
26998
|
+
json3.allOf = [
|
|
26999
26999
|
...patternList.map((regex) => ({
|
|
27000
27000
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
27001
27001
|
pattern: regex.source
|
|
@@ -27005,31 +27005,31 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
27005
27005
|
}
|
|
27006
27006
|
};
|
|
27007
27007
|
var numberProcessor = (schema, ctx, _json, params) => {
|
|
27008
|
-
const
|
|
27008
|
+
const json3 = _json;
|
|
27009
27009
|
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
27010
|
-
|
|
27010
|
+
json3.type = isInt ? "integer" : "number";
|
|
27011
27011
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
27012
27012
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
27013
27013
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
27014
27014
|
if (exMin) {
|
|
27015
27015
|
if (legacy) {
|
|
27016
|
-
|
|
27017
|
-
|
|
27016
|
+
json3.minimum = exclusiveMinimum;
|
|
27017
|
+
json3.exclusiveMinimum = true;
|
|
27018
27018
|
} else {
|
|
27019
|
-
|
|
27019
|
+
json3.exclusiveMinimum = exclusiveMinimum;
|
|
27020
27020
|
}
|
|
27021
27021
|
} else if (typeof minimum === "number") {
|
|
27022
|
-
|
|
27022
|
+
json3.minimum = minimum;
|
|
27023
27023
|
}
|
|
27024
27024
|
if (exMax) {
|
|
27025
27025
|
if (legacy) {
|
|
27026
|
-
|
|
27027
|
-
|
|
27026
|
+
json3.maximum = exclusiveMaximum;
|
|
27027
|
+
json3.exclusiveMaximum = true;
|
|
27028
27028
|
} else {
|
|
27029
|
-
|
|
27029
|
+
json3.exclusiveMaximum = exclusiveMaximum;
|
|
27030
27030
|
}
|
|
27031
27031
|
} else if (typeof maximum === "number") {
|
|
27032
|
-
|
|
27032
|
+
json3.maximum = maximum;
|
|
27033
27033
|
}
|
|
27034
27034
|
if (multipleOf) {
|
|
27035
27035
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -27037,75 +27037,75 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
27037
27037
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
27038
27038
|
divisors.add(Math.abs(divisor));
|
|
27039
27039
|
else
|
|
27040
|
-
handleUnrepresentable(schema, ctx,
|
|
27040
|
+
handleUnrepresentable(schema, ctx, json3, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
27041
27041
|
}
|
|
27042
27042
|
const [first, ...rest] = divisors;
|
|
27043
27043
|
if (first !== void 0)
|
|
27044
|
-
|
|
27044
|
+
json3.multipleOf = first;
|
|
27045
27045
|
if (rest.length)
|
|
27046
|
-
|
|
27046
|
+
json3.allOf = [...json3.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
27047
27047
|
}
|
|
27048
27048
|
};
|
|
27049
|
-
var booleanProcessor = (_schema, _ctx,
|
|
27050
|
-
|
|
27049
|
+
var booleanProcessor = (_schema, _ctx, json3, _params) => {
|
|
27050
|
+
json3.type = "boolean";
|
|
27051
27051
|
};
|
|
27052
|
-
var bigintProcessor = (schema, ctx,
|
|
27053
|
-
handleUnrepresentable(schema, ctx,
|
|
27052
|
+
var bigintProcessor = (schema, ctx, json3, params) => {
|
|
27053
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt cannot be represented in JSON Schema");
|
|
27054
27054
|
};
|
|
27055
|
-
var symbolProcessor = (schema, ctx,
|
|
27056
|
-
handleUnrepresentable(schema, ctx,
|
|
27055
|
+
var symbolProcessor = (schema, ctx, json3, params) => {
|
|
27056
|
+
handleUnrepresentable(schema, ctx, json3, params, "Symbols cannot be represented in JSON Schema");
|
|
27057
27057
|
};
|
|
27058
|
-
var nullProcessor = (_schema, ctx,
|
|
27058
|
+
var nullProcessor = (_schema, ctx, json3, _params) => {
|
|
27059
27059
|
if (ctx.target === "openapi-3.0") {
|
|
27060
|
-
|
|
27061
|
-
|
|
27062
|
-
|
|
27060
|
+
json3.type = "string";
|
|
27061
|
+
json3.nullable = true;
|
|
27062
|
+
json3.enum = [null];
|
|
27063
27063
|
} else {
|
|
27064
|
-
|
|
27064
|
+
json3.type = "null";
|
|
27065
27065
|
}
|
|
27066
27066
|
};
|
|
27067
|
-
var undefinedProcessor = (schema, ctx,
|
|
27068
|
-
handleUnrepresentable(schema, ctx,
|
|
27067
|
+
var undefinedProcessor = (schema, ctx, json3, params) => {
|
|
27068
|
+
handleUnrepresentable(schema, ctx, json3, params, "Undefined cannot be represented in JSON Schema");
|
|
27069
27069
|
};
|
|
27070
|
-
var voidProcessor = (schema, ctx,
|
|
27071
|
-
handleUnrepresentable(schema, ctx,
|
|
27070
|
+
var voidProcessor = (schema, ctx, json3, params) => {
|
|
27071
|
+
handleUnrepresentable(schema, ctx, json3, params, "Void cannot be represented in JSON Schema");
|
|
27072
27072
|
};
|
|
27073
|
-
var neverProcessor = (_schema, _ctx,
|
|
27074
|
-
|
|
27073
|
+
var neverProcessor = (_schema, _ctx, json3, _params) => {
|
|
27074
|
+
json3.not = {};
|
|
27075
27075
|
};
|
|
27076
27076
|
var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
27077
27077
|
};
|
|
27078
27078
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
27079
27079
|
};
|
|
27080
|
-
var dateProcessor = (schema, ctx,
|
|
27081
|
-
handleUnrepresentable(schema, ctx,
|
|
27080
|
+
var dateProcessor = (schema, ctx, json3, params) => {
|
|
27081
|
+
handleUnrepresentable(schema, ctx, json3, params, "Date cannot be represented in JSON Schema");
|
|
27082
27082
|
};
|
|
27083
|
-
var enumProcessor = (schema, _ctx,
|
|
27083
|
+
var enumProcessor = (schema, _ctx, json3, _params) => {
|
|
27084
27084
|
const def = schema._zod.def;
|
|
27085
27085
|
const values = getEnumValues(def.entries);
|
|
27086
27086
|
if (values.length === 0) {
|
|
27087
|
-
|
|
27087
|
+
json3.not = {};
|
|
27088
27088
|
return;
|
|
27089
27089
|
}
|
|
27090
27090
|
if (values.every((v) => typeof v === "number"))
|
|
27091
|
-
|
|
27091
|
+
json3.type = "number";
|
|
27092
27092
|
if (values.every((v) => typeof v === "string"))
|
|
27093
|
-
|
|
27094
|
-
|
|
27093
|
+
json3.type = "string";
|
|
27094
|
+
json3.enum = values;
|
|
27095
27095
|
};
|
|
27096
|
-
var literalProcessor = (schema, ctx,
|
|
27096
|
+
var literalProcessor = (schema, ctx, json3, params) => {
|
|
27097
27097
|
const def = schema._zod.def;
|
|
27098
27098
|
if (def.values.length === 0) {
|
|
27099
|
-
|
|
27099
|
+
json3.not = {};
|
|
27100
27100
|
return;
|
|
27101
27101
|
}
|
|
27102
27102
|
const vals = [];
|
|
27103
27103
|
for (const val of def.values) {
|
|
27104
27104
|
if (val === void 0) {
|
|
27105
|
-
if (handleUnrepresentable(schema, ctx,
|
|
27105
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
27106
27106
|
return;
|
|
27107
27107
|
} else if (typeof val === "bigint") {
|
|
27108
|
-
if (handleUnrepresentable(schema, ctx,
|
|
27108
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
27109
27109
|
return;
|
|
27110
27110
|
vals.push(Number(val));
|
|
27111
27111
|
} else {
|
|
@@ -27115,37 +27115,37 @@ var literalProcessor = (schema, ctx, json2, params) => {
|
|
|
27115
27115
|
if (vals.length === 0) {
|
|
27116
27116
|
} else if (vals.length === 1) {
|
|
27117
27117
|
const val = vals[0];
|
|
27118
|
-
|
|
27118
|
+
json3.type = val === null ? "null" : typeof val;
|
|
27119
27119
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
27120
|
-
|
|
27120
|
+
json3.enum = [val];
|
|
27121
27121
|
} else {
|
|
27122
|
-
|
|
27122
|
+
json3.const = val;
|
|
27123
27123
|
}
|
|
27124
27124
|
} else {
|
|
27125
27125
|
if (vals.every((v) => typeof v === "number"))
|
|
27126
|
-
|
|
27126
|
+
json3.type = "number";
|
|
27127
27127
|
if (vals.every((v) => typeof v === "string"))
|
|
27128
|
-
|
|
27128
|
+
json3.type = "string";
|
|
27129
27129
|
if (vals.every((v) => typeof v === "boolean"))
|
|
27130
|
-
|
|
27130
|
+
json3.type = "boolean";
|
|
27131
27131
|
if (vals.every((v) => v === null))
|
|
27132
|
-
|
|
27133
|
-
|
|
27132
|
+
json3.type = "null";
|
|
27133
|
+
json3.enum = vals;
|
|
27134
27134
|
}
|
|
27135
27135
|
};
|
|
27136
|
-
var nanProcessor = (schema, ctx,
|
|
27137
|
-
handleUnrepresentable(schema, ctx,
|
|
27136
|
+
var nanProcessor = (schema, ctx, json3, params) => {
|
|
27137
|
+
handleUnrepresentable(schema, ctx, json3, params, "NaN cannot be represented in JSON Schema");
|
|
27138
27138
|
};
|
|
27139
|
-
var templateLiteralProcessor = (schema, _ctx,
|
|
27140
|
-
const _json =
|
|
27139
|
+
var templateLiteralProcessor = (schema, _ctx, json3, _params) => {
|
|
27140
|
+
const _json = json3;
|
|
27141
27141
|
const pattern = schema._zod.pattern;
|
|
27142
27142
|
if (!pattern)
|
|
27143
27143
|
throw new Error("Pattern not found in template literal");
|
|
27144
27144
|
_json.type = "string";
|
|
27145
27145
|
_json.pattern = pattern.source;
|
|
27146
27146
|
};
|
|
27147
|
-
var fileProcessor = (schema, _ctx,
|
|
27148
|
-
const _json =
|
|
27147
|
+
var fileProcessor = (schema, _ctx, json3, _params) => {
|
|
27148
|
+
const _json = json3;
|
|
27149
27149
|
_json.type = "string";
|
|
27150
27150
|
_json.format = "binary";
|
|
27151
27151
|
_json.contentEncoding = "binary";
|
|
@@ -27163,34 +27163,34 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
27163
27163
|
else
|
|
27164
27164
|
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
27165
27165
|
};
|
|
27166
|
-
var successProcessor = (_schema, _ctx,
|
|
27167
|
-
|
|
27166
|
+
var successProcessor = (_schema, _ctx, json3, _params) => {
|
|
27167
|
+
json3.type = "boolean";
|
|
27168
27168
|
};
|
|
27169
|
-
var customProcessor = (schema, ctx,
|
|
27170
|
-
handleUnrepresentable(schema, ctx,
|
|
27169
|
+
var customProcessor = (schema, ctx, json3, params) => {
|
|
27170
|
+
handleUnrepresentable(schema, ctx, json3, params, "Custom types cannot be represented in JSON Schema");
|
|
27171
27171
|
};
|
|
27172
|
-
var functionProcessor = (schema, ctx,
|
|
27173
|
-
handleUnrepresentable(schema, ctx,
|
|
27172
|
+
var functionProcessor = (schema, ctx, json3, params) => {
|
|
27173
|
+
handleUnrepresentable(schema, ctx, json3, params, "Function types cannot be represented in JSON Schema");
|
|
27174
27174
|
};
|
|
27175
|
-
var transformProcessor = (schema, ctx,
|
|
27176
|
-
handleUnrepresentable(schema, ctx,
|
|
27175
|
+
var transformProcessor = (schema, ctx, json3, params) => {
|
|
27176
|
+
handleUnrepresentable(schema, ctx, json3, params, "Transforms cannot be represented in JSON Schema");
|
|
27177
27177
|
};
|
|
27178
|
-
var mapProcessor = (schema, ctx,
|
|
27179
|
-
handleUnrepresentable(schema, ctx,
|
|
27178
|
+
var mapProcessor = (schema, ctx, json3, params) => {
|
|
27179
|
+
handleUnrepresentable(schema, ctx, json3, params, "Map cannot be represented in JSON Schema");
|
|
27180
27180
|
};
|
|
27181
|
-
var setProcessor = (schema, ctx,
|
|
27182
|
-
handleUnrepresentable(schema, ctx,
|
|
27181
|
+
var setProcessor = (schema, ctx, json3, params) => {
|
|
27182
|
+
handleUnrepresentable(schema, ctx, json3, params, "Set cannot be represented in JSON Schema");
|
|
27183
27183
|
};
|
|
27184
27184
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
27185
|
-
const
|
|
27185
|
+
const json3 = _json;
|
|
27186
27186
|
const def = schema._zod.def;
|
|
27187
27187
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
27188
27188
|
if (typeof minimum === "number")
|
|
27189
|
-
|
|
27189
|
+
json3.minItems = minimum;
|
|
27190
27190
|
if (typeof maximum === "number")
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27191
|
+
json3.maxItems = maximum;
|
|
27192
|
+
json3.type = "array";
|
|
27193
|
+
json3.items = processSchema(def.element, ctx, {
|
|
27194
27194
|
...params,
|
|
27195
27195
|
path: [...params.path, "items"]
|
|
27196
27196
|
});
|
|
@@ -27206,17 +27206,17 @@ function inputOptin(schema) {
|
|
|
27206
27206
|
return schema._zod.optin;
|
|
27207
27207
|
}
|
|
27208
27208
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
27209
|
-
const
|
|
27209
|
+
const json3 = _json;
|
|
27210
27210
|
const def = schema._zod.def;
|
|
27211
27211
|
const shape = def.shape;
|
|
27212
27212
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
27213
|
-
if (symbolKeys.length && handleUnrepresentable(schema, ctx,
|
|
27213
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json3, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
27214
27214
|
return;
|
|
27215
27215
|
}
|
|
27216
|
-
|
|
27217
|
-
|
|
27216
|
+
json3.type = "object";
|
|
27217
|
+
json3.properties = {};
|
|
27218
27218
|
for (const key in shape) {
|
|
27219
|
-
assignProp(
|
|
27219
|
+
assignProp(json3.properties, key, processSchema(shape[key], ctx, {
|
|
27220
27220
|
...params,
|
|
27221
27221
|
path: [...params.path, "properties", key]
|
|
27222
27222
|
}));
|
|
@@ -27229,21 +27229,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
27229
27229
|
}
|
|
27230
27230
|
}
|
|
27231
27231
|
if (requiredKeys.length > 0) {
|
|
27232
|
-
|
|
27232
|
+
json3.required = requiredKeys;
|
|
27233
27233
|
}
|
|
27234
27234
|
if (def.catchall?._zod.def.type === "never") {
|
|
27235
|
-
|
|
27235
|
+
json3.additionalProperties = false;
|
|
27236
27236
|
} else if (!def.catchall) {
|
|
27237
27237
|
if (ctx.io === "output")
|
|
27238
|
-
|
|
27238
|
+
json3.additionalProperties = false;
|
|
27239
27239
|
} else if (def.catchall) {
|
|
27240
|
-
|
|
27240
|
+
json3.additionalProperties = processSchema(def.catchall, ctx, {
|
|
27241
27241
|
...params,
|
|
27242
27242
|
path: [...params.path, "additionalProperties"]
|
|
27243
27243
|
});
|
|
27244
27244
|
}
|
|
27245
27245
|
};
|
|
27246
|
-
var unionProcessor = (schema, ctx,
|
|
27246
|
+
var unionProcessor = (schema, ctx, json3, params) => {
|
|
27247
27247
|
const def = schema._zod.def;
|
|
27248
27248
|
const isExclusive = def.inclusive === false;
|
|
27249
27249
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
@@ -27251,12 +27251,12 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
27251
27251
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
27252
27252
|
}));
|
|
27253
27253
|
if (isExclusive) {
|
|
27254
|
-
|
|
27254
|
+
json3.oneOf = options;
|
|
27255
27255
|
} else {
|
|
27256
|
-
|
|
27256
|
+
json3.anyOf = options;
|
|
27257
27257
|
}
|
|
27258
27258
|
};
|
|
27259
|
-
var intersectionProcessor = (schema, ctx,
|
|
27259
|
+
var intersectionProcessor = (schema, ctx, json3, params) => {
|
|
27260
27260
|
const def = schema._zod.def;
|
|
27261
27261
|
const a = processSchema(def.left, ctx, {
|
|
27262
27262
|
...params,
|
|
@@ -27271,13 +27271,13 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
27271
27271
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
27272
27272
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
27273
27273
|
];
|
|
27274
|
-
|
|
27274
|
+
json3.allOf = allOf;
|
|
27275
27275
|
ctx.intersections.push(allOf);
|
|
27276
27276
|
};
|
|
27277
27277
|
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
27278
|
-
const
|
|
27278
|
+
const json3 = _json;
|
|
27279
27279
|
const def = schema._zod.def;
|
|
27280
|
-
|
|
27280
|
+
json3.type = "array";
|
|
27281
27281
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
27282
27282
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
27283
27283
|
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
@@ -27299,70 +27299,70 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
27299
27299
|
const maxItems = def.items.length;
|
|
27300
27300
|
const isClosed = !def.rest;
|
|
27301
27301
|
if (ctx.target === "draft-2020-12") {
|
|
27302
|
-
|
|
27302
|
+
json3.prefixItems = prefixItems;
|
|
27303
27303
|
if (isClosed) {
|
|
27304
|
-
|
|
27304
|
+
json3.items = false;
|
|
27305
27305
|
} else if (rest) {
|
|
27306
|
-
|
|
27306
|
+
json3.items = rest;
|
|
27307
27307
|
}
|
|
27308
27308
|
if (minItems > 0)
|
|
27309
|
-
|
|
27309
|
+
json3.minItems = minItems;
|
|
27310
27310
|
if (isClosed)
|
|
27311
|
-
|
|
27311
|
+
json3.maxItems = maxItems;
|
|
27312
27312
|
} else if (ctx.target === "openapi-3.0") {
|
|
27313
|
-
|
|
27313
|
+
json3.items = {
|
|
27314
27314
|
anyOf: prefixItems
|
|
27315
27315
|
};
|
|
27316
27316
|
if (rest) {
|
|
27317
|
-
|
|
27317
|
+
json3.items.anyOf.push(rest);
|
|
27318
27318
|
}
|
|
27319
27319
|
if (minItems > 0)
|
|
27320
|
-
|
|
27320
|
+
json3.minItems = minItems;
|
|
27321
27321
|
if (isClosed)
|
|
27322
|
-
|
|
27322
|
+
json3.maxItems = maxItems;
|
|
27323
27323
|
} else {
|
|
27324
|
-
|
|
27324
|
+
json3.items = prefixItems;
|
|
27325
27325
|
if (isClosed) {
|
|
27326
|
-
|
|
27326
|
+
json3.additionalItems = false;
|
|
27327
27327
|
} else if (rest) {
|
|
27328
|
-
|
|
27328
|
+
json3.additionalItems = rest;
|
|
27329
27329
|
}
|
|
27330
27330
|
if (minItems > 0)
|
|
27331
|
-
|
|
27331
|
+
json3.minItems = minItems;
|
|
27332
27332
|
if (isClosed)
|
|
27333
|
-
|
|
27333
|
+
json3.maxItems = maxItems;
|
|
27334
27334
|
}
|
|
27335
27335
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
27336
27336
|
if (typeof minimum === "number")
|
|
27337
|
-
|
|
27337
|
+
json3.minItems = minimum;
|
|
27338
27338
|
if (typeof maximum === "number")
|
|
27339
|
-
|
|
27339
|
+
json3.maxItems = maximum;
|
|
27340
27340
|
};
|
|
27341
|
-
function stringifyKeyNames(bySchema,
|
|
27342
|
-
if (
|
|
27343
|
-
if (visited.has(
|
|
27344
|
-
return
|
|
27345
|
-
visited.add(
|
|
27346
|
-
const def = bySchema.get(
|
|
27341
|
+
function stringifyKeyNames(bySchema, json3, visited) {
|
|
27342
|
+
if (json3.$ref) {
|
|
27343
|
+
if (visited.has(json3))
|
|
27344
|
+
return json3;
|
|
27345
|
+
visited.add(json3);
|
|
27346
|
+
const def = bySchema.get(json3)?.def;
|
|
27347
27347
|
if (!def)
|
|
27348
|
-
return
|
|
27348
|
+
return json3;
|
|
27349
27349
|
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
27350
|
-
return inlined === def ?
|
|
27350
|
+
return inlined === def ? json3 : inlined;
|
|
27351
27351
|
}
|
|
27352
27352
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
27353
|
-
const branches =
|
|
27353
|
+
const branches = json3[keyword];
|
|
27354
27354
|
if (!Array.isArray(branches))
|
|
27355
27355
|
continue;
|
|
27356
27356
|
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
27357
27357
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
27358
|
-
|
|
27358
|
+
json3 = { ...json3, [keyword]: mapped };
|
|
27359
27359
|
}
|
|
27360
|
-
const types = Array.isArray(
|
|
27360
|
+
const types = Array.isArray(json3.type) ? json3.type : [json3.type];
|
|
27361
27361
|
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
27362
|
-
const values =
|
|
27362
|
+
const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
|
|
27363
27363
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
27364
|
-
return
|
|
27365
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } =
|
|
27364
|
+
return json3;
|
|
27365
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json3;
|
|
27366
27366
|
if (rest.enum)
|
|
27367
27367
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
27368
27368
|
else if (typeof rest.const === "number")
|
|
@@ -27402,9 +27402,9 @@ function rewriteKeyNames(ctx) {
|
|
|
27402
27402
|
}
|
|
27403
27403
|
}
|
|
27404
27404
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
27405
|
-
const
|
|
27405
|
+
const json3 = _json;
|
|
27406
27406
|
const def = schema._zod.def;
|
|
27407
|
-
|
|
27407
|
+
json3.type = "object";
|
|
27408
27408
|
const keyType = def.keyType;
|
|
27409
27409
|
const patterns = aggregateChecks(keyType).patterns;
|
|
27410
27410
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
@@ -27412,13 +27412,13 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
27412
27412
|
...params,
|
|
27413
27413
|
path: [...params.path, "patternProperties", "*"]
|
|
27414
27414
|
});
|
|
27415
|
-
|
|
27415
|
+
json3.patternProperties = {};
|
|
27416
27416
|
for (const pattern of patterns) {
|
|
27417
|
-
assignProp(
|
|
27417
|
+
assignProp(json3.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
27418
27418
|
}
|
|
27419
27419
|
} else {
|
|
27420
27420
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
27421
|
-
|
|
27421
|
+
json3.propertyNames = processSchema(def.keyType, ctx, {
|
|
27422
27422
|
...params,
|
|
27423
27423
|
path: [...params.path, "propertyNames"]
|
|
27424
27424
|
});
|
|
@@ -27430,7 +27430,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
27430
27430
|
}
|
|
27431
27431
|
pending.push(schema);
|
|
27432
27432
|
}
|
|
27433
|
-
|
|
27433
|
+
json3.additionalProperties = processSchema(def.valueType, ctx, {
|
|
27434
27434
|
...params,
|
|
27435
27435
|
path: [...params.path, "additionalProperties"]
|
|
27436
27436
|
});
|
|
@@ -27440,19 +27440,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
27440
27440
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
27441
27441
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
27442
27442
|
if (validKeyValues.length > 0) {
|
|
27443
|
-
|
|
27443
|
+
json3.required = validKeyValues.map(String);
|
|
27444
27444
|
}
|
|
27445
27445
|
}
|
|
27446
27446
|
};
|
|
27447
|
-
var nullableProcessor = (schema, ctx,
|
|
27447
|
+
var nullableProcessor = (schema, ctx, json3, params) => {
|
|
27448
27448
|
const def = schema._zod.def;
|
|
27449
27449
|
const inner = processSchema(def.innerType, ctx, params);
|
|
27450
27450
|
const seen = ctx.seen.get(schema);
|
|
27451
27451
|
if (ctx.target === "openapi-3.0") {
|
|
27452
27452
|
seen.ref = def.innerType;
|
|
27453
|
-
|
|
27453
|
+
json3.nullable = true;
|
|
27454
27454
|
} else {
|
|
27455
|
-
|
|
27455
|
+
json3.anyOf = [inner, { type: "null" }];
|
|
27456
27456
|
}
|
|
27457
27457
|
};
|
|
27458
27458
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -27462,7 +27462,7 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
27462
27462
|
seen.ref = def.innerType;
|
|
27463
27463
|
};
|
|
27464
27464
|
var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
27465
|
-
function serializeDefaultValue(value, schema, ctx,
|
|
27465
|
+
function serializeDefaultValue(value, schema, ctx, json3, params) {
|
|
27466
27466
|
let unrepresentable = false;
|
|
27467
27467
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
27468
27468
|
if (typeof val !== "bigint")
|
|
@@ -27472,30 +27472,30 @@ function serializeDefaultValue(value, schema, ctx, json2, params) {
|
|
|
27472
27472
|
});
|
|
27473
27473
|
if (!unrepresentable)
|
|
27474
27474
|
return JSON.parse(serialized);
|
|
27475
|
-
handleUnrepresentable(schema, ctx,
|
|
27475
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
27476
27476
|
return UNREPRESENTABLE_DEFAULT;
|
|
27477
27477
|
}
|
|
27478
|
-
var defaultProcessor = (schema, ctx,
|
|
27478
|
+
var defaultProcessor = (schema, ctx, json3, params) => {
|
|
27479
27479
|
const def = schema._zod.def;
|
|
27480
27480
|
processSchema(def.innerType, ctx, params);
|
|
27481
27481
|
const seen = ctx.seen.get(schema);
|
|
27482
27482
|
seen.ref = def.innerType;
|
|
27483
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
27483
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
27484
27484
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
27485
|
-
|
|
27485
|
+
json3.default = value;
|
|
27486
27486
|
};
|
|
27487
|
-
var prefaultProcessor = (schema, ctx,
|
|
27487
|
+
var prefaultProcessor = (schema, ctx, json3, params) => {
|
|
27488
27488
|
const def = schema._zod.def;
|
|
27489
27489
|
processSchema(def.innerType, ctx, params);
|
|
27490
27490
|
const seen = ctx.seen.get(schema);
|
|
27491
27491
|
seen.ref = def.innerType;
|
|
27492
27492
|
if (ctx.io !== "input")
|
|
27493
27493
|
return;
|
|
27494
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
27494
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
27495
27495
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
27496
|
-
|
|
27496
|
+
json3._prefault = value;
|
|
27497
27497
|
};
|
|
27498
|
-
var catchProcessor = (schema, ctx,
|
|
27498
|
+
var catchProcessor = (schema, ctx, json3, params) => {
|
|
27499
27499
|
const def = schema._zod.def;
|
|
27500
27500
|
processSchema(def.innerType, ctx, params);
|
|
27501
27501
|
const seen = ctx.seen.get(schema);
|
|
@@ -27504,10 +27504,10 @@ var catchProcessor = (schema, ctx, json2, params) => {
|
|
|
27504
27504
|
try {
|
|
27505
27505
|
catchValue = def.catchValue(void 0);
|
|
27506
27506
|
} catch {
|
|
27507
|
-
handleUnrepresentable(schema, ctx,
|
|
27507
|
+
handleUnrepresentable(schema, ctx, json3, params, "Dynamic catch values are not supported in JSON Schema");
|
|
27508
27508
|
return;
|
|
27509
27509
|
}
|
|
27510
|
-
|
|
27510
|
+
json3.default = catchValue;
|
|
27511
27511
|
};
|
|
27512
27512
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
27513
27513
|
const def = schema._zod.def;
|
|
@@ -27517,12 +27517,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
27517
27517
|
const seen = ctx.seen.get(schema);
|
|
27518
27518
|
seen.ref = innerType;
|
|
27519
27519
|
};
|
|
27520
|
-
var readonlyProcessor = (schema, ctx,
|
|
27520
|
+
var readonlyProcessor = (schema, ctx, json3, params) => {
|
|
27521
27521
|
const def = schema._zod.def;
|
|
27522
27522
|
processSchema(def.innerType, ctx, params);
|
|
27523
27523
|
const seen = ctx.seen.get(schema);
|
|
27524
27524
|
seen.ref = def.innerType;
|
|
27525
|
-
|
|
27525
|
+
json3.readOnly = true;
|
|
27526
27526
|
};
|
|
27527
27527
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
27528
27528
|
const def = schema._zod.def;
|
|
@@ -28164,7 +28164,7 @@ var _ZodString = /* @__PURE__ */ $constructor(
|
|
|
28164
28164
|
(inst, def) => {
|
|
28165
28165
|
$ZodString.init(inst, def);
|
|
28166
28166
|
ZodType.init(inst, def);
|
|
28167
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28167
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => stringProcessor(inst, ctx, json3, params);
|
|
28168
28168
|
},
|
|
28169
28169
|
/* @__PURE__ */ util_exports.derived({
|
|
28170
28170
|
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
@@ -28523,7 +28523,7 @@ var ZodNumber = /* @__PURE__ */ $constructor(
|
|
|
28523
28523
|
(inst, def) => {
|
|
28524
28524
|
$ZodNumber.init(inst, def);
|
|
28525
28525
|
ZodType.init(inst, def);
|
|
28526
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28526
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => numberProcessor(inst, ctx, json3, params);
|
|
28527
28527
|
inst.isFinite = true;
|
|
28528
28528
|
},
|
|
28529
28529
|
/* @__PURE__ */ util_exports.derived({
|
|
@@ -28613,7 +28613,7 @@ function uint32(params) {
|
|
|
28613
28613
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
28614
28614
|
$ZodBoolean.init(inst, def);
|
|
28615
28615
|
ZodType.init(inst, def);
|
|
28616
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28616
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => booleanProcessor(inst, ctx, json3, params);
|
|
28617
28617
|
});
|
|
28618
28618
|
function boolean2(params) {
|
|
28619
28619
|
return _boolean(ZodBoolean, params);
|
|
@@ -28623,7 +28623,7 @@ var ZodBigInt = /* @__PURE__ */ $constructor(
|
|
|
28623
28623
|
(inst, def) => {
|
|
28624
28624
|
$ZodBigInt.init(inst, def);
|
|
28625
28625
|
ZodType.init(inst, def);
|
|
28626
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28626
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => bigintProcessor(inst, ctx, json3, params);
|
|
28627
28627
|
},
|
|
28628
28628
|
/* @__PURE__ */ util_exports.derived({
|
|
28629
28629
|
minValue: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
@@ -28681,7 +28681,7 @@ function uint64(params) {
|
|
|
28681
28681
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
28682
28682
|
$ZodSymbol.init(inst, def);
|
|
28683
28683
|
ZodType.init(inst, def);
|
|
28684
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28684
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => symbolProcessor(inst, ctx, json3, params);
|
|
28685
28685
|
});
|
|
28686
28686
|
function symbol(params) {
|
|
28687
28687
|
return _symbol(ZodSymbol, params);
|
|
@@ -28689,7 +28689,7 @@ function symbol(params) {
|
|
|
28689
28689
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
28690
28690
|
$ZodUndefined.init(inst, def);
|
|
28691
28691
|
ZodType.init(inst, def);
|
|
28692
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28692
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => undefinedProcessor(inst, ctx, json3, params);
|
|
28693
28693
|
});
|
|
28694
28694
|
function _undefined3(params) {
|
|
28695
28695
|
return _undefined2(ZodUndefined, params);
|
|
@@ -28697,7 +28697,7 @@ function _undefined3(params) {
|
|
|
28697
28697
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
28698
28698
|
$ZodNull.init(inst, def);
|
|
28699
28699
|
ZodType.init(inst, def);
|
|
28700
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28700
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullProcessor(inst, ctx, json3, params);
|
|
28701
28701
|
});
|
|
28702
28702
|
function _null3(params) {
|
|
28703
28703
|
return _null2(ZodNull, params);
|
|
@@ -28705,7 +28705,7 @@ function _null3(params) {
|
|
|
28705
28705
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
28706
28706
|
$ZodAny.init(inst, def);
|
|
28707
28707
|
ZodType.init(inst, def);
|
|
28708
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28708
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => anyProcessor(inst, ctx, json3, params);
|
|
28709
28709
|
});
|
|
28710
28710
|
function any() {
|
|
28711
28711
|
return _any(ZodAny);
|
|
@@ -28713,7 +28713,7 @@ function any() {
|
|
|
28713
28713
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
28714
28714
|
$ZodUnknown.init(inst, def);
|
|
28715
28715
|
ZodType.init(inst, def);
|
|
28716
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28716
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unknownProcessor(inst, ctx, json3, params);
|
|
28717
28717
|
});
|
|
28718
28718
|
function unknown() {
|
|
28719
28719
|
return _unknown(ZodUnknown);
|
|
@@ -28721,7 +28721,7 @@ function unknown() {
|
|
|
28721
28721
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
28722
28722
|
$ZodNever.init(inst, def);
|
|
28723
28723
|
ZodType.init(inst, def);
|
|
28724
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28724
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => neverProcessor(inst, ctx, json3, params);
|
|
28725
28725
|
});
|
|
28726
28726
|
function never(params) {
|
|
28727
28727
|
return _never(ZodNever, params);
|
|
@@ -28729,7 +28729,7 @@ function never(params) {
|
|
|
28729
28729
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
28730
28730
|
$ZodVoid.init(inst, def);
|
|
28731
28731
|
ZodType.init(inst, def);
|
|
28732
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28732
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => voidProcessor(inst, ctx, json3, params);
|
|
28733
28733
|
});
|
|
28734
28734
|
function _void2(params) {
|
|
28735
28735
|
return _void(ZodVoid, params);
|
|
@@ -28739,7 +28739,7 @@ var ZodDate = /* @__PURE__ */ $constructor(
|
|
|
28739
28739
|
(inst, def) => {
|
|
28740
28740
|
$ZodDate.init(inst, def);
|
|
28741
28741
|
ZodType.init(inst, def);
|
|
28742
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28742
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => dateProcessor(inst, ctx, json3, params);
|
|
28743
28743
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
28744
28744
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
28745
28745
|
},
|
|
@@ -28761,7 +28761,7 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
28761
28761
|
_ensureDefaultMemoizer();
|
|
28762
28762
|
$ZodArray.init(inst, def);
|
|
28763
28763
|
ZodType.init(inst, def);
|
|
28764
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28764
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => arrayProcessor(inst, ctx, json3, params);
|
|
28765
28765
|
inst.element = def.element;
|
|
28766
28766
|
}, {
|
|
28767
28767
|
min(n, params) {
|
|
@@ -28791,7 +28791,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
28791
28791
|
_ensureDefaultMemoizer();
|
|
28792
28792
|
$ZodObjectJIT.init(inst, def);
|
|
28793
28793
|
ZodType.init(inst, def);
|
|
28794
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28794
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => objectProcessor(inst, ctx, json3, params);
|
|
28795
28795
|
util_exports.installLazyProp(inst, "shape", (self2) => self2._zod.def.shape, false);
|
|
28796
28796
|
}, {
|
|
28797
28797
|
keyof() {
|
|
@@ -28864,7 +28864,7 @@ function looseObject(shape, params) {
|
|
|
28864
28864
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
28865
28865
|
$ZodUnion.init(inst, def);
|
|
28866
28866
|
ZodType.init(inst, def);
|
|
28867
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28867
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
28868
28868
|
inst.options = def.options;
|
|
28869
28869
|
});
|
|
28870
28870
|
function union(options, params) {
|
|
@@ -28877,7 +28877,7 @@ function union(options, params) {
|
|
|
28877
28877
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
28878
28878
|
ZodUnion.init(inst, def);
|
|
28879
28879
|
$ZodXor.init(inst, def);
|
|
28880
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28880
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
28881
28881
|
inst.options = def.options;
|
|
28882
28882
|
});
|
|
28883
28883
|
function xor(options, params) {
|
|
@@ -28903,7 +28903,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
28903
28903
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
28904
28904
|
$ZodIntersection.init(inst, def);
|
|
28905
28905
|
ZodType.init(inst, def);
|
|
28906
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28906
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => intersectionProcessor(inst, ctx, json3, params);
|
|
28907
28907
|
});
|
|
28908
28908
|
function intersection(left, right) {
|
|
28909
28909
|
return new ZodIntersection({
|
|
@@ -28916,7 +28916,7 @@ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
|
28916
28916
|
_ensureDefaultMemoizer();
|
|
28917
28917
|
$ZodTuple.init(inst, def);
|
|
28918
28918
|
ZodType.init(inst, def);
|
|
28919
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28919
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => tupleProcessor(inst, ctx, json3, params);
|
|
28920
28920
|
}, {
|
|
28921
28921
|
rest(rest) {
|
|
28922
28922
|
return this.clone({
|
|
@@ -28949,7 +28949,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
28949
28949
|
_ensureDefaultMemoizer();
|
|
28950
28950
|
$ZodRecord.init(inst, def);
|
|
28951
28951
|
ZodType.init(inst, def);
|
|
28952
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28952
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => recordProcessor(inst, ctx, json3, params);
|
|
28953
28953
|
inst.keyType = def.keyType;
|
|
28954
28954
|
inst.valueType = def.valueType;
|
|
28955
28955
|
});
|
|
@@ -28991,7 +28991,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
28991
28991
|
_ensureDefaultMemoizer();
|
|
28992
28992
|
$ZodMap.init(inst, def);
|
|
28993
28993
|
ZodType.init(inst, def);
|
|
28994
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28994
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => mapProcessor(inst, ctx, json3, params);
|
|
28995
28995
|
inst.keyType = def.keyType;
|
|
28996
28996
|
inst.valueType = def.valueType;
|
|
28997
28997
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -29011,7 +29011,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
|
29011
29011
|
_ensureDefaultMemoizer();
|
|
29012
29012
|
$ZodSet.init(inst, def);
|
|
29013
29013
|
ZodType.init(inst, def);
|
|
29014
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29014
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => setProcessor(inst, ctx, json3, params);
|
|
29015
29015
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
29016
29016
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
29017
29017
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -29027,7 +29027,7 @@ function set(valueType, params) {
|
|
|
29027
29027
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
29028
29028
|
$ZodEnum.init(inst, def);
|
|
29029
29029
|
ZodType.init(inst, def);
|
|
29030
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29030
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => enumProcessor(inst, ctx, json3, params);
|
|
29031
29031
|
inst.enum = def.entries;
|
|
29032
29032
|
inst.options = [...inst._zod.values];
|
|
29033
29033
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -29080,7 +29080,7 @@ function nativeEnum(entries, params) {
|
|
|
29080
29080
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
29081
29081
|
$ZodLiteral.init(inst, def);
|
|
29082
29082
|
ZodType.init(inst, def);
|
|
29083
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29083
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => literalProcessor(inst, ctx, json3, params);
|
|
29084
29084
|
inst.values = new Set(def.values);
|
|
29085
29085
|
Object.defineProperty(inst, "value", {
|
|
29086
29086
|
get() {
|
|
@@ -29101,7 +29101,7 @@ function literal(value, params) {
|
|
|
29101
29101
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
29102
29102
|
$ZodFile.init(inst, def);
|
|
29103
29103
|
ZodType.init(inst, def);
|
|
29104
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29104
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
|
|
29105
29105
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
29106
29106
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
29107
29107
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -29113,7 +29113,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
29113
29113
|
_ensureDefaultMemoizer();
|
|
29114
29114
|
$ZodTransform.init(inst, def);
|
|
29115
29115
|
ZodType.init(inst, def);
|
|
29116
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29116
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => transformProcessor(inst, ctx, json3, params);
|
|
29117
29117
|
inst._zod.parse = (payload, _ctx) => {
|
|
29118
29118
|
if (_ctx.direction === "backward") {
|
|
29119
29119
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -29152,7 +29152,7 @@ function transform(fn) {
|
|
|
29152
29152
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
29153
29153
|
$ZodOptional.init(inst, def);
|
|
29154
29154
|
ZodType.init(inst, def);
|
|
29155
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29155
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
29156
29156
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29157
29157
|
});
|
|
29158
29158
|
function optional(innerType) {
|
|
@@ -29164,7 +29164,7 @@ function optional(innerType) {
|
|
|
29164
29164
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
29165
29165
|
$ZodExactOptional.init(inst, def);
|
|
29166
29166
|
ZodType.init(inst, def);
|
|
29167
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29167
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
29168
29168
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29169
29169
|
});
|
|
29170
29170
|
function exactOptional(innerType) {
|
|
@@ -29176,7 +29176,7 @@ function exactOptional(innerType) {
|
|
|
29176
29176
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
29177
29177
|
$ZodNullable.init(inst, def);
|
|
29178
29178
|
ZodType.init(inst, def);
|
|
29179
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29179
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullableProcessor(inst, ctx, json3, params);
|
|
29180
29180
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29181
29181
|
});
|
|
29182
29182
|
function nullable(innerType) {
|
|
@@ -29191,7 +29191,7 @@ function nullish2(innerType) {
|
|
|
29191
29191
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
29192
29192
|
$ZodDefault.init(inst, def);
|
|
29193
29193
|
ZodType.init(inst, def);
|
|
29194
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29194
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => defaultProcessor(inst, ctx, json3, params);
|
|
29195
29195
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29196
29196
|
inst.removeDefault = inst.unwrap;
|
|
29197
29197
|
});
|
|
@@ -29207,7 +29207,7 @@ function _default2(innerType, defaultValue) {
|
|
|
29207
29207
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
29208
29208
|
$ZodPrefault.init(inst, def);
|
|
29209
29209
|
ZodType.init(inst, def);
|
|
29210
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29210
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => prefaultProcessor(inst, ctx, json3, params);
|
|
29211
29211
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29212
29212
|
});
|
|
29213
29213
|
function prefault(innerType, defaultValue) {
|
|
@@ -29222,7 +29222,7 @@ function prefault(innerType, defaultValue) {
|
|
|
29222
29222
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
29223
29223
|
$ZodNonOptional.init(inst, def);
|
|
29224
29224
|
ZodType.init(inst, def);
|
|
29225
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29225
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nonoptionalProcessor(inst, ctx, json3, params);
|
|
29226
29226
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29227
29227
|
});
|
|
29228
29228
|
function nonoptional(innerType, params) {
|
|
@@ -29235,7 +29235,7 @@ function nonoptional(innerType, params) {
|
|
|
29235
29235
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
29236
29236
|
$ZodSuccess.init(inst, def);
|
|
29237
29237
|
ZodType.init(inst, def);
|
|
29238
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29238
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => successProcessor(inst, ctx, json3, params);
|
|
29239
29239
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29240
29240
|
});
|
|
29241
29241
|
function success(innerType) {
|
|
@@ -29247,7 +29247,7 @@ function success(innerType) {
|
|
|
29247
29247
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
29248
29248
|
$ZodCatch.init(inst, def);
|
|
29249
29249
|
ZodType.init(inst, def);
|
|
29250
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29250
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => catchProcessor(inst, ctx, json3, params);
|
|
29251
29251
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29252
29252
|
inst.removeCatch = inst.unwrap;
|
|
29253
29253
|
});
|
|
@@ -29261,7 +29261,7 @@ function _catch2(innerType, catchValue) {
|
|
|
29261
29261
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
29262
29262
|
$ZodNaN.init(inst, def);
|
|
29263
29263
|
ZodType.init(inst, def);
|
|
29264
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29264
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nanProcessor(inst, ctx, json3, params);
|
|
29265
29265
|
});
|
|
29266
29266
|
function nan(params) {
|
|
29267
29267
|
return _nan(ZodNaN, params);
|
|
@@ -29269,7 +29269,7 @@ function nan(params) {
|
|
|
29269
29269
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
29270
29270
|
$ZodPipe.init(inst, def);
|
|
29271
29271
|
ZodType.init(inst, def);
|
|
29272
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29272
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => pipeProcessor(inst, ctx, json3, params);
|
|
29273
29273
|
inst.in = def.in;
|
|
29274
29274
|
inst.out = def.out;
|
|
29275
29275
|
});
|
|
@@ -29311,7 +29311,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
29311
29311
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
29312
29312
|
$ZodReadonly.init(inst, def);
|
|
29313
29313
|
ZodType.init(inst, def);
|
|
29314
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29314
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => readonlyProcessor(inst, ctx, json3, params);
|
|
29315
29315
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29316
29316
|
});
|
|
29317
29317
|
function readonly(innerType) {
|
|
@@ -29323,7 +29323,7 @@ function readonly(innerType) {
|
|
|
29323
29323
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
29324
29324
|
$ZodTemplateLiteral.init(inst, def);
|
|
29325
29325
|
ZodType.init(inst, def);
|
|
29326
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29326
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => templateLiteralProcessor(inst, ctx, json3, params);
|
|
29327
29327
|
});
|
|
29328
29328
|
function templateLiteral(parts, params) {
|
|
29329
29329
|
return new ZodTemplateLiteral({
|
|
@@ -29335,7 +29335,7 @@ function templateLiteral(parts, params) {
|
|
|
29335
29335
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
29336
29336
|
$ZodLazy.init(inst, def);
|
|
29337
29337
|
ZodType.init(inst, def);
|
|
29338
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29338
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => lazyProcessor(inst, ctx, json3, params);
|
|
29339
29339
|
inst.unwrap = () => inst._zod.def.getter();
|
|
29340
29340
|
});
|
|
29341
29341
|
function lazy(getter) {
|
|
@@ -29347,7 +29347,7 @@ function lazy(getter) {
|
|
|
29347
29347
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
29348
29348
|
$ZodPromise.init(inst, def);
|
|
29349
29349
|
ZodType.init(inst, def);
|
|
29350
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29350
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => promiseProcessor(inst, ctx, json3, params);
|
|
29351
29351
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29352
29352
|
});
|
|
29353
29353
|
function promise(innerType) {
|
|
@@ -29359,7 +29359,7 @@ function promise(innerType) {
|
|
|
29359
29359
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
29360
29360
|
$ZodFunction.init(inst, def);
|
|
29361
29361
|
ZodType.init(inst, def);
|
|
29362
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29362
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => functionProcessor(inst, ctx, json3, params);
|
|
29363
29363
|
});
|
|
29364
29364
|
function _function(params) {
|
|
29365
29365
|
return new ZodFunction({
|
|
@@ -29371,7 +29371,7 @@ function _function(params) {
|
|
|
29371
29371
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
29372
29372
|
$ZodCustom.init(inst, def);
|
|
29373
29373
|
ZodType.init(inst, def);
|
|
29374
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29374
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => customProcessor(inst, ctx, json3, params);
|
|
29375
29375
|
});
|
|
29376
29376
|
function check(fn) {
|
|
29377
29377
|
const ch = new $ZodCheck({
|
|
@@ -29591,13 +29591,13 @@ function resolveRef(ref, ctx) {
|
|
|
29591
29591
|
if (!ref.startsWith("#")) {
|
|
29592
29592
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
29593
29593
|
}
|
|
29594
|
-
const
|
|
29595
|
-
if (
|
|
29594
|
+
const path5 = ref.slice(1).split("/").filter(Boolean);
|
|
29595
|
+
if (path5.length === 0) {
|
|
29596
29596
|
return ctx.rootSchema;
|
|
29597
29597
|
}
|
|
29598
29598
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
29599
|
-
if (
|
|
29600
|
-
const key =
|
|
29599
|
+
if (path5[0] === defsKey) {
|
|
29600
|
+
const key = path5[1] === void 0 ? void 0 : decodeJSONPointerSegment(path5[1]);
|
|
29601
29601
|
if (!key || !ctx.defs[key]) {
|
|
29602
29602
|
throw new Error(`Reference not found: ${ref}`);
|
|
29603
29603
|
}
|
|
@@ -32277,6 +32277,7 @@ function createServicesKernel(services, options) {
|
|
|
32277
32277
|
const freshSessions = /* @__PURE__ */ new Map();
|
|
32278
32278
|
const seenEventTypes = /* @__PURE__ */ new Set();
|
|
32279
32279
|
const unmappedEventTypes = /* @__PURE__ */ new Set();
|
|
32280
|
+
const injectedUserMessages = /* @__PURE__ */ new Map();
|
|
32280
32281
|
const listenerErrors = /* @__PURE__ */ new Map();
|
|
32281
32282
|
let approvalFace = "not-attached";
|
|
32282
32283
|
let questionsFace = "pending";
|
|
@@ -32612,6 +32613,10 @@ function createServicesKernel(services, options) {
|
|
|
32612
32613
|
log("unmapped session event type", { type, keys: shapeOf(data) });
|
|
32613
32614
|
}
|
|
32614
32615
|
}
|
|
32616
|
+
if (type === "user/message" && !isHumanUserMessage(data)) {
|
|
32617
|
+
const kind = String(data.source?.kind ?? "?");
|
|
32618
|
+
injectedUserMessages.set(kind, (injectedUserMessages.get(kind) ?? 0) + 1);
|
|
32619
|
+
}
|
|
32615
32620
|
}
|
|
32616
32621
|
function translateAgentStatus(onEvent, args) {
|
|
32617
32622
|
const payload = args.find((arg) => arg && typeof arg === "object");
|
|
@@ -32769,6 +32774,7 @@ function createServicesKernel(services, options) {
|
|
|
32769
32774
|
// 真机排错的第一现场:内核到底发了哪些事件类型、其中哪些我们没认。
|
|
32770
32775
|
eventTypes: [...seenEventTypes].slice(-24).join("|"),
|
|
32771
32776
|
unmappedEventTypes: [...unmappedEventTypes].join("|"),
|
|
32777
|
+
injectedUserMessages: [...injectedUserMessages].map(([kind, count]) => `${count}\xD7${kind}`).join("|") || "none",
|
|
32772
32778
|
approvalFace,
|
|
32773
32779
|
questionsFace,
|
|
32774
32780
|
listenerErrors: [...listenerErrors].slice(0, 4).map(([key, count]) => `${count}\xD7${key}`).join(" | ") || "none"
|
|
@@ -32793,17 +32799,29 @@ function sessionEventKernelEvents(input2) {
|
|
|
32793
32799
|
case "turn/start":
|
|
32794
32800
|
return [{ kind: "run-state", sessionId, state: "running" }];
|
|
32795
32801
|
case "assistant/message":
|
|
32796
|
-
case "user/message":
|
|
32797
32802
|
return [
|
|
32798
32803
|
{
|
|
32799
32804
|
kind: "delta",
|
|
32800
32805
|
sessionId,
|
|
32801
32806
|
messageId: messageIdOf(data, input2.seq),
|
|
32802
32807
|
text: textOf(data),
|
|
32803
|
-
role:
|
|
32808
|
+
role: "assistant",
|
|
32804
32809
|
done: true
|
|
32805
32810
|
}
|
|
32806
32811
|
];
|
|
32812
|
+
case "user/message": {
|
|
32813
|
+
if (!isHumanUserMessage(data)) return [];
|
|
32814
|
+
return [
|
|
32815
|
+
{
|
|
32816
|
+
kind: "delta",
|
|
32817
|
+
sessionId,
|
|
32818
|
+
messageId: messageIdOf(data, input2.seq),
|
|
32819
|
+
text: textOf(data),
|
|
32820
|
+
role: "user",
|
|
32821
|
+
done: true
|
|
32822
|
+
}
|
|
32823
|
+
];
|
|
32824
|
+
}
|
|
32807
32825
|
case "tool/call": {
|
|
32808
32826
|
const argsRaw = data.arguments ?? data.args;
|
|
32809
32827
|
return [
|
|
@@ -32941,6 +32959,14 @@ function charCountOf(event) {
|
|
|
32941
32959
|
if (event.kind === "tool") return (event.resultPreview ?? "").length + (event.argsPreview ?? "").length;
|
|
32942
32960
|
return 0;
|
|
32943
32961
|
}
|
|
32962
|
+
function isHumanUserMessage(data) {
|
|
32963
|
+
const source = data?.source;
|
|
32964
|
+
if (source === void 0 || source === null) return true;
|
|
32965
|
+
if (typeof source !== "object") return true;
|
|
32966
|
+
const kind = source.kind;
|
|
32967
|
+
if (typeof kind !== "string" || !kind) return true;
|
|
32968
|
+
return kind === "user";
|
|
32969
|
+
}
|
|
32944
32970
|
function textOf(data) {
|
|
32945
32971
|
const content = eventContent(data);
|
|
32946
32972
|
if (typeof content === "string") return content;
|
|
@@ -33152,7 +33178,11 @@ var DEFAULT_CONFIG = {
|
|
|
33152
33178
|
takeOverQuestions: false,
|
|
33153
33179
|
approvalTimeoutSec: 180,
|
|
33154
33180
|
listingRefreshSec: 15,
|
|
33155
|
-
conversationIdleTtlSec: 86400
|
|
33181
|
+
conversationIdleTtlSec: 86400,
|
|
33182
|
+
// 图默认落在会话工作区(`<workspace>/.dsh/sidebar-qr.png`),这里只是**兜底位**:
|
|
33183
|
+
// 会话 → 工作区解析不出来时才用它。故意不写进 patch YAML——把某个人的家目录
|
|
33184
|
+
// 焊进分发包是错的(拆分版同一理由)。
|
|
33185
|
+
sidebarQr: { enabled: true, imageFile: path2.join(homedir2(), ".dsh", "sidebar-qr.png"), refreshMs: 2e3 }
|
|
33156
33186
|
};
|
|
33157
33187
|
var loopback = /^wss?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/;
|
|
33158
33188
|
var wsUrl = /^wss?:\/\/.+/;
|
|
@@ -33169,7 +33199,10 @@ function readConfig(injected, env = process.env) {
|
|
|
33169
33199
|
const merged = {
|
|
33170
33200
|
...DEFAULT_CONFIG,
|
|
33171
33201
|
...injected ?? {},
|
|
33172
|
-
keepAwake: { ...DEFAULT_CONFIG.keepAwake, ...injected?.keepAwake ?? {} }
|
|
33202
|
+
keepAwake: { ...DEFAULT_CONFIG.keepAwake, ...injected?.keepAwake ?? {} },
|
|
33203
|
+
// 折进来的那一半同样是**逐键合并**:patch 里只写 `sidebarQr.refreshMs` 时,
|
|
33204
|
+
// enabled 与 imageFile 必须仍取默认值,而不是被整个对象覆盖成 undefined。
|
|
33205
|
+
sidebarQr: { ...DEFAULT_CONFIG.sidebarQr, ...injected?.sidebarQr ?? {} }
|
|
33173
33206
|
};
|
|
33174
33207
|
const fromEnv = (name) => env[name];
|
|
33175
33208
|
if (fromEnv("DRC_SERVER_URL")) merged.serverUrl = env.DRC_SERVER_URL;
|
|
@@ -33179,6 +33212,7 @@ function readConfig(injected, env = process.env) {
|
|
|
33179
33212
|
if (fromEnv("DRC_QR_IMAGE")) merged.qrImage = envFlag(env.DRC_QR_IMAGE, merged.qrImage);
|
|
33180
33213
|
if (fromEnv("DRC_QR_OPEN")) merged.qrOpen = envFlag(env.DRC_QR_OPEN, merged.qrOpen);
|
|
33181
33214
|
if (fromEnv("DRC_QR_ANSI")) merged.qrAnsi = envFlag(env.DRC_QR_ANSI, merged.qrAnsi);
|
|
33215
|
+
if (fromEnv("DRC_SIDEBAR_QR")) merged.sidebarQr.enabled = envFlag(env.DRC_SIDEBAR_QR, merged.sidebarQr.enabled);
|
|
33182
33216
|
if (fromEnv("DRC_QR_STYLE")) {
|
|
33183
33217
|
const style = env.DRC_QR_STYLE;
|
|
33184
33218
|
if (["ascii", "block", "half"].includes(style)) merged.qrStyle = style;
|
|
@@ -33273,6 +33307,28 @@ function validateConfig(config2) {
|
|
|
33273
33307
|
message: "\u63D0\u95EE\u63A5\u7BA1\u4F1A**\u53D6\u4EE3\u684C\u9762 UI \u7684\u63D0\u95EE\u80FD\u529B**\uFF08ctx.userQuestions \u53EA\u5141\u8BB8\u4E00\u4E2A\u6D3B\u8DC3 provider\uFF09\uFF1B\u624B\u673A\u7AEF\u4E0D\u5728\u7EBF\u65F6\u63D0\u95EE\u4F1A\u76F4\u63A5\u5931\u8D25"
|
|
33274
33308
|
});
|
|
33275
33309
|
}
|
|
33310
|
+
if (typeof config2.sidebarQr.imageFile !== "string" || config2.sidebarQr.imageFile === "") {
|
|
33311
|
+
problems.push({
|
|
33312
|
+
level: "warn",
|
|
33313
|
+
field: "sidebarQr.imageFile",
|
|
33314
|
+
message: "\u4E3A\u7A7A\u5C31\u65E0\u5904\u843D\u515C\u5E95\u56FE\uFF0C\u5DF2\u5939\u56DE ~/.dsh/sidebar-qr.png\uFF08\u5DE5\u4F5C\u533A\u89E3\u6790\u5F97\u51FA\u6765\u65F6\u672C\u6765\u4E5F\u7528\u4E0D\u5230\u5B83\uFF09"
|
|
33315
|
+
});
|
|
33316
|
+
config2.sidebarQr.imageFile = DEFAULT_CONFIG.sidebarQr.imageFile;
|
|
33317
|
+
} else if (!path2.isAbsolute(config2.sidebarQr.imageFile)) {
|
|
33318
|
+
problems.push({
|
|
33319
|
+
level: "warn",
|
|
33320
|
+
field: "sidebarQr.imageFile",
|
|
33321
|
+
message: `\u4E0D\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF08${config2.sidebarQr.imageFile}\uFF09\uFF0C\u5DE5\u4F5C\u533A\u89E3\u6790\u4E0D\u51FA\u6765\u65F6\u4F1A\u88AB\u89E3\u6790\u5230\u8FDB\u7A0B\u5DE5\u4F5C\u76EE\u5F55\u4E0B`
|
|
33322
|
+
});
|
|
33323
|
+
}
|
|
33324
|
+
if (!secondsSchema.safeParse(config2.sidebarQr.refreshMs).success || config2.sidebarQr.refreshMs < 200) {
|
|
33325
|
+
problems.push({
|
|
33326
|
+
level: "warn",
|
|
33327
|
+
field: "sidebarQr.refreshMs",
|
|
33328
|
+
message: "\u5FC5\u987B\u662F \u2265200 \u7684\u6709\u9650\u6BEB\u79D2\u6570\uFF0C\u5DF2\u5939\u56DE 2000\uFF08\u539F\u503C " + JSON.stringify(config2.sidebarQr.refreshMs) + "\uFF09"
|
|
33329
|
+
});
|
|
33330
|
+
config2.sidebarQr.refreshMs = DEFAULT_CONFIG.sidebarQr.refreshMs;
|
|
33331
|
+
}
|
|
33276
33332
|
return problems;
|
|
33277
33333
|
}
|
|
33278
33334
|
function redactSecret(value) {
|
|
@@ -33331,6 +33387,330 @@ async function qrPng(text, options = {}) {
|
|
|
33331
33387
|
});
|
|
33332
33388
|
}
|
|
33333
33389
|
|
|
33390
|
+
// src/presentation/sidebar.ts
|
|
33391
|
+
import path4 from "node:path";
|
|
33392
|
+
|
|
33393
|
+
// src/presentation/presenter.ts
|
|
33394
|
+
var import_qrcode2 = __toESM(require_lib(), 1);
|
|
33395
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
33396
|
+
import { mkdirSync as mkdirSync2, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
33397
|
+
import path3 from "node:path";
|
|
33398
|
+
function toEpochMs(value) {
|
|
33399
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : 0;
|
|
33400
|
+
if (typeof value === "string") {
|
|
33401
|
+
const parsed = Date.parse(value);
|
|
33402
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
33403
|
+
}
|
|
33404
|
+
return 0;
|
|
33405
|
+
}
|
|
33406
|
+
var PairingPresenter = class {
|
|
33407
|
+
constructor(deps) {
|
|
33408
|
+
this.deps = deps;
|
|
33409
|
+
}
|
|
33410
|
+
deps;
|
|
33411
|
+
value = { state: "none" };
|
|
33412
|
+
artifact = null;
|
|
33413
|
+
rendering = false;
|
|
33414
|
+
snapshot() {
|
|
33415
|
+
return this.value;
|
|
33416
|
+
}
|
|
33417
|
+
/**
|
|
33418
|
+
* 当前这一版的 PNG 字节;没有可看的码时是 null。
|
|
33419
|
+
*
|
|
33420
|
+
* **路由必须先拿它落盘成功,再回答 `ready`**——反过来就等于把用户送到一个不存在的
|
|
33421
|
+
* 文件上(右栏会弹出一张破图,比不弹更糟)。
|
|
33422
|
+
*/
|
|
33423
|
+
current() {
|
|
33424
|
+
return this.value.state === "ready" ? this.artifact : null;
|
|
33425
|
+
}
|
|
33426
|
+
/**
|
|
33427
|
+
* 看一眼当前的码。
|
|
33428
|
+
*
|
|
33429
|
+
* 三种结果:
|
|
33430
|
+
* - 没有码 / 码已过期 → `none`(右栏不该被一张废码顶开);
|
|
33431
|
+
* - 码没变 → 只更新 `expiresAt`(同一版码的过期时间可能被服务端 TTL 改写);
|
|
33432
|
+
* - 码变了 → 渲染成功后认这一版;渲染抛错就是 `none`(宁可不弹,也不弹一张上一版的图)。
|
|
33433
|
+
*/
|
|
33434
|
+
async observe(pairing) {
|
|
33435
|
+
const qr = typeof pairing?.qr === "string" && pairing.qr !== "" ? pairing.qr : null;
|
|
33436
|
+
const expiresAt = toEpochMs(pairing?.expiresAt);
|
|
33437
|
+
if (qr === null || expiresAt <= this.deps.now()) {
|
|
33438
|
+
this.value = { state: "none" };
|
|
33439
|
+
this.artifact = null;
|
|
33440
|
+
return;
|
|
33441
|
+
}
|
|
33442
|
+
const epoch = this.deps.digest(qr);
|
|
33443
|
+
if (this.artifact?.epoch !== epoch) {
|
|
33444
|
+
if (this.rendering) return;
|
|
33445
|
+
this.rendering = true;
|
|
33446
|
+
try {
|
|
33447
|
+
const buffer = await this.deps.render(qr);
|
|
33448
|
+
this.artifact = { epoch, buffer };
|
|
33449
|
+
} catch (error62) {
|
|
33450
|
+
this.artifact = null;
|
|
33451
|
+
this.deps.log("\u4E8C\u7EF4\u7801\u6E32\u67D3\u5931\u8D25", { message: String(error62?.message ?? error62).slice(0, 200) });
|
|
33452
|
+
} finally {
|
|
33453
|
+
this.rendering = false;
|
|
33454
|
+
}
|
|
33455
|
+
}
|
|
33456
|
+
this.value = this.artifact?.epoch === epoch ? { state: "ready", epoch, expiresAt } : { state: "none" };
|
|
33457
|
+
}
|
|
33458
|
+
};
|
|
33459
|
+
function liveDeps(log) {
|
|
33460
|
+
return {
|
|
33461
|
+
now: () => Date.now(),
|
|
33462
|
+
render: (qr) => import_qrcode2.default.toBuffer(qr, { errorCorrectionLevel: "M", margin: 4, scale: 8, type: "png" }),
|
|
33463
|
+
digest: (qr) => createHash2("sha256").update(qr).digest("hex").slice(0, 16),
|
|
33464
|
+
log
|
|
33465
|
+
};
|
|
33466
|
+
}
|
|
33467
|
+
function writePrivatePng(file2, data) {
|
|
33468
|
+
if (!file2) return false;
|
|
33469
|
+
try {
|
|
33470
|
+
mkdirSync2(path3.dirname(file2), { recursive: true });
|
|
33471
|
+
const tmp = `${file2}.tmp-${process.pid}`;
|
|
33472
|
+
writeFileSync2(tmp, data, { mode: 384 });
|
|
33473
|
+
renameSync2(tmp, file2);
|
|
33474
|
+
return true;
|
|
33475
|
+
} catch {
|
|
33476
|
+
return false;
|
|
33477
|
+
}
|
|
33478
|
+
}
|
|
33479
|
+
|
|
33480
|
+
// src/presentation/address.ts
|
|
33481
|
+
var FILE_ADDRESS_PREFIX = "dsh-resource://file/";
|
|
33482
|
+
function encodeSegment(segment) {
|
|
33483
|
+
return encodeURIComponent(segment).replace(/%3A/gi, ":");
|
|
33484
|
+
}
|
|
33485
|
+
function sessionFileAddress(sessionId, filePath) {
|
|
33486
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
33487
|
+
const encoded = normalized.split("/").map(encodeSegment).join("/");
|
|
33488
|
+
return `${FILE_ADDRESS_PREFIX}session/${encodeSegment(sessionId)}/${encoded}`;
|
|
33489
|
+
}
|
|
33490
|
+
function isUsableSessionId(value) {
|
|
33491
|
+
return typeof value === "string" && /^[A-Za-z0-9._:-]{1,200}$/.test(value);
|
|
33492
|
+
}
|
|
33493
|
+
|
|
33494
|
+
// src/presentation/route.ts
|
|
33495
|
+
var PAIRING_ROUTE = "/plugins/dsh-remote-control/pairing";
|
|
33496
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
33497
|
+
function hostnameOf(host) {
|
|
33498
|
+
const trimmed = host.trim().toLowerCase();
|
|
33499
|
+
if (trimmed.startsWith("[")) {
|
|
33500
|
+
const end = trimmed.indexOf("]");
|
|
33501
|
+
if (end === -1) return trimmed;
|
|
33502
|
+
const rest = trimmed.slice(end + 1);
|
|
33503
|
+
if (rest !== "" && !/^:\d+$/.test(rest)) return trimmed;
|
|
33504
|
+
return trimmed.slice(0, end + 1);
|
|
33505
|
+
}
|
|
33506
|
+
const colon = trimmed.lastIndexOf(":");
|
|
33507
|
+
if (colon !== -1 && !trimmed.slice(0, colon).includes(":") && /^\d+$/.test(trimmed.slice(colon + 1))) {
|
|
33508
|
+
return trimmed.slice(0, colon);
|
|
33509
|
+
}
|
|
33510
|
+
return trimmed;
|
|
33511
|
+
}
|
|
33512
|
+
function hostIsLoopback(host) {
|
|
33513
|
+
if (host === void 0 || host.trim() === "") return false;
|
|
33514
|
+
return LOOPBACK_HOSTS.has(hostnameOf(host));
|
|
33515
|
+
}
|
|
33516
|
+
function originIsLoopback(origin) {
|
|
33517
|
+
if (origin === void 0) return true;
|
|
33518
|
+
try {
|
|
33519
|
+
const { hostname: hostname3 } = new URL(origin);
|
|
33520
|
+
return LOOPBACK_HOSTS.has(hostname3) || hostname3 === "::1";
|
|
33521
|
+
} catch {
|
|
33522
|
+
return false;
|
|
33523
|
+
}
|
|
33524
|
+
}
|
|
33525
|
+
function json2(response, status, body) {
|
|
33526
|
+
const payload = JSON.stringify(body);
|
|
33527
|
+
response.writeHead(status, { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(payload) });
|
|
33528
|
+
response.end(payload);
|
|
33529
|
+
}
|
|
33530
|
+
function pairingHandler(options) {
|
|
33531
|
+
return async (request, response) => {
|
|
33532
|
+
if (request.method !== "GET") {
|
|
33533
|
+
json2(response, 405, { error: "method not allowed" });
|
|
33534
|
+
return;
|
|
33535
|
+
}
|
|
33536
|
+
if (!hostIsLoopback(request.headers.host) || !originIsLoopback(request.headers.origin)) {
|
|
33537
|
+
json2(response, 403, { error: "request-not-trusted" });
|
|
33538
|
+
return;
|
|
33539
|
+
}
|
|
33540
|
+
try {
|
|
33541
|
+
const url2 = new URL(request.url ?? "/", "http://dsh.invalid");
|
|
33542
|
+
const sessionId = url2.searchParams.get("session");
|
|
33543
|
+
const snapshot = options.snapshot();
|
|
33544
|
+
if (snapshot.state !== "ready") {
|
|
33545
|
+
json2(response, 200, { state: "none" });
|
|
33546
|
+
return;
|
|
33547
|
+
}
|
|
33548
|
+
if (!isUsableSessionId(sessionId)) {
|
|
33549
|
+
json2(response, 400, { state: "none", error: "session parameter required" });
|
|
33550
|
+
return;
|
|
33551
|
+
}
|
|
33552
|
+
const target = options.target(sessionId);
|
|
33553
|
+
if (!target.persist()) {
|
|
33554
|
+
json2(response, 200, { state: "none" });
|
|
33555
|
+
return;
|
|
33556
|
+
}
|
|
33557
|
+
json2(response, 200, {
|
|
33558
|
+
state: "ready",
|
|
33559
|
+
epoch: snapshot.epoch,
|
|
33560
|
+
address: sessionFileAddress(sessionId, target.file),
|
|
33561
|
+
expiresAt: snapshot.expiresAt
|
|
33562
|
+
});
|
|
33563
|
+
} catch (error62) {
|
|
33564
|
+
json2(response, 500, { error: String(error62?.message ?? error62).slice(0, 200) });
|
|
33565
|
+
}
|
|
33566
|
+
};
|
|
33567
|
+
}
|
|
33568
|
+
function registerPairingRoute(webServer, options) {
|
|
33569
|
+
return webServer.register({ kind: "exact", path: PAIRING_ROUTE, handler: pairingHandler(options) });
|
|
33570
|
+
}
|
|
33571
|
+
|
|
33572
|
+
// src/presentation/sidebar.ts
|
|
33573
|
+
function startSidebarQr(ctx, deps) {
|
|
33574
|
+
const { config: config2, log } = deps;
|
|
33575
|
+
const probe = {};
|
|
33576
|
+
const presenter = new PairingPresenter(liveDeps(log));
|
|
33577
|
+
let web;
|
|
33578
|
+
let timer;
|
|
33579
|
+
let unregister;
|
|
33580
|
+
let started = false;
|
|
33581
|
+
let stopped = false;
|
|
33582
|
+
let written = null;
|
|
33583
|
+
const targetFor = (sessionId) => {
|
|
33584
|
+
let workspace;
|
|
33585
|
+
try {
|
|
33586
|
+
workspace = deps.workspaceOf(sessionId);
|
|
33587
|
+
} catch (error62) {
|
|
33588
|
+
log("\u4F1A\u8BDD\u5DE5\u4F5C\u533A\u89E3\u6790\u5931\u8D25", { message: String(error62?.message ?? error62).slice(0, 160) });
|
|
33589
|
+
workspace = void 0;
|
|
33590
|
+
}
|
|
33591
|
+
const file2 = workspace ? path4.join(workspace, ".dsh", "sidebar-qr.png") : config2.imageFile;
|
|
33592
|
+
return {
|
|
33593
|
+
file: file2,
|
|
33594
|
+
persist: () => {
|
|
33595
|
+
const artifact = presenter.current();
|
|
33596
|
+
if (!artifact) return false;
|
|
33597
|
+
if (written && written.epoch === artifact.epoch && written.file === file2) return true;
|
|
33598
|
+
if (!writePrivatePng(file2, artifact.buffer)) {
|
|
33599
|
+
log("\u4E8C\u7EF4\u7801\u843D\u76D8\u5931\u8D25", { file: file2 });
|
|
33600
|
+
return false;
|
|
33601
|
+
}
|
|
33602
|
+
written = { epoch: artifact.epoch, file: file2 };
|
|
33603
|
+
return true;
|
|
33604
|
+
}
|
|
33605
|
+
};
|
|
33606
|
+
};
|
|
33607
|
+
const tick = async () => {
|
|
33608
|
+
let pairing = null;
|
|
33609
|
+
try {
|
|
33610
|
+
const raw = deps.pairing();
|
|
33611
|
+
pairing = raw && typeof raw === "object" ? raw : null;
|
|
33612
|
+
} catch (error62) {
|
|
33613
|
+
log("read pairing state failed", { message: String(error62?.message ?? error62).slice(0, 160) });
|
|
33614
|
+
return;
|
|
33615
|
+
}
|
|
33616
|
+
try {
|
|
33617
|
+
await presenter.observe(pairing);
|
|
33618
|
+
} catch (error62) {
|
|
33619
|
+
log("observe failed", { message: String(error62?.message ?? error62).slice(0, 160) });
|
|
33620
|
+
}
|
|
33621
|
+
};
|
|
33622
|
+
const tryStart = () => {
|
|
33623
|
+
if (started || stopped || !web) return;
|
|
33624
|
+
started = true;
|
|
33625
|
+
try {
|
|
33626
|
+
unregister = registerPairingRoute(web, {
|
|
33627
|
+
snapshot: () => presenter.snapshot(),
|
|
33628
|
+
target: targetFor
|
|
33629
|
+
});
|
|
33630
|
+
probe.route = "registered";
|
|
33631
|
+
} catch (error62) {
|
|
33632
|
+
probe.route = `register threw: ${String(error62?.message ?? error62).slice(0, 80)}`;
|
|
33633
|
+
log("route registration failed", { message: String(error62?.message ?? error62).slice(0, 200) });
|
|
33634
|
+
started = false;
|
|
33635
|
+
return;
|
|
33636
|
+
}
|
|
33637
|
+
timer = setInterval(() => void tick(), config2.refreshMs);
|
|
33638
|
+
timer.unref?.();
|
|
33639
|
+
void tick();
|
|
33640
|
+
log("sidebar started", { fallbackImageFile: config2.imageFile, refreshMs: config2.refreshMs });
|
|
33641
|
+
};
|
|
33642
|
+
const pickFrom = (source, name) => {
|
|
33643
|
+
if (!source || typeof source !== "object") return void 0;
|
|
33644
|
+
const asContext = source;
|
|
33645
|
+
if (typeof asContext.get === "function") {
|
|
33646
|
+
try {
|
|
33647
|
+
const got = asContext.get(name, true);
|
|
33648
|
+
if (got) return got;
|
|
33649
|
+
} catch {
|
|
33650
|
+
}
|
|
33651
|
+
}
|
|
33652
|
+
try {
|
|
33653
|
+
return source[name];
|
|
33654
|
+
} catch {
|
|
33655
|
+
return void 0;
|
|
33656
|
+
}
|
|
33657
|
+
};
|
|
33658
|
+
const acceptWebServer = (value, via) => {
|
|
33659
|
+
if (!value || typeof value !== "object") return false;
|
|
33660
|
+
if (typeof value.register !== "function") {
|
|
33661
|
+
probe.webServer = "object without register()";
|
|
33662
|
+
return false;
|
|
33663
|
+
}
|
|
33664
|
+
web = value;
|
|
33665
|
+
probe.webServer = via;
|
|
33666
|
+
tryStart();
|
|
33667
|
+
return true;
|
|
33668
|
+
};
|
|
33669
|
+
if (!config2.enabled) {
|
|
33670
|
+
probe.sidebar = "disabled";
|
|
33671
|
+
} else {
|
|
33672
|
+
try {
|
|
33673
|
+
const found = ctx.get?.("webServer", true);
|
|
33674
|
+
if (found) acceptWebServer(found, "via get");
|
|
33675
|
+
else probe.webServer = "none";
|
|
33676
|
+
} catch (error62) {
|
|
33677
|
+
probe.webServer = `get threw: ${String(error62?.message ?? error62).slice(0, 80)}`;
|
|
33678
|
+
}
|
|
33679
|
+
try {
|
|
33680
|
+
ctx.inject?.(["webServer"], ((...args) => {
|
|
33681
|
+
try {
|
|
33682
|
+
let value;
|
|
33683
|
+
for (const candidate of [args[0], ...args, ctx]) {
|
|
33684
|
+
value = pickFrom(candidate, "webServer");
|
|
33685
|
+
if (value) break;
|
|
33686
|
+
}
|
|
33687
|
+
if (acceptWebServer(value, "via inject")) return;
|
|
33688
|
+
probe.webServer = `${probe.webServer ?? "none"} (inject fired, empty)`;
|
|
33689
|
+
} catch (error62) {
|
|
33690
|
+
probe["injectThrew:webServer"] = String(error62?.message ?? error62).slice(0, 160);
|
|
33691
|
+
}
|
|
33692
|
+
}));
|
|
33693
|
+
} catch (error62) {
|
|
33694
|
+
probe["injectThrew:webServer"] = String(error62?.message ?? error62).slice(0, 160);
|
|
33695
|
+
}
|
|
33696
|
+
}
|
|
33697
|
+
const stop = () => {
|
|
33698
|
+
if (stopped) return;
|
|
33699
|
+
stopped = true;
|
|
33700
|
+
if (timer !== void 0) {
|
|
33701
|
+
clearInterval(timer);
|
|
33702
|
+
timer = void 0;
|
|
33703
|
+
}
|
|
33704
|
+
try {
|
|
33705
|
+
unregister?.();
|
|
33706
|
+
} catch {
|
|
33707
|
+
}
|
|
33708
|
+
unregister = void 0;
|
|
33709
|
+
if (started) log("sidebar stopped");
|
|
33710
|
+
};
|
|
33711
|
+
return { stop, probe };
|
|
33712
|
+
}
|
|
33713
|
+
|
|
33334
33714
|
// src/index.ts
|
|
33335
33715
|
var SERVICE_NAMES = [
|
|
33336
33716
|
"sessions",
|
|
@@ -33427,6 +33807,7 @@ function applyInner(ctx, injected) {
|
|
|
33427
33807
|
let runtime;
|
|
33428
33808
|
let relay;
|
|
33429
33809
|
let startedCarrier = "";
|
|
33810
|
+
let sidebar;
|
|
33430
33811
|
let lastRelayState = "connecting";
|
|
33431
33812
|
let lastRelayProblem;
|
|
33432
33813
|
let lastRelayGeneration = 0;
|
|
@@ -33531,6 +33912,8 @@ function applyInner(ctx, injected) {
|
|
|
33531
33912
|
// 出站计数:手机上"没收到 X"的第一现场对比点(插件没发 vs 发了但路上丢了)。
|
|
33532
33913
|
outbound: runtime?.stats ?? null,
|
|
33533
33914
|
probe,
|
|
33915
|
+
// 右栏那一半为什么没起,是"二维码不弹"唯一的排查入口:这里直接把软探测的结果带出来。
|
|
33916
|
+
sidebar: sidebar?.probe ?? { webServer: "not-started" },
|
|
33534
33917
|
// token 永远不出现真值;这条有测试锁住。
|
|
33535
33918
|
hostToken: void 0,
|
|
33536
33919
|
hostTokenShape: config2.hostToken ? redactSecret(config2.hostToken) : void 0,
|
|
@@ -33913,6 +34296,25 @@ function applyInner(ctx, injected) {
|
|
|
33913
34296
|
if (child !== void 0) injectChildren.push(["commands", child]);
|
|
33914
34297
|
} catch {
|
|
33915
34298
|
}
|
|
34299
|
+
try {
|
|
34300
|
+
sidebar = startSidebarQr(ctx, {
|
|
34301
|
+
config: config2.sidebarQr,
|
|
34302
|
+
pairing: () => describeActivePairing(),
|
|
34303
|
+
workspaceOf(sessionId) {
|
|
34304
|
+
try {
|
|
34305
|
+
return kernel?.sessionWorkspace?.(sessionId);
|
|
34306
|
+
} catch {
|
|
34307
|
+
return void 0;
|
|
34308
|
+
}
|
|
34309
|
+
},
|
|
34310
|
+
log
|
|
34311
|
+
});
|
|
34312
|
+
} catch (error62) {
|
|
34313
|
+
sidebar = void 0;
|
|
34314
|
+
log("sidebar start threw\uFF08\u914D\u5BF9\u94FE\u8DEF\u4E0D\u53D7\u5F71\u54CD\uFF09", {
|
|
34315
|
+
message: String(error62?.message ?? error62).slice(0, 200)
|
|
34316
|
+
});
|
|
34317
|
+
}
|
|
33916
34318
|
return {
|
|
33917
34319
|
config: config2,
|
|
33918
34320
|
state,
|
|
@@ -33926,6 +34328,7 @@ function applyInner(ctx, injected) {
|
|
|
33926
34328
|
},
|
|
33927
34329
|
stop() {
|
|
33928
34330
|
oneShot.cancelAll();
|
|
34331
|
+
sidebar?.stop();
|
|
33929
34332
|
status.stop();
|
|
33930
34333
|
runtime?.stop();
|
|
33931
34334
|
relay?.stop();
|