← All packages

@searsuite/sear-render-node

Scene graph

SceneGraph is the root of the retained render tree. A plugin contributes one or more Node values under its own key. addPluginNode() replaces that plugin's top-level nodes; reconcilePluginNodes() retains nodes with stable keys and updates only what changed. GenerationalDirtyTracker records the regions that need repainting.

Use this layer when implementing a renderer or a visual plugin. Content and selection still come from their domain owners; scene nodes hold the geometry and paint behavior for a view.

classSceneGraph
class SceneGraph<T> extends Node<T>

Root scene tree that owns top-level render nodes for each plugin.

constructorSceneGraph<T>(container: Container): SceneGraph<T>

Creates a scene graph bound to one editor-local DI runtime.

propertyreadonly symbol: symbolstatic

DI token for resolving the scene graph.

methodaddPluginNode(pluginKeyString: string, node: Node<T> | Node<T>[], options?: { markDirty?: boolean }): void

Replaces all scene nodes owned by one plugin.

pluginKeyString

Stable plugin key.

node

Node or nodes produced by the plugin render method.

methodclear(context: RenderContext): void

SceneGraph is cleared through strategy-owned dirty regions.

methoddrawHit(context: RenderContext): void

SceneGraph is a root container and is not drawn into the hit layer directly.

methoddrawScene(context: RenderContext): void

SceneGraph is a root container and is not drawn directly.

methodmarkRemovePluginNode(pluginKeyString: string, options?: { markDirty?: boolean }): void

Marks and removes all existing top-level nodes owned by one plugin.

pluginKeyString

Stable plugin key.

methodreconcilePluginNodes(pluginKeyString: string, node: Node<T> | Node<T>[], options?: { markDirty?: boolean; replaceRetainedGeometryChanged?: boolean; replaceRetainedKeys?: ReadonlySet<string>; retainExisting?: boolean; updateRetainedGeometry?: boolean }): void

Reconciles one plugin's top-level nodes by stable node key.

Existing nodes with keys that are still present can be retained, new keys are inserted, and keys no longer returned by the plugin are removed. This is the block-level retained path used by virtualized document rendering.

Inherited members 40

Inherited from Node.

classNode
class Node<T> extends EventListener<string>

Abstract base class for all nodes in the render tree. Handles geometry, appearance, event management, and hierarchical relationships.

constructorNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): Node<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

propertyreadonly childKeys: string[]

Keys of direct child nodes registered via add(), used for recursive cleanup.

propertydepth: number

Render and event ordering depth for Node.

propertyname: string

Name of the node, defaults to the class name.

propertyreadonly nodeKey: string

Stable key used by SceneGraph, DataStorage and spatial indexes.

propertyparentKey: string | null

Parent node's stable render key, used for tree relationships.

propertyreadonly positionRect: PositionRect<string>

Rectangle representing the node's position and size.

propertyproperties: Partial<T>

Visual and geometric properties of the node.

propertyreadonly randomColorKey: templateLiteral | null

Unique random color key used for hit detection.

propertysticky: boolean

Whether this node remains fixed while its scroll container moves.

memberbottom
bottom: unknown
memberconfigEngine
configEngine: unknown
memberfill
fill: unknown
memberheight
height: unknown
memberhorizontalAlign
horizontalAlign: unknown
memberleft
left: unknown
memberlineDash
lineDash: unknown
memberright
right: unknown
memberstroke
stroke: unknown
memberstrokeWidth
strokeWidth: unknown
membertop
top: unknown
memberverticalAlign
verticalAlign: unknown
memberwidth
width: unknown
memberx
x: unknown
membery
y: unknown
methodadd
add(child: Node<T>): Node<T> add(children: Node<T>[]): Node<T>

Implements the single-node and multiple-node add overloads.

ReturnsThe current node (for chaining).

child

The child node to add.

methodaddEventListener(type: string, handler: Function): void

Adds an event listener for the specified event type.

type

The event type to listen for.

handler

The function to handle the event.

methodbindRuntime(container: Container): void

Binds this node tree to the editor-local services owned by one SceneGraph.

methodclear(context: RenderContext): void

Clears state owned by Node.

methoddispose(): void

