@irtio/runtime 3.0.0 → 3.1.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.
@@ -3652,7 +3652,9 @@ function parseHibernationBlob(bytes) {
3652
3652
  const r = new ByteReader3(bytes);
3653
3653
  const version = r.u8();
3654
3654
  if (!READABLE_SNAPSHOT_VERSIONS.includes(version)) {
3655
- throw new Error(`RoomCore.restore: unsupported snapshot format version ${version}`);
3655
+ throw new Error(
3656
+ `RoomCore.restore: unsupported snapshot format version ${version} \u2014 this blob was written by a different irtio release`
3657
+ );
3656
3658
  }
3657
3659
  const seed = r.u32();
3658
3660
  const rngState = r.u32();
@@ -3,7 +3,7 @@ import {
3
3
  parseHibernationBlob,
4
4
  sameSchemaHash,
5
5
  writeHibernationBlob
6
- } from "./chunk-NPRIYYNM.js";
6
+ } from "./chunk-2L3RGWXM.js";
7
7
 
8
8
  // src/migrate.ts
9
9
  import { PRESENCE_COLLECTION, withBuiltins } from "@irtio/protocol";
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  fromMigrationState,
3
3
  migrateSnapshot,
4
4
  toMigrationState
5
- } from "./chunk-3BCTP4YS.js";
5
+ } from "./chunk-XPRLQCNF.js";
6
6
  import {
7
7
  AdmissionError,
8
8
  CRASH_AFTER_THROWS,
@@ -58,7 +58,7 @@ import {
58
58
  visibleNames,
59
59
  visibleTo,
60
60
  writeHibernationBlob
61
- } from "./chunk-NPRIYYNM.js";
61
+ } from "./chunk-2L3RGWXM.js";
62
62
  export {
63
63
  AdmissionError,
64
64
  CRASH_AFTER_THROWS,
@@ -148,16 +148,22 @@ declare class HarnessHost implements RoomHost {
148
148
  }[]>;
149
149
  private nextRecordingId;
150
150
  /**
151
- * D44: the in-process harness has no supervisor, no sockets and therefore no loopback session
152
- * to open. Recording the request rather than faking a session is the honest option: a test that
153
- * wants to see an NPC *play* needs a real tenant (`packages/supervisor/test/npc.test.ts`), and
154
- * one that wants to see a room ask for one reads these.
151
+ * D44: every NPC the room asked for, in order, and every despawn.
152
+ *
153
+ * On its own this host has no supervisor, no sockets and therefore no loopback session to open,
154
+ * so recording the request is all it can honestly do. A caller that *can* run an NPC — `testRoom`
155
+ * in `@irtio/testing`, which owns real in-process clients on this same clock — installs
156
+ * {@link onSpawnNpc} / {@link onDespawnNpc} and drives one. The arrays stay populated either way:
157
+ * a test that only wants to see that the room asked reads them, with or without a driver.
155
158
  */
156
159
  readonly spawnedNpcs: {
157
160
  clientId: string;
158
161
  config: NpcConfig;
159
162
  }[];
160
163
  readonly despawnedNpcs: string[];
164
+ /** Installed by a host embedder that can actually run an NPC session. */
165
+ onSpawnNpc: ((clientId: string, config: NpcConfig) => void) | undefined;
166
+ onDespawnNpc: ((clientId: string) => void) | undefined;
161
167
  spawnNpc(clientId: string, config: NpcConfig): void;
162
168
  despawnNpc(clientId: string): void;
163
169
  /** Every `room.bus.send` the room asked for, in order. */
@@ -5,7 +5,7 @@ import {
5
5
  initPhysics,
6
6
  initRapier2d,
7
7
  visibleNames
8
- } from "../chunk-NPRIYYNM.js";
8
+ } from "../chunk-2L3RGWXM.js";
9
9
 
10
10
  // src/test/clock.ts
11
11
  var FakeClock = class {
@@ -237,18 +237,26 @@ var HarnessHost = class {
237
237
  // Week 12: durable alarms (D26)
238
238
  // -------------------------------------------------------------------------
239
239
  /**
240
- * D44: the in-process harness has no supervisor, no sockets and therefore no loopback session
241
- * to open. Recording the request rather than faking a session is the honest option: a test that
242
- * wants to see an NPC *play* needs a real tenant (`packages/supervisor/test/npc.test.ts`), and
243
- * one that wants to see a room ask for one reads these.
240
+ * D44: every NPC the room asked for, in order, and every despawn.
241
+ *
242
+ * On its own this host has no supervisor, no sockets and therefore no loopback session to open,
243
+ * so recording the request is all it can honestly do. A caller that *can* run an NPC — `testRoom`
244
+ * in `@irtio/testing`, which owns real in-process clients on this same clock — installs
245
+ * {@link onSpawnNpc} / {@link onDespawnNpc} and drives one. The arrays stay populated either way:
246
+ * a test that only wants to see that the room asked reads them, with or without a driver.
244
247
  */
245
248
  spawnedNpcs = [];
246
249
  despawnedNpcs = [];
250
+ /** Installed by a host embedder that can actually run an NPC session. */
251
+ onSpawnNpc;
252
+ onDespawnNpc;
247
253
  spawnNpc(clientId, config) {
248
254
  this.spawnedNpcs.push({ clientId, config });
255
+ this.onSpawnNpc?.(clientId, config);
249
256
  }
250
257
  despawnNpc(clientId) {
251
258
  this.despawnedNpcs.push(clientId);
259
+ this.onDespawnNpc?.(clientId);
252
260
  }
253
261
  // -------------------------------------------------------------------------
254
262
  // D59: the bus
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  migrateSnapshot
3
- } from "../chunk-3BCTP4YS.js";
3
+ } from "../chunk-XPRLQCNF.js";
4
4
  import {
5
5
  AdmissionError,
6
6
  RoomCore,
@@ -10,7 +10,7 @@ import {
10
10
  initRapier2d,
11
11
  onFirstRapierStep,
12
12
  rapierHasStepped
13
- } from "../chunk-NPRIYYNM.js";
13
+ } from "../chunk-2L3RGWXM.js";
14
14
 
15
15
  // src/worker/index.ts
16
16
  import { getHeapStatistics } from "v8";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irtio/runtime",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "irtio room runtime: RoomCore, worker_threads host, in-process test harness",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,9 +36,9 @@
36
36
  "@dimforge/rapier2d-compat": "0.20.0",
37
37
  "@dimforge/rapier3d-compat": "0.20.0",
38
38
  "matter-js": "0.20.0",
39
- "@irtio/protocol": "3.0.0",
40
- "@irtio/schema": "3.0.0",
41
- "@irtio/server": "3.0.0"
39
+ "@irtio/protocol": "3.1.1",
40
+ "@irtio/schema": "3.1.1",
41
+ "@irtio/server": "3.1.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/matter-js": "0.20.2"