@crowdedkingdoms/crowdyjs 18.10.0 → 18.12.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 (90) hide show
  1. package/MIGRATION.md +69 -0
  2. package/README.md +91 -30
  3. package/dist/crowdy-client.d.ts +11 -3
  4. package/dist/crowdy-client.d.ts.map +1 -1
  5. package/dist/crowdy-client.js +25 -4
  6. package/dist/default-origin.d.ts +6 -6
  7. package/dist/default-origin.d.ts.map +1 -1
  8. package/dist/default-origin.js +6 -6
  9. package/dist/domains/exec.d.ts +6 -0
  10. package/dist/domains/exec.d.ts.map +1 -1
  11. package/dist/domains/exec.js +28 -2
  12. package/dist/generated/graphql-schema.d.ts +1 -1
  13. package/dist/generated/graphql-schema.d.ts.map +1 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +5 -3
  17. package/dist/kit/index.d.ts +22 -2
  18. package/dist/kit/index.d.ts.map +1 -1
  19. package/dist/kit/index.js +22 -2
  20. package/dist/kit/kit.d.ts +141 -7
  21. package/dist/kit/kit.d.ts.map +1 -1
  22. package/dist/kit/kit.js +138 -4
  23. package/dist/kit/mirror.d.ts +111 -0
  24. package/dist/kit/mirror.d.ts.map +1 -0
  25. package/dist/kit/mirror.js +295 -0
  26. package/dist/kit/modules/arenas.d.ts +87 -0
  27. package/dist/kit/modules/arenas.d.ts.map +1 -0
  28. package/dist/kit/modules/arenas.js +66 -0
  29. package/dist/kit/modules/encounters.d.ts +75 -0
  30. package/dist/kit/modules/encounters.d.ts.map +1 -0
  31. package/dist/kit/modules/encounters.js +57 -0
  32. package/dist/kit/modules/instances.d.ts +78 -0
  33. package/dist/kit/modules/instances.d.ts.map +1 -0
  34. package/dist/kit/modules/instances.js +72 -0
  35. package/dist/kit/modules/leaderboards.d.ts +79 -0
  36. package/dist/kit/modules/leaderboards.d.ts.map +1 -0
  37. package/dist/kit/modules/leaderboards.js +69 -0
  38. package/dist/kit/modules/matchmaking.d.ts +107 -0
  39. package/dist/kit/modules/matchmaking.d.ts.map +1 -0
  40. package/dist/kit/modules/matchmaking.js +109 -0
  41. package/dist/kit/modules/minigames.d.ts +59 -0
  42. package/dist/kit/modules/minigames.d.ts.map +1 -0
  43. package/dist/kit/modules/minigames.js +55 -0
  44. package/dist/kit/modules/npcs.d.ts +80 -0
  45. package/dist/kit/modules/npcs.d.ts.map +1 -0
  46. package/dist/kit/modules/npcs.js +102 -0
  47. package/dist/kit/modules/presence.d.ts +81 -0
  48. package/dist/kit/modules/presence.d.ts.map +1 -0
  49. package/dist/kit/modules/presence.js +99 -0
  50. package/dist/kit/modules/racing.d.ts +131 -0
  51. package/dist/kit/modules/racing.d.ts.map +1 -0
  52. package/dist/kit/modules/racing.js +113 -0
  53. package/dist/kit/modules/sessions.d.ts +91 -0
  54. package/dist/kit/modules/sessions.d.ts.map +1 -0
  55. package/dist/kit/modules/sessions.js +84 -0
  56. package/dist/kit/modules/tables.d.ts +76 -0
  57. package/dist/kit/modules/tables.d.ts.map +1 -0
  58. package/dist/kit/modules/tables.js +73 -0
  59. package/dist/kit/modules/tactics.d.ts +79 -0
  60. package/dist/kit/modules/tactics.d.ts.map +1 -0
  61. package/dist/kit/modules/tactics.js +67 -0
  62. package/dist/kit/modules/territory.d.ts +92 -0
  63. package/dist/kit/modules/territory.d.ts.map +1 -0
  64. package/dist/kit/modules/territory.js +84 -0
  65. package/dist/kit/modules/world.d.ts +69 -0
  66. package/dist/kit/modules/world.d.ts.map +1 -0
  67. package/dist/kit/modules/world.js +35 -0
  68. package/dist/kit/protocol.d.ts +128 -0
  69. package/dist/kit/protocol.d.ts.map +1 -0
  70. package/dist/kit/protocol.js +171 -0
  71. package/dist/kit/realtime.d.ts +72 -0
  72. package/dist/kit/realtime.d.ts.map +1 -0
  73. package/dist/kit/realtime.js +108 -0
  74. package/dist/kit/runtime.d.ts +90 -0
  75. package/dist/kit/runtime.d.ts.map +1 -0
  76. package/dist/kit/runtime.js +194 -0
  77. package/dist/kit/store.d.ts +20 -0
  78. package/dist/kit/store.d.ts.map +1 -0
  79. package/dist/kit/store.js +25 -0
  80. package/dist/kit/topology.d.ts +69 -0
  81. package/dist/kit/topology.d.ts.map +1 -0
  82. package/dist/kit/topology.js +156 -0
  83. package/dist/kit/wire.d.ts +45 -5
  84. package/dist/kit/wire.d.ts.map +1 -1
  85. package/dist/kit/wire.js +51 -5
  86. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  87. package/dist/live-coding/assets/manifest.json +1 -1
  88. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  89. package/dist/live-coding/browser-authoring-index.generated.js +5092 -45
  90. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ import { CrowdyError } from '../errors.js';