Disposes this node and all of its descendants recursively. Removes nodes from DataStorage and positionRectStorage, and releases their hit color keys.

methoddraw(sceneContext: RenderContext, hitContext: RenderContext): void

Draws the node in both the scene and hit detection contexts.

sceneContext

The context for scene rendering.

hitContext

The context for hit detection rendering.

methoddrawHit(context: RenderContext): void

Abstract method to draw the node's hit detection representation. Must be implemented by subclasses.

context

The rendering context.

methoddrawScene(context: RenderContext, clipRegion?: ClipRegion): void

Abstract method to draw the node's scene representation. Must be implemented by subclasses.

context

The rendering context.

clipRegion

Optional clipping region: a PositionRect for axis-aligned rectangular clip, or a Point[] polygon (array of [x, y] vertices) for arbitrary shape clip.

methodgetNodeByNodeKey(key: string): Node<T> | null

Finds a node by its stable render-node key.

ReturnsThe node if found, otherwise null.

key

The stable render node key.

methodgetNodeByRandomColorKey(key: templateLiteral): Node<T> | null

Finds a node by its random color key.

ReturnsThe node if found, otherwise null.

key

The random color key to search for.

methodquery(range: PositionRect<templateLiteral>): Node<T>[]

Queries all nodes within a given rectangular range.

ReturnsAn array of nodes found within the range.

range

The rectangle to query.

methodremoveChild(child: Node<T>): void

Removes a child node from this node and disposes its entire subtree.

methodremoveEventListener(type: string): void

Removes an event listener for the specified event type.

type

The event type to remove.

methodsetStickyTree(sticky: boolean, affix?: Pick<NodeProperties, "top" | "left">): this

Marks this node tree as sticky and applies the supplied affix axes to every descendant.

methodtoJSON(): { }

Converts the node and its properties to a JSON object. Can be extended to recursively serialize children.

Inherited members 4

Inherited from EventListener.

classRenderNode
class RenderNode<T> extends Node<T>

Abstract class for render nodes. Extend this for nodes that manage rendering.

constructorRenderNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): RenderNode<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

Inherited members 43

Inherited from Node.

classBlockManager
class BlockManager extends RichTextBlockLayoutProvider

Measures rich-document blocks and produces wrapped rich-text layout lines.

constructorBlockManager(textShaper: TextShaper, inlineStyleRegistry: RichTextInlineStyleRegistry, runRenderRegistry: RichTextRunRenderRegistry, lineBoxRegistry: RichTextLineBoxRegistry, baseFont?: string, paragraphLayoutDefaults?: RichTextParagraphLayoutDefaults): BlockManager

Creates a block manager from the text-shaping and rich-text services.

propertymaxWidth: number

Maximum measured unwrapped block width.

propertyreadonly symbol: typeof symbolstatic

DI token for resolving the rich-document block manager.

methodadd(node: RichDocNode): void

Adds a rich document block and records its measured size.

methodcalculateLayout(width: number): RichTextLine[]

Calculates a flattened list of wrapped rich-text lines for all blocks.

methodcalculateLayoutPerParagraph(width: number): RichTextLine[][]

Calculates wrapped rich-text lines per paragraph while preserving paragraph mapping.

methodclear(): void

Clears all measured blocks and cached size information.

methodcreateDetached(): BlockManager

Creates an unshared measurement workspace for a read-only layout request.

methodenforceCommandBoundary(isCommandExecuting: (): boolean): void

Closes direct block writes after the owning editor has assembled.

methodsetBaseFont(font: string): void

Selects the transient base font used for the next layout pass.

classContainer
class Container extends EventListener<string>

Scene node that owns, queries, and serializes an ordered child collection.

constructorContainer(): Container
propertyreadonly randomColorKey: templateLiteral | null

Unique random color key for hit detection.

memberchildren
children: unknown
methodadd
add(child: Container): this add(children: Container[]): this

Adds the value.

methoddescendants(): never[]

Iterates every descendant in scene order.

methodquery(): void

Returns descendants whose boundaries intersect the supplied rectangle.

methodremove(): void

Removes the value.

methodtoJSON(): { }

Serializes this scene structure into diagnostic JSON.

