@craft_eco/craft-mcp 0.1.25 → 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.
Files changed (620) hide show
  1. package/README.md +31 -10
  2. package/bin/craft-mcp.mjs +10 -8
  3. package/dist-server/game-workflow/bundle-files.mjs +43 -0
  4. package/dist-server/game-workflow/engines.mjs +13 -6
  5. package/dist-server/game-workflow/project-bundles.mjs +90 -0
  6. package/dist-server/game-workflow/project-context.mjs +91 -0
  7. package/dist-server/game-workflow/projects.mjs +16 -4
  8. package/dist-server/game-workflow/publication-materials.mjs +18 -20
  9. package/dist-server/game-workflow/publications.mjs +15 -17
  10. package/dist-server/game-workflow/publish-capture.mjs +21 -57
  11. package/dist-server/integrations/config.mjs +71 -0
  12. package/dist-server/integrations/files.mjs +54 -0
  13. package/dist-server/integrations/hosts.mjs +30 -0
  14. package/dist-server/integrations/install.mjs +86 -0
  15. package/dist-server/integrations/runtime.mjs +71 -0
  16. package/dist-server/mcp/publication-page.mjs +18 -50
  17. package/dist-server/mcp/publish-panel.mjs +28 -35
  18. package/dist-server/mcp/server.mjs +17 -14
  19. package/dist-server/preview/preview-launcher.mjs +9 -2
  20. package/dist-server/preview/preview-start.mjs +2 -2
  21. package/dist-server/upstream/publication-transport.mjs +19 -19
  22. package/package.json +10 -2
  23. package/resources/craft-create/SKILL.md +14 -0
  24. package/resources/craft-game-maker/SKILL.md +77 -71
  25. package/resources/craft-game-maker/js.md +10 -10
  26. package/resources/craft-game-maker/js3d.md +13 -13
  27. package/resources/game_visual_qa.mjs +1149 -1149
  28. package/resources/js/bundle.json +93 -0
  29. package/resources/js/context/AGENTS.md +15 -102
  30. package/resources/js/context/knowledge/AigcWiring.md +5 -196
  31. package/resources/js/context/knowledge/AssetUrl.md +5 -20
  32. package/resources/js/context/knowledge/Layout.md +7 -0
  33. package/resources/js/context/knowledge/Lifecycle.md +6 -27
  34. package/resources/js/context/skills/aigc-generate/SKILL.md +6 -141
  35. package/resources/js/context/skills/asset-search/SKILL.md +5 -62
  36. package/resources/js/context/skills/asset-search/references/resource-config.md +9 -0
  37. package/resources/js/context/skills/export-config/SKILL.md +7 -19
  38. package/resources/js/context/skills/export-config/scripts/export-config.mjs +3 -45
  39. package/resources/js/context/skills/index.json +30 -0
  40. package/resources/js/context/skills/visual-qa/SKILL.md +6 -28
  41. package/resources/js/project/README.md +4 -96
  42. package/resources/js/project/package.json +1 -2
  43. package/resources/js/project/scripts/config-export/panel-resource-path.mjs +106 -0
  44. package/resources/js/{context/skills/export-config/scripts → project/scripts/config-export}/sync-asset-controls.mjs +1 -37
  45. package/resources/js/project/scripts/config-export.mjs +10 -34
  46. package/resources/js3d/bundle.json +104 -0
  47. package/resources/js3d/context/AGENTS.md +16 -85
  48. package/resources/js3d/context/knowledge/AigcWiring.md +9 -0
  49. package/resources/js3d/context/knowledge/AssetUrl.md +9 -0
  50. package/resources/js3d/context/knowledge/CodingGuide/Pitfalls.md +9 -67
  51. package/resources/js3d/context/knowledge/Layout.md +7 -0
  52. package/resources/js3d/context/knowledge/Runtime.md +5 -30
  53. package/resources/js3d/context/skills/aigc-integration/SKILL.md +6 -164
  54. package/resources/js3d/context/skills/asset-search/SKILL.md +5 -171
  55. package/resources/js3d/context/skills/asset-search/references/resource-config.md +6 -94
  56. package/resources/js3d/context/skills/asset-usage-audit/SKILL.md +6 -82
  57. package/resources/js3d/context/skills/export-config/SKILL.md +7 -11
  58. package/resources/js3d/context/skills/export-config/scripts/export-config.mjs +3 -55
  59. package/resources/js3d/context/skills/index.json +42 -0
  60. package/resources/js3d/context/skills/performance-audit/SKILL.md +8 -153
  61. package/resources/js3d/context/skills/visual-qa/SKILL.md +14 -0
  62. package/resources/js3d/project/README.md +4 -103
  63. package/resources/js3d/project/package.json +1 -2
  64. package/resources/js3d/project/scripts/config-export/panel-resource-path.mjs +106 -0
  65. package/resources/js3d/{context/skills/export-config/scripts → project/scripts/config-export}/sync-scene-assets.mjs +3 -28
  66. package/resources/js3d/project/scripts/config-export.mjs +12 -34
  67. package/vendor/agent-cli/dist/src/artifacts/build-failure.d.ts +8 -0
  68. package/vendor/agent-cli/dist/src/artifacts/build-failure.d.ts.map +1 -0
  69. package/vendor/agent-cli/dist/src/artifacts/build-failure.js +39 -0
  70. package/vendor/agent-cli/dist/src/artifacts/build-failure.js.map +1 -0
  71. package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.d.ts +5 -0
  72. package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.d.ts.map +1 -0
  73. package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.js +45 -0
  74. package/vendor/agent-cli/dist/src/artifacts/dependency-toolchain.js.map +1 -0
  75. package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.d.ts.map +1 -1
  76. package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js +2 -1
  77. package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js.map +1 -1
  78. package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts +2 -0
  79. package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts.map +1 -1
  80. package/vendor/agent-cli/dist/src/artifacts/prepare.js +7 -2
  81. package/vendor/agent-cli/dist/src/artifacts/prepare.js.map +1 -1
  82. package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts +2 -0
  83. package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts.map +1 -1
  84. package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js +27 -16
  85. package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js.map +1 -1
  86. package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.d.ts +14 -0
  87. package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.d.ts.map +1 -0
  88. package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.js +119 -0
  89. package/vendor/agent-cli/dist/src/artifacts/scene-asset-references.js.map +1 -0
  90. package/vendor/agent-cli/dist/src/artifacts/static.d.ts.map +1 -1
  91. package/vendor/agent-cli/dist/src/artifacts/static.js +20 -6
  92. package/vendor/agent-cli/dist/src/artifacts/static.js.map +1 -1
  93. package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts.map +1 -1
  94. package/vendor/agent-cli/dist/src/cli/process-protocol.js +24 -2
  95. package/vendor/agent-cli/dist/src/cli/process-protocol.js.map +1 -1
  96. package/vendor/agent-cli/dist/src/cli/process-steering.d.ts +21 -0
  97. package/vendor/agent-cli/dist/src/cli/process-steering.d.ts.map +1 -0
  98. package/vendor/agent-cli/dist/src/cli/process-steering.js +66 -0
  99. package/vendor/agent-cli/dist/src/cli/process-steering.js.map +1 -0
  100. package/vendor/agent-cli/dist/src/context/user-skill-bundle.js +1 -1
  101. package/vendor/agent-cli/dist/src/context/user-skill-bundle.js.map +1 -1
  102. package/vendor/agent-cli/dist/src/index.d.ts +4 -1
  103. package/vendor/agent-cli/dist/src/index.d.ts.map +1 -1
  104. package/vendor/agent-cli/dist/src/index.js +3 -0
  105. package/vendor/agent-cli/dist/src/index.js.map +1 -1
  106. package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts +29 -1
  107. package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts.map +1 -1
  108. package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js +18 -1
  109. package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js.map +1 -1
  110. package/vendor/agent-cli/dist/src/session/client.d.ts +10 -0
  111. package/vendor/agent-cli/dist/src/session/client.d.ts.map +1 -1
  112. package/vendor/agent-cli/dist/src/session/client.js +15 -5
  113. package/vendor/agent-cli/dist/src/session/client.js.map +1 -1
  114. package/vendor/agent-cli/dist/src/session/link-session.d.ts +3 -0
  115. package/vendor/agent-cli/dist/src/session/link-session.d.ts.map +1 -1
  116. package/vendor/agent-cli/dist/src/session/link-session.js +14 -1
  117. package/vendor/agent-cli/dist/src/session/link-session.js.map +1 -1
  118. package/vendor/agent-cli/dist/src/session/process-observability.d.ts +3 -0
  119. package/vendor/agent-cli/dist/src/session/process-observability.d.ts.map +1 -1
  120. package/vendor/agent-cli/dist/src/session/process-observability.js +11 -0
  121. package/vendor/agent-cli/dist/src/session/process-observability.js.map +1 -1
  122. package/vendor/agent-cli/dist/src/session/process-request.d.ts +3 -2
  123. package/vendor/agent-cli/dist/src/session/process-request.d.ts.map +1 -1
  124. package/vendor/agent-cli/dist/src/session/process-request.js +27 -9
  125. package/vendor/agent-cli/dist/src/session/process-request.js.map +1 -1
  126. package/vendor/agent-cli/dist/src/session/run-start-body.d.ts +1 -0
  127. package/vendor/agent-cli/dist/src/session/run-start-body.d.ts.map +1 -1
  128. package/vendor/agent-cli/dist/src/session/run-start-body.js +8 -3
  129. package/vendor/agent-cli/dist/src/session/run-start-body.js.map +1 -1
  130. package/vendor/agent-cli/dist/src/session/run-steer.d.ts +42 -0
  131. package/vendor/agent-cli/dist/src/session/run-steer.d.ts.map +1 -0
  132. package/vendor/agent-cli/dist/src/session/run-steer.js +205 -0
  133. package/vendor/agent-cli/dist/src/session/run-steer.js.map +1 -0
  134. package/vendor/agent-cli/dist/src/shared/types.d.ts +6 -0
  135. package/vendor/agent-cli/dist/src/shared/types.d.ts.map +1 -1
  136. package/vendor/agent-cli/dist/src/tools/context-program-receipt.d.ts +21 -0
  137. package/vendor/agent-cli/dist/src/tools/context-program-receipt.d.ts.map +1 -0
  138. package/vendor/agent-cli/dist/src/tools/context-program-receipt.js +102 -0
  139. package/vendor/agent-cli/dist/src/tools/context-program-receipt.js.map +1 -0
  140. package/vendor/agent-cli/dist/src/tools/context-program.d.ts.map +1 -1
  141. package/vendor/agent-cli/dist/src/tools/context-program.js +3 -0
  142. package/vendor/agent-cli/dist/src/tools/context-program.js.map +1 -1
  143. package/resources/js/context/.role/AGENTS_DESIGN.md +0 -9
  144. package/resources/js/context/agents/aigc-asset.md +0 -168
  145. package/resources/js/context/knowledge/AigcEnabled.md +0 -49
  146. package/resources/js/context/knowledge/FrontendComponents.md +0 -17
  147. package/resources/js/context/knowledge/MobileAdaptation.md +0 -73
  148. package/resources/js/context/knowledge/MobileAdapted.md +0 -36
  149. package/resources/js/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +0 -114
  150. package/resources/js/context/knowledge/Multiplayer/OverviewKnowledge.md +0 -115
  151. package/resources/js/context/knowledge/Multiplayer/StateSyncKnowledge.md +0 -392
  152. package/resources/js/context/knowledge/PlatformServices.md +0 -190
  153. package/resources/js/context/knowledge/ProjectDisplayConfig.md +0 -35
  154. package/resources/js/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +0 -242
  155. package/resources/js/context/knowledge/Ui.md +0 -11
  156. package/resources/js/context/knowledge/UiEditorCompat.md +0 -21
  157. package/resources/js/context/rules/MultiplayerCapability.md +0 -23
  158. package/resources/js/context/rules/MultiplayerRoomEntryUX.md +0 -63
  159. package/resources/js/context/rules/PlatformBoundaryModules.md +0 -44
  160. package/resources/js/context/rules/preview_ready.md +0 -8
  161. package/resources/js/context/skills/aigc-generate/knowledge/audio.md +0 -39
  162. package/resources/js/context/skills/aigc-generate/knowledge/batch-replace.md +0 -26
  163. package/resources/js/context/skills/aigc-generate/knowledge/character2d.md +0 -132
  164. package/resources/js/context/skills/aigc-generate/knowledge/non-stepwise-aigc.md +0 -53
  165. package/resources/js/context/skills/aigc-generate/knowledge/texture-prop.md +0 -52
  166. package/resources/js/context/skills/aigc-generate/knowledge/texture-scene.md +0 -191
  167. package/resources/js/context/skills/aigc-generate/knowledge/texture-ui.md +0 -55
  168. package/resources/js/context/skills/asset-search/scripts/asset_display.mjs +0 -62
  169. package/resources/js/context/skills/asset-search/scripts/config.json +0 -5
  170. package/resources/js/context/skills/asset-search/scripts/provided_assets.mjs +0 -125
  171. package/resources/js/context/skills/asset-search/scripts/search.mjs +0 -760
  172. package/resources/js/context/skills/asset-search/scripts/sprite_source_materializer.mjs +0 -657
  173. package/resources/js/context/skills/asset-search/strategies/anim2d.md +0 -42
  174. package/resources/js/context/skills/asset-search/strategies/audio.md +0 -34
  175. package/resources/js/context/skills/asset-search/strategies/effect2d.md +0 -31
  176. package/resources/js/context/skills/asset-search/strategies/texture-prop.md +0 -22
  177. package/resources/js/context/skills/asset-search/strategies/ui-common.md +0 -40
  178. package/resources/js/context/skills/asset-search/strategies/ui-style.md +0 -28
  179. package/resources/js/context/skills/export-config/scripts/translate-asset-titles.mjs +0 -161
  180. package/resources/js/context/skills/lightgame-runtime-adapt/SKILL.md +0 -93
  181. package/resources/js/context/skills/lightgame-runtime-adapt/project/game-runtime.json +0 -7
  182. package/resources/js/context/skills/lightgame-runtime-adapt/project/package.json +0 -22
  183. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +0 -5
  184. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +0 -208
  185. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +0 -37
  186. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-capture-video.mjs +0 -227
  187. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-service.d.mts +0 -31
  188. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +0 -272
  189. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform.d.mts +0 -79
  190. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform.mjs +0 -29
  191. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/release.json +0 -22
  192. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/cli.mjs +0 -16
  193. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.d.mts +0 -4
  194. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.mjs +0 -50
  195. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +0 -3
  196. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.mjs +0 -72
  197. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/assets.d.mts +0 -24
  198. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/assets.mjs +0 -2
  199. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/astc.d.mts +0 -10
  200. package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tools/astc.mjs +0 -1
  201. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/config-export.mjs +0 -37
  202. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/refresh-runtime.mjs +0 -50
  203. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/cli.mjs +0 -20
  204. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.d.mts +0 -19
  205. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.mjs +0 -1
  206. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/installed.json +0 -6
  207. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.d.mts +0 -6
  208. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.mjs +0 -77
  209. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.d.mts +0 -2
  210. package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.mjs +0 -34
  211. package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/ui-stage.ts +0 -156
  212. package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/viewport.ts +0 -249
  213. package/resources/js/context/skills/lightgame-runtime-adapt/project/src/main.ts +0 -87
  214. package/resources/js/context/skills/lightgame-runtime-adapt/project/src/platform.ts +0 -2
  215. package/resources/js/context/skills/lightgame-runtime-adapt/project/src/screenUi.ts +0 -185
  216. package/resources/js/context/skills/lightgame-runtime-adapt/project/src/style.css +0 -294
  217. package/resources/js/context/skills/lightgame-runtime-adapt/project/tsconfig.json +0 -20
  218. package/resources/js/context/skills/lightgame-runtime-adapt/project/vite.config.ts +0 -5
  219. package/resources/js/context/skills/lightgame-runtime-adapt/scripts/install-template.mjs +0 -159
  220. package/resources/js/context/skills/mobile-adaptation/SKILL.md +0 -277
  221. package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +0 -50
  222. package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +0 -862
  223. package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +0 -92
  224. package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +0 -254
  225. package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +0 -245
  226. package/resources/js/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +0 -135
  227. package/resources/js/context/skills/mobile-adaptation/references/input-config.md +0 -342
  228. package/resources/js/context/skills/mobile-adaptation/references/verification.md +0 -140
  229. package/resources/js/context/skills/mobile-adaptation/references/web-audio.md +0 -11
  230. package/resources/js/context/skills/mobile-compat-qa/SKILL.md +0 -53
  231. package/resources/js/context/skills/mobile-compat-qa/references/startup-diagnosis.md +0 -23
  232. package/resources/js/context/skills/mobile-compat-qa/references/web-lifecycle.md +0 -20
  233. package/resources/js/context/skills/mobile-compat-qa/references/web-performance.md +0 -19
  234. package/resources/js/context/skills/optimization-suggestions/SKILL.md +0 -89
  235. package/resources/js/context/skills/platform-services/SKILL.md +0 -101
  236. package/resources/js/context/skills/platform-services/assets/modules/MultiplayerManager.ts +0 -465
  237. package/resources/js/context/skills/platform-services/assets/modules/eventBus.ts +0 -57
  238. package/resources/js/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +0 -5
  239. package/resources/js/context/skills/platform-services/assets/modules/identity/qq-session.mjs +0 -208
  240. package/resources/js/context/skills/platform-services/assets/modules/identity/shared.mjs +0 -37
  241. package/resources/js/context/skills/platform-services/assets/modules/leaderboard.d.mts +0 -39
  242. package/resources/js/context/skills/platform-services/assets/modules/leaderboard.mjs +0 -1
  243. package/resources/js/context/skills/platform-services/assets/modules/log.ts +0 -35
  244. package/resources/js/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +0 -61
  245. package/resources/js/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +0 -52
  246. package/resources/js/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +0 -30
  247. package/resources/js/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +0 -89
  248. package/resources/js/context/skills/platform-services/assets/modules/multiplayer/types.ts +0 -47
  249. package/resources/js/context/skills/platform-services/assets/modules/platform-service.d.mts +0 -31
  250. package/resources/js/context/skills/platform-services/assets/modules/platform-service.mjs +0 -272
  251. package/resources/js/context/skills/platform-services/assets/modules/save.d.mts +0 -49
  252. package/resources/js/context/skills/platform-services/assets/modules/save.mjs +0 -1
  253. package/resources/js/context/skills/platform-services/assets/scaffold/ds/main.mjs +0 -7
  254. package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +0 -264
  255. package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +0 -39
  256. package/resources/js/context/skills/platform-services/references/SERVER_GUIDE.md +0 -139
  257. package/resources/js/context/skills/platform-services/references/api_reference.md +0 -18
  258. package/resources/js/context/skills/platform-services/references/leaderboard_playbook.md +0 -96
  259. package/resources/js/context/skills/platform-services/scripts/install.mjs +0 -148
  260. package/resources/js/context/skills/resolution-adaptation/SKILL.md +0 -47
  261. package/resources/js/context/skills/resolution-adaptation/assets/display/ui-stage.ts +0 -156
  262. package/resources/js/context/skills/resolution-adaptation/assets/display/viewport.ts +0 -249
  263. package/resources/js/context/skills/resolution-adaptation/assets/example/main.ts +0 -98
  264. package/resources/js/context/skills/resolution-adaptation/assets/example/ui-tokens.css +0 -200
  265. package/resources/js/context/skills/resolution-adaptation/references/audit.md +0 -31
  266. package/resources/js/context/skills/resolution-adaptation/references/device-safe-area.md +0 -40
  267. package/resources/js/context/skills/resolution-adaptation/references/game-ui-occlusion.md +0 -18
  268. package/resources/js/context/skills/resolution-adaptation/references/layout-rules.md +0 -15
  269. package/resources/js/context/skills/resolution-adaptation/references/troubleshooting.md +0 -34
  270. package/resources/js/context/skills/resolution-adaptation/references/viewport-api.md +0 -38
  271. package/resources/js/context/skills/resolution-adaptation/references/world-resize.md +0 -55
  272. package/resources/js/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +0 -448
  273. package/resources/js/context/skills/scene-editor-compat/SKILL.md +0 -94
  274. package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.assets.json +0 -13
  275. package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.scene-editor.json +0 -6
  276. package/resources/js/context/skills/scene-editor-compat/assets/example/src/game/sceneAdapter.ts +0 -25
  277. package/resources/js/context/skills/scene-editor-compat/assets/example/src/scenes/main.scene.json +0 -18
  278. package/resources/js/context/skills/scene-editor-compat/assets/runtime/release.json +0 -7
  279. package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.d.mts +0 -42
  280. package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.mjs +0 -144
  281. package/resources/js/context/skills/scene-editor-compat/docs/contract.md +0 -330
  282. package/resources/js/context/skills/scene-editor-compat/docs/resource-sync.md +0 -64
  283. package/resources/js/context/skills/scene-editor-compat/docs/runtime-state.md +0 -28
  284. package/resources/js/context/skills/scene-editor-compat/docs/terrain-contract.md +0 -47
  285. package/resources/js/context/skills/scene-editor-compat/docs/visual-contract.md +0 -64
  286. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.assets.json +0 -38
  287. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.scene-editor.json +0 -9
  288. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneAdapter.ts +0 -59
  289. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneBlockers.ts +0 -30
  290. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneFileAssets.ts +0 -66
  291. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/Main.Scene.ts +0 -20
  292. package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/SceneTypes.ts +0 -26
  293. package/resources/js/context/skills/scene-editor-compat/references/contract.md +0 -73
  294. package/resources/js/context/skills/scene-editor-compat/scripts/apply_scene_marker.py +0 -162
  295. package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_contract.py +0 -853
  296. package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_resource_urls.py +0 -173
  297. package/resources/js/context/skills/scene-editor-compat/scripts/scene-editor.mjs +0 -427
  298. package/resources/js/context/skills/scene-editor-compat/version.json +0 -1
  299. package/resources/js/context/skills/ui-editor-compat/SKILL.md +0 -48
  300. package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +0 -35
  301. package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +0 -74
  302. package/resources/js/context/skills/ui-editor-compat/assets/example/hud/hud.css +0 -60
  303. package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +0 -45
  304. package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +0 -265
  305. package/resources/js/context/skills/ui-editor-compat/assets/runtime/release.json +0 -7
  306. package/resources/js/context/skills/ui-editor-compat/references/contract.md +0 -132
  307. package/resources/js/context/skills/ui-editor-compat/scripts/editor-contract.mjs +0 -327
  308. package/resources/js/context/skills/ui-editor-compat/scripts/project-files.mjs +0 -80
  309. package/resources/js/context/skills/ui-editor-compat/scripts/ui-editor.mjs +0 -84
  310. package/resources/js/context/skills/version-update/SKILL.md +0 -192
  311. package/resources/js/context/skills/version-update/scripts/check_runtime_refs.mjs +0 -129
  312. package/resources/js/context/skills/version-update/scripts/feature_snapshot.mjs +0 -159
  313. package/resources/js/context/skills/version-update/scripts/update_feature_version.mjs +0 -157
  314. package/resources/js/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
  315. package/resources/js/context/version/version.json +0 -1
  316. package/resources/js/project/SPEC/assist/.gitkeep +0 -0
  317. package/resources/js/project/SPEC/guide/.gitkeep +0 -0
  318. package/resources/js/project/SPEC/plan/.gitkeep +0 -0
  319. package/resources/js/project/SPEC/readme.md +0 -6
  320. package/resources/js/project/SPEC/res/.gitkeep +0 -0
  321. package/resources/js/project/SPEC/task-item/.gitkeep +0 -0
  322. package/resources/js/project/runtime/lightgame/1.0.0/platform/config.d.mts +0 -19
  323. package/resources/js/project/runtime/lightgame/1.0.0/platform/config.mjs +0 -1
  324. package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +0 -39
  325. package/resources/js/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +0 -1
  326. package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +0 -227
  327. package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +0 -25
  328. package/resources/js/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +0 -1
  329. package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.d.mts +0 -79
  330. package/resources/js/project/runtime/lightgame/1.0.0/platform/platform.mjs +0 -29
  331. package/resources/js/project/runtime/lightgame/1.0.0/platform/save.d.mts +0 -49
  332. package/resources/js/project/runtime/lightgame/1.0.0/platform/save.mjs +0 -1
  333. package/resources/js/project/runtime/lightgame/1.0.0/release.json +0 -37
  334. package/resources/js/project/runtime/lightgame/1.0.0/tooling/cli.mjs +0 -2
  335. package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.d.mts +0 -8
  336. package/resources/js/project/runtime/lightgame/1.0.0/tooling/project.mjs +0 -2
  337. package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +0 -3
  338. package/resources/js/project/runtime/lightgame/1.0.0/tooling/vite.mjs +0 -8
  339. package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.d.mts +0 -24
  340. package/resources/js/project/runtime/lightgame/1.0.0/tools/assets.mjs +0 -2
  341. package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.d.mts +0 -10
  342. package/resources/js/project/runtime/lightgame/1.0.0/tools/astc.mjs +0 -1
  343. package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.d.mts +0 -20
  344. package/resources/js/project/runtime/lightgame/1.0.0/tools/audio.mjs +0 -1
  345. package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +0 -21
  346. package/resources/js/project/runtime/lightgame/1.0.0/tools/canvas.mjs +0 -1
  347. package/resources/js/project/runtime/lightgame/1.0.0/tools/input.d.mts +0 -17
  348. package/resources/js/project/runtime/lightgame/1.0.0/tools/input.mjs +0 -1
  349. package/resources/js/project/runtime/lightgame/1.0.0/tools/three.d.mts +0 -40
  350. package/resources/js/project/runtime/lightgame/1.0.0/tools/three.mjs +0 -1
  351. package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.d.mts +0 -10
  352. package/resources/js/project/runtime/lightgame/1.0.0/tools/ui.mjs +0 -1
  353. package/resources/js/project/runtime/lightgame/1.0.0/tools/video.d.mts +0 -8
  354. package/resources/js/project/runtime/lightgame/1.0.0/tools/video.mjs +0 -1
  355. package/resources/js/project/scripts/refresh-runtime.mjs +0 -50
  356. package/resources/js/project/vendor/core-manager-js/package.json +0 -33
  357. package/resources/js/project/vendor/core-manager-js/src/.versions.json +0 -42
  358. package/resources/js/project/vendor/core-manager-js/src/CoreManagerPlugin.ts +0 -41
  359. package/resources/js/project/vendor/core-manager-js/src/assetManager/AssetRef.ts +0 -93
  360. package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcFirstImageFile.ts +0 -203
  361. package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcTextureLoader.ts +0 -106
  362. package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.test.ts +0 -25
  363. package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.ts +0 -21
  364. package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.test.ts +0 -65
  365. package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.ts +0 -340
  366. package/resources/js/project/vendor/core-manager-js/src/configManager/FeatureConfig.ts +0 -87
  367. package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.d.mts +0 -92
  368. package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.mjs +0 -271
  369. package/resources/js/project/vendor/core-manager-js/src/index.ts +0 -31
  370. package/resources/js/project/vendor/core-manager-js/src/inputManager/InputConfig.ts +0 -81
  371. package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.test.ts +0 -43
  372. package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.ts +0 -32
  373. package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.test.ts +0 -141
  374. package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.ts +0 -20
  375. package/resources/js/project/vendor/core-manager-js/src/inputManager/KeyboardProvider.ts +0 -183
  376. package/resources/js/project/vendor/core-manager-js/src/inputManager/TouchProvider.ts +0 -304
  377. package/resources/js/project/vendor/core-manager-js/src/inputManager/VirtualJoystick.ts +0 -351
  378. package/resources/js/project/vendor/core-manager-js/src/inputManager/_internal/InputManagerImpl.ts +0 -180
  379. package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64 +0 -13
  380. package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64.d.ts +0 -14
  381. package/resources/js/project/vendor/core-manager-js/src/inputManager/input_config.example.json +0 -68
  382. package/resources/js/project/vendor/core-manager-js/src/logManager/DebugConsole.ts +0 -433
  383. package/resources/js/project/vendor/core-manager-js/src/logManager/LogCapture.ts +0 -118
  384. package/resources/js/project/vendor/core-manager-js/src/logManager/LogManager.ts +0 -444
  385. package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCapture.ts +0 -485
  386. package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.test.ts +0 -66
  387. package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.ts +0 -149
  388. package/resources/js/project/vendor/core-manager-js/src/logManager/icons.b64 +0 -9
  389. package/resources/js/project/vendor/core-manager-js/src/resourceManager/AssetUrlResolver.ts +0 -29
  390. package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.test.ts +0 -88
  391. package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.ts +0 -122
  392. package/resources/js/project/vendor/core-manager-js/src/runtime.ts +0 -24
  393. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterEntity.ts +0 -318
  394. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.test.ts +0 -151
  395. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.ts +0 -235
  396. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.test.ts +0 -98
  397. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.ts +0 -94
  398. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectEntity.ts +0 -209
  399. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.test.ts +0 -106
  400. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.ts +0 -341
  401. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.test.ts +0 -68
  402. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.ts +0 -236
  403. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.test.ts +0 -22
  404. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.ts +0 -29
  405. package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteEntity.test.ts +0 -197
  406. package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiContracts.ts +0 -9
  407. package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiKit.ts +0 -555
  408. package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.test.ts +0 -112
  409. package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.ts +0 -178
  410. package/resources/js/project/vendor/core-manager-js/src/uiManager/ui-base.css +0 -246
  411. package/resources/js/project/vendor/core-manager-js/src/videoManager/VideoManager.ts +0 -139
  412. package/resources/js/project/vendor/core-manager-js/tsconfig.json +0 -15
  413. package/resources/js/project/vendor/run.sh +0 -4
  414. package/resources/js/project/version/craft_feature_version.json +0 -42
  415. package/resources/js/project/version/project_feature_version.json +0 -11
  416. package/resources/js3d/context/.role/AGENTS_DESIGN.md +0 -9
  417. package/resources/js3d/context/knowledge/3D/PoseInterpolationKnowledge.md +0 -75
  418. package/resources/js3d/context/knowledge/CodingGuide/SceneEditableGuide.md +0 -42
  419. package/resources/js3d/context/knowledge/FrontendComponents.md +0 -19
  420. package/resources/js3d/context/knowledge/MobileAdaptation.md +0 -73
  421. package/resources/js3d/context/knowledge/MobileAdapted.md +0 -36
  422. package/resources/js3d/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +0 -114
  423. package/resources/js3d/context/knowledge/Multiplayer/OverviewKnowledge.md +0 -117
  424. package/resources/js3d/context/knowledge/Multiplayer/StateSyncKnowledge.md +0 -430
  425. package/resources/js3d/context/knowledge/PlatformServices.md +0 -190
  426. package/resources/js3d/context/knowledge/ProjectDisplayConfig.md +0 -35
  427. package/resources/js3d/context/knowledge/SceneEditorCompat.md +0 -35
  428. package/resources/js3d/context/knowledge/StepByStep.md +0 -21
  429. package/resources/js3d/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +0 -242
  430. package/resources/js3d/context/knowledge/UiEditorCompat.md +0 -21
  431. package/resources/js3d/context/rules/MultiplayerCapability.md +0 -27
  432. package/resources/js3d/context/rules/MultiplayerRoomEntryUX.md +0 -63
  433. package/resources/js3d/context/rules/PlatformBoundaryModules.md +0 -44
  434. package/resources/js3d/context/rules/preview_ready.md +0 -8
  435. package/resources/js3d/context/skills/aigc-integration/assets/sprite-sheet-player.mjs +0 -70
  436. package/resources/js3d/context/skills/aigc-integration/callback.md +0 -77
  437. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/README.md +0 -23
  438. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/audio-aigc-knowledge.md +0 -38
  439. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/character2d-aigc-knowledge.md +0 -72
  440. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/staticmesh-aigc-knowledge.md +0 -33
  441. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-prop-aigc-knowledge.md +0 -36
  442. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-scene-aigc-knowledge.md +0 -37
  443. package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-ui-aigc-knowledge.md +0 -35
  444. package/resources/js3d/context/skills/asset-search/references/sprite-sheets.md +0 -58
  445. package/resources/js3d/context/skills/asset-search/scripts/asset_display.mjs +0 -62
  446. package/resources/js3d/context/skills/asset-search/scripts/config.json +0 -235
  447. package/resources/js3d/context/skills/asset-search/scripts/manifest_pipeline.mjs +0 -905
  448. package/resources/js3d/context/skills/asset-search/scripts/preflight.mjs +0 -79
  449. package/resources/js3d/context/skills/asset-search/scripts/provided_assets.mjs +0 -74
  450. package/resources/js3d/context/skills/asset-search/scripts/search.mjs +0 -637
  451. package/resources/js3d/context/skills/asset-search/scripts/sprite_source_materializer.mjs +0 -667
  452. package/resources/js3d/context/skills/asset-search/strategies/anim2d.md +0 -42
  453. package/resources/js3d/context/skills/asset-search/strategies/effect2d.md +0 -31
  454. package/resources/js3d/context/skills/asset-usage-audit/references/case-tidewater-zoo.md +0 -89
  455. package/resources/js3d/context/skills/asset-usage-audit/references/optimization-playbook.md +0 -143
  456. package/resources/js3d/context/skills/asset-usage-audit/references/usage-model.md +0 -90
  457. package/resources/js3d/context/skills/export-config/scripts/translate-asset-titles.mjs +0 -161
  458. package/resources/js3d/context/skills/game-art-style/SKILL.md +0 -60
  459. package/resources/js3d/context/skills/game-art-style/assets/previews/cartoon.png +0 -0
  460. package/resources/js3d/context/skills/game-art-style/assets/previews/comic.png +0 -0
  461. package/resources/js3d/context/skills/game-art-style/assets/previews/cozy.png +0 -0
  462. package/resources/js3d/context/skills/game-art-style/assets/previews/cyber.png +0 -0
  463. package/resources/js3d/context/skills/game-art-style/assets/previews/horror.png +0 -0
  464. package/resources/js3d/context/skills/game-art-style/assets/previews/lowpoly.png +0 -0
  465. package/resources/js3d/context/skills/game-art-style/assets/previews/paper.png +0 -0
  466. package/resources/js3d/context/skills/game-art-style/assets/previews/voxel.png +0 -0
  467. package/resources/js3d/context/skills/game-art-style/references/art-parameters-lite.md +0 -38
  468. package/resources/js3d/context/skills/game-art-style/references/construction.md +0 -111
  469. package/resources/js3d/context/skills/game-art-style/references/materials-textures.md +0 -105
  470. package/resources/js3d/context/skills/game-art-style/references/sources.md +0 -25
  471. package/resources/js3d/context/skills/game-art-style/references/styles/cartoon.md +0 -175
  472. package/resources/js3d/context/skills/game-art-style/references/styles/comic.md +0 -168
  473. package/resources/js3d/context/skills/game-art-style/references/styles/cozy.md +0 -191
  474. package/resources/js3d/context/skills/game-art-style/references/styles/cyber.md +0 -165
  475. package/resources/js3d/context/skills/game-art-style/references/styles/horror.md +0 -173
  476. package/resources/js3d/context/skills/game-art-style/references/styles/lowpoly.md +0 -185
  477. package/resources/js3d/context/skills/game-art-style/references/styles/paper.md +0 -181
  478. package/resources/js3d/context/skills/game-art-style/references/styles/voxel.md +0 -189
  479. package/resources/js3d/context/skills/game-art-style/references/user-style-document.md +0 -88
  480. package/resources/js3d/context/skills/mobile-adaptation/SKILL.md +0 -301
  481. package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +0 -104
  482. package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +0 -933
  483. package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +0 -92
  484. package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +0 -254
  485. package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +0 -245
  486. package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +0 -257
  487. package/resources/js3d/context/skills/mobile-adaptation/references/input-config.md +0 -342
  488. package/resources/js3d/context/skills/mobile-adaptation/references/verification.md +0 -140
  489. package/resources/js3d/context/skills/mobile-adaptation/references/web-audio.md +0 -11
  490. package/resources/js3d/context/skills/mobile-compat-qa/SKILL.md +0 -53
  491. package/resources/js3d/context/skills/mobile-compat-qa/references/startup-diagnosis.md +0 -23
  492. package/resources/js3d/context/skills/mobile-compat-qa/references/web-form-input.md +0 -10
  493. package/resources/js3d/context/skills/mobile-compat-qa/references/web-lifecycle.md +0 -20
  494. package/resources/js3d/context/skills/mobile-compat-qa/references/web-performance.md +0 -19
  495. package/resources/js3d/context/skills/optimization-suggestions/SKILL.md +0 -74
  496. package/resources/js3d/context/skills/performance-audit/references/case-notes.md +0 -93
  497. package/resources/js3d/context/skills/performance-audit/references/rules.md +0 -183
  498. package/resources/js3d/context/skills/platform-services/SKILL.md +0 -101
  499. package/resources/js3d/context/skills/platform-services/assets/modules/MultiplayerManager.ts +0 -465
  500. package/resources/js3d/context/skills/platform-services/assets/modules/eventBus.ts +0 -57
  501. package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +0 -5
  502. package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-session.mjs +0 -208
  503. package/resources/js3d/context/skills/platform-services/assets/modules/identity/shared.mjs +0 -37
  504. package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.d.mts +0 -39
  505. package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.mjs +0 -1
  506. package/resources/js3d/context/skills/platform-services/assets/modules/log.ts +0 -35
  507. package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +0 -61
  508. package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +0 -52
  509. package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +0 -30
  510. package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +0 -89
  511. package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/types.ts +0 -47
  512. package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.d.mts +0 -31
  513. package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.mjs +0 -272
  514. package/resources/js3d/context/skills/platform-services/assets/modules/save.d.mts +0 -49
  515. package/resources/js3d/context/skills/platform-services/assets/modules/save.mjs +0 -1
  516. package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/main.mjs +0 -7
  517. package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +0 -264
  518. package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +0 -39
  519. package/resources/js3d/context/skills/platform-services/references/SERVER_GUIDE.md +0 -139
  520. package/resources/js3d/context/skills/platform-services/references/api_reference.md +0 -18
  521. package/resources/js3d/context/skills/platform-services/references/leaderboard_playbook.md +0 -96
  522. package/resources/js3d/context/skills/platform-services/scripts/install.mjs +0 -148
  523. package/resources/js3d/context/skills/resolution-adaptation/SKILL.md +0 -46
  524. package/resources/js3d/context/skills/resolution-adaptation/assets/display/ui-stage.ts +0 -156
  525. package/resources/js3d/context/skills/resolution-adaptation/assets/display/viewport.ts +0 -239
  526. package/resources/js3d/context/skills/resolution-adaptation/assets/example/main.ts +0 -129
  527. package/resources/js3d/context/skills/resolution-adaptation/assets/example/ui-tokens.css +0 -188
  528. package/resources/js3d/context/skills/resolution-adaptation/references/audit.md +0 -31
  529. package/resources/js3d/context/skills/resolution-adaptation/references/device-safe-area.md +0 -40
  530. package/resources/js3d/context/skills/resolution-adaptation/references/game-ui-occlusion.md +0 -18
  531. package/resources/js3d/context/skills/resolution-adaptation/references/layout-rules.md +0 -15
  532. package/resources/js3d/context/skills/resolution-adaptation/references/troubleshooting.md +0 -34
  533. package/resources/js3d/context/skills/resolution-adaptation/references/viewport-api.md +0 -38
  534. package/resources/js3d/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +0 -448
  535. package/resources/js3d/context/skills/scene-editor-compat/SKILL.md +0 -599
  536. package/resources/js3d/context/skills/scene-editor-compat/references/bundle-contract.md +0 -141
  537. package/resources/js3d/context/skills/scene-editor-compat/references/editor-integration.md +0 -92
  538. package/resources/js3d/context/skills/scene-editor-compat/references/scene-data-format.md +0 -125
  539. package/resources/js3d/context/skills/scene-editor-compat/references/slots-rules.md +0 -113
  540. package/resources/js3d/context/skills/scene-editor-compat/scripts/scene-editor.mjs +0 -1187
  541. package/resources/js3d/context/skills/threejs-game-quality/SKILL.md +0 -53
  542. package/resources/js3d/context/skills/threejs-game-quality/agents/openai.yaml +0 -4
  543. package/resources/js3d/context/skills/threejs-game-quality/references/01-build.md +0 -94
  544. package/resources/js3d/context/skills/threejs-game-quality/references/02-avoid.md +0 -50
  545. package/resources/js3d/context/skills/threejs-game-quality/references/03-detect.md +0 -105
  546. package/resources/js3d/context/skills/threejs-game-quality/references/camera-by-genre.md +0 -147
  547. package/resources/js3d/context/skills/threejs-game-quality/references/camera-distance.md +0 -79
  548. package/resources/js3d/context/skills/threejs-game-quality/references/camera-sources.md +0 -56
  549. package/resources/js3d/context/skills/threejs-game-quality/references/character-motion-face.md +0 -51
  550. package/resources/js3d/context/skills/threejs-game-quality/references/parameter-contract.md +0 -55
  551. package/resources/js3d/context/skills/threejs-game-quality/references/refine-existing.md +0 -78
  552. package/resources/js3d/context/skills/threejs-game-quality/references/rendering-stability.md +0 -84
  553. package/resources/js3d/context/skills/threejs-game-quality/references/runtime-tools.md +0 -120
  554. package/resources/js3d/context/skills/threejs-game-quality/scripts/package.json +0 -4
  555. package/resources/js3d/context/skills/threejs-game-quality/scripts/runtime-audit.js +0 -238
  556. package/resources/js3d/context/skills/ui-editor-compat/SKILL.md +0 -59
  557. package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +0 -35
  558. package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +0 -61
  559. package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/hud.css +0 -60
  560. package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +0 -45
  561. package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +0 -265
  562. package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/release.json +0 -7
  563. package/resources/js3d/context/skills/ui-editor-compat/references/contract.md +0 -110
  564. package/resources/js3d/context/skills/ui-editor-compat/scripts/editor-contract.mjs +0 -327
  565. package/resources/js3d/context/skills/ui-editor-compat/scripts/project-files.mjs +0 -80
  566. package/resources/js3d/context/skills/ui-editor-compat/scripts/ui-editor.mjs +0 -84
  567. package/resources/js3d/context/skills/version-update/SKILL.md +0 -191
  568. package/resources/js3d/context/skills/version-update/scripts/check_runtime_refs.mjs +0 -129
  569. package/resources/js3d/context/skills/version-update/scripts/feature_snapshot.mjs +0 -159
  570. package/resources/js3d/context/skills/version-update/scripts/update_feature_version.mjs +0 -157
  571. package/resources/js3d/context/skills/version-update/upgrade_diffs/.gitkeep +0 -0
  572. package/resources/js3d/context/version/version.json +0 -1
  573. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.d.mts +0 -19
  574. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/config.mjs +0 -1
  575. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +0 -39
  576. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +0 -1
  577. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-capture-video.mjs +0 -227
  578. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.d.mts +0 -25
  579. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +0 -1
  580. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.d.mts +0 -79
  581. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/platform.mjs +0 -30
  582. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.d.mts +0 -49
  583. package/resources/js3d/project/runtime/lightgame/1.0.0/platform/save.mjs +0 -1
  584. package/resources/js3d/project/runtime/lightgame/1.0.0/release.json +0 -39
  585. package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/cli.mjs +0 -2
  586. package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.d.mts +0 -8
  587. package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/project.mjs +0 -2
  588. package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +0 -3
  589. package/resources/js3d/project/runtime/lightgame/1.0.0/tooling/vite.mjs +0 -7
  590. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.d.mts +0 -24
  591. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/assets.mjs +0 -2
  592. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.d.mts +0 -10
  593. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/astc.mjs +0 -1
  594. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.d.mts +0 -20
  595. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/audio.mjs +0 -1
  596. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +0 -21
  597. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/canvas.mjs +0 -1
  598. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.d.mts +0 -26
  599. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.mjs +0 -351
  600. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.d.mts +0 -17
  601. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/input.mjs +0 -1
  602. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.d.mts +0 -40
  603. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/three.mjs +0 -1
  604. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.d.mts +0 -10
  605. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/ui.mjs +0 -1
  606. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.d.mts +0 -8
  607. package/resources/js3d/project/runtime/lightgame/1.0.0/tools/video.mjs +0 -1
  608. package/resources/js3d/project/scripts/refresh-runtime.mjs +0 -50
  609. package/resources/js3d/project/vendor/core-manager-three/package.json +0 -12
  610. package/resources/js3d/project/vendor/core-manager-three/src/index.ts +0 -2
  611. package/resources/js3d/project/vendor/run.sh +0 -4
  612. package/resources/js3d/project/version/craft_feature_version.json +0 -42
  613. package/resources/js3d/project/version/project_feature_version.json +0 -11
  614. package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.d.ts +0 -7
  615. package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.d.ts.map +0 -1
  616. package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.js +0 -145
  617. package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.js.map +0 -1
  618. /package/resources/js/{context/skills/export-config/scripts → project/scripts/config-export}/assert-asset-wiring.mjs +0 -0
  619. /package/resources/js3d/{context/skills/export-config/scripts → project/scripts/config-export}/assert-asset-wiring.mjs +0 -0
  620. /package/resources/js3d/{context/skills/export-config/scripts → project/scripts/config-export}/sync-asset-controls.mjs +0 -0
