Skip to content

willow family ​

Presentation bindings from game records to willow nodes, and the pointer and key input bridge.

Import these from gamekit/src/willow (a few are also re-exported by the package root, as noted on each).

15 symbols, 0 of them also in the package root.

SymbolSummary
WillowBindingclass. Coordinates the WillowBinding presentation resource and its lifetime.
WillowBindingTicketclass. Coordinates the WillowBindingTicket presentation resource and its lifetime.
WillowInputBridgeclass. Adapts Willow pointer samples into explicit game-owned input offers.
WillowInputConsumerenum. Defines the closed willow input consumer value set.
WillowInputFrameclass. Carries WillowInputFrame state across the presentation-to-game boundary.
WillowInputInspectionclass. Carries WillowInputInspection state across the presentation-to-game boundary.
WillowInputOwnerclass. Carries WillowInputOwner state across the presentation-to-game boundary.
WillowInputTargetclass. Carries WillowInputTarget state across the presentation-to-game boundary.
WillowKeySampleclass. Represents the runtime willow key sample value and its explicit state.
WillowPointerPhaseenum. Defines the closed willow pointer phase value set.
WillowPointerSampleclass. Represents the runtime willow pointer sample value and its explicit state.
WillowPresentationclass. Coordinates the WillowPresentation presentation resource and its lifetime.
WillowPresentationAdapterclass. Coordinates the WillowPresentationAdapter presentation resource and its lifetime.
WillowPresentationStateclass. Coordinates the WillowPresentationState presentation resource and its lifetime.
WillowViewportclass. Represents the runtime willow viewport value and its explicit state.

WillowBinding ​

ts
import { WillowBinding } from "gamekit/src/willow";
class WillowBinding<T>

Coordinates the WillowBinding presentation resource and its lifetime.

Members

ts
constructor(adapter: any, record: T)

Initializes a willow binding with explicit dependencies.

  • adapter: Presentation adapter that creates and synchronizes the Willow node.
  • record: Initial game record retained until replacement, pooling, or disposal.
ts
get active(): boolean

Reports whether the binding participates in the next presentation pass.

  • Returns: True only in the active lifecycle state.
ts
get detached(): boolean

Reports whether the binding retains a node that has been removed from its parent.

  • Returns: True only after detach and before attach or another terminal transition.
ts
get pooled(): boolean

Reports whether the binding retains a detached node but no game record.

  • Returns: True only after pool and before reuse or disposal.
ts
get disposed(): boolean

Reports whether the binding has permanently released its node and record.

  • Returns: True after dispose; the state never becomes live again.
ts
get generation(): int

Exposes the revision used to invalidate asynchronous tickets.

  • Returns: A monotonically increasing revision changed by each lifecycle mutation.
ts
ticket(): WillowBindingTicket<T>

Captures the current generation for guarded asynchronous completion.

  • Returns: A ticket that applies callbacks only while this binding remains active at that generation.
ts
detach(): void

Removes the node from Willow while retaining it for a later attach.

  • Throws: Error When called on a pooled binding.
ts
attach(): void

Reactivates a detached binding; the next presentation pass reparents its node.

  • Throws: Error Unless the binding is detached and not disposed.
ts
pool(): void

Detaches the node, clears the record, and invalidates all outstanding tickets.

ts
reuse(record: T): void

Reactivates a pooled node for a new record and generation.

  • record: New record synchronized on the next presentation pass.
  • Throws: Error Unless the binding is pooled and not disposed.
ts
replace(record: T): void

Invalidates tickets and disposes the current node before adopting a replacement record.

  • record: Replacement record whose node is created on the next presentation pass.
  • Throws: Error When the binding is pooled or disposed.
ts
dispose(): void

Permanently releases the record and owned node; repeated calls do nothing.

WillowBindingTicket ​

ts
import { WillowBindingTicket } from "gamekit/src/willow";
class WillowBindingTicket<T>

Coordinates the WillowBindingTicket presentation resource and its lifetime.