methodupdateBoundary(): void

Updates the indexed boundary after geometry changes.

Inherited members 4

Inherited from EventListener.

classDirtyTree

DI token placeholder for the dirty-region spatial index.

constructorDirtyTree(): DirtyTree
propertyreadonly symbol: symbolstatic

DI token used to resolve the dirty tree implementation.

classGenerationalDirtyTracker

Frame-scoped dirty-region tracker.

A scene mutation may replace several plugins before the render pass starts. Every affected region must therefore remain recorded until DirtyRenderStrategy has consumed the frame. In particular, node replacement must never clear regions recorded by an earlier replacement in that frame.

The class name is retained for DI/API compatibility; its behaviour is no longer generation-based.

constructorGenerationalDirtyTracker(tree: Tree<PositionRect<templateLiteral>>): GenerationalDirtyTracker
propertyreadonly symbol: symbolstatic

DI token for resolving GenerationalDirtyTracker.

methodclear(): void

Frame-end full cleanup (called by DirtyRenderStrategy.render()). All items are removed regardless of generation.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the boundary.

methodmark(rect: PositionRect<templateLiteral>): void

Records a region until the current dirty render pass finishes.

methodquery(range: PositionRect<templateLiteral>): PositionRect<templateLiteral>[]

Returns dirty nodes for the requested render generation.

classLayoutNode
class LayoutNode<T> extends Node<T>

Abstract class for layout nodes. Extend this for nodes that manage layout.

constructorLayoutNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): LayoutNode<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

Inherited members 43

Inherited from Node.

classTree
class Tree<T>

Shared spatial-index contract. The item shape is owned by each index.

constructorTree<T>(boundary: PositionRect<templateLiteral>, capacity: number): Tree<T>
propertyreadonly capacity: number

The maximum number of entries retained by this spatial node.

propertyparent: Tree<T> | null

The parent spatial node, or null at the root.

propertyreadonly symbol: symbolstatic

DI token for resolving Tree.

methodclear(): void

Clears state owned by Tree.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the boundary.

methodinsert(item: T): boolean

Inserts a bounded entry into the spatial index.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns indexed entries whose boundaries intersect the supplied rectangle.

methodremove(item: T, predicate?: (rect: PositionRect<templateLiteral>): boolean): boolean

Removes the value.

methodtoJSON(): object

Serializes this scene structure into diagnostic JSON.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Updates the indexed boundary after geometry changes.

typeNodeProperties
type NodeProperties = unknown
propertybottom?: number
propertycontentInsetStart?: number

Space reserved before projected text for a cell visual.

propertycornerRadius?: [number, number, number, number]
propertydepth?: number
propertyfill?: string
propertyfitNumberValue?: number

Raw General-format number fitted against the actual render width.

propertyhideText?: boolean

Suppresses projected text while preserving its underlying value.

propertyhorizontalAlign?: SheetHorizontalAlignment
propertyisEdit?: boolean
propertyleft?: number
propertylineDash?: number[]
propertynodeKey?: RenderNodeKey

Stable render-node key.

When omitted, Node falls back to its generated hit color key for backwards compatibility. Semantic render nodes should provide stable ids such as block ids here instead of using hit colors as identity.

propertyoverlayClipRect?: PositionRectProps

Optional world-coordinate clip applied by OverlayRenderStrategy. Overlay nodes normally render above sticky UI; this lets a visual stay within a host-defined content region instead (for example, a sheet selection must not draw over row/column headers).

propertyright?: number
propertysemanticOwner?: string

Stable semantic ownership exposed by retained render targets.

propertysemanticRole?: string

Stable semantic role exposed by retained render targets.

propertyshouldBeClipInDirtyRender?: boolean

Business marker: true when selection represents a whole row or whole column range. Dirty render may use this to choose a different redraw shape.

propertyskipHit?: boolean

Visual-only nodes do not participate in hit canvas.

Background: FixBoxNode.drawHit fills the entire rect with random color for Hit Canvas lookup. But once visual-only nodes (such as selection strokes and header highlight backgrounds) enter the Hit Canvas, they can cover underlying cell hit colors and block click-through. Setting skipHit: true in properties makes drawHit skip directly.

