@irtio/runtime 0.5.1 → 0.5.2

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.
@@ -65,8 +65,15 @@ type ToWorker = {
65
65
  } | {
66
66
  t: 'inspect';
67
67
  reqId: number;
68
- } | {
68
+ }
69
+ /**
70
+ * D36: `reqId` correlates the answer, so a caller can *await* one room's counters instead of
71
+ * waiting for a periodic push. Optional and echoed back when present, so a host that asks
72
+ * without one still gets the uncorrelated message it expects.
73
+ */
74
+ | {
69
75
  t: 'stats';
76
+ reqId?: number;
70
77
  }
71
78
  /**
72
79
  * Week 12: the supervisor answering a `hostCall` (a D24 save, a D25 KV operation). It arrives
@@ -160,6 +167,8 @@ type FromWorker = {
160
167
  rss: number;
161
168
  } | {
162
169
  t: 'stats';
170
+ /** Echoed from the request when it carried one (D36). */
171
+ reqId?: number;
163
172
  stats: Omit<RoomStats, 'bytesOutByClient'> & {
164
173
  bytesOutByClient: [string, number][];
165
174
  };
@@ -91,9 +91,13 @@ async function loadChain(steps) {
91
91
  }
92
92
  return out;
93
93
  }
94
- function statsPayload(stats) {
94
+ function statsPayload(stats, reqId) {
95
95
  const { bytesOutByClient, ...rest } = stats;
96
- return { t: "stats", stats: { ...rest, bytesOutByClient: [...bytesOutByClient.entries()] } };
96
+ return {
97
+ t: "stats",
98
+ ...reqId !== void 0 ? { reqId } : {},
99
+ stats: { ...rest, bytesOutByClient: [...bytesOutByClient.entries()] }
100
+ };
97
101
  }
98
102
  async function handleMessage(state, host, post, msg) {
99
103
  try {
@@ -256,7 +260,7 @@ async function handleMessage(state, host, post, msg) {
256
260
  case "stats": {
257
261
  const core = state.core;
258
262
  if (!core) return;
259
- post(statsPayload(core.stats));
263
+ post(statsPayload(core.stats, msg.reqId));
260
264
  return;
261
265
  }
262
266
  case "hostResult": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irtio/runtime",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "irtio room runtime: RoomCore, worker_threads host, in-process test harness",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -29,9 +29,9 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@dimforge/rapier3d-compat": "0.20.0",
32
- "@irtio/schema": "0.5.1",
33
- "@irtio/server": "0.5.1",
34
- "@irtio/protocol": "0.5.1"
32
+ "@irtio/protocol": "0.5.2",
33
+ "@irtio/schema": "0.5.2",
34
+ "@irtio/server": "0.5.2"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsup",