@egret/engine 7.0.1-rc.3 → 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.
- package/dist/Engine.js +7 -2
- package/dist/animation/sequenceResetTypes.d.ts +6 -0
- package/dist/animation/types.d.ts +6 -0
- package/dist/assetBundle.d.ts +2 -0
- package/dist/assetGroupTypes.d.ts +2 -0
- package/dist/audioCues.d.ts +4 -0
- package/dist/audioTypes.d.ts +13 -0
- package/dist/bitmapButtonTypes.d.ts +2 -0
- package/dist/bitmapFontTypes.d.ts +3 -0
- package/dist/bitmapResourceSlot.d.ts +1 -0
- package/dist/camera2d.js +10 -2
- package/dist/cameraTypes.d.ts +12 -0
- package/dist/contentTypes.d.ts +2 -0
- package/dist/createEngineForProfile.js +8 -5
- package/dist/fontContentTypes.d.ts +5 -0
- package/dist/gameClockTypes.d.ts +6 -0
- package/dist/gameRun.d.ts +3 -0
- package/dist/gamepadTypes.d.ts +8 -0
- package/dist/hoverInputTypes.d.ts +10 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -1
- package/dist/inputActions.d.ts +5 -0
- package/dist/internal/uiFactoryState.d.ts +4 -0
- package/dist/internal/uiFactoryState.js +18 -2
- package/dist/keyboardInput.d.ts +1 -0
- package/dist/keyboardInput.js +1 -0
- package/dist/keyboardInputTypes.d.ts +12 -0
- package/dist/kit.d.ts +3 -1
- package/dist/kit.js +2 -1
- package/dist/manifestResourceState.d.ts +1 -0
- package/dist/manifestResourceState.js +1 -0
- package/dist/manifestResourceTypes.d.ts +1 -0
- package/dist/motion.d.ts +2 -0
- package/dist/mouseInputTypes.d.ts +4 -0
- package/dist/particleEmitter.js +8 -0
- package/dist/particleTypes.d.ts +8 -0
- package/dist/physics2d.d.ts +2 -2
- package/dist/physics2d.js +1 -1
- package/dist/physics2dTypes.d.ts +55 -1
- package/dist/physics2dWorld.js +209 -9
- package/dist/pointerInput.d.ts +1 -0
- package/dist/pointerInput.js +1 -0
- package/dist/pointerInputTypes.d.ts +3 -0
- package/dist/random.d.ts +1 -0
- package/dist/rendering/packSharedDraws2D.js +53 -5
- package/dist/rendering/prepareSharedDraws2D.d.ts +2 -0
- package/dist/rendering/prepareSharedDraws2D.js +17 -6
- package/dist/rendering/sharedColor2D.d.ts +35 -1
- package/dist/rendering/sharedColor2D.js +131 -8
- package/dist/rendering/sharedEffects2D.js +16 -8
- package/dist/rendering/world3d/Animation3D.d.ts +9 -0
- package/dist/rendering/world3d/Animation3D.js +4 -0
- package/dist/rendering/world3d/AnimationTexture3D.d.ts +6 -0
- package/dist/rendering/world3d/AnimationTexture3D.js +2 -0
- package/dist/rendering/world3d/Batch3D.d.ts +4 -0
- package/dist/rendering/world3d/Batch3D.js +3 -0
- package/dist/rendering/world3d/Camera3D.d.ts +5 -0
- package/dist/rendering/world3d/Camera3D.js +3 -0
- package/dist/rendering/world3d/Character3D.d.ts +4 -0
- package/dist/rendering/world3d/Character3D.js +2 -0
- package/dist/rendering/world3d/Cloth3D.d.ts +18 -3
- package/dist/rendering/world3d/Cloth3D.js +6 -1
- package/dist/rendering/world3d/Compression3D.d.ts +1 -0
- package/dist/rendering/world3d/Compression3D.js +1 -0
- package/dist/rendering/world3d/Curves3D.d.ts +8 -0
- package/dist/rendering/world3d/Curves3D.js +5 -0
- package/dist/rendering/world3d/Decal3D.d.ts +2 -0
- package/dist/rendering/world3d/Decal3D.js +1 -0
- package/dist/rendering/world3d/Export3D.d.ts +13 -0
- package/dist/rendering/world3d/Export3D.js +263 -0
- package/dist/rendering/world3d/Geometry3D.d.ts +11 -1
- package/dist/rendering/world3d/Geometry3D.js +10 -1
- package/dist/rendering/world3d/GeometryBuilder3D.d.ts +2 -0
- package/dist/rendering/world3d/Gizmo3D.d.ts +5 -0
- package/dist/rendering/world3d/Gizmo3D.js +2 -0
- package/dist/rendering/world3d/Gltf3D.d.ts +6 -0
- package/dist/rendering/world3d/Gltf3D.js +25 -5
- package/dist/rendering/world3d/GpuParticles3D.d.ts +2 -0
- package/dist/rendering/world3d/GpuParticles3D.js +1 -0
- package/dist/rendering/world3d/Hdr3D.d.ts +2 -0
- package/dist/rendering/world3d/Hdr3D.js +1 -0
- package/dist/rendering/world3d/Jelly3D.d.ts +2 -0
- package/dist/rendering/world3d/Jelly3D.js +1 -0
- package/dist/rendering/world3d/Ktx23D.d.ts +3 -0
- package/dist/rendering/world3d/Light3D.d.ts +9 -0
- package/dist/rendering/world3d/Light3D.js +4 -0
- package/dist/rendering/world3d/Material3D.d.ts +10 -0
- package/dist/rendering/world3d/Material3D.js +2 -0
- package/dist/rendering/world3d/Mesh3D.d.ts +4 -0
- package/dist/rendering/world3d/Mesh3D.js +16 -2
- package/dist/rendering/world3d/Meshopt3D.d.ts +3 -0
- package/dist/rendering/world3d/Meshopt3D.js +1 -0
- package/dist/rendering/world3d/Navigation3D.d.ts +41 -1
- package/dist/rendering/world3d/Navigation3D.js +74 -2
- package/dist/rendering/world3d/Object3D.d.ts +11 -0
- package/dist/rendering/world3d/Object3D.js +10 -0
- package/dist/rendering/world3d/Particles3D.d.ts +5 -0
- package/dist/rendering/world3d/Particles3D.js +3 -0
- package/dist/rendering/world3d/Physics3D.d.ts +14 -0
- package/dist/rendering/world3d/Physics3D.js +5 -0
- package/dist/rendering/world3d/PhysicsHull3D.d.ts +2 -0
- package/dist/rendering/world3d/PhysicsHull3D.js +2 -0
- package/dist/rendering/world3d/PhysicsMesh3D.d.ts +2 -0
- package/dist/rendering/world3d/PhysicsMesh3D.js +2 -0
- package/dist/rendering/world3d/PhysicsRemote3D.d.ts +5 -0
- package/dist/rendering/world3d/PhysicsRemote3D.js +2 -0
- package/dist/rendering/world3d/Ragdoll3D.d.ts +5 -0
- package/dist/rendering/world3d/Ragdoll3D.js +2 -0
- package/dist/rendering/world3d/Raycast3D.d.ts +3 -0
- package/dist/rendering/world3d/Raycast3D.js +1 -0
- package/dist/rendering/world3d/RenderList3D.d.ts +3 -0
- package/dist/rendering/world3d/RenderList3D.js +12 -0
- package/dist/rendering/world3d/Retarget3D.d.ts +1 -0
- package/dist/rendering/world3d/Rig3D.d.ts +57 -0
- package/dist/rendering/world3d/Rig3D.js +219 -0
- package/dist/rendering/world3d/Sdf3D.d.ts +181 -0
- package/dist/rendering/world3d/Sdf3D.js +1136 -0
- package/dist/rendering/world3d/SdfLod3D.d.ts +17 -0
- package/dist/rendering/world3d/SdfLod3D.js +56 -0
- package/dist/rendering/world3d/Serialize3D.d.ts +17 -0
- package/dist/rendering/world3d/Serialize3D.js +22 -0
- package/dist/rendering/world3d/Simplify3D.d.ts +29 -0
- package/dist/rendering/world3d/Simplify3D.js +426 -0
- package/dist/rendering/world3d/StateMachine3D.d.ts +9 -0
- package/dist/rendering/world3d/StateMachine3D.js +3 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.d.ts +26 -0
- package/dist/rendering/world3d/SurfaceMaterial3D.js +138 -0
- package/dist/rendering/world3d/Terrain3D.d.ts +21 -0
- package/dist/rendering/world3d/Terrain3D.js +25 -1
- package/dist/rendering/world3d/Text3D.d.ts +5 -0
- package/dist/rendering/world3d/Text3D.js +2 -0
- package/dist/rendering/world3d/Texture3D.d.ts +16 -1
- package/dist/rendering/world3d/Texture3D.js +19 -1
- package/dist/rendering/world3d/Trail3D.d.ts +3 -0
- package/dist/rendering/world3d/Trail3D.js +2 -0
- package/dist/rendering/world3d/Vehicle3D.d.ts +5 -0
- package/dist/rendering/world3d/Vehicle3D.js +2 -0
- package/dist/rendering/world3d/VolumetricFog3D.d.ts +2 -0
- package/dist/rendering/world3d/VolumetricFog3D.js +1 -0
- package/dist/rendering/world3d/Water3D.d.ts +2 -0
- package/dist/rendering/world3d/Water3D.js +1 -0
- package/dist/rendering/world3d/core3D.d.ts +2 -0
- package/dist/rendering/world3d/debug3D.d.ts +5 -0
- package/dist/rendering/world3d/debug3D.js +5 -0
- package/dist/rendering/world3d/geometries3D.d.ts +12 -0
- package/dist/rendering/world3d/geometries3D.js +5 -0
- package/dist/rendering/world3d/helpers3D.d.ts +2 -0
- package/dist/rendering/world3d/helpers3D.js +1 -0
- package/dist/rendering/world3d/index.d.ts +12 -0
- package/dist/rendering/world3d/index.js +6 -0
- package/dist/rendering/world3d/math3D.d.ts +36 -0
- package/dist/rendering/world3d/math3D.js +35 -0
- package/dist/rendering/world3d/primitives3D.d.ts +7 -0
- package/dist/rendering/world3d/primitives3D.js +1 -0
- package/dist/saveStore.d.ts +18 -3
- package/dist/saveStore.js +23 -4
- package/dist/semanticList.d.ts +4 -0
- package/dist/semanticList.js +1 -0
- package/dist/semanticTree.js +11 -4
- package/dist/semanticTypes.d.ts +8 -0
- package/dist/sequencePlaybackTypes.d.ts +3 -0
- package/dist/text.d.ts +1 -0
- package/dist/textTable.d.ts +41 -0
- package/dist/textTable.js +114 -0
- package/dist/tilemapTypes.d.ts +13 -0
- package/dist/timer.d.ts +34 -0
- package/dist/timer.js +119 -0
- package/dist/tweenTypes.d.ts +4 -0
- package/dist/ui/controlKeys.d.ts +4 -0
- package/dist/ui/controlKeys.js +1 -0
- package/dist/ui/controls.d.ts +6 -0
- package/dist/ui/controls.js +2 -0
- package/dist/ui/layerTypes.d.ts +7 -0
- package/dist/ui/rangeControl.d.ts +3 -0
- package/dist/ui/rangeControl.js +1 -0
- package/dist/ui/scrollControl.d.ts +12 -0
- package/dist/ui/scrollControl.js +5 -1
- package/dist/ui/stateControls.d.ts +8 -0
- package/dist/ui/stateControls.js +3 -0
- package/dist/ui/textEditor.d.ts +1 -0
- package/dist/ui/textEditor.js +1 -0
- package/dist/ui/textEditorTypes.d.ts +7 -0
- package/dist/ui/textFieldControl.d.ts +4 -0
- package/dist/ui/textFieldControl.js +1 -0
- package/dist/ui/theme.d.ts +5 -0
- package/dist/ui/theme.js +1 -0
- package/dist/ui/types.d.ts +20 -0
- package/dist/ui/uiRoot.js +38 -9
- package/dist/ui/uiRootModel.d.ts +3 -1
- package/dist/ui/uiRootModel.js +8 -2
- package/dist/videoTypes.d.ts +3 -0
- package/dist/web/BrowserAssetBundle.d.ts +2 -0
- package/dist/web/BrowserAudio.d.ts +34 -1
- package/dist/web/BrowserAudio.js +69 -39
- package/dist/web/BrowserFrameLoop.d.ts +4 -0
- package/dist/web/BrowserGame.d.ts +64 -2
- package/dist/web/BrowserGame.js +129 -8
- package/dist/web/BrowserGamepadInput.d.ts +3 -0
- package/dist/web/BrowserHoverInput.d.ts +1 -0
- package/dist/web/BrowserImageTextures.d.ts +6 -0
- package/dist/web/BrowserInputActions.d.ts +10 -0
- package/dist/web/BrowserInputActions.js +4 -1
- package/dist/web/BrowserPlay.d.ts +130 -2
- package/dist/web/BrowserPlay.js +366 -19
- package/dist/web/BrowserPreferences.d.ts +10 -0
- package/dist/web/BrowserPreferences.js +39 -0
- package/dist/web/BrowserSemantics.d.ts +2 -0
- package/dist/web/BrowserStatsPanel.d.ts +10 -0
- package/dist/web/BrowserStatsPanel.js +9 -3
- package/dist/web/BrowserStorage.d.ts +2 -0
- package/dist/web/BrowserTextEditor.d.ts +3 -0
- package/dist/web/BrowserTextInput.d.ts +6 -0
- package/dist/web/BrowserTextureProvider.d.ts +6 -0
- package/dist/web/BrowserVideo.d.ts +13 -1
- package/dist/web/BrowserVideo.js +28 -2
- package/dist/web/CanvasKitFontSetProvider.d.ts +3 -0
- package/dist/web/CanvasKitParagraphProvider.d.ts +4 -0
- package/dist/web/CanvasKitParagraphProvider.js +1 -0
- package/dist/web/ManifestByteSource.d.ts +4 -0
- package/dist/web/ManifestByteSource.js +1 -0
- package/dist/web/ManifestFontContentLoader.d.ts +1 -0
- package/dist/web/WebGL2Host.js +64 -25
- package/dist/web/WebGPUHost.d.ts +13 -0
- package/dist/web/WebGPUHost.js +117 -36
- package/dist/web/audio.d.ts +2 -2
- package/dist/web/audio.js +1 -1
- package/dist/web/editorFonts.d.ts +4 -0
- package/dist/web/game.d.ts +1 -1
- package/dist/web/imageProjections2D.d.ts +2 -0
- package/dist/web/kit.d.ts +1 -0
- package/dist/web/kit.js +1 -0
- package/dist/web/play.d.ts +6 -1
- package/dist/web/play.js +4 -1
- package/dist/web/playMusic.d.ts +33 -0
- package/dist/web/playMusic.js +194 -0
- package/dist/web/playTouch.d.ts +45 -0
- package/dist/web/playTouch.js +141 -0
- package/dist/web/playWidgets.d.ts +71 -0
- package/dist/web/playWidgets.js +431 -0
- package/dist/web/prepareSharedSubmission2D.js +9 -3
- package/dist/web/resources.d.ts +2 -0
- package/dist/web/sharedEffectShaders.d.ts +6 -2
- package/dist/web/sharedEffectShaders.js +23 -7
- package/dist/web/sharedSubmissionStorage2D.js +1 -1
- package/dist/web/sharedWebGL2Options.d.ts +3 -0
- package/dist/web/sharedWebGL2Options.js +8 -2
- package/dist/web/sharedWebGL2Shaders.d.ts +15 -2
- package/dist/web/sharedWebGL2Shaders.js +108 -14
- package/dist/web/sharedWebGPUOptions.d.ts +5 -1
- package/dist/web/sharedWebGPUOptions.js +6 -2
- package/dist/web/video.d.ts +1 -1
- package/dist/web/webgl2Native.d.ts +3 -1
- package/dist/web/webgl2Native.js +9 -5
- package/dist/web/webgl2Types.d.ts +18 -0
- package/dist/web/webgpuImageResidency.d.ts +5 -2
- package/dist/web/webgpuImageResidency.js +7 -3
- package/dist/web/webgpuRetentionPool.d.ts +2 -2
- package/dist/web/webgpuRetentionPool.js +2 -1
- package/dist/web/webgpuSharedPass.d.ts +1 -1
- package/dist/web/webgpuSharedPass.js +87 -5
- package/dist/web/webgpuSharedResolvePass.d.ts +1 -1
- package/dist/web/webgpuSharedResolvePass.js +9 -4
- package/dist/web/world3d/Audio3D.d.ts +18 -1
- package/dist/web/world3d/Audio3D.js +62 -3
- package/dist/web/world3d/BrowserPlay3D.d.ts +115 -2
- package/dist/web/world3d/BrowserPlay3D.js +448 -43
- package/dist/web/world3d/FlyControls3D.d.ts +4 -0
- package/dist/web/world3d/FlyControls3D.js +2 -0
- package/dist/web/world3d/FollowControls3D.d.ts +3 -0
- package/dist/web/world3d/FollowControls3D.js +2 -0
- package/dist/web/world3d/OrbitControls3D.d.ts +3 -0
- package/dist/web/world3d/OrbitControls3D.js +2 -0
- package/dist/web/world3d/TransformControls3D.d.ts +5 -2
- package/dist/web/world3d/TransformControls3D.js +7 -4
- package/dist/web/world3d/WebGL2Renderer3D.d.ts +3 -0
- package/dist/web/world3d/WebGL2Renderer3D.js +2 -0
- package/dist/web/world3d/WebGPURenderer3D.d.ts +2 -0
- package/dist/web/world3d/WebGPURenderer3D.js +1 -0
- package/dist/web/world3d/World3DView.d.ts +3 -0
- package/dist/web/world3d/World3DView.js +2 -0
- package/dist/web/world3d/app3D.d.ts +7 -0
- package/dist/web/world3d/app3D.js +1 -0
- package/dist/web/world3d/assets3D.d.ts +1 -0
- package/dist/web/world3d/atmosphere3D.d.ts +9 -0
- package/dist/web/world3d/atmosphere3D.js +19 -4
- package/dist/web/world3d/canvasFont3D.d.ts +21 -0
- package/dist/web/world3d/canvasFont3D.js +165 -0
- package/dist/web/world3d/frame3D.d.ts +2 -0
- package/dist/web/world3d/host3D.d.ts +1 -0
- package/dist/web/world3d/index.d.ts +4 -2
- package/dist/web/world3d/index.js +2 -1
- package/dist/web/world3d/loaders3D.d.ts +1 -0
- package/dist/web/world3d/markers3D.d.ts +4 -0
- package/dist/web/world3d/overlay3D.d.ts +19 -0
- package/dist/web/world3d/overlay3D.js +21 -4
- package/dist/web/world3d/post3D.d.ts +4 -0
- package/dist/web/world3d/post3D.js +3 -0
- package/dist/web/world3d/probe3D.d.ts +1 -0
- package/dist/web/world3d/stats3D.d.ts +3 -0
- package/dist/web/world3d/stats3D.js +1 -0
- package/dist/web/world3d/webGL2FrameMetrics3D.d.ts +5 -0
- package/dist/web/world3d/webgpu.d.ts +2 -0
- package/dist/web/world3d/webgpu.js +1 -0
- package/package.json +3 -3
package/dist/ui/uiRoot.js
CHANGED
|
@@ -7,14 +7,28 @@ import { registerUiRoot } from '../internal/uiRootState.js';
|
|
|
7
7
|
import { captureSource, captureReveal, revealScroll } from './virtualList.js';
|
|
8
8
|
import { createUiKeyboardFocus } from './keyboardFocus.js';
|
|
9
9
|
import { captureUiTree, leafConstraintTree, leafMeasuredTree, fixedLeafMeasurement } from './leafContent.js';
|
|
10
|
-
import { withoutSources, preparationError, fail, next, number, viewport, origin } from './uiRootModel.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
|
+
}
|
|
11
23
|
import { createUiRootDisplayDraft, stageUiRootDisplay } from './uiRootDisplay.js';
|
|
12
24
|
const freeze = Object.freeze;
|
|
13
25
|
/** One owned transaction domain over the genuine display and input authorities. */
|
|
14
26
|
export function createUiRoot(options) {
|
|
15
27
|
const port = requireUiEngine(options.engine);
|
|
16
28
|
port.assertOpen();
|
|
17
|
-
|
|
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();
|
|
18
32
|
const owner = port.scope(options.scope);
|
|
19
33
|
owner.assertOpen();
|
|
20
34
|
const display = port.display(createUiDisplayOperations);
|
|
@@ -364,7 +378,7 @@ export function createUiRoot(options) {
|
|
|
364
378
|
fail('UI_STALE');
|
|
365
379
|
}
|
|
366
380
|
const content = value.content, height = number(value.measuredHeight, 1, 1048576);
|
|
367
|
-
display.validateContent(content, scope.scope);
|
|
381
|
+
contentOf('row ' + JSON.stringify(key), () => display.validateContent(content, scope.scope));
|
|
368
382
|
check(w.revision);
|
|
369
383
|
// Explicit height updates can supersede the measurement retained by a binding.
|
|
370
384
|
const committedPosition = committedIndex?.indexOf(key) ?? -1;
|
|
@@ -469,7 +483,7 @@ export function createUiRoot(options) {
|
|
|
469
483
|
fail('UI_STALE');
|
|
470
484
|
}
|
|
471
485
|
const content = value.content, height = number(value.measuredHeight, 0, 1048576);
|
|
472
|
-
display.validateContent(content, scope.scope);
|
|
486
|
+
contentOf('leaf ' + JSON.stringify(name), () => display.validateContent(content, scope.scope));
|
|
473
487
|
check(w.revision);
|
|
474
488
|
if (w.paintOnly && height !== leafBindings.get(name)?.height)
|
|
475
489
|
fail('UI_THEME_METRICS_CHANGED');
|
|
@@ -1030,7 +1044,7 @@ export function createUiRoot(options) {
|
|
|
1030
1044
|
if (value === inputIdentity)
|
|
1031
1045
|
return;
|
|
1032
1046
|
if (busy || committing)
|
|
1033
|
-
|
|
1047
|
+
failBusy(busy);
|
|
1034
1048
|
port.assertIdle();
|
|
1035
1049
|
display.assertStage();
|
|
1036
1050
|
if (input !== undefined && input.state() !== 'closed' && input.activeContacts() !== 0)
|
|
@@ -1086,9 +1100,23 @@ export function createUiRoot(options) {
|
|
|
1086
1100
|
},
|
|
1087
1101
|
async prepare() {
|
|
1088
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
|
+
}
|
|
1089
1117
|
port.assertIdle();
|
|
1090
1118
|
if (busy || committing)
|
|
1091
|
-
|
|
1119
|
+
failBusy(busy);
|
|
1092
1120
|
for (const c of [...candidates])
|
|
1093
1121
|
clearCandidate(c);
|
|
1094
1122
|
busy = true;
|
|
@@ -1130,7 +1158,7 @@ export function createUiRoot(options) {
|
|
|
1130
1158
|
}
|
|
1131
1159
|
port.assertIdle();
|
|
1132
1160
|
if (busy || committing)
|
|
1133
|
-
|
|
1161
|
+
failBusy(busy);
|
|
1134
1162
|
display.assertStage();
|
|
1135
1163
|
if (entry.retired === true ||
|
|
1136
1164
|
(entry.candidate !== undefined && !candidates.has(entry.candidate)) ||
|
|
@@ -1331,7 +1359,7 @@ export function createUiRoot(options) {
|
|
|
1331
1359
|
open();
|
|
1332
1360
|
port.assertIdle();
|
|
1333
1361
|
if (committing)
|
|
1334
|
-
|
|
1362
|
+
failBusy(false);
|
|
1335
1363
|
const p = origin({ x: value.x, y: value.y }, snapshot.viewport);
|
|
1336
1364
|
display.presentRoot(rootWrapper, {
|
|
1337
1365
|
x: p.x,
|
|
@@ -1430,7 +1458,8 @@ export function createUiRoot(options) {
|
|
|
1430
1458
|
touchChildren: false
|
|
1431
1459
|
}
|
|
1432
1460
|
]);
|
|
1433
|
-
port.
|
|
1461
|
+
port.assertNotDrawing();
|
|
1462
|
+
// The placeholder is drawn into the root's own wrapper, which is on no stage until it is anchored.
|
|
1434
1463
|
display.commit(placeholder);
|
|
1435
1464
|
owner.use({
|
|
1436
1465
|
dispose: () => api.dispose()
|
package/dist/ui/uiRootModel.d.ts
CHANGED
|
@@ -89,7 +89,9 @@ export interface TokenState {
|
|
|
89
89
|
}
|
|
90
90
|
export declare function withoutSources(tree: UiLayoutTree): UiLayoutTree;
|
|
91
91
|
export declare function preparationError(cause: unknown, cleanupErrors: unknown[]): EgretError;
|
|
92
|
-
export declare function fail(code: string): never;
|
|
92
|
+
export declare function fail(code: string, reason?: string): never;
|
|
93
|
+
/** Why a root is busy with its own work: a preparation that has not settled, or a commit being made. */
|
|
94
|
+
export declare function failBusy(preparing: boolean): never;
|
|
93
95
|
export declare function next(value: number): number;
|
|
94
96
|
export declare function number(value: number, min: number, max: number): number;
|
|
95
97
|
export declare function viewport(value: Readonly<{
|
package/dist/ui/uiRootModel.js
CHANGED
|
@@ -29,8 +29,14 @@ export function preparationError(cause, cleanupErrors) {
|
|
|
29
29
|
return cause;
|
|
30
30
|
return new EgretError(cause instanceof EgretError ? cause.code : 'UI_PREPARE_FAILED', { cause, cleanupErrors });
|
|
31
31
|
}
|
|
32
|
-
export function fail(code) {
|
|
33
|
-
throw new EgretError(code);
|
|
32
|
+
export function fail(code, reason) {
|
|
33
|
+
throw new EgretError(code, reason === undefined ? {} : { cause: new Error(reason) });
|
|
34
|
+
}
|
|
35
|
+
/** Why a root is busy with its own work: a preparation that has not settled, or a commit being made. */
|
|
36
|
+
export function failBusy(preparing) {
|
|
37
|
+
fail('UI_BUSY', preparing
|
|
38
|
+
? 'an earlier prepare() of this root has not settled yet: await it, then prepare again'
|
|
39
|
+
: 'a commit of this root is being made');
|
|
34
40
|
}
|
|
35
41
|
export function next(value) {
|
|
36
42
|
if (value >= Number.MAX_SAFE_INTEGER)
|
package/dist/videoTypes.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AssetManager, DisplayObjectContainer } from '@egret/runtime';
|
|
|
2
2
|
import type { ImageData2D } from '@egret/contracts';
|
|
3
3
|
/** Where a source is: still opening, able to show a frame, playing, paused, at its end, or unable to play. */
|
|
4
4
|
export type VideoSourceState = 'loading' | 'ready' | 'playing' | 'paused' | 'ended' | 'failed';
|
|
5
|
+
/** Whether a video is loading, ready, playing, paused, ended, failed or closed. */
|
|
5
6
|
export type VideoState = VideoSourceState | 'closed';
|
|
6
7
|
/** One picture of a video, the time of the video it shows. */
|
|
7
8
|
export interface VideoFrame {
|
|
@@ -31,11 +32,13 @@ export interface VideoSource {
|
|
|
31
32
|
seek(seconds: number): void;
|
|
32
33
|
dispose(): void;
|
|
33
34
|
}
|
|
35
|
+
/** A video to show: the asset manager that leases its pictures, and its source. */
|
|
34
36
|
export interface VideoOptions {
|
|
35
37
|
/** The Engine's assets, which lease each picture as a texture. */
|
|
36
38
|
readonly assets: AssetManager;
|
|
37
39
|
readonly source: VideoSource;
|
|
38
40
|
}
|
|
41
|
+
/** A video as it is now: its state, its pictures shown and skipped, and its times. */
|
|
39
42
|
export interface VideoSnapshot {
|
|
40
43
|
readonly state: VideoState;
|
|
41
44
|
/** Pictures shown since it was made. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AssetBundleEntry, AssetBundleIndex } from '@egret/engine/kit';
|
|
2
|
+
/** An asset bundle to open: how it is fetched and from where, whether it is read whole, and the cache it is kept in. */
|
|
2
3
|
export interface BrowserAssetBundleOptions {
|
|
3
4
|
/** `fetch` by default; tests and service workers give their own. */
|
|
4
5
|
readonly fetch?: (url: string, init?: {
|
|
@@ -18,6 +19,7 @@ export interface BrowserAssetBundleOptions {
|
|
|
18
19
|
put(key: string, bytes: Uint8Array): Promise<void>;
|
|
19
20
|
};
|
|
20
21
|
}
|
|
22
|
+
/** An asset bundle opened in the browser: its index and entries, and calls that read an entry's bytes. */
|
|
21
23
|
export interface BrowserAssetBundle {
|
|
22
24
|
readonly url: string;
|
|
23
25
|
readonly index: AssetBundleIndex;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AudioMixer, AudioMixerOptions } from '@egret/engine/audio';
|
|
1
|
+
import type { AudioBackend, AudioMixer, AudioMixerOptions } from '@egret/engine/audio';
|
|
2
|
+
/** Browser audio to make: its audio context, what unlocks it, whether it pauses when the page is hidden, and its limiter. */
|
|
2
3
|
export interface BrowserAudioOptions extends Omit<AudioMixerOptions, 'backend' | 'locked'> {
|
|
3
4
|
/** An output the page made. It is used as it is and is not closed with the mixer. Without it one is made. */
|
|
4
5
|
readonly context?: BaseAudioContext;
|
|
@@ -25,6 +26,28 @@ export interface BrowserAudioLimiter {
|
|
|
25
26
|
readonly attack?: number;
|
|
26
27
|
readonly release?: number;
|
|
27
28
|
}
|
|
29
|
+
/** The Web Audio half of browser sound alone: its output, what unlocks it, whether it pauses when hidden, its limiter. */
|
|
30
|
+
export interface WebAudioBackendOptions {
|
|
31
|
+
readonly context?: BaseAudioContext;
|
|
32
|
+
readonly unlockTarget?: EventTarget;
|
|
33
|
+
readonly pauseWhenHidden?: boolean;
|
|
34
|
+
readonly onError?: (cause: unknown) => void;
|
|
35
|
+
readonly limiter?: boolean | BrowserAudioLimiter;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A backend for `createAudioMixer` that plays through Web Audio. Give `locked` to the mixer as it is made, and then the
|
|
39
|
+
* mixer to `attach`, so the lock follows the first touch and the sound pauses while the page is hidden.
|
|
40
|
+
*/
|
|
41
|
+
export interface WebAudioBackend extends AudioBackend {
|
|
42
|
+
readonly context: BaseAudioContext;
|
|
43
|
+
/** What every sound passes on its way out, once the mixer has made its master bus. */
|
|
44
|
+
readonly output: AudioNode | undefined;
|
|
45
|
+
/** Whether the output is waiting for the person to touch the page before it may sound. */
|
|
46
|
+
readonly locked: boolean;
|
|
47
|
+
/** The mixer made on this backend: its lock follows the output from now on. Once only. */
|
|
48
|
+
attach(mixer: AudioMixer): void;
|
|
49
|
+
}
|
|
50
|
+
/** A sound mixer playing through Web Audio, with its context and output node. */
|
|
28
51
|
export interface BrowserAudio {
|
|
29
52
|
readonly mixer: AudioMixer;
|
|
30
53
|
readonly context: BaseAudioContext;
|
|
@@ -33,6 +56,16 @@ export interface BrowserAudio {
|
|
|
33
56
|
/** The same as disposing the mixer. A scope can own the sound of a game through this. */
|
|
34
57
|
dispose(): void;
|
|
35
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* A Web Audio backend for a mixer the page makes itself with `createAudioMixer`:
|
|
61
|
+
*
|
|
62
|
+
* const backend = createWebAudioBackend();
|
|
63
|
+
* const mixer = createAudioMixer({ backend, locked: backend.locked });
|
|
64
|
+
* backend.attach(mixer);
|
|
65
|
+
*
|
|
66
|
+
* `createBrowserAudio` does these three steps in one call.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createWebAudioBackend(options?: WebAudioBackendOptions): WebAudioBackend;
|
|
36
69
|
/**
|
|
37
70
|
* Sound for a page on Web Audio. A page may not sound before the person has touched it: until
|
|
38
71
|
* then the mixer is locked, music asked for waits, and the first touch or key lets it start.
|
package/dist/web/BrowserAudio.js
CHANGED
|
@@ -12,13 +12,18 @@ const at = (line, time) => time >= line.end
|
|
|
12
12
|
? line.from
|
|
13
13
|
: line.from + ((line.to - line.from) * (time - line.start)) / (line.end - line.start);
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* A Web Audio backend for a mixer the page makes itself with `createAudioMixer`:
|
|
16
|
+
*
|
|
17
|
+
* const backend = createWebAudioBackend();
|
|
18
|
+
* const mixer = createAudioMixer({ backend, locked: backend.locked });
|
|
19
|
+
* backend.attach(mixer);
|
|
20
|
+
*
|
|
21
|
+
* `createBrowserAudio` does these three steps in one call.
|
|
17
22
|
*/
|
|
18
|
-
export function
|
|
23
|
+
export function createWebAudioBackend(options = {}) {
|
|
19
24
|
if (options === null || typeof options !== 'object' || Array.isArray(options))
|
|
20
25
|
throw new EgretError('AUDIO_OPTIONS_INVALID');
|
|
21
|
-
const { context: given, unlockTarget, pauseWhenHidden = true, onError, limiter: limit
|
|
26
|
+
const { context: given, unlockTarget, pauseWhenHidden = true, onError, limiter: limit } = options;
|
|
22
27
|
const Live = globalThis.AudioContext, page = globalThis.document;
|
|
23
28
|
if ((given !== undefined && (given === null || typeof given !== 'object')) ||
|
|
24
29
|
typeof pauseWhenHidden !== 'boolean' ||
|
|
@@ -53,6 +58,7 @@ export function createBrowserAudio(options = {}) {
|
|
|
53
58
|
const sounding = new Set();
|
|
54
59
|
const pairs = [];
|
|
55
60
|
const armed = [];
|
|
61
|
+
let mixer;
|
|
56
62
|
let closed = false, desired = true, output, silent;
|
|
57
63
|
function report(cause) {
|
|
58
64
|
if (onError !== undefined)
|
|
@@ -94,13 +100,13 @@ export function createBrowserAudio(options = {}) {
|
|
|
94
100
|
follow();
|
|
95
101
|
if (live.state === 'running') {
|
|
96
102
|
unlisten(armed);
|
|
97
|
-
mixer
|
|
103
|
+
mixer?.setLocked(false);
|
|
98
104
|
if (!desired)
|
|
99
105
|
live.suspend().catch(report);
|
|
100
106
|
}
|
|
101
107
|
else if (desired) {
|
|
102
108
|
arm();
|
|
103
|
-
mixer
|
|
109
|
+
mixer?.setLocked(true);
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
catch (cause) {
|
|
@@ -270,6 +276,39 @@ export function createBrowserAudio(options = {}) {
|
|
|
270
276
|
};
|
|
271
277
|
}
|
|
272
278
|
const backend = {
|
|
279
|
+
context,
|
|
280
|
+
get output() {
|
|
281
|
+
return output;
|
|
282
|
+
},
|
|
283
|
+
get locked() {
|
|
284
|
+
return live !== undefined && live.state !== 'running';
|
|
285
|
+
},
|
|
286
|
+
attach(made) {
|
|
287
|
+
if (mixer !== undefined || made === null || typeof made !== 'object')
|
|
288
|
+
throw new EgretError('AUDIO_OPTIONS_INVALID');
|
|
289
|
+
mixer = made;
|
|
290
|
+
if (live === undefined)
|
|
291
|
+
return;
|
|
292
|
+
listen(pairs, live, 'statechange', settle);
|
|
293
|
+
if (pauseWhenHidden && page !== undefined) {
|
|
294
|
+
const visibility = () => {
|
|
295
|
+
try {
|
|
296
|
+
if (page.visibilityState === 'hidden')
|
|
297
|
+
made.suspend('hidden');
|
|
298
|
+
else
|
|
299
|
+
made.resume('hidden');
|
|
300
|
+
}
|
|
301
|
+
catch (cause) {
|
|
302
|
+
report(cause);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
listen(pairs, page, 'visibilitychange', visibility);
|
|
306
|
+
if (page.visibilityState === 'hidden')
|
|
307
|
+
made.suspend('hidden');
|
|
308
|
+
}
|
|
309
|
+
if (live.state !== 'running')
|
|
310
|
+
arm();
|
|
311
|
+
},
|
|
273
312
|
get time() {
|
|
274
313
|
return context.currentTime;
|
|
275
314
|
},
|
|
@@ -420,51 +459,42 @@ export function createBrowserAudio(options = {}) {
|
|
|
420
459
|
live.close().catch(report);
|
|
421
460
|
}
|
|
422
461
|
};
|
|
462
|
+
return backend;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Sound for a page on Web Audio. A page may not sound before the person has touched it: until
|
|
466
|
+
* then the mixer is locked, music asked for waits, and the first touch or key lets it start.
|
|
467
|
+
*/
|
|
468
|
+
export function createBrowserAudio(options = {}) {
|
|
469
|
+
if (options === null || typeof options !== 'object' || Array.isArray(options))
|
|
470
|
+
throw new EgretError('AUDIO_OPTIONS_INVALID');
|
|
471
|
+
const { context: _context, unlockTarget: _target, pauseWhenHidden: _hidden, onError: _error, limiter: _limiter, ...configuration } = options;
|
|
472
|
+
// The backend reads its own options and no others.
|
|
473
|
+
const backend = createWebAudioBackend(options);
|
|
423
474
|
let mixer;
|
|
424
475
|
try {
|
|
425
|
-
mixer = createAudioMixer({ ...configuration, backend, locked:
|
|
476
|
+
mixer = createAudioMixer({ ...configuration, backend, locked: backend.locked });
|
|
426
477
|
}
|
|
427
478
|
catch (cause) {
|
|
428
|
-
|
|
429
|
-
live.close().catch(report);
|
|
479
|
+
backend.close();
|
|
430
480
|
throw cause;
|
|
431
481
|
}
|
|
432
|
-
|
|
482
|
+
try {
|
|
483
|
+
backend.attach(mixer);
|
|
484
|
+
}
|
|
485
|
+
catch (cause) {
|
|
433
486
|
try {
|
|
434
|
-
|
|
435
|
-
if (pauseWhenHidden && page !== undefined) {
|
|
436
|
-
const visibility = () => {
|
|
437
|
-
try {
|
|
438
|
-
if (page.visibilityState === 'hidden')
|
|
439
|
-
mixer.suspend('hidden');
|
|
440
|
-
else
|
|
441
|
-
mixer.resume('hidden');
|
|
442
|
-
}
|
|
443
|
-
catch (cause) {
|
|
444
|
-
report(cause);
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
listen(pairs, page, 'visibilitychange', visibility);
|
|
448
|
-
if (page.visibilityState === 'hidden')
|
|
449
|
-
mixer.suspend('hidden');
|
|
450
|
-
}
|
|
451
|
-
if (live.state !== 'running')
|
|
452
|
-
arm();
|
|
487
|
+
mixer.dispose();
|
|
453
488
|
}
|
|
454
|
-
catch
|
|
455
|
-
|
|
456
|
-
mixer.dispose();
|
|
457
|
-
}
|
|
458
|
-
catch {
|
|
459
|
-
/* the first failure is the one told */
|
|
460
|
-
}
|
|
461
|
-
throw cause;
|
|
489
|
+
catch {
|
|
490
|
+
/* the first failure is the one told */
|
|
462
491
|
}
|
|
492
|
+
throw cause;
|
|
463
493
|
}
|
|
464
494
|
return Object.freeze({
|
|
465
495
|
mixer,
|
|
466
|
-
context,
|
|
467
|
-
output: output,
|
|
496
|
+
context: backend.context,
|
|
497
|
+
output: backend.output,
|
|
468
498
|
dispose() {
|
|
469
499
|
mixer.dispose();
|
|
470
500
|
}
|
|
@@ -12,6 +12,7 @@ export interface FrameLoopHost {
|
|
|
12
12
|
readonly pendingFrames: number;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
/** A frame loop to run: its engine, frame and host, its update, how long a step and a catch-up may be, and its frame requests. */
|
|
15
16
|
export interface BrowserFrameLoopOptions<F> {
|
|
16
17
|
readonly engine: FrameLoopEngine<F>;
|
|
17
18
|
/** The frame to draw: its size and clear colour. A function is called for each frame that is drawn. */
|
|
@@ -37,7 +38,9 @@ export interface BrowserFrameLoopOptions<F> {
|
|
|
37
38
|
readonly requestFrame?: (callback: (milliseconds: number) => void) => number;
|
|
38
39
|
readonly cancelFrame?: (handle: number) => void;
|
|
39
40
|
}
|
|
41
|
+
/** Whether a frame loop is idle, running, failed or closed. */
|
|
40
42
|
export type BrowserFrameLoopState = 'idle' | 'running' | 'failed' | 'closed';
|
|
43
|
+
/** A frame loop as it is now: its state, its steps, frames and skipped frames, its seconds and any failure. */
|
|
41
44
|
export interface BrowserFrameLoopSnapshot {
|
|
42
45
|
readonly state: BrowserFrameLoopState;
|
|
43
46
|
/** Steps taken, frames drawn, and frames skipped because the Host was busy. */
|
|
@@ -48,6 +51,7 @@ export interface BrowserFrameLoopSnapshot {
|
|
|
48
51
|
readonly seconds: number;
|
|
49
52
|
readonly failure: unknown;
|
|
50
53
|
}
|
|
54
|
+
/** Steps the Engine and draws a frame on each animation frame of the browser. */
|
|
51
55
|
export interface BrowserFrameLoop {
|
|
52
56
|
readonly state: BrowserFrameLoopState;
|
|
53
57
|
/** Starts, or starts again after `stop`. The time spent stopped is not played back. */
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import type { AssetLease, DiagnosticHandler, Engine, Scope, Stage, SharedFrameOptions2D, Texture } from '@egret/engine';
|
|
1
|
+
import type { AssetLease, DisplayObject, DiagnosticHandler, Engine, Scope, Stage, SharedFrameOptions2D, Texture } from '@egret/engine';
|
|
2
2
|
import type { TextField } from '@egret/engine/text';
|
|
3
3
|
import type { BrowserFrameLoop } from './loop.js';
|
|
4
4
|
import type { PointerInput } from './pointer.js';
|
|
5
5
|
import type { KeyboardInput } from './keyboard.js';
|
|
6
|
+
import type { createBrowserHoverInput } from './hover.js';
|
|
7
|
+
/** The hover and wheel input of the page, as `createBrowserHoverInput` of `@egret/engine/web/hover` makes it. */
|
|
8
|
+
type BrowserGameHoverInput = ReturnType<typeof createBrowserHoverInput>;
|
|
6
9
|
import type { BrowserStatsPanel } from './BrowserStatsPanel.js';
|
|
10
|
+
/** Which GPU interface a browser game draws with. */
|
|
7
11
|
export type BrowserGameBackend = 'webgpu' | 'webgl2';
|
|
8
12
|
/** How the canvas fills the element it is in: not at all, whole inside it, covering it, or stretched to it. */
|
|
9
13
|
export type BrowserGameFit = 'none' | 'contain' | 'cover' | 'stretch';
|
|
14
|
+
/** A text label to make: its text, font, size and weight, line height, color, locale and direction. */
|
|
10
15
|
export interface BrowserGameLabelOptions {
|
|
11
16
|
readonly text?: string;
|
|
12
17
|
/** A font the page has: a family of the system, or one the page loaded. "sans-serif" unless given. */
|
|
@@ -23,6 +28,14 @@ export interface BrowserGameLabelOptions {
|
|
|
23
28
|
readonly locale?: string;
|
|
24
29
|
readonly direction?: 'ltr' | 'rtl';
|
|
25
30
|
}
|
|
31
|
+
/** A label to make: its words and style, and the scope that owns it. */
|
|
32
|
+
export interface BrowserGameLabelCreateOptions extends BrowserGameLabelOptions {
|
|
33
|
+
/**
|
|
34
|
+
* The scope that owns the label's display object. Defaults to `game.scope`. Give the `context.scope` of a UI leaf to
|
|
35
|
+
* use the label as that leaf's content; the label then ends with that scope.
|
|
36
|
+
*/
|
|
37
|
+
readonly scope?: Scope;
|
|
38
|
+
}
|
|
26
39
|
/** A line of text on the stage whose words can be set like a value. */
|
|
27
40
|
export interface BrowserGameLabel {
|
|
28
41
|
/** The text on the stage: place it with `display.x` and `display.y`, add it where it belongs. */
|
|
@@ -35,6 +48,7 @@ export interface BrowserGameLabel {
|
|
|
35
48
|
set(options: BrowserGameLabelOptions): void;
|
|
36
49
|
dispose(): void;
|
|
37
50
|
}
|
|
51
|
+
/** A browser game to make: its canvas and size, its backend and colors, its update, its input and stats, and how it fits the page. */
|
|
38
52
|
export interface BrowserGameOptions {
|
|
39
53
|
/** The canvas the game is drawn on. The page gives it its size on the screen. */
|
|
40
54
|
readonly canvas: HTMLCanvasElement;
|
|
@@ -48,6 +62,16 @@ export interface BrowserGameOptions {
|
|
|
48
62
|
/** What a frame is cleared to before the stage is drawn: 0x000000 and 1 unless given. */
|
|
49
63
|
readonly clearColor?: number;
|
|
50
64
|
readonly clearAlpha?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Where translucent draws mix with what is under them: "linear" light unless given, or the stored "srgb"
|
|
67
|
+
* codes, as a 2D canvas and Egret 5 mix them, so a faint white over a dark ground stays faint.
|
|
68
|
+
*/
|
|
69
|
+
readonly blendSpace?: 'linear' | 'srgb';
|
|
70
|
+
/**
|
|
71
|
+
* Whether render effects are drawn: blurs, colour matrices, glows, outlines, and masks of images or of shapes.
|
|
72
|
+
* Off unless given; a frame with an effect is refused without it.
|
|
73
|
+
*/
|
|
74
|
+
readonly effects?: boolean;
|
|
51
75
|
/** One step of the game, called before each frame with the seconds since the step before. */
|
|
52
76
|
readonly update?: (deltaSeconds: number) => void;
|
|
53
77
|
/** Told once of what stopped the game's loop. Without it the failure is thrown where the console shows it. */
|
|
@@ -55,6 +79,11 @@ export interface BrowserGameOptions {
|
|
|
55
79
|
/** Touch, mouse and pen on display objects, and the keyboard. Both are made unless false is given. */
|
|
56
80
|
readonly pointer?: boolean;
|
|
57
81
|
readonly keyboard?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Hover and the mouse wheel over display objects, as `createBrowserHoverInput` makes them: what a scroll control's
|
|
84
|
+
* `wheel` and a button's hover look need. Made only when true is given; its module is loaded only then.
|
|
85
|
+
*/
|
|
86
|
+
readonly hover?: boolean;
|
|
58
87
|
/** A panel over the canvas with frames a second, what a frame holds and how busy the Host is. Not made unless true is given. */
|
|
59
88
|
readonly stats?: boolean;
|
|
60
89
|
/** "none" unless given. The canvas is sized inside `fitTo`, or its parent element, and again whenever that changes size. */
|
|
@@ -63,6 +92,7 @@ export interface BrowserGameOptions {
|
|
|
63
92
|
/** The loop starts at once unless false is given; then `game.loop.start()` starts it. */
|
|
64
93
|
readonly autoStart?: boolean;
|
|
65
94
|
}
|
|
95
|
+
/** A game in a canvas: its Engine, host and stage, its frame loop and input, and calls that load textures and make labels. */
|
|
66
96
|
export interface BrowserGame {
|
|
67
97
|
readonly backend: BrowserGameBackend;
|
|
68
98
|
readonly engine: Engine;
|
|
@@ -82,14 +112,45 @@ export interface BrowserGame {
|
|
|
82
112
|
readonly loop: BrowserFrameLoop;
|
|
83
113
|
readonly pointer: PointerInput | undefined;
|
|
84
114
|
readonly keyboard: KeyboardInput | undefined;
|
|
115
|
+
/** The hover and wheel input, when `hover: true` was given. */
|
|
116
|
+
readonly hover: BrowserGameHoverInput | undefined;
|
|
85
117
|
readonly stats: BrowserStatsPanel | undefined;
|
|
86
118
|
/**
|
|
87
119
|
* Loads a PNG image from an address and gives the lease of its texture, for `new Bitmap(lease)` or
|
|
88
120
|
* `graphics.beginBitmapFill(lease)`. The lease belongs to the game's scope. The same address loaded twice is one texture.
|
|
89
121
|
*/
|
|
90
122
|
loadTexture(url: string): Promise<AssetLease<Texture>>;
|
|
123
|
+
/**
|
|
124
|
+
* The lease of a texture of pixels painted in code: `width` × `height` pixels of 4 bytes each, red, green, blue and
|
|
125
|
+
* alpha, rows from the top, alpha not multiplied in (as `ImageData` holds them). The bytes are copied, so the array can
|
|
126
|
+
* be changed after. At most 4,096 pixels on an edge and 4,194,304 in all. The lease belongs to the game's scope; each
|
|
127
|
+
* call is a texture of its own, ended with its lease.
|
|
128
|
+
*/
|
|
129
|
+
textureFromPixels(width: number, height: number, pixels: Uint8Array | Uint8ClampedArray): Promise<AssetLease<Texture>>;
|
|
130
|
+
/**
|
|
131
|
+
* The lease of a texture of what a canvas holds now, as `textureFromPixels` of its pixels. A canvas with a 2D context,
|
|
132
|
+
* or none yet, is read with that context; one drawn by WebGL or WebGPU is copied through a 2D canvas first. To scale
|
|
133
|
+
* down a larger picture, or read an image or bitmap, `textureFromCanvas` of `@egret/engine/web/kit` gives a texture.
|
|
134
|
+
*/
|
|
135
|
+
textureFromCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): Promise<AssetLease<Texture>>;
|
|
91
136
|
/** A line of text for the stage. The first call loads the page's text rasterizer. */
|
|
92
|
-
createLabel(options?:
|
|
137
|
+
createLabel(options?: BrowserGameLabelCreateOptions): Promise<BrowserGameLabel>;
|
|
138
|
+
/**
|
|
139
|
+
* Stage units in one CSS pixel as the canvas is shown now, the larger of across and down: `44 * game.unitsPerCssPixel`
|
|
140
|
+
* is a touch target a finger can hit. 1 before the canvas is laid out.
|
|
141
|
+
*/
|
|
142
|
+
readonly unitsPerCssPixel: number;
|
|
143
|
+
/**
|
|
144
|
+
* Gives a display object a hit area at least `cssPixels` (44 unless given) square as the canvas is shown now, centred
|
|
145
|
+
* on what it draws and never smaller than it, so a small icon is as easy to press as a finger needs. Call it again
|
|
146
|
+
* after the node, its ancestors or the canvas change transform or size. Returns the area, in the node's own units.
|
|
147
|
+
*/
|
|
148
|
+
padHitArea(node: DisplayObject, cssPixels?: number): {
|
|
149
|
+
readonly x: number;
|
|
150
|
+
readonly y: number;
|
|
151
|
+
readonly width: number;
|
|
152
|
+
readonly height: number;
|
|
153
|
+
};
|
|
93
154
|
/** A place in the page, as a pointer event gives it in `clientX` and `clientY`, as a place on the stage. */
|
|
94
155
|
toStage(clientX: number, clientY: number): {
|
|
95
156
|
x: number;
|
|
@@ -109,4 +170,5 @@ export declare function gameDiagnostics(onError: ((error: unknown) => void) | un
|
|
|
109
170
|
* to `game.stage`. Everything it makes is what the separate entries make; a game that outgrows it takes them apart.
|
|
110
171
|
*/
|
|
111
172
|
export declare function createBrowserGame(options: BrowserGameOptions): Promise<BrowserGame>;
|
|
173
|
+
export {};
|
|
112
174
|
//# sourceMappingURL=BrowserGame.d.ts.map
|