@hono/node-server 1.19.14 → 2.0.0-rc.2

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 (63) hide show
  1. package/README.md +56 -18
  2. package/dist/conninfo.cjs +22 -0
  3. package/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
  4. package/dist/conninfo.d.mts +4 -3
  5. package/dist/conninfo.mjs +19 -16
  6. package/dist/constants-BLSFu_RU.mjs +5 -0
  7. package/dist/constants-BXAKTxRC.cjs +11 -0
  8. package/dist/index.cjs +1006 -0
  9. package/dist/index.d.cts +73 -0
  10. package/dist/index.d.mts +73 -8
  11. package/dist/index.mjs +976 -637
  12. package/dist/serve-static.cjs +135 -0
  13. package/dist/serve-static.d.cts +18 -0
  14. package/dist/serve-static.d.mts +14 -13
  15. package/dist/serve-static.mjs +127 -145
  16. package/dist/utils/response.cjs +8 -0
  17. package/dist/utils/response.d.cts +4 -0
  18. package/dist/utils/response.d.mts +3 -2
  19. package/dist/utils/response.mjs +6 -9
  20. package/package.json +53 -40
  21. package/dist/conninfo.js +0 -42
  22. package/dist/globals.d.mts +0 -2
  23. package/dist/globals.d.ts +0 -2
  24. package/dist/globals.js +0 -29
  25. package/dist/globals.mjs +0 -5
  26. package/dist/index.d.ts +0 -8
  27. package/dist/index.js +0 -702
  28. package/dist/listener.d.mts +0 -13
  29. package/dist/listener.d.ts +0 -13
  30. package/dist/listener.js +0 -670
  31. package/dist/listener.mjs +0 -635
  32. package/dist/request.d.mts +0 -25
  33. package/dist/request.d.ts +0 -25
  34. package/dist/request.js +0 -238
  35. package/dist/request.mjs +0 -206
  36. package/dist/response.d.mts +0 -26
  37. package/dist/response.d.ts +0 -26
  38. package/dist/response.js +0 -112
  39. package/dist/response.mjs +0 -85
  40. package/dist/serve-static.d.ts +0 -17
  41. package/dist/serve-static.js +0 -177
  42. package/dist/server.d.mts +0 -10
  43. package/dist/server.d.ts +0 -10
  44. package/dist/server.js +0 -696
  45. package/dist/server.mjs +0 -660
  46. package/dist/types.d.mts +0 -44
  47. package/dist/types.d.ts +0 -44
  48. package/dist/types.js +0 -18
  49. package/dist/types.mjs +0 -0
  50. package/dist/utils/response/constants.d.mts +0 -3
  51. package/dist/utils/response/constants.d.ts +0 -3
  52. package/dist/utils/response/constants.js +0 -30
  53. package/dist/utils/response/constants.mjs +0 -5
  54. package/dist/utils/response.d.ts +0 -3
  55. package/dist/utils/response.js +0 -37
  56. package/dist/utils.d.mts +0 -9
  57. package/dist/utils.d.ts +0 -9
  58. package/dist/utils.js +0 -99
  59. package/dist/utils.mjs +0 -71
  60. package/dist/vercel.d.mts +0 -7
  61. package/dist/vercel.d.ts +0 -7
  62. package/dist/vercel.js +0 -677
  63. package/dist/vercel.mjs +0 -640
