@k8ordo/framework 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.mjs +1 -2
- package/dist/runtime/app-router.d.mts +1 -3
- package/dist/runtime/app-router.mjs +1 -2
- package/dist/runtime/browser-payloads.d.mts +1 -3
- package/dist/runtime/browser-payloads.mjs +1 -2
- package/dist/runtime/cancel.d.mts +1 -3
- package/dist/runtime/cancel.mjs +1 -2
- package/dist/runtime/client-ready.d.mts +1 -3
- package/dist/runtime/client-ready.mjs +1 -2
- package/dist/runtime/cookies.d.mts +1 -3
- package/dist/runtime/cookies.mjs +1 -2
- package/dist/runtime/entry.browser.mjs +1 -2
- package/dist/runtime/entry.rsc.d.mts +1 -3
- package/dist/runtime/entry.rsc.mjs +1 -2
- package/dist/runtime/entry.ssr.d.mts +1 -3
- package/dist/runtime/entry.ssr.mjs +1 -2
- package/dist/runtime/fallback-boundary.d.mts +0 -2
- package/dist/runtime/fallback-boundary.mjs +1 -2
- package/dist/runtime/guard.d.mts +0 -2
- package/dist/runtime/guard.mjs +1 -2
- package/dist/runtime/is-payload.d.mts +1 -3
- package/dist/runtime/is-payload.mjs +1 -2
- package/dist/runtime/mount.d.mts +1 -3
- package/dist/runtime/mount.mjs +1 -2
- package/dist/runtime/page-boundary.d.mts +0 -2
- package/dist/runtime/page-boundary.mjs +1 -2
- package/dist/runtime/page-shown.d.mts +1 -3
- package/dist/runtime/page-shown.mjs +1 -2
- package/dist/runtime/page-watch.d.mts +1 -3
- package/dist/runtime/page-watch.mjs +1 -2
- package/dist/runtime/params.d.mts +0 -2
- package/dist/runtime/params.mjs +1 -2
- package/dist/runtime/pathname.d.mts +1 -3
- package/dist/runtime/pathname.mjs +1 -2
- package/dist/runtime/payload-path.d.mts +1 -3
- package/dist/runtime/payload-path.mjs +1 -2
- package/dist/runtime/payload.d.mts +1 -3
- package/dist/runtime/payload.mjs +1 -2
- package/dist/runtime/prefetch.d.mts +1 -3
- package/dist/runtime/prefetch.mjs +1 -2
- package/dist/runtime/recover.d.mts +1 -3
- package/dist/runtime/recover.mjs +1 -2
- package/dist/runtime/redirect-file.d.mts +0 -2
- package/dist/runtime/redirect-file.mjs +1 -2
- package/dist/runtime/redirect.d.mts +0 -2
- package/dist/runtime/redirect.mjs +1 -2
- package/dist/runtime/reload.d.mts +1 -3
- package/dist/runtime/reload.mjs +1 -2
- package/dist/runtime/render.d.mts +1 -3
- package/dist/runtime/render.mjs +1 -2
- package/dist/runtime/request-scope.d.mts +1 -3
- package/dist/runtime/request-scope.mjs +1 -2
- package/dist/runtime/request.d.mts +1 -3
- package/dist/runtime/request.mjs +1 -2
- package/dist/runtime/revealed.d.mts +1 -3
- package/dist/runtime/revealed.mjs +1 -2
- package/dist/runtime/route.d.mts +0 -2
- package/dist/runtime/route.mjs +1 -2
- package/dist/runtime/says-not-found.d.mts +1 -3
- package/dist/runtime/says-not-found.mjs +1 -2
- package/dist/runtime/shell.d.mts +1 -3
- package/dist/runtime/shell.mjs +1 -2
- package/dist/runtime/tree-pathname.d.mts +1 -3
- package/dist/runtime/tree-pathname.mjs +1 -2
- package/dist/serve.d.mts +1 -3
- package/dist/serve.mjs +2 -3
- package/dist/server.d.mts +0 -16
- package/dist/server.mjs +2 -4
- package/dist/{shared-dir-CkF4QCWc.mjs → shared-dir-CNXFRZgP.mjs} +1 -2
- package/dist/{static-BaGdAVF1.d.mts → static-6z8_6B1U.d.mts} +0 -6
- package/dist/{static-host-dgtttTuZ.mjs → static-host-C6D_11Gp.mjs} +6 -12
- package/dist/vercel.d.mts +1 -5
- package/dist/vercel.mjs +3 -5
- package/dist/vite.d.mts +1 -3
- package/dist/vite.mjs +16 -30
- package/docs/GUIDE.md +10 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ dependencies in either mode: the build bundles what the application runs.
|
|
|
35
35
|
|
|
36
36
|
| Package | Version | Required | Needed for |
|
|
37
37
|
| --------------------- | -------- | -------- | ------------------------------------------ |
|
|
38
|
-
| `@k8ordo/router` | ^1.4.
|
|
38
|
+
| `@k8ordo/router` | ^1.4.2 | yes | routing, re-exported by the framework |
|
|
39
39
|
| `react` | ≥19.3.0 | yes | rendering |
|
|
40
40
|
| `react-dom` | ≥19.3.0 | yes | rendering |
|
|
41
41
|
| `vite` | ≥8.1.0 | yes | the build (`framework()` is a Vite plugin) |
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolveConfig } from "vite";
|
|
3
|
-
|
|
3
|
+
// src/cli.ts
|
|
4
4
|
const USAGE = `usage: k8ordo generate
|
|
5
5
|
|
|
6
6
|
Writes .k8ordo/ from the Vite config in this directory, as vite build does
|
|
@@ -29,5 +29,4 @@ if (args.length !== 1 || args[0] !== "generate") {
|
|
|
29
29
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
30
30
|
process.exitCode = 1;
|
|
31
31
|
}
|
|
32
|
-
//#endregion
|
|
33
32
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Payload } from "./payload.mjs";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
//#region src/runtime/app-router.d.ts
|
|
4
3
|
export declare const setDocumentClient: (client: string) => void;
|
|
5
4
|
/** Taken before a Server Action is sent, and handed to `answerAction`. */
|
|
6
5
|
export declare const navigationsApplied: () => number;
|
|
@@ -28,5 +27,4 @@ export declare function AppRouter({ pathname, search, tree, notFound }: {
|
|
|
28
27
|
tree: ReactNode;
|
|
29
28
|
/** A shell's not-found, when the tree is a shell. */
|
|
30
29
|
notFound?: ReactNode | undefined;
|
|
31
|
-
}): ReactNode;
|
|
32
|
-
//#endregion
|
|
30
|
+
}): ReactNode;
|
|
@@ -9,7 +9,7 @@ import { TreePathname } from "./tree-pathname.mjs";
|
|
|
9
9
|
import { NavigationGeneration, PathnameProvider, normalizePathname, useInterceptedNavigation, withoutBase } from "@k8ordo/router";
|
|
10
10
|
import { startTransition, useDeferredValue, useEffect, useRef, useState } from "react";
|
|
11
11
|
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
|
|
12
|
+
// src/runtime/app-router.tsx
|
|
13
13
|
/**
|
|
14
14
|
* Where a Server Action's answer lands. The callback has to be registered
|
|
15
15
|
* before any client component can call one, which is earlier than a component
|
|
@@ -304,5 +304,4 @@ function AppRouter({ pathname, search, tree, notFound }) {
|
|
|
304
304
|
})
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
//#endregion
|
|
308
307
|
export { AppRouter, answerAction, navigationsApplied, setDocumentClient, setPayloadReader };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
//#region src/runtime/browser-payloads.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Hands app-router the browser's Flight client: how a fetched payload is
|
|
4
3
|
* read, and where a Server Action is sent. Called by the browser entry
|
|
5
4
|
* before anything renders.
|
|
6
5
|
*/
|
|
7
|
-
export declare const connectAppRouter: () => void;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare const connectAppRouter: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ACTION_ID_HEADER } from "./payload.mjs";
|
|
2
2
|
import { answerAction, navigationsApplied, setPayloadReader } from "./app-router.mjs";
|
|
3
3
|
import { createFromFetch, createFromReadableStream, createTemporaryReferenceSet, encodeReply, setServerCallback } from "@vitejs/plugin-rsc/browser";
|
|
4
|
-
|
|
4
|
+
// src/runtime/browser-payloads.ts
|
|
5
5
|
/**
|
|
6
6
|
* Hands app-router the browser's Flight client: how a fetched payload is
|
|
7
7
|
* read, and where a Server Action is sent. Called by the browser entry
|
|
@@ -21,5 +21,4 @@ const connectAppRouter = () => {
|
|
|
21
21
|
return answerAction(payload, sent, url);
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
export { connectAppRouter };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/cancel.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* `stream` as its reader reads it, with `cancelled` told first when that
|
|
4
3
|
* reader gives up — a visitor who left, a navigation overtaken — before the
|
|
@@ -7,5 +6,4 @@
|
|
|
7
6
|
* reason the host gave, and only what is told first can tell that apart from
|
|
8
7
|
* a page that failed.
|
|
9
8
|
*/
|
|
10
|
-
export declare const noticeCancel: <T>(stream: ReadableStream<T>, cancelled: (reason: unknown) => void) => ReadableStream<T>;
|
|
11
|
-
//#endregion
|
|
9
|
+
export declare const noticeCancel: <T>(stream: ReadableStream<T>, cancelled: (reason: unknown) => void) => ReadableStream<T>;
|
package/dist/runtime/cancel.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/cancel.ts
|
|
2
2
|
/**
|
|
3
3
|
* `stream` as its reader reads it, with `cancelled` told first when that
|
|
4
4
|
* reader gives up — a visitor who left, a navigation overtaken — before the
|
|
@@ -21,5 +21,4 @@ const noticeCancel = (stream, cancelled) => {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
|
-
//#endregion
|
|
25
24
|
export { noticeCancel };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/client-ready.d.ts
|
|
2
1
|
export type ClientReadyOptions = {
|
|
3
2
|
/**
|
|
4
3
|
* What to do with a row still on its way: `'wait'` for it; `'leave'` one
|
|
@@ -27,5 +26,4 @@ export type ClientReadyOptions = {
|
|
|
27
26
|
* render, a module that would not load — ends the wait there, for the
|
|
28
27
|
* render to meet where an error boundary takes it.
|
|
29
28
|
*/
|
|
30
|
-
export declare const whenClientReady: (trees: readonly unknown[], { rows }: ClientReadyOptions) => Promise<void>;
|
|
31
|
-
//#endregion
|
|
29
|
+
export declare const whenClientReady: (trees: readonly unknown[], { rows }: ClientReadyOptions) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/client-ready.ts
|
|
2
2
|
/**
|
|
3
3
|
* The shapes React shares between `React.lazy`, the Flight client and the
|
|
4
4
|
* reconciler, and the only ones read here: an element's `$$typeof`, `type`
|
|
@@ -96,5 +96,4 @@ const whenClientReady = async (trees, { rows }) => {
|
|
|
96
96
|
for (const tree of trees) visit(tree, false);
|
|
97
97
|
await settle();
|
|
98
98
|
};
|
|
99
|
-
//#endregion
|
|
100
99
|
export { whenClientReady };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/cookies.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* How a cookie is kept. The defaults are the ones a session wants: sent on
|
|
4
3
|
* every path, never readable from a page's script, only over HTTPS, and not
|
|
@@ -46,5 +45,4 @@ export type Cookies = {
|
|
|
46
45
|
export declare const createCookies: (incoming: ReadonlyMap<string, string>, url: URL) => {
|
|
47
46
|
readonly cookies: Cookies;
|
|
48
47
|
readonly lines: () => string[];
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
48
|
+
};
|
package/dist/runtime/cookies.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/cookies.ts
|
|
2
2
|
/** RFC 6265's token: what a cookie name may be spelled with. */
|
|
3
3
|
const TOKEN = /^[!#$%&'*+\-.^`|~\w]+$/u;
|
|
4
4
|
/**
|
|
@@ -82,5 +82,4 @@ const createCookies = (incoming, url) => {
|
|
|
82
82
|
lines: () => [...lines.values()]
|
|
83
83
|
};
|
|
84
84
|
};
|
|
85
|
-
//#endregion
|
|
86
85
|
export { createCookies };
|
|
@@ -7,7 +7,7 @@ import { whenRevealed } from "./revealed.mjs";
|
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { createFromReadableStream } from "@vitejs/plugin-rsc/browser";
|
|
9
9
|
import { rscStream } from "rsc-html-stream/client";
|
|
10
|
-
|
|
10
|
+
// src/runtime/entry.browser.tsx
|
|
11
11
|
connectAppRouter();
|
|
12
12
|
const start = async () => {
|
|
13
13
|
const payload = await createFromReadableStream(rscStream);
|
|
@@ -25,5 +25,4 @@ const start = async () => {
|
|
|
25
25
|
});
|
|
26
26
|
};
|
|
27
27
|
start();
|
|
28
|
-
//#endregion
|
|
29
28
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Mode } from "../host.mjs";
|
|
2
|
-
//#region src/runtime/entry.rsc.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Where Vite serves the application, as the build was told (`base`). A host
|
|
5
4
|
* serving the client build's files needs it to find them — `serve` reads it
|
|
@@ -18,5 +17,4 @@ export declare const mode: Mode;
|
|
|
18
17
|
* What it knows of the mode is compiled in (`K8ORDO_MODE`): whether a page
|
|
19
18
|
* gets the request, and whether a failed render may still stream.
|
|
20
19
|
*/
|
|
21
|
-
export default function handler(request: Request): Promise<Response>;
|
|
22
|
-
//#endregion
|
|
20
|
+
export default function handler(request: Request): Promise<Response>;
|
|
@@ -17,7 +17,7 @@ import { isNotFound, normalizePathname, withBase, withoutBase } from "@k8ordo/ro
|
|
|
17
17
|
import { jsx } from "react/jsx-runtime";
|
|
18
18
|
import { createTemporaryReferenceSet, decodeAction, decodeFormState, decodeReply, loadServerAction, renderToReadableStream } from "@vitejs/plugin-rsc/rsc/server";
|
|
19
19
|
import { catchAllSchemas, fallbacks, guards, pageModules, paramSchemas, redirects, routeModules, routes, searchReaders } from "virtual:k8ordo/routes";
|
|
20
|
-
|
|
20
|
+
// src/runtime/entry.rsc.tsx
|
|
21
21
|
const redirectFor = resolveRedirects(redirects);
|
|
22
22
|
const redirectResponse = (to, status) => new Response(null, {
|
|
23
23
|
status,
|
|
@@ -445,5 +445,4 @@ const renderPayload = (payload, enter, temporaryReferences) => {
|
|
|
445
445
|
*/
|
|
446
446
|
const drain = (stream) => stream.pipeTo(new WritableStream()).catch(() => void 0);
|
|
447
447
|
if (import.meta.hot) import.meta.hot.accept();
|
|
448
|
-
//#endregion
|
|
449
448
|
export { base, handler as default, mode };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ClientDeps } from "./payload.mjs";
|
|
2
|
-
//#region src/runtime/entry.ssr.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The script every page's HTML loads, and so the client every payload is
|
|
5
4
|
* rendered for. Exported for the RSC entry, which renders the payloads:
|
|
@@ -13,5 +12,4 @@ export declare const clientEntry: string;
|
|
|
13
12
|
* one round trip. It is also what lets a prerendered `404.html` come alive —
|
|
14
13
|
* there is no payload file at a URL the application does not have.
|
|
15
14
|
*/
|
|
16
|
-
export declare function renderHtml(rscStream: ReadableStream<Uint8Array>, nonce: string, showsPage: boolean, carriesFormState: boolean, named: readonly ClientDeps[]): Promise<ReadableStream>;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function renderHtml(rscStream: ReadableStream<Uint8Array>, nonce: string, showsPage: boolean, carriesFormState: boolean, named: readonly ClientDeps[]): Promise<ReadableStream>;
|
|
@@ -10,7 +10,7 @@ import { preinit, preloadModule } from "react-dom";
|
|
|
10
10
|
import { renderToReadableStream } from "react-dom/server.edge";
|
|
11
11
|
import { injectRSCPayload } from "rsc-html-stream/server";
|
|
12
12
|
import assetsManifest from "virtual:vite-rsc/assets-manifest";
|
|
13
|
-
|
|
13
|
+
// src/runtime/entry.ssr.tsx
|
|
14
14
|
/**
|
|
15
15
|
* The script every page's HTML loads, and so the client every payload is
|
|
16
16
|
* rendered for. Exported for the RSC entry, which renders the payloads:
|
|
@@ -101,5 +101,4 @@ async function renderHtml(rscStream, nonce, showsPage, carriesFormState, named)
|
|
|
101
101
|
readerLeft = true;
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
-
//#endregion
|
|
105
104
|
export { clientEntry, renderHtml };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ReactNode } from "react";
|
|
2
|
-
//#region src/runtime/fallback-boundary.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* What shows a shell's not-found in place — `true` when it did — or null
|
|
5
4
|
* where the payload carries none.
|
|
@@ -39,5 +38,4 @@ export declare class FallbackCatch extends Component<CatchProps, CatchState> {
|
|
|
39
38
|
export declare const FallbackBoundary: ({ children }: {
|
|
40
39
|
children: ReactNode;
|
|
41
40
|
}) => ReactNode;
|
|
42
|
-
//#endregion
|
|
43
41
|
export {};
|
|
@@ -3,7 +3,7 @@ import { saysNotFound } from "./says-not-found.mjs";
|
|
|
3
3
|
import { BrowserPathname, NavigationGeneration } from "@k8ordo/router";
|
|
4
4
|
import { Component, Suspense, createContext, use } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/runtime/fallback-boundary.tsx
|
|
7
7
|
/**
|
|
8
8
|
* What shows a shell's not-found in place — `true` when it did — or null
|
|
9
9
|
* where the payload carries none.
|
|
@@ -60,5 +60,4 @@ const FallbackBoundary = ({ children }) => /* @__PURE__ */ jsx(FallbackCatch, {
|
|
|
60
60
|
show: use(ShowNotFound),
|
|
61
61
|
children
|
|
62
62
|
});
|
|
63
|
-
//#endregion
|
|
64
63
|
export { FallbackBoundary, FallbackCatch, ShowNotFound };
|
package/dist/runtime/guard.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ParamsOf } from "@k8ordo/router";
|
|
2
|
-
//#region src/runtime/guard.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* What a `guard.ts` receives: the request, and the params of the pattern its
|
|
5
4
|
* directory puts it under, as the strings the pathname carried — a guard runs
|
|
@@ -26,5 +25,4 @@ type AnyGuard = (context: {
|
|
|
26
25
|
* inner guard assume what an outer one checked.
|
|
27
26
|
*/
|
|
28
27
|
export declare const runGuards: (guards: readonly AnyGuard[], context: Parameters<AnyGuard>[0]) => Promise<Response | null>;
|
|
29
|
-
//#endregion
|
|
30
28
|
export {};
|
package/dist/runtime/guard.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inPhase } from "./request-scope.mjs";
|
|
2
|
-
|
|
2
|
+
// src/runtime/guard.ts
|
|
3
3
|
/**
|
|
4
4
|
* Runs the guards along a pattern, outer first, one at a time: an outer guard
|
|
5
5
|
* that ends the request leaves the inner ones unrun, which is what lets an
|
|
@@ -14,5 +14,4 @@ const runGuards = async (guards, context) => {
|
|
|
14
14
|
}
|
|
15
15
|
return null;
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { runGuards };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/is-payload.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Whether what came back is this application's answer rather than the host's.
|
|
4
3
|
*
|
|
@@ -9,5 +8,4 @@
|
|
|
9
8
|
* payload. A host that guesses some other type for `.rsc` is taken at its
|
|
10
9
|
* word and the parse decides.
|
|
11
10
|
*/
|
|
12
|
-
export declare const isPayload: (response: Response) => boolean;
|
|
13
|
-
//#endregion
|
|
11
|
+
export declare const isPayload: (response: Response) => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/is-payload.ts
|
|
2
2
|
/**
|
|
3
3
|
* Whether what came back is this application's answer rather than the host's.
|
|
4
4
|
*
|
|
@@ -14,5 +14,4 @@ const isPayload = (response) => {
|
|
|
14
14
|
if (type.startsWith("text/html")) return false;
|
|
15
15
|
return response.ok || type.startsWith("text/x-component");
|
|
16
16
|
};
|
|
17
|
-
//#endregion
|
|
18
17
|
export { isPayload };
|
package/dist/runtime/mount.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Root, hydrateRoot } from "react-dom/client";
|
|
3
|
-
//#region src/runtime/mount.d.ts
|
|
4
3
|
export type HydrateOptions = NonNullable<Parameters<typeof hydrateRoot>[2]>;
|
|
5
4
|
/**
|
|
6
5
|
* Brings the server's HTML to life where the browser is. Hydration holds the
|
|
@@ -13,5 +12,4 @@ export type HydrateOptions = NonNullable<Parameters<typeof hydrateRoot>[2]>;
|
|
|
13
12
|
* until the client's replaces it, rather than failing hydration and being
|
|
14
13
|
* regenerated anyway, with the server's `<title>` left behind.
|
|
15
14
|
*/
|
|
16
|
-
export declare const mount: (container: Document | Element, app: ReactNode, renderedFor: string, options?: HydrateOptions) => Root;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare const mount: (container: Document | Element, app: ReactNode, renderedFor: string, options?: HydrateOptions) => Root;
|
package/dist/runtime/mount.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizePathname, withoutBase } from "@k8ordo/router";
|
|
2
2
|
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
3
|
-
|
|
3
|
+
// src/runtime/mount.ts
|
|
4
4
|
/**
|
|
5
5
|
* Brings the server's HTML to life where the browser is. Hydration holds the
|
|
6
6
|
* first render to the HTML it finds, and that HTML was rendered for one
|
|
@@ -20,5 +20,4 @@ const mount = (container, app, renderedFor, options) => {
|
|
|
20
20
|
root.render(app);
|
|
21
21
|
return root;
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { mount };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ReactNode } from "react";
|
|
2
|
-
//#region src/runtime/page-boundary.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* What the root reports of an error a boundary caught: what React would —
|
|
5
4
|
* the error, and under `vite dev` where in the tree — except a navigation's
|
|
@@ -36,5 +35,4 @@ export declare class PageBoundary extends Component<{
|
|
|
36
35
|
componentDidCatch(error: unknown): void;
|
|
37
36
|
render(): ReactNode;
|
|
38
37
|
}
|
|
39
|
-
//#endregion
|
|
40
38
|
export {};
|
|
@@ -4,7 +4,7 @@ import { FallbackCatch } from "./fallback-boundary.mjs";
|
|
|
4
4
|
import { reloadDocument } from "./reload.mjs";
|
|
5
5
|
import { isNavigated } from "./recover.mjs";
|
|
6
6
|
import { Component } from "react";
|
|
7
|
-
|
|
7
|
+
// src/runtime/page-boundary.tsx
|
|
8
8
|
/** Whether the boundary answers `error` with a document load. */
|
|
9
9
|
const sendsBack = (error) => saysNotFound(error) && isNavigated();
|
|
10
10
|
/**
|
|
@@ -53,5 +53,4 @@ var PageBoundary = class extends Component {
|
|
|
53
53
|
throw this.state.error;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
//#endregion
|
|
57
56
|
export { PageBoundary, reportCaught };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/page-shown.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* What the HTML render of a document is told by once the page's own
|
|
4
3
|
* component has rendered there; `null` everywhere else.
|
|
@@ -9,5 +8,4 @@ export declare const PageShownContext: import("react").Context<(() => void) | nu
|
|
|
9
8
|
* content has: in the HTML render, that is how the render learns the page is
|
|
10
9
|
* in place before anything is sent. Renders nothing.
|
|
11
10
|
*/
|
|
12
|
-
export declare function PageShown(): null;
|
|
13
|
-
//#endregion
|
|
11
|
+
export declare function PageShown(): null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, use } from "react";
|
|
3
|
-
|
|
3
|
+
// src/runtime/page-shown.tsx
|
|
4
4
|
/**
|
|
5
5
|
* What the HTML render of a document is told by once the page's own
|
|
6
6
|
* component has rendered there; `null` everywhere else.
|
|
@@ -15,5 +15,4 @@ function PageShown() {
|
|
|
15
15
|
use(PageShownContext)?.();
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { PageShown, PageShownContext };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RouteComponent } from "@k8ordo/router";
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
|
-
//#region src/runtime/page-watch.d.ts
|
|
4
3
|
export type WatchedPage = {
|
|
5
4
|
/** What to render in the page's place: the page, watched. */
|
|
6
5
|
readonly Page: ComponentType<never>;
|
|
@@ -29,5 +28,4 @@ export type WatchedPage = {
|
|
|
29
28
|
* same row of the payload — so wherever the payload is read, it renders only
|
|
30
29
|
* once the page's own content has arrived.
|
|
31
30
|
*/
|
|
32
|
-
export declare const watchPage: (page: RouteComponent, after?: ReactNode) => WatchedPage;
|
|
33
|
-
//#endregion
|
|
31
|
+
export declare const watchPage: (page: RouteComponent, after?: ReactNode) => WatchedPage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, createElement } from "react";
|
|
2
|
-
|
|
2
|
+
// src/runtime/page-watch.ts
|
|
3
3
|
const CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
4
4
|
const isThenable = (value) => typeof value === "object" && value !== null && typeof value.then === "function";
|
|
5
5
|
/**
|
|
@@ -47,5 +47,4 @@ const watchPage = (page, after) => {
|
|
|
47
47
|
followed: after !== void 0
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
export { watchPage };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/params.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A route file's `paramsSchema` export, in the one shape every validation library
|
|
4
3
|
* agrees on (Standard Schema). The framework runs it; the router only types
|
|
@@ -46,5 +45,4 @@ export declare const parseParams: (schemas: readonly ParamsSchema[], raw: Readon
|
|
|
46
45
|
* says.
|
|
47
46
|
*/
|
|
48
47
|
export declare const parseCatchAllParams: (schemas: readonly ParamsSchema[], raw: Readonly<Record<string, string>>) => ParsedParams;
|
|
49
|
-
//#endregion
|
|
50
48
|
export {};
|
package/dist/runtime/params.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
|
|
2
|
-
|
|
2
|
+
// src/runtime/params.ts
|
|
3
3
|
/**
|
|
4
4
|
* Runs the schemas along a matched stack — outer layouts first, the page
|
|
5
5
|
* last — over the raw params, each replacing the strings it names with what
|
|
@@ -39,5 +39,4 @@ const parseCatchAllParams = (schemas, raw) => ({
|
|
|
39
39
|
params: raw,
|
|
40
40
|
enter: parseParams(schemas, raw)?.enter ?? ((fn) => fn())
|
|
41
41
|
});
|
|
42
|
-
//#endregion
|
|
43
42
|
export { parseCatchAllParams, parseParams };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/pathname.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A pathname as the URL carries it, decoded for the filesystem — the one
|
|
4
3
|
* thing the static writer and the server's file lookup both have to do
|
|
@@ -19,5 +18,4 @@ export declare const NOT_FOUND_SEGMENT = "__k8ordo-not-found__";
|
|
|
19
18
|
* `encodeURIComponent` nor the URL parser rewrites `!`, so a host that
|
|
20
19
|
* re-encodes a rewrite target finds the directory under the same spelling.
|
|
21
20
|
*/
|
|
22
|
-
export declare const FALLBACK_SEGMENT = "!fallback";
|
|
23
|
-
//#endregion
|
|
21
|
+
export declare const FALLBACK_SEGMENT = "!fallback";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/pathname.ts
|
|
2
2
|
/**
|
|
3
3
|
* A pathname as the URL carries it, decoded for the filesystem — the one
|
|
4
4
|
* thing the static writer and the server's file lookup both have to do
|
|
@@ -28,5 +28,4 @@ const NOT_FOUND_SEGMENT = "__k8ordo-not-found__";
|
|
|
28
28
|
* re-encodes a rewrite target finds the directory under the same spelling.
|
|
29
29
|
*/
|
|
30
30
|
const FALLBACK_SEGMENT = "!fallback";
|
|
31
|
-
//#endregion
|
|
32
31
|
export { FALLBACK_SEGMENT, NOT_FOUND_SEGMENT, decodePathname };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/payload-path.d.ts
|
|
2
1
|
export declare const payloadPathFor: (pathname: string) => string;
|
|
3
2
|
export declare const isPayloadPath: (pathname: string) => boolean;
|
|
4
|
-
export declare const pagePathFor: (payloadPath: string) => string;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare const pagePathFor: (payloadPath: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizePathname } from "@k8ordo/router";
|
|
2
|
-
|
|
2
|
+
// src/runtime/payload-path.ts
|
|
3
3
|
/**
|
|
4
4
|
* Where a page's RSC payload lives. It has to be a plain path, not a header
|
|
5
5
|
* or a query, because static hosting varies on neither — the same convention
|
|
@@ -17,5 +17,4 @@ const pagePathFor = (payloadPath) => {
|
|
|
17
17
|
const page = payloadPath.slice(0, -10);
|
|
18
18
|
return page === "" ? "/" : page;
|
|
19
19
|
};
|
|
20
|
-
//#endregion
|
|
21
20
|
export { isPayloadPath, pagePathFor, payloadPathFor };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/runtime/payload.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* What a page is, on the wire. Always an object rather than the tree itself,
|
|
5
4
|
* because a Server Action's answer travels back with the page it re-rendered
|
|
@@ -110,5 +109,4 @@ export declare const CLIENT_DEPS_HEADER = "x-k8ordo-client-deps";
|
|
|
110
109
|
*/
|
|
111
110
|
export declare const clientDepsHeader: (named: Iterable<ClientDeps>) => string;
|
|
112
111
|
/** What `clientDepsHeader` said. */
|
|
113
|
-
export declare const readClientDeps: (value: string) => ClientDeps[];
|
|
114
|
-
//#endregion
|
|
112
|
+
export declare const readClientDeps: (value: string) => ClientDeps[];
|
package/dist/runtime/payload.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/payload.ts
|
|
2
2
|
/** The header a client-invoked Server Action is addressed with. */
|
|
3
3
|
const ACTION_ID_HEADER = "x-k8ordo-action";
|
|
4
4
|
/**
|
|
@@ -52,5 +52,4 @@ const CLIENT_DEPS_HEADER = "x-k8ordo-client-deps";
|
|
|
52
52
|
const clientDepsHeader = (named) => encodeURIComponent(JSON.stringify([...named]));
|
|
53
53
|
/** What `clientDepsHeader` said. */
|
|
54
54
|
const readClientDeps = (value) => JSON.parse(decodeURIComponent(value));
|
|
55
|
-
//#endregion
|
|
56
55
|
export { ACTION_ID_HEADER, CLIENT_DEPS_HEADER, NONCE_HEADER, NOT_FOUND_DIGEST, NOT_FOUND_HEADER, SERVER_STYLESHEETS, SHELL_HEADER, STYLESHEET_ORDER_HREF, clientDepsHeader, readClientDeps };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/prefetch.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* How long a prefetched page stays usable, from the moment it was asked for.
|
|
4
3
|
* Long enough to cover a pointer resting on a link and then clicking it; short
|
|
@@ -40,5 +39,4 @@ export type PrefetchCache<T> = {
|
|
|
40
39
|
* did before anything was prefetched. A load forgotten before anyone took it
|
|
41
40
|
* is aborted, so a request nobody will read does not run on.
|
|
42
41
|
*/
|
|
43
|
-
export declare const createPrefetchCache: <T>(load: (key: string, signal: AbortSignal) => Promise<T>, now?: () => number) => PrefetchCache<T>;
|
|
44
|
-
//#endregion
|
|
42
|
+
export declare const createPrefetchCache: <T>(load: (key: string, signal: AbortSignal) => Promise<T>, now?: () => number) => PrefetchCache<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizePathname, withoutBase } from "@k8ordo/router";
|
|
2
|
-
|
|
2
|
+
// src/runtime/prefetch.ts
|
|
3
3
|
/**
|
|
4
4
|
* How long a prefetched page stays usable, from the moment it was asked for.
|
|
5
5
|
* Long enough to cover a pointer resting on a link and then clicking it; short
|
|
@@ -84,5 +84,4 @@ const createPrefetchCache = (load, now = () => performance.now()) => {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
|
-
//#endregion
|
|
88
87
|
export { PREFETCH_ATTRIBUTE, PREFETCH_LIFETIME, createPrefetchCache, prefetchTargetOf };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component, ReactNode } from "react";
|
|
2
|
-
//#region src/runtime/recover.d.ts
|
|
3
2
|
export declare const markNavigated: () => void;
|
|
4
3
|
/** Whether the tree on screen came from a client navigation, not the HTML. */
|
|
5
4
|
export declare const isNavigated: () => boolean;
|
|
@@ -32,5 +31,4 @@ export declare class Recover extends Component<{
|
|
|
32
31
|
};
|
|
33
32
|
componentDidCatch(error: unknown): void;
|
|
34
33
|
render(): ReactNode;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
34
|
+
}
|
package/dist/runtime/recover.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { reloadDocument } from "./reload.mjs";
|
|
3
3
|
import { Component } from "react";
|
|
4
|
-
|
|
4
|
+
// src/runtime/recover.tsx
|
|
5
5
|
/**
|
|
6
6
|
* Whether a client navigation has put a tree on screen yet. Until one has,
|
|
7
7
|
* the tree being rendered is the one the server sent as HTML. A fact about
|
|
@@ -45,5 +45,4 @@ var Recover = class extends Component {
|
|
|
45
45
|
return this.state.failed ? null : this.props.children;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
//#endregion
|
|
49
48
|
export { Recover, isNavigated, markNavigated, reloadInstead };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/redirect-file.d.ts
|
|
2
1
|
/** What a `redirect.ts` route file default-exports. */
|
|
3
2
|
export type RedirectTarget = string | {
|
|
4
3
|
readonly to: string;
|
|
@@ -18,5 +17,4 @@ type ResolvedRedirect = {
|
|
|
18
17
|
* the table normalizes it, so `/old/` is `/old` here too.
|
|
19
18
|
*/
|
|
20
19
|
export declare const resolveRedirects: (declared: Readonly<Record<string, RedirectTarget>>) => ((pattern: string, pathname: string) => ResolvedRedirect | null);
|
|
21
|
-
//#endregion
|
|
22
20
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizePathname } from "@k8ordo/router";
|
|
2
|
-
|
|
2
|
+
// src/runtime/redirect-file.ts
|
|
3
3
|
const resolveTarget = (target, segments) => {
|
|
4
4
|
const { to, permanent } = typeof target === "string" ? {
|
|
5
5
|
to: target,
|
|
@@ -39,5 +39,4 @@ const resolveRedirects = (declared) => {
|
|
|
39
39
|
return resolveTarget(declaredHere.target, segments);
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
//#endregion
|
|
43
42
|
export { resolveRedirects };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/redirect.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A redirect thrown from a Server Action. Branded with a registry symbol
|
|
4
3
|
* rather than a class: the framework bundles this module once into the
|
|
@@ -25,5 +24,4 @@ export declare class Redirect extends Error {
|
|
|
25
24
|
*/
|
|
26
25
|
export declare const redirect: (to: string) => never;
|
|
27
26
|
export declare const isRedirect: (value: unknown) => value is Redirect;
|
|
28
|
-
//#endregion
|
|
29
27
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/redirect.ts
|
|
2
2
|
/**
|
|
3
3
|
* A redirect thrown from a Server Action. Branded with a registry symbol
|
|
4
4
|
* rather than a class: the framework bundles this module once into the
|
|
@@ -31,5 +31,4 @@ const redirect = (to) => {
|
|
|
31
31
|
throw new Redirect(to);
|
|
32
32
|
};
|
|
33
33
|
const isRedirect = (value) => typeof value === "object" && value !== null && value[BRAND] === true;
|
|
34
|
-
//#endregion
|
|
35
34
|
export { Redirect, isRedirect, redirect };
|