2
+ /** The crates one build takes at most (the game API's `execBuild`). */
3
+ export const KIT_BUILD_MAX_CRATES = 16;
4
+ /** The node API scopes a manifest may declare (ck-exec `bounds::NODE_API_SCOPES`). */
5
+ export const KIT_NODE_API_SCOPES = [
6
+ 'players.read',
7
+ 'players.write',
8
+ 'world.read',
9
+ 'world.write',
10
+ 'grids.read',
11
+ 'permissions.write',
12
+ 'grids.write',
13
+ 'access.read',
14
+ 'access.write',
15
+ ];
16
+ const NAME = /^[A-Za-z0-9_-]{1,64}$/;
17
+ /**
18
+ * What the execution manager would refuse in `manifest`, in its words (ck-exec
19
+ * `Manifest::problems`, less the digests, which the build fills in): the root is a hub
20
+ * without a parent, every other type has a defined parent, `calls` name defined types or `*`,
21
+ * replicas are for spokes, scopes are known. Empty when it deploys.
22
+ */
23
+ export function kitManifestProblems(manifest) {
24
+ const out = [];
25
+ const types = manifest.types;
26
+ const root = types[manifest.root];
27
+ if (!root)
28
+ out.push(`root type \`${manifest.root}\` is not defined`);
29
+ else if (root.kind !== 'hub')
30
+ out.push('the root type must be a hub');
31
+ else if (root.parent)
32
+ out.push('the root type has no parent');
33
+ for (const [name, t] of Object.entries(types)) {
34
+ if (!NAME.test(name))
35
+ out.push(`type name \`${name}\` must be 1-64 letters, digits, \`-\` or \`_\``);
36
+ if (name !== manifest.root) {
37
+ if (!t.parent)
38
+ out.push(`\`${name}\` needs a parent`);
39
+ else if (!types[t.parent])
40
+ out.push(`\`${name}\`: parent \`${t.parent}\` is not defined`);
41
+ }
42
+ for (const c of t.calls ?? []) {
43
+ if (c !== '*' && !types[c])
44
+ out.push(`\`${name}\` calls \`${c}\`, which is not defined`);
45
+ }
46
+ if (t.kind === 'hub' && (t.replicas !== undefined || t.max_replicas !== undefined || t.concurrency !== undefined)) {
47
+ out.push(`\`${name}\`: replicas, max_replicas and concurrency are for spokes`);
48
+ }
49
+ for (const s of t.scopes ?? []) {
50
+ if (!KIT_NODE_API_SCOPES.includes(s)) {
51
+ out.push(`\`${name}\`: unknown node API scope \`${s}\` (allowed: ${KIT_NODE_API_SCOPES.join(', ')})`);
52
+ }
53
+ }
54
+ }
55
+ return out;
56
+ }
57
+ /**
58
+ * An app's tree of kit hubs, composed from the starter packs (`exec.starters`): pick the node
59
+ * types a game uses, and {@link plan} adds the hubs they hang under and the ones they call,
60
+ * checks the tree, and {@link deploy} builds the crates on the platform and deploys them.
61
+ * For the app's developers (the org's `manage_compute`), from an identity session.
62
+ */
63
+ export class KitTopology {
64
+ constructor(appId, exec) {
65
+ this.appId = appId;
66
+ this.exec = exec;
67
+ this.packed = null;
68
+ }
69
+ api() {
70
+ if (!this.exec)
71
+ throw new CrowdyError({ message: 'the kit has no exec client' });
72
+ return this.exec;
73
+ }
74
+ /** The starter packs this tier's toolchain carries (fetched once). */
75
+ pack() {
76
+ if (!this.packed) {
77
+ this.packed = this.api()
78
+ .starters(this.appId)
79
+ .catch((e) => {
80
+ this.packed = null;
81
+ throw e;
82
+ });
83
+ }
84
+ return this.packed;
85
+ }
86
+ /** The node types the packs offer. */
87
+ async types() {
88
+ return Object.keys((await this.pack()).manifest.types);
89
+ }
90
+ /**
91
+ * A manifest with the types in `select`, the types they hang under up to the root, and the
92
+ * types they call (by name, not `*`), from the packs' manifest.
93
+ * @throws {CrowdyError} for a type the packs do not have, a tree the manager would refuse,
94
+ * or more crates than one build takes.
95
+ */
96
+ async plan(select, options = {}) {
97
+ const pack = await this.pack();
98
+ const all = pack.manifest.types;
99
+ const chosen = new Set();
100
+ const add = (name) => {
101
+ if (chosen.has(name))
102
+ return;
103
+ const t = all[name];
104
+ if (!t)
105
+ throw new CrowdyError({ message: `the starter packs have no node type '${name}' (they have ${Object.keys(all).join(', ')})` });
106
+ chosen.add(name);
107
+ if (t.parent)
108
+ add(t.parent);
109
+ for (const c of t.calls ?? [])
110
+ if (c !== '*')
111
+ add(c);
112
+ };
113
+ add(pack.manifest.root);
114
+ for (const name of select)
115
+ add(name);
116
+ const types = {};
117
+ for (const name of chosen) {
118
+ const merged = { ...all[name], ...(options.overrides?.[name] ?? {}) };
119
+ // A type calls only what the plan holds.
120
+ if (merged.calls)
121
+ merged.calls = merged.calls.filter((c) => c === '*' || chosen.has(c));
122
+ types[name] = merged;
123
+ }
124
+ const problems = kitManifestProblems({ root: pack.manifest.root, types });
125
+ if (problems.length)
126
+ throw new CrowdyError({ message: `the composed manifest would be refused: ${problems.join('; ')}` });
127
+ const crates = [...new Set(Object.values(types).map((t) => t.crate).filter((c) => typeof c === 'string'))];
128
+ if (crates.length > KIT_BUILD_MAX_CRATES) {
129
+ throw new CrowdyError({ message: `${crates.length} crates are more than one build takes (${KIT_BUILD_MAX_CRATES})` });
130
+ }
131
+ return { root: pack.manifest.root, types, crates };
132
+ }
133
+ /**
134
+ * Builds the plan's crates on the platform, waits, and deploys the manifest with the build.
135
+ * Resolves with the deployed version and the build id.
136
+ * @throws {CrowdyError} when the build fails (its log in the message).
137
+ */
138
+ async deploy(plan, options = {}) {
139
+ const pack = await this.pack();
140
+ const crates = plan.crates.map((name) => {
141
+ const s = pack.starters.find((x) => x.crate === name);
142
+ if (!s)
143
+ throw new CrowdyError({ message: `the starter packs have no crate '${name}'` });
144
+ return { name, files: s.files };
145
+ });
146
+ const exec = this.api();
147
+ const queued = await exec.build(this.appId, crates);
148
+ const done = await exec.waitForBuild(this.appId, queued.buildId, { timeoutMs: options.timeoutMs });
149
+ options.onBuild?.(done);
150
+ if (done.status !== 'succeeded') {
151
+ throw new CrowdyError({ message: `build ${done.buildId} ${done.status}: ${(done.log ?? '').slice(-2000)}` });
152
+ }
153
+ const { version } = await exec.deploy({ appId: this.appId, root: plan.root, types: plan.types, buildId: done.buildId });
154
+ return { version, buildId: done.buildId };
155
+ }
156
+ }
@@ -1,9 +1,11 @@
1
1
  /**
2
- * Engine wire registry — the client mirror of `crowdy-game-kit-core::wire`
3
- * (the actor pose layout and flag-bit registry the game engines emit, and
4
- * hubs that keep a game's client parsers still send). Parity with the Rust
5
- * crate is checked by the kit wire unit suite: any change here must land in
6
- * kit-core first.
2
+ * The kit's realtime wire: the server-event registry kit hubs emit through
3
+ * the realtime tier (`ckx_sdk::kit::wire` is its source: ids 77 and 90-101,
4
+ * JSON bodies with camelCase keys, an app's own from 1000), and the 48-byte
5
+ * engine pose layout with its flag bits, for hubs that show actors with it
6
+ * rather than with `KitActorState` (`realtime.ts`). The registry's bodies are
7
+ * held to ck-exec's `kit-protocol.json` by the kit protocol unit suite: a
8
+ * change lands in `ckx_sdk::kit::wire` first.
7
9
  *
8
10
  * 48-byte little-endian pose: pos f32 x3 (0..11), yaw/pitch f32 (12..19),
9
11
  * velocity f32 x3 (20..31), flags u8 (32), held u8 (33), 34-35 reserved,
@@ -76,6 +78,14 @@ export declare const EVENT_CONTROL_POINT = 96;
76
78
  export declare const EVENT_RACE_TIMING = 97;
77
79
  /** Zone change: shrinking circles, event areas (kit-sim zones). */
