@irtio/runtime 0.10.1 → 1.0.0
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.
- package/dist/{chunk-EENJ37KK.js → chunk-LT46QFLW.js} +1626 -108
- package/dist/{chunk-WNAEE4EP.js → chunk-YWDRE77H.js} +1 -1
- package/dist/{contract-C5aqs49-.d.ts → contract-UEKTud1Z.d.ts} +145 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +12 -2
- package/dist/{room-Db3iPBKM.d.ts → room-uhj3b-8E.d.ts} +32 -2
- package/dist/test/index.d.ts +32 -38
- package/dist/test/index.js +77 -4
- package/dist/worker/index.d.ts +37 -3
- package/dist/worker/index.js +34 -3
- package/package.json +4 -4
package/dist/worker/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
migrateSnapshot
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-YWDRE77H.js";
|
|
4
4
|
import {
|
|
5
5
|
RoomCore,
|
|
6
6
|
RoomFullError,
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
initRapier2d,
|
|
10
10
|
onFirstRapierStep,
|
|
11
11
|
rapierHasStepped
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-LT46QFLW.js";
|
|
13
13
|
|
|
14
14
|
// src/worker/index.ts
|
|
15
15
|
import { getHeapStatistics } from "v8";
|
|
16
|
-
import { isMainThread, parentPort } from "worker_threads";
|
|
16
|
+
import { isMainThread, parentPort, workerData } from "worker_threads";
|
|
17
17
|
import { isRoomDefinition } from "@irtio/server";
|
|
18
18
|
|
|
19
19
|
// src/worker/protocol.ts
|
|
@@ -352,6 +352,11 @@ async function handleMessage(state, host, post, msg) {
|
|
|
352
352
|
state.core?.fireAlarm(msg.name);
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
+
case "platformNotice": {
|
|
356
|
+
const broadcast = state.core?.deliverPlatformNotice(msg.notice) ?? true;
|
|
357
|
+
post({ t: "platformNoticeResult", reqId: msg.reqId, broadcast });
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
355
360
|
case "busEvent": {
|
|
356
361
|
state.core?.deliverBusEvent(msg.channel, msg.from, msg.payload);
|
|
357
362
|
return;
|
|
@@ -390,7 +395,32 @@ async function handleMessage(state, host, post, msg) {
|
|
|
390
395
|
});
|
|
391
396
|
}
|
|
392
397
|
}
|
|
398
|
+
function seedMathRandom(seedHex) {
|
|
399
|
+
if (!/^[0-9a-f]{32}$/.test(seedHex)) return;
|
|
400
|
+
const u32 = (i) => Number.parseInt(seedHex.slice(i * 8, i * 8 + 8), 16) >>> 0;
|
|
401
|
+
let a = u32(0);
|
|
402
|
+
let b = u32(1);
|
|
403
|
+
let c = u32(2);
|
|
404
|
+
let d = u32(3);
|
|
405
|
+
const sfc32 = () => {
|
|
406
|
+
a >>>= 0;
|
|
407
|
+
b >>>= 0;
|
|
408
|
+
c >>>= 0;
|
|
409
|
+
d >>>= 0;
|
|
410
|
+
const t = a + b + d >>> 0;
|
|
411
|
+
d = d + 1 >>> 0;
|
|
412
|
+
a = b ^ b >>> 9;
|
|
413
|
+
b = c + (c << 3) >>> 0;
|
|
414
|
+
c = (c << 21 | c >>> 11) >>> 0;
|
|
415
|
+
c = c + t >>> 0;
|
|
416
|
+
return t / 4294967296;
|
|
417
|
+
};
|
|
418
|
+
for (let i = 0; i < 12; i++) sfc32();
|
|
419
|
+
Math.random = sfc32;
|
|
420
|
+
}
|
|
393
421
|
if (!isMainThread && parentPort) {
|
|
422
|
+
const seed = workerData?.mathRandomSeed;
|
|
423
|
+
if (typeof seed === "string") seedMathRandom(seed);
|
|
394
424
|
const port = parentPort;
|
|
395
425
|
const post = (msg, transfer) => {
|
|
396
426
|
port.postMessage(msg, transfer ?? transferList(msg));
|
|
@@ -404,5 +434,6 @@ if (!isMainThread && parentPort) {
|
|
|
404
434
|
export {
|
|
405
435
|
createWorkerHost,
|
|
406
436
|
handleMessage,
|
|
437
|
+
seedMathRandom,
|
|
407
438
|
transferList
|
|
408
439
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@irtio/runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "irtio room runtime: RoomCore, worker_threads host, in-process test harness",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@dimforge/rapier2d-compat": "0.20.0",
|
|
32
32
|
"@dimforge/rapier3d-compat": "0.20.0",
|
|
33
33
|
"matter-js": "0.20.0",
|
|
34
|
-
"@irtio/protocol": "0.
|
|
35
|
-
"@irtio/schema": "0.
|
|
36
|
-
"@irtio/server": "0.
|
|
34
|
+
"@irtio/protocol": "1.0.0",
|
|
35
|
+
"@irtio/schema": "1.0.0",
|
|
36
|
+
"@irtio/server": "1.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/matter-js": "0.20.2"
|