@bloopjs/web 0.0.89 → 0.0.90
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.map +1 -1
- package/dist/mod.js +151 -7
- package/dist/mod.js.map +5 -5
- package/package.json +3 -3
- package/src/App.ts +60 -0
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,EACL,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,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;AAI1B,MAAM,MAAM,YAAY,GAAG;IACzB,4BAA4B;IAC5B,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,yEAAyE;IACzE,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,sDAAsD;IACtD,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,qFAAqF;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wFAAwF;IACxF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAIF,oCAAoC;AACpC,wBAAsB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAuB5D;AAED;;;;;;GAMG;AACH,qBAAa,GAAG;;IAEd,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC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AC,OAAO,cAAc,CAAC,CAA8B;IAC5E,qDAAqD;IACrD,UAAU,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAA8B;IAC3E,qCAAqC;IACrC,KAAK,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAgC;IAExE,gEAAgE;IAChE,SAAS,IAAI,IAAI;IA4PjB,kDAAkD;IAClD,OAAO,IAAI,IAAI;IAUf;;;;;;;;;;;;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
|
@@ -77,9 +77,11 @@ __export2(exports_engine, {
|
|
|
77
77
|
inputSourceCodeToInputSource: () => inputSourceCodeToInputSource,
|
|
78
78
|
TimeContext: () => TimeContext,
|
|
79
79
|
TIME_CTX_OFFSET: () => TIME_CTX_OFFSET,
|
|
80
|
+
ScreenContext: () => ScreenContext,
|
|
80
81
|
SNAPSHOT_HEADER_USER_LEN_OFFSET: () => SNAPSHOT_HEADER_USER_LEN_OFFSET,
|
|
81
82
|
SNAPSHOT_HEADER_LEN: () => SNAPSHOT_HEADER_LEN,
|
|
82
83
|
SNAPSHOT_HEADER_ENGINE_LEN_OFFSET: () => SNAPSHOT_HEADER_ENGINE_LEN_OFFSET,
|
|
84
|
+
SCREEN_CTX_OFFSET: () => SCREEN_CTX_OFFSET,
|
|
83
85
|
PlayerInputContext: () => PlayerInputContext,
|
|
84
86
|
PLAYER_INPUTS_SIZE: () => PLAYER_INPUTS_SIZE,
|
|
85
87
|
PLAYER_INPUTS_MOUSE_CTX_OFFSET: () => PLAYER_INPUTS_MOUSE_CTX_OFFSET,
|
|
@@ -141,6 +143,7 @@ var EventType;
|
|
|
141
143
|
EventType2[EventType2["NetPeerAssignLocalId"] = 12] = "NetPeerAssignLocalId";
|
|
142
144
|
EventType2[EventType2["NetPacketReceived"] = 13] = "NetPacketReceived";
|
|
143
145
|
EventType2[EventType2["NetSessionInit"] = 14] = "NetSessionInit";
|
|
146
|
+
EventType2[EventType2["Resize"] = 15] = "Resize";
|
|
144
147
|
})(EventType ||= {});
|
|
145
148
|
var MouseButton;
|
|
146
149
|
((MouseButton2) => {
|
|
@@ -412,6 +415,11 @@ var NET_CTX_PEERS_OFFSET = 32;
|
|
|
412
415
|
var NET_CTX_LAST_ROLLBACK_DEPTH_OFFSET = 128;
|
|
413
416
|
var NET_CTX_TOTAL_ROLLBACKS_OFFSET = 132;
|
|
414
417
|
var NET_CTX_FRAMES_RESIMULATED_OFFSET = 136;
|
|
418
|
+
var SCREEN_CTX_WIDTH_OFFSET = 0;
|
|
419
|
+
var SCREEN_CTX_HEIGHT_OFFSET = 4;
|
|
420
|
+
var SCREEN_CTX_PHYSICAL_WIDTH_OFFSET = 8;
|
|
421
|
+
var SCREEN_CTX_PHYSICAL_HEIGHT_OFFSET = 12;
|
|
422
|
+
var SCREEN_CTX_PIXEL_RATIO_OFFSET = 16;
|
|
415
423
|
var MOUSE_CTX_X_OFFSET = 0;
|
|
416
424
|
var MOUSE_CTX_Y_OFFSET = 4;
|
|
417
425
|
var MOUSE_CTX_WHEEL_X_OFFSET = 8;
|
|
@@ -1328,6 +1336,43 @@ class NetContext {
|
|
|
1328
1336
|
}
|
|
1329
1337
|
}
|
|
1330
1338
|
|
|
1339
|
+
class ScreenContext {
|
|
1340
|
+
dataView;
|
|
1341
|
+
constructor(dataView) {
|
|
1342
|
+
this.dataView = dataView;
|
|
1343
|
+
}
|
|
1344
|
+
get width() {
|
|
1345
|
+
if (!this.dataView) {
|
|
1346
|
+
throw new Error("ScreenContext DataView is not initialized");
|
|
1347
|
+
}
|
|
1348
|
+
return this.dataView.getUint32(SCREEN_CTX_WIDTH_OFFSET, true);
|
|
1349
|
+
}
|
|
1350
|
+
get height() {
|
|
1351
|
+
if (!this.dataView) {
|
|
1352
|
+
throw new Error("ScreenContext DataView is not initialized");
|
|
1353
|
+
}
|
|
1354
|
+
return this.dataView.getUint32(SCREEN_CTX_HEIGHT_OFFSET, true);
|
|
1355
|
+
}
|
|
1356
|
+
get physicalWidth() {
|
|
1357
|
+
if (!this.dataView) {
|
|
1358
|
+
throw new Error("ScreenContext DataView is not initialized");
|
|
1359
|
+
}
|
|
1360
|
+
return this.dataView.getUint32(SCREEN_CTX_PHYSICAL_WIDTH_OFFSET, true);
|
|
1361
|
+
}
|
|
1362
|
+
get physicalHeight() {
|
|
1363
|
+
if (!this.dataView) {
|
|
1364
|
+
throw new Error("ScreenContext DataView is not initialized");
|
|
1365
|
+
}
|
|
1366
|
+
return this.dataView.getUint32(SCREEN_CTX_PHYSICAL_HEIGHT_OFFSET, true);
|
|
1367
|
+
}
|
|
1368
|
+
get pixelRatio() {
|
|
1369
|
+
if (!this.dataView) {
|
|
1370
|
+
throw new Error("ScreenContext DataView is not initialized");
|
|
1371
|
+
}
|
|
1372
|
+
return this.dataView.getFloat32(SCREEN_CTX_PIXEL_RATIO_OFFSET, true);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1331
1376
|
class TimeContext {
|
|
1332
1377
|
dataView;
|
|
1333
1378
|
constructor(dataView) {
|
|
@@ -1387,12 +1432,13 @@ function readTapeHeader(tape) {
|
|
|
1387
1432
|
eventCount: view.getUint16(14, true)
|
|
1388
1433
|
};
|
|
1389
1434
|
}
|
|
1390
|
-
var DEFAULT_WASM_URL = new URL("https://unpkg.com/@bloopjs/engine@0.0.
|
|
1435
|
+
var DEFAULT_WASM_URL = new URL("https://unpkg.com/@bloopjs/engine@0.0.90/wasm/bloop.wasm");
|
|
1391
1436
|
var MAX_ROLLBACK_FRAMES = 500;
|
|
1392
1437
|
var TIME_CTX_OFFSET = 0;
|
|
1393
1438
|
var INPUT_CTX_OFFSET = TIME_CTX_OFFSET + 4;
|
|
1394
1439
|
var EVENTS_OFFSET = INPUT_CTX_OFFSET + 4;
|
|
1395
1440
|
var NET_CTX_OFFSET = EVENTS_OFFSET + 4;
|
|
1441
|
+
var SCREEN_CTX_OFFSET = NET_CTX_OFFSET + 4;
|
|
1396
1442
|
var SNAPSHOT_HEADER_LEN = 16;
|
|
1397
1443
|
var SNAPSHOT_HEADER_USER_LEN_OFFSET = 4;
|
|
1398
1444
|
var SNAPSHOT_HEADER_ENGINE_LEN_OFFSET = 8;
|
|
@@ -1414,6 +1460,7 @@ class Sim {
|
|
|
1414
1460
|
#serialize;
|
|
1415
1461
|
#isPaused = false;
|
|
1416
1462
|
#net;
|
|
1463
|
+
#screen;
|
|
1417
1464
|
onTapeFull;
|
|
1418
1465
|
constructor(wasm, memory, opts) {
|
|
1419
1466
|
this.wasm = wasm;
|
|
@@ -1422,6 +1469,7 @@ class Sim {
|
|
|
1422
1469
|
this.id = `${Math.floor(Math.random() * 1e6)}`;
|
|
1423
1470
|
this.#serialize = opts?.serialize;
|
|
1424
1471
|
this.#net = new NetContext;
|
|
1472
|
+
this.#screen = new ScreenContext;
|
|
1425
1473
|
}
|
|
1426
1474
|
step(ms) {
|
|
1427
1475
|
if (this.#isPaused) {
|
|
@@ -1534,6 +1582,12 @@ class Sim {
|
|
|
1534
1582
|
}
|
|
1535
1583
|
return this.#net;
|
|
1536
1584
|
}
|
|
1585
|
+
get screen() {
|
|
1586
|
+
if (!this.#screen.dataView || this.#screen.dataView.buffer !== this.#memory.buffer) {
|
|
1587
|
+
this.#screen.dataView = new DataView(this.#memory.buffer, this.wasm.get_screen_ctx());
|
|
1588
|
+
}
|
|
1589
|
+
return this.#screen;
|
|
1590
|
+
}
|
|
1537
1591
|
get buffer() {
|
|
1538
1592
|
return this.#memory.buffer;
|
|
1539
1593
|
}
|
|
@@ -1565,6 +1619,9 @@ class Sim {
|
|
|
1565
1619
|
mousewheel: (x, y, peerId = 0) => {
|
|
1566
1620
|
this.wasm.emit_mousewheel(x, y, peerId);
|
|
1567
1621
|
},
|
|
1622
|
+
resize: (width, height, physicalWidth, physicalHeight, pixelRatio) => {
|
|
1623
|
+
this.wasm.emit_resize(width, height, physicalWidth, physicalHeight, pixelRatio);
|
|
1624
|
+
},
|
|
1568
1625
|
network: (type, data) => {
|
|
1569
1626
|
switch (type) {
|
|
1570
1627
|
case "join:ok": {
|
|
@@ -1730,6 +1787,39 @@ function calculateTapeConfig(tape) {
|
|
|
1730
1787
|
return { maxEvents, maxPacketBytes };
|
|
1731
1788
|
}
|
|
1732
1789
|
|
|
1790
|
+
class Players {
|
|
1791
|
+
#inputs;
|
|
1792
|
+
#net;
|
|
1793
|
+
constructor(inputs, net) {
|
|
1794
|
+
this.#inputs = inputs;
|
|
1795
|
+
this.#net = net;
|
|
1796
|
+
}
|
|
1797
|
+
get(index) {
|
|
1798
|
+
const players = this.#inputs.players;
|
|
1799
|
+
if (index < 0 || index >= players.length) {
|
|
1800
|
+
throw new RangeError(`Player index ${index} out of bounds (0-${players.length - 1})`);
|
|
1801
|
+
}
|
|
1802
|
+
return players[index];
|
|
1803
|
+
}
|
|
1804
|
+
get count() {
|
|
1805
|
+
return this.#net.isInSession ? this.#net.peerCount : 1;
|
|
1806
|
+
}
|
|
1807
|
+
*[Symbol.iterator]() {
|
|
1808
|
+
const players = this.#inputs.players;
|
|
1809
|
+
const count = this.count;
|
|
1810
|
+
for (let i = 0;i < count; i++) {
|
|
1811
|
+
yield players[i];
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
*entries() {
|
|
1815
|
+
const players = this.#inputs.players;
|
|
1816
|
+
const count = this.count;
|
|
1817
|
+
for (let i = 0;i < count; i++) {
|
|
1818
|
+
yield [i, players[i]];
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1733
1823
|
class Bloop {
|
|
1734
1824
|
#systems = [];
|
|
1735
1825
|
#context;
|
|
@@ -1742,15 +1832,16 @@ class Bloop {
|
|
|
1742
1832
|
throw new Error("Bloop constructor is private. Use Bloop.create() to create a new game instance.");
|
|
1743
1833
|
}
|
|
1744
1834
|
const inputs = new InputContext;
|
|
1835
|
+
const net = new NetContext;
|
|
1836
|
+
const screen = new ScreenContext;
|
|
1745
1837
|
this.#context = {
|
|
1746
1838
|
bag: opts.bag ?? {},
|
|
1747
1839
|
time: new TimeContext,
|
|
1748
1840
|
inputs,
|
|
1749
|
-
|
|
1750
|
-
return inputs.players;
|
|
1751
|
-
},
|
|
1841
|
+
players: new Players(inputs, net),
|
|
1752
1842
|
rawPointer: -1,
|
|
1753
|
-
net
|
|
1843
|
+
net,
|
|
1844
|
+
screen
|
|
1754
1845
|
};
|
|
1755
1846
|
}
|
|
1756
1847
|
get bag() {
|
|
@@ -1798,6 +1889,7 @@ class Bloop {
|
|
|
1798
1889
|
const timeCtxPtr = dv.getUint32(TIME_CTX_OFFSET, true);
|
|
1799
1890
|
const inputCtxPtr = dv.getUint32(INPUT_CTX_OFFSET, true);
|
|
1800
1891
|
const netCtxPtr = dv.getUint32(NET_CTX_OFFSET, true);
|
|
1892
|
+
const screenCtxPtr = dv.getUint32(SCREEN_CTX_OFFSET, true);
|
|
1801
1893
|
this.#context.rawPointer = ptr;
|
|
1802
1894
|
if (!this.#context.inputs.hasDataView() || this.#context.inputs.dataView.buffer !== this.#engineBuffer || this.#context.inputs.dataView.byteOffset !== inputCtxPtr) {
|
|
1803
1895
|
this.#context.inputs.dataView = new DataView(this.#engineBuffer, inputCtxPtr);
|
|
@@ -1808,6 +1900,9 @@ class Bloop {
|
|
|
1808
1900
|
if (this.#context.net.dataView?.buffer !== this.#engineBuffer || this.#context.net.dataView?.byteOffset !== netCtxPtr) {
|
|
1809
1901
|
this.#context.net.dataView = new DataView(this.#engineBuffer, netCtxPtr);
|
|
1810
1902
|
}
|
|
1903
|
+
if (this.#context.screen.dataView?.buffer !== this.#engineBuffer || this.#context.screen.dataView?.byteOffset !== screenCtxPtr) {
|
|
1904
|
+
this.#context.screen.dataView = new DataView(this.#engineBuffer, screenCtxPtr);
|
|
1905
|
+
}
|
|
1811
1906
|
},
|
|
1812
1907
|
systemsCallback: (system_handle, ptr) => {
|
|
1813
1908
|
this.hooks.setContext(ptr);
|
|
@@ -1919,6 +2014,15 @@ class Bloop {
|
|
|
1919
2014
|
};
|
|
1920
2015
|
system.netcode?.(this.#context);
|
|
1921
2016
|
break;
|
|
2017
|
+
case exports_enums.EventType.Resize:
|
|
2018
|
+
system.resize?.(attachEvent(this.#context, {
|
|
2019
|
+
width: this.#context.screen.width,
|
|
2020
|
+
height: this.#context.screen.height,
|
|
2021
|
+
physicalWidth: this.#context.screen.physicalWidth,
|
|
2022
|
+
physicalHeight: this.#context.screen.physicalHeight,
|
|
2023
|
+
pixelRatio: this.#context.screen.pixelRatio
|
|
2024
|
+
}));
|
|
2025
|
+
break;
|
|
1922
2026
|
default:
|
|
1923
2027
|
break;
|
|
1924
2028
|
}
|
|
@@ -1970,6 +2074,7 @@ var EventType2;
|
|
|
1970
2074
|
EventType22[EventType22["NetPeerAssignLocalId"] = 12] = "NetPeerAssignLocalId";
|
|
1971
2075
|
EventType22[EventType22["NetPacketReceived"] = 13] = "NetPacketReceived";
|
|
1972
2076
|
EventType22[EventType22["NetSessionInit"] = 14] = "NetSessionInit";
|
|
2077
|
+
EventType22[EventType22["Resize"] = 15] = "Resize";
|
|
1973
2078
|
})(EventType2 ||= {});
|
|
1974
2079
|
var MouseButton2;
|
|
1975
2080
|
((MouseButton22) => {
|
|
@@ -3168,11 +3273,12 @@ function readTapeHeader2(tape) {
|
|
|
3168
3273
|
eventCount: view.getUint16(14, true)
|
|
3169
3274
|
};
|
|
3170
3275
|
}
|
|
3171
|
-
var DEFAULT_WASM_URL2 = new URL("https://unpkg.com/@bloopjs/engine@0.0.
|
|
3276
|
+
var DEFAULT_WASM_URL2 = new URL("https://unpkg.com/@bloopjs/engine@0.0.90/wasm/bloop.wasm");
|
|
3172
3277
|
var TIME_CTX_OFFSET2 = 0;
|
|
3173
3278
|
var INPUT_CTX_OFFSET2 = TIME_CTX_OFFSET2 + 4;
|
|
3174
3279
|
var EVENTS_OFFSET2 = INPUT_CTX_OFFSET2 + 4;
|
|
3175
3280
|
var NET_CTX_OFFSET2 = EVENTS_OFFSET2 + 4;
|
|
3281
|
+
var SCREEN_CTX_OFFSET2 = NET_CTX_OFFSET2 + 4;
|
|
3176
3282
|
|
|
3177
3283
|
// src/debugui/mod.ts
|
|
3178
3284
|
var exports_mod = {};
|
|
@@ -6592,6 +6698,41 @@ class App {
|
|
|
6592
6698
|
onHmr = createListener();
|
|
6593
6699
|
subscribe() {
|
|
6594
6700
|
const shouldEmitInputs = () => !this.sim.isReplaying;
|
|
6701
|
+
let resizeObserver = null;
|
|
6702
|
+
let cleanupPixelRatio = null;
|
|
6703
|
+
const emitResize = () => {
|
|
6704
|
+
const canvas2 = this.canvas;
|
|
6705
|
+
const pixelRatio = window.devicePixelRatio || 1;
|
|
6706
|
+
let width;
|
|
6707
|
+
let height;
|
|
6708
|
+
if (canvas2) {
|
|
6709
|
+
const rect = canvas2.getBoundingClientRect();
|
|
6710
|
+
width = Math.round(rect.width);
|
|
6711
|
+
height = Math.round(rect.height);
|
|
6712
|
+
} else {
|
|
6713
|
+
width = window.innerWidth;
|
|
6714
|
+
height = window.innerHeight;
|
|
6715
|
+
}
|
|
6716
|
+
this.sim.emit.resize(width, height, Math.round(width * pixelRatio), Math.round(height * pixelRatio), pixelRatio);
|
|
6717
|
+
};
|
|
6718
|
+
const canvas = this.canvas;
|
|
6719
|
+
if (canvas) {
|
|
6720
|
+
resizeObserver = new ResizeObserver(() => emitResize());
|
|
6721
|
+
resizeObserver.observe(canvas);
|
|
6722
|
+
} else {
|
|
6723
|
+
window.addEventListener("resize", emitResize);
|
|
6724
|
+
}
|
|
6725
|
+
const updatePixelRatioListener = () => {
|
|
6726
|
+
const mediaQuery = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
6727
|
+
const handler = () => {
|
|
6728
|
+
emitResize();
|
|
6729
|
+
updatePixelRatioListener();
|
|
6730
|
+
};
|
|
6731
|
+
mediaQuery.addEventListener("change", handler, { once: true });
|
|
6732
|
+
return () => mediaQuery.removeEventListener("change", handler);
|
|
6733
|
+
};
|
|
6734
|
+
cleanupPixelRatio = updatePixelRatioListener();
|
|
6735
|
+
emitResize();
|
|
6595
6736
|
const handleKeydown = (event) => {
|
|
6596
6737
|
if (shouldEmitInputs())
|
|
6597
6738
|
this.sim.emit.keydown(event.code);
|
|
@@ -6745,6 +6886,9 @@ class App {
|
|
|
6745
6886
|
window.removeEventListener("touchstart", handleTouchstart);
|
|
6746
6887
|
window.removeEventListener("touchend", handleTouchend);
|
|
6747
6888
|
window.removeEventListener("touchmove", handleTouchmove);
|
|
6889
|
+
window.removeEventListener("resize", emitResize);
|
|
6890
|
+
resizeObserver?.disconnect();
|
|
6891
|
+
cleanupPixelRatio?.();
|
|
6748
6892
|
if (this.#rafHandle != null) {
|
|
6749
6893
|
cancelAnimationFrame(this.#rafHandle);
|
|
6750
6894
|
}
|
|
@@ -6810,5 +6954,5 @@ export {
|
|
|
6810
6954
|
App
|
|
6811
6955
|
};
|
|
6812
6956
|
|
|
6813
|
-
//# debugId=
|
|
6957
|
+
//# debugId=669ECA7E8ACBF62064756E2164756E21
|
|
6814
6958
|
//# sourceMappingURL=mod.js.map
|