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