@@ -0,0 +1,135 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let node_stream = require("node:stream");
3
+ let hono_utils_mime = require("hono/utils/mime");
4
+ let node_fs = require("node:fs");
5
+ let node_path = require("node:path");
6
+ let node_process = require("node:process");
7
+
8
+ //#region src/serve-static.ts
9
+ const 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;
10
+ const ENCODINGS = {
11
+ br: ".br",
12
+ zstd: ".zst",
13
+ gzip: ".gz"
14
+ };
15
+ const ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
16
+ const pr54206Applied = () => {
17
+ const [major, minor] = node_process.versions.node.split(".").map((component) => parseInt(component));
18
+ return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
19
+ };
20
+ const useReadableToWeb = pr54206Applied();
21
+ const createStreamBody = (stream) => {
22
+ if (useReadableToWeb) return node_stream.Readable.toWeb(stream);
23
+ return new ReadableStream({
24
+ start(controller) {
25
+ stream.on("data", (chunk) => {
26
+ controller.enqueue(chunk);
27
+ });
28
+ stream.on("error", (err) => {
29
+ controller.error(err);
30
+ });
31
+ stream.on("end", () => {
32
+ controller.close();
33
+ });
34
+ },
35
+ cancel() {
36
+ stream.destroy();
37
+ }
38
+ });
39
+ };
40
+ const getStats = (path) => {
41
+ let stats;
42
+ try {
43
+ stats = (0, node_fs.statSync)(path);
44
+ } catch {}
45
+ return stats;
46
+ };
47
+ const tryDecode = (str, decoder) => {
48
+ try {
49
+ return decoder(str);
50
+ } catch {
51
+ return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
52
+ try {
53
+ return decoder(match);
54
+ } catch {
55
+ return match;
56
+ }
57
+ });
58
+ }
59
+ };
60
+ const tryDecodeURI = (str) => tryDecode(str, decodeURI);
61
+ const serveStatic = (options = { root: "" }) => {
62
+ const root = options.root || "";
63
+ const optionPath = options.path;
64
+ if (root !== "" && !(0, node_fs.existsSync)(root)) console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
65
+ return async (c, next) => {
66
+ if (c.finalized) return next();
67
+ let filename;
68
+ if (optionPath) filename = optionPath;
69
+ else try {
70
+ filename = tryDecodeURI(c.req.path);
71
+ if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) throw new Error();
72
+ } catch {
73
+ await options.onNotFound?.(c.req.path, c);
74
+ return next();
75
+ }
76
+ let path = (0, node_path.join)(root, !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename);
77
+ let stats = getStats(path);
78
+ if (stats && stats.isDirectory()) {
79
+ const indexFile = options.index ?? "index.html";
80
+ path = (0, node_path.join)(path, indexFile);
81
+ stats = getStats(path);
82
+ }
83
+ if (!stats) {
84
+ await options.onNotFound?.(path, c);
85
+ return next();
86
+ }
87
+ const mimeType = (0, hono_utils_mime.getMimeType)(path);
88
+ c.header("Content-Type", mimeType || "application/octet-stream");
89
+ if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
90
+ const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim()));
91
+ for (const encoding of ENCODINGS_ORDERED_KEYS) {
92
+ if (!acceptEncodingSet.has(encoding)) continue;
93
+ const precompressedStats = getStats(path + ENCODINGS[encoding]);
94
+ if (precompressedStats) {
95
+ c.header("Content-Encoding", encoding);
96
+ c.header("Vary", "Accept-Encoding", { append: true });
97
+ stats = precompressedStats;
98
+ path = path + ENCODINGS[encoding];
99
+ break;
100
+ }
101
+ }
102
+ }
103
+ let result;
104
+ const size = stats.size;
105
+ const range = c.req.header("range") || "";
106
+ if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
107
+ c.header("Content-Length", size.toString());
108
+ c.status(200);
109
+ result = c.body(null);
110
+ } else if (!range) {
111
+ c.header("Content-Length", size.toString());
112
+ result = c.body(createStreamBody((0, node_fs.createReadStream)(path)), 200);
113
+ } else {
114
+ c.header("Accept-Ranges", "bytes");
115
+ c.header("Date", stats.birthtime.toUTCString());
116
+ const parts = range.replace(/bytes=/, "").split("-", 2);
117
+ const start = parseInt(parts[0], 10) || 0;
118
+ let end = parseInt(parts[1], 10) || size - 1;
119
+ if (size < end - start + 1) end = size - 1;
120
+ const chunksize = end - start + 1;
121
+ const stream = (0, node_fs.createReadStream)(path, {
122
+ start,
123
+ end
124
+ });
125
+ c.header("Content-Length", chunksize.toString());
126
+ c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
127
+ result = c.body(createStreamBody(stream), 206);
128
+ }
129
+ await options.onFound?.(path, c);
130
+ return result;
131
+ };
132
+ };
133
+
134
+ //#endregion
135
+ exports.serveStatic = serveStatic;
@@ -0,0 +1,18 @@
1
+ import { Context, Env, MiddlewareHandler } from "hono";
2
+
3
+ //#region src/serve-static.d.ts
4
+ type ServeStaticOptions<E extends Env = Env> = {
5
+ /**
6
+ * Root path, relative to current working directory from which the app was started. Absolute paths are not supported.
7
+ */
8
+ root?: string;
9
+ path?: string;
10
+ index?: string;
11
+ precompressed?: boolean;
12
+ rewriteRequestPath?: (path: string, c: Context<E>) => string;
13
+ onFound?: (path: string, c: Context<E>) => void | Promise<void>;
14
+ onNotFound?: (path: string, c: Context<E>) => void | Promise<void>;
15
+ };
16
+ declare const serveStatic: <E extends Env = any>(options?: ServeStaticOptions<E>) => MiddlewareHandler<E>;
17
+ //#endregion
18
+ export { ServeStaticOptions, serveStatic };
@@ -1,17 +1,18 @@
1
- import { Env, Context, MiddlewareHandler } from 'hono';
1
+ import { Context, Env, MiddlewareHandler } from "hono";
2
2
 
