@crowdedkingdoms/crowdyjs 17.13.0-dev.1 → 18.0.0-dev.1

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 (284) hide show
  1. package/MIGRATION.md +163 -1
  2. package/README.md +142 -146
  3. package/dist/crowdy-client.d.ts +12 -31
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +15 -37
  6. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  7. package/dist/crowdy-dsh/bridge.js +3 -6
  8. package/dist/crowdy-studio/controller.d.ts +59 -57
  9. package/dist/crowdy-studio/controller.d.ts.map +1 -1
  10. package/dist/crowdy-studio/controller.js +268 -206
  11. package/dist/crowdy-studio/diagnostics.d.ts +3 -12
  12. package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
  13. package/dist/crowdy-studio/dom-shell.d.ts +2 -4
  14. package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
  15. package/dist/crowdy-studio/dom-shell.js +16 -47
  16. package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -1
  17. package/dist/crowdy-studio/embed/panel.d.ts +3 -12
  18. package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
  19. package/dist/crowdy-studio/embed/panel.js +3 -6
  20. package/dist/crowdy-studio/index.d.ts +1 -3
  21. package/dist/crowdy-studio/index.d.ts.map +1 -1
  22. package/dist/crowdy-studio/index.js +0 -2
  23. package/dist/crowdy-studio/models.d.ts +3 -4
  24. package/dist/crowdy-studio/models.d.ts.map +1 -1
  25. package/dist/crowdy-studio/starter-projects.d.ts +8 -4
  26. package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
  27. package/dist/crowdy-studio/starter-projects.js +83 -100
  28. package/dist/domains/appAccess.d.ts +14 -1
  29. package/dist/domains/appAccess.d.ts.map +1 -1
  30. package/dist/domains/appAccess.js +37 -1
  31. package/dist/domains/exec.d.ts +162 -15
  32. package/dist/domains/exec.d.ts.map +1 -1
  33. package/dist/domains/exec.js +180 -18
  34. package/dist/domains/host.d.ts +3 -3
  35. package/dist/domains/host.js +3 -3
  36. package/dist/domains/marketplace.d.ts +9 -58
  37. package/dist/domains/marketplace.d.ts.map +1 -1
  38. package/dist/domains/marketplace.js +9 -106
  39. package/dist/domains/playerWallet.d.ts +6 -12
  40. package/dist/domains/playerWallet.d.ts.map +1 -1
  41. package/dist/domains/playerWallet.js +6 -21
  42. package/dist/errors.d.ts +7 -13
  43. package/dist/errors.d.ts.map +1 -1
  44. package/dist/errors.js +6 -10
  45. package/dist/generated/graphql.d.ts +1384 -7977
  46. package/dist/generated/graphql.d.ts.map +1 -1
  47. package/dist/generated/graphql.js +22 -321
  48. package/dist/grid-mods/exec-client-halves.d.ts +156 -0
  49. package/dist/grid-mods/exec-client-halves.d.ts.map +1 -0
  50. package/dist/grid-mods/exec-client-halves.js +356 -0
  51. package/dist/grid-mods/grid-host-calls.d.ts +29 -15
  52. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
  53. package/dist/grid-mods/grid-host-calls.js +40 -44
  54. package/dist/grid-mods/index.d.ts +1 -0
  55. package/dist/grid-mods/index.d.ts.map +1 -1
  56. package/dist/grid-mods/index.js +1 -0
  57. package/dist/grid-mods/mod-runtime.d.ts +21 -6
  58. package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
  59. package/dist/grid-mods/mod-runtime.js +6 -2
  60. package/dist/grid-scope.d.ts +0 -188
  61. package/dist/grid-scope.d.ts.map +1 -1
  62. package/dist/grid-scope.js +0 -69
  63. package/dist/index.d.ts +12 -18
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +11 -16
  66. package/dist/kit/actions.d.ts +5 -9
  67. package/dist/kit/actions.d.ts.map +1 -1
  68. package/dist/kit/actions.js +5 -9
  69. package/dist/kit/index.d.ts +2 -33
  70. package/dist/kit/index.d.ts.map +1 -1
  71. package/dist/kit/index.js +1 -32
  72. package/dist/kit/kit.d.ts +8 -208
  73. package/dist/kit/kit.d.ts.map +1 -1
  74. package/dist/kit/kit.js +5 -163
  75. package/dist/kit/social.d.ts +1 -3
  76. package/dist/kit/social.d.ts.map +1 -1
  77. package/dist/kit/social.js +1 -3
  78. package/dist/kit/wire.d.ts +16 -5
  79. package/dist/kit/wire.d.ts.map +1 -1
  80. package/dist/kit/wire.js +19 -5
  81. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  82. package/dist/live-coding/assets/manifest.json +1 -1
  83. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  84. package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
  85. package/dist/live-coding/rust-analysis.d.ts.map +1 -1
  86. package/dist/live-coding/rust-analysis.js +31 -23
  87. package/dist/player-runtime/client-host-calls.d.ts +8 -0
  88. package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
  89. package/dist/player-runtime/client-host-calls.js +28 -0
  90. package/dist/player-runtime/glue-runtime.d.ts +27 -10
  91. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  92. package/dist/player-runtime/glue-runtime.js +40 -45
  93. package/dist/player-runtime/glue-sab.d.ts +2 -2
  94. package/dist/player-runtime/glue-sab.js +2 -2
  95. package/dist/player-runtime/player-code-broker.d.ts +80 -24
  96. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  97. package/dist/player-runtime/player-code-broker.js +169 -41
  98. package/dist/player-runtime/player-glue-worker.d.ts +8 -8
  99. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  100. package/dist/player-runtime/player-glue-worker.js +26 -9
  101. package/dist/stores/actors.d.ts +12 -2
  102. package/dist/stores/actors.d.ts.map +1 -1
  103. package/dist/stores/actors.js +43 -18
  104. package/dist/stores/chunks.d.ts +12 -0
  105. package/dist/stores/chunks.d.ts.map +1 -1
  106. package/dist/stores/chunks.js +112 -39
  107. package/dist/stores/durable.d.ts.map +1 -1
  108. package/dist/stores/durable.js +2 -1
  109. package/dist/stores/inbox.d.ts +1 -1
  110. package/dist/stores/inbox.d.ts.map +1 -1
  111. package/dist/stores/index.d.ts +0 -11
  112. package/dist/stores/index.d.ts.map +1 -1
  113. package/dist/stores/index.js +0 -4
  114. package/dist/stores/session.d.ts +0 -2
  115. package/dist/stores/session.d.ts.map +1 -1
  116. package/package.json +1 -1
  117. package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
  118. package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
  119. package/dist/crowdy-studio/model-lint-log.js +0 -93
  120. package/dist/crowdy-studio/model-lint.d.ts +0 -61
  121. package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
  122. package/dist/crowdy-studio/model-lint.js +0 -45
  123. package/dist/domains/compute.d.ts +0 -208
  124. package/dist/domains/compute.d.ts.map +0 -1
  125. package/dist/domains/compute.js +0 -274
  126. package/dist/domains/controlPlane.d.ts +0 -38
  127. package/dist/domains/controlPlane.d.ts.map +0 -1
  128. package/dist/domains/controlPlane.js +0 -43
  129. package/dist/domains/gameModel.d.ts +0 -1174
  130. package/dist/domains/gameModel.d.ts.map +0 -1
  131. package/dist/domains/gameModel.js +0 -1333
  132. package/dist/domains/playerCompute.d.ts +0 -91
  133. package/dist/domains/playerCompute.d.ts.map +0 -1
  134. package/dist/domains/playerCompute.js +0 -136
  135. package/dist/domains/playerModel.d.ts +0 -20
  136. package/dist/domains/playerModel.d.ts.map +0 -1
  137. package/dist/domains/playerModel.js +0 -54
  138. package/dist/kit/abilities.d.ts +0 -66
  139. package/dist/kit/abilities.d.ts.map +0 -1
  140. package/dist/kit/abilities.js +0 -71
  141. package/dist/kit/blueprints/combat.d.ts +0 -81
  142. package/dist/kit/blueprints/combat.d.ts.map +0 -1
  143. package/dist/kit/blueprints/combat.js +0 -357
  144. package/dist/kit/blueprints/core.d.ts +0 -222
  145. package/dist/kit/blueprints/core.d.ts.map +0 -1
  146. package/dist/kit/blueprints/core.js +0 -185
  147. package/dist/kit/blueprints/decks.d.ts +0 -50
  148. package/dist/kit/blueprints/decks.d.ts.map +0 -1
  149. package/dist/kit/blueprints/decks.js +0 -163
  150. package/dist/kit/blueprints/economy.d.ts +0 -88
  151. package/dist/kit/blueprints/economy.d.ts.map +0 -1
  152. package/dist/kit/blueprints/economy.js +0 -533
  153. package/dist/kit/blueprints/guild.d.ts +0 -51
  154. package/dist/kit/blueprints/guild.d.ts.map +0 -1
  155. package/dist/kit/blueprints/guild.js +0 -50
  156. package/dist/kit/blueprints/index.d.ts +0 -23
  157. package/dist/kit/blueprints/index.d.ts.map +0 -1
  158. package/dist/kit/blueprints/index.js +0 -22
  159. package/dist/kit/blueprints/inventory.d.ts +0 -84
  160. package/dist/kit/blueprints/inventory.d.ts.map +0 -1
  161. package/dist/kit/blueprints/inventory.js +0 -257
  162. package/dist/kit/blueprints/leaderboards.d.ts +0 -49
  163. package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
  164. package/dist/kit/blueprints/leaderboards.js +0 -126
  165. package/dist/kit/blueprints/liveops.d.ts +0 -42
  166. package/dist/kit/blueprints/liveops.d.ts.map +0 -1
  167. package/dist/kit/blueprints/liveops.js +0 -170
  168. package/dist/kit/blueprints/locks.d.ts +0 -82
  169. package/dist/kit/blueprints/locks.d.ts.map +0 -1
  170. package/dist/kit/blueprints/locks.js +0 -155
  171. package/dist/kit/blueprints/loot.d.ts +0 -90
  172. package/dist/kit/blueprints/loot.d.ts.map +0 -1
  173. package/dist/kit/blueprints/loot.js +0 -229
  174. package/dist/kit/blueprints/matches.d.ts +0 -84
  175. package/dist/kit/blueprints/matches.d.ts.map +0 -1
  176. package/dist/kit/blueprints/matches.js +0 -349
  177. package/dist/kit/blueprints/moderation.d.ts +0 -32
  178. package/dist/kit/blueprints/moderation.d.ts.map +0 -1
  179. package/dist/kit/blueprints/moderation.js +0 -140
  180. package/dist/kit/blueprints/npcs.d.ts +0 -78
  181. package/dist/kit/blueprints/npcs.d.ts.map +0 -1
  182. package/dist/kit/blueprints/npcs.js +0 -125
  183. package/dist/kit/blueprints/plots.d.ts +0 -63
  184. package/dist/kit/blueprints/plots.d.ts.map +0 -1
  185. package/dist/kit/blueprints/plots.js +0 -151
  186. package/dist/kit/blueprints/progression.d.ts +0 -68
  187. package/dist/kit/blueprints/progression.d.ts.map +0 -1
  188. package/dist/kit/blueprints/progression.js +0 -324
  189. package/dist/kit/blueprints/quests.d.ts +0 -72
  190. package/dist/kit/blueprints/quests.d.ts.map +0 -1
  191. package/dist/kit/blueprints/quests.js +0 -285
  192. package/dist/kit/blueprints/worldsim.d.ts +0 -91
  193. package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
  194. package/dist/kit/blueprints/worldsim.js +0 -468
  195. package/dist/kit/combat.d.ts +0 -141
  196. package/dist/kit/combat.d.ts.map +0 -1
  197. package/dist/kit/combat.js +0 -196
  198. package/dist/kit/decks.d.ts +0 -157
  199. package/dist/kit/decks.d.ts.map +0 -1
  200. package/dist/kit/decks.js +0 -186
  201. package/dist/kit/director.d.ts +0 -88
  202. package/dist/kit/director.d.ts.map +0 -1
  203. package/dist/kit/director.js +0 -86
  204. package/dist/kit/economy.d.ts +0 -289
  205. package/dist/kit/economy.d.ts.map +0 -1
  206. package/dist/kit/economy.js +0 -427
  207. package/dist/kit/engine.d.ts +0 -48
  208. package/dist/kit/engine.d.ts.map +0 -1
  209. package/dist/kit/engine.js +0 -113
  210. package/dist/kit/features.d.ts +0 -60
  211. package/dist/kit/features.d.ts.map +0 -1
  212. package/dist/kit/features.js +0 -65
  213. package/dist/kit/instances.d.ts +0 -52
  214. package/dist/kit/instances.d.ts.map +0 -1
  215. package/dist/kit/instances.js +0 -60
  216. package/dist/kit/inventory.d.ts +0 -129
  217. package/dist/kit/inventory.d.ts.map +0 -1
  218. package/dist/kit/inventory.js +0 -200
  219. package/dist/kit/leaderboards.d.ts +0 -86
  220. package/dist/kit/leaderboards.d.ts.map +0 -1
  221. package/dist/kit/leaderboards.js +0 -133
  222. package/dist/kit/liveops.d.ts +0 -112
  223. package/dist/kit/liveops.d.ts.map +0 -1
  224. package/dist/kit/liveops.js +0 -183
  225. package/dist/kit/loot.d.ts +0 -128
  226. package/dist/kit/loot.d.ts.map +0 -1
  227. package/dist/kit/loot.js +0 -160
  228. package/dist/kit/matches.d.ts +0 -301
  229. package/dist/kit/matches.d.ts.map +0 -1
  230. package/dist/kit/matches.js +0 -458
  231. package/dist/kit/matchmaking.d.ts +0 -57
  232. package/dist/kit/matchmaking.d.ts.map +0 -1
  233. package/dist/kit/matchmaking.js +0 -59
  234. package/dist/kit/minigames.d.ts +0 -30
  235. package/dist/kit/minigames.d.ts.map +0 -1
  236. package/dist/kit/minigames.js +0 -38
  237. package/dist/kit/mobs.d.ts +0 -90
  238. package/dist/kit/mobs.d.ts.map +0 -1
  239. package/dist/kit/mobs.js +0 -98
  240. package/dist/kit/moderation.d.ts +0 -73
  241. package/dist/kit/moderation.d.ts.map +0 -1
  242. package/dist/kit/moderation.js +0 -103
  243. package/dist/kit/movement.d.ts +0 -78
  244. package/dist/kit/movement.d.ts.map +0 -1
  245. package/dist/kit/movement.js +0 -103
  246. package/dist/kit/notifications.d.ts +0 -45
  247. package/dist/kit/notifications.d.ts.map +0 -1
  248. package/dist/kit/notifications.js +0 -67
  249. package/dist/kit/npcs.d.ts +0 -226
  250. package/dist/kit/npcs.d.ts.map +0 -1
  251. package/dist/kit/npcs.js +0 -141
  252. package/dist/kit/objects.d.ts +0 -116
  253. package/dist/kit/objects.d.ts.map +0 -1
  254. package/dist/kit/objects.js +0 -119
  255. package/dist/kit/pets.d.ts +0 -85
  256. package/dist/kit/pets.d.ts.map +0 -1
  257. package/dist/kit/pets.js +0 -96
  258. package/dist/kit/plots.d.ts +0 -85
  259. package/dist/kit/plots.d.ts.map +0 -1
  260. package/dist/kit/plots.js +0 -113
  261. package/dist/kit/progression.d.ts +0 -181
  262. package/dist/kit/progression.d.ts.map +0 -1
  263. package/dist/kit/progression.js +0 -265
  264. package/dist/kit/quests.d.ts +0 -171
  265. package/dist/kit/quests.d.ts.map +0 -1
  266. package/dist/kit/quests.js +0 -237
  267. package/dist/kit/racing.d.ts +0 -85
  268. package/dist/kit/racing.d.ts.map +0 -1
  269. package/dist/kit/racing.js +0 -99
  270. package/dist/kit/shared.d.ts +0 -73
  271. package/dist/kit/shared.d.ts.map +0 -1
  272. package/dist/kit/shared.js +0 -101
  273. package/dist/kit/telemetry.d.ts +0 -66
  274. package/dist/kit/telemetry.d.ts.map +0 -1
  275. package/dist/kit/telemetry.js +0 -133
  276. package/dist/kit/territory.d.ts +0 -97
  277. package/dist/kit/territory.d.ts.map +0 -1
  278. package/dist/kit/territory.js +0 -114
  279. package/dist/kit/worldsim.d.ts +0 -263
  280. package/dist/kit/worldsim.d.ts.map +0 -1
  281. package/dist/kit/worldsim.js +0 -268
  282. package/dist/stores/model.d.ts +0 -81
  283. package/dist/stores/model.d.ts.map +0 -1
  284. package/dist/stores/model.js +0 -163
