@egret/runtime 0.0.0-stage → 7.0.2

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.
Files changed (157) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +70 -2
  4. package/README.zh-CN.md +71 -0
  5. package/dist/AssetLease.d.ts +23 -0
  6. package/dist/AssetLease.js +69 -0
  7. package/dist/AssetManager.d.ts +58 -0
  8. package/dist/AssetManager.js +451 -0
  9. package/dist/AssetRef.d.ts +21 -0
  10. package/dist/AssetRef.js +33 -0
  11. package/dist/Bitmap.d.ts +40 -0
  12. package/dist/Bitmap.js +545 -0
  13. package/dist/ByteReader.d.ts +32 -0
  14. package/dist/ByteReader.js +178 -0
  15. package/dist/ByteWriter.d.ts +30 -0
  16. package/dist/ByteWriter.js +181 -0
  17. package/dist/CancellationController.d.ts +10 -0
  18. package/dist/CancellationController.js +66 -0
  19. package/dist/DisplayObject.d.ts +97 -0
  20. package/dist/DisplayObject.js +366 -0
  21. package/dist/DisplayObjectContainer.d.ts +28 -0
  22. package/dist/DisplayObjectContainer.js +226 -0
  23. package/dist/EgretError.d.ts +12 -0
  24. package/dist/EgretError.js +36 -0
  25. package/dist/Event.d.ts +47 -0
  26. package/dist/Event.js +84 -0
  27. package/dist/EventDispatcher.d.ts +24 -0
  28. package/dist/EventDispatcher.js +178 -0
  29. package/dist/Graphics.d.ts +117 -0
  30. package/dist/Graphics.js +548 -0
  31. package/dist/Mesh2D.d.ts +27 -0
  32. package/dist/Mesh2D.js +200 -0
  33. package/dist/NineSliceBitmap.d.ts +24 -0
  34. package/dist/NineSliceBitmap.js +164 -0
  35. package/dist/NineSliceGeometry2D.d.ts +19 -0
  36. package/dist/NineSliceGeometry2D.js +126 -0
  37. package/dist/Scope.d.ts +19 -0
  38. package/dist/Scope.js +133 -0
  39. package/dist/SequencePlayer.d.ts +12 -0
  40. package/dist/SequencePlayer.js +69 -0
  41. package/dist/Sprite.d.ts +8 -0
  42. package/dist/Sprite.js +12 -0
  43. package/dist/Stage.d.ts +14 -0
  44. package/dist/Stage.js +31 -0
  45. package/dist/Texture.d.ts +30 -0
  46. package/dist/Texture.js +178 -0
  47. package/dist/assetManagerOwnerState.d.ts +36 -0
  48. package/dist/assetManagerOwnerState.js +115 -0
  49. package/dist/assetState.d.ts +45 -0
  50. package/dist/assetState.js +2 -0
  51. package/dist/atlasFrameLayout.d.ts +21 -0
  52. package/dist/atlasFrameLayout.js +48 -0
  53. package/dist/bitmapDisplayState.d.ts +24 -0
  54. package/dist/bitmapDisplayState.js +22 -0
  55. package/dist/coordinateInverse.d.ts +4 -0
  56. package/dist/coordinateInverse.js +107 -0
  57. package/dist/diagnostics.d.ts +4 -0
  58. package/dist/diagnostics.js +13 -0
  59. package/dist/displayBounds.d.ts +9 -0
  60. package/dist/displayBounds.js +181 -0
  61. package/dist/displayCoordinates.d.ts +8 -0
  62. package/dist/displayCoordinates.js +81 -0
  63. package/dist/displayHitState.d.ts +18 -0
  64. package/dist/displayHitState.js +97 -0
  65. package/dist/displayHitTest.d.ts +8 -0
  66. package/dist/displayHitTest.js +219 -0
  67. package/dist/displayInputOperations.d.ts +12 -0
  68. package/dist/displayInputOperations.js +71 -0
  69. package/dist/displayTransform.d.ts +5 -0
  70. package/dist/displayTransform.js +38 -0
  71. package/dist/displayTreeState.d.ts +90 -0
  72. package/dist/displayTreeState.js +450 -0
  73. package/dist/displayVisualState.d.ts +76 -0
  74. package/dist/displayVisualState.js +141 -0
  75. package/dist/errorHelp.d.ts +15 -0
  76. package/dist/errorHelp.js +435 -0
  77. package/dist/errorHelpZh.d.ts +5 -0
  78. package/dist/errorHelpZh.js +342 -0
  79. package/dist/geometry.d.ts +173 -0
  80. package/dist/geometry.js +311 -0
  81. package/dist/graphicsFill.d.ts +37 -0
  82. package/dist/graphicsFill.js +302 -0
  83. package/dist/graphicsShape.d.ts +170 -0
  84. package/dist/graphicsShape.js +961 -0
  85. package/dist/index.d.ts +53 -0
  86. package/dist/index.js +31 -0
  87. package/dist/input/PointerRouter.d.ts +4 -0
  88. package/dist/input/PointerRouter.js +453 -0
  89. package/dist/input/index.d.ts +3 -0
  90. package/dist/input/index.js +3 -0
  91. package/dist/input/types.d.ts +64 -0
  92. package/dist/input/types.js +3 -0
  93. package/dist/meshCaptureSnapshot.d.ts +5 -0
  94. package/dist/meshCaptureSnapshot.js +13 -0
  95. package/dist/meshDisplayState.d.ts +18 -0
  96. package/dist/meshDisplayState.js +21 -0
  97. package/dist/ownership.d.ts +75 -0
  98. package/dist/ownership.js +157 -0
  99. package/dist/paragraph/Paragraph.d.ts +13 -0
  100. package/dist/paragraph/Paragraph.js +193 -0
  101. package/dist/paragraph/ParagraphCache.d.ts +5 -0
  102. package/dist/paragraph/ParagraphCache.js +354 -0
  103. package/dist/paragraph/geometry.d.ts +4 -0
  104. package/dist/paragraph/geometry.js +180 -0
  105. package/dist/paragraph/index.d.ts +3 -0
  106. package/dist/paragraph/index.js +3 -0
  107. package/dist/paragraph/request.d.ts +6 -0
  108. package/dist/paragraph/request.js +191 -0
  109. package/dist/paragraph/types.d.ts +183 -0
  110. package/dist/paragraph/types.js +2 -0
  111. package/dist/preparedDisplaySubtree.d.ts +7 -0
  112. package/dist/preparedDisplaySubtree.js +205 -0
  113. package/dist/renderEffect.d.ts +57 -0
  114. package/dist/renderEffect.js +109 -0
  115. package/dist/sequenceClip.d.ts +48 -0
  116. package/dist/sequenceClip.js +197 -0
  117. package/dist/sharedFrameCapture.d.ts +24 -0
  118. package/dist/sharedFrameCapture.js +1128 -0
  119. package/dist/spriteSheet.d.ts +34 -0
  120. package/dist/spriteSheet.js +321 -0
  121. package/dist/srgbBytes.d.ts +3 -0
  122. package/dist/srgbBytes.js +64 -0
  123. package/dist/text/TextField.d.ts +13 -0
  124. package/dist/text/TextField.js +261 -0
  125. package/dist/text/TextRasterCache.d.ts +5 -0
  126. package/dist/text/TextRasterCache.js +1191 -0
  127. package/dist/text/budget.d.ts +51 -0
  128. package/dist/text/budget.js +116 -0
  129. package/dist/text/index.d.ts +4 -0
  130. package/dist/text/index.js +3 -0
  131. package/dist/text/plan.d.ts +16 -0
  132. package/dist/text/plan.js +238 -0
  133. package/dist/text/request.d.ts +44 -0
  134. package/dist/text/request.js +303 -0
  135. package/dist/text/types.d.ts +179 -0
  136. package/dist/text/types.js +2 -0
  137. package/dist/textDisplayState.d.ts +21 -0
  138. package/dist/textDisplayState.js +27 -0
  139. package/dist/ui/displayCommit.d.ts +43 -0
  140. package/dist/ui/displayCommit.js +384 -0
  141. package/dist/ui/editing.d.ts +3 -0
  142. package/dist/ui/editing.js +3 -0
  143. package/dist/ui/heightIndex.d.ts +35 -0
  144. package/dist/ui/heightIndex.js +295 -0
  145. package/dist/ui/index.d.ts +6 -0
  146. package/dist/ui/index.js +6 -0
  147. package/dist/ui/layout.d.ts +9 -0
  148. package/dist/ui/layout.js +349 -0
  149. package/dist/ui/managedState.d.ts +12 -0
  150. package/dist/ui/managedState.js +44 -0
  151. package/dist/ui/textEditState.d.ts +4 -0
  152. package/dist/ui/textEditState.js +206 -0
  153. package/dist/ui/textEditTypes.d.ts +48 -0
  154. package/dist/ui/textEditTypes.js +2 -0
  155. package/dist/ui/types.d.ts +99 -0
  156. package/dist/ui/types.js +2 -0
  157. package/package.json +44 -4
