token-usage-dashboard 1.0.12 → 1.0.14
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/build/adapter-node.js +11 -0
- package/build/client/_app/immutable/chunks/B0VWrXPj.js +1 -0
- package/build/client/_app/immutable/chunks/B0VWrXPj.js.br +0 -0
- package/build/client/_app/immutable/chunks/B0VWrXPj.js.gz +0 -0
- package/build/client/_app/immutable/chunks/BaNbYf_w.js +1 -0
- package/build/client/_app/immutable/chunks/BaNbYf_w.js.br +0 -0
- package/build/client/_app/immutable/chunks/BaNbYf_w.js.gz +0 -0
- package/build/client/_app/immutable/chunks/CbiRHTcG.js +1 -0
- package/build/client/_app/immutable/chunks/CbiRHTcG.js.br +0 -0
- package/build/client/_app/immutable/chunks/CbiRHTcG.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DTingiCe.js +3 -0
- package/build/client/_app/immutable/chunks/DTingiCe.js.br +0 -0
- package/build/client/_app/immutable/chunks/DTingiCe.js.gz +0 -0
- package/build/client/_app/immutable/chunks/ssd4Rw-g.js +3 -0
- package/build/client/_app/immutable/chunks/ssd4Rw-g.js.br +0 -0
- package/build/client/_app/immutable/chunks/ssd4Rw-g.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.CRLWmGVY.js +2 -0
- package/build/client/_app/immutable/entry/app.CRLWmGVY.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CRLWmGVY.js.gz +0 -0
- package/build/client/_app/immutable/entry/payload.DSmR2FwN.js +1 -0
- package/build/client/_app/immutable/entry/payload.DSmR2FwN.js.br +0 -0
- package/build/client/_app/immutable/entry/payload.DSmR2FwN.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.CzGx2BYz.js +2 -0
- package/build/client/_app/immutable/entry/start.CzGx2BYz.js.br +0 -0
- package/build/client/_app/immutable/entry/start.CzGx2BYz.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.BBGTwdwd.js +1 -0
- package/build/client/_app/immutable/nodes/0.BBGTwdwd.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.BBGTwdwd.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js +1 -0
- package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js.br +2 -0
- package/build/client/_app/immutable/nodes/1.Cy2JV0fN.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.CRMPKkcX.js +2 -0
- package/build/client/_app/immutable/nodes/2.CRMPKkcX.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CRMPKkcX.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/handler.js +1 -22
- package/build/index.js +1 -145
- package/build/server/.vite/manifest.json +271 -0
- package/build/server/_app/immutable/assets/_layout.CZ6VMqH1.css +1 -0
- package/build/server/_app/immutable/assets/_page.CZocdpCk.css +1 -0
- package/build/server/adapter-env.js +2 -0
- package/build/server/adapter-index.js +74 -0
- package/build/server/adapter-node-env.js +63 -0
- package/build/server/adapter-node-handler.js +584 -0
- package/build/server/chunks/config.js +10 -0
- package/build/server/chunks/functions.js +30 -0
- package/build/server/chunks/index-server.js +2 -0
- package/build/server/chunks/instance.js +3546 -0
- package/build/server/chunks/internal.js +3323 -0
- package/build/server/chunks/navigation.js +16 -0
- package/build/server/chunks/{chunks/queries.js-BEdRnpMa.js → queries.js} +9 -9
- package/build/server/chunks/{chunks/range.js-CiCoLGqh.js → range.js} +3 -2
- package/build/server/chunks/{chunks/refresh.js-0W7-GwaH.js → refresh.js} +7 -7
- package/build/server/chunks/{chunks/request.js-BF7n7fZo.js → request.js} +5 -5
- package/build/server/chunks/server-errors.js +489 -0
- package/build/server/chunks/server.js +9 -0
- package/build/server/chunks/server2.js +1504 -0
- package/build/server/chunks/shared.js +84 -0
- package/build/server/chunks/uneval.js +537 -0
- package/build/server/entries/endpoints/api/refresh/_server.ts.js +12 -0
- package/build/server/entries/endpoints/api/settings/_server.ts.js +15 -0
- package/build/server/entries/endpoints/api/usage/_server.ts.js +8 -0
- package/build/server/entries/fallbacks/error.svelte.js +47 -0
- package/build/server/entries/hooks.server.js +10 -0
- package/build/server/{chunks/entries/pages/_layout.svelte.js-C9kkUOBf.js → entries/pages/_layout.svelte.js} +4 -2
- package/build/server/entries/pages/_page.server.ts.js +12 -0
- package/build/server/{chunks/entries/pages/_page.svelte.js-BqU3UuBL.js → entries/pages/_page.svelte.js} +64 -27
- package/build/server/env.js +2 -0
- package/build/server/handler.js +2 -0
- package/build/server/index.js +67 -0
- package/build/server/manifest-full.js +58 -0
- package/build/server/manifest.js +58 -0
- package/build/server/nodes/0.js +8 -0
- package/build/server/nodes/1.js +8 -0
- package/build/server/nodes/2.js +10 -0
- package/build/server/remote-entry.js +1564 -0
- package/build/server/server.js +60 -0
- package/package.json +8 -8
- package/build/client/_app/immutable/chunks/Dsm7b1TR.js +0 -3
- package/build/client/_app/immutable/chunks/Dsm7b1TR.js.br +0 -0
- package/build/client/_app/immutable/chunks/Dsm7b1TR.js.gz +0 -0
- package/build/client/_app/immutable/chunks/G5wHZJy8.js +0 -2
- package/build/client/_app/immutable/chunks/G5wHZJy8.js.br +0 -0
- package/build/client/_app/immutable/chunks/G5wHZJy8.js.gz +0 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js +0 -1
- package/build/client/_app/immutable/chunks/xihTtKlq.js.br +0 -1
- package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.CuA0PQ3L.js +0 -2
- package/build/client/_app/immutable/entry/app.CuA0PQ3L.js.br +0 -0
- package/build/client/_app/immutable/entry/app.CuA0PQ3L.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.CV_ip-Hp.js +0 -1
- package/build/client/_app/immutable/entry/start.CV_ip-Hp.js.br +0 -1
- package/build/client/_app/immutable/entry/start.CV_ip-Hp.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.PGglbI9f.js +0 -1
- package/build/client/_app/immutable/nodes/0.PGglbI9f.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.PGglbI9f.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.CTCsoy2V.js +0 -1
- package/build/client/_app/immutable/nodes/1.CTCsoy2V.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.CTCsoy2V.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.DBV8nX84.js +0 -2
- package/build/client/_app/immutable/nodes/2.DBV8nX84.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.DBV8nX84.js.gz +0 -0
- package/build/env.js +0 -70
- package/build/server/chunks/chunks/client.js-BQauTa0m.js +0 -28
- package/build/server/chunks/chunks/env.js-l0sNRNKZ.js +0 -2
- package/build/server/chunks/chunks/exports.js-Bbyr-JtB.js +0 -349
- package/build/server/chunks/chunks/internal.js-U26BXAw4.js +0 -1202
- package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js +0 -22
- package/build/server/chunks/chunks/server.js-UOanU7fq.js +0 -5527
- package/build/server/chunks/chunks/shared.js-Dg3Ewm8t.js +0 -255
- package/build/server/chunks/chunks/utils.js-DUDFXVFd.js +0 -1049
- package/build/server/chunks/entries/endpoints/api/refresh/_server.ts.js-CcG44vTx.js +0 -21
- package/build/server/chunks/entries/endpoints/api/settings/_server.ts.js-B0LWCQis.js +0 -24
- package/build/server/chunks/entries/endpoints/api/usage/_server.ts.js-CJGTdjik.js +0 -17
- package/build/server/chunks/entries/fallbacks/error.svelte.js-BdtN0SJD.js +0 -68
- package/build/server/chunks/entries/hooks.server.js-_Fcw_IVA.js +0 -16
- package/build/server/chunks/entries/pages/_page.server.ts.js-BBibcAZP.js +0 -17
- package/build/server/chunks/handler-D8S2N5vX.js +0 -1475
- package/build/server/chunks/index.js-BDweEDAt.js +0 -3972
- package/build/server/chunks/manifest.js-CUe1IdHJ.js +0 -63
- package/build/server/chunks/nodes/0.js-7EReDAeT.js +0 -9
- package/build/server/chunks/nodes/1.js-MVTzwi8l.js +0 -9
- package/build/server/chunks/nodes/2.js-C7xGlKUF.js +0 -20
- package/build/shims.js +0 -33
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { a as SvelteKitError } from "./chunks/shared.js";
|
|
2
|
+
import { n as noop } from "./chunks/functions.js";
|
|
3
|
+
import { t as env } from "./adapter-node-env.js";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import fs, { createReadStream } from "node:fs";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { Readable, pipeline } from "node:stream";
|
|
8
|
+
import { app_path, assets, base, dir, env_prefix, mime_types, origin, prerendered_assets, server } from "../adapter-node.js";
|
|
9
|
+
import { format } from "node:url";
|
|
10
|
+
//#region node_modules/@sveltejs/kit/src/exports/node/index.js
|
|
11
|
+
/** @type {WeakMap<import('http').IncomingMessage, (chunk: Buffer) => void>} */
|
|
12
|
+
var body_data_listeners = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
/**
|
|
14
|
+
* @param {import('http').IncomingMessage} req
|
|
15
|
+
* @param {number} [body_size_limit]
|
|
16
|
+
*/
|
|
17
|
+
function get_raw_body(req, body_size_limit) {
|
|
18
|
+
const h = req.headers;
|
|
19
|
+
const content_length = Number(h["content-length"]);
|
|
20
|
+
const has_content_length = Number.isFinite(content_length);
|
|
21
|
+
if (req.httpVersionMajor === 1 && !has_content_length && h["transfer-encoding"] == null || content_length === 0) return null;
|
|
22
|
+
if (req.destroyed) {
|
|
23
|
+
const readable = new ReadableStream();
|
|
24
|
+
readable.cancel();
|
|
25
|
+
return readable;
|
|
26
|
+
}
|
|
27
|
+
let size = 0;
|
|
28
|
+
let cancelled = false;
|
|
29
|
+
return new ReadableStream({
|
|
30
|
+
start(controller) {
|
|
31
|
+
if (body_size_limit !== void 0 && has_content_length && content_length > body_size_limit) {
|
|
32
|
+
const error = new SvelteKitError(413, "Payload Too Large", `Content-length of ${content_length} exceeds limit of ${body_size_limit} bytes.`);
|
|
33
|
+
controller.error(error);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
/** @param {Error} error */
|
|
37
|
+
const on_error = (error) => {
|
|
38
|
+
cancelled = true;
|
|
39
|
+
controller.error(error);
|
|
40
|
+
};
|
|
41
|
+
const on_end = () => {
|
|
42
|
+
if (cancelled) return;
|
|
43
|
+
controller.close();
|
|
44
|
+
};
|
|
45
|
+
/** @param {Buffer} chunk */
|
|
46
|
+
const on_data = (chunk) => {
|
|
47
|
+
if (cancelled) return;
|
|
48
|
+
size += chunk.length;
|
|
49
|
+
if (body_size_limit !== void 0 && size > body_size_limit) {
|
|
50
|
+
cancelled = true;
|
|
51
|
+
const message = `request body size exceeded BODY_SIZE_LIMIT of ${body_size_limit}`;
|
|
52
|
+
const error = new SvelteKitError(413, "Payload Too Large", message);
|
|
53
|
+
controller.error(error);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (has_content_length && size > content_length) {
|
|
57
|
+
cancelled = true;
|
|
58
|
+
const message = `request body size exceeded content-length of ${content_length}`;
|
|
59
|
+
const error = new SvelteKitError(413, "Payload Too Large", message);
|
|
60
|
+
controller.error(error);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
controller.enqueue(chunk);
|
|
64
|
+
if (controller.desiredSize === null || controller.desiredSize <= 0) req.pause();
|
|
65
|
+
};
|
|
66
|
+
req.on("error", on_error);
|
|
67
|
+
req.on("end", on_end);
|
|
68
|
+
req.on("data", on_data);
|
|
69
|
+
body_data_listeners.set(req, on_data);
|
|
70
|
+
},
|
|
71
|
+
pull() {
|
|
72
|
+
req.resume();
|
|
73
|
+
},
|
|
74
|
+
cancel(reason) {
|
|
75
|
+
cancelled = true;
|
|
76
|
+
req.destroy(reason);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @param {{
|
|
82
|
+
* request: import('http').IncomingMessage;
|
|
83
|
+
* response?: import('http').ServerResponse;
|
|
84
|
+
* base: string;
|
|
85
|
+
* bodySizeLimit?: number;
|
|
86
|
+
* }} options
|
|
87
|
+
* @returns {Request}
|
|
88
|
+
*/
|
|
89
|
+
function getRequest({ request, response, base, bodySizeLimit }) {
|
|
90
|
+
let headers = request.headers;
|
|
91
|
+
if (request.httpVersionMajor >= 2) {
|
|
92
|
+
headers = Object.assign({}, headers);
|
|
93
|
+
if (headers[":authority"]) headers.host = headers[":authority"];
|
|
94
|
+
delete headers[":authority"];
|
|
95
|
+
delete headers[":method"];
|
|
96
|
+
delete headers[":path"];
|
|
97
|
+
delete headers[":scheme"];
|
|
98
|
+
}
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
request.once("close", () => {
|
|
101
|
+
if (request.readableAborted) controller.abort();
|
|
102
|
+
});
|
|
103
|
+
response?.once("close", () => {
|
|
104
|
+
if (!response.writableEnded) controller.abort();
|
|
105
|
+
});
|
|
106
|
+
return new Request(base + request.url, {
|
|
107
|
+
duplex: "half",
|
|
108
|
+
method: request.method,
|
|
109
|
+
headers: Object.entries(headers),
|
|
110
|
+
signal: controller.signal,
|
|
111
|
+
body: request.method === "GET" || request.method === "HEAD" ? void 0 : get_raw_body(request, bodySizeLimit)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Drains any unconsumed request body once the response has been sent. When a
|
|
116
|
+
* route doesn't read the request body (for example a page route receiving a
|
|
117
|
+
* POST), the unread bytes remain buffered in the socket. On keep-alive
|
|
118
|
+
* connections Node's HTTP parser then reads those leftover bytes as the next
|
|
119
|
+
* request, fails to parse them, and resets the connection — losing any
|
|
120
|
+
* pipelined request. Resuming the request discards the bytes so the connection
|
|
121
|
+
* stays usable.
|
|
122
|
+
*
|
|
123
|
+
* Because `get_raw_body` attaches a `data` listener, Node marks the request as
|
|
124
|
+
* being consumed (`req._consuming`) and skips its own automatic drain, so we
|
|
125
|
+
* have to do it ourselves. The whole remaining body is read and discarded; this
|
|
126
|
+
* is the intended trade-off (keeping the connection reusable) over destroying it.
|
|
127
|
+
* @see https://github.com/sveltejs/kit/issues/14916
|
|
128
|
+
* @see https://github.com/sveltejs/kit/issues/15526
|
|
129
|
+
* @param {import('http').ServerResponse} res
|
|
130
|
+
*/
|
|
131
|
+
function drain_request(res) {
|
|
132
|
+
const req = res.req;
|
|
133
|
+
if (!req || req.readableEnded || req.destroyed) return;
|
|
134
|
+
const on_data = body_data_listeners.get(req);
|
|
135
|
+
if (on_data) {
|
|
136
|
+
req.removeListener("data", on_data);
|
|
137
|
+
body_data_listeners.delete(req);
|
|
138
|
+
}
|
|
139
|
+
req.resume();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @param {import('http').ServerResponse} res
|
|
143
|
+
* @param {Response} response
|
|
144
|
+
* @returns {void}
|
|
145
|
+
*/
|
|
146
|
+
function setResponse(res, response) {
|
|
147
|
+
res.once("finish", () => drain_request(res));
|
|
148
|
+
res.once("close", () => drain_request(res));
|
|
149
|
+
for (const [key, value] of response.headers) try {
|
|
150
|
+
res.setHeader(key, key === "set-cookie" ? response.headers.getSetCookie() : value);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
res.getHeaderNames().forEach((name) => res.removeHeader(name));
|
|
153
|
+
res.writeHead(500).end(String(error));
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (!response.body) {
|
|
157
|
+
res.writeHead(response.status);
|
|
158
|
+
res.end();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (response.body.locked) {
|
|
162
|
+
res.writeHead(response.status);
|
|
163
|
+
res.end("Fatal error: Response body is locked. This can happen when the response was already read (for example through 'response.json()' or 'response.text()').");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const reader = response.body.getReader();
|
|
167
|
+
if (res.destroyed) {
|
|
168
|
+
reader.cancel();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const cancel = (error) => {
|
|
172
|
+
res.off("close", cancel);
|
|
173
|
+
res.off("error", cancel);
|
|
174
|
+
reader.cancel(error).catch(noop);
|
|
175
|
+
if (error) res.destroy(error);
|
|
176
|
+
};
|
|
177
|
+
res.on("close", cancel);
|
|
178
|
+
res.on("error", cancel);
|
|
179
|
+
/** @type {Uint8Array<ArrayBuffer>[]} */
|
|
180
|
+
const buffered = [];
|
|
181
|
+
/** @type {ReturnType<typeof reader.read> | null} */
|
|
182
|
+
let pending = null;
|
|
183
|
+
probe();
|
|
184
|
+
async function probe() {
|
|
185
|
+
try {
|
|
186
|
+
/** @type {Promise<undefined>} */
|
|
187
|
+
const deadline = new Promise((fulfil) => setImmediate(() => fulfil(void 0)));
|
|
188
|
+
while (buffered.length < 2) {
|
|
189
|
+
pending = reader.read();
|
|
190
|
+
const result = await Promise.race([pending, deadline]);
|
|
191
|
+
if (!result) break;
|
|
192
|
+
pending = null;
|
|
193
|
+
if (result.done) {
|
|
194
|
+
if (!res.hasHeader("content-length") && !res.hasHeader("transfer-encoding")) res.setHeader("content-length", buffered.reduce((total, chunk) => total + chunk.byteLength, 0));
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
buffered.push(result.value);
|
|
198
|
+
}
|
|
199
|
+
if (res.destroyed) return;
|
|
200
|
+
res.writeHead(response.status);
|
|
201
|
+
await next();
|
|
202
|
+
} catch (error) {
|
|
203
|
+
if (!res.headersSent) res.writeHead(response.status);
|
|
204
|
+
cancel(error instanceof Error ? error : new Error(String(error)));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async function next() {
|
|
208
|
+
try {
|
|
209
|
+
for (;;) {
|
|
210
|
+
/** @type {Awaited<ReturnType<typeof reader.read>>} */
|
|
211
|
+
let result;
|
|
212
|
+
if (buffered.length > 0) result = {
|
|
213
|
+
done: false,
|
|
214
|
+
value: buffered.shift()
|
|
215
|
+
};
|
|
216
|
+
else if (pending) {
|
|
217
|
+
result = await pending;
|
|
218
|
+
pending = null;
|
|
219
|
+
} else result = await reader.read();
|
|
220
|
+
const { done, value } = result;
|
|
221
|
+
if (done) break;
|
|
222
|
+
if (!res.write(value)) {
|
|
223
|
+
res.once("drain", next);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
res.end();
|
|
228
|
+
} catch (error) {
|
|
229
|
+
cancel(error instanceof Error ? error : new Error(String(error)));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Converts a file on disk to a readable stream
|
|
235
|
+
* @param {string} file
|
|
236
|
+
* @returns {ReadableStream}
|
|
237
|
+
* @since 2.4.0
|
|
238
|
+
*/
|
|
239
|
+
function createReadableStream(file) {
|
|
240
|
+
return Readable.toWeb(createReadStream(file));
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region node_modules/@sveltejs/adapter-node/src/utils.js
|
|
244
|
+
/**
|
|
245
|
+
* Parses the given value into number of bytes.
|
|
246
|
+
*
|
|
247
|
+
* @param {string} value - Size in bytes. Can also be specified with a unit suffix kilobytes (K), megabytes (M), or gigabytes (G).
|
|
248
|
+
* @returns {number}
|
|
249
|
+
*/
|
|
250
|
+
function parse_as_bytes(value) {
|
|
251
|
+
const multiplier = {
|
|
252
|
+
K: 1024,
|
|
253
|
+
M: 1048576,
|
|
254
|
+
G: 1073741824
|
|
255
|
+
}[value[value.length - 1]?.toUpperCase()] ?? 1;
|
|
256
|
+
return Number(multiplier != 1 ? value.substring(0, value.length - 1) : value) * multiplier;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Formats the address the server is listening on.
|
|
260
|
+
*
|
|
261
|
+
* @param {string | false} path
|
|
262
|
+
* @param {string} host
|
|
263
|
+
* @param {string | false} port
|
|
264
|
+
* @param {import('node:net').AddressInfo | string | null} address
|
|
265
|
+
* @returns {string}
|
|
266
|
+
*/
|
|
267
|
+
function format_listening_address(path, host, port, address) {
|
|
268
|
+
if (path) return path;
|
|
269
|
+
if (address && typeof address === "object") return format({
|
|
270
|
+
protocol: "http:",
|
|
271
|
+
hostname: address.address,
|
|
272
|
+
port: address.port
|
|
273
|
+
});
|
|
274
|
+
return format({
|
|
275
|
+
protocol: "http:",
|
|
276
|
+
hostname: host,
|
|
277
|
+
port: String(port)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region node_modules/@sveltejs/adapter-node/src/static.js
|
|
282
|
+
/** @import { IncomingMessage, ServerResponse } from 'node:http' */
|
|
283
|
+
/**
|
|
284
|
+
* @typedef {(req: IncomingMessage, res: ServerResponse, next: () => void | Promise<void>) => void | Promise<void>} Middleware
|
|
285
|
+
* @typedef {AssetEntry & { type?: string, cache_control?: string }} Asset
|
|
286
|
+
* @typedef {Asset | { location: string }} Entry
|
|
287
|
+
*/
|
|
288
|
+
/**
|
|
289
|
+
* Splits `req.url` into a decoded pathname and the search string.
|
|
290
|
+
* Decoding follows kit's router: reserved characters such as `%2F` stay
|
|
291
|
+
* encoded. An undecodable pathname is returned as-is, so it misses the
|
|
292
|
+
* asset table and falls through to SvelteKit's 400
|
|
293
|
+
* @param {import('node:http').IncomingMessage} req
|
|
294
|
+
*/
|
|
295
|
+
function split_url(req) {
|
|
296
|
+
let pathname = req.url;
|
|
297
|
+
let search = "";
|
|
298
|
+
const query_index = pathname.indexOf("?");
|
|
299
|
+
if (query_index !== -1) {
|
|
300
|
+
search = pathname.slice(query_index);
|
|
301
|
+
pathname = pathname.slice(0, query_index);
|
|
302
|
+
}
|
|
303
|
+
if (pathname.includes("%")) try {
|
|
304
|
+
pathname = pathname.split("%25").map(decodeURI).join("%25");
|
|
305
|
+
} catch {}
|
|
306
|
+
return {
|
|
307
|
+
pathname,
|
|
308
|
+
search
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Relative reference from `from` to `to`, which must differ only by a trailing slash.
|
|
313
|
+
* Keep in sync with the copy in `packages/kit/src/utils/url.js`
|
|
314
|
+
* @param {string} from
|
|
315
|
+
* @param {string} to
|
|
316
|
+
* @returns {string}
|
|
317
|
+
*/
|
|
318
|
+
function relative_pathname(from, to) {
|
|
319
|
+
const segment = to.replace(/\/$/, "").split("/").at(-1);
|
|
320
|
+
return from.endsWith("/") ? `../${segment}` : `./${segment}/`;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Parses `Accept-Encoding` and picks the preferred variant that exists
|
|
324
|
+
* @param {string | undefined} header
|
|
325
|
+
* @param {Asset} asset
|
|
326
|
+
* @returns {'br' | 'gz' | undefined}
|
|
327
|
+
*/
|
|
328
|
+
function negotiate(header, asset) {
|
|
329
|
+
if (!header || !(asset.br || asset.gz)) return;
|
|
330
|
+
/** @type {Map<string, number>} */
|
|
331
|
+
const weights = /* @__PURE__ */ new Map();
|
|
332
|
+
for (const part of header.toLowerCase().split(",")) {
|
|
333
|
+
const [coding, ...params] = part.split(";");
|
|
334
|
+
let weight = 1;
|
|
335
|
+
for (const param of params) {
|
|
336
|
+
const [name, value] = param.split("=");
|
|
337
|
+
if (name.trim() === "q") weight = parseFloat(value) || 0;
|
|
338
|
+
}
|
|
339
|
+
weights.set(coding.trim(), weight);
|
|
340
|
+
}
|
|
341
|
+
/** @param {string} coding */
|
|
342
|
+
const weight = (coding) => weights.get(coding) ?? weights.get("*") ?? 0;
|
|
343
|
+
const br = asset.br ? weight("br") : 0;
|
|
344
|
+
if ((asset.gz ? weight("gzip") : 0) > br) return "gz";
|
|
345
|
+
if (br > 0) return "br";
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Whether an `If-None-Match` value matches `etag`, using weak comparison
|
|
349
|
+
* @param {string | undefined} header
|
|
350
|
+
* @param {string} etag
|
|
351
|
+
*/
|
|
352
|
+
function etag_matches(header, etag) {
|
|
353
|
+
if (!header) return false;
|
|
354
|
+
if (header.trim() === "*") return true;
|
|
355
|
+
return header.split(",").some((tag) => tag.trim().replace(/^W\//, "") === etag);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Absolute file paths and content types for one table
|
|
359
|
+
* @param {string} dir
|
|
360
|
+
* @param {AssetTable} table
|
|
361
|
+
* @param {Record<string, string>} mime_types
|
|
362
|
+
* @returns {Map<string, Asset>}
|
|
363
|
+
*/
|
|
364
|
+
function resolve(dir, table, mime_types) {
|
|
365
|
+
/** @type {Map<string, Asset>} */
|
|
366
|
+
const files = /* @__PURE__ */ new Map();
|
|
367
|
+
for (const [key, entry] of table.entries) {
|
|
368
|
+
let type = mime_types[entry.file.slice(entry.file.lastIndexOf("."))];
|
|
369
|
+
if (type === "text/html") type += ";charset=utf-8";
|
|
370
|
+
files.set(key, {
|
|
371
|
+
...entry,
|
|
372
|
+
file: path.join(dir, entry.file),
|
|
373
|
+
type
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
for (const [alias, key] of table.aliases) files.set(alias, files.get(key));
|
|
377
|
+
return files;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* One lookup for every request, decided at boot: client assets (immutable below
|
|
381
|
+
* `app_path`), prerendered pages, and a 308 from the non-canonical trailing-slash
|
|
382
|
+
* form of a prerendered path to the canonical one. Client assets win a collision
|
|
383
|
+
* @param {{
|
|
384
|
+
* dir: string,
|
|
385
|
+
* base: string,
|
|
386
|
+
* app_path: string,
|
|
387
|
+
* mime_types: Record<string, string>,
|
|
388
|
+
* assets: AssetTable,
|
|
389
|
+
* prerendered_assets: AssetTable
|
|
390
|
+
* }} opts
|
|
391
|
+
* @returns {Map<string, Entry>}
|
|
392
|
+
*/
|
|
393
|
+
function create_file_map({ dir, base, app_path, mime_types, assets, prerendered_assets }) {
|
|
394
|
+
/** @type {Map<string, Entry>} */
|
|
395
|
+
const files = resolve(`${dir}/client${base}`, assets, mime_types);
|
|
396
|
+
const immutable = `/${app_path}/immutable/`;
|
|
397
|
+
for (const [key, asset] of files) if (key.startsWith(immutable))
|
|
398
|
+
/** @type {Asset} */ asset.cache_control = "public,max-age=31536000,immutable";
|
|
399
|
+
const prerendered = resolve(`${dir}/prerendered${base}`, prerendered_assets, mime_types);
|
|
400
|
+
for (const [key, asset] of prerendered) if (!files.has(key)) files.set(key, asset);
|
|
401
|
+
for (const key of prerendered.keys()) {
|
|
402
|
+
const inverted = key.at(-1) === "/" ? key.slice(0, -1) : key + "/";
|
|
403
|
+
if (inverted && !files.has(inverted)) files.set(inverted, { location: relative_pathname(inverted, key) });
|
|
404
|
+
}
|
|
405
|
+
return files;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Serves the closed set of files recorded at adapt time. Everything about a
|
|
409
|
+
* response is decided before the first request, so a request is one map
|
|
410
|
+
* lookup, header negotiation and a stream
|
|
411
|
+
* @param {Map<string, Entry>} files
|
|
412
|
+
* @returns {Middleware}
|
|
413
|
+
*/
|
|
414
|
+
function serve_static(files) {
|
|
415
|
+
return (req, res, next) => {
|
|
416
|
+
const { pathname, search } = split_url(req);
|
|
417
|
+
const asset = files.get(pathname);
|
|
418
|
+
if (!asset) return next();
|
|
419
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
420
|
+
res.writeHead(405, { allow: "GET, HEAD" }).end();
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if ("location" in asset) {
|
|
424
|
+
res.writeHead(308, { location: asset.location + search }).end();
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
let file = asset.file;
|
|
428
|
+
let size = asset.size;
|
|
429
|
+
let etag = `"${asset.etag}"`;
|
|
430
|
+
const variant = negotiate(req.headers["accept-encoding"], asset);
|
|
431
|
+
if (variant) {
|
|
432
|
+
size = asset[variant];
|
|
433
|
+
file += `.${variant}`;
|
|
434
|
+
etag = `"${asset.etag}.${variant}"`;
|
|
435
|
+
}
|
|
436
|
+
/** @type {Record<string, string | number>} */
|
|
437
|
+
const headers = { etag };
|
|
438
|
+
if (asset.br || asset.gz) headers.vary = "Accept-Encoding";
|
|
439
|
+
if (asset.cache_control) headers["cache-control"] = asset.cache_control;
|
|
440
|
+
if (etag_matches(req.headers["if-none-match"], etag)) {
|
|
441
|
+
res.writeHead(304, headers).end();
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
headers["content-length"] = size;
|
|
445
|
+
headers["accept-ranges"] = "bytes";
|
|
446
|
+
if (asset.type) headers["content-type"] = asset.type;
|
|
447
|
+
if (variant) headers["content-encoding"] = variant === "gz" ? "gzip" : "br";
|
|
448
|
+
/** @type {{ start?: number, end?: number }} */
|
|
449
|
+
const range = {};
|
|
450
|
+
let status = 200;
|
|
451
|
+
const if_range = req.headers["if-range"];
|
|
452
|
+
if (req.headers.range && (!if_range || if_range === etag)) {
|
|
453
|
+
const match = /^bytes=(\d*)-(\d*)$/.exec(req.headers.range);
|
|
454
|
+
if (match && (match[1] || match[2])) {
|
|
455
|
+
let start = match[1] ? parseInt(match[1], 10) : NaN;
|
|
456
|
+
let end = match[2] ? parseInt(match[2], 10) : size - 1;
|
|
457
|
+
if (isNaN(start)) {
|
|
458
|
+
start = Math.max(size - end, 0);
|
|
459
|
+
end = size - 1;
|
|
460
|
+
} else end = Math.min(end, size - 1);
|
|
461
|
+
if (start >= size || start > end) {
|
|
462
|
+
res.writeHead(416, { "content-range": `bytes */${size}` }).end();
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
status = 206;
|
|
466
|
+
headers["content-range"] = `bytes ${start}-${end}/${size}`;
|
|
467
|
+
headers["content-length"] = end - start + 1;
|
|
468
|
+
range.start = start;
|
|
469
|
+
range.end = end;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
res.writeHead(status, headers);
|
|
473
|
+
if (req.method === "HEAD") {
|
|
474
|
+
res.end();
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
pipeline(fs.createReadStream(file, range), res, () => {});
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region node_modules/@sveltejs/adapter-node/src/handler.js
|
|
482
|
+
/** @import { IncomingHttpHeaders } from 'node:http' */
|
|
483
|
+
/** @import { Middleware } from './static.js' */
|
|
484
|
+
var xff_depth = parseInt(env("XFF_DEPTH", "1"));
|
|
485
|
+
var address_header = env("ADDRESS_HEADER", "").toLowerCase();
|
|
486
|
+
var protocol_header = env("PROTOCOL_HEADER", "").toLowerCase();
|
|
487
|
+
var host_header = env("HOST_HEADER", "").toLowerCase();
|
|
488
|
+
var port_header = env("PORT_HEADER", "").toLowerCase();
|
|
489
|
+
var body_size_limit = parse_as_bytes(env("BODY_SIZE_LIMIT", "512K"));
|
|
490
|
+
if (isNaN(body_size_limit)) throw new Error(`Invalid BODY_SIZE_LIMIT: '${env("BODY_SIZE_LIMIT")}'. Please provide a numeric value.`);
|
|
491
|
+
var asset_dir = `${dir}/client${base}`;
|
|
492
|
+
await server.init({
|
|
493
|
+
env: process.env,
|
|
494
|
+
read: (file) => createReadableStream(`${asset_dir}/${file}`)
|
|
495
|
+
});
|
|
496
|
+
/** @type {Middleware} */
|
|
497
|
+
var ssr = async (req, res) => {
|
|
498
|
+
/** @type {Request} */
|
|
499
|
+
let request;
|
|
500
|
+
let request_origin = origin;
|
|
501
|
+
if (!request_origin) try {
|
|
502
|
+
request_origin = get_origin(req.headers);
|
|
503
|
+
} catch (error) {
|
|
504
|
+
console.error(`Could not determine request origin: ${error instanceof Error ? error.message : String(error)}`);
|
|
505
|
+
res.statusCode = 400;
|
|
506
|
+
res.end("Bad Request");
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
try {
|
|
510
|
+
request = getRequest({
|
|
511
|
+
base: request_origin,
|
|
512
|
+
request: req,
|
|
513
|
+
response: res,
|
|
514
|
+
bodySizeLimit: body_size_limit
|
|
515
|
+
});
|
|
516
|
+
} catch {
|
|
517
|
+
res.statusCode = 400;
|
|
518
|
+
res.end("Bad Request");
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
const response = await server.respond(request, {
|
|
522
|
+
platform: { req },
|
|
523
|
+
getClientAddress: () => {
|
|
524
|
+
if (address_header) {
|
|
525
|
+
if (!(address_header in req.headers)) throw new Error(`Address header was specified with ${env_prefix + "ADDRESS_HEADER"}=${address_header} but is absent from request`);
|
|
526
|
+
const value = req.headers[address_header] || "";
|
|
527
|
+
if (address_header === "x-forwarded-for") {
|
|
528
|
+
const addresses = value.split(",");
|
|
529
|
+
if (xff_depth < 1) throw new Error(`${env_prefix + "XFF_DEPTH"} must be a positive integer`);
|
|
530
|
+
if (xff_depth > addresses.length) throw new Error(`${env_prefix + "XFF_DEPTH"} is ${xff_depth}, but only found ${addresses.length} addresses`);
|
|
531
|
+
return addresses[addresses.length - xff_depth].trim();
|
|
532
|
+
}
|
|
533
|
+
return value;
|
|
534
|
+
}
|
|
535
|
+
return req.connection?.remoteAddress || req.connection?.socket?.remoteAddress || req.socket?.remoteAddress || req.info?.remoteAddress;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
if (response.headers.get("content-type") === "text/event-stream") response.headers.set("x-accel-buffering", "no");
|
|
539
|
+
setResponse(res, response);
|
|
540
|
+
};
|
|
541
|
+
/**
|
|
542
|
+
* @param {string} name
|
|
543
|
+
* @param {string | string[] | undefined} value
|
|
544
|
+
* @returns {string | undefined}
|
|
545
|
+
*/
|
|
546
|
+
function normalise_header(name, value) {
|
|
547
|
+
if (!name) return void 0;
|
|
548
|
+
if (Array.isArray(value)) {
|
|
549
|
+
if (value.length === 0) return void 0;
|
|
550
|
+
if (value.length === 1) return value[0];
|
|
551
|
+
throw new Error(`Multiple values provided for ${name} header where only one expected: ${value}`);
|
|
552
|
+
}
|
|
553
|
+
return value;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* @param {IncomingHttpHeaders} headers
|
|
557
|
+
* @returns {string}
|
|
558
|
+
*/
|
|
559
|
+
function get_origin(headers) {
|
|
560
|
+
const protocol = decodeURIComponent(normalise_header(protocol_header, headers[protocol_header]) || "https");
|
|
561
|
+
if (protocol.includes(":")) throw new Error(`The ${protocol_header} header specified ${protocol} which is an invalid because it includes \`:\`. It should only contain the protocol scheme (e.g. \`https\`)`);
|
|
562
|
+
const host = normalise_header(host_header, headers[host_header]) || normalise_header("host", headers["host"]);
|
|
563
|
+
if (!host) {
|
|
564
|
+
const header_names = host_header ? `${host_header} or host headers` : "host header";
|
|
565
|
+
throw new Error(`Could not determine host. The request must have a value provided by the ${header_names}`);
|
|
566
|
+
}
|
|
567
|
+
const port = normalise_header(port_header, headers[port_header]);
|
|
568
|
+
if (port && isNaN(+port)) throw new Error(`The ${port_header} header specified ${port} which is an invalid port because it is not a number. The value should only contain the port number (e.g. 443)`);
|
|
569
|
+
return port ? `${protocol}://${host}:${port}` : `${protocol}://${host}`;
|
|
570
|
+
}
|
|
571
|
+
var serve = serve_static(create_file_map({
|
|
572
|
+
dir,
|
|
573
|
+
base,
|
|
574
|
+
app_path,
|
|
575
|
+
mime_types,
|
|
576
|
+
assets,
|
|
577
|
+
prerendered_assets
|
|
578
|
+
}));
|
|
579
|
+
/** @type {Middleware} */
|
|
580
|
+
var handler = (req, res, next) => serve(req, res, () => ssr(req, res, next));
|
|
581
|
+
//#endregion
|
|
582
|
+
export { format_listening_address as n, handler as t };
|
|
583
|
+
|
|
584
|
+
//# sourceMappingURL=adapter-node-handler.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region .svelte-kit/generated/build/env/config.js
|
|
2
|
+
var variables = {};
|
|
3
|
+
var dynamic_private_env = {};
|
|
4
|
+
var explicit_public_env = {};
|
|
5
|
+
var rendered_env = {};
|
|
6
|
+
function set_env(env) {}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { variables as a, set_env as i, explicit_public_env as n, rendered_env as r, dynamic_private_env as t };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { G as server_api_unavailable } from "./server-errors.js";
|
|
2
|
+
//#region node_modules/@sveltejs/kit/src/utils/functions.js
|
|
3
|
+
function noop() {}
|
|
4
|
+
/**
|
|
5
|
+
* @template T
|
|
6
|
+
* @param {() => T} fn
|
|
7
|
+
*/
|
|
8
|
+
function once(fn) {
|
|
9
|
+
let done = false;
|
|
10
|
+
/** @type T */
|
|
11
|
+
let result;
|
|
12
|
+
return () => {
|
|
13
|
+
if (done) return result;
|
|
14
|
+
done = true;
|
|
15
|
+
return result = fn();
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} name
|
|
20
|
+
* @param {string} [parens]
|
|
21
|
+
*/
|
|
22
|
+
function disallow_on_server(name, parens = "(...)") {
|
|
23
|
+
return () => {
|
|
24
|
+
server_api_unavailable({ name: `${name}${parens}` });
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { noop as n, once as r, disallow_on_server as t };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=functions.js.map
|