@rebask/core 0.1.4 → 0.2.0
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.rsc.d.ts +1 -0
- package/dist/entry.rsc.d.ts.map +1 -1
- package/dist/entry.rsc.js +1 -0
- package/dist/handlers/markdown.d.ts +16 -0
- package/dist/handlers/markdown.d.ts.map +1 -0
- package/dist/handlers/markdown.js +161 -0
- package/dist/handlers/rsc/cache-lookup.d.ts.map +1 -1
- package/dist/handlers/rsc/cache-lookup.js +10 -4
- package/dist/handlers/rsc/index.js +1 -1
- package/dist/handlers/rsc/render-to-response.js +6 -2
- package/dist/handlers/rsc/segment-shell.d.ts +1 -1
- package/dist/handlers/rsc/segment-shell.d.ts.map +1 -1
- package/dist/handlers/rsc/segment-shell.js +5 -9
- package/dist/handlers/rsc/state.d.ts +1 -0
- package/dist/handlers/rsc/state.d.ts.map +1 -1
- package/dist/handlers/rsc/state.js +4 -0
- package/dist/lib/app-manifest.d.ts +12 -4
- package/dist/lib/app-manifest.d.ts.map +1 -1
- package/dist/lib/app-manifest.js +5 -0
- package/dist/lib/cache-key-tags.d.ts +2 -0
- package/dist/lib/cache-key-tags.d.ts.map +1 -1
- package/dist/lib/cache-key-tags.js +2 -0
- package/dist/lib/cache-storage.d.ts +7 -2
- package/dist/lib/cache-storage.d.ts.map +1 -1
- package/dist/lib/cache-storage.js +1 -0
- package/dist/lib/config.d.ts +2 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +8 -3
- package/dist/lib/dev-page-exports.d.ts +5 -0
- package/dist/lib/dev-page-exports.d.ts.map +1 -0
- package/dist/lib/dev-page-exports.js +14 -0
- package/dist/lib/lru-cache.d.ts.map +1 -1
- package/dist/lib/lru-cache.js +2 -0
- package/dist/lib/markdown.d.ts +5 -0
- package/dist/lib/markdown.d.ts.map +1 -0
- package/dist/lib/markdown.js +53 -0
- package/dist/lib/page-exports.d.ts +9 -0
- package/dist/lib/page-exports.d.ts.map +1 -0
- package/dist/lib/page-exports.js +47 -0
- package/dist/lib/ppr/cache-status.d.ts +3 -0
- package/dist/lib/ppr/cache-status.d.ts.map +1 -0
- package/dist/lib/ppr/cache-status.js +5 -0
- package/dist/lib/ppr/headers.d.ts +1 -1
- package/dist/lib/ppr/headers.d.ts.map +1 -1
- package/dist/lib/ppr/headers.js +1 -1
- package/dist/lib/prerender-params.d.ts +1 -1
- package/dist/lib/prerender-params.d.ts.map +1 -1
- package/dist/lib/prerender-params.js +17 -2
- package/dist/lib/project-files.d.ts +2 -1
- package/dist/lib/project-files.d.ts.map +1 -1
- package/dist/lib/project-files.js +16 -6
- package/dist/lib/route-builder.d.ts +4 -3
- package/dist/lib/route-builder.d.ts.map +1 -1
- package/dist/lib/route-builder.js +61 -13
- package/dist/lib/route-matcher.d.ts +4 -0
- package/dist/lib/route-matcher.d.ts.map +1 -1
- package/dist/lib/rsc-request.d.ts.map +1 -1
- package/dist/lib/rsc-request.js +3 -3
- package/dist/lib/server-router/get-router.d.ts.map +1 -1
- package/dist/lib/server-router/get-router.js +71 -16
- package/dist/lib/server-router/types.d.ts +4 -1
- package/dist/lib/server-router/types.d.ts.map +1 -1
- package/dist/lib/write-behind-cache.d.ts.map +1 -1
- package/dist/lib/write-behind-cache.js +5 -3
- package/dist/plugins/devtools.d.ts.map +1 -1
- package/dist/plugins/devtools.js +2 -2
- package/dist/plugins/ppr.d.ts +5 -0
- package/dist/plugins/ppr.d.ts.map +1 -1
- package/dist/plugins/prerender.d.ts.map +1 -1
- package/dist/plugins/prerender.js +114 -70
- package/dist/plugins/router/wint-router.d.ts.map +1 -1
- package/dist/plugins/router/wint-router.js +4 -2
- package/dist/router.d.ts +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +3 -1
- package/dist/server-router.d.ts +1 -1
- package/dist/server-router.d.ts.map +1 -1
- package/dist/vite.d.ts +20 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +17 -4
- package/package.json +1 -5
- package/dist/components/prefetch-links.d.ts +0 -5
- package/dist/components/prefetch-links.d.ts.map +0 -1
- package/dist/components/prefetch-links.js +0 -174
package/dist/lib/lru-cache.js
CHANGED
|
@@ -103,6 +103,8 @@ function defaultCalculateSize(entry) {
|
|
|
103
103
|
if (entry.type === CacheEntryType.HTML) {
|
|
104
104
|
return entry.html.length + (entry.postponed?.length ?? 0);
|
|
105
105
|
}
|
|
106
|
+
if (entry.type === CacheEntryType.MARKDOWN)
|
|
107
|
+
return entry.markdown.length;
|
|
106
108
|
if (entry.type === CacheEntryType.DURABLE_CACHE) {
|
|
107
109
|
return entry.data.length;
|
|
108
110
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Whether the request explicitly prefers Markdown over HTML. */
|
|
2
|
+
export declare function prefersMarkdown(accept: string | null): boolean;
|
|
3
|
+
/** The page pathname for a `.md` URL, or `null` when it is not one. */
|
|
4
|
+
export declare function getMarkdownPathname(pathname: string): string | null;
|
|
5
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/lib/markdown.ts"],"names":[],"mappings":"AAiBA,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,WA6BpD;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,iBAKnD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function parseQuality(params) {
|
|
2
|
+
for (const param of params) {
|
|
3
|
+
const [rawName, rawValue] = param.split("=");
|
|
4
|
+
if (rawName?.trim().toLowerCase() !== "q")
|
|
5
|
+
continue;
|
|
6
|
+
const value = rawValue?.trim();
|
|
7
|
+
if (!value)
|
|
8
|
+
return 1;
|
|
9
|
+
const q = Number(value);
|
|
10
|
+
if (!Number.isFinite(q))
|
|
11
|
+
return 1;
|
|
12
|
+
return Math.min(1, Math.max(0, q));
|
|
13
|
+
}
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
/** Whether the request explicitly prefers Markdown over HTML. */
|
|
17
|
+
export function prefersMarkdown(accept) {
|
|
18
|
+
if (!accept)
|
|
19
|
+
return false;
|
|
20
|
+
let markdown;
|
|
21
|
+
let exactHtml;
|
|
22
|
+
let typeWildcardHtml;
|
|
23
|
+
let wildcardHtml;
|
|
24
|
+
for (const part of accept.split(",")) {
|
|
25
|
+
const [range, ...params] = part.split(";");
|
|
26
|
+
const [type, subtype] = (range ?? "").trim().toLowerCase().split("/");
|
|
27
|
+
if (!type || !subtype)
|
|
28
|
+
continue;
|
|
29
|
+
const q = parseQuality(params);
|
|
30
|
+
if (type === "text" && subtype === "markdown") {
|
|
31
|
+
markdown = Math.max(markdown ?? 0, q);
|
|
32
|
+
}
|
|
33
|
+
else if (type === "text" && subtype === "html") {
|
|
34
|
+
exactHtml = Math.max(exactHtml ?? 0, q);
|
|
35
|
+
}
|
|
36
|
+
else if (type === "text" && subtype === "*") {
|
|
37
|
+
typeWildcardHtml = Math.max(typeWildcardHtml ?? 0, q);
|
|
38
|
+
}
|
|
39
|
+
else if (type === "*" && subtype === "*") {
|
|
40
|
+
wildcardHtml = Math.max(wildcardHtml ?? 0, q);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!markdown)
|
|
44
|
+
return false;
|
|
45
|
+
return markdown >= (exactHtml ?? typeWildcardHtml ?? wildcardHtml ?? 0);
|
|
46
|
+
}
|
|
47
|
+
/** The page pathname for a `.md` URL, or `null` when it is not one. */
|
|
48
|
+
export function getMarkdownPathname(pathname) {
|
|
49
|
+
if (!pathname.endsWith(".md"))
|
|
50
|
+
return null;
|
|
51
|
+
const stripped = pathname.slice(0, -3).replace(/\/+$/, "");
|
|
52
|
+
return stripped || "/";
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-exports.d.ts","sourceRoot":"","sources":["../../src/lib/page-exports.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM;;;GAiDrD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { parseSync } from "vite";
|
|
3
|
+
export async function readPageExports(filePath) {
|
|
4
|
+
const source = await readFile(filePath, "utf8");
|
|
5
|
+
const { program } = parseSync(filePath, source);
|
|
6
|
+
let hasDefault = false;
|
|
7
|
+
let hasNotFound = false;
|
|
8
|
+
for (const statement of program.body) {
|
|
9
|
+
if (statement.type === "ExportDefaultDeclaration") {
|
|
10
|
+
hasDefault = true;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (statement.type === "ExportAllDeclaration") {
|
|
14
|
+
const exported = statement.exported;
|
|
15
|
+
if (exported?.type === "Identifier" && exported.name === "default") {
|
|
16
|
+
hasDefault = true;
|
|
17
|
+
}
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (statement.type !== "ExportNamedDeclaration")
|
|
21
|
+
continue;
|
|
22
|
+
const declaration = statement.declaration;
|
|
23
|
+
if (declaration?.type === "VariableDeclaration") {
|
|
24
|
+
for (const declarator of declaration.declarations) {
|
|
25
|
+
if (declarator.id.type !== "Identifier")
|
|
26
|
+
continue;
|
|
27
|
+
if (declarator.id.name === "notFound") {
|
|
28
|
+
let init = declarator.init;
|
|
29
|
+
while (init &&
|
|
30
|
+
(init.type === "TSAsExpression" ||
|
|
31
|
+
init.type === "TSSatisfiesExpression" ||
|
|
32
|
+
init.type === "ParenthesizedExpression")) {
|
|
33
|
+
init = init.expression;
|
|
34
|
+
}
|
|
35
|
+
hasNotFound = init?.type === "Literal" && init.value === true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
for (const specifier of statement.specifiers ?? []) {
|
|
40
|
+
if (specifier.exported.type !== "Identifier")
|
|
41
|
+
continue;
|
|
42
|
+
if (specifier.exported.name === "default")
|
|
43
|
+
hasDefault = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { default: hasDefault, notFound: hasNotFound };
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-status.d.ts","sourceRoot":"","sources":["../../../src/lib/ppr/cache-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE1E,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExF"}
|
|
@@ -15,7 +15,7 @@ export declare const REBASK_TAIL_HEADER = "x-rebask-tail";
|
|
|
15
15
|
* This indicates the response is a cached static shell + streamed dynamic content.
|
|
16
16
|
*/
|
|
17
17
|
export declare const REBASK_PRERENDER_HEADER = "x-rebask-prerender";
|
|
18
|
-
/**
|
|
18
|
+
/** The origin cache outcome. Omitted when the adapter owns page caching. */
|
|
19
19
|
export declare const REBASK_CACHE_HEADER = "x-rebask-cache";
|
|
20
20
|
/**
|
|
21
21
|
* Boundary between a segment's Flight stream and the trailer carrying the search params the segment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/lib/ppr/headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,4CAA4C;AAC5C,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,uBAAuB,CAAA;AAE3D,
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/lib/ppr/headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,4CAA4C;AAC5C,eAAO,MAAM,oBAAoB,iBAAiB,CAAA;AAElD,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,uBAAuB,CAAA;AAE3D,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAA;AAEvD,eAAO,MAAM,uBAAuB,0BAAkC,CAAA;AAEtE,eAAO,MAAM,sBAAsB,yDAAiF,CAAA;AAEpH,oBAAY,iBAAiB;IAC5B,mCAAmC;IACnC,GAAG,QAAQ;IACX,wEAAwE;IACxE,KAAK,UAAU;IACf,8BAA8B;IAC9B,IAAI,SAAS;CACb;AAED,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,EAAE,IAAI,UAAQ,GAAG,MAAM,CAoBtF;AAED,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/E"}
|
package/dist/lib/ppr/headers.js
CHANGED
|
@@ -14,7 +14,7 @@ export const REBASK_TAIL_HEADER = "x-rebask-tail";
|
|
|
14
14
|
* This indicates the response is a cached static shell + streamed dynamic content.
|
|
15
15
|
*/
|
|
16
16
|
export const REBASK_PRERENDER_HEADER = "x-rebask-prerender";
|
|
17
|
-
/**
|
|
17
|
+
/** The origin cache outcome. Omitted when the adapter owns page caching. */
|
|
18
18
|
export const REBASK_CACHE_HEADER = "x-rebask-cache";
|
|
19
19
|
/**
|
|
20
20
|
* Boundary between a segment's Flight stream and the trailer carrying the search params the segment
|
|
@@ -5,7 +5,7 @@ type IntermediateShellEntry = {
|
|
|
5
5
|
keys: string[];
|
|
6
6
|
encoded: string;
|
|
7
7
|
};
|
|
8
|
-
/** Page `prerenderParams`. */
|
|
8
|
+
/** Page or Markdown route `prerenderParams`. */
|
|
9
9
|
export declare function getPrerenderParams(route: PageRoute): Promise<PrerenderParamsResult | null>;
|
|
10
10
|
/**
|
|
11
11
|
* Returns intermediate shells from ancestor layouts. Richest shells are listed first for runtime
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerender-params.d.ts","sourceRoot":"","sources":["../../src/lib/prerender-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"prerender-params.d.ts","sourceRoot":"","sources":["../../src/lib/prerender-params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA8B,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE1F,OAAO,EAEN,KAAK,SAAS,EAEd,KAAK,WAAW,EAChB,MAAM,oBAAoB,CAAA;AAG3B,KAAK,sBAAsB,GAAG;IAC7B,MAAM,EAAE,WAAW,CAAA;IACnB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CACf,CAAA;AA6CD,gDAAgD;AAChD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,SAAS,yCAyBxD;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,KAAK,EAAE,SAAS,qCA2ChE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { layoutModules, pageModules } from "./app-manifest.js";
|
|
1
|
+
import { layoutModules, markdownHandlerModules, pageModules } from "./app-manifest.js";
|
|
2
2
|
import { getDynamicSegmentNames, parseSegment, } from "./route-matcher.js";
|
|
3
3
|
import { collectShellParamParts } from "./shell-params.js";
|
|
4
4
|
const prerenderParamsByFile = new Map();
|
|
@@ -29,8 +29,23 @@ function loadPrerenderParams(filePath, loader) {
|
|
|
29
29
|
}
|
|
30
30
|
return pending;
|
|
31
31
|
}
|
|
32
|
-
/** Page `prerenderParams`. */
|
|
32
|
+
/** Page or Markdown route `prerenderParams`. */
|
|
33
33
|
export async function getPrerenderParams(route) {
|
|
34
|
+
if (route.hasPage === false && route.markdownFilePath) {
|
|
35
|
+
return loadPrerenderParams(route.markdownFilePath, markdownHandlerModules[route.markdownFilePath]);
|
|
36
|
+
}
|
|
37
|
+
if (route.markdownFilePath && !route.markdownFilePath.endsWith(".md")) {
|
|
38
|
+
const [pageParams, markdownParams] = await Promise.all([
|
|
39
|
+
loadPrerenderParams(route.filePath, pageModules[route.filePath]),
|
|
40
|
+
loadPrerenderParams(route.markdownFilePath, markdownHandlerModules[route.markdownFilePath]),
|
|
41
|
+
]);
|
|
42
|
+
if (pageParams && markdownParams) {
|
|
43
|
+
throw new Error(`Cannot define prerenderParams in both "${route.filePath}" and ` +
|
|
44
|
+
`"${route.markdownFilePath}". Remove it from the Markdown file; ` +
|
|
45
|
+
`the page's prerenderParams takes priority.`);
|
|
46
|
+
}
|
|
47
|
+
return pageParams ?? markdownParams;
|
|
48
|
+
}
|
|
34
49
|
return loadPrerenderParams(route.filePath, pageModules[route.filePath]);
|
|
35
50
|
}
|
|
36
51
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export declare const PAGE_EXTENSIONS: string[];
|
|
2
2
|
export declare const CONFIG_EXTENSIONS: string[];
|
|
3
3
|
/** Scan directory recursively for pages, layouts, and not-found components */
|
|
4
|
-
export declare function scanAppDirectory(appDir: string): Promise<{
|
|
4
|
+
export declare function scanAppDirectory(appDir: string, markdownUrls?: boolean): Promise<{
|
|
5
5
|
pages: string[];
|
|
6
6
|
layouts: string[];
|
|
7
7
|
routeHandlers: string[];
|
|
8
|
+
markdownFiles: string[];
|
|
8
9
|
}>;
|
|
9
10
|
export declare function findProjectFile(root: string, name: string): Promise<string | undefined>;
|
|
10
11
|
//# sourceMappingURL=project-files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-files.d.ts","sourceRoot":"","sources":["../../src/lib/project-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project-files.d.ts","sourceRoot":"","sources":["../../src/lib/project-files.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,UAA6B,CAAA;AACzD,eAAO,MAAM,iBAAiB,UAA6B,CAAA;AAS3D,8EAA8E;AAC9E,wBAAsB,gBAAgB,CACrC,MAAM,EAAE,MAAM,EACd,YAAY,UAAQ,GAClB,OAAO,CAAC;IACV,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,aAAa,EAAE,MAAM,EAAE,CAAA;CACvB,CAAC,CAuDD;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,+BAU/D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readdir, stat } from "node:fs/promises";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
|
+
import { assertNoMarkdownRoutePath } from "./route-builder.js";
|
|
3
4
|
export const PAGE_EXTENSIONS = ["jsx", "js", "tsx", "ts"];
|
|
4
5
|
export const CONFIG_EXTENSIONS = ["ts", "mts", "mjs", "js"];
|
|
5
6
|
function absolutePathToGlobKey(absolutePath) {
|
|
@@ -8,10 +9,11 @@ function absolutePathToGlobKey(absolutePath) {
|
|
|
8
9
|
return `/${relativePath.replace(/\\/g, "/")}`;
|
|
9
10
|
}
|
|
10
11
|
/** Scan directory recursively for pages, layouts, and not-found components */
|
|
11
|
-
export async function scanAppDirectory(appDir) {
|
|
12
|
+
export async function scanAppDirectory(appDir, markdownUrls = false) {
|
|
12
13
|
const pages = [];
|
|
13
14
|
const layouts = [];
|
|
14
15
|
const routeHandlers = [];
|
|
16
|
+
const markdownFiles = [];
|
|
15
17
|
async function scanDirectory(dir) {
|
|
16
18
|
try {
|
|
17
19
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
@@ -22,22 +24,30 @@ export async function scanAppDirectory(appDir) {
|
|
|
22
24
|
await scanDirectory(fullPath);
|
|
23
25
|
}
|
|
24
26
|
else if (entry.isFile()) {
|
|
25
|
-
|
|
27
|
+
const globKey = absolutePathToGlobKey(fullPath);
|
|
28
|
+
if (markdownUrls)
|
|
29
|
+
assertNoMarkdownRoutePath(globKey);
|
|
30
|
+
// Check if it's a page, layout, route, or Markdown file.
|
|
26
31
|
for (const ext of PAGE_EXTENSIONS) {
|
|
27
32
|
if (entry.name === `page.${ext}`) {
|
|
28
|
-
pages.push(
|
|
33
|
+
pages.push(globKey);
|
|
29
34
|
break;
|
|
30
35
|
}
|
|
31
36
|
if (entry.name === `layout.${ext}`) {
|
|
32
|
-
layouts.push(
|
|
37
|
+
layouts.push(globKey);
|
|
33
38
|
break;
|
|
34
39
|
}
|
|
35
40
|
if (entry.name === `route.${ext}`) {
|
|
36
|
-
const globKey = absolutePathToGlobKey(fullPath);
|
|
37
41
|
routeHandlers.push(globKey);
|
|
38
42
|
break;
|
|
39
43
|
}
|
|
44
|
+
if (entry.name === `markdown.${ext}`) {
|
|
45
|
+
markdownFiles.push(globKey);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
40
48
|
}
|
|
49
|
+
if (entry.name === "markdown.md")
|
|
50
|
+
markdownFiles.push(globKey);
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
}
|
|
@@ -50,7 +60,7 @@ export async function scanAppDirectory(appDir) {
|
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
await scanDirectory(appDir);
|
|
53
|
-
return { pages, layouts, routeHandlers };
|
|
63
|
+
return { pages, layouts, routeHandlers, markdownFiles };
|
|
54
64
|
}
|
|
55
65
|
export async function findProjectFile(root, name) {
|
|
56
66
|
for (const ext of CONFIG_EXTENSIONS) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type LayoutRoute, type
|
|
2
|
-
export declare function
|
|
1
|
+
import { type LayoutRoute, type PageRoute, type RouteHandlerRoute } from "./route-matcher.js";
|
|
2
|
+
export declare function assertNoMarkdownRoutePath(filePath: string): void;
|
|
3
|
+
export declare function buildRoutes(layouts: string[], pages: string[], markdownFiles?: string[]): PageRoute[];
|
|
3
4
|
/** Build internal layout routes. These routes use the /_rebask/1/{path} URL pattern. */
|
|
4
5
|
export declare function buildLayoutRoutes(layouts: string[]): LayoutRoute[];
|
|
5
6
|
export declare function buildRouteHandlerRoutes(routeHandlers: string[]): RouteHandlerRoute[];
|
|
6
|
-
export declare function assertNoPageRouteHandlerConflicts(pages: string[], routeHandlers: string[]): void;
|
|
7
|
+
export declare function assertNoPageRouteHandlerConflicts(pages: string[], routeHandlers: string[], markdownFiles?: string[]): void;
|
|
7
8
|
//# sourceMappingURL=route-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-builder.d.ts","sourceRoot":"","sources":["../../src/lib/route-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,WAAW,EAChB,KAAK,
|
|
1
|
+
{"version":3,"file":"route-builder.d.ts","sourceRoot":"","sources":["../../src/lib/route-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,MAAM,oBAAoB,CAAA;AAS3B,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,QASzD;AA6JD,wBAAgB,WAAW,CAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,GAAE,MAAM,EAAO,GAC1B,SAAS,EAAE,CAwEb;AAsDD,wFAAwF;AACxF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAgBlE;AAED,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,iBAAiB,EAAE,CAYpF;AAED,wBAAgB,iCAAiC,CAChD,KAAK,EAAE,MAAM,EAAE,EACf,aAAa,EAAE,MAAM,EAAE,EACvB,aAAa,GAAE,MAAM,EAAO,QA6C5B"}
|
|
@@ -3,6 +3,15 @@ const PAGE_EXTENSIONS = ["jsx", "js", "tsx", "ts"];
|
|
|
3
3
|
const pageSuffixRegex = new RegExp(`\\/page\\.(${PAGE_EXTENSIONS.join("|")})$`);
|
|
4
4
|
const layoutSuffixRegex = new RegExp(`\\/layout\\.(${PAGE_EXTENSIONS.join("|")})$`);
|
|
5
5
|
const routeSuffixRegex = new RegExp(`\\/route\\.(${PAGE_EXTENSIONS.join("|")})$`);
|
|
6
|
+
const markdownSuffixRegex = new RegExp(`\\/markdown\\.(md|${PAGE_EXTENSIONS.join("|")})$`);
|
|
7
|
+
const markdownDirectoryRegex = /([^/]*\.md)\//;
|
|
8
|
+
export function assertNoMarkdownRoutePath(filePath) {
|
|
9
|
+
const segment = markdownDirectoryRegex.exec(filePath)?.[1];
|
|
10
|
+
if (segment) {
|
|
11
|
+
throw new Error(`Route "${filePath}" contains the reserved "${segment}" path segment. ` +
|
|
12
|
+
`Use a markdown.md or markdown.ts file instead, or set markdownUrls: false.`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
16
|
* Build a directory-to-file map. e.g: "/app/blog/layout.tsx" -> Map { "/app/blog" => RouteFile }
|
|
8
17
|
*/
|
|
@@ -52,6 +61,9 @@ function normalizeRouteFile(filePath, suffixRegex) {
|
|
|
52
61
|
const pathSegments = relativePath.split("/").filter(Boolean);
|
|
53
62
|
const segments = pathSegments.map(parseSegment);
|
|
54
63
|
const urlSegments = segments.filter((segment) => segment.type !== "group");
|
|
64
|
+
if (typeof __REBASK_MARKDOWN_URLS !== "undefined" && __REBASK_MARKDOWN_URLS) {
|
|
65
|
+
assertNoMarkdownRoutePath(filePath);
|
|
66
|
+
}
|
|
55
67
|
for (const [index, segment] of segments.entries()) {
|
|
56
68
|
if (segment.type === "group")
|
|
57
69
|
continue;
|
|
@@ -71,6 +83,7 @@ function normalizeRouteFile(filePath, suffixRegex) {
|
|
|
71
83
|
return {
|
|
72
84
|
filePath,
|
|
73
85
|
dir,
|
|
86
|
+
hasPage: false,
|
|
74
87
|
segments,
|
|
75
88
|
urlSegments,
|
|
76
89
|
signature: "/" + urlSegments.map(segmentToSignaturePart).filter(Boolean).join("/"),
|
|
@@ -97,26 +110,46 @@ function computeShellParams(layouts) {
|
|
|
97
110
|
}
|
|
98
111
|
return result.size > 0 ? [...result] : undefined;
|
|
99
112
|
}
|
|
100
|
-
export function buildRoutes(layouts, pages) {
|
|
101
|
-
const
|
|
113
|
+
export function buildRoutes(layouts, pages, markdownFiles = []) {
|
|
114
|
+
const pageBySignature = new Map();
|
|
115
|
+
const routeFiles = pages.map((filePath) => {
|
|
116
|
+
const file = normalizeRouteFile(filePath, pageSuffixRegex);
|
|
117
|
+
file.hasPage = true;
|
|
118
|
+
pageBySignature.set(file.signature, file);
|
|
119
|
+
return file;
|
|
120
|
+
});
|
|
121
|
+
for (const filePath of markdownFiles) {
|
|
122
|
+
const file = normalizeRouteFile(filePath, markdownSuffixRegex);
|
|
123
|
+
const pageFile = pageBySignature.get(file.signature);
|
|
124
|
+
if (pageFile) {
|
|
125
|
+
pageFile.markdownFilePath = file.filePath;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
file.markdownFilePath = file.filePath;
|
|
129
|
+
routeFiles.push(file);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
102
132
|
const layoutFiles = layouts.map((filePath) => normalizeRouteFile(filePath, layoutSuffixRegex));
|
|
103
133
|
const layoutMap = buildFileMap(layoutFiles);
|
|
104
|
-
const routeTree = buildRouteTree(
|
|
105
|
-
const urlTree = buildRouteTree(
|
|
106
|
-
assertNoDuplicateRouteSignatures(
|
|
134
|
+
const routeTree = buildRouteTree(routeFiles, (file) => file.segments);
|
|
135
|
+
const urlTree = buildRouteTree(routeFiles, (file) => file.urlSegments);
|
|
136
|
+
assertNoDuplicateRouteSignatures(routeFiles, "page");
|
|
107
137
|
const routes = [];
|
|
108
138
|
function walk(node, segments) {
|
|
109
139
|
if (node.page) {
|
|
110
|
-
const
|
|
140
|
+
const { hasPage, markdownFilePath } = node.page;
|
|
141
|
+
const staticSiblings = hasPage ? getStaticSiblings(node.page, urlTree) : {};
|
|
111
142
|
const dynamicSegmentNames = getDynamicSegmentNames(segments);
|
|
112
143
|
const pageLayouts = collectAncestorFiles(node.page, layoutMap);
|
|
113
|
-
const shellParams = computeShellParams(pageLayouts);
|
|
144
|
+
const shellParams = hasPage ? computeShellParams(pageLayouts) : undefined;
|
|
114
145
|
const shellParamCount = shellParams?.length ?? 0;
|
|
115
146
|
// Intermediate shells only when layout dynamics are a proper subset of the page's dynamics.
|
|
116
147
|
const hasIntermediateShell = shellParamCount > 0 && shellParamCount < dynamicSegmentNames.length;
|
|
117
148
|
routes.push({
|
|
118
149
|
type: "page",
|
|
119
150
|
filePath: node.page.filePath,
|
|
151
|
+
...(!hasPage && { hasPage: false }),
|
|
152
|
+
...(markdownFilePath && { markdownFilePath }),
|
|
120
153
|
// We always add an empty segment at the end for the page leaf.
|
|
121
154
|
// This ensures layouts at the same level as the page are properly rendered.
|
|
122
155
|
// For example, /app/products/layout.tsx + /app/products/page.tsx:
|
|
@@ -166,7 +199,7 @@ function getStaticSiblings(file, node) {
|
|
|
166
199
|
if (segment.type !== "static") {
|
|
167
200
|
const siblings = [];
|
|
168
201
|
for (const child of node.children.values()) {
|
|
169
|
-
if (child.segment?.type === "static" && child.page) {
|
|
202
|
+
if (child.segment?.type === "static" && child.page?.hasPage) {
|
|
170
203
|
siblings.push({ name: child.segment.value, filePath: child.page.filePath });
|
|
171
204
|
}
|
|
172
205
|
}
|
|
@@ -200,18 +233,33 @@ export function buildRouteHandlerRoutes(routeHandlers) {
|
|
|
200
233
|
segments: file.segments,
|
|
201
234
|
}));
|
|
202
235
|
}
|
|
203
|
-
export function assertNoPageRouteHandlerConflicts(pages, routeHandlers) {
|
|
236
|
+
export function assertNoPageRouteHandlerConflicts(pages, routeHandlers, markdownFiles = []) {
|
|
204
237
|
const pageBySignature = new Map();
|
|
205
238
|
for (const pagePath of pages) {
|
|
206
239
|
const pageFile = normalizeRouteFile(pagePath, pageSuffixRegex);
|
|
207
240
|
pageBySignature.set(pageFile.signature, pageFile.filePath);
|
|
208
241
|
}
|
|
242
|
+
const markdownBySignature = new Map();
|
|
243
|
+
for (const markdownPath of markdownFiles) {
|
|
244
|
+
const markdownFile = normalizeRouteFile(markdownPath, markdownSuffixRegex);
|
|
245
|
+
const existing = markdownBySignature.get(markdownFile.signature);
|
|
246
|
+
if (existing) {
|
|
247
|
+
throw new Error(`Cannot define both markdown.md and markdown.ts for the same route signature: ` +
|
|
248
|
+
`${existing} and ${markdownPath}.`);
|
|
249
|
+
}
|
|
250
|
+
markdownBySignature.set(markdownFile.signature, markdownPath);
|
|
251
|
+
}
|
|
209
252
|
for (const routePath of routeHandlers) {
|
|
210
253
|
const routeFile = normalizeRouteFile(routePath, routeSuffixRegex);
|
|
211
254
|
const pagePath = pageBySignature.get(routeFile.signature);
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
255
|
+
if (pagePath) {
|
|
256
|
+
throw new Error(`Cannot define both page and route handler for the same route signature: ` +
|
|
257
|
+
`${pagePath} and ${routePath}.`);
|
|
258
|
+
}
|
|
259
|
+
const markdownPath = markdownBySignature.get(routeFile.signature);
|
|
260
|
+
if (markdownPath) {
|
|
261
|
+
throw new Error(`Cannot define both markdown and route handler for the same route signature: ` +
|
|
262
|
+
`${markdownPath} and ${routePath}.`);
|
|
263
|
+
}
|
|
216
264
|
}
|
|
217
265
|
}
|
|
@@ -28,6 +28,10 @@ export type PageRoute = RouteBase & {
|
|
|
28
28
|
filePath: string;
|
|
29
29
|
/** Dynamic segment names from layout paths (params baked into intermediate shells). */
|
|
30
30
|
shellParams?: string[];
|
|
31
|
+
/** Whether the route has a `page.tsx` module. */
|
|
32
|
+
hasPage?: boolean;
|
|
33
|
+
/** The Markdown source file, relative to the app root. */
|
|
34
|
+
markdownFilePath?: string;
|
|
31
35
|
};
|
|
32
36
|
export type NotFoundRoute = RouteBase & {
|
|
33
37
|
type: "not-found";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-matcher.d.ts","sourceRoot":"","sources":["../../src/lib/route-matcher.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AACtD,KAAK,cAAc,GAAG;IAAE,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,oBAAoB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAC5F,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,YAAY,CAAA;AAExE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAA;AAEvE,eAAO,MAAM,YAAY,YAAI,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAU,CAAA;AAEjG,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD,KAAK,SAAS,GAAG;IAChB,QAAQ,EAAE,YAAY,EAAE,CAAA;IACxB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,oFAAoF;IACp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,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG,IAAI,cAAc,CAEzE;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAMzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-request.d.ts","sourceRoot":"","sources":["../../src/lib/rsc-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAMN,KAAK,kBAAkB,EAIvB,MAAM,uBAAuB,CAAA;AAK9B,OAAO,EAAkB,KAAK,aAAa,EAAU,MAAM,oBAAoB,CAAA;AAS/E,OAAO,
|
|
1
|
+
{"version":3,"file":"rsc-request.d.ts","sourceRoot":"","sources":["../../src/lib/rsc-request.ts"],"names":[],"mappings":"AAKA,OAAO,EAMN,KAAK,kBAAkB,EAIvB,MAAM,uBAAuB,CAAA;AAK9B,OAAO,EAAkB,KAAK,aAAa,EAAU,MAAM,oBAAoB,CAAA;AAS/E,OAAO,EAKN,iBAAiB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,qBAAqB,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAI5C,wBAAsB,aAAa,CAAC,CAAC,EACpC,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,CAAC,CAUZ;AAcD,wBAAgB,SAAS,CACxB,OAAO,EAAE,UAAU,EACnB,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,EACrE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,+CAclC;AAED,wBAAgB,YAAY,CAC3B,OAAO,EAAE,UAA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,CAyBrE;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,UAAU,EAAE,GAAG,EACf,MAAM,SAAM,GACV,QAAQ,CAmCV;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,SAAM,YA2BxF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,QAExD;AAED,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,GACtD,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
package/dist/lib/rsc-request.js
CHANGED
|
@@ -8,11 +8,11 @@ import { CacheKeyTag } from "./cache-key-tags.js";
|
|
|
8
8
|
import { getCacheKey } from "./cache-keys.js";
|
|
9
9
|
import { streamFromCachePayload, streamToCachePayload } from "./cache-payload.js";
|
|
10
10
|
import { CacheEntryType, STATIC } from "./cache-storage.js";
|
|
11
|
-
import { getCacheHandler } from "./config.js";
|
|
11
|
+
import { cacheStatusHeader, getCacheHandler } from "./config.js";
|
|
12
12
|
import { getDeploymentIdHeader } from "./deployment-id.js";
|
|
13
13
|
import { renderChannel, rscChannel } from "./devtools-channels.js";
|
|
14
14
|
import { isHangingPromiseError, isPrerenderAbortError, SERVER_RENDER_ERROR_DIGEST, } from "./errors.js";
|
|
15
|
-
import { getCacheControlHeader,
|
|
15
|
+
import { getCacheControlHeader, REBASK_RSC_VARY_HEADER, REBASK_TAIL_HEADER, REBASK_TRAILER_HEADER, RebaskCacheStatus, } from "./ppr/headers.js";
|
|
16
16
|
import { RenderStorage } from "./render-context.js";
|
|
17
17
|
import { MicrotaskStorage } from "./scheduler-patch.js";
|
|
18
18
|
import { recordRenderDuration } from "./telemetry.js";
|
|
@@ -77,7 +77,7 @@ export function createRscResponse(rscStream, options = {}) {
|
|
|
77
77
|
headers: mergeResponseHeaders({
|
|
78
78
|
...(contentType && { "content-type": contentType }),
|
|
79
79
|
vary: REBASK_RSC_VARY_HEADER,
|
|
80
|
-
|
|
80
|
+
...cacheStatusHeader(cacheStatus),
|
|
81
81
|
...(cacheControl && { "cache-control": cacheControl }),
|
|
82
82
|
...(tagHeader && tags?.length && { [tagHeader]: tags.join(",") }),
|
|
83
83
|
...(tailId && { [REBASK_TAIL_HEADER]: tailId }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-router.d.ts","sourceRoot":"","sources":["../../../src/lib/server-router/get-router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-router.d.ts","sourceRoot":"","sources":["../../../src/lib/server-router/get-router.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AA6O9C,yDAAyD;AACzD,wBAAsB,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC,CA4BvD"}
|