/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The Schematic canvas's paint path (#57, #172, #1387): ONE commit-phase * snapshot of every render-derived value the async closures read — the frame's * apply, a fly's re-aim, the pointer handlers — written by one dep-less layout * effect, never in a render, the palette and each entity's colour read from the * theme bridge's probe in the same effect (invariant 1); the apply, which moves * every surface with the live camera and calls the painter behind the paint's * identity short-circuit (invariant 2); the minimap's paint, from the same * snapshot (#1393); the builder's reveal, heard through `RevealTell` for the * painted placeholders (#1398, invariant 30), and a pulse's breath (#1392, * invariant 22) — neither rendering the canvas. The painter is `paint.ts`, pure. * * The snapshot reads every part's state and every part's behaviour reads the * snapshot: {@link usePaint} is made after the camera's, the selection's, the * gestures' and the drop's state, and before what moves the camera, keeps the * selection, handles the gestures and takes the drop. * * @packageDocumentation */ import { type RefObject } from "react"; import type { SchematicDensity } from "../area.js"; import type { SchematicValue } from "../data.js"; import type { SchematicDropMark } from "../drop.js"; import type { SchematicNarrowedLook } from "../narrowing.js"; import type { Viewport } from "./camera"; import type { DrawnItem, DrawnZone, SchematicDrawn } from "./drawn"; import type { LodTier, WorldBox } from "./model"; import { type RGB, type SchematicPaintEffect, type SchematicPalette } from "./paint"; import { type SchematicTints } from "./tints"; import type { Camera } from "./use-camera"; import type { CanvasSelection } from "./use-canvas-selection"; import type { GestureState } from "./use-gestures"; type Pt = { x: number; y: number; }; /** * The theme's colour tokens an entity's colour may name (D14): a dot whose token names none of them draws its tone's * colour, and is stacked by its tone — what the painter and a tap's pick of the dot drawn on top read alike. */ export declare const THEME_COLOURS: ReadonlySet; /** * Tells the canvas whether its builder's reveal shows a read in flight (#1398, CL4), as its clock flips: what its * painted placeholders — a marker whose status is unread — show by. It draws nothing, and its flip renders it alone, * never the canvas. Outside a builder's reveal a placeholder shows, as the shared shapes do. */ export declare const RevealTell: import("react").MemoExoticComponent<({ onReveal }: { onReveal: (shown: boolean) => void; }) => null>; /** A round scale-bar length (1/2/5 × 10^k) rendering near `targetPx`. */ export declare function niceScaleLength(ppu: number, targetPx: number): number; /** What {@link usePaint} reads: what the snapshot holds, and the pulse's narrowing. */ export interface PaintProps { /** The payload, decoded: the drawing's extent. */ readonly value: SchematicValue; /** What the canvas draws: its reader's stored rows, the editing session's drafts in place — what the colours are read for. */ readonly data: SchematicDrawn; /** What the painter draws: the drawing, its items where a Move's preview has them — the ONE seam into the painter (invariant 4). */ readonly paintValue: SchematicDrawn; /** The items in view. */ readonly visibleItems: readonly DrawnItem[]; /** What each item in view draws as at the zoom. */ readonly tiers: ReadonlyMap; /** Each item drawn's centre, by its id. */ readonly centers: ReadonlyMap; /** What a hidden layer holds, by id. */ readonly layerHiddenKeys: ReadonlySet; /** Each dimmed entity's opacity, by id. */ readonly layerAlpha: ReadonlyMap; /** Connect's draft in world units (#176): from the item it runs from to the pointer, or the target it snaps to. */ readonly connectDraftWorld: { from: Pt; to: Pt; fromKey: string; snapped: boolean; toKey?: string; forbiddenKey?: string; } | undefined; /** The link or the net lit under the pointer, while it draws and takes the pointer (#1403). */ readonly litShown: string | undefined; /** The link a retarget moves, drawn as its `was` line (#1403). */ readonly wasLink: string | undefined; /** Where a library card's drop lands while its drag rests there (#1390). */ readonly dropMark: SchematicDropMark | undefined; /** What the painter draws of the narrowing, but the pulse's phase (#1392). */ readonly paintEffect: Omit | undefined; /** The box the narrowing's fit flies to (#1392). */ readonly fitBox: WorldBox | undefined; /** Each kind read by area drawing its density in place of its items (D25), by its slot. */ readonly density: ReadonlyMap; /** Whether what it draws stands in for a new narrowing (#1398): its words painted in the third ink. */ readonly stale: boolean; /** Whether what it draws is retained (#1398, CL8): no gesture edits it. */ readonly retained: boolean; /** Whether the minimap shows. */ readonly showMinimap: boolean; /** The minimap's size, in CSS px; `undefined` while the canvas has no size. */ readonly minimapBox: { w: number; h: number; } | undefined; /** The zones drawn, a hidden layer's left out: the minimap's. */ readonly shownZones: readonly DrawnZone[]; /** Each kind read by area's whole drawing's density: the minimap's (#1393). */ readonly minimapDensities: readonly SchematicDensity[]; /** Each item of a kind read whole: the minimap's dots (#1393). */ readonly minimapItems: readonly DrawnItem[]; /** How a narrowed-out row draws, and what the matches take: whether a pulse breathes. */ readonly look: SchematicNarrowedLook; /** The narrowing's matches, by id (#1392). */ readonly matches: ReadonlySet; /** The items wearing the conflicts' warn ring, by key: holding a conflict not yet chosen, or a row its fields' bounds don't hold (#1585). */ readonly conflicted: ReadonlySet; /** The camera (`use-camera.ts`). */ readonly camera: Camera; /** What is selected, and the report's context the snapshot writes (`use-canvas-selection.ts`). */ readonly canvasSelection: CanvasSelection; /** The gestures' state (`use-gestures.ts`). */ readonly gestureState: GestureState; } /** * The commit-phase snapshot (invariant 1): every render-derived value the async closures read — the apply, a fly's * re-aim, the pointer handlers — as the last commit left it, the palette and each entity's colour read from the probe * with it. */ export interface CanvasSnapshot { /** What the painter draws: the drawing, its items where a Move's preview has them — the ONE seam into the painter (invariant 4). */ readonly value: SchematicDrawn; /** What the canvas draws, as its reader and the drafts give it: the drawing an item a drop asks to select waits on. */ readonly drawn: SchematicDrawn; /** The canvas's size, in CSS px; `null` before it is measured. */ readonly size: Camera["size"]; /** Px per world unit at Fit's zoom; `0` before the canvas is measured. */ readonly fit: number; /** Fit's camera: home. */ readonly home: Viewport; /** The zoom's limit, as a factor of Fit's (invariant 24). */ readonly maxZoom: number; /** The device's pixel ratio. */ readonly dpr: number; /** The camera as the render last took it: its throttled snapshot, which the culling and the tiers follow. */ readonly camera: Viewport; /** The items in view. */ readonly visibleItems: readonly DrawnItem[]; /** What each item in view draws as at the zoom. */ readonly tiers: ReadonlyMap; /** The items selected, and the anchor the steps walk from. */ readonly selection: CanvasSelection["selection"]; /** The zones selected. */ readonly zoneSelection: ReadonlySet; /** What draws selected: the selection, or what a marquee in flight would select. */ readonly renderSelected: ReadonlySet; /** Each item drawn's centre, by its id. */ readonly centers: ReadonlyMap; /** What a hidden layer holds, by id. */ readonly layerHiddenKeys: ReadonlySet; /** Each dimmed entity's opacity, by id. */ readonly layerAlpha: ReadonlyMap; /** The tool in force. */ readonly effectiveTool: GestureState["effectiveTool"]; /** Whether the tool in force drags a box: Zoom box, or Marquee. */ readonly isBoxTool: boolean; /** Connect's draft in world units (#176). */ readonly connectDraftWorld: PaintProps["connectDraftWorld"]; /** The link or the net selected, and a net's leg. */ readonly selectedLink: CanvasSelection["selectedLink"]; /** Whether the selected link writes: its handles draw, and a press on one re-targets it. */ readonly selectedLinkEditable: boolean; /** Where a library card's drop lands while its drag rests there (#1390). */ readonly dropMark: SchematicDropMark | undefined; /** What the painter draws of the narrowing, but the pulse's phase (#1392). */ readonly paintEffect: PaintProps["paintEffect"]; /** The box the narrowing's fit flies to (#1392). */ readonly fitBox: WorldBox | undefined; /** The link or the net lit under the pointer (#1403). */ readonly lit: string | undefined; /** The link a retarget moves, drawn as its `was` line (#1403). */ readonly wasLink: string | undefined; /** Each kind read by area drawing its density in place of its items, by its slot (D25). */ readonly density: ReadonlyMap; /** Whether what it draws stands in for a new narrowing (#1398). */ readonly stale: boolean; /** Whether what it draws is retained (#1398, CL8). */ readonly retained: boolean; /** The drawing's extent, in world units. */ readonly extent: SchematicValue["extent"]; /** What the minimap draws, while it shows and the canvas has a size (#1393). */ readonly minimap: { readonly box: { readonly w: number; readonly h: number; }; readonly zones: readonly DrawnZone[]; readonly densities: readonly SchematicDensity[]; readonly items: readonly DrawnItem[]; } | undefined; /** The palette the probe last read; `null` before it is first read. */ readonly palette: SchematicPalette | null; /** Each entity's colour, by its id, as the probe resolved it. */ readonly tints: ReadonlyMap; } /** The paint path, as {@link usePaint} gives it. */ export interface Paint { /** The painted canvas's element. */ readonly drawRef: RefObject; /** * Each card's size as the page lays it out, by its item's id (#1403): what the card layer's observer writes, in place, * and a link's end meets. */ readonly cardSizesRef: RefObject>; /** Draws again as a card's size moves: the card layer tells it so, and the paint's short-circuit hears it (invariant 2). */ readonly applyCardSizes: () => void; /** The card layer's element: what the apply writes the live camera's custom properties to. */ readonly cardLayerRef: RefObject; /** The grid's element: its cells and its position, as the apply writes them. */ readonly gridRef: RefObject; /** The unread area's layer, under the grid (#1398). */ readonly washLayerRef: RefObject; /** Every colour the drawing names, and each entity's: what the probe holds (`tints.ts`). */ readonly tintIndex: SchematicTints; /** The theme bridge's probe's element (`theme.tsx`). */ readonly probeRef: RefObject; /** What draws selected: the selection, or what a marquee in flight would select. */ readonly renderSelected: ReadonlySet; /** The commit-phase snapshot (invariant 1). */ readonly renderSnapRef: RefObject; /** Applies the live camera to every surface, then paints behind the paint's identity short-circuit (invariant 2). */ readonly applyCamera: () => void; /** Hears the builder's reveal flip (CL4): the painted placeholders show, or go unseen, with no render of the canvas. */ readonly onReveal: (shown: boolean) => void; /** Whether the painted placeholders show, as the reveal last said: what a tap's pick of the marker drawn on top reads too. */ readonly placeholdersRef: RefObject; /** The minimap's painted canvas's element. */ readonly minimapPaintRef: RefObject; } /** * The paint path (see the module docs). * * @param props - What the snapshot holds — the drawing and what it draws in view, the camera, what is selected, the * gestures' state, the drop's mark, the narrowing's look and what stands in — and the minimap's * @returns The surfaces' refs, the probe's colours and its ref, what the cards draw selected, the snapshot's ref, the * apply, what hears the reveal, and the minimap's paint's ref */ export declare function usePaint({ value, data, paintValue, visibleItems, tiers, centers, layerHiddenKeys, layerAlpha, connectDraftWorld, litShown, wasLink, dropMark, paintEffect, fitBox, density, stale, retained, showMinimap, minimapBox, shownZones, minimapDensities, minimapItems, look, matches, conflicted, camera, canvasSelection, gestureState, }: PaintProps): Paint; export {}; //# sourceMappingURL=use-paint.d.ts.map