# types/page.types.ts

> 121 lines of code and 22 definitions.

Tree: Bane's Lab Build Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/build-scripts#file-build-scripts-types-page-types-ts
Source text: https://banes-lab.com/source/build-scripts/types/page.types.ts.txt

Listed in [types](https://banes-lab.com/api/source/build-scripts/types.md), after [types/ontology.types.ts](https://banes-lab.com/source/build-scripts/types/ontology.types.ts.md) and before [types/payload.types.ts](https://banes-lab.com/source/build-scripts/types/payload.types.ts.md).

## Definitions

- `PageHead` (interface_declaration, line 13, exported)
- `PageDefinition` (interface_declaration, line 20, exported)
- `PageRegistry` (interface_declaration, line 27, exported)
- `PageRenderer` (interface_declaration, line 33, exported)
- `PageShell` (type_alias_declaration, line 44, exported)
- `SectionSelector` (interface_declaration, line 46, exported)
- `SectionPageSource` (interface_declaration, line 50, exported)
- `Links` (interface_declaration, line 56, exported)
- `RouteExporter` (type_alias_declaration, line 62, exported)
- `Loaded` (interface_declaration, line 64, exported)
- `SiteSource` (type_alias_declaration, line 81, exported)
- `PageSource` (type_alias_declaration, line 87, exported)
- `SourceBodyRenderer` (interface_declaration, line 92, exported)
- `RecordBodyRenderer` (interface_declaration, line 96, exported)
- `RecordRegistry` (interface_declaration, line 100, exported)
- `RecordPageSource` (interface_declaration, line 104, exported)
- `SourcePageSource` (interface_declaration, line 111, exported)
- `TextConverter` (interface_declaration, line 118, exported)
- `TranscriptRenderer` (interface_declaration, line 122, exported)
- `PageRoute` (interface_declaration, line 126, exported)
- `Prerendered` (interface_declaration, line 132, exported)
- `DevState` (interface_declaration, line 140, exported)

## Contained in

- [types](https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-types.md)

## Source

```typescript
import type { Discovery, Inline } from "#types/site.types";
import type {
    PageDates,
    RecordSubject,
    SectionSeed,
    SectionSubject,
    SourceBody,
    SourceSubject,
} from "@banes-lab/web/types/page.types.js";
import type { ModuleRunner } from "vite/module-runner";
import type { SectionExporter } from "#types/section.types";

export interface PageHead {
    readonly description: string;
    readonly path: string;
    readonly robots: string;
    readonly title: string;
}

export interface PageDefinition {
    readonly content: unknown;
    readonly description: string;
    readonly id: string;
    readonly title: string;
}

export interface PageRegistry {
    readonly loadCompletePage: (id: string) => Promise<PageDefinition | undefined>;
    readonly loadPage: (id: string) => Promise<PageDefinition | undefined>;
    readonly loadedPage: (id: string) => PageDefinition | undefined;
}

export interface PageRenderer {
    readonly applyHead: (root: Document, head: PageHead) => void;
    readonly headOf: (page: string, definition?: PageDefinition, pathname?: string, dates?: PageDates) => PageHead;
    readonly recordHead: (subject: RecordSubject) => PageHead;
    readonly renderSectionPage: (subject: SectionSubject) => Element;
    readonly renderStaticPage: (page: string) => readonly Element[];
    readonly renderStaticSection: (page: string, path: string, id: string) => Element | null;
    readonly sectionHead: (subject: SectionSubject) => PageHead;
    readonly sourceHead: (subject: SourceSubject) => PageHead;
}

export type PageShell = "renderSectionPage" | "renderStaticPage" | "renderStaticSection";

export interface SectionSelector {
    readonly sectionSeedsOf: (page: string, budget: number) => readonly SectionSeed[];
}

export interface SectionPageSource {
    readonly main: string;
    readonly renderer: Pick<PageRenderer, "applyHead" | "renderSectionPage" | "sectionHead">;
    readonly site: string;
}

export interface Links {
    readonly SITE_URL: string;
    readonly pagePath: (page: string) => string;
    readonly tabLink: (page: string, tab: string, section?: string) => string;
}

export type RouteExporter = (path: string, page: string, sections: readonly string[]) => string;

export interface Loaded {
    readonly author: string;
    readonly consent: string;
    readonly exportSections: SectionExporter;
    readonly exportText: RouteExporter;
    readonly ids: readonly string[];
    readonly inline: Inline;
    readonly links: Links;
    readonly main: string;
    readonly name: string;
    readonly registry: PageRegistry;
    readonly renderer: PageRenderer;
    readonly runner: ModuleRunner;
    readonly summary: string;
    readonly visit: (path: string) => void;
}

export type SiteSource = Pick<Loaded, "author" | "consent" | "exportText" | "ids" | "inline" | "name" | "summary"> & {
    readonly links: Pick<Links, "SITE_URL" | "tabLink">;
    readonly registry: Pick<PageRegistry, "loadedPage">;
    readonly renderer: Pick<PageRenderer, "headOf">;
};

export type PageSource = Pick<Loaded, "main" | "visit"> & {
    readonly registry: Pick<PageRegistry, "loadedPage">;
    readonly renderer: Pick<PageRenderer, "applyHead" | "headOf" | "renderStaticPage">;
};

export interface SourceBodyRenderer {
    readonly renderSourceBody: (body: SourceBody, text: string | null) => Element;
}

export interface RecordBodyRenderer {
    readonly renderRecordBody: (subject: RecordSubject) => Element;
}

export interface RecordRegistry {
    readonly registerRecords: (refs: readonly string[]) => void;
}

export interface RecordPageSource {
    readonly body: RecordBodyRenderer;
    readonly main: string;
    readonly renderer: Pick<PageRenderer, "applyHead" | "recordHead" | "renderStaticSection">;
    readonly site: string;
}

export interface SourcePageSource {
    readonly body: SourceBodyRenderer;
    readonly main: string;
    readonly renderer: Pick<PageRenderer, "applyHead" | "sourceHead">;
    readonly site: string;
}

export interface TextConverter {
    readonly exportText: (element: Element) => string;
}

export interface TranscriptRenderer {
    readonly renderTranscripts: (root: Element, recordings: readonly unknown[]) => void;
}

export interface PageRoute {
    readonly dates?: PageDates;
    readonly page: string;
    readonly path: string;
}

export interface Prerendered {
    readonly catalog: number;
    readonly records: number;
    readonly routes: number;
    readonly sections: number;
    readonly sources: number;
}

export interface DevState {
    readonly discovery: Discovery;
    readonly loaded: Loaded;
}
```