3
+ //#region src/serve-static.d.ts
3
4
  type ServeStaticOptions<E extends Env = Env> = {
4
- /**
5
- * Root path, relative to current working directory from which the app was started. Absolute paths are not supported.
6
- */
7
- root?: string;
8
- path?: string;
9
- index?: string;
10
- precompressed?: boolean;
11
- rewriteRequestPath?: (path: string, c: Context<E>) => string;
12
- onFound?: (path: string, c: Context<E>) => void | Promise<void>;
13
- onNotFound?: (path: string, c: Context<E>) => void | Promise<void>;
5
+ /**
6
+ * Root path, relative to current working directory from which the app was started. Absolute paths are not supported.
7
+ */
8
+ root?: string;
9
+ path?: string;
10
+ index?: string;
11
+ precompressed?: boolean;
12
+ rewriteRequestPath?: (path: string, c: Context<E>) => string;
13
+ onFound?: (path: string, c: Context<E>) => void | Promise<void>;
14
+ onNotFound?: (path: string, c: Context<E>) => void | Promise<void>;
14
15
  };
15
16
  declare const serveStatic: <E extends Env = any>(options?: ServeStaticOptions<E>) => MiddlewareHandler<E>;
16
-
17
- export { type ServeStaticOptions, serveStatic };
17
+ //#endregion
18
+ export { ServeStaticOptions, serveStatic };
@@ -1,152 +1,134 @@
1
- // src/serve-static.ts
1
+ import { Readable } from "node:stream";
2
2
  import { getMimeType } from "hono/utils/mime";
