@crowdedkingdoms/crowdyjs 17.6.0-test.1 → 17.7.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 (86) hide show
  1. package/MIGRATION.md +41 -0
  2. package/README.md +33 -0
  3. package/dist/client.d.ts +7 -0
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +2 -1
  6. package/dist/crowdy-client.d.ts +24 -0
  7. package/dist/crowdy-client.d.ts.map +1 -1
  8. package/dist/crowdy-client.js +16 -0
  9. package/dist/crowdy-dsh/bridge.d.ts +24 -1
  10. package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
  11. package/dist/crowdy-dsh/bridge.js +32 -0
  12. package/dist/crowdy-dsh/index.d.ts +1 -1
  13. package/dist/crowdy-dsh/index.d.ts.map +1 -1
  14. package/dist/crowdy-dsh/protocol.d.ts +64 -1
  15. package/dist/crowdy-dsh/protocol.d.ts.map +1 -1
  16. package/dist/crowdy-dsh/protocol.js +8 -1
  17. package/dist/crowdy-studio/starter-projects.js +1 -1
  18. package/dist/default-origin.d.ts +6 -6
  19. package/dist/default-origin.d.ts.map +1 -1
  20. package/dist/default-origin.js +6 -6
  21. package/dist/domains/actors.d.ts +38 -17
  22. package/dist/domains/actors.d.ts.map +1 -1
  23. package/dist/domains/actors.js +38 -17
  24. package/dist/domains/crowdyStudio.js +1 -1
  25. package/dist/domains/grids.d.ts +30 -0
  26. package/dist/domains/grids.d.ts.map +1 -0
  27. package/dist/domains/grids.js +39 -0
  28. package/dist/domains/udp.d.ts +5 -1
  29. package/dist/domains/udp.d.ts.map +1 -1
  30. package/dist/domains/udp.js +5 -1
  31. package/dist/generated/graphql.d.ts +169 -9
  32. package/dist/generated/graphql.d.ts.map +1 -1
  33. package/dist/generated/graphql.js +13 -10
  34. package/dist/grid-mods/grid-host-calls.d.ts +70 -0
  35. package/dist/grid-mods/grid-host-calls.d.ts.map +1 -0
  36. package/dist/grid-mods/grid-host-calls.js +220 -0
  37. package/dist/grid-mods/index.d.ts +3 -0
  38. package/dist/grid-mods/index.d.ts.map +1 -0
  39. package/dist/grid-mods/index.js +2 -0
  40. package/dist/grid-mods/mod-runtime.d.ts +52 -0
  41. package/dist/grid-mods/mod-runtime.d.ts.map +1 -0
  42. package/dist/grid-mods/mod-runtime.js +55 -0
  43. package/dist/grid-program/host.d.ts +88 -0
  44. package/dist/grid-program/host.d.ts.map +1 -0
  45. package/dist/grid-program/host.js +231 -0
  46. package/dist/grid-program/index.d.ts +14 -0
  47. package/dist/grid-program/index.d.ts.map +1 -0
  48. package/dist/grid-program/index.js +13 -0
  49. package/dist/grid-program/program.d.ts +19 -0
  50. package/dist/grid-program/program.d.ts.map +1 -0
  51. package/dist/grid-program/program.js +154 -0
  52. package/dist/grid-program/protocol.d.ts +87 -0
  53. package/dist/grid-program/protocol.d.ts.map +1 -0
  54. package/dist/grid-program/protocol.js +17 -0
  55. package/dist/grid-scope.d.ts +296 -0
  56. package/dist/grid-scope.d.ts.map +1 -0
  57. package/dist/grid-scope.js +183 -0
  58. package/dist/index.d.ts +7 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +7 -2
  61. package/dist/kit/matches.d.ts +1 -0
  62. package/dist/kit/matches.d.ts.map +1 -1
  63. package/dist/kit/npcs.d.ts.map +1 -1
  64. package/dist/kit/social.d.ts.map +1 -1
  65. package/dist/live-coding/assets/browser-authoring-index.json +1 -1
  66. package/dist/live-coding/assets/manifest.json +1 -1
  67. package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
  68. package/dist/live-coding/browser-authoring-index.generated.js +118 -6
  69. package/dist/player-runtime/client-grid-event-bus.d.ts +37 -0
  70. package/dist/player-runtime/client-grid-event-bus.d.ts.map +1 -0
  71. package/dist/player-runtime/client-grid-event-bus.js +56 -0
  72. package/dist/player-runtime/glue-runtime.d.ts +4 -2
  73. package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
  74. package/dist/player-runtime/glue-runtime.js +20 -23
  75. package/dist/player-runtime/host-catalog.generated.d.ts +16 -0
  76. package/dist/player-runtime/host-catalog.generated.d.ts.map +1 -0
  77. package/dist/player-runtime/host-catalog.generated.js +296 -0
  78. package/dist/player-runtime/player-code-broker.d.ts +38 -0
  79. package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
  80. package/dist/player-runtime/player-code-broker.js +116 -35
  81. package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
  82. package/dist/player-runtime/player-glue-worker.js +5 -0
  83. package/dist/realtime.d.ts +7 -0
  84. package/dist/realtime.d.ts.map +1 -1
  85. package/dist/realtime.js +3 -1
  86. package/package.json +10 -3
