@withl5e/l5e 0.2.2 → 0.2.3
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/entry-server.js +142 -10
- package/dist/entry-server.js.map +1 -1
- package/dist/index-BlfNBupp.js +318 -0
- package/dist/index-BlfNBupp.js.map +1 -0
- package/dist/index.js +31 -32
- package/dist/index.js.map +1 -1
- package/dist/middleware.js +3 -5
- package/dist/render-BF7iTagJ.js +202 -0
- package/dist/render-BF7iTagJ.js.map +1 -0
- package/dist/server.js +250 -244
- package/dist/server.js.map +1 -1
- package/dist/vite-plugin.js +97 -97
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +4 -1
- package/src/core/entry-server.ts +16 -7
- package/src/core/index.ts +0 -2
- package/src/core/render.ts +36 -0
- package/src/core/request.ts +11 -10
- package/src/core/server.ts +23 -9
- package/src/core/vite-plugin.ts +13 -0
- package/src/middleware/index.ts +0 -48
- package/dist/entry-server-DJzzhCmz.js +0 -224
- package/dist/entry-server-DJzzhCmz.js.map +0 -1
- package/dist/index-BIt7MJT9.js +0 -163
- package/dist/index-BIt7MJT9.js.map +0 -1
package/dist/entry-server.js
CHANGED
|
@@ -1,13 +1,145 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import {
|
|
5
|
-
import "virtual:l5e-views";
|
|
6
|
-
import "virtual:l5e-route";
|
|
7
|
-
import "virtual:l5e-global-loader";
|
|
8
|
-
import { loadMiddleware as
|
|
1
|
+
import { r as p, s as I } from "./render-BF7iTagJ.js";
|
|
2
|
+
import { M as B } from "./generateMetadata-DLMaI0EO.js";
|
|
3
|
+
import { N as z, I as R, R as G, H as U, S as b } from "./exceptions-CHPz01DJ.js";
|
|
4
|
+
import { o as Y, s as V, b as H, p as P, l as T, k as g, i as K, a as Q, H as W, d as D, e as j, h as X, g as Z, f as k } from "./jsx-runtime-DVQ9eOji.js";
|
|
5
|
+
import { viewLoaders as N, viewComponents as u } from "virtual:l5e-views";
|
|
6
|
+
import q from "virtual:l5e-route";
|
|
7
|
+
import { globalLoader as $ } from "virtual:l5e-global-loader";
|
|
8
|
+
import { loadMiddleware as me } from "virtual:l5e-middleware";
|
|
9
|
+
async function O(n, a) {
|
|
10
|
+
const t = "_error", o = `/src/views/${t}/index.tsx`;
|
|
11
|
+
V(t);
|
|
12
|
+
const i = u[o] ? await u[o]() : null;
|
|
13
|
+
if (i?.default) {
|
|
14
|
+
const l = {
|
|
15
|
+
statusCode: n.statusCode,
|
|
16
|
+
message: n.message,
|
|
17
|
+
data: n.data
|
|
18
|
+
}, w = i.default, s = p(g(w, l)), f = D(), v = j(), m = k(), E = m.length > 0 ? m.map((r) => p(r)).join(`
|
|
19
|
+
`) : void 0;
|
|
20
|
+
return {
|
|
21
|
+
html: s,
|
|
22
|
+
scripts: f.map((r) => r.path),
|
|
23
|
+
styles: v.map((r) => r.path),
|
|
24
|
+
head: E,
|
|
25
|
+
lang: a,
|
|
26
|
+
statusCode: n.statusCode
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
const l = g("div", {}, `${n.statusCode} - ${n.message}`);
|
|
30
|
+
return {
|
|
31
|
+
html: p(l),
|
|
32
|
+
statusCode: n.statusCode
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function ce(n, a = {}) {
|
|
37
|
+
return Y(async () => {
|
|
38
|
+
try {
|
|
39
|
+
const t = await q(a);
|
|
40
|
+
if (!t)
|
|
41
|
+
throw new z("Page not found", {
|
|
42
|
+
path: a.path,
|
|
43
|
+
pathname: a.pathname,
|
|
44
|
+
url: a.url?.href
|
|
45
|
+
});
|
|
46
|
+
const o = typeof t == "string" ? t : t.view;
|
|
47
|
+
a.params = typeof t == "string" ? {} : t.params ?? {}, V(o);
|
|
48
|
+
let i = {}, l;
|
|
49
|
+
const w = "/src/global-loader.ts", s = $[w] ? await $[w]() : null;
|
|
50
|
+
if (s?.loader)
|
|
51
|
+
if (s.shouldIgnore?.(o) || !1)
|
|
52
|
+
console.info(`Global loader ignored for view: ${o}`);
|
|
53
|
+
else {
|
|
54
|
+
const d = await s.loader(a);
|
|
55
|
+
i = d.props || {}, l = d.lang, d.cacheTags && H(d.cacheTags);
|
|
56
|
+
}
|
|
57
|
+
let f = {}, v, m, E, r = !1;
|
|
58
|
+
const x = `/src/views/${o}/loader.ts`, c = N[x] ? await N[x]() : null;
|
|
59
|
+
if (c?.loader) {
|
|
60
|
+
const e = await c.loader(a);
|
|
61
|
+
if (e.rawResponse)
|
|
62
|
+
return {
|
|
63
|
+
rawResponse: e.rawResponse,
|
|
64
|
+
statusCode: e.rawResponse.statusCode || 200
|
|
65
|
+
};
|
|
66
|
+
f = e.props || {}, v = e.maxAge, m = e.sMaxAge, E = e.swr, r = e.rawHtml || !1, e.cacheTags && H(e.cacheTags), e.lang && (l = e.lang);
|
|
67
|
+
} else
|
|
68
|
+
console.info(`No loader for view: ${o}`);
|
|
69
|
+
const h = { ...i, ...f };
|
|
70
|
+
if (s?.generateMetadata) {
|
|
71
|
+
const e = s.generateMetadata(a, h);
|
|
72
|
+
e && P(e);
|
|
73
|
+
}
|
|
74
|
+
if (c?.generateMetadata) {
|
|
75
|
+
const e = c.generateMetadata(a, h);
|
|
76
|
+
e && P(e);
|
|
77
|
+
}
|
|
78
|
+
if (s?.generateSchema) {
|
|
79
|
+
const e = s.generateSchema(a, h);
|
|
80
|
+
e && T(e);
|
|
81
|
+
}
|
|
82
|
+
if (c?.generateSchema) {
|
|
83
|
+
const e = c.generateSchema(a, h);
|
|
84
|
+
e && T(e);
|
|
85
|
+
}
|
|
86
|
+
const C = `/src/views/${o}/index.tsx`, S = (u[C] ? await u[C]() : null)?.default;
|
|
87
|
+
if (!S)
|
|
88
|
+
throw console.error(`View component not found: ${o}`), process.env.NODE_ENV !== "production" ? new R(`View component not found: "${o}"`, {
|
|
89
|
+
viewName: o,
|
|
90
|
+
expectedPath: C,
|
|
91
|
+
availableViews: Object.keys(u),
|
|
92
|
+
hint: `Make sure the view component exists at ${C} and exports a default component`,
|
|
93
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
94
|
+
}) : new R("Internal Server Error");
|
|
95
|
+
p(g(B, {})), K().forEach((e) => {
|
|
96
|
+
const d = I(e, { isJSON: !0 });
|
|
97
|
+
Q({
|
|
98
|
+
priority: W.SEO,
|
|
99
|
+
children: g("script", {
|
|
100
|
+
type: "application/ld+json",
|
|
101
|
+
setHtml: d
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
const A = p(g(S, h)), L = D(), J = j(), M = X(), _ = Z(), y = k(), F = y.length > 0 ? y.map((e) => p(e)).join(`
|
|
106
|
+
`) : void 0;
|
|
107
|
+
return {
|
|
108
|
+
html: A,
|
|
109
|
+
scripts: L.map((e) => e.path),
|
|
110
|
+
styles: J.map((e) => e.path),
|
|
111
|
+
islands: M.length > 0 ? M : void 0,
|
|
112
|
+
head: F,
|
|
113
|
+
lang: l,
|
|
114
|
+
maxAge: v,
|
|
115
|
+
sMaxAge: m,
|
|
116
|
+
swr: E,
|
|
117
|
+
cacheTags: _,
|
|
118
|
+
rawHtml: r
|
|
119
|
+
};
|
|
120
|
+
} catch (t) {
|
|
121
|
+
if (t instanceof G)
|
|
122
|
+
return {
|
|
123
|
+
html: "",
|
|
124
|
+
redirect: {
|
|
125
|
+
url: t.url,
|
|
126
|
+
statusCode: t.statusCode
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
if (t instanceof U)
|
|
130
|
+
return await O(t);
|
|
131
|
+
console.error("Failed to render:", t);
|
|
132
|
+
const i = process.env.NODE_ENV === "production" ? new b("Internal Server Error") : new b(t.message || "Internal Server Error", {
|
|
133
|
+
originalError: t.name,
|
|
134
|
+
stack: t.stack,
|
|
135
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
136
|
+
});
|
|
137
|
+
return await O(i);
|
|
138
|
+
}
|
|
139
|
+
}, a);
|
|
140
|
+
}
|
|
9
141
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
142
|
+
me as loadMiddleware,
|
|
143
|
+
ce as render
|
|
12
144
|
};
|
|
13
145
|
//# sourceMappingURL=entry-server.js.map
|
package/dist/entry-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-server.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"entry-server.js","sources":["../src/core/entry-server.ts"],"sourcesContent":["/// <reference path=\"./jsx-types.d.ts\" />\nimport serialize from 'serialize-javascript';\nimport { MetadataRenderer } from '../seo/generateMetadata';\nimport type { Metadata } from '../seo/types';\nimport {\n HttpException,\n InternalServerErrorException,\n NotFoundException,\n RedirectException,\n ServiceUnavailableException,\n} from './exceptions';\nimport { HEAD_PRIORITY } from './head-priority';\nimport {\n addCacheTag,\n getCacheTags,\n getClientJsEntries,\n getCssEntries,\n getHeadContent,\n getIslandEntries,\n getSchemas,\n jsxFactory as h,\n Head,\n pushMetadata,\n pushSchema,\n runInRenderContext,\n setViewName,\n} from './jsx-runtime';\nimport { renderJsxToHtmlString } from './render';\n// @ts-ignore - Virtual modules provided by Vite plugin\nimport { viewComponents, viewLoaders } from 'virtual:l5e-views';\n// @ts-ignore - Virtual modules provided by Vite plugin\nimport routeHandler from 'virtual:l5e-route';\n// @ts-ignore - Virtual modules provided by Vite plugin\nimport { globalLoader } from 'virtual:l5e-global-loader';\n// @ts-ignore - Virtual modules provided by Vite plugin\nexport { loadMiddleware } from 'virtual:l5e-middleware';\n\nexport interface RawResponse {\n body: string | Buffer;\n contentType: string;\n statusCode?: number;\n headers?: Record<string, string>;\n}\n\nexport interface RenderResult {\n html?: string;\n scripts?: string[];\n styles?: string[];\n islands?: Array<{ key: string; src: string; name: string }>;\n head?: string;\n lang?: string;\n statusCode?: number;\n maxAge?: number;\n sMaxAge?: number;\n swr?: number;\n cacheTags?: string[];\n redirect?: { url: string; statusCode: number };\n rawResponse?: RawResponse;\n rawHtml?: boolean;\n}\n\nexport interface RequestInfo {\n url?: URL;\n path?: string;\n pathname?: string;\n method?: string;\n headers?: Record<string, any>;\n cookies?: Record<string, string>;\n query?: Record<string, any>;\n ip?: string;\n locals?: Record<string, unknown>;\n params?: Record<string, any>;\n}\n\nexport type RouteResult =\n | string\n | null\n | { view: string; params?: Record<string, any> };\n\n// SchemaMarkup type - có thể là single schema hoặc array of schemas\n// Sử dụng any để tương thích với schema-dts types từ frontend\nexport type SchemaMarkup = any | Array<any>;\n\nexport interface LoaderResult {\n props?: Record<string, any>;\n lang?: string;\n maxAge?: number;\n sMaxAge?: number;\n swr?: number;\n cacheTags?: string[] | Record<string, boolean>;\n rawResponse?: RawResponse;\n rawHtml?: boolean;\n}\n\nexport type LoaderFunction = (requestInfo: RequestInfo) => Promise<LoaderResult>;\n\nexport type GenerateMetadataFunction = (requestInfo: RequestInfo, props: any) => Metadata | null;\n\nexport type GenerateSchemaFunction = (requestInfo: RequestInfo, props: any) => SchemaMarkup | null;\n\nexport interface GlobalLoaderModule {\n loader: LoaderFunction;\n generateMetadata?: GenerateMetadataFunction;\n generateSchema?: GenerateSchemaFunction;\n shouldIgnore?: (viewName: string) => boolean;\n}\n\n/**\n * Helper function to render error view\n */\nasync function renderErrorView(err: HttpException, lang?: string): Promise<RenderResult> {\n const errorViewName = `_error`;\n const errorComponentPath = `/src/views/${errorViewName}/index.tsx`;\n\n // Set error view name in context\n setViewName(errorViewName);\n\n // Try to load error view\n const errorComponentModule = viewComponents[errorComponentPath]\n ? await viewComponents[errorComponentPath]()\n : null;\n\n if (errorComponentModule?.default) {\n // Render error view with exception data\n const errorProps = {\n statusCode: err.statusCode,\n message: err.message,\n data: err.data,\n };\n\n const Component = errorComponentModule.default;\n const htmlBody = renderJsxToHtmlString(h(Component, errorProps));\n const clientEntries = getClientJsEntries();\n const cssEntries = getCssEntries();\n const headContent = getHeadContent();\n\n const headHtml =\n headContent.length > 0\n ? headContent.map((content) => renderJsxToHtmlString(content)).join('\\n ')\n : undefined;\n\n return {\n html: htmlBody,\n scripts: clientEntries.map((entry) => entry.path),\n styles: cssEntries.map((entry) => entry.path),\n head: headHtml,\n lang,\n statusCode: err.statusCode,\n };\n } else {\n // No error view found, render default error message\n const html = h('div', {}, `${err.statusCode} - ${err.message}`);\n return {\n html: renderJsxToHtmlString(html),\n statusCode: err.statusCode,\n };\n }\n}\n\nexport async function render(url: string, requestInfo: RequestInfo = {}): Promise<RenderResult> {\n return runInRenderContext(async () => {\n try {\n // Step 1: Call route handler to get view name\n const rawRouteResult: RouteResult = await routeHandler(requestInfo);\n\n if (!rawRouteResult) {\n // Throw NotFoundException to render error_404 view\n throw new NotFoundException('Page not found', {\n path: requestInfo.path,\n pathname: requestInfo.pathname,\n url: requestInfo.url?.href,\n });\n }\n\n const viewName =\n typeof rawRouteResult === 'string' ? rawRouteResult : rawRouteResult.view;\n requestInfo.params =\n typeof rawRouteResult === 'string' ? {} : (rawRouteResult.params ?? {});\n\n // Set view name in render context\n setViewName(viewName);\n\n // Step 2: Load global loader (optional)\n let globalProps: Record<string, any> = {};\n let lang: string | undefined;\n\n // Try to load global loader\n const globalLoaderPathTs = '/src/global-loader.ts';\n\n const globalLoaderModule: GlobalLoaderModule | null = globalLoader[globalLoaderPathTs]\n ? await globalLoader[globalLoaderPathTs]()\n : null;\n\n // Run global loader if exists and not ignored\n if (globalLoaderModule?.loader) {\n const shouldIgnore = globalLoaderModule.shouldIgnore?.(viewName) || false;\n\n if (!shouldIgnore) {\n const globalLoaderResult = await globalLoaderModule.loader(requestInfo);\n\n globalProps = globalLoaderResult.props || {};\n lang = globalLoaderResult.lang; // Extract lang from global loader\n\n if (globalLoaderResult.cacheTags) {\n addCacheTag(globalLoaderResult.cacheTags);\n }\n\n // generateMetadata và generateSchema sẽ được gọi sau khi có props\n } else {\n console.info(`Global loader ignored for view: ${viewName}`);\n }\n }\n\n // Step 3: Dynamic import view loader (optional)\n let viewProps: Record<string, any> = {};\n let maxAge: number | undefined;\n let sMaxAge: number | undefined;\n let swr: number | undefined;\n let rawHtml: boolean = false;\n const loaderPathTs = `/src/views/${viewName}/loader.ts`;\n\n // Try TypeScript loader formats only\n const loaderModule = viewLoaders[loaderPathTs] ? await viewLoaders[loaderPathTs]() : null;\n\n if (loaderModule?.loader) {\n const loaderResult = await loaderModule.loader(requestInfo);\n\n // Check if loader returns raw response\n if (loaderResult.rawResponse) {\n return {\n rawResponse: loaderResult.rawResponse,\n statusCode: loaderResult.rawResponse.statusCode || 200,\n };\n }\n\n viewProps = loaderResult.props || {};\n maxAge = loaderResult.maxAge;\n sMaxAge = loaderResult.sMaxAge;\n swr = loaderResult.swr;\n rawHtml = loaderResult.rawHtml || false;\n\n if (loaderResult.cacheTags) {\n addCacheTag(loaderResult.cacheTags);\n }\n\n // View loader lang overrides global loader lang\n if (loaderResult.lang) {\n lang = loaderResult.lang;\n }\n } else {\n console.info(`No loader for view: ${viewName}`);\n }\n\n // Merge props: global props first, then view props (view can override)\n const props = { ...globalProps, ...viewProps };\n\n // Step 3.5: Generate metadata và schema từ generateMetadata và generateSchema functions\n // Global generateMetadata (parent metadata)\n if (globalLoaderModule?.generateMetadata) {\n const globalMetadata = globalLoaderModule.generateMetadata(requestInfo, props);\n if (globalMetadata) {\n pushMetadata(globalMetadata);\n }\n }\n\n // View generateMetadata (child metadata, sẽ merge với parent)\n if (loaderModule?.generateMetadata) {\n const viewMetadata = loaderModule.generateMetadata(requestInfo, props);\n if (viewMetadata) {\n pushMetadata(viewMetadata);\n }\n }\n\n // Global generateSchema (base schemas)\n if (globalLoaderModule?.generateSchema) {\n const globalSchema = globalLoaderModule.generateSchema(requestInfo, props);\n if (globalSchema) {\n pushSchema(globalSchema);\n }\n }\n\n // View generateSchema (view-specific schemas)\n if (loaderModule?.generateSchema) {\n const viewSchema = loaderModule.generateSchema(requestInfo, props);\n if (viewSchema) {\n pushSchema(viewSchema);\n }\n }\n\n // Step 4: Dynamic import component (required)\n const componentPathTsx = `/src/views/${viewName}/index.tsx`;\n\n const componentModule = viewComponents[componentPathTsx]\n ? await viewComponents[componentPathTsx]()\n : null;\n\n const Component = componentModule?.default;\n\n if (!Component) {\n console.error(`View component not found: ${viewName}`);\n\n // Check if in development or production mode\n const isDevelopment = process.env.NODE_ENV !== 'production';\n\n if (isDevelopment) {\n // Development: provide detailed error information\n throw new InternalServerErrorException(`View component not found: \"${viewName}\"`, {\n viewName,\n expectedPath: componentPathTsx,\n availableViews: Object.keys(viewComponents),\n hint: `Make sure the view component exists at ${componentPathTsx} and exports a default component`,\n timestamp: new Date().toISOString(),\n });\n } else {\n // Production: simple error message\n throw new InternalServerErrorException('Internal Server Error');\n }\n }\n\n // Auto-render MetadataRenderer trước khi render component\n // MetadataRenderer sẽ push metadata vào headRegistry thông qua Head component\n renderJsxToHtmlString(h(MetadataRenderer, {}));\n\n // Auto-render schemas vào headRegistry\n const schemas = getSchemas();\n schemas.forEach((schema) => {\n // serialize-javascript escapes HTML-sensitive chars (<, >, &, U+2028/2029)\n // so schema values cannot break out of the <script> block (XSS).\n const schemaJson = serialize(schema, { isJSON: true });\n // Push schema vào headRegistry thông qua Head component\n // Head component chỉ push vào registry, không cần renderJsxToHtmlString\n Head({\n priority: HEAD_PRIORITY.SEO,\n children: h('script', {\n type: 'application/ld+json',\n setHtml: schemaJson,\n }),\n });\n });\n\n // Render component (có thể có Head components khác)\n const htmlBody = renderJsxToHtmlString(h(Component, props));\n const clientEntries = getClientJsEntries();\n const cssEntries = getCssEntries();\n const islandEntries = getIslandEntries();\n const cacheTags = getCacheTags();\n const headContent = getHeadContent();\n\n // Render head content to HTML string\n const headHtml =\n headContent.length > 0\n ? headContent.map((content) => renderJsxToHtmlString(content)).join('\\n ')\n : undefined;\n\n return {\n html: htmlBody,\n scripts: clientEntries.map((entry) => entry.path),\n styles: cssEntries.map((entry) => entry.path),\n islands: islandEntries.length > 0 ? islandEntries : undefined,\n head: headHtml,\n lang,\n maxAge,\n sMaxAge,\n swr,\n cacheTags,\n rawHtml,\n };\n } catch (err: any) {\n // Handle RedirectException\n if (err instanceof RedirectException) {\n return {\n html: '',\n redirect: {\n url: err.url,\n statusCode: err.statusCode,\n },\n };\n }\n\n // Handle HttpException\n if (err instanceof HttpException) {\n return await renderErrorView(err);\n }\n\n // For other (unexpected) errors, convert to ServiceUnavailableException.\n // Intentional HttpExceptions above keep their developer-authored message;\n // but an unexpected error's raw message/stack must not leak to the client\n // in production (it can carry internals, secrets, etc.). Dev keeps detail.\n console.error(`Failed to render:`, err);\n const isProduction = process.env.NODE_ENV === 'production';\n const serviceError = isProduction\n ? new ServiceUnavailableException('Internal Server Error')\n : new ServiceUnavailableException(err.message || 'Internal Server Error', {\n originalError: err.name,\n stack: err.stack,\n timestamp: new Date().toISOString(),\n });\n return await renderErrorView(serviceError);\n }\n }, requestInfo);\n}\n"],"names":["renderErrorView","err","lang","errorViewName","errorComponentPath","setViewName","errorComponentModule","viewComponents","errorProps","Component","htmlBody","renderJsxToHtmlString","h","clientEntries","getClientJsEntries","cssEntries","getCssEntries","headContent","getHeadContent","headHtml","content","entry","html","render","url","requestInfo","runInRenderContext","rawRouteResult","routeHandler","NotFoundException","viewName","globalProps","globalLoaderPathTs","globalLoaderModule","globalLoader","globalLoaderResult","addCacheTag","viewProps","maxAge","sMaxAge","swr","rawHtml","loaderPathTs","loaderModule","viewLoaders","loaderResult","props","globalMetadata","pushMetadata","viewMetadata","globalSchema","pushSchema","viewSchema","componentPathTsx","InternalServerErrorException","MetadataRenderer","getSchemas","schema","schemaJson","serialize","Head","HEAD_PRIORITY","islandEntries","getIslandEntries","cacheTags","getCacheTags","RedirectException","HttpException","serviceError","ServiceUnavailableException"],"mappings":";;;;;;;;AA8GA,eAAeA,EAAgBC,GAAoBC,GAAsC;AACvF,QAAMC,IAAgB,UAChBC,IAAqB,cAAcD,CAAa;AAGtD,EAAAE,EAAYF,CAAa;AAGzB,QAAMG,IAAuBC,EAAeH,CAAkB,IAC1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parseCookie = g, w.parse = g, w.stringifyCookie = y, w.stringifySetCookie = x, w.serialize = x, w.parseSetCookie = v, w.stringifySetCookie = x, w.serialize = x;
|
|
5
|
+
const n = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, i = /^[\u0021-\u003A\u003C-\u007E]*$/, r = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, u = /^[\u0020-\u003A\u003D-\u007E]*$/, o = /^-?\d+$/, p = Object.prototype.toString, h = /* @__PURE__ */ (() => {
|
|
6
|
+
const t = function() {
|
|
7
|
+
};
|
|
8
|
+
return t.prototype = /* @__PURE__ */ Object.create(null), t;
|
|
9
|
+
})();
|
|
10
|
+
function g(t, l) {
|
|
11
|
+
const f = new h(), e = t.length;
|
|
12
|
+
if (e < 2)
|
|
13
|
+
return f;
|
|
14
|
+
const d = l?.decode || q;
|
|
15
|
+
let s = 0;
|
|
16
|
+
do {
|
|
17
|
+
const c = $(t, s, e);
|
|
18
|
+
if (c === -1)
|
|
19
|
+
break;
|
|
20
|
+
const a = C(t, s, e);
|
|
21
|
+
if (c > a) {
|
|
22
|
+
s = t.lastIndexOf(";", c - 1) + 1;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const b = k(t, s, c);
|
|
26
|
+
f[b] === void 0 && (f[b] = d(k(t, c + 1, a))), s = a + 1;
|
|
27
|
+
} while (s < e);
|
|
28
|
+
return f;
|
|
29
|
+
}
|
|
30
|
+
function y(t, l) {
|
|
31
|
+
const f = l?.encode || encodeURIComponent, e = [];
|
|
32
|
+
for (const d of Object.keys(t)) {
|
|
33
|
+
const s = t[d];
|
|
34
|
+
if (s === void 0)
|
|
35
|
+
continue;
|
|
36
|
+
if (!n.test(d))
|
|
37
|
+
throw new TypeError(`cookie name is invalid: ${d}`);
|
|
38
|
+
const c = f(s);
|
|
39
|
+
if (!i.test(c))
|
|
40
|
+
throw new TypeError(`cookie val is invalid: ${s}`);
|
|
41
|
+
e.push(`${d}=${c}`);
|
|
42
|
+
}
|
|
43
|
+
return e.join("; ");
|
|
44
|
+
}
|
|
45
|
+
function x(t, l, f) {
|
|
46
|
+
const e = typeof t == "object" ? t : { ...f, name: t, value: String(l) }, s = (typeof l == "object" ? l : f)?.encode || encodeURIComponent;
|
|
47
|
+
if (!n.test(e.name))
|
|
48
|
+
throw new TypeError(`argument name is invalid: ${e.name}`);
|
|
49
|
+
const c = e.value ? s(e.value) : "";
|
|
50
|
+
if (!i.test(c))
|
|
51
|
+
throw new TypeError(`argument val is invalid: ${e.value}`);
|
|
52
|
+
let a = e.name + "=" + c;
|
|
53
|
+
if (e.maxAge !== void 0) {
|
|
54
|
+
if (!Number.isInteger(e.maxAge))
|
|
55
|
+
throw new TypeError(`option maxAge is invalid: ${e.maxAge}`);
|
|
56
|
+
a += "; Max-Age=" + e.maxAge;
|
|
57
|
+
}
|
|
58
|
+
if (e.domain) {
|
|
59
|
+
if (!r.test(e.domain))
|
|
60
|
+
throw new TypeError(`option domain is invalid: ${e.domain}`);
|
|
61
|
+
a += "; Domain=" + e.domain;
|
|
62
|
+
}
|
|
63
|
+
if (e.path) {
|
|
64
|
+
if (!u.test(e.path))
|
|
65
|
+
throw new TypeError(`option path is invalid: ${e.path}`);
|
|
66
|
+
a += "; Path=" + e.path;
|
|
67
|
+
}
|
|
68
|
+
if (e.expires) {
|
|
69
|
+
if (!P(e.expires) || !Number.isFinite(e.expires.valueOf()))
|
|
70
|
+
throw new TypeError(`option expires is invalid: ${e.expires}`);
|
|
71
|
+
a += "; Expires=" + e.expires.toUTCString();
|
|
72
|
+
}
|
|
73
|
+
if (e.httpOnly && (a += "; HttpOnly"), e.secure && (a += "; Secure"), e.partitioned && (a += "; Partitioned"), e.priority)
|
|
74
|
+
switch (typeof e.priority == "string" ? e.priority.toLowerCase() : void 0) {
|
|
75
|
+
case "low":
|
|
76
|
+
a += "; Priority=Low";
|
|
77
|
+
break;
|
|
78
|
+
case "medium":
|
|
79
|
+
a += "; Priority=Medium";
|
|
80
|
+
break;
|
|
81
|
+
case "high":
|
|
82
|
+
a += "; Priority=High";
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
throw new TypeError(`option priority is invalid: ${e.priority}`);
|
|
86
|
+
}
|
|
87
|
+
if (e.sameSite)
|
|
88
|
+
switch (typeof e.sameSite == "string" ? e.sameSite.toLowerCase() : e.sameSite) {
|
|
89
|
+
case !0:
|
|
90
|
+
case "strict":
|
|
91
|
+
a += "; SameSite=Strict";
|
|
92
|
+
break;
|
|
93
|
+
case "lax":
|
|
94
|
+
a += "; SameSite=Lax";
|
|
95
|
+
break;
|
|
96
|
+
case "none":
|
|
97
|
+
a += "; SameSite=None";
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
throw new TypeError(`option sameSite is invalid: ${e.sameSite}`);
|
|
101
|
+
}
|
|
102
|
+
return a;
|
|
103
|
+
}
|
|
104
|
+
function v(t, l) {
|
|
105
|
+
const f = l?.decode || q, e = t.length, d = C(t, 0, e), s = $(t, 0, d), c = s === -1 ? { name: "", value: f(k(t, 0, d)) } : {
|
|
106
|
+
name: k(t, 0, s),
|
|
107
|
+
value: f(k(t, s + 1, d))
|
|
108
|
+
};
|
|
109
|
+
let a = d + 1;
|
|
110
|
+
for (; a < e; ) {
|
|
111
|
+
const b = C(t, a, e), E = $(t, a, b), j = E === -1 ? k(t, a, b) : k(t, a, E), m = E === -1 ? void 0 : k(t, E + 1, b);
|
|
112
|
+
switch (j.toLowerCase()) {
|
|
113
|
+
case "httponly":
|
|
114
|
+
c.httpOnly = !0;
|
|
115
|
+
break;
|
|
116
|
+
case "secure":
|
|
117
|
+
c.secure = !0;
|
|
118
|
+
break;
|
|
119
|
+
case "partitioned":
|
|
120
|
+
c.partitioned = !0;
|
|
121
|
+
break;
|
|
122
|
+
case "domain":
|
|
123
|
+
c.domain = m;
|
|
124
|
+
break;
|
|
125
|
+
case "path":
|
|
126
|
+
c.path = m;
|
|
127
|
+
break;
|
|
128
|
+
case "max-age":
|
|
129
|
+
m && o.test(m) && (c.maxAge = Number(m));
|
|
130
|
+
break;
|
|
131
|
+
case "expires":
|
|
132
|
+
if (!m)
|
|
133
|
+
break;
|
|
134
|
+
const A = new Date(m);
|
|
135
|
+
Number.isFinite(A.valueOf()) && (c.expires = A);
|
|
136
|
+
break;
|
|
137
|
+
case "priority":
|
|
138
|
+
if (!m)
|
|
139
|
+
break;
|
|
140
|
+
const S = m.toLowerCase();
|
|
141
|
+
(S === "low" || S === "medium" || S === "high") && (c.priority = S);
|
|
142
|
+
break;
|
|
143
|
+
case "samesite":
|
|
144
|
+
if (!m)
|
|
145
|
+
break;
|
|
146
|
+
const R = m.toLowerCase();
|
|
147
|
+
(R === "lax" || R === "strict" || R === "none") && (c.sameSite = R);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
a = b + 1;
|
|
151
|
+
}
|
|
152
|
+
return c;
|
|
153
|
+
}
|
|
154
|
+
function C(t, l, f) {
|
|
155
|
+
const e = t.indexOf(";", l);
|
|
156
|
+
return e === -1 ? f : e;
|
|
157
|
+
}
|
|
158
|
+
function $(t, l, f) {
|
|
159
|
+
const e = t.indexOf("=", l);
|
|
160
|
+
return e < f ? e : -1;
|
|
161
|
+
}
|
|
162
|
+
function k(t, l, f) {
|
|
163
|
+
let e = l, d = f;
|
|
164
|
+
do {
|
|
165
|
+
const s = t.charCodeAt(e);
|
|
166
|
+
if (s !== 32 && s !== 9)
|
|
167
|
+
break;
|
|
168
|
+
} while (++e < d);
|
|
169
|
+
for (; d > e; ) {
|
|
170
|
+
const s = t.charCodeAt(d - 1);
|
|
171
|
+
if (s !== 32 && s !== 9)
|
|
172
|
+
break;
|
|
173
|
+
d--;
|
|
174
|
+
}
|
|
175
|
+
return t.slice(e, d);
|
|
176
|
+
}
|
|
177
|
+
function q(t) {
|
|
178
|
+
if (t.indexOf("%") === -1)
|
|
179
|
+
return t;
|
|
180
|
+
try {
|
|
181
|
+
return decodeURIComponent(t);
|
|
182
|
+
} catch {
|
|
183
|
+
return t;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function P(t) {
|
|
187
|
+
return p.call(t) === "[object Date]";
|
|
188
|
+
}
|
|
189
|
+
return w;
|
|
190
|
+
}
|
|
191
|
+
var T = /* @__PURE__ */ L();
|
|
192
|
+
function O(n) {
|
|
193
|
+
if (!n) return {};
|
|
194
|
+
const i = T.parse(n), r = {};
|
|
195
|
+
for (const [u, o] of Object.entries(i))
|
|
196
|
+
o !== void 0 && (r[u] = o);
|
|
197
|
+
return r;
|
|
198
|
+
}
|
|
199
|
+
function N(n) {
|
|
200
|
+
const i = new Headers();
|
|
201
|
+
return Object.entries(n.headers).forEach(([r, u]) => {
|
|
202
|
+
if (u !== void 0) {
|
|
203
|
+
if (Array.isArray(u)) {
|
|
204
|
+
u.forEach((o) => i.append(r, o));
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
i.set(r, u);
|
|
208
|
+
}
|
|
209
|
+
}), i;
|
|
210
|
+
}
|
|
211
|
+
function U(n) {
|
|
212
|
+
return n;
|
|
213
|
+
}
|
|
214
|
+
function F(...n) {
|
|
215
|
+
const i = n.filter(Boolean), r = i.length;
|
|
216
|
+
return r ? (u, o) => {
|
|
217
|
+
let p;
|
|
218
|
+
return h(0, u);
|
|
219
|
+
function h(g, y) {
|
|
220
|
+
const x = i[g];
|
|
221
|
+
return x(y, async (v) => g < r - 1 ? (v && (p = v, z(y, v)), h(g + 1, y)) : o(v ?? p));
|
|
222
|
+
}
|
|
223
|
+
} : (u, o) => o();
|
|
224
|
+
}
|
|
225
|
+
function z(n, i) {
|
|
226
|
+
let r;
|
|
227
|
+
i instanceof Request ? r = i : i instanceof URL ? r = new Request(i.href, n.request.clone()) : r = new Request(new URL(i, n.url).href, n.request.clone());
|
|
228
|
+
const u = n.url, o = new URL(r.url), p = O(r.headers.get("cookie") ?? void 0);
|
|
229
|
+
if (n.request = r, n.url = o, n.cookies = p, n.requestInfo) {
|
|
230
|
+
const h = {};
|
|
231
|
+
r.headers.forEach((g, y) => {
|
|
232
|
+
h[y] = g;
|
|
233
|
+
}), n.requestInfo = {
|
|
234
|
+
...n.requestInfo,
|
|
235
|
+
url: o,
|
|
236
|
+
path: D(o, u, n.requestInfo.path),
|
|
237
|
+
pathname: o.pathname,
|
|
238
|
+
method: r.method,
|
|
239
|
+
headers: h,
|
|
240
|
+
cookies: p,
|
|
241
|
+
query: Object.fromEntries(o.searchParams.entries())
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function D(n, i, r) {
|
|
246
|
+
const u = `${n.pathname}${n.search}` || "/";
|
|
247
|
+
if (!r)
|
|
248
|
+
return u;
|
|
249
|
+
const o = r.split("?")[0] || "/";
|
|
250
|
+
if (o === i.pathname || !i.pathname.endsWith(o))
|
|
251
|
+
return u;
|
|
252
|
+
const p = i.pathname.slice(
|
|
253
|
+
0,
|
|
254
|
+
i.pathname.length - o.length
|
|
255
|
+
);
|
|
256
|
+
if (!p || !n.pathname.startsWith(p))
|
|
257
|
+
return u;
|
|
258
|
+
const h = n.pathname.slice(p.length) || "/";
|
|
259
|
+
return `${h.startsWith("/") ? h : `/${h}`}${n.search}`;
|
|
260
|
+
}
|
|
261
|
+
function H({
|
|
262
|
+
request: n,
|
|
263
|
+
requestInfo: i,
|
|
264
|
+
locals: r = {},
|
|
265
|
+
clientAddress: u
|
|
266
|
+
}) {
|
|
267
|
+
const o = {
|
|
268
|
+
cookies: O(n.headers.get("cookie") ?? void 0),
|
|
269
|
+
request: n,
|
|
270
|
+
requestInfo: i,
|
|
271
|
+
url: new URL(n.url),
|
|
272
|
+
redirect(p, h = 302) {
|
|
273
|
+
return new Response(null, {
|
|
274
|
+
status: h,
|
|
275
|
+
headers: {
|
|
276
|
+
Location: p.toString()
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
rewrite(p) {
|
|
281
|
+
return Promise.resolve(new Response(null));
|
|
282
|
+
},
|
|
283
|
+
get clientAddress() {
|
|
284
|
+
if (u)
|
|
285
|
+
return u;
|
|
286
|
+
throw new Error("clientAddress is not available for this request.");
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
return Object.defineProperty(o, "locals", {
|
|
290
|
+
enumerable: !0,
|
|
291
|
+
get() {
|
|
292
|
+
if (typeof r != "object" || r === null || Array.isArray(r))
|
|
293
|
+
throw new Error("Middleware locals must be a plain object.");
|
|
294
|
+
return r;
|
|
295
|
+
},
|
|
296
|
+
set() {
|
|
297
|
+
throw new Error("Middleware locals cannot be reassigned. Mutate its properties instead.");
|
|
298
|
+
}
|
|
299
|
+
}), o.rewrite = (p) => Promise.resolve(
|
|
300
|
+
new Response(null, {
|
|
301
|
+
status: 307,
|
|
302
|
+
headers: {
|
|
303
|
+
"X-L5E-Rewrite": M(p, o.url)
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
), o;
|
|
307
|
+
}
|
|
308
|
+
function M(n, i) {
|
|
309
|
+
return n instanceof Request ? n.url : n instanceof URL ? n.href : new URL(n, i).href;
|
|
310
|
+
}
|
|
311
|
+
export {
|
|
312
|
+
N as a,
|
|
313
|
+
H as c,
|
|
314
|
+
U as d,
|
|
315
|
+
O as p,
|
|
316
|
+
F as s
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=index-BlfNBupp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BlfNBupp.js","sources":["../../../node_modules/.pnpm/cookie@1.1.1/node_modules/cookie/dist/index.js","../src/core/request.ts","../src/middleware/defineMiddleware.ts","../src/middleware/sequence.ts","../src/middleware/index.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parseCookie = parseCookie;\nexports.parse = parseCookie;\nexports.stringifyCookie = stringifyCookie;\nexports.stringifySetCookie = stringifySetCookie;\nexports.serialize = stringifySetCookie;\nexports.parseSetCookie = parseSetCookie;\nexports.stringifySetCookie = stringifySetCookie;\nexports.serialize = stringifySetCookie;\n/**\n * RegExp to match cookie-name in RFC 6265 sec 4.1.1\n * This refers out to the obsoleted definition of token in RFC 2616 sec 2.2\n * which has been replaced by the token definition in RFC 7230 appendix B.\n *\n * cookie-name = token\n * token = 1*tchar\n * tchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" /\n * \"*\" / \"+\" / \"-\" / \".\" / \"^\" / \"_\" /\n * \"`\" / \"|\" / \"~\" / DIGIT / ALPHA\n *\n * Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191\n * Allow same range as cookie value, except `=`, which delimits end of name.\n */\nconst cookieNameRegExp = /^[\\u0021-\\u003A\\u003C\\u003E-\\u007E]+$/;\n/**\n * RegExp to match cookie-value in RFC 6265 sec 4.1.1\n *\n * cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )\n * cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E\n * ; US-ASCII characters excluding CTLs,\n * ; whitespace DQUOTE, comma, semicolon,\n * ; and backslash\n *\n * Allowing more characters: https://github.com/jshttp/cookie/issues/191\n * Comma, backslash, and DQUOTE are not part of the parsing algorithm.\n */\nconst cookieValueRegExp = /^[\\u0021-\\u003A\\u003C-\\u007E]*$/;\n/**\n * RegExp to match domain-value in RFC 6265 sec 4.1.1\n *\n * domain-value = <subdomain>\n * ; defined in [RFC1034], Section 3.5, as\n * ; enhanced by [RFC1123], Section 2.1\n * <subdomain> = <label> | <subdomain> \".\" <label>\n * <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]\n * Labels must be 63 characters or less.\n * 'let-dig' not 'letter' in the first char, per RFC1123\n * <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>\n * <let-dig-hyp> = <let-dig> | \"-\"\n * <let-dig> = <letter> | <digit>\n * <letter> = any one of the 52 alphabetic characters A through Z in\n * upper case and a through z in lower case\n * <digit> = any one of the ten digits 0 through 9\n *\n * Keep support for leading dot: https://github.com/jshttp/cookie/issues/173\n *\n * > (Note that a leading %x2E (\".\"), if present, is ignored even though that\n * character is not permitted, but a trailing %x2E (\".\"), if present, will\n * cause the user agent to ignore the attribute.)\n */\nconst domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;\n/**\n * RegExp to match path-value in RFC 6265 sec 4.1.1\n *\n * path-value = <any CHAR except CTLs or \";\">\n * CHAR = %x01-7F\n * ; defined in RFC 5234 appendix B.1\n */\nconst pathValueRegExp = /^[\\u0020-\\u003A\\u003D-\\u007E]*$/;\n/**\n * RegExp to match max-age-value in RFC 6265 sec 5.6.2\n */\nconst maxAgeRegExp = /^-?\\d+$/;\nconst __toString = Object.prototype.toString;\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () { };\n C.prototype = Object.create(null);\n return C;\n})();\n/**\n * Parse a `Cookie` header.\n *\n * Parse the given cookie header string into an object\n * The object has the various cookies as keys(names) => values\n */\nfunction parseCookie(str, options) {\n const obj = new NullObject();\n const len = str.length;\n // RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.\n if (len < 2)\n return obj;\n const dec = options?.decode || decode;\n let index = 0;\n do {\n const eqIdx = eqIndex(str, index, len);\n if (eqIdx === -1)\n break; // No more cookie pairs.\n const endIdx = endIndex(str, index, len);\n if (eqIdx > endIdx) {\n // backtrack on prior semicolon\n index = str.lastIndexOf(\";\", eqIdx - 1) + 1;\n continue;\n }\n const key = valueSlice(str, index, eqIdx);\n // only assign once\n if (obj[key] === undefined) {\n obj[key] = dec(valueSlice(str, eqIdx + 1, endIdx));\n }\n index = endIdx + 1;\n } while (index < len);\n return obj;\n}\n/**\n * Stringifies an object into an HTTP `Cookie` header.\n */\nfunction stringifyCookie(cookie, options) {\n const enc = options?.encode || encodeURIComponent;\n const cookieStrings = [];\n for (const name of Object.keys(cookie)) {\n const val = cookie[name];\n if (val === undefined)\n continue;\n if (!cookieNameRegExp.test(name)) {\n throw new TypeError(`cookie name is invalid: ${name}`);\n }\n const value = enc(val);\n if (!cookieValueRegExp.test(value)) {\n throw new TypeError(`cookie val is invalid: ${val}`);\n }\n cookieStrings.push(`${name}=${value}`);\n }\n return cookieStrings.join(\"; \");\n}\nfunction stringifySetCookie(_name, _val, _opts) {\n const cookie = typeof _name === \"object\"\n ? _name\n : { ..._opts, name: _name, value: String(_val) };\n const options = typeof _val === \"object\" ? _val : _opts;\n const enc = options?.encode || encodeURIComponent;\n if (!cookieNameRegExp.test(cookie.name)) {\n throw new TypeError(`argument name is invalid: ${cookie.name}`);\n }\n const value = cookie.value ? enc(cookie.value) : \"\";\n if (!cookieValueRegExp.test(value)) {\n throw new TypeError(`argument val is invalid: ${cookie.value}`);\n }\n let str = cookie.name + \"=\" + value;\n if (cookie.maxAge !== undefined) {\n if (!Number.isInteger(cookie.maxAge)) {\n throw new TypeError(`option maxAge is invalid: ${cookie.maxAge}`);\n }\n str += \"; Max-Age=\" + cookie.maxAge;\n }\n if (cookie.domain) {\n if (!domainValueRegExp.test(cookie.domain)) {\n throw new TypeError(`option domain is invalid: ${cookie.domain}`);\n }\n str += \"; Domain=\" + cookie.domain;\n }\n if (cookie.path) {\n if (!pathValueRegExp.test(cookie.path)) {\n throw new TypeError(`option path is invalid: ${cookie.path}`);\n }\n str += \"; Path=\" + cookie.path;\n }\n if (cookie.expires) {\n if (!isDate(cookie.expires) || !Number.isFinite(cookie.expires.valueOf())) {\n throw new TypeError(`option expires is invalid: ${cookie.expires}`);\n }\n str += \"; Expires=\" + cookie.expires.toUTCString();\n }\n if (cookie.httpOnly) {\n str += \"; HttpOnly\";\n }\n if (cookie.secure) {\n str += \"; Secure\";\n }\n if (cookie.partitioned) {\n str += \"; Partitioned\";\n }\n if (cookie.priority) {\n const priority = typeof cookie.priority === \"string\"\n ? cookie.priority.toLowerCase()\n : undefined;\n switch (priority) {\n case \"low\":\n str += \"; Priority=Low\";\n break;\n case \"medium\":\n str += \"; Priority=Medium\";\n break;\n case \"high\":\n str += \"; Priority=High\";\n break;\n default:\n throw new TypeError(`option priority is invalid: ${cookie.priority}`);\n }\n }\n if (cookie.sameSite) {\n const sameSite = typeof cookie.sameSite === \"string\"\n ? cookie.sameSite.toLowerCase()\n : cookie.sameSite;\n switch (sameSite) {\n case true:\n case \"strict\":\n str += \"; SameSite=Strict\";\n break;\n case \"lax\":\n str += \"; SameSite=Lax\";\n break;\n case \"none\":\n str += \"; SameSite=None\";\n break;\n default:\n throw new TypeError(`option sameSite is invalid: ${cookie.sameSite}`);\n }\n }\n return str;\n}\n/**\n * Deserialize a `Set-Cookie` header into an object.\n *\n * deserialize('foo=bar; httpOnly')\n * => { name: 'foo', value: 'bar', httpOnly: true }\n */\nfunction parseSetCookie(str, options) {\n const dec = options?.decode || decode;\n const len = str.length;\n const endIdx = endIndex(str, 0, len);\n const eqIdx = eqIndex(str, 0, endIdx);\n const setCookie = eqIdx === -1\n ? { name: \"\", value: dec(valueSlice(str, 0, endIdx)) }\n : {\n name: valueSlice(str, 0, eqIdx),\n value: dec(valueSlice(str, eqIdx + 1, endIdx)),\n };\n let index = endIdx + 1;\n while (index < len) {\n const endIdx = endIndex(str, index, len);\n const eqIdx = eqIndex(str, index, endIdx);\n const attr = eqIdx === -1\n ? valueSlice(str, index, endIdx)\n : valueSlice(str, index, eqIdx);\n const val = eqIdx === -1 ? undefined : valueSlice(str, eqIdx + 1, endIdx);\n switch (attr.toLowerCase()) {\n case \"httponly\":\n setCookie.httpOnly = true;\n break;\n case \"secure\":\n setCookie.secure = true;\n break;\n case \"partitioned\":\n setCookie.partitioned = true;\n break;\n case \"domain\":\n setCookie.domain = val;\n break;\n case \"path\":\n setCookie.path = val;\n break;\n case \"max-age\":\n if (val && maxAgeRegExp.test(val))\n setCookie.maxAge = Number(val);\n break;\n case \"expires\":\n if (!val)\n break;\n const date = new Date(val);\n if (Number.isFinite(date.valueOf()))\n setCookie.expires = date;\n break;\n case \"priority\":\n if (!val)\n break;\n const priority = val.toLowerCase();\n if (priority === \"low\" ||\n priority === \"medium\" ||\n priority === \"high\") {\n setCookie.priority = priority;\n }\n break;\n case \"samesite\":\n if (!val)\n break;\n const sameSite = val.toLowerCase();\n if (sameSite === \"lax\" ||\n sameSite === \"strict\" ||\n sameSite === \"none\") {\n setCookie.sameSite = sameSite;\n }\n break;\n }\n index = endIdx + 1;\n }\n return setCookie;\n}\n/**\n * Find the `;` character between `min` and `len` in str.\n */\nfunction endIndex(str, min, len) {\n const index = str.indexOf(\";\", min);\n return index === -1 ? len : index;\n}\n/**\n * Find the `=` character between `min` and `max` in str.\n */\nfunction eqIndex(str, min, max) {\n const index = str.indexOf(\"=\", min);\n return index < max ? index : -1;\n}\n/**\n * Slice out a value between startPod to max.\n */\nfunction valueSlice(str, min, max) {\n let start = min;\n let end = max;\n do {\n const code = str.charCodeAt(start);\n if (code !== 0x20 /* */ && code !== 0x09 /* \\t */)\n break;\n } while (++start < end);\n while (end > start) {\n const code = str.charCodeAt(end - 1);\n if (code !== 0x20 /* */ && code !== 0x09 /* \\t */)\n break;\n end--;\n }\n return str.slice(start, end);\n}\n/**\n * URL-decode string value. Optimized to skip native call when no %.\n */\nfunction decode(str) {\n if (str.indexOf(\"%\") === -1)\n return str;\n try {\n return decodeURIComponent(str);\n }\n catch (e) {\n return str;\n }\n}\n/**\n * Determine if value is a Date.\n */\nfunction isDate(val) {\n return __toString.call(val) === \"[object Date]\";\n}\n//# sourceMappingURL=index.js.map","import { parse as parseCookieHeader } from 'cookie';\nimport type { Request } from 'express';\n\nexport function parseCookies(cookieHeader?: string): Record<string, string> {\n if (!cookieHeader) return {};\n\n // `cookie.parse` decodes values safely (malformed %-sequences fall back to the\n // raw value instead of throwing) and ignores prototype keys.\n const parsed = parseCookieHeader(cookieHeader);\n const cookies: Record<string, string> = {};\n for (const [name, value] of Object.entries(parsed)) {\n if (value !== undefined) {\n cookies[name] = value;\n }\n }\n return cookies;\n}\n\nexport function createHeadersFromExpressRequest(req: Request): Headers {\n const headers = new Headers();\n\n Object.entries(req.headers).forEach(([key, value]) => {\n if (value === undefined) return;\n if (Array.isArray(value)) {\n value.forEach((item) => headers.append(key, item));\n return;\n }\n headers.set(key, value);\n });\n\n return headers;\n}\n","import type { MiddlewareHandler } from './types';\n\nexport function defineMiddleware(fn: MiddlewareHandler): MiddlewareHandler {\n return fn;\n}\n","import { parseCookies } from '../core/request';\nimport { defineMiddleware } from './defineMiddleware';\nimport type { MiddlewareContext, MiddlewareHandler, RewritePayload } from './types';\n\n// From SvelteKit via Astro: compose middleware handlers in declaration order.\nexport function sequence(...handlers: Array<MiddlewareHandler | false | null | undefined>) {\n const filtered = handlers.filter(Boolean) as MiddlewareHandler[];\n const length = filtered.length;\n\n if (!length) {\n return defineMiddleware((_context, next) => {\n return next();\n });\n }\n\n return defineMiddleware((context, next) => {\n let carriedPayload: RewritePayload | undefined;\n return applyHandle(0, context);\n\n function applyHandle(\n i: number,\n handleContext: MiddlewareContext,\n ): Promise<Response> | Response {\n const handle = filtered[i];\n\n return handle(handleContext, async (payload?: RewritePayload) => {\n if (i < length - 1) {\n if (payload) {\n carriedPayload = payload;\n updateContextForRewrite(handleContext, payload);\n }\n return applyHandle(i + 1, handleContext);\n }\n\n return next(payload ?? carriedPayload);\n });\n }\n });\n}\n\nfunction updateContextForRewrite(context: MiddlewareContext, payload: RewritePayload): void {\n let request: Request;\n\n if (payload instanceof Request) {\n request = payload;\n } else if (payload instanceof URL) {\n request = new Request(payload.href, context.request.clone());\n } else {\n request = new Request(new URL(payload, context.url).href, context.request.clone());\n }\n\n const previousUrl = context.url;\n const nextUrl = new URL(request.url);\n const nextCookies = parseCookies(request.headers.get('cookie') ?? undefined);\n context.request = request;\n context.url = nextUrl;\n context.cookies = nextCookies;\n\n if (context.requestInfo) {\n const headers: Record<string, string> = {};\n request.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n context.requestInfo = {\n ...context.requestInfo,\n url: nextUrl,\n path: getRequestInfoPath(nextUrl, previousUrl, context.requestInfo.path),\n pathname: nextUrl.pathname,\n method: request.method,\n headers,\n cookies: nextCookies,\n query: Object.fromEntries(nextUrl.searchParams.entries()),\n };\n }\n}\n\nfunction getRequestInfoPath(nextUrl: URL, previousUrl: URL, previousPath?: string): string {\n const nextPath = `${nextUrl.pathname}${nextUrl.search}` || '/';\n if (!previousPath) {\n return nextPath;\n }\n\n const previousPathname = previousPath.split('?')[0] || '/';\n if (\n previousPathname === previousUrl.pathname ||\n !previousUrl.pathname.endsWith(previousPathname)\n ) {\n return nextPath;\n }\n\n const basePathname = previousUrl.pathname.slice(\n 0,\n previousUrl.pathname.length - previousPathname.length,\n );\n if (!basePathname || !nextUrl.pathname.startsWith(basePathname)) {\n return nextPath;\n }\n\n const strippedPathname = nextUrl.pathname.slice(basePathname.length) || '/';\n const normalizedPathname = strippedPathname.startsWith('/')\n ? strippedPathname\n : `/${strippedPathname}`;\n return `${normalizedPathname}${nextUrl.search}`;\n}\n","import { parseCookies } from '../core/request';\nimport { defineMiddleware } from './defineMiddleware';\nimport { sequence } from './sequence';\nimport type { CreateContext, MiddlewareContext, RewritePayload } from './types';\n\nexport type {\n CreateContext,\n MiddlewareContext,\n MiddlewareHandler,\n MiddlewareNext,\n RewritePayload,\n} from './types';\n\nexport { defineMiddleware, sequence };\n\nexport function createContext({\n request,\n requestInfo,\n locals = {},\n clientAddress,\n}: CreateContext): MiddlewareContext {\n const context = {\n cookies: parseCookies(request.headers.get('cookie') ?? undefined),\n request,\n requestInfo,\n url: new URL(request.url),\n redirect(path: string | URL, status = 302) {\n return new Response(null, {\n status,\n headers: {\n Location: path.toString(),\n },\n });\n },\n rewrite(payload: RewritePayload) {\n return Promise.resolve(new Response(null));\n },\n get clientAddress() {\n if (clientAddress) {\n return clientAddress;\n }\n throw new Error('clientAddress is not available for this request.');\n },\n } as Omit<MiddlewareContext, 'locals'> & {\n locals: Record<string, unknown>;\n };\n\n Object.defineProperty(context, 'locals', {\n enumerable: true,\n get() {\n if (typeof locals !== 'object' || locals === null || Array.isArray(locals)) {\n throw new Error('Middleware locals must be a plain object.');\n }\n return locals;\n },\n set() {\n throw new Error('Middleware locals cannot be reassigned. Mutate its properties instead.');\n },\n });\n\n context.rewrite = (payload: RewritePayload) => {\n return Promise.resolve(\n new Response(null, {\n status: 307,\n headers: {\n 'X-L5E-Rewrite': stringifyRewritePayload(payload, context.url),\n },\n }),\n );\n };\n\n return context;\n}\n\nfunction stringifyRewritePayload(payload: RewritePayload, currentUrl: URL): string {\n if (payload instanceof Request) {\n return payload.url;\n }\n\n if (payload instanceof URL) {\n return payload.href;\n }\n\n return new URL(payload, currentUrl).href;\n}\n"],"names":["dist","parseCookie","stringifyCookie","stringifySetCookie","parseSetCookie","cookieNameRegExp","cookieValueRegExp","domainValueRegExp","pathValueRegExp","maxAgeRegExp","__toString","NullObject","C","str","options","obj","len","dec","decode","index","eqIdx","eqIndex","endIdx","endIndex","key","valueSlice","cookie","enc","cookieStrings","name","val","value","_name","_val","_opts","isDate","setCookie","attr","date","priority","sameSite","min","max","start","end","code","parseCookies","cookieHeader","parsed","parseCookieHeader","cookies","createHeadersFromExpressRequest","req","headers","item","defineMiddleware","fn","sequence","handlers","filtered","length","context","next","carriedPayload","applyHandle","i","handleContext","handle","payload","updateContextForRewrite","_context","request","previousUrl","nextUrl","nextCookies","getRequestInfoPath","previousPath","nextPath","previousPathname","basePathname","strippedPathname","createContext","requestInfo","locals","clientAddress","path","status","stringifyRewritePayload","currentUrl"],"mappings":";;;SACA,OAAO,eAAeA,GAAS,cAAc,EAAE,OAAO,IAAM,GAC5DA,EAAA,cAAsBC,GACtBD,EAAA,QAAgBC,GAChBD,EAAA,kBAA0BE,GAC1BF,EAAA,qBAA6BG,GAC7BH,EAAA,YAAoBG,GACpBH,EAAA,iBAAyBI,GACzBJ,EAAA,qBAA6BG,GAC7BH,EAAA,YAAoBG;AAepB,QAAME,IAAmB,yCAanBC,IAA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