propertystroke?: string
propertystrokeWidth?: number
propertytextColor?: string

Foreground color used by text-rendering nodes.

propertytextFillCharacter?: string

Character repeated to fill the remaining inline width of formatted text.

propertytextOverflowWidth?: number

Maximum width available to single-line text across adjacent empty cells.

propertytop?: number
propertyverticalAlign?: SheetVerticalAlignment
typeRenderNodeKey
type RenderNodeKey = string

Stable key used by SceneGraph, Tree and DataStorage to identify render nodes.

Shape nodes

classAffixNode
class AffixNode<T> extends FixBoxNode<T>

Sticky box node used for row/column headers and other affixed sheet regions.

constructorAffixNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): AffixNode<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

propertysticky: boolean

Affix nodes render in the sticky strategy instead of the scrolled content layer.

Inherited members 42

Inherited from FixBoxNode.

classAffixTextNode
class AffixTextNode<T> extends TextNode<T>

Sticky text node used inside affixed header cells.

constructorAffixTextNode<T>(value: string | RichDocNode, positionRect: PositionRectProps | undefined, properties: Partial<T>, runtime?: Container): AffixTextNode<T>

Constructs a text node and measures its width against the active render context.

value

Text or rich-text value to render.

positionRect

Initial node bounds.

properties

Render properties inherited from the parent cell.

propertysticky: boolean

Affix text renders in the sticky strategy together with its parent.

Inherited members 43

Inherited from TextNode.

classBoxNode
class BoxNode<T> extends LayoutNode<T>

The BoxNode class represents a block-level node in a scene graph. It behaves similarly to an HTML element with position: relative, where its position is determined relative to its parent or siblings.

constructorBoxNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): BoxNode<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

methodclear(context: RenderContext): void

Clears state owned by BoxNode.

methoddrawHit(context: RenderContext): void

Draws the hit area for this node and all its descendants. This is typically used for hit testing (e.g., detecting mouse clicks).

context

The rendering context used to draw the hit area.

methoddrawScene(context: RenderContext): void

Draws the scene for this node and all its descendants. This method recursively calls drawScene on all child nodes.

context

The rendering context used to draw the scene.

Inherited members 40

Inherited from LayoutNode.

classDashedLineNode
class DashedLineNode<T> extends RenderNode<T>

Scene node that renders one dashed line segment.

constructorDashedLineNode<T>(positionRect: PositionRectProps, props: Partial<T>, line: { x1: number; x2: number; y1: number; y2: number }): DashedLineNode<T>

Constructs a dashed line node.

positionRect

Dirty/hit bounds covering the line.

props

Render properties including stroke and dash pattern.

line

Exact line segment coordinates.

methodclear(context: RenderContext): void

Clears the line bounds with stroke padding.

context

Render context to clear.

methoddrawHit(): void

Dashed lines are visual-only and do not participate in hit testing.

methoddrawScene(context: RenderContext, clipRegion?: ClipRegion): void

Draws the dashed line into the render context.

context

Render context receiving draw commands.

Inherited members 40

Inherited from RenderNode.

classFixBoxNode
class FixBoxNode<T> extends RenderNode<T>

Scene node that renders a rectangular box with optional fill, stroke, and clipping.

constructorFixBoxNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): FixBoxNode<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

methodclear(context: RenderContext): void

Clears this node's bounds from a raster context using stroke padding.

context

Render context to clear.

methoddrawHit(context: RenderContext): void

Draws the node into the hit-test context unless the node is visual-only.

context

Hit render context.

methoddrawScene(context: RenderContext, clipRegion?: ClipRegion): void

Draws the box into the visible render context.

context

Render context receiving draw commands.

clipRegion

Optional rectangle or polygon clipping region.

Inherited members 40

Inherited from RenderNode.

classStickyNode
class StickyNode<T> extends BoxNode<T>

Box node specialization reserved for sticky-layer rendering.

constructorStickyNode<T>(positionRect?: PositionRectProps, props?: Partial<T>, runtime?: Container): StickyNode<T>

Constructs a new Node<T> instance with specified properties and position. Updates the boundary in the positionRectStorage if necessary.

props

