@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
package/dist/kit/loot.js DELETED
@@ -1,160 +0,0 @@
1
- import { lootNames, lootRollFn } from './blueprints/index.js';
2
- import { kitContainerProperties, kitInvoke, } from './shared.js';
3
- /**
4
- * Runtime helpers for the {@link lootBlueprint} conventions: create durable
5
- * `LootRoll` containers, roll them (trusted — app admins by default, or the
6
- * blueprint's event-drop automations), and claim results atomically into an
7
- * item stack. The weighted selection runs entirely server-side from a stored
8
- * seed, so clients can neither pick their loot nor claim it twice.
9
- *
10
- * Obtained via `client.kit(appId).loot`.
11
- */
12
- export class LootKit {
13
- constructor(appId, gameModel, options = {}, engines) {
14
- this.appId = appId;
15
- this.gameModel = gameModel;
16
- this.engines = engines;
17
- this.typePrefix = options.typePrefix ?? '';
18
- this.names = lootNames(this.typePrefix);
19
- this.engineModuleName = options.engineModuleName ?? 'loot-engine';
20
- }
21
- /**
22
- * Is a big-table loot module deployed + enabled (cached per session)?
23
- * When true, {@link enginePull} routes rolls through server-held RNG with
24
- * pity timers + audit trails; the blueprint's weighted model rolls stay
25
- * for small tables (the coexistence policy — "the server picks the path").
26
- */
27
- engineAvailable() {
28
- if (!this.engines)
29
- return Promise.resolve(false);
30
- return this.engines.has(this.engineModuleName);
31
- }
32
- /** Pull from the module's table (pity-timer path); count caps at 10. */
33
- async enginePull(count = 1) {
34
- if (!this.engines)
35
- throw new Error('loot engine unavailable: compute domain not wired');
36
- const result = await this.engines.invoke(this.engineModuleName, 'pull', { count });
37
- if (!result.success)
38
- throw new Error(`loot.pull failed: ${result.reason ?? 'unknown'}`);
39
- return result.body;
40
- }
41
- /** Your pity counters + roll totals from the module. */
42
- async enginePity() {
43
- if (!this.engines)
44
- throw new Error('loot engine unavailable: compute domain not wired');
45
- const result = await this.engines.invoke(this.engineModuleName, 'pity', {});
46
- if (!result.success)
47
- throw new Error(`loot.pity failed: ${result.reason ?? 'unknown'}`);
48
- return result.body;
49
- }
50
- /** Your rolling audit trail from the module (dispute resolution). */
51
- async engineAudit() {
52
- if (!this.engines)
53
- throw new Error('loot engine unavailable: compute domain not wired');
54
- const result = await this.engines.invoke(this.engineModuleName, 'audit', {});
55
- if (!result.success)
56
- throw new Error(`loot.audit failed: ${result.reason ?? 'unknown'}`);
57
- return result.body;
58
- }
59
- /**
60
- * Create an unrolled `LootRoll` for a table, owned by `ownerUserId` (who
61
- * will claim it). Event-drop automations pick from the pool of unrolled
62
- * rolls — create a few ahead of time for tables wired to `drops`.
63
- */
64
- async createRoll(input) {
65
- return this.gameModel.createContainer({
66
- appId: this.appId,
67
- typeName: this.names.rollType,
68
- displayName: input.displayName ?? `Roll ${input.tableId}`,
69
- ...(input.sessionId !== undefined ? { sessionId: input.sessionId } : {}),
70
- properties: [
71
- {
72
- key: 'owner_user_id',
73
- valueType: 'int',
74
- valueJson: String(input.ownerUserId),
75
- },
76
- {
77
- key: 'table_id',
78
- valueType: 'string',
79
- valueJson: JSON.stringify(input.tableId),
80
- },
81
- ],
82
- });
83
- }
84
- /**
85
- * Roll a table on an unrolled `LootRoll` — a **trusted** call (default
86
- * blueprint authority: app admins). Resolves with the rolled item id.
87
- *
88
- * @param tableId - The roll container's table (derives the function name);
89
- * read from the container when omitted.
90
- */
91
- async roll(rollId, tableId) {
92
- const table = tableId ?? (await this.state(rollId)).tableId;
93
- return kitInvoke(this.gameModel, {
94
- appId: String(this.appId),
95
- functionName: lootRollFn(table, this.typePrefix),
96
- selfContainerId: rollId,
97
- params: {},
98
- });
99
- }
100
- /**
101
- * Claim a rolled loot into a caller-owned stack of the rolled item. The
102
- * claimed flag and the grant commit atomically. Resolves with the granted
103
- * quantity.
104
- */
105
- async claim(rollId, toStackId) {
106
- return kitInvoke(this.gameModel, {
107
- appId: String(this.appId),
108
- functionName: this.names.claimFn,
109
- selfContainerId: rollId,
110
- params: { to_stack_id: toStackId },
111
- });
112
- }
113
- /** Read one roll's state. */
114
- async state(rollId) {
115
- const container = await this.gameModel.container({
116
- appId: this.appId,
117
- containerId: rollId,
118
- });
119
- return this.toRoll(container.containerId, container.displayName, container.ownerUserId != null ? String(container.ownerUserId) : null);
120
- }
121
- /**
122
- * List a player's rolls, optionally filtered to one table and/or to
123
- * unclaimed rolled loot (the "your drops" screen).
124
- */
125
- async rolls(ownerUserId, options = {}) {
126
- const containers = await this.gameModel.containers({
127
- appId: this.appId,
128
- typeName: this.names.rollType,
129
- });
130
- const mine = containers.filter((c) => c.ownerUserId != null && String(c.ownerUserId) === String(ownerUserId));
131
- const rolls = await Promise.all(mine.map((c) => this.toRoll(c.containerId, c.displayName, c.ownerUserId != null ? String(c.ownerUserId) : null)));
132
- return rolls.filter((r) => (options.tableId === undefined || r.tableId === options.tableId) &&
133
- (!options.unclaimedOnly || (!r.claimed && r.rolledItemId !== '')));
134
- }
135
- /**
136
- * Roll/claim audit history from the model event log (each roll records its
137
- * seed, item, and quantity as applied mutations).
138
- */
139
- async history(options = {}) {
140
- return this.gameModel.events({
141
- appId: this.appId,
142
- functionName: options.tableId !== undefined
143
- ? lootRollFn(options.tableId, this.typePrefix)
144
- : this.names.claimFn,
145
- ...(options.limit !== undefined ? { limit: options.limit } : {}),
146
- });
147
- }
148
- async toRoll(containerId, displayName, ownerUserId) {
149
- const props = await kitContainerProperties(this.gameModel, String(this.appId), containerId);
150
- return {
151
- containerId,
152
- displayName,
153
- ownerUserId,
154
- tableId: String(props.table_id ?? ''),
155
- rolledItemId: String(props.rolled_item_id ?? ''),
156
- rolledQty: Number(props.rolled_qty ?? 0),
157
- claimed: props.claimed === true,
158
- };
159
- }
160
- }
@@ -1,301 +0,0 @@
1
- import type { ChannelsAPI } from '../domains/channels.js';
2
- import type { EngineDetector } from './engine.js';
3
- import type { GameModelAPI } from '../domains/gameModel.js';
4
- import type { UdpAPI } from '../domains/udp.js';
5
- import type { Scalars } from '../generated/graphql.js';
6
- import { type KitInvokeResult } from './shared.js';
7
- /**
8
- * What {@link MatchesKit.finish} did about the backing session after a
9
- * successful `end_match`: `'ended'` (it ended it), `'already_ended'` (a
10
- * replayed finish; the session was already ended), `'forbidden'` (the caller
11
- * passed `end_match` -- creator or the app's elected host -- but is neither
12
- * the session host nor an app admin, so the session is still active; an app
13
- * admin can `gameModel.endSession` it).
14
- * Absent when `end_match` itself was refused (`success: false`).
15
- */
16
- export type KitMatchSessionEnd = 'ended' | 'already_ended' | 'forbidden';
17
- /** {@link MatchesKit.finish}'s result: the invoke result plus what happened to the session. */
18
- export type KitMatchFinishResult = KitInvokeResult<string> & {
19
- sessionEnd?: KitMatchSessionEnd;
20
- };
21
- /** Options for {@link MatchesKit}. Must match the deployed matches blueprint. */
22
- export interface MatchesKitOptions {
23
- /**
24
- * The compute module driving server-side match lifecycle when the app
25
- * runs an engine. Defaults to `'match-engine'`.
26
- */
27
- engineModuleName?: string;
28
- /** The `typePrefix` the matches blueprint was deployed with. */
29
- typePrefix?: string;
30
- /**
31
- * The 32-ASCII-char actor uuid used as the sender id on channel pings.
32
- * Defaults to a random uuid per kit instance.
33
- */
34
- actorUuid?: string;
35
- }
36
- /** A parsed view of one match. */
37
- export interface KitMatch {
38
- /** The session backing the match (participants + turn order). */
39
- sessionId: string;
40
- /** The MatchMeta container id (the `self` of the lifecycle functions). */
41
- metaId: string;
42
- displayName: string;
43
- creatorUserId: number;
44
- mode: string;
45
- state: string;
46
- round: number;
47
- maxPlayers: number;
48
- winnerUserId: number;
49
- /** The per-match notification channel (0 when none was wired). */
50
- channelId: string;
51
- /** Present when the blueprint was deployed with `turnTick`. */
52
- tickCount?: number;
53
- /**
54
- * The current turn's sequence number. Present only when the blueprint was
55
- * deployed with `turnTimer`, which is how the helpers detect that turns
56
- * carry a deadline.
57
- */
58
- turnSeq?: number;
59
- /** The highest turn sequence whose deadline elapsed. See {@link turnExpired}. */
60
- turnExpiredSeq?: number;
61
- }
62
- /**
63
- * Whether the match's current turn has run out of time — true once the
64
- * deadline for the open turn has fired. Always false for a match deployed
65
- * without `turnTimer`, and false for a deadline stranded by an earlier turn,
66
- * since those record a lower sequence than the one now open.
67
- */
68
- export declare function turnExpired(match: KitMatch): boolean;
69
- /** One row of the match standings. */
70
- export interface KitMatchScore {
71
- containerId: string;
72
- ownerUserId: string | null;
73
- points: number;
74
- }
75
- /**
76
- * Runtime helpers for the {@link matchesBlueprint} conventions: sessions ARE
77
- * the match primitive — `create` makes a session + a `MatchMeta` + a
78
- * per-match channel; turn order goes through the platform's session-turn
79
- * authority; lifecycle functions ping the channel post-commit and
80
- * {@link onMatchChanged} wraps the notify-to-pull loop (subscribe →
81
- * `"match_changed"` ping → re-pull state).
82
- *
83
- * Obtained via `client.kit(appId).matches`.
84
- */
85
- export declare class MatchesKit {
86
- private readonly appId;
87
- private readonly gameModel;
88
- private readonly channels;
89
- private readonly udp;
90
- private readonly engines?;
91
- private readonly names;
92
- private readonly actorUuid;
93
- private readonly engineModuleName;
94
- /**
95
- * This client's participant incarnation per session, remembered from
96
- * {@link create} (a creator starts at 1) and {@link join}, so {@link leave}
97
- * can send the value the server requires without the caller carrying it.
98
- */
99
- private readonly incarnations;
100
- constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, channels: ChannelsAPI | undefined, udp: UdpAPI | undefined, options?: MatchesKitOptions, engines?: EngineDetector | undefined);
101
- private requireChannels;
102
- private requireUdp;
103
- /**
104
- * Create a match: a session (the platform match primitive), a per-match
105
- * notification channel, and the session-scoped `MatchMeta`.
106
- *
107
- * @param input.creatorUserId - The calling player's user id (stored so the
108
- * creator may start/advance/end the match).
109
- * @param input.seedFromApp - Optional: container types whose app-scoped keyed
110
- * rows (a `gameModelSeed` with `bindingKey`) are stamped into the match's
111
- * session at creation, inside the same transaction, so the match starts
112
- * with its world rows present (chests, spawners, turrets). Same shape as
113
- * `CreateSessionInput.seedFromApp`: `{ typeNames, initialState? }`. At most
114
- * 2,000 rows; above that the create is refused and no session exists. Only
115
- * `'session'`-scoped types; the copies are the only rows the tier's
116
- * (opt-in) ended-session retention may drop.
117
- */
118
- create(input: {
119
- creatorUserId: Scalars['BigInt']['input'];
120
- mode?: string;
121
- maxPlayers?: number;
122
- displayName?: string;
123
- seedFromApp?: {
124
- typeNames: string[];
125
- initialState?: 'defaults' | 'app';
126
- };
127
- }): Promise<KitMatch>;
128
- /** List joinable matches (metas still in the lobby state). */
129
- open(): Promise<KitMatch[]>;
130
- /** Read one match by its MatchMeta container. */
131
- get(metaId: string): Promise<KitMatch>;
132
- /**
133
- * Join a match: session participation + the notification channel. A rejoin
134
- * (you are already in) returns your row with `incarnation + 1`. The
135
- * incarnation is remembered on this kit instance for {@link leave}.
136
- */
137
- join(match: KitMatch): Promise<{
138
- __typename?: "GmSessionParticipant";
139
- sessionId: string;
140
- userId: string;
141
- role: string;
142
- state: string;
143
- incarnation: number;
144
- actorUuid: string | null;
145
- joinedAt: string;
146
- leftAt: string | null;
147
- leftReason: string | null;
148
- }>;
149
- /**
150
- * Leave a match: session departure + the notification channel. The server
151
- * requires the incarnation {@link join} returned to *this* client, so a
152
- * superseded client can never remove the one that took over; pass it, or
153
- * let the kit use the one it remembered from `create` / `join` on this
154
- * instance. A kit session is `presence: 'none'`, so this and {@link finish}
155
- * are the roster's only exits.
156
- *
157
- * @throws {Error} when no incarnation is known for the match on this
158
- * instance and none was passed.
159
- * @throws {CrowdyGraphQLError} `SESSION_INCARNATION_STALE` (a newer client
160
- * of yours rejoined), `SESSION_NOT_PARTICIPANT`, `NOT_FOUND`.
161
- */
162
- leave(match: KitMatch, incarnation?: number): Promise<{
163
- __typename?: "GmSessionParticipant";
164
- sessionId: string;
165
- userId: string;
166
- role: string;
167
- state: string;
168
- incarnation: number;
169
- actorUuid: string | null;
170
- joinedAt: string;
171
- leftAt: string | null;
172
- leftReason: string | null;
173
- }>;
174
- /** Start the match (creator or host). Pings the match channel post-commit. */
175
- start(match: KitMatch): Promise<KitInvokeResult<string>>;
176
- /** Advance to the next round (creator or host). */
177
- advanceRound(match: KitMatch): Promise<KitInvokeResult<number>>;
178
- /** Whether it is `userId`'s session turn right now. */
179
- myTurn(match: KitMatch, userId: Scalars['BigInt']['input']): Promise<boolean>;
180
- /**
181
- * Pass the turn to the next player via the platform's session-turn
182
- * authority (current holder, host, or admin — enforced by the service),
183
- * then ping the match channel so everyone re-pulls.
184
- *
185
- * For a match deployed with `turnTimer`, this opens the incoming turn first
186
- * so it arrives with a deadline already running. Opening it before the
187
- * handover also means the outgoing holder is still the session's turn user,
188
- * which is what authorizes them to do it.
189
- */
190
- endTurn(match: KitMatch, nextUserId: Scalars['BigInt']['input']): Promise<{
191
- __typename?: "GmSession";
192
- sessionId: string;
193
- appId: string;
194
- name: string | null;
195
- status: string;
196
- createdByUserId: string | null;
197
- currentTurnUserId: string | null;
198
- metadataJson: string;
199
- admission: string;
200
- maxParticipants: number | null;
201
- participantCount: number;
202
- hostUserId: string | null;
203
- hostTerm: number;
204
- revision: string;
205
- endedAt: string | null;
206
- endReason: string | null;
207
- createdAt: string;
208
- presence: string;
209
- gridId: string | null;
210
- seededContainerCount: number | null;
211
- }>;
212
- /**
213
- * Open a turn and arm its deadline (`turnTimer` deployments only) — the
214
- * deadline replaces any still pending for this match. `endTurn` calls this
215
- * for you; call it directly to give the current player a fresh clock, e.g.
216
- * after granting extra time.
217
- */
218
- beginTurn(match: KitMatch): Promise<KitInvokeResult<number>>;
219
- /**
220
- * Cancel the pending turn deadline for this match, if any. Returns how many
221
- * timers were dropped. Ending a match already strands its deadline, so this
222
- * is only needed when you want turns to stop being timed while play
223
- * continues.
224
- */
225
- cancelTurnDeadline(match: KitMatch): Promise<number>;
226
- /** Find-or-create a player's session-scoped Score row. */
227
- ensureScore(match: KitMatch, ownerUserId: Scalars['BigInt']['input']): Promise<{
228
- __typename?: "GmContainer";
229
- containerId: string;
230
- appId: string;
231
- sessionId: string | null;
232
- typeName: string;
233
- displayName: string;
234
- description: string | null;
235
- ownerUserId: string | null;
236
- metadataJson: string;
237
- }>;
238
- /**
239
- * Add points to a Score row — trusted (host-refereed by default).
240
- * Resolves with the new points.
241
- */
242
- score(match: KitMatch, scoreId: string, points: number): Promise<KitInvokeResult<number>>;
243
- /** The match standings, highest points first (client-side sort). */
244
- standings(match: KitMatch): Promise<KitMatchScore[]>;
245
- /**
246
- * Finish the match and record the winner (creator or host). Also drops the
247
- * pending turn deadline on a `turnTimer` match — `end_match` already
248
- * strands it, so this just saves the pointless fire and channel ping.
249
- *
250
- * When `end_match` succeeds the backing session is ended too
251
- * (`gameModelEndSession`, reason `completed`): every participant is marked
252
- * left, admission closes, and the session's events become eligible for
253
- * retention. The game-authoritative step runs first, so the match is
254
- * decided whatever happens next; `sessionEnd` on the result says what
255
- * happened to the session ({@link KitMatchSessionEnd}): `'ended'`, or
256
- * `'already_ended'` for a replayed finish, or `'forbidden'` when the caller
257
- * passed `end_match` (creator or the app's elected host) but is not admitted
258
- * to the session end (session host or app admin only) -- the match is
259
- * finished, the session is not, and nothing is thrown. Any other refusal of
260
- * the session end propagates.
261
- */
262
- finish(match: KitMatch, winnerUserId: Scalars['BigInt']['input']): Promise<KitMatchFinishResult>;
263
- /**
264
- * Manually ping the match channel with `"match_changed"` (the lifecycle
265
- * functions do this automatically via their declared notifications; use
266
- * this after out-of-band changes such as `endTurn`).
267
- */
268
- notifyChanged(match: KitMatch): Promise<boolean>;
269
- /**
270
- * The notify-to-pull loop, wrapped: subscribe to the app's notifications,
271
- * and on every ping of THIS match's channel re-pull the match state and
272
- * hand it to `callback`. Returns the unsubscribe function.
273
- */
274
- onMatchChanged(match: KitMatch, callback: (match: KitMatch) => void): () => void;
275
- private toMatch;
276
- /**
277
- * Is a match compute engine deployed + enabled (cached per session)? When
278
- * true the engine owns transitions (ready checks, turn order + timeouts,
279
- * authoritative scoring); the blueprint's creator-driven functions remain
280
- * for model-only deployments.
281
- */
282
- engineAvailable(): Promise<boolean>;
283
- /**
284
- * Declare ready on an engine match (a MatchMeta container id). The match
285
- * starts server-side once every expected player is ready.
286
- */
287
- engineReady(matchId: string): Promise<Record<string, unknown>>;
288
- /** Submit your move (the engine validates the turn + resolves). */
289
- engineSubmitMove(matchId: string, params?: Record<string, unknown>): Promise<Record<string, unknown>>;
290
- /** Forfeit an engine match. */
291
- engineForfeit(matchId: string): Promise<Record<string, unknown>>;
292
- /** The engine's live view: turn holder, timers, standings, summary. */
293
- engineStatus(matchId: string): Promise<Record<string, unknown>>;
294
- /**
295
- * Resolve a matchmaking proposal to the match the engine created for it
296
- * (poll after everyone accepts; see `kit.matchmaking`).
297
- */
298
- findByProposal(proposalId: string): Promise<string | null>;
299
- private engineInvoke;
300
- }
301
- //# sourceMappingURL=matches.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"matches.d.ts","sourceRoot":"","sources":["../../src/kit/matches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EAGL,KAAK,eAAe,E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