@tonyclaw/agent-inspector 3.0.15 → 3.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-UaIxykqz.js → CompareDrawer-Lx-WeJNC.js} +1 -1
  3. package/.output/public/assets/{ProxyViewerContainer-DlpfcX56.js → ProxyViewerContainer-BNehwMI0.js} +31 -31
  4. package/.output/public/assets/{ReplayDialog-BFFomU1m.js → ReplayDialog-CADaXFPE.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-DKQJBt_c.js → RequestAnatomy-CGoL8ACh.js} +1 -1
  6. package/.output/public/assets/{ResponseView-D7yotmne.js → ResponseView-BSwM1dCH.js} +2 -2
  7. package/.output/public/assets/{StreamingChunkSequence-Da-6WNFG.js → StreamingChunkSequence-qhWtSx3D.js} +1 -1
  8. package/.output/public/assets/{_sessionId-ByTXLS-w.js → _sessionId-2uq_HB8p.js} +1 -1
  9. package/.output/public/assets/index-BHXN1Fsx.css +1 -0
  10. package/.output/public/assets/{index-BrM8t5mc.js → index-DPc2wzgW.js} +1 -1
  11. package/.output/public/assets/index-T0u1foYL.js +1 -0
  12. package/.output/public/assets/{json-viewer-DyjXQdVu.js → json-viewer-uIwLntt-.js} +1 -1
  13. package/.output/public/assets/{main-Zv_gjZMb.js → main-DuFBHsus.js} +7 -7
  14. package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +2658 -0
  15. package/.output/server/_libs/agent-base.mjs +234 -0
  16. package/.output/server/_libs/anthropic-ai__sdk.mjs +6042 -0
  17. package/.output/server/_libs/atomically.mjs +3 -0
  18. package/.output/server/_libs/base64-js.mjs +102 -0
  19. package/.output/server/_libs/bignumber.js.mjs +1353 -0
  20. package/.output/server/_libs/buffer-equal-constant-time.mjs +38 -0
  21. package/.output/server/_libs/data-uri-to-buffer.mjs +39 -0
  22. package/.output/server/_libs/debug.mjs +547 -0
  23. package/.output/server/_libs/ecdsa-sig-formatter.mjs +162 -0
  24. package/.output/server/_libs/extend.mjs +2 -1
  25. package/.output/server/_libs/fetch-blob.mjs +287 -0
  26. package/.output/server/_libs/formdata-polyfill.mjs +88 -0
  27. package/.output/server/_libs/gaxios.mjs +927 -0
  28. package/.output/server/_libs/gcp-metadata.mjs +322 -0
  29. package/.output/server/_libs/google-auth-library.mjs +6339 -0
  30. package/.output/server/_libs/google-logging-utils.mjs +385 -0
  31. package/.output/server/_libs/google__genai.mjs +18034 -0
  32. package/.output/server/_libs/has-flag.mjs +16 -0
  33. package/.output/server/_libs/https-proxy-agent.mjs +280 -0
  34. package/.output/server/_libs/json-bigint.mjs +413 -0
  35. package/.output/server/_libs/jwa.mjs +233 -0
  36. package/.output/server/_libs/jws.mjs +298 -0
  37. package/.output/server/_libs/lucide-react.mjs +261 -226
  38. package/.output/server/_libs/mariozechner__pi-agent-core.mjs +824 -0
  39. package/.output/server/_libs/mariozechner__pi-ai.mjs +22889 -0
  40. package/.output/server/_libs/mistralai__mistralai.mjs +32045 -0
  41. package/.output/server/_libs/ms.mjs +120 -0
  42. package/.output/server/_libs/node-domexception.mjs +17 -0
  43. package/.output/server/_libs/node-fetch.mjs +1578 -0
  44. package/.output/server/_libs/ohash.mjs +1 -1
  45. package/.output/server/_libs/openai.mjs +6766 -0
  46. package/.output/server/_libs/opentelemetry__api.mjs +1678 -0
  47. package/.output/server/_libs/p-retry.mjs +87 -0
  48. package/.output/server/_libs/partial-json.mjs +244 -0
  49. package/.output/server/_libs/react-dom.mjs +5 -5
  50. package/.output/server/_libs/react-markdown.mjs +2 -2
  51. package/.output/server/_libs/react.mjs +30 -0
  52. package/.output/server/_libs/readable-stream.mjs +5 -5
  53. package/.output/server/_libs/retry.mjs +236 -0
  54. package/.output/server/_libs/safe-buffer.mjs +63 -1
  55. package/.output/server/_libs/srvx.mjs +2 -2
  56. package/.output/server/_libs/supports-color.mjs +108 -0
  57. package/.output/server/_libs/tanstack__router-core.mjs +1 -1
  58. package/.output/server/_libs/typebox.mjs +6596 -0
  59. package/.output/server/_libs/util-deprecate.mjs +2 -2
  60. package/.output/server/_libs/vfile.mjs +2 -2
  61. package/.output/server/_libs/web-streams-polyfill.mjs +4282 -0
  62. package/.output/server/_libs/ws.mjs +3715 -0
  63. package/.output/server/_libs/zod-to-json-schema.mjs +1207 -0
  64. package/.output/server/_libs/zod.mjs +597 -9
  65. package/.output/server/{_sessionId-GcFhWT0i.mjs → _sessionId-DL2JQJwR.mjs} +14 -13
  66. package/.output/server/_ssr/{CompareDrawer-BV7dw1TN.mjs → CompareDrawer-hPTOTmyU.mjs} +14 -13
  67. package/.output/server/_ssr/{ProxyViewerContainer-CcgfvaS4.mjs → ProxyViewerContainer-k0mFaufl.mjs} +161 -91
  68. package/.output/server/_ssr/{ReplayDialog-B7sBKxIO.mjs → ReplayDialog-t6QdwnZh.mjs} +15 -14
  69. package/.output/server/_ssr/{RequestAnatomy-s_9Veje2.mjs → RequestAnatomy-BnvWxyac.mjs} +14 -13
  70. package/.output/server/_ssr/{ResponseView-DsOFPCvF.mjs → ResponseView-BhhozRRl.mjs} +14 -13
  71. package/.output/server/_ssr/{StreamingChunkSequence-CyA1XtiF.mjs → StreamingChunkSequence-Dl_laTbX.mjs} +14 -13
  72. package/.output/server/_ssr/{index-CDDRt201.mjs → index-D1-t1D8F.mjs} +25 -15
  73. package/.output/server/_ssr/index.mjs +4 -4
  74. package/.output/server/_ssr/{json-viewer-BFV-xtRM.mjs → json-viewer-D5Lh2yBU.mjs} +14 -13
  75. package/.output/server/_ssr/{router-B2Q7vHPM.mjs → router-DaLFEeWW.mjs} +597 -100
  76. package/.output/server/_tanstack-start-manifest_v-DsSiD2gY.mjs +4 -0
  77. package/.output/server/index.mjs +77 -77
  78. package/package.json +4 -1
  79. package/src/components/ProxyViewer.tsx +12 -4
  80. package/src/components/pi-agent/PiAgentPanel.tsx +204 -0
  81. package/src/lib/chunkLoadRecovery.ts +83 -0
  82. package/src/lib/piAgentContract.ts +21 -0
  83. package/src/routes/__root.tsx +6 -3
  84. package/src/routes/api/pi-agent.ts +29 -0
  85. package/src/routes/index.tsx +25 -1
  86. package/src/routes/session/$sessionId.tsx +1 -0
  87. package/src/services/piAgent.ts +390 -0
  88. package/.output/public/assets/index-CGpPRty8.js +0 -1
  89. package/.output/public/assets/index-HRfrFVYw.css +0 -1
  90. package/.output/server/_tanstack-start-manifest_v-Dm_GmuRz.mjs +0 -4
