react-router-hono-server 2.16.0 → 2.17.0-next.1
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/README.md +4 -0
- package/dist/adapters/aws-lambda.js +5 -2
- package/dist/adapters/bun.js +4 -4
- package/dist/adapters/cloudflare.js +3 -2
- package/dist/adapters/node.js +10 -6
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/chunk-OKB2FS67.js +483 -0
- package/dist/chunk-QDN4PJRA.js +128 -0
- package/dist/{chunk-IZYOBD55.js → chunk-XPXQNPY3.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/cloudflare-SMC4F7QZ.js +50 -0
- package/dist/dev.js +1821 -20
- package/dist/http.js +2 -0
- package/dist/middleware.js +1 -0
- package/dist/serve-static-6NLY75NK.js +7 -0
- package/package.json +23 -13
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// node_modules/.pnpm/@hono+node-server@1.14.1_hono@4.8.5/node_modules/@hono/node-server/dist/serve-static.mjs
|
|
2
|
+
import { getFilePath, getFilePathWithoutDefaultDocument } from "hono/utils/filepath";
|
|
3
|
+
import { getMimeType } from "hono/utils/mime";
|
|
4
|
+
import { createReadStream, lstatSync } from "fs";
|
|
5
|
+
var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
6
|
+
var ENCODINGS = {
|
|
7
|
+
br: ".br",
|
|
8
|
+
zstd: ".zst",
|
|
9
|
+
gzip: ".gz"
|
|
10
|
+
};
|
|
11
|
+
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
12
|
+
var createStreamBody = (stream) => {
|
|
13
|
+
const body = new ReadableStream({
|
|
14
|
+
start(controller) {
|
|
15
|
+
stream.on("data", (chunk) => {
|
|
16
|
+
controller.enqueue(chunk);
|
|
17
|
+
});
|
|
18
|
+
stream.on("end", () => {
|
|
19
|
+
controller.close();
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
cancel() {
|
|
23
|
+
stream.destroy();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return body;
|
|
27
|
+
};
|
|
28
|
+
var addCurrentDirPrefix = (path) => {
|
|
29
|
+
return `./${path}`;
|
|
30
|
+
};
|
|
31
|
+
var getStats = (path) => {
|
|
32
|
+
let stats;
|
|
33
|
+
try {
|
|
34
|
+
stats = lstatSync(path);
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
return stats;
|
|
38
|
+
};
|
|
39
|
+
var serveStatic = (options = { root: "" }) => {
|
|
40
|
+
return async (c, next) => {
|
|
41
|
+
if (c.finalized) {
|
|
42
|
+
return next();
|
|
43
|
+
}
|
|
44
|
+
let filename;
|
|
45
|
+
try {
|
|
46
|
+
filename = options.path ?? decodeURIComponent(c.req.path);
|
|
47
|
+
} catch {
|
|
48
|
+
await options.onNotFound?.(c.req.path, c);
|
|
49
|
+
return next();
|
|
50
|
+
}
|
|
51
|
+
let path = getFilePathWithoutDefaultDocument({
|
|
52
|
+
filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
|
|
53
|
+
root: options.root
|
|
54
|
+
});
|
|
55
|
+
if (path) {
|
|
56
|
+
path = addCurrentDirPrefix(path);
|
|
57
|
+
} else {
|
|
58
|
+
return next();
|
|
59
|
+
}
|
|
60
|
+
let stats = getStats(path);
|
|
61
|
+
if (stats && stats.isDirectory()) {
|
|
62
|
+
path = getFilePath({
|
|
63
|
+
filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
|
|
64
|
+
root: options.root,
|
|
65
|
+
defaultDocument: options.index ?? "index.html"
|
|
66
|
+
});
|
|
67
|
+
if (path) {
|
|
68
|
+
path = addCurrentDirPrefix(path);
|
|
69
|
+
} else {
|
|
70
|
+
return next();
|
|
71
|
+
}
|
|
72
|
+
stats = getStats(path);
|
|
73
|
+
}
|
|
74
|
+
if (!stats) {
|
|
75
|
+
await options.onNotFound?.(path, c);
|
|
76
|
+
return next();
|
|
77
|
+
}
|
|
78
|
+
await options.onFound?.(path, c);
|
|
79
|
+
const mimeType = getMimeType(path);
|
|
80
|
+
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
81
|
+
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
82
|
+
const acceptEncodingSet = new Set(
|
|
83
|
+
c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim())
|
|
84
|
+
);
|
|
85
|
+
for (const encoding of ENCODINGS_ORDERED_KEYS) {
|
|
86
|
+
if (!acceptEncodingSet.has(encoding)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const precompressedStats = getStats(path + ENCODINGS[encoding]);
|
|
90
|
+
if (precompressedStats) {
|
|
91
|
+
c.header("Content-Encoding", encoding);
|
|
92
|
+
c.header("Vary", "Accept-Encoding", { append: true });
|
|
93
|
+
stats = precompressedStats;
|
|
94
|
+
path = path + ENCODINGS[encoding];
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const size = stats.size;
|
|
100
|
+
if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
|
|
101
|
+
c.header("Content-Length", size.toString());
|
|
102
|
+
c.status(200);
|
|
103
|
+
return c.body(null);
|
|
104
|
+
}
|
|
105
|
+
const range = c.req.header("range") || "";
|
|
106
|
+
if (!range) {
|
|
107
|
+
c.header("Content-Length", size.toString());
|
|
108
|
+
return c.body(createStreamBody(createReadStream(path)), 200);
|
|
109
|
+
}
|
|
110
|
+
c.header("Accept-Ranges", "bytes");
|
|
111
|
+
c.header("Date", stats.birthtime.toUTCString());
|
|
112
|
+
const parts = range.replace(/bytes=/, "").split("-", 2);
|
|
113
|
+
const start = parts[0] ? parseInt(parts[0], 10) : 0;
|
|
114
|
+
let end = parts[1] ? parseInt(parts[1], 10) : stats.size - 1;
|
|
115
|
+
if (size < end - start + 1) {
|
|
116
|
+
end = size - 1;
|
|
117
|
+
}
|
|
118
|
+
const chunksize = end - start + 1;
|
|
119
|
+
const stream = createReadStream(path, { start, end });
|
|
120
|
+
c.header("Content-Length", chunksize.toString());
|
|
121
|
+
c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
122
|
+
return c.body(createStreamBody(stream), 206);
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
serveStatic
|
|
128
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// src/cli.ts
|
|
3
|
-
import fs from "
|
|
4
|
-
import path from "
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
5
|
import { command, run } from "@drizzle-team/brocli";
|
|
6
6
|
var runtimeRegex = /runtime:\s*(['"])([^'"]*)\1/;
|
|
7
7
|
function guessRuntime() {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "./chunk-JSBRDJBE.js";
|
|
2
|
+
|
|
3
|
+
// node_modules/.pnpm/@hono+vite-dev-server@0.20.0_hono@4.8.5_miniflare@3.20250408.2_wrangler@4.26.0_@cloudflare+workers-types@4.20250724.0_/node_modules/@hono/vite-dev-server/dist/adapter/cloudflare.js
|
|
4
|
+
import { WebSocketPair } from "miniflare";
|
|
5
|
+
import { getPlatformProxy } from "wrangler";
|
|
6
|
+
Object.assign(globalThis, { WebSocketPair });
|
|
7
|
+
var proxy = void 0;
|
|
8
|
+
var cloudflareAdapter = async (options) => {
|
|
9
|
+
proxy ??= await getPlatformProxy(options?.proxy);
|
|
10
|
+
Object.assign(globalThis, { caches: proxy.caches });
|
|
11
|
+
if (typeof globalThis.navigator === "undefined") {
|
|
12
|
+
globalThis.navigator = {
|
|
13
|
+
userAgent: "Cloudflare-Workers"
|
|
14
|
+
};
|
|
15
|
+
} else {
|
|
16
|
+
Object.defineProperty(globalThis.navigator, "userAgent", {
|
|
17
|
+
value: "Cloudflare-Workers",
|
|
18
|
+
writable: false
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(Request.prototype, "cf", {
|
|
22
|
+
get: function() {
|
|
23
|
+
if (proxy !== void 0) {
|
|
24
|
+
return proxy.cf;
|
|
25
|
+
}
|
|
26
|
+
throw new Error("Proxy is not initialized");
|
|
27
|
+
},
|
|
28
|
+
configurable: true,
|
|
29
|
+
enumerable: true
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
env: proxy.env,
|
|
33
|
+
executionContext: proxy.ctx,
|
|
34
|
+
onServerClose: async () => {
|
|
35
|
+
if (proxy !== void 0) {
|
|
36
|
+
try {
|
|
37
|
+
await proxy.dispose();
|
|
38
|
+
} catch {
|
|
39
|
+
} finally {
|
|
40
|
+
proxy = void 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var cloudflare_default = cloudflareAdapter;
|
|
47
|
+
export {
|
|
48
|
+
cloudflareAdapter,
|
|
49
|
+
cloudflare_default as default
|
|
50
|
+
};
|