78
80
  export declare const EVENT_ZONE_CHANGE = 98;
81
+ /** Encounter: a wave began or was cleared, a boss changed phase (directors). */
82
+ export declare const EVENT_ENCOUNTER = 99;
83
+ /** Possession: the contested object (a ball) changed hands, or a goal was scored. */
84
+ export declare const EVENT_POSSESSION = 100;
85
+ /** An emote: a client event players send, the kit's convention ({@link EmotesKit}). */
86
+ export declare const EVENT_EMOTE = 101;
87
+ /** The first event type an app's own events may use. */
88
+ export declare const EVENT_APP_FIRST = 1000;
79
89
  /** Split an engine server-event payload into its type + JSON body. */
80
90
  export declare function parseEngineEvent(bytes: Uint8Array): {
81
91
  eventType: number;
@@ -183,4 +193,34 @@ export interface ZoneChangeEvent {
183
193
  }
184
194
  /** Parse a zone-change event; null when the payload is another type. */
185
195
  export declare function parseZoneChangeEvent(bytes: Uint8Array): ZoneChangeEvent | null;
196
+ /** A parsed type-99 encounter event (a wave began or was cleared, a boss changed phase). */
197
+ export interface EncounterEvent {
198
+ /** `'wave_started'`, `'wave_cleared'`, `'boss_phase'` or `'finished'`. */
199
+ kind: string;
200
+ encounterId: string;
201
+ wave: number;
202
+ phase: number;
203
+ body: Record<string, unknown>;
204
+ }
205
+ /** Parse an encounter event; null when the payload is another type. */
206
+ export declare function parseEncounterEvent(bytes: Uint8Array): EncounterEvent | null;
207
+ /** A parsed type-100 possession event (the contested object changed hands, or a goal). */
208
+ export interface PossessionEvent {
209
+ /** `'claimed'`, `'passed'`, `'loose'` or `'goal'`. */
210
+ kind: string;
211
+ holderId: string | null;
212
+ team: string | null;
213
+ body: Record<string, unknown>;
214
+ }
215
+ /** Parse a possession event; null when the payload is another type. */
216
+ export declare function parsePossessionEvent(bytes: Uint8Array): PossessionEvent | null;
217
+ /** A parsed type-101 emote (a client event, the kit's convention). */
218
+ export interface EmoteEvent {
219
+ emote: string;
220
+ /** The actor the emote is aimed at, if any. */
221
+ targetUuid: string | null;
222
+ body: Record<string, unknown>;
223
+ }
224
+ /** Parse an emote; null when the payload is another type. */
225
+ export declare function parseEmoteEvent(bytes: Uint8Array): EmoteEvent | null;
186
226
  //# sourceMappingURL=wire.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../src/kit/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK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M,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAQpE"}
package/dist/kit/wire.js CHANGED
@@ -1,9 +1,11 @@
1
1
  /**
2
- * Engine wire registry — the client mirror of `crowdy-game-kit-core::wire`
3
- * (the actor pose layout and flag-bit registry the game engines emit, and
4
- * hubs that keep a game's client parsers still send). Parity with the Rust
5
- * crate is checked by the kit wire unit suite: any change here must land in
6
- * kit-core first.
2
+ * The kit's realtime wire: the server-event registry kit hubs emit through
3
+ * the realtime tier (`ckx_sdk::kit::wire` is its source: ids 77 and 90-101,
4
+ * JSON bodies with camelCase keys, an app's own from 1000), and the 48-byte
5
+ * engine pose layout with its flag bits, for hubs that show actors with it
6
+ * rather than with `KitActorState` (`realtime.ts`). The registry's bodies are
7
+ * held to ck-exec's `kit-protocol.json` by the kit protocol unit suite: a
8
+ * change lands in `ckx_sdk::kit::wire` first.
7
9
  *
8
10
  * 48-byte little-endian pose: pos f32 x3 (0..11), yaw/pitch f32 (12..19),
9
11
  * velocity f32 x3 (20..31), flags u8 (32), held u8 (33), 34-35 reserved,
@@ -130,6 +132,14 @@ export const EVENT_CONTROL_POINT = 96;
130
132
  export const EVENT_RACE_TIMING = 97;
131
133
  /** Zone change: shrinking circles, event areas (kit-sim zones). */
132
134
  export const EVENT_ZONE_CHANGE = 98;
135
+ /** Encounter: a wave began or was cleared, a boss changed phase (directors). */
136
+ export const EVENT_ENCOUNTER = 99;
137
+ /** Possession: the contested object (a ball) changed hands, or a goal was scored. */
138
+ export const EVENT_POSSESSION = 100;
139
+ /** An emote: a client event players send, the kit's convention ({@link EmotesKit}). */
140
+ export const EVENT_EMOTE = 101;
141
+ /** The first event type an app's own events may use. */
142
+ export const EVENT_APP_FIRST = 1000;
133
143
  /** Split an engine server-event payload into its type + JSON body. */
134
144
  export function parseEngineEvent(bytes) {
135
145
  if (bytes.length < 2)
@@ -278,3 +288,39 @@ export function parseZoneChangeEvent(bytes) {
278
288
  body: parsed.body,
279
289
  };
280
290
  }
291
+ /** Parse an encounter event; null when the payload is another type. */
292
+ export function parseEncounterEvent(bytes) {
293
+ const parsed = parseEngineEvent(bytes);
294
+ if (!parsed || parsed.eventType !== EVENT_ENCOUNTER)
295
+ return null;
296
+ return {
297
+ kind: String(parsed.body.kind ?? ''),
298
+ encounterId: String(parsed.body.encounterId ?? ''),
299
+ wave: Number(parsed.body.wave ?? 0),
300
+ phase: Number(parsed.body.phase ?? 0),
301
+ body: parsed.body,
302
+ };
303
+ }
304
+ /** Parse a possession event; null when the payload is another type. */
305
+ export function parsePossessionEvent(bytes) {
306
+ const parsed = parseEngineEvent(bytes);
307
+ if (!parsed || parsed.eventType !== EVENT_POSSESSION)
308
+ return null;
309
+ return {
310
+ kind: String(parsed.body.kind ?? ''),
311
+ holderId: parsed.body.holderId != null ? String(parsed.body.holderId) : null,
312
+ team: parsed.body.team != null ? String(parsed.body.team) : null,
313
+ body: parsed.body,
314
+ };
315
+ }
316
+ /** Parse an emote; null when the payload is another type. */
317
+ export function parseEmoteEvent(bytes) {
318
+ const parsed = parseEngineEvent(bytes);
319
+ if (!parsed || parsed.eventType !== EVENT_EMOTE)
320
+ return null;
321
+ return {
322
+ emote: String(parsed.body.emote ?? ''),
323
+ targetUuid: parsed.body.targetUuid != null ? String(parsed.body.targetUuid) : null,
324
+ body: parsed.body,
325
+ };
326
+ }