Partial properties and position for initialization.

Inherited members 43

Inherited from BoxNode.

classTextNode
class TextNode<T> extends RenderNode<T>

Scene node that renders plain text derived from string or rich-text content.

constructorTextNode<T>(value: string | RichDocNode, positionRect: PositionRectProps | undefined, properties: Partial<T>, runtime?: Container): TextNode<T>

Constructs a text node and measures its width against the active render context.

value

Text or rich-text value to render.

positionRect

Initial node bounds.

properties

Render properties inherited from the parent cell.

propertydepth: number

Text draws above the box background by default.

propertyreadonly value: string | RichDocNode

Text value rendered by this node.

memberwidth
width: unknown
methodclear(context: RenderContext): void

Text nodes are cleared through their parent box dirty region.

methoddrawHit(context: RenderContext): void

Text nodes do not draw separate hit regions; the parent box owns hit testing.

methoddrawScene(context: RenderContext, clipRegion?: ClipRegion): void

Draws text inside the parent node using the parent's alignment and padding.

context

Render context receiving text commands.

clipRegion

Optional clipping region inherited from render strategies.

Inherited members 38

Inherited from RenderNode.

typeClipRegion
type ClipRegion = PositionRect<HexColor> | Point[]

Clip region passed to drawScene.

  • PositionRect&lt;HexColor&gt; — axis-aligned rectangle clip (common case).
  • Point[] — arbitrary polygon clip; each element is an [x, y] vertex.
functioncreateDragGuideNode
createDragGuideNode<T>(line: { x1: number; x2: number; y1: number; y2: number }, properties: Partial<T>): DashedLineNode<T>

Creates a shared visual-only overlay guide for move and resize gestures.

Cell visuals

classCellVisualLayerNode
class CellVisualLayerNode<T> extends RenderNode<T>

Draws a feature-contributed visual between a cell background and its content.

constructorCellVisualLayerNode<T>(rect: PositionRectProps, properties: Partial<T>, layer: CellVisualLayer): CellVisualLayerNode<T>
methodclear(context: RenderContext): void

Clears state owned by Node.

methoddrawHit(): void

Abstract method to draw the node's hit detection representation. Must be implemented by subclasses.

methoddrawScene(context: RenderContext): void

Abstract method to draw the node's scene representation. Must be implemented by subclasses.

context

The rendering context.

Inherited members 40

Inherited from RenderNode.

interfaceCellVisualLabel

One text label drawn within a feature-contributed visual layer.

interfaceCellVisualLayer

A visual rectangle, icon or sequence of labels within its cell bounds.

typeCellVisualIconShape
type CellVisualIconShape = typeof CellVisualIconShape[keyof typeof CellVisualIconShape] CellVisualIconShape: { Bar: "bar"; Check: "check"; Circle: "circle"; Cross: "cross"; Diamond: "diamond"; Down: "down"; Flag: "flag"; Right: "right"; … }
typeCellVisualLayerShape
type CellVisualLayerShape = typeof CellVisualLayerShape[keyof typeof CellVisualLayerShape] CellVisualLayerShape: { Rectangle: "rectangle"; TopLeftTriangle: "topLeftTriangle" }

Primitive shapes available to feature-contributed cell layers.

Rich text rendering

Rich text uses block, line, run, caret, and selection nodes. RichTextRunRenderRegistry lets a feature provide paint behavior for a run without changing the shared tree. HitColorRegistry and the spatial indexes support finding nodes from pointer coordinates. Start with SceneGraph for ownership, then choose the node type that represents the visual element you need to paint or hit test.

classRichTextLineRenderer

Paints laid-out rich-text lines by grouping adjacent characters into runs.

constructorRichTextLineRenderer(inlineStyles: RichTextInlineStyleRegistry, runRenderer: RichTextRunRenderer): RichTextLineRenderer

Creates a line renderer with domain style comparison and run rendering.

propertyreadonly symbol: typeof symbolstatic

DI token for resolving the line renderer.

methodpaint(context: RenderContext, input: { font?: string; line: RichTextRenderLine; origin: Pick<PositionRectProps, "x" | "y"> }): void

Paints one laid-out line at the supplied world-space origin.

