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.
| Symbol | Summary |
|---|---|
WillowBinding | class. Coordinates the WillowBinding presentation resource and its lifetime. |
WillowBindingTicket | class. Coordinates the WillowBindingTicket presentation resource and its lifetime. |
WillowInputBridge | class. Adapts Willow pointer samples into explicit game-owned input offers. |
WillowInputConsumer | enum. Defines the closed willow input consumer value set. |
WillowInputFrame | class. Carries WillowInputFrame state across the presentation-to-game boundary. |
WillowInputInspection | class. Carries WillowInputInspection state across the presentation-to-game boundary. |
WillowInputOwner | class. Carries WillowInputOwner state across the presentation-to-game boundary. |
WillowInputTarget | class. Carries WillowInputTarget state across the presentation-to-game boundary. |
WillowKeySample | class. Represents the runtime willow key sample value and its explicit state. |
WillowPointerPhase | enum. Defines the closed willow pointer phase value set. |
WillowPointerSample | class. Represents the runtime willow pointer sample value and its explicit state. |
WillowPresentation | class. Coordinates the WillowPresentation presentation resource and its lifetime. |
WillowPresentationAdapter | class. Coordinates the WillowPresentationAdapter presentation resource and its lifetime. |
WillowPresentationState | class. Coordinates the WillowPresentationState presentation resource and its lifetime. |
WillowViewport | class. 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(): booleanReports whether the binding participates in the next presentation pass.
- Returns: True only in the active lifecycle state.
ts
get detached(): booleanReports whether the binding retains a node that has been removed from its parent.
- Returns: True only after
detachand beforeattachor another terminal transition.
ts
get pooled(): booleanReports whether the binding retains a detached node but no game record.
- Returns: True only after
pooland beforereuseor disposal.
ts
get disposed(): booleanReports whether the binding has permanently released its node and record.
- Returns: True after
dispose; the state never becomes live again.
ts
get generation(): intExposes 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(): voidRemoves the node from Willow while retaining it for a later attach.
- Throws: Error When called on a pooled binding.
ts
attach(): voidReactivates a detached binding; the next presentation pass reparents its node.
- Throws: Error Unless the binding is detached and not disposed.
ts
pool(): voidDetaches the node, clears the record, and invalidates all outstanding tickets.
ts
reuse(record: T): voidReactivates 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): voidInvalidates 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(): voidPermanently 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): booleanGuards 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 WillowInputBridgeAdapts 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): voidAdds 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): booleanRemoves 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): voidRegisters 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): WillowInputFrameRoutes 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 | nullBuilds 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 | nullCancels 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(): WillowInputInspectionBuilds 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 WillowInputConsumerDefines the closed willow input consumer value set. Store and compare these values directly rather than introducing string aliases;
| Member | Meaning |
|---|---|
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 WillowInputFrameCarries WillowInputFrame state across the presentation-to-game boundary.
Members
ts
owner: WillowInputOwner | nullPointer 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: InputSampleNeutral 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 WillowInputInspectionCarries 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 WillowInputOwnerCarries WillowInputOwner state across the presentation-to-game boundary.
Members
ts
pointerId: intPointer identifier retained for the full capture lifetime.
ts
targetId: stringIdentifier of the target that won capture.
ts
consumer: WillowInputConsumerConsumer notified for this captured interaction.
ts
screen: Vec2Most recent pointer position in screen coordinates.
ts
world: Vec2 | nullMost recent camera-projected position, or null outside a viewport.
ts
viewportId: string | nullViewport used for world projection, or null when none matched.
ts
cancelled: booleanWillowInputOwner: 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(): WillowInputOwnerReturns 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 WillowInputTargetCarries WillowInputTarget state across the presentation-to-game boundary.
Members
ts
id: stringUnique identifier used for registration and capture ownership.
ts
consumer: WillowInputConsumerConsumer that receives interactions selected for this target.
ts
node: anyWillow node whose hit-test ancestry makes a sample eligible; null matches globally.
ts
priority: intExplicit ordering priority; larger values win conflicts.
ts
viewportId: string | nullViewport 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
idis empty.
ts
matches(sample: WillowPointerSample): booleanWillowInputTarget 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
nodeappears 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 WillowKeySampleRepresents the runtime willow key sample value and its explicit state.
Members
ts
control: stringNeutral control name, conventionally Key.<keyCode> for Willow events.
ts
down: booleanTrue for key-down and false for key-up.
ts
repeating: booleanTrue 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
controlis empty.
ts
inputSample(): InputSampleConverts 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): WillowKeySampleAdapts a Willow key event without retaining the event object.
event: Willow event exposingkeyCodeandrepeat.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 WillowPointerPhaseDefines the closed willow pointer phase value set. Store and compare these values directly rather than introducing string aliases;
| Member | Meaning |
|---|---|
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 WillowPointerSampleRepresents the runtime willow pointer sample value and its explicit state.
Members
ts
pointerId: intPointer identity used to maintain capture across event phases.
ts
phase: WillowPointerPhaseCurrent down, move, or up phase.
ts
screen: Vec2Pointer position in Willow screen coordinates.
ts
button: intWillow button number associated with the event.
ts
hit: anyPrimary 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 intohitswhen absent.hits: Hit ancestry copied into the sample.
ts
static fromWillow(event: any, phase: WillowPointerPhase, hits: any[] = []): WillowPointerSampleAdapts Willow pointer coordinates, button, and target without retaining the event.
event: Willow event exposingscreenX,screenY,button, andtarget. 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(): InputSampleConverts 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): voidCreates, 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): voidDetaches the Willow node while preserving it for a later entity transfer.
owner: Entity releasing the component.
ts
onDispose(owner: Entity): voidPermanently disposes the binding when the owning entity is torn down.
owner: Entity whose component lifetime has ended.
ts
replace(record: T): voidReplaces 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(): booleanReports 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(): voidPresents a snapshot of current bindings and then forgets disposed entries.
ts
dispose(): voidWillowPresentationAdapter 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 WillowPresentationStateCoordinates the WillowPresentationState presentation resource and its lifetime.
Members
ts
parent: anyWillow container that should own the presented node.
ts
x: float = 0.0Horizontal position in parent coordinates.
ts
y: float = 0.0Vertical position in parent coordinates.
ts
rotation: float = 0.0Node rotation forwarded to Willow.
ts
scaleX: float = 1.0Horizontal scale factor; defaults to 1.
ts
scaleY: float = 1.0Vertical scale factor; defaults to 1.
ts
pivotX: float = 0.0Horizontal transform pivot in node coordinates.
ts
pivotY: float = 0.0Vertical transform pivot in node coordinates.
ts
skewX: float = 0.0Horizontal skew forwarded to Willow.
ts
skewY: float = 0.0Vertical skew forwarded to Willow.
ts
alpha: float = 1.0Opacity forwarded to Willow; defaults to fully opaque.
ts
visible: boolean = trueWhether Willow should render the node.
ts
zOrder: int = 0Sibling 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 WillowViewportRepresents the runtime willow viewport value and its explicit state.
Members
ts
id: stringUnique identifier referenced by input targets and capture owners.
ts
screen: RectScreen-space rectangle in which this viewport participates.
ts
camera: Camera2DCamera used to project matching screen coordinates into world space.
ts
priority: intExplicit 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
idis empty.
ts
contains(point: Vec2): booleanTests 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.