Members

ts
constructor(binding: any, generation: int)

Initializes a willow binding ticket with explicit dependencies.

  • binding: Binding consulted when asynchronous work completes.
  • generation: Binding revision captured before that work began.
ts
apply(callback: Function): boolean

Guards a deferred node mutation against lifecycle and record changes.

  • callback: Function invoked as (node, record) only while the captured generation is live.
  • Returns: True when the callback ran; false when the ticket is stale or its binding is inactive.

WillowInputBridge ​

ts
import { WillowInputBridge } from "gamekit/src/willow";
class WillowInputBridge

Adapts Willow pointer samples into explicit game-owned input offers. Retain one bridge per presentation boundary and register targets in explicit priority order; it never owns a simulation World.

Members

ts
constructor(policy: InputPolicy | null = null)

Initializes WillowInputBridge with explicit dependencies and configuration.

  • policy: Optional neutral policy used to build action frames and process focus loss.
ts
register(target: WillowInputTarget): void

Adds a registration and rejects a duplicate live identity.

  • target: Target retained until explicitly unregistered.
  • Throws: Error When its id or priority is already registered, or its viewport is unknown.
ts
unregister(id: string): boolean

Removes a registration and releases any state it owns.

  • id: Target identifier to remove.
  • Returns: True when a target was removed; false when no registration matched.
ts
addViewport(viewport: WillowViewport): void

Registers a viewport for pointer projection and overlap selection.

  • viewport: Viewport retained until the bridge is released.
  • Throws: Error When its id or priority is already registered.
ts
pointer(sample: WillowPointerSample): WillowInputFrame

Routes one pointer sample to the highest eligible target and maintains capture. A DOWN sample captures its selected owner until UP or focus loss, so later samples cannot retarget mid-gesture.

  • sample: Willow-normalized pointer fact for this presentation frame.
  • Returns: Owner and offers for the selected target plus the neutral button sample.
ts
actionFrame(): ActionFrame | null

Builds a policy-resolved action frame from the core InputMap when a policy is configured.

  • Returns: The policy-resolved frame, or null when the bridge has no policy.
ts
focusLost(): ActionFrame | null

Cancels active captures and forwards focus loss to the input policy.

  • Returns: The policy's focus-loss frame, or null when no policy is configured.
ts
drainCancelled(): WillowInputOwner[]

Returns and clears the queued cancelled interaction owners.

  • Returns: Independent snapshots in cancellation order; a second drain is empty.
ts
inspect(): WillowInputInspection

Builds a copy suitable for diagnostic inspection.

  • Returns: Capture snapshots and registered ids that can be retained independently.

WillowInputConsumer ​

ts
import { WillowInputConsumer } from "gamekit/src/willow";
enum WillowInputConsumer

Defines the closed willow input consumer value set. Store and compare these values directly rather than introducing string aliases;

MemberMeaning
WORLD = "world"Input is offered to world presentation.
UI = "ui"Input is offered to ordinary interface controls.
MODAL = "modal"Input is offered to a blocking interface layer.
TEXT_ENTRY = "text-entry"Input is offered to editable text controls.
DEBUG = "debug"Input is offered to diagnostic controls.

WillowInputFrame ​

ts
import { WillowInputFrame } from "gamekit/src/willow";
class WillowInputFrame

Carries WillowInputFrame state across the presentation-to-game boundary.

Members

ts
owner: WillowInputOwner | null

Pointer capture owner selected for this frame, or null when no target matched.

ts
offers: any[]

Detached interaction offers returned by the selected target.

ts
sample: InputSample

Neutral input sample derived from the Willow pointer event.

ts
constructor(owner: WillowInputOwner | null, offers: any[], sample: InputSample)

Initializes a willow input frame with explicit dependencies.

  • owner: Selected pointer capture owner, copied when non-null.
  • offers: Interaction offers copied into the frame.
  • sample: Neutral input sample for the current presentation frame.

WillowInputInspection ​