classRichTextRunRenderer

Paints one contiguous rich-text run using the registered render contributions.

classRichTextRunRenderRegistry

Render-layer registry for plugin-owned rich-text run behavior.

constructorRichTextRunRenderRegistry(): RichTextRunRenderRegistry
propertyreadonly symbol: typeof symbolstatic

DI token for resolving the rich-text run render registry.

methodapplyRenderState(context: RenderContext, style: Readonly<Record<string, unknown>> | undefined): void

Applies all registered render-state contributions before text painting.

methodenforceWriteBoundary(assertWrite: (): void): void
methodpaintRun(input: RichTextRunPaintInput): void

Paints all registered plugin-owned run details.

methodregister(contribution: RichTextRunRenderContribution): (): void

Registers one render contribution.

methodresolveFont(font: string, style: Readonly<Record<string, unknown>> | undefined): string

Resolves the final font descriptor after all registered contributions run.

classRichTextVisualNode
class RichTextVisualNode extends Node<RichTextRenderNodeProperties>

Base class for rich-text nodes that only draw pixels and do not own hit state.

methodclear(_context: RenderContext): void

Rich-text visual node pixels are cleared by strategy-owned dirty rectangles.

methoddrawHit(_context: RenderContext): void

Rich-text visual nodes are ignored by hit testing unless a subclass opts in.

Inherited members 41

Inherited from Node.

interfaceRichTextRenderChar

Minimal rich-text character shape consumed by render nodes.

interfaceRichTextRunRenderContribution

Plugin-owned render behavior for one inline text-style concern.

propertyreadonly key: string

Stable contribution key used for duplicate detection and unregister.

methodapplyRenderState(input: { context: RenderContext; style: Readonly<Record<string, unknown>> | undefined }): void

Applies renderer state before the text run is painted.

methodpaintRun(input: RichTextRunPaintInput): void

Paints plugin-owned details for an already painted text run.

methodresolveFont(input: { font: string; style: Readonly<Record<string, unknown>> | undefined }): string

Resolves the font used by shaping and painting for a styled run.

interfaceRichTextSelectionRect

Rectangle highlighted as part of a rich-text selection.

typeRichTextBlockId
type RichTextBlockId = string

Stable rich-text block identifier.

functioncreateRichTextRunRect
createRichTextRunRect(x: number, baselineY: number, width: number, height: number, fontAscent: number): PositionRect<templateLiteral>

Creates a world-space rectangle for one rich-text line/run.

typeRichTextInlineStyle
type RichTextInlineStyle = Readonly<Record<string, unknown>>

Domain-neutral inline style bag carried by measured rich-text chars.

interfaceRichTextRenderNodeProperties
interface RichTextRenderNodeProperties extends NodeProperties

Render-node properties used by rich-text scene graphs.

propertyreadonly blockId?: string

Stable top-level rich-text block id.

propertyreadonly blockIndex?: number

Top-level rich-text block index.

propertyreadonly lineIndex?: number

Layout line index inside the full rich-text snapshot.

propertyreadonly renderRole?: "block" | "line" | "page" | "text-run" | "selection" | "caret" | "composition"

Semantic role for rich-text render nodes.

Inherited members 25

Inherited from NodeProperties.

Hit testing and spatial indexes

Spatial indexes narrow the nodes considered for hit testing; hit colors connect painted regions back to nodes.

classBVH
class BVH<T> extends Tree<T>

Simple bounding-volume hierarchy spatial index implementation.

constructorBVH<T>(): BVH<T>

Constructs a BVH with a broad default world boundary.

methodclear(): void

Removes all indexed items.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the current tree boundary.

methodinsert(data: T): boolean

Inserts one item into the root child list.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns items whose rectangles intersect the query range.

methodremove(data: T): boolean

Removes one item by object identity.

methodtoJSON(): object

Serializes debug data for this spatial index.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the tree boundary and clears indexed items.

Inherited members 3

Inherited from Tree.

classEventListener
class EventListener<CustomEventTypes>

Represents an event listener system that allows adding, removing, and managing event handlers. Supports default event types and allows extension with custom event types.