@@ -0,0 +1,97 @@
1
+ import { assertManagedMutable } from './ui/managedState.js';
2
+ import { EgretError } from './EgretError.js';
3
+ import { assertLive, isDisplayNode } from './displayTreeState.js';
4
+ import { finite } from './displayVisualState.js';
5
+ import { engineOf } from './ownership.js';
6
+ // Interaction authority is independent of rendering content and public hooks.
7
+ const states = new WeakMap();
8
+ export function registerDisplayHitNode(node) {
9
+ states.set(node, { touchEnabled: false, hitArea: undefined, touchChildren: undefined });
10
+ }
11
+ export function registerDisplayHitContainer(node) {
12
+ readDisplayHitState(node).touchChildren = true;
13
+ }
14
+ /** Genuine identity is checked before any receiver property can be consulted. */
15
+ export function readDisplayHitState(receiver) {
16
+ if (!isDisplayNode(receiver))
17
+ throw new EgretError('HIT_TEST_RECEIVER_INVALID');
18
+ const state = states.get(receiver);
19
+ if (state === undefined)
20
+ throw new EgretError('HIT_TEST_RECEIVER_INVALID');
21
+ return state;
22
+ }
23
+ function live(node) {
24
+ assertManagedMutable(node);
25
+ assertLive(node);
26
+ engineOf(node)?.assertOpen();
27
+ }
28
+ export function writeDisplayTouchEnabled(receiver, value) {
29
+ const state = readDisplayHitState(receiver), node = receiver;
30
+ live(node);
31
+ if (typeof value !== 'boolean')
32
+ throw new EgretError('HIT_TEST_VALUE_INVALID');
33
+ state.touchEnabled = value;
34
+ }
35
+ export function readDisplayTouchChildren(receiver) {
36
+ const value = readDisplayHitState(receiver).touchChildren;
37
+ if (value === undefined)
38
+ throw new EgretError('HIT_TEST_RECEIVER_INVALID');
39
+ return value;
40
+ }
41
+ export function writeDisplayTouchChildren(receiver, value) {
42
+ const state = readDisplayHitState(receiver);
43
+ if (state.touchChildren === undefined)
44
+ throw new EgretError('HIT_TEST_RECEIVER_INVALID');
45
+ const node = receiver;
46
+ live(node);
47
+ if (typeof value !== 'boolean')
48
+ throw new EgretError('HIT_TEST_VALUE_INVALID');
49
+ state.touchChildren = value;
50
+ }
51
+ /** Read caller fields once in fixed order; source faults never become semantics. */
52
+ export function writeDisplayHitArea(receiver, source) {
53
+ const state = readDisplayHitState(receiver), node = receiver;
54
+ live(node);
55
+ if (source === undefined) {
56
+ state.hitArea = undefined;
57
+ return;
58
+ }
59
+ if (source === null || typeof source !== 'object')
60
+ throw new EgretError('HIT_TEST_AREA_INVALID');
61
+ let array;
62
+ try {
63
+ array = Array.isArray(source);
64
+ }
65
+ catch (cause) {
66
+ throw new EgretError('HIT_TEST_AREA_INVALID', { cause });
67
+ }
68
+ if (array)
69
+ throw new EgretError('HIT_TEST_AREA_INVALID');
70
+ let x, y, width, height;
71
+ try {
72
+ const area = source;
73
+ x = area.x;
74
+ y = area.y;
75
+ width = area.width;
76
+ height = area.height;
77
+ }
78
+ catch (cause) {
79
+ // Application EgretError and even undefined throws retain their exact cause.
80
+ throw new EgretError('HIT_TEST_AREA_INVALID', { cause });
81
+ }
82
+ // Successful source reads may terminate or rebind the current node. Their
83
+ // completed reentrant effects stand; this outer admission commits only here.
84
+ live(node);
85
+ if (!finite(x) ||
86
+ !finite(y) ||
87
+ !finite(width) ||
88
+ !finite(height) ||
89
+ width < 0 ||
90
+ height < 0 ||
91
+ !finite(x + width) ||
92
+ !finite(y + height)) {
93
+ throw new EgretError('HIT_TEST_AREA_INVALID');
94
+ }
95
+ state.hitArea = Object.freeze({ x, y, width, height });
96
+ }
97
+ //# sourceMappingURL=displayHitState.js.map
@@ -0,0 +1,8 @@
1
+ import type { DisplayObject } from './DisplayObject.js';
2
+ /** Receiver-inclusive whole-tree admission precedes all hit arithmetic. */
3
+ export interface HitTestOptions {
4
+ readonly maxNodes?: number;
5
+ }
6
+ /** Private state only; all active arithmetic completes before a borrowed result. */
7
+ export declare function queryDisplayHit(receiver: unknown, x: unknown, y: unknown, options: unknown): DisplayObject | undefined;
8
+ //# sourceMappingURL=displayHitTest.d.ts.map
@@ -0,0 +1,219 @@
1
+ import { EgretError } from './EgretError.js';
2
+ import { invertCoordinatePoint } from './coordinateInverse.js';
3
+ import { readDisplayHitState } from './displayHitState.js';
4
+ import { composeDisplayTransform } from './displayTransform.js';
5
+ import { assertLive, childAtOf, childCountOf, isDisplayNode, isStageRoot, parentOf } from './displayTreeState.js';
6
+ import { finite, visualOf } from './displayVisualState.js';
7
+ import { engineOf } from './ownership.js';
8
+ import { readBitmapState } from './bitmapDisplayState.js';
9
+ import { resolveShape } from './graphicsShape.js';
10
+ function live(node, engine) {
11
+ assertLive(node);
12
+ engine.assertOpen();
13
+ }
14
+ function budgetOf(root, engine, source) {
15
+ let requested;
16
+ if (source !== undefined) {
17
+ if (source === null || typeof source !== 'object')
18
+ throw new EgretError('HIT_TEST_INPUT_INVALID');
19
+ let array;
20
+ try {
21
+ array = Array.isArray(source);
22
+ }
23
+ catch (cause) {
24
+ throw new EgretError('HIT_TEST_INPUT_INVALID', { cause });
25
+ }
26
+ if (array)
27
+ throw new EgretError('HIT_TEST_INPUT_INVALID');
28
+ try {
29
+ requested = source.maxNodes;
30
+ }
31
+ catch (cause) {
32
+ throw new EgretError('HIT_TEST_INPUT_INVALID', { cause });
33
+ }
34
+ }
35
+ live(root, engine);
36
+ const maximum = requested === undefined ? 4096 : requested;
37
+ if (!finite(maximum) || !Number.isInteger(maximum) || maximum < 1 || maximum > 65536) {
38
+ throw new EgretError('HIT_TEST_INPUT_INVALID');
39
+ }
40
+ return maximum;
41
+ }
42
+ /** Ascending order fixes integrity failure priority without sibling snapshots. */
43
+ function admitStructure(root, engine, maximum) {
44
+ const seen = new Set(), stack = [];
45
+ function enter(node, parent) {
46
+ if (seen.size >= maximum)
47
+ throw new EgretError('HIT_TEST_TREE_LIMIT');
48
+ if (!isDisplayNode(node) || seen.has(node) || parentOf(node) !== parent)
49
+ throw new EgretError('DISPLAY_TREE_INVARIANT');
50
+ assertLive(node);
51
+ if (engineOf(node) !== engine)
52
+ throw new EgretError('ENGINE_MISMATCH');
53
+ seen.add(node);
54
+ stack.push({ node, childCount: childCountOf(node), nextChild: 0 });
55
+ }
56
+ enter(root, undefined);
57
+ while (stack.length !== 0) {
58
+ const cursor = stack[stack.length - 1];
59
+ if (cursor.nextChild === cursor.childCount) {
60
+ stack.pop();
61
+ continue;
62
+ }
63
+ // Debit before retrieving a child, including hidden/suppressed descendants.
64
+ if (seen.size >= maximum)
65
+ throw new EgretError('HIT_TEST_TREE_LIMIT');
66
+ const child = childAtOf(cursor.node, cursor.nextChild++);
67
+ if (child === undefined)
68
+ throw new EgretError('DISPLAY_TREE_INVARIANT');
69
+ enter(child, cursor.node);
70
+ }
71
+ }
72
+ function inversePoint(matrix, x, y) {
73
+ try {
74
+ return invertCoordinatePoint(matrix, x, y);
75
+ }
76
+ catch (cause) {
77
+ if (cause instanceof EgretError && cause.code === 'COORDINATE_ARITHMETIC_RANGE') {
78
+ throw new EgretError('HIT_TEST_ARITHMETIC_RANGE', { cause });
79
+ }
80
+ throw cause;
81
+ }
82
+ }
83
+ function nonsingular(matrix) {
84
+ // This exact-rank probe has zero inverse coordinates when rank is full. It
85
+ // avoids overflowing an irrelevant requested-point inverse on an ancestor.
86
+ try {
87
+ inversePoint(matrix, matrix.tx, matrix.ty);
88
+ return true;
89
+ }
90
+ catch (cause) {
91
+ if (cause instanceof EgretError && cause.code === 'COORDINATE_TRANSFORM_SINGULAR')
92
+ return false;
93
+ throw cause;
94
+ }
95
+ }
96
+ function contains(rectangle, point) {
97
+ return (point.x >= rectangle.x &&
98
+ point.x < rectangle.x + rectangle.width &&
99
+ point.y >= rectangle.y &&
100
+ point.y < rectangle.y + rectangle.height);
101
+ }
102
+ /**
103
+ * Whether a point, in a node's own units, is on what the node itself draws: one of its filled rectangles, a triangle
104
+ * of its shapes, or its bitmap's rectangle. A node that is touch enabled and has no hit area is hit by this.
105
+ */
106
+ function onContent(node, point) {
107
+ const visual = visualOf(node), x = point.x, y = point.y;
108
+ for (const { rect } of visual.primitives)
109
+ if (rect.width > 0 && rect.height > 0 && contains(rect, point))
110
+ return true;
111
+ const bitmap = readBitmapState(node);
112
+ if (bitmap !== undefined && x >= 0 && y >= 0 && x < bitmap.width && y < bitmap.height)
113
+ return true;
114
+ const shape = visual.shape === undefined ? undefined : resolveShape(visual.shape);
115
+ if (shape === undefined)
116
+ return false;
117
+ const bounds = shape.bounds;
118
+ if (x < bounds.x || y < bounds.y || x > bounds.x + bounds.width || y > bounds.y + bounds.height)
119
+ return false;
120
+ for (const { geometry } of shape.parts) {
121
+ const positions = geometry.positions, indices = geometry.indices;
122
+ for (let i = 0; i < geometry.indexCount; i += 3) {
123
+ const a = 2 * indices[i], b = 2 * indices[i + 1], c = 2 * indices[i + 2];
124
+ const ax = positions[a], ay = positions[a + 1], bx = positions[b], by = positions[b + 1], cx = positions[c], cy = positions[c + 1];
125
+ const d1 = (bx - ax) * (y - ay) - (by - ay) * (x - ax), d2 = (cx - bx) * (y - by) - (cy - by) * (x - bx), d3 = (ax - cx) * (y - cy) - (ay - cy) * (x - cx);
126
+ if ((d1 >= 0 && d2 >= 0 && d3 >= 0) || (d1 <= 0 && d2 <= 0 && d3 <= 0))
127
+ return true;
128
+ }
129
+ }
130
+ return false;
131
+ }
132
+ /** Private state only; all active arithmetic completes before a borrowed result. */
133
+ export function queryDisplayHit(receiver, x, y, options) {
134
+ if (!isStageRoot(receiver))
135
+ throw new EgretError('HIT_TEST_RECEIVER_INVALID');
136
+ const root = receiver;
137
+ assertLive(root);
138
+ const engine = engineOf(root);
139
+ if (engine === undefined)
140
+ throw new EgretError('DISPLAY_TREE_INVARIANT');
141
+ engine.assertOpen();
142
+ if (!finite(x) || !finite(y))
143
+ throw new EgretError('HIT_TEST_INPUT_INVALID');
144
+ const globalX = x, globalY = y;
145
+ const maximum = budgetOf(root, engine, options);
146
+ admitStructure(root, engine, maximum);
147
+ const identity = { a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0 };
148
+ const stack = [];
149
+ let winner;
150
+ function enter(node, parentMatrix) {
151
+ const visual = visualOf(node);
152
+ if (!visual.visible)
153
+ return;
154
+ const matrix = composeDisplayTransform(parentMatrix, visual);
155
+ if (!finite(matrix.a) ||
156
+ !finite(matrix.b) ||
157
+ !finite(matrix.c) ||
158
+ !finite(matrix.d) ||
159
+ !finite(matrix.tx) ||
160
+ !finite(matrix.ty)) {
161
+ throw new EgretError('HIT_TEST_ARITHMETIC_RANGE');
162
+ }
163
+ if (!nonsingular(matrix))
164
+ return;
165
+ let localPoint;
166
+ const clip = visual.clipRect;
167
+ if (clip !== undefined) {
168
+ // Existing clip admission allows finite dimensions with infinite sums.
169
+ // Evaluate endpoint validity before empty suppression, only when active.
170
+ if (!finite(clip.x + clip.width) || !finite(clip.y + clip.height))
171
+ throw new EgretError('HIT_TEST_ARITHMETIC_RANGE');
172
+ if (clip.width === 0 || clip.height === 0)
173
+ return;
174
+ localPoint = inversePoint(matrix, globalX, globalY);
175
+ if (!contains(clip, localPoint))
176
+ return;
177
+ }
178
+ const state = readDisplayHitState(node);
179
+ const authored = state.hitArea;
180
+ // An authored area of no size stays what it was: nothing to hit. Without an area, the node's own drawing is the area.
181
+ const area = node === root || !state.touchEnabled
182
+ ? undefined
183
+ : authored === undefined
184
+ ? true
185
+ : authored.width > 0 && authored.height > 0
186
+ ? authored
187
+ : undefined;
188
+ stack.push({
189
+ node,
190
+ matrix,
191
+ area,
192
+ localPoint,
193
+ nextChild: state.touchChildren === false ? -1 : childCountOf(node) - 1
194
+ });
195
+ }
196
+ enter(root, identity);
197
+ while (stack.length !== 0) {
198
+ const cursor = stack[stack.length - 1];
199
+ if (cursor.nextChild >= 0) {
200
+ const child = childAtOf(cursor.node, cursor.nextChild--);
201
+ if (child === undefined)
202
+ throw new EgretError('DISPLAY_TREE_INVARIANT');
203
+ enter(child, cursor.matrix);
204
+ continue;
205
+ }
206
+ if (cursor.area !== undefined) {
207
+ const localPoint = cursor.localPoint ?? inversePoint(cursor.matrix, globalX, globalY);
208
+ // Keep evaluating every eligible candidate after the first winner so a
209
+ // topmost hit cannot hide another active branch's arithmetic failure.
210
+ if (winner === undefined &&
211
+ (cursor.area === true ? onContent(cursor.node, localPoint) : contains(cursor.area, localPoint)))
212
+ winner = cursor.node;
213
+ }
214
+ stack.pop();
215
+ }
216
+ live(root, engine);
217
+ return winner;
218
+ }
219
+ //# sourceMappingURL=displayHitTest.js.map
@@ -0,0 +1,12 @@
1
+ import type { DisplayObject } from "./DisplayObject.js";
2
+ import type { Event } from "./Event.js";
3
+ import type { Stage } from "./Stage.js";
4
+ /** Engine assembly port; absent from the public Engine and browser entries. */
5
+ export interface DisplayInputOperations {
6
+ pick(x: number, y: number, maxNodes: number): DisplayObject | undefined;
7
+ isAttached(target: DisplayObject, maxNodes: number): boolean;
8
+ dispatch<T>(target: DisplayObject, event: Event<T>, maxNodes: number): boolean;
9
+ }
10
+ /** Bind only a genuine Stage and its existing private Engine affinity. */
11
+ export declare function createDisplayInputOperations(stage: Stage): DisplayInputOperations;
12
+ //# sourceMappingURL=displayInputOperations.d.ts.map
@@ -0,0 +1,71 @@
1
+ import { dispatchDisplayInputEvent } from "./EventDispatcher.js";
2
+ import { EgretError } from "./EgretError.js";
3
+ import { queryDisplayHit } from "./displayHitTest.js";
4
+ import { assertLive, isDisplayNode, isStageRoot, isTerminated, parentOf } from "./displayTreeState.js";
5
+ import { engineOf } from "./ownership.js";
6
+ /** Bind only a genuine Stage and its existing private Engine affinity. */
7
+ export function createDisplayInputOperations(stage) {
8
+ if (!isStageRoot(stage))
9
+ throw new EgretError("HIT_TEST_RECEIVER_INVALID");
10
+ assertLive(stage);
11
+ const context = engineOf(stage);
12
+ if (context === undefined || parentOf(stage) !== undefined)
13
+ throw new EgretError("DISPLAY_TREE_INVARIANT");
14
+ const engine = context;
15
+ engine.assertOpen();
16
+ function routeToStage(target, maxNodes) {
17
+ // Root and Engine failures retain their existing identity before target refusal.
18
+ assertLive(stage);
19
+ engine.assertOpen();
20
+ if (engineOf(stage) !== engine || parentOf(stage) !== undefined)
21
+ throw new EgretError("DISPLAY_TREE_INVARIANT");
22
+ if (!Number.isFinite(maxNodes) || !Number.isInteger(maxNodes) || maxNodes < 1 || maxNodes > 65536) {
23
+ throw new EgretError("HIT_TEST_INPUT_INVALID");
24
+ }
25
+ if (!isDisplayNode(target))
26
+ throw new EgretError("DISPLAY_TREE_INVARIANT");
27
+ if (isStageRoot(target) || isTerminated(target) || engineOf(target) !== engine)
28
+ return undefined;
29
+ const seen = new Set();
30
+ const route = [];
31
+ let current = target;
32
+ for (;;) {
33
+ if (seen.size >= maxNodes)
34
+ throw new EgretError("HIT_TEST_TREE_LIMIT");
35
+ if (!isDisplayNode(current) || seen.has(current))
36
+ throw new EgretError("DISPLAY_TREE_INVARIANT");
37
+ if (isTerminated(current) || engineOf(current) !== engine)
38
+ return undefined;
39
+ seen.add(current);
40
+ route.push(current);
41
+ if (current === stage)
42
+ return route;
43
+ if (isStageRoot(current))
44
+ return undefined;
45
+ // The target and captured Stage both count; debit before reading a parent.
46
+ if (seen.size >= maxNodes)
47
+ throw new EgretError("HIT_TEST_TREE_LIMIT");
48
+ const parent = parentOf(current);
49
+ if (parent === undefined)
50
+ return undefined;
51
+ current = parent;
52
+ }
53
+ }
54
+ return Object.freeze({
55
+ pick(x, y, maxNodes) {
56
+ // Reuse HT1's complete structural and arithmetic admission unchanged.
57
+ return queryDisplayHit(stage, x, y, { maxNodes });
58
+ },
59
+ isAttached(target, maxNodes) {
60
+ return routeToStage(target, maxNodes) !== undefined;
61
+ },
62
+ dispatch(target, event, maxNodes) {
63
+ const route = routeToStage(target, maxNodes);
64
+ if (route === undefined)
65
+ return false;
66
+ // No public dispatch, lifetime, parent or candidate hook is input authority.
67
+ return dispatchDisplayInputEvent(target, event, route.slice(1));
68
+ }
69
+ });
70
+ }
71
+ //# sourceMappingURL=displayInputOperations.js.map
@@ -0,0 +1,5 @@
1
+ import type { Matrix2D } from '@egret/contracts';
2
+ import type { VisualState } from './displayVisualState.js';
3
+ /** Preserve capture's parent-times-local binary64 expression order exactly. */
4
+ export declare function composeDisplayTransform(p: Matrix2D, s: VisualState): Matrix2D;
5
+ //# sourceMappingURL=displayTransform.d.ts.map
@@ -0,0 +1,38 @@
1
+ /** Preserve capture's parent-times-local binary64 expression order exactly. */
2
+ export function composeDisplayTransform(p, s) {
3
+ const angle = ((s.rotation % 360) * Math.PI) / 180;
4
+ const cos = Math.cos(angle);
5
+ const sin = Math.sin(angle);
6
+ // Without skew the two axes turn together, by the expressions this always used. With skew, the x axis is turned by
7
+ // the rotation and skewY, and the y axis by the rotation and skewX.
8
+ let a = cos * s.scaleX, b = sin * s.scaleX, c = -sin * s.scaleY, d = cos * s.scaleY;
9
+ if (s.skewX !== 0 || s.skewY !== 0) {
10
+ const xAxis = (((s.rotation + s.skewY) % 360) * Math.PI) / 180, yAxis = (((s.rotation + s.skewX) % 360) * Math.PI) / 180;
11
+ a = Math.cos(xAxis) * s.scaleX;
12
+ b = Math.sin(xAxis) * s.scaleX;
13
+ c = -Math.sin(yAxis) * s.scaleY;
14
+ d = Math.cos(yAxis) * s.scaleY;
15
+ }
16
+ // Keep the original zero-pivot expressions, including signed-zero behavior.
17
+ if (s.anchorOffsetX === 0 && s.anchorOffsetY === 0)
18
+ return {
19
+ a: p.a * a + p.c * b,
20
+ b: p.b * a + p.d * b,
21
+ c: p.a * c + p.c * d,
22
+ d: p.b * c + p.d * d,
23
+ tx: p.a * s.x + p.c * s.y + p.tx,
24
+ ty: p.b * s.x + p.d * s.y + p.ty
25
+ };
26
+ // Subtract the transformed local pivot before composing with the parent.
27
+ const localX = s.x - a * s.anchorOffsetX - c * s.anchorOffsetY;
28
+ const localY = s.y - b * s.anchorOffsetX - d * s.anchorOffsetY;
29
+ return {
30
+ a: p.a * a + p.c * b,
31
+ b: p.b * a + p.d * b,
32
+ c: p.a * c + p.c * d,
33
+ d: p.b * c + p.d * d,
34
+ tx: p.a * localX + p.c * localY + p.tx,
35
+ ty: p.b * localX + p.d * localY + p.ty
36
+ };
37
+ }
38
+ //# sourceMappingURL=displayTransform.js.map
@@ -0,0 +1,90 @@
1
+ import type { DisplayObject } from "./DisplayObject.js";
2
+ import type { DisplayObjectContainer } from "./DisplayObjectContainer.js";
3
+ import type { Stage } from "./Stage.js";
4
+ export declare function registerNode(node: DisplayObject): void;
5
+ export declare function registerContainer(node: DisplayObjectContainer): void;
6
+ /** Authenticate an actual registered container without inspecting its shape. */
7
+ export declare function assertContainer(value: object): void;
8
+ export declare function markStageRoot(node: DisplayObject): void;
9
+ /** Identity-only authentication never reads a forged or proxied Stage. */
10
+ export declare function isStageRoot(value: unknown): value is Stage;
11
+ export declare function isDisplayNode(value: object): value is DisplayObject;
12
+ export declare function isTerminated(node: DisplayObject): boolean;
13
+ export declare function parentOf(node: DisplayObject): DisplayObjectContainer | undefined;
14
+ /** Return a snapshot so callers cannot mutate the authoritative child list. */
15
+ export declare function childrenOf(node: DisplayObject): readonly DisplayObject[];
16
+ /** Callback-free O(1) readers for budgeted traversal; never clone the list. */
17
+ export declare function childCountOf(node: DisplayObject): number;
18
+ export declare function childAtOf(node: DisplayObject, index: number): DisplayObject | undefined;
19
+ /** Read the exact direct-child index in O(n), without a snapshot or callbacks. */
20
+ export declare function childIndexOf(parent: DisplayObjectContainer, child: DisplayObject): number;
21
+ export declare function assertLive(node: DisplayObject): void;
22
+ export declare function assertAttachable(node: DisplayObject): void;
23
+ export declare function assertNoCycle(parent: DisplayObjectContainer, child: DisplayObject): void;
24
+ export declare function detachNode(child: DisplayObject): void;
25
+ /** Caller has completed validation; mutation has no subclass callbacks. */
26
+ export declare function attachNode(parent: DisplayObjectContainer, child: DisplayObject): void;
27
+ export declare function removeNode(parent: DisplayObjectContainer, child: DisplayObject): void;
28
+ /** Preflight every direct edge, then detach the batch without user callbacks. */
29
+ export declare function detachChildren(parent: DisplayObjectContainer): void;
30
+ export declare function setNodeIndex(parent: DisplayObjectContainer, child: DisplayObject, index: number): void;
31
+ export declare function terminateNode(node: DisplayObject): void;
32
+ /** Runtime-private records preserve ordered refusals until after Engine selection. */
33
+ export interface CapturedInsertionNode {
34
+ readonly node: DisplayObject | undefined;
35
+ readonly actualParent: DisplayObjectContainer | undefined;
36
+ readonly children: readonly DisplayObject[] | undefined;
37
+ readonly genuine: boolean;
38
+ readonly terminated: boolean;
39
+ readonly stageRoot: boolean;
40
+ readonly repeated: boolean;
41
+ readonly edgeAgrees: boolean;
42
+ }
43
+ export interface CapturedChildInsertion {
44
+ readonly receiver: DisplayObjectContainer;
45
+ readonly child: DisplayObject;
46
+ readonly receiverTree: readonly CapturedInsertionNode[];
47
+ readonly incomingTree: readonly CapturedInsertionNode[];
48
+ readonly receiverAncestors: readonly DisplayObject[];
49
+ readonly repeatedAncestor: boolean;
50
+ readonly targetChildren: readonly DisplayObject[];
51
+ readonly oldParent: DisplayObjectContainer | undefined;
52
+ readonly sourceChildren: readonly DisplayObject[] | undefined;
53
+ readonly sourceEdges: readonly CapturedInsertionNode[];
54
+ readonly sourceContainerGenuine: boolean;
55
+ readonly oldIndex: number;
56
+ }
57
+ /** The publication port receives fully allocated replacements, never public tokens. */
58
+ export interface PreparedInsertionTree {
59
+ readonly capture: CapturedChildInsertion;
60
+ readonly effectiveIndex: number;
61
+ readonly targetReplacement: DisplayObject[] | undefined;
62
+ readonly sourceReplacement: DisplayObject[] | undefined;
63
+ readonly parentChanged: boolean;
64
+ }
65
+ /** Capture the complete posthook authority once, without semantic refusals or hooks. */
66
+ export declare function captureChildInsertion(receiver: DisplayObjectContainer, child: DisplayObject): CapturedChildInsertion;
67
+ /** Inclusive index checks never coerce boxed, string or other caller values. */
68
+ export declare function assertChildInsertionIndex(receiver: DisplayObjectContainer, index: number): void;
69
+ /** Engine openness is checked by ownership before these ordered root semantics. */
70
+ export declare function validateCapturedInsertionRoots(capture: CapturedChildInsertion, index: number): void;
71
+ /** Identity, life and edge checks precede the corresponding recorded affinity check. */
72
+ export declare function validateCapturedInsertionNode(record: CapturedInsertionNode): void;
73
+ /** Validate every current distinct-source direct edge, including unrelated siblings. */
74
+ export declare function validateCapturedInsertionSource(capture: CapturedChildInsertion): void;
75
+ /** Build both replacements solely from the validated capture; no mapping writes occur. */
76
+ export declare function prepareCapturedInsertionTree(capture: CapturedChildInsertion, index: number): PreparedInsertionTree;
77
+ /** Publication uses captured native writes only: source, target, then moved parent. */
78
+ export declare function publishCapturedInsertionTree(plan: PreparedInsertionTree): void;
79
+ /** UI-only preallocated list replacement, after complete private validation. */
80
+ export interface UiTreeReplacement {
81
+ readonly parent: DisplayObjectContainer;
82
+ readonly previous: readonly DisplayObject[];
83
+ readonly next: DisplayObject[];
84
+ }
85
+ export declare function captureUiChildren(parent: DisplayObjectContainer): DisplayObject[];
86
+ export declare function validateUiChildren(parent: DisplayObjectContainer, expected: readonly DisplayObject[]): boolean;
87
+ export declare function publishUiTree(replacements: readonly UiTreeReplacement[]): void;
88
+ /** One validated borrowed-child replacement; all storage was allocated in preparation. */
89
+ export declare function publishPreparedChildren(parent: DisplayObjectContainer, previous: readonly DisplayObject[], next: DisplayObject[]): void;
90
+ //# sourceMappingURL=displayTreeState.d.ts.map