@bloopjs/web 0.0.59 → 0.0.60
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/mod.js +28 -13
- package/dist/mod.js.map +4 -4
- package/package.json +3 -3
package/dist/mod.js
CHANGED
|
@@ -126,6 +126,11 @@ var EventType;
|
|
|
126
126
|
EventType2[EventType2["MouseUp"] = 5] = "MouseUp";
|
|
127
127
|
EventType2[EventType2["MouseWheel"] = 6] = "MouseWheel";
|
|
128
128
|
EventType2[EventType2["FrameStart"] = 7] = "FrameStart";
|
|
129
|
+
EventType2[EventType2["SessionInit"] = 8] = "SessionInit";
|
|
130
|
+
EventType2[EventType2["SessionSetLocalPeer"] = 9] = "SessionSetLocalPeer";
|
|
131
|
+
EventType2[EventType2["SessionConnectPeer"] = 10] = "SessionConnectPeer";
|
|
132
|
+
EventType2[EventType2["SessionDisconnectPeer"] = 11] = "SessionDisconnectPeer";
|
|
133
|
+
EventType2[EventType2["SessionEnd"] = 12] = "SessionEnd";
|
|
129
134
|
})(EventType ||= {});
|
|
130
135
|
var MouseButton;
|
|
131
136
|
((MouseButton2) => {
|
|
@@ -1316,10 +1321,11 @@ class Sim {
|
|
|
1316
1321
|
copy.set(memoryView);
|
|
1317
1322
|
return copy;
|
|
1318
1323
|
}
|
|
1319
|
-
|
|
1324
|
+
static NETWORK_MAX_PACKET_BYTES = 2 * 1024 * 1024;
|
|
1325
|
+
record(maxEvents, maxPacketBytes) {
|
|
1320
1326
|
const serializer = this.#serialize ? this.#serialize() : null;
|
|
1321
1327
|
const size = serializer ? serializer.size : 0;
|
|
1322
|
-
const result = this.wasm.start_recording(size, maxEvents);
|
|
1328
|
+
const result = this.wasm.start_recording(size, maxEvents, maxPacketBytes);
|
|
1323
1329
|
if (result !== 0) {
|
|
1324
1330
|
throw new Error(`failed to start recording, error code=${result}`);
|
|
1325
1331
|
}
|
|
@@ -1417,12 +1423,12 @@ class Sim {
|
|
|
1417
1423
|
async function mount(opts, options) {
|
|
1418
1424
|
const wasmUrl = options?.wasmUrl ?? opts.wasmUrl ?? DEFAULT_WASM_URL;
|
|
1419
1425
|
const startRecording = options?.startRecording ?? opts.startRecording ?? true;
|
|
1420
|
-
const maxEvents =
|
|
1426
|
+
const { maxEvents, maxPacketBytes } = calculateTapeConfig(options?.tape);
|
|
1421
1427
|
const bytes = await fetch(wasmUrl).then((res) => res.arrayBuffer()).catch((e) => {
|
|
1422
1428
|
console.error(`Failed to fetch wasm at ${wasmUrl}`, e);
|
|
1423
1429
|
throw e;
|
|
1424
1430
|
});
|
|
1425
|
-
const memory = new WebAssembly.Memory({ initial:
|
|
1431
|
+
const memory = new WebAssembly.Memory({ initial: 310, maximum: 1000 });
|
|
1426
1432
|
let sim;
|
|
1427
1433
|
const wasmInstantiatedSource = await WebAssembly.instantiate(bytes, {
|
|
1428
1434
|
env: {
|
|
@@ -1483,7 +1489,7 @@ async function mount(opts, options) {
|
|
|
1483
1489
|
serialize: opts.hooks.serialize
|
|
1484
1490
|
});
|
|
1485
1491
|
if (startRecording) {
|
|
1486
|
-
sim.record(maxEvents);
|
|
1492
|
+
sim.record(maxEvents, maxPacketBytes);
|
|
1487
1493
|
}
|
|
1488
1494
|
opts.hooks.setBuffer(memory.buffer);
|
|
1489
1495
|
opts.hooks.setContext(enginePointer);
|
|
@@ -1491,14 +1497,18 @@ async function mount(opts, options) {
|
|
|
1491
1497
|
sim
|
|
1492
1498
|
};
|
|
1493
1499
|
}
|
|
1494
|
-
function
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1500
|
+
function calculateTapeConfig(tape) {
|
|
1501
|
+
let maxEvents;
|
|
1502
|
+
if (!tape) {
|
|
1503
|
+
maxEvents = 1024;
|
|
1504
|
+
} else if ("maxEvents" in tape) {
|
|
1505
|
+
maxEvents = tape.maxEvents;
|
|
1506
|
+
} else {
|
|
1507
|
+
const avgEvents = tape.averageEventsPerFrame ?? 2;
|
|
1508
|
+
maxEvents = Math.ceil(tape.duration * 60 * avgEvents);
|
|
1499
1509
|
}
|
|
1500
|
-
const
|
|
1501
|
-
return
|
|
1510
|
+
const maxPacketBytes = tape?.localOnly ? 0 : Sim.NETWORK_MAX_PACKET_BYTES;
|
|
1511
|
+
return { maxEvents, maxPacketBytes };
|
|
1502
1512
|
}
|
|
1503
1513
|
|
|
1504
1514
|
class Bloop {
|
|
@@ -1669,6 +1679,11 @@ var EventType2;
|
|
|
1669
1679
|
EventType22[EventType22["MouseUp"] = 5] = "MouseUp";
|
|
1670
1680
|
EventType22[EventType22["MouseWheel"] = 6] = "MouseWheel";
|
|
1671
1681
|
EventType22[EventType22["FrameStart"] = 7] = "FrameStart";
|
|
1682
|
+
EventType22[EventType22["SessionInit"] = 8] = "SessionInit";
|
|
1683
|
+
EventType22[EventType22["SessionSetLocalPeer"] = 9] = "SessionSetLocalPeer";
|
|
1684
|
+
EventType22[EventType22["SessionConnectPeer"] = 10] = "SessionConnectPeer";
|
|
1685
|
+
EventType22[EventType22["SessionDisconnectPeer"] = 11] = "SessionDisconnectPeer";
|
|
1686
|
+
EventType22[EventType22["SessionEnd"] = 12] = "SessionEnd";
|
|
1672
1687
|
})(EventType2 ||= {});
|
|
1673
1688
|
var MouseButton2;
|
|
1674
1689
|
((MouseButton22) => {
|
|
@@ -6064,5 +6079,5 @@ export {
|
|
|
6064
6079
|
App
|
|
6065
6080
|
};
|
|
6066
6081
|
|
|
6067
|
-
//# debugId=
|
|
6082
|
+
//# debugId=AC4FCA29BBBA9B7264756E2164756E21
|
|
6068
6083
|
//# sourceMappingURL=mod.js.map
|