weasel API - v0.8.0
    Preparing search index...

    Interface SceneToAdapterOptions<TData, TLayer, TPose>

    Optional extras for the synthesized adapter. Pass commitInsert to wire the insert gesture into a Scene-owned canvas; the returned object becomes a leaf on the layer named by layer (default 'default').

    interface SceneToAdapterOptions<TData, TLayer extends string, TPose> {
        cascadeContainerPose?:
            | "rect"
            | ((pose: TPose, dx: number, dy: number) => TPose);
        commitInsert?: (
            bounds: Bounds,
        ) => { data: TData; id?: string; pose: TPose } | null;
        insertLayer?: TLayer;
        layouts?:
            | Record<string, LayoutStrategy<TPose>>
            | ((containerId: string) => LayoutStrategy<TPose> | null);
        poseBounds?: (pose: TPose) => Bounds;
        selection?: SceneAdapterSelection;
    }

    Type Parameters

    • TData
    • TLayer extends string
    • TPose
    Index

    Properties

    cascadeContainerPose?: "rect" | ((pose: TPose, dx: number, dy: number) => TPose)

    When set, setPose(id, ...) on a container node cascades the translation to every descendant. Scene v1 stores absolute poses, so dragging a container needs to translate its children to keep them visually attached to their parent. Pass 'rect' to use the built-in translateRectPose (works for any TPose extends { x: number; y: number }); pass a custom (pose, dx, dy) => pose for non-rect pose shapes. Omit to leave setPose primitive — containers move but their descendants don't follow.

    commitInsert?: (
        bounds: Bounds,
    ) => { data: TData; id?: string; pose: TPose } | null

    Factory for new objects. Returning null aborts the insert.

    insertLayer?: TLayer

    Layer to place inserted nodes on. Defaults to the trivial-form layer.

    layouts?:
        | Record<string, LayoutStrategy<TPose>>
        | ((containerId: string) => LayoutStrategy<TPose> | null)

    Layout strategies keyed by container node id. When a container is configured here, move runs its layout-aware pass on drag (reflow on enter, reflow leftovers on exit, reparent + write reflowed poses on commit). Containers without an entry behave as plain parents. Pass either a static map, or a getLayout(id) function for dynamic resolution.

    poseBounds?: (pose: TPose) => Bounds

    Project a pose to an AABB for hitTestArea. Default: identity (works when TPose carries top-level x/y/width/height). Override for non-rect poses.

    Selection source for AreaSelectAdapter.getSelection / setSelection. Pass the result of useSelection() (or its adapterMethods). When omitted, getSelection returns [] and setSelection is a noop — fine for read-only or selection-less canvases, but the marquee gesture won't update any external selection state.