vimp-engine 0.22.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/bin/vimp-surface.js +88 -0
  2. package/core/Cargo.toml +1 -1
  3. package/package.json +1 -1
  4. package/src/client/lib/formBuilder.js +27 -8
  5. package/src/client/lib/socketDispatch.js +34 -0
  6. package/src/client/main.js +55 -7
  7. package/src/config/abiOps.js +31 -0
  8. package/src/config/clientServices.js +27 -0
  9. package/src/config/opcodes.js +11 -2
  10. package/src/config/wsports.js +9 -0
  11. package/src/devtools/contract/loadContext.js +25 -2
  12. package/src/devtools/contract/rules/b10-respawns.js +5 -3
  13. package/src/devtools/contract/rules/b2-engine-api.js +31 -8
  14. package/src/devtools/contract/rules/b3-game-config-shape.js +46 -5
  15. package/src/devtools/contract/rules/b4-teams.js +6 -3
  16. package/src/devtools/contract/rules/b5-room-form.js +40 -8
  17. package/src/devtools/contract/rules/c4-component-dependencies.js +10 -15
  18. package/src/devtools/surface/abiParse.js +175 -0
  19. package/src/devtools/surface/collect.js +413 -0
  20. package/src/host/GameCoreAdapter.js +49 -0
  21. package/src/lib/applyRoomOverrides.js +14 -2
  22. package/src/lib/capabilities.js +32 -0
  23. package/src/lib/coreConfig.js +3 -3
  24. package/src/lib/createHostRuntime.js +5 -3
  25. package/src/lib/formControls.js +89 -0
  26. package/src/lib/gameConfigView.js +211 -0
  27. package/src/lib/gamePlugin.js +65 -87
  28. package/src/lib/loadGamePackage.js +9 -2
  29. package/src/lib/registry.js +94 -0
  30. package/src/standalone/index.js +27 -13
  31. package/tests/fixtures/generations/gen-api3/README.md +7 -0
  32. package/tests/fixtures/generations/gen-api3/client/fakeClientCore.js +307 -0
  33. package/tests/fixtures/generations/gen-api3/client/index.js +38 -0
  34. package/tests/fixtures/generations/gen-api3/client/parts/Actor.js +18 -0
  35. package/tests/fixtures/generations/gen-api3/client/parts/ActorRadar.js +7 -0
  36. package/tests/fixtures/generations/gen-api3/config/auth.js +41 -0
  37. package/tests/fixtures/generations/gen-api3/config/client.js +151 -0
  38. package/tests/fixtures/generations/gen-api3/config/game.js +167 -0
  39. package/tests/fixtures/generations/gen-api3/core/pkg-node/core.js +4 -0
  40. package/tests/fixtures/generations/gen-api3/host/ScriptedManager.js +129 -0
  41. package/tests/fixtures/generations/gen-api3/host/createModules.js +6 -0
  42. package/tests/fixtures/generations/gen-api3/host/fakeCore.js +263 -0
  43. package/tests/fixtures/generations/gen-api3/host/index.js +30 -0
  44. package/tests/fixtures/generations/gen-api3/host/spawnCommand.js +14 -0
  45. package/tests/fixtures/generations/gen-api3/host/systemMessages.js +6 -0
  46. package/tests/fixtures/generations/gen-api3/manifest.json +25 -0
  47. package/tests/fixtures/generations/gen-api4/README.md +7 -0
  48. package/tests/fixtures/generations/gen-api4/client/fakeClientCore.js +307 -0
  49. package/tests/fixtures/generations/gen-api4/client/index.js +38 -0
  50. package/tests/fixtures/generations/gen-api4/client/parts/Actor.js +18 -0
  51. package/tests/fixtures/generations/gen-api4/client/parts/ActorRadar.js +7 -0
  52. package/tests/fixtures/generations/gen-api4/config/auth.js +41 -0
  53. package/tests/fixtures/generations/gen-api4/config/client.js +151 -0
  54. package/tests/fixtures/generations/gen-api4/config/game.js +156 -0
  55. package/tests/fixtures/generations/gen-api4/core/pkg-node/core.js +4 -0
  56. package/tests/fixtures/generations/gen-api4/host/ScriptedManager.js +129 -0
  57. package/tests/fixtures/generations/gen-api4/host/createModules.js +6 -0
  58. package/tests/fixtures/generations/gen-api4/host/fakeCore.js +263 -0
  59. package/tests/fixtures/generations/gen-api4/host/index.js +30 -0
  60. package/tests/fixtures/generations/gen-api4/host/spawnCommand.js +14 -0
  61. package/tests/fixtures/generations/gen-api4/host/systemMessages.js +6 -0
  62. package/tests/fixtures/generations/gen-api4/manifest.json +17 -0
  63. package/tests/fixtures/miniGame/client/fakeClientCore.js +17 -0
  64. package/tests/fixtures/miniGame/host/fakeCore.js +38 -8
@@ -145,15 +145,28 @@ export default class FakeGameCore {
145
145
  return actor ? [actor.x, actor.y] : [];
146
146
  }
147
147
 
148
+ // FIRST_SHOT_DATA: полный снапшот игроков в раскладке снапшот-схемы
149
+ // (ключ схемы -> id -> поля), а не плоским списком: ровно её разбирает
150
+ // клиент (applyShot браузера и VirtualClient._applyGameData). Плоский
151
+ // список доезжал до клиента ключами '0', '1' — сущность первого кадра
152
+ // не появлялась на холсте, и видно это только со второго участника
148
153
  players_data() {
149
- return JSON.stringify(
150
- [...this._actors.entries()].map(([id, a]) => ({
151
- id: Number(id),
152
- x: a.x,
153
- y: a.y,
154
- team: a.team,
155
- })),
156
- );
154
+ const entry = Object.entries(
155
+ this._config.engine?.snapshot?.keys ?? {},
156
+ ).find(([, spec]) => spec.class === 'hot' && spec.kind === 'indexed8');
157
+
158
+ if (!entry) {
159
+ return '{}';
160
+ }
161
+
162
+ const [key, spec] = entry;
163
+ const rows = {};
164
+
165
+ for (const [id, actor] of this._actors) {
166
+ rows[id] = spec.fields.map(field => Number(actor[field.name] ?? 0));
167
+ }
168
+
169
+ return JSON.stringify({ [key]: rows });
157
170
  }
158
171
 
159
172
  // ***** игровой тик ***** //
@@ -247,4 +260,21 @@ export default class FakeGameCore {
247
260
 
248
261
  this._actors = new Map(entries);
249
262
  }
263
+
264
+ // ***** расширение (этап 4 плана plugin-forward-compat) ***** //
265
+
266
+ // самоописание: фикстура представляет ядро текущего поколения, поэтому
267
+ // отвечает так же, как раскрытие движкового макроса
268
+ abi_describe() {
269
+ return JSON.stringify({ abi: 1, core: 'fixture', ops: ['debug.json'] });
270
+ }
271
+
272
+ // опкод вместо нового символа: пустой ответ — «не обработан»
273
+ dispatch(op) {
274
+ if (op === 'debug.json') {
275
+ return new TextEncoder().encode(this.debug_json());
276
+ }
277
+
278
+ return new Uint8Array(0);
279
+ }
250
280
  }