@flighthq/node 0.5.1-next.3259.c391c1c → 0.5.1-next.3269.831c174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/boundsRectangle.d.ts +12 -12
- package/dist/hasBoundsRectangle.d.ts +3 -3
- package/dist/hierarchy.d.ts +22 -22
- package/dist/node.d.ts +10 -10
- package/dist/nodeColorAdjustment.d.ts +4 -4
- package/dist/nodeOrderList.d.ts +16 -16
- package/dist/nodeTransform2d.d.ts +9 -9
- package/dist/nodeTransform3d.d.ts +11 -11
- package/dist/revision.d.ts +17 -17
- package/dist/stageFit.d.ts +2 -2
- package/dist/traversal.d.ts +11 -11
- package/package.json +9 -9
- package/src/hierarchy.test.ts +8 -8
- package/src/node.test.ts +2 -2
- package/src/nodeOrderList.test.ts +5 -5
- package/src/stageFit.test.ts +3 -3
- package/src/traversal.test.ts +17 -17
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/node`. The `@flighth
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/node@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/node@0.5.1-next.3269.831c174](https://github.com/flighthq/flight/tree/831c174bfb28953d8f2cebaefa5a2743e35045e3/packages/node)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/831c174bfb28953d8f2cebaefa5a2743e35045e3/LICENSE.md)
|
|
@@ -3,7 +3,7 @@ import type { BoundsNode, Rectangle, RectangleLike, Spatial2DNode } from '@fligh
|
|
|
3
3
|
* Writes a rectangle which defines the area of the scene node
|
|
4
4
|
* relative to the coordinate system of the `targetCoordinateSpace` object.
|
|
5
5
|
**/
|
|
6
|
-
export declare function computeNodeBoundsRectangle<
|
|
6
|
+
export declare function computeNodeBoundsRectangle<Fields extends object>(out: RectangleLike, source: Spatial2DNode<Fields>, targetCoordinateSpace: Spatial2DNode<Fields> | null | undefined): void;
|
|
7
7
|
/**
|
|
8
8
|
* Writes the tight bounds of `root` and its enabled descendants in a coordinate system where the
|
|
9
9
|
* root's own local transform is identity. A child's transform is still relative to the root and
|
|
@@ -14,24 +14,24 @@ export declare function computeNodeBoundsRectangle<Traits extends object>(out: R
|
|
|
14
14
|
* rotation. Offscreen subtree capture uses this contract together with
|
|
15
15
|
* computeScene2DRenderTargetTransform so the root transform cancels exactly.
|
|
16
16
|
*/
|
|
17
|
-
export declare function computeNodeRootLocalBoundsRectangle<
|
|
18
|
-
export declare function ensureNodeLocalBoundsRectangle<
|
|
19
|
-
export declare function ensureNodeParentBoundsRectangle<
|
|
20
|
-
export declare function ensureNodeWorldBoundsRectangle<
|
|
21
|
-
export declare function getNodeHeight<
|
|
17
|
+
export declare function computeNodeRootLocalBoundsRectangle<Fields extends object>(out: RectangleLike, root: Spatial2DNode<Fields>): void;
|
|
18
|
+
export declare function ensureNodeLocalBoundsRectangle<Fields extends object>(target: BoundsNode<Fields>): void;
|
|
19
|
+
export declare function ensureNodeParentBoundsRectangle<Fields extends object>(target: Spatial2DNode<Fields>): void;
|
|
20
|
+
export declare function ensureNodeWorldBoundsRectangle<Fields extends object>(target: Spatial2DNode<Fields>): void;
|
|
21
|
+
export declare function getNodeHeight<Fields extends object>(source: Spatial2DNode<Fields>): number;
|
|
22
22
|
/**
|
|
23
23
|
* Object's own bounds (not including children)
|
|
24
24
|
*/
|
|
25
|
-
export declare function getNodeLocalBoundsRectangle<
|
|
25
|
+
export declare function getNodeLocalBoundsRectangle<Fields extends object>(target: BoundsNode<Fields>): Readonly<Rectangle>;
|
|
26
26
|
/**
|
|
27
27
|
* localBoundsRectangle * localTransform
|
|
28
28
|
*/
|
|
29
|
-
export declare function getNodeParentBoundsRectangle<
|
|
30
|
-
export declare function getNodeWidth<
|
|
29
|
+
export declare function getNodeParentBoundsRectangle<Fields extends object>(target: Spatial2DNode<Fields>): Readonly<Rectangle>;
|
|
30
|
+
export declare function getNodeWidth<Fields extends object>(source: Spatial2DNode<Fields>): number;
|
|
31
31
|
/**
|
|
32
32
|
* Object's bounds in world space (including children)
|
|
33
33
|
*/
|
|
34
|
-
export declare function getNodeWorldBoundsRectangle<
|
|
35
|
-
export declare function setNodeHeight<
|
|
36
|
-
export declare function setNodeWidth<
|
|
34
|
+
export declare function getNodeWorldBoundsRectangle<Fields extends object>(target: Spatial2DNode<Fields>): Readonly<Rectangle>;
|
|
35
|
+
export declare function setNodeHeight<Fields extends object>(target: Spatial2DNode<Fields>, value: number): void;
|
|
36
|
+
export declare function setNodeWidth<Fields extends object>(target: Spatial2DNode<Fields>, value: number): void;
|
|
37
37
|
//# sourceMappingURL=boundsRectangle.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BoundsNode, HasBoundsRectangle, HasBoundsRectangleRuntime, MethodsOf,
|
|
2
|
-
export declare function defaultComputeLocalBoundsRectangle<
|
|
3
|
-
export declare function initBoundsRectangleRuntimeTrait<
|
|
1
|
+
import type { BoundsNode, HasBoundsRectangle, HasBoundsRectangleRuntime, MethodsOf, NodeFields, Rectangle } from '@flighthq/types/contract';
|
|
2
|
+
export declare function defaultComputeLocalBoundsRectangle<Fields extends object = NodeFields>(_out: Rectangle, _source: Readonly<BoundsNode<Fields>>): void;
|
|
3
|
+
export declare function initBoundsRectangleRuntimeTrait<Fields extends object = NodeFields>(target: HasBoundsRectangleRuntime<Fields>, methods?: Readonly<Partial<MethodsOf<HasBoundsRectangleRuntime<Fields>> & Pick<HasBoundsRectangleRuntime<Fields>, 'isLocalBoundsRectangleValid'>>>): void;
|
|
4
4
|
export declare function initBoundsRectangleTrait(_target: HasBoundsRectangle, _obj?: Readonly<Partial<HasBoundsRectangle>>): void;
|
|
5
5
|
//# sourceMappingURL=hasBoundsRectangle.d.ts.map
|
package/dist/hierarchy.d.ts
CHANGED
|
@@ -4,66 +4,66 @@ import type { Node, NodeOf, Transform2DNode } from '@flighthq/types/contract';
|
|
|
4
4
|
* instance. The child is added to the front (top) of all other children in
|
|
5
5
|
* this Node instance.
|
|
6
6
|
**/
|
|
7
|
-
export declare function addNodeChild<
|
|
7
|
+
export declare function addNodeChild<Fields extends object>(target: Node<Fields>, child: Node<Fields>): NodeOf<Fields>;
|
|
8
8
|
/**
|
|
9
9
|
* Adds a child Node instance to this Node
|
|
10
10
|
* instance. The child is added at the index position specified. An index of
|
|
11
11
|
* 0 represents the back (bottom) of the display list for this
|
|
12
12
|
* Node object.
|
|
13
13
|
**/
|
|
14
|
-
export declare function addNodeChildAt<
|
|
14
|
+
export declare function addNodeChildAt<Fields extends object>(target: Node<Fields>, child: Node<Fields>, index: number): NodeOf<Fields>;
|
|
15
15
|
/**
|
|
16
16
|
* Adds multiple children to `target` in order, appending each after the last. Equivalent to
|
|
17
17
|
* calling `addNodeChild` for each child but signals are still emitted per child.
|
|
18
18
|
*/
|
|
19
|
-
export declare function addNodeChildren<
|
|
19
|
+
export declare function addNodeChildren<Fields extends object>(target: Node<Fields>, ...children: Node<Fields>[]): void;
|
|
20
20
|
/**
|
|
21
21
|
* Determines whether the specified scene node is a child of the
|
|
22
22
|
* NodeContainer instance or the instance itself.
|
|
23
23
|
**/
|
|
24
|
-
export declare function containsNodeChild<
|
|
24
|
+
export declare function containsNodeChild<Fields extends object>(source: Readonly<Node<Fields>>, child: Readonly<Node<Fields>>): boolean;
|
|
25
25
|
/**
|
|
26
26
|
* Calls `callback` for each direct child of `source` in index order (back to front).
|
|
27
27
|
* Stops early if `callback` returns `false`.
|
|
28
28
|
*/
|
|
29
|
-
export declare function forEachNodeChild<
|
|
29
|
+
export declare function forEachNodeChild<Fields extends object>(source: Readonly<Node<Fields>>, callback: (child: Node<Fields>, index: number) => boolean | void): void;
|
|
30
30
|
/**
|
|
31
31
|
* Returns a read-only snapshot of all ancestors of `source`, from immediate parent toward the
|
|
32
32
|
* root. The source node itself is not included.
|
|
33
33
|
*/
|
|
34
|
-
export declare function getNodeAncestors<
|
|
34
|
+
export declare function getNodeAncestors<Fields extends object>(source: Readonly<Node<Fields>>): readonly NodeOf<Fields>[];
|
|
35
35
|
/**
|
|
36
36
|
* Returns the child scene node instance that exists at the specified
|
|
37
37
|
* index.
|
|
38
38
|
**/
|
|
39
|
-
export declare function getNodeChildAt<
|
|
39
|
+
export declare function getNodeChildAt<Fields extends object>(source: Readonly<Node<Fields>>, index: number): NodeOf<Fields> | null;
|
|
40
40
|
/**
|
|
41
41
|
* Returns the child scene node that exists with the specified name. If
|
|
42
42
|
* more that one child scene node has the specified name, the method
|
|
43
43
|
* returns the first object found.
|
|
44
44
|
**/
|
|
45
|
-
export declare function getNodeChildByName<
|
|
46
|
-
export declare function getNodeChildCount<
|
|
45
|
+
export declare function getNodeChildByName<Fields extends object>(source: Readonly<Node<Fields>>, name: string): NodeOf<Fields> | null;
|
|
46
|
+
export declare function getNodeChildCount<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
47
47
|
/**
|
|
48
48
|
* Returns the index position of a `child` Node instance.
|
|
49
49
|
**/
|
|
50
|
-
export declare function getNodeChildIndex<
|
|
50
|
+
export declare function getNodeChildIndex<Fields extends object>(source: Readonly<Node<Fields>>, child: Readonly<Node<Fields>>): number;
|
|
51
51
|
/**
|
|
52
52
|
* Returns the lowest common ancestor of `a` and `b`, or `null` if they share no common ancestor.
|
|
53
53
|
* If one node is an ancestor of the other, that ancestor is returned.
|
|
54
54
|
*/
|
|
55
|
-
export declare function getNodeCommonAncestor<
|
|
56
|
-
export declare function getNodeParent<
|
|
55
|
+
export declare function getNodeCommonAncestor<Fields extends object>(a: Readonly<Node<Fields>>, b: Readonly<Node<Fields>>): NodeOf<Fields> | null;
|
|
56
|
+
export declare function getNodeParent<Fields extends object>(source: Readonly<Node<Fields>>): NodeOf<Fields> | null;
|
|
57
57
|
/**
|
|
58
58
|
* Returns the topmost ancestor of the node, or the node itself if it has no
|
|
59
59
|
* parent.
|
|
60
60
|
**/
|
|
61
|
-
export declare function getNodeRoot<
|
|
61
|
+
export declare function getNodeRoot<Fields extends object>(source: Readonly<Node<Fields>>): NodeOf<Fields>;
|
|
62
62
|
/**
|
|
63
63
|
* Returns `true` if `ancestor` is the same node as `descendant` or is located above
|
|
64
64
|
* `descendant` in the hierarchy.
|
|
65
65
|
*/
|
|
66
|
-
export declare function isNodeAncestorOf<
|
|
66
|
+
export declare function isNodeAncestorOf<Fields extends object>(ancestor: Readonly<Node<Fields>>, descendant: Readonly<Node<Fields>>): boolean;
|
|
67
67
|
/**
|
|
68
68
|
* Removes the specified `child` Node instance from the
|
|
69
69
|
* child list of the Node instance. The `parent`
|
|
@@ -72,7 +72,7 @@ export declare function isNodeAncestorOf<Traits extends object>(ancestor: Readon
|
|
|
72
72
|
* positions of any scene nodes above the child in the
|
|
73
73
|
* Node are decreased by 1.
|
|
74
74
|
**/
|
|
75
|
-
export declare function removeNodeChild<
|
|
75
|
+
export declare function removeNodeChild<Fields extends object>(target: Node<Fields>, child: Node<Fields>): NodeOf<Fields>;
|
|
76
76
|
/**
|
|
77
77
|
* Removes a child Node from the specified `index`
|
|
78
78
|
* position in the child list of the Node. The
|
|
@@ -81,13 +81,13 @@ export declare function removeNodeChild<Traits extends object>(target: Node<Trai
|
|
|
81
81
|
* references to the child exist. The index positions of any scene nodes
|
|
82
82
|
* above the child in the Node are decreased by 1.
|
|
83
83
|
**/
|
|
84
|
-
export declare function removeNodeChildAt<
|
|
84
|
+
export declare function removeNodeChildAt<Fields extends object>(target: Node<Fields>, index: number): NodeOf<Fields> | null;
|
|
85
85
|
/**
|
|
86
86
|
* Removes all `child` Node instances from the child list of the Node
|
|
87
87
|
* instance. The `parent` property of the removed children is set to `null`, and the objects are
|
|
88
88
|
* garbage collected if no other references to the children exist.
|
|
89
89
|
**/
|
|
90
|
-
export declare function removeNodeChildren<
|
|
90
|
+
export declare function removeNodeChildren<Fields extends object>(target: Node<Fields>, beginIndex?: number, endIndex?: number): void;
|
|
91
91
|
/**
|
|
92
92
|
* Moves a child to a new parent while preserving its world-space position, and reports whether it
|
|
93
93
|
* did. The child's local transform fields are recomputed so its effective world transform remains
|
|
@@ -104,18 +104,18 @@ export declare function removeNodeChildren<Traits extends object>(target: Node<T
|
|
|
104
104
|
* To reparent without preserving world position (keeping local TRS unchanged), use addNodeChild
|
|
105
105
|
* instead — that is also the composition to reach for when a caller wants the attachment regardless.
|
|
106
106
|
*/
|
|
107
|
-
export declare function reparentNode<
|
|
107
|
+
export declare function reparentNode<Fields extends object>(child: Transform2DNode<Fields>, newParent: Transform2DNode<Fields>): boolean;
|
|
108
108
|
/**
|
|
109
109
|
* Replaces `oldChild` with `newChild` at the same index position in `target`'s children. If
|
|
110
110
|
* `oldChild` is not a child of `target`, this is a no-op. If `newChild` is already a child of
|
|
111
111
|
* `target`, it is moved to `oldChild`'s index.
|
|
112
112
|
*/
|
|
113
|
-
export declare function replaceNodeChild<
|
|
113
|
+
export declare function replaceNodeChild<Fields extends object>(target: Node<Fields>, oldChild: Node<Fields>, newChild: Node<Fields>): void;
|
|
114
114
|
/**
|
|
115
115
|
* Changes the position of an existing child in the scene node container.
|
|
116
116
|
* This affects the layering of child objects.
|
|
117
117
|
**/
|
|
118
|
-
export declare function setNodeChildIndex<
|
|
118
|
+
export declare function setNodeChildIndex<Fields extends object>(target: Node<Fields>, child: Node<Fields>, index: number): void;
|
|
119
119
|
export declare function setReparentNodeGuard(guard: ((child: Node, newParent: Node) => void) | null): void;
|
|
120
120
|
/**
|
|
121
121
|
* Recursively stops the timeline execution of all MovieClips rooted at this object.
|
|
@@ -125,11 +125,11 @@ export declare function setReparentNodeGuard(guard: ((child: Node, newParent: No
|
|
|
125
125
|
* objects. All other child objects in the scene node container remain in
|
|
126
126
|
* the same index positions.
|
|
127
127
|
**/
|
|
128
|
-
export declare function swapNodeChildren<
|
|
128
|
+
export declare function swapNodeChildren<Fields extends object>(target: Node<Fields>, child1: Node<Fields>, child2: Node<Fields>): void;
|
|
129
129
|
/**
|
|
130
130
|
* Swaps the z-order (front-to-back order) of the child objects at the two
|
|
131
131
|
* specified index positions in the child list. All other child objects in
|
|
132
132
|
* the scene node container remain in the same index positions.
|
|
133
133
|
**/
|
|
134
|
-
export declare function swapNodeChildrenAt<
|
|
134
|
+
export declare function swapNodeChildrenAt<Fields extends object>(target: Node<Fields>, index1: number, index2: number): void;
|
|
135
135
|
//# sourceMappingURL=hierarchy.d.ts.map
|
package/dist/node.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { EntityConstruction, Kind, MethodsOf, Node, NodeData, NodeDataFactory, NodeRuntime, NodeRuntimeFactory, NodeSignals,
|
|
2
|
-
export declare function createNode<
|
|
3
|
-
export declare function createNodeRuntime<
|
|
1
|
+
import type { EntityConstruction, Kind, MethodsOf, Node, NodeData, NodeDataFactory, NodeRuntime, NodeRuntimeFactory, NodeSignals, NodeFields, PartialNode } from '@flighthq/types/contract';
|
|
2
|
+
export declare function createNode<Fields extends object = NodeFields, Data extends NodeData = NodeData, Runtime extends NodeRuntime<Fields> = NodeRuntime<Fields>>(nodeKind: Kind, obj?: Readonly<PartialNode<Node<Fields>>>, createData?: NodeDataFactory<Data>, createNodeRuntimeFactory?: NodeRuntimeFactory<Runtime>): Node<Fields> & Fields;
|
|
3
|
+
export declare function createNodeRuntime<Fields extends object = NodeFields>(methods?: Readonly<Partial<MethodsOf<NodeRuntime<Fields>>>>): NodeRuntime<Fields>;
|
|
4
4
|
export declare function createNodeSignals(): NodeSignals;
|
|
5
|
-
export declare function defaultNodeRuntimeCanAddChild<
|
|
5
|
+
export declare function defaultNodeRuntimeCanAddChild<Fields extends object>(_target: Node<Fields>, _child: Node<Fields>): boolean;
|
|
6
6
|
/**
|
|
7
7
|
* Detaches `target` from its parent, recursively removes all descendants, and clears the
|
|
8
8
|
* `nodeSignals` and `interactionSignals` registries so the node becomes eligible for garbage
|
|
@@ -13,11 +13,11 @@ export declare function defaultNodeRuntimeCanAddChild<Traits extends object>(_ta
|
|
|
13
13
|
* resources (render proxies, GPU textures) should call `disposeNode` first and then release those
|
|
14
14
|
* resources themselves.
|
|
15
15
|
*/
|
|
16
|
-
export declare function disposeNode<
|
|
17
|
-
export declare function enableNodeSignals<
|
|
18
|
-
export declare function getNodeRuntime<
|
|
19
|
-
export declare function getNodeSignals<
|
|
20
|
-
export declare function initializeNode<
|
|
16
|
+
export declare function disposeNode<Fields extends object = NodeFields>(target: Node<Fields>): void;
|
|
17
|
+
export declare function enableNodeSignals<Fields extends object = NodeFields>(source: Node<Fields>): NodeSignals;
|
|
18
|
+
export declare function getNodeRuntime<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>): Readonly<NodeRuntime<Fields>>;
|
|
19
|
+
export declare function getNodeSignals<Fields extends object = NodeFields>(source: Node<Fields>): NodeSignals | null;
|
|
20
|
+
export declare function initializeNode<Fields extends object = NodeFields, Data extends NodeData = NodeData, Runtime extends NodeRuntime<Fields> = NodeRuntime<Fields>>(out: EntityConstruction<Node<Fields> & Fields>, nodeKind: Kind, obj?: Readonly<PartialNode<Node<Fields>>>, createData?: NodeDataFactory<Data>, createNodeRuntimeFactory?: NodeRuntimeFactory<Runtime>): void;
|
|
21
21
|
export declare function initializeNodeSignals(out: EntityConstruction<NodeSignals>): void;
|
|
22
|
-
export declare function setNodeEnabled<
|
|
22
|
+
export declare function setNodeEnabled<Fields extends object = NodeFields>(target: Node<Fields>, value: boolean): void;
|
|
23
23
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -5,16 +5,16 @@ import type { Adjustment, Node } from '@flighthq/types/contract';
|
|
|
5
5
|
* For explicit per-channel scale/bias authoring, use
|
|
6
6
|
* `createColorScaleBiasAdjustment` from `@flighthq/adjustments`.
|
|
7
7
|
*/
|
|
8
|
-
export declare function addNodeColorAdjustment<
|
|
8
|
+
export declare function addNodeColorAdjustment<Fields extends object>(source: Node<Fields>, adjustment: Adjustment): void;
|
|
9
9
|
/** Returns the complete authored adjustment stack, or null for the untinted default. */
|
|
10
|
-
export declare function getNodeColorAdjustments<
|
|
10
|
+
export declare function getNodeColorAdjustments<Fields extends object>(source: Readonly<Node<Fields>>): readonly Adjustment[] | null;
|
|
11
11
|
/**
|
|
12
12
|
* Replaces the complete pointwise adjustment stack; null clears it.
|
|
13
13
|
*
|
|
14
14
|
* Tint's golden path is `setNodeColorAdjustmentsTint`. Use `createColorScaleBiasAdjustment` for
|
|
15
15
|
* explicit per-channel `out = in * scale + bias` values with normalized-linear bias.
|
|
16
16
|
*/
|
|
17
|
-
export declare function setNodeColorAdjustments<
|
|
17
|
+
export declare function setNodeColorAdjustments<Fields extends object>(source: Node<Fields>, value: readonly Adjustment[] | null): void;
|
|
18
18
|
/** Replaces the complete stack with one packed-RGBA tint adjustment. */
|
|
19
|
-
export declare function setNodeColorAdjustmentsTint<
|
|
19
|
+
export declare function setNodeColorAdjustmentsTint<Fields extends object>(source: Node<Fields>, tint: number): void;
|
|
20
20
|
//# sourceMappingURL=nodeColorAdjustment.d.ts.map
|
package/dist/nodeOrderList.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { EntityConstruction, Node, NodeOrderList, NodeOrderListEntryVisitor,
|
|
1
|
+
import type { EntityConstruction, Node, NodeOrderList, NodeOrderListEntryVisitor, NodeFields } from '@flighthq/types/contract';
|
|
2
2
|
/**
|
|
3
3
|
* Appends one entry to the list's valid window. Capacity past `entryCount` is reused, so a list
|
|
4
4
|
* refilled every frame allocates only while it is growing. This does not check whether `node` is
|
|
5
5
|
* already entered — it is the O(1) bulk-fill verb. Use setNodeOrderListEntry to re-key a node that may
|
|
6
6
|
* already be present; a node entered twice resolves to its last entry.
|
|
7
7
|
*/
|
|
8
|
-
export declare function addNodeOrderListEntry<
|
|
8
|
+
export declare function addNodeOrderListEntry<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, node: Node<Fields>, sortKey: number): void;
|
|
9
9
|
/**
|
|
10
10
|
* Reorders `target`'s children so the list's members sit in ascending sort-key order, and does nothing
|
|
11
11
|
* else. This owns order, never membership: members are permuted among the slots they already occupy, so
|
|
@@ -21,43 +21,43 @@ export declare function addNodeOrderListEntry<Traits extends object = NodeTraits
|
|
|
21
21
|
* child of `target`, so no parent pointer or parentReferenceId changes, and the whole permutation stamps
|
|
22
22
|
* `childrenId` once instead of once per moved node.
|
|
23
23
|
*/
|
|
24
|
-
export declare function applyNodeOrderList<
|
|
24
|
+
export declare function applyNodeOrderList<Fields extends object = NodeFields>(target: Node<Fields>, list: Readonly<NodeOrderList<Fields>>): void;
|
|
25
25
|
/**
|
|
26
26
|
* Empties the valid window without releasing capacity, so the next fill reuses the arrays. Entries past
|
|
27
27
|
* `entryCount` keep their node references; use disposeNodeOrderList to drop them.
|
|
28
28
|
*/
|
|
29
|
-
export declare function clearNodeOrderList<
|
|
30
|
-
export declare function createNodeOrderList<
|
|
29
|
+
export declare function clearNodeOrderList<Fields extends object = NodeFields>(list: NodeOrderList<Fields>): void;
|
|
30
|
+
export declare function createNodeOrderList<Fields extends object = NodeFields>(): NodeOrderList<Fields>;
|
|
31
31
|
/**
|
|
32
32
|
* Empties the list and releases its node references, so a long-lived list stops holding nodes reachable.
|
|
33
33
|
* The list stays usable; this is the teardown counterpart to clearNodeOrderList, which deliberately
|
|
34
34
|
* retains both capacity and the references past the window for reuse.
|
|
35
35
|
*/
|
|
36
|
-
export declare function disposeNodeOrderList<
|
|
36
|
+
export declare function disposeNodeOrderList<Fields extends object = NodeFields>(list: NodeOrderList<Fields>): void;
|
|
37
37
|
/**
|
|
38
38
|
* Calls `callback` for each entry in the order the entries were added, which is not the order they
|
|
39
39
|
* resolve to. Stops early if `callback` returns `false`.
|
|
40
40
|
*/
|
|
41
|
-
export declare function forEachNodeOrderListEntry<
|
|
41
|
+
export declare function forEachNodeOrderListEntry<Fields extends object = NodeFields>(list: Readonly<NodeOrderList<Fields>>, callback: NodeOrderListEntryVisitor<Fields>): void;
|
|
42
42
|
/**
|
|
43
43
|
* Returns the sort key `node` is entered with, or `null` when it has no entry. Null rather than -1
|
|
44
44
|
* because every finite number, negative included, is a legal sort key.
|
|
45
45
|
*/
|
|
46
|
-
export declare function getNodeOrderListEntrySortKey<
|
|
47
|
-
export declare function hasNodeOrderListEntry<
|
|
48
|
-
export declare function initializeNodeOrderList<
|
|
46
|
+
export declare function getNodeOrderListEntrySortKey<Fields extends object = NodeFields>(list: Readonly<NodeOrderList<Fields>>, node: Readonly<Node<Fields>>): number | null;
|
|
47
|
+
export declare function hasNodeOrderListEntry<Fields extends object = NodeFields>(list: Readonly<NodeOrderList<Fields>>, node: Readonly<Node<Fields>>): boolean;
|
|
48
|
+
export declare function initializeNodeOrderList<Fields extends object = NodeFields>(out: EntityConstruction<NodeOrderList<Fields>>): void;
|
|
49
49
|
/**
|
|
50
50
|
* Removes `node`'s entry, returning whether one was found. Entries after it shift down rather than
|
|
51
51
|
* being back-filled from the end: entry position breaks ties between equal sort keys, so preserving it
|
|
52
52
|
* is part of the contract, not an implementation detail.
|
|
53
53
|
*/
|
|
54
|
-
export declare function removeNodeOrderListEntry<
|
|
54
|
+
export declare function removeNodeOrderListEntry<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, node: Readonly<Node<Fields>>): boolean;
|
|
55
55
|
/**
|
|
56
56
|
* Enters `node` at `sortKey`, replacing its existing entry in place if it has one. This is the verb for
|
|
57
57
|
* incremental re-keying: unlike addNodeOrderListEntry it never grows the list with a second entry for
|
|
58
58
|
* the same node, at the cost of a scan.
|
|
59
59
|
*/
|
|
60
|
-
export declare function setNodeOrderListEntry<
|
|
60
|
+
export declare function setNodeOrderListEntry<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, node: Node<Fields>, sortKey: number): void;
|
|
61
61
|
/**
|
|
62
62
|
* Enters `node` so it resolves immediately above `target` — drawn after it, in front of it. Does
|
|
63
63
|
* nothing when `target` has no entry, since there is nothing to be above.
|
|
@@ -67,23 +67,23 @@ export declare function setNodeOrderListEntry<Traits extends object = NodeTraits
|
|
|
67
67
|
* That holds however tightly packed the surrounding keys are, and repeated placement never exhausts
|
|
68
68
|
* float precision the way bisection does.
|
|
69
69
|
*/
|
|
70
|
-
export declare function setNodeOrderListEntryAbove<
|
|
70
|
+
export declare function setNodeOrderListEntryAbove<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, node: Node<Fields>, target: Readonly<Node<Fields>>): void;
|
|
71
71
|
/**
|
|
72
72
|
* Enters `node` so it resolves immediately below `target` — drawn before it, behind it. Does nothing
|
|
73
73
|
* when `target` has no entry. The mirror of setNodeOrderListEntryAbove, placing `node`'s entry just
|
|
74
74
|
* before `target`'s at the same sort key.
|
|
75
75
|
*/
|
|
76
|
-
export declare function setNodeOrderListEntryBelow<
|
|
76
|
+
export declare function setNodeOrderListEntryBelow<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, node: Node<Fields>, target: Readonly<Node<Fields>>): void;
|
|
77
77
|
/**
|
|
78
78
|
* Refills the list from `source`'s current children, each entered at its own child index. This is the
|
|
79
79
|
* inverse of applyNodeOrderList: capture what is there, edit it with the *Above/*Below/swap verbs, then
|
|
80
80
|
* apply it back. Any previous contents are discarded.
|
|
81
81
|
*/
|
|
82
|
-
export declare function setNodeOrderListFromNodeChildren<
|
|
82
|
+
export declare function setNodeOrderListFromNodeChildren<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, source: Readonly<Node<Fields>>): void;
|
|
83
83
|
/**
|
|
84
84
|
* Exchanges the sort keys of two entered nodes, the way a display list swaps two depths. Does nothing
|
|
85
85
|
* unless both nodes have entries. Entry positions are left alone, so a tie between the two resolves the
|
|
86
86
|
* same way afterwards as before.
|
|
87
87
|
*/
|
|
88
|
-
export declare function swapNodeOrderListEntries<
|
|
88
|
+
export declare function swapNodeOrderListEntries<Fields extends object = NodeFields>(list: NodeOrderList<Fields>, nodeA: Readonly<Node<Fields>>, nodeB: Readonly<Node<Fields>>): void;
|
|
89
89
|
//# sourceMappingURL=nodeOrderList.d.ts.map
|
|
@@ -3,17 +3,17 @@ import type { Matrix, MatrixLike, Transform2DLike, Transform2DNode, Vector2Like
|
|
|
3
3
|
* Converts the `vector` object from the Scene2D (global) coordinates
|
|
4
4
|
* to the display object's (local) coordinates.
|
|
5
5
|
**/
|
|
6
|
-
export declare function convertNodeVector2GlobalToLocal<
|
|
6
|
+
export declare function convertNodeVector2GlobalToLocal<Fields extends object>(out: Vector2Like, source: Transform2DNode<Fields>, vector: Readonly<Vector2Like>): void;
|
|
7
7
|
/**
|
|
8
8
|
* Converts the `vector` object from the display object's (local)
|
|
9
9
|
* coordinates to world coordinates.
|
|
10
10
|
**/
|
|
11
|
-
export declare function convertNodeVector2LocalToGlobal<
|
|
12
|
-
export declare function ensureNodeLocalMatrix<
|
|
13
|
-
export declare function ensureNodeWorldMatrix<
|
|
14
|
-
export declare function getNodeLocalMatrix<
|
|
15
|
-
export declare function getNodeTransform2D<
|
|
16
|
-
export declare function getNodeWorldMatrix<
|
|
17
|
-
export declare function setNodeLocalMatrix<
|
|
18
|
-
export declare function setNodeTransform2D<
|
|
11
|
+
export declare function convertNodeVector2LocalToGlobal<Fields extends object>(out: Vector2Like, source: Transform2DNode<Fields>, vector: Readonly<Vector2Like>): void;
|
|
12
|
+
export declare function ensureNodeLocalMatrix<Fields extends object>(target: Transform2DNode<Fields>): void;
|
|
13
|
+
export declare function ensureNodeWorldMatrix<Fields extends object>(target: Transform2DNode<Fields>): void;
|
|
14
|
+
export declare function getNodeLocalMatrix<Fields extends object>(target: Transform2DNode<Fields>): Readonly<Matrix>;
|
|
15
|
+
export declare function getNodeTransform2D<Fields extends object>(out: Transform2DLike, source: Transform2DNode<Fields>): void;
|
|
16
|
+
export declare function getNodeWorldMatrix<Fields extends object>(target: Transform2DNode<Fields>): Readonly<Matrix>;
|
|
17
|
+
export declare function setNodeLocalMatrix<Fields extends object>(target: Transform2DNode<Fields>, source: Readonly<MatrixLike>): void;
|
|
18
|
+
export declare function setNodeTransform2D<Fields extends object>(target: Transform2DNode<Fields>, source: Readonly<Transform2DLike>): void;
|
|
19
19
|
//# sourceMappingURL=nodeTransform2d.d.ts.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Matrix4Like, Transform3DLike, Transform3DNode, Vector3Like } from '@flighthq/types/contract';
|
|
2
|
-
export declare function convertNodeVector3GlobalToLocal<
|
|
3
|
-
export declare function convertNodeVector3LocalToGlobal<
|
|
4
|
-
export declare function ensureNodeLocalMatrix4<
|
|
5
|
-
export declare function ensureNodeWorldMatrix4<
|
|
6
|
-
export declare function getNodeLocalMatrix4<
|
|
7
|
-
export declare function getNodeTransform3D<
|
|
8
|
-
export declare function getNodeWorldMatrix4<
|
|
9
|
-
export declare function isNodeLocalMatrix4Detached<
|
|
10
|
-
export declare function setNodeLocalMatrix4<
|
|
11
|
-
export declare function setNodeTransform3D<
|
|
12
|
-
export declare function syncNodeTransform3DFromMatrix4<
|
|
2
|
+
export declare function convertNodeVector3GlobalToLocal<Fields extends object>(out: Vector3Like, source: Transform3DNode<Fields>, point: Readonly<Vector3Like>): void;
|
|
3
|
+
export declare function convertNodeVector3LocalToGlobal<Fields extends object>(out: Vector3Like, source: Transform3DNode<Fields>, point: Readonly<Vector3Like>): void;
|
|
4
|
+
export declare function ensureNodeLocalMatrix4<Fields extends object>(target: Transform3DNode<Fields>): void;
|
|
5
|
+
export declare function ensureNodeWorldMatrix4<Fields extends object>(target: Transform3DNode<Fields>): void;
|
|
6
|
+
export declare function getNodeLocalMatrix4<Fields extends object>(target: Transform3DNode<Fields>): Readonly<Matrix4Like>;
|
|
7
|
+
export declare function getNodeTransform3D<Fields extends object>(out: Transform3DLike, source: Transform3DNode<Fields>): void;
|
|
8
|
+
export declare function getNodeWorldMatrix4<Fields extends object>(target: Transform3DNode<Fields>): Readonly<Matrix4Like>;
|
|
9
|
+
export declare function isNodeLocalMatrix4Detached<Fields extends object>(target: Transform3DNode<Fields>): boolean;
|
|
10
|
+
export declare function setNodeLocalMatrix4<Fields extends object>(target: Transform3DNode<Fields>, source: Readonly<Matrix4Like>): void;
|
|
11
|
+
export declare function setNodeTransform3D<Fields extends object>(target: Transform3DNode<Fields>, source: Readonly<Transform3DLike>): void;
|
|
12
|
+
export declare function syncNodeTransform3DFromMatrix4<Fields extends object>(target: Transform3DNode<Fields>): void;
|
|
13
13
|
//# sourceMappingURL=nodeTransform3d.d.ts.map
|
package/dist/revision.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Node, NodeRuntime } from '@flighthq/types/contract';
|
|
2
|
-
export declare function computeNodeWorldTransformRevision<
|
|
3
|
-
export declare function getNodeAppearanceRevision<
|
|
4
|
-
export declare function getNodeChildrenRevision<
|
|
5
|
-
export declare function getNodeLocalBoundsRevision<
|
|
6
|
-
export declare function getNodeLocalContentRevision<
|
|
7
|
-
export declare function getNodeLocalTransformRevision<
|
|
8
|
-
export declare function getNodeParentReferenceRevision<
|
|
9
|
-
export declare function getNodeWorldTransformRevision<
|
|
2
|
+
export declare function computeNodeWorldTransformRevision<Fields extends object>(runtime: NodeRuntime<Fields>, parentRuntime?: Readonly<NodeRuntime<Fields>>): void;
|
|
3
|
+
export declare function getNodeAppearanceRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
4
|
+
export declare function getNodeChildrenRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
5
|
+
export declare function getNodeLocalBoundsRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
6
|
+
export declare function getNodeLocalContentRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
7
|
+
export declare function getNodeLocalTransformRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
8
|
+
export declare function getNodeParentReferenceRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
9
|
+
export declare function getNodeWorldTransformRevision<Fields extends object>(source: Readonly<Node<Fields>>): number;
|
|
10
10
|
/**
|
|
11
11
|
* Target node's rendered content changed — the general direct-mutation companion. After mutating a
|
|
12
12
|
* node's content fields in place (rather than through a setter), call this to invalidate the content
|
|
@@ -14,38 +14,38 @@ export declare function getNodeWorldTransformRevision<Traits extends object>(sou
|
|
|
14
14
|
* contract for any node kind. Setters keep their own precise per-field invalidation; this is the
|
|
15
15
|
* broad companion, not a replacement for them. Never touches the transform.
|
|
16
16
|
*/
|
|
17
|
-
export declare function invalidateContent<
|
|
18
|
-
export declare function invalidateNode<
|
|
17
|
+
export declare function invalidateContent<Fields extends object>(target: Node<Fields>): void;
|
|
18
|
+
export declare function invalidateNode<Fields extends object>(target: Node<Fields>): void;
|
|
19
19
|
/**
|
|
20
20
|
* Target object's appearance changed (excluding transforms).
|
|
21
21
|
*/
|
|
22
|
-
export declare function invalidateNodeAppearance<
|
|
22
|
+
export declare function invalidateNodeAppearance<Fields extends object>(target: Node<Fields>): void;
|
|
23
23
|
/**
|
|
24
24
|
* Target object's own dimensions (not including children) changed.
|
|
25
25
|
*/
|
|
26
|
-
export declare function invalidateNodeLocalBounds<
|
|
26
|
+
export declare function invalidateNodeLocalBounds<Fields extends object>(target: Node<Fields>): void;
|
|
27
27
|
/**
|
|
28
28
|
* Target object's own drawable surface changed (the rasterizable payload — shape commands, text,
|
|
29
29
|
* pixels — not its children and not how it is composited). Renderers re-rasterize on this; the walk
|
|
30
30
|
* and render caches re-examine the node. Distinct from appearance (compositing) and bounds (extent).
|
|
31
31
|
*/
|
|
32
|
-
export declare function invalidateNodeLocalContent<
|
|
32
|
+
export declare function invalidateNodeLocalContent<Fields extends object>(target: Node<Fields>): void;
|
|
33
33
|
/**
|
|
34
34
|
* Target object's own transform (x, y, rotation, scaleX, scaleY, skewX, skewY, or pivot) changed.
|
|
35
35
|
*/
|
|
36
|
-
export declare function invalidateNodeLocalTransform<
|
|
36
|
+
export declare function invalidateNodeLocalTransform<Fields extends object>(target: Node<Fields>): void;
|
|
37
37
|
/**
|
|
38
38
|
* Target object's parent changed.
|
|
39
39
|
*/
|
|
40
|
-
export declare function invalidateNodeParentReference<
|
|
40
|
+
export declare function invalidateNodeParentReference<Fields extends object>(target: Node<Fields>): void;
|
|
41
41
|
/**
|
|
42
42
|
* Target object's visual output changed (appearance or local transform).
|
|
43
43
|
* Use this when animating properties like alpha, x, y, scaleX, scaleY, rotation.
|
|
44
44
|
*/
|
|
45
|
-
export declare function invalidateNodeRender<
|
|
45
|
+
export declare function invalidateNodeRender<Fields extends object>(target: Node<Fields>): void;
|
|
46
46
|
/**
|
|
47
47
|
* Target object's child bounds have changed. Invalidates the target and every ancestor whose
|
|
48
48
|
* aggregate world bounds include it.
|
|
49
49
|
*/
|
|
50
|
-
export declare function invalidateNodeWorldBounds<
|
|
50
|
+
export declare function invalidateNodeWorldBounds<Fields extends object>(target: Node<Fields>): void;
|
|
51
51
|
//# sourceMappingURL=revision.d.ts.map
|
package/dist/stageFit.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MatrixLike,
|
|
1
|
+
import type { MatrixLike, NodeFields, Scene2DFitContext, ViewportAlign } from '@flighthq/types/contract';
|
|
2
2
|
export declare function computeScene2DFitAlignX(scaledContentWidth: number, viewWidth: number, align: ViewportAlign): number;
|
|
3
3
|
export declare function computeScene2DFitAlignY(scaledContentHeight: number, viewHeight: number, align: ViewportAlign): number;
|
|
4
4
|
export declare function computeScene2DFitFillScale(contentWidth: number, contentHeight: number, viewWidth: number, viewHeight: number): number;
|
|
5
5
|
export declare function computeScene2DFitScale(contentWidth: number, contentHeight: number, viewWidth: number, viewHeight: number): number;
|
|
6
|
-
export declare function computeScene2DFitTransform<
|
|
6
|
+
export declare function computeScene2DFitTransform<Fields extends object = NodeFields>(out: MatrixLike, scene2d: Readonly<Scene2DFitContext<Fields>>, viewWidth: number, viewHeight: number): void;
|
|
7
7
|
//# sourceMappingURL=stageFit.d.ts.map
|
package/dist/traversal.d.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import type { Node, NodeDescendantVisitor, NodeOf,
|
|
1
|
+
import type { Node, NodeDescendantVisitor, NodeOf, NodeFields } from '@flighthq/types/contract';
|
|
2
2
|
/**
|
|
3
3
|
* Finds the first descendant of `source` (depth-first pre-order) that satisfies `predicate`.
|
|
4
4
|
* Returns `null` if no descendant matches. When `predicate` is a type guard, the result is
|
|
5
5
|
* narrowed to the guarded type, so `findNode(root, isMesh)` returns `Mesh | null` with no cast.
|
|
6
6
|
*/
|
|
7
|
-
export declare function findNode<
|
|
8
|
-
export declare function findNode<
|
|
7
|
+
export declare function findNode<Fields extends object, Result extends Node<Fields>>(source: Readonly<Node<Fields>>, predicate: (node: Node<Fields>) => node is Result): Result | null;
|
|
8
|
+
export declare function findNode<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>, predicate: (node: Node<Fields>) => boolean): NodeOf<Fields> | null;
|
|
9
9
|
/**
|
|
10
10
|
* Finds the first descendant of `source` (depth-first pre-order) with the given `name`. Searches
|
|
11
11
|
* the full subtree recursively, unlike `getNodeChildByName` which only checks direct children.
|
|
12
12
|
* Returns `null` if no descendant matches.
|
|
13
13
|
*/
|
|
14
|
-
export declare function findNodeByName<
|
|
14
|
+
export declare function findNodeByName<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>, name: string): NodeOf<Fields> | null;
|
|
15
15
|
/**
|
|
16
16
|
* Walks upward from `source` toward the root, calling `callback` for each ancestor. If `callback`
|
|
17
17
|
* returns `false`, the walk stops early. The source node itself is not visited.
|
|
18
18
|
*/
|
|
19
|
-
export declare function forEachNodeAncestor<
|
|
19
|
+
export declare function forEachNodeAncestor<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>, callback: (node: Node<Fields>) => boolean | void): void;
|
|
20
20
|
/**
|
|
21
21
|
* Calls `callback` for every descendant of `source` in depth-first pre-order. Unlike
|
|
22
22
|
* `walkNodeDescendants`, this variant never stops early — every descendant is visited regardless
|
|
23
23
|
* of the callback's return value.
|
|
24
24
|
*/
|
|
25
|
-
export declare function forEachNodeDescendant<
|
|
25
|
+
export declare function forEachNodeDescendant<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>, callback: (node: Node<Fields>) => void): void;
|
|
26
26
|
/**
|
|
27
27
|
* Returns a read-only snapshot of the direct children of `source`. Returns an empty array if the
|
|
28
28
|
* node has no children. The returned array is a copy and safe to iterate while the graph mutates.
|
|
29
29
|
*/
|
|
30
|
-
export declare function getNodeChildren<
|
|
30
|
+
export declare function getNodeChildren<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>): readonly NodeOf<Fields>[];
|
|
31
31
|
/**
|
|
32
32
|
* Returns the depth of `source` in the tree: 0 for a root node (no parent), 1 for a direct child
|
|
33
33
|
* of the root, and so on.
|
|
34
34
|
*/
|
|
35
|
-
export declare function getNodeDepth<
|
|
35
|
+
export declare function getNodeDepth<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>): number;
|
|
36
36
|
/**
|
|
37
37
|
* Returns the next sibling of `source` (the child immediately after it in its parent's children
|
|
38
38
|
* array), or `null` if `source` is the last child or has no parent.
|
|
39
39
|
*/
|
|
40
|
-
export declare function getNodeNextSibling<
|
|
40
|
+
export declare function getNodeNextSibling<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>): NodeOf<Fields> | null;
|
|
41
41
|
/**
|
|
42
42
|
* Returns the previous sibling of `source` (the child immediately before it in its parent's
|
|
43
43
|
* children array), or `null` if `source` is the first child or has no parent.
|
|
44
44
|
*/
|
|
45
|
-
export declare function getNodePreviousSibling<
|
|
45
|
+
export declare function getNodePreviousSibling<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>): NodeOf<Fields> | null;
|
|
46
46
|
/**
|
|
47
47
|
* Walks the descendants of `source` in depth-first pre-order, calling `visit` for each node.
|
|
48
48
|
* If `visit` returns `false`, the walk stops early (neither the current node's subtree nor any
|
|
49
49
|
* remaining siblings are visited). Returns `true` if the walk completed without early termination,
|
|
50
50
|
* `false` if it was cut short.
|
|
51
51
|
*/
|
|
52
|
-
export declare function walkNodeDescendants<
|
|
52
|
+
export declare function walkNodeDescendants<Fields extends object = NodeFields>(source: Readonly<Node<Fields>>, visit: NodeDescendantVisitor<Fields>): boolean;
|
|
53
53
|
//# sourceMappingURL=traversal.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/node",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.3269.831c174",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/adjustments": "0.5.1-next.
|
|
42
|
-
"@flighthq/entity": "0.5.1-next.
|
|
43
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
44
|
-
"@flighthq/log": "0.5.1-next.
|
|
45
|
-
"@flighthq/materials": "0.5.1-next.
|
|
46
|
-
"@flighthq/math": "0.5.1-next.
|
|
47
|
-
"@flighthq/signals": "0.5.1-next.
|
|
48
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/adjustments": "0.5.1-next.3269.831c174",
|
|
42
|
+
"@flighthq/entity": "0.5.1-next.3269.831c174",
|
|
43
|
+
"@flighthq/geometry": "0.5.1-next.3269.831c174",
|
|
44
|
+
"@flighthq/log": "0.5.1-next.3269.831c174",
|
|
45
|
+
"@flighthq/materials": "0.5.1-next.3269.831c174",
|
|
46
|
+
"@flighthq/math": "0.5.1-next.3269.831c174",
|
|
47
|
+
"@flighthq/signals": "0.5.1-next.3269.831c174",
|
|
48
|
+
"@flighthq/types": "0.5.1-next.3269.831c174"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"typescript": "^5.3.0"
|
package/src/hierarchy.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getEntityRuntime as getRawEntityRuntime } from '@flighthq/entity/contract';
|
|
2
2
|
import { cloneMatrix } from '@flighthq/geometry/contract';
|
|
3
3
|
import { connectSignal } from '@flighthq/signals/contract';
|
|
4
|
-
import type { HasTransform2D, HasTransform2DRuntime, Node, NodeRuntime,
|
|
4
|
+
import type { HasTransform2D, HasTransform2DRuntime, Node, NodeRuntime, NodeFields } from '@flighthq/types/contract';
|
|
5
5
|
import { NodeKind } from '@flighthq/types/contract';
|
|
6
6
|
|
|
7
7
|
import { initTransform2DRuntimeTrait, initTransform2DTrait } from './hasTransform2d.ts';
|
|
@@ -34,9 +34,9 @@ import { createNode, enableNodeSignals, getNodeRuntime } from './node.ts';
|
|
|
34
34
|
import { getNodeWorldMatrix } from './nodeTransform2d.ts';
|
|
35
35
|
import { getNodeChildrenRevision, getNodeParentReferenceRevision, invalidateNodeLocalTransform } from './revision.ts';
|
|
36
36
|
|
|
37
|
-
let container: Node<
|
|
38
|
-
let childA: Node<
|
|
39
|
-
let childB: Node<
|
|
37
|
+
let container: Node<NodeFields>;
|
|
38
|
+
let childA: Node<NodeFields>;
|
|
39
|
+
let childB: Node<NodeFields>;
|
|
40
40
|
|
|
41
41
|
beforeEach(() => {
|
|
42
42
|
container = createNode(NodeKind);
|
|
@@ -146,9 +146,9 @@ describe('addNodeChild', () => {
|
|
|
146
146
|
expect(called).toBe(false);
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
// Compile-time law: Node<
|
|
149
|
+
// Compile-time law: Node<Fields> is invariant in Fields, so nodes from different trait
|
|
150
150
|
// families cannot be mixed in one graph. The @ts-expect-error is the assertion — if the
|
|
151
|
-
// wall ever collapses (e.g.
|
|
151
|
+
// wall ever collapses (e.g. Fields leaks to `any`), this line stops erroring and the test
|
|
152
152
|
// fails to compile under `npm run typecheck`.
|
|
153
153
|
it('rejects mixing nodes from different trait families', () => {
|
|
154
154
|
interface FooTraits {
|
|
@@ -325,7 +325,7 @@ describe('forEachNodeChild', () => {
|
|
|
325
325
|
it('visits each child with its index', () => {
|
|
326
326
|
addNodeChild(container, childA);
|
|
327
327
|
addNodeChild(container, childB);
|
|
328
|
-
const visited: Array<[Node<
|
|
328
|
+
const visited: Array<[Node<NodeFields>, number]> = [];
|
|
329
329
|
forEachNodeChild(container, (child, index) => {
|
|
330
330
|
visited.push([child, index]);
|
|
331
331
|
});
|
|
@@ -338,7 +338,7 @@ describe('forEachNodeChild', () => {
|
|
|
338
338
|
it('stops early when callback returns false', () => {
|
|
339
339
|
addNodeChild(container, childA);
|
|
340
340
|
addNodeChild(container, childB);
|
|
341
|
-
const visited: Node<
|
|
341
|
+
const visited: Node<NodeFields>[] = [];
|
|
342
342
|
forEachNodeChild(container, (child) => {
|
|
343
343
|
visited.push(child);
|
|
344
344
|
return false;
|
package/src/node.test.ts
CHANGED
|
@@ -107,8 +107,8 @@ describe('createNodeRuntime', () => {
|
|
|
107
107
|
expect(runtime.canAddChild).toStrictEqual(defaultNodeRuntimeCanAddChild);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
it('does not set
|
|
111
|
-
expect(runtime.
|
|
110
|
+
it('does not set fields — concrete graph runtimes set it', () => {
|
|
111
|
+
expect(runtime.fields).toBeUndefined();
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
it('allows custom canAddChild', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { connectSignal } from '@flighthq/signals/contract';
|
|
2
|
-
import type { Node,
|
|
2
|
+
import type { Node, NodeFields } from '@flighthq/types/contract';
|
|
3
3
|
import { NodeKind } from '@flighthq/types/contract';
|
|
4
4
|
|
|
5
5
|
import { addNodeChild, removeNodeChild } from './hierarchy.ts';
|
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
} from './nodeOrderList.ts';
|
|
24
24
|
import { getNodeChildrenRevision } from './revision.ts';
|
|
25
25
|
|
|
26
|
-
let container: Node<
|
|
27
|
-
let childA: Node<
|
|
28
|
-
let childB: Node<
|
|
29
|
-
let childC: Node<
|
|
26
|
+
let container: Node<NodeFields>;
|
|
27
|
+
let childA: Node<NodeFields>;
|
|
28
|
+
let childB: Node<NodeFields>;
|
|
29
|
+
let childC: Node<NodeFields>;
|
|
30
30
|
|
|
31
31
|
beforeEach(() => {
|
|
32
32
|
container = createNode(NodeKind);
|
package/src/stageFit.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createMatrix } from '@flighthq/geometry/contract';
|
|
|
2
2
|
import type {
|
|
3
3
|
HasBoundsRectangleRuntime,
|
|
4
4
|
Node,
|
|
5
|
-
|
|
5
|
+
NodeFields,
|
|
6
6
|
ViewportAlign,
|
|
7
7
|
ViewportScaleMode,
|
|
8
8
|
} from '@flighthq/types/contract';
|
|
@@ -31,9 +31,9 @@ function makeNodeWithBounds(width: number, height: number, x = 0, y = 0) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// A structural scene2d-fit context (what Scene2D supplies): root plus how it maps into the view.
|
|
34
|
-
function fit(overrides: { align?: ViewportAlign; root?: Node<
|
|
34
|
+
function fit(overrides: { align?: ViewportAlign; root?: Node<NodeFields> | null; scaleMode?: ViewportScaleMode }): {
|
|
35
35
|
align: ViewportAlign;
|
|
36
|
-
root: Node<
|
|
36
|
+
root: Node<NodeFields> | null;
|
|
37
37
|
scaleMode: ViewportScaleMode;
|
|
38
38
|
} {
|
|
39
39
|
return {
|
package/src/traversal.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, NodeRuntime,
|
|
1
|
+
import type { Node, NodeRuntime, NodeFields } from '@flighthq/types/contract';
|
|
2
2
|
import { NodeKind } from '@flighthq/types/contract';
|
|
3
3
|
|
|
4
4
|
import { addNodeChild } from './hierarchy.ts';
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
walkNodeDescendants,
|
|
16
16
|
} from './traversal.ts';
|
|
17
17
|
|
|
18
|
-
let root: Node<
|
|
19
|
-
let childA: Node<
|
|
20
|
-
let childB: Node<
|
|
21
|
-
let grandchild: Node<
|
|
18
|
+
let root: Node<NodeFields>;
|
|
19
|
+
let childA: Node<NodeFields>;
|
|
20
|
+
let childB: Node<NodeFields>;
|
|
21
|
+
let grandchild: Node<NodeFields>;
|
|
22
22
|
|
|
23
23
|
beforeEach(() => {
|
|
24
24
|
root = createNode(NodeKind);
|
|
@@ -67,10 +67,10 @@ describe('findNode', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it('narrows the result to the guarded type when the predicate is a type guard', () => {
|
|
70
|
-
interface TaggedNode extends Node<
|
|
70
|
+
interface TaggedNode extends Node<NodeFields> {
|
|
71
71
|
tag: string;
|
|
72
72
|
}
|
|
73
|
-
const isTagged = (n: Node<
|
|
73
|
+
const isTagged = (n: Node<NodeFields>): n is TaggedNode => (n as Partial<TaggedNode>).tag === 'tagged';
|
|
74
74
|
(childA as TaggedNode).tag = 'tagged';
|
|
75
75
|
const result = findNode(root, isTagged);
|
|
76
76
|
// Compile-time proof of the guard overload: `result` is `TaggedNode | null`, so reading `.tag`
|
|
@@ -100,7 +100,7 @@ describe('findNodeByName', () => {
|
|
|
100
100
|
|
|
101
101
|
describe('forEachNodeAncestor', () => {
|
|
102
102
|
it('does not call callback for a root node', () => {
|
|
103
|
-
const visited: Node<
|
|
103
|
+
const visited: Node<NodeFields>[] = [];
|
|
104
104
|
forEachNodeAncestor(root, (n) => {
|
|
105
105
|
visited.push(n);
|
|
106
106
|
return true;
|
|
@@ -109,7 +109,7 @@ describe('forEachNodeAncestor', () => {
|
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
it('visits ancestors from parent toward root', () => {
|
|
112
|
-
const visited: Node<
|
|
112
|
+
const visited: Node<NodeFields>[] = [];
|
|
113
113
|
forEachNodeAncestor(grandchild, (n) => {
|
|
114
114
|
visited.push(n);
|
|
115
115
|
});
|
|
@@ -117,7 +117,7 @@ describe('forEachNodeAncestor', () => {
|
|
|
117
117
|
});
|
|
118
118
|
|
|
119
119
|
it('stops early when callback returns false', () => {
|
|
120
|
-
const visited: Node<
|
|
120
|
+
const visited: Node<NodeFields>[] = [];
|
|
121
121
|
forEachNodeAncestor(grandchild, (n) => {
|
|
122
122
|
visited.push(n);
|
|
123
123
|
return false; // stop after first
|
|
@@ -128,19 +128,19 @@ describe('forEachNodeAncestor', () => {
|
|
|
128
128
|
|
|
129
129
|
describe('forEachNodeDescendant', () => {
|
|
130
130
|
it('does not call callback for a leaf node', () => {
|
|
131
|
-
const visited: Node<
|
|
131
|
+
const visited: Node<NodeFields>[] = [];
|
|
132
132
|
forEachNodeDescendant(grandchild, (n) => visited.push(n));
|
|
133
133
|
expect(visited).toHaveLength(0);
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
it('visits all descendants in depth-first pre-order', () => {
|
|
137
|
-
const visited: Node<
|
|
137
|
+
const visited: Node<NodeFields>[] = [];
|
|
138
138
|
forEachNodeDescendant(root, (n) => visited.push(n));
|
|
139
139
|
expect(visited).toEqual([childA, grandchild, childB]);
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
it('does not include the source node', () => {
|
|
143
|
-
const visited: Node<
|
|
143
|
+
const visited: Node<NodeFields>[] = [];
|
|
144
144
|
forEachNodeDescendant(root, (n) => visited.push(n));
|
|
145
145
|
expect(visited).not.toContain(root);
|
|
146
146
|
});
|
|
@@ -230,7 +230,7 @@ describe('walkNodeDescendants', () => {
|
|
|
230
230
|
});
|
|
231
231
|
|
|
232
232
|
it('visits all descendants in depth-first pre-order when visitor always returns true', () => {
|
|
233
|
-
const visited: Node<
|
|
233
|
+
const visited: Node<NodeFields>[] = [];
|
|
234
234
|
const result = walkNodeDescendants(root, (n) => {
|
|
235
235
|
visited.push(n);
|
|
236
236
|
return true;
|
|
@@ -240,7 +240,7 @@ describe('walkNodeDescendants', () => {
|
|
|
240
240
|
});
|
|
241
241
|
|
|
242
242
|
it('stops early and returns false when visitor returns false', () => {
|
|
243
|
-
const visited: Node<
|
|
243
|
+
const visited: Node<NodeFields>[] = [];
|
|
244
244
|
const result = walkNodeDescendants(root, (n) => {
|
|
245
245
|
visited.push(n);
|
|
246
246
|
return false; // stop at first node
|
|
@@ -251,7 +251,7 @@ describe('walkNodeDescendants', () => {
|
|
|
251
251
|
});
|
|
252
252
|
|
|
253
253
|
it('does not visit subtree when visitor returns false for a parent', () => {
|
|
254
|
-
const visited: Node<
|
|
254
|
+
const visited: Node<NodeFields>[] = [];
|
|
255
255
|
walkNodeDescendants(root, (n) => {
|
|
256
256
|
visited.push(n);
|
|
257
257
|
// Stop when we reach childA — its subtree (grandchild) should be skipped
|
|
@@ -262,7 +262,7 @@ describe('walkNodeDescendants', () => {
|
|
|
262
262
|
});
|
|
263
263
|
|
|
264
264
|
it('propagates an early stop from a nested descendant', () => {
|
|
265
|
-
const visited: Node<
|
|
265
|
+
const visited: Node<NodeFields>[] = [];
|
|
266
266
|
|
|
267
267
|
const result = walkNodeDescendants(root, (node) => {
|
|
268
268
|
visited.push(node);
|