ts
import { WillowInputInspection } from "gamekit/src/willow";
class WillowInputInspection

Carries WillowInputInspection state across the presentation-to-game boundary.

Members

ts
owners: WillowInputOwner[]

Snapshots of active pointer capture owners.

ts
targetIds: string[]

Registered target identifiers in bridge order.

ts
viewportIds: string[]

Registered viewport identifiers in bridge order.

ts
constructor(owners: WillowInputOwner[], targetIds: string[], viewportIds: string[])

Initializes a willow input inspection with explicit dependencies.

  • owners: Active capture snapshots prepared by the bridge.
  • targetIds: Registered target identifiers.
  • viewportIds: Registered viewport identifiers.

WillowInputOwner ​

ts
import { WillowInputOwner } from "gamekit/src/willow";
class WillowInputOwner

Carries WillowInputOwner state across the presentation-to-game boundary.

Members

ts
pointerId: int

Pointer identifier retained for the full capture lifetime.

ts
targetId: string

Identifier of the target that won capture.

ts
consumer: WillowInputConsumer

Consumer notified for this captured interaction.

ts
screen: Vec2

Most recent pointer position in screen coordinates.

ts
world: Vec2 | null

Most recent camera-projected position, or null outside a viewport.

ts
viewportId: string | null

Viewport used for world projection, or null when none matched.

ts
cancelled: boolean

WillowInputOwner: whether this interaction ended through cancellation.

ts
constructor(pointerId: int, targetId: string, consumer: WillowInputConsumer, screen: Vec2, world: Vec2 | null, viewportId: string | null, cancelled: boolean = false)

Initializes a willow input owner with explicit dependencies.

  • pointerId: Pointer identifier whose capture is represented.
  • targetId: Identifier of the target that won capture.
  • consumer: Recipient for interaction callbacks.
  • screen: Pointer position in screen coordinates; copied on construction.
  • world: Projected world position, or null; copied when present.
  • viewportId: Viewport used for projection, or null.
  • cancelled: True when focus loss cancelled the interaction.
ts
copy(): WillowInputOwner

Returns a snapshot with independent coordinate values.

  • Returns: A copy retaining the same consumer reference and capture facts.

WillowInputTarget ​

ts
import { WillowInputTarget } from "gamekit/src/willow";
class WillowInputTarget

Carries WillowInputTarget state across the presentation-to-game boundary.

Members

ts
id: string

Unique identifier used for registration and capture ownership.

ts
consumer: WillowInputConsumer

Consumer that receives interactions selected for this target.

ts
node: any

Willow node whose hit-test ancestry makes a sample eligible; null matches globally.

ts
priority: int

Explicit ordering priority; larger values win conflicts.

ts
viewportId: string | null

Viewport used to project matching pointer coordinates, or null.

ts
constructor(id: string, consumer: WillowInputConsumer, node: any, priority: int, viewportId: string | null = null, offersFor: Function | null = null)

Initializes a willow input target with explicit dependencies.

  • id: Non-empty registration and capture identifier.
  • consumer: Recipient for interactions selected for the target.
  • node: Willow hit-test node, or null to match every sample.
  • priority: Selection priority; larger values win.
  • viewportId: Optional viewport for world-coordinate projection.
  • offersFor: Optional callback returning offers for a newly captured owner.
  • Throws: Error When id is empty.
ts
matches(sample: WillowPointerSample): boolean

WillowInputTarget Tests whether the sample is eligible for this target.

  • sample: Pointer sample carrying the Willow hit ancestry.
  • Returns: True for a global target or when node appears in the hit ancestry.
ts
offers(owner: WillowInputOwner): any[]

Evaluates the optional offer factory for a captured interaction.

  • owner: Snapshot passed to the offer factory.
  • Returns: A detached offer list, or an empty list when no offers are available.

WillowKeySample ​

ts
import { WillowKeySample } from "gamekit/src/willow";
class WillowKeySample

Represents the runtime willow key sample value and its explicit state.