constructorEventListener<CustomEventTypes>(): EventListener<CustomEventTypes>
methodemit(eventString: CustomEventTypes, ...args: unknown[]): boolean

Triggers an event, calling all associated handlers in registration order.

Propagation control: If any handler synchronously returns false, dispatch to subsequent handlers stops. Returning true / undefined / void means dispatch continues.

This enables ordered plugin suppression for the same event (for example, a cell editor can block a selection plugin on dblClick) without direct plugin-to-plugin state mutation.

Returnsfalse if a handler actively stopped propagation; otherwise true.

eventString

The name of the event to trigger.

args

Arguments to pass to the event handlers.

methodenforceWriteBoundary(assertWrite: (): void, teardownToken: object): void

Closes registration changes after an owning runtime has assembled.

methodoff(eventString?: CustomEventTypes, handler?: Function): void

Removes event handlers for a specific event or all events.

eventString

The name of the event to remove handlers for. If not provided, all event handlers are removed.

methodon(eventString: CustomEventTypes, handler: Function): EventListener<CustomEventTypes>

Registers an event handler for a specific event.

ReturnsThe current instance to allow method chaining.

eventString

The name of the event to listen for.

handler

The function to be called when the event is triggered.

classHilbertRTree
class HilbertRTree<T> extends Tree<T>

Hilbert-sorted R-tree style spatial index for rectangular data.

constructorHilbertRTree<T>(boundary: PositionRect<templateLiteral>, maxChildren?: number): HilbertRTree<T>

Constructs a Hilbert R-tree.

boundary

Root spatial boundary.

maxChildren

Maximum children retained by the shared tree contract.

methodclear(): void

Removes all indexed items.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the current tree boundary.

methodinsert(data: T): boolean

Inserts one item and maintains Hilbert ordering.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns items whose rectangles intersect the query range.

methodremove(data: T): boolean

Removes an item by matching rectangle bounds.

methodtoJSON(): object

Serializes debug data for this spatial index.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the boundary and clears indexed items.

Inherited members 3

Inherited from Tree.

classHitColorRegistry

Maps hit-canvas color keys back to render nodes.

constructorHitColorRegistry(): HitColorRegistry
propertyreadonly symbol: symbolstatic

DI token for resolving the hit-color registry.

methodclear(): void

Clears all registered hit-color mappings.

methoddelete(key: templateLiteral): void

Removes a hit-canvas color key mapping.

methodget<T>(key: templateLiteral): Node<T> | undefined

Resolves the node currently associated with a hit-canvas color key.

methodregister<T>(key: templateLiteral, node: Node<T>): void

Registers a node for hit-canvas color lookup.

classKDTree
class KDTree<T> extends Tree<T>

KD-tree spatial index for rectangular scene data.

constructorKDTree<T>(boundary?: PositionRect<templateLiteral>, capacity?: number): KDTree<T>

Constructs a KD-tree.

boundary

Root spatial boundary.

capacity

Retained for the shared Tree contract.

methodclear(): void

Removes all indexed items.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the current tree boundary.

methodinsert(data: T): boolean

Inserts an item by alternating x/y split axes.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns items whose rectangles intersect the query range.

methodremove(data: T): boolean

Removes one item by object identity and rebuilds the experimental tree.

methodtoJSON(): object

Serializes debug data for this spatial index.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the boundary and clears indexed items.

Inherited members 3

Inherited from Tree.

classOctree
class Octree<T> extends Tree<T>

Simple Octree-shaped spatial index for rectangular scene data.

constructorOctree<T>(): Octree<T>

Constructs an Octree with a broad default world boundary.

methodclear(): void

Removes all indexed items.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the current tree boundary.

methodinsert(data: T): boolean

Inserts one item into the root child list.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns items whose rectangles intersect the query range.

methodremove(data: T): boolean

Removes one item by object identity.

methodtoJSON(): object

Serializes debug data for this spatial index.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the boundary and clears indexed items.

Inherited members 3

Inherited from Tree.

classQuadTree
class QuadTree extends Tree<PositionRect<HexColor>>

QuadTree spatial index used by scene and dirty-region lookups.

constructorQuadTree(boundary: PositionRect<templateLiteral>, capacity: number): QuadTree

