@eslym/sveltekit-adapter-bun 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/files/index.js +18 -18
- package/dist/index.js +29 -19
- package/package.json +1 -1
package/dist/files/index.js
CHANGED
|
@@ -12,14 +12,14 @@ await server.init({
|
|
|
12
12
|
|
|
13
13
|
// node_modules/cac/dist/index.mjs
|
|
14
14
|
import {EventEmitter} from "events";
|
|
15
|
-
|
|
15
|
+
function toArr(any) {
|
|
16
16
|
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
function toVal(out, key, val, opts) {
|
|
19
19
|
var x, old = out[key], nxt = ~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : ~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
20
20
|
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
21
|
-
}
|
|
22
|
-
|
|
21
|
+
}
|
|
22
|
+
function mri2(args, opts) {
|
|
23
23
|
args = args || [];
|
|
24
24
|
opts = opts || {};
|
|
25
25
|
var k, arr, arg, name, val, out = { _: [] };
|
|
@@ -111,7 +111,7 @@ var mri2 = function(args, opts) {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
return out;
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
115
|
var removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
116
116
|
var findAllBrackets = (v) => {
|
|
117
117
|
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
@@ -647,7 +647,7 @@ var mapping = {
|
|
|
647
647
|
};
|
|
648
648
|
|
|
649
649
|
// src/files/static.ts
|
|
650
|
-
|
|
650
|
+
function lookup(pathname) {
|
|
651
651
|
pathname = normalize(pathname);
|
|
652
652
|
let res = lookupTables.get(pathname);
|
|
653
653
|
if (res)
|
|
@@ -672,8 +672,8 @@ var lookup = function(pathname) {
|
|
|
672
672
|
pathname = pathname.at(-1) === "/" ? pathname.slice(0, -1) : pathname + "/";
|
|
673
673
|
if (lookupTables.has(pathname))
|
|
674
674
|
return [pathname];
|
|
675
|
-
}
|
|
676
|
-
|
|
675
|
+
}
|
|
676
|
+
function parse_range(header) {
|
|
677
677
|
if (!header.has("range"))
|
|
678
678
|
return false;
|
|
679
679
|
const range = header.get("range");
|
|
@@ -683,7 +683,7 @@ var parse_range = function(header) {
|
|
|
683
683
|
if (match[3])
|
|
684
684
|
return [true, +match[3], null];
|
|
685
685
|
return [true, +match[1], match[2] ? +match[2] + 1 : null];
|
|
686
|
-
}
|
|
686
|
+
}
|
|
687
687
|
function serve_static(request, basePath2) {
|
|
688
688
|
if (!methods.has(request.method))
|
|
689
689
|
return;
|
|
@@ -784,7 +784,7 @@ var lookupTables = new Map(PRE_RESOLVE_STATIC);
|
|
|
784
784
|
var methods = new Set(["HEAD", "GET"]);
|
|
785
785
|
|
|
786
786
|
// src/files/handle.ts
|
|
787
|
-
|
|
787
|
+
function clone_req(url, request) {
|
|
788
788
|
return new Request(url, {
|
|
789
789
|
method: request.method,
|
|
790
790
|
headers: request.headers,
|
|
@@ -797,7 +797,7 @@ var clone_req = function(url, request) {
|
|
|
797
797
|
redirect: request.redirect,
|
|
798
798
|
integrity: request.integrity
|
|
799
799
|
});
|
|
800
|
-
}
|
|
800
|
+
}
|
|
801
801
|
async function first_resolve(request, resolvers) {
|
|
802
802
|
const args = { request };
|
|
803
803
|
for (let i = 0;i < resolvers.length; i++) {
|
|
@@ -807,13 +807,13 @@ async function first_resolve(request, resolvers) {
|
|
|
807
807
|
return response;
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
|
-
|
|
810
|
+
function override_origin(args, origin) {
|
|
811
811
|
const url = get_url(args.request);
|
|
812
812
|
const newUrl = new URL(url.pathname + url.search, origin);
|
|
813
813
|
args.request = clone_req(newUrl, args.request);
|
|
814
814
|
set_url(args.request, newUrl);
|
|
815
|
-
}
|
|
816
|
-
|
|
815
|
+
}
|
|
816
|
+
function override_origin_with_header(args, hostHeader, protocolHeader) {
|
|
817
817
|
const url = get_url(args.request);
|
|
818
818
|
let newUrl = new URL(url);
|
|
819
819
|
if (hostHeader && args.request.headers.has(hostHeader)) {
|
|
@@ -826,13 +826,13 @@ var override_origin_with_header = function(args, hostHeader, protocolHeader) {
|
|
|
826
826
|
args.request = clone_req(newUrl, args.request);
|
|
827
827
|
set_url(args.request, newUrl);
|
|
828
828
|
}
|
|
829
|
-
}
|
|
830
|
-
|
|
829
|
+
}
|
|
830
|
+
function resolve_xff_ip(request, depth) {
|
|
831
831
|
if (!request.headers.has("x-forwarded-for"))
|
|
832
832
|
return;
|
|
833
833
|
const ips = request.headers.get("x-forwarded-for").split(",");
|
|
834
834
|
return ips.at(-depth) || undefined;
|
|
835
|
-
}
|
|
835
|
+
}
|
|
836
836
|
function create_fetch({
|
|
837
837
|
overrideOrigin,
|
|
838
838
|
hostHeader,
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ function is_plain_object(thing) {
|
|
|
31
31
|
function get_type(thing) {
|
|
32
32
|
return Object.prototype.toString.call(thing).slice(8, -1);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
function get_escaped_char(char) {
|
|
35
35
|
switch (char) {
|
|
36
36
|
case '"':
|
|
37
37
|
return '\\"';
|
|
@@ -56,7 +56,7 @@ var get_escaped_char = function(char) {
|
|
|
56
56
|
default:
|
|
57
57
|
return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|
|
60
60
|
function stringify_string(str) {
|
|
61
61
|
let result = "";
|
|
62
62
|
let last_pos = 0;
|
|
@@ -93,7 +93,7 @@ class DevalueError extends Error {
|
|
|
93
93
|
this.path = keys.join("");
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
var object_proto_names = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
96
|
+
var object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
97
97
|
|
|
98
98
|
// node_modules/devalue/src/uneval.js
|
|
99
99
|
function uneval(value, replacer) {
|
|
@@ -254,27 +254,27 @@ function uneval(value, replacer) {
|
|
|
254
254
|
return str;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
function get_name(num) {
|
|
258
258
|
let name2 = "";
|
|
259
259
|
do {
|
|
260
260
|
name2 = chars[num % chars.length] + name2;
|
|
261
261
|
num = ~~(num / chars.length) - 1;
|
|
262
262
|
} while (num >= 0);
|
|
263
263
|
return reserved.test(name2) ? `${name2}0` : name2;
|
|
264
|
-
}
|
|
265
|
-
|
|
264
|
+
}
|
|
265
|
+
function escape_unsafe_char(c) {
|
|
266
266
|
return escaped[c] || c;
|
|
267
|
-
}
|
|
268
|
-
|
|
267
|
+
}
|
|
268
|
+
function escape_unsafe_chars(str) {
|
|
269
269
|
return str.replace(unsafe_chars, escape_unsafe_char);
|
|
270
|
-
}
|
|
271
|
-
|
|
270
|
+
}
|
|
271
|
+
function safe_key(key) {
|
|
272
272
|
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
|
|
273
|
-
}
|
|
274
|
-
|
|
273
|
+
}
|
|
274
|
+
function safe_prop(key) {
|
|
275
275
|
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
|
|
276
|
-
}
|
|
277
|
-
|
|
276
|
+
}
|
|
277
|
+
function stringify_primitive(thing) {
|
|
278
278
|
if (typeof thing === "string")
|
|
279
279
|
return stringify_string(thing);
|
|
280
280
|
if (thing === undefined)
|
|
@@ -287,7 +287,7 @@ var stringify_primitive = function(thing) {
|
|
|
287
287
|
if (typeof thing === "bigint")
|
|
288
288
|
return thing + "n";
|
|
289
289
|
return str;
|
|
290
|
-
}
|
|
290
|
+
}
|
|
291
291
|
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
|
|
292
292
|
var unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
|
|
293
293
|
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
|
|
@@ -352,7 +352,17 @@ async function startDevServer({
|
|
|
352
352
|
const { createServer } = await import("vite");
|
|
353
353
|
const upgrades = new WeakMap;
|
|
354
354
|
globalThis[symUpgrades] = upgrades;
|
|
355
|
-
|
|
355
|
+
let sym = undefined;
|
|
356
|
+
let bunternal = (socket) => {
|
|
357
|
+
for (const key in socket) {
|
|
358
|
+
if (typeof key === "symbol" && `${key}`.includes("::bunternal::")) {
|
|
359
|
+
sym = key;
|
|
360
|
+
bunternal = () => sym;
|
|
361
|
+
return key;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
throw new Error("bunternal symbol not found");
|
|
365
|
+
};
|
|
356
366
|
const fakeServer = new EventEmitter;
|
|
357
367
|
const vite = await createServer({
|
|
358
368
|
configFile: config,
|
|
@@ -386,7 +396,7 @@ async function startDevServer({
|
|
|
386
396
|
const req = new IncomingMessage(request);
|
|
387
397
|
const res = new ServerResponse(req, respond);
|
|
388
398
|
const socket = req.socket;
|
|
389
|
-
socket[bunternal] = [server2, res, request];
|
|
399
|
+
socket[bunternal(socket)] = [server2, res, request];
|
|
390
400
|
req.once("error", raise);
|
|
391
401
|
res.once("error", raise);
|
|
392
402
|
if (request.headers.get("upgrade")) {
|
|
@@ -486,11 +496,11 @@ async function compress_file(file, format = "gz") {
|
|
|
486
496
|
const destination = createWriteStream(`${file}.${format}`);
|
|
487
497
|
await pipeline(source, compress2, destination);
|
|
488
498
|
}
|
|
489
|
-
|
|
499
|
+
function exportSetupCLI(out) {
|
|
490
500
|
let src = readFileSync(`${out}/index.js`, "utf8");
|
|
491
501
|
const result = src.replace(/^export\s*{/gm, "export {\nget_hooks,\n");
|
|
492
502
|
writeFileSync(`${out}/index.js`, result, "utf8");
|
|
493
|
-
}
|
|
503
|
+
}
|
|
494
504
|
var files = fileURLToPath(new URL("./files", import.meta.url));
|
|
495
505
|
function adapter(userOpts = {}) {
|
|
496
506
|
const opts = {
|
package/package.json
CHANGED