Members

ts
control: string

Neutral control name, conventionally Key.<keyCode> for Willow events.

ts
down: boolean

True for key-down and false for key-up.

ts
repeating: boolean

True when Willow marks the key event as an auto-repeat.

ts
constructor(control: string, down: boolean, repeating: boolean = false)

Initializes a willow key sample with explicit dependencies.

  • control: Non-empty neutral control name.
  • down: True for press and false for release.
  • repeating: Whether this is an auto-repeat event.
  • Throws: Error When control is empty.
ts
inputSample(): InputSample

Converts the key fact to the neutral input representation.

  • Returns: A keyboard sample with value 1 for down or 0 for up.
ts
static fromWillow(event: any, down: boolean): WillowKeySample

Adapts a Willow key event without retaining the event object.

  • event: Willow event exposing keyCode and repeat.
  • down: True for a key-down callback and false for key-up.
  • Returns: A sample named from the Willow key code.

WillowPointerPhase ​

ts
import { WillowPointerPhase } from "gamekit/src/willow";
enum WillowPointerPhase

Defines the closed willow pointer phase value set. Store and compare these values directly rather than introducing string aliases;

MemberMeaning
DOWN = "down"The pointer began contact.
MOVE = "move"The pointer moved while tracked.
UP = "up"The pointer ended contact.

WillowPointerSample ​

ts
import { WillowPointerSample } from "gamekit/src/willow";
class WillowPointerSample

Represents the runtime willow pointer sample value and its explicit state.

Members

ts
pointerId: int

Pointer identity used to maintain capture across event phases.

ts
phase: WillowPointerPhase

Current down, move, or up phase.

ts
screen: Vec2

Pointer position in Willow screen coordinates.

ts
button: int

Willow button number associated with the event.

ts
hit: any

Primary Willow hit target, or null when nothing was hit.

ts
hits: any[]

Hit-test ancestry used to select eligible input targets.

ts
constructor(pointerId: int, phase: WillowPointerPhase, screenX: float, screenY: float, button: int = 0, hit: any = null, hits: any[] = [])

Initializes a willow pointer sample with explicit dependencies.

  • pointerId: Pointer identity retained through capture.
  • phase: Current pointer event phase.
  • screenX: Horizontal screen coordinate.
  • screenY: Vertical screen coordinate.
  • button: Willow button number.
  • hit: Primary hit target, inserted into hits when absent.
  • hits: Hit ancestry copied into the sample.
ts
static fromWillow(event: any, phase: WillowPointerPhase, hits: any[] = []): WillowPointerSample

Adapts Willow pointer coordinates, button, and target without retaining the event.

  • event: Willow event exposing screenX, screenY, button, and target. The screen position is kept raw, because the bridge converts it to world through the viewport camera exactly once.
  • phase: Phase assigned by the callback that received the event.
  • hits: Hit ancestry supplied by the game integration.
  • Returns: A pointer-zero sample containing copies of the supplied hit list.
ts
inputSample(): InputSample

Converts the pointer button phase to the neutral input representation.

  • Returns: A device-specific button sample with value 0 on up and 1 otherwise.

WillowPresentation ​

ts
import { WillowPresentation } from "gamekit/src/willow";
class WillowPresentation<T>

Coordinates the WillowPresentation presentation resource and its lifetime.

Members

ts
constructor(adapter: WillowPresentationAdapter<T>, record: T)

Initializes a willow presentation with explicit dependencies.

  • adapter: Adapter that owns bindings and presentation passes.
  • record: Initial game record represented by the component.
ts
onAttach(owner: Entity): void

Creates, reattaches, or reuses the binding when the component enters an entity.

  • owner: Entity receiving the component; ownership itself remains with the ECS.
ts
onDetach(owner: Entity): void

Detaches the Willow node while preserving it for a later entity transfer.

  • owner: Entity releasing the component.
ts
onDispose(owner: Entity): void

