@jokerized/decksmith 0.9.4 → 0.9.6
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/cli.js +20775 -10046
- package/dist/deck-runtime.js +2 -2
- package/dist/index.js +11549 -1433
- package/dist/mcp.js +10824 -1086
- package/dist/types/bespoke/pipeline.d.ts +1 -1
- package/dist/types/bespoke/scene.d.ts +18 -2
- package/dist/types/emit/archetypes/index.d.ts +15 -0
- package/dist/types/emit/composition.d.ts +16 -1
- package/dist/types/emit/kit.d.ts +33 -0
- package/dist/types/emit/svg.d.ts +19 -0
- package/dist/types/emit/tex.d.ts +13 -0
- package/dist/types/literal/check.d.ts +45 -0
- package/dist/types/literal/formula.d.ts +78 -0
- package/dist/types/literal/index.d.ts +133 -0
- package/dist/types/literal/kind.d.ts +121 -0
- package/dist/types/literal/kinds/common.d.ts +280 -0
- package/dist/types/literal/kinds/evolve.d.ts +58 -0
- package/dist/types/literal/kinds/flow.d.ts +13 -0
- package/dist/types/literal/kinds/operate.d.ts +27 -0
- package/dist/types/literal/kinds/place-combos.d.ts +33 -0
- package/dist/types/literal/kinds/place-lengths.d.ts +36 -0
- package/dist/types/literal/kinds/place-margins.d.ts +44 -0
- package/dist/types/literal/kinds/place-sets.d.ts +31 -0
- package/dist/types/literal/kinds/place.d.ts +69 -0
- package/dist/types/literal/kinds/prior-work.d.ts +29 -0
- package/dist/types/literal/kinds/read.d.ts +33 -0
- package/dist/types/literal/kinds/recap.d.ts +16 -0
- package/dist/types/literal/kinds/region.d.ts +56 -0
- package/dist/types/literal/kinds/stage.d.ts +108 -0
- package/dist/types/literal/kinds/svg.d.ts +65 -0
- package/dist/types/literal/kinds/table.d.ts +19 -0
- package/dist/types/literal/kinds/tex.d.ts +6 -0
- package/dist/types/literal/kinds-shared.d.ts +15 -0
- package/dist/types/literal/kit.d.ts +86 -0
- package/dist/types/literal/ops.d.ts +56 -0
- package/dist/types/literal/registry.d.ts +20 -0
- package/dist/types/plan/codex.d.ts +28 -5
- package/dist/types/plan/coverage.d.ts +179 -0
- package/dist/types/plan/duration.d.ts +2 -0
- package/dist/types/plan/locate.d.ts +46 -0
- package/dist/types/plan/prompt.d.ts +14 -1
- package/dist/types/plan/variety.d.ts +23 -0
- package/dist/types/render/timing.d.ts +7 -1
- package/dist/types/source/harvest.d.ts +1 -0
- package/dist/types/types.d.ts +21451 -933
- package/dist/types/verify/fidelity.d.ts +7 -2
- package/dist/types/verify/fill.d.ts +70 -9
- package/dist/types/verify/overprint.d.ts +46 -0
- package/dist/types/verify/scenes.d.ts +61 -2
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* recap — the earlier scenes' own computed layers, in order: every one as a tile,
|
|
3
|
+
* the one being spoken also large, then the result the source reports.
|
|
4
|
+
*/
|
|
5
|
+
import type { Literal } from "../../types.js";
|
|
6
|
+
import { type KindImpl } from "../kind.js";
|
|
7
|
+
/**
|
|
8
|
+
* Whether a scene leaves a picture a recap can bring back (`files.thumb`): an
|
|
9
|
+
* operate on a picture, an evolve that streams tiles or noises a picture, a
|
|
10
|
+
* region, a flow whose stage shows an earlier layer, a prior-work with a
|
|
11
|
+
* `from` lane. A word form, a table and a scene on vectors leave none. The
|
|
12
|
+
* plan check holds a recap to this (src/plan/coverage.ts), so a plan the build
|
|
13
|
+
* would refuse goes back to the planner.
|
|
14
|
+
*/
|
|
15
|
+
export declare function leavesPicture(lit: Literal): boolean;
|
|
16
|
+
export declare const recapKind: KindImpl;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* region — the things in a picture the source says matter, picked out (the
|
|
3
|
+
* approved look, .planning/designs/2026-10-12-verb-looks/5-region.png): the
|
|
4
|
+
* picture large on the left, a numbered box on each thing with its number
|
|
5
|
+
* outside the box, the numbered list of what each means on the right, then the
|
|
6
|
+
* `outcome` the source draws from them, under a rule. The picture's legend
|
|
7
|
+
* sits under it. Each thing is revealed with its line; the outcome last.
|
|
8
|
+
*
|
|
9
|
+
* The boxes are never the planner's guess: `plan` finds each `thing` in the
|
|
10
|
+
* panel the scene shows (src/plan/locate.ts) and writes its box, as fractions of
|
|
11
|
+
* that panel, into the storyboard. The panel is cut as `findPanels` cuts it, at
|
|
12
|
+
* plan and at build alike. The picture is zoomed onto its marks only as far as
|
|
13
|
+
* its own pixels allow (`MAX_UPSCALE`) and never past `CONTEXT` of the panel:
|
|
14
|
+
* a stop sign alone says nothing.
|
|
15
|
+
*/
|
|
16
|
+
import type { KindImpl } from "../kind.js";
|
|
17
|
+
import { type Rgb } from "../kit.js";
|
|
18
|
+
import type { MechanismResult } from "./common.js";
|
|
19
|
+
import { type VerbCtx } from "./stage.js";
|
|
20
|
+
type Ctx = VerbCtx<"region">;
|
|
21
|
+
/** The longest side a figure is read at: its own pixels, up to this. */
|
|
22
|
+
export declare const FIGURE_SIDE = 3200;
|
|
23
|
+
/** A figure at its own pixels (at most `FIGURE_SIDE` a side). */
|
|
24
|
+
export declare function readFigure(image: string): Promise<Rgb>;
|
|
25
|
+
/** How many panels the build will cut a figure file into (`findPanels`). */
|
|
26
|
+
export declare function figurePanels(image: string): Promise<number>;
|
|
27
|
+
/** The picture a marked scene shows: the figure's `panel` (1-based), or all of it. */
|
|
28
|
+
export declare function panelOf(fig: Rgb, panel: number | undefined): Rgb;
|
|
29
|
+
/** The most a figure is magnified over its own pixels: past it a crop shows its blur. */
|
|
30
|
+
export declare const MAX_UPSCALE = 2;
|
|
31
|
+
export declare function region(c: Ctx): MechanismResult;
|
|
32
|
+
/** A box in figure pixels. */
|
|
33
|
+
export interface PanelBox {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
w: number;
|
|
37
|
+
h: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A figure's panels, from its pixels: recursive XY-cut along blank gutters.
|
|
41
|
+
*
|
|
42
|
+
* The ground is the colour of the figure's border; a pixel is ink when it
|
|
43
|
+
* differs from it by more than 0.1 on any channel. A box is trimmed to its ink,
|
|
44
|
+
* then split at the middle of its widest blank run of rows or columns, if that
|
|
45
|
+
* run is at least 1.5% of the figure's side and leaves two parts big enough to
|
|
46
|
+
* be panels (each side 12% of the figure's shorter side, each 3% of its area);
|
|
47
|
+
* failing that, at a gutter that splits off a part too small to be a panel —
|
|
48
|
+
* before panels side by side, or a filled title band off one — which is
|
|
49
|
+
* dropped. What cannot be split is a panel. Read in rows (top to bottom, a row
|
|
50
|
+
* being panels whose tops are within 10% of the figure's height), left to right in
|
|
51
|
+
* each. Deterministic: the same figure gives the same panels.
|
|
52
|
+
*/
|
|
53
|
+
export declare function findPanels(img: Rgb): PanelBox[];
|
|
54
|
+
/** region as the build's kind: it reads its figure at the figure's own pixels. */
|
|
55
|
+
export declare const regionKind: KindImpl;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Fragment } from "../../bespoke/contract.js";
|
|
2
|
+
import type { Theme } from "../../emit/kit.js";
|
|
3
|
+
import type { Literal, LiteralKind } from "../../types.js";
|
|
4
|
+
import { type KindImpl, type KindSpec } from "../kind.js";
|
|
5
|
+
import { type Cue, type Layers } from "../kit.js";
|
|
6
|
+
import type { Tensor } from "../ops.js";
|
|
7
|
+
import { type Frame, type Measure, type MechanismResult, type Prim, type Raster, type Region, type Rgb } from "./common.js";
|
|
8
|
+
/** What an earlier scene left that a later one may reuse: its layers and its computed arrays. */
|
|
9
|
+
export interface Earlier {
|
|
10
|
+
kind: string;
|
|
11
|
+
layers: Layers;
|
|
12
|
+
labels: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/** What a verb's run is given. */
|
|
15
|
+
export interface VerbCtx<K extends LiteralKind> {
|
|
16
|
+
lit: Extract<Literal, {
|
|
17
|
+
kind: K;
|
|
18
|
+
}>;
|
|
19
|
+
labels: Readonly<Record<string, string>>;
|
|
20
|
+
region: Region;
|
|
21
|
+
theme: Theme;
|
|
22
|
+
measure: Measure;
|
|
23
|
+
/** Plan time: the material is a placeholder; check and lay out, as the build will. */
|
|
24
|
+
dry: boolean;
|
|
25
|
+
/** The picture, when the verb reads one (a placeholder at plan time). */
|
|
26
|
+
image?: Rgb;
|
|
27
|
+
earlier: ReadonlyMap<string, Earlier>;
|
|
28
|
+
/** Figure id → absolute file, for a stage showing the source's own figure. */
|
|
29
|
+
assets: Readonly<Record<string, string>>;
|
|
30
|
+
/** The beat's headline: an item it names is the scene's subject (src/literal/kind.ts `subjectOf`). */
|
|
31
|
+
headline?: string;
|
|
32
|
+
}
|
|
33
|
+
export type VerbRun<K extends LiteralKind> = (c: VerbCtx<K>) => MechanismResult;
|
|
34
|
+
/**
|
|
35
|
+
* A verb laid out inside the room its camera push takes, for a diagram whose
|
|
36
|
+
* words reach the region's edges (a plot, a chain of cards). The push scales
|
|
37
|
+
* the camera's material about its middle by `PUSH`, so it grows (PUSH-1)/2 of
|
|
38
|
+
* a side each way: laid out that much in, and with the clip grown by the same
|
|
39
|
+
* (`Frame.pad`), nothing is cut while it leans in. Measured on r1: a plot's
|
|
40
|
+
* "0.8" printed as ").8" and the outer cards of a chain lost their first and
|
|
41
|
+
* last glyphs, while the push ran.
|
|
42
|
+
*/
|
|
43
|
+
export declare function withPushRoom<K extends LiteralKind>(run: VerbRun<K>): VerbRun<K>;
|
|
44
|
+
/** Text lines as primitives, top-down from y. */
|
|
45
|
+
export declare function textLines(lines: readonly string[], x: number, y: number, size: number, role: Extract<Prim, {
|
|
46
|
+
p: "text";
|
|
47
|
+
}>["role"], extra?: Partial<Extract<Prim, {
|
|
48
|
+
p: "text";
|
|
49
|
+
}>>, anchor?: "start" | "middle" | "end"): Prim[];
|
|
50
|
+
/** The band under the scene for its example tag and caption: its height, 0 when neither is given. */
|
|
51
|
+
export declare function bandHeight(labels: Readonly<Record<string, string>>, region: Region, measure: Measure): number;
|
|
52
|
+
/** Run a verb with its band reserved; the band is added to every frame. */
|
|
53
|
+
export declare function runVerb<K extends LiteralKind>(run: VerbRun<K>, c: VerbCtx<K>): MechanismResult;
|
|
54
|
+
/** A synthetic picture for plan-time checks: deterministic, with edges and texture. */
|
|
55
|
+
export declare function placeholderPicture(w?: number, h?: number): Rgb;
|
|
56
|
+
/** The picture at its own aspect, at most `maxSide` on its longer side. */
|
|
57
|
+
export declare function readPicture(image: string, maxSide: number): Promise<Rgb>;
|
|
58
|
+
/** The display scale of one-channel arrays drawn side by side: one scale, so a weaker map looks weaker. */
|
|
59
|
+
export declare function sharedScale(ts: readonly Tensor[]): number;
|
|
60
|
+
/** An array as a raster to draw: RGB as itself, one channel on the theme's accent (signed: grey around mid). */
|
|
61
|
+
export declare function rasterOf(t: Tensor, scaleTo?: number): Raster;
|
|
62
|
+
/** Write a result's rasters under `dir`; the layers carry the frames and how each raster is painted. */
|
|
63
|
+
export declare function writeLayers(r: MechanismResult, beatId: string, dir: string): Promise<Layers>;
|
|
64
|
+
/** Copy the source's own figures a result references (`fig:<id>`) beside the layers. */
|
|
65
|
+
export declare function copyFigures(r: MechanismResult, assets: Readonly<Record<string, string>>, beatId: string, dir: string, files: Record<string, string>): Promise<void>;
|
|
66
|
+
/** The axis-aligned box a primitive covers. */
|
|
67
|
+
export declare function boxOf(p: Prim): {
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
w: number;
|
|
71
|
+
h: number;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Where the camera tours a finished frame: the centre of each step's camera
|
|
75
|
+
* material (its `cam` primitives revealed on that step), the last step first.
|
|
76
|
+
*/
|
|
77
|
+
export declare function tourOf(frame: Frame, steps: number): Array<{
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
}>;
|
|
81
|
+
/** The opacity a `preview` frame's parts stand at until they are spoken. */
|
|
82
|
+
export declare const PREVIEW = 0.3;
|
|
83
|
+
/** The most a sentence's camera push waits for its reveals, seconds after the sentence starts. */
|
|
84
|
+
export declare const PUSH_LEAD = 1.2;
|
|
85
|
+
/** Seconds before a scene's end its camera is back at rest (start of the return). */
|
|
86
|
+
export declare const FINAL_REST = 2.2;
|
|
87
|
+
/** How far the camera pushes in on a frame's material once its reveals are out. */
|
|
88
|
+
export declare const PUSH = 1.07;
|
|
89
|
+
/** The fragment of staged frames on the narration's sentences. */
|
|
90
|
+
export declare function stagedFragment(kind: LiteralKind, L: Layers, region: Region, cues: readonly Cue[], spec: KindSpec, theme: Theme, href: (file: string) => string): Fragment;
|
|
91
|
+
/**
|
|
92
|
+
* The share of the region a frame's material covers: its pictures, filled
|
|
93
|
+
* shapes and plotted lines, on an 8px grid. Text and outlines do not count. Pure,
|
|
94
|
+
* read off the primitives that ship.
|
|
95
|
+
*/
|
|
96
|
+
export declare function frameFill(frame: Frame, region: Region): number;
|
|
97
|
+
/** How large a verb reads its picture. */
|
|
98
|
+
export interface VerbOpts {
|
|
99
|
+
/** Longest side the picture is read at; 0: the verb reads no picture. */
|
|
100
|
+
pictureSide: number;
|
|
101
|
+
/** The beat whose picture the verb reads (absent: none). */
|
|
102
|
+
pictureOf?: (lit: Literal) => string | undefined;
|
|
103
|
+
}
|
|
104
|
+
/** A verb drawn on the stage, as the build's `KindImpl`. */
|
|
105
|
+
export declare function verbKind<K extends LiteralKind>(kind: K, run: VerbRun<K>, opts: VerbOpts): KindImpl;
|
|
106
|
+
/** Why a verb cannot be drawn, at plan time: its run on placeholder material. Empty when it can. */
|
|
107
|
+
export declare function verbProblems<K extends LiteralKind>(kind: K, run: VerbRun<K>, lit: Literal, region: Region, theme: Theme): string[];
|
|
108
|
+
export type { Frame, MechanismResult, Prim, Raster, Region };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One frame of a mechanism kind as SVG: what the framework draws, and what the
|
|
3
|
+
* preview strips and the judge frames are rasterised from. Pure: rasters are
|
|
4
|
+
* referenced by `href(layer)`, slot texts come from `text(slot, vars)`, and
|
|
5
|
+
* every colour is a style-pack token (fg, muted, dim, rule, panel, accent,
|
|
6
|
+
* tones): a heat layer is a white alpha mask the theme colours here, so one
|
|
7
|
+
* computed file serves a dark pack and a light one. The ground (`bg`) is the
|
|
8
|
+
* shell's: it is painted only in a preview (`ground: true`), and read only to
|
|
9
|
+
* judge contrast against.
|
|
10
|
+
*
|
|
11
|
+
* Also the contrast arithmetic (WCAG 2 relative luminance) the tests hold the
|
|
12
|
+
* frames to, and the backdrop lookup a text with role "auto" is resolved by.
|
|
13
|
+
*/
|
|
14
|
+
import type { Theme } from "../../emit/kit.js";
|
|
15
|
+
import type { DataRgb, Prim, Role } from "./common.js";
|
|
16
|
+
/** An sRGB colour, 0..255 per channel. */
|
|
17
|
+
export type Rgb8 = [number, number, number];
|
|
18
|
+
export declare function hex(c: string): Rgb8;
|
|
19
|
+
export declare function roleRgb(theme: Theme, role: Role): Rgb8;
|
|
20
|
+
/** The heat ramp: the panel colour at 0, the accent at 1. */
|
|
21
|
+
export declare function heatRgb(theme: Theme, t: number): Rgb8;
|
|
22
|
+
/** Tone weights (a, b, c, d) mixed over the panel: hue from their proportions, strength from their sum. */
|
|
23
|
+
export declare function mixRgb(theme: Theme, w: readonly number[]): Rgb8;
|
|
24
|
+
/** A filled shape's fill, or undefined when it has none. */
|
|
25
|
+
export declare function fillRgb(theme: Theme, p: {
|
|
26
|
+
fill?: Role;
|
|
27
|
+
heat?: number;
|
|
28
|
+
mix?: number[];
|
|
29
|
+
rgb?: DataRgb;
|
|
30
|
+
}): Rgb8 | undefined;
|
|
31
|
+
/** WCAG 2 contrast ratio, 1..21. */
|
|
32
|
+
export declare function contrastRatio(a: Rgb8, b: Rgb8): number;
|
|
33
|
+
/** Where a primitive sits, for finding what is under it. */
|
|
34
|
+
export declare function anchorOf(p: Prim): [number, number];
|
|
35
|
+
/**
|
|
36
|
+
* The colour under prims[index] at its anchor: the last opaque filled rect or
|
|
37
|
+
* circle drawn before it that contains the point, else the ground. Undefined
|
|
38
|
+
* when a picture is under it (its colour is the data's, not the theme's).
|
|
39
|
+
* `containersOnly`: look through marks (another series' head, a start dot) to
|
|
40
|
+
* the panel or ground they sit on — how a mark is judged.
|
|
41
|
+
*/
|
|
42
|
+
export declare function backdropOf(prims: readonly Prim[], index: number, theme: Theme, containersOnly?: boolean): Rgb8 | undefined;
|
|
43
|
+
/** A text's colour: its role's, or for "auto" the ink or the panel colour, whichever reads better on its backdrop. */
|
|
44
|
+
export declare function textRgb(prims: readonly Prim[], index: number, theme: Theme): Rgb8;
|
|
45
|
+
/**
|
|
46
|
+
* An "auto" text's halo: when neither ink nor panel reaches 4.5:1 on a
|
|
47
|
+
* mid-tone fill (a bright accent at half strength), the text gets a 6px
|
|
48
|
+
* outline in the other colour, and that outline is what it is read against.
|
|
49
|
+
*/
|
|
50
|
+
export declare function textHalo(prims: readonly Prim[], index: number, theme: Theme): Rgb8 | undefined;
|
|
51
|
+
/** How a raster layer is drawn: a picture as itself, a heat mask in a theme colour at an opacity. */
|
|
52
|
+
export type LayerPaint = {
|
|
53
|
+
mask: Role;
|
|
54
|
+
alpha: number;
|
|
55
|
+
} | undefined;
|
|
56
|
+
export interface Draw {
|
|
57
|
+
theme: Theme;
|
|
58
|
+
href: (layer: string) => string;
|
|
59
|
+
text: (slot: string, vars: Readonly<Record<string, string | number>>) => string;
|
|
60
|
+
paint: (layer: string) => LayerPaint;
|
|
61
|
+
/** Prefix of every id this frame defines (masks), so two frames in one page never collide. */
|
|
62
|
+
ids: string;
|
|
63
|
+
}
|
|
64
|
+
/** One primitive as SVG; `prims` and `index` place it among what is drawn under it. */
|
|
65
|
+
export declare function primSvg(prims: readonly Prim[], index: number, d: Draw): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* table — numbers and claims the source reports, cited, rows lit in spoken
|
|
3
|
+
* order, winning or missing cells marked. A row the headline names (by its
|
|
4
|
+
* first cell) is the subject: lit, with its name in the accent, from the first
|
|
5
|
+
* frame to the last — r3 dimmed the method's own row at both holds.
|
|
6
|
+
*/
|
|
7
|
+
import { type KindImpl } from "../kind.js";
|
|
8
|
+
/**
|
|
9
|
+
* Which rows light on which step: spoken order, spread over the cues when there
|
|
10
|
+
* are more rows than cues — the LATER steps take the extra rows, since a
|
|
11
|
+
* narration names its point first and then elaborates.
|
|
12
|
+
*/
|
|
13
|
+
export declare function rowSteps(highlight: readonly number[], cues: number): number[][];
|
|
14
|
+
/**
|
|
15
|
+
* Column widths that fit `W`: water-filling from the narrowest column, so a
|
|
16
|
+
* short column keeps its natural width and only the widest ones wrap.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fitColumns(natural: readonly number[], W: number): number[];
|
|
19
|
+
export declare const tableKind: KindImpl;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Helpers more than one kind shares: a picture's own size, tile ratios. */
|
|
2
|
+
export declare function nativeSize(image: string): Promise<{
|
|
3
|
+
w: number;
|
|
4
|
+
h: number;
|
|
5
|
+
}>;
|
|
6
|
+
/** How many copies of the smallest value tile the largest (0: too close to be worth it). */
|
|
7
|
+
export declare const tiles: (vals: readonly number[]) => number;
|
|
8
|
+
/**
|
|
9
|
+
* The ratio line a tiled group prints ("35 ÷ 20 = 1.75"), or undefined when the
|
|
10
|
+
* group does not tile. One function, so the truth gate checks the very number
|
|
11
|
+
* the scene draws (src/plan/coverage.ts `literalTexts`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function tileRatio(items: ReadonlyArray<{
|
|
14
|
+
value: string;
|
|
15
|
+
}>): string | undefined;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Theme } from "../emit/kit.js";
|
|
2
|
+
import { type LITERAL_KIND_NAMES } from "../types.js";
|
|
3
|
+
type LiteralKindName = (typeof LITERAL_KIND_NAMES)[number];
|
|
4
|
+
/** An RGB picture, 0..1 per channel, row-major. */
|
|
5
|
+
export interface Rgb {
|
|
6
|
+
w: number;
|
|
7
|
+
h: number;
|
|
8
|
+
d: Float32Array;
|
|
9
|
+
}
|
|
10
|
+
/** Decode any picture ffmpeg reads, resampled (area) to w×h. */
|
|
11
|
+
export declare function readRgb(file: string, w: number, h: number): Promise<Rgb>;
|
|
12
|
+
/** Write RGBA bytes as a PNG (lossless) or a JPEG (`.jpg`, photographs only). */
|
|
13
|
+
export declare function writeRaster(out: string, w: number, h: number, rgba: Uint8Array): Promise<void>;
|
|
14
|
+
export declare function toRgba(img: Rgb): Uint8Array;
|
|
15
|
+
/** A grey map (0..1) as RGBA: `color` at `alpha` = value, or grey levels when no colour. */
|
|
16
|
+
export declare function mapRgba(v: Float32Array, color?: [number, number, number]): Uint8Array;
|
|
17
|
+
export declare function clamp255(x: number): number;
|
|
18
|
+
export interface Layers {
|
|
19
|
+
/** File names under `LITERAL_DIR`. */
|
|
20
|
+
files: Record<string, string>;
|
|
21
|
+
/** Numbers the fragment draws (profiles, grids, traces). */
|
|
22
|
+
data: Record<string, unknown>;
|
|
23
|
+
/** The arrays a verb computed, in memory, for a later verb to stream (`evolve` from). */
|
|
24
|
+
material?: Material;
|
|
25
|
+
}
|
|
26
|
+
/** What a verb computed that a later one may take as input. */
|
|
27
|
+
export interface Material {
|
|
28
|
+
/** The last output. */
|
|
29
|
+
final?: import("./ops.js").Tensor;
|
|
30
|
+
/** Pieces of it (crops, tiles), in order. */
|
|
31
|
+
tiles?: import("./ops.js").Tensor[];
|
|
32
|
+
}
|
|
33
|
+
export declare const r3: (n: number) => number;
|
|
34
|
+
export declare const round3: (n: number) => number;
|
|
35
|
+
export declare const px: (n: number) => string;
|
|
36
|
+
/** Escape a label for markup. */
|
|
37
|
+
export declare const esc: (s: string) => string;
|
|
38
|
+
/** The scene's tween lines, every one `fromTo` (invariant 2), every selector `#SCENEID-…` (invariant 3). */
|
|
39
|
+
export declare class Tl {
|
|
40
|
+
lines: string[];
|
|
41
|
+
private seen;
|
|
42
|
+
/**
|
|
43
|
+
* An element's FIRST tween renders its "from" state at once (GSAP's default),
|
|
44
|
+
* so whatever enters later is hidden from the scene's first frame; every
|
|
45
|
+
* later tween of it waits for its own start (`immediateRender: false`), so it
|
|
46
|
+
* cannot overwrite the earlier one's state when the timeline is built.
|
|
47
|
+
*/
|
|
48
|
+
fromTo(id: string, from: Record<string, unknown>, to: Record<string, unknown>, at: number): void;
|
|
49
|
+
/** Fade in (opacity 0→1) at `at`. */
|
|
50
|
+
show(id: string, at: number, dur?: number, extra?: {
|
|
51
|
+
from?: Record<string, unknown>;
|
|
52
|
+
to?: Record<string, unknown>;
|
|
53
|
+
}): void;
|
|
54
|
+
hide(id: string, at: number, dur?: number): void;
|
|
55
|
+
get script(): string;
|
|
56
|
+
}
|
|
57
|
+
export interface Cue {
|
|
58
|
+
t0: number;
|
|
59
|
+
t1: number;
|
|
60
|
+
/** This sentence opens a narration stop: a hold sits at its start (src/bespoke/scene.ts `bespokeHolds`). */
|
|
61
|
+
stop?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The stretches of [from, to] in which no tween of a scene's script runs —
|
|
65
|
+
* what a viewer sees as the picture standing still. Read off the emitted
|
|
66
|
+
* script (`tl.fromTo(..., {...duration...}, at)`), so it measures what ships.
|
|
67
|
+
* A tween with no duration runs GSAP's default 0.5s. Pure; the tests hold
|
|
68
|
+
* every kind to a ceiling with it (r1 of an early literal deck had 13 stretches
|
|
69
|
+
* of 6–9s where nothing moved).
|
|
70
|
+
*/
|
|
71
|
+
export declare function stillSpans(script: string, from: number, to: number): Array<[number, number]>;
|
|
72
|
+
/**
|
|
73
|
+
* A scene's words by slot (src/types.ts `LITERAL_KIND_DOCS`). Throws on a slot the
|
|
74
|
+
* kind does not declare — a fragment reading an undocumented slot is a bug,
|
|
75
|
+
* since the planner was never told to fill it — and on a required one the
|
|
76
|
+
* plan left out: no kind has a default, in any language or for any paper.
|
|
77
|
+
* `{name}` in the text is replaced by the computed `vars[name]`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function slotText(kind: LiteralKindName, labels: Readonly<Record<string, string>>, slot: string, vars?: Readonly<Record<string, string | number>>): string;
|
|
80
|
+
export declare const LABEL: 44;
|
|
81
|
+
export declare const SMALL: 40;
|
|
82
|
+
/** A label as positioned HTML. Never below 40px (invariant 5). */
|
|
83
|
+
export declare function label(id: string, text: string, x: number, y: number, size: number, color: string, extra?: string): string;
|
|
84
|
+
export declare const ON_PHOTO = "color:#fff;text-shadow:0 2px 10px rgba(0,0,0,.75),0 0 2px rgba(0,0,0,.9);font-weight:600";
|
|
85
|
+
export declare function baseCss(theme: Theme): string;
|
|
86
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE OP LIBRARY the `operate` and `evolve` verbs compose: a small set of
|
|
3
|
+
* general operations on arrays, pure and deterministic. What each op is, its
|
|
4
|
+
* variants and the words that ground them are one table, `LITERAL_OPS` in
|
|
5
|
+
* src/types.ts, read by the planner's prompt and the truth gate; this file is
|
|
6
|
+
* only the arithmetic, so the three cannot drift.
|
|
7
|
+
*
|
|
8
|
+
* An array is a `Tensor`: h rows × w columns × c channels, row-major with the
|
|
9
|
+
* channels interleaved. A picture is c = 3, a map c = 1, a vector h = 1, a
|
|
10
|
+
* matrix c = 1. Every op takes the list of earlier outputs (the input first)
|
|
11
|
+
* and returns one new array; none of them knows what a paper is. Kernels are
|
|
12
|
+
* applied as correlation (as image libraries do), edges replicated.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here is learned and nothing has a default a paper would have to
|
|
15
|
+
* state: every parameter comes from the plan, grounded by the gate.
|
|
16
|
+
*/
|
|
17
|
+
import type { LiteralOpName } from "../types.js";
|
|
18
|
+
export interface Tensor {
|
|
19
|
+
h: number;
|
|
20
|
+
w: number;
|
|
21
|
+
c: number;
|
|
22
|
+
d: Float32Array;
|
|
23
|
+
}
|
|
24
|
+
export declare const tensor: (h: number, w: number, c: number, d?: ArrayLike<number>) => Tensor;
|
|
25
|
+
/** A matrix (rows of equal length) as a tensor. */
|
|
26
|
+
export declare function fromRows(rows: readonly (readonly number[])[]): Tensor;
|
|
27
|
+
export declare const fromVector: (v: readonly number[]) => Tensor;
|
|
28
|
+
/** One step of a chain, its parameters already read as numbers. */
|
|
29
|
+
export interface OpStep {
|
|
30
|
+
op: LiteralOpName;
|
|
31
|
+
how?: string;
|
|
32
|
+
stat?: "mean" | "var" | "std";
|
|
33
|
+
over?: "all" | "channel" | "row";
|
|
34
|
+
params: Readonly<Record<string, number>>;
|
|
35
|
+
weights?: readonly (readonly number[])[];
|
|
36
|
+
/** Indexes into the list of outputs (0 = the input). */
|
|
37
|
+
of?: readonly number[];
|
|
38
|
+
expr?: string;
|
|
39
|
+
}
|
|
40
|
+
/** The kernels a NAME fixes: their numbers are the name (definitional). */
|
|
41
|
+
export declare const NAMED_KERNELS: Readonly<Record<string, readonly (readonly number[])[]>>;
|
|
42
|
+
export declare function statOf(v: ArrayLike<number>, stat: "mean" | "var" | "std" | "min" | "max" | "sum"): number;
|
|
43
|
+
/** The kernel a conv step applies. */
|
|
44
|
+
export declare function kernelOf(step: OpStep, oneD: boolean): number[][];
|
|
45
|
+
/** θ per group: the stated one, or scale × the group's statistic. */
|
|
46
|
+
export declare function thresholds(t: Tensor, step: OpStep): number[];
|
|
47
|
+
/** One op on the list of outputs so far (the input first); returns its output. */
|
|
48
|
+
export declare function runOp(step: OpStep, list: readonly Tensor[]): Tensor;
|
|
49
|
+
/** Every output of a chain, after the inputs: `[...inputs, out1, …, outN]`. */
|
|
50
|
+
export declare function runChain(inputs: readonly Tensor[], chain: readonly OpStep[]): Tensor[];
|
|
51
|
+
/** Deterministic standard normals (mulberry32 + Box–Muller). */
|
|
52
|
+
export declare function seededNormals(seed: number): () => number;
|
|
53
|
+
/** An EXAMPLE degradation of an input: never the paper's, always tagged as an example. */
|
|
54
|
+
export declare function degrade(t: Tensor, how: "contrast" | "noise" | "blur", amount: number): Tensor;
|
|
55
|
+
/** ᾱ_t for t = 1..T: linear β (Ho et al.) or the cosine ᾱ (Nichol & Dhariwal). */
|
|
56
|
+
export declare function alphaBars(schedule: "linear" | "cosine", T: number, betaStart?: number, betaEnd?: number): Float64Array;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EVERY KIND THE BUILD DRAWS, by name: one entry per name in src/types.ts
|
|
3
|
+
* `LITERAL_KIND_NAMES`, a `Record` so a name added there does not compile
|
|
4
|
+
* until it is drawn here, and nothing is registered at run time.
|
|
5
|
+
*
|
|
6
|
+
* - THE VERBS compose general operations on the source's own numbers:
|
|
7
|
+
* operate (an op chain on a picture, vectors or a matrix), evolve (a state
|
|
8
|
+
* under a stated rule), flow (stages), place (items on
|
|
9
|
+
* axes, and the word forms: margins, lengths, combos, sets) and region
|
|
10
|
+
* (the things in a picture, marked). Most are drawn on the stage
|
|
11
|
+
* (./kinds/stage.ts).
|
|
12
|
+
* - THE CROSS-CUTTING KINDS: recap (earlier scenes' own layers), prior-work
|
|
13
|
+
* (families by what an earlier scene computed or by their numbers) and
|
|
14
|
+
* table (the last resort).
|
|
15
|
+
*/
|
|
16
|
+
import type { LiteralKind } from "../types.js";
|
|
17
|
+
import type { KindImpl } from "./kind.js";
|
|
18
|
+
/** How large a verb reads its picture, for display (region reads its figure at its own pixels). */
|
|
19
|
+
export declare const PICTURE_SIDE = 768;
|
|
20
|
+
export declare const KINDS: Readonly<Record<LiteralKind, KindImpl>>;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { type Prefs } from "../prefs.js";
|
|
2
2
|
import { type Source, type Storyboard } from "../types.js";
|
|
3
|
-
/** The schema for one run. `role` is present only when the paper arc was asked for. */
|
|
4
|
-
export declare function schemaFor(prefs: Pick<Prefs, "genre" | "bespoke" | "design">): unknown;
|
|
5
3
|
/**
|
|
6
|
-
* The
|
|
7
|
-
* `
|
|
4
|
+
* The schema for one run. `role` is present only when the paper arc was asked
|
|
5
|
+
* for; `part` only when `source` has parts to cover.
|
|
6
|
+
*/
|
|
7
|
+
export declare function schemaFor(prefs: Pick<Prefs, "genre" | "bespoke" | "design"> & {
|
|
8
|
+
images?: Prefs["images"];
|
|
9
|
+
}, source?: Source): unknown;
|
|
10
|
+
/**
|
|
11
|
+
* The default-preferences schema, still exported: `general` hides `role`, and
|
|
12
|
+
* images default off, so it hides the picture briefs too (0.9.5).
|
|
8
13
|
*/
|
|
9
14
|
export declare const SCHEMA: unknown;
|
|
10
15
|
export interface CodexOptions {
|
|
@@ -18,8 +23,16 @@ export interface CodexOptions {
|
|
|
18
23
|
prefs?: Prefs;
|
|
19
24
|
/** Swappable so a test can drive the real parse path without spawning anything. */
|
|
20
25
|
run?: Runner;
|
|
21
|
-
/** Told what
|
|
26
|
+
/** Told what a plan broke, before each repair round (at most `REPAIRS`) is asked for. */
|
|
22
27
|
onRepair?: (broken: readonly string[]) => void;
|
|
28
|
+
/** Told each deck answer's beat count and the beats that carry a literal scene. */
|
|
29
|
+
onAnswer?: (beats: number, scenes: readonly string[]) => void;
|
|
30
|
+
/** Told a scene is redrawn on its own, after the deck, and why. */
|
|
31
|
+
onScene?: (beat: string, broken: readonly string[]) => void;
|
|
32
|
+
/** Told the beats whose scene was dropped (still broken after its own repairs, or broken only by a symbolic quantity), and why. */
|
|
33
|
+
onDropScenes?: (beats: readonly string[], why: readonly string[]) => void;
|
|
34
|
+
/** Each source figure's panel count as the build will cut it, when the caller read them. */
|
|
35
|
+
panels?: Readonly<Record<string, number>>;
|
|
23
36
|
}
|
|
24
37
|
export interface RunnerArgs {
|
|
25
38
|
prompt: string;
|
|
@@ -47,6 +60,16 @@ export interface RunnerArgs {
|
|
|
47
60
|
/** What the planner needs from the outside world: a prompt in, a final message out. */
|
|
48
61
|
export type Runner = (args: RunnerArgs) => Promise<void>;
|
|
49
62
|
export declare function codexPlanner(source: Source, opts?: CodexOptions): Promise<Storyboard>;
|
|
63
|
+
/**
|
|
64
|
+
* A plan Codex answered that this source cannot build — out of the schema's
|
|
65
|
+
* bounds, a picture brief with images off, an id the source lacks — with what
|
|
66
|
+
* is wrong and the JSON it came as, for the repair rounds.
|
|
67
|
+
*/
|
|
68
|
+
export declare class PlanRejected extends Error {
|
|
69
|
+
readonly problems: string[];
|
|
70
|
+
readonly plan: unknown;
|
|
71
|
+
constructor(message: string, problems: string[], plan: unknown);
|
|
72
|
+
}
|
|
50
73
|
/**
|
|
51
74
|
* The `codex` command line for a run, and the environment it needs.
|
|
52
75
|
*
|