@@ -12,7 +12,7 @@
12
12
  },
13
13
  {
14
14
  "name": "browser-authoring-index.json",
15
- "bytes": 140085,
15
+ "bytes": 144927,
16
16
  "provenance": "cks-game-api generated browser authoring index"
17
17
  }
18
18
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"browser-authoring-index.generated.d.ts","sourceRoot":"","sources":["../../src/live-coding/browser-authoring-index.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iCAAiC,EAAE,OAqgK/C,CAAC"}
1
+ {"version":3,"file":"browser-authoring-index.generated.d.ts","sourceRoot":"","sources":["../../src/live-coding/browser-authoring-index.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iCAAiC,EAAE,OAqnK/C,CAAC"}
@@ -2,9 +2,9 @@
2
2
  export const GENERATED_BROWSER_AUTHORING_INDEX = {
3
3
  "schemaVersion": 2,
4
4
  "rustVersion": "1.97.1",
5
- "sdkVersion": "0.1.5",
5
+ "sdkVersion": "0.1.6",
6
6
  "abiVersion": 0,
7
- "contentHash": "3f5f39d46f732a346033aaf2435528a183e2ab0d0e3691f29c3fa3ecada18ffb",
7
+ "contentHash": "403558606363e0ed9227513fb31aacacad18d4215843321f7d7874370ff8702e",
8
8
  "crates": [
9
9
  {
10
10
  "name": "alloc",
@@ -18,8 +18,8 @@ export const GENERATED_BROWSER_AUTHORING_INDEX = {
18
18
  },
19
19
  {
20
20
  "name": "crowdy-compute-sdk",
21
- "version": "0.1.5",
22
- "sourceHash": "a43147b89a4ec0ca03cc1e7d15a7cc858df36faa2f1f486cb536342155615852"
21
+ "version": "0.1.6",
22
+ "sourceHash": "33e063cbb758695b01ea2cce6f9d1b7b12878d939b231f3b9cb4905bb8b879b0"
23
23
  },
24
24
  {
25
25
  "name": "crowdy-game-kit-ai",
@@ -29,7 +29,7 @@ export const GENERATED_BROWSER_AUTHORING_INDEX = {
29
29
  {
30
30
  "name": "crowdy-game-kit-core",
31
31
  "version": "0.1.0",
32
- "sourceHash": "9750b5294348076d2b75cc67229cdb9e198ed6c2fbc4d76adc063e7124c9e84d"
32
+ "sourceHash": "25e6bd39c2fe668915f58af556e5346fac46a4bff4c512cab76f6f54176ae988"
33
33
  },
34
34
  {
35
35
  "name": "crowdy-game-kit-econ",
@@ -508,7 +508,14 @@ export const GENERATED_BROWSER_AUTHORING_INDEX = {
508
508
  "name": "emit_event",
509
509
  "kind": "function",
510
510
  "signature": "pub fn emit_event(name: &str, payload: Value) -> Result<Value, HostError>",
511
- "docs": "Emit a compute event other modules (or this one) can subscribe to via an on_event=compute_event trigger. Cascade depth is host-bounded."
511
+ "docs": "Emit a compute event. Studio modules publish on the app event bus (on_event=compute_event triggers); player modules publish on their grid's bus, which reaches the other modules on the same grid (on_event=grid_event) and Studio modules that opted in with a grid_event trigger. Cascade depth is host-bounded; nothing reaches a client."
512
+ },
513
+ {
514
+ "module": "crowdy_compute_sdk::api",
515
+ "name": "emit_event_to",
516
+ "kind": "function",
517
+ "signature": "pub fn emit_event_to(target: &str, name: &str, payload: Value) -> Result<Value, HostError>",
518
+ "docs": "Address one module by name on the same bus (on a grid: a module on the same grid, itself included). Delivered through its `on_event` whether or not it subscribed to `name`."
512
519
  },
513
520
  {
514
521
  "module": "crowdy_compute_sdk::api",
@@ -552,6 +559,13 @@ export const GENERATED_BROWSER_AUTHORING_INDEX = {
552
559
  "signature": "pub fn model_invoke_with_world( function_name: &str, self_container_id: &str, params: Value, session_id: Option<&str>, caller_user_id: Option<&str>, world_writes: &[WorldWrite], ) -> Result<Value, HostError>",
553
560
  "docs": "`model_invoke` with atomic world writes: the voxel writes and the Model function's mutations commit in ONE transaction — if either side fails, both roll back. Use for referee actions that change the world and the ledger together (mine/place). Up to 16 writes per call; each write charges a db op. Requires SDK 0.1.4+ on the host."
554
561
  },
562
+ {
563
+ "module": "crowdy_compute_sdk::api",
564
+ "name": "pointer_clicks",
565
+ "kind": "function",
566
+ "signature": "pub fn pointer_clicks() -> Result<Value, HostError>",
567
+ "docs": "Drain queued holodeck mouse clicks since the last call (CLIENT). Returns `{ nowMs, buttons, holdingMs, clicks }`. `buttons` is the live `MouseEvent.buttons` bitfield (1 = left held). `holdingMs` maps button index → milliseconds already held (`\"0\"` = left). `clicks` is drained: `{ t: \"down\"|\"up\", button, atMs, heldMs?, nx, ny }` with canvas NDC (`nx`/`ny` in −1..1, +ny up). Studio chrome is omitted. Call every `on_tick`. Click-to-charge: start on left `down`, read `holdingMs[\"0\"]` for the power bar, fire on left `up` using `heldMs`."
568
+ },
555
569
  {
556
570
  "module": "crowdy_compute_sdk::api",
557
571
  "name": "property_set",
@@ -1196,6 +1210,13 @@ export const GENERATED_BROWSER_AUTHORING_INDEX = {
1196
1210
  "signature": "pub mod events;",
1197
1211
  "docs": ""
1198
1212
  },
1213
+ {
1214
+ "module": "crowdy_game_kit_core",
1215
+ "name": "grid",
1216
+ "kind": "module",
1217
+ "signature": "pub mod grid;",
1218
+ "docs": ""
1219
+ },
1199
1220
  {
1200
1221
  "module": "crowdy_game_kit_core",
1201
1222
  "name": "invoke",
@@ -1469,6 +1490,97 @@ export const GENERATED_BROWSER_AUTHORING_INDEX = {
1469
1490
  "signature": "pub fn encode_event(event_type: u16, state: &[u8]) -> Vec<u8>",
1470
1491
  "docs": ""
1471
1492
  },
1493
+ {
1494
+ "module": "crowdy_game_kit_core::grid",
1495
+ "name": "GridEvent",
1496
+ "kind": "struct",
1497
+ "signature": "pub struct GridEvent { /// The grid whose bus carried it (`None` on a grid: it is always your own). pub grid_id: Option<String>, /// The grid's owner (Studio side only). pub owner_user_id: Option<String>, pub event_name: String, /// Module that published it, when the platform names one. pub source_module: Option<String>, /// Set when the publisher addressed one module by name. pub target: Option<String>, pub payload: Value, pub cascade_depth: u32, }",
1498
+ "docs": "A grid-bus event as a module's `on_event` receives it."
1499
+ },
1500
+ {
1501
+ "module": "crowdy_game_kit_core::grid",
1502
+ "name": "GridEvent::cascade_depth",
1503
+ "kind": "field",
1504
+ "signature": "pub cascade_depth: u32",
1505
+ "docs": ""
1506
+ },
1507
+ {
1508
+ "module": "crowdy_game_kit_core::grid",
1509
+ "name": "GridEvent::event_name",
1510
+ "kind": "field",
1511
+ "signature": "pub event_name: String",
1512
+ "docs": ""
1513
+ },
1514
+ {
1515
+ "module": "crowdy_game_kit_core::grid",
1516
+ "name": "GridEvent::grid_id",
1517
+ "kind": "field",
1518
+ "signature": "pub grid_id: Option<String>",
1519
+ "docs": "The grid whose bus carried it (`None` on a grid: it is always your own)."
1520
+ },
1521
+ {
1522
+ "module": "crowdy_game_kit_core::grid",
1523
+ "name": "GridEvent::owner_user_id",
1524
+ "kind": "field",
1525
+ "signature": "pub owner_user_id: Option<String>",
1526
+ "docs": "The grid's owner (Studio side only)."
1527
+ },
1528
+ {
1529
+ "module": "crowdy_game_kit_core::grid",
1530
+ "name": "GridEvent::payload",
1531
+ "kind": "field",
1532
+ "signature": "pub payload: Value",
1533
+ "docs": ""
1534
+ },
1535
+ {
1536
+ "module": "crowdy_game_kit_core::grid",
1537
+ "name": "GridEvent::source_module",
1538
+ "kind": "field",
1539
+ "signature": "pub source_module: Option<String>",
1540
+ "docs": "Module that published it, when the platform names one."
1541
+ },
1542
+ {
1543
+ "module": "crowdy_game_kit_core::grid",
1544
+ "name": "GridEvent::target",
1545
+ "kind": "field",
1546
+ "signature": "pub target: Option<String>",
1547
+ "docs": "Set when the publisher addressed one module by name."
1548
+ },
1549
+ {
1550
+ "module": "crowdy_game_kit_core::grid",
1551
+ "name": "decode",
1552
+ "kind": "function",
1553
+ "signature": "pub fn decode(body: &[u8]) -> Option<GridEvent>",
1554
+ "docs": "Decode an `on_event` body. Returns `None` for any other event kind. Two shapes carry grid events: a player module gets the player-plane event (`kind: \"grid_event\"`, with `eventName`, `sourceModuleName`, `targetModuleName`, `payload`), and a Studio module gets the app-plane one (`event: \"grid_event\"`, `eventName`, and `payload: { gridId, ownerUserId, sourceModule, payload }`)."
1555
+ },
1556
+ {
1557
+ "module": "crowdy_game_kit_core::grid",
1558
+ "name": "post",
1559
+ "kind": "function",
1560
+ "signature": "pub fn post(channel_id: &str, bytes: &[u8]) -> Result<Value, HostError>",
1561
+ "docs": "Post raw bytes into a grid channel. The platform stamps the sender uuid as `grid:<gridId>`; a channel of another grid is `unavailable`."
1562
+ },
1563
+ {
1564
+ "module": "crowdy_game_kit_core::grid",
1565
+ "name": "post_json",
1566
+ "kind": "function",
1567
+ "signature": "pub fn post_json(channel_id: &str, message: &Value) -> Result<Value, HostError>",
1568
+ "docs": "Post a JSON message into a grid channel."
1569
+ },
1570
+ {
1571
+ "module": "crowdy_game_kit_core::grid",
1572
+ "name": "publish",
1573
+ "kind": "function",
1574
+ "signature": "pub fn publish(name: &str, payload: Value) -> Result<Value, HostError>",
1575
+ "docs": "Publish `name` on this grid's bus: every other module on the grid with a `grid_event` subscription to it (or to `*`), and any Studio module that opted in. Never another grid, never a client."
1576
+ },
1577
+ {
1578
+ "module": "crowdy_game_kit_core::grid",
1579
+ "name": "send_to",
1580
+ "kind": "function",
1581
+ "signature": "pub fn send_to(module: &str, name: &str, payload: Value) -> Result<Value, HostError>",
1582
+ "docs": "Deliver `name` to one module on this grid (itself included), whether or not it subscribed to `name`."
1583
+ },
1472
1584
  {
1473
1585
  "module": "crowdy_game_kit_core::invoke",
1474
1586
  "name": "InvokeCtx",
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The page-local half of the grid event bus (DN-10 §4). A CLIENT mod's
3
+ * `emit_event(name, payload, target?)` never leaves the page: it reaches the
4
+ * other client mods running on the SAME grid in this browser, through their
5
+ * `on_event` export. A mod on another grid never sees it, and neither does the
6
+ * server (server mods have their own grid bus, reached by server code).
7
+ */
8
+ /** What a subscribed mod receives in `on_event` (JSON-encoded). */
9
+ export interface ClientGridEvent {
10
+ kind: 'grid_event';
11
+ gridId: string;
12
+ eventName: string;
13
+ payload: unknown;
14
+ sourceModule: string | null;
15
+ /** Set when the emitter addressed one module by name. */
16
+ target: string | null;
17
+ /** Hops since the originating dispatch; the bus drops anything past the cap. */
18
+ cascadeDepth: number;
19
+ }
20
+ export interface ClientGridEventSubscriber {
21
+ moduleName: string | null;
22
+ deliver(event: ClientGridEvent): boolean;
23
+ }
24
+ /** Same ceiling as the server event buses. */
25
+ export declare const CLIENT_GRID_EVENT_MAX_CASCADE = 8;
26
+ export declare class ClientGridEventBus {
27
+ private readonly byGrid;
28
+ subscribe(gridId: string, subscriber: ClientGridEventSubscriber): () => void;
29
+ /**
30
+ * Deliver to every subscriber on `event.gridId` except the sender (unless
31
+ * the sender addressed itself). Returns how many mods accepted it.
32
+ */
33
+ publish(event: ClientGridEvent, sender?: ClientGridEventSubscriber): number;
34
+ }
35
+ /** The bus every broker joins unless it is given its own (or `null`). */
36
+ export declare const defaultClientGridEventBus: ClientGridEventBus;
37
+ //# sourceMappingURL=client-grid-event-bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-grid-event-bus.d.ts","sourceRoot":"","sources":["../../src/player-runtime/client-grid-event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,yDAAyD;IACzD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC;CAC1C;AAED,8CAA8C;AAC9C,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqD;IAE5E,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,yBAAyB,GAAG,MAAM,IAAI;IAe5E;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,yBAAyB,GAAG,MAAM;CAe5E;AAED,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,oBAA2B,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The page-local half of the grid event bus (DN-10 §4). A CLIENT mod's
3
+ * `emit_event(name, payload, target?)` never leaves the page: it reaches the
4
+ * other client mods running on the SAME grid in this browser, through their
5
+ * `on_event` export. A mod on another grid never sees it, and neither does the
6
+ * server (server mods have their own grid bus, reached by server code).
7
+ */
8
+ /** Same ceiling as the server event buses. */
9
+ export const CLIENT_GRID_EVENT_MAX_CASCADE = 8;
10
+ export class ClientGridEventBus {
11
+ constructor() {
12
+ this.byGrid = new Map();
13
+ }
14
+ subscribe(gridId, subscriber) {
15
+ let set = this.byGrid.get(gridId);
16
+ if (!set) {
17
+ set = new Set();
18
+ this.byGrid.set(gridId, set);
19
+ }
20
+ set.add(subscriber);
21
+ return () => {
22
+ const current = this.byGrid.get(gridId);
23
+ if (!current)
24
+ return;
25
+ current.delete(subscriber);
26
+ if (current.size === 0)
27
+ this.byGrid.delete(gridId);
28
+ };
29
+ }
30
+ /**
31
+ * Deliver to every subscriber on `event.gridId` except the sender (unless
32
+ * the sender addressed itself). Returns how many mods accepted it.
33
+ */
34
+ publish(event, sender) {
35
+ if (event.cascadeDepth > CLIENT_GRID_EVENT_MAX_CASCADE)
36
+ return 0;
37
+ const set = this.byGrid.get(event.gridId);
38
+ if (!set)
39
+ return 0;
40
+ let delivered = 0;
41
+ for (const subscriber of [...set]) {
42
+ if (event.target !== null) {
43
+ if (subscriber.moduleName !== event.target)
44
+ continue;
45
+ }
46
+ else if (subscriber === sender) {
47
+ continue;
48
+ }
49
+ if (subscriber.deliver(event))
50
+ delivered += 1;
51
+ }
52
+ return delivered;
53
+ }
54
+ }
55
+ /** The bus every broker joins unless it is given its own (or `null`). */
56
+ export const defaultClientGridEventBus = new ClientGridEventBus();
@@ -19,8 +19,8 @@
19
19
  * (the worker blocks; the page/broker services the async SDK call and writes
20
20
  * the reply back). Everything else here is pure.
21
21
  */
22
- /** The host-call names surfaced to a guest (mirrors the broker allowlist). */
23
- export declare const GLUE_HOST_FUNCTIONS: readonly ["container_create", "container_get", "containers_list", "container_delete", "property_set", "model_invoke", "user_state_get", "user_state_set", "grid_state_get", "grid_state_set", "chunk_get", "voxels_list", "actors_list", "actors_list_radius", "voxel_set", "emit_spatial", "hud_set", "overlay_draw", "pointer_clicks", "grid_permission_check"];
22
+ /** The host-call names surfaced to a guest: the client half of the host catalog (the broker allowlist). */
23
+ export declare const GLUE_HOST_FUNCTIONS: readonly string[];
24
24
  export interface GlueInitMessage {
25
25
  type: 'init';
26
26
  artifact: ArrayBuffer;
@@ -95,6 +95,8 @@ export declare class GlueRuntime {
95
95
  init(): void;
96
96
  /** Run one `tick(dt_ms)`. Throws propagate to the caller's watchdog wrapper. */
97
97
  tick(dtMs: number): void;
98
+ /** Deliver one grid event to `on_event`; a module without the export ignores it. */
99
+ event(payload: Uint8Array): void;
98
100
  /** Invoke the module with an opaque payload; returns the reply bytes (copied out). */
99
101
  invoke(payload: Uint8Array): Uint8Array;
100
102
  }
@@ -1 +1 @@
1
- {"version":3,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IAAI;IAchC,sFAAsF;IACtF,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;CAuBxC"}
@@ -19,29 +19,11 @@
19
19
  * (the worker blocks; the page/broker services the async SDK call and writes
20
20
  * the reply back). Everything else here is pure.
21
21
  */
22
- /** The host-call names surfaced to a guest (mirrors the broker allowlist). */
23
- export const GLUE_HOST_FUNCTIONS = [
24
- 'container_create',
25
- 'container_get',
26
- 'containers_list',
27
- 'container_delete',
28
- 'property_set',
29
- 'model_invoke',
30
- 'user_state_get',
31
- 'user_state_set',
32
- 'grid_state_get',
33
- 'grid_state_set',
34
- 'chunk_get',
35
- 'voxels_list',
36
- 'actors_list',
37
- 'actors_list_radius',
38
- 'voxel_set',
39
- 'emit_spatial',
40
- 'hud_set',
41
- 'overlay_draw',
42
- 'pointer_clicks',
43
- 'grid_permission_check',
44
- ];
22
+ import { GENERATED_HOST_CATALOG } from './host-catalog.generated.js';
23
+ /** The host-call names surfaced to a guest: the client half of the host catalog (the broker allowlist). */
24
+ export const GLUE_HOST_FUNCTIONS = GENERATED_HOST_CATALOG.functions
25
+ .filter((fn) => fn.targets.includes('client'))
26
+ .map((fn) => fn.name);
45
27
  /**
46
28
  * Parse the server-authored budget used to refill an instrumented artifact's
47
29
  * mutable `ck_fuel` global before every guest dispatch.
@@ -238,6 +220,21 @@ export class GlueRuntime {
238
220
  this.resetFuel();
239
221
  this.exports?.tick?.(dtMs);
240
222
  }
223
+ /** Deliver one grid event to `on_event`; a module without the export ignores it. */
224
+ event(payload) {
225
+ const ex = this.exports;
226
+ if (!ex || typeof ex.on_event !== 'function')
227
+ return;
228
+ const ptr = ex.ck_alloc(payload.length);
229
+ if (payload.length > 0 && ptr === 0) {
230
+ throw new RangeError('ck_alloc returned a null event pointer');
231
+ }
232
+ assertMemoryRange(ex.memory.buffer, ptr, payload.length, 'event write');
233
+ new Uint8Array(ex.memory.buffer, ptr, payload.length).set(payload);
234
+ this.resetFuel();
235
+ ex.on_event(ptr, payload.length);
236
+ ex.ck_free?.(ptr, payload.length);
237
+ }
241
238
  /** Invoke the module with an opaque payload; returns the reply bytes (copied out). */
242
239
  invoke(payload) {
243
240
  const ex = this.exports;
@@ -0,0 +1,16 @@
1
+ export interface HostCatalogFunction {
2
+ name: string;
3
+ group: string;
4
+ targets: ReadonlyArray<'server' | 'client'>;
5
+ egress?: boolean;
6
+ app: string;
7
+ grid: string;
8
+ }
9
+ export interface HostCatalog {
10
+ catalogVersion: number;
11
+ description: string;
12
+ groups: Readonly<Record<string, string>>;
13
+ functions: ReadonlyArray<HostCatalogFunction>;
14
+ }
15
+ export declare const GENERATED_HOST_CATALOG: HostCatalog;
16
+ //# sourceMappingURL=host-catalog.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-catalog.generated.d.ts","sourceRoot":"","sources":["../../src/player-runtime/host-catalog.generated.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzC,SAAS,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,sBAAsB,EAAE,WAuSpC,CAAC"}