@@ -1,85 +0,0 @@
1
- import type { GameModelAPI } from '../domains/gameModel.js';
2
- import type { Scalars } from '../generated/graphql.js';
3
- import type { EngineDetector } from './engine.js';
4
- import { type RaceTimingEvent } from './wire.js';
5
- /** Options for {@link RacingKit}. */
6
- export interface RacingKitOptions {
7
- /** The racing engine module name. Defaults to `'racing'`. */
8
- moduleName?: string;
9
- /** The possession (ball) engine module name. Defaults to `'possession'`. */
10
- possessionModuleName?: string;
11
- /** The course container type. Defaults to `'Course'`. */
12
- courseTypeName?: string;
13
- }
14
- /** Your live run as the engine reports it. */
15
- export interface KitRaceRun {
16
- courseId: string;
17
- started: boolean;
18
- lap: number;
19
- nextGate: number;
20
- splitsMs: number[];
21
- bestLapMs: number;
22
- finished: boolean;
23
- totalMs: number;
24
- }
25
- /**
26
- * Runtime helpers for the racing engine (Wave 3, G16) and its possession
27
- * sub-template (G17 sports-lite): server-timed gates/laps from the pose
28
- * stream (type-97 events), course records with ghost replays on the actor
29
- * lane (suffix `ghost:<courseId>`, FLAG_RESERVED3), and the authoritative
30
- * ball (claim/steal/pass/shoot; lane suffix `ball`).
31
- *
32
- * Obtained via `client.kit(appId).racing`.
33
- */
34
- export declare class RacingKit {
35
- private readonly appId;
36
- private readonly gameModel;
37
- private readonly engines;
38
- private readonly moduleName;
39
- private readonly possessionModuleName;
40
- private readonly courseTypeName;
41
- constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, engines: EngineDetector, options?: RacingKitOptions);
42
- /** Is the racing engine deployed + enabled (cached per session)? */
43
- engineAvailable(): Promise<boolean>;
44
- /** Is the possession (ball) engine deployed + enabled? */
45
- possessionAvailable(): Promise<boolean>;
46
- /** STUDIO (admin) — create a course (`gates` = [[x, z, radius], ...]). */
47
- defineCourse(input: {
48
- courseId: string;
49
- gates: Array<[number, number, number]>;
50
- laps?: number;
51
- displayName?: string;
52
- }): Promise<{
53
- __typename?: "GmContainer";
54
- containerId: string;
55
- appId: string;
56
- sessionId: string | null;
57
- typeName: string;
58
- displayName: string;
59
- description: string | null;
60
- ownerUserId: string | null;
61
- metadataJson: string;
62
- }>;
63
- /** Enter a course: your next pose through gate 0 starts the clock. */
64
- enter(courseId: string): Promise<Record<string, unknown>>;
65
- /** Your live run (splits, lap, next gate). */
66
- raceStatus(): Promise<KitRaceRun>;
67
- /** The course record (holder, time, ghost length). */
68
- best(courseId: string): Promise<Record<string, unknown>>;
69
- /** Replay the course-record ghost onto the actor lane. */
70
- ghostPlay(courseId: string): Promise<Record<string, unknown>>;
71
- /** Parse a type-97 race-timing server event. */
72
- parseRaceTiming(bytes: Uint8Array): RaceTimingEvent | null;
73
- /** Join the ball match (teams fill by join order). */
74
- joinMatch(): Promise<Record<string, unknown>>;
75
- /** Claim the free ball (or steal after the protection window). */
76
- claim(): Promise<Record<string, unknown>>;
77
- /** Pass along a direction (holder only). */
78
- pass(dirX: number, dirZ: number): Promise<Record<string, unknown>>;
79
- /** Shoot at the opposing goal (holder only; the server aims). */
80
- shoot(): Promise<Record<string, unknown>>;
81
- /** The live ball match (teams, ball, standings, summary). */
82
- matchState(): Promise<Record<string, unknown>>;
83
- private invoke;
84
- }
85
- //# sourceMappingURL=racing.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"racing.d.ts","sourceRoot":"","sources":["../../src/kit/racing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEvE,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,qBAAa,SAAS;IAMlB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAGrB,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EACjC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,cAAc,EACxC,OAAO,GAAE,gBAAqB;IAOhC,oEAAoE;IACpE,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC,0DAA0D;IAC1D,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;IAIvC,0EAA0E;IACpE,YAAY,CAAC,KAAK,EAAE;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;;;;;;;;;;;IAaD,sEAAsE;IAChE,KAAK,CAAC,QAAQ,EAAE,MAAM;IAI5B,8CAA8C;IACxC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC;IAcvC,sDAAsD;IAChD,IAAI,CAAC,QAAQ,EAAE,MAAM;IAI3B,0DAA0D;IACpD,SAAS,CAAC,QAAQ,EAAE,MAAM;IAIhC,gDAAgD;IAChD,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,eAAe,GAAG,IAAI;IAM1D,sDAAsD;IAChD,SAAS;IAIf,kEAAkE;IAC5D,KAAK;IAIX,4CAA4C;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAIrC,iEAAiE;IAC3D,KAAK;IAIX,6DAA6D;IACvD,UAAU;YAIF,MAAM;CAOrB"}
@@ -1,99 +0,0 @@
1
- import { parseRaceTimingEvent } from './wire.js';
2
- /**
3
- * Runtime helpers for the racing engine (Wave 3, G16) and its possession
4
- * sub-template (G17 sports-lite): server-timed gates/laps from the pose
5
- * stream (type-97 events), course records with ghost replays on the actor
6
- * lane (suffix `ghost:<courseId>`, FLAG_RESERVED3), and the authoritative
7
- * ball (claim/steal/pass/shoot; lane suffix `ball`).
8
- *
9
- * Obtained via `client.kit(appId).racing`.
10
- */
11
- export class RacingKit {
12
- constructor(appId, gameModel, engines, options = {}) {
13
- this.appId = appId;
14
- this.gameModel = gameModel;
15
- this.engines = engines;
16
- this.moduleName = options.moduleName ?? 'racing';
17
- this.possessionModuleName = options.possessionModuleName ?? 'possession';
18
- this.courseTypeName = options.courseTypeName ?? 'Course';
19
- }
20
- /** Is the racing engine deployed + enabled (cached per session)? */
21
- engineAvailable() {
22
- return this.engines.has(this.moduleName);
23
- }
24
- /** Is the possession (ball) engine deployed + enabled? */
25
- possessionAvailable() {
26
- return this.engines.has(this.possessionModuleName);
27
- }
28
- /** STUDIO (admin) — create a course (`gates` = [[x, z, radius], ...]). */
29
- async defineCourse(input) {
30
- return this.gameModel.createContainer({
31
- appId: this.appId,
32
- typeName: this.courseTypeName,
33
- displayName: input.displayName ?? `course-${input.courseId}`,
34
- properties: [
35
- { key: 'course_id', valueType: 'string', valueJson: JSON.stringify(input.courseId) },
36
- { key: 'gates', valueType: 'string', valueJson: JSON.stringify(JSON.stringify(input.gates)) },
37
- { key: 'laps', valueType: 'int', valueJson: String(input.laps ?? 1) },
38
- ],
39
- });
40
- }
41
- /** Enter a course: your next pose through gate 0 starts the clock. */
42
- async enter(courseId) {
43
- return this.invoke(this.moduleName, 'enter', { courseId });
44
- }
45
- /** Your live run (splits, lap, next gate). */
46
- async raceStatus() {
47
- const body = await this.invoke(this.moduleName, 'race_status', {});
48
- return {
49
- courseId: String(body.courseId ?? ''),
50
- started: body.started === true,
51
- lap: Number(body.lap ?? 0),
52
- nextGate: Number(body.nextGate ?? 0),
53
- splitsMs: Array.isArray(body.splitsMs) ? body.splitsMs.map(Number) : [],
54
- bestLapMs: Number(body.bestLapMs ?? 0),
55
- finished: body.finished === true,
56
- totalMs: Number(body.totalMs ?? 0),
57
- };
58
- }
59
- /** The course record (holder, time, ghost length). */
60
- async best(courseId) {
61
- return this.invoke(this.moduleName, 'best', { courseId });
62
- }
63
- /** Replay the course-record ghost onto the actor lane. */
64
- async ghostPlay(courseId) {
65
- return this.invoke(this.moduleName, 'ghost_play', { courseId });
66
- }
67
- /** Parse a type-97 race-timing server event. */
68
- parseRaceTiming(bytes) {
69
- return parseRaceTimingEvent(bytes);
70
- }
71
- // -- possession (sports-lite ball) ----------------------------------------
72
- /** Join the ball match (teams fill by join order). */
73
- async joinMatch() {
74
- return this.invoke(this.possessionModuleName, 'join_match', {});
75
- }
76
- /** Claim the free ball (or steal after the protection window). */
77
- async claim() {
78
- return this.invoke(this.possessionModuleName, 'claim', {});
79
- }
80
- /** Pass along a direction (holder only). */
81
- async pass(dirX, dirZ) {
82
- return this.invoke(this.possessionModuleName, 'pass', { dirX, dirZ });
83
- }
84
- /** Shoot at the opposing goal (holder only; the server aims). */
85
- async shoot() {
86
- return this.invoke(this.possessionModuleName, 'shoot', {});
87
- }
88
- /** The live ball match (teams, ball, standings, summary). */
89
- async matchState() {
90
- return this.invoke(this.possessionModuleName, 'match_state', {});
91
- }
92
- async invoke(moduleName, exportName, params) {
93
- const result = await this.engines.invoke(moduleName, exportName, params);
94
- if (!result.success) {
95
- throw new Error(`racing.${exportName} failed: ${result.reason ?? 'unknown'}`);
96
- }
97
- return result.body;
98
- }
99
- }
@@ -1,73 +0,0 @@
1
- import { CrowdyGraphQLError } from '../errors.js';
2
- import type { GameModelAPI } from '../domains/gameModel.js';
3
- import type { GameModelInvokeMutation } from '../generated/graphql.js';
4
- /** The raw server result of a `gameModelInvoke` call. */
5
- export type RawInvokeResult = GameModelInvokeMutation['gameModelInvoke'];
6
- /**
7
- * A kit invoke outcome: the server's authority/evaluation verdict plus the
8
- * parsed return value. Authority denials and expression errors are **not**
9
- * exceptions — check {@link success}.
10
- *
11
- * Older `cks-game-api` builds violate that contract for policy denials: they
12
- * throw a GraphQL error with `extensions.code === 'FORBIDDEN'` instead of
13
- * resolving with `success: false`. {@link kitInvoke} tolerates both server
14
- * generations by mapping that error onto a denial result — see {@link raw}
15
- * for how to recognize the mapped case.
16
- */
17
- export interface KitInvokeResult<T = unknown> {
18
- /** `false` when the invoke policy denied the caller or the logic errored (rolled back). */
19
- success: boolean;
20
- /** The parsed `returnValueJson`, when present and `success` is true. */
21
- returnValue?: T;
22
- /** The server's error message when `success` is false. */
23
- errorMessage?: string;
24
- /**
25
- * The full server result (event id, applied mutations, …).
26
- *
27
- * When an older server reported a policy denial as a `FORBIDDEN` GraphQL
28
- * error (see the interface doc above), no server result exists; the SDK
29
- * synthesizes a minimal one — `success: false`, `errorMessage` from the
30
- * GraphQL error, `eventId: ''`, and no applied mutations.
31
- */
32
- raw: RawInvokeResult;
33
- }
34
- /**
35
- * Is this thrown error a **gameplay verdict** rather than a transport/user
36
- * error — i.e. should a kit invoke helper resolve `{ success: false }`
37
- * instead of rethrowing? Two server shapes qualify:
38
- *
39
- * 1. `FORBIDDEN` — older `cks-game-api` builds threw this for invoke-policy
40
- * denials instead of resolving with `success: false`.
41
- * 2. `BAD_REQUEST` with a message starting `"Invoke params violate"` — the
42
- * typed invoke-contract violation `computeInvoke` raises when declared
43
- * params fail pre-sandbox validation (game-api 2026-07-19+). To a kit
44
- * caller that is a referee "no", not an exception.
45
- *
46
- * Anything else (UNAUTHENTICATED, rate limits, network failures, other
47
- * BAD_REQUESTs like a disabled module) stays a thrown error.
48
- */
49
- export declare function isKitVerdictError(error: unknown): error is CrowdyGraphQLError;
50
- /** Wrap a raw invoke result, parsing the JSON return value. */
51
- export declare function toKitInvokeResult<T>(raw: RawInvokeResult): KitInvokeResult<T>;
52
- /**
53
- * Invoke a model function and wrap the result.
54
- *
55
- * Server-generation tolerance: current `cks-game-api` builds resolve policy
56
- * denials with `success: false` (the kit contract), but older builds throw a
57
- * {@link CrowdyGraphQLError} with `extensions.code === 'FORBIDDEN'` instead.
58
- * This helper catches every {@link isKitVerdictError | gameplay-verdict
59
- * error} (the legacy FORBIDDEN denial and the typed invoke-contract
60
- * violation) and maps it to a `{ success: false, errorMessage }` result with
61
- * a synthesized {@link KitInvokeResult.raw}, so kit callers see one contract
62
- * against both server generations. Any other error is rethrown unchanged.
63
- */
64
- export declare function kitInvoke<T = unknown>(gameModel: GameModelAPI, input: {
65
- appId: string;
66
- functionName: string;
67
- selfContainerId: string;
68
- params?: Record<string, unknown>;
69
- sessionId?: string;
70
- }): Promise<KitInvokeResult<T>>;
71
- /** Read a container's visible properties as a parsed object. */
72
- export declare function kitContainerProperties(gameModel: GameModelAPI, appId: string, containerId: string): Promise<Record<string, unknown>>;
73
- //# sourceMappingURL=shared.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/kit/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,2FAA2F;IAC3F,OAAO,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,CAAC,CAAC;IAChB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,GAAG,EAAE,eAAe,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAO7E;AAED,+DAA+D;AAC/D,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,CAe7E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,CAAC,GAAG,OAAO,EACzC,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE;IACL,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAmC7B;AAED,gEAAgE;AAChE,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,YAAY,EACvB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAOlC"}
@@ -1,101 +0,0 @@
1
- import { CrowdyGraphQLError } from '../errors.js';
2
- /**
3
- * Is this thrown error a **gameplay verdict** rather than a transport/user
4
- * error — i.e. should a kit invoke helper resolve `{ success: false }`
5
- * instead of rethrowing? Two server shapes qualify:
6
- *
7
- * 1. `FORBIDDEN` — older `cks-game-api` builds threw this for invoke-policy
8
- * denials instead of resolving with `success: false`.
9
- * 2. `BAD_REQUEST` with a message starting `"Invoke params violate"` — the
10
- * typed invoke-contract violation `computeInvoke` raises when declared
11
- * params fail pre-sandbox validation (game-api 2026-07-19+). To a kit
12
- * caller that is a referee "no", not an exception.
13
- *
14
- * Anything else (UNAUTHENTICATED, rate limits, network failures, other
15
- * BAD_REQUESTs like a disabled module) stays a thrown error.
16
- */
17
- export function isKitVerdictError(error) {
18
- if (!(error instanceof CrowdyGraphQLError))
19
- return false;
20
- if (error.code === 'FORBIDDEN')
21
- return true;
22
- return (error.code === 'BAD_REQUEST' &&
23
- error.message.startsWith('Invoke params violate'));
24
- }
25
- /** Wrap a raw invoke result, parsing the JSON return value. */
26
- export function toKitInvokeResult(raw) {
27
- let returnValue;
28
- if (raw.success && raw.returnValueJson != null) {
29
- try {
30
- returnValue = JSON.parse(raw.returnValueJson);
31
- }
32
- catch {
33
- returnValue = undefined;
34
- }
35
- }
36
- return {
37
- success: raw.success,
38
- returnValue,
39
- errorMessage: raw.errorMessage ?? undefined,
40
- raw,
41
- };
42
- }
43
- /**
44
- * Invoke a model function and wrap the result.
45
- *
46
- * Server-generation tolerance: current `cks-game-api` builds resolve policy
47
- * denials with `success: false` (the kit contract), but older builds throw a
48
- * {@link CrowdyGraphQLError} with `extensions.code === 'FORBIDDEN'` instead.
49
- * This helper catches every {@link isKitVerdictError | gameplay-verdict
50
- * error} (the legacy FORBIDDEN denial and the typed invoke-contract
51
- * violation) and maps it to a `{ success: false, errorMessage }` result with
52
- * a synthesized {@link KitInvokeResult.raw}, so kit callers see one contract
53
- * against both server generations. Any other error is rethrown unchanged.
54
- */
55
- export async function kitInvoke(gameModel, input) {
56
- let raw;
57
- try {
58
- raw = await gameModel.invoke({
59
- appId: input.appId,
60
- functionName: input.functionName,
61
- selfContainerId: input.selfContainerId,
62
- paramsJson: JSON.stringify(input.params ?? {}),
63
- ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
64
- });
65
- }
66
- catch (error) {
67
- if (isKitVerdictError(error)) {
68
- return {
69
- success: false,
70
- returnValue: undefined,
71
- errorMessage: error.message,
72
- raw: {
73
- eventId: '',
74
- functionName: input.functionName,
75
- success: false,
76
- policyBypassed: null,
77
- returnValueJson: null,
78
- // Synthesised locally from a THROWN verdict, so there is no server
79
- // attribution to carry. Null rather than a guessed blame: `playerFaultOf`
80
- // reads null as "not a question about whose code failed", which is exactly
81
- // right for a scope violation caught on the way in.
82
- fault: null,
83
- errorMessage: error.message,
84
- mutationsApplied: [],
85
- },
86
- };
87
- }
88
- throw error;
89
- }
90
- return toKitInvokeResult(raw);
91
- }
92
- /** Read a container's visible properties as a parsed object. */
93
- export async function kitContainerProperties(gameModel, appId, containerId) {
94
- const state = await gameModel.containerState({ appId, containerId });
95
- try {
96
- return JSON.parse(state.propertiesJson);
97
- }
98
- catch {
99
- return {};
100
- }
101
- }
@@ -1,66 +0,0 @@
1
- import type { GameModelAPI } from '../domains/gameModel.js';
2
- import type { Scalars } from '../generated/graphql.js';
3
- /** Options for {@link TelemetryKit}. */
4
- export interface TelemetryKitOptions {
5
- /** The counter container type name. Defaults to `'TelemetryCounter'`. */
6
- counterTypeName?: string;
7
- /**
8
- * Sample rate for `track()` in [0, 1] — the client-side budget knob.
9
- * Defaults to 1 (every event).
10
- */
11
- sampleRate?: number;
12
- }
13
- /**
14
- * Game analytics events (matrix P7) — MODEL-THIN by design: `track()`
15
- * writes a naming-convention row into the existing model event log via a
16
- * fire-and-forget container property bump, and sampled counters live in
17
- * ordinary `TelemetryCounter` containers (`event_name` + `count`). Export
18
- * and BI are platform concerns, deliberately out of scope; the convention
19
- * is the abstraction.
20
- *
21
- * Naming convention: `<area>.<action>` (e.g. `ftue.step_completed`,
22
- * `shop.purchase`). Keep cardinality low — counters are containers.
23
- *
24
- * Obtained via `client.kit(appId).telemetry`.
25
- */
26
- export declare class TelemetryKit {
27
- private readonly appId;
28
- private readonly gameModel;
29
- private readonly counterTypeName;
30
- private readonly sampleRate;
31
- /** event name -> counter container id (cached per session). */
32
- private readonly counterIds;
33
- constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: TelemetryKitOptions);
34
- /**
35
- * Track one event — fire-and-forget (never throws, never blocks
36
- * gameplay): bumps the event's sampled counter. `props` ride the
37
- * container's last-props snapshot for spot-debugging (NOT a warehouse).
38
- */
39
- track(name: string, props?: Record<string, unknown>): void;
40
- /** The awaitable form of {@link track} for tests/backfills. */
41
- bump(name: string, props?: Record<string, unknown>): Promise<void>;
42
- /** Read the sampled counters (dashboards, tests). */
43
- counters(): Promise<Array<{
44
- eventName: string;
45
- count: number;
46
- lastProps: string;
47
- }>>;
48
- private ensureCounter;
49
- }
50
- /** The telemetry blueprint: one counter type; the convention is the point. */
51
- export declare function telemetryBlueprint(counterTypeName?: string): {
52
- name: string;
53
- containerTypes: {
54
- typeName: string;
55
- displayName: string;
56
- description: string;
57
- }[];
58
- propertyDefinitions: {
59
- containerTypeName: string;
60
- key: string;
61
- valueType: string;
62
- defaultValueJson: string;
63
- description: string;
64
- }[];
65
- };
66
- //# sourceMappingURL=telemetry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/kit/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvD,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAP5B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;gBAGrC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EACjC,SAAS,EAAE,YAAY,EACxC,OAAO,GAAE,mBAAwB;IAMnC;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,IAAI;IAK9D,+DAA+D;IACzD,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB5E,qDAAqD;IAC/C,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;YAiB3E,aAAa;CA0B5B;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,eAAe,SAAqB;;;;;;;;;;;;;;EAmCtE"}
@@ -1,133 +0,0 @@
1
- import { kitContainerProperties } from './shared.js';
2
- /**
3
- * Game analytics events (matrix P7) — MODEL-THIN by design: `track()`
4
- * writes a naming-convention row into the existing model event log via a
5
- * fire-and-forget container property bump, and sampled counters live in
6
- * ordinary `TelemetryCounter` containers (`event_name` + `count`). Export
7
- * and BI are platform concerns, deliberately out of scope; the convention
8
- * is the abstraction.
9
- *
10
- * Naming convention: `<area>.<action>` (e.g. `ftue.step_completed`,
11
- * `shop.purchase`). Keep cardinality low — counters are containers.
12
- *
13
- * Obtained via `client.kit(appId).telemetry`.
14
- */
15
- export class TelemetryKit {
16
- constructor(appId, gameModel, options = {}) {
17
- this.appId = appId;
18
- this.gameModel = gameModel;
19
- /** event name -> counter container id (cached per session). */
20
- this.counterIds = new Map();
21
- this.counterTypeName = options.counterTypeName ?? 'TelemetryCounter';
22
- this.sampleRate = options.sampleRate ?? 1;
23
- }
24
- /**
25
- * Track one event — fire-and-forget (never throws, never blocks
26
- * gameplay): bumps the event's sampled counter. `props` ride the
27
- * container's last-props snapshot for spot-debugging (NOT a warehouse).
28
- */
29
- track(name, props = {}) {
30
- if (Math.random() > this.sampleRate)
31
- return;
32
- void this.bump(name, props).catch(() => undefined);
33
- }
34
- /** The awaitable form of {@link track} for tests/backfills. */
35
- async bump(name, props = {}) {
36
- const containerId = await this.ensureCounter(name);
37
- const current = await kitContainerProperties(this.gameModel, String(this.appId), containerId);
38
- await this.gameModel.setProperty({
39
- appId: this.appId,
40
- containerId,
41
- key: 'count',
42
- valueType: 'int',
43
- valueJson: String(Number(current.count ?? 0) + 1),
44
- });
45
- if (Object.keys(props).length > 0) {
46
- await this.gameModel.setProperty({
47
- appId: this.appId,
48
- containerId,
49
- key: 'last_props',
50
- valueType: 'string',
51
- valueJson: JSON.stringify(JSON.stringify(props).slice(0, 500)),
52
- });
53
- }
54
- }
55
- /** Read the sampled counters (dashboards, tests). */
56
- async counters() {
57
- const containers = await this.gameModel.containers({
58
- appId: this.appId,
59
- typeName: this.counterTypeName,
60
- });
61
- return Promise.all(containers.map(async (c) => {
62
- const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
63
- return {
64
- eventName: String(props.event_name ?? ''),
65
- count: Number(props.count ?? 0),
66
- lastProps: String(props.last_props ?? ''),
67
- };
68
- }));
69
- }
70
- async ensureCounter(name) {
71
- const cached = this.counterIds.get(name);
72
- if (cached)
73
- return cached;
74
- const containers = await this.gameModel.containers({
75
- appId: this.appId,
76
- typeName: this.counterTypeName,
77
- });
78
- for (const c of containers) {
79
- const props = await kitContainerProperties(this.gameModel, String(this.appId), c.containerId);
80
- if (String(props.event_name ?? '') === name) {
81
- this.counterIds.set(name, c.containerId);
82
- return c.containerId;
83
- }
84
- }
85
- const created = await this.gameModel.createContainer({
86
- appId: this.appId,
87
- typeName: this.counterTypeName,
88
- displayName: `telemetry ${name}`,
89
- properties: [
90
- { key: 'event_name', valueType: 'string', valueJson: JSON.stringify(name) },
91
- { key: 'count', valueType: 'int', valueJson: '0' },
92
- ],
93
- });
94
- this.counterIds.set(name, created.containerId);
95
- return created.containerId;
96
- }
97
- }
98
- /** The telemetry blueprint: one counter type; the convention is the point. */
99
- export function telemetryBlueprint(counterTypeName = 'TelemetryCounter') {
100
- return {
101
- name: 'telemetry',
102
- containerTypes: [
103
- {
104
- typeName: counterTypeName,
105
- displayName: 'Telemetry counter',
106
- description: "One sampled event counter (event_name + count + last_props). Naming convention: '<area>.<action>'.",
107
- },
108
- ],
109
- propertyDefinitions: [
110
- {
111
- containerTypeName: counterTypeName,
112
- key: 'event_name',
113
- valueType: 'string',
114
- defaultValueJson: '""',
115
- description: "The tracked event's convention name ('<area>.<action>').",
116
- },
117
- {
118
- containerTypeName: counterTypeName,
119
- key: 'count',
120
- valueType: 'int',
121
- defaultValueJson: '0',
122
- description: 'Sampled occurrence count.',
123
- },
124
- {
125
- containerTypeName: counterTypeName,
126
- key: 'last_props',
127
- valueType: 'string',
128
- defaultValueJson: '""',
129
- description: 'The last tracked props JSON (spot-debugging, not a warehouse).',
130
- },
131
- ],
132
- };
133
- }
@@ -1,97 +0,0 @@
1
- import type { GameModelAPI } from '../domains/gameModel.js';
2
- import type { Scalars } from '../generated/graphql.js';
3
- import type { EngineDetector } from './engine.js';
4
- import { type ControlPointEvent } from './wire.js';
5
- /** Options for {@link TerritoryKit}. */
6
- export interface TerritoryKitOptions {
7
- /** The territory engine module name. Defaults to `'territory'`. */
8
- moduleName?: string;
9
- }
10
- /** A control point as the engine reports it. */
11
- export interface KitControlPoint {
12
- pointId: string;
13
- x: number;
14
- z: number;
15
- radius: number;
16
- owner: string;
17
- challenger: string;
18
- progress: number;
19
- incomePerMin: number;
20
- siegeOpen: boolean;
21
- }
22
- /**
23
- * Runtime helpers for the territory engine (Wave 3): control-point state,
24
- * faction standings, and the admin CRUD for the map (factions, members,
25
- * points). Capture itself is pure presence — stand inside a point's radius
26
- * with your faction; the engine does the rest and announces flips as
27
- * type-96 events.
28
- *
29
- * Obtained via `client.kit(appId).territory`.
30
- */
31
- export declare class TerritoryKit {
32
- private readonly appId;
33
- private readonly gameModel;
34
- private readonly engines;
35
- private readonly moduleName;
36
- constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, engines: EngineDetector, options?: TerritoryKitOptions);
37
- /** Is the territory engine deployed + enabled (cached per session)? */
38
- engineAvailable(): Promise<boolean>;
39
- /** Every control point with live capture state. */
40
- points(): Promise<KitControlPoint[]>;
41
- /** Faction standings (id + treasury). */
42
- factions(): Promise<Array<{
43
- factionId: string;
44
- gold: number;
45
- }>>;
46
- /** Engine totals (flips, income paid). */
47
- status(): Promise<Record<string, unknown>>;
48
- /** STUDIO (admin) — create a faction. */
49
- defineFaction(factionId: string, displayName?: string): Promise<{
50
- __typename?: "GmContainer";
51
- containerId: string;
52
- appId: string;
53
- sessionId: string | null;
54
- typeName: string;
55
- displayName: string;
56
- description: string | null;
57
- ownerUserId: string | null;
58
- metadataJson: string;
59
- }>;
60
- /** STUDIO (admin) — enroll a player in a faction. */
61
- enroll(userId: string, factionId: string): Promise<{
62
- __typename?: "GmContainer";
63
- containerId: string;
64
- appId: string;
65
- sessionId: string | null;
66
- typeName: string;
67
- displayName: string;
68
- description: string | null;
69
- ownerUserId: string | null;
70
- metadataJson: string;
71
- }>;
72
- /** STUDIO (admin) — create a control point. */
73
- definePoint(input: {
74
- pointId: string;
75
- x: number;
76
- z: number;
77
- radius: number;
78
- incomePerMin?: number;
79
- siegeFromMin?: number;
80
- siegeToMin?: number;
81
- displayName?: string;
82
- }): Promise<{
83
- __typename?: "GmContainer";
84
- containerId: string;
85
- appId: string;
86
- sessionId: string | null;
87
- typeName: string;
88
- displayName: string;
89
- description: string | null;
90
- ownerUserId: string | null;
91
- metadataJson: string;
92
- }>;
93
- /** Parse a type-96 control-point server event (flips). */
94
- parseControlPoint(bytes: Uint8Array): ControlPointEvent | null;
95
- private invoke;
96
- }
97
- //# sourceMappingURL=territory.d.ts.map