Permanently disposes the binding when the owning entity is torn down.

  • owner: Entity whose component lifetime has ended.
ts
replace(record: T): void

Replaces the game record and invalidates any node created for the previous record.

  • record: Record to present on the next adapter pass.
ts
ticket(): WillowBindingTicket<T>

Captures the attached binding generation for guarded asynchronous work.

  • Returns: A ticket tied to the current record and lifecycle revision.
  • Throws: Error Before the component has attached to an entity.

WillowPresentationAdapter ​

ts
import { WillowPresentationAdapter } from "gamekit/src/willow";
class WillowPresentationAdapter<T>

Coordinates the WillowPresentationAdapter presentation resource and its lifetime.

Members

ts
constructor(createNode: Function, readState: Function, syncNode: Function | null = null)

Initializes a willow presentation adapter with explicit dependencies.

  • createNode: Factory called with a record when an active binding has no node.
  • readState: Callback returning transform and parent state for each presented record.
  • syncNode: Optional callback for content synchronization after transform state is copied.
ts
get disposed(): boolean

Reports whether all bindings have been disposed and future binds are forbidden.

  • Returns: True after the first call to dispose.
ts
bind(record: T): WillowBinding<T>

Associates supplied records with the caller's presentation factory.

  • record: Game record retained by the new binding.
  • Returns: An active binding whose node is created at the next presentation boundary.
  • Throws: Error After the adapter has been disposed.
ts
present(): void

Presents a snapshot of current bindings and then forgets disposed entries.

ts
dispose(): void

WillowPresentationAdapter Releases retained resources and makes later use invalid.

  • Throws: Error When the supplied value violates this operation’s preconditions.

WillowPresentationState ​

ts
import { WillowPresentationState } from "gamekit/src/willow";
class WillowPresentationState

Coordinates the WillowPresentationState presentation resource and its lifetime.

Members

ts
parent: any

Willow container that should own the presented node.

ts
x: float = 0.0

Horizontal position in parent coordinates.

ts
y: float = 0.0

Vertical position in parent coordinates.

ts
rotation: float = 0.0

Node rotation forwarded to Willow.

ts
scaleX: float = 1.0

Horizontal scale factor; defaults to 1.

ts
scaleY: float = 1.0

Vertical scale factor; defaults to 1.

ts
pivotX: float = 0.0

Horizontal transform pivot in node coordinates.

ts
pivotY: float = 0.0

Vertical transform pivot in node coordinates.

ts
skewX: float = 0.0

Horizontal skew forwarded to Willow.

ts
skewY: float = 0.0

Vertical skew forwarded to Willow.

ts
alpha: float = 1.0

Opacity forwarded to Willow; defaults to fully opaque.

ts
visible: boolean = true

Whether Willow should render the node.

ts
zOrder: int = 0

Sibling ordering value forwarded to Willow.

ts
constructor(parent: any)

Initializes a willow presentation state with explicit dependencies.

  • parent: Willow container that receives the node during presentation.

WillowViewport ​

ts
import { WillowViewport } from "gamekit/src/willow";
class WillowViewport

Represents the runtime willow viewport value and its explicit state.

Members

ts
id: string

Unique identifier referenced by input targets and capture owners.

ts
screen: Rect

Screen-space rectangle in which this viewport participates.

ts
camera: Camera2D

Camera used to project matching screen coordinates into world space.

ts
priority: int

Explicit ordering priority; larger values win conflicts.

ts
constructor(id: string, screen: Rect, camera: Camera2D, priority: int)

Initializes a willow viewport with explicit dependencies.

  • id: Non-empty viewport identifier.
  • screen: Screen-space bounds copied into the viewport.
  • camera: Camera retained for coordinate projection.
  • priority: Selection priority; larger values win overlaps.
  • Throws: Error When id is empty.
ts
contains(point: Vec2): boolean

Tests a point against the inclusive screen-space bounds.

  • point: Screen-space coordinate to test.
  • Returns: True when both coordinates lie on or inside the rectangle edges.