@bloopjs/web 0.0.67 → 0.0.69
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/App.d.ts +2 -2
- package/dist/App.d.ts.map +1 -1
- package/dist/mod.js +17 -19
- package/dist/mod.js.map +4 -4
- package/package.json +3 -3
- package/src/App.ts +9 -6
package/dist/App.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Bloop, type
|
|
1
|
+
import { type Bloop, type MountOptions, type Sim } from "@bloopjs/bloop";
|
|
2
2
|
import { DebugUi, type DebugUiOptions } from "./debugui/mod.ts";
|
|
3
3
|
import { type RoomEvents } from "./netcode/broker";
|
|
4
4
|
export type StartOptions = {
|
|
@@ -66,7 +66,7 @@ export declare class App {
|
|
|
66
66
|
* });
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
acceptHmr(module: any, opts?:
|
|
69
|
+
acceptHmr(module: any, opts?: MountOptions & {
|
|
70
70
|
files?: string[];
|
|
71
71
|
}): Promise<void>;
|
|
72
72
|
}
|
package/dist/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,EAEjB,KAAK,GAAG,EACT,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOhE,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,YAAY,GAAG;IACzB,4BAA4B;IAC5B,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,yEAAyE;IACzE,GAAG,CAAC,EAAE,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CAAC,CAAgC;IAExE,gEAAgE;IAChE,SAAS,IAAI,IAAI;IA6LjB,kDAAkD;IAClD,OAAO,IAAI,IAAI;IASf;;;;;;;;;;;;OAYG;IACG,SAAS,CACb,MAAM,EAAE,GAAG,EACX,IAAI,CAAC,EAAE,YAAY,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GACzC,OAAO,CAAC,IAAI,CAAC;CAuBjB;AAED,iBAAS,cAAc,CAAC,CAAC,SAAS,GAAG,EAAE,KAAK;IAC1C,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,KAAK,aAAa,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,cAAc,EAAE,aAAa,CAAC;CAC/B,CAuBA;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC"}
|
package/dist/mod.js
CHANGED
|
@@ -1427,9 +1427,9 @@ class Sim {
|
|
|
1427
1427
|
this.wasm.session_end();
|
|
1428
1428
|
}
|
|
1429
1429
|
}
|
|
1430
|
-
async function mount(
|
|
1431
|
-
const wasmUrl = options?.wasmUrl ??
|
|
1432
|
-
const startRecording = options?.startRecording ??
|
|
1430
|
+
async function mount(mountable, options) {
|
|
1431
|
+
const wasmUrl = options?.wasmUrl ?? DEFAULT_WASM_URL;
|
|
1432
|
+
const startRecording = options?.startRecording ?? true;
|
|
1433
1433
|
const { maxEvents, maxPacketBytes } = calculateTapeConfig(options?.tape);
|
|
1434
1434
|
const bytes = await fetch(wasmUrl).then((res) => res.arrayBuffer()).catch((e) => {
|
|
1435
1435
|
console.error(`Failed to fetch wasm at ${wasmUrl}`, e);
|
|
@@ -1441,14 +1441,14 @@ async function mount(opts, options) {
|
|
|
1441
1441
|
env: {
|
|
1442
1442
|
memory,
|
|
1443
1443
|
__systems: function(system_handle, ptr) {
|
|
1444
|
-
|
|
1445
|
-
|
|
1444
|
+
mountable.hooks.setBuffer(memory.buffer);
|
|
1445
|
+
mountable.hooks.systemsCallback(system_handle, ptr);
|
|
1446
1446
|
},
|
|
1447
1447
|
__before_frame: function(ptr, frame) {
|
|
1448
1448
|
try {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1449
|
+
mountable.hooks.setBuffer(memory.buffer);
|
|
1450
|
+
mountable.hooks.setContext(ptr);
|
|
1451
|
+
mountable.hooks.beforeFrame?.(frame);
|
|
1452
1452
|
} catch (e) {
|
|
1453
1453
|
console.error("Error in beforeFrame hook:", e);
|
|
1454
1454
|
}
|
|
@@ -1477,29 +1477,29 @@ async function mount(opts, options) {
|
|
|
1477
1477
|
console.log(string);
|
|
1478
1478
|
},
|
|
1479
1479
|
__user_data_len: function() {
|
|
1480
|
-
const serializer =
|
|
1480
|
+
const serializer = mountable.hooks.serialize();
|
|
1481
1481
|
return serializer ? serializer.size : 0;
|
|
1482
1482
|
},
|
|
1483
1483
|
user_data_serialize: function(ptr, len) {
|
|
1484
|
-
const serializer =
|
|
1484
|
+
const serializer = mountable.hooks.serialize();
|
|
1485
1485
|
assert(len === serializer.size, `user_data_serialize length mismatch, expected=${serializer.size} got=${len}`);
|
|
1486
1486
|
serializer.write(memory.buffer, ptr);
|
|
1487
1487
|
},
|
|
1488
1488
|
user_data_deserialize: function(ptr, len) {
|
|
1489
|
-
|
|
1489
|
+
mountable.hooks.deserialize(memory.buffer, ptr, len);
|
|
1490
1490
|
}
|
|
1491
1491
|
}
|
|
1492
1492
|
});
|
|
1493
1493
|
const wasm = wasmInstantiatedSource.instance.exports;
|
|
1494
1494
|
const enginePointer = wasm.initialize();
|
|
1495
1495
|
sim = new Sim(wasm, memory, {
|
|
1496
|
-
serialize:
|
|
1496
|
+
serialize: mountable.hooks.serialize
|
|
1497
1497
|
});
|
|
1498
1498
|
if (startRecording) {
|
|
1499
1499
|
sim.record(maxEvents, maxPacketBytes);
|
|
1500
1500
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1501
|
+
mountable.hooks.setBuffer(memory.buffer);
|
|
1502
|
+
mountable.hooks.setContext(enginePointer);
|
|
1503
1503
|
return {
|
|
1504
1504
|
sim
|
|
1505
1505
|
};
|
|
@@ -5899,8 +5899,7 @@ function joinRoom(brokerUrl, _roomId, cbs) {
|
|
|
5899
5899
|
var DEFAULT_BROKER_URL = "wss://webrtc-divine-glade-8064.fly.dev/ws";
|
|
5900
5900
|
async function start(opts) {
|
|
5901
5901
|
if (!opts.sim) {
|
|
5902
|
-
const { sim } = await mount({
|
|
5903
|
-
hooks: opts.game.hooks,
|
|
5902
|
+
const { sim } = await mount(opts.game, {
|
|
5904
5903
|
startRecording: opts.startRecording ?? true,
|
|
5905
5904
|
wasmUrl: opts.engineWasmUrl
|
|
5906
5905
|
});
|
|
@@ -6142,8 +6141,7 @@ class App {
|
|
|
6142
6141
|
throw new Error(`HMR: missing game.hooks export on module: ${JSON.stringify(module)}`);
|
|
6143
6142
|
}
|
|
6144
6143
|
this.sim.pause();
|
|
6145
|
-
const { sim } = await mount({
|
|
6146
|
-
hooks: game.hooks,
|
|
6144
|
+
const { sim } = await mount(game, {
|
|
6147
6145
|
wasmUrl: new URL("/bloop-wasm/bloop.wasm", window.location.href),
|
|
6148
6146
|
...opts
|
|
6149
6147
|
});
|
|
@@ -6309,5 +6307,5 @@ export {
|
|
|
6309
6307
|
App
|
|
6310
6308
|
};
|
|
6311
6309
|
|
|
6312
|
-
//# debugId=
|
|
6310
|
+
//# debugId=47EAAE8DC7343DDC64756E2164756E21
|
|
6313
6311
|
//# sourceMappingURL=mod.js.map
|