Adds the prerendering requirements, design and baseline

Records the requirements, execution plan, application design, the first unit's
functional design and code generation plan, and the baseline on master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 17:41:12 +01:00
co-authored by Claude Opus 5.5
parent c4c2f83d6c
commit 65c850e949
22 changed files with 2569 additions and 0 deletions
@@ -0,0 +1,73 @@
# Component Methods: prerendering
Signatures are the intended interfaces. Detailed rules follow in Functional Design.
## `config/inlineScripts.ts`
```ts
type MovedScript = { fileName: string; body: string };
type ExternalizeResult = { html: string; moved: MovedScript[] };
// Replaces each executable inline script with a reference to a file named
// after its content hash; order and all other content stay as they are.
export function externalizeInlineScripts(html: string): ExternalizeResult;
// Executable inline scripts still present; data blocks such as JSON-LD excluded.
export function findExecutableInlineScripts(html: string): string[];
```
## `config/externalizeInlineScripts.ts`
```ts
// Rewrites all HTML under clientDir and writes moved scripts to clientDir/assets.
// Exits non-zero when a page has no moved scripts or a violation remains.
export function externalizeOutput(clientDir: string): void;
```
## `config/previewServer.ts`
```ts
// Maps a request path to a file following the nginx rules.
export function resolveRequest(
path: string,
fileExists: (file: string) => boolean,
): { file: string; status: 200 | 404 } | { redirect: string };
export function startPreviewServer(clientDir: string, port: number): Server;
```
## `src/router.tsx`
```ts
export function getRouter(): AnyRouter;
```
## `src/hooks/useHydrated.ts`
```ts
export default function useHydrated(): boolean;
```
## `src/components/Reveal`
```ts
// Props are unchanged, so the 21 call sites stay as they are.
type RevealProps = BoxProps & { delay?: number };
```
`useReveal<T>()` keeps returning `{ ref, visible }`. `visible` now starts as `true` and only becomes `false` when the element is below the viewport after hydration.
## `src/components/DeferredImage`
Props are unchanged. The rendered output gains a `<noscript>` image.
## `src/seo.ts`
```ts
// Adds the preload link for a page's first photo to its head.
export function preloadImage(src: string): HeadLink;
```
## Route `head()`
Pages pass their first photo to `pageHead`, so the existing `pageHead(path)` helper stays the single source for head tags. The exact shape is settled in unit 2.