Erster Docker-Stand

This commit is contained in:
Ali
2026-02-20 16:06:40 +09:00
commit f31e2e8ed3
8818 changed files with 1605323 additions and 0 deletions

20
_node_modules/hono/dist/helper/accepts/accepts.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
// src/helper/accepts/accepts.ts
import { parseAccept } from "../../utils/accept.js";
var defaultMatch = (accepts2, config) => {
const { supports, default: defaultSupport } = config;
const accept = accepts2.sort((a, b) => b.q - a.q).find((accept2) => supports.includes(accept2.type));
return accept ? accept.type : defaultSupport;
};
var accepts = (c, options) => {
const acceptHeader = c.req.header(options.header);
if (!acceptHeader) {
return options.default;
}
const accepts2 = parseAccept(acceptHeader);
const match = options.match || defaultMatch;
return match(accepts2, options);
};
export {
accepts,
defaultMatch
};

5
_node_modules/hono/dist/helper/accepts/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// src/helper/accepts/index.ts
import { accepts } from "./accepts.js";
export {
accepts
};

56
_node_modules/hono/dist/helper/adapter/index.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
// src/helper/adapter/index.ts
var env = (c, runtime) => {
const global = globalThis;
const globalEnv = global?.process?.env;
runtime ??= getRuntimeKey();
const runtimeEnvHandlers = {
bun: () => globalEnv,
node: () => globalEnv,
"edge-light": () => globalEnv,
deno: () => {
return Deno.env.toObject();
},
workerd: () => c.env,
// On Fastly Compute, you can use the ConfigStore to manage user-defined data.
fastly: () => ({}),
other: () => ({})
};
return runtimeEnvHandlers[runtime]();
};
var knownUserAgents = {
deno: "Deno",
bun: "Bun",
workerd: "Cloudflare-Workers",
node: "Node.js"
};
var getRuntimeKey = () => {
const global = globalThis;
const userAgentSupported = typeof navigator !== "undefined" && typeof navigator.userAgent === "string";
if (userAgentSupported) {
for (const [runtimeKey, userAgent] of Object.entries(knownUserAgents)) {
if (checkUserAgentEquals(userAgent)) {
return runtimeKey;
}
}
}
if (typeof global?.EdgeRuntime === "string") {
return "edge-light";
}
if (global?.fastly !== void 0) {
return "fastly";
}
if (global?.process?.release?.name === "node") {
return "node";
}
return "other";
};
var checkUserAgentEquals = (platform) => {
const userAgent = navigator.userAgent;
return userAgent.startsWith(platform);
};
export {
checkUserAgentEquals,
env,
getRuntimeKey,
knownUserAgents
};

0
_node_modules/hono/dist/helper/conninfo/index.js generated vendored Normal file
View File

0
_node_modules/hono/dist/helper/conninfo/types.js generated vendored Normal file
View File

102
_node_modules/hono/dist/helper/cookie/index.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
// src/helper/cookie/index.ts
import { parse, parseSigned, serialize, serializeSigned } from "../../utils/cookie.js";
var getCookie = (c, key, prefix) => {
const cookie = c.req.raw.headers.get("Cookie");
if (typeof key === "string") {
if (!cookie) {
return void 0;
}
let finalKey = key;
if (prefix === "secure") {
finalKey = "__Secure-" + key;
} else if (prefix === "host") {
finalKey = "__Host-" + key;
}
const obj2 = parse(cookie, finalKey);
return obj2[finalKey];
}
if (!cookie) {
return {};
}
const obj = parse(cookie);
return obj;
};
var getSignedCookie = async (c, secret, key, prefix) => {
const cookie = c.req.raw.headers.get("Cookie");
if (typeof key === "string") {
if (!cookie) {
return void 0;
}
let finalKey = key;
if (prefix === "secure") {
finalKey = "__Secure-" + key;
} else if (prefix === "host") {
finalKey = "__Host-" + key;
}
const obj2 = await parseSigned(cookie, secret, finalKey);
return obj2[finalKey];
}
if (!cookie) {
return {};
}
const obj = await parseSigned(cookie, secret);
return obj;
};
var generateCookie = (name, value, opt) => {
let cookie;
if (opt?.prefix === "secure") {
cookie = serialize("__Secure-" + name, value, { path: "/", ...opt, secure: true });
} else if (opt?.prefix === "host") {
cookie = serialize("__Host-" + name, value, {
...opt,
path: "/",
secure: true,
domain: void 0
});
} else {
cookie = serialize(name, value, { path: "/", ...opt });
}
return cookie;
};
var setCookie = (c, name, value, opt) => {
const cookie = generateCookie(name, value, opt);
c.header("Set-Cookie", cookie, { append: true });
};
var generateSignedCookie = async (name, value, secret, opt) => {
let cookie;
if (opt?.prefix === "secure") {
cookie = await serializeSigned("__Secure-" + name, value, secret, {
path: "/",
...opt,
secure: true
});
} else if (opt?.prefix === "host") {
cookie = await serializeSigned("__Host-" + name, value, secret, {
...opt,
path: "/",
secure: true,
domain: void 0
});
} else {
cookie = await serializeSigned(name, value, secret, { path: "/", ...opt });
}
return cookie;
};
var setSignedCookie = async (c, name, value, secret, opt) => {
const cookie = await generateSignedCookie(name, value, secret, opt);
c.header("set-cookie", cookie, { append: true });
};
var deleteCookie = (c, name, opt) => {
const deletedCookie = getCookie(c, name, opt?.prefix);
setCookie(c, name, "", { ...opt, maxAge: 0 });
return deletedCookie;
};
export {
deleteCookie,
generateCookie,
generateSignedCookie,
getCookie,
getSignedCookie,
setCookie,
setSignedCookie
};

