@craft_eco/craft-mcp 0.1.22 → 0.1.26
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 +28 -7
- package/bin/craft-mcp.mjs +10 -2
- package/dist-server/game-workflow/bundle-files.mjs +43 -0
- package/dist-server/game-workflow/engines.mjs +13 -6
- package/dist-server/game-workflow/project-bundles.mjs +90 -0
- package/dist-server/game-workflow/project-context.mjs +91 -0
- package/dist-server/game-workflow/projects.mjs +16 -4
- package/dist-server/integrations/config.mjs +71 -0
- package/dist-server/integrations/files.mjs +54 -0
- package/dist-server/integrations/hosts.mjs +30 -0
- package/dist-server/integrations/install.mjs +86 -0
- package/dist-server/integrations/runtime.mjs +71 -0
- package/dist-server/mcp/server.mjs +13 -9
- package/dist-server/preview/preview-launcher.mjs +9 -2
- package/dist-server/preview/preview-start.mjs +2 -2
- package/package.json +10 -1
- package/resources/craft-create/SKILL.md +14 -0
- package/resources/craft-game-maker/SKILL.md +77 -71
- package/resources/craft-game-maker/js.md +10 -10
- package/resources/craft-game-maker/js3d.md +13 -13
- package/resources/game_visual_qa.mjs +1149 -1149
- package/resources/js/bundle.json +93 -0
- package/resources/js/context/AGENTS.md +15 -102
- package/resources/js/context/knowledge/AigcWiring.md +5 -196
- package/resources/js/context/knowledge/AssetUrl.md +5 -20
- package/resources/js/context/knowledge/Layout.md +7 -0
- package/resources/js/context/knowledge/Lifecycle.md +6 -27
- package/resources/js/context/skills/aigc-generate/SKILL.md +6 -141
- package/resources/js/context/skills/asset-search/SKILL.md +5 -62
- package/resources/js/context/skills/asset-search/references/resource-config.md +9 -0
- package/resources/js/context/skills/export-config/SKILL.md +7 -19
- package/resources/js/context/skills/export-config/scripts/export-config.mjs +3 -45
- package/resources/js/context/skills/index.json +30 -0
- package/resources/js/context/skills/visual-qa/SKILL.md +6 -28
- package/resources/js/project/README.md +4 -96
- package/resources/js/project/package.json +1 -2
- package/resources/js/project/scripts/config-export/panel-resource-path.mjs +106 -0
- package/resources/js/{context/skills/export-config/scripts → project/scripts/config-export}/sync-asset-controls.mjs +1 -37
- package/resources/js/project/scripts/config-export.mjs +10 -34
- package/resources/js3d/bundle.json +104 -0
- package/resources/js3d/context/AGENTS.md +16 -85
- package/resources/js3d/context/knowledge/AigcWiring.md +9 -0
- package/resources/js3d/context/knowledge/AssetUrl.md +9 -0
- package/resources/js3d/context/knowledge/CodingGuide/Pitfalls.md +9 -67
- package/resources/js3d/context/knowledge/Layout.md +7 -0
- package/resources/js3d/context/knowledge/Runtime.md +5 -30
- package/resources/js3d/context/skills/aigc-integration/SKILL.md +6 -164
- package/resources/js3d/context/skills/asset-search/SKILL.md +5 -171
- package/resources/js3d/context/skills/asset-search/references/resource-config.md +6 -94
- package/resources/js3d/context/skills/asset-usage-audit/SKILL.md +6 -82
- package/resources/js3d/context/skills/export-config/SKILL.md +7 -11
- package/resources/js3d/context/skills/export-config/scripts/export-config.mjs +3 -55
- package/resources/js3d/context/skills/index.json +42 -0
- package/resources/js3d/context/skills/performance-audit/SKILL.md +8 -153
- package/resources/js3d/context/skills/visual-qa/SKILL.md +14 -0
- package/resources/js3d/project/README.md +4 -103
- package/resources/js3d/project/package.json +1 -2
- package/resources/js3d/project/scripts/config-export/panel-resource-path.mjs +106 -0
- package/resources/js3d/{context/skills/export-config/scripts → project/scripts/config-export}/sync-scene-assets.mjs +3 -28
- package/resources/js3d/project/scripts/config-export.mjs +12 -34
- package/vendor/agent-cli/dist/src/artifacts/build-failure.d.ts +8 -0
- package/vendor/agent-cli/dist/src/artifacts/build-failure.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/build-failure.js +39 -0
- package/vendor/agent-cli/dist/src/artifacts/build-failure.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.d.ts +5 -0
- package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.js +45 -0
- package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js +71 -6
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts +2 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/prepare.js +7 -2
- package/vendor/agent-cli/dist/src/artifacts/prepare.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts +2 -0
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js +27 -16
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.d.ts +14 -0
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.js +119 -0
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/static.js +20 -6
- package/vendor/agent-cli/dist/src/artifacts/static.js.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-protocol.js +24 -2
- package/vendor/agent-cli/dist/src/cli/process-protocol.js.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-steering.d.ts +21 -0
- package/vendor/agent-cli/dist/src/cli/process-steering.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/cli/process-steering.js +66 -0
- package/vendor/agent-cli/dist/src/cli/process-steering.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.js +1 -1
- package/vendor/agent-cli/dist/src/context/user-skill-bundle.js.map +1 -1
- package/vendor/agent-cli/dist/src/index.d.ts +4 -1
- package/vendor/agent-cli/dist/src/index.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/index.js +3 -0
- package/vendor/agent-cli/dist/src/index.js.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts +31 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js +19 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/client.d.ts +10 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/client.js +16 -5
- package/vendor/agent-cli/dist/src/session/client.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/link-session.d.ts +3 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/link-session.js +17 -1
- package/vendor/agent-cli/dist/src/session/link-session.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-observability.d.ts +3 -0
- package/vendor/agent-cli/dist/src/session/process-observability.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-observability.js +11 -0
- package/vendor/agent-cli/dist/src/session/process-observability.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-request.d.ts +3 -2
- package/vendor/agent-cli/dist/src/session/process-request.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-request.js +27 -9
- package/vendor/agent-cli/dist/src/session/process-request.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts +2 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.js +9 -3
- package/vendor/agent-cli/dist/src/session/run-start-body.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-steer.d.ts +42 -0
- package/vendor/agent-cli/dist/src/session/run-steer.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/run-steer.js +205 -0
- package/vendor/agent-cli/dist/src/session/run-steer.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts +10 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/context-program-receipt.d.ts +21 -0
- package/vendor/agent-cli/dist/src/tools/context-program-receipt.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program-receipt.js +102 -0
- package/vendor/agent-cli/dist/src/tools/context-program-receipt.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/context-program.js +3 -0
- package/vendor/agent-cli/dist/src/tools/context-program.js.map +1 -1
- package/resources/js/context/.role/AGENTS_DESIGN.md +0 -9
- package/resources/js/context/agents/aigc-asset.md +0 -168
- package/resources/js/context/knowledge/AigcEnabled.md +0 -49
- package/resources/js/context/knowledge/FrontendComponents.md +0 -17
- package/resources/js/context/knowledge/MobileAdaptation.md +0 -73
- package/resources/js/context/knowledge/MobileAdapted.md +0 -36
- package/resources/js/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +0 -114
- package/resources/js/context/knowledge/Multiplayer/OverviewKnowledge.md +0 -115
- package/resources/js/context/knowledge/Multiplayer/StateSyncKnowledge.md +0 -392
- package/resources/js/context/knowledge/PlatformServices.md +0 -190
- package/resources/js/context/knowledge/ProjectDisplayConfig.md +0 -35
- package/resources/js/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +0 -242
- package/resources/js/context/knowledge/Ui.md +0 -11
- package/resources/js/context/knowledge/UiEditorCompat.md +0 -21
- package/resources/js/context/rules/MultiplayerCapability.md +0 -23
- package/resources/js/context/rules/MultiplayerRoomEntryUX.md +0 -63
- package/resources/js/context/rules/PlatformBoundaryModules.md +0 -44
- package/resources/js/context/rules/preview_ready.md +0 -8
- package/resources/js/context/skills/aigc-generate/knowledge/audio.md +0 -39
- package/resources/js/context/skills/aigc-generate/knowledge/batch-replace.md +0 -26
- package/resources/js/context/skills/aigc-generate/knowledge/character2d.md +0 -132
- package/resources/js/context/skills/aigc-generate/knowledge/non-stepwise-aigc.md +0 -53
- package/resources/js/context/skills/aigc-generate/knowledge/texture-prop.md +0 -52
- package/resources/js/context/skills/aigc-generate/knowledge/texture-scene.md +0 -191
- package/resources/js/context/skills/aigc-generate/knowledge/texture-ui.md +0 -55
- package/resources/js/context/skills/asset-search/scripts/asset_display.mjs +0 -62
- package/resources/js/context/skills/asset-search/scripts/config.json +0 -5
- package/resources/js/context/skills/asset-search/scripts/provided_assets.mjs +0 -125
- package/resources/js/context/skills/asset-search/scripts/search.mjs +0 -760
- package/resources/js/context/skills/asset-search/scripts/sprite_source_materializer.mjs +0 -657
- package/resources/js/context/skills/asset-search/strategies/anim2d.md +0 -42
- package/resources/js/context/skills/asset-search/strategies/audio.md +0 -34
- package/resources/js/context/skills/asset-search/strategies/effect2d.md +0 -31
- package/resources/js/context/skills/asset-search/strategies/texture-prop.md +0 -22
- package/resources/js/context/skills/asset-search/strategies/ui-common.md +0 -40
- package/resources/js/context/skills/asset-search/strategies/ui-style.md +0 -28
- package/resources/js/context/skills/export-config/scripts/translate-asset-titles.mjs +0 -161
- package/resources/js/context/skills/lightgame-runtime-adapt/SKILL.md +0 -93
- package/resources/js/context/skills/lightgame-runtime-adapt/project/game-runtime.json +0 -7
- package/resources/js/context/skills/lightgame-runtime-adapt/project/package.json +0 -22
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +0 -5
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +0 -208
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +0 -37
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-capture-video.mjs +0 -227
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-service.d.mts +0 -31
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +0 -272
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform.d.mts +0 -79
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform.mjs +0 -29
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/release.json +0 -22
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/cli.mjs +0 -16
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.d.mts +0 -4
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.mjs +0 -50
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +0 -3
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.mjs +0 -72
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/assets.d.mts +0 -24
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/assets.mjs +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/astc.d.mts +0 -10
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/astc.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/config-export.mjs +0 -37
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/refresh-runtime.mjs +0 -50
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/cli.mjs +0 -20
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.d.mts +0 -19
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/installed.json +0 -6
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.d.mts +0 -6
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.mjs +0 -77
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.d.mts +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.mjs +0 -34
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/ui-stage.ts +0 -156
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/viewport.ts +0 -249
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/main.ts +0 -87
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/platform.ts +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/screenUi.ts +0 -185
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/style.css +0 -294
- package/resources/js/context/skills/lightgame-runtime-adapt/project/tsconfig.json +0 -20
- package/resources/js/context/skills/lightgame-runtime-adapt/project/vite.config.ts +0 -5
- package/resources/js/context/skills/lightgame-runtime-adapt/scripts/install-template.mjs +0 -159
- package/resources/js/context/skills/mobile-adaptation/SKILL.md +0 -277
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +0 -50
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +0 -862
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +0 -92
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +0 -254
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +0 -245
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +0 -135
- package/resources/js/context/skills/mobile-adaptation/references/input-config.md +0 -342
- package/resources/js/context/skills/mobile-adaptation/references/verification.md +0 -140
- package/resources/js/context/skills/mobile-adaptation/references/web-audio.md +0 -11
- package/resources/js/context/skills/mobile-compat-qa/SKILL.md +0 -53
- package/resources/js/context/skills/mobile-compat-qa/references/startup-diagnosis.md +0 -23
- package/resources/js/context/skills/mobile-compat-qa/references/web-lifecycle.md +0 -20
- package/resources/js/context/skills/mobile-compat-qa/references/web-performance.md +0 -19
- package/resources/js/context/skills/optimization-suggestions/SKILL.md +0 -89
- package/resources/js/context/skills/platform-services/SKILL.md +0 -101
- package/resources/js/context/skills/platform-services/assets/modules/MultiplayerManager.ts +0 -465
- package/resources/js/context/skills/platform-services/assets/modules/eventBus.ts +0 -57
- package/resources/js/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +0 -5
- package/resources/js/context/skills/platform-services/assets/modules/identity/qq-session.mjs +0 -208
- package/resources/js/context/skills/platform-services/assets/modules/identity/shared.mjs +0 -37
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.d.mts +0 -39
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.mjs +0 -1
- package/resources/js/context/skills/platform-services/assets/modules/log.ts +0 -35
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +0 -61
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +0 -52
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +0 -30
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +0 -89
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/types.ts +0 -47
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.d.mts +0 -31
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.mjs +0 -272
- package/resources/js/context/skills/platform-services/assets/modules/save.d.mts +0 -49
- package/resources/js/context/skills/platform-services/assets/modules/save.mjs +0 -1
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/main.mjs +0 -7
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +0 -264
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +0 -39
- package/resources/js/context/skills/platform-services/references/SERVER_GUIDE.md +0 -139
- package/resources/js/context/skills/platform-services/references/api_reference.md +0 -18
- package/resources/js/context/skills/platform-services/references/leaderboard_playbook.md +0 -96
- package/resources/js/context/skills/platform-services/scripts/install.mjs +0 -148
- package/resources/js/context/skills/resolution-adaptation/SKILL.md +0 -47
- package/resources/js/context/skills/resolution-adaptation/assets/display/ui-stage.ts +0 -156
- package/resources/js/context/skills/resolution-adaptation/assets/display/viewport.ts +0 -249
- package/resources/js/context/skills/resolution-adaptation/assets/example/main.ts +0 -98
- package/resources/js/context/skills/resolution-adaptation/assets/example/ui-tokens.css +0 -200
- package/resources/js/context/skills/resolution-adaptation/references/audit.md +0 -31
- package/resources/js/context/skills/resolution-adaptation/references/device-safe-area.md +0 -40
- package/resources/js/context/skills/resolution-adaptation/references/game-ui-occlusion.md +0 -18
- package/resources/js/context/skills/resolution-adaptation/references/layout-rules.md +0 -15
- package/resources/js/context/skills/resolution-adaptation/references/troubleshooting.md +0 -34
- package/resources/js/context/skills/resolution-adaptation/references/viewport-api.md +0 -38
- package/resources/js/context/skills/resolution-adaptation/references/world-resize.md +0 -55
- package/resources/js/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +0 -448
- package/resources/js/context/skills/scene-editor-compat/SKILL.md +0 -94
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.assets.json +0 -13
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.scene-editor.json +0 -6
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/game/sceneAdapter.ts +0 -25
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/scenes/main.scene.json +0 -18
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/release.json +0 -7
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.d.mts +0 -42
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.mjs +0 -144
- package/resources/js/context/skills/scene-editor-compat/docs/contract.md +0 -330
- package/resources/js/context/skills/scene-editor-compat/docs/resource-sync.md +0 -64
- package/resources/js/context/skills/scene-editor-compat/docs/runtime-state.md +0 -28
- package/resources/js/context/skills/scene-editor-compat/docs/terrain-contract.md +0 -47
- package/resources/js/context/skills/scene-editor-compat/docs/visual-contract.md +0 -64
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.assets.json +0 -38
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.scene-editor.json +0 -9
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneAdapter.ts +0 -59
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneBlockers.ts +0 -30
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneFileAssets.ts +0 -66
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/Main.Scene.ts +0 -20
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/SceneTypes.ts +0 -26
- package/resources/js/context/skills/scene-editor-compat/references/contract.md +0 -73
- package/resources/js/context/skills/scene-editor-compat/scripts/apply_scene_marker.py +0 -162
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_contract.py +0 -853
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_resource_urls.py +0 -173
- package/resources/js/context/skills/scene-editor-compat/scripts/scene-editor.mjs +0 -427
- package/resources/js/context/skills/scene-editor-compat/version.json +0 -1
- package/resources/js/context/skills/ui-editor-compat/SKILL.md +0 -48
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +0 -35
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +0 -74
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/hud.css +0 -60
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +0 -45
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +0 -265
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/release.json +0 -7
- package/resources/js/context/skills/ui-editor-compat/references/contract.md +0 -132
- package/resources/js/context/skills/ui-editor-compat/scripts/editor-contract.mjs +0 -327
- package/resources/js/context/skills/ui-editor-compat/scripts/project-files.mjs +0 -80
- package/resources/js/context/skills/ui-editor-compat/scripts/ui-editor.mjs +0 -84
- package/resources/js/context/skills/version-update/SKILL.md +0 -192
- package/resources/js/context/skills/version-update/scripts/check_runtime_refs.mjs +0 -129
- package/resources/js/context/skills/version-update/scripts/feature_snapshot.mjs +0 -159
- package/resources/js/context/skills/version-update/scripts/update_feature_version.mjs +0 -157
- package/resources/js/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
- package/resources/js/context/version/version.json +0 -1
- 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 +0 -6
- package/resources/js/project/SPEC/res/.gitkeep +0 -0
- package/resources/js/project/SPEC/task-item/.gitkeep +0 -0
- package/resources/js/project/runtime/lightgame/1.0.0/platform/config.d.mts +0 -19
- package/resources/js/project/runtime/lightgame/1.0.0/platform/config.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +0 -39
- package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +0 -227
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +0 -25
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.d.mts +0 -79
- package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.mjs +0 -29
- package/resources/js/project/runtime/lightgame/1.0.0/platform/save.d.mts +0 -49
- package/resources/js/project/runtime/lightgame/1.0.0/platform/save.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/release.json +0 -37
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/cli.mjs +0 -2
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.d.mts +0 -8
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.mjs +0 -2
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +0 -3
- package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.mjs +0 -8
- package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.d.mts +0 -24
- package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.mjs +0 -2
- package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.d.mts +0 -10
- package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.d.mts +0 -20
- package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +0 -21
- package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/tools/input.d.mts +0 -17
- package/resources/js/project/runtime/lightgame/1.0.0/tools/input.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/tools/three.d.mts +0 -40
- package/resources/js/project/runtime/lightgame/1.0.0/tools/three.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.d.mts +0 -10
- package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.mjs +0 -1
- package/resources/js/project/runtime/lightgame/1.0.0/tools/video.d.mts +0 -8
- package/resources/js/project/runtime/lightgame/1.0.0/tools/video.mjs +0 -1
- package/resources/js/project/scripts/refresh-runtime.mjs +0 -50
- package/resources/js/project/vendor/core-manager-js/package.json +0 -33
- package/resources/js/project/vendor/core-manager-js/src/.versions.json +0 -42
- package/resources/js/project/vendor/core-manager-js/src/CoreManagerPlugin.ts +0 -41
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AssetRef.ts +0 -93
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcFirstImageFile.ts +0 -203
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcTextureLoader.ts +0 -106
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.test.ts +0 -25
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.ts +0 -21
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.test.ts +0 -65
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.ts +0 -340
- package/resources/js/project/vendor/core-manager-js/src/configManager/FeatureConfig.ts +0 -87
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.d.mts +0 -92
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.mjs +0 -271
- package/resources/js/project/vendor/core-manager-js/src/index.ts +0 -31
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputConfig.ts +0 -81
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.test.ts +0 -43
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.ts +0 -32
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.test.ts +0 -141
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.ts +0 -20
- package/resources/js/project/vendor/core-manager-js/src/inputManager/KeyboardProvider.ts +0 -183
- package/resources/js/project/vendor/core-manager-js/src/inputManager/TouchProvider.ts +0 -304
- package/resources/js/project/vendor/core-manager-js/src/inputManager/VirtualJoystick.ts +0 -351
- package/resources/js/project/vendor/core-manager-js/src/inputManager/_internal/InputManagerImpl.ts +0 -180
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64 +0 -13
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64.d.ts +0 -14
- package/resources/js/project/vendor/core-manager-js/src/inputManager/input_config.example.json +0 -68
- package/resources/js/project/vendor/core-manager-js/src/logManager/DebugConsole.ts +0 -433
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogCapture.ts +0 -118
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogManager.ts +0 -444
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCapture.ts +0 -485
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.test.ts +0 -66
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.ts +0 -149
- package/resources/js/project/vendor/core-manager-js/src/logManager/icons.b64 +0 -9
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/AssetUrlResolver.ts +0 -29
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.test.ts +0 -88
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.ts +0 -122
- package/resources/js/project/vendor/core-manager-js/src/runtime.ts +0 -24
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterEntity.ts +0 -318
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.test.ts +0 -151
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.ts +0 -235
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.test.ts +0 -98
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.ts +0 -94
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectEntity.ts +0 -209
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.test.ts +0 -106
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.ts +0 -341
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.test.ts +0 -68
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.ts +0 -236
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.test.ts +0 -22
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.ts +0 -29
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteEntity.test.ts +0 -197
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiContracts.ts +0 -9
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiKit.ts +0 -555
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.test.ts +0 -112
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.ts +0 -178
- package/resources/js/project/vendor/core-manager-js/src/uiManager/ui-base.css +0 -246
- package/resources/js/project/vendor/core-manager-js/src/videoManager/VideoManager.ts +0 -139
- package/resources/js/project/vendor/core-manager-js/tsconfig.json +0 -15
- package/resources/js/project/vendor/run.sh +0 -4
- package/resources/js/project/version/craft_feature_version.json +0 -42
- package/resources/js/project/version/project_feature_version.json +0 -11
- package/resources/js3d/context/.role/AGENTS_DESIGN.md +0 -9
- package/resources/js3d/context/knowledge/3D/PoseInterpolationKnowledge.md +0 -75
- package/resources/js3d/context/knowledge/CodingGuide/SceneEditableGuide.md +0 -42
- package/resources/js3d/context/knowledge/FrontendComponents.md +0 -19
- package/resources/js3d/context/knowledge/MobileAdaptation.md +0 -73
- package/resources/js3d/context/knowledge/MobileAdapted.md +0 -36
- package/resources/js3d/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +0 -114
- package/resources/js3d/context/knowledge/Multiplayer/OverviewKnowledge.md +0 -117
- package/resources/js3d/context/knowledge/Multiplayer/StateSyncKnowledge.md +0 -430
- package/resources/js3d/context/knowledge/PlatformServices.md +0 -190
- package/resources/js3d/context/knowledge/ProjectDisplayConfig.md +0 -35
- package/resources/js3d/context/knowledge/SceneEditorCompat.md +0 -35
- package/resources/js3d/context/knowledge/StepByStep.md +0 -21
- package/resources/js3d/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +0 -242
- package/resources/js3d/context/knowledge/UiEditorCompat.md +0 -21
- package/resources/js3d/context/rules/MultiplayerCapability.md +0 -27
- package/resources/js3d/context/rules/MultiplayerRoomEntryUX.md +0 -63
- package/resources/js3d/context/rules/PlatformBoundaryModules.md +0 -44
- package/resources/js3d/context/rules/preview_ready.md +0 -8
- package/resources/js3d/context/skills/aigc-integration/assets/sprite-sheet-player.mjs +0 -70
- package/resources/js3d/context/skills/aigc-integration/callback.md +0 -77
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/README.md +0 -23
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/audio-aigc-knowledge.md +0 -38
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/character2d-aigc-knowledge.md +0 -72
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/staticmesh-aigc-knowledge.md +0 -33
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-prop-aigc-knowledge.md +0 -36
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-scene-aigc-knowledge.md +0 -37
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-ui-aigc-knowledge.md +0 -35
- package/resources/js3d/context/skills/asset-search/references/sprite-sheets.md +0 -58
- package/resources/js3d/context/skills/asset-search/scripts/asset_display.mjs +0 -62
- package/resources/js3d/context/skills/asset-search/scripts/config.json +0 -235
- package/resources/js3d/context/skills/asset-search/scripts/manifest_pipeline.mjs +0 -905
- package/resources/js3d/context/skills/asset-search/scripts/preflight.mjs +0 -79
- package/resources/js3d/context/skills/asset-search/scripts/provided_assets.mjs +0 -74
- package/resources/js3d/context/skills/asset-search/scripts/search.mjs +0 -637
- package/resources/js3d/context/skills/asset-search/scripts/sprite_source_materializer.mjs +0 -667
- package/resources/js3d/context/skills/asset-search/strategies/anim2d.md +0 -42
- package/resources/js3d/context/skills/asset-search/strategies/effect2d.md +0 -31
- package/resources/js3d/context/skills/asset-usage-audit/references/case-tidewater-zoo.md +0 -89
- package/resources/js3d/context/skills/asset-usage-audit/references/optimization-playbook.md +0 -143
- package/resources/js3d/context/skills/asset-usage-audit/references/usage-model.md +0 -90
- package/resources/js3d/context/skills/export-config/scripts/translate-asset-titles.mjs +0 -161
- package/resources/js3d/context/skills/game-art-style/SKILL.md +0 -60
- 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 +0 -38
- package/resources/js3d/context/skills/game-art-style/references/construction.md +0 -111
- package/resources/js3d/context/skills/game-art-style/references/materials-textures.md +0 -105
- package/resources/js3d/context/skills/game-art-style/references/sources.md +0 -25
- package/resources/js3d/context/skills/game-art-style/references/styles/cartoon.md +0 -175
- package/resources/js3d/context/skills/game-art-style/references/styles/comic.md +0 -168
- package/resources/js3d/context/skills/game-art-style/references/styles/cozy.md +0 -191
- package/resources/js3d/context/skills/game-art-style/references/styles/cyber.md +0 -165
- package/resources/js3d/context/skills/game-art-style/references/styles/horror.md +0 -173
- package/resources/js3d/context/skills/game-art-style/references/styles/lowpoly.md +0 -185
- package/resources/js3d/context/skills/game-art-style/references/styles/paper.md +0 -181
- package/resources/js3d/context/skills/game-art-style/references/styles/voxel.md +0 -189
- package/resources/js3d/context/skills/game-art-style/references/user-style-document.md +0 -88
- package/resources/js3d/context/skills/mobile-adaptation/SKILL.md +0 -301
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +0 -104
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +0 -933
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +0 -92
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +0 -254
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +0 -245
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +0 -257
- package/resources/js3d/context/skills/mobile-adaptation/references/input-config.md +0 -342
- package/resources/js3d/context/skills/mobile-adaptation/references/verification.md +0 -140
- package/resources/js3d/context/skills/mobile-adaptation/references/web-audio.md +0 -11
- package/resources/js3d/context/skills/mobile-compat-qa/SKILL.md +0 -53
- package/resources/js3d/context/skills/mobile-compat-qa/references/startup-diagnosis.md +0 -23
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-form-input.md +0 -10
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-lifecycle.md +0 -20
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-performance.md +0 -19
- package/resources/js3d/context/skills/optimization-suggestions/SKILL.md +0 -74
- package/resources/js3d/context/skills/performance-audit/references/case-notes.md +0 -93
- package/resources/js3d/context/skills/performance-audit/references/rules.md +0 -183
- package/resources/js3d/context/skills/platform-services/SKILL.md +0 -101
- package/resources/js3d/context/skills/platform-services/assets/modules/MultiplayerManager.ts +0 -465
- package/resources/js3d/context/skills/platform-services/assets/modules/eventBus.ts +0 -57
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +0 -5
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-session.mjs +0 -208
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/shared.mjs +0 -37
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.d.mts +0 -39
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.mjs +0 -1
- package/resources/js3d/context/skills/platform-services/assets/modules/log.ts +0 -35
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +0 -61
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +0 -52
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +0 -30
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +0 -89
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/types.ts +0 -47
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.d.mts +0 -31
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.mjs +0 -272
- package/resources/js3d/context/skills/platform-services/assets/modules/save.d.mts +0 -49
- package/resources/js3d/context/skills/platform-services/assets/modules/save.mjs +0 -1
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/main.mjs +0 -7
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +0 -264
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +0 -39
- package/resources/js3d/context/skills/platform-services/references/SERVER_GUIDE.md +0 -139
- package/resources/js3d/context/skills/platform-services/references/api_reference.md +0 -18
- package/resources/js3d/context/skills/platform-services/references/leaderboard_playbook.md +0 -96
- package/resources/js3d/context/skills/platform-services/scripts/install.mjs +0 -148
- package/resources/js3d/context/skills/resolution-adaptation/SKILL.md +0 -46
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/ui-stage.ts +0 -156
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/viewport.ts +0 -239
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/main.ts +0 -129
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/ui-tokens.css +0 -188
- package/resources/js3d/context/skills/resolution-adaptation/references/audit.md +0 -31
- package/resources/js3d/context/skills/resolution-adaptation/references/device-safe-area.md +0 -40
- package/resources/js3d/context/skills/resolution-adaptation/references/game-ui-occlusion.md +0 -18
- package/resources/js3d/context/skills/resolution-adaptation/references/layout-rules.md +0 -15
- package/resources/js3d/context/skills/resolution-adaptation/references/troubleshooting.md +0 -34
- package/resources/js3d/context/skills/resolution-adaptation/references/viewport-api.md +0 -38
- package/resources/js3d/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +0 -448
- package/resources/js3d/context/skills/scene-editor-compat/SKILL.md +0 -599
- package/resources/js3d/context/skills/scene-editor-compat/references/bundle-contract.md +0 -141
- package/resources/js3d/context/skills/scene-editor-compat/references/editor-integration.md +0 -92
- package/resources/js3d/context/skills/scene-editor-compat/references/scene-data-format.md +0 -125
- package/resources/js3d/context/skills/scene-editor-compat/references/slots-rules.md +0 -113
- package/resources/js3d/context/skills/scene-editor-compat/scripts/scene-editor.mjs +0 -1187
- package/resources/js3d/context/skills/threejs-game-quality/SKILL.md +0 -53
- package/resources/js3d/context/skills/threejs-game-quality/agents/openai.yaml +0 -4
- package/resources/js3d/context/skills/threejs-game-quality/references/01-build.md +0 -94
- package/resources/js3d/context/skills/threejs-game-quality/references/02-avoid.md +0 -50
- package/resources/js3d/context/skills/threejs-game-quality/references/03-detect.md +0 -105
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-by-genre.md +0 -147
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-distance.md +0 -79
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-sources.md +0 -56
- package/resources/js3d/context/skills/threejs-game-quality/references/character-motion-face.md +0 -51
- package/resources/js3d/context/skills/threejs-game-quality/references/parameter-contract.md +0 -55
- package/resources/js3d/context/skills/threejs-game-quality/references/refine-existing.md +0 -78
- package/resources/js3d/context/skills/threejs-game-quality/references/rendering-stability.md +0 -84
- package/resources/js3d/context/skills/threejs-game-quality/references/runtime-tools.md +0 -120
- package/resources/js3d/context/skills/threejs-game-quality/scripts/package.json +0 -4
- package/resources/js3d/context/skills/threejs-game-quality/scripts/runtime-audit.js +0 -238
- package/resources/js3d/context/skills/ui-editor-compat/SKILL.md +0 -59
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +0 -35
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +0 -61
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/hud.css +0 -60
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +0 -45
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +0 -265
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/release.json +0 -7
- package/resources/js3d/context/skills/ui-editor-compat/references/contract.md +0 -110
- package/resources/js3d/context/skills/ui-editor-compat/scripts/editor-contract.mjs +0 -327
- package/resources/js3d/context/skills/ui-editor-compat/scripts/project-files.mjs +0 -80
- package/resources/js3d/context/skills/ui-editor-compat/scripts/ui-editor.mjs +0 -84
- package/resources/js3d/context/skills/version-update/SKILL.md +0 -191
- package/resources/js3d/context/skills/version-update/scripts/check_runtime_refs.mjs +0 -129
- package/resources/js3d/context/skills/version-update/scripts/feature_snapshot.mjs +0 -159
- package/resources/js3d/context/skills/version-update/scripts/update_feature_version.mjs +0 -157
- package/resources/js3d/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
- package/resources/js3d/context/version/version.json +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.d.mts +0 -19
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +0 -39
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +0 -227
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +0 -25
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.d.mts +0 -79
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.mjs +0 -30
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.d.mts +0 -49
- package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/release.json +0 -39
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/cli.mjs +0 -2
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.d.mts +0 -8
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.mjs +0 -2
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +0 -3
- package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.mjs +0 -7
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.d.mts +0 -24
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.mjs +0 -2
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.d.mts +0 -10
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.d.mts +0 -20
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +0 -21
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.d.mts +0 -26
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.mjs +0 -351
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.d.mts +0 -17
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.d.mts +0 -40
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.d.mts +0 -10
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.mjs +0 -1
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.d.mts +0 -8
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.mjs +0 -1
- package/resources/js3d/project/scripts/refresh-runtime.mjs +0 -50
- package/resources/js3d/project/vendor/core-manager-three/package.json +0 -12
- package/resources/js3d/project/vendor/core-manager-three/src/index.ts +0 -2
- package/resources/js3d/project/vendor/run.sh +0 -4
- package/resources/js3d/project/version/craft_feature_version.json +0 -42
- package/resources/js3d/project/version/project_feature_version.json +0 -11
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.d.ts +0 -7
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.d.ts.map +0 -1
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.js +0 -145
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.js.map +0 -1
- /package/resources/js/{context/skills/export-config/scripts → project/scripts/config-export}/assert-asset-wiring.mjs +0 -0
- /package/resources/js3d/{context/skills/export-config/scripts → project/scripts/config-export}/assert-asset-wiring.mjs +0 -0
- /package/resources/js3d/{context/skills/export-config/scripts → project/scripts/config-export}/sync-asset-controls.mjs +0 -0
package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-session.mjs
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { apiBase } from './shared.mjs';
|
|
2
|
-
|
|
3
|
-
const EXCHANGE_PATH = '/api/auth/qq-game-session';
|
|
4
|
-
const EXCHANGE_TIMEOUT_MS = 10_000;
|
|
5
|
-
const BRIDGE_WAIT_MS = 10_000;
|
|
6
|
-
const BRIDGE_POLL_MS = 50;
|
|
7
|
-
const DEFAULT_EXPIRES_IN_S = 1800;
|
|
8
|
-
/** session_token cannot be renewed; a fresh login() + exchange runs this long before expiry. */
|
|
9
|
-
const REFRESH_LEAD_MS = 120_000;
|
|
10
|
-
const MIN_REFRESH_DELAY_MS = 30_000;
|
|
11
|
-
/** Stops a burst of 401s from turning into a burst of login() + exchange round trips. */
|
|
12
|
-
const RETRY_COOLDOWN_MS = 5_000;
|
|
13
|
-
|
|
14
|
-
/** `api` comes from the URL, so it is the only thing deciding where game_token is sent. */
|
|
15
|
-
const QQ_API_HOST = /(^|\.)craft\.qq\.com$/;
|
|
16
|
-
const LOOPBACK = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
17
|
-
|
|
18
|
-
const text = value => (typeof value === 'string' ? value.trim() : '');
|
|
19
|
-
|
|
20
|
-
/** Hosts disagree on naming (`game_token` vs `gameToken`); snake_case wins when both are present. */
|
|
21
|
-
const pick = (source, snake, camel) => {
|
|
22
|
-
const value = source?.[snake];
|
|
23
|
-
return value == null || value === '' ? source?.[camel] : value;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const trustedApi = value => {
|
|
27
|
-
const api = apiBase(value);
|
|
28
|
-
if (!api) return null;
|
|
29
|
-
const { hostname } = new URL(api);
|
|
30
|
-
return QQ_API_HOST.test(hostname) || LOOPBACK.has(hostname) ? api : null;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
class QqSessionError extends Error {
|
|
34
|
-
constructor(reason, { status = 0, permanent = false } = {}) {
|
|
35
|
-
super(reason);
|
|
36
|
-
this.status = status;
|
|
37
|
-
this.permanent = permanent;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Craft appends `api`, `app_id`, `qq_test` to the game URL when syncing to QQ; `qq_test` alone marks the QQ host. */
|
|
42
|
-
export function readQqRuntime(win) {
|
|
43
|
-
const search = win?.location?.search;
|
|
44
|
-
const params = new URLSearchParams(typeof search === 'string' ? search : '');
|
|
45
|
-
if (!params.has('qq_test')) return null;
|
|
46
|
-
const api = trustedApi(text(params.get('api')));
|
|
47
|
-
const appId = text(params.get('app_id'));
|
|
48
|
-
const flag = text(params.get('qq_test'));
|
|
49
|
-
const qqTest = flag === '0' || flag === '1' ? Number(flag) : null;
|
|
50
|
-
if (api && appId && qqTest !== null) return { api, appId, qqTest };
|
|
51
|
-
const problems = [!api && 'api (need https *.craft.qq.com, no query/hash)', !appId && 'app_id', qqTest === null && 'qq_test (need 0 or 1)'].filter(Boolean);
|
|
52
|
-
return { invalid: true, reason: `missing or invalid: ${problems.join(', ')}` };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** The SDK picks bridge or mock once, at evaluation time, so it must load after the host bridge exists. */
|
|
56
|
-
export async function loadQqSdk(win) {
|
|
57
|
-
const deadline = Date.now() + BRIDGE_WAIT_MS;
|
|
58
|
-
while (!win?.qqAiGameSdk && typeof win?.__qqAiGameBridge?.invoke !== 'function') {
|
|
59
|
-
if (Date.now() >= deadline) return null;
|
|
60
|
-
await new Promise(resolve => setTimeout(resolve, BRIDGE_POLL_MS));
|
|
61
|
-
}
|
|
62
|
-
if (!win?.qqAiGameSdk) await import('./qq-ai-game-sdk.min.js');
|
|
63
|
-
return win?.qqAiGameSdk ?? null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const sessionData = payload => {
|
|
67
|
-
if (typeof payload?.session_token === 'string') return payload;
|
|
68
|
-
if (payload?.code === 0 && payload.data && typeof payload.data === 'object') return payload.data;
|
|
69
|
-
return null;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export function createQqSession({ win, runtime, loadSdk = loadQqSdk, log, apply, fail, now = Date.now }) {
|
|
73
|
-
const fetchImpl = win?.fetch ? win.fetch.bind(win) : globalThis.fetch;
|
|
74
|
-
let sdk = null, stopped = false, inflight = null, timer, controller = null, expiresAt = 0, attemptedAt = 0;
|
|
75
|
-
|
|
76
|
-
const resolveSdk = async () => {
|
|
77
|
-
if (!sdk) {
|
|
78
|
-
try {
|
|
79
|
-
sdk = await loadSdk(win);
|
|
80
|
-
} catch {
|
|
81
|
-
throw new QqSessionError('sdk load failed');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (!sdk || typeof sdk.login !== 'function') throw new QqSessionError('sdk unavailable', { permanent: true });
|
|
85
|
-
if (sdk.isMock) throw new QqSessionError('sdk in mock mode', { permanent: true });
|
|
86
|
-
return sdk;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const login = async () => {
|
|
90
|
-
let result;
|
|
91
|
-
const ready = await resolveSdk();
|
|
92
|
-
if (stopped) throw new QqSessionError('disposed');
|
|
93
|
-
try {
|
|
94
|
-
result = await ready.login();
|
|
95
|
-
} catch (error) {
|
|
96
|
-
throw new QqSessionError(`login ${text(error?.code) || 'failed'}`);
|
|
97
|
-
}
|
|
98
|
-
const gopenid = text(result?.gopenid);
|
|
99
|
-
const gameToken = text(pick(result, 'game_token', 'gameToken'));
|
|
100
|
-
if (!gopenid || !gameToken) throw new QqSessionError('login returned no credentials');
|
|
101
|
-
return { gopenid, gameToken };
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const exchange = async () => {
|
|
105
|
-
const { gopenid, gameToken } = await login();
|
|
106
|
-
if (stopped) throw new QqSessionError('disposed');
|
|
107
|
-
const request = new AbortController();
|
|
108
|
-
controller = request;
|
|
109
|
-
const timeout = setTimeout(() => request.abort(), EXCHANGE_TIMEOUT_MS);
|
|
110
|
-
try {
|
|
111
|
-
const response = await fetchImpl(`${runtime.api}${EXCHANGE_PATH}`, {
|
|
112
|
-
method: 'POST',
|
|
113
|
-
headers: { 'Content-Type': 'application/json' },
|
|
114
|
-
body: JSON.stringify({ app_id: runtime.appId, qq_test: runtime.qqTest, game_token: gameToken, gopenid }),
|
|
115
|
-
signal: request.signal,
|
|
116
|
-
redirect: 'error',
|
|
117
|
-
credentials: 'omit',
|
|
118
|
-
});
|
|
119
|
-
if (response.status !== 200) {
|
|
120
|
-
const permanent = response.status === 400 || response.status === 403 || response.status === 503;
|
|
121
|
-
throw new QqSessionError(`exchange http ${response.status}`, { status: response.status, permanent });
|
|
122
|
-
}
|
|
123
|
-
const data = sessionData(await response.json());
|
|
124
|
-
const token = text(data?.session_token);
|
|
125
|
-
const playerId = text(data?.player_id);
|
|
126
|
-
if (!token || !playerId) throw new QqSessionError('exchange response malformed');
|
|
127
|
-
const ttl = Number(pick(data, 'expires_in', 'expiresIn'));
|
|
128
|
-
const expiresIn = ttl > 0 ? ttl : DEFAULT_EXPIRES_IN_S;
|
|
129
|
-
const playerName = text(data.player_name) || `用户${playerId.slice(-6)}`;
|
|
130
|
-
return { identity: { api: runtime.api, token, appId: runtime.appId, playerId, playerName }, expiresIn };
|
|
131
|
-
} catch (error) {
|
|
132
|
-
if (error instanceof QqSessionError) throw error;
|
|
133
|
-
throw new QqSessionError('exchange network error');
|
|
134
|
-
} finally {
|
|
135
|
-
clearTimeout(timeout);
|
|
136
|
-
if (controller === request) controller = null;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const attempt = async () => {
|
|
141
|
-
try {
|
|
142
|
-
return await exchange();
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error.status !== 401 || stopped) throw error;
|
|
145
|
-
return exchange();
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const schedule = expiresIn => {
|
|
150
|
-
expiresAt = now() + expiresIn * 1000;
|
|
151
|
-
clearTimeout(timer);
|
|
152
|
-
const delay = Math.max(expiresIn * 1000 - REFRESH_LEAD_MS, MIN_REFRESH_DELAY_MS);
|
|
153
|
-
timer = setTimeout(() => void refresh(), delay);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const refresh = () => {
|
|
157
|
-
if (stopped) return Promise.resolve(false);
|
|
158
|
-
if (inflight) return inflight;
|
|
159
|
-
inflight = (async () => {
|
|
160
|
-
try {
|
|
161
|
-
const result = await attempt();
|
|
162
|
-
if (stopped) return false;
|
|
163
|
-
schedule(result.expiresIn);
|
|
164
|
-
apply(result.identity);
|
|
165
|
-
return true;
|
|
166
|
-
} catch (error) {
|
|
167
|
-
if (stopped) return false;
|
|
168
|
-
if (error.permanent) stop();
|
|
169
|
-
fail(error.message);
|
|
170
|
-
return false;
|
|
171
|
-
} finally {
|
|
172
|
-
attemptedAt = now();
|
|
173
|
-
inflight = null;
|
|
174
|
-
}
|
|
175
|
-
})();
|
|
176
|
-
return inflight;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const coolingDown = () => attemptedAt > 0 && now() - attemptedAt < RETRY_COOLDOWN_MS;
|
|
180
|
-
|
|
181
|
-
const onVisibility = () => {
|
|
182
|
-
if (stopped || inflight || win?.document?.visibilityState !== 'visible' || coolingDown()) return;
|
|
183
|
-
if (expiresAt && now() < expiresAt - REFRESH_LEAD_MS) return;
|
|
184
|
-
void refresh();
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
function stop() {
|
|
188
|
-
stopped = true;
|
|
189
|
-
clearTimeout(timer);
|
|
190
|
-
controller?.abort();
|
|
191
|
-
win?.document?.removeEventListener?.('visibilitychange', onVisibility);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
start() {
|
|
196
|
-
win?.document?.addEventListener?.('visibilitychange', onVisibility);
|
|
197
|
-
log('qq session exchanging');
|
|
198
|
-
return refresh();
|
|
199
|
-
},
|
|
200
|
-
/** Resolves true once a new session_token is in place; shares an exchange already in flight. */
|
|
201
|
-
reauthenticate() {
|
|
202
|
-
if (inflight) return refresh();
|
|
203
|
-
if (stopped || coolingDown()) return Promise.resolve(false);
|
|
204
|
-
return refresh();
|
|
205
|
-
},
|
|
206
|
-
dispose: stop,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const unavailable = () => ({ ok: false, code: 'PLATFORM_UNAVAILABLE', message: '当前环境不支持平台服务' });
|
|
2
|
-
|
|
3
|
-
export const failure = (code = 'INTERNAL_ERROR', message = '服务暂不可用,请稍后重试') => ({ ok: false, code, message });
|
|
4
|
-
|
|
5
|
-
export const duration = (value, fallback) => (Number.isFinite(value) && value >= 0 ? Math.min(value, 60_000) : fallback);
|
|
6
|
-
|
|
7
|
-
const httpOrigin = value => {
|
|
8
|
-
try {
|
|
9
|
-
const url = new URL(value);
|
|
10
|
-
return /^https?:$/.test(url.protocol) ? url.origin : null;
|
|
11
|
-
} catch {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export function parentOrigin(win, explicit) {
|
|
17
|
-
if (explicit && explicit !== '*') return httpOrigin(explicit);
|
|
18
|
-
const referrer = httpOrigin(win?.document?.referrer);
|
|
19
|
-
if (referrer) return referrer;
|
|
20
|
-
try {
|
|
21
|
-
return httpOrigin(win?.parent?.location?.origin);
|
|
22
|
-
} catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** HTTPS gateway base without trailing slashes; plain HTTP only for loopback hosts. */
|
|
28
|
-
export function apiBase(value) {
|
|
29
|
-
try {
|
|
30
|
-
const url = new URL(value);
|
|
31
|
-
const local = url.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
32
|
-
if ((url.protocol !== 'https:' && !local) || url.username || url.password || url.search || url.hash) return null;
|
|
33
|
-
return url.href.replace(/\/+$/, '');
|
|
34
|
-
} catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { PlatformService } from './platform-service.mjs';
|
|
2
|
-
export type SortOrder = 'asc' | 'desc';
|
|
3
|
-
export type UpdatePolicy = 'BEST' | 'OVERWRITE' | 'ACCUMULATE';
|
|
4
|
-
/** One logical board splits into one physical board per period; the server buckets by wall clock. */
|
|
5
|
-
export type Period = 'all_time' | 'weekly' | 'monthly' | 'season';
|
|
6
|
-
/** Platform category. Free-form labels belong in subType, never here. */
|
|
7
|
-
export type BoardType = 'comprehensive' | 'periodic' | 'test';
|
|
8
|
-
/** Season boards only. The server derives the current season from this and refuses configs that straddle a calendar month or overlap an existing season. */
|
|
9
|
-
export interface PeriodConfig { startTime: number; periodDays: number; loopCount?: number; }
|
|
10
|
-
export interface ConfigureOptions { type?: BoardType; subType?: string; period?: Period; periodConfig?: PeriodConfig; }
|
|
11
|
-
/** No seasonNumber on purpose: reports always land in the current period, so a closed season can never be backfilled. */
|
|
12
|
-
export interface ReportOptions { boardKey?: string; period?: Period; extra?: unknown; }
|
|
13
|
-
export interface BatchReportItem { boardKey?: string; score: number; playerName?: string; period?: Period; extra?: unknown; }
|
|
14
|
-
export interface QueryOptions { boardKey?: string; period?: Period; seasonNumber?: number; limit?: number; includeSelf?: boolean; aroundSelf?: number; }
|
|
15
|
-
export interface UpdateDisplayOptions { boardKey?: string; period?: Period; seasonNumber?: number; }
|
|
16
|
-
export interface ClearOptions { boardKey?: string; allBoards?: boolean; }
|
|
17
|
-
export interface ReportResult { result: string; message: string; board_key?: string; period?: Period; season_number?: number; type?: string; is_best?: boolean; score?: number; rank?: number; total?: number; }
|
|
18
|
-
export interface BatchResult { result: string; message: string; boards?: ReportResult[]; reported?: number; succeeded?: number; }
|
|
19
|
-
export interface QueryItem { rank: number; player_id: string; player_name: string; score: number; extra?: unknown; }
|
|
20
|
-
export interface QueryResult { result: string; message: string; board_key?: string; period?: Period; season_number?: number; display_name?: string; type?: string; items?: QueryItem[]; self?: QueryItem | null; total?: number; }
|
|
21
|
-
export interface UpdateDisplayResult { result: string; message: string; board_key?: string; period?: Period; season_number?: number; player_name?: string; }
|
|
22
|
-
export interface ClearResult { result: string; message: string; board_key?: string; all_boards?: boolean; deleted?: number; }
|
|
23
|
-
export interface Leaderboard {
|
|
24
|
-
/**
|
|
25
|
-
* Stores the board's creation params and its period; later calls reuse that period unless one is passed explicitly.
|
|
26
|
-
* A string is the legacy boardType: a BoardType value becomes `type`, any other non-empty label becomes `subType`.
|
|
27
|
-
*/
|
|
28
|
-
configure(sortOrder: SortOrder, updatePolicy: UpdatePolicy, scoreRange: [number, number], boardKey?: string, opts?: ConfigureOptions | string): void;
|
|
29
|
-
report(score: number, playerName?: string, onDone?: (result: ReportResult) => void, opts?: ReportOptions): Promise<ReportResult>;
|
|
30
|
-
/** Up to 10 boards. Each entry succeeds or fails on its own and nothing is rolled back, so read every boards[i].result. */
|
|
31
|
-
reportBatch(boards: BatchReportItem[], onDone?: (result: BatchResult) => void): Promise<BatchResult>;
|
|
32
|
-
query(onDone?: (result: QueryResult) => void, opts?: QueryOptions): Promise<QueryResult>;
|
|
33
|
-
/** Requires an existing score row on that board, otherwise NOT_ON_BOARD. */
|
|
34
|
-
updateDisplay(playerName?: string, extra?: unknown, onDone?: (result: UpdateDisplayResult) => void, opts?: UpdateDisplayOptions): Promise<UpdateDisplayResult>;
|
|
35
|
-
/** Author-only; permissions are enforced by the server. */
|
|
36
|
-
clear(onDone?: (result: ClearResult) => void, opts?: ClearOptions): Promise<ClearResult>;
|
|
37
|
-
}
|
|
38
|
-
export function createLeaderboard(options?: { service?: PlatformService }): Leaderboard;
|
|
39
|
-
export const LeaderboardManager: Leaderboard;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:true});var SERVICE_KEY=Symbol.for("@game-runtime/platform-service/v1");var unavailable=__name(()=>({ok:false,code:"PLATFORM_UNAVAILABLE",message:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u5E73\u53F0\u670D\u52A1"}),"unavailable");var failure=__name((code="INTERNAL_ERROR",message="\u670D\u52A1\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")=>({ok:false,code,message}),"failure");var duration=__name((value,fallback)=>Number.isFinite(value)&&value>=0?Math.min(value,6e4):fallback,"duration");function parentOrigin(win,explicit){const valid=__name(value=>{try{const url=new URL(value);return/^https?:$/.test(url.protocol)?url.origin:null}catch{return null}},"valid");if(explicit&&explicit!=="*")return valid(explicit);const referrer=valid(win?.document?.referrer);if(referrer)return referrer;try{return valid(win?.parent?.location?.origin)}catch{return null}}__name(parentOrigin,"parentOrigin");function apiBase(value){try{const url=new URL(value);const local=url.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(url.hostname);if(url.protocol!=="https:"&&!local||url.username||url.password||url.search||url.hash)return null;return url.href.replace(/\/+$/,"")}catch{return null}}__name(apiBase,"apiBase");function createPlatformService(options={}){const win=options.window??(typeof window==="undefined"?void 0:window);let initialized=false,disposed=false,state="pending",identity=null,session=0,initTimer;let origin=null;const waiters=new Set,requests=new Set,listeners=new Map;const emit=__name((event,...args)=>{for(const listener of[...listeners.get(event)||[]]){try{listener(...args)}catch{}}},"emit");const settle=__name(next=>{const previous=state;state=next;clearTimeout(initTimer);for(const resolve of waiters)resolve();waiters.clear();if(previous!==next)emit("state-change",next,previous)},"settle");const invalidate=__name(()=>{session++;for(const cancel of[...requests])cancel()},"invalidate");const onMessage=__name(event=>{if(disposed||!origin||event.source!==win?.parent||event.origin!==origin)return;const{type,data}=event.data||{};if(!data||typeof data!=="object")return;if(type==="runtime-init"){const api=typeof data.api==="string"?apiBase(data.api.trim()):null;const token=typeof data.token==="string"?data.token.trim():"";const appId=typeof data.app_id==="string"?data.app_id.trim():"";const playerId=typeof data.player_id==="string"?data.player_id.trim():"";if(!api||!token||!appId||!playerId)return;if(!identity||identity.api!==api||identity.appId!==appId||identity.playerId!==playerId)invalidate();identity={api,token,appId,playerId,playerName:typeof data.player_name==="string"?data.player_name.trim():""};settle("active")}else if(type==="session-token-refresh"&&identity&&typeof data.token==="string"&&data.token.trim()){identity={...identity,token:data.token.trim()};emit("token-refreshed")}},"onMessage");const dispatch=__name(async(options2,expectedSession)=>{if(disposed||state!=="active"||session!==expectedSession)return unavailable();const currentIdentity=identity;const controller=new AbortController;let timer,cancel;const interrupted=new Promise(resolve=>{cancel=__name(()=>{controller.abort();resolve(unavailable())},"cancel");requests.add(cancel);timer=setTimeout(()=>{controller.abort();resolve(failure())},duration(options2.timeoutMs,1e4))});const operation=__name(async()=>{try{const headers=new Headers(options2.headers);headers.set("Content-Type","application/json");headers.set("Authorization",`Bearer ${currentIdentity.token}`);const response=await(win?.fetch?win.fetch.bind(win):globalThis.fetch)(`${currentIdentity.api}${options2.path}`,{method:"POST",headers,body:JSON.stringify(options2.body??{}),signal:controller.signal,redirect:"error",credentials:"omit"});if(response.status===401)return failure("AUTH_FAILED","\u767B\u5F55\u6001\u5931\u6548");if(response.status===403)return failure("FORBIDDEN","\u65E0\u6743\u64CD\u4F5C");if(response.status!==200)return failure();const envelope=await response.json();if(envelope?.code!==0||typeof envelope?.data?.result!=="string"||!envelope.data.result)return failure();const data=envelope.data;return{ok:data.result==="OK",code:data.result,message:typeof data.message==="string"?data.message:"",data}}catch{return failure()}},"operation");try{const result=await Promise.race([operation(),interrupted]);if(disposed||session!==expectedSession)return unavailable();return{...result,tokenChanged:identity.token!==currentIdentity.token}}finally{clearTimeout(timer);requests.delete(cancel)}},"dispatch");const service={get disposed(){return disposed},init(){if(initialized||disposed)return Promise.resolve();initialized=true;origin=parentOrigin(win,options.targetOrigin);if(!win?.addEventListener||win.parent===win||!origin)settle("noop");else{win.addEventListener("message",onMessage);win.addEventListener("pagehide",service.dispose);initTimer=setTimeout(()=>settle("noop"),duration(options.initTimeoutMs,5e3))}return Promise.resolve()},whenReady(){void service.init();if(state!=="pending"||disposed)return Promise.resolve();if(waiters.size>=16){const oldest=waiters.values().next().value;waiters.delete(oldest);oldest()}return new Promise(resolve=>waiters.add(resolve))},getState:__name(()=>state,"getState"),isReady:__name(()=>state==="active"&&!disposed,"isReady"),getAppId:__name(()=>identity?.appId??"","getAppId"),getPlayerId:__name(()=>identity?.playerId??"","getPlayerId"),getPlayerName:__name(()=>identity?.playerName??"","getPlayerName"),getSessionId:__name(()=>session,"getSessionId"),async request(options2){if(!options2||typeof options2.path!=="string"||!/^\/[A-Za-z0-9/_-]+$/.test(options2.path))return failure("INVALID_ARGUMENT","\u975E\u6CD5\u8BF7\u6C42\u8DEF\u5F84");const expected=options2.sessionId??(state==="pending"?null:session);await service.whenReady();if(disposed||state!=="active"||expected!==null&&expected!==session)return unavailable();const requestSession=session;let result=await dispatch(options2,requestSession);if(result.code==="AUTH_FAILED"&&result.tokenChanged)result=await dispatch(options2,requestSession);const{tokenChanged,...publicResult}=result;return publicResult},on(event,listener){if(!listeners.has(event))listeners.set(event,new Set);listeners.get(event).add(listener);return()=>service.off(event,listener)},off(event,listener){listeners.get(event)?.delete(listener)},dispose(){if(disposed)return;disposed=true;invalidate();identity=null;settle("noop");win?.removeEventListener?.("message",onMessage);win?.removeEventListener?.("pagehide",service.dispose);emit("dispose");listeners.clear();if(win?.[SERVICE_KEY]===service)delete win[SERVICE_KEY]}};return service}__name(createPlatformService,"createPlatformService");function getPlatformService(options={}){const win=options.window??(typeof window==="undefined"?void 0:window);if(!win)throw new Error("getPlatformService requires a browser window");if(!win[SERVICE_KEY]||win[SERVICE_KEY].disposed)win[SERVICE_KEY]=createPlatformService({...options,window:win});return win[SERVICE_KEY]}__name(getPlatformService,"getPlatformService");var PlatformServiceManager=Object.freeze(Object.fromEntries(["init","whenReady","getState","isReady","getAppId","getPlayerId","getPlayerName","getSessionId","request","on","off","dispose"].map(method=>[method,(...args)=>getPlatformService()[method](...args)])));var MANAGER_KEY=Symbol.for("@game-runtime/leaderboard/v1");var invalid=__name(message=>({result:"INVALID_ARGUMENT",message}),"invalid");var boardKey=__name(value=>value===void 0||value===""?"default":value,"boardKey");var validKey=__name(value=>typeof value==="string"&&/^[A-Za-z0-9._-]{1,64}$/.test(value),"validKey");var PERIODS=["all_time","weekly","monthly","season"];var validPeriod=__name(value=>PERIODS.includes(value),"validPeriod");var MAX_AROUND_SELF=25;var seasonConfig=__name(value=>{if(value===null||typeof value!=="object")return void 0;return{start_time:value.startTime??value.start_time,period_days:value.periodDays??value.period_days,loop_count:value.loopCount??value.loop_count??0}},"seasonConfig");var BOARD_TYPES=["comprehensive","periodic","test"];var configureOptions=__name(value=>typeof value==="string"?BOARD_TYPES.includes(value)?{type:value}:value?{subType:value}:{}:value!==null&&typeof value==="object"?value:{},"configureOptions");var deliver=__name(async(promise,callback)=>{const result=await promise;try{callback?.(result)}catch{}return result},"deliver");const note=__name((action,key,result,extra="")=>{try{const board=result?.board_key??key??"";const items=action==="query"&&Array.isArray(result?.items)?` items=${result.items.length}`:"";console.info(`[leaderboard] ${action} result=${result?.result??""} message=${result?.message??""}${board?` board_key=${board}`:""}${items}${extra}`)}catch{}return result},"note");function createLeaderboard(options={}){const service=options.service??getPlatformService();const specs=new Map;const send=__name(async(action,body)=>{const res=await service.request({path:`/api/leaderboard/${action}`,body});return{...res.data,result:res.code,message:res.message}},"send");const periodOf=__name((key,opts)=>{const p=opts?.period??specs.get(key)?.period;return validPeriod(p)?p:"all_time"},"periodOf");const guard=__name((key,opts)=>{if(!validKey(key))return invalid("\u975E\u6CD5 boardKey");if(opts?.period!==void 0&&!validPeriod(opts.period))return invalid("\u975E\u6CD5 period\uFF0C\u53EA\u80FD\u662F all_time/weekly/monthly/season");return null},"guard");const ready=__name(async()=>{const sessionId=service.getState()==="pending"?null:service.getSessionId();await service.whenReady();return sessionId!==null&&sessionId!==service.getSessionId()?{result:"PLATFORM_UNAVAILABLE",message:"\u5E73\u53F0\u8EAB\u4EFD\u5DF2\u5207\u6362"}:null},"ready");const scoreBody=__name((key,score,playerName,opts)=>{const body={score,player_name:typeof playerName==="string"&&playerName.trim()?playerName.trim():service.getPlayerName(),board_key:key,...specs.get(key),period:periodOf(key,opts)};if(opts?.extra!==void 0)body.extra=opts.extra;return body},"scoreBody");return{configure(sortOrder,updatePolicy,scoreRange,key="default",opts={}){opts=configureOptions(opts);if(!["asc","desc"].includes(sortOrder)||!["BEST","OVERWRITE","ACCUMULATE"].includes(updatePolicy)||!Array.isArray(scoreRange)||scoreRange.length!==2||!scoreRange.every(Number.isFinite)||scoreRange[0]>scoreRange[1]||!validKey(key)){note("configure",key,{result:"IGNORED",message:"invalid configure"});return}const period=validPeriod(opts.period)?opts.period:"all_time";const spec={sort_order:sortOrder,update_policy:updatePolicy,score_range:[...scoreRange],period,type:opts.type!==void 0&&opts.type!==""?String(opts.type):period==="all_time"?"comprehensive":"periodic"};if(opts.subType!==void 0&&opts.subType!=="")spec.sub_type=String(opts.subType);const cfg=period==="season"?seasonConfig(opts.periodConfig):void 0;if(cfg)spec.period_config=cfg;specs.set(key,spec);note("configure",key,{result:"OK",message:"stored",board_key:key},` sort_order=${sortOrder} update_policy=${updatePolicy} period=${period}`)},report(score,playerName,onDone,opts={}){const key=boardKey(opts.boardKey);const run=__name(async()=>{if(!Number.isFinite(score))return note("report",key,{result:"INVALID_SCORE",message:"score \u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57"});const bad=guard(key,opts);if(bad)return note("report",key,bad);const stale=await ready();if(stale)return note("report",key,stale);const spec=specs.get(key);return note("report",key,await send("report",scoreBody(key,score,playerName,opts)),` configured=${spec?"yes":"no"}`)},"run");return deliver(run(),onDone)},reportBatch(boards,onDone){const run=__name(async()=>{if(!Array.isArray(boards)||boards.length===0)return note("reportBatch","",invalid("boards \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4"));const stale=await ready();if(stale)return note("reportBatch","",stale);const items=[];for(const item of boards){const key=boardKey(item?.boardKey);if(!Number.isFinite(item?.score))return note("reportBatch",key,{result:"INVALID_SCORE",message:"score \u5FC5\u987B\u662F\u6709\u9650\u6570\u5B57"});const bad=guard(key,item);if(bad)return note("reportBatch",key,bad);items.push(scoreBody(key,item.score,item.playerName,item))}const res=await send("report-batch",{boards:items});const out=Array.isArray(res.boards)?{...res,boards:res.boards.map(b=>({...b,message:b.message??(b.result==="OK"?"\u6210\u529F":"\u64CD\u4F5C\u5931\u8D25")}))}:res;return note("reportBatch","",out)},"run");return deliver(run(),onDone)},query(onDone,opts={}){const key=boardKey(opts.boardKey);const run=__name(async()=>{const bad=guard(key,opts);if(bad)return note("query",key,bad);const body={board_key:key,period:periodOf(key,opts),limit:Number.isFinite(opts.limit)&&opts.limit>0?Math.floor(opts.limit):50,include_self:opts.includeSelf!==false};if(Number.isFinite(opts.seasonNumber)&&opts.seasonNumber>0)body.season_number=Math.floor(opts.seasonNumber);if(Number.isFinite(opts.aroundSelf)&&opts.aroundSelf>0)body.around_self=Math.min(Math.floor(opts.aroundSelf),MAX_AROUND_SELF);const res=await send("query",body);return note("query",key,res.result==="BOARD_NOT_FOUND"||res.result==="ARCHIVED"?{...res,board_key:key,items:[],self:null,total:0}:res)},"run");return deliver(run(),onDone)},updateDisplay(playerName,extra,onDone,opts={}){const key=boardKey(opts.boardKey);const run=__name(async()=>{const bad=guard(key,opts);if(bad)return note("updateDisplay",key,bad);const body={board_key:key,period:periodOf(key,opts)};if(Number.isFinite(opts.seasonNumber)&&opts.seasonNumber>0)body.season_number=Math.floor(opts.seasonNumber);if(typeof playerName==="string"&&playerName.trim())body.player_name=playerName.trim();if(extra!==void 0)body.extra=extra;return note("updateDisplay",key,await send("update-display-data",body))},"run");return deliver(run(),onDone)},clear(onDone,opts={}){const key=boardKey(opts.boardKey);const body=opts.allBoards===true?{all_boards:true}:{all_boards:false,board_key:key};const run=opts.allBoards!==true&&!validKey(key)?Promise.resolve(note("clear",key,invalid("\u975E\u6CD5 boardKey"))):send("clear",body).then(result=>note("clear",opts.allBoards===true?"*":key,result));return deliver(run,onDone)}}}__name(createLeaderboard,"createLeaderboard");function current(){const service=getPlatformService();if(window[MANAGER_KEY]?.service!==service)window[MANAGER_KEY]={service,manager:createLeaderboard({service})};return window[MANAGER_KEY].manager}__name(current,"current");var LeaderboardManager=Object.freeze(Object.fromEntries(["configure","report","query","clear","reportBatch","updateDisplay"].map(method=>[method,(...args)=>current()[method](...args)])));export{LeaderboardManager,createLeaderboard};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @template_name multiplayerManager/log
|
|
3
|
-
*
|
|
4
|
-
* 极薄日志门面(零依赖)。联机模板唯一需要的日志能力就是「带 tag 的 console」——
|
|
5
|
-
* `Log.scope(tag)` 返回一个 { info, warn, error },各方法把 tag 前缀到 console 对应级别。
|
|
6
|
-
*
|
|
7
|
-
* 为什么模板自带而不依赖宿主:master 已废弃整套 CoreManager/vendor(含原 LogManager),
|
|
8
|
-
* 新的极薄 runtime 也不提供日志单例。联机对日志的用法极浅(只 scope + info/warn/error),
|
|
9
|
-
* 故内联一份最小实现,随模板一起落地,保证「即插即用、零外部依赖」,且不逆 master 删 vendor 的方向。
|
|
10
|
-
*
|
|
11
|
-
* 安装后与 MultiplayerManager.ts 同目录,不要删,也不要换成别的日志实现。
|
|
12
|
-
* 形状是 `scope(tag).{info,warn,error}`。
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export interface ScopedLogger {
|
|
16
|
-
info(...args: unknown[]): void;
|
|
17
|
-
warn(...args: unknown[]): void;
|
|
18
|
-
error(...args: unknown[]): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function prefix(tag: string): string {
|
|
22
|
-
return `[${tag}]`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const Log = {
|
|
26
|
-
/** 返回一个把 `[tag]` 前缀到每条日志的 scoped logger。 */
|
|
27
|
-
scope(tag: string): ScopedLogger {
|
|
28
|
-
const head = prefix(tag);
|
|
29
|
-
return {
|
|
30
|
-
info: (...args: unknown[]) => console.info(head, ...args),
|
|
31
|
-
warn: (...args: unknown[]) => console.warn(head, ...args),
|
|
32
|
-
error: (...args: unknown[]) => console.error(head, ...args),
|
|
33
|
-
};
|
|
34
|
-
},
|
|
35
|
-
};
|
package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 时钟标定 ping 间隔。这是一个**低频测量**,不是每帧动作——3s 一次足够把偏移收敛住并跟随缓慢漂移。
|
|
3
|
-
* ⚠️ 绝不要把 ping 放进游戏循环 / update() / 每帧路径:偏移是慢变量,高频 ping 只会烧上行、抢占 patch 窗口,
|
|
4
|
-
* 一次都不会让标定更准。需要更快收敛就在连上后头几秒临时密一点,稳定后回落到这个间隔,仍远低于每帧。
|
|
5
|
-
*/
|
|
6
|
-
const CLOCK_PING_INTERVAL_MS = 3_000;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 本机时钟与 DS 时钟的偏移测量。`serverNow() = Date.now() + offset`。
|
|
10
|
-
* 只做**测量**,无玩法语义——不是预测/插值/回滚。
|
|
11
|
-
* 未标定时 offset 为 0(即当作两端时钟一致,退化为无补偿),随 pong 用最小 RTT 样本收敛。
|
|
12
|
-
*/
|
|
13
|
-
export class ClockSync {
|
|
14
|
-
private _offset = 0;
|
|
15
|
-
private _calibrated = false;
|
|
16
|
-
/** 最小 RTT 样本:只有更小的 RTT 才更新偏移(RTT 越小,单向延迟估得越准)。 */
|
|
17
|
-
private _minRtt = Infinity;
|
|
18
|
-
private _timer: ReturnType<typeof setInterval> | null = null;
|
|
19
|
-
|
|
20
|
-
get offset(): number {
|
|
21
|
-
return this._offset;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get calibrated(): boolean {
|
|
25
|
-
return this._calibrated;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 连上即开、断开即停;间隔 3s,不进游戏循环。
|
|
30
|
-
* `sendPing(t)` 负责把本机时间戳 `t` 发给 DS,DS 原样回传(配 `st` = DS 当前时钟),据此在 onPong 里算偏移。
|
|
31
|
-
*/
|
|
32
|
-
start(sendPing: (t: number) => void): void {
|
|
33
|
-
this.stop();
|
|
34
|
-
sendPing(Date.now());
|
|
35
|
-
this._timer = setInterval(() => sendPing(Date.now()), CLOCK_PING_INTERVAL_MS);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
stop(): void {
|
|
39
|
-
if (this._timer) {
|
|
40
|
-
clearInterval(this._timer);
|
|
41
|
-
this._timer = null;
|
|
42
|
-
}
|
|
43
|
-
// 偏移不清零:换连接(重连)后先沿用上次标定值,等新 pong 收敛,避免瞬间回退到无补偿。
|
|
44
|
-
this._minRtt = Infinity;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 收到 pong:用**最小 RTT 样本**更新偏移。
|
|
49
|
-
* - `rtt = now − t`(t 是这次 ping 发出时打的本机时间戳,原样回来的)。
|
|
50
|
-
* - 只在 rtt 创新低时才更新:`offset = st − (t + rtt/2)`(假设来回对称,单向 ≈ rtt/2)。
|
|
51
|
-
* 最小 RTT 抗抖:某次网络抖动导致的大 RTT 样本会把单向延迟估偏,直接丢弃只留最干净的那次。
|
|
52
|
-
*/
|
|
53
|
-
onPong(t: number, st: number): void {
|
|
54
|
-
if (!t || !st) return;
|
|
55
|
-
const rtt = Date.now() - t;
|
|
56
|
-
if (rtt < 0 || rtt >= this._minRtt) return;
|
|
57
|
-
this._minRtt = rtt;
|
|
58
|
-
this._offset = st - (t + rtt / 2);
|
|
59
|
-
this._calibrated = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/** 连 DS 的传输层:只走网关 `/api/ds-proxy/{port}`,DS 刚被拉起时带重试。房间监听留在 MultiplayerManager。 */
|
|
2
|
-
|
|
3
|
-
import { Client, type Room } from '@colyseus/sdk';
|
|
4
|
-
import type { ScopedLogger } from '../log';
|
|
5
|
-
|
|
6
|
-
/** DS 进程可能刚被平台拉起、还没 listen;重试上限与退避见 joinDs。 */
|
|
7
|
-
const CONNECT_MAX_ATTEMPTS = 10;
|
|
8
|
-
|
|
9
|
-
/** 由 `PlatformServiceManager.getApi()` 的 host 原文拼 `wss://{host}{prefix}/api/ds-proxy/{port}`;api 非法返回 null。 */
|
|
10
|
-
export function dsEndpoint(api: string, port: number): string | null {
|
|
11
|
-
try {
|
|
12
|
-
const url = new URL(api);
|
|
13
|
-
const wsProto = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
14
|
-
const prefix = url.pathname.replace(/\/+$/, '');
|
|
15
|
-
return `${wsProto}//${url.host}${prefix}/api/ds-proxy/${port}`;
|
|
16
|
-
} catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function joinDs(
|
|
22
|
-
endpoint: string,
|
|
23
|
-
dsHost: string,
|
|
24
|
-
roomName: string,
|
|
25
|
-
joinOptions: Record<string, unknown>,
|
|
26
|
-
log: ScopedLogger,
|
|
27
|
-
): Promise<{ room: Room<any>; attempt: number } | null> {
|
|
28
|
-
const host = dsHost.trim();
|
|
29
|
-
// endpoint 不带 ?host=:Colyseus 会丢掉 URL 的 search,只能在 urlBuilder 里每次补。
|
|
30
|
-
const client = new Client(endpoint, {
|
|
31
|
-
urlBuilder(url: URL) {
|
|
32
|
-
if (host) url.searchParams.set('host', host);
|
|
33
|
-
return url.toString();
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
for (let attempt = 1; attempt <= CONNECT_MAX_ATTEMPTS; attempt++) {
|
|
38
|
-
try {
|
|
39
|
-
// 传的是进程内房间名(ds/main.mjs 的 key),不是 roomId——
|
|
40
|
-
// 进哪个进程已由 HTTP 的 connect 决定,改成 roomId 会在 DS 里另建一间没人认识的房。
|
|
41
|
-
const room = await client.joinOrCreate<any>(roomName, joinOptions);
|
|
42
|
-
return { room, attempt };
|
|
43
|
-
} catch (err) {
|
|
44
|
-
log.warn(`DS 连接失败 attempt=${attempt}/${CONNECT_MAX_ATTEMPTS}`, err);
|
|
45
|
-
if (attempt < CONNECT_MAX_ATTEMPTS) {
|
|
46
|
-
const delay = Math.min(500 + (attempt - 1) * 100, 1000);
|
|
47
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** 入站单包硬上限:超限时连接被以 code 1009 断开,不是丢包。必须按字节算。 */
|
|
2
|
-
export const MAX_PAYLOAD_BYTES = 4 * 1024;
|
|
3
|
-
|
|
4
|
-
/** data 线上是字符串;宽容处理 object。 */
|
|
5
|
-
export function parsePayload(raw: unknown): Record<string, unknown> {
|
|
6
|
-
if (raw == null) return {};
|
|
7
|
-
if (typeof raw === 'object') return raw as Record<string, unknown>;
|
|
8
|
-
if (typeof raw !== 'string') return {};
|
|
9
|
-
try {
|
|
10
|
-
return JSON.parse(raw || '{}');
|
|
11
|
-
} catch {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** 归一为字符串并按字节卡 4KB;超限返回 null。 */
|
|
17
|
-
export function encodePayload(data: unknown): string | null {
|
|
18
|
-
let raw: string;
|
|
19
|
-
if (typeof data === 'string') {
|
|
20
|
-
raw = data;
|
|
21
|
-
} else {
|
|
22
|
-
try {
|
|
23
|
-
raw = JSON.stringify(data ?? {});
|
|
24
|
-
} catch {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// 中文 UTF-8 每字 3 字节,String.length 会低估。
|
|
29
|
-
return new TextEncoder().encode(raw).length > MAX_PAYLOAD_BYTES ? null : raw;
|
|
30
|
-
}
|
package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/** 平台 Room HTTP(`/api/room/*`)。身份、token、app_id 一律经 PlatformServiceManager,不自取。 */
|
|
2
|
-
|
|
3
|
-
import { Log } from '../log';
|
|
4
|
-
import { PlatformServiceManager } from '../platform-service.mjs';
|
|
5
|
-
import type { MpResult, RoomBrief } from './types';
|
|
6
|
-
|
|
7
|
-
/** 等平台握手结算的上限。PlatformServiceManager 保证 5s 内 pending → active / noop,多给 1s 兜底。 */
|
|
8
|
-
const PLATFORM_SETTLE_TIMEOUT_MS = 6_000;
|
|
9
|
-
|
|
10
|
-
const log = Log.scope('MultiplayerManager');
|
|
11
|
-
|
|
12
|
-
export type RoomAction = 'create' | 'list' | 'join' | 'leave' | 'describe';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 等平台握手结算。PlatformServiceManager 保证 pending 在 5s 内必转 active 或 noop,
|
|
16
|
-
* 这里的超时只是兜底:万一接入方漏了 PlatformServiceManager.init()(state 恒 pending),
|
|
17
|
-
* 也不能把大厅调用永久挂住。
|
|
18
|
-
*/
|
|
19
|
-
async function awaitPlatformSettled(): Promise<void> {
|
|
20
|
-
if (PlatformServiceManager.getState() !== 'pending') return;
|
|
21
|
-
|
|
22
|
-
await new Promise<void>((resolve) => {
|
|
23
|
-
let settled = false;
|
|
24
|
-
let off: (() => void) | null = null;
|
|
25
|
-
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
26
|
-
|
|
27
|
-
const finish = () => {
|
|
28
|
-
if (settled) return;
|
|
29
|
-
settled = true;
|
|
30
|
-
if (timer) clearTimeout(timer);
|
|
31
|
-
off?.();
|
|
32
|
-
resolve();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
off = PlatformServiceManager.on('state-change', (next: string) => {
|
|
36
|
-
if (next !== 'pending') finish();
|
|
37
|
-
});
|
|
38
|
-
timer = setTimeout(finish, PLATFORM_SETTLE_TIMEOUT_MS);
|
|
39
|
-
// 订阅前可能已经结算完。
|
|
40
|
-
if (PlatformServiceManager.getState() !== 'pending') finish();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function roomPost(action: RoomAction, body: Record<string, unknown>): Promise<MpResult<unknown>> {
|
|
45
|
-
// 首屏(如大厅 create() 里直接拉房间列表)调进来时平台可能还在握手,pending 期间
|
|
46
|
-
// getAppId() 恒为空。不等就返 NO_PLATFORM 会把"还没就绪"误报成"环境不支持联机"。
|
|
47
|
-
await awaitPlatformSettled();
|
|
48
|
-
|
|
49
|
-
const platformState = PlatformServiceManager.getState();
|
|
50
|
-
const appId = PlatformServiceManager.getAppId();
|
|
51
|
-
if (platformState === 'noop') {
|
|
52
|
-
log.warn(`room/${action} 跳过:当前环境无平台身份`);
|
|
53
|
-
return { ok: false, code: 'NO_PLATFORM', message: '当前环境不支持联机' };
|
|
54
|
-
}
|
|
55
|
-
if (!appId) {
|
|
56
|
-
log.warn(`room/${action} 跳过:平台握手未完成 state=${platformState}`);
|
|
57
|
-
return { ok: false, code: 'NO_PLATFORM', message: '平台连接未就绪,请稍后重试' };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// app_id 每个接口必带;engine 不要传(平台按 app_id 查引擎)。
|
|
61
|
-
const res = await PlatformServiceManager.request({
|
|
62
|
-
path: `/api/room/${action}`,
|
|
63
|
-
body: { app_id: appId, ...body },
|
|
64
|
-
});
|
|
65
|
-
return { ok: res.ok, code: res.code, message: res.message, data: res.data };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function toRoomBrief(raw: unknown): RoomBrief {
|
|
69
|
-
const item = (raw && typeof raw === 'object' ? raw : {}) as Record<string, unknown>;
|
|
70
|
-
const num = (v: unknown): number => {
|
|
71
|
-
const n = Number(v);
|
|
72
|
-
return Number.isFinite(n) ? Math.max(0, Math.floor(n)) : 0;
|
|
73
|
-
};
|
|
74
|
-
const pick = (snake: string, camel: string): unknown =>
|
|
75
|
-
item[snake] !== undefined && item[snake] !== null ? item[snake] : item[camel];
|
|
76
|
-
return {
|
|
77
|
-
roomId: String(pick('room_id', 'roomId') ?? ''),
|
|
78
|
-
title: String(item.title ?? ''),
|
|
79
|
-
playerCount: num(pick('player_count', 'playerCount')),
|
|
80
|
-
maxPlayers: num(pick('max_players', 'maxPlayers')),
|
|
81
|
-
status: String(item.status ?? ''),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** createRoom 的 version_id 取自 URL `?config=`。 */
|
|
86
|
-
export function getVersionId(): string {
|
|
87
|
-
if (typeof window === 'undefined') return '';
|
|
88
|
-
return new URLSearchParams(window.location.search).get('config') ?? '';
|
|
89
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/** MultiplayerManager 对外类型。业务从 `../MultiplayerManager` 引入即可,不必直接引本文件。 */
|
|
2
|
-
|
|
3
|
-
export type MpState = 'idle' | 'connecting' | 'in-room' | 'left' | 'error';
|
|
4
|
-
|
|
5
|
-
export interface MpInitConfig {
|
|
6
|
-
/** 房间名,须与 ds/main.mjs 里 rooms 的 key 一致。默认 'sync'。 */
|
|
7
|
-
roomName?: string;
|
|
8
|
-
/** 开房人数上限(1–64)。必须与 ds/ 的 maxClients、玩法人数三者相同。默认 8。 */
|
|
9
|
-
maxPlayers?: number;
|
|
10
|
-
/**
|
|
11
|
-
* 开房标题,仅供大厅列表展示,留空由平台填 'Room'。
|
|
12
|
-
* 平台**不保证唯一、也不支持按 title 查房**:别拿它当"房间号"再遍历 listRooms 反查,
|
|
13
|
-
* 撞标题时两人会进到不同的 room_id、双方都看不到对手。进房一律用 listRooms 给的 roomId。
|
|
14
|
-
*/
|
|
15
|
-
title?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface RoomBrief {
|
|
19
|
-
roomId: string;
|
|
20
|
-
title: string;
|
|
21
|
-
playerCount: number;
|
|
22
|
-
maxPlayers: number;
|
|
23
|
-
status: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface MpResult<T = undefined> {
|
|
27
|
-
ok: boolean;
|
|
28
|
-
/** 'OK' 或平台 result 枚举(ROOM_FULL / NOT_FOUND / DS_ALLOC_FAILED / AUTH_FAILED …)、本地码(NO_PLATFORM / CONNECT_FAILED / PAYLOAD_TOO_LARGE) */
|
|
29
|
-
code: string;
|
|
30
|
-
message: string;
|
|
31
|
-
data?: T;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** createRoom / joinRoom 可选。默认失败即释放座位。 */
|
|
35
|
-
export interface MpEnterOptions {
|
|
36
|
-
/** 占座成功但 DS 未连上时保留座位,供随后 joinRoom 重试。默认 false。 */
|
|
37
|
-
keepSeat?: boolean;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface DsConnect {
|
|
41
|
-
host: string;
|
|
42
|
-
port: number;
|
|
43
|
-
protocol: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type EventHandler = (from: string, type: string, data: Record<string, unknown>) => void;
|
|
47
|
-
export type StateFieldHandler = (value: any, previous: any) => void;
|