@tonyclaw/agent-inspector 4.0.8 → 4.0.9
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +915 -25970
- package/.output/server/_chunks/ssr-renderer.mjs +1 -38
- package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +1 -2658
- package/.output/server/_libs/agent-base.mjs +2 -234
- package/.output/server/_libs/ajv-formats.mjs +1 -330
- package/.output/server/_libs/ajv.mjs +8 -6080
- package/.output/server/_libs/anthropic-ai__sdk.mjs +19 -6021
- package/.output/server/_libs/atomically.mjs +1 -155
- package/.output/server/_libs/base64-js.mjs +1 -102
- package/.output/server/_libs/bignumber.js.mjs +1 -1353
- package/.output/server/_libs/buffer-equal-constant-time.mjs +1 -38
- package/.output/server/_libs/conf.mjs +1 -635
- package/.output/server/_libs/cookie-es.mjs +1 -44
- package/.output/server/_libs/core-util-is.mjs +1 -75
- package/.output/server/_libs/data-uri-to-buffer.mjs +1 -39
- package/.output/server/_libs/debounce-fn.mjs +1 -69
- package/.output/server/_libs/debug.mjs +5 -547
- package/.output/server/_libs/dot-prop.mjs +1 -265
- package/.output/server/_libs/ecdsa-sig-formatter.mjs +1 -162
- package/.output/server/_libs/env-paths.mjs +1 -57
- package/.output/server/_libs/extend.mjs +1 -94
- package/.output/server/_libs/fast-deep-equal.mjs +1 -38
- package/.output/server/_libs/fast-uri.mjs +1 -812
- package/.output/server/_libs/fetch-blob.mjs +1 -287
- package/.output/server/_libs/formdata-polyfill.mjs +9 -86
- package/.output/server/_libs/gaxios.mjs +5 -926
- package/.output/server/_libs/gcp-metadata.mjs +1 -322
- package/.output/server/_libs/google-auth-library.mjs +16 -6339
- package/.output/server/_libs/google-logging-utils.mjs +1 -385
- package/.output/server/_libs/google__genai.mjs +13 -18034
- package/.output/server/_libs/h3-v2.mjs +2 -287
- package/.output/server/_libs/h3.mjs +2 -408
- package/.output/server/_libs/has-flag.mjs +1 -16
- package/.output/server/_libs/https-proxy-agent.mjs +7 -280
- package/.output/server/_libs/immediate.mjs +1 -74
- package/.output/server/_libs/inherits.mjs +1 -50
- package/.output/server/_libs/isarray.mjs +1 -14
- package/.output/server/_libs/isbot.mjs +1 -20
- package/.output/server/_libs/json-bigint.mjs +8 -413
- package/.output/server/_libs/json-schema-traverse.mjs +1 -91
- package/.output/server/_libs/jszip.mjs +2 -3051
- package/.output/server/_libs/jwa.mjs +3 -233
- package/.output/server/_libs/jws.mjs +1 -298
- package/.output/server/_libs/lie.mjs +1 -273
- package/.output/server/_libs/mariozechner__pi-agent-core.mjs +1 -824
- package/.output/server/_libs/mariozechner__pi-ai.mjs +34 -22887
- package/.output/server/_libs/mimic-function.mjs +2 -47
- package/.output/server/_libs/mistralai__mistralai.mjs +7 -32045
- package/.output/server/_libs/modelcontextprotocol__core.mjs +1 -1121
- package/.output/server/_libs/modelcontextprotocol__server.mjs +13 -13205
- package/.output/server/_libs/ms.mjs +1 -120
- package/.output/server/_libs/node-domexception.mjs +1 -17
- package/.output/server/_libs/node-fetch.mjs +4 -1578
- package/.output/server/_libs/ohash.mjs +1 -1
- package/.output/server/_libs/openai.mjs +23 -6766
- package/.output/server/_libs/opentelemetry__api.mjs +1 -1678
- package/.output/server/_libs/p-retry.mjs +1 -87
- package/.output/server/_libs/pako.mjs +1 -4223
- package/.output/server/_libs/partial-json.mjs +2 -244
- package/.output/server/_libs/process-nextick-args.mjs +1 -48
- package/.output/server/_libs/react-dom.mjs +62 -10778
- package/.output/server/_libs/react.mjs +1 -519
- package/.output/server/_libs/readable-stream.mjs +1 -1518
- package/.output/server/_libs/retry.mjs +1 -236
- package/.output/server/_libs/rou3.mjs +1 -14
- package/.output/server/_libs/safe-buffer.mjs +1 -126
- package/.output/server/_libs/semver.mjs +1 -1938
- package/.output/server/_libs/seroval-plugins.mjs +1 -58
- package/.output/server/_libs/seroval.mjs +3 -1775
- package/.output/server/_libs/setimmediate.mjs +1 -152
- package/.output/server/_libs/srvx.mjs +4 -1390
- package/.output/server/_libs/stubborn-fs.mjs +1 -91
- package/.output/server/_libs/stubborn-utils.mjs +1 -66
- package/.output/server/_libs/supports-color.mjs +1 -108
- package/.output/server/_libs/tanstack__history.mjs +1 -230
- package/.output/server/_libs/tanstack__react-router.mjs +1 -848
- package/.output/server/_libs/tanstack__react-store.mjs +1 -1
- package/.output/server/_libs/tanstack__router-core.mjs +1 -4839
- package/.output/server/_libs/typebox.mjs +3 -6596
- package/.output/server/_libs/ufo.mjs +1 -54
- package/.output/server/_libs/uint8array-extras.mjs +1 -69
- package/.output/server/_libs/util-deprecate.mjs +1 -12
- package/.output/server/_libs/web-streams-polyfill.mjs +1 -4282
- package/.output/server/_libs/when-exit.mjs +1 -53
- package/.output/server/_libs/ws.mjs +7 -3715
- package/.output/server/_libs/zod-to-json-schema.mjs +5 -1207
- package/.output/server/_libs/zod.mjs +59 -9958
- package/.output/server/_ssr/empty-plugin-adapters-C3Q1xu4u.mjs +1 -0
- package/.output/server/_ssr/index.mjs +2 -1512
- package/.output/server/_ssr/publicBasePathContext--TAQS2_5.mjs +1 -0
- package/.output/server/_ssr/router-zSWaME0l.mjs +341 -0
- package/.output/server/_ssr/start-PDVGOqUN.mjs +1 -0
- package/.output/server/_tanstack-start-manifest_v-D7cKwKzM.mjs +1 -0
- package/.output/server/index.mjs +1 -320
- package/.output/ui/assets/{CompareDrawer-DafpfgaT.js → CompareDrawer-C6KvvPtJ.js} +1 -1
- package/.output/ui/assets/{InspectorPet-Brsmmfzx.js → InspectorPet-CSH6OAhB.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-D2pq1fUr.js → ProxyViewerContainer-vPd7g0Xn.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-D4mXXgT9.js → ReplayDialog-DbXUcT39.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-Ccnsq12U.js → RequestAnatomy-BWOCIN7J.js} +1 -1
- package/.output/ui/assets/{ResponseView-CJv3vB5X.js → ResponseView-BqDbTzFs.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-CEkLnOF6.js → StreamingChunkSequence-UHl2g6w6.js} +1 -1
- package/.output/ui/assets/{_sessionId-DlG-yHoI.js → _sessionId-B2S61lDJ.js} +1 -1
- package/.output/ui/assets/{_sessionId-C7s68UH3.js → _sessionId-CS6hqj8-.js} +1 -1
- package/.output/ui/assets/{index-Cqh47jeU.js → index-C6V66rNI.js} +1 -1
- package/.output/ui/assets/{index-CFqnSirZ.js → index-DY5xBYHr.js} +1 -1
- package/.output/ui/assets/{index-B0NCZQ93.js → index-DgyIeqyV.js} +2 -2
- package/.output/ui/assets/{index-ChZZrVHa.js → index-HLs5jTyi.js} +1 -1
- package/.output/ui/assets/{json-viewer-DvpI0vbY.js → json-viewer-i5LcN8e7.js} +1 -1
- package/.output/ui/assets/{jszip.min-5AG8hW2c.js → jszip.min-yNpb9qnf.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/.output/workers/logFinalizer.worker.js +41 -17739
- package/.output/workers/sessionWorkerEntry.js +41 -17735
- package/package.json +7 -7
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
- package/.output/server/_ssr/publicBasePathContext-IH2ilOfu.mjs +0 -176
- package/.output/server/_ssr/router-BDyF-OMB.mjs +0 -27187
- package/.output/server/_ssr/start-COQu_AgD.mjs +0 -57
- package/.output/server/_tanstack-start-manifest_v-ClTaMkEj.mjs +0 -4
|
@@ -1,287 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function decodePathname(pathname) {
|
|
4
|
-
return decodeURI(pathname.includes("%25") ? pathname.replace(/%25/g, "%2525") : pathname);
|
|
5
|
-
}
|
|
6
|
-
const kEventNS = "h3.internal.event.";
|
|
7
|
-
const kEventRes = /* @__PURE__ */ Symbol.for(`${kEventNS}res`);
|
|
8
|
-
const kEventResHeaders = /* @__PURE__ */ Symbol.for(`${kEventNS}res.headers`);
|
|
9
|
-
const kEventResErrHeaders = /* @__PURE__ */ Symbol.for(`${kEventNS}res.err.headers`);
|
|
10
|
-
var H3Event = class {
|
|
11
|
-
app;
|
|
12
|
-
req;
|
|
13
|
-
url;
|
|
14
|
-
context;
|
|
15
|
-
static __is_event__ = true;
|
|
16
|
-
constructor(req, context, app) {
|
|
17
|
-
this.context = context || req.context || new NullProtoObj();
|
|
18
|
-
this.req = req;
|
|
19
|
-
this.app = app;
|
|
20
|
-
const _url = req._url;
|
|
21
|
-
const url = _url && _url instanceof URL ? _url : new FastURL(req.url);
|
|
22
|
-
if (url.pathname.includes("%")) url.pathname = decodePathname(url.pathname);
|
|
23
|
-
this.url = url;
|
|
24
|
-
}
|
|
25
|
-
get res() {
|
|
26
|
-
return this[kEventRes] ||= new H3EventResponse();
|
|
27
|
-
}
|
|
28
|
-
get runtime() {
|
|
29
|
-
return this.req.runtime;
|
|
30
|
-
}
|
|
31
|
-
waitUntil(promise) {
|
|
32
|
-
this.req.waitUntil?.(promise);
|
|
33
|
-
}
|
|
34
|
-
toString() {
|
|
35
|
-
return `[${this.req.method}] ${this.req.url}`;
|
|
36
|
-
}
|
|
37
|
-
toJSON() {
|
|
38
|
-
return this.toString();
|
|
39
|
-
}
|
|
40
|
-
get node() {
|
|
41
|
-
return this.req.runtime?.node;
|
|
42
|
-
}
|
|
43
|
-
get headers() {
|
|
44
|
-
return this.req.headers;
|
|
45
|
-
}
|
|
46
|
-
get path() {
|
|
47
|
-
return this.url.pathname + this.url.search;
|
|
48
|
-
}
|
|
49
|
-
get method() {
|
|
50
|
-
return this.req.method;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var H3EventResponse = class {
|
|
54
|
-
status;
|
|
55
|
-
statusText;
|
|
56
|
-
get headers() {
|
|
57
|
-
return this[kEventResHeaders] ||= new Headers();
|
|
58
|
-
}
|
|
59
|
-
get errHeaders() {
|
|
60
|
-
return this[kEventResErrHeaders] ||= new Headers();
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const DISALLOWED_STATUS_CHARS = /[^\u0009\u0020-\u007E]/g;
|
|
64
|
-
function sanitizeStatusMessage(statusMessage = "") {
|
|
65
|
-
return statusMessage.replace(DISALLOWED_STATUS_CHARS, "");
|
|
66
|
-
}
|
|
67
|
-
function sanitizeStatusCode(statusCode, defaultStatusCode = 200) {
|
|
68
|
-
if (!statusCode) return defaultStatusCode;
|
|
69
|
-
if (typeof statusCode === "string") statusCode = +statusCode;
|
|
70
|
-
if (statusCode < 100 || statusCode > 599) return defaultStatusCode;
|
|
71
|
-
return statusCode;
|
|
72
|
-
}
|
|
73
|
-
var HTTPError = class HTTPError2 extends Error {
|
|
74
|
-
get name() {
|
|
75
|
-
return "HTTPError";
|
|
76
|
-
}
|
|
77
|
-
status;
|
|
78
|
-
statusText;
|
|
79
|
-
headers;
|
|
80
|
-
cause;
|
|
81
|
-
data;
|
|
82
|
-
body;
|
|
83
|
-
unhandled;
|
|
84
|
-
static isError(input) {
|
|
85
|
-
return input instanceof Error && input?.name === "HTTPError";
|
|
86
|
-
}
|
|
87
|
-
static status(status, statusText, details) {
|
|
88
|
-
return new HTTPError2({
|
|
89
|
-
...details,
|
|
90
|
-
statusText,
|
|
91
|
-
status
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
constructor(arg1, arg2) {
|
|
95
|
-
let messageInput;
|
|
96
|
-
let details;
|
|
97
|
-
if (typeof arg1 === "string") {
|
|
98
|
-
messageInput = arg1;
|
|
99
|
-
details = arg2;
|
|
100
|
-
} else details = arg1;
|
|
101
|
-
const status = sanitizeStatusCode(details?.status || details?.statusCode || details?.cause?.status || details?.cause?.statusCode, 500);
|
|
102
|
-
const statusText = sanitizeStatusMessage(details?.statusText || details?.statusMessage || details?.cause?.statusText || details?.cause?.statusMessage);
|
|
103
|
-
const message = messageInput || details?.message || details?.cause?.message || details?.statusText || details?.statusMessage || [
|
|
104
|
-
"HTTPError",
|
|
105
|
-
status,
|
|
106
|
-
statusText
|
|
107
|
-
].filter(Boolean).join(" ");
|
|
108
|
-
super(message, { cause: details });
|
|
109
|
-
this.cause = details;
|
|
110
|
-
this.status = status;
|
|
111
|
-
this.statusText = statusText || void 0;
|
|
112
|
-
const rawHeaders = details?.headers || details?.cause?.headers;
|
|
113
|
-
this.headers = rawHeaders ? new Headers(rawHeaders) : void 0;
|
|
114
|
-
this.unhandled = details?.unhandled ?? details?.cause?.unhandled ?? void 0;
|
|
115
|
-
this.data = details?.data;
|
|
116
|
-
this.body = details?.body;
|
|
117
|
-
}
|
|
118
|
-
get statusCode() {
|
|
119
|
-
return this.status;
|
|
120
|
-
}
|
|
121
|
-
get statusMessage() {
|
|
122
|
-
return this.statusText;
|
|
123
|
-
}
|
|
124
|
-
toJSON() {
|
|
125
|
-
const unhandled = this.unhandled;
|
|
126
|
-
return {
|
|
127
|
-
status: this.status,
|
|
128
|
-
statusText: this.statusText,
|
|
129
|
-
unhandled,
|
|
130
|
-
message: unhandled ? "HTTPError" : this.message,
|
|
131
|
-
data: unhandled ? void 0 : this.data,
|
|
132
|
-
...unhandled ? void 0 : this.body
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
function isJSONSerializable(value, _type) {
|
|
137
|
-
if (value === null || value === void 0) return true;
|
|
138
|
-
if (_type !== "object") return _type === "boolean" || _type === "number" || _type === "string";
|
|
139
|
-
if (typeof value.toJSON === "function") return true;
|
|
140
|
-
if (Array.isArray(value)) return true;
|
|
141
|
-
if (typeof value.pipe === "function" || typeof value.pipeTo === "function") return false;
|
|
142
|
-
if (value instanceof NullProtoObj) return true;
|
|
143
|
-
const proto = Object.getPrototypeOf(value);
|
|
144
|
-
return proto === Object.prototype || proto === null;
|
|
145
|
-
}
|
|
146
|
-
const kNotFound = /* @__PURE__ */ Symbol.for("h3.notFound");
|
|
147
|
-
const kHandled = /* @__PURE__ */ Symbol.for("h3.handled");
|
|
148
|
-
function toResponse(val, event, config = {}) {
|
|
149
|
-
if (typeof val?.then === "function") return (val.catch?.((error) => error) || Promise.resolve(val)).then((resolvedVal) => toResponse(resolvedVal, event, config));
|
|
150
|
-
const response = prepareResponse(val, event, config);
|
|
151
|
-
if (typeof response?.then === "function") return toResponse(response, event, config);
|
|
152
|
-
const { onResponse } = config;
|
|
153
|
-
return onResponse ? Promise.resolve(onResponse(response, event)).then(() => response) : response;
|
|
154
|
-
}
|
|
155
|
-
var HTTPResponse = class {
|
|
156
|
-
#headers;
|
|
157
|
-
#init;
|
|
158
|
-
body;
|
|
159
|
-
constructor(body, init) {
|
|
160
|
-
this.body = body;
|
|
161
|
-
this.#init = init;
|
|
162
|
-
}
|
|
163
|
-
get status() {
|
|
164
|
-
return this.#init?.status || 200;
|
|
165
|
-
}
|
|
166
|
-
get statusText() {
|
|
167
|
-
return this.#init?.statusText || "OK";
|
|
168
|
-
}
|
|
169
|
-
get headers() {
|
|
170
|
-
return this.#headers ||= new Headers(this.#init?.headers);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
function prepareResponse(val, event, config, nested) {
|
|
174
|
-
if (val === kHandled) return new NodeResponse(null);
|
|
175
|
-
if (val === kNotFound) val = new HTTPError({
|
|
176
|
-
status: 404,
|
|
177
|
-
message: `Cannot find any route matching [${event.req.method}] ${event.url}`
|
|
178
|
-
});
|
|
179
|
-
if (val && val instanceof Error) {
|
|
180
|
-
const isHTTPError = HTTPError.isError(val);
|
|
181
|
-
const error = isHTTPError ? val : new HTTPError(val);
|
|
182
|
-
if (!isHTTPError) {
|
|
183
|
-
error.unhandled = true;
|
|
184
|
-
if (val?.stack) error.stack = val.stack;
|
|
185
|
-
}
|
|
186
|
-
if (error.unhandled && !config.silent) console.error(error);
|
|
187
|
-
const { onError } = config;
|
|
188
|
-
const errHeaders = event[kEventRes]?.[kEventResErrHeaders];
|
|
189
|
-
return onError && !nested ? Promise.resolve(onError(error, event)).catch((error2) => error2).then((newVal) => prepareResponse(newVal ?? val, event, config, true)) : errorResponse(error, config.debug, errHeaders);
|
|
190
|
-
}
|
|
191
|
-
const preparedRes = event[kEventRes];
|
|
192
|
-
const preparedHeaders = preparedRes?.[kEventResHeaders];
|
|
193
|
-
event[kEventRes] = void 0;
|
|
194
|
-
if (!(val instanceof Response)) {
|
|
195
|
-
const res = prepareResponseBody(val, event, config);
|
|
196
|
-
const status = res.status || preparedRes?.status;
|
|
197
|
-
return new NodeResponse(nullBody(event.req.method, status) ? null : res.body, {
|
|
198
|
-
status,
|
|
199
|
-
statusText: res.statusText || preparedRes?.statusText,
|
|
200
|
-
headers: res.headers && preparedHeaders ? mergeHeaders$1(res.headers, preparedHeaders) : res.headers || preparedHeaders
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
if (!preparedHeaders || nested || !val.ok) return val;
|
|
204
|
-
try {
|
|
205
|
-
mergeHeaders$1(val.headers, preparedHeaders, val.headers);
|
|
206
|
-
return val;
|
|
207
|
-
} catch {
|
|
208
|
-
return new NodeResponse(nullBody(event.req.method, val.status) ? null : val.body, {
|
|
209
|
-
status: val.status,
|
|
210
|
-
statusText: val.statusText,
|
|
211
|
-
headers: mergeHeaders$1(val.headers, preparedHeaders)
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function mergeHeaders$1(base, overrides, target = new Headers(base)) {
|
|
216
|
-
for (const [name, value] of overrides) if (name === "set-cookie") target.append(name, value);
|
|
217
|
-
else target.set(name, value);
|
|
218
|
-
return target;
|
|
219
|
-
}
|
|
220
|
-
const frozen = (name) => (...args) => {
|
|
221
|
-
throw new Error(`Headers are frozen (${name} ${args.join(", ")})`);
|
|
222
|
-
};
|
|
223
|
-
var FrozenHeaders = class extends Headers {
|
|
224
|
-
set = frozen("set");
|
|
225
|
-
append = frozen("append");
|
|
226
|
-
delete = frozen("delete");
|
|
227
|
-
};
|
|
228
|
-
const emptyHeaders = /* @__PURE__ */ new FrozenHeaders({ "content-length": "0" });
|
|
229
|
-
const jsonHeaders = /* @__PURE__ */ new FrozenHeaders({ "content-type": "application/json;charset=UTF-8" });
|
|
230
|
-
function prepareResponseBody(val, event, config) {
|
|
231
|
-
if (val === null || val === void 0) return {
|
|
232
|
-
body: "",
|
|
233
|
-
headers: emptyHeaders
|
|
234
|
-
};
|
|
235
|
-
const valType = typeof val;
|
|
236
|
-
if (valType === "string") return { body: val };
|
|
237
|
-
if (val instanceof Uint8Array) {
|
|
238
|
-
event.res.headers.set("content-length", val.byteLength.toString());
|
|
239
|
-
return { body: val };
|
|
240
|
-
}
|
|
241
|
-
if (val instanceof HTTPResponse || val?.constructor?.name === "HTTPResponse") return val;
|
|
242
|
-
if (isJSONSerializable(val, valType)) return {
|
|
243
|
-
body: JSON.stringify(val, void 0, config.debug ? 2 : void 0),
|
|
244
|
-
headers: jsonHeaders
|
|
245
|
-
};
|
|
246
|
-
if (valType === "bigint") return {
|
|
247
|
-
body: val.toString(),
|
|
248
|
-
headers: jsonHeaders
|
|
249
|
-
};
|
|
250
|
-
if (val instanceof Blob) {
|
|
251
|
-
const headers = new Headers({
|
|
252
|
-
"content-type": val.type,
|
|
253
|
-
"content-length": val.size.toString()
|
|
254
|
-
});
|
|
255
|
-
let filename = val.name;
|
|
256
|
-
if (filename) {
|
|
257
|
-
filename = encodeURIComponent(filename);
|
|
258
|
-
headers.set("content-disposition", `filename="${filename}"; filename*=UTF-8''${filename}`);
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
body: val.stream(),
|
|
262
|
-
headers
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
if (valType === "symbol") return { body: val.toString() };
|
|
266
|
-
if (valType === "function") return { body: `${val.name}()` };
|
|
267
|
-
return { body: val };
|
|
268
|
-
}
|
|
269
|
-
function nullBody(method, status) {
|
|
270
|
-
return method === "HEAD" || status === 100 || status === 101 || status === 102 || status === 204 || status === 205 || status === 304;
|
|
271
|
-
}
|
|
272
|
-
function errorResponse(error, debug, errHeaders) {
|
|
273
|
-
let headers = error.headers ? mergeHeaders$1(jsonHeaders, error.headers) : new Headers(jsonHeaders);
|
|
274
|
-
if (errHeaders) headers = mergeHeaders$1(headers, errHeaders);
|
|
275
|
-
return new NodeResponse(JSON.stringify({
|
|
276
|
-
...error.toJSON(),
|
|
277
|
-
stack: debug && error.stack ? error.stack.split("\n").map((l) => l.trim()) : void 0
|
|
278
|
-
}, void 0, debug ? 2 : void 0), {
|
|
279
|
-
status: error.status,
|
|
280
|
-
statusText: error.statusText,
|
|
281
|
-
headers
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
export {
|
|
285
|
-
H3Event as H,
|
|
286
|
-
toResponse as t
|
|
287
|
-
};
|
|
1
|
+
import{a as H}from"./rou3.mjs";import{a as P,b as c}from"./srvx.mjs";function k(e){return decodeURI(e.includes("%25")?e.replace(/%25/g,"%2525"):e)}const T="h3.internal.event.",h=Symbol.for(`${T}res`),l=Symbol.for(`${T}res.headers`),x=Symbol.for(`${T}res.err.headers`);var B=class{app;req;url;context;static __is_event__=!0;constructor(e,t,n){this.context=t||e.context||new H,this.req=e,this.app=n;const r=e._url,s=r&&r instanceof URL?r:new P(e.url);s.pathname.includes("%")&&(s.pathname=k(s.pathname)),this.url=s}get res(){return this[h]||=new O}get runtime(){return this.req.runtime}waitUntil(e){this.req.waitUntil?.(e)}toString(){return`[${this.req.method}] ${this.req.url}`}toJSON(){return this.toString()}get node(){return this.req.runtime?.node}get headers(){return this.req.headers}get path(){return this.url.pathname+this.url.search}get method(){return this.req.method}},O=class{status;statusText;get headers(){return this[l]||=new Headers}get errHeaders(){return this[x]||=new Headers}};const $=/[^\u0009\u0020-\u007E]/g;function N(e=""){return e.replace($,"")}function U(e,t=200){return!e||(typeof e=="string"&&(e=+e),e<100||e>599)?t:e}var m=class S extends Error{get name(){return"HTTPError"}status;statusText;headers;cause;data;body;unhandled;static isError(t){return t instanceof Error&&t?.name==="HTTPError"}static status(t,n,r){return new S({...r,statusText:n,status:t})}constructor(t,n){let r,s;typeof t=="string"?(r=t,s=n):s=t;const o=U(s?.status||s?.statusCode||s?.cause?.status||s?.cause?.statusCode,500),i=N(s?.statusText||s?.statusMessage||s?.cause?.statusText||s?.cause?.statusMessage),a=r||s?.message||s?.cause?.message||s?.statusText||s?.statusMessage||["HTTPError",o,i].filter(Boolean).join(" ");super(a,{cause:s}),this.cause=s,this.status=o,this.statusText=i||void 0;const u=s?.headers||s?.cause?.headers;this.headers=u?new Headers(u):void 0,this.unhandled=s?.unhandled??s?.cause?.unhandled??void 0,this.data=s?.data,this.body=s?.body}get statusCode(){return this.status}get statusMessage(){return this.statusText}toJSON(){const t=this.unhandled;return{status:this.status,statusText:this.statusText,unhandled:t,message:t?"HTTPError":this.message,data:t?void 0:this.data,...t?void 0:this.body}}};function q(e,t){if(e==null)return!0;if(t!=="object")return t==="boolean"||t==="number"||t==="string";if(typeof e.toJSON=="function"||Array.isArray(e))return!0;if(typeof e.pipe=="function"||typeof e.pipeTo=="function")return!1;if(e instanceof H)return!0;const n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}const j=Symbol.for("h3.notFound"),z=Symbol.for("h3.handled");function g(e,t,n={}){if(typeof e?.then=="function")return(e.catch?.(o=>o)||Promise.resolve(e)).then(o=>g(o,t,n));const r=w(e,t,n);if(typeof r?.then=="function")return g(r,t,n);const{onResponse:s}=n;return s?Promise.resolve(s(r,t)).then(()=>r):r}var A=class{#t;#e;body;constructor(e,t){this.body=e,this.#e=t}get status(){return this.#e?.status||200}get statusText(){return this.#e?.statusText||"OK"}get headers(){return this.#t||=new Headers(this.#e?.headers)}};function w(e,t,n,r){if(e===z)return new c(null);if(e===j&&(e=new m({status:404,message:`Cannot find any route matching [${t.req.method}] ${t.url}`})),e&&e instanceof Error){const i=m.isError(e),a=i?e:new m(e);i||(a.unhandled=!0,e?.stack&&(a.stack=e.stack)),a.unhandled&&!n.silent&&console.error(a);const{onError:u}=n,R=t[h]?.[x];return u&&!r?Promise.resolve(u(a,t)).catch(p=>p).then(p=>w(p??e,t,n,!0)):L(a,n.debug,R)}const s=t[h],o=s?.[l];if(t[h]=void 0,!(e instanceof Response)){const i=F(e,t,n),a=i.status||s?.status;return new c(b(t.req.method,a)?null:i.body,{status:a,statusText:i.statusText||s?.statusText,headers:i.headers&&o?d(i.headers,o):i.headers||o})}if(!o||r||!e.ok)return e;try{return d(e.headers,o,e.headers),e}catch{return new c(b(t.req.method,e.status)?null:e.body,{status:e.status,statusText:e.statusText,headers:d(e.headers,o)})}}function d(e,t,n=new Headers(e)){for(const[r,s]of t)r==="set-cookie"?n.append(r,s):n.set(r,s);return n}const y=e=>(...t)=>{throw new Error(`Headers are frozen (${e} ${t.join(", ")})`)};var E=class extends Headers{set=y("set");append=y("append");delete=y("delete")};const J=new E({"content-length":"0"}),f=new E({"content-type":"application/json;charset=UTF-8"});function F(e,t,n){if(e==null)return{body:"",headers:J};const r=typeof e;if(r==="string")return{body:e};if(e instanceof Uint8Array)return t.res.headers.set("content-length",e.byteLength.toString()),{body:e};if(e instanceof A||e?.constructor?.name==="HTTPResponse")return e;if(q(e,r))return{body:JSON.stringify(e,void 0,n.debug?2:void 0),headers:f};if(r==="bigint")return{body:e.toString(),headers:f};if(e instanceof Blob){const s=new Headers({"content-type":e.type,"content-length":e.size.toString()});let o=e.name;return o&&(o=encodeURIComponent(o),s.set("content-disposition",`filename="${o}"; filename*=UTF-8''${o}`)),{body:e.stream(),headers:s}}return r==="symbol"?{body:e.toString()}:r==="function"?{body:`${e.name}()`}:{body:e}}function b(e,t){return e==="HEAD"||t===100||t===101||t===102||t===204||t===205||t===304}function L(e,t,n){let r=e.headers?d(f,e.headers):new Headers(f);return n&&(r=d(r,n)),new c(JSON.stringify({...e.toJSON(),stack:t&&e.stack?e.stack.split(`
|
|
2
|
+
`).map(s=>s.trim()):void 0},void 0,t?2:void 0),{status:e.status,statusText:e.statusText,headers:r})}export{B as H,g as t};
|