@@ -1,862 +0,0 @@
1
- /**
2
- * 统一输入层:把 PC 键鼠与移动端虚拟控件收敛到**同一套语义接口**。
3
- *
4
- * 落盘位置:`${CRAFT_PROJECT_DIR}/src/input/input-layer.ts`
5
- *
6
- * Phaser 侧的用法:入口 `main.ts` 建一次(`canvas` 传 `game.canvas`),拿到 `input` 后挂到
7
- * `game.registry` 或模块单例上;Scene 在 `update()` 里读语义接口。
8
- * **不要用 `this.input.on('pointerdown')` 处理同一批玩法动作** —— 那是另一条输入通路,
9
- * 会在 PC 与移动端上各触发一次。Phaser 的指针事件只保留给「世界内点选 / 拖拽世界物体」,
10
- * 且这类交互要按 SKILL.md「四、触点仲裁」确认触点没有被虚拟控件消费。
11
- *
12
- * 三层职责,不要混:
13
- * ① 语义层(本文件的对外接口):`isDown('jump')` / `horizontal()` / `lookDelta()`。
14
- * **业务只认这一层**,因此 PC 与移动端是同一条代码路径,不需要 `if (mobile)`。
15
- * ② 映射层:`input-config.json` 里每个条目同时给出 `pc`(按键名)与 `mobile`(控件描述)。
16
- * 两者映射到同一个语义 key;缺一边等于该平台玩不了。
17
- * ③ 控件层:PC 用键盘事件;移动端用 DOM 虚拟控件(摇杆 / 动作按钮 / 视角滑动区)。
18
- *
19
- * 触点仲裁:**button > joystick > look**。这里靠 DOM 命中测试天然成立 ——
20
- * 动作按钮是滑动区**之后**插入的兄弟节点(同 z-index 下后插入者优先命中),
21
- * 摇杆区与滑动区是互不重叠的左下区域与右半屏。一次 pointerdown 只可能落在其中一个元素上,
22
- * 且 `setPointerCapture` 之后该指针的后续事件只发给它 —— 等价于「一根手指自 down 起归属唯一控件」。
23
- * 由此得到两条可以直接依赖的性质:
24
- * - 落在动作按钮上的触点**不会**驱动视角,无需给滑动区配排除区;
25
- * - 拖摇杆时手指划过按钮**不会**误触发按钮(触点已被摇杆捕获)。
26
- */
27
- import {
28
- createActionInput,
29
- createJoystick,
30
- createKeyboard,
31
- } from './input-primitives';
32
- import { applyPlatformAttr } from './input-platform';
33
- import type { InputPlatform } from './input-platform';
34
- import { createLookPad } from './look-pad';
35
- import type { LookPad } from './look-pad';
36
- import type { UiStageHandle } from '../display/ui-stage';
37
- import inputConfig from './input-config.json';
38
-
39
- // ─────────────────────── 配置结构(与 input-config.json 一一对应) ───────────────────────
40
-
41
- export interface InputAxisConfig {
42
- pc: {
43
- /** 键位名见 SKILL.md「PC 键位名」 */
44
- horizontal: { negative: readonly string[]; positive: readonly string[] };
45
- vertical: { negative: readonly string[]; positive: readonly string[] };
46
- };
47
- mobile: {
48
- type: 'joystick';
49
- /** 有效拖动半径(设计像素)。**不得小于 40** */
50
- radius: number;
51
- /** 死区比例 [0,1),默认 0.12 */
52
- deadZone?: number;
53
- };
54
- }
55
-
56
- export interface InputActionConfig {
57
- /**
58
- * PC 触发源。两类 token,可混写:
59
- * - 键盘:逐字的 `KeyboardEvent.code`(`KeyJ` / `Space` / `ArrowUp`);
60
- * - 鼠标键:`Mouse0`(左)/ `Mouse1`(中)/ `Mouse2`(右)。
61
- * 鼠标键**不是** `event.code`,由本文件转成 `createActionInput({ buttons })` 回调,
62
- * 与键盘是 OR 关系、边沿检测同一条路径。写错的键名会打 warn(见 `warnSuspectKeyNames`)。
63
- */
64
- pc: readonly string[];
65
- /**
66
- * 触发语义,默认 `'hold'`。
67
- * - `'hold'`:`isDown()` 跟随物理按下(开火、加速、格挡);
68
- * - `'toggle'`:**按一次翻转一次**,`isDown()` 返回锁存态(瞄准镜、自动奔跑、静步)。
69
- * 此时 `wasPressed()` / `wasReleased()` 报的是**锁存开 / 关**的那一帧,
70
- * 不是手指按下 / 抬起 —— 业务不需要自己存 boolean 做翻转。
71
- *
72
- * **写在 action 级而不是 `mobile` 里**:PC 与移动端必须同为 toggle,
73
- * 否则 `isDown()` 在一个平台是瞬时、另一个平台是锁存,业务被迫分平台写两套。
74
- */
75
- mode?: 'hold' | 'toggle';
76
- mobile: {
77
- type: 'button';
78
- /** 按钮文字(图标走 CSS background,见 touch-controls.css) */
79
- label: string;
80
- /** 中心 X。**负数从右边缘算起** */
81
- x: number;
82
- /** 中心 Y。**负数从下边缘算起** */
83
- y: number;
84
- /** 触控半径(设计像素)。**不得小于 40** */
85
- radius: number;
86
- /**
87
- * 建出来就先隐藏。**上下文交互按钮**(靠近才出现的「开门 / 拾取 / 对话」)写 `true`,
88
- * 之后由业务用 `setActionButtonVisible(action, true)` 放出来。
89
- * 不写的话开局会先闪一下按钮,再被业务第一帧的 `setActionButtonVisible(false)` 收掉。
90
- */
91
- hidden?: boolean;
92
- /**
93
- * 按住本按钮拖动时,把指针位移并入 look 通道 ——
94
- * 需求形态是「开火按钮按下即持续开火,拖拽可控制方向」。不写则拖动不影响视角。
95
- *
96
- * 前提是同名 look 通道已在 `looks` 里声明;缺失会打 warn 并忽略。
97
- */
98
- drag?: {
99
- /** 注入哪个 look 通道,默认 `'look'` */
100
- look?: string;
101
- /**
102
- * **相对该 look 通道 `mobile.sensitivity` 的倍率**,默认 1。
103
- * 位移先乘这里、再进 LookPad 乘通道灵敏度,所以两条路的 `invertY` 天然一致。
104
- * 按钮拖拽通常要比滑动区更钝(拇指还要兼顾按住),建议 0.5~0.8。
105
- */
106
- sensitivity?: number;
107
- /**
108
- * 起手死区(CSS 像素),默认 0。
109
- * 按钮本身已是明确的按下意图,一般不需要再过滤;只有按钮很小、按下时容易带位移才调大。
110
- */
111
- deadZonePx?: number;
112
- };
113
- };
114
- }
115
-
116
- export interface InputLookConfig {
117
- /**
118
- * PC:鼠标位移。`requireButton=2` 按住右键拖动转向(**字段缺省时的默认值**);
119
- * `0`=左键;**显式写 `null` = 不限制**,移动鼠标即转向(FPS 标准操作)。
120
- * `null` 与「不写」语义不同,读取一律走 `pcLookRequireButton()`,不要用 `??`。
121
- */
122
- pc: { requireButton?: number | null; sensitivity?: number; invertY?: boolean };
123
- /** 移动端:滑动区几何由 CSS 决定(默认右半屏),不在配置里写坐标 */
124
- mobile: { sensitivity?: number; invertY?: boolean; deadZonePx?: number };
125
- }
126
-
127
- export interface InputConfigFile {
128
- axes: Record<string, InputAxisConfig>;
129
- actions: Record<string, InputActionConfig>;
130
- /** 视角通道:**只在玩家需要主动控制镜头(FPS/TPS)时声明**,其它品类整段不写 */
131
- looks?: Record<string, InputLookConfig>;
132
- }
133
-
134
- // ─────────────────────── 对外接口 ───────────────────────
135
-
136
- /** 轴上两根键的极性统一为「右正 X、下正 Y」,与键盘一致;世界方向转换在消费侧统一做 */
137
- export interface GameInput {
138
- readonly platform: InputPlatform;
139
- /** 每帧一次,**必须在所有消费者之前**调用 */
140
- sample(): void;
141
- /**
142
- * 直接读键盘边沿时需要,在所有消费者之后调用。
143
- * 只用本接口的 `wasPressed/wasReleased` 时,可在 `sample()` 之后立即调用。
144
- */
145
- endFrame(): void;
146
- /** `mode: 'toggle'` 的动作返回**锁存态**(按一次开、再按一次关),不是物理按下 */
147
- isDown(action: string): boolean;
148
- /** toggle 型动作报的是**锁存打开**的那一帧,不是手指按下 */
149
- wasPressed(action: string): boolean;
150
- /** toggle 型动作报的是**锁存关闭**的那一帧,不是手指抬起 */
151
- wasReleased(action: string): boolean;
152
- /**
153
- * 手动设置 `mode: 'toggle'` 动作的锁存态:死亡 / 换弹 / 切武器时强制退出瞄准。
154
- * 在 `sample()` 之后调用 —— 本帧的 `wasPressed` / `wasReleased` 会反映这次变化,
155
- * 下一次 `sample()` 清掉。对 `'hold'` 型动作调用会打 warn 并忽略。
156
- */
157
- setToggle(action: string, on: boolean): void;
158
- /** 语义轴(`move` / …):右正 X、下正的 [-1,1] */
159
- horizontal(axis?: string): number;
160
- vertical(axis?: string): number;
161
- /** 消费型:读一次即清零,**每帧只能读一次** */
162
- lookDelta(look?: string): { x: number; y: number };
163
- isLookActive(look?: string): boolean;
164
- /** 把外部位移并入 look 通道(如「开火按钮按住拖拽也能控向」) */
165
- feedLookDelta(dx: number, dy: number, look?: string): void;
166
- /**
167
- * 显隐**单个**移动端虚拟按钮 —— 上下文交互按钮(靠近宝箱才出现的「开门 / 拾取」)用这个。
168
- * 可以每帧无脑调用,值没变时不做任何事。
169
- *
170
- * **只管移动端 UI,不屏蔽 PC 键位。** PC 上没有虚拟控件,这里是 no-op;
171
- * 业务照常自己判上下文 —— `if (target && input.wasPressed('interact'))` ——
172
- * 这一条判断两端共用,不构成平台分支。
173
- *
174
- * **不要自己去改 `.touch-btn` 的 DOM**:隐藏时必须同时清掉按钮上残留的触点,
175
- * 否则 `display: none` 不保证释放指针捕获(元素仍在文档里),`pointerup` 可能永远收不到,
176
- * `isDown()` 会永久为真(表现为「按钮消失了却一直在开火」)。
177
- *
178
- * 对 `mode: 'toggle'` 的按钮**不清锁存**:`latched` 是两端共享的语义状态,
179
- * 单端的 UI 可见性不该改它。需要退出锁存时显式调 `setToggle(action, false)`。
180
- */
181
- setActionButtonVisible(action: string, visible: boolean): void;
182
- /**
183
- * 改移动端按钮文案:同一个 `interact` 按钮在门前显示「开门」、在 NPC 前显示「对话」。
184
- * PC 上是 no-op —— PC 的操作提示(「按 E 开门」)属于业务 HUD,不在输入层。
185
- */
186
- setActionLabel(action: string, label: string): void;
187
- /** 模态面板打开 / 暂停时隐藏并复位**全部**虚拟控件,避免触点残留与按键卡住 */
188
- setControlsVisible(visible: boolean): void;
189
- dispose(): void;
190
- }
191
-
192
- export interface InputLayerOptions {
193
- /** 游戏容器(模板 `#game`);`data-platform` 写在它上面 */
194
- container: HTMLElement;
195
- /**
196
- * 分辨率适配 skill 的 UI stage 句柄(`src/display/ui-stage.ts`)。
197
- * 虚拟控件按设计像素摆放,尺寸换算取这里的 `scale`(= 短边锁定模型解出的
198
- * viewport 短边 / 1080),**不要按固定设计尺寸另算 contain 缩放** ——
199
- * 长边伸缩下会与 stage 实际缩放不一致。
200
- */
201
- ui: UiStageHandle;
202
- /** PC 鼠标视角的监听目标(canvas);键盘监听目标是 window —— canvas 默认不可聚焦,收不到 keydown */
203
- canvas: HTMLCanvasElement;
204
- config?: InputConfigFile;
205
- }
206
-
207
- const DEFAULT_AXIS = 'move';
208
- const DEFAULT_LOOK = 'look';
209
-
210
- export function createInputLayer(options: InputLayerOptions): GameInput {
211
- const { container, ui, canvas } = options;
212
- const config = options.config ?? (inputConfig as unknown as InputConfigFile);
213
- const platform = applyPlatformAttr(container);
214
-
215
- // ── ② 映射层 ──
216
- const pcActions: Record<string, readonly string[]> = {};
217
- const pcAxes: Record<string, { negative?: readonly string[]; positive?: readonly string[] }> = {};
218
- const analog: Record<string, () => number> = {};
219
- /** 动作 → 「当前是否按下」。PC 鼠标键与移动端虚拟按钮都汇到这里,两个平台互斥不会打架 */
220
- const buttons: Record<string, () => boolean> = {};
221
- const heldPointers = new Map<string, Set<number>>();
222
- /** 动作 → 需要的鼠标键(`event.button` 值)。空数组表示该动作只用键盘 */
223
- const pcMouse = new Map<string, number[]>();
224
- /**
225
- * `mode: 'toggle'` 动作的**锁存态**。键的存在与否就是「这个动作是不是 toggle 型」的判据,
226
- * 所以 `latched.has(name)` 与 `latched.get(name)` 分别承担类型判定与取值,不要再存一份 Set。
227
- */
228
- const latched = new Map<string, boolean>();
229
- /** 本帧锁存的翻转方向(`true` = 刚打开)。用来合成 toggle 的 wasPressed / wasReleased */
230
- const latchEdge = new Map<string, boolean>();
231
- /** 动作 → 同步移动端按钮的锁存视觉。PC 无虚拟控件时为空 */
232
- const latchVisuals = new Map<string, (on: boolean) => void>();
233
- /** 按钮拖拽状态的复位钩子(隐藏控件 / dispose 时调用) */
234
- const dragResets: Array<() => void> = [];
235
- /** 动作 → 移动端按钮句柄。**PC 上为空**,所以两个 setter 在 PC 上天然是 no-op */
236
- const mobileButtons = new Map<string, MobileButtonHandle>();
237
- /** 已经报过的未知动作名。两个 setter 通常每帧调用,不去重会刷屏 */
238
- const warnedUnknownActions = new Set<string>();
239
-
240
- /** 动作名写错时两个 setter 会静默失效(PC 上本来就是 no-op,更难发现),这里报一次 */
241
- const isUnknownAction = (api: string, action: string): boolean => {
242
- if (config.actions?.[action]) return false;
243
- if (!warnedUnknownActions.has(action)) {
244
- warnedUnknownActions.add(action);
245
- console.warn(`[input] ${api}("${action}"):该动作不在 input-config.json 的 actions 里`);
246
- }
247
- return true;
248
- };
249
-
250
- for (const [name, action] of Object.entries(config.actions ?? {})) {
251
- // 鼠标键不能交给 keyboard(它只认 KeyboardEvent.code),必须在这里分流
252
- const split = splitPcBinding(action.pc);
253
- pcActions[name] = split.codes;
254
- if (split.mouseButtons.length > 0) pcMouse.set(name, split.mouseButtons);
255
- if (action.mode === 'toggle') latched.set(name, false);
256
- }
257
-
258
- for (const [name, axis] of Object.entries(config.axes ?? {})) {
259
- // createActionInput 的轴 key 是「一个轴一个条目」,与本配置的 h/v 双键结构对齐
260
- pcAxes[`${name}.h`] = axis.pc.horizontal;
261
- pcAxes[`${name}.v`] = axis.pc.vertical;
262
- }
263
-
264
- // 键名写错不会有任何运行时报错(isDown 恒 false),这里把它变成显式 warn。
265
- // **两个平台都校验**:移动端预览时也能发现 PC 配置的拼写错误。
266
- warnSuspectKeyNames(config);
267
-
268
- // ── ③ PC:键盘 + 鼠标视角 ──
269
- // 只在 PC 装配键盘;移动端不装,避免两套输入同时改同一份状态
270
- // (触屏笔记本按 (pointer: coarse) 判为 pc,用键鼠,符合「主要指针是鼠标」的直觉)。
271
- const keyboard =
272
- platform === 'pc'
273
- ? createKeyboard(window, {
274
- blurTarget: window,
275
- visibilityTarget: document,
276
- // 阻止方向键 / 空格滚动页面,否则浏览器会吃掉按键
277
- preventDefault: collectPreventDefault(config),
278
- })
279
- : null;
280
-
281
- /**
282
- * PC 鼠标键。**右键一旦参与输入就必须吃掉 contextmenu**,否则按下右键先弹出系统菜单
283
- * (`looks.*.pc.requireButton` 默认就是右键,所以有 look 通道时基本一定要吃)。
284
- */
285
- const needsRightButton =
286
- [...pcMouse.values()].some((list) => list.includes(2)) ||
287
- Object.values(config.looks ?? {}).some((look) => pcLookRequireButton(look) === 2);
288
- const mouse =
289
- platform === 'pc' && (pcMouse.size > 0 || needsRightButton)
290
- ? createMouseButtons(canvas, { suppressContextMenu: needsRightButton })
291
- : null;
292
- if (mouse) {
293
- for (const [action, list] of pcMouse) {
294
- buttons[action] = () => list.some((button) => mouse.isDown(button));
295
- }
296
- }
297
-
298
- const lookPads = new Map<string, LookPad>();
299
- if (platform === 'pc') {
300
- for (const [name, look] of Object.entries(config.looks ?? {})) {
301
- lookPads.set(
302
- name,
303
- createLookPad(canvas, {
304
- pointerTypes: ['mouse'],
305
- requireButton: pcLookRequireButton(look),
306
- sensitivity: look.pc?.sensitivity,
307
- invertY: look.pc?.invertY,
308
- }),
309
- );
310
- }
311
- }
312
-
313
- // ── ③ 移动端:虚拟控件 ──
314
- // 控件建在 UI stage 的 hud 层里:坐标即设计像素,缩放由 stage 的 transform 承担,
315
- // 因此「半径 72 设计像素」在任何设备上的物理大小都一致。
316
- let controls: HTMLElement | null = null;
317
-
318
- if (platform === 'mobile') {
319
- const root = document.createElement('div');
320
- root.id = 'touch-controls';
321
-
322
- // 视角滑动区先插入(先插入 = 命中优先级低)
323
- for (const [name, look] of Object.entries(config.looks ?? {})) {
324
- const zone = document.createElement('div');
325
- zone.className = 'touch-look-zone';
326
- zone.dataset.look = name;
327
- root.appendChild(zone);
328
- lookPads.set(
329
- name,
330
- createLookPad(zone, {
331
- /**
332
- * **必须带上 `'mouse'`**:桌面浏览器用 `?launchPlatform=mobile` 验收时,
333
- * 指针类型仍然是 mouse。只写 `['touch', 'pen']` 会让滑动区在验收环境里完全不响应 ——
334
- * 而同一形态下摇杆(`createJoystick` 认鼠标左键)和动作按钮(不筛 pointerType)都能用,
335
- * 于是表现为「摇杆能推、按钮能按,唯独视角拖不动」,很容易被误判成 look 区没实现。
336
- * 真机不会产生 mouse 事件,这一项对真机无影响。
337
- *
338
- * `requireButton: 0` 让鼠标只认左键,与 `createJoystick` 的门槛逐字一致;
339
- * touch / pen 不受它约束(见 look-pad.ts 的 `allowed()`:非 mouse 直接放行)。
340
- */
341
- pointerTypes: ['touch', 'pen', 'mouse'],
342
- requireButton: 0,
343
- sensitivity: look.mobile?.sensitivity,
344
- invertY: look.mobile?.invertY,
345
- deadZonePx: look.mobile?.deadZonePx,
346
- }),
347
- );
348
- }
349
-
350
- // 摇杆区(CSS 定为左侧 50% 宽、下方 65% 高)。范式实现为**浮动摇杆**(手指落点即圆心):
351
- // 移动端推荐形态,不需要玩家去找固定摇杆的位置。
352
- for (const [name, axis] of Object.entries(config.axes ?? {})) {
353
- if (axis.mobile?.type !== 'joystick') {
354
- console.warn(`[input] 轴 ${name} 的 mobile.type 不是 'joystick',已跳过`);
355
- continue;
356
- }
357
- const zone = document.createElement('div');
358
- zone.className = 'touch-stick-zone';
359
- zone.dataset.axis = name;
360
- const base = document.createElement('div');
361
- base.className = 'touch-stick__base';
362
- const thumb = document.createElement('div');
363
- thumb.className = 'touch-stick__thumb';
364
- base.appendChild(thumb);
365
- zone.appendChild(base);
366
- root.appendChild(zone);
367
-
368
- const radius = axis.mobile.radius;
369
- // 尺寸在配置里(设计像素),这里落到内联样式;CSS 只管居中与配色
370
- base.style.width = `${radius * 2}px`;
371
- base.style.height = `${radius * 2}px`;
372
- thumb.style.width = `${radius}px`;
373
- thumb.style.height = `${radius}px`;
374
- const joystick = createJoystick(zone, {
375
- radius,
376
- deadZone: axis.mobile.deadZone ?? 0.12,
377
- floating: true,
378
- onStart: (origin) => {
379
- // base 相对 zone 定位;不能用 stage 原点,否则区域下移会产生偏移。
380
- const rect = zone.getBoundingClientRect();
381
- base.style.left = `${(origin.x - rect.left) / ui.scale}px`;
382
- base.style.top = `${(origin.y - rect.top) / ui.scale}px`;
383
- },
384
- // radius 按设计像素给,这里换算成实际 CSS 像素
385
- scale: () => ui.scale,
386
- blurTarget: window,
387
- onChange: (value) => {
388
- // 居中位移与摇杆位移写进同一个 transform,避免两处争抢(CSS 里不再写 thumb 的 transform)
389
- thumb.style.transform =
390
- `translate(calc(-50% + ${value.x * radius * 0.6}px), calc(-50% + ${value.y * radius * 0.6}px))`;
391
- base.classList.toggle('is-active', value.active);
392
- },
393
- });
394
-
395
-
396
- analog[`${name}.h`] = () => joystick.value().x;
397
- // 摇杆「下正 Y」与键盘 vertical(负向=W/上)极性一致,**不要在移动端单独取反**
398
- analog[`${name}.v`] = () => joystick.value().y;
399
- }
400
-
401
- // 动作按钮最后插入:同 z-index 下后插入者优先命中 → **button > look** 成立
402
- for (const [action, definition] of Object.entries(config.actions ?? {})) {
403
- const mobile = definition.mobile;
404
- if (mobile?.type !== 'button') {
405
- console.warn(`[input] 动作 ${action} 的 mobile.type 不是 'button',已跳过`);
406
- continue;
407
- }
408
- const button = document.createElement('button');
409
- button.type = 'button';
410
- button.className = 'touch-btn';
411
- button.dataset.action = action;
412
- button.textContent = mobile.label;
413
- // 负值从右 / 下边缘算起:用 right / bottom 表达,转屏与改比例后**不需要重算**
414
- applyEdgeAnchors(button, mobile);
415
- root.appendChild(button);
416
-
417
- const pointers = new Set<number>();
418
- heldPointers.set(action, pointers);
419
- const sync = (): void => {
420
- button.classList.toggle('is-pressed', pointers.size > 0);
421
- };
422
-
423
- if (latched.has(action)) {
424
- // toggle 按钮的「亮」= 锁存开启,与手指是否还按着无关,所以是独立的 class。
425
- // `.is-latched` 在 CSS 里必须排在 `.is-pressed` 之后才能赢样式(同特异度后来者胜)。
426
- button.classList.add('is-toggle');
427
- latchVisuals.set(action, (on) => button.classList.toggle('is-latched', on));
428
- }
429
-
430
- // 「按住持续开火 + 拖拽控向」:拖拽量并入 look 通道,业务侧仍只读一个 lookDelta()
431
- const drag = mobile.drag
432
- ? createButtonDrag(button, action, mobile.drag, () =>
433
- lookPads.get(mobile.drag?.look ?? DEFAULT_LOOK),
434
- )
435
- : null;
436
- if (drag) dragResets.push(drag.reset);
437
-
438
- button.addEventListener('pointerdown', (event) => {
439
- // 捕获失败(指针已失效)不致命:后续 move 由元素自身命中的事件兜底
440
- try {
441
- button.setPointerCapture(event.pointerId);
442
- } catch {
443
- /* ignore */
444
- }
445
- pointers.add(event.pointerId);
446
- // 捕获之后手指拖出按钮外仍归属本按钮:这既让「按住不放继续开火」成立,
447
- // 也让 pointermove 继续发给按钮,拖拽控向才有事件可用
448
- drag?.begin(event);
449
- sync();
450
- event.preventDefault();
451
- });
452
- const release = (event: PointerEvent): void => {
453
- drag?.end(event);
454
- if (!pointers.delete(event.pointerId)) return;
455
- sync();
456
- };
457
- button.addEventListener('pointerup', release);
458
- button.addEventListener('pointercancel', release);
459
- button.addEventListener('lostpointercapture', release);
460
-
461
- buttons[action] = () => pointers.size > 0;
462
-
463
- // 上下文交互按钮:建好即隐藏,等业务判定「够得着」时再放出来
464
- if (mobile.hidden) button.classList.add('is-hidden');
465
- mobileButtons.set(action, {
466
- setVisible(visible) {
467
- // toggle 的第二个参数是「是否加上」,返回值是加完之后 token 在不在 —— 即「现在是否隐藏」
468
- const nowHidden = button.classList.toggle('is-hidden', !visible);
469
- if (!nowHidden) return;
470
- // 隐藏瞬间必须自己清触点:`display: none` 的元素**仍在文档里**,
471
- // 规范不保证释放指针捕获,`pointerup` / `lostpointercapture` 可能永远收不到,
472
- // `pointers` 会残留 → `isDown()` 永久为真。
473
- pointers.clear();
474
- sync();
475
- drag?.reset();
476
- },
477
- setLabel(label) {
478
- button.textContent = label;
479
- },
480
- });
481
- }
482
-
483
- ui.layer('hud').appendChild(root);
484
- controls = root;
485
- }
486
-
487
- // ── ① 语义层:按键与控件的边沿统一由 createActionInput 维护 ──
488
- const actionInput = createActionInput({
489
- keyboard: keyboard ?? undefined,
490
- actions: pcActions,
491
- axes: pcAxes,
492
- buttons,
493
- analog,
494
- });
495
-
496
- return {
497
- platform,
498
- sample() {
499
- actionInput.sample();
500
- // toggle:用**物理按下沿**翻转锁存。合成的边沿只在本帧有效,下一次 sample 清掉。
501
- // 注意只改既有 key 的值,不新增 key,因此边遍历边 set 是安全的。
502
- latchEdge.clear();
503
- for (const [action, on] of latched) {
504
- if (!actionInput.wasPressed(action)) continue;
505
- const next = !on;
506
- latched.set(action, next);
507
- latchEdge.set(action, next);
508
- latchVisuals.get(action)?.(next);
509
- }
510
- },
511
- endFrame() {
512
- keyboard?.endFrame();
513
- },
514
- // toggle 型返回锁存态:`latched.get()` 为 false 时 `??` 不会退化到物理状态(只有 undefined 才会)
515
- isDown: (action) => latched.get(action) ?? actionInput.isDown(action),
516
- wasPressed: (action) =>
517
- latched.has(action) ? latchEdge.get(action) === true : actionInput.wasPressed(action),
518
- wasReleased: (action) =>
519
- latched.has(action) ? latchEdge.get(action) === false : actionInput.wasReleased(action),
520
- setToggle(action, on) {
521
- if (!latched.has(action)) {
522
- console.warn(`[input] 动作 ${action} 不是 mode: 'toggle',setToggle 无效`);
523
- return;
524
- }
525
- if (latched.get(action) === on) return;
526
- latched.set(action, on);
527
- latchEdge.set(action, on);
528
- latchVisuals.get(action)?.(on);
529
- },
530
- horizontal: (axis = DEFAULT_AXIS) => actionInput.axis(`${axis}.h`),
531
- vertical: (axis = DEFAULT_AXIS) => actionInput.axis(`${axis}.v`),
532
- lookDelta: (look = DEFAULT_LOOK) => lookPads.get(look)?.consumeDelta() ?? { x: 0, y: 0 },
533
- isLookActive: (look = DEFAULT_LOOK) => lookPads.get(look)?.isActive() ?? false,
534
- feedLookDelta: (dx, dy, look = DEFAULT_LOOK) => lookPads.get(look)?.feedDelta(dx, dy),
535
- setActionButtonVisible(action, visible) {
536
- if (isUnknownAction('setActionButtonVisible', action)) return;
537
- mobileButtons.get(action)?.setVisible(visible);
538
- },
539
- setActionLabel(action, label) {
540
- if (isUnknownAction('setActionLabel', action)) return;
541
- mobileButtons.get(action)?.setLabel(label);
542
- },
543
- setControlsVisible(visible) {
544
- if (controls) {
545
- controls.style.display = visible ? '' : 'none';
546
- if (!visible) {
547
- // 关闭时复位:否则手指抬起前切走会留下「一直在按」的残留状态
548
- for (const pad of lookPads.values()) pad.reset();
549
- for (const reset of dragResets) reset();
550
- for (const pointers of heldPointers.values()) pointers.clear();
551
- for (const button of controls.querySelectorAll<HTMLElement>('.touch-btn')) {
552
- // 只清按下态:`is-hidden` 是单个按钮的**上下文可用性**,由业务用
553
- // `setActionButtonVisible` 维护,恢复控件时不能把它一起抹掉
554
- // (否则关掉暂停面板,所有上下文按钮会一起冒出来)
555
- button.classList.remove('is-pressed');
556
- }
557
- }
558
- }
559
- // PC 上没有虚拟控件,但同样要清掉按键与鼠标键状态:
560
- // 模态面板打开时不应该角色还在走,也不应该「一直在开火」
561
- if (!visible) {
562
- keyboard?.clear();
563
- mouse?.clear();
564
- }
565
- },
566
- dispose() {
567
- for (const reset of dragResets) reset();
568
- dragResets.length = 0;
569
- latched.clear();
570
- latchEdge.clear();
571
- latchVisuals.clear();
572
- mobileButtons.clear();
573
- warnedUnknownActions.clear();
574
- for (const pad of lookPads.values()) pad.dispose();
575
- lookPads.clear();
576
- keyboard?.dispose();
577
- mouse?.dispose();
578
- actionInput.reset();
579
- controls?.remove();
580
- controls = null;
581
- },
582
- };
583
- }
584
-
585
- // ─────────────────────── 内部工具 ───────────────────────
586
-
587
- /** 单个移动端按钮的运行时句柄。只有移动端会建,PC 上这张表是空的 */
588
- interface MobileButtonHandle {
589
- setVisible(visible: boolean): void;
590
- setLabel(label: string): void;
591
- }
592
-
593
- /**
594
- * PC look 通道的鼠标键门槛。**不要改成 `?? 2`** —— `??` 对 `null` 也生效,
595
- * 会把配置里显式写的 `"requireButton": null`(语义:不限制,移动鼠标即转向,
596
- * FPS/TPS 在 PC 上的标准操作)强制成右键,表现为「视角必须按住右键才能转」。
597
- * 只有「字段缺省」(`undefined`) 才落到默认的右键。
598
- * 这个函数是该语义的唯一出口,`needsRightButton` 的 contextmenu 判断也必须走它,
599
- * 否则配 `null` 时会误判成「用了右键」而多抑制一次右键菜单。
600
- */
601
- function pcLookRequireButton(look: InputLookConfig): number | null {
602
- const required = look.pc?.requireButton;
603
- return required === undefined ? 2 : required;
604
- }
605
-
606
- /** 鼠标键 token:`Mouse0` = 左键、`Mouse1` = 中键、`Mouse2` = 右键(对应 `event.button`) */
607
- const MOUSE_TOKEN = /^Mouse([0-4])$/;
608
-
609
- /** 把 `pc` 数组拆成键盘 code 与鼠标键两组。鼠标键不能进 keyboard,它只认 `event.code` */
610
- function splitPcBinding(names: readonly string[]): { codes: string[]; mouseButtons: number[] } {
611
- const codes: string[] = [];
612
- const mouseButtons: number[] = [];
613
- for (const name of names) {
614
- const matched = MOUSE_TOKEN.exec(name);
615
- if (matched) mouseButtons.push(Number(matched[1]));
616
- else codes.push(name);
617
- }
618
- return { codes, mouseButtons };
619
- }
620
-
621
- export interface MouseButtons {
622
- isDown(button: number): boolean;
623
- clear(): void;
624
- dispose(): void;
625
- }
626
-
627
- /**
628
- * PC 鼠标键状态。只产出**状态量**,边沿(`wasPressed` / `wasReleased`)仍由
629
- * `createActionInput` 统一算 —— 与键盘、移动端虚拟按钮走同一条路径,业务不需要区分来源。
630
- *
631
- * 两个必须这么写的点:
632
- * 1. **抬起监听挂在 window 上**:鼠标按住后移出 canvas 再松开,canvas 收不到 `pointerup`,
633
- * 状态会永久卡在「按下」(表现为松手后还在持续开火)。
634
- * 2. **失焦 / 切标签页一律清空**:期间的抬起事件收不到,回来时状态不可信。
635
- */
636
- function createMouseButtons(
637
- canvas: HTMLElement,
638
- options: { suppressContextMenu: boolean },
639
- ): MouseButtons {
640
- const held = new Set<number>();
641
-
642
- const onDown = (event: PointerEvent): void => {
643
- if (event.pointerType !== 'mouse') return;
644
- held.add(event.button);
645
- };
646
- const onUp = (event: PointerEvent): void => {
647
- if (event.pointerType !== 'mouse') return;
648
- held.delete(event.button);
649
- };
650
- const clear = (): void => held.clear();
651
- const onContextMenu = (event: MouseEvent): void => event.preventDefault();
652
-
653
- canvas.addEventListener('pointerdown', onDown);
654
- window.addEventListener('pointerup', onUp);
655
- window.addEventListener('pointercancel', onUp);
656
- window.addEventListener('blur', clear);
657
- document.addEventListener('visibilitychange', clear);
658
- if (options.suppressContextMenu) canvas.addEventListener('contextmenu', onContextMenu);
659
-
660
- return {
661
- isDown: (button) => held.has(button),
662
- clear,
663
- dispose() {
664
- clear();
665
- canvas.removeEventListener('pointerdown', onDown);
666
- window.removeEventListener('pointerup', onUp);
667
- window.removeEventListener('pointercancel', onUp);
668
- window.removeEventListener('blur', clear);
669
- document.removeEventListener('visibilitychange', clear);
670
- canvas.removeEventListener('contextmenu', onContextMenu);
671
- },
672
- };
673
- }
674
-
675
- /** 旧键名 / 常见笔误 → 正确写法。**只用于 warn 文案,不参与实际匹配** */
676
- const KEY_NAME_HINTS: Record<string, string> = {
677
- UP: 'ArrowUp',
678
- DOWN: 'ArrowDown',
679
- LEFT: 'ArrowLeft',
680
- RIGHT: 'ArrowRight',
681
- SPACE: 'Space',
682
- ENTER: 'Enter',
683
- SHIFT: 'ShiftLeft',
684
- CTRL: 'ControlLeft',
685
- ALT: 'AltLeft',
686
- TAB: 'Tab',
687
- ESC: 'Escape',
688
- MOUSE_LEFT: 'Mouse0',
689
- MOUSE_MIDDLE: 'Mouse1',
690
- MOUSE_RIGHT: 'Mouse2',
691
- };
692
-
693
- /** 能明确判定写错的给出建议;形态合法但不认识的名字放过(无法穷举所有 code) */
694
- function keyNameHint(name: string): string | null {
695
- if (MOUSE_TOKEN.test(name)) return null;
696
- if (KEY_NAME_HINTS[name]) return KEY_NAME_HINTS[name];
697
- if (/^[A-Za-z]$/.test(name)) return `Key${name.toUpperCase()}`;
698
- if (/^[0-9]$/.test(name)) return `Digit${name}`;
699
- if (name !== name.trim()) return `"${name.trim()}"(去掉首尾空格)`;
700
- if (/^[a-z]/.test(name)) return name.charAt(0).toUpperCase() + name.slice(1);
701
- return null;
702
- }
703
-
704
- /**
705
- * 键名写错不会有任何运行时报错 —— `keyboard.isDown()` 逐字比较,不匹配就恒为 `false`,
706
- * 表现是「这个键完全没反应」。这里把静默失效变成一条 warn。
707
- */
708
- function warnSuspectKeyNames(config: InputConfigFile): void {
709
- const names = new Set<string>();
710
- for (const axis of Object.values(config.axes ?? {})) {
711
- for (const group of [axis.pc.horizontal, axis.pc.vertical]) {
712
- group.negative.forEach((name) => names.add(name));
713
- group.positive.forEach((name) => names.add(name));
714
- }
715
- }
716
- for (const action of Object.values(config.actions ?? {})) {
717
- action.pc.forEach((name) => names.add(name));
718
- }
719
- for (const name of names) {
720
- const hint = keyNameHint(name);
721
- if (hint) {
722
- console.warn(
723
- `[input] 键名 "${name}" 不是 KeyboardEvent.code,永远不会触发;应写成 ${hint}`,
724
- );
725
- }
726
- }
727
- }
728
-
729
- /**
730
- * 收集需要 preventDefault 的键,避免方向键滚动页面 / 空格滚动。
731
- *
732
- * **逐字使用配置里的名字,不做任何别名或大小写转换。** 这里转换过一次就会出现
733
- * 「preventDefault 生效、`isDown` 永假」的静默失效 —— `keyboard.isDown()` 用的是配置原值。
734
- * 写错的名字在 `warnSuspectKeyNames` 里报出来,不在这里悄悄纠正。
735
- */
736
- function collectPreventDefault(config: InputConfigFile): string[] {
737
- const codes = new Set<string>();
738
- const add = (name: string): void => {
739
- // 鼠标键不走 keyboard,别塞进它的 preventDefault 名单
740
- if (!MOUSE_TOKEN.test(name)) codes.add(name);
741
- };
742
- for (const axis of Object.values(config.axes ?? {})) {
743
- axis.pc.horizontal.negative.forEach(add);
744
- axis.pc.horizontal.positive.forEach(add);
745
- axis.pc.vertical.negative.forEach(add);
746
- axis.pc.vertical.positive.forEach(add);
747
- }
748
- for (const action of Object.values(config.actions ?? {})) action.pc.forEach(add);
749
- for (const code of ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Space']) codes.add(code);
750
- return [...codes];
751
- }
752
-
753
- interface ButtonDrag {
754
- /** pointerdown 时登记拖拽起点 */
755
- begin(event: PointerEvent): void;
756
- /** pointerup / cancel / lostcapture 时结束 */
757
- end(event: PointerEvent): void;
758
- reset(): void;
759
- }
760
-
761
- /**
762
- * 动作按钮的「按住拖拽 → 并入 look 通道」。
763
- *
764
- * 为什么能直接监听按钮自己的 `pointermove`:按钮在 pointerdown 时做了
765
- * `setPointerCapture`,该指针的后续事件**只**发给按钮,手指拖出按钮外仍然收得到。
766
- * 这同时保证了按住拖出去 `isDown` 不掉(需求里的「按下即持续开火」)。
767
- *
768
- * 三条不能省的性质:
769
- * 1. **只跟随第一根手指。** 同一按钮上的第二根手指不参与转向,否则两指微抖会互相叠加。
770
- * 2. **滑动区已有活跃指针时让位。** 玩家已经有专职转向手指时,按钮的抖动只会给镜头加噪。
771
- * 让位期间**仍然更新 last**,否则恢复瞬间会把攒下的位移一次性灌进去(镜头猛甩)。
772
- * 3. **传原始 CSS 像素位移,不按 `ui.scale` 换算。** LookPad 的量纲就是 CSS 像素
773
- * (滑动区也是直接用 `clientX` 差值),换算会让两条路的速度不一致。
774
- */
775
- function createButtonDrag(
776
- button: HTMLElement,
777
- action: string,
778
- config: NonNullable<InputActionConfig['mobile']['drag']>,
779
- getPad: () => LookPad | undefined,
780
- ): ButtonDrag {
781
- const factor = config.sensitivity ?? 1;
782
- const deadZonePx = Math.max(0, config.deadZonePx ?? 0);
783
- let pointerId: number | null = null;
784
- let startX = 0;
785
- let startY = 0;
786
- let lastX = 0;
787
- let lastY = 0;
788
- /** 是否已越过起手死区 */
789
- let crossed = false;
790
- let warnedMissingLook = false;
791
-
792
- const onMove = (event: PointerEvent): void => {
793
- if (event.pointerId !== pointerId) return;
794
- event.preventDefault();
795
-
796
- if (!crossed) {
797
- // 与 LookPad 一致:越界瞬间把基准挪到当前点,丢弃死区那一小段,避免起手时镜头跳一下
798
- if (Math.hypot(event.clientX - startX, event.clientY - startY) < deadZonePx) return;
799
- crossed = true;
800
- lastX = event.clientX;
801
- lastY = event.clientY;
802
- return;
803
- }
804
-
805
- const dx = event.clientX - lastX;
806
- const dy = event.clientY - lastY;
807
- lastX = event.clientX;
808
- lastY = event.clientY;
809
-
810
- const pad = getPad();
811
- if (!pad) {
812
- if (!warnedMissingLook) {
813
- warnedMissingLook = true;
814
- console.warn(
815
- `[input] 动作 ${action} 配了 mobile.drag 但 look 通道 ` +
816
- `"${config.look ?? 'look'}" 不存在(looks 里没声明),拖拽已忽略`,
817
- );
818
- }
819
- return;
820
- }
821
- // 让位判断放在更新 last 之后 —— 顺序反了会攒出一次猛甩
822
- if (pad.isActive()) return;
823
- pad.feedDelta(dx * factor, dy * factor);
824
- };
825
-
826
- button.addEventListener('pointermove', onMove);
827
-
828
- return {
829
- begin(event) {
830
- if (pointerId !== null) return;
831
- pointerId = event.pointerId;
832
- startX = event.clientX;
833
- startY = event.clientY;
834
- lastX = startX;
835
- lastY = startY;
836
- // 死区为 0 时不能走「丢弃首段」分支,否则第一次 move 的位移会被吞掉
837
- crossed = deadZonePx === 0;
838
- },
839
- end(event) {
840
- if (event.pointerId === pointerId) pointerId = null;
841
- },
842
- reset() {
843
- pointerId = null;
844
- crossed = deadZonePx === 0;
845
- },
846
- };
847
- }
848
-
849
- /** 负值 = 从右 / 下边缘算起。用 right / bottom 表达,尺寸变化时无需重算 */
850
- function applyEdgeAnchors(
851
- element: HTMLElement,
852
- mobile: { x: number; y: number; radius: number },
853
- ): void {
854
- const size = mobile.radius * 2;
855
- element.style.position = 'absolute';
856
- element.style.width = `${size}px`;
857
- element.style.height = `${size}px`;
858
- if (mobile.x < 0) element.style.right = `${-mobile.x - mobile.radius}px`;
859
- else element.style.left = `${mobile.x - mobile.radius}px`;
860
- if (mobile.y < 0) element.style.bottom = `${-mobile.y - mobile.radius}px`;
861
- else element.style.top = `${mobile.y - mobile.radius}px`;
862
- }