@craft_eco/craft-mcp 0.1.18 → 0.1.21
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/README.md +45 -8
- package/bin/craft-mcp.mjs +14 -1
- package/dist-server/core/connector-auth.mjs +3 -3
- package/dist-server/game-workflow/asset-formats.mjs +25 -64
- package/dist-server/game-workflow/asset-import.mjs +83 -67
- package/dist-server/game-workflow/assets.mjs +81 -9
- package/dist-server/game-workflow/capture-worker.mjs +1 -1
- package/dist-server/game-workflow/check.mjs +1 -1
- package/dist-server/game-workflow/draft-archive.mjs +53 -53
- package/dist-server/game-workflow/draft-bindings.mjs +35 -35
- package/dist-server/game-workflow/draft-uploads.mjs +207 -207
- package/dist-server/game-workflow/engines.mjs +2 -2
- package/dist-server/game-workflow/library-assets.mjs +16 -5
- package/dist-server/game-workflow/library-candidates.mjs +2 -1
- package/dist-server/game-workflow/library-catalog.mjs +2 -2
- package/dist-server/game-workflow/publication-materials.mjs +67 -67
- package/dist-server/game-workflow/publications.mjs +148 -148
- package/dist-server/game-workflow/publish-capture-worker.mjs +57 -57
- package/dist-server/game-workflow/publish-capture.mjs +75 -75
- package/dist-server/game-workflow/resource-catalog.mjs +16 -13
- package/dist-server/mcp/control-panel.html +2 -2
- package/dist-server/mcp/control-panel.mjs +59 -59
- package/dist-server/mcp/publication-page.html +85 -86
- package/dist-server/mcp/publication-page.mjs +346 -347
- package/dist-server/mcp/publication-preview.mjs +62 -48
- package/dist-server/mcp/publication-tools.mjs +22 -22
- package/dist-server/mcp/publish-panel.mjs +191 -191
- package/dist-server/mcp/server.mjs +312 -312
- package/dist-server/upstream/craft-aigc.mjs +182 -169
- package/dist-server/upstream/library-url.mjs +3 -5
- package/dist-server/upstream/publication-transport.mjs +81 -81
- package/dist-server/upstream/resource-path.mjs +17 -0
- package/package.json +2 -2
- package/resources/craft-game-maker/SKILL.md +71 -69
- package/resources/craft-game-maker/js.md +6 -5
- package/resources/craft-game-maker/js3d.md +6 -5
- package/resources/game_visual_qa.mjs +9 -3
- package/resources/js/context/.role/AGENTS_DESIGN.md +9 -0
- package/resources/js/context/AGENTS.md +112 -0
- package/resources/js/context/agents/aigc-asset.md +168 -0
- package/resources/js/context/hooks/hooks.json +14 -20
- package/resources/js/context/knowledge/AigcEnabled.md +49 -41
- package/resources/js/context/knowledge/AigcWiring.md +200 -200
- package/resources/js/context/knowledge/AssetUrl.md +24 -24
- package/resources/js/context/knowledge/FrontendComponents.md +17 -23
- package/resources/js/context/knowledge/Lifecycle.md +32 -27
- package/resources/js/context/knowledge/MobileAdaptation.md +73 -0
- package/resources/js/context/knowledge/MobileAdapted.md +36 -0
- package/resources/js/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -114
- package/resources/js/context/knowledge/Multiplayer/OverviewKnowledge.md +115 -115
- package/resources/js/context/knowledge/Multiplayer/StateSyncKnowledge.md +392 -392
- package/resources/js/context/knowledge/PlatformServices.md +190 -184
- package/resources/js/context/knowledge/ProjectDisplayConfig.md +35 -0
- package/resources/js/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -242
- package/resources/js/context/knowledge/Ui.md +11 -11
- package/resources/js/context/knowledge/UiEditorCompat.md +21 -21
- package/resources/js/context/rules/MultiplayerCapability.md +23 -23
- package/resources/js/context/rules/MultiplayerRoomEntryUX.md +63 -63
- package/resources/js/context/rules/PlatformBoundaryModules.md +44 -43
- package/resources/js/context/rules/preview_ready.md +8 -0
- package/resources/js/context/skills/aigc-generate/SKILL.md +149 -301
- package/resources/js/context/skills/aigc-generate/knowledge/audio.md +39 -39
- package/resources/js/context/skills/aigc-generate/knowledge/batch-replace.md +26 -14
- package/resources/js/context/skills/aigc-generate/knowledge/character2d.md +132 -129
- package/resources/js/context/skills/aigc-generate/knowledge/non-stepwise-aigc.md +53 -54
- package/resources/js/context/skills/aigc-generate/knowledge/texture-prop.md +52 -50
- package/resources/js/context/skills/aigc-generate/knowledge/texture-scene.md +191 -201
- package/resources/js/context/skills/aigc-generate/knowledge/texture-ui.md +55 -53
- package/resources/js/context/skills/asset-search/SKILL.md +69 -73
- package/resources/js/context/skills/asset-search/scripts/asset_display.mjs +62 -62
- package/resources/js/context/skills/asset-search/scripts/config.json +5 -5
- package/resources/js/context/skills/asset-search/scripts/provided_assets.mjs +125 -125
- package/resources/js/context/skills/asset-search/scripts/search.mjs +760 -749
- package/resources/js/context/skills/asset-search/scripts/sprite_source_materializer.mjs +657 -723
- package/resources/js/context/skills/asset-search/strategies/anim2d.md +42 -0
- package/resources/js/context/skills/asset-search/strategies/audio.md +34 -34
- package/resources/js/context/skills/asset-search/strategies/effect2d.md +31 -31
- package/resources/js/context/skills/asset-search/strategies/texture-prop.md +22 -22
- package/resources/js/context/skills/asset-search/strategies/ui-common.md +40 -40
- package/resources/js/context/skills/asset-search/strategies/ui-style.md +28 -28
- package/resources/js/context/skills/export-config/SKILL.md +28 -20
- package/resources/js/context/skills/export-config/assets/tooling/cli.mjs +20 -0
- package/resources/js/context/skills/{lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform → export-config/assets/tooling}/config.d.mts +19 -19
- package/resources/js/context/skills/{lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform → export-config/assets/tooling}/config.mjs +1 -1
- package/resources/js/context/skills/export-config/assets/tooling/project.d.mts +6 -0
- package/resources/js/context/skills/export-config/assets/tooling/project.mjs +77 -0
- package/resources/js/context/skills/export-config/assets/tooling/vite.d.mts +2 -0
- package/resources/js/context/skills/export-config/assets/tooling/vite.mjs +34 -0
- package/resources/js/context/skills/export-config/scripts/assert-asset-wiring.mjs +72 -72
- package/resources/js/context/skills/export-config/scripts/export-config.mjs +46 -43
- package/resources/js/context/skills/export-config/scripts/install.mjs +89 -0
- package/resources/js/context/skills/export-config/scripts/panel-resource-path.mjs +106 -106
- package/resources/js/context/skills/export-config/scripts/sync-asset-controls.mjs +352 -351
- package/resources/js/context/skills/export-config/scripts/translate-asset-titles.mjs +161 -163
- package/resources/js/context/skills/lightgame-runtime-adapt/SKILL.md +93 -92
- package/resources/js/context/skills/lightgame-runtime-adapt/project/game-runtime.json +7 -7
- package/resources/js/context/skills/lightgame-runtime-adapt/project/package.json +22 -22
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +208 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +37 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform-capture-video.mjs +227 -227
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform-service.d.mts +31 -25
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +272 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform.d.mts +79 -79
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform.mjs +29 -29
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/release.json +22 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/cli.mjs +16 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.d.mts +4 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.mjs +50 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +3 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.mjs +72 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/assets.d.mts +24 -24
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/assets.mjs +2 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/astc.d.mts +10 -10
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/astc.mjs +1 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/config-export.mjs +37 -32
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/refresh-runtime.mjs +50 -50
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/cli.mjs +20 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.d.mts +19 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/installed.json +6 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.d.mts +6 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.mjs +77 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.d.mts +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.mjs +34 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/ui-stage.ts +156 -121
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/viewport.ts +249 -254
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/main.ts +87 -99
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/platform.ts +2 -14
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/screenUi.ts +185 -172
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/style.css +294 -165
- package/resources/js/context/skills/lightgame-runtime-adapt/project/tsconfig.json +20 -20
- package/resources/js/context/skills/lightgame-runtime-adapt/project/vite.config.ts +5 -4
- package/resources/js/context/skills/lightgame-runtime-adapt/scripts/install-template.mjs +159 -109
- package/resources/js/context/skills/mobile-adaptation/SKILL.md +277 -260
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +50 -50
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +862 -881
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -92
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +254 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -245
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +135 -134
- package/resources/js/context/skills/mobile-adaptation/references/input-config.md +342 -311
- package/resources/js/context/skills/mobile-adaptation/references/verification.md +140 -106
- package/resources/js/context/skills/mobile-adaptation/references/web-audio.md +11 -0
- package/resources/js/context/skills/mobile-compat-qa/SKILL.md +53 -0
- package/resources/js/context/skills/mobile-compat-qa/references/startup-diagnosis.md +23 -0
- package/resources/js/context/skills/mobile-compat-qa/references/web-lifecycle.md +20 -0
- package/resources/js/context/skills/mobile-compat-qa/references/web-performance.md +19 -0
- package/resources/js/context/skills/optimization-suggestions/SKILL.md +89 -89
- package/resources/js/context/skills/platform-services/SKILL.md +101 -94
- package/resources/js/context/skills/platform-services/assets/modules/MultiplayerManager.ts +465 -783
- package/resources/js/context/skills/platform-services/assets/modules/eventBus.ts +57 -57
- package/resources/js/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js/context/skills/platform-services/assets/modules/identity/qq-session.mjs +208 -0
- package/resources/js/context/skills/platform-services/assets/modules/identity/shared.mjs +37 -0
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -39
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -1
- package/resources/js/context/skills/platform-services/assets/modules/log.ts +35 -35
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +61 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +52 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +30 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +89 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/types.ts +47 -0
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.d.mts +31 -25
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.mjs +272 -1
- package/resources/js/context/skills/platform-services/assets/modules/save.d.mts +49 -49
- package/resources/js/context/skills/platform-services/assets/modules/save.mjs +1 -1
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -7
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -264
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -39
- package/resources/js/context/skills/platform-services/references/SERVER_GUIDE.md +139 -139
- package/resources/js/context/skills/platform-services/references/api_reference.md +18 -18
- package/resources/js/context/skills/platform-services/references/leaderboard_playbook.md +96 -0
- package/resources/js/context/skills/platform-services/scripts/install.mjs +148 -134
- package/resources/js/context/skills/resolution-adaptation/SKILL.md +47 -202
- package/resources/js/context/skills/resolution-adaptation/assets/display/ui-stage.ts +156 -121
- package/resources/js/context/skills/resolution-adaptation/assets/display/viewport.ts +249 -254
- package/resources/js/context/skills/resolution-adaptation/assets/example/main.ts +98 -98
- package/resources/js/context/skills/resolution-adaptation/assets/example/ui-tokens.css +200 -200
- package/resources/js/context/skills/resolution-adaptation/references/audit.md +31 -0
- package/resources/js/context/skills/resolution-adaptation/references/device-safe-area.md +40 -0
- package/resources/js/context/skills/resolution-adaptation/references/game-ui-occlusion.md +18 -0
- package/resources/js/context/skills/resolution-adaptation/references/layout-rules.md +15 -134
- package/resources/js/context/skills/resolution-adaptation/references/troubleshooting.md +34 -0
- package/resources/js/context/skills/resolution-adaptation/references/viewport-api.md +38 -119
- package/resources/js/context/skills/resolution-adaptation/references/world-resize.md +55 -0
- package/resources/js/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +448 -338
- package/resources/js/context/skills/scene-editor-compat/SKILL.md +94 -94
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.assets.json +13 -13
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.scene-editor.json +6 -6
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/game/sceneAdapter.ts +25 -25
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/scenes/main.scene.json +18 -18
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/release.json +7 -7
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.d.mts +42 -42
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.mjs +144 -144
- package/resources/js/context/skills/scene-editor-compat/docs/contract.md +330 -330
- package/resources/js/context/skills/scene-editor-compat/docs/resource-sync.md +64 -64
- package/resources/js/context/skills/scene-editor-compat/docs/runtime-state.md +28 -28
- package/resources/js/context/skills/scene-editor-compat/docs/terrain-contract.md +47 -47
- package/resources/js/context/skills/scene-editor-compat/docs/visual-contract.md +64 -64
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.assets.json +38 -38
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.scene-editor.json +9 -9
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneAdapter.ts +59 -59
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneBlockers.ts +30 -30
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneFileAssets.ts +66 -66
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/Main.Scene.ts +20 -20
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/SceneTypes.ts +26 -26
- package/resources/js/context/skills/scene-editor-compat/references/contract.md +73 -73
- package/resources/js/context/skills/scene-editor-compat/scripts/apply_scene_marker.py +162 -162
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_contract.py +853 -853
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_resource_urls.py +173 -173
- package/resources/js/context/skills/scene-editor-compat/scripts/scene-editor.mjs +427 -427
- package/resources/js/context/skills/scene-editor-compat/version.json +1 -1
- package/resources/js/context/skills/ui-editor-compat/SKILL.md +48 -48
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -35
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +74 -74
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -60
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -45
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -265
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/release.json +7 -7
- package/resources/js/context/skills/ui-editor-compat/references/contract.md +132 -132
- package/resources/js/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -327
- package/resources/js/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -80
- package/resources/js/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -84
- package/resources/js/context/skills/version-update/SKILL.md +192 -192
- package/resources/js/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -129
- package/resources/js/context/skills/version-update/scripts/feature_snapshot.mjs +159 -159
- package/resources/js/context/skills/version-update/scripts/update_feature_version.mjs +157 -157
- package/resources/js/context/skills/visual-qa/SKILL.md +36 -36
- package/resources/js/context/version/version.json +1 -1
- package/resources/js/project/README.md +99 -99
- package/resources/js/project/SPEC/readme.md +6 -6
- package/resources/js/project/configs/assets.json +1 -1
- package/resources/js/project/configs/game.controls.json +3 -3
- package/resources/js/project/configs/game.json +3 -3
- package/resources/js/project/game-runtime.json +2 -2
- package/resources/js/project/{projectDisplayInfo.json → game.config.json} +7 -7
- package/resources/js/project/index.html +20 -20
- package/resources/js/project/package.json +23 -23
- package/resources/js/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +208 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +37 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform-service.d.mts +31 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +272 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform.d.mts +79 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform.mjs +29 -0
- package/resources/js/project/runtime/lightgame/1.1.0/release.json +22 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/cli.mjs +16 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/project.d.mts +4 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/project.mjs +50 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +3 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/vite.mjs +72 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/assets.d.mts +24 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/assets.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/astc.d.mts +10 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/astc.mjs +1 -0
- package/resources/js/project/scripts/config-export.mjs +37 -32
- package/resources/js/project/scripts/refresh-runtime.mjs +50 -50
- package/resources/js/project/scripts/skill-modules/export-config/cli.mjs +20 -0
- package/resources/js/project/scripts/skill-modules/export-config/config.d.mts +19 -0
- package/resources/js/project/scripts/skill-modules/export-config/config.mjs +1 -0
- package/resources/js/project/scripts/skill-modules/export-config/installed.json +6 -0
- package/resources/js/project/scripts/skill-modules/export-config/project.d.mts +6 -0
- package/resources/js/project/scripts/skill-modules/export-config/project.mjs +77 -0
- package/resources/js/project/scripts/skill-modules/export-config/vite.d.mts +2 -0
- package/resources/js/project/scripts/skill-modules/export-config/vite.mjs +34 -0
- package/resources/js/project/scripts/write-preview-ready.mjs +22 -0
- package/resources/js/project/src/display/ui-stage.ts +156 -121
- package/resources/js/project/src/display/viewport.ts +249 -254
- package/resources/js/project/src/main.ts +87 -99
- package/resources/js/project/src/platform.ts +2 -14
- package/resources/js/project/src/scenes/LoadScene.ts +89 -89
- package/resources/js/project/src/scenes/PlayScene.ts +17 -17
- package/resources/js/project/src/screenUi.ts +185 -172
- package/resources/js/project/src/style.css +294 -165
- package/resources/js/project/tsconfig.json +20 -20
- package/resources/js/project/unified_data_control_config.json +20 -20
- package/resources/js/project/vendor/core-manager-js/src/.versions.json +42 -42
- package/resources/js/project/vendor/core-manager-js/src/CoreManagerPlugin.ts +41 -41
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AssetRef.ts +93 -90
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcFirstImageFile.ts +203 -203
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcTextureLoader.ts +106 -106
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.test.ts +25 -25
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.ts +21 -21
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.test.ts +65 -65
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.ts +340 -340
- package/resources/js/project/vendor/core-manager-js/src/configManager/FeatureConfig.ts +87 -87
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.d.mts +92 -92
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.mjs +271 -271
- package/resources/js/project/vendor/core-manager-js/src/index.ts +31 -31
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputConfig.ts +81 -81
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.test.ts +43 -43
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.ts +32 -32
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.test.ts +141 -141
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.ts +20 -20
- package/resources/js/project/vendor/core-manager-js/src/inputManager/KeyboardProvider.ts +183 -183
- package/resources/js/project/vendor/core-manager-js/src/inputManager/TouchProvider.ts +304 -304
- package/resources/js/project/vendor/core-manager-js/src/inputManager/VirtualJoystick.ts +351 -351
- package/resources/js/project/vendor/core-manager-js/src/inputManager/_internal/InputManagerImpl.ts +180 -180
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64 +13 -13
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64.d.ts +14 -14
- package/resources/js/project/vendor/core-manager-js/src/inputManager/input_config.example.json +68 -68
- package/resources/js/project/vendor/core-manager-js/src/logManager/DebugConsole.ts +433 -433
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogCapture.ts +118 -118
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogManager.ts +444 -444
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCapture.ts +485 -485
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.test.ts +66 -66
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.ts +149 -149
- package/resources/js/project/vendor/core-manager-js/src/logManager/icons.b64 +9 -9
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/AssetUrlResolver.ts +29 -29
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.test.ts +88 -88
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.ts +122 -122
- package/resources/js/project/vendor/core-manager-js/src/runtime.ts +24 -24
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterEntity.ts +318 -318
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.test.ts +151 -151
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.ts +235 -235
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.test.ts +98 -98
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.ts +94 -94
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectEntity.ts +209 -209
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.test.ts +106 -106
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.ts +341 -341
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.test.ts +68 -68
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.ts +236 -236
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.test.ts +22 -22
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.ts +29 -29
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteEntity.test.ts +197 -197
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiContracts.ts +9 -9
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiKit.ts +555 -555
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.test.ts +112 -112
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.ts +178 -178
- package/resources/js/project/vendor/core-manager-js/src/uiManager/ui-base.css +246 -246
- package/resources/js/project/vendor/core-manager-js/src/videoManager/VideoManager.ts +139 -139
- package/resources/js/project/vendor/core-manager-js/tsconfig.json +15 -15
- package/resources/js/project/vendor/run.sh +4 -107
- package/resources/js/project/version/craft_feature_version.json +42 -42
- package/resources/js/project/version/project_feature_version.json +11 -11
- package/resources/js/project/vite.config.ts +5 -4
- package/resources/js3d/context/.role/AGENTS_DESIGN.md +9 -0
- package/resources/js3d/context/AGENTS.md +95 -0
- package/resources/js3d/context/hooks/hooks.json +14 -20
- package/resources/js3d/context/knowledge/3D/PoseInterpolationKnowledge.md +75 -87
- package/resources/js3d/context/knowledge/CodingGuide/Pitfalls.md +69 -69
- package/resources/js3d/context/knowledge/CodingGuide/SceneEditableGuide.md +42 -42
- package/resources/js3d/context/knowledge/FrontendComponents.md +19 -23
- package/resources/js3d/context/knowledge/MobileAdaptation.md +73 -0
- package/resources/js3d/context/knowledge/MobileAdapted.md +36 -0
- package/resources/js3d/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -114
- package/resources/js3d/context/knowledge/Multiplayer/OverviewKnowledge.md +117 -117
- package/resources/js3d/context/knowledge/Multiplayer/StateSyncKnowledge.md +430 -430
- package/resources/js3d/context/knowledge/PlatformServices.md +190 -162
- package/resources/js3d/context/knowledge/ProjectDisplayConfig.md +35 -0
- package/resources/js3d/context/knowledge/Runtime.md +34 -30
- package/resources/js3d/context/knowledge/SceneEditorCompat.md +35 -34
- package/resources/js3d/context/knowledge/StepByStep.md +21 -21
- package/resources/js3d/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -242
- package/resources/js3d/context/knowledge/UiEditorCompat.md +21 -21
- package/resources/js3d/context/rules/MultiplayerCapability.md +27 -27
- package/resources/js3d/context/rules/MultiplayerRoomEntryUX.md +63 -63
- package/resources/js3d/context/rules/PlatformBoundaryModules.md +44 -43
- package/resources/js3d/context/rules/preview_ready.md +8 -0
- package/resources/js3d/context/skills/aigc-integration/SKILL.md +172 -176
- package/resources/js3d/context/skills/aigc-integration/assets/sprite-sheet-player.mjs +70 -0
- package/resources/js3d/context/skills/aigc-integration/callback.md +77 -56
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/README.md +23 -22
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/audio-aigc-knowledge.md +38 -38
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/character2d-aigc-knowledge.md +72 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/staticmesh-aigc-knowledge.md +33 -33
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-prop-aigc-knowledge.md +36 -36
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-scene-aigc-knowledge.md +37 -37
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-ui-aigc-knowledge.md +35 -35
- package/resources/js3d/context/skills/asset-search/SKILL.md +178 -159
- package/resources/js3d/context/skills/asset-search/references/resource-config.md +99 -56
- package/resources/js3d/context/skills/asset-search/references/sprite-sheets.md +58 -0
- package/resources/js3d/context/skills/asset-search/scripts/asset_display.mjs +62 -62
- package/resources/js3d/context/skills/asset-search/scripts/config.json +235 -213
- package/resources/js3d/context/skills/asset-search/scripts/manifest_pipeline.mjs +905 -885
- package/resources/js3d/context/skills/asset-search/scripts/preflight.mjs +79 -79
- package/resources/js3d/context/skills/asset-search/scripts/provided_assets.mjs +74 -74
- package/resources/js3d/context/skills/asset-search/scripts/search.mjs +637 -597
- package/resources/js3d/context/skills/asset-search/scripts/sprite_source_materializer.mjs +667 -0
- package/resources/js3d/context/skills/asset-search/strategies/anim2d.md +42 -0
- package/resources/js3d/context/skills/asset-search/strategies/effect2d.md +31 -0
- package/resources/js3d/context/skills/asset-usage-audit/SKILL.md +92 -0
- package/resources/js3d/context/skills/asset-usage-audit/references/case-tidewater-zoo.md +89 -0
- package/resources/js3d/context/skills/asset-usage-audit/references/optimization-playbook.md +143 -0
- package/resources/js3d/context/skills/asset-usage-audit/references/usage-model.md +90 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/compare-animations.mjs +48 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/lib/anim.mjs +266 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/lib/glb.mjs +241 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/lib/scan.mjs +455 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/scan-assets.mjs +77 -0
- package/resources/js3d/context/skills/export-config/SKILL.md +20 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/cli.mjs +20 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/config.d.mts +19 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/config.mjs +1 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/project.d.mts +6 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/project.mjs +77 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/vite.d.mts +2 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/vite.mjs +34 -0
- package/resources/js3d/context/skills/export-config/scripts/assert-asset-wiring.mjs +97 -83
- package/resources/js3d/context/skills/export-config/scripts/export-config.mjs +56 -53
- package/resources/js3d/context/skills/export-config/scripts/install.mjs +89 -0
- package/resources/js3d/context/skills/export-config/scripts/panel-resource-path.mjs +106 -106
- package/resources/js3d/context/skills/export-config/scripts/sync-asset-controls.mjs +327 -325
- package/resources/js3d/context/skills/export-config/scripts/sync-scene-assets.mjs +216 -181
- package/resources/js3d/context/skills/export-config/scripts/translate-asset-titles.mjs +161 -163
- package/resources/js3d/context/skills/game-art-style/SKILL.md +60 -60
- package/resources/js3d/context/skills/game-art-style/references/art-parameters-lite.md +38 -38
- package/resources/js3d/context/skills/game-art-style/references/construction.md +111 -111
- package/resources/js3d/context/skills/game-art-style/references/materials-textures.md +105 -105
- package/resources/js3d/context/skills/game-art-style/references/sources.md +25 -25
- package/resources/js3d/context/skills/game-art-style/references/styles/cartoon.md +175 -175
- package/resources/js3d/context/skills/game-art-style/references/styles/comic.md +168 -168
- package/resources/js3d/context/skills/game-art-style/references/styles/cozy.md +191 -191
- package/resources/js3d/context/skills/game-art-style/references/styles/cyber.md +165 -165
- package/resources/js3d/context/skills/game-art-style/references/styles/horror.md +173 -173
- package/resources/js3d/context/skills/game-art-style/references/styles/lowpoly.md +185 -185
- package/resources/js3d/context/skills/game-art-style/references/styles/paper.md +181 -181
- package/resources/js3d/context/skills/game-art-style/references/styles/voxel.md +189 -189
- package/resources/js3d/context/skills/game-art-style/references/user-style-document.md +88 -88
- package/resources/js3d/context/skills/mobile-adaptation/SKILL.md +301 -284
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +104 -104
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +933 -952
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -92
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +254 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -245
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +257 -256
- package/resources/js3d/context/skills/mobile-adaptation/references/input-config.md +342 -311
- package/resources/js3d/context/skills/mobile-adaptation/references/verification.md +140 -106
- package/resources/js3d/context/skills/mobile-adaptation/references/web-audio.md +11 -0
- package/resources/js3d/context/skills/mobile-compat-qa/SKILL.md +53 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/startup-diagnosis.md +23 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-form-input.md +10 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-lifecycle.md +20 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-performance.md +19 -0
- package/resources/js3d/context/skills/optimization-suggestions/SKILL.md +74 -74
- package/resources/js3d/context/skills/performance-audit/SKILL.md +166 -0
- package/resources/js3d/context/skills/performance-audit/references/case-notes.md +93 -0
- package/resources/js3d/context/skills/performance-audit/references/rules.md +183 -0
- package/resources/js3d/context/skills/performance-audit/scripts/lib/rules.mjs +470 -0
- package/resources/js3d/context/skills/performance-audit/scripts/lib/scan.mjs +387 -0
- package/resources/js3d/context/skills/performance-audit/scripts/lib/source.mjs +398 -0
- package/resources/js3d/context/skills/performance-audit/scripts/scan-perf.mjs +130 -0
- package/resources/js3d/context/skills/platform-services/SKILL.md +101 -94
- package/resources/js3d/context/skills/platform-services/assets/modules/MultiplayerManager.ts +465 -783
- package/resources/js3d/context/skills/platform-services/assets/modules/eventBus.ts +57 -57
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-session.mjs +208 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/shared.mjs +37 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -39
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -1
- package/resources/js3d/context/skills/platform-services/assets/modules/log.ts +35 -35
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +61 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +52 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +30 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +89 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/types.ts +47 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.d.mts +31 -25
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.mjs +272 -1
- package/resources/js3d/context/skills/platform-services/assets/modules/save.d.mts +49 -49
- package/resources/js3d/context/skills/platform-services/assets/modules/save.mjs +1 -1
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -7
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -264
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -39
- package/resources/js3d/context/skills/platform-services/references/SERVER_GUIDE.md +139 -139
- package/resources/js3d/context/skills/platform-services/references/api_reference.md +18 -18
- package/resources/js3d/context/skills/platform-services/references/leaderboard_playbook.md +96 -0
- package/resources/js3d/context/skills/platform-services/scripts/install.mjs +148 -134
- package/resources/js3d/context/skills/resolution-adaptation/SKILL.md +46 -170
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/ui-stage.ts +156 -121
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/viewport.ts +239 -244
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/main.ts +129 -127
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/ui-tokens.css +188 -188
- package/resources/js3d/context/skills/resolution-adaptation/references/audit.md +31 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/device-safe-area.md +40 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/game-ui-occlusion.md +18 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/layout-rules.md +15 -124
- package/resources/js3d/context/skills/resolution-adaptation/references/troubleshooting.md +34 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/viewport-api.md +38 -117
- package/resources/js3d/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +448 -338
- package/resources/js3d/context/skills/scene-editor-compat/SKILL.md +599 -599
- package/resources/js3d/context/skills/scene-editor-compat/references/bundle-contract.md +141 -141
- package/resources/js3d/context/skills/scene-editor-compat/references/editor-integration.md +92 -92
- package/resources/js3d/context/skills/scene-editor-compat/references/scene-data-format.md +125 -125
- package/resources/js3d/context/skills/scene-editor-compat/references/slots-rules.md +113 -113
- package/resources/js3d/context/skills/scene-editor-compat/scripts/scene-editor.mjs +1187 -1187
- package/resources/js3d/context/skills/threejs-game-quality/SKILL.md +53 -52
- package/resources/js3d/context/skills/threejs-game-quality/agents/openai.yaml +4 -4
- package/resources/js3d/context/skills/threejs-game-quality/references/01-build.md +94 -94
- package/resources/js3d/context/skills/threejs-game-quality/references/02-avoid.md +50 -50
- package/resources/js3d/context/skills/threejs-game-quality/references/03-detect.md +105 -105
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-by-genre.md +147 -147
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-distance.md +79 -79
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-sources.md +56 -56
- package/resources/js3d/context/skills/threejs-game-quality/references/character-motion-face.md +51 -51
- package/resources/js3d/context/skills/threejs-game-quality/references/parameter-contract.md +55 -55
- package/resources/js3d/context/skills/threejs-game-quality/references/refine-existing.md +78 -78
- package/resources/js3d/context/skills/threejs-game-quality/references/rendering-stability.md +84 -84
- package/resources/js3d/context/skills/threejs-game-quality/references/runtime-tools.md +117 -117
- package/resources/js3d/context/skills/threejs-game-quality/scripts/package.json +4 -4
- package/resources/js3d/context/skills/threejs-game-quality/scripts/runtime-audit.js +238 -238
- package/resources/js3d/context/skills/ui-editor-compat/SKILL.md +59 -59
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -35
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +61 -61
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -60
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -45
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -265
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/release.json +7 -7
- package/resources/js3d/context/skills/ui-editor-compat/references/contract.md +110 -110
- package/resources/js3d/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -327
- package/resources/js3d/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -80
- package/resources/js3d/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -84
- package/resources/js3d/context/skills/version-update/SKILL.md +191 -191
- package/resources/js3d/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -129
- package/resources/js3d/context/skills/version-update/scripts/feature_snapshot.mjs +159 -159
- package/resources/js3d/context/skills/version-update/scripts/update_feature_version.mjs +157 -157
- package/resources/js3d/context/version/version.json +1 -1
- package/resources/js3d/project/README.md +106 -100
- package/resources/js3d/project/configs/game.controls.json +3 -3
- package/resources/js3d/project/configs/game.json +3 -3
- package/resources/js3d/project/game-runtime.json +2 -2
- package/resources/js3d/project/{projectDisplayInfo.json → game.config.json} +7 -7
- package/resources/js3d/project/index.html +12 -12
- package/resources/js3d/project/package.json +24 -24
- package/resources/js3d/project/runtime/lightgame/1.0.0/release.json +2 -2
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.d.mts +2 -12
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.mjs +21 -29
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +208 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +37 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform-service.d.mts +31 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +272 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform.d.mts +79 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform.mjs +30 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/release.json +24 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/cli.mjs +16 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/project.d.mts +4 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/project.mjs +50 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +3 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/vite.mjs +72 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/assets.d.mts +24 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/assets.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/astc.d.mts +10 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/astc.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/glb.d.mts +26 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/glb.mjs +351 -0
- package/resources/js3d/project/scripts/config-export.mjs +37 -32
- package/resources/js3d/project/scripts/refresh-runtime.mjs +50 -50
- package/resources/js3d/project/scripts/skill-modules/export-config/cli.mjs +20 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/config.d.mts +19 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/config.mjs +1 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/installed.json +6 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/project.d.mts +6 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/project.mjs +77 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/vite.d.mts +2 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/vite.mjs +34 -0
- package/resources/js3d/project/scripts/write-preview-ready.mjs +22 -0
- package/resources/js3d/project/src/display/ui-stage.ts +156 -121
- package/resources/js3d/project/src/display/viewport.ts +239 -244
- package/resources/js3d/project/src/main.ts +85 -83
- package/resources/js3d/project/src/platform.ts +2 -14
- package/resources/js3d/project/src/style.css +83 -17
- package/resources/js3d/project/tsconfig.json +20 -20
- package/resources/js3d/project/unified_data_control_config.json +20 -20
- package/resources/js3d/project/vendor/core-manager-three/package.json +12 -12
- package/resources/js3d/project/vendor/core-manager-three/src/index.ts +2 -2
- package/resources/js3d/project/vendor/run.sh +4 -4
- package/resources/js3d/project/version/craft_feature_version.json +42 -42
- package/resources/js3d/project/version/project_feature_version.json +11 -11
- package/resources/js3d/project/vite.config.ts +5 -4
- package/vendor/agent-cli/dist/runtime-tools/ue/blender-cook-assets.cjs +19 -19
- package/vendor/agent-cli/dist/runtime-tools/ue/tool-manifest.json +1 -1
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts +1 -1
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js +15 -6
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/native-source.d.ts +3 -0
- package/vendor/agent-cli/dist/src/artifacts/native-source.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/native-source.js +13 -0
- package/vendor/agent-cli/dist/src/artifacts/native-source.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.d.ts +13 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js +300 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts +4 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/prepare.js +20 -7
- package/vendor/agent-cli/dist/src/artifacts/prepare.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts +8 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js +59 -37
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.d.ts +27 -0
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.js +112 -0
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts +9 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/restore.js +137 -57
- package/vendor/agent-cli/dist/src/artifacts/restore.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts +6 -2
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/static.js +100 -28
- package/vendor/agent-cli/dist/src/artifacts/static.js.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-protocol.js +6 -3
- package/vendor/agent-cli/dist/src/cli/process-protocol.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/browser-queue.d.ts +55 -0
- package/vendor/agent-cli/dist/src/component/browser-queue.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/browser-queue.js +63 -0
- package/vendor/agent-cli/dist/src/component/browser-queue.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts +4 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/component/execution.js +16 -4
- package/vendor/agent-cli/dist/src/component/execution.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/isolated-launcher.d.ts +2 -0
- package/vendor/agent-cli/dist/src/component/isolated-launcher.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/isolated-launcher.js +76 -0
- package/vendor/agent-cli/dist/src/component/isolated-launcher.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.d.ts +2 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.js +27 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts +0 -5
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/component/platform-access/server.js +9 -3
- package/vendor/agent-cli/dist/src/component/platform-access/server.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js +5 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/process-diagnostics.d.ts +25 -0
- package/vendor/agent-cli/dist/src/component/process-diagnostics.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/process-diagnostics.js +137 -0
- package/vendor/agent-cli/dist/src/component/process-diagnostics.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.d.ts +10 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.js +59 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.d.ts +2 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.js +46 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/public-egress.d.ts +17 -0
- package/vendor/agent-cli/dist/src/component/public-egress.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/public-egress.js +246 -0
- package/vendor/agent-cli/dist/src/component/public-egress.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.js +68 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts +1 -1
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/cache-publication.js +8 -4
- package/vendor/agent-cli/dist/src/context/cache-publication.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-cache.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-cache.js +5 -2
- package/vendor/agent-cli/dist/src/context/context-cache.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-project.d.ts +45 -4
- package/vendor/agent-cli/dist/src/context/context-project.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-project.js +157 -16
- package/vendor/agent-cli/dist/src/context/context-project.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-scoped-source.d.ts +13 -0
- package/vendor/agent-cli/dist/src/context/context-scoped-source.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-scoped-source.js +78 -0
- package/vendor/agent-cli/dist/src/context/context-scoped-source.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts +14 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js +110 -44
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts +2 -0
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/local-skills.js +36 -19
- package/vendor/agent-cli/dist/src/context/local-skills.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/member-context.d.ts +2 -1
- package/vendor/agent-cli/dist/src/context/member-context.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/member-context.js +17 -9
- package/vendor/agent-cli/dist/src/context/member-context.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts +9 -1
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/script-dependencies.js +22 -6
- package/vendor/agent-cli/dist/src/context/script-dependencies.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts +1 -1
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js +1 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/team-knowledge.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/team-knowledge.js +11 -2
- package/vendor/agent-cli/dist/src/context/team-knowledge.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-cache.js +2 -2
- package/vendor/agent-cli/dist/src/context/template-cache.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-seed.js +50 -16
- package/vendor/agent-cli/dist/src/context/template-seed.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts +3 -1
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/user-skill-context.js +41 -2
- package/vendor/agent-cli/dist/src/context/user-skill-context.js.map +1 -1
- package/vendor/agent-cli/dist/src/index.d.ts +4 -1
- package/vendor/agent-cli/dist/src/index.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/index.js +4 -1
- package/vendor/agent-cli/dist/src/index.js.map +1 -1
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.d.ts +2 -2
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js +4 -2
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js.map +1 -1
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js +1 -1
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts +24 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js +6 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts +71 -4
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js +13 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/command-translate.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/command-translate.js +4 -0
- package/vendor/agent-cli/dist/src/security/command-translate.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/guard.d.ts +4 -0
- package/vendor/agent-cli/dist/src/security/guard.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/guard.js +17 -5
- package/vendor/agent-cli/dist/src/security/guard.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts +11 -2
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/mount-table.js +92 -5
- package/vendor/agent-cli/dist/src/security/mount-table.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts +4 -1
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/tool-scope.js +38 -4
- package/vendor/agent-cli/dist/src/security/tool-scope.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/client.d.ts +20 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/client.js +26 -4
- package/vendor/agent-cli/dist/src/session/client.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/custom-context.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/custom-context.js +12 -6
- package/vendor/agent-cli/dist/src/session/custom-context.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/execution-recovery.d.ts +9 -0
- package/vendor/agent-cli/dist/src/session/execution-recovery.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/execution-recovery.js +49 -0
- package/vendor/agent-cli/dist/src/session/execution-recovery.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.js +20 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-config.js +1 -1
- package/vendor/agent-cli/dist/src/session/link-config.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/link-session.d.ts +1 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/link-session.js +19 -2
- package/vendor/agent-cli/dist/src/session/link-session.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-lifecycle.d.ts +5 -0
- package/vendor/agent-cli/dist/src/session/process-lifecycle.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-lifecycle.js +18 -0
- package/vendor/agent-cli/dist/src/session/process-lifecycle.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-observability.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/process-observability.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-observability.js +14 -0
- package/vendor/agent-cli/dist/src/session/process-observability.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-request.d.ts +6 -6
- package/vendor/agent-cli/dist/src/session/process-request.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-request.js +55 -60
- package/vendor/agent-cli/dist/src/session/process-request.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-restore.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/process-restore.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-restore.js +21 -0
- package/vendor/agent-cli/dist/src/session/process-restore.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.d.ts +3 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.js +21 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/reference-tools.js +3 -2
- package/vendor/agent-cli/dist/src/session/reference-tools.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-setup.js +33 -14
- package/vendor/agent-cli/dist/src/session/run-setup.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts +5 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.js +13 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/team-persistence.js +1 -1
- package/vendor/agent-cli/dist/src/session/team-persistence.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/tool-scheduler.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js +32 -23
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.js +25 -0
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js +2 -1
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.js +15 -0
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts +50 -3
- package/vendor/agent-cli/dist/src/shared/types.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts +3 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/command-executor.js +42 -5
- package/vendor/agent-cli/dist/src/tools/command-executor.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/context-program.js +46 -20
- package/vendor/agent-cli/dist/src/tools/context-program.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts +10 -19
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/file-ops.js +11 -85
- package/vendor/agent-cli/dist/src/tools/file-ops.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/file-search.d.ts +29 -0
- package/vendor/agent-cli/dist/src/tools/file-search.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-search.js +98 -0
- package/vendor/agent-cli/dist/src/tools/file-search.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.d.ts +9 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.js +29 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/local-hands.js +10 -2
- package/vendor/agent-cli/dist/src/tools/local-hands.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts +3 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js +3 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js.map +1 -1
- package/resources/js/context/CLAUDE.md +0 -54
- package/resources/js/context/agents/aigc-manager.md +0 -91
- package/resources/js/context/knowledge/GameProbe.md +0 -74
- package/resources/js/context/skills/aigc-generate/scripts/apply-results.mjs +0 -83
- package/resources/js/context/skills/aigc-generate/scripts/config.json +0 -29
- package/resources/js/context/skills/aigc-generate/scripts/generate.mjs +0 -1016
- package/resources/js/context/skills/aigc-generate/scripts/lib/client.mjs +0 -228
- package/resources/js/context/skills/aigc-generate/scripts/lib/ledger.mjs +0 -119
- package/resources/js/context/skills/aigc-generate/scripts/lib/nstep-handoff.mjs +0 -100
- package/resources/js/context/skills/aigc-generate/scripts/lib/pipelines.mjs +0 -441
- package/resources/js/context/skills/aigc-generate/scripts/lib/queue.mjs +0 -283
- package/resources/js/context/skills/aigc-generate/scripts/lib/submit.mjs +0 -122
- package/resources/js/context/skills/aigc-generate/scripts/worker.mjs +0 -171
- package/resources/js/context/skills/asset-search/scripts/recalled_sprite_paths.mjs +0 -47
- package/resources/js/context/skills/asset-search/strategies/character2d.md +0 -33
- package/resources/js/context/skills/asset-search/strategies/texture-ui.md +0 -35
- package/resources/js/context/skills/display-info-setup/SKILL.md +0 -32
- package/resources/js/context/skills/display-info-setup/scripts/init_project.mjs +0 -38
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +0 -39
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.d.mts +0 -49
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/release.json +0 -37
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/cli.mjs +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.d.mts +0 -8
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.mjs +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +0 -3
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.mjs +0 -8
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.d.mts +0 -20
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +0 -21
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.d.mts +0 -17
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.d.mts +0 -40
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.d.mts +0 -10
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.d.mts +0 -8
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.mjs +0 -1
- package/resources/js/context/skills/platform-services/assets/release.json +0 -44
- package/resources/js/project/.gitattributes +0 -2
- package/resources/js/project/gameplay-probe.json +0 -37
- package/resources/js/project/package-lock.json +0 -1155
- package/resources/js3d/context/CLAUDE.md +0 -50
- package/resources/js3d/context/skills/aigc-integration/scripts/config.json +0 -3
- package/resources/js3d/context/skills/aigc-integration/scripts/lib/submit.mjs +0 -344
- package/resources/js3d/context/skills/aigc-integration/scripts/query-music.mjs +0 -53
- package/resources/js3d/context/skills/aigc-integration/scripts/query-results.mjs +0 -53
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-cover.mjs +0 -44
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-image.mjs +0 -48
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-music.mjs +0 -34
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-staticmesh.mjs +0 -39
- package/resources/js3d/context/skills/platform-services/assets/release.json +0 -44
- package/resources/js3d/project/.gitattributes +0 -2
- package/resources/js3d/project/gameplay-probe.json +0 -38
- package/resources/js3d/project/package-lock.json +0 -1204
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.test.mjs +0 -25
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
# ds/ 目录规则(Agent 必读)
|
|
2
|
-
|
|
3
|
-
平台 DS 进程的代码。目录名 `ds` 与入口 `ds/main.mjs` 由平台规定,**不可改**。
|
|
4
|
-
|
|
5
|
-
版本快照与客户端同包上传,但 DS 壳(`js-ds-shell`)**只物化并执行 `ds/` 前缀下的文件**:`src/`、根 `package.json`、`configs/` 都不会出现在 DS 进程里。两端不能共享模块,需要的常量各写一份。
|
|
6
|
-
|
|
7
|
-
**玩法逻辑由你写。** 本文只描述壳与平台的行为契约——哪些写法会让进程起不来、哪些是硬上限、哪些 Colyseus 机制在这里失效。房间内怎么玩、状态怎么设计、谁权威,都不在这里规定。
|
|
8
|
-
|
|
9
|
-
## 运行模型(先理解这三条,下面的约束都是它的推论)
|
|
10
|
-
|
|
11
|
-
**一个平台房 = 一个 DS 进程。** 玩家在大厅 `create` 时平台拉起一个进程(所以刚开房的头一两秒可能还没 listen,客户端要重试),`DSAgentPipe.end()` 或心跳超时时整个进程被 Kill、房记录被删、房号失效。进程里只跑这一局,所以模块级变量天然是"本局独占"的,不需要按房隔离——但这个前提是 `maxClients` 配对了,否则同进程会出现第二间房来共享它们。
|
|
12
|
-
|
|
13
|
-
**撮合分两层,`room_id` 和房间名不是一回事。** 平台 Room HTTP 决定"进哪个进程"(返回 `room_id` + `connect`),Colyseus 只负责"进这个进程里的那一间房"(`joinOrCreate(<房间名>)`)。`room_id` **不会**传给 Colyseus,客户端那句 `joinOrCreate("sync")` 写的是本目录 `main.mjs` 导出的 key,不是房号——看着像 bug,其实是分层。另外 Colyseus 自己也有个 `room.roomId`(进程内房 id),与平台 `room_id` 同名不同物,打日志时别混。
|
|
14
|
-
|
|
15
|
-
**Colyseus 用来自治的机制,在这里只在进程内生效,平台看不见。** `autoDispose` 只析构进程内对象、`matchmaker` 只看得见自己进程、`allowReconnection` 只挂起自己的 `onLeave`——它们都不知道平台的房记录和进程。所以回收走 `DSAgentPipe.end()`、撮合走 Room HTTP、人数走 `setSessionsProvider`。**从 Colyseus 官方文档抄来的自治写法,先确认它要管的那件事是不是已经归平台管了。**
|
|
16
|
-
|
|
17
|
-
分工上:DS 进程 = 壳 + 你的 `ds/`。壳装好依赖、注入 `DSAgentPipe`(`main.mjs` 被 import 时已可用)、`gameServer.define()` 每个导出的房间并 `listen`。你只写 Room 类。
|
|
18
|
-
|
|
19
|
-
## 硬约束(违反 = 进程起不来 / 静默失败)
|
|
20
|
-
|
|
21
|
-
- **入口**:`ds/main.mjs` 必须 `export const rooms = { <房间名>: RoomClass }`;key 与客户端 `joinOrCreate(<房间名>)` 一致。缺入口时 DS 直接启动失败(`snapshot missing entry ds/main.mjs`);值必须是**类本身**,写成 `new SyncRoom()` 这样的实例会 `room <name> is not a constructor` 然后 exit(1)。
|
|
22
|
-
- **ESM only**:`ds/` 下一律 `.mjs`,禁止 CJS(`require`)。Node 运行时 ≥ 22。
|
|
23
|
-
- **没有依赖安装环节**:壳把自己的 `node_modules` 软链到工作目录根,所以 `ds/` 里直接 `import { Room } from "@colyseus/core"` / `import { Schema } from "@colyseus/schema"` 能解析。写 `ds/package.json` 声明依赖**不会被安装**(快照只被物化,全程不跑 `npm install`),任何第三方包都 import 失败——玩法要的算法只能用标准库自己实现。
|
|
24
|
-
- **不自己起服务**:禁止 `new Server()` / `listen()` / 选端口。端口由平台在 27000–27999 动态分配,壳已 `listen`。
|
|
25
|
-
- **没有可信身份**:壳不校验 token,也不把平台票传给 DS,所以 `onAuth` 里没有任何可信凭据可验(写了也只是在验客户端自报的东西)。准入由 Room HTTP(经网关鉴权)保证,因此**禁止**信任客户端自报的 `uid` 做权限判断——它只用于向平台上报在场名单。
|
|
26
|
-
- **入站单包 ≤ 4KB(只卡入站,出站不受此限)**:4KB = `@colyseus/ws-transport@0.17.13` 构造函数默认 `maxPayload = 4 * 1024`,且默认 `perMessageDeflate = false`(无压缩兜底);平台壳 `new WebSocketTransport({ server })` 未覆盖该项——**所以这不是平台的业务决策,是库默认值**(出处:`backend/game/js-ds-shell/src/runtime.mjs` + `@colyseus/ws-transport` build/WebSocketTransport.mjs)。这是 **DS 作为接收方**收下客户端消息的上限,超限时连接以 code 1009 被断开、`onMessage` 根本不会执行。有效检查在**客户端发送前**,且要按**字节**算(`TextEncoder`),不是 `String.length`。**反向的出站(DS → 客户端,`client.send` / `broadcast`)没有对应的 4KB 上限**——浏览器端不设等价接收限制,下行大包不会触发 1009。**不要把入站的这个 4KB 体积检查套到 DS 的下行发送上**(如在 `client.send` 前写 `if (over) return`):那会把本该送达的下行包静默丢掉,且毫无日志痕迹,是极难排查的一类 bug。onJoin 补全整局面、把某份大内容定向下发等场景下行本就会偏大,属正常;但下行大包只在这类**一次性时机**发,不要在每帧/定时路径整包广播(会队头阻塞,见客户端 `StateSyncKnowledge.md`「频率与包体」)。**注意区分**:上面这条「下行大包别高频」针对的是**手动 `broadcast` 全量**;state 根字段走 Colyseus **patch 通道**(自带同窗口合并,一个 patch 窗口内写多次只发一次),性质不同、不受那条约束——**不要拿"下行别高频整包"去否决合法的根字段写入**。
|
|
27
|
-
- **`maxClients` === 平台 `max_players` === 玩法人数**(平台侧取值 1–64,越界按 8):小于则 `joinOrCreate` 会在同一进程里再开一间房,两拨人互相看不见,且进程级 `DSAgentPipe` 的 `setSessionsProvider` 被后一间房覆盖。大于则大厅人数口径与玩法不一致。
|
|
28
|
-
- **`ds/main.mjs` 只 export 实际使用的 Room 类**,禁止留下未注册的模板 `SyncRoom`。
|
|
29
|
-
- **席位按 uid 认领时,`onJoin` 必须把 `parseJoinUid(options)` 写入该席位**。只放进 `_uidBySession` 不够:占座 uid 对不上连接 uid 时,平台人数 = 连接 + 未对齐占座,双人房会显示 2/2。
|
|
30
|
-
- **空房必须自己收尾**:`onLeave` 里人数归零 → `broadcast("room_closed")` → `DSAgentPipe.end("empty")`。只靠平台心跳超时(默认 15s)强杀是异常路径,不是正常路径。
|
|
31
|
-
- **`MapSchema` / `ArraySchema` 只能用方法访问**:`.set()` / `.get()` / `.has()` / `.delete()` / `.forEach()` / `.size`。下标(`m[k] = v`、`m[k]`、`delete m[k]`)在 `@colyseus/schema@4.0.30` 下**静默失效** —— Proxy 已于 2.0 移除,下标只会在实例上挂一个普通 JS 属性:**读得回来**(所以按 key 取的代码看着完全正常),但 `.size` 恒为 0、`.get(k)` 恒 `undefined`、**用下标写入的条目完全不进编码,客户端永远收不到**。`Object.entries()` / `Object.keys()` 同样无效,返回的是 `~refId` / `childType` / `$items` / `$indexes` / `deletedItems` 五个内部字段。**最危险的形态是同一文件里下标与方法混用**:按 key 取的路径正常、遍历与计数的路径全空,表现为「能连上、能同步一部分」,是本平台上最难定位的一类故障。注意区分:**用 `.set()` 正确填充的 MapSchema,`.forEach()` / `for...of` 迭代、`.size` 都是正常的**,不要因为它"看起来像普通 Map"就以为下标也能用;`JSON.stringify(mapSchema)` 也是正常的(会输出条目)。`onCreate` 里对容器**必须用 `new MapSchema()` / `new ArraySchema()`** 初始化,不能赋 `{}` / `[]` —— 普通对象 / 数组当不了 Colyseus 容器根字段。
|
|
32
|
-
- **不要用 `allowReconnection`**:Colyseus 官方教程里的这个写法在本平台上会打架——它让 `onLeave` 挂起、`players` 不减,于是空房永远不 `end`,同时在场名单里那个已断线的人还占着 `player_count`。断线重连在本平台是 HTTP 层的事:客户端重 `join`(对同一账号幂等)拿回原座位,那是一条**新的 Colyseus 连接**,`sessionId` 会变。
|
|
33
|
-
- **`DSAgentPipe` 是唯一上报通道**:`setSessionsProvider(fn)` 注册在场名单、`hb()` 在人数变化时补心跳、`end(reason)` 声明本局结束;`onDispose` 里 `setSessionsProvider(null)` 解绑。**不注册 provider 的后果**:心跳不带在场名单,平台只能回退按 HTTP 座位数算人数,DS 里的真实连接数不被采信。全部用 `?.` 保护:经壳启动时它一定存在(没有管道 fd 时壳装的是 no-op 桩,`end()` 只打日志),但直接 `node ds/main.mjs` 裸跑时没有。
|
|
34
|
-
- **骨架里的 `normalizePayload()` / `encodeData()` / `parseJoinUid()` / `requestClose()` 是两端契约与平台协议的载体,不是示例代码**:前三者分别锁定 pub 载荷形状(`{ type, data: 字符串 }`,业务字段在 `data` 里、不在顶层)、`state.set` 的字符串化、以及平台在场名单要求的 **uint32** `uid`;`requestClose()` 锁定空房收尾的**时序契约**——它先 `broadcast("room_closed", { reason })` 再**延迟 200ms** 才 `DSAgentPipe.end()`,这 200ms 是留给客户端收到 `room_closed` 的窗口。客户端模板(`multiplayerManager`)监听的正是 `room_closed` 这个消息名;**把延迟当冗余删掉、或改掉消息名,客户端就只拿到一个没有关闭码的空 `onError`**,玩家不知道为什么被踢。重写 Room 时这四个函数**连定义带调用一起照搬**,别当占位删掉或内联简化——历史上删 `parseJoinUid` 导致 `uid` 变字符串、平台解在场名单失败 15s 强杀,绕过 `normalizePayload` 直读 `payload.id` 导致伤害裁决 `NaN` 静默失效,删 `requestClose` 方法体只留调用点导致 `onLeave` 空房收尾抛 `TypeError`、后面的 `DSAgentPipe.end()` 永不执行、空房收不了尾,三次都零报错。
|
|
35
|
-
- **结构性规则(枚举永远会漏,认这条)**:骨架里凡是 `this.xxx()` 调用到、而 Colyseus `Room` 基类上找不到的方法,都是骨架自定义的**契约载体**(`requestClose` 就是其一,`Room` 上没有它)。重写时**要么连定义一起照搬,要么连调用点一起删**;只留调用点会在运行时抛 `TypeError`,而它往往埋在 `onLeave` / 空房收尾这类**不常走的分支**里——正常游玩测不到,一到真正散场才炸,且后面的 `DSAgentPipe.end()` 就永远执行不到,两端零报错。
|
|
36
|
-
|
|
37
|
-
## 与客户端的接口对应
|
|
38
|
-
|
|
39
|
-
房间名、消息名、state 形状、`from` 的含义都是**你和客户端之间的约定**,平台不认识这些名字,改的唯一要求是两端一致。骨架选了 `state.set` / `pub` / `evt` / `room_closed` 这组名字。
|
|
40
|
-
|
|
41
|
-
客户端模板(`multiplayerManager`)只提供三个收口,DS 侧数据放哪决定了客户端能不能收到:
|
|
42
|
-
|
|
43
|
-
| DS 侧 | 客户端收口 |
|
|
44
|
-
|---|---|
|
|
45
|
-
| `players[sessionId].data`(字符串) | `bus.on('mp-peer-pose', (sid, pose) => ...)` |
|
|
46
|
-
| state **根字段** | `MultiplayerManager.onStateField(field, cb)`,字段已有值时立即回调一次 |
|
|
47
|
-
| `broadcast("evt", ...)` 或 `client.send("evt", ...)` 定向发 | `MultiplayerManager.onEvent((from, type, data) => ...)` |
|
|
48
|
-
|
|
49
|
-
模板在 player 上只监听 `data` 这一个字段;要用 player 级的其它真 schema 字段,得同时在客户端 `src/skill-modules/platform-services/MultiplayerManager.ts` 的 `_attachRoom()` 里、`players.onAdd` 回调中补 `$(player).listen('<字段>', ...)`,经 `bus.emit` 交给业务。
|
|
50
|
-
|
|
51
|
-
**反方向(客户端 → DS)上行只有两个消息名**,两者的 `data` **在线上都是 JSON 字符串**(客户端模板发送前已 `JSON.stringify`):
|
|
52
|
-
|
|
53
|
-
| 客户端调用 | 线上形状 | DS 侧读法 |
|
|
54
|
-
|---|---|---|
|
|
55
|
-
| `sendPose(obj)` | `state.set` → `{ data: "<JSON 字符串>" }` | `payload.data` 原样存进 `players[sid].data`,**不要解析** |
|
|
56
|
-
| `sendEvent(type, obj)` | `pub` → `{ type, data: "<JSON 字符串>" }` | 用 `payload.type` 分流;业务字段必须 `JSON.parse(payload.data \|\| "{}")` 之后再取,**不在 `payload` 顶层** |
|
|
57
|
-
|
|
58
|
-
直读 `payload.<业务字段>`(如 `payload.id` / `payload.hp`)恒为 `undefined`,经 `Number()` 变 `NaN` 后被校验分支静默丢弃——两端都不 throw,`.mjs` 无类型也检不出,是本平台最难定位的一类故障。历史上就因为绕过归一化直读 `payload.id` 做伤害裁决,导致裁决静默失效、谁都没报错。
|
|
59
|
-
|
|
60
|
-
**方向不对称,别写反**:这条「data 是字符串、要先 parse」只约束**上行**。下行(DS → 客户端)客户端 `_parse` 对对象宽容(`broadcast("evt", { type, data: <对象> })` 直接可用),**不要**给下行也加「必须 stringify」的约束。
|
|
61
|
-
|
|
62
|
-
**权威快照带服务端时间戳 `t`(两端契约的一部分,做本地模拟纠偏时必须)**:连续运动玩法若客户端要跑「本地权威同款模拟 + 快照纠偏」(收端形态 C,见客户端 StateSyncKnowledge),**DS 写快照时必须带上写入那一刻的服务端单调时钟** `t`(`Date.now()` ms)——放进 `players[sid].data` 或对应根字段里随快照一起下发。客户端拿 `t` 算快照年龄 `age = getServerNow() − snap.t`,把旧快照外推到当前时刻再纠偏;没有 `t`,客户端只能拿「到达时刻」当基准,等于把单向网络延迟当 0,纠偏必飘。配套的时钟标定回程(客户端 ping → DS 回 pong 带 `st`)已在骨架 `SyncRoom.mjs` 的 `_onPing` 里,走 pub 契约同一条路,不需另开通道。**纯回合 / 棋牌玩法不做形态 C,可以不带 `t`**——这条只对「客户端本地模拟纠偏」的玩法是硬契约。
|
|
63
|
-
|
|
64
|
-
**三条路怎么选**(选错是"能连上、但状态对不齐"的头号成因):
|
|
65
|
-
|
|
66
|
-
> **state 根字段有两种形态,客户端收口完全不同,先分清再选**:
|
|
67
|
-
|
|
68
|
-
| 根字段形态 | 客户端收口 | 说明 |
|
|
69
|
-
|---|---|---|
|
|
70
|
-
| **标量**(string / number / boolean) | 现成 `onStateField(field, cb)`,**握手自带当前值**,后进房/重连即得 | `phase` / `readySids` / `seats:"string"`(JSON 字符串)都走这个 |
|
|
71
|
-
| **容器**(MapSchema / ArraySchema) | **收不到条目增删与嵌套字段变化** | 底层 `onStateField` 是 `$(room.state).listen(field)`,只在**引用被整体替换**时触发,对 map 字段看不到条目增删、更看不到嵌套字段变化 |
|
|
72
|
-
|
|
73
|
-
容器形态若确有必要(整表 ≥ 几 KB 或条目上百),必须【同时】给出客户端扩订阅写法,否则读者只能像本次一样自己发明一套 `evt` 增量广播来绕:
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
// 客户端:加在 src/skill-modules/platform-services/MultiplayerManager.ts 的 _attachRoom() 里、players.onAdd 旁边。
|
|
77
|
-
// 该函数里已有 $,连上与重连都会执行;onStateField 收不到容器的嵌套变化。业务用 bus.on 订阅这些事件。
|
|
78
|
-
$(room.state).seats.onAdd((seat, playerId) => {
|
|
79
|
-
bus.emit("mp-seat-add", playerId, seat);
|
|
80
|
-
$(seat).listen("hp", (v) => bus.emit("mp-seat-hp", playerId, v)); // 字段级增量
|
|
81
|
-
});
|
|
82
|
-
$(room.state).seats.onRemove((_s, playerId) => bus.emit("mp-seat-remove", playerId));
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
**选型判据按【三问】顺序**,不要写成「高频用 map、低频用字符串」(频率已被 patchRate 抹平):
|
|
86
|
-
|
|
87
|
-
> 第 1 问 · **owner 是谁?** DS 裁决的 → 根字段(高低频都一样)。玩家自报的连续态 → `players[sid].data`。这一问**优先于**体积和频率:`players[sid].data` 是客户端上报通道(DS 只存不改),且**不回推给发起者自己**,权威态放进去会导致本机必须另存一份,两份状态必然分叉。所以 `hp` / `score` / `kills` / `alive` 这类由 DS 裁决的量,**即使变化频繁,也必须走根字段**,不能因为「它变得快」就塞进 `players[sid].data`。
|
|
88
|
-
> 第 2 问 · **整表全量多大?** `patchRate` 已把下发频率锁在 20Hz(**同窗口内多次写入合并,写 10 次只发一次**),成本上限 = 全量 payload × 20Hz,与写入频率无关。≤ 约 1KB → JSON 字符串够用(现成 `onStateField`,零客户端改动);≥ 几 KB 或条目上百 → 用 MapSchema 字段级增量 + 上面的客户端扩订阅。
|
|
89
|
-
> 第 3 问 · **客户端要什么粒度?** 整表刷新即可 → 字符串。需要「只有 hp 变了才更新这一个血条」→ MapSchema。
|
|
90
|
-
|
|
91
|
-
- **权威状态 → state 根字段**。阶段、该谁行动、局面、比分、准备名单:凡是"全场只有一份、且必须服端说了算"的都放这里。根字段对所有人一致(**包括改动的发起者自己**),后进房与重连的人握手即得,不需要谁补发。骨架里的 `phase` / `readySids` 就是例子。
|
|
92
|
-
- **各自的连续态 → `players[sid].data`**。位置、朝向、动画状态这类每人一份、丢一帧无所谓的高频数据。它**不回推给发起者自己**(本机数据本机已经有了),所以别指望自己的状态绕一圈回来。
|
|
93
|
-
- **纯表现层的一次性通知 → `broadcast("evt")`**。喊话、表情、命中特效。它是一次性的:晚进房和重连的人都收不到,所以"错过就玩不下去"的东西不能只走这条路。
|
|
94
|
-
|
|
95
|
-
按玩法类型的默认选择:
|
|
96
|
-
|
|
97
|
-
- **回合制 / 棋牌 / 桌游**:几乎全部走根字段 + 服端裁决。客户端只发意图(`sendEvent('place', ...)`)、只读 state 渲染,非法操作由服端忽略。**别用 evt 广播落子/出牌**——两端各自推演必然分叉,且重连的人无法恢复局面。
|
|
98
|
-
- **实时同场(跑动 / 射击 / 赛车)**:位姿走 `players[].data` + `sendPose`(≤20Hz),但判定结果(命中、得分、胜负)仍然走根字段,因为它必须唯一。
|
|
99
|
-
- **合作 / 派对**:按上面两条混用,别让"谁赢了"这种事落在 evt 上。
|
|
100
|
-
|
|
101
|
-
`patchRate` 默认 **50ms(20Hz)**:state 增量按这个节奏推,所以客户端上行超过 20Hz 不会有额外效果。
|
|
102
|
-
|
|
103
|
-
**⚠️ 仿真 tick 频率 ≠ 快照写入频率,是两件独立的事**(真实项目栽过:把 `setSimulationInterval` 从 50ms 改成 20ms 时,顺手把写 state 的间隔也改成 20ms,还留下「50Hz 快照更新鲜」的错误注释):
|
|
104
|
-
|
|
105
|
-
- **仿真要多细就多细**(碰撞检测、防隧穿需要 `setSimulationInterval` 跑到 20ms 甚至更细,这是对的);但**「往 state 根字段写值」的间隔不得快于 patchRate(50ms)**。`patchRate` 已把下行锁在 20Hz,**同一个 50ms 窗口内多次写同一字段会被合并,只发最后一次**——写 10 次发 1 次,多出的 9 次写入纯烧序列化 CPU,**不会让任何客户端画面更新鲜**(下行还是 20Hz)。
|
|
106
|
-
- 所以 **tick 比 50ms 细时,快照写入要单独节流**:tick 里只推进物理,攒够 50ms 再把 state 写一次,别让写入跟着 tick 频率走。
|
|
107
|
-
- **不要用「提高 patchRate(`setPatchRate(...)` 调更小)」来治卡顿**:它成倍放大**所有**客户端的下行带宽和 DS 序列化开销(DS 一局一进程,直接顶到心跳超时被强杀、整房掉线),而**连续运动玩法的卡顿根因几乎都在收端纠偏数学**(见客户端 StateSyncKnowledge「形态 C」四条铁律:外推 / 时钟标定 / 积分同源),**不在下发频率**。先按形态 C 排查收端,别动 patchRate。
|
|
108
|
-
|
|
109
|
-
房主、准备、踢人、观战、队伍在平台侧**没有对应物**,平台 API 里找不到这些字段;要就在 Room 里自己实现。
|
|
110
|
-
|
|
111
|
-
## 环境变量(壳注入,只读)
|
|
112
|
-
|
|
113
|
-
`DS_PORT`(壳已 listen)、`DS_APP_ID` / `DS_VERSION_ID` / `DS_INSTANCE_ID`(打日志用)、`DS_WORKDIR`、`DS_ENGINE`、`DS_HEARTBEAT_INTERVAL_MS`。玩法参数**不要**依赖新环境变量(平台不会注入),要写死在 `ds/` 或由客户端上行。
|
|
114
|
-
|
|
115
|
-
## 平台运行时数值(写玩法/排查时按这些实际值算,勿凭感觉)
|
|
116
|
-
|
|
117
|
-
> 以下为平台仓库当前默认值,供设计容量、超时、重连宽限时对齐。**这些数字由平台侧维护、可能随版本调整**,改玩法逻辑前若涉及关键容量/超时,最好再核对一次平台仓库对应常量。出处均在 `backend/game/`(`room_server.go` / `pipe.mjs` / `runtime.mjs`,不在本引擎工作目录内,故此处记录的是平台侧核对值)。
|
|
118
|
-
|
|
119
|
-
- **`max_players` 有效范围 1–64,越界回落 8**:开房时平台对 `max_players` 取 1–64;不在范围内按 8 处理。`ds/` 里 `maxClients` 必须等于实际生效的 `max_players`(回落后是 8),且等于玩法人数。(出处:`room_server.go` 开房参数校验)
|
|
120
|
-
- **HTTP 占座宽限 `seatGrace` 默认 30s**:玩家在 Room HTTP 拿到座位、但还没建立 Colyseus 连接的这段时间,平台按「已占座」计数,默认 30s;超时未连上则释放座位。重连设计的等待窗别短于这个值。(出处:`room_server.go`)
|
|
121
|
-
- **`player_count` = Colyseus 有效连接数 + 有效 HTTP 占座数**:平台人数是这两者合计,不是单看连接。**同账号双开 = 2**(两条连接、两个 sessionId),不去重 uid。设计满员判断时按这个口径。(出处:`pipe.mjs` `setSessionsProvider` 上报聚合)
|
|
122
|
-
- **`join` 幂等前提**:房**未满**时,同 uid 重复 `join`(同一连接语义)幂等,返回原座位;房**已满**时,`join` 一律被拒(**含该 uid 已在房内的情况**——满员后即使是本人也不再放新连接进来)。重连要趁未被顶满时回来。(出处:`room_server.go` join 分支)
|
|
123
|
-
- **DS 空闲回收 `DS_IDLE_TIMEOUT_MS` 默认 60000ms(0 = 关闭)**:进程在无人且无占座后闲置超过此值被平台回收。这是**兜底回收**,正常收尾仍应由 `onLeave` 空房 `DSAgentPipe.end("empty")` 主动触发,别依赖闲置超时。(出处:`runtime.mjs`)
|
|
124
|
-
- **DS 心跳 `DS_HEARTBEAT_INTERVAL_MS` 默认 5000ms;连续 3 次未收到 → 强杀(≈15s)**:低于 500ms 的配置回落 5000ms。心跳超时强杀是**异常路径**,正常靠主动 `end()`;「默认 15s」= 3 × 5000ms 心跳窗,即空房检查里提到的那个 15s。(出处:`runtime.mjs` / `pipe.mjs`)
|
|
125
|
-
- **每游戏并发 DS 上限默认 8**:同一 App 同时存活的 DS 进程数默认封顶 8;超出时 `create` 返回 `DS_QUOTA_EXCEEDED`。客户端收到该错误应引导玩家 `list` / `join` 现有房,**不要立即重试 `create`**(重试仍会被拒且徒增压力)。(出处:`room_server.go` 配额分支)
|
|
126
|
-
|
|
127
|
-
## 目录归属
|
|
128
|
-
|
|
129
|
-
- `main.mjs` — 只做 `rooms` 导出,不写玩法逻辑
|
|
130
|
-
- `rooms/<玩法>Room.mjs` — 一个玩法一个 Room 类,与客户端玩法业务 System 对应
|
|
131
|
-
- `rooms/<玩法>Schema.mjs` — 该 Room 的 Schema 定义
|
|
132
|
-
|
|
133
|
-
## 收尾检查
|
|
134
|
-
|
|
135
|
-
- `ds/` 不参与客户端 `type-check`;**禁止** `npm run build` / `vite build`。
|
|
136
|
-
- 改动 `ds/` 后自检:入口导出形状、`maxClients` 是否等于开房时用的 `max_players` 且等于玩法人数、空房是否 `end()`、`onCreate`/`onJoin`/`onLeave` 是否补 `hb()`、`onDispose` 是否解绑 provider。
|
|
137
|
-
- **可机检**:`ds/` 全文 grep 不到 `this.state.<字段>[` 形式的下标访问;所有 **MapSchema / ArraySchema** 容器走 `.set/.get/.has/.delete/.forEach`(JS 原生 `Map`、JSON 解析出的普通对象不受此限,只查 `state.` 开的容器字段)。每个 state 根字段都能说出它是**标量还是容器**,以及**客户端从哪个收口拿到它**(标量 → 现成 `onStateField`;容器 → 客户端 `MultiplayerManager.ts` 的 `_attachRoom()` 里补的订阅,见「三条路怎么选」)。
|
|
138
|
-
- 从 pub 载荷取业务字段前先 `JSON.parse(payload.data || "{}")` 再取;`payload` 顶层只有 `type` / `data`,直读 `payload.<业务字段>` 恒 `undefined`(见硬约束段契约载体条)。
|
|
139
|
-
- **可机检(uid 写法层判定)**:`ds/` 内所有进入 `setSessionsProvider` 上报的 `uid`,取值**必须是 `parseJoinUid(options)` 的返回值或 `Number(x) || 0`**;出现 `sessionId`、`player_id`、任何字符串表达式即为错误。join options 里 `uid`(number)与 `player_id`(string)**并存且相邻**,协议要的是 `uid`;`player_id` 是账号字符串,只能经 `parseJoinUid` 的 `/^u(\d+)$/` 分支间接使用。这条必须停在**写法层可判定**——因为该错误可观测性为零:坏帧在平台入口被静默丢弃,DS 侧无异常、客户端只有空 `onError`、服务端无日志,Agent 自己跑不出来,只能靠 grep 写法拦。典型错法(在两个都像的字段间选错,不是忘了约束):`const uid = typeof options.player_id === 'string' && options.player_id ? options.player_id : client.sessionId;`。
|
|
1
|
+
# ds/ 目录规则(Agent 必读)
|
|
2
|
+
|
|
3
|
+
平台 DS 进程的代码。目录名 `ds` 与入口 `ds/main.mjs` 由平台规定,**不可改**。
|
|
4
|
+
|
|
5
|
+
版本快照与客户端同包上传,但 DS 壳(`js-ds-shell`)**只物化并执行 `ds/` 前缀下的文件**:`src/`、根 `package.json`、`configs/` 都不会出现在 DS 进程里。两端不能共享模块,需要的常量各写一份。
|
|
6
|
+
|
|
7
|
+
**玩法逻辑由你写。** 本文只描述壳与平台的行为契约——哪些写法会让进程起不来、哪些是硬上限、哪些 Colyseus 机制在这里失效。房间内怎么玩、状态怎么设计、谁权威,都不在这里规定。
|
|
8
|
+
|
|
9
|
+
## 运行模型(先理解这三条,下面的约束都是它的推论)
|
|
10
|
+
|
|
11
|
+
**一个平台房 = 一个 DS 进程。** 玩家在大厅 `create` 时平台拉起一个进程(所以刚开房的头一两秒可能还没 listen,客户端要重试),`DSAgentPipe.end()` 或心跳超时时整个进程被 Kill、房记录被删、房号失效。进程里只跑这一局,所以模块级变量天然是"本局独占"的,不需要按房隔离——但这个前提是 `maxClients` 配对了,否则同进程会出现第二间房来共享它们。
|
|
12
|
+
|
|
13
|
+
**撮合分两层,`room_id` 和房间名不是一回事。** 平台 Room HTTP 决定"进哪个进程"(返回 `room_id` + `connect`),Colyseus 只负责"进这个进程里的那一间房"(`joinOrCreate(<房间名>)`)。`room_id` **不会**传给 Colyseus,客户端那句 `joinOrCreate("sync")` 写的是本目录 `main.mjs` 导出的 key,不是房号——看着像 bug,其实是分层。另外 Colyseus 自己也有个 `room.roomId`(进程内房 id),与平台 `room_id` 同名不同物,打日志时别混。
|
|
14
|
+
|
|
15
|
+
**Colyseus 用来自治的机制,在这里只在进程内生效,平台看不见。** `autoDispose` 只析构进程内对象、`matchmaker` 只看得见自己进程、`allowReconnection` 只挂起自己的 `onLeave`——它们都不知道平台的房记录和进程。所以回收走 `DSAgentPipe.end()`、撮合走 Room HTTP、人数走 `setSessionsProvider`。**从 Colyseus 官方文档抄来的自治写法,先确认它要管的那件事是不是已经归平台管了。**
|
|
16
|
+
|
|
17
|
+
分工上:DS 进程 = 壳 + 你的 `ds/`。壳装好依赖、注入 `DSAgentPipe`(`main.mjs` 被 import 时已可用)、`gameServer.define()` 每个导出的房间并 `listen`。你只写 Room 类。
|
|
18
|
+
|
|
19
|
+
## 硬约束(违反 = 进程起不来 / 静默失败)
|
|
20
|
+
|
|
21
|
+
- **入口**:`ds/main.mjs` 必须 `export const rooms = { <房间名>: RoomClass }`;key 与客户端 `joinOrCreate(<房间名>)` 一致。缺入口时 DS 直接启动失败(`snapshot missing entry ds/main.mjs`);值必须是**类本身**,写成 `new SyncRoom()` 这样的实例会 `room <name> is not a constructor` 然后 exit(1)。
|
|
22
|
+
- **ESM only**:`ds/` 下一律 `.mjs`,禁止 CJS(`require`)。Node 运行时 ≥ 22。
|
|
23
|
+
- **没有依赖安装环节**:壳把自己的 `node_modules` 软链到工作目录根,所以 `ds/` 里直接 `import { Room } from "@colyseus/core"` / `import { Schema } from "@colyseus/schema"` 能解析。写 `ds/package.json` 声明依赖**不会被安装**(快照只被物化,全程不跑 `npm install`),任何第三方包都 import 失败——玩法要的算法只能用标准库自己实现。
|
|
24
|
+
- **不自己起服务**:禁止 `new Server()` / `listen()` / 选端口。端口由平台在 27000–27999 动态分配,壳已 `listen`。
|
|
25
|
+
- **没有可信身份**:壳不校验 token,也不把平台票传给 DS,所以 `onAuth` 里没有任何可信凭据可验(写了也只是在验客户端自报的东西)。准入由 Room HTTP(经网关鉴权)保证,因此**禁止**信任客户端自报的 `uid` 做权限判断——它只用于向平台上报在场名单。
|
|
26
|
+
- **入站单包 ≤ 4KB(只卡入站,出站不受此限)**:4KB = `@colyseus/ws-transport@0.17.13` 构造函数默认 `maxPayload = 4 * 1024`,且默认 `perMessageDeflate = false`(无压缩兜底);平台壳 `new WebSocketTransport({ server })` 未覆盖该项——**所以这不是平台的业务决策,是库默认值**(出处:`backend/game/js-ds-shell/src/runtime.mjs` + `@colyseus/ws-transport` build/WebSocketTransport.mjs)。这是 **DS 作为接收方**收下客户端消息的上限,超限时连接以 code 1009 被断开、`onMessage` 根本不会执行。有效检查在**客户端发送前**,且要按**字节**算(`TextEncoder`),不是 `String.length`。**反向的出站(DS → 客户端,`client.send` / `broadcast`)没有对应的 4KB 上限**——浏览器端不设等价接收限制,下行大包不会触发 1009。**不要把入站的这个 4KB 体积检查套到 DS 的下行发送上**(如在 `client.send` 前写 `if (over) return`):那会把本该送达的下行包静默丢掉,且毫无日志痕迹,是极难排查的一类 bug。onJoin 补全整局面、把某份大内容定向下发等场景下行本就会偏大,属正常;但下行大包只在这类**一次性时机**发,不要在每帧/定时路径整包广播(会队头阻塞,见客户端 `StateSyncKnowledge.md`「频率与包体」)。**注意区分**:上面这条「下行大包别高频」针对的是**手动 `broadcast` 全量**;state 根字段走 Colyseus **patch 通道**(自带同窗口合并,一个 patch 窗口内写多次只发一次),性质不同、不受那条约束——**不要拿"下行别高频整包"去否决合法的根字段写入**。
|
|
27
|
+
- **`maxClients` === 平台 `max_players` === 玩法人数**(平台侧取值 1–64,越界按 8):小于则 `joinOrCreate` 会在同一进程里再开一间房,两拨人互相看不见,且进程级 `DSAgentPipe` 的 `setSessionsProvider` 被后一间房覆盖。大于则大厅人数口径与玩法不一致。
|
|
28
|
+
- **`ds/main.mjs` 只 export 实际使用的 Room 类**,禁止留下未注册的模板 `SyncRoom`。
|
|
29
|
+
- **席位按 uid 认领时,`onJoin` 必须把 `parseJoinUid(options)` 写入该席位**。只放进 `_uidBySession` 不够:占座 uid 对不上连接 uid 时,平台人数 = 连接 + 未对齐占座,双人房会显示 2/2。
|
|
30
|
+
- **空房必须自己收尾**:`onLeave` 里人数归零 → `broadcast("room_closed")` → `DSAgentPipe.end("empty")`。只靠平台心跳超时(默认 15s)强杀是异常路径,不是正常路径。
|
|
31
|
+
- **`MapSchema` / `ArraySchema` 只能用方法访问**:`.set()` / `.get()` / `.has()` / `.delete()` / `.forEach()` / `.size`。下标(`m[k] = v`、`m[k]`、`delete m[k]`)在 `@colyseus/schema@4.0.30` 下**静默失效** —— Proxy 已于 2.0 移除,下标只会在实例上挂一个普通 JS 属性:**读得回来**(所以按 key 取的代码看着完全正常),但 `.size` 恒为 0、`.get(k)` 恒 `undefined`、**用下标写入的条目完全不进编码,客户端永远收不到**。`Object.entries()` / `Object.keys()` 同样无效,返回的是 `~refId` / `childType` / `$items` / `$indexes` / `deletedItems` 五个内部字段。**最危险的形态是同一文件里下标与方法混用**:按 key 取的路径正常、遍历与计数的路径全空,表现为「能连上、能同步一部分」,是本平台上最难定位的一类故障。注意区分:**用 `.set()` 正确填充的 MapSchema,`.forEach()` / `for...of` 迭代、`.size` 都是正常的**,不要因为它"看起来像普通 Map"就以为下标也能用;`JSON.stringify(mapSchema)` 也是正常的(会输出条目)。`onCreate` 里对容器**必须用 `new MapSchema()` / `new ArraySchema()`** 初始化,不能赋 `{}` / `[]` —— 普通对象 / 数组当不了 Colyseus 容器根字段。
|
|
32
|
+
- **不要用 `allowReconnection`**:Colyseus 官方教程里的这个写法在本平台上会打架——它让 `onLeave` 挂起、`players` 不减,于是空房永远不 `end`,同时在场名单里那个已断线的人还占着 `player_count`。断线重连在本平台是 HTTP 层的事:客户端重 `join`(对同一账号幂等)拿回原座位,那是一条**新的 Colyseus 连接**,`sessionId` 会变。
|
|
33
|
+
- **`DSAgentPipe` 是唯一上报通道**:`setSessionsProvider(fn)` 注册在场名单、`hb()` 在人数变化时补心跳、`end(reason)` 声明本局结束;`onDispose` 里 `setSessionsProvider(null)` 解绑。**不注册 provider 的后果**:心跳不带在场名单,平台只能回退按 HTTP 座位数算人数,DS 里的真实连接数不被采信。全部用 `?.` 保护:经壳启动时它一定存在(没有管道 fd 时壳装的是 no-op 桩,`end()` 只打日志),但直接 `node ds/main.mjs` 裸跑时没有。
|
|
34
|
+
- **骨架里的 `normalizePayload()` / `encodeData()` / `parseJoinUid()` / `requestClose()` 是两端契约与平台协议的载体,不是示例代码**:前三者分别锁定 pub 载荷形状(`{ type, data: 字符串 }`,业务字段在 `data` 里、不在顶层)、`state.set` 的字符串化、以及平台在场名单要求的 **uint32** `uid`;`requestClose()` 锁定空房收尾的**时序契约**——它先 `broadcast("room_closed", { reason })` 再**延迟 200ms** 才 `DSAgentPipe.end()`,这 200ms 是留给客户端收到 `room_closed` 的窗口。客户端模板(`multiplayerManager`)监听的正是 `room_closed` 这个消息名;**把延迟当冗余删掉、或改掉消息名,客户端就只拿到一个没有关闭码的空 `onError`**,玩家不知道为什么被踢。重写 Room 时这四个函数**连定义带调用一起照搬**,别当占位删掉或内联简化——历史上删 `parseJoinUid` 导致 `uid` 变字符串、平台解在场名单失败 15s 强杀,绕过 `normalizePayload` 直读 `payload.id` 导致伤害裁决 `NaN` 静默失效,删 `requestClose` 方法体只留调用点导致 `onLeave` 空房收尾抛 `TypeError`、后面的 `DSAgentPipe.end()` 永不执行、空房收不了尾,三次都零报错。
|
|
35
|
+
- **结构性规则(枚举永远会漏,认这条)**:骨架里凡是 `this.xxx()` 调用到、而 Colyseus `Room` 基类上找不到的方法,都是骨架自定义的**契约载体**(`requestClose` 就是其一,`Room` 上没有它)。重写时**要么连定义一起照搬,要么连调用点一起删**;只留调用点会在运行时抛 `TypeError`,而它往往埋在 `onLeave` / 空房收尾这类**不常走的分支**里——正常游玩测不到,一到真正散场才炸,且后面的 `DSAgentPipe.end()` 就永远执行不到,两端零报错。
|
|
36
|
+
|
|
37
|
+
## 与客户端的接口对应
|
|
38
|
+
|
|
39
|
+
房间名、消息名、state 形状、`from` 的含义都是**你和客户端之间的约定**,平台不认识这些名字,改的唯一要求是两端一致。骨架选了 `state.set` / `pub` / `evt` / `room_closed` 这组名字。
|
|
40
|
+
|
|
41
|
+
客户端模板(`multiplayerManager`)只提供三个收口,DS 侧数据放哪决定了客户端能不能收到:
|
|
42
|
+
|
|
43
|
+
| DS 侧 | 客户端收口 |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `players[sessionId].data`(字符串) | `bus.on('mp-peer-pose', (sid, pose) => ...)` |
|
|
46
|
+
| state **根字段** | `MultiplayerManager.onStateField(field, cb)`,字段已有值时立即回调一次 |
|
|
47
|
+
| `broadcast("evt", ...)` 或 `client.send("evt", ...)` 定向发 | `MultiplayerManager.onEvent((from, type, data) => ...)` |
|
|
48
|
+
|
|
49
|
+
模板在 player 上只监听 `data` 这一个字段;要用 player 级的其它真 schema 字段,得同时在客户端 `src/skill-modules/platform-services/MultiplayerManager.ts` 的 `_attachRoom()` 里、`players.onAdd` 回调中补 `$(player).listen('<字段>', ...)`,经 `bus.emit` 交给业务。
|
|
50
|
+
|
|
51
|
+
**反方向(客户端 → DS)上行只有两个消息名**,两者的 `data` **在线上都是 JSON 字符串**(客户端模板发送前已 `JSON.stringify`):
|
|
52
|
+
|
|
53
|
+
| 客户端调用 | 线上形状 | DS 侧读法 |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `sendPose(obj)` | `state.set` → `{ data: "<JSON 字符串>" }` | `payload.data` 原样存进 `players[sid].data`,**不要解析** |
|
|
56
|
+
| `sendEvent(type, obj)` | `pub` → `{ type, data: "<JSON 字符串>" }` | 用 `payload.type` 分流;业务字段必须 `JSON.parse(payload.data \|\| "{}")` 之后再取,**不在 `payload` 顶层** |
|
|
57
|
+
|
|
58
|
+
直读 `payload.<业务字段>`(如 `payload.id` / `payload.hp`)恒为 `undefined`,经 `Number()` 变 `NaN` 后被校验分支静默丢弃——两端都不 throw,`.mjs` 无类型也检不出,是本平台最难定位的一类故障。历史上就因为绕过归一化直读 `payload.id` 做伤害裁决,导致裁决静默失效、谁都没报错。
|
|
59
|
+
|
|
60
|
+
**方向不对称,别写反**:这条「data 是字符串、要先 parse」只约束**上行**。下行(DS → 客户端)客户端 `_parse` 对对象宽容(`broadcast("evt", { type, data: <对象> })` 直接可用),**不要**给下行也加「必须 stringify」的约束。
|
|
61
|
+
|
|
62
|
+
**权威快照带服务端时间戳 `t`(两端契约的一部分,做本地模拟纠偏时必须)**:连续运动玩法若客户端要跑「本地权威同款模拟 + 快照纠偏」(收端形态 C,见客户端 StateSyncKnowledge),**DS 写快照时必须带上写入那一刻的服务端单调时钟** `t`(`Date.now()` ms)——放进 `players[sid].data` 或对应根字段里随快照一起下发。客户端拿 `t` 算快照年龄 `age = getServerNow() − snap.t`,把旧快照外推到当前时刻再纠偏;没有 `t`,客户端只能拿「到达时刻」当基准,等于把单向网络延迟当 0,纠偏必飘。配套的时钟标定回程(客户端 ping → DS 回 pong 带 `st`)已在骨架 `SyncRoom.mjs` 的 `_onPing` 里,走 pub 契约同一条路,不需另开通道。**纯回合 / 棋牌玩法不做形态 C,可以不带 `t`**——这条只对「客户端本地模拟纠偏」的玩法是硬契约。
|
|
63
|
+
|
|
64
|
+
**三条路怎么选**(选错是"能连上、但状态对不齐"的头号成因):
|
|
65
|
+
|
|
66
|
+
> **state 根字段有两种形态,客户端收口完全不同,先分清再选**:
|
|
67
|
+
|
|
68
|
+
| 根字段形态 | 客户端收口 | 说明 |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| **标量**(string / number / boolean) | 现成 `onStateField(field, cb)`,**握手自带当前值**,后进房/重连即得 | `phase` / `readySids` / `seats:"string"`(JSON 字符串)都走这个 |
|
|
71
|
+
| **容器**(MapSchema / ArraySchema) | **收不到条目增删与嵌套字段变化** | 底层 `onStateField` 是 `$(room.state).listen(field)`,只在**引用被整体替换**时触发,对 map 字段看不到条目增删、更看不到嵌套字段变化 |
|
|
72
|
+
|
|
73
|
+
容器形态若确有必要(整表 ≥ 几 KB 或条目上百),必须【同时】给出客户端扩订阅写法,否则读者只能像本次一样自己发明一套 `evt` 增量广播来绕:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
// 客户端:加在 src/skill-modules/platform-services/MultiplayerManager.ts 的 _attachRoom() 里、players.onAdd 旁边。
|
|
77
|
+
// 该函数里已有 $,连上与重连都会执行;onStateField 收不到容器的嵌套变化。业务用 bus.on 订阅这些事件。
|
|
78
|
+
$(room.state).seats.onAdd((seat, playerId) => {
|
|
79
|
+
bus.emit("mp-seat-add", playerId, seat);
|
|
80
|
+
$(seat).listen("hp", (v) => bus.emit("mp-seat-hp", playerId, v)); // 字段级增量
|
|
81
|
+
});
|
|
82
|
+
$(room.state).seats.onRemove((_s, playerId) => bus.emit("mp-seat-remove", playerId));
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**选型判据按【三问】顺序**,不要写成「高频用 map、低频用字符串」(频率已被 patchRate 抹平):
|
|
86
|
+
|
|
87
|
+
> 第 1 问 · **owner 是谁?** DS 裁决的 → 根字段(高低频都一样)。玩家自报的连续态 → `players[sid].data`。这一问**优先于**体积和频率:`players[sid].data` 是客户端上报通道(DS 只存不改),且**不回推给发起者自己**,权威态放进去会导致本机必须另存一份,两份状态必然分叉。所以 `hp` / `score` / `kills` / `alive` 这类由 DS 裁决的量,**即使变化频繁,也必须走根字段**,不能因为「它变得快」就塞进 `players[sid].data`。
|
|
88
|
+
> 第 2 问 · **整表全量多大?** `patchRate` 已把下发频率锁在 20Hz(**同窗口内多次写入合并,写 10 次只发一次**),成本上限 = 全量 payload × 20Hz,与写入频率无关。≤ 约 1KB → JSON 字符串够用(现成 `onStateField`,零客户端改动);≥ 几 KB 或条目上百 → 用 MapSchema 字段级增量 + 上面的客户端扩订阅。
|
|
89
|
+
> 第 3 问 · **客户端要什么粒度?** 整表刷新即可 → 字符串。需要「只有 hp 变了才更新这一个血条」→ MapSchema。
|
|
90
|
+
|
|
91
|
+
- **权威状态 → state 根字段**。阶段、该谁行动、局面、比分、准备名单:凡是"全场只有一份、且必须服端说了算"的都放这里。根字段对所有人一致(**包括改动的发起者自己**),后进房与重连的人握手即得,不需要谁补发。骨架里的 `phase` / `readySids` 就是例子。
|
|
92
|
+
- **各自的连续态 → `players[sid].data`**。位置、朝向、动画状态这类每人一份、丢一帧无所谓的高频数据。它**不回推给发起者自己**(本机数据本机已经有了),所以别指望自己的状态绕一圈回来。
|
|
93
|
+
- **纯表现层的一次性通知 → `broadcast("evt")`**。喊话、表情、命中特效。它是一次性的:晚进房和重连的人都收不到,所以"错过就玩不下去"的东西不能只走这条路。
|
|
94
|
+
|
|
95
|
+
按玩法类型的默认选择:
|
|
96
|
+
|
|
97
|
+
- **回合制 / 棋牌 / 桌游**:几乎全部走根字段 + 服端裁决。客户端只发意图(`sendEvent('place', ...)`)、只读 state 渲染,非法操作由服端忽略。**别用 evt 广播落子/出牌**——两端各自推演必然分叉,且重连的人无法恢复局面。
|
|
98
|
+
- **实时同场(跑动 / 射击 / 赛车)**:位姿走 `players[].data` + `sendPose`(≤20Hz),但判定结果(命中、得分、胜负)仍然走根字段,因为它必须唯一。
|
|
99
|
+
- **合作 / 派对**:按上面两条混用,别让"谁赢了"这种事落在 evt 上。
|
|
100
|
+
|
|
101
|
+
`patchRate` 默认 **50ms(20Hz)**:state 增量按这个节奏推,所以客户端上行超过 20Hz 不会有额外效果。
|
|
102
|
+
|
|
103
|
+
**⚠️ 仿真 tick 频率 ≠ 快照写入频率,是两件独立的事**(真实项目栽过:把 `setSimulationInterval` 从 50ms 改成 20ms 时,顺手把写 state 的间隔也改成 20ms,还留下「50Hz 快照更新鲜」的错误注释):
|
|
104
|
+
|
|
105
|
+
- **仿真要多细就多细**(碰撞检测、防隧穿需要 `setSimulationInterval` 跑到 20ms 甚至更细,这是对的);但**「往 state 根字段写值」的间隔不得快于 patchRate(50ms)**。`patchRate` 已把下行锁在 20Hz,**同一个 50ms 窗口内多次写同一字段会被合并,只发最后一次**——写 10 次发 1 次,多出的 9 次写入纯烧序列化 CPU,**不会让任何客户端画面更新鲜**(下行还是 20Hz)。
|
|
106
|
+
- 所以 **tick 比 50ms 细时,快照写入要单独节流**:tick 里只推进物理,攒够 50ms 再把 state 写一次,别让写入跟着 tick 频率走。
|
|
107
|
+
- **不要用「提高 patchRate(`setPatchRate(...)` 调更小)」来治卡顿**:它成倍放大**所有**客户端的下行带宽和 DS 序列化开销(DS 一局一进程,直接顶到心跳超时被强杀、整房掉线),而**连续运动玩法的卡顿根因几乎都在收端纠偏数学**(见客户端 StateSyncKnowledge「形态 C」四条铁律:外推 / 时钟标定 / 积分同源),**不在下发频率**。先按形态 C 排查收端,别动 patchRate。
|
|
108
|
+
|
|
109
|
+
房主、准备、踢人、观战、队伍在平台侧**没有对应物**,平台 API 里找不到这些字段;要就在 Room 里自己实现。
|
|
110
|
+
|
|
111
|
+
## 环境变量(壳注入,只读)
|
|
112
|
+
|
|
113
|
+
`DS_PORT`(壳已 listen)、`DS_APP_ID` / `DS_VERSION_ID` / `DS_INSTANCE_ID`(打日志用)、`DS_WORKDIR`、`DS_ENGINE`、`DS_HEARTBEAT_INTERVAL_MS`。玩法参数**不要**依赖新环境变量(平台不会注入),要写死在 `ds/` 或由客户端上行。
|
|
114
|
+
|
|
115
|
+
## 平台运行时数值(写玩法/排查时按这些实际值算,勿凭感觉)
|
|
116
|
+
|
|
117
|
+
> 以下为平台仓库当前默认值,供设计容量、超时、重连宽限时对齐。**这些数字由平台侧维护、可能随版本调整**,改玩法逻辑前若涉及关键容量/超时,最好再核对一次平台仓库对应常量。出处均在 `backend/game/`(`room_server.go` / `pipe.mjs` / `runtime.mjs`,不在本引擎工作目录内,故此处记录的是平台侧核对值)。
|
|
118
|
+
|
|
119
|
+
- **`max_players` 有效范围 1–64,越界回落 8**:开房时平台对 `max_players` 取 1–64;不在范围内按 8 处理。`ds/` 里 `maxClients` 必须等于实际生效的 `max_players`(回落后是 8),且等于玩法人数。(出处:`room_server.go` 开房参数校验)
|
|
120
|
+
- **HTTP 占座宽限 `seatGrace` 默认 30s**:玩家在 Room HTTP 拿到座位、但还没建立 Colyseus 连接的这段时间,平台按「已占座」计数,默认 30s;超时未连上则释放座位。重连设计的等待窗别短于这个值。(出处:`room_server.go`)
|
|
121
|
+
- **`player_count` = Colyseus 有效连接数 + 有效 HTTP 占座数**:平台人数是这两者合计,不是单看连接。**同账号双开 = 2**(两条连接、两个 sessionId),不去重 uid。设计满员判断时按这个口径。(出处:`pipe.mjs` `setSessionsProvider` 上报聚合)
|
|
122
|
+
- **`join` 幂等前提**:房**未满**时,同 uid 重复 `join`(同一连接语义)幂等,返回原座位;房**已满**时,`join` 一律被拒(**含该 uid 已在房内的情况**——满员后即使是本人也不再放新连接进来)。重连要趁未被顶满时回来。(出处:`room_server.go` join 分支)
|
|
123
|
+
- **DS 空闲回收 `DS_IDLE_TIMEOUT_MS` 默认 60000ms(0 = 关闭)**:进程在无人且无占座后闲置超过此值被平台回收。这是**兜底回收**,正常收尾仍应由 `onLeave` 空房 `DSAgentPipe.end("empty")` 主动触发,别依赖闲置超时。(出处:`runtime.mjs`)
|
|
124
|
+
- **DS 心跳 `DS_HEARTBEAT_INTERVAL_MS` 默认 5000ms;连续 3 次未收到 → 强杀(≈15s)**:低于 500ms 的配置回落 5000ms。心跳超时强杀是**异常路径**,正常靠主动 `end()`;「默认 15s」= 3 × 5000ms 心跳窗,即空房检查里提到的那个 15s。(出处:`runtime.mjs` / `pipe.mjs`)
|
|
125
|
+
- **每游戏并发 DS 上限默认 8**:同一 App 同时存活的 DS 进程数默认封顶 8;超出时 `create` 返回 `DS_QUOTA_EXCEEDED`。客户端收到该错误应引导玩家 `list` / `join` 现有房,**不要立即重试 `create`**(重试仍会被拒且徒增压力)。(出处:`room_server.go` 配额分支)
|
|
126
|
+
|
|
127
|
+
## 目录归属
|
|
128
|
+
|
|
129
|
+
- `main.mjs` — 只做 `rooms` 导出,不写玩法逻辑
|
|
130
|
+
- `rooms/<玩法>Room.mjs` — 一个玩法一个 Room 类,与客户端玩法业务 System 对应
|
|
131
|
+
- `rooms/<玩法>Schema.mjs` — 该 Room 的 Schema 定义
|
|
132
|
+
|
|
133
|
+
## 收尾检查
|
|
134
|
+
|
|
135
|
+
- `ds/` 不参与客户端 `type-check`;**禁止** `npm run build` / `vite build`。
|
|
136
|
+
- 改动 `ds/` 后自检:入口导出形状、`maxClients` 是否等于开房时用的 `max_players` 且等于玩法人数、空房是否 `end()`、`onCreate`/`onJoin`/`onLeave` 是否补 `hb()`、`onDispose` 是否解绑 provider。
|
|
137
|
+
- **可机检**:`ds/` 全文 grep 不到 `this.state.<字段>[` 形式的下标访问;所有 **MapSchema / ArraySchema** 容器走 `.set/.get/.has/.delete/.forEach`(JS 原生 `Map`、JSON 解析出的普通对象不受此限,只查 `state.` 开的容器字段)。每个 state 根字段都能说出它是**标量还是容器**,以及**客户端从哪个收口拿到它**(标量 → 现成 `onStateField`;容器 → 客户端 `MultiplayerManager.ts` 的 `_attachRoom()` 里补的订阅,见「三条路怎么选」)。
|
|
138
|
+
- 从 pub 载荷取业务字段前先 `JSON.parse(payload.data || "{}")` 再取;`payload` 顶层只有 `type` / `data`,直读 `payload.<业务字段>` 恒 `undefined`(见硬约束段契约载体条)。
|
|
139
|
+
- **可机检(uid 写法层判定)**:`ds/` 内所有进入 `setSessionsProvider` 上报的 `uid`,取值**必须是 `parseJoinUid(options)` 的返回值或 `Number(x) || 0`**;出现 `sessionId`、`player_id`、任何字符串表达式即为错误。join options 里 `uid`(number)与 `player_id`(string)**并存且相邻**,协议要的是 `uid`;`player_id` 是账号字符串,只能经 `parseJoinUid` 的 `/^u(\d+)$/` 分支间接使用。这条必须停在**写法层可判定**——因为该错误可观测性为零:坏帧在平台入口被静默丢弃,DS 侧无异常、客户端只有空 `onError`、服务端无日志,Agent 自己跑不出来,只能靠 grep 写法拦。典型错法(在两个都像的字段间选错,不是忘了约束):`const uid = typeof options.player_id === 'string' && options.player_id ? options.player_id : client.sessionId;`。
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# 平台服务契约
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- `
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- `getPlatformService()` 使用页面单例。这次装上的排行榜、存档、联机共享该实例。不同版本的服务不能同时接入。
|
|
11
|
-
- 保留 `@lightgame/save/v1/` 本地存储命名空间、同槽位队列、防抖、冲突令牌、云/本地降级规则,避免把已有存档当新数据覆盖。
|
|
12
|
-
- 请求错误按返回的 `ok/code/message` 处理。禁止输出 Bearer token 或完整身份消息。通信状态用 `console.info`,前缀 `[platform-service]`、`[leaderboard]`、`[save]`,不记录 token、app_id、player_id。排行榜日志含 `result`、`message`、`board_key`;`report` 另含 `configured=yes/no`。存档日志含 `result`、`message`、`source`、`slot_key`。
|
|
13
|
-
- 排行榜 `configure` 按 `boardKey` 暂存建榜参数和 `period`(`all_time` / `weekly` / `monthly`;`season` 暂未开放,服务端拒绝)。`period` 之后 `report` / `query` / `updateDisplay` 自动带上,漏设落回 `all_time`;`boardKey`
|
|
14
|
-
- 云存档 `CONFLICT` 带回服务端 `fields`、`updated_at`、`blob_size`,默认不带回 blob;需要时写选项传 `conflictIncludeBlob: true`。SDK 不刷新冲突令牌,禁止盲目重试覆盖另一台设备。单玩家最多 32 个槽,只有新建超出才返回 `QUOTA_EXCEEDED_SLOT_COUNT`。
|
|
15
|
-
- 联机对业务暴露 `createRoom` / `joinRoom` / `leaveRoom` / `sendPose` / `sendEvent` / `onEvent`。房间事件从同目录 `eventBus.ts` 导出的 `bus` 订阅。不要改这几个文件之间的 import,也不要删 `log.ts` / `eventBus.ts
|
|
16
|
-
- 预览桥的 `dispose()` 不销毁服务。项目入口负责 HMR 清理;存档管理器和身份服务按使用顺序释放。
|
|
17
|
-
|
|
18
|
-
资源包沿用既有服务实现及其行为;它不提供游戏玩法、UI 或自动登录界面。
|
|
1
|
+
# 平台服务契约
|
|
2
|
+
|
|
3
|
+
权威类型随能力包发布:`assets/modules/platform-service.d.mts`、`leaderboard.d.mts`、`save.d.mts`、`MultiplayerManager.ts`。安装后读取项目内同名文件,先确认接口再接线。只读这次装上的文件。
|
|
4
|
+
|
|
5
|
+
- `identity`、`leaderboard`、`save`、`multiplayer` 分开安装。后三个各自附带身份实现,因为它们调用 `PlatformServiceManager`;附带身份不会把排行榜、云存档、联机装在一起。
|
|
6
|
+
- 初始化只挂监听,不向父页面发送消息。预览桥发出 `ready` 后,父页面回复 `{ type: 'runtime-init', data }`;token 更新是 `session-token-refresh`。只接受已确定的父页面来源,生产环境优先显式设置 `targetOrigin`。
|
|
7
|
+
- QQ 轻游:页面 URL 带 `qq_test` 时,`init()` 不听 `runtime-init`,从 URL 读 `api`(只接受 `https://craft.qq.com` 及其子域)、`app_id`、`qq_test`(`0` 正式 / `1` 测试),改为 `import()` `identity/qq-ai-game-sdk.min.js`(构建时单独成 chunk,非 QQ 环境不加载),`login()` 后 POST `{api}/api/auth/qq-game-session`,请求体 `{ app_id, qq_test: <数字>, game_token, gopenid }`,换 `session_token`,业务请求仍走 Bearer。`game_token` 只放请求体,不进 URL、不进日志。session 不能续期:过期前 2 分钟重新 `login()` 换票并发 `token-refreshed`;业务接口 401 时重新换票一次再重试,5 秒内不重复换。SDK 为 mock、URL 参数缺失或非法、换票 400/403/503 或失败时降级为 `noop`。
|
|
8
|
+
- 身份服务必须在预览 ready 前挂监听,不阻塞首帧和 ready。没有宿主或初始化超时时按原 API 降级。装了 `leaderboard` 或 `save` 时业务侧传 `initTimeoutMs: 20000`(SDK 默认 5s 对手 Q 偏紧)。排行面板:loading → `whenReady` → `isReady` 再 query;身份未就绪时提供【重新加载游戏】,身份有效时请求失败可重新查榜,见 `leaderboard_playbook.md`。`noop` 下重复 `whenReady()` / `init()` 不会重新换票。云存档:首次云读及重试云读写前确认身份就绪;`OK` + `source === 'local'` 不是云成功。
|
|
9
|
+
- `getApi()` 返回当前身份的网关地址(无尾斜杠),未就绪为 `''`。联机用它拼 DS 端点,其它模块不需要。
|
|
10
|
+
- `getPlatformService()` 使用页面单例。这次装上的排行榜、存档、联机共享该实例。不同版本的服务不能同时接入。
|
|
11
|
+
- 保留 `@lightgame/save/v1/` 本地存储命名空间、同槽位队列、防抖、冲突令牌、云/本地降级规则,避免把已有存档当新数据覆盖。
|
|
12
|
+
- 请求错误按返回的 `ok/code/message` 处理。禁止输出 Bearer token 或完整身份消息。通信状态用 `console.info`,前缀 `[platform-service]`、`[leaderboard]`、`[save]`,不记录 token、app_id、player_id。排行榜日志含 `result`、`message`、`board_key`;`report` 另含 `configured=yes/no`。存档日志含 `result`、`message`、`source`、`slot_key`。
|
|
13
|
+
- 排行榜 `configure` 按 `boardKey` 暂存建榜参数和 `period`(`all_time` / `weekly` / `monthly`;`season` 暂未开放,服务端拒绝)。`period` 之后 `report` / `query` / `updateDisplay` 自动带上,漏设落回 `all_time`;`boardKey` 不会被记住,**每次调用都显式传同一个**(新代码不要省略),漏传落到 `default` 榜(未 `configure` 时首报回 `INVALID_BOARD_CONFIG`,日志 `configured=no`)。`report` / `reportBatch` 不能传 `seasonNumber`。`query` 的 `aroundSelf` 本地钳到 25。`BOARD_NOT_FOUND` 与 `ARCHIVED` 按空榜。`reportBatch` 逐榜看 `boards[i].result`。不要传 `period: 'season'` / `periodConfig`,周期需求用 `weekly` / `monthly`。写法见 `leaderboard_playbook.md`。
|
|
14
|
+
- 云存档 `CONFLICT` 带回服务端 `fields`、`updated_at`、`blob_size`,默认不带回 blob;需要时写选项传 `conflictIncludeBlob: true`。SDK 不刷新冲突令牌,禁止盲目重试覆盖另一台设备。单玩家最多 32 个槽,只有新建超出才返回 `QUOTA_EXCEEDED_SLOT_COUNT`。
|
|
15
|
+
- 联机对业务暴露 `createRoom` / `joinRoom` / `leaveRoom` / `sendPose` / `sendEvent` / `onEvent`。房间事件从同目录 `eventBus.ts` 导出的 `bus` 订阅。不要改这几个文件之间的 import,也不要删 `log.ts` / `eventBus.ts` / `multiplayer/`。玩法需要的监听直接加在 `MultiplayerManager.ts` 的 `_attachRoom()`;重装会覆盖为当前版本,改过的文件备份为 `.previous`,按 SKILL「修改与重装」合入。服务端 Room 在项目 `ds/`:安装 `multiplayer` 时若没有 `ds/` 会写入骨架,之后归工程所有。约束见同目录 `SERVER_GUIDE.md`。
|
|
16
|
+
- 预览桥的 `dispose()` 不销毁服务。项目入口负责 HMR 清理;存档管理器和身份服务按使用顺序释放。
|
|
17
|
+
|
|
18
|
+
资源包沿用既有服务实现及其行为;它不提供游戏玩法、UI 或自动登录界面。
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# 云排行接入规范(Craft + 手 Q)
|
|
2
|
+
|
|
3
|
+
装了 `leaderboard` 时必读。业务只调 `LeaderboardManager` 与 `PlatformServiceManager`。禁止手写 `/api/auth/*`、`/api/leaderboard/*`,禁止在 `index.html` 挂 QQ SDK。
|
|
4
|
+
|
|
5
|
+
## 接线
|
|
6
|
+
|
|
7
|
+
1. 入口、任何 `markReady()` 之前初始化身份。装了排行榜时加长等待(手 Q 要 login + 换票,默认 5s 不够):
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// 首次创建单例时就必须带超时;不要先 PlatformServiceManager.init() 再补参数(补不上)
|
|
11
|
+
void getPlatformService({ initTimeoutMs: 20000 }).init();
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
2. 先出画面并发 `ready`,禁止 `await whenReady()` 再 `markReady()`。
|
|
15
|
+
3. Craft / 手 Q 同一套业务代码。有无 `qq_test` 由 SDK 分流,业务不得 `if (qq)`。
|
|
16
|
+
|
|
17
|
+
## boardKey(最易错)
|
|
18
|
+
|
|
19
|
+
- 常量一处定义,例如 `const BOARD_KEY = 'highest_level'`。
|
|
20
|
+
- **始终显式传 `boardKey`**,不要依赖「单榜可省略 → default」。
|
|
21
|
+
- `configure` / `report` / `reportBatch` 每一项 / `query` / `updateDisplay` 必须同一 `BOARD_KEY`。漏传落到 `default`,表现为空榜或没上榜。
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
LeaderboardManager.configure('desc', 'BEST', [0, 999999], BOARD_KEY, { type: 'comprehensive' });
|
|
25
|
+
await LeaderboardManager.report(score, playerName, undefined, { boardKey: BOARD_KEY });
|
|
26
|
+
const ranking = await LeaderboardManager.query(undefined, {
|
|
27
|
+
boardKey: BOARD_KEY, limit: 50, includeSelf: true,
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 上报
|
|
32
|
+
|
|
33
|
+
- 有游戏内昵称:`report(score, playerName, …)`(手 Q 尤其需要)。
|
|
34
|
+
- 无昵称可省略,用平台兜底。
|
|
35
|
+
- 看 `result`:`OK` 才算成功;其它失败不阻断通关。
|
|
36
|
+
- 不要用 `extra` 存玩法大数据;`query` 不保证回传 `extra`。
|
|
37
|
+
|
|
38
|
+
## 查榜 UI(手 Q 关键)
|
|
39
|
+
|
|
40
|
+
面板先显示 loading,再等身份,再查榜。恢复方式按身份状态区分:
|
|
41
|
+
|
|
42
|
+
- `whenReady()` 返回后仍未就绪:显示「平台连接失败」和【重新加载游戏】,按钮点击时执行 `window.location.reload()`,重新走初始化与换票。
|
|
43
|
+
- 身份已就绪、查榜失败:显示失败原因和【重试】,点击时重新执行查榜流程。
|
|
44
|
+
|
|
45
|
+
`whenReady()` 只等待首次初始化的结果,不保证身份可用;`noop` 下再次调用它或 `init()` 不会重新登录换票。不要把重复调用这两个方法当成身份重试,也不要自动循环刷新。
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
await PlatformServiceManager.whenReady();
|
|
49
|
+
if (!PlatformServiceManager.isReady()) {
|
|
50
|
+
// 「平台连接失败」+【重新加载游戏】
|
|
51
|
+
// 按钮点击时执行 window.location.reload();不要在这里立即刷新
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const ranking = await LeaderboardManager.query(undefined, {
|
|
55
|
+
boardKey: BOARD_KEY, limit: 50, includeSelf: true,
|
|
56
|
+
});
|
|
57
|
+
if (ranking.result === 'OK' || ranking.result === 'BOARD_NOT_FOUND' || ranking.result === 'ARCHIVED') {
|
|
58
|
+
// 空数组 → 「暂无数据」
|
|
59
|
+
} else if (ranking.result === 'PLATFORM_UNAVAILABLE') {
|
|
60
|
+
// 「暂不可用」;重新检查 isReady()
|
|
61
|
+
// 仍为 true →【重试】重新执行查榜流程;否则 →【重新加载游戏】
|
|
62
|
+
} else {
|
|
63
|
+
// 「加载失败」+【重试】重新执行查榜流程
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- 面板打开时监听 `state-change`:迟到的身份变为 `active` 后自动重查;只在面板仍打开时更新 UI,关闭面板时取消订阅。
|
|
68
|
+
- 高亮自己:`item.player_id === PlatformServiceManager.getPlayerId()`,禁止比昵称。
|
|
69
|
+
- 名字用 `textContent`,不要当 HTML。
|
|
70
|
+
|
|
71
|
+
## 结果码
|
|
72
|
+
|
|
73
|
+
| result | UI |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `OK` / `BOARD_NOT_FOUND` / `ARCHIVED` | 正常或空榜 |
|
|
76
|
+
| `PLATFORM_UNAVAILABLE` | 暂不可用;身份仍就绪则重新查榜,否则重新加载游戏 |
|
|
77
|
+
| 其它 | 加载失败 + 重试查榜 |
|
|
78
|
+
|
|
79
|
+
禁止把所有非 `OK` 都显示成「暂不可用」。禁止造假在线榜。
|
|
80
|
+
|
|
81
|
+
## 手 Q 专项
|
|
82
|
+
|
|
83
|
+
- 业务零分支;同步 URL 由平台带 `api` / `app_id` / `qq_test`。
|
|
84
|
+
- `initTimeoutMs` ≥ 20000。
|
|
85
|
+
- 换票失败进入 `noop`:UI 提供【重新加载游戏】;重复 `whenReady()` 不会重新换票。mock / 缺参数需宿主修复后重新打开游戏。
|
|
86
|
+
- 本地与 Craft 预览不能代替手 Q 验收;手 Q 打开排行面板成功前标「未验证」。
|
|
87
|
+
|
|
88
|
+
## 验收清单
|
|
89
|
+
|
|
90
|
+
- [ ] 只装了 `leaderboard`,无手写鉴权
|
|
91
|
+
- [ ] `init` 早于 `markReady`,且未阻塞 `ready`;装排行时 `initTimeoutMs` ≥ 20000
|
|
92
|
+
- [ ] 所有 `report` / `query` 带同一 `boardKey`
|
|
93
|
+
- [ ] 排行面板:loading → 有数据或空榜;身份有效时请求失败可重查
|
|
94
|
+
- [ ] 首次换票网络失败后,恢复网络并点击【重新加载游戏】,能重新登录换票;迟到 `active` 时打开的面板自动重查
|
|
95
|
+
- [ ] 无宿主:不白屏、不造假榜
|
|
96
|
+
- [ ] 手 Q:真机打开排行面板(本地 / Craft 预览不算通过)
|