@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,384 @@
1
+ import { DisplayObjectContainer } from '../DisplayObjectContainer.js';
2
+ import { Scope } from '../Scope.js';
3
+ import { EgretError } from '../EgretError.js';
4
+ import { engineOf, ownerOf, preflightBinding } from '../ownership.js';
5
+ import { captureUiChildren, childAtOf, childCountOf, detachNode, isDisplayNode, isStageRoot, isTerminated, parentOf, publishUiTree, validateUiChildren } from '../displayTreeState.js';
6
+ import { copyRect, finite, recordVisualChange, visualOf, VISUAL_APPEARANCE, VISUAL_TRANSFORM } from '../displayVisualState.js';
7
+ import { readDisplayHitState } from '../displayHitState.js';
8
+ import { cleanupManagedWrapper, isManagedWrapper, managedBy, managedTerminal, registerManagedWrapper } from './managedState.js';
9
+ const scopeUse = Scope.prototype.use;
10
+ const scopeState = Object.getOwnPropertyDescriptor(Scope.prototype, 'state').get;
11
+ const containerDispose = DisplayObjectContainer.prototype.dispose;
12
+ const own = Object.prototype.hasOwnProperty;
13
+ const MAX_UPDATES = 8192;
14
+ function refuse(code = 'UI_CONTENT_INVALID', reason) {
15
+ throw new EgretError(code, reason === undefined ? {} : { cause: new Error(reason) });
16
+ }
17
+ /** A callback-capable array exposes exactly one admitted finite capture boundary. */
18
+ function captureArrayCount(value) {
19
+ if (!Array.isArray(value))
20
+ refuse('UI_CAP_EXCEEDED');
21
+ const count = value.length;
22
+ if (typeof count !== 'number' || !Number.isInteger(count) || count < 0 || count > MAX_UPDATES)
23
+ refuse('UI_CAP_EXCEEDED');
24
+ return count;
25
+ }
26
+ function rectangle(value) {
27
+ if (value === undefined)
28
+ return undefined;
29
+ const result = copyRect(value, 'UI_VALUE_INVALID');
30
+ if (!finite(result.x + result.width) || !finite(result.y + result.height))
31
+ refuse('UI_VALUE_INVALID');
32
+ return result;
33
+ }
34
+ /** Create a single root publication authority over the original genuine Stage. */
35
+ export function createUiDisplayOperations(stage) {
36
+ if (!isStageRoot(stage))
37
+ refuse('UI_OWNER_INVALID');
38
+ const engine = engineOf(stage);
39
+ if (engine === undefined)
40
+ refuse('UI_OWNER_INVALID');
41
+ const authority = {};
42
+ const plans = new WeakMap();
43
+ let epoch = 0;
44
+ let mountedRoot;
45
+ let detached = false;
46
+ function assertStage() {
47
+ engine.assertOpen();
48
+ if (isTerminated(stage))
49
+ refuse('UI_OWNER_INVALID');
50
+ const state = visualOf(stage);
51
+ if (state.x !== 0 ||
52
+ state.y !== 0 ||
53
+ state.scaleX !== 1 ||
54
+ state.scaleY !== 1 ||
55
+ state.rotation !== 0 ||
56
+ state.anchorOffsetX !== 0 ||
57
+ state.anchorOffsetY !== 0)
58
+ refuse('UI_STAGE_TRANSFORM_UNSUPPORTED');
59
+ }
60
+ function assertWrapper(wrapper) {
61
+ if (!managedBy(wrapper, authority) || isTerminated(wrapper) || engineOf(wrapper) !== engine)
62
+ refuse('UI_OWNER_INVALID');
63
+ const scope = ownerOf(wrapper);
64
+ if (scope === undefined || scopeState.call(scope) !== 'open')
65
+ refuse('UI_OWNER_INVALID');
66
+ }
67
+ function validateContent(content, scope) {
68
+ if (scopeState.call(scope) !== 'open')
69
+ refuse('UI_CONTENT_INVALID', 'the scope of the leaf is closed');
70
+ const pending = [{ node: content, depth: 1 }];
71
+ const seen = new Set();
72
+ while (pending.length !== 0) {
73
+ const { node, depth } = pending.pop();
74
+ const what = node === content ? 'the content' : 'a display object inside the content';
75
+ if (!isDisplayNode(node))
76
+ refuse('UI_CONTENT_INVALID', what + ' is not a display object');
77
+ if (isTerminated(node) || managedTerminal(node))
78
+ refuse('UI_CONTENT_INVALID', what + ' is disposed');
79
+ if (isStageRoot(node))
80
+ refuse('UI_CONTENT_INVALID', what + ' is the stage');
81
+ if (seen.has(node))
82
+ refuse('UI_CONTENT_INVALID', what + ' appears twice');
83
+ if (depth > 8 || seen.size >= 32)
84
+ refuse('UI_CONTENT_INVALID', 'the content has more than 32 display objects, or is deeper than 8');
85
+ if (ownerOf(node) !== scope)
86
+ refuse('UI_CONTENT_INVALID', what +
87
+ ' does not belong to the scope of the leaf: make it with `context.scope.use(...)` in `prepare`, ' +
88
+ 'or give that scope to whatever makes it (such as `createLabel({ scope })`)');
89
+ if (engineOf(node) !== engine)
90
+ refuse('UI_CONTENT_INVALID', what + ' belongs to another Engine');
91
+ if (isManagedWrapper(node))
92
+ refuse('UI_CONTENT_INVALID', what + ' is a node the UI made itself');
93
+ seen.add(node);
94
+ const parent = parentOf(node);
95
+ if (node === content && parent !== undefined && !managedBy(parent, authority))
96
+ refuse('UI_CONTENT_INVALID', 'the content is already a child of another display object: remove it first');
97
+ const childCount = childCountOf(node);
98
+ // Refuse before allocating a frontier wider than the remaining subtree budget.
99
+ if (childCount > 32 - seen.size - pending.length || (depth === 8 && childCount !== 0))
100
+ refuse('UI_CONTENT_INVALID', 'the content has more than 32 display objects, or is deeper than 8');
101
+ for (let index = 0; index < childCount; index++) {
102
+ const child = childAtOf(node, index);
103
+ if (parentOf(child) !== node)
104
+ refuse();
105
+ pending.push({ node: child, depth: depth + 1 });
106
+ }
107
+ }
108
+ }
109
+ function capture(node) {
110
+ const children = [];
111
+ for (let index = 0; index < childCountOf(node); index++)
112
+ children.push(childAtOf(node, index));
113
+ return { node, parent: parentOf(node), owner: ownerOf(node), children };
114
+ }
115
+ function validatePlan(plan) {
116
+ if (detached || plan.epoch !== epoch || (mountedRoot !== undefined && mountedRoot !== plan.root))
117
+ refuse('UI_STALE_PREPARATION');
118
+ for (let index = 0; index < plan.nodes.length; index++) {
119
+ const item = plan.nodes[index], node = item.node;
120
+ if (isTerminated(node) ||
121
+ ownerOf(node) !== item.owner ||
122
+ engineOf(node) !== engine ||
123
+ parentOf(node) !== item.parent ||
124
+ childCountOf(node) !== item.children.length)
125
+ refuse('UI_STALE_PREPARATION');
126
+ for (let childIndex = 0; childIndex < item.children.length; childIndex++) {
127
+ if (childAtOf(node, childIndex) !== item.children[childIndex] || parentOf(item.children[childIndex]) !== node)
128
+ refuse('UI_STALE_PREPARATION');
129
+ }
130
+ if (item.owner !== undefined && scopeState.call(item.owner) !== 'open')
131
+ refuse('UI_STALE_PREPARATION');
132
+ }
133
+ for (let index = 0; index < plan.replacements.length; index++) {
134
+ const replacement = plan.replacements[index];
135
+ if (!validateUiChildren(replacement.parent, replacement.previous))
136
+ refuse('UI_STALE_PREPARATION');
137
+ }
138
+ }
139
+ assertStage();
140
+ return Object.freeze({
141
+ assertStage,
142
+ createWrapper(scope) {
143
+ assertStage();
144
+ const wrapper = new DisplayObjectContainer();
145
+ try {
146
+ scopeUse.call(scope, wrapper);
147
+ if (engineOf(wrapper) !== engine)
148
+ refuse('UI_OWNER_INVALID');
149
+ registerManagedWrapper(wrapper, authority, () => containerDispose.call(wrapper));
150
+ return wrapper;
151
+ }
152
+ catch (cause) {
153
+ containerDispose.call(wrapper);
154
+ throw cause;
155
+ }
156
+ },
157
+ validateContent,
158
+ prepare(root, sources) {
159
+ assertStage();
160
+ assertWrapper(root);
161
+ if (detached || (mountedRoot !== undefined && mountedRoot !== root))
162
+ refuse('UI_OWNER_INVALID');
163
+ const baseEpoch = epoch;
164
+ const sourceCount = captureArrayCount(sources);
165
+ const replacements = [];
166
+ const updates = [];
167
+ const seen = new Set();
168
+ const contents = [];
169
+ for (let index = 0; index < sourceCount; index++) {
170
+ const source = sources[index], wrapper = source.wrapper;
171
+ assertWrapper(wrapper);
172
+ if (seen.has(wrapper))
173
+ refuse('UI_CONTENT_INVALID');
174
+ seen.add(wrapper);
175
+ const visual = visualOf(wrapper), hit = readDisplayHitState(wrapper);
176
+ const x = own.call(source, 'x') ? source.x : visual.x, y = own.call(source, 'y') ? source.y : visual.y;
177
+ const visible = own.call(source, 'visible') ? source.visible : visual.visible;
178
+ const touchEnabled = own.call(source, 'touchEnabled') ? source.touchEnabled : hit.touchEnabled;
179
+ const touchChildren = own.call(source, 'touchChildren') ? source.touchChildren : hit.touchChildren;
180
+ const clipRect = own.call(source, 'clipRect') ? rectangle(source.clipRect) : visual.clipRect;
181
+ const hitArea = own.call(source, 'hitArea') ? rectangle(source.hitArea) : hit.hitArea;
182
+ if (!finite(x) ||
183
+ !finite(y) ||
184
+ typeof visible !== 'boolean' ||
185
+ typeof touchEnabled !== 'boolean' ||
186
+ typeof touchChildren !== 'boolean')
187
+ refuse('UI_VALUE_INVALID');
188
+ updates.push({ wrapper, visual, hit, x, y, visible, touchEnabled, touchChildren, clipRect, hitArea });
189
+ const children = source.children;
190
+ if (children !== undefined) {
191
+ const childCount = captureArrayCount(children);
192
+ const next = [];
193
+ for (let childIndex = 0; childIndex < childCount; childIndex++) {
194
+ const child = children[childIndex];
195
+ if (managedBy(child, authority))
196
+ assertWrapper(child);
197
+ else {
198
+ const scope = ownerOf(wrapper);
199
+ validateContent(child, scope);
200
+ contents.push({ node: child, scope });
201
+ }
202
+ next.push(child);
203
+ }
204
+ replacements.push({ parent: wrapper, previous: captureUiChildren(wrapper), next });
205
+ }
206
+ }
207
+ // Hooks are preparation only. Revalidate every content after the final hook.
208
+ for (let index = 0; index < contents.length; index++)
209
+ preflightBinding(contents[index].node, engine);
210
+ for (let index = 0; index < contents.length; index++)
211
+ validateContent(contents[index].node, contents[index].scope);
212
+ assertStage();
213
+ assertWrapper(root);
214
+ if (epoch !== baseEpoch || detached)
215
+ refuse('UI_STALE_PREPARATION');
216
+ const stageChildren = captureUiChildren(stage);
217
+ const rootParent = parentOf(root);
218
+ if (rootParent !== undefined && rootParent !== stage)
219
+ refuse('UI_CONTENT_INVALID');
220
+ const nextStage = stageChildren.slice();
221
+ if (rootParent === undefined)
222
+ nextStage.push(root);
223
+ replacements.push({ parent: stage, previous: stageChildren, next: nextStage });
224
+ const desiredParents = new Map();
225
+ const replaced = new Set();
226
+ for (let index = 0; index < replacements.length; index++)
227
+ replaced.add(replacements[index].parent);
228
+ for (let index = 0; index < replacements.length; index++) {
229
+ const item = replacements[index];
230
+ for (let childIndex = 0; childIndex < item.next.length; childIndex++) {
231
+ const child = item.next[childIndex];
232
+ if (desiredParents.has(child))
233
+ refuse();
234
+ desiredParents.set(child, item.parent);
235
+ const oldParent = parentOf(child);
236
+ if (oldParent !== undefined && oldParent !== item.parent && !replaced.has(oldParent))
237
+ refuse();
238
+ }
239
+ }
240
+ // Walk final ancestry to reject cycles, including unchanged intermediate edges.
241
+ for (const [child] of desiredParents) {
242
+ const ancestors = new Set();
243
+ let current = child;
244
+ while (current !== undefined) {
245
+ if (ancestors.has(current))
246
+ refuse();
247
+ ancestors.add(current);
248
+ const previous = parentOf(current);
249
+ current =
250
+ desiredParents.get(current) ?? (previous !== undefined && replaced.has(previous) ? undefined : previous);
251
+ }
252
+ }
253
+ const nodes = [];
254
+ const captured = new Set();
255
+ const pending = [root];
256
+ for (let index = 0; index < replacements.length; index++) {
257
+ const item = replacements[index];
258
+ if (item.parent !== stage)
259
+ for (let childIndex = 0; childIndex < item.next.length; childIndex++)
260
+ pending.push(item.next[childIndex]);
261
+ }
262
+ for (let index = 0; index < updates.length; index++) {
263
+ assertWrapper(updates[index].wrapper);
264
+ pending.push(updates[index].wrapper);
265
+ }
266
+ for (let index = 0; index < contents.length; index++)
267
+ pending.push(contents[index].node);
268
+ while (pending.length !== 0) {
269
+ const node = pending.pop();
270
+ if (captured.has(node))
271
+ continue;
272
+ captured.add(node);
273
+ const entry = capture(node);
274
+ nodes.push(entry);
275
+ for (let index = 0; index < entry.children.length; index++)
276
+ pending.push(entry.children[index]);
277
+ }
278
+ const plan = { epoch, root, nodes, replacements, updates };
279
+ validatePlan(plan);
280
+ const token = Object.freeze({});
281
+ plans.set(token, plan);
282
+ return token;
283
+ },
284
+ commit(token) {
285
+ const plan = plans.get(token);
286
+ if (plan === undefined)
287
+ refuse('UI_STALE_PREPARATION');
288
+ plans.delete(token);
289
+ assertStage();
290
+ validatePlan(plan);
291
+ // All callbacks, validation and allocations precede this straight-line publication.
292
+ publishUiTree(plan.replacements);
293
+ for (let index = 0; index < plan.updates.length; index++) {
294
+ const item = plan.updates[index];
295
+ item.visual.x = item.x;
296
+ item.visual.y = item.y;
297
+ item.visual.visible = item.visible;
298
+ item.visual.clipRect = item.clipRect;
299
+ item.hit.hitArea = item.hitArea;
300
+ item.hit.touchEnabled = item.touchEnabled;
301
+ item.hit.touchChildren = item.touchChildren;
302
+ recordVisualChange(item.wrapper, VISUAL_TRANSFORM | VISUAL_APPEARANCE);
303
+ }
304
+ mountedRoot = plan.root;
305
+ epoch++;
306
+ },
307
+ presentRoot(root, value) {
308
+ // Capture external descriptors before revalidating the genuine owned root/Stage.
309
+ const x = value.x, y = value.y, visible = value.visible, interactive = value.interactive, index = value.index;
310
+ if (!finite(x) ||
311
+ !finite(y) ||
312
+ typeof visible !== 'boolean' ||
313
+ typeof interactive !== 'boolean' ||
314
+ (index !== undefined && (!Number.isInteger(index) || index < 0 || index >= childCountOf(stage))))
315
+ refuse('UI_VALUE_INVALID');
316
+ assertStage();
317
+ assertWrapper(root);
318
+ if (detached || mountedRoot !== root || parentOf(root) !== stage)
319
+ refuse('UI_OWNER_INVALID');
320
+ if (index !== undefined) {
321
+ const previous = captureUiChildren(stage), next = previous.slice(), at = next.indexOf(root);
322
+ if (at < 0)
323
+ refuse('UI_OWNER_INVALID');
324
+ if (at !== index) {
325
+ next.splice(at, 1);
326
+ next.splice(index, 0, root);
327
+ publishUiTree([{ parent: stage, previous, next }]);
328
+ }
329
+ }
330
+ const visual = visualOf(root), hit = readDisplayHitState(root);
331
+ if (visual.x !== x || visual.y !== y || visual.visible !== visible || hit.touchChildren !== interactive) {
332
+ visual.x = x;
333
+ visual.y = y;
334
+ visual.visible = visible;
335
+ hit.touchEnabled = false;
336
+ hit.touchChildren = interactive;
337
+ recordVisualChange(root, VISUAL_TRANSFORM | VISUAL_APPEARANCE);
338
+ }
339
+ epoch++;
340
+ },
341
+ releaseRoot(root, value) {
342
+ const x = value.x, y = value.y, visible = value.visible;
343
+ if (!finite(x) || !finite(y) || typeof visible !== 'boolean')
344
+ refuse('UI_VALUE_INVALID');
345
+ if (!managedBy(root, authority) ||
346
+ isTerminated(root) ||
347
+ detached ||
348
+ mountedRoot !== root ||
349
+ parentOf(root) !== stage)
350
+ refuse('UI_OWNER_INVALID');
351
+ const visual = visualOf(root), hit = readDisplayHitState(root);
352
+ visual.x = x;
353
+ visual.y = y;
354
+ visual.visible = visible;
355
+ hit.touchEnabled = false;
356
+ hit.touchChildren = visible;
357
+ recordVisualChange(root, VISUAL_TRANSFORM | VISUAL_APPEARANCE);
358
+ epoch++;
359
+ },
360
+ detach(root) {
361
+ if (detached)
362
+ return;
363
+ if (!managedBy(root, authority) && !managedTerminal(root))
364
+ refuse('UI_OWNER_INVALID');
365
+ if (mountedRoot !== undefined && root !== mountedRoot)
366
+ refuse('UI_OWNER_INVALID');
367
+ detached = true;
368
+ epoch++;
369
+ visualOf(root).visible = false;
370
+ readDisplayHitState(root).touchEnabled = false;
371
+ detachNode(root);
372
+ recordVisualChange(root, VISUAL_APPEARANCE);
373
+ },
374
+ disposeWrapper(wrapper) {
375
+ if (managedTerminal(wrapper))
376
+ return;
377
+ if (!managedBy(wrapper, authority))
378
+ refuse('UI_OWNER_INVALID');
379
+ epoch++;
380
+ cleanupManagedWrapper(wrapper);
381
+ }
382
+ });
383
+ }
384
+ //# sourceMappingURL=displayCommit.js.map
@@ -0,0 +1,3 @@
1
+ export { createTextEditState } from './textEditState.js';
2
+ export type { TextEditSelection, TextEditSample, TextEditSession, TextEditSnapshot, TextEditResult, TextEditStateOptions, TextEditState } from './textEditTypes.js';
3
+ //# sourceMappingURL=editing.d.ts.map
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ export { createTextEditState } from './textEditState.js';
3
+ //# sourceMappingURL=editing.js.map
@@ -0,0 +1,35 @@
1
+ import type { UiHeightRecord, UiHeightUpdate, UiHeightView, UiHeightJournal, UiRowRange, UiScrollAnchor } from './types.js';
2
+ declare abstract class HeightView implements UiHeightView {
3
+ abstract readonly size: number;
4
+ abstract readonly totalHeight: number;
5
+ abstract readonly measuredCount: number;
6
+ abstract keyAt(i: number): string;
7
+ abstract versionAt(i: number): number;
8
+ abstract heightAt(i: number): number;
9
+ abstract indexOf(k: string): number;
10
+ protected abstract cell(i: number): number;
11
+ prefix(end: number): number;
12
+ find(offset: number): number;
13
+ clampScroll(scroll: number, viewport: number): number;
14
+ range(scroll: number, viewport: number, overscan?: number): UiRowRange;
15
+ anchor(scroll: number): UiScrollAnchor | undefined;
16
+ preserveAnchor(anchor: UiScrollAnchor | undefined, old: UiHeightView, viewport: number): number;
17
+ }
18
+ /** O(n) structural rebuild; point candidates retain only sparse changed cells. */
19
+ export declare class UiHeightIndex extends HeightView {
20
+ #private;
21
+ constructor(records: readonly UiHeightRecord[], width: number, density: number, previous?: UiHeightIndex);
22
+ get size(): number;
23
+ get totalHeight(): number;
24
+ get measuredCount(): number;
25
+ /** Numeric typed-array bytes only; string, map and JS heap storage excluded. */
26
+ get logicalBytes(): number;
27
+ keyAt(i: number): string;
28
+ versionAt(i: number): number;
29
+ heightAt(i: number): number;
30
+ indexOf(k: string): number;
31
+ protected cell(i: number): number;
32
+ stageHeights(updates: readonly UiHeightUpdate[]): UiHeightJournal;
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=heightIndex.d.ts.map