185
_node_modules/hono/dist/helper/css/common.js generated vendored Normal file
View File

@@ -0,0 +1,185 @@
// src/helper/css/common.ts
var PSEUDO_GLOBAL_SELECTOR = ":-hono-global";
var isPseudoGlobalSelectorRe = new RegExp(`^${PSEUDO_GLOBAL_SELECTOR}{(.*)}$`);
var DEFAULT_STYLE_ID = "hono-css";
var SELECTOR = /* @__PURE__ */ Symbol();
var CLASS_NAME = /* @__PURE__ */ Symbol();
var STYLE_STRING = /* @__PURE__ */ Symbol();
var SELECTORS = /* @__PURE__ */ Symbol();
var EXTERNAL_CLASS_NAMES = /* @__PURE__ */ Symbol();
var CSS_ESCAPED = /* @__PURE__ */ Symbol();
var IS_CSS_ESCAPED = /* @__PURE__ */ Symbol();
var rawCssString = (value) => {
return {
[CSS_ESCAPED]: value
};
};
var toHash = (str) => {
let i = 0, out = 11;
while (i < str.length) {
out = 101 * out + str.charCodeAt(i++) >>> 0;
}
return "css-" + out;
};
var cssStringReStr = [
'"(?:(?:\\\\[\\s\\S]|[^"\\\\])*)"',
// double quoted string
"'(?:(?:\\\\[\\s\\S]|[^'\\\\])*)'"
// single quoted string
].join("|");
var minifyCssRe = new RegExp(
[
"(" + cssStringReStr + ")",
// $1: quoted string
"(?:" + [
"^\\s+",
// head whitespace
"\\/\\*.*?\\*\\/\\s*",
// multi-line comment
"\\/\\/.*\\n\\s*",
// single-line comment
"\\s+$"
// tail whitespace
].join("|") + ")",
"\\s*;\\s*(}|$)\\s*",
// $2: trailing semicolon
"\\s*([{};:,])\\s*",
// $3: whitespace around { } : , ;
"(\\s)\\s+"
// $4: 2+ spaces
].join("|"),
"g"
);
var minify = (css) => {
return css.replace(minifyCssRe, (_, $1, $2, $3, $4) => $1 || $2 || $3 || $4 || "");
};
var buildStyleString = (strings, values) => {
const selectors = [];
const externalClassNames = [];
const label = strings[0].match(/^\s*\/\*(.*?)\*\//)?.[1] || "";
let styleString = "";
for (let i = 0, len = strings.length; i < len; i++) {
styleString += strings[i];
let vArray = values[i];
if (typeof vArray === "boolean" || vArray === null || vArray === void 0) {
continue;
}
if (!Array.isArray(vArray)) {
vArray = [vArray];
}
for (let j = 0, len2 = vArray.length; j < len2; j++) {
let value = vArray[j];
if (typeof value === "boolean" || value === null || value === void 0) {
continue;
}
if (typeof value === "string") {
if (/([\\"'\/])/.test(value)) {
styleString += value.replace(/([\\"']|(?<=<)\/)/g, "\\$1");
} else {
styleString += value;
}
} else if (typeof value === "number") {
styleString += value;
} else if (value[CSS_ESCAPED]) {
styleString += value[CSS_ESCAPED];
} else if (value[CLASS_NAME].startsWith("@keyframes ")) {
selectors.push(value);
styleString += ` ${value[CLASS_NAME].substring(11)} `;
} else {
if (strings[i + 1]?.match(/^\s*{/)) {
selectors.push(value);
value = `.${value[CLASS_NAME]}`;
} else {
selectors.push(...value[SELECTORS]);
externalClassNames.push(...value[EXTERNAL_CLASS_NAMES]);
value = value[STYLE_STRING];
const valueLen = value.length;
if (valueLen > 0) {
const lastChar = value[valueLen - 1];
if (lastChar !== ";" && lastChar !== "}") {
value += ";";
}
}
}
styleString += `${value || ""}`;
}
}
}
return [label, minify(styleString), selectors, externalClassNames];
};
var cssCommon = (strings, values) => {
let [label, thisStyleString, selectors, externalClassNames] = buildStyleString(strings, values);
const isPseudoGlobal = isPseudoGlobalSelectorRe.exec(thisStyleString);
if (isPseudoGlobal) {
thisStyleString = isPseudoGlobal[1];
}
const selector = (isPseudoGlobal ? PSEUDO_GLOBAL_SELECTOR : "") + toHash(label + thisStyleString);
const className = (isPseudoGlobal ? selectors.map((s) => s[CLASS_NAME]) : [selector, ...externalClassNames]).join(" ");
return {
[SELECTOR]: selector,
[CLASS_NAME]: className,
[STYLE_STRING]: thisStyleString,
[SELECTORS]: selectors,
[EXTERNAL_CLASS_NAMES]: externalClassNames
};
};
var cxCommon = (args) => {
for (let i = 0, len = args.length; i < len; i++) {
const arg = args[i];
if (typeof arg === "string") {
args[i] = {
[SELECTOR]: "",
[CLASS_NAME]: "",
[STYLE_STRING]: "",
[SELECTORS]: [],
[EXTERNAL_CLASS_NAMES]: [arg]
};
}
}
return args;
};
var keyframesCommon = (strings, ...values) => {
const [label, styleString] = buildStyleString(strings, values);
return {
[SELECTOR]: "",
[CLASS_NAME]: `@keyframes ${toHash(label + styleString)}`,
[STYLE_STRING]: styleString,
[SELECTORS]: [],
[EXTERNAL_CLASS_NAMES]: []
};
};
var viewTransitionNameIndex = 0;
var viewTransitionCommon = ((strings, values) => {
if (!strings) {
strings = [`/* h-v-t ${viewTransitionNameIndex++} */`];
}
const content = Array.isArray(strings) ? cssCommon(strings, values) : strings;
const transitionName = content[CLASS_NAME];
const res = cssCommon(["view-transition-name:", ""], [transitionName]);
content[CLASS_NAME] = PSEUDO_GLOBAL_SELECTOR + content[CLASS_NAME];
content[STYLE_STRING] = content[STYLE_STRING].replace(
/(?<=::view-transition(?:[a-z-]*)\()(?=\))/g,
transitionName
);
res[CLASS_NAME] = res[SELECTOR] = transitionName;
res[SELECTORS] = [...content[SELECTORS], content];
return res;
});
export {
CLASS_NAME,
DEFAULT_STYLE_ID,
EXTERNAL_CLASS_NAMES,
IS_CSS_ESCAPED,
PSEUDO_GLOBAL_SELECTOR,
SELECTOR,
SELECTORS,
STYLE_STRING,
buildStyleString,
cssCommon,
cxCommon,
isPseudoGlobalSelectorRe,
keyframesCommon,
minify,
rawCssString,
viewTransitionCommon
};

125
_node_modules/hono/dist/helper/css/index.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
// src/helper/css/index.ts
import { raw } from "../../helper/html/index.js";
import { DOM_RENDERER } from "../../jsx/constants.js";
import { createCssJsxDomObjects } from "../../jsx/dom/css.js";
import {
CLASS_NAME,
DEFAULT_STYLE_ID,
PSEUDO_GLOBAL_SELECTOR,
SELECTOR,
SELECTORS,
STYLE_STRING,
cssCommon,
cxCommon,
keyframesCommon,
viewTransitionCommon
} from "./common.js";
import { rawCssString } from "./common.js";
var createCssContext = ({ id }) => {
const [cssJsxDomObject, StyleRenderToDom] = createCssJsxDomObjects({ id });
const contextMap = /* @__PURE__ */ new WeakMap();
const nonceMap = /* @__PURE__ */ new WeakMap();
const replaceStyleRe = new RegExp(`(<style id="${id}"(?: nonce="[^"]*")?>.*?)(</style>)`);
const newCssClassNameObject = (cssClassName) => {
const appendStyle = ({ buffer, context }) => {
const [toAdd, added] = contextMap.get(context);
const names = Object.keys(toAdd);
if (!names.length) {
return;
}
let stylesStr = "";
names.forEach((className2) => {
added[className2] = true;
stylesStr += className2.startsWith(PSEUDO_GLOBAL_SELECTOR) ? toAdd[className2] : `${className2[0] === "@" ? "" : "."}${className2}{${toAdd[className2]}}`;
});
contextMap.set(context, [{}, added]);
if (buffer && replaceStyleRe.test(buffer[0])) {
buffer[0] = buffer[0].replace(replaceStyleRe, (_, pre, post) => `${pre}${stylesStr}${post}`);
return;
}
const nonce = nonceMap.get(context);
const appendStyleScript = `<script${nonce ? ` nonce="${nonce}"` : ""}>document.querySelector('#${id}').textContent+=${JSON.stringify(stylesStr)}</script>`;
if (buffer) {
buffer[0] = `${appendStyleScript}${buffer[0]}`;
return;
}
return Promise.resolve(appendStyleScript);
};
const addClassNameToContext = ({ context }) => {
if (!contextMap.has(context)) {
contextMap.set(context, [{}, {}]);
}
const [toAdd, added] = contextMap.get(context);
let allAdded = true;
if (!added[cssClassName[SELECTOR]]) {
allAdded = false;
toAdd[cssClassName[SELECTOR]] = cssClassName[STYLE_STRING];
}
cssClassName[SELECTORS].forEach(
({ [CLASS_NAME]: className2, [STYLE_STRING]: styleString }) => {
if (!added[className2]) {
allAdded = false;
toAdd[className2] = styleString;
}
}
);
if (allAdded) {
return;
}
return Promise.resolve(raw("", [appendStyle]));
};
const className = new String(cssClassName[CLASS_NAME]);
Object.assign(className, cssClassName);
className.isEscaped = true;
className.callbacks = [addClassNameToContext];
const promise = Promise.resolve(className);
Object.assign(promise, cssClassName);
promise.toString = cssJsxDomObject.toString;
return promise;
};
const css2 = (strings, ...values) => {
return newCssClassNameObject(cssCommon(strings, values));
};
const cx2 = (...args) => {
args = cxCommon(args);
return css2(Array(args.length).fill(""), ...args);
};
const keyframes2 = keyframesCommon;
const viewTransition2 = ((strings, ...values) => {
return newCssClassNameObject(viewTransitionCommon(strings, values));
});
const Style2 = ({ children, nonce } = {}) => raw(
`<style id="${id}"${nonce ? ` nonce="${nonce}"` : ""}>${children ? children[STYLE_STRING] : ""}</style>`,
[
({ context }) => {
nonceMap.set(context, nonce);
return void 0;
}
]
);
Style2[DOM_RENDERER] = StyleRenderToDom;
return {
css: css2,
cx: cx2,
keyframes: keyframes2,
viewTransition: viewTransition2,
Style: Style2
};
};
var defaultContext = createCssContext({
id: DEFAULT_STYLE_ID
});
var css = defaultContext.css;
var cx = defaultContext.cx;
var keyframes = defaultContext.keyframes;
var viewTransition = defaultContext.viewTransition;
var Style = defaultContext.Style;
export {
Style,
createCssContext,
css,
cx,
keyframes,
rawCssString,
viewTransition
};

55
_node_modules/hono/dist/helper/dev/index.js generated vendored Normal file
View File

@@ -0,0 +1,55 @@
// src/helper/dev/index.ts
import { getColorEnabled } from "../../utils/color.js";
import { findTargetHandler, isMiddleware } from "../../utils/handler.js";
var handlerName = (handler) => {
return handler.name || (isMiddleware(handler) ? "[middleware]" : "[handler]");
};
var inspectRoutes = (hono) => {
return hono.routes.map(({ path, method, handler }) => {
const targetHandler = findTargetHandler(handler);
return {
path,
method,
name: handlerName(targetHandler),
isMiddleware: isMiddleware(targetHandler)
};
});
};
var showRoutes = (hono, opts) => {
const colorEnabled = opts?.colorize ?? getColorEnabled();
const routeData = {};
let maxMethodLength = 0;
let maxPathLength = 0;
inspectRoutes(hono).filter(({ isMiddleware: isMiddleware2 }) => opts?.verbose || !isMiddleware2).map((route) => {
const key = `${route.method}-${route.path}`;
(routeData[key] ||= []).push(route);
if (routeData[key].length > 1) {
return;
}
maxMethodLength = Math.max(maxMethodLength, route.method.length);
maxPathLength = Math.max(maxPathLength, route.path.length);
return { method: route.method, path: route.path, routes: routeData[key] };
}).forEach((data) => {
if (!data) {
return;
}
const { method, path, routes } = data;
const methodStr = colorEnabled ? `\x1B[32m${method}\x1B[0m` : method;
console.log(`${methodStr} ${" ".repeat(maxMethodLength - method.length)} ${path}`);
if (!opts?.verbose) {
return;
}
routes.forEach(({ name }) => {
console.log(`${" ".repeat(maxMethodLength + 3)} ${name}`);
});
});
};
var getRouterName = (app) => {
app.router.match("GET", "/");
return app.router.name;
};
export {
getRouterName,
inspectRoutes,
showRoutes
};

30
_node_modules/hono/dist/helper/factory/index.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
// src/helper/factory/index.ts
import { Hono } from "../../hono.js";
var Factory = class {
initApp;
#defaultAppOptions;
constructor(init) {
this.initApp = init?.initApp;
this.#defaultAppOptions = init?.defaultAppOptions;
}
createApp = (options) => {
const app = new Hono(
options && this.#defaultAppOptions ? { ...this.#defaultAppOptions, ...options } : options ?? this.#defaultAppOptions
);
if (this.initApp) {
this.initApp(app);
}
return app;
};
createMiddleware = (middleware) => middleware;
createHandlers = (...handlers) => {
return handlers.filter((handler) => handler !== void 0);
};
};
var createFactory = (init) => new Factory(init);
var createMiddleware = (middleware) => middleware;
export {
Factory,
createFactory,
createMiddleware
};

41
_node_modules/hono/dist/helper/html/index.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
// src/helper/html/index.ts
import { escapeToBuffer, raw, resolveCallbackSync, stringBufferToString } from "../../utils/html.js";
var html = (strings, ...values) => {
const buffer = [""];
for (let i = 0, len = strings.length - 1; i < len; i++) {
buffer[0] += strings[i];
const children = Array.isArray(values[i]) ? values[i].flat(Infinity) : [values[i]];
for (let i2 = 0, len2 = children.length; i2 < len2; i2++) {
const child = children[i2];
if (typeof child === "string") {
escapeToBuffer(child, buffer);
} else if (typeof child === "number") {
;
buffer[0] += child;
} else if (typeof child === "boolean" || child === null || child === void 0) {
continue;
} else if (typeof child === "object" && child.isEscaped) {
if (child.callbacks) {
buffer.unshift("", child);
} else {
const tmp = child.toString();
if (tmp instanceof Promise) {
buffer.unshift("", tmp);
} else {
buffer[0] += tmp;
}
}
} else if (child instanceof Promise) {
buffer.unshift("", child);
} else {
escapeToBuffer(child.toString(), buffer);
}
}
}
buffer[0] += strings.at(-1);
return buffer.length === 1 ? "callbacks" in buffer ? raw(resolveCallbackSync(raw(buffer[0], buffer.callbacks))) : raw(buffer[0]) : stringBufferToString(buffer, buffer.callbacks);
};
export {
html,
raw
};

89
_node_modules/hono/dist/helper/proxy/index.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
// src/helper/proxy/index.ts
import { HTTPException } from "../../http-exception.js";
var hopByHopHeaders = [
"connection",
"keep-alive",
"proxy-authenticate",
"proxy-authorization",
"te",
"trailer",
"transfer-encoding",
"upgrade"
];
var ALLOWED_TOKEN_PATTERN = /^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/;
var buildRequestInitFromRequest = (request, strictConnectionProcessing) => {
if (!request) {
return {};
}
const headers = new Headers(request.headers);
if (strictConnectionProcessing) {
const connectionValue = headers.get("connection");
if (connectionValue) {
const headerNames = connectionValue.split(",").map((h) => h.trim());
const invalidHeaders = headerNames.filter((h) => !ALLOWED_TOKEN_PATTERN.test(h));
if (invalidHeaders.length > 0) {
throw new HTTPException(400, {
message: `Invalid Connection header value: ${invalidHeaders.join(", ")}`
});
}
headerNames.forEach((headerName) => {
headers.delete(headerName);
});
}
}
hopByHopHeaders.forEach((header) => {
headers.delete(header);
});
return {
method: request.method,
body: request.body,
duplex: request.body ? "half" : void 0,
headers,
signal: request.signal
};
};
var preprocessRequestInit = (requestInit) => {
if (!requestInit.headers || Array.isArray(requestInit.headers) || requestInit.headers instanceof Headers) {
return requestInit;
}
const headers = new Headers();
for (const [key, value] of Object.entries(requestInit.headers)) {
if (value == null) {
headers.delete(key);
} else {
headers.set(key, value);
}
}
requestInit.headers = headers;
return requestInit;
};
var proxy = async (input, proxyInit) => {
const {
raw,
customFetch,
strictConnectionProcessing = false,
...requestInit
} = proxyInit instanceof Request ? { raw: proxyInit } : proxyInit ?? {};
const req = new Request(input, {
...buildRequestInitFromRequest(raw, strictConnectionProcessing),
...preprocessRequestInit(requestInit)
});
req.headers.delete("accept-encoding");
const res = await (customFetch || fetch)(req);
const resHeaders = new Headers(res.headers);
hopByHopHeaders.forEach((header) => {
resHeaders.delete(header);
});
if (resHeaders.has("content-encoding")) {
resHeaders.delete("content-encoding");
resHeaders.delete("content-length");
}
return new Response(res.body, {
status: res.status,
statusText: res.statusText,
headers: resHeaders
});
};
export {
proxy
};

46
_node_modules/hono/dist/helper/route/index.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
// src/helper/route/index.ts
import { GET_MATCH_RESULT } from "../../request/constants.js";
import { getPattern, splitRoutingPath } from "../../utils/url.js";
var matchedRoutes = (c) => (
// @ts-expect-error c.req[GET_MATCH_RESULT] is not typed
c.req[GET_MATCH_RESULT][0].map(([[, route]]) => route)
);
var routePath = (c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.path ?? "";
var baseRoutePath = (c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.basePath ?? "";
var basePathCacheMap = /* @__PURE__ */ new WeakMap();
var basePath = (c, index) => {
index ??= c.req.routeIndex;
const cache = basePathCacheMap.get(c) || [];
if (typeof cache[index] === "string") {
return cache[index];
}
let result;
const rp = baseRoutePath(c, index);
if (!/[:*]/.test(rp)) {
result = rp;
} else {
const paths = splitRoutingPath(rp);
const reqPath = c.req.path;
let basePathLength = 0;
for (let i = 0, len = paths.length; i < len; i++) {
const pattern = getPattern(paths[i], paths[i + 1]);
if (pattern) {
const re = pattern[2] === true || pattern === "*" ? /[^\/]+/ : pattern[2];
basePathLength += reqPath.substring(basePathLength + 1).match(re)?.[0].length || 0;
} else {
basePathLength += paths[i].length;
}
basePathLength += 1;
}
result = reqPath.substring(0, basePathLength);
}
cache[index] = result;
basePathCacheMap.set(c, cache);
return result;
};
export {
basePath,
baseRoutePath,
matchedRoutes,
routePath
};

16
_node_modules/hono/dist/helper/ssg/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
// src/helper/ssg/index.ts
export * from "./ssg.js";
import {
X_HONO_DISABLE_SSG_HEADER_KEY,
ssgParams,
isSSGContext,
disableSSG,
onlySSG
} from "./middleware.js";
export {
X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG,
isSSGContext,
onlySSG,
ssgParams
};

45
_node_modules/hono/dist/helper/ssg/middleware.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
// src/helper/ssg/middleware.ts
import { isDynamicRoute } from "./utils.js";
var SSG_CONTEXT = "HONO_SSG_CONTEXT";
var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
var SSG_DISABLED_RESPONSE = (() => {
try {
return new Response("SSG is disabled", {
status: 404,
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: "true" }
});
} catch {
return null;
}
})();
var ssgParams = (params) => async (c, next) => {
if (isDynamicRoute(c.req.path)) {
;
c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
return c.notFound();
}
await next();
};
var isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
var disableSSG = () => async function disableSSG2(c, next) {
if (isSSGContext(c)) {
c.header(X_HONO_DISABLE_SSG_HEADER_KEY, "true");
return c.notFound();
}
await next();
};
var onlySSG = () => async function onlySSG2(c, next) {
if (!isSSGContext(c)) {
return c.notFound();
}
await next();
};
export {
SSG_CONTEXT,
SSG_DISABLED_RESPONSE,
X_HONO_DISABLE_SSG_HEADER_KEY,
disableSSG,
isSSGContext,
onlySSG,
ssgParams
};

295
_node_modules/hono/dist/helper/ssg/ssg.js generated vendored Normal file
View File

@@ -0,0 +1,295 @@
// src/helper/ssg/ssg.ts
import { replaceUrlParam } from "../../client/utils.js";
import { createPool } from "../../utils/concurrent.js";
import { getExtension } from "../../utils/mime.js";
import { SSG_CONTEXT, X_HONO_DISABLE_SSG_HEADER_KEY } from "./middleware.js";
import { dirname, filterStaticGenerateRoutes, isDynamicRoute, joinPaths } from "./utils.js";
var DEFAULT_CONCURRENCY = 2;
var DEFAULT_CONTENT_TYPE = "text/plain";
var DEFAULT_OUTPUT_DIR = "./static";
var generateFilePath = (routePath, outDir, mimeType, extensionMap) => {
const extension = determineExtension(mimeType, extensionMap);
if (routePath.endsWith(`.${extension}`)) {
return joinPaths(outDir, routePath);
}
if (routePath === "/") {
return joinPaths(outDir, `index.${extension}`);
}
if (routePath.endsWith("/")) {
return joinPaths(outDir, routePath, `index.${extension}`);
}
return joinPaths(outDir, `${routePath}.${extension}`);
};
var parseResponseContent = async (response) => {
const contentType = response.headers.get("Content-Type");
try {
if (contentType?.includes("text") || contentType?.includes("json")) {
return await response.text();
} else {
return await response.arrayBuffer();
}
} catch (error) {
throw new Error(
`Error processing response: ${error instanceof Error ? error.message : "Unknown error"}`
);
}
};
var defaultExtensionMap = {
"text/html": "html",
"text/xml": "xml",
"application/xml": "xml",
"application/yaml": "yaml"
};
var determineExtension = (mimeType, userExtensionMap) => {
const extensionMap = userExtensionMap || defaultExtensionMap;
if (mimeType in extensionMap) {
return extensionMap[mimeType];
}
return getExtension(mimeType) || "html";
};
var combineBeforeRequestHooks = (hooks) => {
if (!Array.isArray(hooks)) {
return hooks;
}
return async (req) => {
let currentReq = req;
for (const hook of hooks) {
const result = await hook(currentReq);
if (result === false) {
return false;
}
if (result instanceof Request) {
currentReq = result;
}
}
return currentReq;
};
};
var combineAfterResponseHooks = (hooks) => {
if (!Array.isArray(hooks)) {
return hooks;
}
return async (res) => {
let currentRes = res;
for (const hook of hooks) {
const result = await hook(currentRes);
if (result === false) {
return false;
}
if (result instanceof Response) {
currentRes = result;
}
}
return currentRes;
};
};
var combineAfterGenerateHooks = (hooks, fsModule, options) => {
if (!Array.isArray(hooks)) {
return hooks;
}
return async (result) => {
for (const hook of hooks) {
await hook(result, fsModule, options);
}
};
};
var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, concurrency) {
const baseURL = "http://localhost";
const pool = createPool({ concurrency });
for (const route of filterStaticGenerateRoutes(app)) {
const thisRouteBaseURL = new URL(route.path, baseURL).toString();
let forGetInfoURLRequest = new Request(thisRouteBaseURL);
yield new Promise(async (resolveGetInfo, rejectGetInfo) => {
try {
if (beforeRequestHook) {
const maybeRequest = await beforeRequestHook(forGetInfoURLRequest);
if (!maybeRequest) {
resolveGetInfo(void 0);
return;
}
forGetInfoURLRequest = maybeRequest;
}
await pool.run(() => app.fetch(forGetInfoURLRequest));
if (!forGetInfoURLRequest.ssgParams) {
if (isDynamicRoute(route.path)) {
resolveGetInfo(void 0);
return;
}
forGetInfoURLRequest.ssgParams = [{}];
}
const requestInit = {
method: forGetInfoURLRequest.method,
headers: forGetInfoURLRequest.headers
};
resolveGetInfo(
(function* () {
for (const param of forGetInfoURLRequest.ssgParams) {
yield new Promise(async (resolveReq, rejectReq) => {
try {
const replacedUrlParam = replaceUrlParam(route.path, param);
let response = await pool.run(
() => app.request(replacedUrlParam, requestInit, {
[SSG_CONTEXT]: true
})
);
if (response.headers.get(X_HONO_DISABLE_SSG_HEADER_KEY)) {
resolveReq(void 0);
return;
}
if (afterResponseHook) {
const maybeResponse = await afterResponseHook(response);
if (!maybeResponse) {
resolveReq(void 0);
return;
}
response = maybeResponse;
}
const mimeType = response.headers.get("Content-Type")?.split(";")[0] || DEFAULT_CONTENT_TYPE;
const content = await parseResponseContent(response);
resolveReq({
routePath: replacedUrlParam,
mimeType,
content
});
} catch (error) {
rejectReq(error);
}
});
}
})()
);
} catch (error) {
rejectGetInfo(error);
}
});
}
};
var createdDirs = /* @__PURE__ */ new Set();
var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
const awaitedData = await data;
if (!awaitedData) {
return;
}
const { routePath, content, mimeType } = awaitedData;
const filePath = generateFilePath(routePath, outDir, mimeType, extensionMap);
const dirPath = dirname(filePath);
if (!createdDirs.has(dirPath)) {
await fsModule.mkdir(dirPath, { recursive: true });
createdDirs.add(dirPath);
}
if (typeof content === "string") {
await fsModule.writeFile(filePath, content);
} else if (content instanceof ArrayBuffer) {
await fsModule.writeFile(filePath, new Uint8Array(content));
}
return filePath;
};
var defaultPlugin = {
afterResponseHook: (res) => {
if (res.status !== 200) {
return false;
}
return res;
}
};
var toSSG = async (app, fs, options) => {
let result;
const getInfoPromises = [];
const savePromises = [];
const plugins = options?.plugins || [defaultPlugin];
const beforeRequestHooks = [];
const afterResponseHooks = [];
const afterGenerateHooks = [];
if (options?.beforeRequestHook) {
beforeRequestHooks.push(
...Array.isArray(options.beforeRequestHook) ? options.beforeRequestHook : [options.beforeRequestHook]
);
}
if (options?.afterResponseHook) {
afterResponseHooks.push(
...Array.isArray(options.afterResponseHook) ? options.afterResponseHook : [options.afterResponseHook]
);
}
if (options?.afterGenerateHook) {
afterGenerateHooks.push(
...Array.isArray(options.afterGenerateHook) ? options.afterGenerateHook : [options.afterGenerateHook]
);
}
for (const plugin of plugins) {
if (plugin.beforeRequestHook) {
beforeRequestHooks.push(
...Array.isArray(plugin.beforeRequestHook) ? plugin.beforeRequestHook : [plugin.beforeRequestHook]
);
}
if (plugin.afterResponseHook) {
afterResponseHooks.push(
...Array.isArray(plugin.afterResponseHook) ? plugin.afterResponseHook : [plugin.afterResponseHook]
);
}
if (plugin.afterGenerateHook) {
afterGenerateHooks.push(
...Array.isArray(plugin.afterGenerateHook) ? plugin.afterGenerateHook : [plugin.afterGenerateHook]
);
}
}
try {
const outputDir = options?.dir ?? DEFAULT_OUTPUT_DIR;
const concurrency = options?.concurrency ?? DEFAULT_CONCURRENCY;
const combinedBeforeRequestHook = combineBeforeRequestHooks(
beforeRequestHooks.length > 0 ? beforeRequestHooks : [(req) => req]
);
const combinedAfterResponseHook = combineAfterResponseHooks(
afterResponseHooks.length > 0 ? afterResponseHooks : [(req) => req]
);
const getInfoGen = fetchRoutesContent(
app,
combinedBeforeRequestHook,
combinedAfterResponseHook,
concurrency
);
for (const getInfo of getInfoGen) {
getInfoPromises.push(
getInfo.then((getContentGen) => {
if (!getContentGen) {
return;
}
for (const content of getContentGen) {
savePromises.push(
saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e)
);
}
})
);
}
await Promise.all(getInfoPromises);
const files = [];
for (const savePromise of savePromises) {
const fileOrError = await savePromise;
if (typeof fileOrError === "string") {
files.push(fileOrError);
} else if (fileOrError) {
throw fileOrError;
}
}
result = { success: true, files };
} catch (error) {
const errorObj = error instanceof Error ? error : new Error(String(error));
result = { success: false, files: [], error: errorObj };
}
if (afterGenerateHooks.length > 0) {
const combinedAfterGenerateHooks = combineAfterGenerateHooks(afterGenerateHooks, fs, options);
await combinedAfterGenerateHooks(result, fs, options);
}
return result;
};
export {
DEFAULT_OUTPUT_DIR,
combineAfterGenerateHooks,
combineAfterResponseHooks,
combineBeforeRequestHooks,
defaultExtensionMap,
defaultPlugin,
fetchRoutesContent,
saveContentToFile,
toSSG
};

59
_node_modules/hono/dist/helper/ssg/utils.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
// src/helper/ssg/utils.ts
import { METHOD_NAME_ALL } from "../../router.js";
import { findTargetHandler, isMiddleware } from "../../utils/handler.js";
var dirname = (path) => {
const separatedPath = path.split(/[\/\\]/);
return separatedPath.slice(0, -1).join("/");
};
var normalizePath = (path) => {
return path.replace(/(\\)/g, "/").replace(/\/$/g, "");
};
var handleParent = (resultPaths, beforeParentFlag) => {
if (resultPaths.length === 0 || beforeParentFlag) {
resultPaths.push("..");
} else {
resultPaths.pop();
}
};
var handleNonDot = (path, resultPaths) => {
path = path.replace(/^\.(?!.)/, "");
if (path !== "") {
resultPaths.push(path);
}
};
var handleSegments = (paths, resultPaths) => {
let beforeParentFlag = false;
for (const path of paths) {
if (path === "..") {
handleParent(resultPaths, beforeParentFlag);
beforeParentFlag = true;
} else {
handleNonDot(path, resultPaths);
beforeParentFlag = false;
}
}
};
var joinPaths = (...paths) => {
paths = paths.map(normalizePath);
const resultPaths = [];
handleSegments(paths.join("/").split("/"), resultPaths);
return (paths[0][0] === "/" ? "/" : "") + resultPaths.join("/");
};
var filterStaticGenerateRoutes = (hono) => {
return hono.routes.reduce((acc, { method, handler, path }) => {
const targetHandler = findTargetHandler(handler);
if (["GET", METHOD_NAME_ALL].includes(method) && !isMiddleware(targetHandler)) {
acc.push({ path });
}
return acc;
}, []);
};
var isDynamicRoute = (path) => {
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
};
export {
dirname,
filterStaticGenerateRoutes,
isDynamicRoute,
joinPaths
};

10
_node_modules/hono/dist/helper/streaming/index.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
// src/helper/streaming/index.ts
import { stream } from "./stream.js";
import { streamSSE, SSEStreamingApi } from "./sse.js";
import { streamText } from "./text.js";
export {
SSEStreamingApi,
stream,
streamSSE,
streamText
};

62
_node_modules/hono/dist/helper/streaming/sse.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
// src/helper/streaming/sse.ts
import { HtmlEscapedCallbackPhase, resolveCallback } from "../../utils/html.js";
import { StreamingApi } from "../../utils/stream.js";
import { isOldBunVersion } from "./utils.js";
var SSEStreamingApi = class extends StreamingApi {
constructor(writable, readable) {
super(writable, readable);
}
async writeSSE(message) {
const data = await resolveCallback(message.data, HtmlEscapedCallbackPhase.Stringify, false, {});
const dataLines = data.split("\n").map((line) => {
return `data: ${line}`;
}).join("\n");
const sseData = [
message.event && `event: ${message.event}`,
dataLines,
message.id && `id: ${message.id}`,
message.retry && `retry: ${message.retry}`
].filter(Boolean).join("\n") + "\n\n";
await this.write(sseData);
}
};
var run = async (stream, cb, onError) => {
try {
await cb(stream);
} catch (e) {
if (e instanceof Error && onError) {
await onError(e, stream);
await stream.writeSSE({
event: "error",
data: e.message
});
} else {
console.error(e);
}
} finally {
stream.close();
}
};
var contextStash = /* @__PURE__ */ new WeakMap();
var streamSSE = (c, cb, onError) => {
const { readable, writable } = new TransformStream();
const stream = new SSEStreamingApi(writable, readable);
if (isOldBunVersion()) {
c.req.raw.signal.addEventListener("abort", () => {
if (!stream.closed) {
stream.abort();
}
});
}
contextStash.set(stream.responseReadable, c);
c.header("Transfer-Encoding", "chunked");
c.header("Content-Type", "text/event-stream");
c.header("Cache-Control", "no-cache");
c.header("Connection", "keep-alive");
run(stream, cb, onError);
return c.newResponse(stream.responseReadable);
};
export {
SSEStreamingApi,
streamSSE
};

34
_node_modules/hono/dist/helper/streaming/stream.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
// src/helper/streaming/stream.ts
import { StreamingApi } from "../../utils/stream.js";
import { isOldBunVersion } from "./utils.js";
var contextStash = /* @__PURE__ */ new WeakMap();
var stream = (c, cb, onError) => {
const { readable, writable } = new TransformStream();
const stream2 = new StreamingApi(writable, readable);
if (isOldBunVersion()) {
c.req.raw.signal.addEventListener("abort", () => {
if (!stream2.closed) {
stream2.abort();
}
});
}
contextStash.set(stream2.responseReadable, c);
(async () => {
try {
await cb(stream2);
} catch (e) {
if (e === void 0) {
} else if (e instanceof Error && onError) {
await onError(e, stream2);
} else {
console.error(e);
}
} finally {
stream2.close();
}
})();
return c.newResponse(stream2.responseReadable);
};
export {
stream
};

12
_node_modules/hono/dist/helper/streaming/text.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
// src/helper/streaming/text.ts
import { TEXT_PLAIN } from "../../context.js";
import { stream } from "./index.js";
var streamText = (c, cb, onError) => {
c.header("Content-Type", TEXT_PLAIN);
c.header("X-Content-Type-Options", "nosniff");
c.header("Transfer-Encoding", "chunked");
return stream(c, cb, onError);
};
export {
streamText
};

13
_node_modules/hono/dist/helper/streaming/utils.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
// src/helper/streaming/utils.ts
var isOldBunVersion = () => {
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
if (version === void 0) {
return false;
}
const result = version.startsWith("1.1") || version.startsWith("1.0") || version.startsWith("0.");
isOldBunVersion = () => result;
return result;
};
export {
isOldBunVersion
};

11
_node_modules/hono/dist/helper/testing/index.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
// src/helper/testing/index.ts
import { hc } from "../../client/index.js";
var testClient = (app, Env, executionCtx, options) => {
const customFetch = (input, init) => {
return app.request(input, init, Env, executionCtx);
};
return hc("http://localhost", { ...options, fetch: customFetch });
};
export {
testClient
};

57
_node_modules/hono/dist/helper/websocket/index.js generated vendored Normal file
View File

@@ -0,0 +1,57 @@
// src/helper/websocket/index.ts
var WSContext = class {
#init;
constructor(init) {
this.#init = init;
this.raw = init.raw;
this.url = init.url ? new URL(init.url) : null;
this.protocol = init.protocol ?? null;
}
send(source, options) {
this.#init.send(source, options ?? {});
}
raw;
binaryType = "arraybuffer";
get readyState() {
return this.#init.readyState;
}
url;
protocol;
close(code, reason) {
this.#init.close(code, reason);
}
};
var createWSMessageEvent = (source) => {
return new MessageEvent("message", {
data: source
});
};
var defineWebSocketHelper = (handler) => {
return ((...args) => {
if (typeof args[0] === "function") {
const [createEvents, options] = args;
return async function upgradeWebSocket(c, next) {
const events = await createEvents(c);
const result = await handler(c, events, options);
if (result) {
return result;
}
await next();
};
} else {
const [c, events, options] = args;
return (async () => {
const upgraded = await handler(c, events, options);
if (!upgraded) {
throw new Error("Failed to upgrade WebSocket");
}
return upgraded;
})();
}
});
};
export {
WSContext,
createWSMessageEvent,
defineWebSocketHelper
};