zhuda-laya-engine 0.0.0-stage → 2.1.0
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/AGENTS.md +236 -0
- package/CHANGELOG.md +431 -0
- package/LICENSE +41 -0
- package/README.md +247 -2
- package/assets/branding/layaair-tribute-mark.svg +5 -0
- package/assets/branding/zhuda-layaair-mark.svg +34 -0
- package/assets/prefabs/CoinFountainVfx.lh +197 -0
- package/assets/prefabs/ConfirmActionButton.lh +87 -0
- package/assets/prefabs/LevelUpAuraVfx.lh +136 -0
- package/assets/prefabs/MineExplosionParticle.lh +352 -0
- package/assets/prefabs/NineSliceDialogFrame.lh +171 -0
- package/assets/prefabs/SwordSlashTrailVfx.lh +117 -0
- package/assets/prefabs/TacticalHudBar.lh +134 -0
- package/assets/prefabs/TelemetryDashboard.lh +87 -0
- package/assets/prefabs/UnityCrystalGuardian.lh +144 -0
- package/assets/prefabs/ZhudaSpine42Mascot.lh +183 -0
- package/assets/scenes/MinesweeperStage.ls +1180 -0
- package/dist/asset-calibration-report.json +969 -0
- package/dist/build-manifest.json +254 -0
- package/dist/sdk/zhuda-laya-csg.cjs +710 -0
- package/dist/sdk/zhuda-laya-csg.esm.js +683 -0
- package/dist/sdk/zhuda-laya-csg.min.cjs +7 -0
- package/dist/sdk/zhuda-laya-csg.min.esm.js +7 -0
- package/dist/sdk/zhuda-laya-demo.cjs +5990 -0
- package/dist/sdk/zhuda-laya-demo.esm.js +5956 -0
- package/dist/sdk/zhuda-laya-demo.min.cjs +12 -0
- package/dist/sdk/zhuda-laya-demo.min.esm.js +12 -0
- package/dist/sdk/zhuda-laya-engine.cjs +52628 -0
- package/dist/sdk/zhuda-laya-engine.esm.js +51848 -0
- package/dist/sdk/zhuda-laya-engine.min.cjs +2710 -0
- package/dist/sdk/zhuda-laya-engine.min.esm.js +2710 -0
- package/docs/3d-acceptance.md +47 -0
- package/docs/3d-integration.md +190 -0
- package/docs/README.md +112 -0
- package/docs/SUPPORT.md +21 -0
- package/docs/agent-development.md +219 -0
- package/docs/animation-control.md +213 -0
- package/docs/asset-loading.md +97 -0
- package/docs/assets/reference-games.jpg +0 -0
- package/docs/assets/solana-qr.png +0 -0
- package/docs/assets/sponsor-pass.svg +32 -0
- package/docs/audio.md +319 -0
- package/docs/backend-delivery.md +218 -0
- package/docs/basis-textures.md +94 -0
- package/docs/browser-sdk-releases.json +204 -0
- package/docs/browser-sdk.md +187 -0
- package/docs/cinematics.md +267 -0
- package/docs/cloth.md +280 -0
- package/docs/combat-runtime.md +82 -0
- package/docs/consumer-route.md +169 -0
- package/docs/consumer-tooling.md +518 -0
- package/docs/crowd-runtime.md +195 -0
- package/docs/developer-tooling.md +191 -0
- package/docs/film-scenes.md +1504 -0
- package/docs/filmic-rendering.md +743 -0
- package/docs/flythrough.md +89 -0
- package/docs/gpu-depth.md +207 -0
- package/docs/grass.md +127 -0
- package/docs/hdr-environment.md +76 -0
- package/docs/instanced-meshes.md +137 -0
- package/docs/layout-and-media.md +37 -0
- package/docs/layout-wireframe.md +80 -0
- package/docs/lighting-depth.md +185 -0
- package/docs/minigame-packaging.md +79 -0
- package/docs/model-editor.md +66 -0
- package/docs/model-lod.md +122 -0
- package/docs/model-pipeline.md +74 -0
- package/docs/model-showcase.md +365 -0
- package/docs/overview.md +183 -0
- package/docs/plans/README.md +133 -0
- package/docs/plans/TASK-TEMPLATE.md +64 -0
- package/docs/plans/TASK-spine38-isolated-topology-20261106.md +89 -0
- package/docs/plans/TEMPLATE.md +44 -0
- package/docs/plans/VERIFICATION-TEMPLATE.md +45 -0
- package/docs/plans/asset-packaging.md +140 -0
- package/docs/plans/cinematic-production/task.md +97 -0
- package/docs/plans/cinematic-production/verification.md +49 -0
- package/docs/plans/consumer-delivery-followups.md +129 -0
- package/docs/plans/desktop-and-agent-gates/hardening-task.md +85 -0
- package/docs/plans/desktop-and-agent-gates/hardening-verification.md +109 -0
- package/docs/plans/desktop-and-agent-gates/task.md +94 -0
- package/docs/plans/desktop-and-agent-gates/verification.md +60 -0
- package/docs/plans/prefab-toolchain.md +73 -0
- package/docs/plans/preview-runtime-hardening.md +68 -0
- package/docs/platform-adapters.md +113 -0
- package/docs/post-quality.md +242 -0
- package/docs/prefab-editor.md +194 -0
- package/docs/prefab-library.md +94 -0
- package/docs/prefab-workflow.md +75 -0
- package/docs/procedural-assets.md +463 -0
- package/docs/procedural-prefabs.md +133 -0
- package/docs/quality-route.md +386 -0
- package/docs/release-policy.md +79 -0
- package/docs/routes/README.md +180 -0
- package/docs/routes/TEMPLATE.md +54 -0
- package/docs/routes/action-adventure-3d-minigame.md +238 -0
- package/docs/routes/apocalypse-survival-3d.md +219 -0
- package/docs/routes/aqua-freeze-2d-minigame.md +183 -0
- package/docs/routes/astral-minimal-film-look.md +141 -0
- package/docs/routes/cascade-slot.md +93 -0
- package/docs/routes/clip-free-garments.md +229 -0
- package/docs/routes/drop-merge-2d-minigame.md +200 -0
- package/docs/routes/dungeon-line-slot.md +87 -0
- package/docs/routes/film-as-data.md +131 -0
- package/docs/routes/film-fight-that-lands.md +198 -0
- package/docs/routes/film-ink-lines.md +120 -0
- package/docs/routes/floating-island.md +229 -0
- package/docs/routes/game-2d.md +168 -0
- package/docs/routes/game-rules-first.md +89 -0
- package/docs/routes/game-to-prefabs.md +249 -0
- package/docs/routes/go-game-server.md +95 -0
- package/docs/routes/good-looking-3d-scene.md +99 -0
- package/docs/routes/high-quality-character.md +263 -0
- package/docs/routes/humanoid-from-shapes.md +97 -0
- package/docs/routes/hunting-action-3d.md +76 -0
- package/docs/routes/idle-gacha-2d.md +67 -0
- package/docs/routes/interactive-film-viewer.md +141 -0
- package/docs/routes/isometric-mystery-2d.md +217 -0
- package/docs/routes/key-art-to-animated-title.md +132 -0
- package/docs/routes/laya-ide-project-cli-web.md +125 -0
- package/docs/routes/layered-cloth-on-body.md +240 -0
- package/docs/routes/low-poly-character-from-shapes.md +475 -0
- package/docs/routes/match-three-2d.md +64 -0
- package/docs/routes/merge-2d.md +59 -0
- package/docs/routes/mini-game-build.md +80 -0
- package/docs/routes/mobile-always-landscape.md +149 -0
- package/docs/routes/mobile-web-fullscreen.md +255 -0
- package/docs/routes/model-from-dcc.md +106 -0
- package/docs/routes/new-game-project.md +100 -0
- package/docs/routes/onboarding-tutorial-2d.md +54 -0
- package/docs/routes/online-lockstep-match.md +473 -0
- package/docs/routes/outdoor-landscape.md +134 -0
- package/docs/routes/outfit-swap-3d.md +144 -0
- package/docs/routes/papercraft-diorama.md +186 -0
- package/docs/routes/platform-fighter-2d.md +235 -0
- package/docs/routes/platformer-2d.md +69 -0
- package/docs/routes/pole-rescue-arcade-3d.md +198 -0
- package/docs/routes/pose-atlas-motion.md +188 -0
- package/docs/routes/prototype-to-center.md +162 -0
- package/docs/routes/raft-brawl-3d-minigame.md +205 -0
- package/docs/routes/rhythm-2d.md +82 -0
- package/docs/routes/rigged-phone-character.md +120 -0
- package/docs/routes/screen-fit-game-box.md +127 -0
- package/docs/routes/shared-islands.md +195 -0
- package/docs/routes/side-view-duel.md +266 -0
- package/docs/routes/single-html-page.md +83 -0
- package/docs/routes/smooth-character-motion.md +162 -0
- package/docs/routes/spine-character.md +175 -0
- package/docs/routes/story-counting-2d.md +219 -0
- package/docs/routes/survivors-2d.md +60 -0
- package/docs/routes/third-person-town-3d.md +240 -0
- package/docs/routes/tower-defence-3d.md +67 -0
- package/docs/routes/ui-test-by-probe.md +219 -0
- package/docs/routes/underwater.md +138 -0
- package/docs/routes/visual-content-prefab.md +101 -0
- package/docs/runtime-hardening.md +108 -0
- package/docs/shader-warm-up.md +125 -0
- package/docs/spring-bones.md +79 -0
- package/docs/stylized-shading.md +171 -0
- package/docs/terrain-shader.md +130 -0
- package/docs/vrm.md +128 -0
- package/docs/walking.md +97 -0
- package/docs/webgpu.md +225 -0
- package/docs/white-label-themes.md +212 -0
- package/docs/zh-CN/README.md +130 -0
- package/examples/browser-sdk/2d-webgpu.html +46 -0
- package/examples/browser-sdk/2d.html +46 -0
- package/examples/browser-sdk/3d-gltf-webgpu.html +50 -0
- package/examples/browser-sdk/3d-gltf.html +50 -0
- package/examples/browser-sdk/3d-webgpu.html +46 -0
- package/examples/browser-sdk/3d.html +46 -0
- package/examples/cinematic-capture/Main.ts +294 -0
- package/examples/cinematic-capture/README.md +27 -0
- package/examples/model-inspector/README.md +15 -0
- package/examples/model-inspector/asset.gltf +158 -0
- package/examples/windows-webgpu/README.md +57 -0
- package/examples/windows-webgpu/bundle.mjs +122 -0
- package/examples/windows-webgpu/main.mjs +302 -0
- package/examples/windows-webgpu/package-lock.json +2353 -0
- package/examples/windows-webgpu/package.json +40 -0
- package/examples/windows-webgpu/squirrel.mjs +66 -0
- package/package.json +259 -4
- package/packages/ci-gate/export-film.mjs +347 -0
- package/packages/ci-gate/verify-sequence.mjs +285 -0
- package/packages/compiler/agent-contract.mjs +545 -0
- package/packages/compiler/ast-scanner.mjs +254 -0
- package/packages/compiler/backend-loader.mjs +62 -0
- package/packages/compiler/branding-assets.mjs +32 -0
- package/packages/compiler/branding.mjs +324 -0
- package/packages/compiler/browser-auto-example.mjs +31 -0
- package/packages/compiler/browser-model-example.mjs +53 -0
- package/packages/compiler/browser-process.mjs +344 -0
- package/packages/compiler/browser-sdk-example.mjs +50 -0
- package/packages/compiler/browser-sdk.mjs +342 -0
- package/packages/compiler/chrome-host.mjs +196 -0
- package/packages/compiler/cli.mjs +22 -0
- package/packages/compiler/compiler-runtime.mjs +41 -0
- package/packages/compiler/consumer-accept.mjs +89 -0
- package/packages/compiler/consumer-build.mjs +641 -0
- package/packages/compiler/consumer-guards.mjs +422 -0
- package/packages/compiler/consumer-publication.mjs +56 -0
- package/packages/compiler/consumer-scripts.mjs +134 -0
- package/packages/compiler/consumer-starter-2d.mjs +54 -0
- package/packages/compiler/consumer-starter-minigame.mjs +30 -0
- package/packages/compiler/editor-http.mjs +210 -0
- package/packages/compiler/editor-request.ts +12 -0
- package/packages/compiler/film-host-client.ts +249 -0
- package/packages/compiler/flythrough-file.mjs +144 -0
- package/packages/compiler/json-locate.mjs +85 -0
- package/packages/compiler/layout-contract.mjs +472 -0
- package/packages/compiler/minigame-bootstrap.mjs +24 -0
- package/packages/compiler/minigame-bridge.mjs +66 -0
- package/packages/compiler/minigame-guards.mjs +107 -0
- package/packages/compiler/minigame-toolchain.mjs +241 -0
- package/packages/compiler/model-crown.mjs +173 -0
- package/packages/compiler/model-editor-client.ts +809 -0
- package/packages/compiler/model-editor.mjs +242 -0
- package/packages/compiler/model-lod.mjs +547 -0
- package/packages/compiler/prefab-check.mjs +288 -0
- package/packages/compiler/prefab-checks.mjs +74 -0
- package/packages/compiler/prefab-dependencies.mjs +102 -0
- package/packages/compiler/prefab-editor-client.ts +950 -0
- package/packages/compiler/prefab-editor-preview.ts +89 -0
- package/packages/compiler/prefab-editor-server.mjs +585 -0
- package/packages/compiler/prefab-editor.mjs +43 -0
- package/packages/compiler/prefab-environment.mjs +107 -0
- package/packages/compiler/prefab-lifecycle.mjs +60 -0
- package/packages/compiler/prefab-preview.mjs +159 -0
- package/packages/compiler/prefab-watch.mjs +459 -0
- package/packages/compiler/runtime3d-types.mjs +91 -0
- package/packages/compiler/stage-probe.mjs +557 -0
- package/packages/compiler/visual-asset-audit.mjs +609 -0
- package/packages/compiler/visual-contract-audit.mjs +173 -0
- package/packages/compiler/webgpu-loader.mjs +153 -0
- package/packages/compiler/zhuda-build.mjs +714 -0
- package/packages/compiler/zhuda-doctor.mjs +186 -0
- package/packages/compiler/zhuda-init.mjs +353 -0
- package/packages/compiler/zhuda-layout.mjs +163 -0
- package/packages/compiler/zhuda-minigame.mjs +636 -0
- package/packages/core/BenchmarkEngine.ts +2 -0
- package/packages/core/BitmapFontContract.ts +159 -0
- package/packages/core/DeclarativeSDK.ts +686 -0
- package/packages/core/IframeSoundAdapter.ts +1824 -0
- package/packages/core/NoSleepAdapter.ts +302 -0
- package/packages/core/PixelCalibrationEngine.ts +602 -0
- package/packages/core/Prefab.ts +314 -0
- package/packages/core/RealmGuards.ts +111 -0
- package/packages/core/ResponsiveLayout.ts +149 -0
- package/packages/core/RuntimeGuards.ts +261 -0
- package/packages/core/SpineCharacter.ts +243 -0
- package/packages/core/SpineVisualContract.ts +238 -0
- package/packages/core/SplashSignal.ts +72 -0
- package/packages/core/StaticAssetPipeline.ts +3 -0
- package/packages/core/TopologyGraph.ts +693 -0
- package/packages/core/UnityBridgePipeline.ts +2 -0
- package/packages/core/VideoSurface.ts +75 -0
- package/packages/core/ViewportMatrixEngine.ts +237 -0
- package/packages/core/VisualFocusContract.ts +76 -0
- package/packages/core/VisualMigrationPipeline.ts +245 -0
- package/packages/core/WebViewSurface.ts +116 -0
- package/packages/core/audio/OfflineMix.ts +186 -0
- package/packages/core/audio/Spatial.ts +312 -0
- package/packages/core/audio/StreamVoice.ts +161 -0
- package/packages/core/csg/Bsp.ts +310 -0
- package/packages/core/csg/index.ts +589 -0
- package/packages/core/effects/Effect2D.ts +286 -0
- package/packages/core/effects/Effect3D.ts +213 -0
- package/packages/core/effects/EffectBudget.ts +695 -0
- package/packages/core/effects/EffectDirector.ts +254 -0
- package/packages/core/effects/EffectPresets.ts +843 -0
- package/packages/core/effects/EffectPresets2D.ts +1011 -0
- package/packages/core/effects/EffectSprites.ts +143 -0
- package/packages/core/effects/ParticleEventLink.ts +53 -0
- package/packages/core/effects/README.md +108 -0
- package/packages/core/effects/VfxMaterial.ts +253 -0
- package/packages/core/film/BakeKey.ts +21 -0
- package/packages/core/film/ColorValues.ts +44 -0
- package/packages/core/film/FilmLint.ts +353 -0
- package/packages/core/film/FilmPrefab.ts +82 -0
- package/packages/core/film/FilmReview.ts +84 -0
- package/packages/core/film/FilmScene.ts +3442 -0
- package/packages/core/film/FilmStage.ts +2148 -0
- package/packages/core/film/Flythrough.ts +169 -0
- package/packages/core/film/FlythroughReport.ts +326 -0
- package/packages/core/film/FrameMetrics.ts +167 -0
- package/packages/core/film/LiveLook.ts +242 -0
- package/packages/core/film/LookQuality.ts +94 -0
- package/packages/core/film/Projection.ts +74 -0
- package/packages/core/film/SceneLook.ts +363 -0
- package/packages/core/film/index.ts +12 -0
- package/packages/core/index.ts +48 -0
- package/packages/core/particles/EffectEnvelope.ts +52 -0
- package/packages/core/particles/LayaParticleRenderer.ts +182 -0
- package/packages/core/particles/LayaParticleRenderer3D.ts +218 -0
- package/packages/core/particles/ParticleExtras.ts +163 -0
- package/packages/core/particles/ParticleMesh3D.ts +156 -0
- package/packages/core/particles/ParticleSystem.ts +324 -0
- package/packages/core/particles/ParticleSystem3D.ts +411 -0
- package/packages/core/particles/ParticleTypes.ts +230 -0
- package/packages/core/particles/ParticleTypes3D.ts +115 -0
- package/packages/core/particles/README.md +181 -0
- package/packages/core/particles/RibbonPath3D.ts +234 -0
- package/packages/core/particles/RibbonTrail.ts +145 -0
- package/packages/core/particles/RibbonTrail3D.ts +166 -0
- package/packages/core/particles/index.ts +12 -0
- package/packages/core/prefabs/PrefabLibrary.ts +692 -0
- package/packages/core/prefabs/PrefabTree3D.ts +291 -0
- package/packages/core/prefabs/index.ts +10 -0
- package/packages/core/procedural/Geometry.ts +1871 -0
- package/packages/core/procedural/Hand.ts +1510 -0
- package/packages/core/procedural/Isosurface.ts +1035 -0
- package/packages/core/procedural/ModuleHarness.ts +180 -0
- package/packages/core/procedural/Noise.ts +123 -0
- package/packages/core/procedural/PhotoMaterial.ts +283 -0
- package/packages/core/procedural/ProceduralAssetProvider.ts +105 -0
- package/packages/core/procedural/ProceduralMaterial.ts +184 -0
- package/packages/core/procedural/PropFactory.ts +307 -0
- package/packages/core/procedural/Random.ts +70 -0
- package/packages/core/procedural/SynthAudio.ts +221 -0
- package/packages/core/procedural/TerrainMesh.ts +207 -0
- package/packages/core/procedural/TextureRecipe.ts +464 -0
- package/packages/core/procedural/TriplanarMaterial.ts +169 -0
- package/packages/core/procedural/Variation.ts +94 -0
- package/packages/core/procedural/index.ts +15 -0
- package/packages/core/runtime3d/ActionFrames.ts +245 -0
- package/packages/core/runtime3d/AnimationBlend.ts +282 -0
- package/packages/core/runtime3d/AnimationBlendMath.ts +98 -0
- package/packages/core/runtime3d/AssetProvider.ts +775 -0
- package/packages/core/runtime3d/AssetShowcase.ts +190 -0
- package/packages/core/runtime3d/Assets.ts +801 -0
- package/packages/core/runtime3d/AsyncDeadline.ts +53 -0
- package/packages/core/runtime3d/AsyncOperation.ts +39 -0
- package/packages/core/runtime3d/BackendChoice.ts +359 -0
- package/packages/core/runtime3d/BakedCrowd.ts +575 -0
- package/packages/core/runtime3d/BasisTexture.ts +657 -0
- package/packages/core/runtime3d/CameraCollision.ts +69 -0
- package/packages/core/runtime3d/CameraEffects.ts +752 -0
- package/packages/core/runtime3d/CameraRig.ts +70 -0
- package/packages/core/runtime3d/CharacterController.ts +272 -0
- package/packages/core/runtime3d/CinematicCapture.ts +457 -0
- package/packages/core/runtime3d/Clocks.ts +724 -0
- package/packages/core/runtime3d/Cloth.ts +183 -0
- package/packages/core/runtime3d/Clouds.ts +462 -0
- package/packages/core/runtime3d/ColorLut.ts +351 -0
- package/packages/core/runtime3d/CombatQueries.ts +240 -0
- package/packages/core/runtime3d/ComputePass.ts +582 -0
- package/packages/core/runtime3d/CrowdPresentation.ts +368 -0
- package/packages/core/runtime3d/DebugDraw.ts +567 -0
- package/packages/core/runtime3d/DebugStats.ts +35 -0
- package/packages/core/runtime3d/Decals.ts +309 -0
- package/packages/core/runtime3d/DensityVolume.ts +238 -0
- package/packages/core/runtime3d/DistanceBricks.ts +349 -0
- package/packages/core/runtime3d/Dither.ts +199 -0
- package/packages/core/runtime3d/DrawWarmUp.ts +217 -0
- package/packages/core/runtime3d/EdgeSmoothing.ts +108 -0
- package/packages/core/runtime3d/EnvironmentProbe.ts +656 -0
- package/packages/core/runtime3d/Filmic.ts +973 -0
- package/packages/core/runtime3d/Foliage.ts +367 -0
- package/packages/core/runtime3d/GltfIntake.ts +914 -0
- package/packages/core/runtime3d/GltfSecondUv.ts +153 -0
- package/packages/core/runtime3d/GraphicsGuard.ts +171 -0
- package/packages/core/runtime3d/Grass.ts +1080 -0
- package/packages/core/runtime3d/GroundTruthAO.ts +360 -0
- package/packages/core/runtime3d/HalfFloat.ts +44 -0
- package/packages/core/runtime3d/HdrEnvironment.ts +588 -0
- package/packages/core/runtime3d/Ik.ts +392 -0
- package/packages/core/runtime3d/InputBuffer.ts +165 -0
- package/packages/core/runtime3d/InstancedMesh.ts +460 -0
- package/packages/core/runtime3d/Laya342Adapters.ts +1095 -0
- package/packages/core/runtime3d/Laya342GltfAdapter.ts +751 -0
- package/packages/core/runtime3d/LensFinish.ts +153 -0
- package/packages/core/runtime3d/LensFlare.ts +490 -0
- package/packages/core/runtime3d/LightFog.ts +1008 -0
- package/packages/core/runtime3d/LightingDepth.ts +544 -0
- package/packages/core/runtime3d/Lightmap.ts +238 -0
- package/packages/core/runtime3d/Math3D.ts +84 -0
- package/packages/core/runtime3d/MeshQuery.ts +547 -0
- package/packages/core/runtime3d/MeshoptModelDecoder.ts +354 -0
- package/packages/core/runtime3d/MiniGameSplash.ts +70 -0
- package/packages/core/runtime3d/ModelAnimationSampler.ts +97 -0
- package/packages/core/runtime3d/ModelCompatibility.ts +890 -0
- package/packages/core/runtime3d/ModelDecoder.ts +294 -0
- package/packages/core/runtime3d/ModelInspector.ts +226 -0
- package/packages/core/runtime3d/ModelLod.ts +163 -0
- package/packages/core/runtime3d/ModelPlacements.ts +426 -0
- package/packages/core/runtime3d/ObjectMotion.ts +217 -0
- package/packages/core/runtime3d/PhysicalCamera.ts +190 -0
- package/packages/core/runtime3d/PointShadow.ts +500 -0
- package/packages/core/runtime3d/PointShadowSchedule.ts +201 -0
- package/packages/core/runtime3d/Pool.ts +120 -0
- package/packages/core/runtime3d/ProbeVolume.ts +695 -0
- package/packages/core/runtime3d/QualityGovernor.ts +385 -0
- package/packages/core/runtime3d/QualityMemory.ts +200 -0
- package/packages/core/runtime3d/RenderScale.ts +356 -0
- package/packages/core/runtime3d/RenderSpaces.ts +105 -0
- package/packages/core/runtime3d/Renderer.ts +377 -0
- package/packages/core/runtime3d/ResultPlayback.ts +239 -0
- package/packages/core/runtime3d/Runtime.ts +507 -0
- package/packages/core/runtime3d/RuntimeDriver.ts +127 -0
- package/packages/core/runtime3d/SceneLifecycle.ts +211 -0
- package/packages/core/runtime3d/SceneMutation.ts +107 -0
- package/packages/core/runtime3d/SceneQueries.ts +191 -0
- package/packages/core/runtime3d/ScreenReflections.ts +595 -0
- package/packages/core/runtime3d/SelectionOutline.ts +389 -0
- package/packages/core/runtime3d/ShaderErrors.ts +104 -0
- package/packages/core/runtime3d/ShaderRegistry.ts +34 -0
- package/packages/core/runtime3d/ShaderWarmUp.ts +473 -0
- package/packages/core/runtime3d/ShadowUpdates.ts +287 -0
- package/packages/core/runtime3d/SkinBinding.ts +235 -0
- package/packages/core/runtime3d/Smaa.ts +386 -0
- package/packages/core/runtime3d/SmaaTables.ts +244 -0
- package/packages/core/runtime3d/SpringBones.ts +184 -0
- package/packages/core/runtime3d/SurfaceBuffer.ts +76 -0
- package/packages/core/runtime3d/Surfaces.ts +1105 -0
- package/packages/core/runtime3d/Themes.ts +344 -0
- package/packages/core/runtime3d/Timeline.ts +362 -0
- package/packages/core/runtime3d/ToneCurves.ts +292 -0
- package/packages/core/runtime3d/TransformGizmo.ts +539 -0
- package/packages/core/runtime3d/TriangleMask.ts +250 -0
- package/packages/core/runtime3d/Underwater.ts +778 -0
- package/packages/core/runtime3d/Utf8.ts +87 -0
- package/packages/core/runtime3d/Vrm.ts +773 -0
- package/packages/core/runtime3d/VrmDocument.ts +1830 -0
- package/packages/core/runtime3d/WalkGrid.ts +471 -0
- package/packages/core/runtime3d/WebGPU342Adapters.ts +280 -0
- package/packages/core/runtime3d/index.ts +147 -0
- package/packages/core/shaders/Laya342ShaderTemplates.ts +6 -0
- package/packages/core/shaders/LitSurfaceMaterial.ts +1076 -0
- package/packages/core/shaders/LitSurfaceTemplates.ts +13 -0
- package/packages/core/shaders/ReflectiveSurface.ts +285 -0
- package/packages/core/shaders/ShaderMaterials.ts +387 -0
- package/packages/core/shaders/ToonMaterial.ts +559 -0
- package/packages/core/shaders/WaterRipples.ts +170 -0
- package/packages/core/shaders/WaterSurface.ts +480 -0
- package/packages/core/shaders/ZhudaCommon.ts +109 -0
- package/packages/core/shaders/index.ts +6 -0
- package/packages/core/simulation/Cloth.ts +1541 -0
- package/packages/core/simulation/ParticleCore.ts +498 -0
- package/packages/core/simulation/SpringBones.ts +553 -0
- package/packages/core/simulation/index.ts +3 -0
- package/packages/core/terrain/Heightfield.ts +385 -0
- package/packages/core/terrain/Terrain2D.ts +324 -0
- package/packages/core/terrain/Terrain3D.ts +452 -0
- package/packages/core/terrain/TerrainShell.ts +94 -0
- package/packages/core/terrain/index.ts +3 -0
- package/packages/demo/BenchmarkEngine.ts +184 -0
- package/packages/demo/PixelCalibrationEngine.ts +36 -0
- package/packages/demo/ProceduralStarter.ts +312 -0
- package/packages/demo/StaticAssetPipeline.ts +1631 -0
- package/packages/demo/UnityBridgePipeline.ts +485 -0
- package/packages/demo/index.ts +6 -0
- package/packages/mcp-server/arguments.mjs +81 -0
- package/packages/mcp-server/corpus.mjs +627 -0
- package/packages/mcp-server/film-host.mjs +627 -0
- package/packages/mcp-server/film-session.mjs +95 -0
- package/packages/mcp-server/film-tools.mjs +460 -0
- package/packages/mcp-server/index.mjs +931 -0
- package/packages/mcp-server/quality-route.mjs +332 -0
- package/packages/mcp-server/roots.mjs +72 -0
- package/packages/mcp-server/runtime.mjs +81 -0
- package/packages/types/BitmapFontContract.d.ts +19 -0
- package/packages/types/DeclarativeSDK.d.ts +137 -0
- package/packages/types/IframeSoundAdapter.d.ts +173 -0
- package/packages/types/NoSleepAdapter.d.ts +50 -0
- package/packages/types/PixelCalibrationEngine.d.ts +83 -0
- package/packages/types/Prefab.d.ts +11 -0
- package/packages/types/RealmGuards.d.ts +26 -0
- package/packages/types/ResponsiveLayout.d.ts +10 -0
- package/packages/types/RuntimeGuards.d.ts +55 -0
- package/packages/types/SpineCharacter.d.ts +94 -0
- package/packages/types/SpineVisualContract.d.ts +50 -0
- package/packages/types/SplashSignal.d.ts +27 -0
- package/packages/types/TopologyGraph.d.ts +76 -0
- package/packages/types/VideoSurface.d.ts +21 -0
- package/packages/types/ViewportMatrixEngine.d.ts +27 -0
- package/packages/types/VisualFocusContract.d.ts +32 -0
- package/packages/types/VisualMigrationPipeline.d.ts +53 -0
- package/packages/types/WebViewSurface.d.ts +26 -0
- package/packages/types/audio/OfflineMix.d.ts +10 -0
- package/packages/types/audio/Spatial.d.ts +63 -0
- package/packages/types/audio/StreamVoice.d.ts +31 -0
- package/packages/types/browser.d.ts +44 -0
- package/packages/types/csg/Bsp.d.ts +85 -0
- package/packages/types/csg/index.d.ts +81 -0
- package/packages/types/demo/BenchmarkEngine.d.ts +61 -0
- package/packages/types/demo/PixelCalibrationEngine.d.ts +13 -0
- package/packages/types/demo/ProceduralStarter.d.ts +11 -0
- package/packages/types/demo/StaticAssetPipeline.d.ts +87 -0
- package/packages/types/demo/UnityBridgePipeline.d.ts +49 -0
- package/packages/types/demo/index.d.ts +7 -0
- package/packages/types/editor-preview.d.ts +27 -0
- package/packages/types/effects/Effect2D.d.ts +65 -0
- package/packages/types/effects/Effect3D.d.ts +42 -0
- package/packages/types/effects/EffectBudget.d.ts +179 -0
- package/packages/types/effects/EffectDirector.d.ts +68 -0
- package/packages/types/effects/EffectPresets.d.ts +27 -0
- package/packages/types/effects/EffectPresets2D.d.ts +32 -0
- package/packages/types/effects/EffectSprites.d.ts +23 -0
- package/packages/types/effects/ParticleEventLink.d.ts +16 -0
- package/packages/types/effects/VfxMaterial.d.ts +52 -0
- package/packages/types/film/BakeKey.d.ts +9 -0
- package/packages/types/film/ColorValues.d.ts +25 -0
- package/packages/types/film/FilmLint.d.ts +40 -0
- package/packages/types/film/FilmPrefab.d.ts +22 -0
- package/packages/types/film/FilmReview.d.ts +27 -0
- package/packages/types/film/FilmScene.d.ts +1214 -0
- package/packages/types/film/FilmStage.d.ts +237 -0
- package/packages/types/film/Flythrough.d.ts +44 -0
- package/packages/types/film/FlythroughReport.d.ts +132 -0
- package/packages/types/film/FrameMetrics.d.ts +49 -0
- package/packages/types/film/LiveLook.d.ts +60 -0
- package/packages/types/film/LookQuality.d.ts +24 -0
- package/packages/types/film/Projection.d.ts +20 -0
- package/packages/types/film/SceneLook.d.ts +122 -0
- package/packages/types/film/index.d.ts +13 -0
- package/packages/types/index.d.ts +49 -0
- package/packages/types/particles/EffectEnvelope.d.ts +18 -0
- package/packages/types/particles/LayaParticleRenderer.d.ts +30 -0
- package/packages/types/particles/LayaParticleRenderer3D.d.ts +29 -0
- package/packages/types/particles/ParticleExtras.d.ts +50 -0
- package/packages/types/particles/ParticleMesh3D.d.ts +24 -0
- package/packages/types/particles/ParticleSystem.d.ts +52 -0
- package/packages/types/particles/ParticleSystem3D.d.ts +69 -0
- package/packages/types/particles/ParticleTypes.d.ts +89 -0
- package/packages/types/particles/ParticleTypes3D.d.ts +56 -0
- package/packages/types/particles/RibbonPath3D.d.ts +32 -0
- package/packages/types/particles/RibbonTrail.d.ts +38 -0
- package/packages/types/particles/RibbonTrail3D.d.ts +22 -0
- package/packages/types/particles/index.d.ts +13 -0
- package/packages/types/prefabs/PrefabLibrary.d.ts +176 -0
- package/packages/types/prefabs/PrefabTree3D.d.ts +59 -0
- package/packages/types/prefabs/index.d.ts +4 -0
- package/packages/types/procedural/Geometry.d.ts +252 -0
- package/packages/types/procedural/Hand.d.ts +150 -0
- package/packages/types/procedural/Isosurface.d.ts +181 -0
- package/packages/types/procedural/ModuleHarness.d.ts +90 -0
- package/packages/types/procedural/Noise.d.ts +15 -0
- package/packages/types/procedural/PhotoMaterial.d.ts +49 -0
- package/packages/types/procedural/ProceduralAssetProvider.d.ts +31 -0
- package/packages/types/procedural/ProceduralMaterial.d.ts +63 -0
- package/packages/types/procedural/PropFactory.d.ts +94 -0
- package/packages/types/procedural/Random.d.ts +26 -0
- package/packages/types/procedural/SynthAudio.d.ts +49 -0
- package/packages/types/procedural/TerrainMesh.d.ts +55 -0
- package/packages/types/procedural/TextureRecipe.d.ts +125 -0
- package/packages/types/procedural/TriplanarMaterial.d.ts +27 -0
- package/packages/types/procedural/Variation.d.ts +23 -0
- package/packages/types/procedural/index.d.ts +16 -0
- package/packages/types/runtime3d/ActionFrames.d.ts +62 -0
- package/packages/types/runtime3d/AnimationBlend.d.ts +57 -0
- package/packages/types/runtime3d/AnimationBlendMath.d.ts +27 -0
- package/packages/types/runtime3d/AssetProvider.d.ts +167 -0
- package/packages/types/runtime3d/AssetShowcase.d.ts +44 -0
- package/packages/types/runtime3d/Assets.d.ts +166 -0
- package/packages/types/runtime3d/AsyncDeadline.d.ts +6 -0
- package/packages/types/runtime3d/AsyncOperation.d.ts +3 -0
- package/packages/types/runtime3d/BackendChoice.d.ts +130 -0
- package/packages/types/runtime3d/BakedCrowd.d.ts +156 -0
- package/packages/types/runtime3d/BasisTexture.d.ts +169 -0
- package/packages/types/runtime3d/CameraCollision.d.ts +20 -0
- package/packages/types/runtime3d/CameraEffects.d.ts +134 -0
- package/packages/types/runtime3d/CameraRig.d.ts +27 -0
- package/packages/types/runtime3d/CharacterController.d.ts +71 -0
- package/packages/types/runtime3d/CinematicCapture.d.ts +103 -0
- package/packages/types/runtime3d/Clocks.d.ts +200 -0
- package/packages/types/runtime3d/Cloth.d.ts +57 -0
- package/packages/types/runtime3d/Clouds.d.ts +69 -0
- package/packages/types/runtime3d/ColorLut.d.ts +73 -0
- package/packages/types/runtime3d/CombatQueries.d.ts +50 -0
- package/packages/types/runtime3d/ComputePass.d.ts +134 -0
- package/packages/types/runtime3d/CrowdPresentation.d.ts +104 -0
- package/packages/types/runtime3d/DebugDraw.d.ts +161 -0
- package/packages/types/runtime3d/DebugStats.d.ts +24 -0
- package/packages/types/runtime3d/Decals.d.ts +65 -0
- package/packages/types/runtime3d/DensityVolume.d.ts +39 -0
- package/packages/types/runtime3d/DistanceBricks.d.ts +97 -0
- package/packages/types/runtime3d/Dither.d.ts +78 -0
- package/packages/types/runtime3d/DrawWarmUp.d.ts +93 -0
- package/packages/types/runtime3d/EdgeSmoothing.d.ts +10 -0
- package/packages/types/runtime3d/EnvironmentProbe.d.ts +139 -0
- package/packages/types/runtime3d/Filmic.d.ts +243 -0
- package/packages/types/runtime3d/Foliage.d.ts +95 -0
- package/packages/types/runtime3d/GltfIntake.d.ts +236 -0
- package/packages/types/runtime3d/GltfSecondUv.d.ts +54 -0
- package/packages/types/runtime3d/GraphicsGuard.d.ts +18 -0
- package/packages/types/runtime3d/Grass.d.ts +226 -0
- package/packages/types/runtime3d/GroundTruthAO.d.ts +64 -0
- package/packages/types/runtime3d/HalfFloat.d.ts +13 -0
- package/packages/types/runtime3d/HdrEnvironment.d.ts +144 -0
- package/packages/types/runtime3d/Ik.d.ts +123 -0
- package/packages/types/runtime3d/InputBuffer.d.ts +49 -0
- package/packages/types/runtime3d/InstancedMesh.d.ts +116 -0
- package/packages/types/runtime3d/Laya342Adapters.d.ts +306 -0
- package/packages/types/runtime3d/Laya342GltfAdapter.d.ts +105 -0
- package/packages/types/runtime3d/LensFinish.d.ts +38 -0
- package/packages/types/runtime3d/LensFlare.d.ts +114 -0
- package/packages/types/runtime3d/LightFog.d.ts +190 -0
- package/packages/types/runtime3d/LightingDepth.d.ts +128 -0
- package/packages/types/runtime3d/Lightmap.d.ts +55 -0
- package/packages/types/runtime3d/Math3D.d.ts +19 -0
- package/packages/types/runtime3d/MeshQuery.d.ts +107 -0
- package/packages/types/runtime3d/MeshoptModelDecoder.d.ts +34 -0
- package/packages/types/runtime3d/MiniGameSplash.d.ts +4 -0
- package/packages/types/runtime3d/ModelAnimationSampler.d.ts +26 -0
- package/packages/types/runtime3d/ModelCompatibility.d.ts +169 -0
- package/packages/types/runtime3d/ModelDecoder.d.ts +66 -0
- package/packages/types/runtime3d/ModelInspector.d.ts +77 -0
- package/packages/types/runtime3d/ModelLod.d.ts +61 -0
- package/packages/types/runtime3d/ModelPlacements.d.ts +77 -0
- package/packages/types/runtime3d/ObjectMotion.d.ts +43 -0
- package/packages/types/runtime3d/PhysicalCamera.d.ts +51 -0
- package/packages/types/runtime3d/PointShadow.d.ts +71 -0
- package/packages/types/runtime3d/PointShadowSchedule.d.ts +74 -0
- package/packages/types/runtime3d/Pool.d.ts +33 -0
- package/packages/types/runtime3d/ProbeVolume.d.ts +123 -0
- package/packages/types/runtime3d/QualityGovernor.d.ts +201 -0
- package/packages/types/runtime3d/QualityMemory.d.ts +83 -0
- package/packages/types/runtime3d/RenderScale.d.ts +69 -0
- package/packages/types/runtime3d/RenderSpaces.d.ts +44 -0
- package/packages/types/runtime3d/Renderer.d.ts +62 -0
- package/packages/types/runtime3d/ResultPlayback.d.ts +70 -0
- package/packages/types/runtime3d/Runtime.d.ts +136 -0
- package/packages/types/runtime3d/RuntimeDriver.d.ts +42 -0
- package/packages/types/runtime3d/SceneLifecycle.d.ts +84 -0
- package/packages/types/runtime3d/SceneMutation.d.ts +34 -0
- package/packages/types/runtime3d/SceneQueries.d.ts +71 -0
- package/packages/types/runtime3d/ScreenReflections.d.ts +78 -0
- package/packages/types/runtime3d/SelectionOutline.d.ts +68 -0
- package/packages/types/runtime3d/ShaderErrors.d.ts +27 -0
- package/packages/types/runtime3d/ShaderRegistry.d.ts +10 -0
- package/packages/types/runtime3d/ShaderWarmUp.d.ts +162 -0
- package/packages/types/runtime3d/ShadowUpdates.d.ts +125 -0
- package/packages/types/runtime3d/SkinBinding.d.ts +53 -0
- package/packages/types/runtime3d/Smaa.d.ts +60 -0
- package/packages/types/runtime3d/SmaaTables.d.ts +12 -0
- package/packages/types/runtime3d/SpringBones.d.ts +69 -0
- package/packages/types/runtime3d/SurfaceBuffer.d.ts +28 -0
- package/packages/types/runtime3d/Surfaces.d.ts +326 -0
- package/packages/types/runtime3d/Themes.d.ts +70 -0
- package/packages/types/runtime3d/Timeline.d.ts +88 -0
- package/packages/types/runtime3d/ToneCurves.d.ts +59 -0
- package/packages/types/runtime3d/TransformGizmo.d.ts +139 -0
- package/packages/types/runtime3d/TriangleMask.d.ts +84 -0
- package/packages/types/runtime3d/Underwater.d.ts +120 -0
- package/packages/types/runtime3d/Utf8.d.ts +12 -0
- package/packages/types/runtime3d/Vrm.d.ts +120 -0
- package/packages/types/runtime3d/VrmDocument.d.ts +381 -0
- package/packages/types/runtime3d/WalkGrid.d.ts +94 -0
- package/packages/types/runtime3d/WebGPU342Adapters.d.ts +27 -0
- package/packages/types/runtime3d/index.d.ts +102 -0
- package/packages/types/shaders/Laya342ShaderTemplates.d.ts +3 -0
- package/packages/types/shaders/LitSurfaceMaterial.d.ts +257 -0
- package/packages/types/shaders/LitSurfaceTemplates.d.ts +7 -0
- package/packages/types/shaders/ReflectiveSurface.d.ts +58 -0
- package/packages/types/shaders/ShaderMaterials.d.ts +60 -0
- package/packages/types/shaders/ToonMaterial.d.ts +176 -0
- package/packages/types/shaders/WaterRipples.d.ts +48 -0
- package/packages/types/shaders/WaterSurface.d.ts +110 -0
- package/packages/types/shaders/ZhudaCommon.d.ts +31 -0
- package/packages/types/shaders/index.d.ts +7 -0
- package/packages/types/simulation/Cloth.d.ts +381 -0
- package/packages/types/simulation/ParticleCore.d.ts +125 -0
- package/packages/types/simulation/SpringBones.d.ts +107 -0
- package/packages/types/simulation/index.d.ts +4 -0
- package/packages/types/terrain/Heightfield.d.ts +67 -0
- package/packages/types/terrain/Terrain2D.d.ts +81 -0
- package/packages/types/terrain/Terrain3D.d.ts +80 -0
- package/packages/types/terrain/TerrainShell.d.ts +8 -0
- package/packages/types/terrain/index.d.ts +4 -0
- package/packages/types/vendor/LayaAir.runtime.d.ts +97440 -0
- package/packages/types/vendor/REPAIRS.md +30 -0
- package/packages/types/vendor/restored-3.4.2.json +142 -0
- package/packages/types/vendor/spine.runtime.d.ts +1507 -0
- package/packages/types/vendor/wechat-media.d.ts +877 -0
- package/packages/types/zhuda-2d-ui.d.ts +244 -0
- package/packages/types/zhuda-3d-physics.d.ts +34 -0
- package/packages/types/zhuda-audio.d.ts +128 -0
- package/packages/types/zhuda-bootstrap.d.ts +100 -0
- package/packages/types/zhuda-branding.d.ts +6 -0
- package/packages/types/zhuda-core.d.ts +46 -0
- package/packages/types/zhuda-declarative.d.ts +81 -0
- package/packages/types/zhuda-effects.d.ts +302 -0
- package/packages/types/zhuda-layout.d.ts +96 -0
- package/packages/types/zhuda-particles.d.ts +477 -0
- package/packages/types/zhuda-spine42.d.ts +23 -0
- package/packages/types/zhuda-static-assets.d.ts +389 -0
- package/packages/types/zhuda-video.d.ts +24 -0
- package/packages/types/zhuda-visual-contract.d.ts +52 -0
- package/packages/types/zhuda-webview.d.ts +43 -0
- package/vendor/basis/LICENSE.txt +55 -0
- package/vendor/basis/README.md +25 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/vendor/laya-3.4.2/WEBGPU-LICENSES.txt +1259 -0
- package/vendor/laya-3.4.2/libs/laya.ani.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.box2D.js +1209 -0
- package/vendor/laya-3.4.2/libs/laya.bridge.js +2273 -0
- package/vendor/laya-3.4.2/libs/laya.bullet.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.core.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.d3.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.device.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.gltf.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ik.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.light2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.line2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.native-spine42.js +7672 -0
- package/vendor/laya-3.4.2/libs/laya.navMesh2d.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.navMesh3d.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.navMeshCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particle.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particle3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particleCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.physics2D.js +3774 -0
- package/vendor/laya-3.4.2/libs/laya.physics3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.postProcess.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.spine.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.spine3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.tilemap.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trail2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trail3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trailCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ui.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ui2.js +9904 -0
- package/vendor/laya-3.4.2/libs/laya.vfx.js +6754 -0
- package/vendor/laya-3.4.2/libs/laya.webgl_2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.webgl_3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.webgpu_2D.js +18576 -0
- package/vendor/laya-3.4.2/libs/laya.webgpu_3D.js +6729 -0
- package/vendor/laya-3.4.2/libs/nagabind.js +395 -0
- package/vendor/laya-3.4.2/libs/nagabind_bg.wasm +0 -0
- package/vendor/laya-3.4.2/libs/shader_compiler_web.js +22 -0
- package/vendor/laya-3.4.2/libs/shader_compiler_web.wasm +0 -0
- package/vendor/laya-3.4.2/libs/spine-core-3.8.js +1 -0
- package/vendor/laya-3.4.2/libs/spine-core-4.2.js +10216 -0
- package/vendor/laya-3.4.2/webgpu-provenance.json +41 -0
- package/vendor/meshoptimizer/LICENSE.txt +21 -0
- package/vendor/meshoptimizer/README.md +13 -0
- package/vendor/threejs-post/LICENSE.txt +53 -0
- package/vendor/threejs-post/README.md +54 -0
- package/zhuda.config.json +22 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
// The Laya stage of a running page, read from outside it, and scenario steps that use it:
|
|
2
|
+
// a click on a control found by its name or by what it says, and an expectation checked
|
|
3
|
+
// against the stage. Nothing here is in a game's bundle: the probe is sent to the page as
|
|
4
|
+
// text by the tool that drives the browser (Chrome's debugging protocol, Playwright, the
|
|
5
|
+
// phone driver), so a release build is not one byte larger and a page built before the
|
|
6
|
+
// probe existed can be read all the same. It needs `window.Laya`, which every page of this
|
|
7
|
+
// engine has (the LayaAir libraries are classic scripts).
|
|
8
|
+
//
|
|
9
|
+
// const report = await browser.evaluate(stageProbeExpression());
|
|
10
|
+
// findStageNodes(report, { name: 'menu' })[0].rect // [x, y, width, height] in CSS pixels
|
|
11
|
+
//
|
|
12
|
+
// Scenario steps (prefabs/viewer2d/tools/play.mjs, prefabs/tools/detplay.mjs):
|
|
13
|
+
// { "click": { "name": "level-0" } } { "click": "level-0" } { "click": { "text": "選單" } }
|
|
14
|
+
// { "click": { "text": "前進" }, "hold": 0.2 } the button stays down that long
|
|
15
|
+
// { "expect": { "name": "menu" } } a shown node of that name
|
|
16
|
+
// { "expect": { "name": "mute", "text": "聲音:關" } } it, or a label inside it, says so
|
|
17
|
+
// { "expect": { "textMatches": "^\\d+ / 1500 分$" } } a shown label matches
|
|
18
|
+
// { "expect": { "name": "again", "visible": false } } there, and not shown
|
|
19
|
+
// { "expect": { "text": "豐收!", "count": 0 } } no shown label says so
|
|
20
|
+
// { "expect": { "js": "S.screen === 'play'" } } an expression on the page hook
|
|
21
|
+
// { "expect": [ … ] } every one of them
|
|
22
|
+
// { "expect": { "text": "豐收!", "within": 30 } } … within 30 seconds of the player's clock
|
|
23
|
+
// { "probe": "title" } the whole report, as <out>/title.stage.json
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Runs in the page. Walks `Laya.stage` and gives back every node: its name, its LayaAir
|
|
27
|
+
* class, whether it is visible itself and shown (it and every node above it), whether its
|
|
28
|
+
* `mouseEnabled` is set and which pointer events it listens for, what it says, and where it
|
|
29
|
+
* is on the page in CSS pixels.
|
|
30
|
+
*
|
|
31
|
+
* It is sent as text (`stageProbeExpression`), so it uses nothing outside itself, and it
|
|
32
|
+
* is written for an old runtime: no optional chaining, no `??`.
|
|
33
|
+
*
|
|
34
|
+
* `options.counts`: only the two counts (no tree, no rectangles).
|
|
35
|
+
* `options.maxNodes`: stop adding to the tree at this many nodes (default 20000).
|
|
36
|
+
*/
|
|
37
|
+
export function zhudaStageProbe(options) {
|
|
38
|
+
const o = options || {};
|
|
39
|
+
const L = globalThis.Laya;
|
|
40
|
+
const stage = L && L.stage;
|
|
41
|
+
if (!stage) return { ok: false, reason: 'no Laya.stage on this page' };
|
|
42
|
+
|
|
43
|
+
// The libraries are minified: a constructor's own name is a letter. The keys of the Laya
|
|
44
|
+
// namespace are the real names, so a node's class is the nearest one found there.
|
|
45
|
+
const names = new Map();
|
|
46
|
+
for (const key of Object.keys(L)) {
|
|
47
|
+
let value;
|
|
48
|
+
try {
|
|
49
|
+
value = L[key];
|
|
50
|
+
} catch {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (typeof value === 'function' && value.prototype && !names.has(value)) names.set(value, key);
|
|
54
|
+
}
|
|
55
|
+
const classOf = (node) => {
|
|
56
|
+
for (let c = node.constructor; typeof c === 'function'; c = Object.getPrototypeOf(c)) {
|
|
57
|
+
const known = names.get(c);
|
|
58
|
+
if (known) return known;
|
|
59
|
+
}
|
|
60
|
+
return 'Node';
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Stage units to CSS pixels of the page. The canvas covers the stage in every scale mode,
|
|
64
|
+
// so its client rectangle is the answer; a stage LayaAir itself has turned on the page
|
|
65
|
+
// (screenMode on a screen of the other shape) is LayaAir's own pointer mapping, backwards.
|
|
66
|
+
const doc = globalThis.document;
|
|
67
|
+
const main = L.Browser && L.Browser.mainCanvas && L.Browser.mainCanvas.source;
|
|
68
|
+
const canvas = main && main.getBoundingClientRect ? main : doc && doc.querySelector('canvas');
|
|
69
|
+
const box =
|
|
70
|
+
canvas && canvas.getBoundingClientRect
|
|
71
|
+
? canvas.getBoundingClientRect()
|
|
72
|
+
: { left: 0, top: 0, width: stage.width, height: stage.height };
|
|
73
|
+
const kx = box.width / stage.width;
|
|
74
|
+
const ky = box.height / stage.height;
|
|
75
|
+
const m = stage._canvasTransform;
|
|
76
|
+
const turned = !!m && (Math.abs(m.b) > 1e-6 || Math.abs(m.c) > 1e-6);
|
|
77
|
+
const toPage = (x, y) => {
|
|
78
|
+
if (!turned) return [box.left + x * kx, box.top + y * ky];
|
|
79
|
+
const px = x * stage.clientScaleX;
|
|
80
|
+
const py = y * stage.clientScaleY;
|
|
81
|
+
return [
|
|
82
|
+
m.a * px + m.c * py + m.tx - (globalThis.scrollX || 0),
|
|
83
|
+
m.b * px + m.d * py + m.ty - (globalThis.scrollY || 0),
|
|
84
|
+
];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const round = (v) => Math.round(v * 100) / 100;
|
|
88
|
+
const point = L.Point ? new L.Point() : null;
|
|
89
|
+
const rectOf = (node) => {
|
|
90
|
+
if (!point || typeof node.localToGlobal !== 'function') return null;
|
|
91
|
+
let x = 0;
|
|
92
|
+
let y = 0;
|
|
93
|
+
let w = 0;
|
|
94
|
+
let h = 0;
|
|
95
|
+
try {
|
|
96
|
+
w = Number(node.width) || 0;
|
|
97
|
+
h = Number(node.height) || 0;
|
|
98
|
+
// No size of its own: what it draws (a sprite with only graphics).
|
|
99
|
+
if (!(w > 0 && h > 0) && typeof node.getSelfBounds === 'function') {
|
|
100
|
+
const b = node.getSelfBounds();
|
|
101
|
+
if (b && b.width > 0 && b.height > 0) {
|
|
102
|
+
x = b.x;
|
|
103
|
+
y = b.y;
|
|
104
|
+
w = b.width;
|
|
105
|
+
h = b.height;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch {
|
|
109
|
+
/* a node that cannot say its size has none */
|
|
110
|
+
}
|
|
111
|
+
let x0 = Infinity;
|
|
112
|
+
let y0 = Infinity;
|
|
113
|
+
let x1 = -Infinity;
|
|
114
|
+
let y1 = -Infinity;
|
|
115
|
+
const corners = [
|
|
116
|
+
[x, y],
|
|
117
|
+
[x + w, y],
|
|
118
|
+
[x, y + h],
|
|
119
|
+
[x + w, y + h],
|
|
120
|
+
];
|
|
121
|
+
for (let i = 0; i < 4; i++) {
|
|
122
|
+
point.x = corners[i][0];
|
|
123
|
+
point.y = corners[i][1];
|
|
124
|
+
let g;
|
|
125
|
+
try {
|
|
126
|
+
g = node.localToGlobal(point, false);
|
|
127
|
+
} catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const p = toPage(g.x, g.y);
|
|
131
|
+
x0 = Math.min(x0, p[0]);
|
|
132
|
+
y0 = Math.min(y0, p[1]);
|
|
133
|
+
x1 = Math.max(x1, p[0]);
|
|
134
|
+
y1 = Math.max(y1, p[1]);
|
|
135
|
+
}
|
|
136
|
+
return [round(x0), round(y0), round(x1 - x0), round(y1 - y0)];
|
|
137
|
+
};
|
|
138
|
+
const textOf = (node) => {
|
|
139
|
+
const keys = ['text', 'label', 'title'];
|
|
140
|
+
for (let i = 0; i < keys.length; i++) {
|
|
141
|
+
let value;
|
|
142
|
+
try {
|
|
143
|
+
value = node[keys[i]];
|
|
144
|
+
} catch {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (typeof value === 'string') return value;
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const pointerEvents = ['click', 'mousedown', 'mouseup'];
|
|
153
|
+
const max = o.maxNodes > 0 ? o.maxNodes : 20000;
|
|
154
|
+
let total = 0;
|
|
155
|
+
let shownCount = 0;
|
|
156
|
+
let truncated = false;
|
|
157
|
+
const walk = (node, parentShown) => {
|
|
158
|
+
total++;
|
|
159
|
+
const visible = node.visible !== false && node.active !== false;
|
|
160
|
+
const shown = parentShown && visible;
|
|
161
|
+
if (shown) shownCount++;
|
|
162
|
+
const kids = node._children || [];
|
|
163
|
+
if (o.counts) {
|
|
164
|
+
for (let i = 0; i < kids.length; i++)
|
|
165
|
+
if (kids[i] && !kids[i]._destroyed) walk(kids[i], shown);
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
const out = {
|
|
169
|
+
name: typeof node.name === 'string' ? node.name : '',
|
|
170
|
+
class: classOf(node),
|
|
171
|
+
visible: visible,
|
|
172
|
+
shown: shown,
|
|
173
|
+
mouseEnabled: node.mouseEnabled === true,
|
|
174
|
+
};
|
|
175
|
+
// A node may take the pointer without `mouseEnabled` ever being set: listening is enough.
|
|
176
|
+
if (typeof node.hasListener === 'function') {
|
|
177
|
+
const heard = [];
|
|
178
|
+
for (let i = 0; i < pointerEvents.length; i++)
|
|
179
|
+
if (node.hasListener(pointerEvents[i])) heard.push(pointerEvents[i]);
|
|
180
|
+
if (heard.length) out.listens = heard;
|
|
181
|
+
}
|
|
182
|
+
const text = textOf(node);
|
|
183
|
+
if (text !== undefined) out.text = text;
|
|
184
|
+
out.rect = rectOf(node);
|
|
185
|
+
out.children = [];
|
|
186
|
+
for (let i = 0; i < kids.length; i++) {
|
|
187
|
+
if (!kids[i] || kids[i]._destroyed) continue;
|
|
188
|
+
if (total >= max) {
|
|
189
|
+
truncated = true;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
out.children.push(walk(kids[i], shown));
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
};
|
|
196
|
+
const root = walk(stage, true);
|
|
197
|
+
const report = {
|
|
198
|
+
ok: true,
|
|
199
|
+
stage: [stage.width, stage.height],
|
|
200
|
+
canvas: [round(box.left), round(box.top), round(box.width), round(box.height)],
|
|
201
|
+
view: [globalThis.innerWidth || 0, globalThis.innerHeight || 0],
|
|
202
|
+
turned: turned,
|
|
203
|
+
total: total,
|
|
204
|
+
shown: shownCount,
|
|
205
|
+
};
|
|
206
|
+
if (!o.counts) {
|
|
207
|
+
report.truncated = truncated;
|
|
208
|
+
report.root = root;
|
|
209
|
+
}
|
|
210
|
+
return report;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Runs in the page. The page element that would take a click at a point instead of the
|
|
215
|
+
* stage's canvas (a splash still fading, an HTML panel over the game), as `tag#id.class`;
|
|
216
|
+
* null when the canvas is on top there. Sent as text, like the probe.
|
|
217
|
+
*/
|
|
218
|
+
export function zhudaStageCover(x, y) {
|
|
219
|
+
const L = globalThis.Laya;
|
|
220
|
+
const doc = globalThis.document;
|
|
221
|
+
if (!doc || typeof doc.elementFromPoint !== 'function') return null;
|
|
222
|
+
const main = L && L.Browser && L.Browser.mainCanvas && L.Browser.mainCanvas.source;
|
|
223
|
+
const canvas = main && main.getBoundingClientRect ? main : doc.querySelector('canvas');
|
|
224
|
+
const top = doc.elementFromPoint(x, y);
|
|
225
|
+
if (!top || top === canvas) return null;
|
|
226
|
+
const classes = typeof top.className === 'string' ? top.className.trim() : '';
|
|
227
|
+
return (
|
|
228
|
+
String(top.tagName).toLowerCase() +
|
|
229
|
+
(top.id ? '#' + top.id : '') +
|
|
230
|
+
(classes ? '.' + classes.split(/\s+/).join('.') : '')
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** The probe as an expression a browser driver evaluates in the page (returned by value). */
|
|
235
|
+
export function stageProbeExpression(options = {}) {
|
|
236
|
+
return `(${zhudaStageProbe.toString()})(${JSON.stringify(options)})`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* What `node` says and what the labels inside it say, as long as nothing between one and
|
|
241
|
+
* `node` is hidden. LayaAir's Label holds a Text that says the same: that is said once.
|
|
242
|
+
*/
|
|
243
|
+
function textsWithin(node, out = [], above) {
|
|
244
|
+
if (typeof node.text === 'string' && node.text !== above) out.push(node.text);
|
|
245
|
+
for (const child of node.children ?? []) if (child.visible) textsWithin(child, out, node.text);
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* A probe report's tree as a list in drawing order. Each entry is the node without its
|
|
251
|
+
* children, with `path` (names from the stage down; a node without a name is its class and
|
|
252
|
+
* its place among its parent's children), `depth`, `texts` (what it says, then what the
|
|
253
|
+
* labels inside it say), `echo` (it only repeats the label it sits in) and `node` (the entry
|
|
254
|
+
* of the tree itself).
|
|
255
|
+
*/
|
|
256
|
+
export function listStageNodes(report) {
|
|
257
|
+
if (!report?.root)
|
|
258
|
+
throw Error('Not a stage report with a tree (was the probe asked for counts only?)');
|
|
259
|
+
const list = [];
|
|
260
|
+
const visit = (node, path, depth, above) => {
|
|
261
|
+
const { children = [], ...own } = node;
|
|
262
|
+
const entry = { ...own, path, depth, texts: textsWithin(node), node };
|
|
263
|
+
// The Text inside a Label: the same words a second time, one level down.
|
|
264
|
+
if (typeof node.text === 'string' && node.text === above) entry.echo = true;
|
|
265
|
+
list.push(entry);
|
|
266
|
+
children.forEach((child, i) =>
|
|
267
|
+
visit(child, `${path}/${child.name || `${child.class}[${i}]`}`, depth + 1, node.text),
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
visit(report.root, report.root.name || report.root.class, 0);
|
|
271
|
+
return list;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const SELECTOR_KEYS = ['name', 'text', 'textMatches', 'class', 'nth'];
|
|
275
|
+
const EXPECT_KEYS = [...SELECTOR_KEYS, 'visible', 'count', 'js', 'within'];
|
|
276
|
+
|
|
277
|
+
/** A selector as written in a scenario (a string is a name), checked; throws on a slip of the pen. */
|
|
278
|
+
export function normalizeStageSelector(value, what = 'selector', known = SELECTOR_KEYS) {
|
|
279
|
+
const selector = typeof value === 'string' ? { name: value } : value;
|
|
280
|
+
if (!selector || typeof selector !== 'object' || Array.isArray(selector))
|
|
281
|
+
throw Error(`${what} is a name or an object with any of ${known.join(', ')}`);
|
|
282
|
+
for (const key of Object.keys(selector))
|
|
283
|
+
if (!known.includes(key))
|
|
284
|
+
throw Error(`${what} has an unknown key "${key}" (known: ${known.join(', ')})`);
|
|
285
|
+
for (const key of ['name', 'text', 'textMatches', 'class'])
|
|
286
|
+
if (selector[key] !== undefined && typeof selector[key] !== 'string')
|
|
287
|
+
throw Error(`${what}: "${key}" is a string`);
|
|
288
|
+
if (selector.textMatches !== undefined)
|
|
289
|
+
try {
|
|
290
|
+
new RegExp(selector.textMatches);
|
|
291
|
+
} catch (error) {
|
|
292
|
+
throw Error(`${what}: "textMatches" is not a regular expression (${error.message})`);
|
|
293
|
+
}
|
|
294
|
+
if (selector.nth !== undefined && !(Number.isInteger(selector.nth) && selector.nth >= 0))
|
|
295
|
+
throw Error(`${what}: "nth" is a whole number, counted from 0`);
|
|
296
|
+
return selector;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const selects = (selector) =>
|
|
300
|
+
['name', 'text', 'textMatches', 'class'].some((key) => selector[key] !== undefined);
|
|
301
|
+
|
|
302
|
+
function matches(entry, selector) {
|
|
303
|
+
if (selector.name !== undefined && entry.name !== selector.name) return false;
|
|
304
|
+
if (selector.class !== undefined && entry.class !== selector.class) return false;
|
|
305
|
+
// With a name or a class the node is a control: what it says may be said by a label inside
|
|
306
|
+
// it. With the text alone the node is the label itself, so one label is one match (and a
|
|
307
|
+
// Label that holds a Text of the same words is the Label).
|
|
308
|
+
const control = selector.name !== undefined || selector.class !== undefined;
|
|
309
|
+
if (!control && entry.echo) return false;
|
|
310
|
+
const texts = control ? entry.texts : entry.text === undefined ? [] : [entry.text];
|
|
311
|
+
if (selector.text !== undefined && !texts.includes(selector.text)) return false;
|
|
312
|
+
if (selector.textMatches !== undefined) {
|
|
313
|
+
const pattern = new RegExp(selector.textMatches);
|
|
314
|
+
if (!texts.some((text) => pattern.test(text))) return false;
|
|
315
|
+
}
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* The nodes of a report that a selector picks, in drawing order. `shown: true` (the
|
|
321
|
+
* default) keeps the ones on show, `false` the ones that are there and hidden, `null` both.
|
|
322
|
+
*/
|
|
323
|
+
export function findStageNodes(report, selector, { shown = true } = {}) {
|
|
324
|
+
const wanted = normalizeStageSelector(selector, 'selector', EXPECT_KEYS);
|
|
325
|
+
const found = listStageNodes(report).filter(
|
|
326
|
+
(entry) => matches(entry, wanted) && (shown === null || entry.shown === shown),
|
|
327
|
+
);
|
|
328
|
+
return wanted.nth === undefined ? found : found.slice(wanted.nth, wanted.nth + 1);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const quote = (text) => JSON.stringify(text.length > 60 ? text.slice(0, 57) + '…' : text);
|
|
332
|
+
const describe = (entry) =>
|
|
333
|
+
`${entry.path} (${entry.shown ? 'shown' : 'hidden'}${entry.texts.length ? `, says ${entry.texts.slice(0, 3).map(quote).join(' ')}` : ''})`;
|
|
334
|
+
|
|
335
|
+
/** What is on the stage that is nearest to what a selector asked for, in words. */
|
|
336
|
+
export function describeStageNear(report, selector) {
|
|
337
|
+
const wanted = normalizeStageSelector(selector, 'selector', EXPECT_KEYS);
|
|
338
|
+
const all = listStageNodes(report);
|
|
339
|
+
const control = wanted.name !== undefined || wanted.class !== undefined;
|
|
340
|
+
if (control) {
|
|
341
|
+
const same = all.filter(
|
|
342
|
+
(entry) =>
|
|
343
|
+
(wanted.name === undefined || entry.name === wanted.name) &&
|
|
344
|
+
(wanted.class === undefined || entry.class === wanted.class),
|
|
345
|
+
);
|
|
346
|
+
if (same.length)
|
|
347
|
+
return `found ${same.length}: ${same.slice(0, 5).map(describe).join('; ')}${same.length > 5 ? '; …' : ''}`;
|
|
348
|
+
const others = [
|
|
349
|
+
...new Set(
|
|
350
|
+
all
|
|
351
|
+
.filter((entry) => entry.shown)
|
|
352
|
+
.map((entry) => (wanted.name !== undefined ? entry.name : entry.class))
|
|
353
|
+
.filter(Boolean),
|
|
354
|
+
),
|
|
355
|
+
];
|
|
356
|
+
return `found no node ${wanted.name !== undefined ? `named ${quote(wanted.name)}` : `of class ${wanted.class}`}; shown ${wanted.name !== undefined ? 'names' : 'classes'}: ${others.slice(0, 24).join(', ') || 'none'}${others.length > 24 ? ', …' : ''}`;
|
|
357
|
+
}
|
|
358
|
+
const said = all.filter((entry) => entry.text !== undefined && entry.text !== '' && !entry.echo);
|
|
359
|
+
const shown = said.filter((entry) => entry.shown).map((entry) => quote(entry.text));
|
|
360
|
+
const hidden = said.filter((entry) => !entry.shown && matches(entry, wanted));
|
|
361
|
+
return `shown labels say: ${shown.slice(0, 16).join(' ') || 'nothing'}${shown.length > 16 ? ' …' : ''}${hidden.length ? `; hidden and matching: ${hidden.slice(0, 3).map(describe).join('; ')}` : ''}`;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** An expectation as written in a scenario, checked; throws on a slip of the pen. */
|
|
365
|
+
export function normalizeStageExpectation(value, what = 'expect') {
|
|
366
|
+
const expectation = normalizeStageSelector(value, what, EXPECT_KEYS);
|
|
367
|
+
if (!selects(expectation) && expectation.js === undefined)
|
|
368
|
+
throw Error(`${what} names a node (name, text, textMatches, class) or gives "js"`);
|
|
369
|
+
if (expectation.js !== undefined && typeof expectation.js !== 'string')
|
|
370
|
+
throw Error(`${what}: "js" is an expression as a string`);
|
|
371
|
+
if (expectation.visible !== undefined && typeof expectation.visible !== 'boolean')
|
|
372
|
+
throw Error(`${what}: "visible" is true or false`);
|
|
373
|
+
if (
|
|
374
|
+
expectation.count !== undefined &&
|
|
375
|
+
!(Number.isInteger(expectation.count) && expectation.count >= 0)
|
|
376
|
+
)
|
|
377
|
+
throw Error(`${what}: "count" is a whole number`);
|
|
378
|
+
if (
|
|
379
|
+
expectation.within !== undefined &&
|
|
380
|
+
!(Number.isFinite(expectation.within) && expectation.within >= 0)
|
|
381
|
+
)
|
|
382
|
+
throw Error(`${what}: "within" is a number of seconds`);
|
|
383
|
+
if (!selects(expectation))
|
|
384
|
+
for (const key of ['visible', 'count', 'nth'])
|
|
385
|
+
if (expectation[key] !== undefined) throw Error(`${what}: "${key}" needs a node to be named`);
|
|
386
|
+
return expectation;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Checks the part of an expectation that is about the stage against a report. Passes when
|
|
391
|
+
* a shown node matches (`visible: false`: a hidden one), or exactly `count` of them.
|
|
392
|
+
* Gives `{ pass, found }`, `found` being what was there, in words.
|
|
393
|
+
*/
|
|
394
|
+
export function checkStageExpectation(report, value) {
|
|
395
|
+
const expectation = normalizeStageExpectation(value);
|
|
396
|
+
if (!selects(expectation)) return { pass: true, found: 'no node asked for' };
|
|
397
|
+
const got = findStageNodes(report, expectation, { shown: expectation.visible !== false });
|
|
398
|
+
const pass = expectation.count === undefined ? got.length > 0 : got.length === expectation.count;
|
|
399
|
+
if (pass)
|
|
400
|
+
return {
|
|
401
|
+
pass,
|
|
402
|
+
found: got.length ? got.slice(0, 3).map(describe).join('; ') : 'none, as expected',
|
|
403
|
+
};
|
|
404
|
+
if (got.length)
|
|
405
|
+
return {
|
|
406
|
+
pass,
|
|
407
|
+
found: `found ${got.length} where ${expectation.count} were expected: ${got.slice(0, 5).map(describe).join('; ')}`,
|
|
408
|
+
};
|
|
409
|
+
return { pass, found: describeStageNear(report, expectation) };
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** A scenario as read from its file, with the steps this module adds checked. Gives it back. */
|
|
413
|
+
export function checkScenario(steps) {
|
|
414
|
+
if (!Array.isArray(steps)) throw Error('A scenario is a list of steps');
|
|
415
|
+
steps.forEach((step, index) => {
|
|
416
|
+
const at = `step ${index + 1}`;
|
|
417
|
+
if (!step || typeof step !== 'object' || Array.isArray(step))
|
|
418
|
+
throw Error(`${at} is not an object`);
|
|
419
|
+
// An array is a point on the page, as before.
|
|
420
|
+
if (step.click !== undefined && !Array.isArray(step.click)) {
|
|
421
|
+
const selector = normalizeStageSelector(step.click, `${at}: click`);
|
|
422
|
+
if (!selects(selector))
|
|
423
|
+
throw Error(`${at}: click names a node (name, text, textMatches, class) or is [x, y]`);
|
|
424
|
+
}
|
|
425
|
+
if (step.expect !== undefined)
|
|
426
|
+
for (const one of [step.expect].flat()) normalizeStageExpectation(one, `${at}: expect`);
|
|
427
|
+
if (step.probe !== undefined && !/^[\w.-]+$/.test(String(step.probe)))
|
|
428
|
+
throw Error(`${at}: probe is a file name without a folder (letters, digits, - _ .)`);
|
|
429
|
+
});
|
|
430
|
+
return steps;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Where a click on a node goes: the middle of it, or of what is shown inside a node without a size. */
|
|
434
|
+
export function stageClickPoint(entry) {
|
|
435
|
+
const sized = (rect) => rect && rect[2] > 0 && rect[3] > 0;
|
|
436
|
+
let rect = entry.rect;
|
|
437
|
+
if (!sized(rect)) {
|
|
438
|
+
let x0 = Infinity;
|
|
439
|
+
let y0 = Infinity;
|
|
440
|
+
let x1 = -Infinity;
|
|
441
|
+
let y1 = -Infinity;
|
|
442
|
+
const grow = (node) => {
|
|
443
|
+
for (const child of node.children ?? []) {
|
|
444
|
+
if (!child.visible) continue;
|
|
445
|
+
if (sized(child.rect)) {
|
|
446
|
+
x0 = Math.min(x0, child.rect[0]);
|
|
447
|
+
y0 = Math.min(y0, child.rect[1]);
|
|
448
|
+
x1 = Math.max(x1, child.rect[0] + child.rect[2]);
|
|
449
|
+
y1 = Math.max(y1, child.rect[1] + child.rect[3]);
|
|
450
|
+
}
|
|
451
|
+
grow(child);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
grow(entry.node ?? entry);
|
|
455
|
+
rect = x1 > x0 && y1 > y0 ? [x0, y0, x1 - x0, y1 - y0] : null;
|
|
456
|
+
}
|
|
457
|
+
return rect ? [Math.round(rect[0] + rect[2] / 2), Math.round(rect[1] + rect[3] / 2)] : null;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* The named click and the expectation, for a scenario player. The player gives:
|
|
462
|
+
* evaluate(expression) the page's answer, by value
|
|
463
|
+
* press(x, y, hold) a click at a point of the page, in CSS pixels, held `hold` seconds
|
|
464
|
+
* advance(seconds) lets the player's clock run (real time, or a virtual clock's frames)
|
|
465
|
+
* hook the page hook as an expression (`S` in an expectation's "js")
|
|
466
|
+
* total how many steps the scenario has, for the messages
|
|
467
|
+
* A step that fails throws an Error that says which step it was and what was found.
|
|
468
|
+
*/
|
|
469
|
+
export function stageSteps({ evaluate, press, advance, hook = 'undefined', total }) {
|
|
470
|
+
const at = (index) => `step ${index + 1}${total ? ` of ${total}` : ''}`;
|
|
471
|
+
const probe = async (options) => {
|
|
472
|
+
const report = await evaluate(stageProbeExpression(options));
|
|
473
|
+
if (report?.ok !== true)
|
|
474
|
+
throw Error(`the stage could not be read: ${report?.reason ?? 'the page gave nothing back'}`);
|
|
475
|
+
return report;
|
|
476
|
+
};
|
|
477
|
+
const askPage = async (js) => {
|
|
478
|
+
const got = await evaluate(
|
|
479
|
+
`(() => { const S = ${hook}; const say = (v) => { try { const s = JSON.stringify(v); return s === undefined ? String(v) : s; } catch (e) { return String(v); } }; try { const v = (${js}); return { pass: !!v, found: say(v) }; } catch (e) { return { pass: false, found: 'it threw ' + String(e) }; } })()`,
|
|
480
|
+
);
|
|
481
|
+
return got ?? { pass: false, found: 'the page gave nothing back' };
|
|
482
|
+
};
|
|
483
|
+
const checkOnce = async (expectation) => {
|
|
484
|
+
const stage = selects(expectation)
|
|
485
|
+
? checkStageExpectation(await probe(), expectation)
|
|
486
|
+
: { pass: true, found: '' };
|
|
487
|
+
if (!stage.pass || expectation.js === undefined) return stage;
|
|
488
|
+
const page = await askPage(expectation.js);
|
|
489
|
+
return {
|
|
490
|
+
pass: page.pass,
|
|
491
|
+
found: `${stage.found ? stage.found + '; ' : ''}the expression gave ${String(page.found).slice(0, 300)}`,
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
return {
|
|
495
|
+
probe,
|
|
496
|
+
/**
|
|
497
|
+
* Clicks the one shown node a selector picks; `hold` seconds keep the button down (a
|
|
498
|
+
* control that listens for the press and the release, not for a click). Gives what it
|
|
499
|
+
* did, for the log.
|
|
500
|
+
*/
|
|
501
|
+
async click(value, index, hold = 0) {
|
|
502
|
+
const selector = normalizeStageSelector(value, `${at(index)}: click`);
|
|
503
|
+
const report = await probe();
|
|
504
|
+
const found = findStageNodes(report, selector);
|
|
505
|
+
const what = `${at(index)}: click ${JSON.stringify(selector)}`;
|
|
506
|
+
if (!found.length) throw Error(`${what}: ${describeStageNear(report, selector)}`);
|
|
507
|
+
if (found.length > 1)
|
|
508
|
+
throw Error(
|
|
509
|
+
`${what}: ${found.length} shown nodes match (say which with "nth"): ${found.slice(0, 5).map(describe).join('; ')}`,
|
|
510
|
+
);
|
|
511
|
+
const point = stageClickPoint(found[0]);
|
|
512
|
+
if (!point) throw Error(`${what}: ${found[0].path} has no size on the page`);
|
|
513
|
+
const [width, height] = report.view;
|
|
514
|
+
if (
|
|
515
|
+
point[0] < 0 ||
|
|
516
|
+
point[1] < 0 ||
|
|
517
|
+
(width && point[0] >= width) ||
|
|
518
|
+
(height && point[1] >= height)
|
|
519
|
+
)
|
|
520
|
+
throw Error(
|
|
521
|
+
`${what}: ${found[0].path} is off the page, at ${point.join(', ')} of ${width}×${height}`,
|
|
522
|
+
);
|
|
523
|
+
// Where a finger would land: on the canvas, or on something of the page above it.
|
|
524
|
+
const cover = await evaluate(`(${zhudaStageCover.toString()})(${point[0]}, ${point[1]})`);
|
|
525
|
+
if (cover)
|
|
526
|
+
throw Error(
|
|
527
|
+
`${what}: ${found[0].path} at ${point.join(', ')} is under the page element <${cover}>, which would take the click`,
|
|
528
|
+
);
|
|
529
|
+
await press(point[0], point[1], hold);
|
|
530
|
+
return { click: selector, at: point, node: found[0].path };
|
|
531
|
+
},
|
|
532
|
+
/** Checks one expectation or a list of them; one with "within" is asked again as the clock runs. */
|
|
533
|
+
async expect(value, index) {
|
|
534
|
+
const list = [value]
|
|
535
|
+
.flat()
|
|
536
|
+
.map((one) => normalizeStageExpectation(one, `${at(index)}: expect`));
|
|
537
|
+
let waited = 0;
|
|
538
|
+
for (const expectation of list) {
|
|
539
|
+
const { within = 0, ...asked } = expectation;
|
|
540
|
+
let spent = 0;
|
|
541
|
+
let result = await checkOnce(asked);
|
|
542
|
+
while (!result.pass && spent < within) {
|
|
543
|
+
const slice = Math.min(0.1, within - spent);
|
|
544
|
+
await advance(slice);
|
|
545
|
+
spent += slice;
|
|
546
|
+
result = await checkOnce(asked);
|
|
547
|
+
}
|
|
548
|
+
waited += spent;
|
|
549
|
+
if (!result.pass)
|
|
550
|
+
throw Error(
|
|
551
|
+
`${at(index)}: expected ${JSON.stringify(asked)}${within ? ` within ${within} s` : ''}: ${result.found}`,
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
return { expect: list.length, waited: Math.round(waited * 100) / 100 };
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
}
|