@craft_eco/craft-mcp 0.0.0-stage → 0.1.14
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 +32 -2
- package/bin/craft-mcp.mjs +7 -0
- package/dist-server/core/app-paths.mjs +15 -0
- package/dist-server/core/auth-store.mjs +70 -0
- package/dist-server/core/connector-auth.mjs +30 -0
- package/dist-server/core/http-utils.mjs +14 -0
- package/dist-server/game-workflow/asset-formats.mjs +76 -0
- package/dist-server/game-workflow/asset-import.mjs +113 -0
- package/dist-server/game-workflow/asset-inputs.mjs +10 -0
- package/dist-server/game-workflow/assets.mjs +161 -0
- package/dist-server/game-workflow/capture-worker.mjs +14 -0
- package/dist-server/game-workflow/check.mjs +74 -0
- package/dist-server/game-workflow/draft-archive.mjs +91 -0
- package/dist-server/game-workflow/draft-bindings.mjs +35 -0
- package/dist-server/game-workflow/draft-uploads.mjs +207 -0
- package/dist-server/game-workflow/engines.mjs +30 -0
- package/dist-server/game-workflow/library-assets.mjs +77 -0
- package/dist-server/game-workflow/library-candidates.mjs +37 -0
- package/dist-server/game-workflow/library-catalog.mjs +45 -0
- package/dist-server/game-workflow/project-leases.mjs +52 -0
- package/dist-server/game-workflow/projects.mjs +92 -0
- package/dist-server/game-workflow/publication-materials.mjs +67 -0
- package/dist-server/game-workflow/publications.mjs +146 -0
- package/dist-server/game-workflow/publish-capture-worker.mjs +57 -0
- package/dist-server/game-workflow/publish-capture.mjs +75 -0
- package/dist-server/game-workflow/request-store.mjs +52 -0
- package/dist-server/game-workflow/resource-catalog.mjs +97 -0
- package/dist-server/game-workflow/tasks.mjs +93 -0
- package/dist-server/mcp/asset-tools.mjs +42 -0
- package/dist-server/mcp/control-panel.html +17 -0
- package/dist-server/mcp/control-panel.mjs +40 -0
- package/dist-server/mcp/publication-tools.mjs +19 -0
- package/dist-server/mcp/server.mjs +297 -0
- package/dist-server/mcp/start.mjs +20 -0
- package/dist-server/preview/local-static-preview.mjs +71 -0
- package/dist-server/preview/preview-control.mjs +35 -0
- package/dist-server/preview/preview-launcher.mjs +26 -0
- package/dist-server/preview/preview-snapshot.mjs +35 -0
- package/dist-server/preview/preview-start.mjs +12 -0
- package/dist-server/preview/preview-worker.mjs +68 -0
- package/dist-server/upstream/craft-aigc.mjs +197 -0
- package/dist-server/upstream/library-url.mjs +14 -0
- package/dist-server/upstream/publication-transport.mjs +80 -0
- package/package.json +33 -4
- package/resources/craft-game-maker/SKILL.md +67 -0
- package/resources/craft-game-maker/js.md +9 -0
- package/resources/craft-game-maker/js3d.md +12 -0
- package/resources/game_visual_qa.mjs +1143 -0
- package/resources/js/context/CLAUDE.md +54 -0
- package/resources/js/context/agents/aigc-manager.md +91 -0
- package/resources/js/context/hooks/hooks.json +20 -0
- package/resources/js/context/knowledge/AigcEnabled.md +41 -0
- package/resources/js/context/knowledge/AigcWiring.md +200 -0
- package/resources/js/context/knowledge/AssetUrl.md +24 -0
- package/resources/js/context/knowledge/FrontendComponents.md +23 -0
- package/resources/js/context/knowledge/GameProbe.md +74 -0
- package/resources/js/context/knowledge/Lifecycle.md +27 -0
- package/resources/js/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -0
- package/resources/js/context/knowledge/Multiplayer/OverviewKnowledge.md +115 -0
- package/resources/js/context/knowledge/Multiplayer/StateSyncKnowledge.md +392 -0
- package/resources/js/context/knowledge/PlatformServices.md +184 -0
- package/resources/js/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -0
- package/resources/js/context/knowledge/Ui.md +11 -0
- package/resources/js/context/knowledge/UiEditorCompat.md +21 -0
- package/resources/js/context/rules/MultiplayerCapability.md +23 -0
- package/resources/js/context/rules/MultiplayerRoomEntryUX.md +63 -0
- package/resources/js/context/rules/PlatformBoundaryModules.md +43 -0
- package/resources/js/context/skills/aigc-generate/SKILL.md +301 -0
- package/resources/js/context/skills/aigc-generate/knowledge/audio.md +39 -0
- package/resources/js/context/skills/aigc-generate/knowledge/batch-replace.md +14 -0
- package/resources/js/context/skills/aigc-generate/knowledge/character2d.md +129 -0
- package/resources/js/context/skills/aigc-generate/knowledge/non-stepwise-aigc.md +54 -0
- package/resources/js/context/skills/aigc-generate/knowledge/texture-prop.md +50 -0
- package/resources/js/context/skills/aigc-generate/knowledge/texture-scene.md +201 -0
- package/resources/js/context/skills/aigc-generate/knowledge/texture-ui.md +53 -0
- package/resources/js/context/skills/aigc-generate/scripts/apply-results.mjs +83 -0
- package/resources/js/context/skills/aigc-generate/scripts/config.json +29 -0
- package/resources/js/context/skills/aigc-generate/scripts/generate.mjs +1016 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/client.mjs +228 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/ledger.mjs +119 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/nstep-handoff.mjs +100 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/pipelines.mjs +441 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/queue.mjs +283 -0
- package/resources/js/context/skills/aigc-generate/scripts/lib/submit.mjs +122 -0
- package/resources/js/context/skills/aigc-generate/scripts/worker.mjs +171 -0
- package/resources/js/context/skills/asset-search/SKILL.md +73 -0
- package/resources/js/context/skills/asset-search/scripts/asset_display.mjs +62 -0
- package/resources/js/context/skills/asset-search/scripts/config.json +5 -0
- package/resources/js/context/skills/asset-search/scripts/provided_assets.mjs +125 -0
- package/resources/js/context/skills/asset-search/scripts/recalled_sprite_paths.mjs +47 -0
- package/resources/js/context/skills/asset-search/scripts/search.mjs +749 -0
- package/resources/js/context/skills/asset-search/scripts/sprite_source_materializer.mjs +723 -0
- package/resources/js/context/skills/asset-search/strategies/audio.md +34 -0
- package/resources/js/context/skills/asset-search/strategies/character2d.md +33 -0
- package/resources/js/context/skills/asset-search/strategies/effect2d.md +31 -0
- package/resources/js/context/skills/asset-search/strategies/texture-prop.md +22 -0
- package/resources/js/context/skills/asset-search/strategies/texture-ui.md +35 -0
- package/resources/js/context/skills/asset-search/strategies/ui-common.md +40 -0
- package/resources/js/context/skills/asset-search/strategies/ui-style.md +28 -0
- package/resources/js/context/skills/display-info-setup/SKILL.md +32 -0
- package/resources/js/context/skills/display-info-setup/scripts/init_project.mjs +38 -0
- package/resources/js/context/skills/export-config/SKILL.md +20 -0
- package/resources/js/context/skills/export-config/scripts/assert-asset-wiring.mjs +72 -0
- package/resources/js/context/skills/export-config/scripts/export-config.mjs +43 -0
- package/resources/js/context/skills/export-config/scripts/panel-resource-path.mjs +106 -0
- package/resources/js/context/skills/export-config/scripts/sync-asset-controls.mjs +351 -0
- package/resources/js/context/skills/export-config/scripts/translate-asset-titles.mjs +163 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/SKILL.md +92 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/game-runtime.json +7 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/package.json +22 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/config.d.mts +19 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/config.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +39 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +25 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform.d.mts +79 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform.mjs +29 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.d.mts +49 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/release.json +37 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/cli.mjs +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.d.mts +8 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.mjs +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +3 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.mjs +8 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/assets.d.mts +24 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/assets.mjs +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/astc.d.mts +10 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/astc.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.d.mts +20 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +21 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.d.mts +17 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.d.mts +40 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.d.mts +10 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.d.mts +8 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/config-export.mjs +32 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/refresh-runtime.mjs +50 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/ui-stage.ts +121 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/viewport.ts +254 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/main.ts +99 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/platform.ts +14 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/screenUi.ts +172 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/style.css +165 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/tsconfig.json +20 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/vite.config.ts +4 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/scripts/install-template.mjs +109 -0
- package/resources/js/context/skills/mobile-adaptation/SKILL.md +260 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +50 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +881 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +134 -0
- package/resources/js/context/skills/mobile-adaptation/references/input-config.md +311 -0
- package/resources/js/context/skills/mobile-adaptation/references/verification.md +106 -0
- package/resources/js/context/skills/optimization-suggestions/SKILL.md +89 -0
- package/resources/js/context/skills/platform-services/SKILL.md +94 -0
- package/resources/js/context/skills/platform-services/assets/modules/MultiplayerManager.ts +783 -0
- package/resources/js/context/skills/platform-services/assets/modules/eventBus.ts +57 -0
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -0
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -0
- package/resources/js/context/skills/platform-services/assets/modules/log.ts +35 -0
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.d.mts +25 -0
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.mjs +1 -0
- package/resources/js/context/skills/platform-services/assets/modules/save.d.mts +49 -0
- package/resources/js/context/skills/platform-services/assets/modules/save.mjs +1 -0
- package/resources/js/context/skills/platform-services/assets/release.json +44 -0
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -0
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -0
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -0
- package/resources/js/context/skills/platform-services/references/SERVER_GUIDE.md +139 -0
- package/resources/js/context/skills/platform-services/references/api_reference.md +18 -0
- package/resources/js/context/skills/platform-services/scripts/install.mjs +134 -0
- package/resources/js/context/skills/resolution-adaptation/SKILL.md +202 -0
- package/resources/js/context/skills/resolution-adaptation/assets/display/ui-stage.ts +121 -0
- package/resources/js/context/skills/resolution-adaptation/assets/display/viewport.ts +254 -0
- package/resources/js/context/skills/resolution-adaptation/assets/example/main.ts +98 -0
- package/resources/js/context/skills/resolution-adaptation/assets/example/ui-tokens.css +200 -0
- package/resources/js/context/skills/resolution-adaptation/references/layout-rules.md +134 -0
- package/resources/js/context/skills/resolution-adaptation/references/viewport-api.md +119 -0
- package/resources/js/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +338 -0
- package/resources/js/context/skills/scene-editor-compat/SKILL.md +94 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.assets.json +13 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.scene-editor.json +6 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/game/sceneAdapter.ts +25 -0
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/scenes/main.scene.json +18 -0
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/release.json +7 -0
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.d.mts +42 -0
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.mjs +144 -0
- package/resources/js/context/skills/scene-editor-compat/docs/contract.md +330 -0
- package/resources/js/context/skills/scene-editor-compat/docs/resource-sync.md +64 -0
- package/resources/js/context/skills/scene-editor-compat/docs/runtime-state.md +28 -0
- package/resources/js/context/skills/scene-editor-compat/docs/terrain-contract.md +47 -0
- package/resources/js/context/skills/scene-editor-compat/docs/visual-contract.md +64 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.assets.json +38 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.scene-editor.json +9 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneAdapter.ts +59 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneBlockers.ts +30 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneFileAssets.ts +66 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/Main.Scene.ts +20 -0
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/SceneTypes.ts +26 -0
- package/resources/js/context/skills/scene-editor-compat/references/contract.md +73 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/apply_scene_marker.py +162 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_contract.py +853 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_resource_urls.py +173 -0
- package/resources/js/context/skills/scene-editor-compat/scripts/scene-editor.mjs +427 -0
- package/resources/js/context/skills/scene-editor-compat/version.json +1 -0
- package/resources/js/context/skills/ui-editor-compat/SKILL.md +48 -0
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -0
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +74 -0
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -0
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -0
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -0
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/release.json +7 -0
- package/resources/js/context/skills/ui-editor-compat/references/contract.md +132 -0
- package/resources/js/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -0
- package/resources/js/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -0
- package/resources/js/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -0
- package/resources/js/context/skills/version-update/SKILL.md +192 -0
- package/resources/js/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -0
- package/resources/js/context/skills/version-update/scripts/feature_snapshot.mjs +159 -0
- package/resources/js/context/skills/version-update/scripts/update_feature_version.mjs +157 -0
- package/resources/js/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
- package/resources/js/context/skills/visual-qa/SKILL.md +36 -0
- package/resources/js/context/version/version.json +1 -0
- package/resources/js/project/.gitattributes +2 -0
- package/resources/js/project/README.md +99 -0
- package/resources/js/project/SPEC/assist/.gitkeep +0 -0
- package/resources/js/project/SPEC/guide/.gitkeep +0 -0
- package/resources/js/project/SPEC/plan/.gitkeep +0 -0
- package/resources/js/project/SPEC/readme.md +6 -0
- package/resources/js/project/SPEC/res/.gitkeep +0 -0
- package/resources/js/project/SPEC/task-item/.gitkeep +0 -0
- package/resources/js/project/configs/assets.json +1 -0
- package/resources/js/project/configs/game.controls.json +3 -0
- package/resources/js/project/configs/game.json +3 -0
- package/resources/js/project/game-runtime.json +7 -0
- package/resources/js/project/gameplay-probe.json +37 -0
- package/resources/js/project/index.html +20 -0
- package/resources/js/project/package-lock.json +1155 -0
- package/resources/js/project/package.json +23 -0
- package/resources/js/project/projectDisplayInfo.json +7 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/config.d.mts +19 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/config.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +39 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +25 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.d.mts +79 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.mjs +29 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/save.d.mts +49 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/save.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/release.json +37 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/cli.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.d.mts +8 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +3 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.mjs +8 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.d.mts +24 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.d.mts +10 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.d.mts +20 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +21 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/input.d.mts +17 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/input.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/three.d.mts +40 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/three.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.d.mts +10 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.mjs +1 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/video.d.mts +8 -0
- package/resources/js/project/runtime/lightgame/1.0.0/tools/video.mjs +1 -0
- package/resources/js/project/scripts/config-export.mjs +32 -0
- package/resources/js/project/scripts/refresh-runtime.mjs +50 -0
- package/resources/js/project/src/display/ui-stage.ts +121 -0
- package/resources/js/project/src/display/viewport.ts +254 -0
- package/resources/js/project/src/main.ts +99 -0
- package/resources/js/project/src/platform.ts +14 -0
- package/resources/js/project/src/scenes/LoadScene.ts +89 -0
- package/resources/js/project/src/scenes/PlayScene.ts +17 -0
- package/resources/js/project/src/screenUi.ts +172 -0
- package/resources/js/project/src/style.css +165 -0
- package/resources/js/project/tsconfig.json +20 -0
- package/resources/js/project/unified_data_control_config.json +20 -0
- package/resources/js/project/vendor/core-manager-js/package.json +33 -0
- package/resources/js/project/vendor/core-manager-js/src/.versions.json +42 -0
- package/resources/js/project/vendor/core-manager-js/src/CoreManagerPlugin.ts +41 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AssetRef.ts +90 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcFirstImageFile.ts +203 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcTextureLoader.ts +106 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.test.ts +25 -0
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.ts +21 -0
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.test.ts +65 -0
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.ts +340 -0
- package/resources/js/project/vendor/core-manager-js/src/configManager/FeatureConfig.ts +87 -0
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.d.mts +92 -0
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.mjs +271 -0
- package/resources/js/project/vendor/core-manager-js/src/index.ts +31 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputConfig.ts +81 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.test.ts +43 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.ts +32 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.test.ts +141 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.ts +20 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/KeyboardProvider.ts +183 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/TouchProvider.ts +304 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/VirtualJoystick.ts +351 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/_internal/InputManagerImpl.ts +180 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64 +13 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64.d.ts +14 -0
- package/resources/js/project/vendor/core-manager-js/src/inputManager/input_config.example.json +68 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/DebugConsole.ts +433 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogCapture.ts +118 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogManager.ts +444 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCapture.ts +485 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.test.ts +66 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.ts +149 -0
- package/resources/js/project/vendor/core-manager-js/src/logManager/icons.b64 +9 -0
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/AssetUrlResolver.ts +29 -0
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.test.ts +88 -0
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.ts +122 -0
- package/resources/js/project/vendor/core-manager-js/src/runtime.ts +24 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterEntity.ts +318 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.test.ts +151 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.ts +235 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.test.ts +98 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.ts +94 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectEntity.ts +209 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.test.ts +106 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.ts +341 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.test.ts +68 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.ts +236 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.test.ts +22 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.ts +29 -0
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteEntity.test.ts +197 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiContracts.ts +9 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiKit.ts +555 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.test.ts +112 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.ts +178 -0
- package/resources/js/project/vendor/core-manager-js/src/uiManager/ui-base.css +246 -0
- package/resources/js/project/vendor/core-manager-js/src/videoManager/VideoManager.ts +139 -0
- package/resources/js/project/vendor/core-manager-js/tsconfig.json +15 -0
- package/resources/js/project/vendor/run.sh +107 -0
- package/resources/js/project/version/craft_feature_version.json +42 -0
- package/resources/js/project/version/project_feature_version.json +11 -0
- package/resources/js/project/vite.config.ts +4 -0
- package/resources/js3d/context/CLAUDE.md +50 -0
- package/resources/js3d/context/hooks/hooks.json +20 -0
- package/resources/js3d/context/knowledge/3D/PoseInterpolationKnowledge.md +87 -0
- package/resources/js3d/context/knowledge/CodingGuide/Pitfalls.md +69 -0
- package/resources/js3d/context/knowledge/CodingGuide/SceneEditableGuide.md +42 -0
- package/resources/js3d/context/knowledge/FrontendComponents.md +23 -0
- package/resources/js3d/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -0
- package/resources/js3d/context/knowledge/Multiplayer/OverviewKnowledge.md +117 -0
- package/resources/js3d/context/knowledge/Multiplayer/StateSyncKnowledge.md +430 -0
- package/resources/js3d/context/knowledge/PlatformServices.md +162 -0
- package/resources/js3d/context/knowledge/Runtime.md +30 -0
- package/resources/js3d/context/knowledge/SceneEditorCompat.md +34 -0
- package/resources/js3d/context/knowledge/StepByStep.md +21 -0
- package/resources/js3d/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -0
- package/resources/js3d/context/knowledge/UiEditorCompat.md +21 -0
- package/resources/js3d/context/rules/MultiplayerCapability.md +27 -0
- package/resources/js3d/context/rules/MultiplayerRoomEntryUX.md +63 -0
- package/resources/js3d/context/rules/PlatformBoundaryModules.md +43 -0
- package/resources/js3d/context/skills/aigc-integration/SKILL.md +176 -0
- package/resources/js3d/context/skills/aigc-integration/callback.md +56 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/README.md +22 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/audio-aigc-knowledge.md +38 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/staticmesh-aigc-knowledge.md +33 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-prop-aigc-knowledge.md +36 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-scene-aigc-knowledge.md +37 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-ui-aigc-knowledge.md +35 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/config.json +3 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/lib/submit.mjs +344 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/query-music.mjs +53 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/query-results.mjs +53 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-cover.mjs +44 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-image.mjs +48 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-music.mjs +34 -0
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-staticmesh.mjs +39 -0
- package/resources/js3d/context/skills/asset-search/SKILL.md +159 -0
- package/resources/js3d/context/skills/asset-search/references/resource-config.md +56 -0
- package/resources/js3d/context/skills/asset-search/scripts/asset_display.mjs +62 -0
- package/resources/js3d/context/skills/asset-search/scripts/config.json +213 -0
- package/resources/js3d/context/skills/asset-search/scripts/manifest_pipeline.mjs +885 -0
- package/resources/js3d/context/skills/asset-search/scripts/preflight.mjs +79 -0
- package/resources/js3d/context/skills/asset-search/scripts/provided_assets.mjs +74 -0
- package/resources/js3d/context/skills/asset-search/scripts/search.mjs +597 -0
- package/resources/js3d/context/skills/export-config/scripts/assert-asset-wiring.mjs +83 -0
- package/resources/js3d/context/skills/export-config/scripts/export-config.mjs +53 -0
- package/resources/js3d/context/skills/export-config/scripts/panel-resource-path.mjs +106 -0
- package/resources/js3d/context/skills/export-config/scripts/sync-asset-controls.mjs +325 -0
- package/resources/js3d/context/skills/export-config/scripts/sync-scene-assets.mjs +181 -0
- package/resources/js3d/context/skills/export-config/scripts/translate-asset-titles.mjs +163 -0
- package/resources/js3d/context/skills/game-art-style/SKILL.md +60 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/cartoon.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/comic.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/cozy.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/cyber.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/horror.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/lowpoly.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/paper.png +0 -0
- package/resources/js3d/context/skills/game-art-style/assets/previews/voxel.png +0 -0
- package/resources/js3d/context/skills/game-art-style/references/art-parameters-lite.md +38 -0
- package/resources/js3d/context/skills/game-art-style/references/construction.md +111 -0
- package/resources/js3d/context/skills/game-art-style/references/materials-textures.md +105 -0
- package/resources/js3d/context/skills/game-art-style/references/sources.md +25 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/cartoon.md +175 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/comic.md +168 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/cozy.md +191 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/cyber.md +165 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/horror.md +173 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/lowpoly.md +185 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/paper.md +181 -0
- package/resources/js3d/context/skills/game-art-style/references/styles/voxel.md +189 -0
- package/resources/js3d/context/skills/game-art-style/references/user-style-document.md +88 -0
- package/resources/js3d/context/skills/mobile-adaptation/SKILL.md +284 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +104 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +952 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +256 -0
- package/resources/js3d/context/skills/mobile-adaptation/references/input-config.md +311 -0
- package/resources/js3d/context/skills/mobile-adaptation/references/verification.md +106 -0
- package/resources/js3d/context/skills/optimization-suggestions/SKILL.md +74 -0
- package/resources/js3d/context/skills/platform-services/SKILL.md +94 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/MultiplayerManager.ts +783 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/eventBus.ts +57 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/log.ts +35 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.d.mts +25 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.mjs +1 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/save.d.mts +49 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/save.mjs +1 -0
- package/resources/js3d/context/skills/platform-services/assets/release.json +44 -0
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -0
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -0
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -0
- package/resources/js3d/context/skills/platform-services/references/SERVER_GUIDE.md +139 -0
- package/resources/js3d/context/skills/platform-services/references/api_reference.md +18 -0
- package/resources/js3d/context/skills/platform-services/scripts/install.mjs +134 -0
- package/resources/js3d/context/skills/resolution-adaptation/SKILL.md +170 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/ui-stage.ts +121 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/viewport.ts +244 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/main.ts +127 -0
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/ui-tokens.css +188 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/layout-rules.md +124 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/viewport-api.md +117 -0
- package/resources/js3d/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +338 -0
- package/resources/js3d/context/skills/scene-editor-compat/SKILL.md +599 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/bundle-contract.md +141 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/editor-integration.md +92 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/scene-data-format.md +125 -0
- package/resources/js3d/context/skills/scene-editor-compat/references/slots-rules.md +113 -0
- package/resources/js3d/context/skills/scene-editor-compat/scripts/scene-editor.mjs +1187 -0
- package/resources/js3d/context/skills/threejs-game-quality/SKILL.md +52 -0
- package/resources/js3d/context/skills/threejs-game-quality/agents/openai.yaml +4 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/01-build.md +94 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/02-avoid.md +50 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/03-detect.md +105 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-by-genre.md +147 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-distance.md +79 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-sources.md +56 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/character-motion-face.md +51 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/parameter-contract.md +55 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/refine-existing.md +78 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/rendering-stability.md +84 -0
- package/resources/js3d/context/skills/threejs-game-quality/references/runtime-tools.md +120 -0
- package/resources/js3d/context/skills/threejs-game-quality/scripts/package.json +4 -0
- package/resources/js3d/context/skills/threejs-game-quality/scripts/runtime-audit.js +238 -0
- package/resources/js3d/context/skills/ui-editor-compat/SKILL.md +59 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +61 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -0
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/release.json +7 -0
- package/resources/js3d/context/skills/ui-editor-compat/references/contract.md +110 -0
- package/resources/js3d/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -0
- package/resources/js3d/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -0
- package/resources/js3d/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -0
- package/resources/js3d/context/skills/version-update/SKILL.md +191 -0
- package/resources/js3d/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -0
- package/resources/js3d/context/skills/version-update/scripts/feature_snapshot.mjs +159 -0
- package/resources/js3d/context/skills/version-update/scripts/update_feature_version.mjs +157 -0
- package/resources/js3d/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
- package/resources/js3d/context/version/version.json +1 -0
- package/resources/js3d/project/.gitattributes +2 -0
- package/resources/js3d/project/README.md +100 -0
- package/resources/js3d/project/configs/game.controls.json +3 -0
- package/resources/js3d/project/configs/game.json +3 -0
- package/resources/js3d/project/game-runtime.json +7 -0
- package/resources/js3d/project/gameplay-probe.json +38 -0
- package/resources/js3d/project/index.html +12 -0
- package/resources/js3d/project/package-lock.json +1204 -0
- package/resources/js3d/project/package.json +24 -0
- package/resources/js3d/project/projectDisplayInfo.json +7 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.d.mts +19 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +39 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +25 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.d.mts +79 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.mjs +30 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.d.mts +49 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/release.json +39 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/cli.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.d.mts +8 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +3 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.mjs +7 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.d.mts +24 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.d.mts +10 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.d.mts +20 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +21 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.d.mts +36 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.mjs +359 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.test.mjs +25 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.d.mts +17 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.d.mts +40 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.d.mts +10 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.d.mts +8 -0
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.mjs +1 -0
- package/resources/js3d/project/scripts/config-export.mjs +32 -0
- package/resources/js3d/project/scripts/refresh-runtime.mjs +50 -0
- package/resources/js3d/project/src/display/ui-stage.ts +121 -0
- package/resources/js3d/project/src/display/viewport.ts +244 -0
- package/resources/js3d/project/src/main.ts +83 -0
- package/resources/js3d/project/src/platform.ts +14 -0
- package/resources/js3d/project/src/style.css +17 -0
- package/resources/js3d/project/tsconfig.json +20 -0
- package/resources/js3d/project/unified_data_control_config.json +20 -0
- package/resources/js3d/project/vendor/core-manager-three/package.json +12 -0
- package/resources/js3d/project/vendor/core-manager-three/src/index.ts +2 -0
- package/resources/js3d/project/vendor/run.sh +4 -0
- package/resources/js3d/project/version/craft_feature_version.json +42 -0
- package/resources/js3d/project/version/project_feature_version.json +11 -0
- package/resources/js3d/project/vite.config.ts +4 -0
- package/vendor/agent-cli/dist/runtime-tools/registry.json +6 -0
- package/vendor/agent-cli/dist/runtime-tools/tool-bundle-types.d.cts +15 -0
- package/vendor/agent-cli/dist/runtime-tools/tool-bundle.cjs +129 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/blender-cook-assets.cjs +296 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/context-adapter.cjs +48 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/scene-process-lock.cjs +110 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/tool-manifest.json +22 -0
- package/vendor/agent-cli/dist/runtime-tools/ue/ue-asset-references.cjs +305 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts +3 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js +45 -0
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts +57 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.js +198 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts +32 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js +146 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts +28 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.js +384 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts +15 -0
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/static.js +152 -0
- package/vendor/agent-cli/dist/src/artifacts/static.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.d.ts +4 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.js +24 -0
- package/vendor/agent-cli/dist/src/cli/commands/process.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.d.ts +23 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.js +62 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-controls.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.d.ts +9 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.js +15 -0
- package/vendor/agent-cli/dist/src/cli/commands/run-mock.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.d.ts +3 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.js +284 -0
- package/vendor/agent-cli/dist/src/cli/commands/run.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.d.ts +11 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.js +161 -0
- package/vendor/agent-cli/dist/src/cli/commands/setup.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/options.d.ts +83 -0
- package/vendor/agent-cli/dist/src/cli/options.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/options.js +213 -0
- package/vendor/agent-cli/dist/src/cli/options.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts +5 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.js +276 -0
- package/vendor/agent-cli/dist/src/cli/process-protocol.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/registry.d.ts +55 -0
- package/vendor/agent-cli/dist/src/cli/registry.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/registry.js +99 -0
- package/vendor/agent-cli/dist/src/cli/registry.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.d.ts +44 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.js +83 -0
- package/vendor/agent-cli/dist/src/cli/render/jsonl-sink.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.d.ts +28 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.js +52 -0
- package/vendor/agent-cli/dist/src/cli/render/text-sink.js.map +1 -0
- package/vendor/agent-cli/dist/src/cli.d.ts +9 -0
- package/vendor/agent-cli/dist/src/cli.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli.js +54 -0
- package/vendor/agent-cli/dist/src/cli.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts +24 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/execution.js +131 -0
- package/vendor/agent-cli/dist/src/component/execution.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts +24 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.js +200 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.d.ts +31 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js +57 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation.d.ts +10 -0
- package/vendor/agent-cli/dist/src/component/preparation.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/preparation.js +35 -0
- package/vendor/agent-cli/dist/src/component/preparation.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.d.ts +15 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.js +37 -0
- package/vendor/agent-cli/dist/src/component/runtime-tools.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime.d.ts +8 -0
- package/vendor/agent-cli/dist/src/component/runtime.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/runtime.js +95 -0
- package/vendor/agent-cli/dist/src/component/runtime.js.map +1 -0
- package/vendor/agent-cli/dist/src/config/config-store.d.ts +50 -0
- package/vendor/agent-cli/dist/src/config/config-store.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/config/config-store.js +117 -0
- package/vendor/agent-cli/dist/src/config/config-store.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.d.ts +17 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.js +133 -0
- package/vendor/agent-cli/dist/src/context/cache-lease.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.d.ts +9 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.js +51 -0
- package/vendor/agent-cli/dist/src/context/cache-prune-diagnostics.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts +4 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.js +54 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.d.ts +12 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.js +100 -0
- package/vendor/agent-cli/dist/src/context/client-context-view.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-budget.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/context-budget.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-budget.js +10 -0
- package/vendor/agent-cli/dist/src/context/context-budget.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-cache.d.ts +108 -0
- package/vendor/agent-cli/dist/src/context/context-cache.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-cache.js +357 -0
- package/vendor/agent-cli/dist/src/context/context-cache.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-project.d.ts +26 -0
- package/vendor/agent-cli/dist/src/context/context-project.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-project.js +113 -0
- package/vendor/agent-cli/dist/src/context/context-project.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-resource.d.ts +4 -0
- package/vendor/agent-cli/dist/src/context/context-resource.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-resource.js +11 -0
- package/vendor/agent-cli/dist/src/context/context-resource.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts +9 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js +134 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts +4 -0
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/local-skills.js +157 -0
- package/vendor/agent-cli/dist/src/context/local-skills.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-context.d.ts +19 -0
- package/vendor/agent-cli/dist/src/context/member-context.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-context.js +105 -0
- package/vendor/agent-cli/dist/src/context/member-context.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-documents.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/member-documents.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-documents.js +38 -0
- package/vendor/agent-cli/dist/src/context/member-documents.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.js +62 -0
- package/vendor/agent-cli/dist/src/context/member-profile-header.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile.d.ts +43 -0
- package/vendor/agent-cli/dist/src/context/member-profile.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-profile.js +91 -0
- package/vendor/agent-cli/dist/src/context/member-profile.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-selection.d.ts +7 -0
- package/vendor/agent-cli/dist/src/context/member-selection.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/member-selection.js +58 -0
- package/vendor/agent-cli/dist/src/context/member-selection.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts +6 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.js +24 -0
- package/vendor/agent-cli/dist/src/context/script-dependencies.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js +55 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-definition.d.ts +39 -0
- package/vendor/agent-cli/dist/src/context/team-definition.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-definition.js +78 -0
- package/vendor/agent-cli/dist/src/context/team-definition.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.d.ts +7 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.js +37 -0
- package/vendor/agent-cli/dist/src/context/team-knowledge.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-cache.d.ts +27 -0
- package/vendor/agent-cli/dist/src/context/template-cache.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-cache.js +100 -0
- package/vendor/agent-cli/dist/src/context/template-cache.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts +32 -0
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-seed.js +117 -0
- package/vendor/agent-cli/dist/src/context/template-seed.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.d.ts +19 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.js +292 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts +13 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.js +178 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.d.ts +54 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.js +184 -0
- package/vendor/agent-cli/dist/src/context/user-skill-install.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.d.ts +14 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.js +130 -0
- package/vendor/agent-cli/dist/src/context/zip-extract.js.map +1 -0
- package/vendor/agent-cli/dist/src/index.d.ts +56 -0
- package/vendor/agent-cli/dist/src/index.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/index.js +82 -0
- package/vendor/agent-cli/dist/src/index.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.d.ts +68 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js +242 -0
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.d.ts +40 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js +87 -0
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.d.ts +134 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.js +152 -0
- package/vendor/agent-cli/dist/src/lifecycle/registry.js.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.d.ts +40 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.js +149 -0
- package/vendor/agent-cli/dist/src/lifecycle/workspace-change.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/client.d.ts +12 -0
- package/vendor/agent-cli/dist/src/mcp/client.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/client.js +95 -0
- package/vendor/agent-cli/dist/src/mcp/client.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/connection.d.ts +14 -0
- package/vendor/agent-cli/dist/src/mcp/connection.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/connection.js +115 -0
- package/vendor/agent-cli/dist/src/mcp/connection.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/execute.d.ts +5 -0
- package/vendor/agent-cli/dist/src/mcp/execute.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/execute.js +26 -0
- package/vendor/agent-cli/dist/src/mcp/execute.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.d.ts +11 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.js +51 -0
- package/vendor/agent-cli/dist/src/mcp/instance-lock.js.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/types.d.ts +27 -0
- package/vendor/agent-cli/dist/src/mcp/types.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/mcp/types.js +2 -0
- package/vendor/agent-cli/dist/src/mcp/types.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/input.d.ts +21 -0
- package/vendor/agent-cli/dist/src/protocol/input.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/input.js +95 -0
- package/vendor/agent-cli/dist/src/protocol/input.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.d.ts +58 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.js +337 -0
- package/vendor/agent-cli/dist/src/protocol/link/channel.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.d.ts +13 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.js +27 -0
- package/vendor/agent-cli/dist/src/protocol/link/codec-json.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.d.ts +57 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.js +93 -0
- package/vendor/agent-cli/dist/src/protocol/link/envelope.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.d.ts +28 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.js +86 -0
- package/vendor/agent-cli/dist/src/protocol/link/liveness.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.d.ts +14 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.js +40 -0
- package/vendor/agent-cli/dist/src/protocol/link/middleware.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.d.ts +31 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.js +90 -0
- package/vendor/agent-cli/dist/src/protocol/link/rpc.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.d.ts +32 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.js +106 -0
- package/vendor/agent-cli/dist/src/protocol/link/transport-ws.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts +509 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js +131 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts +351 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js +103 -0
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.d.ts +9 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.js +58 -0
- package/vendor/agent-cli/dist/src/security/binary-read-receipts.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-parse.d.ts +21 -0
- package/vendor/agent-cli/dist/src/security/command-parse.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-parse.js +395 -0
- package/vendor/agent-cli/dist/src/security/command-parse.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-translate.d.ts +30 -0
- package/vendor/agent-cli/dist/src/security/command-translate.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/command-translate.js +161 -0
- package/vendor/agent-cli/dist/src/security/command-translate.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.d.ts +18 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.js +121 -0
- package/vendor/agent-cli/dist/src/security/context-write-policy.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/guard.d.ts +41 -0
- package/vendor/agent-cli/dist/src/security/guard.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/guard.js +154 -0
- package/vendor/agent-cli/dist/src/security/guard.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts +47 -0
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/mount-table.js +164 -0
- package/vendor/agent-cli/dist/src/security/mount-table.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.d.ts +23 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.js +110 -0
- package/vendor/agent-cli/dist/src/security/sandbox-path.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.d.ts +5 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.js +16 -0
- package/vendor/agent-cli/dist/src/security/tool-run-owner.js.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts +16 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.js +88 -0
- package/vendor/agent-cli/dist/src/security/tool-scope.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts +116 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/client.js +376 -0
- package/vendor/agent-cli/dist/src/session/client.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/custom-context.d.ts +6 -0
- package/vendor/agent-cli/dist/src/session/custom-context.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/custom-context.js +100 -0
- package/vendor/agent-cli/dist/src/session/custom-context.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.d.ts +38 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.js +87 -0
- package/vendor/agent-cli/dist/src/session/engine-decide.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.js +15 -0
- package/vendor/agent-cli/dist/src/session/execution-settlement.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-config.d.ts +13 -0
- package/vendor/agent-cli/dist/src/session/link-config.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-config.js +29 -0
- package/vendor/agent-cli/dist/src/session/link-config.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.d.ts +30 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.js +67 -0
- package/vendor/agent-cli/dist/src/session/link-outcome.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts +76 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-session.js +412 -0
- package/vendor/agent-cli/dist/src/session/link-session.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/local-execution.d.ts +28 -0
- package/vendor/agent-cli/dist/src/session/local-execution.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/local-execution.js +119 -0
- package/vendor/agent-cli/dist/src/session/local-execution.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/member-tools.d.ts +22 -0
- package/vendor/agent-cli/dist/src/session/member-tools.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/member-tools.js +72 -0
- package/vendor/agent-cli/dist/src/session/member-tools.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.d.ts +7 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.js +30 -0
- package/vendor/agent-cli/dist/src/session/process-artifact-publisher.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-environment.d.ts +3 -0
- package/vendor/agent-cli/dist/src/session/process-environment.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-environment.js +22 -0
- package/vendor/agent-cli/dist/src/session/process-environment.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-request.d.ts +36 -0
- package/vendor/agent-cli/dist/src/session/process-request.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-request.js +494 -0
- package/vendor/agent-cli/dist/src/session/process-request.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.d.ts +8 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.js +34 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-events.d.ts +81 -0
- package/vendor/agent-cli/dist/src/session/run-events.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-events.js +160 -0
- package/vendor/agent-cli/dist/src/session/run-events.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts +76 -0
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-setup.js +273 -0
- package/vendor/agent-cli/dist/src/session/run-setup.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts +41 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.js +64 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.d.ts +17 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.js +75 -0
- package/vendor/agent-cli/dist/src/session/team-persistence.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.d.ts +37 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js +232 -0
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-choice.d.ts +5 -0
- package/vendor/agent-cli/dist/src/session/user-choice.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-choice.js +80 -0
- package/vendor/agent-cli/dist/src/session/user-choice.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.d.ts +31 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js +104 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/app-id.d.ts +13 -0
- package/vendor/agent-cli/dist/src/shared/app-id.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/app-id.js +25 -0
- package/vendor/agent-cli/dist/src/shared/app-id.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.d.ts +13 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.js +16 -0
- package/vendor/agent-cli/dist/src/shared/auth-headers.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.d.ts +3 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.js +22 -0
- package/vendor/agent-cli/dist/src/shared/cli-version.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.d.ts +14 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.js +29 -0
- package/vendor/agent-cli/dist/src/shared/error-detail.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.d.ts +36 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.js +94 -0
- package/vendor/agent-cli/dist/src/shared/output-guard.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.d.ts +3 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.js +11 -0
- package/vendor/agent-cli/dist/src/shared/process-cwd.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-types.d.ts +60 -0
- package/vendor/agent-cli/dist/src/shared/process-types.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/process-types.js +10 -0
- package/vendor/agent-cli/dist/src/shared/process-types.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.d.ts +7 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.js +113 -0
- package/vendor/agent-cli/dist/src/shared/server-headers.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.d.ts +47 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.js +210 -0
- package/vendor/agent-cli/dist/src/shared/shell-runtime.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts +458 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.js +2 -0
- package/vendor/agent-cli/dist/src/shared/types.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.d.ts +22 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.js +2 -0
- package/vendor/agent-cli/dist/src/shared/user-choice.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.d.ts +9 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.js +85 -0
- package/vendor/agent-cli/dist/src/tools/artifact-publisher.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts +30 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.js +96 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.d.ts +16 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.js +104 -0
- package/vendor/agent-cli/dist/src/tools/context-program-publish.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts +21 -0
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program.js +207 -0
- package/vendor/agent-cli/dist/src/tools/context-program.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts +61 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.js +477 -0
- package/vendor/agent-cli/dist/src/tools/file-ops.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.d.ts +58 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.js +322 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.d.ts +24 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.js +160 -0
- package/vendor/agent-cli/dist/src/tools/ripgrep-search.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts +66 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js +65 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.d.ts +29 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.js +88 -0
- package/vendor/agent-cli/dist/src/tools/tool-timeout.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.d.ts +42 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.js +34 -0
- package/vendor/agent-cli/dist/src/tools/write-guard.js.map +1 -0
- package/vendor/agent-cli/package.json +29 -0
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template_name multiplayerManager
|
|
3
|
+
*
|
|
4
|
+
* 联网玩法能力(ES Module Singleton)。
|
|
5
|
+
*
|
|
6
|
+
* 职责:
|
|
7
|
+
* - 大厅:listRooms / createRoom / joinRoom / leaveRoom / describeRoom,全部经平台 Room HTTP。
|
|
8
|
+
* - 连 DS:只走网关 `/api/ds-proxy/{connect.port}`,`host` 由 urlBuilder 每次补;DS 刚被拉起时带重试。
|
|
9
|
+
* - 同步:sendPose(持续态 → state.set)/ sendEvent(一次性事件 → pub);收端经 getStateCallbacks 绑定。
|
|
10
|
+
* - bus 事件转发:
|
|
11
|
+
* mp-state-change / mp-peer-join / mp-peer-leave / mp-peer-pose
|
|
12
|
+
* mp-event / mp-room-closed / mp-disconnect / mp-error
|
|
13
|
+
*
|
|
14
|
+
* 不做:
|
|
15
|
+
* - 不实现玩法逻辑(移动 / 命中 / 胜负 / 结算归玩法业务 System 与 ds/)。
|
|
16
|
+
* - 不做本地预测 / 回滚 / 插值。
|
|
17
|
+
* - 不直连 DS(`ws://connect.host:port`):DS 在内网无公网入口与证书,网关是唯一入口。
|
|
18
|
+
*
|
|
19
|
+
* 关于 api:token / app_id / player_id / 身份 / request 一律从 platform-services 单例
|
|
20
|
+
* `PlatformServiceManager`(`src/skill-modules/platform-services/platform-service.mjs`)读,绝不自取,
|
|
21
|
+
* 也不要从 `runtime/lightgame/1.0.0` 引入。
|
|
22
|
+
* **唯独 api 一个字段例外**:身份单例把 api 封在闭包里、只在其内部 `request()` 用,对外无读口
|
|
23
|
+
* (方法白名单里没有 getApi);而连 DS 必须拿 api 的 host 原文去拼 `wss://{host}{prefix}/api/ds-proxy/{port}`,
|
|
24
|
+
* request()(POST 拿响应体、path 被正则限死)顶不了。故本模板在 `init()` 早期(早于游戏发 `ready`、
|
|
25
|
+
* 早于宿主下发 `runtime-init`,不会错过广播)**旁听同一条 runtime-init,只抽取 api 这一个字段**,
|
|
26
|
+
* origin/source 校验与去尾斜杠(apiBase)逻辑逐字对齐 platform-services 单例,保证同源同规则。旁听不影响
|
|
27
|
+
* 单例自身的监听(两者收同一条广播、各取所需)。
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { Client, getStateCallbacks, type Room } from '@colyseus/sdk';
|
|
31
|
+
// 与本文件同目录安装。哈希锁定,不要改 import,也不要删 log.ts / eventBus.ts。
|
|
32
|
+
import { Log } from './log';
|
|
33
|
+
import { bus } from './eventBus';
|
|
34
|
+
// 身份模块由同一 multiplayer 安装组放到同目录。不要改回 runtime/lightgame/1.0.0。
|
|
35
|
+
import { PlatformServiceManager } from './platform-service.mjs';
|
|
36
|
+
|
|
37
|
+
const LOG_TAG = 'MultiplayerManager';
|
|
38
|
+
/** DS 进程可能刚被平台拉起、还没 listen;重试上限与退避见 _connectDs。 */
|
|
39
|
+
const CONNECT_MAX_ATTEMPTS = 10;
|
|
40
|
+
/** 入站单包硬上限:超限时连接被以 code 1009 断开,不是丢包。必须按字节算。 */
|
|
41
|
+
const MAX_PAYLOAD_BYTES = 4 * 1024;
|
|
42
|
+
/** 等平台握手结算的上限。PlatformServiceManager 保证 5s 内 pending → active / noop,多给 1s 兜底。 */
|
|
43
|
+
const PLATFORM_SETTLE_TIMEOUT_MS = 6_000;
|
|
44
|
+
/**
|
|
45
|
+
* 时钟标定 ping 间隔。这是一个**低频测量**,不是每帧动作——3s 一次足够把偏移收敛住并跟随缓慢漂移。
|
|
46
|
+
* ⚠️ 绝不要把 ping 放进游戏循环 / update() / 每帧路径:偏移是慢变量,高频 ping 只会烧上行、抢占 patch 窗口,
|
|
47
|
+
* 一次都不会让标定更准。需要更快收敛就在连上后头几秒临时密一点,稳定后回落到这个间隔,仍远低于每帧。
|
|
48
|
+
*/
|
|
49
|
+
const CLOCK_PING_INTERVAL_MS = 3_000;
|
|
50
|
+
|
|
51
|
+
export type MpState = 'idle' | 'connecting' | 'in-room' | 'left' | 'error';
|
|
52
|
+
|
|
53
|
+
export interface MpInitConfig {
|
|
54
|
+
/** 房间名,须与 ds/main.mjs 里 rooms 的 key 一致。默认 'sync'。 */
|
|
55
|
+
roomName?: string;
|
|
56
|
+
/** 开房人数上限(1–64)。必须与 ds/ 的 maxClients、玩法人数三者相同。默认 8。 */
|
|
57
|
+
maxPlayers?: number;
|
|
58
|
+
/**
|
|
59
|
+
* 开房标题,仅供大厅列表展示,留空由平台填 'Room'。
|
|
60
|
+
* 平台**不保证唯一、也不支持按 title 查房**:别拿它当"房间号"再遍历 listRooms 反查,
|
|
61
|
+
* 撞标题时两人会进到不同的 room_id、双方都看不到对手。进房一律用 listRooms 给的 roomId。
|
|
62
|
+
*/
|
|
63
|
+
title?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface RoomBrief {
|
|
67
|
+
roomId: string;
|
|
68
|
+
title: string;
|
|
69
|
+
playerCount: number;
|
|
70
|
+
maxPlayers: number;
|
|
71
|
+
status: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface MpResult<T = undefined> {
|
|
75
|
+
ok: boolean;
|
|
76
|
+
/** 'OK' 或平台 result 枚举(ROOM_FULL / NOT_FOUND / DS_ALLOC_FAILED / AUTH_FAILED …)、本地码(NO_PLATFORM / CONNECT_FAILED / PAYLOAD_TOO_LARGE) */
|
|
77
|
+
code: string;
|
|
78
|
+
message: string;
|
|
79
|
+
data?: T;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** createRoom / joinRoom 可选。默认失败即释放座位。 */
|
|
83
|
+
export interface MpEnterOptions {
|
|
84
|
+
/** 占座成功但 DS 未连上时保留座位,供随后 joinRoom 重试。默认 false。 */
|
|
85
|
+
keepSeat?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface DsConnect {
|
|
89
|
+
host: string;
|
|
90
|
+
port: number;
|
|
91
|
+
protocol: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type EventHandler = (from: string, type: string, data: Record<string, unknown>) => void;
|
|
95
|
+
type StateFieldHandler = (value: any, previous: any) => void;
|
|
96
|
+
|
|
97
|
+
class MultiplayerManagerClass {
|
|
98
|
+
private _log = Log.scope(LOG_TAG);
|
|
99
|
+
|
|
100
|
+
private _roomName = 'sync';
|
|
101
|
+
private _maxPlayers = 8;
|
|
102
|
+
private _title = '';
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 从 runtime-init 旁听抽出的 api(HTTPS 网关,已去尾斜杠)。仅 _connectDs 拼 wss 端点用。
|
|
106
|
+
* 未收到合法广播前为 '',此时 _connectDs 走原 error 分支(不 join)。token/身份仍从单例读,不落这里。
|
|
107
|
+
*/
|
|
108
|
+
private _api = '';
|
|
109
|
+
private _apiListenerBound = false;
|
|
110
|
+
private _apiOrigin: string | null = null;
|
|
111
|
+
private _onRuntimeInit: ((event: MessageEvent) => void) | null = null;
|
|
112
|
+
|
|
113
|
+
private _room: Room<any> | null = null;
|
|
114
|
+
private _roomId = '';
|
|
115
|
+
/** 最近一次占座的 roomId。断线后 getRoomId() 已空,重连读这个或 mp-disconnect 的 roomId。 */
|
|
116
|
+
private _lastRoomId = '';
|
|
117
|
+
private _sessionId = '';
|
|
118
|
+
private _state: MpState = 'idle';
|
|
119
|
+
|
|
120
|
+
private _peers: Set<string> = new Set();
|
|
121
|
+
private _eventHandlers: Set<EventHandler> = new Set();
|
|
122
|
+
|
|
123
|
+
/** state 根字段订阅。跨连接保留,重连后自动重绑。 */
|
|
124
|
+
private _stateFieldHandlers: Map<string, Set<StateFieldHandler>> = new Map();
|
|
125
|
+
private _stateFieldUnbinds: Array<() => void> = [];
|
|
126
|
+
private _callbacks: any = null;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 时钟标定:本机时钟与 DS 时钟的偏移(ms)。`serverNow() = Date.now() + _clockOffset`。
|
|
130
|
+
* 只做**测量**,无玩法语义——与 getSessionId/getRoomId 同层,不是预测/插值/回滚。
|
|
131
|
+
* 未标定时为 0(即当作两端时钟一致,退化为无补偿),随 pong 用最小 RTT 样本收敛。
|
|
132
|
+
*/
|
|
133
|
+
private _clockOffset = 0;
|
|
134
|
+
private _clockCalibrated = false;
|
|
135
|
+
/** 最小 RTT 样本:只有更小的 RTT 才更新偏移(RTT 越小,单向延迟估得越准)。 */
|
|
136
|
+
private _minRtt = Infinity;
|
|
137
|
+
private _pingTimer: ReturnType<typeof setInterval> | null = null;
|
|
138
|
+
|
|
139
|
+
/** 幂等;在 PlatformServiceManager.init() 之后调用一次。不建连接,只记开房参数。 */
|
|
140
|
+
init(config: MpInitConfig = {}): void {
|
|
141
|
+
if (typeof config.roomName === 'string' && config.roomName.trim()) {
|
|
142
|
+
this._roomName = config.roomName.trim();
|
|
143
|
+
}
|
|
144
|
+
const max = Number(config.maxPlayers);
|
|
145
|
+
if (Number.isFinite(max) && max >= 1 && max <= 64) {
|
|
146
|
+
this._maxPlayers = Math.floor(max);
|
|
147
|
+
}
|
|
148
|
+
if (typeof config.title === 'string') this._title = config.title;
|
|
149
|
+
|
|
150
|
+
// 在此挂 api 旁听:init() 在游戏入口、发 `ready` 之前调,早于宿主下发 runtime-init,
|
|
151
|
+
// 保证不会错过广播(迟到的合法 runtime-init 也会更新 _api)。幂等,重复 init 不重复挂。
|
|
152
|
+
this._bindApiListener();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
getState(): MpState {
|
|
156
|
+
return this._state;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getRoomId(): string {
|
|
160
|
+
return this._roomId;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** 最近一次占座的 roomId。断线后 getRoomId() 为空;主动 leaveRoom / room_closed 后也为空。 */
|
|
164
|
+
getLastRoomId(): string {
|
|
165
|
+
return this._lastRoomId;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** 本机同步实体的唯一 key。不要用 player_id:同账号双开是两个 session。 */
|
|
169
|
+
getSessionId(): string {
|
|
170
|
+
return this._sessionId;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
getPeers(): string[] {
|
|
174
|
+
return [...this._peers];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 标定后的「DS 当前时钟」估值(ms):`Date.now() + getClockOffset()`。
|
|
179
|
+
* 用途:把收到的权威快照按年龄外推到当前时刻——`age = getServerNow() − snap.t`(snap.t 是 DS 打的时间戳)。
|
|
180
|
+
* 这是收端形态 C(本地模拟 + 快照纠偏)的前置测量,见 `knowledge/Multiplayer/StateSyncKnowledge.md`「形态 C」。
|
|
181
|
+
* ⚠️ 这是**测量设施**,不是预测/插值/回滚(那些仍是玩法层的活,模板不做);未标定时 offset 为 0,退化为「当作两端时钟一致」。
|
|
182
|
+
*/
|
|
183
|
+
getServerNow(): number {
|
|
184
|
+
return Date.now() + this._clockOffset;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** 本机时钟与 DS 时钟的偏移(ms,`serverNow = Date.now() + offset`)。未标定时为 0。 */
|
|
188
|
+
getClockOffset(): number {
|
|
189
|
+
return this._clockOffset;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
isConnected(): boolean {
|
|
193
|
+
return !!this._room;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ===================== 大厅:Room HTTP =====================
|
|
197
|
+
|
|
198
|
+
async listRooms(): Promise<MpResult<RoomBrief[]>> {
|
|
199
|
+
const res = await this._roomPost('list', {});
|
|
200
|
+
if (!res.ok) return { ok: false, code: res.code, message: res.message };
|
|
201
|
+
|
|
202
|
+
const items = (res.data as Record<string, unknown>)?.items;
|
|
203
|
+
const rooms = Array.isArray(items) ? items.map((raw) => this._toRoomBrief(raw)) : [];
|
|
204
|
+
return { ok: true, code: 'OK', message: '', data: rooms };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** 开房并连上其 DS。version_id 取自 URL `?config=`。DS 连不上时默认 leaveRoom。 */
|
|
208
|
+
async createRoom(options?: MpEnterOptions): Promise<MpResult<{ roomId: string }>> {
|
|
209
|
+
const versionId = this._getVersionId();
|
|
210
|
+
if (!versionId) {
|
|
211
|
+
return { ok: false, code: 'INVALID_ARGUMENT', message: '缺少 ?config=version_id' };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const body: Record<string, unknown> = { version_id: versionId, max_players: this._maxPlayers };
|
|
215
|
+
if (this._title) body.title = this._title;
|
|
216
|
+
|
|
217
|
+
const res = await this._roomPost('create', body);
|
|
218
|
+
if (!res.ok) return { ok: false, code: res.code, message: res.message };
|
|
219
|
+
return this._afterSeat(res.data, options?.keepSeat === true);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** 进房并连上其 DS。同一账号重复 join 是幂等的,可直接用于断线重连。 */
|
|
223
|
+
async joinRoom(roomId: string, options?: MpEnterOptions): Promise<MpResult<{ roomId: string }>> {
|
|
224
|
+
if (typeof roomId !== 'string' || !roomId.trim()) {
|
|
225
|
+
return { ok: false, code: 'INVALID_ARGUMENT', message: 'roomId 不能为空' };
|
|
226
|
+
}
|
|
227
|
+
const res = await this._roomPost('join', { room_id: roomId.trim() });
|
|
228
|
+
if (!res.ok) return { ok: false, code: res.code, message: res.message };
|
|
229
|
+
return this._afterSeat(res.data, options?.keepSeat === true);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** 只读查询,不占座。 */
|
|
233
|
+
async describeRoom(roomId: string): Promise<MpResult<RoomBrief>> {
|
|
234
|
+
if (typeof roomId !== 'string' || !roomId.trim()) {
|
|
235
|
+
return { ok: false, code: 'INVALID_ARGUMENT', message: 'roomId 不能为空' };
|
|
236
|
+
}
|
|
237
|
+
const res = await this._roomPost('describe', { room_id: roomId.trim() });
|
|
238
|
+
if (!res.ok) return { ok: false, code: res.code, message: res.message };
|
|
239
|
+
return { ok: true, code: 'OK', message: '', data: this._toRoomBrief(res.data) };
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 退出:先断 Colyseus,再调 HTTP leave。顺序不能反——只断 WS 会让大厅座位残留。
|
|
244
|
+
* HTTP leave 不杀 DS,空房由 ds/ 自己 end('empty') 回收。
|
|
245
|
+
*/
|
|
246
|
+
async leaveRoom(): Promise<void> {
|
|
247
|
+
const roomId = this._roomId;
|
|
248
|
+
this._lastRoomId = '';
|
|
249
|
+
this._detachRoom();
|
|
250
|
+
this._setState('left');
|
|
251
|
+
if (!roomId) return;
|
|
252
|
+
await this._roomPost('leave', { room_id: roomId });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ===================== 同步收发 =====================
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 上报本机持续态(位姿等),写进 players[sessionId].data。
|
|
259
|
+
* 超 4KB 直接丢弃并 warn:发出去会被断连,砍精度或砍字段而不是拆包。
|
|
260
|
+
*/
|
|
261
|
+
sendPose(pose: unknown): MpResult {
|
|
262
|
+
if (!this._room) return { ok: false, code: 'NOT_IN_ROOM', message: '未连接 DS' };
|
|
263
|
+
|
|
264
|
+
const encoded = this._encode(pose);
|
|
265
|
+
if (encoded == null) {
|
|
266
|
+
this._log.warn('sendPose 超 4KB 已丢弃,请砍精度或字段');
|
|
267
|
+
return { ok: false, code: 'PAYLOAD_TOO_LARGE', message: '单包超 4KB' };
|
|
268
|
+
}
|
|
269
|
+
this._room.send('state.set', { data: encoded });
|
|
270
|
+
return { ok: true, code: 'OK', message: '' };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** 发一次性事件(pub)。ds/ 决定原样转发还是校验后再广播。 */
|
|
274
|
+
sendEvent(type: string, data?: unknown): MpResult {
|
|
275
|
+
if (!this._room) return { ok: false, code: 'NOT_IN_ROOM', message: '未连接 DS' };
|
|
276
|
+
if (typeof type !== 'string' || !type) {
|
|
277
|
+
return { ok: false, code: 'INVALID_ARGUMENT', message: 'type 不能为空' };
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const encoded = data === undefined ? '' : this._encode(data);
|
|
281
|
+
if (encoded == null) {
|
|
282
|
+
this._log.warn(`sendEvent(${type}) 超 4KB 已丢弃`);
|
|
283
|
+
return { ok: false, code: 'PAYLOAD_TOO_LARGE', message: '单包超 4KB' };
|
|
284
|
+
}
|
|
285
|
+
this._room.send('pub', { type, data: encoded });
|
|
286
|
+
return { ok: true, code: 'OK', message: '' };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* 监听 evt。返回 off 函数。
|
|
291
|
+
* 自己 pub 回来的已过滤;`from === ''` 表示这条来自 DS 自己。
|
|
292
|
+
*/
|
|
293
|
+
onEvent(handler: EventHandler): () => void {
|
|
294
|
+
if (typeof handler !== 'function') return () => { /* noop */ };
|
|
295
|
+
this._eventHandlers.add(handler);
|
|
296
|
+
return () => this._eventHandlers.delete(handler);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 监听 state 根字段(字段名由 ds/ 的 Schema 决定)。返回 off 函数。
|
|
301
|
+
*
|
|
302
|
+
* 与 sendPose 的分工:玩家各自的数据走 players[sid].data,房间级的走 state 根字段。
|
|
303
|
+
* 根字段已有值时立即回调一次,所以后进房的人不需要 DS 补发(evt 则要自己在 onJoin 补)。
|
|
304
|
+
*
|
|
305
|
+
* 可在连接前调用:订阅跨连接保留,连上或重连后自动重绑。
|
|
306
|
+
*/
|
|
307
|
+
onStateField(field: string, handler: StateFieldHandler): () => void {
|
|
308
|
+
if (typeof field !== 'string' || !field || typeof handler !== 'function') {
|
|
309
|
+
return () => { /* noop */ };
|
|
310
|
+
}
|
|
311
|
+
let handlers = this._stateFieldHandlers.get(field);
|
|
312
|
+
if (!handlers) {
|
|
313
|
+
handlers = new Set();
|
|
314
|
+
this._stateFieldHandlers.set(field, handlers);
|
|
315
|
+
this._bindStateField(field);
|
|
316
|
+
}
|
|
317
|
+
handlers.add(handler);
|
|
318
|
+
return () => {
|
|
319
|
+
const set = this._stateFieldHandlers.get(field);
|
|
320
|
+
if (!set) return;
|
|
321
|
+
set.delete(handler);
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ===================== 内部:Room HTTP =====================
|
|
326
|
+
|
|
327
|
+
private async _roomPost(
|
|
328
|
+
action: 'create' | 'list' | 'join' | 'leave' | 'describe',
|
|
329
|
+
body: Record<string, unknown>,
|
|
330
|
+
): Promise<MpResult<unknown>> {
|
|
331
|
+
// 首屏(如大厅 create() 里直接拉房间列表)调进来时平台可能还在握手,pending 期间
|
|
332
|
+
// getAppId() 恒为空。不等就返 NO_PLATFORM 会把"还没就绪"误报成"环境不支持联机"。
|
|
333
|
+
await this._awaitPlatformSettled();
|
|
334
|
+
|
|
335
|
+
const platformState = PlatformServiceManager.getState();
|
|
336
|
+
const appId = PlatformServiceManager.getAppId();
|
|
337
|
+
if (platformState === 'noop') {
|
|
338
|
+
this._log.warn(`room/${action} 跳过:当前环境无平台身份`);
|
|
339
|
+
return { ok: false, code: 'NO_PLATFORM', message: '当前环境不支持联机' };
|
|
340
|
+
}
|
|
341
|
+
if (!appId) {
|
|
342
|
+
this._log.warn(`room/${action} 跳过:平台握手未完成 state=${platformState}`);
|
|
343
|
+
return { ok: false, code: 'NO_PLATFORM', message: '平台连接未就绪,请稍后重试' };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// app_id 每个接口必带;engine 不要传(平台按 app_id 查引擎)。
|
|
347
|
+
const res = await PlatformServiceManager.request({
|
|
348
|
+
path: `/api/room/${action}`,
|
|
349
|
+
body: { app_id: appId, ...body },
|
|
350
|
+
});
|
|
351
|
+
return { ok: res.ok, code: res.code, message: res.message, data: res.data };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 等平台握手结算。PlatformServiceManager 保证 pending 在 5s 内必转 active 或 noop,
|
|
356
|
+
* 这里的超时只是兜底:万一接入方漏了 PlatformServiceManager.init()(state 恒 pending),
|
|
357
|
+
* 也不能把大厅调用永久挂住。
|
|
358
|
+
*/
|
|
359
|
+
private async _awaitPlatformSettled(): Promise<void> {
|
|
360
|
+
if (PlatformServiceManager.getState() !== 'pending') return;
|
|
361
|
+
|
|
362
|
+
await new Promise<void>((resolve) => {
|
|
363
|
+
let settled = false;
|
|
364
|
+
let off: (() => void) | null = null;
|
|
365
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
366
|
+
|
|
367
|
+
const finish = () => {
|
|
368
|
+
if (settled) return;
|
|
369
|
+
settled = true;
|
|
370
|
+
if (timer) clearTimeout(timer);
|
|
371
|
+
off?.();
|
|
372
|
+
resolve();
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
off = PlatformServiceManager.on('state-change', (next: string) => {
|
|
376
|
+
if (next !== 'pending') finish();
|
|
377
|
+
});
|
|
378
|
+
timer = setTimeout(finish, PLATFORM_SETTLE_TIMEOUT_MS);
|
|
379
|
+
// 订阅前可能已经结算完。
|
|
380
|
+
if (PlatformServiceManager.getState() !== 'pending') finish();
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** create / join 拿到座位后:记 roomId 并连 DS。连不上默认释放座位。 */
|
|
385
|
+
private async _afterSeat(data: unknown, keepSeat: boolean): Promise<MpResult<{ roomId: string }>> {
|
|
386
|
+
const seat = (data ?? {}) as Record<string, unknown>;
|
|
387
|
+
const roomId = typeof seat.room_id === 'string' ? seat.room_id : '';
|
|
388
|
+
const connect = seat.connect as DsConnect | undefined;
|
|
389
|
+
|
|
390
|
+
if (!roomId || !connect || typeof connect.port !== 'number') {
|
|
391
|
+
return { ok: false, code: 'INTERNAL_ERROR', message: '平台未返回 room_id / connect' };
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
this._roomId = roomId;
|
|
395
|
+
this._lastRoomId = roomId;
|
|
396
|
+
const connected = await this._connectDs(connect);
|
|
397
|
+
if (!connected) {
|
|
398
|
+
if (!keepSeat) await this.leaveRoom();
|
|
399
|
+
return { ok: false, code: 'CONNECT_FAILED', message: '连接对局服务失败,请稍后重试' };
|
|
400
|
+
}
|
|
401
|
+
return { ok: true, code: 'OK', message: '', data: { roomId } };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private _toRoomBrief(raw: unknown): RoomBrief {
|
|
405
|
+
const item = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>;
|
|
406
|
+
const num = (v: unknown): number => {
|
|
407
|
+
const n = Number(v);
|
|
408
|
+
return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : 0;
|
|
409
|
+
};
|
|
410
|
+
const pick = (snake: string, camel: string): unknown =>
|
|
411
|
+
item[snake] !== undefined && item[snake] !== null ? item[snake] : item[camel];
|
|
412
|
+
return {
|
|
413
|
+
roomId: String(pick('room_id', 'roomId') ?? ''),
|
|
414
|
+
title: String(item.title ?? ''),
|
|
415
|
+
playerCount: num(pick('player_count', 'playerCount')),
|
|
416
|
+
maxPlayers: num(pick('max_players', 'maxPlayers')),
|
|
417
|
+
status: String(item.status ?? ''),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private _getVersionId(): string {
|
|
422
|
+
if (typeof window === 'undefined') return '';
|
|
423
|
+
return new URLSearchParams(window.location.search).get('config') ?? '';
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// ===================== 内部:api 旁听 =====================
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 旁听 runtime-init,只抽 api 一个字段。origin/source 校验与 apiBase 去尾斜杠逻辑
|
|
430
|
+
* 逐字对齐 platform-services 的 platform-service.mjs 的 onMessage,保证与身份单例同源同规则。
|
|
431
|
+
* 幂等:重复 init 不重复挂监听。无 window / 无父窗口 / 无法确认父源时不挂(此时本就没有联机宿主)。
|
|
432
|
+
*/
|
|
433
|
+
private _bindApiListener(): void {
|
|
434
|
+
if (this._apiListenerBound) return;
|
|
435
|
+
if (typeof window === 'undefined' || !window.addEventListener || window.parent === window) return;
|
|
436
|
+
|
|
437
|
+
const origin = this._parentOrigin(window);
|
|
438
|
+
if (!origin) return; // 无法确认可信父源:与 platform-services 单例一致,直接不监听(等价 noop)。
|
|
439
|
+
this._apiOrigin = origin;
|
|
440
|
+
|
|
441
|
+
const handler = (event: MessageEvent): void => {
|
|
442
|
+
// 与 platform-services onMessage 同款校验:只收可信父窗口、指定 origin 的消息。
|
|
443
|
+
if (event.source !== window.parent || event.origin !== origin) return;
|
|
444
|
+
const payload = (event.data || {}) as { type?: unknown; data?: unknown };
|
|
445
|
+
if (payload.type !== 'runtime-init') return;
|
|
446
|
+
const data = (payload.data && typeof payload.data === 'object' ? payload.data : {}) as Record<string, unknown>;
|
|
447
|
+
const api = typeof data.api === 'string' ? this._apiBase(data.api.trim()) : null;
|
|
448
|
+
if (!api) return; // 非法 api(非 https / 带凭证或 query 等):与 platform-services 一致,忽略。
|
|
449
|
+
this._api = api;
|
|
450
|
+
};
|
|
451
|
+
this._onRuntimeInit = handler;
|
|
452
|
+
window.addEventListener('message', handler);
|
|
453
|
+
this._apiListenerBound = true;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* 确认可信父窗口 origin。逐字对齐 platform-services 的 parentOrigin:referrer 优先,退回同源父窗口 origin;
|
|
458
|
+
* 只认 http/https。本模板不接 getPlatformService 的 targetOrigin,故 explicit 恒省略(走 referrer/父源)。
|
|
459
|
+
*/
|
|
460
|
+
private _parentOrigin(win: Window): string | null {
|
|
461
|
+
const valid = (value: unknown): string | null => {
|
|
462
|
+
try {
|
|
463
|
+
const url = new URL(String(value));
|
|
464
|
+
return /^https?:$/.test(url.protocol) ? url.origin : null;
|
|
465
|
+
} catch {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const referrer = valid(win?.document?.referrer);
|
|
470
|
+
if (referrer) return referrer;
|
|
471
|
+
try {
|
|
472
|
+
return valid(win?.parent?.location?.origin);
|
|
473
|
+
} catch {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* 规整 api 网关地址。逐字对齐 platform-services 的 apiBase:只接受 https(本机开发允许 localhost/127.0.0.1/::1 的 http),
|
|
480
|
+
* 拒绝带 username/password/search/hash 的 URL,去尾斜杠。非法返回 null。
|
|
481
|
+
*/
|
|
482
|
+
private _apiBase(value: string): string | null {
|
|
483
|
+
try {
|
|
484
|
+
const url = new URL(value);
|
|
485
|
+
const local = url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
486
|
+
if ((url.protocol !== 'https:' && !local) || url.username || url.password || url.search || url.hash) {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
return url.href.replace(/\/+$/, '');
|
|
490
|
+
} catch {
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// ===================== 内部:连 DS =====================
|
|
496
|
+
|
|
497
|
+
private async _connectDs(connect: DsConnect): Promise<boolean> {
|
|
498
|
+
// api 由 init() 里的 runtime-init 旁听抽出(见 _bindApiListener);身份单例不暴露 api 读口,
|
|
499
|
+
// 故本模板自取这一个字段。为空时(广播未到 / 非法源)不要调 joinOrCreate。
|
|
500
|
+
const api = this._api;
|
|
501
|
+
if (!api) {
|
|
502
|
+
this._log.warn(`连 DS 跳过:api 未就绪(platformState=${PlatformServiceManager.getState()})`);
|
|
503
|
+
this._setState('error');
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
let endpoint: string;
|
|
508
|
+
try {
|
|
509
|
+
const url = new URL(api);
|
|
510
|
+
const wsProto = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
511
|
+
const prefix = url.pathname.replace(/\/+$/, '');
|
|
512
|
+
endpoint = `${wsProto}//${url.host}${prefix}/api/ds-proxy/${connect.port}`;
|
|
513
|
+
} catch (err) {
|
|
514
|
+
this._log.error(`api 解析失败: ${api}`, err);
|
|
515
|
+
this._setState('error');
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
const dsHost = String(connect.host ?? '').trim();
|
|
520
|
+
// endpoint 不带 ?host=:Colyseus 会丢掉 URL 的 search,只能在 urlBuilder 里每次补。
|
|
521
|
+
const client = new Client(endpoint, {
|
|
522
|
+
urlBuilder(url: URL) {
|
|
523
|
+
if (dsHost) url.searchParams.set('host', dsHost);
|
|
524
|
+
return url.toString();
|
|
525
|
+
},
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
this._setState('connecting');
|
|
529
|
+
const joinOptions = this._joinOptions();
|
|
530
|
+
|
|
531
|
+
for (let attempt = 1; attempt <= CONNECT_MAX_ATTEMPTS; attempt++) {
|
|
532
|
+
try {
|
|
533
|
+
// 传的是进程内房间名(ds/main.mjs 的 key),不是 roomId——
|
|
534
|
+
// 进哪个进程已由 HTTP 的 connect 决定,改成 roomId 会在 DS 里另建一间没人认识的房。
|
|
535
|
+
const room = await client.joinOrCreate<any>(this._roomName, joinOptions);
|
|
536
|
+
this._attachRoom(room);
|
|
537
|
+
this._setState('in-room');
|
|
538
|
+
this._log.info(`DS 已连接 session=${room.sessionId} room=${this._roomId} attempt=${attempt}`);
|
|
539
|
+
return true;
|
|
540
|
+
} catch (err) {
|
|
541
|
+
this._log.warn(`DS 连接失败 attempt=${attempt}/${CONNECT_MAX_ATTEMPTS}`, err);
|
|
542
|
+
if (attempt < CONNECT_MAX_ATTEMPTS) {
|
|
543
|
+
const delay = Math.min(500 + (attempt - 1) * 100, 1000);
|
|
544
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
this._setState('error');
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** join options 只用于 DS 向平台上报在场名单;DS 不会拿它做权限判断。 */
|
|
554
|
+
private _joinOptions(): { uid: number; player_id: string } {
|
|
555
|
+
const playerId = PlatformServiceManager.getPlayerId();
|
|
556
|
+
const m = /^u(\d+)$/i.exec(playerId.trim());
|
|
557
|
+
return { uid: m ? Number(m[1]) || 0 : 0, player_id: playerId };
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ===================== 内部:房间监听 =====================
|
|
561
|
+
|
|
562
|
+
private _attachRoom(room: Room<any>): void {
|
|
563
|
+
this._room = room;
|
|
564
|
+
this._sessionId = room.sessionId;
|
|
565
|
+
this._peers.clear();
|
|
566
|
+
|
|
567
|
+
// 0.17 起 Schema 回调迁到 callbacks proxy;直接 room.state.players.onAdd 无效。
|
|
568
|
+
const $ = getStateCallbacks(room);
|
|
569
|
+
this._callbacks = $;
|
|
570
|
+
const me = room.sessionId;
|
|
571
|
+
|
|
572
|
+
// 连接前注册的 state 根字段订阅在这里补绑(重连同理)。
|
|
573
|
+
for (const field of this._stateFieldHandlers.keys()) this._bindStateField(field);
|
|
574
|
+
|
|
575
|
+
$(room.state).players.onAdd((player: any, sessionId: string) => {
|
|
576
|
+
const sid = String(sessionId ?? '');
|
|
577
|
+
if (!sid || sid === me) return;
|
|
578
|
+
this._peers.add(sid);
|
|
579
|
+
bus.emit('mp-peer-join', sid);
|
|
580
|
+
this._emitPose(sid, player?.data);
|
|
581
|
+
$(player).listen('data', (value: unknown) => this._emitPose(sid, value));
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
$(room.state).players.onRemove((_player: any, sessionId: string) => {
|
|
585
|
+
const sid = String(sessionId ?? '');
|
|
586
|
+
if (!sid || sid === me) return;
|
|
587
|
+
this._peers.delete(sid);
|
|
588
|
+
bus.emit('mp-peer-leave', sid);
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
room.onMessage('evt', (msg: any) => {
|
|
592
|
+
if (this._room !== room || !msg) return;
|
|
593
|
+
const from = typeof msg.from === 'string' ? msg.from : '';
|
|
594
|
+
// 只跳过自己 pub 又回来的;from === '' 是 DS 自己发的,要透传给业务。
|
|
595
|
+
if (from && from === me) return;
|
|
596
|
+
const type = msg.type != null ? String(msg.type) : '';
|
|
597
|
+
const data = this._parse(msg.data);
|
|
598
|
+
bus.emit('mp-event', from, type, data);
|
|
599
|
+
for (const handler of [...this._eventHandlers]) {
|
|
600
|
+
try {
|
|
601
|
+
handler(from, type, data);
|
|
602
|
+
} catch (err) {
|
|
603
|
+
this._log.warn('onEvent 回调抛错', err);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
// 本局正常结束(空房 / 结算)。与断线不同:不要重连。
|
|
609
|
+
room.onMessage('room_closed', (msg: any) => {
|
|
610
|
+
if (this._room !== room) return;
|
|
611
|
+
const reason = String(msg?.reason ?? 'closed');
|
|
612
|
+
this._log.warn(`房间关闭: ${reason}`);
|
|
613
|
+
this._lastRoomId = '';
|
|
614
|
+
this._detachRoom();
|
|
615
|
+
this._setState('left');
|
|
616
|
+
bus.emit('mp-room-closed', reason);
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
// 时钟标定回程:DS 定向回的 pong(见 ds/ 的 _onPing)。只做测量,不触发任何 bus 事件。
|
|
620
|
+
room.onMessage('pong', (msg: any) => {
|
|
621
|
+
if (this._room !== room || !msg) return;
|
|
622
|
+
this._onPong(Number(msg.t) || 0, Number(msg.st) || 0);
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
room.onError((code: number, message?: string) => {
|
|
626
|
+
if (this._room !== room) return;
|
|
627
|
+
this._log.warn(`onError code=${code} message=${message ?? ''}`);
|
|
628
|
+
bus.emit('mp-error', String(code), message ?? '');
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
// 守卫 this._room !== room:leaveRoom 主动断开也会触发 onLeave,
|
|
632
|
+
// 不拦会误报断线,业务照此自动重连就成死循环。
|
|
633
|
+
room.onLeave((code: number) => {
|
|
634
|
+
if (this._room !== room) return;
|
|
635
|
+
const roomId = this._roomId;
|
|
636
|
+
this._lastRoomId = roomId;
|
|
637
|
+
this._log.info(`DS 断开 code=${code} room=${roomId}`);
|
|
638
|
+
this._detachRoom();
|
|
639
|
+
this._setState('left');
|
|
640
|
+
// 带上 roomId:业务据此重连(joinRoom 幂等)。晚于 detach 发,保证 handler 里状态干净。
|
|
641
|
+
bus.emit('mp-disconnect', code, roomId);
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
// 时钟标定 ping 循环:连上即开,低频(3s)测量偏移,_detachRoom 里停。玩法不用形态 C 时这几个包也无害。
|
|
645
|
+
this._startClockPing();
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
private _detachRoom(): void {
|
|
649
|
+
const room = this._room;
|
|
650
|
+
this._room = null;
|
|
651
|
+
this._roomId = '';
|
|
652
|
+
this._sessionId = '';
|
|
653
|
+
this._peers.clear();
|
|
654
|
+
this._stopClockPing();
|
|
655
|
+
|
|
656
|
+
// 只解绑 Colyseus 侧回调,_stateFieldHandlers 保留供重连后重绑。
|
|
657
|
+
for (const off of this._stateFieldUnbinds) {
|
|
658
|
+
try {
|
|
659
|
+
off();
|
|
660
|
+
} catch {
|
|
661
|
+
/* 连接已销毁 */
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
this._stateFieldUnbinds = [];
|
|
665
|
+
this._callbacks = null;
|
|
666
|
+
|
|
667
|
+
if (!room) return;
|
|
668
|
+
try {
|
|
669
|
+
room.leave();
|
|
670
|
+
} catch {
|
|
671
|
+
/* 已断开 */
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
private _bindStateField(field: string): void {
|
|
676
|
+
const room = this._room;
|
|
677
|
+
const $ = this._callbacks;
|
|
678
|
+
if (!room || !$) return;
|
|
679
|
+
|
|
680
|
+
// listen 的 immediate 默认为 true:字段已有值时立刻回调一次。
|
|
681
|
+
const off = $(room.state).listen(field, (value: any, previous: any) => {
|
|
682
|
+
if (this._room !== room) return;
|
|
683
|
+
bus.emit('mp-state-field', field, value, previous);
|
|
684
|
+
for (const handler of [...(this._stateFieldHandlers.get(field) ?? [])]) {
|
|
685
|
+
try {
|
|
686
|
+
handler(value, previous);
|
|
687
|
+
} catch (err) {
|
|
688
|
+
this._log.warn(`onStateField(${field}) 回调抛错`, err);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
if (typeof off === 'function') this._stateFieldUnbinds.push(off);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
private _emitPose(sessionId: string, raw: unknown): void {
|
|
696
|
+
bus.emit('mp-peer-pose', sessionId, this._parse(raw));
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
// ===================== 内部:时钟标定 =====================
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* 低频 ping DS 测时钟偏移。连上即开、断开即停;间隔 3s,不进游戏循环。
|
|
703
|
+
* 每次 ping 带一个本机时间戳 `t`,DS 原样回传(配 `st` = DS 当前时钟),据此在 _onPong 里算偏移。
|
|
704
|
+
*/
|
|
705
|
+
private _startClockPing(): void {
|
|
706
|
+
this._stopClockPing();
|
|
707
|
+
this._sendPing();
|
|
708
|
+
this._pingTimer = setInterval(() => this._sendPing(), CLOCK_PING_INTERVAL_MS);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
private _stopClockPing(): void {
|
|
712
|
+
if (this._pingTimer) {
|
|
713
|
+
clearInterval(this._pingTimer);
|
|
714
|
+
this._pingTimer = null;
|
|
715
|
+
}
|
|
716
|
+
// 偏移不清零:换连接(重连)后先沿用上次标定值,等新 pong 收敛,避免瞬间回退到无补偿。
|
|
717
|
+
this._minRtt = Infinity;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** 走 pub 契约上行(sendEvent 同一条路),type='ping',DS 侧 _onPing 认这个 type。 */
|
|
721
|
+
private _sendPing(): void {
|
|
722
|
+
const room = this._room;
|
|
723
|
+
if (!room) return;
|
|
724
|
+
// 只发一个时间戳,远小于 4KB;不经 sendEvent 的公开 API 是为了不与业务事件混淆,但线上形状同为 pub。
|
|
725
|
+
const encoded = this._encode({ t: Date.now() });
|
|
726
|
+
if (encoded == null) return;
|
|
727
|
+
room.send('pub', { type: 'ping', data: encoded });
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* 收到 pong:用**最小 RTT 样本**更新偏移。
|
|
732
|
+
* - `rtt = now − t`(t 是这次 ping 发出时打的本机时间戳,原样回来的)。
|
|
733
|
+
* - 只在 rtt 创新低时才更新:`offset = st − (t + rtt/2)`(假设来回对称,单向 ≈ rtt/2)。
|
|
734
|
+
* 最小 RTT 抗抖:某次网络抖动导致的大 RTT 样本会把单向延迟估偏,直接丢弃只留最干净的那次。
|
|
735
|
+
*/
|
|
736
|
+
private _onPong(t: number, st: number): void {
|
|
737
|
+
if (!t || !st) return;
|
|
738
|
+
const rtt = Date.now() - t;
|
|
739
|
+
if (rtt < 0 || rtt >= this._minRtt) return;
|
|
740
|
+
this._minRtt = rtt;
|
|
741
|
+
this._clockOffset = st - (t + rtt / 2);
|
|
742
|
+
this._clockCalibrated = true;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// ===================== 内部:编解码 =====================
|
|
746
|
+
|
|
747
|
+
/** data 线上是字符串;宽容处理 object。 */
|
|
748
|
+
private _parse(raw: unknown): Record<string, unknown> {
|
|
749
|
+
if (raw == null) return {};
|
|
750
|
+
if (typeof raw === 'object') return raw as Record<string, unknown>;
|
|
751
|
+
if (typeof raw !== 'string') return {};
|
|
752
|
+
try {
|
|
753
|
+
return JSON.parse(raw || '{}');
|
|
754
|
+
} catch {
|
|
755
|
+
return {};
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/** 归一为字符串并按字节卡 4KB;超限返回 null。 */
|
|
760
|
+
private _encode(data: unknown): string | null {
|
|
761
|
+
let raw: string;
|
|
762
|
+
if (typeof data === 'string') {
|
|
763
|
+
raw = data;
|
|
764
|
+
} else {
|
|
765
|
+
try {
|
|
766
|
+
raw = JSON.stringify(data ?? {});
|
|
767
|
+
} catch {
|
|
768
|
+
return null;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
// 中文 UTF-8 每字 3 字节,String.length 会低估。
|
|
772
|
+
return new TextEncoder().encode(raw).length > MAX_PAYLOAD_BYTES ? null : raw;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
private _setState(next: MpState): void {
|
|
776
|
+
if (this._state === next) return;
|
|
777
|
+
const prev = this._state;
|
|
778
|
+
this._state = next;
|
|
779
|
+
bus.emit('mp-state-change', next, prev);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
export const MultiplayerManager = new MultiplayerManagerClass();
|