@searsuite/sear-render-cursor
Portable cursor policies with Web and headless host adapters.
Cursor engines
- classCursorEngine
-
Abstract cursor presentation layer.
Responsibilities: translate a logical CursorToken into a concrete presentation (CSS cursor, Canvas sprite, Electron native cursor, test stub, …). Fully decoupled from the Plugin system and the rule system.
Contract:
- mount() called once during plugin initialization, receives the render target.
- apply() called on every cursor change; implementations must be idempotent.
- unmount() called during plugin destruction; must clean up all side-effects.
constructor CursorEngine(): CursorEngineproperty readonly symbol: symbolstaticDI token for resolving CursorEngine.
method apply(token: CursorToken): voidApplies a transaction to CursorEngine state.
method mount(target: unknown): voidAttaches this adapter to its host surface.
method override(token: CursorToken | null): voidLock the cursor to a fixed token (e.g. during cell editing). Pass null to release.
method unmount(): voidDetaches this adapter from its host surface.
- classCursorRegistry
-
Stores cursor rules and resolves the correct CursorToken for a given CellProperties.
Resolution priority (highest → lowest):
- Matching PositionCursorRule at the greatest layer — last registered wins
- PredicateCursorRule { priority: 'high' } — last registered wins
- RegionCursorRule — exact region match
- TypeCursorRule — exact type match
- PredicateCursorRule { priority: 'low' } — last registered wins
- Fallback: 'default'
constructor CursorRegistry(platform?: Platform): CursorRegistryCreates a registry and optionally enables position-rule conflict diagnostics.
property readonly symbol: symbolstaticDI token for resolving CursorRegistry.
method register(rule: CursorRule): (): voidRegisters a cursor rule and returns an idempotent disposer that restores the previous rule for the same key when applicable.
method registerPosition(rule: Omit<PositionCursorRule, "kind">): (): voidRegisters a coordinate-aware cursor rule without requiring callers to repeat the position-rule discriminator.
ReturnsAn idempotent disposer that restores the previous rule for its key.
rulePosition rule fields excluding the fixed
kinddiscriminator.
method resolve(properties: CellProperties | null, position?: CursorPosition): CursorTokenResolves a logical cursor token without exposing presentation details.
propertiesHit-tested cell properties, if any.
positionPointer context used by registered coordinate rules.
- classHeadlessCursorEngine
-
class HeadlessCursorEngine extends CursorEngineCursor adapter for environments that have no visible pointer.
constructor HeadlessCursorEngine(): HeadlessCursorEngineproperty readonly symbol: symbolstaticDI token for resolving HeadlessCursorEngine.
method apply(_token: CursorToken): voidApplies a transaction to HeadlessCursorEngine state.
method mount(_target: unknown): voidAttaches this adapter to its host surface.
method override(_token: CursorToken | null): voidApplies a temporary host cursor override.
method unmount(): voidDetaches this adapter from its host surface.
- classSheetCursorPlugin
-
class SheetCursorPlugin extends Plugin<SearCoreSheet, CellProperties, ISheetCursorState>Projects Sheet interaction state into host cursor behavior.
constructor SheetCursorPlugin(cursorRegistry: CursorRegistry, cursorEngine: CursorEngine, coordinates: CoordinateEngine, renderContext: RenderContext): SheetCursorPluginproperty readonly symbol: symbolstaticDI token for resolving SheetCursorPlugin.
method apply(_state: ISheetCursorState, _tx: Transaction): ISheetCursorState | nullApplies a transaction to SheetCursorPlugin state.
method getPluginConfig(): { }Returns the plugin config.
method onMouseMove(_searCore: SearCoreSheet, event: EventWithOffsetAndTarget<CellProperties>): voidReturns void (not false) so the event continues to propagate to downstream plugins (selection, editor, etc.). See Guide.md §8: returning false blocks subsequent plugins.
method registerState(): { key: PluginKey; state: { } }Registers the state.
method render(): nullReturns null: this plugin produces no scene nodes. Nothing is written to SceneGraph → DirtyTree, StickyRenderStrategy, and Hit Canvas are completely unaffected (Rule.md §1.4, §1.5).
Inherited members 29
Inherited from Plugin.
- depth
- documentState
- interestedIn
- pluginKey
- transactionHistory
- transactionOT
- warnOnDuplicateDepth
- key
- dirtyRect
- enforceRuntimeWriteBoundary
- enforceStateWriteBoundary
- getState
- hasStateWriteBoundary
- lockCommittedState
- onClick
- onDblClick
- onInitialDataCell
- onInitialDataComplete
- onMouseDown
- onMouseUp
- onResize
- onScroll
- onTransactionCommitted
- projectTransaction
- registerConfig
- sealRuntimeMetadata
- sealRuntimeMethods
- sealRuntimeWrites
- setState
- classWebCursorEngine
-
class WebCursorEngine extends CursorEngineBrowser CSS cursor implementation. Maps CursorToken to CSS cursor values (including SVG data URI custom cursors).
constructor WebCursorEngine(): WebCursorEnginemethod apply(token: CursorToken): voidApplies a transaction to WebCursorEngine state.
method mount(target: unknown): voidAttaches this adapter to its host surface.
method override(token: CursorToken | null): voidApplies a temporary host cursor override.
method registerToken(token: string, cssCursor: string): voidAllow third parties to extend or override Token → CSS mapping.
method unmount(): voidDetaches this adapter from its host surface.
Cursor rules
- interfaceCursorPosition
-
Pointer coordinates supplied to a position cursor rule for one pointer event.
property core: SearCoreSheetSheet core whose current data and interaction state may inform the cursor decision.
property origin: EventWithOffsetOriginal host pointer event.
property target: CellProperties | nullHit-tested cell properties, or null when the pointer is not over a scene node.
property view: { x: number; y: number }Pointer location relative to the rendered viewport.
property world: { x: number; y: number }Pointer location in scrollable sheet-world coordinates.
- interfacePositionCursorRule
-
Cursor rule evaluated from the pointer location rather than a hit node. Higher layers win over lower layers and all structural cursor rules. When multiple matching rules share the highest layer, the last registered rule wins and CursorRegistry reports the ambiguous registration once.
property cursor: CursorTokenLogical cursor presented while this rule owns the pointer.
property key: string | symbolStable owner key used for replacement, removal, and conflict diagnostics.
property kind: "position"property layer: numberPrecedence among position rules; larger values take precedence.
property test: (position: CursorPosition): booleanReturns whether this rule owns the supplied pointer location.
- interfacePredicateCursorRule
-
Fully custom predicate rule.
priority: 'high' → evaluated before region/type rules (e.g., isEdit override). priority: 'low' → evaluated after region/type rules as a fallback (default).
property cursor: CursorTokenproperty key?: string | symbolPredicates need an explicit key to replace a previous predicate rule.
property kind: "predicate"property priority?: "high" | "low"property test: (properties: CellProperties): boolean - interfaceRegionCursorRule
-
Exact region-match rule (highest priority among structural rules).
property cursor: CursorTokenproperty key?: string | symbolOptional extension key; defaults to the region identifier.
property kind: "region"property region: CellRegion - interfaceTypeCursorRule
-
Type-field match rule (secondary match).
property cellType: string | symbolproperty cursor: CursorTokenproperty key?: string | symbolOptional extension key; defaults to the cell type.
property kind: "type" - typeCursorRule
-
type CursorRule = RegionCursorRule | TypeCursorRule | PredicateCursorRule | PositionCursorRule - typeCursorToken
-
type CursorToken = typeof CursorToken[keyof typeof CursorToken] | string & { }CursorToken: { Cell: "cell"; ColumnResize: "col-resize"; ColumnSelect: "col-select"; Copy: "copy"; Default: "default"; Grab: "grab"; Grabbing: "grabbing"; Move: "move"; … }Built-in tokens plus an extension point for third-party plugins.
- variableCursorRuleKind
-
CursorRuleKind: { Position: "position"; Predicate: "predicate"; Region: "region"; Type: "type" } - variableCursorRulePriority
-
CursorRulePriority: { High: "high"; Low: "low" }
No matching API entries.