@egret/engine 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 (601) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +101 -2
  4. package/README.zh-CN.md +102 -0
  5. package/dist/Engine.d.ts +77 -0
  6. package/dist/Engine.js +469 -0
  7. package/dist/animation/index.d.ts +6 -0
  8. package/dist/animation/index.js +5 -0
  9. package/dist/animation/sequenceController.d.ts +22 -0
  10. package/dist/animation/sequenceController.js +618 -0
  11. package/dist/animation/sequenceCoordinator.d.ts +26 -0
  12. package/dist/animation/sequenceCoordinator.js +161 -0
  13. package/dist/animation/sequenceInput.d.ts +25 -0
  14. package/dist/animation/sequenceInput.js +108 -0
  15. package/dist/animation/sequenceMath.d.ts +35 -0
  16. package/dist/animation/sequenceMath.js +164 -0
  17. package/dist/animation/sequenceResetSlot.d.ts +7 -0
  18. package/dist/animation/sequenceResetSlot.js +367 -0
  19. package/dist/animation/sequenceResetTypes.d.ts +48 -0
  20. package/dist/animation/sequenceResetTypes.js +2 -0
  21. package/dist/animation/types.d.ts +75 -0
  22. package/dist/animation/types.js +2 -0
  23. package/dist/assetBundle.d.ts +54 -0
  24. package/dist/assetBundle.js +173 -0
  25. package/dist/assetGroup.d.ts +17 -0
  26. package/dist/assetGroup.js +332 -0
  27. package/dist/assetGroupTypes.d.ts +17 -0
  28. package/dist/assetGroupTypes.js +2 -0
  29. package/dist/audio.d.ts +4 -0
  30. package/dist/audio.js +4 -0
  31. package/dist/audioCues.d.ts +47 -0
  32. package/dist/audioCues.js +127 -0
  33. package/dist/audioMixer.d.ts +7 -0
  34. package/dist/audioMixer.js +785 -0
  35. package/dist/audioTypes.d.ts +246 -0
  36. package/dist/audioTypes.js +3 -0
  37. package/dist/bitmapBindingTicket.d.ts +24 -0
  38. package/dist/bitmapBindingTicket.js +215 -0
  39. package/dist/bitmapButton.d.ts +4 -0
  40. package/dist/bitmapButton.js +407 -0
  41. package/dist/bitmapButtonTypes.d.ts +31 -0
  42. package/dist/bitmapButtonTypes.js +2 -0
  43. package/dist/bitmapFontParse.d.ts +10 -0
  44. package/dist/bitmapFontParse.js +246 -0
  45. package/dist/bitmapFontTypes.d.ts +112 -0
  46. package/dist/bitmapFontTypes.js +2 -0
  47. package/dist/bitmapResourceSlot.d.ts +26 -0
  48. package/dist/bitmapResourceSlot.js +340 -0
  49. package/dist/bitmapText.d.ts +6 -0
  50. package/dist/bitmapText.js +320 -0
  51. package/dist/bitmapfont.d.ts +5 -0
  52. package/dist/bitmapfont.js +5 -0
  53. package/dist/camera.d.ts +4 -0
  54. package/dist/camera.js +4 -0
  55. package/dist/camera2d.d.ts +7 -0
  56. package/dist/camera2d.js +419 -0
  57. package/dist/cameraTypes.d.ts +126 -0
  58. package/dist/cameraTypes.js +2 -0
  59. package/dist/closeHost.d.ts +4 -0
  60. package/dist/closeHost.js +66 -0
  61. package/dist/contentArtifacts.d.ts +12 -0
  62. package/dist/contentArtifacts.js +153 -0
  63. package/dist/contentAtlasPages.d.ts +13 -0
  64. package/dist/contentAtlasPages.js +117 -0
  65. package/dist/contentLoader.d.ts +6 -0
  66. package/dist/contentLoader.js +327 -0
  67. package/dist/contentTypes.d.ts +35 -0
  68. package/dist/contentTypes.js +2 -0
  69. package/dist/createEngine.d.ts +7 -0
  70. package/dist/createEngine.js +25 -0
  71. package/dist/createEngineForProfile.d.ts +5 -0
  72. package/dist/createEngineForProfile.js +45 -0
  73. package/dist/displaySubtreeTicket.d.ts +25 -0
  74. package/dist/displaySubtreeTicket.js +76 -0
  75. package/dist/fontContentLoader.d.ts +6 -0
  76. package/dist/fontContentLoader.js +298 -0
  77. package/dist/fontContentTypes.d.ts +39 -0
  78. package/dist/fontContentTypes.js +2 -0
  79. package/dist/gameClock.d.ts +24 -0
  80. package/dist/gameClock.js +246 -0
  81. package/dist/gameClockTypes.d.ts +37 -0
  82. package/dist/gameClockTypes.js +2 -0
  83. package/dist/gameRun.d.ts +53 -0
  84. package/dist/gameRun.js +97 -0
  85. package/dist/gamepad.d.ts +5 -0
  86. package/dist/gamepad.js +5 -0
  87. package/dist/gamepadInput.d.ts +4 -0
  88. package/dist/gamepadInput.js +281 -0
  89. package/dist/gamepadKeys.d.ts +4 -0
  90. package/dist/gamepadKeys.js +205 -0
  91. package/dist/gamepadTypes.d.ts +142 -0
  92. package/dist/gamepadTypes.js +3 -0
  93. package/dist/hover.d.ts +4 -0
  94. package/dist/hover.js +4 -0
  95. package/dist/hoverInput.d.ts +8 -0
  96. package/dist/hoverInput.js +503 -0
  97. package/dist/hoverInputTypes.d.ts +129 -0
  98. package/dist/hoverInputTypes.js +2 -0
  99. package/dist/index.d.ts +52 -0
  100. package/dist/index.js +21 -0
  101. package/dist/input.d.ts +6 -0
  102. package/dist/input.js +5 -0
  103. package/dist/inputActions.d.ts +86 -0
  104. package/dist/inputActions.js +330 -0
  105. package/dist/internal/contentFactoryState.d.ts +19 -0
  106. package/dist/internal/contentFactoryState.js +42 -0
  107. package/dist/internal/mouseInputFactoryState.d.ts +57 -0
  108. package/dist/internal/mouseInputFactoryState.js +125 -0
  109. package/dist/internal/sequenceControllerFactoryState.d.ts +42 -0
  110. package/dist/internal/sequenceControllerFactoryState.js +98 -0
  111. package/dist/internal/textFieldFactoryState.d.ts +11 -0
  112. package/dist/internal/textFieldFactoryState.js +32 -0
  113. package/dist/internal/texturedFrameState.d.ts +4 -0
  114. package/dist/internal/texturedFrameState.js +12 -0
  115. package/dist/internal/uiFactoryState.d.ts +68 -0
  116. package/dist/internal/uiFactoryState.js +173 -0
  117. package/dist/internal/uiRootState.d.ts +67 -0
  118. package/dist/internal/uiRootState.js +103 -0
  119. package/dist/keyboardInput.d.ts +13 -0
  120. package/dist/keyboardInput.js +579 -0
  121. package/dist/keyboardInputTypes.d.ts +93 -0
  122. package/dist/keyboardInputTypes.js +2 -0
  123. package/dist/kit.d.ts +16 -0
  124. package/dist/kit.js +10 -0
  125. package/dist/layout.d.ts +5 -0
  126. package/dist/layout.js +132 -0
  127. package/dist/layoutTypes.d.ts +28 -0
  128. package/dist/layoutTypes.js +2 -0
  129. package/dist/manifestAssetGroup.d.ts +10 -0
  130. package/dist/manifestAssetGroup.js +477 -0
  131. package/dist/manifestResourceState.d.ts +17 -0
  132. package/dist/manifestResourceState.js +58 -0
  133. package/dist/manifestResourceTypes.d.ts +26 -0
  134. package/dist/manifestResourceTypes.js +2 -0
  135. package/dist/motion.d.ts +35 -0
  136. package/dist/motion.js +206 -0
  137. package/dist/mouseInput.d.ts +102 -0
  138. package/dist/mouseInput.js +562 -0
  139. package/dist/mouseInputTypes.d.ts +41 -0
  140. package/dist/mouseInputTypes.js +2 -0
  141. package/dist/paragraph.d.ts +8 -0
  142. package/dist/paragraph.js +7 -0
  143. package/dist/particleEmitter.d.ts +4 -0
  144. package/dist/particleEmitter.js +300 -0
  145. package/dist/particleTypes.d.ts +115 -0
  146. package/dist/particleTypes.js +2 -0
  147. package/dist/particles.d.ts +4 -0
  148. package/dist/particles.js +4 -0
  149. package/dist/physics2d.d.ts +4 -0
  150. package/dist/physics2d.js +4 -0
  151. package/dist/physics2dGeometry.d.ts +39 -0
  152. package/dist/physics2dGeometry.js +230 -0
  153. package/dist/physics2dTypes.d.ts +221 -0
  154. package/dist/physics2dTypes.js +2 -0
  155. package/dist/physics2dWorld.d.ts +4 -0
  156. package/dist/physics2dWorld.js +823 -0
  157. package/dist/pointerInput.d.ts +12 -0
  158. package/dist/pointerInput.js +300 -0
  159. package/dist/pointerInputTypes.d.ts +41 -0
  160. package/dist/pointerInputTypes.js +2 -0
  161. package/dist/random.d.ts +30 -0
  162. package/dist/random.js +131 -0
  163. package/dist/rendering/ownedPreparationFailure2D.d.ts +5 -0
  164. package/dist/rendering/ownedPreparationFailure2D.js +33 -0
  165. package/dist/rendering/packSharedDraws2D.d.ts +50 -0
  166. package/dist/rendering/packSharedDraws2D.js +379 -0
  167. package/dist/rendering/packedOrientation.d.ts +4 -0
  168. package/dist/rendering/packedOrientation.js +7 -0
  169. package/dist/rendering/prepareRectangles2D.d.ts +92 -0
  170. package/dist/rendering/prepareRectangles2D.js +481 -0
  171. package/dist/rendering/prepareSharedDraws2D.d.ts +90 -0
  172. package/dist/rendering/prepareSharedDraws2D.js +663 -0
  173. package/dist/rendering/preparedBatches2D.d.ts +17 -0
  174. package/dist/rendering/preparedBatches2D.js +30 -0
  175. package/dist/rendering/preparedSharedBatches2D.d.ts +44 -0
  176. package/dist/rendering/preparedSharedBatches2D.js +247 -0
  177. package/dist/rendering/sharedColor2D.d.ts +52 -0
  178. package/dist/rendering/sharedColor2D.js +191 -0
  179. package/dist/rendering/sharedEffects2D.d.ts +23 -0
  180. package/dist/rendering/sharedEffects2D.js +126 -0
  181. package/dist/rendering/sharedPreparationRetention2D.d.ts +120 -0
  182. package/dist/rendering/sharedPreparationRetention2D.js +357 -0
  183. package/dist/rendering/srgbBytes.d.ts +3 -0
  184. package/dist/rendering/srgbBytes.js +64 -0
  185. package/dist/rendering/texturedPreparationBudget2D.d.ts +31 -0
  186. package/dist/rendering/texturedPreparationBudget2D.js +81 -0
  187. package/dist/rendering/world3d/Animation3D.d.ts +104 -0
  188. package/dist/rendering/world3d/Animation3D.js +384 -0
  189. package/dist/rendering/world3d/AnimationTexture3D.d.ts +163 -0
  190. package/dist/rendering/world3d/AnimationTexture3D.js +603 -0
  191. package/dist/rendering/world3d/Batch3D.d.ts +75 -0
  192. package/dist/rendering/world3d/Batch3D.js +332 -0
  193. package/dist/rendering/world3d/Camera3D.d.ts +62 -0
  194. package/dist/rendering/world3d/Camera3D.js +132 -0
  195. package/dist/rendering/world3d/Character3D.d.ts +127 -0
  196. package/dist/rendering/world3d/Character3D.js +305 -0
  197. package/dist/rendering/world3d/Cloth3D.d.ts +130 -0
  198. package/dist/rendering/world3d/Cloth3D.js +503 -0
  199. package/dist/rendering/world3d/Compression3D.d.ts +22 -0
  200. package/dist/rendering/world3d/Compression3D.js +703 -0
  201. package/dist/rendering/world3d/Curves3D.d.ts +119 -0
  202. package/dist/rendering/world3d/Curves3D.js +460 -0
  203. package/dist/rendering/world3d/Decal3D.d.ts +43 -0
  204. package/dist/rendering/world3d/Decal3D.js +242 -0
  205. package/dist/rendering/world3d/Export3D.d.ts +13 -0
  206. package/dist/rendering/world3d/Export3D.js +263 -0
  207. package/dist/rendering/world3d/Geometry3D.d.ts +95 -0
  208. package/dist/rendering/world3d/Geometry3D.js +335 -0
  209. package/dist/rendering/world3d/GeometryBuilder3D.d.ts +53 -0
  210. package/dist/rendering/world3d/GeometryBuilder3D.js +196 -0
  211. package/dist/rendering/world3d/Gizmo3D.d.ts +80 -0
  212. package/dist/rendering/world3d/Gizmo3D.js +514 -0
  213. package/dist/rendering/world3d/Gltf3D.d.ts +73 -0
  214. package/dist/rendering/world3d/Gltf3D.js +996 -0
  215. package/dist/rendering/world3d/GpuParticles3D.d.ts +109 -0
  216. package/dist/rendering/world3d/GpuParticles3D.js +401 -0
  217. package/dist/rendering/world3d/Hdr3D.d.ts +35 -0
  218. package/dist/rendering/world3d/Hdr3D.js +191 -0
  219. package/dist/rendering/world3d/Jelly3D.d.ts +77 -0
  220. package/dist/rendering/world3d/Jelly3D.js +267 -0
  221. package/dist/rendering/world3d/Ktx23D.d.ts +30 -0
  222. package/dist/rendering/world3d/Ktx23D.js +112 -0
  223. package/dist/rendering/world3d/Light3D.d.ts +84 -0
  224. package/dist/rendering/world3d/Light3D.js +97 -0
  225. package/dist/rendering/world3d/Material3D.d.ts +253 -0
  226. package/dist/rendering/world3d/Material3D.js +269 -0
  227. package/dist/rendering/world3d/Mesh3D.d.ts +112 -0
  228. package/dist/rendering/world3d/Mesh3D.js +337 -0
  229. package/dist/rendering/world3d/Meshopt3D.d.ts +15 -0
  230. package/dist/rendering/world3d/Meshopt3D.js +276 -0
  231. package/dist/rendering/world3d/Navigation3D.d.ts +213 -0
  232. package/dist/rendering/world3d/Navigation3D.js +1043 -0
  233. package/dist/rendering/world3d/Object3D.d.ts +118 -0
  234. package/dist/rendering/world3d/Object3D.js +315 -0
  235. package/dist/rendering/world3d/Particles3D.d.ts +90 -0
  236. package/dist/rendering/world3d/Particles3D.js +277 -0
  237. package/dist/rendering/world3d/Physics3D.d.ts +430 -0
  238. package/dist/rendering/world3d/Physics3D.js +2840 -0
  239. package/dist/rendering/world3d/PhysicsHull3D.d.ts +37 -0
  240. package/dist/rendering/world3d/PhysicsHull3D.js +229 -0
  241. package/dist/rendering/world3d/PhysicsMesh3D.d.ts +41 -0
  242. package/dist/rendering/world3d/PhysicsMesh3D.js +340 -0
  243. package/dist/rendering/world3d/PhysicsQueries3D.d.ts +24 -0
  244. package/dist/rendering/world3d/PhysicsQueries3D.js +323 -0
  245. package/dist/rendering/world3d/PhysicsRemote3D.d.ts +179 -0
  246. package/dist/rendering/world3d/PhysicsRemote3D.js +536 -0
  247. package/dist/rendering/world3d/Ragdoll3D.d.ts +74 -0
  248. package/dist/rendering/world3d/Ragdoll3D.js +202 -0
  249. package/dist/rendering/world3d/Raycast3D.d.ts +40 -0
  250. package/dist/rendering/world3d/Raycast3D.js +247 -0
  251. package/dist/rendering/world3d/RenderList3D.d.ts +91 -0
  252. package/dist/rendering/world3d/RenderList3D.js +502 -0
  253. package/dist/rendering/world3d/Retarget3D.d.ts +21 -0
  254. package/dist/rendering/world3d/Retarget3D.js +185 -0
  255. package/dist/rendering/world3d/Rig3D.d.ts +57 -0
  256. package/dist/rendering/world3d/Rig3D.js +219 -0
  257. package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
  258. package/dist/rendering/world3d/Sdf3D.js +1136 -0
  259. package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
  260. package/dist/rendering/world3d/SdfLod3D.js +56 -0
  261. package/dist/rendering/world3d/Serialize3D.d.ts +66 -0
  262. package/dist/rendering/world3d/Serialize3D.js +629 -0
  263. package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
  264. package/dist/rendering/world3d/Simplify3D.js +426 -0
  265. package/dist/rendering/world3d/StateMachine3D.d.ts +87 -0
  266. package/dist/rendering/world3d/StateMachine3D.js +280 -0
  267. package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
  268. package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
  269. package/dist/rendering/world3d/Terrain3D.d.ts +248 -0
  270. package/dist/rendering/world3d/Terrain3D.js +827 -0
  271. package/dist/rendering/world3d/Text3D.d.ts +95 -0
  272. package/dist/rendering/world3d/Text3D.js +560 -0
  273. package/dist/rendering/world3d/Texture3D.d.ts +148 -0
  274. package/dist/rendering/world3d/Texture3D.js +270 -0
  275. package/dist/rendering/world3d/Trail3D.d.ts +62 -0
  276. package/dist/rendering/world3d/Trail3D.js +195 -0
  277. package/dist/rendering/world3d/Vehicle3D.d.ts +102 -0
  278. package/dist/rendering/world3d/Vehicle3D.js +228 -0
  279. package/dist/rendering/world3d/VolumetricFog3D.d.ts +57 -0
  280. package/dist/rendering/world3d/VolumetricFog3D.js +230 -0
  281. package/dist/rendering/world3d/Water3D.d.ts +165 -0
  282. package/dist/rendering/world3d/Water3D.js +607 -0
  283. package/dist/rendering/world3d/core3D.d.ts +36 -0
  284. package/dist/rendering/world3d/core3D.js +99 -0
  285. package/dist/rendering/world3d/debug3D.d.ts +69 -0
  286. package/dist/rendering/world3d/debug3D.js +262 -0
  287. package/dist/rendering/world3d/decoders3D.d.ts +42 -0
  288. package/dist/rendering/world3d/decoders3D.js +133 -0
  289. package/dist/rendering/world3d/geometries3D.d.ts +111 -0
  290. package/dist/rendering/world3d/geometries3D.js +610 -0
  291. package/dist/rendering/world3d/helpers3D.d.ts +67 -0
  292. package/dist/rendering/world3d/helpers3D.js +178 -0
  293. package/dist/rendering/world3d/index.d.ts +103 -0
  294. package/dist/rendering/world3d/index.js +62 -0
  295. package/dist/rendering/world3d/math3D.d.ts +114 -0
  296. package/dist/rendering/world3d/math3D.js +675 -0
  297. package/dist/rendering/world3d/primitives3D.d.ts +67 -0
  298. package/dist/rendering/world3d/primitives3D.js +197 -0
  299. package/dist/resources.d.ts +8 -0
  300. package/dist/resources.js +6 -0
  301. package/dist/saveStore.d.ts +71 -0
  302. package/dist/saveStore.js +182 -0
  303. package/dist/semanticList.d.ts +126 -0
  304. package/dist/semanticList.js +175 -0
  305. package/dist/semanticTree.d.ts +10 -0
  306. package/dist/semanticTree.js +539 -0
  307. package/dist/semanticTypes.d.ts +175 -0
  308. package/dist/semanticTypes.js +2 -0
  309. package/dist/semantics.d.ts +6 -0
  310. package/dist/semantics.js +5 -0
  311. package/dist/sequencePlayback.d.ts +19 -0
  312. package/dist/sequencePlayback.js +391 -0
  313. package/dist/sequencePlaybackTypes.d.ts +24 -0
  314. package/dist/sequencePlaybackTypes.js +2 -0
  315. package/dist/sequenceTargetClaims.d.ts +10 -0
  316. package/dist/sequenceTargetClaims.js +31 -0
  317. package/dist/srgbBytes.d.ts +3 -0
  318. package/dist/srgbBytes.js +64 -0
  319. package/dist/startEngine.d.ts +5 -0
  320. package/dist/startEngine.js +31 -0
  321. package/dist/surfaceOwnership.d.ts +3 -0
  322. package/dist/surfaceOwnership.js +15 -0
  323. package/dist/text.d.ts +24 -0
  324. package/dist/text.js +4 -0
  325. package/dist/textField.d.ts +6 -0
  326. package/dist/textField.js +6 -0
  327. package/dist/textTable.d.ts +41 -0
  328. package/dist/textTable.js +114 -0
  329. package/dist/tileMapDraw.d.ts +7 -0
  330. package/dist/tileMapDraw.js +310 -0
  331. package/dist/tiledImport.d.ts +9 -0
  332. package/dist/tiledImport.js +357 -0
  333. package/dist/tilemap.d.ts +5 -0
  334. package/dist/tilemap.js +5 -0
  335. package/dist/tilemapTypes.d.ts +182 -0
  336. package/dist/tilemapTypes.js +2 -0
  337. package/dist/timer.d.ts +34 -0
  338. package/dist/timer.js +119 -0
  339. package/dist/tween.d.ts +15 -0
  340. package/dist/tween.js +329 -0
  341. package/dist/tweenTypes.d.ts +31 -0
  342. package/dist/tweenTypes.js +2 -0
  343. package/dist/ui/controlKeys.d.ts +113 -0
  344. package/dist/ui/controlKeys.js +250 -0
  345. package/dist/ui/controls.d.ts +58 -0
  346. package/dist/ui/controls.js +290 -0
  347. package/dist/ui/editing.d.ts +3 -0
  348. package/dist/ui/editing.js +3 -0
  349. package/dist/ui/index.d.ts +19 -0
  350. package/dist/ui/index.js +11 -0
  351. package/dist/ui/keyboardFocus.d.ts +32 -0
  352. package/dist/ui/keyboardFocus.js +146 -0
  353. package/dist/ui/layerTypes.d.ts +98 -0
  354. package/dist/ui/layerTypes.js +2 -0
  355. package/dist/ui/layers.d.ts +4 -0
  356. package/dist/ui/layers.js +586 -0
  357. package/dist/ui/leafContent.d.ts +21 -0
  358. package/dist/ui/leafContent.js +136 -0
  359. package/dist/ui/rangeControl.d.ts +53 -0
  360. package/dist/ui/rangeControl.js +168 -0
  361. package/dist/ui/scrollControl.d.ts +84 -0
  362. package/dist/ui/scrollControl.js +222 -0
  363. package/dist/ui/stateControls.d.ts +90 -0
  364. package/dist/ui/stateControls.js +331 -0
  365. package/dist/ui/textEditor.d.ts +54 -0
  366. package/dist/ui/textEditor.js +371 -0
  367. package/dist/ui/textEditorTypes.d.ts +85 -0
  368. package/dist/ui/textEditorTypes.js +2 -0
  369. package/dist/ui/textFieldControl.d.ts +100 -0
  370. package/dist/ui/textFieldControl.js +260 -0
  371. package/dist/ui/theme.d.ts +64 -0
  372. package/dist/ui/theme.js +166 -0
  373. package/dist/ui/types.d.ts +285 -0
  374. package/dist/ui/types.js +2 -0
  375. package/dist/ui/uiRoot.d.ts +4 -0
  376. package/dist/ui/uiRoot.js +1526 -0
  377. package/dist/ui/uiRootDisplay.d.ts +46 -0
  378. package/dist/ui/uiRootDisplay.js +148 -0
  379. package/dist/ui/uiRootModel.d.ts +114 -0
  380. package/dist/ui/uiRootModel.js +66 -0
  381. package/dist/ui/virtualList.d.ts +20 -0
  382. package/dist/ui/virtualList.js +105 -0
  383. package/dist/video.d.ts +4 -0
  384. package/dist/video.js +4 -0
  385. package/dist/videoPlayer.d.ts +4 -0
  386. package/dist/videoPlayer.js +215 -0
  387. package/dist/videoTypes.d.ts +77 -0
  388. package/dist/videoTypes.js +2 -0
  389. package/dist/web/BrowserAssetBundle.d.ts +41 -0
  390. package/dist/web/BrowserAssetBundle.js +136 -0
  391. package/dist/web/BrowserAudio.d.ts +74 -0
  392. package/dist/web/BrowserAudio.js +503 -0
  393. package/dist/web/BrowserFrameLoop.d.ts +69 -0
  394. package/dist/web/BrowserFrameLoop.js +125 -0
  395. package/dist/web/BrowserGame.d.ts +174 -0
  396. package/dist/web/BrowserGame.js +473 -0
  397. package/dist/web/BrowserGamepadInput.d.ts +38 -0
  398. package/dist/web/BrowserGamepadInput.js +134 -0
  399. package/dist/web/BrowserHoverInput.d.ts +25 -0
  400. package/dist/web/BrowserHoverInput.js +266 -0
  401. package/dist/web/BrowserImageTextures.d.ts +72 -0
  402. package/dist/web/BrowserImageTextures.js +169 -0
  403. package/dist/web/BrowserInputActions.d.ts +63 -0
  404. package/dist/web/BrowserInputActions.js +345 -0
  405. package/dist/web/BrowserKeyboardInput.d.ts +4 -0
  406. package/dist/web/BrowserKeyboardInput.js +223 -0
  407. package/dist/web/BrowserPlay.d.ts +417 -0
  408. package/dist/web/BrowserPlay.js +1648 -0
  409. package/dist/web/BrowserPointerInput.d.ts +4 -0
  410. package/dist/web/BrowserPointerInput.js +511 -0
  411. package/dist/web/BrowserPreferences.d.ts +10 -0
  412. package/dist/web/BrowserPreferences.js +39 -0
  413. package/dist/web/BrowserSemantics.d.ts +36 -0
  414. package/dist/web/BrowserSemantics.js +418 -0
  415. package/dist/web/BrowserStatsPanel.d.ts +56 -0
  416. package/dist/web/BrowserStatsPanel.js +143 -0
  417. package/dist/web/BrowserStorage.d.ts +35 -0
  418. package/dist/web/BrowserStorage.js +132 -0
  419. package/dist/web/BrowserTextEditor.d.ts +52 -0
  420. package/dist/web/BrowserTextEditor.js +839 -0
  421. package/dist/web/BrowserTextInput.d.ts +89 -0
  422. package/dist/web/BrowserTextInput.js +524 -0
  423. package/dist/web/BrowserTextureProvider.d.ts +58 -0
  424. package/dist/web/BrowserTextureProvider.js +935 -0
  425. package/dist/web/BrowserVideo.d.ts +40 -0
  426. package/dist/web/BrowserVideo.js +237 -0
  427. package/dist/web/CanvasKitFontSetProvider.d.ts +32 -0
  428. package/dist/web/CanvasKitFontSetProvider.js +215 -0
  429. package/dist/web/CanvasKitParagraphProvider.d.ts +173 -0
  430. package/dist/web/CanvasKitParagraphProvider.js +692 -0
  431. package/dist/web/CanvasTextRasterProvider.d.ts +4 -0
  432. package/dist/web/CanvasTextRasterProvider.js +312 -0
  433. package/dist/web/ManifestByteSource.d.ts +151 -0
  434. package/dist/web/ManifestByteSource.js +975 -0
  435. package/dist/web/ManifestFontContentLoader.d.ts +13 -0
  436. package/dist/web/ManifestFontContentLoader.js +30 -0
  437. package/dist/web/MouseInput.d.ts +4 -0
  438. package/dist/web/MouseInput.js +218 -0
  439. package/dist/web/WebGL2Host.d.ts +5 -0
  440. package/dist/web/WebGL2Host.js +2711 -0
  441. package/dist/web/WebGPUHost.d.ts +100 -0
  442. package/dist/web/WebGPUHost.js +3430 -0
  443. package/dist/web/audio.d.ts +3 -0
  444. package/dist/web/audio.js +4 -0
  445. package/dist/web/canvasKitParagraphGeometry.d.ts +27 -0
  446. package/dist/web/canvasKitParagraphGeometry.js +83 -0
  447. package/dist/web/editing.d.ts +5 -0
  448. package/dist/web/editing.js +4 -0
  449. package/dist/web/editorFonts.d.ts +54 -0
  450. package/dist/web/editorFonts.js +297 -0
  451. package/dist/web/game.d.ts +5 -0
  452. package/dist/web/game.js +6 -0
  453. package/dist/web/gamepad.d.ts +3 -0
  454. package/dist/web/gamepad.js +4 -0
  455. package/dist/web/hover.d.ts +3 -0
  456. package/dist/web/hover.js +4 -0
  457. package/dist/web/image.d.ts +4 -0
  458. package/dist/web/image.js +4 -0
  459. package/dist/web/imageProjections2D.d.ts +16 -0
  460. package/dist/web/imageProjections2D.js +2 -0
  461. package/dist/web/input.d.ts +6 -0
  462. package/dist/web/input.js +4 -0
  463. package/dist/web/keyboard.d.ts +3 -0
  464. package/dist/web/keyboard.js +3 -0
  465. package/dist/web/kit.d.ts +11 -0
  466. package/dist/web/kit.js +8 -0
  467. package/dist/web/loop.d.ts +3 -0
  468. package/dist/web/loop.js +4 -0
  469. package/dist/web/paragraph.d.ts +6 -0
  470. package/dist/web/paragraph.js +4 -0
  471. package/dist/web/play.d.ts +10 -0
  472. package/dist/web/play.js +9 -0
  473. package/dist/web/playMusic.d.ts +33 -0
  474. package/dist/web/playMusic.js +194 -0
  475. package/dist/web/playSfx.d.ts +36 -0
  476. package/dist/web/playSfx.js +112 -0
  477. package/dist/web/playTouch.d.ts +45 -0
  478. package/dist/web/playTouch.js +141 -0
  479. package/dist/web/playWidgets.d.ts +71 -0
  480. package/dist/web/playWidgets.js +431 -0
  481. package/dist/web/pointer.d.ts +3 -0
  482. package/dist/web/pointer.js +3 -0
  483. package/dist/web/prepareSharedSubmission2D.d.ts +27 -0
  484. package/dist/web/prepareSharedSubmission2D.js +63 -0
  485. package/dist/web/resources.d.ts +29 -0
  486. package/dist/web/resources.js +96 -0
  487. package/dist/web/semantics.d.ts +3 -0
  488. package/dist/web/semantics.js +4 -0
  489. package/dist/web/sharedDeviceSession.d.ts +64 -0
  490. package/dist/web/sharedDeviceSession.js +2 -0
  491. package/dist/web/sharedEffectShaders.d.ts +13 -0
  492. package/dist/web/sharedEffectShaders.js +181 -0
  493. package/dist/web/sharedFrameUpload.d.ts +25 -0
  494. package/dist/web/sharedFrameUpload.js +2 -0
  495. package/dist/web/sharedHostDeferred.d.ts +7 -0
  496. package/dist/web/sharedHostDeferred.js +12 -0
  497. package/dist/web/sharedRetentionLedger.d.ts +85 -0
  498. package/dist/web/sharedRetentionLedger.js +391 -0
  499. package/dist/web/sharedSubmissionStorage2D.d.ts +56 -0
  500. package/dist/web/sharedSubmissionStorage2D.js +73 -0
  501. package/dist/web/sharedWebGL2Arena.d.ts +40 -0
  502. package/dist/web/sharedWebGL2Arena.js +77 -0
  503. package/dist/web/sharedWebGL2Options.d.ts +33 -0
  504. package/dist/web/sharedWebGL2Options.js +102 -0
  505. package/dist/web/sharedWebGL2Shaders.d.ts +33 -0
  506. package/dist/web/sharedWebGL2Shaders.js +408 -0
  507. package/dist/web/sharedWebGPUOptions.d.ts +41 -0
  508. package/dist/web/sharedWebGPUOptions.js +130 -0
  509. package/dist/web/text.d.ts +3 -0
  510. package/dist/web/text.js +3 -0
  511. package/dist/web/textInput.d.ts +3 -0
  512. package/dist/web/textInput.js +3 -0
  513. package/dist/web/video.d.ts +3 -0
  514. package/dist/web/video.js +4 -0
  515. package/dist/web/webgl2.d.ts +7 -0
  516. package/dist/web/webgl2.js +4 -0
  517. package/dist/web/webgl2LayerState.d.ts +50 -0
  518. package/dist/web/webgl2LayerState.js +102 -0
  519. package/dist/web/webgl2Native.d.ts +72 -0
  520. package/dist/web/webgl2Native.js +572 -0
  521. package/dist/web/webgl2Types.d.ts +150 -0
  522. package/dist/web/webgl2Types.js +2 -0
  523. package/dist/web/webgpu.d.ts +6 -0
  524. package/dist/web/webgpu.js +2 -0
  525. package/dist/web/webgpuBindingCache.d.ts +26 -0
  526. package/dist/web/webgpuBindingCache.js +223 -0
  527. package/dist/web/webgpuBufferPool.d.ts +51 -0
  528. package/dist/web/webgpuBufferPool.js +58 -0
  529. package/dist/web/webgpuImageResidency.d.ts +56 -0
  530. package/dist/web/webgpuImageResidency.js +65 -0
  531. package/dist/web/webgpuLifetime.d.ts +45 -0
  532. package/dist/web/webgpuLifetime.js +64 -0
  533. package/dist/web/webgpuRetentionPool.d.ts +66 -0
  534. package/dist/web/webgpuRetentionPool.js +85 -0
  535. package/dist/web/webgpuSharedPass.d.ts +7 -0
  536. package/dist/web/webgpuSharedPass.js +293 -0
  537. package/dist/web/webgpuSharedResolvePass.d.ts +3 -0
  538. package/dist/web/webgpuSharedResolvePass.js +34 -0
  539. package/dist/web/world3d/Audio3D.d.ts +85 -0
  540. package/dist/web/world3d/Audio3D.js +271 -0
  541. package/dist/web/world3d/BrowserPlay3D.d.ts +295 -0
  542. package/dist/web/world3d/BrowserPlay3D.js +1256 -0
  543. package/dist/web/world3d/FlyControls3D.d.ts +59 -0
  544. package/dist/web/world3d/FlyControls3D.js +162 -0
  545. package/dist/web/world3d/FollowControls3D.d.ts +31 -0
  546. package/dist/web/world3d/FollowControls3D.js +119 -0
  547. package/dist/web/world3d/OrbitControls3D.d.ts +58 -0
  548. package/dist/web/world3d/OrbitControls3D.js +189 -0
  549. package/dist/web/world3d/TransformControls3D.d.ts +37 -0
  550. package/dist/web/world3d/TransformControls3D.js +128 -0
  551. package/dist/web/world3d/WebGL2Renderer3D.d.ts +136 -0
  552. package/dist/web/world3d/WebGL2Renderer3D.js +1175 -0
  553. package/dist/web/world3d/WebGPURenderer3D.d.ts +112 -0
  554. package/dist/web/world3d/WebGPURenderer3D.js +1916 -0
  555. package/dist/web/world3d/World3DView.d.ts +54 -0
  556. package/dist/web/world3d/World3DView.js +79 -0
  557. package/dist/web/world3d/app3D.d.ts +143 -0
  558. package/dist/web/world3d/app3D.js +305 -0
  559. package/dist/web/world3d/assets3D.d.ts +39 -0
  560. package/dist/web/world3d/assets3D.js +112 -0
  561. package/dist/web/world3d/atmosphere3D.d.ts +56 -0
  562. package/dist/web/world3d/atmosphere3D.js +193 -0
  563. package/dist/web/world3d/canvasFont3D.d.ts +21 -0
  564. package/dist/web/world3d/canvasFont3D.js +165 -0
  565. package/dist/web/world3d/frame3D.d.ts +144 -0
  566. package/dist/web/world3d/frame3D.js +388 -0
  567. package/dist/web/world3d/gpuResources3D.d.ts +98 -0
  568. package/dist/web/world3d/gpuResources3D.js +901 -0
  569. package/dist/web/world3d/host3D.d.ts +24 -0
  570. package/dist/web/world3d/host3D.js +61 -0
  571. package/dist/web/world3d/index.d.ts +40 -0
  572. package/dist/web/world3d/index.js +24 -0
  573. package/dist/web/world3d/loaders3D.d.ts +27 -0
  574. package/dist/web/world3d/loaders3D.js +138 -0
  575. package/dist/web/world3d/markers3D.d.ts +53 -0
  576. package/dist/web/world3d/markers3D.js +130 -0
  577. package/dist/web/world3d/materialWebGL23D.d.ts +34 -0
  578. package/dist/web/world3d/materialWebGL23D.js +218 -0
  579. package/dist/web/world3d/overlay3D.d.ts +47 -0
  580. package/dist/web/world3d/overlay3D.js +187 -0
  581. package/dist/web/world3d/post3D.d.ts +116 -0
  582. package/dist/web/world3d/post3D.js +462 -0
  583. package/dist/web/world3d/postWebGL23D.d.ts +24 -0
  584. package/dist/web/world3d/postWebGL23D.js +237 -0
  585. package/dist/web/world3d/postWebGPU3D.d.ts +23 -0
  586. package/dist/web/world3d/postWebGPU3D.js +255 -0
  587. package/dist/web/world3d/probe3D.d.ts +15 -0
  588. package/dist/web/world3d/probe3D.js +66 -0
  589. package/dist/web/world3d/shaders3D.d.ts +43 -0
  590. package/dist/web/world3d/shaders3D.js +851 -0
  591. package/dist/web/world3d/stats3D.d.ts +34 -0
  592. package/dist/web/world3d/stats3D.js +81 -0
  593. package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +71 -0
  594. package/dist/web/world3d/webGL2FrameMetrics3D.js +185 -0
  595. package/dist/web/world3d/webgpu.d.ts +37 -0
  596. package/dist/web/world3d/webgpu.js +23 -0
  597. package/dist/web/world3d/webgpuPacking3D.d.ts +13 -0
  598. package/dist/web/world3d/webgpuPacking3D.js +85 -0
  599. package/dist/web/world3d/wgsl3D.d.ts +68 -0
  600. package/dist/web/world3d/wgsl3D.js +781 -0
  601. package/package.json +220 -4