3
- import { createReadStream, statSync, existsSync } from "fs";
4
- import { join } from "path";
5
- import { versions } from "process";
6
- import { Readable } from "stream";
7
- 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;
8
- var ENCODINGS = {
9
- br: ".br",
10
- zstd: ".zst",
11
- gzip: ".gz"
3
+ import { createReadStream, existsSync, statSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { versions } from "node:process";
6
+
7
+ //#region src/serve-static.ts
8
+ const 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;
9
+ const ENCODINGS = {
10
+ br: ".br",
11
+ zstd: ".zst",
12
+ gzip: ".gz"
12
13
  };
13
- var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
14
- var pr54206Applied = () => {
15
- const [major, minor] = versions.node.split(".").map((component) => parseInt(component));
16
- return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
14
+ const ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
15
+ const pr54206Applied = () => {
16
+ const [major, minor] = versions.node.split(".").map((component) => parseInt(component));
17
+ return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
17
18
  };
18
- var useReadableToWeb = pr54206Applied();
19
- var createStreamBody = (stream) => {
20
- if (useReadableToWeb) {
21
- return Readable.toWeb(stream);
22
- }
23
- const body = new ReadableStream({
24
- start(controller) {
25
- stream.on("data", (chunk) => {
26
- controller.enqueue(chunk);
27
- });
28
- stream.on("error", (err) => {
29
- controller.error(err);
30
- });
31
- stream.on("end", () => {
32
- controller.close();
33
- });
34
- },
35
- cancel() {
36
- stream.destroy();
37
- }
38
- });
39
- return body;
19
+ const useReadableToWeb = pr54206Applied();
20
+ const createStreamBody = (stream) => {
21
+ if (useReadableToWeb) return Readable.toWeb(stream);
22
+ return new ReadableStream({
23
+ start(controller) {
24
+ stream.on("data", (chunk) => {
25
+ controller.enqueue(chunk);
26
+ });
27
+ stream.on("error", (err) => {
28
+ controller.error(err);
29
+ });
30
+ stream.on("end", () => {
31
+ controller.close();
32
+ });
33
+ },
34
+ cancel() {
35
+ stream.destroy();
36
+ }
37
+ });
40
38
  };
41
- var getStats = (path) => {
42
- let stats;
43
- try {
44
- stats = statSync(path);
45
- } catch {
46
- }
47
- return stats;
39
+ const getStats = (path) => {
40
+ let stats;
41
+ try {
42
+ stats = statSync(path);
43
+ } catch {}
44
+ return stats;
48
45
  };
49
- var tryDecode = (str, decoder) => {
50
- try {
51
- return decoder(str);
52
- } catch {
53
- return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
54
- try {
55
- return decoder(match);
56
- } catch {
57
- return match;
58
- }
59
- });
60
- }
46
+ const tryDecode = (str, decoder) => {
47
+ try {
48
+ return decoder(str);
49
+ } catch {
50
+ return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
51
+ try {
52
+ return decoder(match);
53
+ } catch {
54
+ return match;
55
+ }
56
+ });
57
+ }
61
58
  };
62
- var tryDecodeURI = (str) => tryDecode(str, decodeURI);
63
- var serveStatic = (options = { root: "" }) => {
64
- const root = options.root || "";
65
- const optionPath = options.path;
66
- if (root !== "" && !existsSync(root)) {
67
- console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
68
- }
69
- return async (c, next) => {
70
- if (c.finalized) {
71
- return next();
72
- }
73
- let filename;
74
- if (optionPath) {
75
- filename = optionPath;
76
- } else {
77
- try {
78
- filename = tryDecodeURI(c.req.path);
79
- if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) {
80
- throw new Error();
81
- }
82
- } catch {
83
- await options.onNotFound?.(c.req.path, c);
84
- return next();
85
- }
86
- }
87
- let path = join(
88
- root,
89
- !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
90
- );
91
- let stats = getStats(path);
92
- if (stats && stats.isDirectory()) {
93
- const indexFile = options.index ?? "index.html";
94
- path = join(path, indexFile);
95
- stats = getStats(path);
96
- }
97
- if (!stats) {
98
- await options.onNotFound?.(path, c);
99
- return next();
100
- }
101
- const mimeType = getMimeType(path);
102
- c.header("Content-Type", mimeType || "application/octet-stream");
103
- if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
104
- const acceptEncodingSet = new Set(
105
- c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim())
106
- );
107
- for (const encoding of ENCODINGS_ORDERED_KEYS) {
108
- if (!acceptEncodingSet.has(encoding)) {
109
- continue;
110
- }
111
- const precompressedStats = getStats(path + ENCODINGS[encoding]);
112
- if (precompressedStats) {
113
- c.header("Content-Encoding", encoding);
114
- c.header("Vary", "Accept-Encoding", { append: true });
115
- stats = precompressedStats;
116
- path = path + ENCODINGS[encoding];
117
- break;
118
- }
119
- }
120
- }
121
- let result;
122
- const size = stats.size;
123
- const range = c.req.header("range") || "";
124
- if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
125
- c.header("Content-Length", size.toString());
126
- c.status(200);
127
- result = c.body(null);
128
- } else if (!range) {
129
- c.header("Content-Length", size.toString());
130
- result = c.body(createStreamBody(createReadStream(path)), 200);
131
- } else {
132
- c.header("Accept-Ranges", "bytes");
133
- c.header("Date", stats.birthtime.toUTCString());
134
- const parts = range.replace(/bytes=/, "").split("-", 2);
135
- const start = parseInt(parts[0], 10) || 0;
136
- let end = parseInt(parts[1], 10) || size - 1;
137
- if (size < end - start + 1) {
138
- end = size - 1;
139
- }
140
- const chunksize = end - start + 1;
141
- const stream = createReadStream(path, { start, end });
142
- c.header("Content-Length", chunksize.toString());
143
- c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
144
- result = c.body(createStreamBody(stream), 206);
145
- }
146
- await options.onFound?.(path, c);
147
- return result;
148
- };
149
- };
150
- export {
151
- serveStatic
59
+ const tryDecodeURI = (str) => tryDecode(str, decodeURI);
60
+ const serveStatic = (options = { root: "" }) => {
61
+ const root = options.root || "";
62
+ const optionPath = options.path;
63
+ if (root !== "" && !existsSync(root)) console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
64
+ return async (c, next) => {
65
+ if (c.finalized) return next();
66
+ let filename;
67
+ if (optionPath) filename = optionPath;
68
+ else try {
69
+ filename = tryDecodeURI(c.req.path);
70
+ if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) throw new Error();
71
+ } catch {
72
+ await options.onNotFound?.(c.req.path, c);
73
+ return next();
74
+ }
75
+ let path = join(root, !optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename);
76
+ let stats = getStats(path);
77
+ if (stats && stats.isDirectory()) {
78
+ const indexFile = options.index ?? "index.html";
79
+ path = join(path, indexFile);
80
+ stats = getStats(path);
81
+ }
82
+ if (!stats) {
83
+ await options.onNotFound?.(path, c);
84
+ return next();
85
+ }
86
+ const mimeType = getMimeType(path);
87
+ c.header("Content-Type", mimeType || "application/octet-stream");
88
+ if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
89
+ const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim()));
90
+ for (const encoding of ENCODINGS_ORDERED_KEYS) {
91
+ if (!acceptEncodingSet.has(encoding)) continue;
92
+ const precompressedStats = getStats(path + ENCODINGS[encoding]);
93
+ if (precompressedStats) {
94
+ c.header("Content-Encoding", encoding);
95
+ c.header("Vary", "Accept-Encoding", { append: true });
96
+ stats = precompressedStats;
97
+ path = path + ENCODINGS[encoding];
98
+ break;
99
+ }
100
+ }
101
+ }
102
+ let result;
103
+ const size = stats.size;
104
+ const range = c.req.header("range") || "";
105
+ if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
106
+ c.header("Content-Length", size.toString());
107
+ c.status(200);
108
+ result = c.body(null);
109
+ } else if (!range) {
110
+ c.header("Content-Length", size.toString());
111
+ result = c.body(createStreamBody(createReadStream(path)), 200);
112
+ } else {
113
+ c.header("Accept-Ranges", "bytes");
114
+ c.header("Date", stats.birthtime.toUTCString());
115
+ const parts = range.replace(/bytes=/, "").split("-", 2);
116
+ const start = parseInt(parts[0], 10) || 0;
117
+ let end = parseInt(parts[1], 10) || size - 1;
118
+ if (size < end - start + 1) end = size - 1;
119
+ const chunksize = end - start + 1;
120
+ const stream = createReadStream(path, {
121
+ start,
122
+ end
123
+ });
124
+ c.header("Content-Length", chunksize.toString());
125
+ c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
126
+ result = c.body(createStreamBody(stream), 206);
127
+ }
128
+ await options.onFound?.(path, c);
129
+ return result;
130
+ };
152
131
  };
