/** * Durable annotation layers. * * A layer has an identity that is not its name, not its colour, and not its CSS * class. That separation is the whole point: renaming a layer or recolouring it * must not move a single annotation, and it must not change what any annotation * means. The identity is what annotations reference; everything else is * presentation the user is free to change. * * Three different things get called "layer" nearby, so, precisely: * * - a **display filter** hides a layer's annotations from the stage, and is not * stored on any annotation; * - **membership** is the layer an annotation belongs to, stored as the target's * `styleClass`; and * - an **AnnotationPage** is a storage container, unrelated to either. */ export type AnnotationLayer = { /** Stable identity. Never derived from the name or the colour. */ id: string; name: string; color: string; /** Drawn on the stage. A view state, never a property of an annotation. */ visible: boolean; /** Archived layers keep their annotations but are out of the way. */ archived?: boolean; /** Nothing new can be drawn into a read-only layer. */ readOnly?: boolean; description?: string; }; export declare const DEFAULT_LAYER_COLOR = "#a78bfa"; export declare const DEFAULT_LAYER_ID = "mine"; export declare const createLayer: (layers: readonly AnnotationLayer[]) => AnnotationLayer; export declare const renameLayer: (layers: readonly AnnotationLayer[], id: string, name: string) => AnnotationLayer[]; export declare const recolourLayer: (layers: readonly AnnotationLayer[], id: string, color: string) => AnnotationLayer[]; export declare const setLayerVisibility: (layers: readonly AnnotationLayer[], id: string, visible: boolean) => AnnotationLayer[]; /** * Moves a layer up or down the list. * * Order is presentation: it decides what the panel lists first and what draws on * top. It is not membership, so reordering never touches an annotation. */ export declare const moveLayer: (layers: readonly AnnotationLayer[], id: string, direction: -1 | 1) => AnnotationLayer[]; /** * Archives a layer rather than deleting it. * * Deleting would raise a question with no good answer: what happens to the * annotations in it? Archiving takes the layer out of the way and leaves every * annotation exactly where it is, still reachable through the list filter. */ export declare const archiveLayer: (layers: readonly AnnotationLayer[], id: string, archived?: boolean) => AnnotationLayer[]; export declare const setLayerReadOnly: (layers: readonly AnnotationLayer[], id: string, readOnly: boolean) => AnnotationLayer[]; /** Layers offered for drawing into: present, not archived, not read-only. */ export declare const writableLayers: (layers: readonly AnnotationLayer[]) => AnnotationLayer[]; /** * The layer a new annotation should go into. * * Falls forward to the first writable layer rather than silently drawing into an * archived or read-only one, and only then to the default. */ export declare const resolveActiveLayer: (layers: readonly AnnotationLayer[], preferred: string) => string; /** Adds layers named by annotations but not yet known. */ export declare const mergeDiscoveredLayers: (layers: readonly AnnotationLayer[], discovered: ReadonlyArray<{ id: string; color?: string; }>) => AnnotationLayer[]; /** * Layer metadata as stored. * * Versioned because layers are the kind of thing that grows fields, and a * reader that cannot tell which shape it is holding has to guess. */ export type StoredLayers = { version: 1; layers: AnnotationLayer[]; }; export declare const serializeLayers: (layers: readonly AnnotationLayer[]) => StoredLayers; /** * Reads stored layer metadata, ignoring anything malformed. * * Layer state is convenience, not content: a corrupt record should cost the * user their colour choices, not their annotations, so this never throws. */ export declare const parseLayers: (value: unknown) => AnnotationLayer[] | null;