@@ -0,0 +1,1526 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { requireUiTheme, sameThemeMetrics, applyUiTheme } from './theme.js';
3
+ import { EgretError, DisplayObject } from '@egret/runtime';
4
+ import { captureUiLayout, planUiLayout, UiHeightIndex, createUiDisplayOperations } from '@egret/runtime/ui';
5
+ import { requireUiEngine } from '../internal/uiFactoryState.js';
6
+ import { registerUiRoot } from '../internal/uiRootState.js';
7
+ import { captureSource, captureReveal, revealScroll } from './virtualList.js';
8
+ import { createUiKeyboardFocus } from './keyboardFocus.js';
9
+ import { captureUiTree, leafConstraintTree, leafMeasuredTree, fixedLeafMeasurement } from './leafContent.js';
10
+ import { withoutSources, preparationError, fail, failBusy, next, number, viewport, origin } from './uiRootModel.js';
11
+ /** Content a leaf or row gave is checked; a refusal says which leaf or row, and why. */
12
+ function contentOf(where, check) {
13
+ try {
14
+ check();
15
+ }
16
+ catch (e) {
17
+ if (!(e instanceof EgretError) || e.code !== 'UI_CONTENT_INVALID')
18
+ throw e;
19
+ const why = e.cause instanceof Error ? e.cause.message : 'it cannot be shown there';
20
+ throw new EgretError('UI_CONTENT_INVALID', { cause: new Error('the content of ' + where + ': ' + why) });
21
+ }
22
+ }
23
+ import { createUiRootDisplayDraft, stageUiRootDisplay } from './uiRootDisplay.js';
24
+ const freeze = Object.freeze;
25
+ /** One owned transaction domain over the genuine display and input authorities. */
26
+ export function createUiRoot(options) {
27
+ const port = requireUiEngine(options.engine);
28
+ port.assertOpen();
29
+ // A root may be made from a button's callback, while input is delivered: making it changes nothing on the stage,
30
+ // which its first commit does, and its first prepare waits until the delivery is over.
31
+ port.assertNotDrawing();
32
+ const owner = port.scope(options.scope);
33
+ owner.assertOpen();
34
+ const display = port.display(createUiDisplayOperations);
35
+ display.assertStage();
36
+ const id = options.id;
37
+ if (typeof id !== 'string' || id.length === 0 || id.length > 128)
38
+ fail('UI_VALUE_INVALID');
39
+ let size = viewport(options.viewport), density = number(options.density, Number.MIN_VALUE, 8), position = origin(options.origin ?? {
40
+ x: 0,
41
+ y: 0
42
+ }, size);
43
+ const capturedTree = captureUiTree(options.tree);
44
+ let theme = options.theme;
45
+ requireUiTheme(theme);
46
+ let authoredTree = capturedTree.tree, themeBindings = capturedTree.themes;
47
+ let tree = applyUiTheme(authoredTree, themeBindings, theme), leafContents = capturedTree.contents;
48
+ const initialNodes = [...tree.nodes.values()];
49
+ const listNodes = initialNodes.filter(n => n.kind === 'virtualList');
50
+ if (listNodes.length > 1)
51
+ fail('UI_LIMIT');
52
+ const listId = listNodes[0]?.id;
53
+ let source = listNodes[0] === undefined ? undefined : captureSource(listNodes[0].source);
54
+ let explicitScroll = listNodes[0] === undefined
55
+ ? undefined
56
+ : number(listNodes[0].initialScrollOffset ?? 0, -Number.MAX_VALUE, Number.MAX_VALUE);
57
+ let revealIntent;
58
+ tree = withoutSources(tree);
59
+ authoredTree = withoutSources(authoredTree);
60
+ const emptyTree = captureUiLayout({
61
+ id,
62
+ kind: 'leaf',
63
+ explicitWidth: 1,
64
+ explicitHeight: 1
65
+ });
66
+ const overscan = number(options.limits?.overscan ?? 2, 0, 32), residentCap = number(options.limits?.residentCap ?? 128, 1, 2048), retainedCap = number(options.limits?.retainedCap ?? 2, 0, 8);
67
+ if (!Number.isInteger(overscan) || !Number.isInteger(residentCap) || !Number.isInteger(retainedCap))
68
+ fail('UI_VALUE_INVALID');
69
+ const callback = options.onRowPointer;
70
+ if (callback !== undefined && typeof callback !== 'function')
71
+ fail('UI_VALUE_INVALID');
72
+ let inputIdentity = options.input, input = inputIdentity === undefined ? undefined : port.requireInput(inputIdentity);
73
+ function validateNewInput(value) {
74
+ if (value !== undefined && (value.state() !== 'active' || value.activeContacts() !== 0))
75
+ fail('UI_INPUT_BUSY');
76
+ }
77
+ validateNewInput(input);
78
+ const keyboardOptions = options.keyboard;
79
+ const keyboardIdentity = keyboardOptions === undefined ? undefined : port.requireKeyboard(keyboardOptions.input);
80
+ const keyboard = keyboardIdentity === undefined
81
+ ? undefined
82
+ : createUiKeyboardFocus(keyboardIdentity, keyboardOptions.idPrefix, keyboardOptions.tabStop);
83
+ let layerVisible = true, layerPointer = true, layerKeyboard = true, layerGeneration = 0, layerOwned = false;
84
+ let layerOrigin;
85
+ keyboard?.validate(source?.byKey.keys() ?? []);
86
+ let committedTheme, paintThemeOnly = false, paintCommitted = false, layoutPasses = 0;
87
+ function layout(...args) {
88
+ layoutPasses = next(layoutPasses);
89
+ return planUiLayout(...args);
90
+ }
91
+ let closed = false, desired = 1, committed = 0, inputGeneration = 0, generation = 0, busy = false, committing = false;
92
+ let closeEditorRoot = () => [];
93
+ let cancelFlight, preparedWindow, plan, committedIndex, committedSource;
94
+ let bindings = new Map(), shells = new Map(), pool = [], fills = [];
95
+ let leafBindings = new Map();
96
+ const allLeafBindings = new Set();
97
+ let outstandingLeaves = 0;
98
+ const allBindings = new Set(), retentions = new Map(), dirty = new Map(), heightUpdates = new Map(), admissions = new Set();
99
+ // Native editors retain row identity while permitting authenticated readonly re-publication.
100
+ // Public focus/composition retention continues to lock binding content and metrics.
101
+ const editorRetentions = new Set();
102
+ const bindingLocked = (key) => [...(retentions.get(key) ?? [])].some(token => !editorRetentions.has(token));
103
+ const tokens = new WeakMap();
104
+ const candidates = new Set();
105
+ const candidateEntries = new Map();
106
+ let outstanding = 0, bindTotal = 0, unbindTotal = 0, retentionCount = 0;
107
+ let unsubscribeClose = () => { };
108
+ const rootWrapper = display.createWrapper(owner.scope);
109
+ const listWrapper = listId === undefined ? undefined : display.createWrapper(owner.scope);
110
+ function counters(rows = [], index = committedIndex) {
111
+ const listBox = plan?.boxes.find(box => box.id === listId);
112
+ const range = index === undefined || listBox === undefined
113
+ ? undefined
114
+ : index.range(snapshot.scrollOffset, listBox.innerHeight, overscan);
115
+ const overscanOnly = range === undefined
116
+ ? 0
117
+ : rows.filter(row => !row.visible && row.index >= range.start && row.index < range.end).length;
118
+ return freeze({
119
+ layoutPasses,
120
+ recordCount: index?.size ?? 0,
121
+ heightIndexEntries: index?.size ?? 0,
122
+ heightIndexBytes: index?.logicalBytes ?? 0,
123
+ measuredRecordCount: index?.measuredCount ?? 0,
124
+ liveShells: shells.size + pool.length,
125
+ visibleRows: rows.filter(r => r.visible).length,
126
+ overscanOnlyRows: overscanOnly,
127
+ retainedOnlyRows: rows.filter(r => !r.visible).length - overscanOnly,
128
+ freeShells: pool.length,
129
+ activeBindings: bindings.size,
130
+ stagedBindings: [...allBindings].filter(b => !b.terminal && bindings.get(b.key) !== b).length,
131
+ unsettledBindCalls: outstanding,
132
+ measurementCalls: paintCommitted ? 0 : (plan?.measurementCalls ?? 0),
133
+ reusedMeasurements: paintCommitted ? 0 : (plan?.reusedMeasurements ?? 0),
134
+ bindTotal,
135
+ unbindTotal,
136
+ resourceDemands: undefined,
137
+ resourceLeases: undefined
138
+ });
139
+ }
140
+ let snapshot = freeze({
141
+ theme: undefined,
142
+ id: listId ?? id,
143
+ rootId: id,
144
+ committedRevision: 0,
145
+ desiredRevision: desired,
146
+ origin: position,
147
+ viewport: size,
148
+ density,
149
+ boxes: freeze([]),
150
+ rows: freeze([]),
151
+ scrollOffset: 0,
152
+ scrollExtent: 0,
153
+ anchor: undefined,
154
+ counters: counters()
155
+ });
156
+ function open() {
157
+ if (closed)
158
+ fail('UI_CLOSED');
159
+ port.assertOpen();
160
+ owner.assertOpen();
161
+ }
162
+ function admit(name, action) {
163
+ open();
164
+ if (admissions.has(name))
165
+ fail('UI_BUSY');
166
+ admissions.add(name);
167
+ try {
168
+ return action();
169
+ }
170
+ finally {
171
+ admissions.delete(name);
172
+ }
173
+ }
174
+ // Mark terminal before callbacks so cancellation and unbind reentry cannot retire twice.
175
+ function retire(binding, reason, errors = []) {
176
+ if (binding.terminal)
177
+ return;
178
+ binding.terminal = true;
179
+ const pairedSource = binding.source;
180
+ binding.source = undefined;
181
+ allBindings.delete(binding);
182
+ for (const remove of binding.subscriptions.splice(0)) {
183
+ try {
184
+ remove();
185
+ }
186
+ catch (e) {
187
+ errors.push(e);
188
+ }
189
+ }
190
+ if (binding.entered) {
191
+ unbindTotal++;
192
+ try {
193
+ pairedSource.unbind.call(pairedSource.identity, freeze({
194
+ key: binding.key,
195
+ bindingGeneration: binding.generation,
196
+ contentVersion: binding.version,
197
+ reason
198
+ }));
199
+ }
200
+ catch (e) {
201
+ errors.push(e);
202
+ }
203
+ }
204
+ try {
205
+ binding.scope.dispose();
206
+ }
207
+ catch (e) {
208
+ errors.push(e);
209
+ }
210
+ }
211
+ function discardWindow(errors, reason = 'cancel') {
212
+ if (preparedWindow === undefined)
213
+ return;
214
+ const previous = preparedWindow;
215
+ preparedWindow = undefined;
216
+ const retiring = [...previous.bindings.values()];
217
+ // Ignored provider promises may retain this small settlement object. Clear
218
+ // full data/index/layout references before any terminal user callback.
219
+ previous.bindings.clear();
220
+ const retiringLeaves = [...previous.leafBindings.values()];
221
+ previous.leafBindings.clear();
222
+ previous.heights.clear();
223
+ previous.source = undefined;
224
+ previous.index = undefined;
225
+ previous.plan = undefined;
226
+ previous.box = undefined;
227
+ for (const leaf of retiringLeaves)
228
+ if (leafBindings.get(leaf.id) !== leaf)
229
+ retireLeaf(leaf, errors ?? previous.cleanupErrors);
230
+ for (const binding of retiring) {
231
+ if (bindings.get(binding.key) !== binding)
232
+ retire(binding, reason, errors ?? previous.cleanupErrors);
233
+ }
234
+ }
235
+ // Supersession accepts intent first, retires all staging, then reports direct
236
+ // cleanup failures. The prior committed geometry is never partially changed.
237
+ function change(onlyTheme = false) {
238
+ paintThemeOnly = onlyTheme && (desired === committed || paintThemeOnly) && sameThemeMetrics(committedTheme, theme);
239
+ desired = next(desired);
240
+ const errors = preparedWindow?.cleanupErrors ?? [];
241
+ cancelFlight?.(new EgretError('UI_STALE'));
242
+ for (const candidate of [...candidates])
243
+ clearCandidate(candidate, errors);
244
+ discardWindow(errors);
245
+ if (errors.length !== 0)
246
+ throw new EgretError('UI_CLEANUP_FAILED', {
247
+ cause: errors[0],
248
+ cleanupErrors: errors.slice(1)
249
+ });
250
+ }
251
+ function check(revision) {
252
+ open();
253
+ if (desired !== revision)
254
+ fail('UI_STALE');
255
+ }
256
+ function sync(errors) {
257
+ if (input !== undefined) {
258
+ try {
259
+ if (input.state() !== 'active')
260
+ fail('UI_INPUT_CLOSED');
261
+ input.sync();
262
+ }
263
+ catch (e) {
264
+ errors.push(e);
265
+ }
266
+ }
267
+ }
268
+ function subscriptions(binding, bridge) {
269
+ if (bridge === undefined || callback === undefined)
270
+ return [];
271
+ const result = [];
272
+ try {
273
+ for (const kind of ['begin', 'move', 'end', 'cancel']) {
274
+ const descriptor = bridge.events[kind];
275
+ result.push(binding.wrapper.on(descriptor, event => {
276
+ if (closed || binding.terminal || bindings.get(binding.key) !== binding)
277
+ return;
278
+ const row = snapshot.rows.find(row => row.key === binding.key);
279
+ if (row === undefined)
280
+ return;
281
+ return callback(freeze({
282
+ kind,
283
+ listId: listId,
284
+ key: binding.key,
285
+ index: row.index,
286
+ bindingGeneration: binding.generation,
287
+ contentVersion: binding.version,
288
+ layoutRevision: committed,
289
+ target: binding.wrapper,
290
+ event
291
+ }));
292
+ }));
293
+ }
294
+ return result;
295
+ }
296
+ catch (e) {
297
+ for (const remove of result)
298
+ remove();
299
+ throw e;
300
+ }
301
+ }
302
+ function compatible(binding, w, key) {
303
+ const record = w.source?.byKey.get(key);
304
+ return (binding !== undefined &&
305
+ !binding.terminal &&
306
+ record !== undefined &&
307
+ binding.theme === w.theme &&
308
+ binding.version === record.contentVersion &&
309
+ binding.width === w.width &&
310
+ binding.density === density);
311
+ }
312
+ function makeBinding(w, key) {
313
+ if (outstanding >= residentCap)
314
+ fail('UI_PENDING_LIMIT');
315
+ if (allBindings.size - bindings.size >= residentCap)
316
+ fail('UI_LIMIT');
317
+ generation = next(generation);
318
+ const record = w.source.byKey.get(key);
319
+ const scope = port.scope(port.createScope());
320
+ let wrapper;
321
+ try {
322
+ wrapper = display.createWrapper(scope.scope);
323
+ }
324
+ catch (e) {
325
+ scope.dispose();
326
+ throw e;
327
+ }
328
+ const binding = {
329
+ theme: w.theme,
330
+ key,
331
+ version: record.contentVersion,
332
+ generation,
333
+ width: w.width,
334
+ density,
335
+ source: { identity: w.source.identity, bind: w.source.bind, unbind: w.source.unbind },
336
+ scope,
337
+ wrapper,
338
+ entered: false,
339
+ terminal: false,
340
+ subscriptions: []
341
+ };
342
+ // A single replaceable listener set follows this binding Scope across input swaps.
343
+ scope.add(() => {
344
+ for (const remove of binding.subscriptions.splice(0))
345
+ remove();
346
+ });
347
+ allBindings.add(binding);
348
+ w.bindings.set(key, binding);
349
+ const context = freeze({
350
+ theme: w.theme,
351
+ key,
352
+ index: w.index.indexOf(key),
353
+ value: record.value,
354
+ contentVersion: record.contentVersion,
355
+ bindingGeneration: binding.generation,
356
+ width: w.width,
357
+ density,
358
+ scope: scope.scope,
359
+ signal: scope.signal,
360
+ target: wrapper
361
+ });
362
+ binding.entered = true;
363
+ bindTotal++;
364
+ outstanding++;
365
+ let returned;
366
+ try {
367
+ returned = binding.source.bind.call(binding.source.identity, context);
368
+ }
369
+ catch (e) {
370
+ outstanding--;
371
+ retire(binding, 'error', w.cleanupErrors);
372
+ return Promise.reject(e);
373
+ }
374
+ return Promise.resolve(returned)
375
+ .then(value => {
376
+ if (binding.terminal || closed || desired !== w.revision) {
377
+ retire(binding, 'cancel');
378
+ fail('UI_STALE');
379
+ }
380
+ const content = value.content, height = number(value.measuredHeight, 1, 1048576);
381
+ contentOf('row ' + JSON.stringify(key), () => display.validateContent(content, scope.scope));
382
+ check(w.revision);
383
+ // Explicit height updates can supersede the measurement retained by a binding.
384
+ const committedPosition = committedIndex?.indexOf(key) ?? -1;
385
+ if (w.paintOnly && (committedPosition < 0 || height !== committedIndex.heightAt(committedPosition)))
386
+ fail('UI_THEME_METRICS_CHANGED');
387
+ binding.content = content;
388
+ binding.height = height;
389
+ binding.subscriptions = subscriptions(binding, input);
390
+ w.heights.set(key, {
391
+ key,
392
+ height,
393
+ contentVersion: binding.version
394
+ });
395
+ return binding;
396
+ })
397
+ .catch(e => {
398
+ retire(binding, 'error', w.cleanupErrors);
399
+ throw e;
400
+ })
401
+ .finally(() => {
402
+ outstanding--;
403
+ });
404
+ }
405
+ function selected(index, scroll, height) {
406
+ const selected = [];
407
+ if (index.size === 0)
408
+ return selected;
409
+ const range = index.range(scroll, height, overscan);
410
+ for (let i = range.start; i < range.end; i++)
411
+ selected.push(index.keyAt(i));
412
+ for (const key of retentions.keys())
413
+ if (!selected.includes(key))
414
+ selected.push(key);
415
+ if (selected.length > residentCap)
416
+ fail('UI_LIMIT');
417
+ let retainedOnly = 0;
418
+ for (const key of retentions.keys()) {
419
+ const i = index.indexOf(key);
420
+ if (i < range.start || i >= range.end)
421
+ retainedOnly++;
422
+ }
423
+ if (retainedOnly > retainedCap)
424
+ fail('UI_LIMIT');
425
+ return selected;
426
+ }
427
+ function retireLeaf(binding, errors = []) {
428
+ if (binding.terminal)
429
+ return;
430
+ binding.terminal = true;
431
+ binding.source = undefined;
432
+ delete binding.content;
433
+ delete binding.measure;
434
+ allLeafBindings.delete(binding);
435
+ try {
436
+ binding.scope.dispose();
437
+ }
438
+ catch (cause) {
439
+ errors.push(cause);
440
+ }
441
+ }
442
+ function makeLeafBinding(w, name, captured, width) {
443
+ if (outstandingLeaves >= 4096)
444
+ fail('UI_PENDING_LIMIT');
445
+ if (allLeafBindings.size - leafBindings.size >= 4096)
446
+ fail('UI_LIMIT');
447
+ const scope = port.scope(port.createScope());
448
+ let wrapper;
449
+ try {
450
+ wrapper = display.createWrapper(scope.scope);
451
+ }
452
+ catch (cause) {
453
+ scope.dispose();
454
+ throw cause;
455
+ }
456
+ const binding = {
457
+ theme: w.theme,
458
+ id: name,
459
+ width,
460
+ density,
461
+ scope,
462
+ wrapper,
463
+ source: captured,
464
+ terminal: false
465
+ };
466
+ allLeafBindings.add(binding);
467
+ w.leafBindings.set(name, binding);
468
+ const context = freeze({ theme: w.theme, scope: scope.scope, width, density, signal: scope.signal });
469
+ outstandingLeaves++;
470
+ let returned;
471
+ try {
472
+ returned = captured.prepare.call(captured.identity, context);
473
+ }
474
+ catch (cause) {
475
+ outstandingLeaves--;
476
+ retireLeaf(binding, w.cleanupErrors);
477
+ return Promise.reject(cause);
478
+ }
479
+ return Promise.resolve(returned)
480
+ .then(value => {
481
+ if (binding.terminal || closed || desired !== w.revision) {
482
+ retireLeaf(binding, w.cleanupErrors);
483
+ fail('UI_STALE');
484
+ }
485
+ const content = value.content, height = number(value.measuredHeight, 0, 1048576);
486
+ contentOf('leaf ' + JSON.stringify(name), () => display.validateContent(content, scope.scope));
487
+ check(w.revision);
488
+ if (w.paintOnly && height !== leafBindings.get(name)?.height)
489
+ fail('UI_THEME_METRICS_CHANGED');
490
+ binding.content = content;
491
+ binding.height = height;
492
+ binding.measure = fixedLeafMeasurement(width, height, binding.source.revision);
493
+ return binding;
494
+ })
495
+ .catch(cause => {
496
+ retireLeaf(binding, w.cleanupErrors);
497
+ throw cause;
498
+ })
499
+ .finally(() => {
500
+ outstandingLeaves--;
501
+ });
502
+ }
503
+ function makeWindow(revision) {
504
+ return {
505
+ theme,
506
+ paintOnly: paintThemeOnly && plan !== undefined,
507
+ cleanupErrors: [],
508
+ revision,
509
+ source,
510
+ index: undefined,
511
+ plan: undefined,
512
+ box: undefined,
513
+ width: 0,
514
+ height: 0,
515
+ scroll: 0,
516
+ round: 0,
517
+ heights: new Map(heightUpdates),
518
+ bindings: new Map(),
519
+ leafBindings: new Map()
520
+ };
521
+ }
522
+ function initializeWindow(w) {
523
+ const baseTree = tree, sources = leafContents, widths = new Map();
524
+ if (sources.size !== 0) {
525
+ if (w.paintOnly) {
526
+ for (const box of plan.boxes)
527
+ if (sources.has(box.id))
528
+ widths.set(box.id, box.innerWidth);
529
+ }
530
+ else
531
+ layout(leafConstraintTree(baseTree, sources, widths), size, density);
532
+ check(w.revision);
533
+ const work = [], force = new Set();
534
+ function collectMeasureDirty(node, ancestorDirty) {
535
+ const measureDirty = ancestorDirty || dirty.get(node.id) === 'measure' || !sameThemeMetrics(committedTheme, w.theme);
536
+ if (node.kind === 'leaf' && measureDirty)
537
+ force.add(node.id);
538
+ for (const child of node.children ?? [])
539
+ collectMeasureDirty(child, measureDirty);
540
+ }
541
+ collectMeasureDirty(baseTree.root, false);
542
+ for (const [name, captured] of sources) {
543
+ const width = number(widths.get(name), Number.MIN_VALUE, 16384), prior = leafBindings.get(name);
544
+ if (!force.has(name) &&
545
+ prior !== undefined &&
546
+ !prior.terminal &&
547
+ prior.theme === w.theme &&
548
+ prior.source?.identity === captured.identity &&
549
+ prior.source.revision === captured.revision &&
550
+ prior.source.prepare === captured.prepare &&
551
+ prior.width === width &&
552
+ prior.density === density) {
553
+ w.leafBindings.set(name, prior);
554
+ continue;
555
+ }
556
+ const promise = makeLeafBinding(w, name, captured, width);
557
+ void promise.catch(() => { });
558
+ work.push(promise);
559
+ check(w.revision);
560
+ }
561
+ return Promise.all(work).then(() => {
562
+ check(w.revision);
563
+ completeWindow(w, baseTree);
564
+ });
565
+ }
566
+ completeWindow(w, baseTree);
567
+ }
568
+ function completeWindow(w, baseTree) {
569
+ const measures = new Map();
570
+ for (const [name, binding] of w.leafBindings)
571
+ measures.set(name, binding.measure);
572
+ const layoutDirty = !sameThemeMetrics(committedTheme, w.theme)
573
+ ? new Map(dirty).set(baseTree.root.id, 'measure')
574
+ : dirty;
575
+ const nextPlan = w.paintOnly
576
+ ? plan
577
+ : layout(measures.size === 0 ? baseTree : leafMeasuredTree(baseTree, measures), size, density, plan, layoutDirty);
578
+ check(w.revision);
579
+ const box = nextPlan.boxes.find(b => b.id === listId), width = box?.innerWidth ?? 0, height = box?.innerHeight ?? 0;
580
+ if (box !== undefined && (width <= 0 || height <= 0))
581
+ fail('UI_VALUE_INVALID');
582
+ const index = w.source === undefined
583
+ ? undefined
584
+ : sameThemeMetrics(committedTheme, w.theme) &&
585
+ w.source === committedSource &&
586
+ committedIndex !== undefined &&
587
+ snapshot.boxes.find(b => b.id === listId)?.innerWidth === width &&
588
+ snapshot.density === density
589
+ ? committedIndex
590
+ : new UiHeightIndex(w.source.records, width, density, sameThemeMetrics(committedTheme, w.theme) ? committedIndex : undefined);
591
+ for (const key of retentions.keys()) {
592
+ const b = bindings.get(key);
593
+ if (!w.source?.byKey.has(key) ||
594
+ (bindingLocked(key) &&
595
+ b !== undefined &&
596
+ (b.theme !== w.theme ||
597
+ w.source?.byKey.get(key)?.contentVersion !== b.version ||
598
+ width !== b.width ||
599
+ density !== b.density)))
600
+ fail('UI_ROW_RETAINED');
601
+ }
602
+ const scroll = index === undefined
603
+ ? 0
604
+ : explicitScroll !== undefined
605
+ ? index.clampScroll(explicitScroll, height)
606
+ : committedIndex === undefined
607
+ ? 0
608
+ : index.preserveAnchor(snapshot.anchor, committedIndex, height);
609
+ w.plan = nextPlan;
610
+ w.box = box;
611
+ w.width = width;
612
+ w.height = height;
613
+ w.index = index;
614
+ w.scroll = scroll;
615
+ }
616
+ function token(status, candidate) {
617
+ const result = freeze({
618
+ status,
619
+ desiredRevision: desired,
620
+ baseCommittedRevision: committed
621
+ });
622
+ const entry = {
623
+ used: false,
624
+ ...(candidate === undefined
625
+ ? {}
626
+ : {
627
+ candidate
628
+ })
629
+ };
630
+ tokens.set(result, entry);
631
+ if (candidate !== undefined) {
632
+ candidates.add(candidate);
633
+ candidateEntries.set(candidate, entry);
634
+ }
635
+ return result;
636
+ }
637
+ // Each explicit prepare expands the detached preparedWindow once, with a hard eight-round limit.
638
+ async function prepareWork(revision) {
639
+ if (desired === committed)
640
+ return token('unchanged');
641
+ if (preparedWindow === undefined || preparedWindow.revision !== revision)
642
+ preparedWindow = makeWindow(revision);
643
+ const w = preparedWindow;
644
+ if (w.plan === undefined) {
645
+ const initialization = initializeWindow(w);
646
+ if (initialization !== undefined)
647
+ await initialization;
648
+ }
649
+ check(revision);
650
+ w.round++;
651
+ if (w.round > 8) {
652
+ discardWindow();
653
+ fail('UI_LAYOUT_UNSTABLE');
654
+ }
655
+ let journal = w.index?.stageHeights([...w.heights.values()]);
656
+ let view = journal ?? w.index;
657
+ if (view !== undefined)
658
+ w.scroll =
659
+ revealIntent !== undefined
660
+ ? revealScroll(view, revealIntent, snapshot.scrollOffset, w.height)
661
+ : explicitScroll !== undefined
662
+ ? view.clampScroll(explicitScroll, w.height)
663
+ : committedIndex === undefined
664
+ ? view.clampScroll(w.scroll, w.height)
665
+ : view.preserveAnchor(snapshot.anchor, committedIndex, w.height);
666
+ const keys = view === undefined ? [] : selected(view, w.scroll, w.height);
667
+ const work = [];
668
+ for (const key of keys) {
669
+ if (compatible(w.bindings.get(key), w, key))
670
+ continue;
671
+ const live = bindings.get(key);
672
+ if (compatible(live, w, key)) {
673
+ w.bindings.set(key, live);
674
+ continue;
675
+ }
676
+ const promise = makeBinding(w, key);
677
+ void promise.catch(() => { });
678
+ work.push(promise);
679
+ check(revision);
680
+ }
681
+ // Do not retain Fenwick base/journal references across ignored callbacks.
682
+ journal = undefined;
683
+ view = undefined;
684
+ await Promise.all(work);
685
+ check(revision);
686
+ journal = w.index?.stageHeights([...w.heights.values()]);
687
+ view = journal ?? w.index;
688
+ if (view !== undefined)
689
+ w.scroll =
690
+ revealIntent !== undefined
691
+ ? revealScroll(view, revealIntent, snapshot.scrollOffset, w.height)
692
+ : explicitScroll !== undefined
693
+ ? view.clampScroll(explicitScroll, w.height)
694
+ : committedIndex === undefined
695
+ ? view.clampScroll(w.scroll, w.height)
696
+ : view.preserveAnchor(snapshot.anchor, committedIndex, w.height);
697
+ const finalKeys = view === undefined ? [] : selected(view, w.scroll, w.height);
698
+ if (finalKeys.some(key => !compatible(w.bindings.get(key), w, key))) {
699
+ if (w.round >= 8) {
700
+ discardWindow();
701
+ fail('UI_LAYOUT_UNSTABLE');
702
+ }
703
+ return token('pending');
704
+ }
705
+ const draft = createUiRootDisplayDraft(pool, shells, finalKeys);
706
+ const { updates, nextBindings, nextShells, freshShells, fillScopes, rows } = draft;
707
+ try {
708
+ stageUiRootDisplay(draft, {
709
+ w,
710
+ finalKeys,
711
+ view,
712
+ shells,
713
+ port,
714
+ display,
715
+ tree,
716
+ listWrapper,
717
+ listId,
718
+ rootWrapper,
719
+ layerOrigin,
720
+ position,
721
+ size,
722
+ layerVisible,
723
+ layerPointer
724
+ });
725
+ const displayToken = display.prepare(rootWrapper, updates);
726
+ check(revision);
727
+ const nextSnapshot = freeze({
728
+ theme: w.theme,
729
+ id: listId ?? id,
730
+ rootId: id,
731
+ committedRevision: revision,
732
+ desiredRevision: revision,
733
+ origin: position,
734
+ viewport: size,
735
+ density,
736
+ boxes: w.plan.boxes,
737
+ rows: freeze(rows),
738
+ scrollOffset: w.scroll,
739
+ scrollExtent: view?.totalHeight ?? 0,
740
+ anchor: view?.anchor(w.scroll),
741
+ counters: counters(rows, w.index)
742
+ });
743
+ const used = new Set(nextShells.values()), availablePool = [...pool, ...shells.values()].filter((s, i, a) => !used.has(s) && a.indexOf(s) === i), nextPool = availablePool.slice(0, residentCap - nextShells.size), discardedShells = availablePool.slice(residentCap - nextShells.size);
744
+ const retiring = [];
745
+ for (const [key, b] of bindings)
746
+ if (nextBindings.get(key) !== b)
747
+ retiring.push({
748
+ binding: b,
749
+ reason: w.source?.byKey.has(key)
750
+ ? w.source.byKey.get(key).contentVersion === b.version
751
+ ? 'recycle'
752
+ : 'replace'
753
+ : 'delete'
754
+ });
755
+ for (const b of w.bindings.values())
756
+ if (nextBindings.get(b.key) !== b && !retiring.some(r => r.binding === b))
757
+ retiring.push({
758
+ binding: b,
759
+ reason: 'recycle'
760
+ });
761
+ return token('ready', {
762
+ nextPool,
763
+ discardedShells,
764
+ retiring,
765
+ oldFills: fills,
766
+ retiringLeaves: [...leafBindings.values()].filter(binding => w.leafBindings.get(binding.id) !== binding),
767
+ preparedWindow: w,
768
+ rows: nextSnapshot.rows,
769
+ bindings: nextBindings,
770
+ shells: nextShells,
771
+ freshShells,
772
+ fillScopes,
773
+ displayToken,
774
+ indexJournal: journal,
775
+ snapshot: nextSnapshot,
776
+ inputGeneration,
777
+ layerGeneration
778
+ });
779
+ }
780
+ catch (e) {
781
+ for (const s of freshShells)
782
+ s.scope.dispose();
783
+ for (const s of fillScopes)
784
+ s.dispose();
785
+ throw e;
786
+ }
787
+ }
788
+ function clearCandidate(candidate, errors = []) {
789
+ if (!candidates.delete(candidate))
790
+ return;
791
+ const entry = candidateEntries.get(candidate);
792
+ if (entry !== undefined) {
793
+ entry.retired = true;
794
+ delete entry.candidate;
795
+ }
796
+ candidateEntries.delete(candidate);
797
+ for (const shell of candidate.freshShells) {
798
+ try {
799
+ shell.scope.dispose();
800
+ }
801
+ catch (cause) {
802
+ errors.push(cause);
803
+ }
804
+ }
805
+ for (const scope of candidate.fillScopes) {
806
+ try {
807
+ scope.dispose();
808
+ }
809
+ catch (cause) {
810
+ errors.push(cause);
811
+ }
812
+ }
813
+ }
814
+ function retainRow(key, reason, editor = false) {
815
+ return admit('retain', () => {
816
+ if (reason !== 'focus' && reason !== 'composition')
817
+ fail('UI_VALUE_INVALID');
818
+ if (!bindings.has(key))
819
+ fail('UI_ROW_NOT_REALIZED');
820
+ if (retentionCount >= 16)
821
+ fail('UI_LIMIT');
822
+ const identity = {}, set = retentions.get(key) ?? new Set();
823
+ set.add(identity);
824
+ if (editor)
825
+ editorRetentions.add(identity);
826
+ retentions.set(key, set);
827
+ retentionCount++;
828
+ change();
829
+ let released = false;
830
+ return freeze({
831
+ release() {
832
+ if (released)
833
+ return;
834
+ released = true;
835
+ if (closed)
836
+ return;
837
+ set.delete(identity);
838
+ editorRetentions.delete(identity);
839
+ retentionCount--;
840
+ if (set.size === 0)
841
+ retentions.delete(key);
842
+ change();
843
+ }
844
+ });
845
+ });
846
+ }
847
+ const handle = freeze({
848
+ setSource(value) {
849
+ admit('source', () => {
850
+ const revision = desired;
851
+ const captured = captureSource(value);
852
+ keyboard?.validate(captured.byKey.keys());
853
+ check(revision);
854
+ if (source?.identity === value && source.revision === captured.revision) {
855
+ if (source.bind !== captured.bind ||
856
+ source.unbind !== captured.unbind ||
857
+ source.records.length !== captured.records.length ||
858
+ source.records.some((r, i) => {
859
+ const other = captured.records[i];
860
+ return (r.key !== other.key ||
861
+ r.contentVersion !== other.contentVersion ||
862
+ r.estimatedHeight !== other.estimatedHeight ||
863
+ r.value !== other.value);
864
+ }))
865
+ fail('UI_SOURCE_REVISION');
866
+ return;
867
+ }
868
+ if (source !== undefined && captured.revision <= source.revision)
869
+ fail('UI_SOURCE_REVISION');
870
+ for (const key of retentions.keys())
871
+ if (!captured.byKey.has(key) ||
872
+ (bindingLocked(key) && captured.byKey.get(key)?.contentVersion !== bindings.get(key)?.version))
873
+ fail('UI_ROW_RETAINED');
874
+ source = captured;
875
+ revealIntent = undefined;
876
+ change();
877
+ });
878
+ },
879
+ reveal(key, options) {
880
+ admit('reveal', () => {
881
+ const revision = desired, intent = captureReveal(key, options);
882
+ check(revision);
883
+ if (intent !== undefined && !source?.byKey.has(intent.key))
884
+ fail('UI_UNKNOWN_KEY');
885
+ if (intent === undefined && revealIntent === undefined)
886
+ return;
887
+ revealIntent = intent;
888
+ // Cancelling restores ordinary committed-anchor preservation, never a staged offset.
889
+ explicitScroll = undefined;
890
+ change();
891
+ });
892
+ },
893
+ setScrollOffset(value) {
894
+ admit('scroll', () => {
895
+ const scroll = number(value, -Number.MAX_VALUE, Number.MAX_VALUE);
896
+ // A scroll to where the list is changes nothing while nothing else waits. After a new source in the same turn it is not
897
+ // nothing: the list would follow its anchor to another offset, and this says where it is to be instead.
898
+ if (revealIntent === undefined &&
899
+ (explicitScroll === scroll ||
900
+ (explicitScroll === undefined && snapshot.scrollOffset === scroll && desired === committed)))
901
+ return;
902
+ revealIntent = undefined;
903
+ explicitScroll = scroll;
904
+ change();
905
+ });
906
+ },
907
+ updateHeights(values) {
908
+ admit('heights', () => {
909
+ const revision = desired, seen = new Set(), accepted = [];
910
+ for (const v of values) {
911
+ const key = v.key, height = number(v.height, 1, 1048576), contentVersion = v.contentVersion;
912
+ if (seen.has(key) || !source?.byKey.has(key))
913
+ fail('UI_VALUE_INVALID');
914
+ seen.add(key);
915
+ if (source.byKey.get(key).contentVersion === contentVersion)
916
+ accepted.push({
917
+ key,
918
+ height,
919
+ contentVersion
920
+ });
921
+ }
922
+ check(revision);
923
+ if (accepted.length === 0)
924
+ return;
925
+ for (const v of accepted)
926
+ heightUpdates.set(v.key, v);
927
+ change();
928
+ });
929
+ },
930
+ focus(key, options) {
931
+ open();
932
+ if (keyboard === undefined)
933
+ fail('UI_KEYBOARD_UNAVAILABLE');
934
+ keyboard.focus(key, options);
935
+ },
936
+ getFocus() {
937
+ return keyboard?.getFocus() ?? freeze({ key: undefined, focusVisible: false });
938
+ },
939
+ retain(key, reason) {
940
+ return retainRow(key, reason);
941
+ },
942
+ snapshot() {
943
+ return api.snapshot();
944
+ }
945
+ });
946
+ const api = {
947
+ id,
948
+ get state() {
949
+ return closed ? 'closed' : 'open';
950
+ },
951
+ setViewport(value, newDensity) {
952
+ admit('viewport', () => {
953
+ const revision = desired, newSize = viewport(value), d = number(newDensity, Number.MIN_VALUE, 8);
954
+ origin(position, newSize);
955
+ check(revision);
956
+ if (newSize.width === size.width && newSize.height === size.height && d === density)
957
+ return;
958
+ for (const key of retentions.keys())
959
+ if (bindingLocked(key) && (d !== density || newSize.width !== size.width))
960
+ fail('UI_ROW_RETAINED');
961
+ size = newSize;
962
+ density = d;
963
+ change();
964
+ });
965
+ },
966
+ setOrigin(value) {
967
+ admit('origin', () => {
968
+ const revision = desired, p = origin(value, size);
969
+ check(revision);
970
+ if (p.x === position.x && p.y === position.y)
971
+ return;
972
+ position = p;
973
+ change();
974
+ });
975
+ },
976
+ setTree(value) {
977
+ admit('tree', () => {
978
+ const revision = desired, captured = captureUiTree(value), t = applyUiTheme(captured.tree, captured.themes, theme);
979
+ check(revision);
980
+ if (t.nodes.size !== tree.nodes.size ||
981
+ [...t.nodes].some(([key, node]) => tree.nodes.get(key)?.kind !== node.kind))
982
+ fail('UI_TREE_SHAPE');
983
+ const list = listId === undefined ? undefined : t.nodes.get(listId), s = list === undefined ? undefined : captureSource(list.source);
984
+ keyboard?.validate(s?.byKey.keys() ?? []);
985
+ if (s !== undefined &&
986
+ source !== undefined &&
987
+ s.revision <= source.revision &&
988
+ (s.revision !== source.revision ||
989
+ s.identity !== source.identity ||
990
+ s.bind !== source.bind ||
991
+ s.unbind !== source.unbind ||
992
+ s.records.length !== source.records.length ||
993
+ s.records.some((record, index) => {
994
+ const old = source.records[index];
995
+ return (record.key !== old.key ||
996
+ record.contentVersion !== old.contentVersion ||
997
+ record.estimatedHeight !== old.estimatedHeight ||
998
+ record.value !== old.value);
999
+ })))
1000
+ fail('UI_SOURCE_REVISION');
1001
+ check(revision);
1002
+ for (const key of retentions.keys())
1003
+ if (!s?.byKey.has(key) ||
1004
+ (bindingLocked(key) && s?.byKey.get(key)?.contentVersion !== bindings.get(key)?.version))
1005
+ fail('UI_ROW_RETAINED');
1006
+ for (const [name, content] of captured.contents) {
1007
+ const previous = leafContents.get(name);
1008
+ if (previous?.identity === content.identity &&
1009
+ (content.revision < previous.revision ||
1010
+ (content.revision === previous.revision && content.prepare !== previous.prepare)))
1011
+ fail('UI_SOURCE_REVISION');
1012
+ }
1013
+ authoredTree = withoutSources(captured.tree);
1014
+ themeBindings = captured.themes;
1015
+ tree = withoutSources(t);
1016
+ leafContents = captured.contents;
1017
+ if (s !== undefined) {
1018
+ if (s.identity !== source?.identity || s.revision !== source?.revision)
1019
+ revealIntent = undefined;
1020
+ source = s;
1021
+ }
1022
+ change();
1023
+ });
1024
+ },
1025
+ setTheme(value) {
1026
+ admit('theme', () => {
1027
+ requireUiTheme(value);
1028
+ if (value === theme)
1029
+ return;
1030
+ // Explicit focus/composition retention forbids replacing its live content.
1031
+ for (const key of retentions.keys())
1032
+ if (bindingLocked(key) && bindings.get(key)?.theme !== value)
1033
+ fail('UI_ROW_RETAINED');
1034
+ const resolved = applyUiTheme(authoredTree, themeBindings, value);
1035
+ theme = value;
1036
+ tree = resolved;
1037
+ change(true);
1038
+ });
1039
+ },
1040
+ setInput(value) {
1041
+ if (layerOwned && value !== inputIdentity)
1042
+ fail('UI_LAYER_INPUT_MISMATCH');
1043
+ admit('input', () => {
1044
+ if (value === inputIdentity)
1045
+ return;
1046
+ if (busy || committing)
1047
+ failBusy(busy);
1048
+ port.assertIdle();
1049
+ display.assertStage();
1050
+ if (input !== undefined && input.state() !== 'closed' && input.activeContacts() !== 0)
1051
+ fail('UI_INPUT_BUSY');
1052
+ const revision = desired, association = inputGeneration, oldInput = input;
1053
+ const bridge = value === undefined ? undefined : port.requireInput(value);
1054
+ validateNewInput(bridge);
1055
+ const staged = new Map();
1056
+ try {
1057
+ for (const b of allBindings)
1058
+ staged.set(b, subscriptions(b, bridge));
1059
+ port.assertIdle();
1060
+ display.assertStage();
1061
+ check(revision);
1062
+ if (inputGeneration !== association || input !== oldInput)
1063
+ fail('UI_STALE');
1064
+ if (oldInput !== undefined && oldInput.state() !== 'closed' && oldInput.activeContacts() !== 0)
1065
+ fail('UI_INPUT_BUSY');
1066
+ validateNewInput(bridge);
1067
+ }
1068
+ catch (e) {
1069
+ for (const list of staged.values())
1070
+ for (const remove of list)
1071
+ remove();
1072
+ throw e;
1073
+ }
1074
+ for (const [b, list] of staged) {
1075
+ for (const remove of b.subscriptions)
1076
+ remove();
1077
+ b.subscriptions = list;
1078
+ }
1079
+ inputIdentity = value;
1080
+ input = bridge;
1081
+ inputGeneration = next(inputGeneration);
1082
+ });
1083
+ },
1084
+ list(key) {
1085
+ open();
1086
+ if (key !== listId)
1087
+ fail('UI_LIST_NOT_FOUND');
1088
+ return handle;
1089
+ },
1090
+ invalidate(key, kind) {
1091
+ admit('invalidate', () => {
1092
+ if (!tree.nodes.has(key) || !['measure', 'arrange', 'paint', 'interaction', 'semantic'].includes(kind))
1093
+ fail('UI_VALUE_INVALID');
1094
+ const rank = { measure: 4, arrange: 3, paint: 2, interaction: 1, semantic: 0 };
1095
+ const previous = dirty.get(key);
1096
+ if (previous === undefined || rank[kind] > rank[previous])
1097
+ dirty.set(key, kind);
1098
+ change();
1099
+ });
1100
+ },
1101
+ async prepare() {
1102
+ open();
1103
+ // Asked for while input is delivered or a frame drawn, as from a button's callback: it starts once that is over,
1104
+ // and holds its place meanwhile, so a prepare asked for after it is the one that is busy.
1105
+ if (!port.isIdle()) {
1106
+ if (busy || committing)
1107
+ failBusy(busy);
1108
+ busy = true;
1109
+ try {
1110
+ await Promise.resolve();
1111
+ }
1112
+ finally {
1113
+ busy = false;
1114
+ }
1115
+ open();
1116
+ }
1117
+ port.assertIdle();
1118
+ if (busy || committing)
1119
+ failBusy(busy);
1120
+ for (const c of [...candidates])
1121
+ clearCandidate(c);
1122
+ busy = true;
1123
+ const revision = desired;
1124
+ let rejectCancellation = () => { };
1125
+ const canceled = new Promise((_, reject) => {
1126
+ rejectCancellation = reject;
1127
+ });
1128
+ cancelFlight = rejectCancellation;
1129
+ let flightWindow;
1130
+ try {
1131
+ const operation = prepareWork(revision);
1132
+ flightWindow = preparedWindow;
1133
+ return await Promise.race([operation, canceled]);
1134
+ }
1135
+ catch (e) {
1136
+ const cleanupErrors = flightWindow?.cleanupErrors ?? [];
1137
+ if (desired === revision)
1138
+ discardWindow(cleanupErrors);
1139
+ throw preparationError(e, cleanupErrors);
1140
+ }
1141
+ finally {
1142
+ if (cancelFlight === rejectCancellation)
1143
+ cancelFlight = undefined;
1144
+ busy = false;
1145
+ }
1146
+ },
1147
+ commit(preparation) {
1148
+ const entry = tokens.get(preparation);
1149
+ if (entry === undefined || entry.used)
1150
+ fail('UI_PREPARATION_INVALID');
1151
+ if (preparation.status === 'pending')
1152
+ fail('UI_NOT_READY');
1153
+ if (closed) {
1154
+ entry.used = true;
1155
+ if (entry.candidate !== undefined)
1156
+ clearCandidate(entry.candidate);
1157
+ return result('closed', []);
1158
+ }
1159
+ port.assertIdle();
1160
+ if (busy || committing)
1161
+ failBusy(busy);
1162
+ display.assertStage();
1163
+ if (entry.retired === true ||
1164
+ (entry.candidate !== undefined && !candidates.has(entry.candidate)) ||
1165
+ preparation.desiredRevision !== desired ||
1166
+ preparation.baseCommittedRevision !== committed ||
1167
+ (entry.candidate !== undefined &&
1168
+ (entry.candidate.inputGeneration !== inputGeneration || entry.candidate.layerGeneration !== layerGeneration))) {
1169
+ entry.used = true;
1170
+ if (entry.candidate !== undefined)
1171
+ clearCandidate(entry.candidate);
1172
+ return result('stale', []);
1173
+ }
1174
+ if (preparation.status === 'unchanged') {
1175
+ entry.used = true;
1176
+ return result('unchanged', []);
1177
+ }
1178
+ const c = entry.candidate;
1179
+ committing = true;
1180
+ const errors = [];
1181
+ // All child arrays, pool membership, retire lists and the snapshot already exist.
1182
+ // Runtime publication and index/reference assignment contain no user callbacks.
1183
+ try {
1184
+ const keyboardRows = c.rows.map(row => ({
1185
+ key: row.key,
1186
+ content: c.bindings.get(row.key).content,
1187
+ visible: row.visible
1188
+ }));
1189
+ const restoreFocus = keyboard?.before(keyboardRows);
1190
+ // Cancellation callbacks may change or close the UI. Never publish their obsolete proposal.
1191
+ if (closed || desired !== preparation.desiredRevision || committed !== preparation.baseCommittedRevision) {
1192
+ entry.used = true;
1193
+ clearCandidate(c, errors);
1194
+ return result(closed ? 'closed' : 'stale', errors);
1195
+ }
1196
+ display.commit(c.displayToken);
1197
+ c.indexJournal?.apply();
1198
+ candidates.delete(c);
1199
+ candidateEntries.delete(c);
1200
+ delete entry.candidate;
1201
+ entry.used = true;
1202
+ pool = c.nextPool;
1203
+ bindings = c.bindings;
1204
+ shells = c.shells;
1205
+ fills = c.fillScopes;
1206
+ leafBindings = c.preparedWindow.leafBindings;
1207
+ committed = desired;
1208
+ committedIndex = c.preparedWindow.index;
1209
+ committedSource = c.preparedWindow.source;
1210
+ plan = c.preparedWindow.plan;
1211
+ snapshot = c.snapshot;
1212
+ committedTheme = c.preparedWindow.theme;
1213
+ paintCommitted = c.preparedWindow.paintOnly;
1214
+ paintThemeOnly = false;
1215
+ preparedWindow = undefined;
1216
+ explicitScroll = undefined;
1217
+ revealIntent = undefined;
1218
+ heightUpdates.clear();
1219
+ dirty.clear();
1220
+ try {
1221
+ keyboard?.commit(keyboardRows, restoreFocus);
1222
+ }
1223
+ catch (cause) {
1224
+ errors.push(cause);
1225
+ }
1226
+ // Observers see the new complete revision before any old binding is retired.
1227
+ sync(errors);
1228
+ for (const leaf of c.retiringLeaves)
1229
+ retireLeaf(leaf, errors);
1230
+ for (const item of c.retiring)
1231
+ retire(item.binding, item.reason, errors);
1232
+ for (const s of c.discardedShells) {
1233
+ try {
1234
+ s.scope.dispose();
1235
+ }
1236
+ catch (e) {
1237
+ errors.push(e);
1238
+ }
1239
+ }
1240
+ for (const s of c.oldFills) {
1241
+ try {
1242
+ s.dispose();
1243
+ }
1244
+ catch (e) {
1245
+ errors.push(e);
1246
+ }
1247
+ }
1248
+ return result('committed', errors);
1249
+ }
1250
+ finally {
1251
+ committing = false;
1252
+ }
1253
+ },
1254
+ snapshot() {
1255
+ return freeze({
1256
+ ...snapshot,
1257
+ ...(layerOrigin === undefined ? {} : { origin: layerOrigin, layerRevision: layerGeneration }),
1258
+ desiredRevision: desired,
1259
+ counters: counters(snapshot.rows)
1260
+ });
1261
+ },
1262
+ dispose() {
1263
+ if (closed)
1264
+ return;
1265
+ closed = true;
1266
+ owner.remove(onOwnerAbort);
1267
+ const errors = preparedWindow?.cleanupErrors ?? [];
1268
+ errors.push(...closeEditorRoot());
1269
+ cancelFlight?.(new EgretError('UI_CLOSED'));
1270
+ for (const candidate of [...candidates])
1271
+ clearCandidate(candidate, errors);
1272
+ try {
1273
+ keyboard?.dispose();
1274
+ }
1275
+ catch (cause) {
1276
+ errors.push(cause);
1277
+ }
1278
+ try {
1279
+ display.detach(rootWrapper);
1280
+ }
1281
+ catch (e) {
1282
+ errors.push(e);
1283
+ }
1284
+ if (input?.state() === 'active')
1285
+ sync(errors);
1286
+ discardWindow(errors, 'dispose');
1287
+ for (const leaf of [...allLeafBindings])
1288
+ retireLeaf(leaf, errors);
1289
+ leafBindings.clear();
1290
+ for (const b of [...allBindings])
1291
+ retire(b, 'dispose', errors);
1292
+ for (const s of [...shells.values(), ...pool]) {
1293
+ try {
1294
+ s.scope.dispose();
1295
+ }
1296
+ catch (e) {
1297
+ errors.push(e);
1298
+ }
1299
+ }
1300
+ for (const s of fills) {
1301
+ try {
1302
+ s.dispose();
1303
+ }
1304
+ catch (e) {
1305
+ errors.push(e);
1306
+ }
1307
+ }
1308
+ try {
1309
+ if (listWrapper !== undefined)
1310
+ display.disposeWrapper(listWrapper);
1311
+ display.disposeWrapper(rootWrapper);
1312
+ }
1313
+ catch (e) {
1314
+ errors.push(e);
1315
+ }
1316
+ bindings.clear();
1317
+ shells.clear();
1318
+ pool = [];
1319
+ fills = [];
1320
+ preparedWindow = undefined;
1321
+ retentions.clear();
1322
+ editorRetentions.clear();
1323
+ retentionCount = 0;
1324
+ heightUpdates.clear();
1325
+ dirty.clear();
1326
+ source = undefined;
1327
+ revealIntent = undefined;
1328
+ committedSource = undefined;
1329
+ committedIndex = undefined;
1330
+ plan = undefined;
1331
+ tree = emptyTree;
1332
+ authoredTree = emptyTree;
1333
+ themeBindings = new Map();
1334
+ theme = undefined;
1335
+ committedTheme = undefined;
1336
+ leafContents = new Map();
1337
+ input = undefined;
1338
+ inputIdentity = undefined;
1339
+ unsubscribeClose();
1340
+ snapshot = freeze({
1341
+ ...snapshot,
1342
+ theme: undefined,
1343
+ rows: freeze([]),
1344
+ boxes: freeze([]),
1345
+ scrollExtent: 0,
1346
+ scrollOffset: 0,
1347
+ anchor: undefined,
1348
+ counters: counters()
1349
+ });
1350
+ if (errors.length !== 0)
1351
+ throw new EgretError('UI_CLEANUP_FAILED', {
1352
+ cause: errors[0],
1353
+ cleanupErrors: errors.slice(1)
1354
+ });
1355
+ }
1356
+ };
1357
+ // Layer publication has its own epoch: pending content can finish without resurrecting an old overlay.
1358
+ function presentLayer(value) {
1359
+ open();
1360
+ port.assertIdle();
1361
+ if (committing)
1362
+ failBusy(false);
1363
+ const p = origin({ x: value.x, y: value.y }, snapshot.viewport);
1364
+ display.presentRoot(rootWrapper, {
1365
+ x: p.x,
1366
+ y: p.y,
1367
+ visible: value.visible,
1368
+ interactive: value.pointerEnabled,
1369
+ ...(value.index === undefined ? {} : { index: value.index })
1370
+ });
1371
+ layerVisible = value.visible;
1372
+ layerPointer = value.pointerEnabled;
1373
+ layerKeyboard = value.keyboardEnabled;
1374
+ layerOrigin = p;
1375
+ layerGeneration = next(layerGeneration);
1376
+ }
1377
+ // Revoke only the layer presentation domain. This must also work during routed callbacks and Scope close.
1378
+ function releaseLayer(visible) {
1379
+ layerOrigin = undefined;
1380
+ layerVisible = visible;
1381
+ layerPointer = visible;
1382
+ layerKeyboard = visible;
1383
+ layerGeneration = next(layerGeneration);
1384
+ if (!closed)
1385
+ display.releaseRoot(rootWrapper, { x: snapshot.origin.x, y: snapshot.origin.y, visible });
1386
+ }
1387
+ const rootVisible = Object.getOwnPropertyDescriptor(DisplayObject.prototype, 'visible').get;
1388
+ const rootParent = Object.getOwnPropertyDescriptor(DisplayObject.prototype, 'parent').get;
1389
+ function anchor(target) {
1390
+ if (closed || committed === 0)
1391
+ return undefined;
1392
+ let box, content;
1393
+ if (target.kind === 'row') {
1394
+ if (target.listId !== listId)
1395
+ return undefined;
1396
+ const row = snapshot.rows.find(r => r.key === target.key && r.visible);
1397
+ if (!row)
1398
+ return undefined;
1399
+ box = row.box;
1400
+ content = bindings.get(target.key)?.content;
1401
+ }
1402
+ else {
1403
+ if (tree.nodes.get(target.id)?.kind !== 'leaf')
1404
+ return undefined;
1405
+ box = snapshot.boxes.find(b => b.id === target.id);
1406
+ content = leafBindings.get(target.id)?.content;
1407
+ }
1408
+ if (!box)
1409
+ return undefined;
1410
+ if (content) {
1411
+ let node = content, count = 0;
1412
+ while (node !== undefined && node !== rootWrapper) {
1413
+ if (++count > 64 || Reflect.apply(rootVisible, node, []) !== true)
1414
+ return undefined;
1415
+ node = Reflect.apply(rootParent, node, []);
1416
+ }
1417
+ if (node !== rootWrapper)
1418
+ return undefined;
1419
+ }
1420
+ let left = Math.max(0, box.x), top = Math.max(0, box.y), right = Math.min(snapshot.viewport.width, box.x + box.width), bottom = Math.min(snapshot.viewport.height, box.y + box.height);
1421
+ if (target.kind === 'row') {
1422
+ const list = snapshot.boxes.find(b => b.id === listId);
1423
+ if (!list)
1424
+ return undefined;
1425
+ left = Math.max(left, list.innerX);
1426
+ top = Math.max(top, list.innerY);
1427
+ right = Math.min(right, list.innerX + list.innerWidth);
1428
+ bottom = Math.min(bottom, list.innerY + list.innerHeight);
1429
+ }
1430
+ if (right <= left || bottom <= top)
1431
+ return undefined;
1432
+ return freeze({ x: left, y: top, width: right - left, height: bottom - top });
1433
+ }
1434
+ function onOwnerAbort() {
1435
+ api.dispose();
1436
+ }
1437
+ function result(kind, errors) {
1438
+ return freeze({
1439
+ kind,
1440
+ revision: committed,
1441
+ postCommitErrors: freeze(errors)
1442
+ });
1443
+ }
1444
+ try {
1445
+ const placeholder = display.prepare(rootWrapper, [
1446
+ {
1447
+ wrapper: rootWrapper,
1448
+ x: position.x,
1449
+ y: position.y,
1450
+ clipRect: {
1451
+ x: 0,
1452
+ y: 0,
1453
+ width: size.width,
1454
+ height: size.height
1455
+ },
1456
+ children: [],
1457
+ touchEnabled: false,
1458
+ touchChildren: false
1459
+ }
1460
+ ]);
1461
+ port.assertNotDrawing();
1462
+ // The placeholder is drawn into the root's own wrapper, which is on no stage until it is anchored.
1463
+ display.commit(placeholder);
1464
+ owner.use({
1465
+ dispose: () => api.dispose()
1466
+ });
1467
+ owner.add(onOwnerAbort);
1468
+ unsubscribeClose = port.onClose(() => api.dispose());
1469
+ owner.assertOpen();
1470
+ closeEditorRoot = registerUiRoot(api, options.engine, freeze({
1471
+ wrapper: rootWrapper,
1472
+ state: () => (closed ? 'closed' : 'open'),
1473
+ snapshot: () => api.snapshot(),
1474
+ layerState: () => freeze({
1475
+ snapshot,
1476
+ ready: !closed && !busy && !committing && candidates.size === 0 && desired === committed && committed > 0,
1477
+ mutable: !closed && !committing,
1478
+ lifetimeOpen: !closed && !owner.signal.aborted && !port.terminal(),
1479
+ visible: layerVisible,
1480
+ pointerEnabled: layerPointer,
1481
+ keyboardEnabled: layerKeyboard,
1482
+ input: inputIdentity,
1483
+ keyboard: keyboardIdentity
1484
+ }),
1485
+ presentLayer,
1486
+ releaseLayer,
1487
+ layerOwnership: (active) => {
1488
+ layerOwned = active;
1489
+ },
1490
+ anchor,
1491
+ lookup(target) {
1492
+ if (closed)
1493
+ return undefined;
1494
+ if (target.kind === 'leaf') {
1495
+ const leaf = leafBindings.get(target.id);
1496
+ return leaf?.content === undefined ? undefined : freeze({ content: leaf.content, visible: true });
1497
+ }
1498
+ if (target.listId !== listId)
1499
+ return undefined;
1500
+ const row = snapshot.rows.find(row => row.key === target.key), binding = bindings.get(target.key);
1501
+ return row === undefined || binding?.content === undefined
1502
+ ? undefined
1503
+ : freeze({
1504
+ content: binding.content,
1505
+ visible: row.visible,
1506
+ bindingGeneration: row.bindingGeneration,
1507
+ contentVersion: row.contentVersion
1508
+ });
1509
+ },
1510
+ retain(id, key) {
1511
+ if (id !== listId)
1512
+ fail('UI_UNKNOWN_LIST');
1513
+ return retainRow(key, 'focus', true);
1514
+ }
1515
+ }));
1516
+ return freeze(api);
1517
+ }
1518
+ catch (e) {
1519
+ try {
1520
+ api.dispose();
1521
+ }
1522
+ catch { }
1523
+ throw e;
1524
+ }
1525
+ }
1526
+ //# sourceMappingURL=uiRoot.js.map