Constructs a QuadTree node.

boundary

Node boundary.

capacity

Maximum items before subdivision.

propertybottomleft: QuadTree | null

Bottom-left child node.

propertybottomright: QuadTree | null

Bottom-right child node.

propertydivided: boolean

Whether this node has been subdivided into children.

propertyrects: PositionRect<templateLiteral>[]

Rectangles stored directly in this node.

propertytopleft: QuadTree | null

Top-left child node.

propertytopright: QuadTree | null

Top-right child node.

methodclear(): void

Clears all indexed rectangles and child quadrants.

methodcontains(boundary: PositionRect<templateLiteral>, rect: PositionRect<templateLiteral>): boolean

Returns whether boundary fully contains rect.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the root boundary for this tree node.

methodinsert(data: PositionRect<templateLiteral>): boolean

Inserts a rectangle into the tree.

ReturnsTrue when data intersects this tree boundary.

data

Rectangle to index.

methodintersects(a: PositionRect<templateLiteral>, b: PositionRect<templateLiteral>): boolean

Returns whether two rectangles overlap.

methodquery(range: PositionRect<templateLiteral>, found?: PositionRect<templateLiteral>[]): PositionRect<templateLiteral>[]

Queries rectangles intersecting a range.

ReturnsMatching rectangles.

range

Search rectangle.

found

Accumulator used during recursion.

methodremove(data: PositionRect<templateLiteral>, predicate?: (rect: PositionRect<templateLiteral>): boolean): boolean

Removes matching rectangle entries.

ReturnsTrue when an entry was removed.

data

Rectangle coordinates to remove.

predicate

Optional predicate for entries with matching bounds.

methodsubdivide(): void

Splits this node into four child quadrants and redistributes contained items.

methodtoJSON(): object

Serializes debug data for this tree.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the boundary and reinserts existing rectangles.

boundary

New root boundary.

Inherited members 3

Inherited from Tree.

classQuadTreeFactory
class QuadTreeFactory<T> extends TreeFactory<PositionRect<HexColor>>

Factory that creates QuadTree spatial indexes for rectangular scene data.

constructorQuadTreeFactory<T>(): QuadTreeFactory<T>
methodcreate(boundary: PositionRect<templateLiteral>, capacity: number): QuadTree

Creates a QuadTree.

boundary

Root spatial boundary.

capacity

Maximum items in a leaf before subdivision.

classRTree
class RTree<T> extends Tree<T>

Simple R-tree spatial index for rectangular scene data.

constructorRTree<T>(): RTree<T>

Constructs an R-tree with a broad default world boundary.

methodclear(): void

Removes all indexed items.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the current tree boundary.

methodinsert(data: T): boolean

Inserts one item into the root child list.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns items whose rectangles intersect the query range.

methodremove(data: T): boolean

Removes one item by object identity.

methodtoJSON(): object

Serializes debug data for this spatial index.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the boundary and clears indexed items.

Inherited members 3

Inherited from Tree.

classSpatialHash
class SpatialHash<T> extends Tree<T>

Spatial hash index that buckets rectangular items by their top-left cell.

constructorSpatialHash<T>(cellSize?: number, boundary?: PositionRect<templateLiteral>, capacity?: number): SpatialHash<T>

Constructs a spatial hash index.

cellSize

Logical size of one hash bucket.

boundary

Root spatial boundary.

capacity

Retained for the shared Tree contract.

methodclear(): void

Removes all indexed items.

methodgetBoundary(): PositionRect<templateLiteral>

Returns the current tree boundary.

methodinsert(data: T): boolean

Inserts an item into the bucket containing its top-left corner.

methodquery(range: PositionRect<templateLiteral>): T[]

Returns items in intersecting buckets whose rectangles overlap the query range.

methodremove(data: T): boolean

Removes one item from its hashed bucket.

methodtoJSON(): object

Serializes debug data for this spatial index.

methodupdateBoundary(boundary: PositionRect<templateLiteral>): void

Replaces the boundary and clears indexed items.

Inherited members 3

Inherited from Tree.

typeHitColorKey
type HitColorKey = HexColor

Color key used only by hit-canvas rendering and pixel-to-node lookup.