@@ -0,0 +1,162 @@
1
+ import { a as requireSafeBuffer } from "./safe-buffer.mjs";
2
+ var paramBytesForAlg_1;
3
+ var hasRequiredParamBytesForAlg;
4
+ function requireParamBytesForAlg() {
5
+ if (hasRequiredParamBytesForAlg) return paramBytesForAlg_1;
6
+ hasRequiredParamBytesForAlg = 1;
7
+ function getParamSize(keySize) {
8
+ var result = (keySize / 8 | 0) + (keySize % 8 === 0 ? 0 : 1);
9
+ return result;
10
+ }
11
+ var paramBytesForAlg = {
12
+ ES256: getParamSize(256),
13
+ ES384: getParamSize(384),
14
+ ES512: getParamSize(521)
15
+ };
16
+ function getParamBytesForAlg(alg) {
17
+ var paramBytes = paramBytesForAlg[alg];
18
+ if (paramBytes) {
19
+ return paramBytes;
20
+ }
21
+ throw new Error('Unknown algorithm "' + alg + '"');
22
+ }
23
+ paramBytesForAlg_1 = getParamBytesForAlg;
24
+ return paramBytesForAlg_1;
25
+ }
26
+ var ecdsaSigFormatter;
27
+ var hasRequiredEcdsaSigFormatter;
28
+ function requireEcdsaSigFormatter() {
29
+ if (hasRequiredEcdsaSigFormatter) return ecdsaSigFormatter;
30
+ hasRequiredEcdsaSigFormatter = 1;
31
+ var Buffer = requireSafeBuffer().Buffer;
32
+ var getParamBytesForAlg = requireParamBytesForAlg();
33
+ var MAX_OCTET = 128, CLASS_UNIVERSAL = 0, PRIMITIVE_BIT = 32, TAG_SEQ = 16, TAG_INT = 2, ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | CLASS_UNIVERSAL << 6, ENCODED_TAG_INT = TAG_INT | CLASS_UNIVERSAL << 6;
34
+ function base64Url(base64) {
35
+ return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
36
+ }
37
+ function signatureAsBuffer(signature) {
38
+ if (Buffer.isBuffer(signature)) {
39
+ return signature;
40
+ } else if ("string" === typeof signature) {
41
+ return Buffer.from(signature, "base64");
42
+ }
43
+ throw new TypeError("ECDSA signature must be a Base64 string or a Buffer");
44
+ }
45
+ function derToJose(signature, alg) {
46
+ signature = signatureAsBuffer(signature);
47
+ var paramBytes = getParamBytesForAlg(alg);
48
+ var maxEncodedParamLength = paramBytes + 1;
49
+ var inputLength = signature.length;
50
+ var offset = 0;
51
+ if (signature[offset++] !== ENCODED_TAG_SEQ) {
52
+ throw new Error('Could not find expected "seq"');
53
+ }
54
+ var seqLength = signature[offset++];
55
+ if (seqLength === (MAX_OCTET | 1)) {
56
+ seqLength = signature[offset++];
57
+ }
58
+ if (inputLength - offset < seqLength) {
59
+ throw new Error('"seq" specified length of "' + seqLength + '", only "' + (inputLength - offset) + '" remaining');
60
+ }
61
+ if (signature[offset++] !== ENCODED_TAG_INT) {
62
+ throw new Error('Could not find expected "int" for "r"');
63
+ }
64
+ var rLength = signature[offset++];
65
+ if (inputLength - offset - 2 < rLength) {
66
+ throw new Error('"r" specified length of "' + rLength + '", only "' + (inputLength - offset - 2) + '" available');
67
+ }
68
+ if (maxEncodedParamLength < rLength) {
69
+ throw new Error('"r" specified length of "' + rLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
70
+ }
71
+ var rOffset = offset;
72
+ offset += rLength;
73
+ if (signature[offset++] !== ENCODED_TAG_INT) {
74
+ throw new Error('Could not find expected "int" for "s"');
75
+ }
76
+ var sLength = signature[offset++];
77
+ if (inputLength - offset !== sLength) {
78
+ throw new Error('"s" specified length of "' + sLength + '", expected "' + (inputLength - offset) + '"');
79
+ }
80
+ if (maxEncodedParamLength < sLength) {
81
+ throw new Error('"s" specified length of "' + sLength + '", max of "' + maxEncodedParamLength + '" is acceptable');
82
+ }
83
+ var sOffset = offset;
84
+ offset += sLength;
85
+ if (offset !== inputLength) {
86
+ throw new Error('Expected to consume entire buffer, but "' + (inputLength - offset) + '" bytes remain');
87
+ }
88
+ var rPadding = paramBytes - rLength, sPadding = paramBytes - sLength;
89
+ var dst = Buffer.allocUnsafe(rPadding + rLength + sPadding + sLength);
90
+ for (offset = 0; offset < rPadding; ++offset) {
91
+ dst[offset] = 0;
92
+ }
93
+ signature.copy(dst, offset, rOffset + Math.max(-rPadding, 0), rOffset + rLength);
94
+ offset = paramBytes;
95
+ for (var o = offset; offset < o + sPadding; ++offset) {
96
+ dst[offset] = 0;
97
+ }
98
+ signature.copy(dst, offset, sOffset + Math.max(-sPadding, 0), sOffset + sLength);
99
+ dst = dst.toString("base64");
100
+ dst = base64Url(dst);
101
+ return dst;
102
+ }
103
+ function countPadding(buf, start, stop) {
104
+ var padding = 0;
105
+ while (start + padding < stop && buf[start + padding] === 0) {
106
+ ++padding;
107
+ }
108
+ var needsSign = buf[start + padding] >= MAX_OCTET;
109
+ if (needsSign) {
110
+ --padding;
111
+ }
112
+ return padding;
113
+ }
114
+ function joseToDer(signature, alg) {
115
+ signature = signatureAsBuffer(signature);
116
+ var paramBytes = getParamBytesForAlg(alg);
117
+ var signatureBytes = signature.length;
118
+ if (signatureBytes !== paramBytes * 2) {
119
+ throw new TypeError('"' + alg + '" signatures must be "' + paramBytes * 2 + '" bytes, saw "' + signatureBytes + '"');
120
+ }
121
+ var rPadding = countPadding(signature, 0, paramBytes);
122
+ var sPadding = countPadding(signature, paramBytes, signature.length);
123
+ var rLength = paramBytes - rPadding;
124
+ var sLength = paramBytes - sPadding;
125
+ var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength;
126
+ var shortLength = rsBytes < MAX_OCTET;
127
+ var dst = Buffer.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
128
+ var offset = 0;
129
+ dst[offset++] = ENCODED_TAG_SEQ;
130
+ if (shortLength) {
131
+ dst[offset++] = rsBytes;
132
+ } else {
133
+ dst[offset++] = MAX_OCTET | 1;
134
+ dst[offset++] = rsBytes & 255;
135
+ }
136
+ dst[offset++] = ENCODED_TAG_INT;
137
+ dst[offset++] = rLength;
138
+ if (rPadding < 0) {
139
+ dst[offset++] = 0;
140
+ offset += signature.copy(dst, offset, 0, paramBytes);
141
+ } else {
142
+ offset += signature.copy(dst, offset, rPadding, paramBytes);
143
+ }
144
+ dst[offset++] = ENCODED_TAG_INT;
145
+ dst[offset++] = sLength;
146
+ if (sPadding < 0) {
147
+ dst[offset++] = 0;
148
+ signature.copy(dst, offset, paramBytes);
149
+ } else {
150
+ signature.copy(dst, offset, paramBytes + sPadding);
151
+ }
152
+ return dst;
153
+ }
154
+ ecdsaSigFormatter = {
155
+ derToJose,
156
+ joseToDer
157
+ };
158
+ return ecdsaSigFormatter;
159
+ }
160
+ export {
161
+ requireEcdsaSigFormatter as r
162
+ };
@@ -93,5 +93,6 @@ function requireExtend() {
93
93
  var extendExports = requireExtend();
94
94
  const extend = /* @__PURE__ */ getDefaultExportFromCjs(extendExports);
95
95
  export {
96
- extend as e
96
+ extend as e,
97
+ requireExtend as r
97
98
  };
@@ -0,0 +1,287 @@
1
+ import { promises } from "node:fs";
2
+ import "node:path";
3
+ import "./node-domexception.mjs";
4
+ import { r as requirePonyfill_es2018 } from "./web-streams-polyfill.mjs";
5
+ var streams = {};
6
+ var hasRequiredStreams;
7
+ function requireStreams() {
8
+ if (hasRequiredStreams) return streams;
9
+ hasRequiredStreams = 1;
10
+ const POOL_SIZE2 = 65536;
11
+ if (!globalThis.ReadableStream) {
12
+ try {
13
+ const process = require("node:process");
14
+ const { emitWarning } = process;
15
+ try {
16
+ process.emitWarning = () => {
17
+ };
18
+ Object.assign(globalThis, require("node:stream/web"));
19
+ process.emitWarning = emitWarning;
20
+ } catch (error) {
21
+ process.emitWarning = emitWarning;
22
+ throw error;
23
+ }
24
+ } catch (error) {
25
+ Object.assign(globalThis, requirePonyfill_es2018());
26
+ }
27
+ }
28
+ try {
29
+ const { Blob: Blob3 } = require("buffer");
30
+ if (Blob3 && !Blob3.prototype.stream) {
31
+ Blob3.prototype.stream = function name(params) {
32
+ let position = 0;
33
+ const blob = this;
34
+ return new ReadableStream({
35
+ type: "bytes",
36
+ async pull(ctrl) {
37
+ const chunk = blob.slice(position, Math.min(blob.size, position + POOL_SIZE2));
38
+ const buffer = await chunk.arrayBuffer();
39
+ position += buffer.byteLength;
40
+ ctrl.enqueue(new Uint8Array(buffer));
41
+ if (position === blob.size) {
42
+ ctrl.close();
43
+ }
44
+ }
45
+ });
46
+ };
47
+ }
48
+ } catch (error) {
49
+ }
50
+ return streams;
51
+ }
52
+ requireStreams();
53
+ const POOL_SIZE = 65536;
54
+ async function* toIterator(parts, clone = true) {
55
+ for (const part of parts) {
56
+ if ("stream" in part) {
57
+ yield* (
58
+ /** @type {AsyncIterableIterator<Uint8Array>} */
59
+ part.stream()
60
+ );
61
+ } else if (ArrayBuffer.isView(part)) {
62
+ if (clone) {
63
+ let position = part.byteOffset;
64
+ const end = part.byteOffset + part.byteLength;
65
+ while (position !== end) {
66
+ const size = Math.min(end - position, POOL_SIZE);
67
+ const chunk = part.buffer.slice(position, position + size);
68
+ position += chunk.byteLength;
69
+ yield new Uint8Array(chunk);
70
+ }
71
+ } else {
72
+ yield part;
73
+ }
74
+ } else {
75
+ let position = 0, b = (
76
+ /** @type {Blob} */
77
+ part
78
+ );
79
+ while (position !== b.size) {
80
+ const chunk = b.slice(position, Math.min(b.size, position + POOL_SIZE));
81
+ const buffer = await chunk.arrayBuffer();
82
+ position += buffer.byteLength;
83
+ yield new Uint8Array(buffer);
84
+ }
85
+ }
86
+ }
87
+ }
88
+ const _Blob = class Blob {
89
+ /** @type {Array.<(Blob|Uint8Array)>} */
90
+ #parts = [];
91
+ #type = "";
92
+ #size = 0;
93
+ #endings = "transparent";
94
+ /**
95
+ * The Blob() constructor returns a new Blob object. The content
96
+ * of the blob consists of the concatenation of the values given
97
+ * in the parameter array.
98
+ *
99
+ * @param {*} blobParts
100
+ * @param {{ type?: string, endings?: string }} [options]
101
+ */
102
+ constructor(blobParts = [], options = {}) {
103
+ if (typeof blobParts !== "object" || blobParts === null) {
104
+ throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
105
+ }
106
+ if (typeof blobParts[Symbol.iterator] !== "function") {
107
+ throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
108
+ }
109
+ if (typeof options !== "object" && typeof options !== "function") {
110
+ throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
111
+ }
112
+ if (options === null) options = {};
113
+ const encoder = new TextEncoder();
114
+ for (const element of blobParts) {
115
+ let part;
116
+ if (ArrayBuffer.isView(element)) {
117
+ part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
118
+ } else if (element instanceof ArrayBuffer) {
119
+ part = new Uint8Array(element.slice(0));
120
+ } else if (element instanceof Blob) {
121
+ part = element;
122
+ } else {
123
+ part = encoder.encode(`${element}`);
124
+ }
125
+ this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
126
+ this.#parts.push(part);
127
+ }
128
+ this.#endings = `${options.endings === void 0 ? "transparent" : options.endings}`;
129
+ const type = options.type === void 0 ? "" : String(options.type);
130
+ this.#type = /^[\x20-\x7E]*$/.test(type) ? type : "";
131
+ }
132
+ /**
133
+ * The Blob interface's size property returns the
134
+ * size of the Blob in bytes.
135
+ */
136
+ get size() {
137
+ return this.#size;
138
+ }
139
+ /**
140
+ * The type property of a Blob object returns the MIME type of the file.
141
+ */
142
+ get type() {
143
+ return this.#type;
144
+ }
145
+ /**
146
+ * The text() method in the Blob interface returns a Promise
147
+ * that resolves with a string containing the contents of
148
+ * the blob, interpreted as UTF-8.
149
+ *
150
+ * @return {Promise<string>}
151
+ */
152
+ async text() {
153
+ const decoder = new TextDecoder();
154
+ let str = "";
155
+ for await (const part of toIterator(this.#parts, false)) {
156
+ str += decoder.decode(part, { stream: true });
157
+ }
158
+ str += decoder.decode();
159
+ return str;
160
+ }
161
+ /**
162
+ * The arrayBuffer() method in the Blob interface returns a
163
+ * Promise that resolves with the contents of the blob as
164
+ * binary data contained in an ArrayBuffer.
165
+ *
166
+ * @return {Promise<ArrayBuffer>}
167
+ */
168
+ async arrayBuffer() {
169
+ const data = new Uint8Array(this.size);
170
+ let offset = 0;
171
+ for await (const chunk of toIterator(this.#parts, false)) {
172
+ data.set(chunk, offset);
173
+ offset += chunk.length;
174
+ }
175
+ return data.buffer;
176
+ }
177
+ stream() {
178
+ const it = toIterator(this.#parts, true);
179
+ return new globalThis.ReadableStream({
180
+ // @ts-ignore
181
+ type: "bytes",
182
+ async pull(ctrl) {
183
+ const chunk = await it.next();
184
+ chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
185
+ },
186
+ async cancel() {
187
+ await it.return();
188
+ }
189
+ });
190
+ }
191
+ /**
192
+ * The Blob interface's slice() method creates and returns a
193
+ * new Blob object which contains data from a subset of the
194
+ * blob on which it's called.
195
+ *
196
+ * @param {number} [start]
197
+ * @param {number} [end]
198
+ * @param {string} [type]
199
+ */
200
+ slice(start = 0, end = this.size, type = "") {
201
+ const { size } = this;
202
+ let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
203
+ let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
204
+ const span = Math.max(relativeEnd - relativeStart, 0);
205
+ const parts = this.#parts;
206
+ const blobParts = [];
207
+ let added = 0;
208
+ for (const part of parts) {
209
+ if (added >= span) {
210
+ break;
211
+ }
212
+ const size2 = ArrayBuffer.isView(part) ? part.byteLength : part.size;
213
+ if (relativeStart && size2 <= relativeStart) {
214
+ relativeStart -= size2;
215
+ relativeEnd -= size2;
216
+ } else {
217
+ let chunk;
218
+ if (ArrayBuffer.isView(part)) {
219
+ chunk = part.subarray(relativeStart, Math.min(size2, relativeEnd));
220
+ added += chunk.byteLength;
221
+ } else {
222
+ chunk = part.slice(relativeStart, Math.min(size2, relativeEnd));
223
+ added += chunk.size;
224
+ }
225
+ relativeEnd -= size2;
226
+ blobParts.push(chunk);
227
+ relativeStart = 0;
228
+ }
229
+ }
230
+ const blob = new Blob([], { type: String(type).toLowerCase() });
231
+ blob.#size = span;
232
+ blob.#parts = blobParts;
233
+ return blob;
234
+ }
235
+ get [Symbol.toStringTag]() {
236
+ return "Blob";
237
+ }
238
+ static [Symbol.hasInstance](object) {
239
+ return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
240
+ }
241
+ };
242
+ Object.defineProperties(_Blob.prototype, {
243
+ size: { enumerable: true },
244
+ type: { enumerable: true },
245
+ slice: { enumerable: true }
246
+ });
247
+ const Blob2 = _Blob;
248
+ const _File = class File extends Blob2 {
249
+ #lastModified = 0;
250
+ #name = "";
251
+ /**
252
+ * @param {*[]} fileBits
253
+ * @param {string} fileName
254
+ * @param {{lastModified?: number, type?: string}} options
255
+ */
256
+ // @ts-ignore
257
+ constructor(fileBits, fileName, options = {}) {
258
+ if (arguments.length < 2) {
259
+ throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
260
+ }
261
+ super(fileBits, options);
262
+ if (options === null) options = {};
263
+ const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
264
+ if (!Number.isNaN(lastModified)) {
265
+ this.#lastModified = lastModified;
266
+ }
267
+ this.#name = String(fileName);
268
+ }
269
+ get name() {
270
+ return this.#name;
271
+ }
272
+ get lastModified() {
273
+ return this.#lastModified;
274
+ }
275
+ get [Symbol.toStringTag]() {
276
+ return "File";
277
+ }
278
+ static [Symbol.hasInstance](object) {
279
+ return !!object && object instanceof Blob2 && /^(File)$/.test(object[Symbol.toStringTag]);
280
+ }
281
+ };
282
+ const File2 = _File;
283
+ const { stat } = promises;
284
+ export {
285
+ Blob2 as B,
286
+ File2 as F
287
+ };
@@ -0,0 +1,88 @@
1
+ import { B as Blob, F as File } from "./fetch-blob.mjs";
2
+ var { toStringTag: t, iterator: i, hasInstance: h } = Symbol, r = Math.random, m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new File([b], c, b) : b] : [a, b + ""]), e = (c, f2) => (f2 ? c : c.replace(/\r?\n|\r/g, "\r\n")).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), x = (n, a, e2) => {
3
+ if (a.length < e2) {
4
+ throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
5
+ }
6
+ };
7
+ const FormData = class FormData2 {
8
+ #d = [];
9
+ constructor(...a) {
10
+ if (a.length) throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
11
+ }
12
+ get [t]() {
13
+ return "FormData";
14
+ }
15
+ [i]() {
16
+ return this.entries();
17
+ }
18
+ static [h](o) {
19
+ return o && typeof o === "object" && o[t] === "FormData" && !m.some((m2) => typeof o[m2] != "function");
20
+ }
21
+ append(...a) {
22
+ x("append", arguments, 2);
23
+ this.#d.push(f(...a));
24
+ }
25
+ delete(a) {
26
+ x("delete", arguments, 1);
27
+ a += "";
28
+ this.#d = this.#d.filter(([b]) => b !== a);
29
+ }
30
+ get(a) {
31
+ x("get", arguments, 1);
32
+ a += "";
33
+ for (var b = this.#d, l = b.length, c = 0; c < l; c++) if (b[c][0] === a) return b[c][1];
34
+ return null;
35
+ }
36
+ getAll(a, b) {
37
+ x("getAll", arguments, 1);
38
+ b = [];
39
+ a += "";
40
+ this.#d.forEach((c) => c[0] === a && b.push(c[1]));
41
+ return b;
42
+ }
43
+ has(a) {
44
+ x("has", arguments, 1);
45
+ a += "";
46
+ return this.#d.some((b) => b[0] === a);
47
+ }
48
+ forEach(a, b) {
49
+ x("forEach", arguments, 1);
50
+ for (var [c, d] of this) a.call(b, d, c, this);
51
+ }
52
+ set(...a) {
53
+ x("set", arguments, 2);
54
+ var b = [], c = true;
55
+ a = f(...a);
56
+ this.#d.forEach((d) => {
57
+ d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
58
+ });
59
+ c && b.push(a);
60
+ this.#d = b;
61
+ }
62
+ *entries() {
63
+ yield* this.#d;
64
+ }
65
+ *keys() {
66
+ for (var [a] of this) yield a;
67
+ }
68
+ *values() {
69
+ for (var [, a] of this) yield a;
70
+ }
71
+ };
72
+ function formDataToBlob(F, B = Blob) {
73
+ var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c = [], p = `--${b}\r
74
+ Content-Disposition: form-data; name="`;
75
+ F.forEach((v, n) => typeof v == "string" ? c.push(p + e(n) + `"\r
76
+ \r
77
+ ${v.replace(new RegExp("\\r(?!\\n)|(?<!\\r)\\n", "g"), "\r\n")}\r
78
+ `) : c.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r
79
+ Content-Type: ${v.type || "application/octet-stream"}\r
80
+ \r
81
+ `, v, "\r\n"));
82
+ c.push(`--${b}--`);
83
+ return new B(c, { type: "multipart/form-data; boundary=" + b });
84
+ }
85
+ export {
86
+ FormData as F,
87
+ formDataToBlob as f
88
+ };