132
+
133
+ //#endregion
134
+ export { serveStatic };
@@ -0,0 +1,8 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_constants = require('../constants-BXAKTxRC.cjs');
3
+
4
+ //#region src/utils/response.ts
5
+ const RESPONSE_ALREADY_SENT = new Response(null, { headers: { [require_constants.X_ALREADY_SENT]: "true" } });
6
+
7
+ //#endregion
8
+ exports.RESPONSE_ALREADY_SENT = RESPONSE_ALREADY_SENT;
@@ -0,0 +1,4 @@
1
+ //#region src/utils/response.d.ts
2
+ declare const RESPONSE_ALREADY_SENT: Response;
3
+ //#endregion
4
+ export { RESPONSE_ALREADY_SENT };
@@ -1,3 +1,4 @@
1
+ //#region src/utils/response.d.ts
1
2
  declare const RESPONSE_ALREADY_SENT: Response;
2
-
3
- export { RESPONSE_ALREADY_SENT };
3
+ //#endregion
4
+ export { RESPONSE_ALREADY_SENT };
@@ -1,10 +1,7 @@
1
- // src/utils/response/constants.ts
2
- var X_ALREADY_SENT = "x-hono-already-sent";
1
+ import { t as X_ALREADY_SENT } from "../constants-BLSFu_RU.mjs";
3
2
 
4
- // src/utils/response.ts
5
- var RESPONSE_ALREADY_SENT = new Response(null, {
6
- headers: { [X_ALREADY_SENT]: "true" }
7
- });
8
- export {
9
- RESPONSE_ALREADY_SENT
10
- };
3
+ //#region src/utils/response.ts
4
+ const RESPONSE_ALREADY_SENT = new Response(null, { headers: { [X_ALREADY_SENT]: "true" } });
5
+
6
+ //#endregion
7
+ export { RESPONSE_ALREADY_SENT };