/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type ValueTypeOf } from "@elaraai/east"; import type { RecordSliceBindType } from "@elaraai/east-ui/internal"; import type { EditHistory, Origin } from "@elaraai/east-ui-components"; import { type ScheduleEditing, type ScheduleEntryRef } from "../shared/schedule/editing.js"; import type { SchematicRef } from "./canvas/drawn.js"; import type { SchematicHeldRows, SchematicValue, SchematicWindowRows } from "./data.js"; import { type SchematicDrafts, type SchematicLanded } from "./drafted.js"; import type { SchematicEdit } from "./edits.js"; export { detailsKey, recordSlot } from "./record-keys.js"; /** What the Schematic's editing says of a new row's key (#1549). */ export interface SchematicKeyWords { /** A new row held under a placeholder, its key still to be typed — `Type this rack's key: Save waits for it`; `name` is its kind's. */ readonly placeholder: (p: { name: string; }) => string; } /** A new row's key, as its kind makes it (#1549). */ export type SchematicNewKey = /** Its key: built from its row, minted, one past the largest, or a placeholder until the viewer types its key. */ { readonly key: string; } /** None: the key its row builds is held already, by the row of that key. */ | { readonly taken: string; } /** None: its kind's keys are of a type the form can't type — by the type's name — and its kind builds none. */ | { readonly untyped: string; }; /** A row a gesture moves under the key its fields build once the gesture writes them (#1549). */ export interface SchematicMove { /** The row. */ readonly ref: SchematicRef; /** The key its row builds after the gesture. */ readonly to: string; } /** The Schematic's editing: its history, every kind's drafts, and how a gesture is recorded. */ export interface SchematicEditing { /** The shared Schedule editing over the records: each one's session, and what each holds. */ readonly schedule: ScheduleEditing; /** The one history over them. */ readonly history: EditHistory; /** Whether any record is edited: a kind or a details record bound with its patch door, and the Schematic not read only. */ readonly edits: boolean; /** Every kind's drafts, by sort, each decoded once. */ readonly drafts: SchematicDrafts; /** * What each confirmed Save landed of the kinds read by area, as their sessions keep it (`EditSession.landed`), each * row decoded once: drawn as the Save left it over a window read before the commit (`drafted.ts`' `landedDrafts`). */ readonly landed: SchematicLanded; /** The history's version: it moves with every change of it or of its sessions. */ readonly version: number; /** * Lets go of what Saves landed of a kind's rows, once its reads draw them as the record holds them now (`drafted.ts`' * `landedRead`). * * @param slot - The kind's slot * @param keys - The rows' keys */ shown(slot: string, keys: readonly string[]): void; /** * Whether a record takes an edit now: its session takes one, and nothing the canvas draws is retained (#1398, CL8). * * @param record - The record's key in the history: a kind's slot, or its details' (`detailsKey`) * @returns Whether it takes one */ available(record: string): boolean; /** * Records one gesture's edits as one step of the history. * * @param edits - The rows it changes, and how * @param origin - The gesture * @param label - Its label in the history * @returns Whether anything was recorded: nothing is when a kind refuses a row, a row's read is in flight, or what the * canvas draws is retained */ record(edits: readonly SchematicEdit[], origin: Origin, label: string): boolean; /** * Whether a record is edited at all: a kind or a details record bound with its patch door, and the Schematic not read * only (SC14). * * @param record - The record's key in the history: a kind's slot, or its details' (`detailsKey`) */ edited(record: string): boolean; /** * A new row's key, as its kind makes one (#1549; the module docs): built from the row the edit makes, by the kind's * `key`, refused where a row stands under it; else, keyed by String, minted unique (SC7); by Integer, one past the * largest; by a type the form types, a placeholder; by any other, none. * * @param made - The edit making the row — an item's, a link's or a net's — under any key: its kind's, and the row the * kind's `key` builds a key from * @param minted - The keys the gesture has made already * @returns The key, or why there is none; `undefined` while a kind read by key asks its record for its largest, or * where the kind makes no row of the edit */ newKey(made: SchematicEdit, minted?: ReadonlySet): SchematicNewKey | undefined; /** * Whether the Schematic holds a key of a kind already: read, or drafted — a new row's among them. A kind read by key * knows the keys its reads hold: a key e3 holds unread is its Save's conflict. * * @param slot - The kind's slot * @param key - The key's text */ taken(slot: string, key: string): boolean; /** * Whether a row of a kind stands under a key (#1549): drafted, else read — a key whose row a draft deletes stands * free, so a row built under it again takes it back. * * @param slot - The kind's slot * @param key - The key's text */ stands(slot: string, key: string): boolean; /** * The rows a gesture moves under the keys their fields build once it writes them (#1549): each row it finds held — * never one it makes — whose kind builds its key from its row, where the key its row builds changes, to another than * the one it stands under — a row whose fields an app wrote apart from its key, edited back to build it, stays (#1581). * * @param edits - The gesture's edits * @returns Each row it moves, and the key it moves under */ moves(edits: readonly SchematicEdit[]): SchematicMove[]; /** * Whether a kind builds a new row's key from its row: its `key` (#1549). * * @param slot - The kind's slot */ builds(slot: string): boolean; /** * Why a kind adds no row (#1549): its keys are of a type the form can't type, and it builds none. * * @param slot - The kind's slot * @returns The key type's name; `undefined` for a kind that keys the rows it adds */ untyped(slot: string): string | undefined; /** * Whether the viewer types a kind's new rows' keys (#1549): it makes none of its own — keyed by neither String nor * Integer, and building none — and the form types its key type. A new row waits under a placeholder until it is typed. * * @param slot - The kind's slot */ keysTyped(slot: string): boolean; } /** * The Schematic's sessions over its records, and their drafts (see the module * docs). * * @param value - The payload * @param storageKey - The Schematic's key: its sessions and their history are kept under it * @param recordSlices - The slice's parts over the kinds read through their sources: each Save notice counts what leaves its own * @param held - Each kind's rows its read holds: the keys a new row's key is minted unique among * @param areas - The kinds read by area, by slot: never read whole, nor their narrowing complete * @param windows - The rows each kind read by area holds in its window, at the revision they were read at * @param words - What the editing says of a new row's key * @param paged - A row of a kind read by area the paged Backlog's pages read, by the kind's slot and the row's key, and the * revision they read it at (#1393): asked as a gesture reads it, for a row the window does not hold * @param retained - Whether what the canvas draws is retained (#1398, CL8): no record takes an edit while it is * @returns The editing */ export declare function useSchematicEditing(value: SchematicValue, storageKey: string, recordSlices: readonly ValueTypeOf[], held: SchematicHeldRows, areas: ReadonlySet, windows: SchematicWindowRows, words: SchematicKeyWords, paged?: (slot: string, key: string) => { readonly revision: string; readonly row: Uint8Array; } | undefined, retained?: boolean): SchematicEditing; //# sourceMappingURL=editing.d.ts.map