@quake2ts/test-utils 0.0.1 → 0.0.740
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/index.cjs +486 -556
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -38
- package/dist/index.d.ts +30 -38
- package/dist/index.js +482 -551
- package/dist/index.js.map +1 -1
- package/package.json +32 -9
- package/src/e2e/visual.ts +72 -139
- package/src/game/factories.ts +17 -0
- package/src/game/helpers.ts +35 -5
- package/src/index.ts +1 -1
- package/src/server/mocks/state.ts +21 -13
- package/src/game/mocks.ts +0 -105
package/dist/index.cjs
CHANGED
|
@@ -62,7 +62,6 @@ __export(index_exports, {
|
|
|
62
62
|
captureGameState: () => captureGameState,
|
|
63
63
|
captureTexture: () => captureTexture,
|
|
64
64
|
compareSaveGames: () => compareSaveGames,
|
|
65
|
-
compareScreenshot: () => compareScreenshot,
|
|
66
65
|
compareScreenshots: () => compareScreenshots,
|
|
67
66
|
compareSnapshots: () => compareSnapshots,
|
|
68
67
|
createBandwidthTestScenario: () => createBandwidthTestScenario,
|
|
@@ -723,6 +722,24 @@ function createPlayerEntityFactory(overrides = {}) {
|
|
|
723
722
|
movetype: import_game.MoveType.Walk,
|
|
724
723
|
svflags: import_game.ServerFlags.Player,
|
|
725
724
|
viewheight: 22,
|
|
725
|
+
client: {
|
|
726
|
+
inventory: {
|
|
727
|
+
ammo: { counts: [], caps: [] },
|
|
728
|
+
ownedWeapons: /* @__PURE__ */ new Set(),
|
|
729
|
+
powerups: /* @__PURE__ */ new Map(),
|
|
730
|
+
keys: /* @__PURE__ */ new Set(),
|
|
731
|
+
items: /* @__PURE__ */ new Set()
|
|
732
|
+
},
|
|
733
|
+
weaponStates: {
|
|
734
|
+
currentWeapon: null,
|
|
735
|
+
lastFireTime: 0,
|
|
736
|
+
weaponFrame: 0,
|
|
737
|
+
weaponIdleTime: 0,
|
|
738
|
+
states: /* @__PURE__ */ new Map(),
|
|
739
|
+
// Initialize states map correctly
|
|
740
|
+
activeWeaponId: null
|
|
741
|
+
}
|
|
742
|
+
},
|
|
726
743
|
...overrides
|
|
727
744
|
});
|
|
728
745
|
}
|
|
@@ -975,6 +992,33 @@ function createGameImportsAndEngine(overrides) {
|
|
|
975
992
|
};
|
|
976
993
|
return { imports, engine };
|
|
977
994
|
}
|
|
995
|
+
function createMockGameExports(overrides = {}) {
|
|
996
|
+
return {
|
|
997
|
+
init: import_vitest2.vi.fn(),
|
|
998
|
+
shutdown: import_vitest2.vi.fn(),
|
|
999
|
+
frame: import_vitest2.vi.fn().mockReturnValue({ state: {} }),
|
|
1000
|
+
clientThink: import_vitest2.vi.fn(),
|
|
1001
|
+
time: 0,
|
|
1002
|
+
spawnWorld: import_vitest2.vi.fn(),
|
|
1003
|
+
deathmatch: false,
|
|
1004
|
+
coop: false,
|
|
1005
|
+
gameImports: {},
|
|
1006
|
+
gameEngine: {},
|
|
1007
|
+
entities: {
|
|
1008
|
+
spawn: import_vitest2.vi.fn(),
|
|
1009
|
+
free: import_vitest2.vi.fn(),
|
|
1010
|
+
find: import_vitest2.vi.fn(),
|
|
1011
|
+
findByClassname: import_vitest2.vi.fn(),
|
|
1012
|
+
findByRadius: import_vitest2.vi.fn(() => []),
|
|
1013
|
+
forEachEntity: import_vitest2.vi.fn(),
|
|
1014
|
+
timeSeconds: 0,
|
|
1015
|
+
...overrides.entities
|
|
1016
|
+
},
|
|
1017
|
+
multicast: import_vitest2.vi.fn(),
|
|
1018
|
+
unicast: import_vitest2.vi.fn(),
|
|
1019
|
+
...overrides
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
978
1022
|
|
|
979
1023
|
// src/game/helpers/physics.ts
|
|
980
1024
|
var import_game3 = require("@quake2ts/game");
|
|
@@ -1403,96 +1447,8 @@ function createMockPowerupItem(id, duration, overrides = {}) {
|
|
|
1403
1447
|
return { ...base, ...overrides };
|
|
1404
1448
|
}
|
|
1405
1449
|
|
|
1406
|
-
// src/game/mocks.ts
|
|
1407
|
-
var import_vitest5 = require("vitest");
|
|
1408
|
-
function createMockGameState(overrides) {
|
|
1409
|
-
return {
|
|
1410
|
-
levelName: "test_level",
|
|
1411
|
-
time: 0,
|
|
1412
|
-
entities: [],
|
|
1413
|
-
clients: [],
|
|
1414
|
-
...overrides
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
function createMockGameExports(overrides) {
|
|
1418
|
-
return {
|
|
1419
|
-
init: import_vitest5.vi.fn(),
|
|
1420
|
-
shutdown: import_vitest5.vi.fn(),
|
|
1421
|
-
spawnWorld: import_vitest5.vi.fn(),
|
|
1422
|
-
frame: import_vitest5.vi.fn().mockReturnValue({ state: {} }),
|
|
1423
|
-
clientConnect: import_vitest5.vi.fn().mockReturnValue(true),
|
|
1424
|
-
clientBegin: import_vitest5.vi.fn().mockReturnValue({ index: 1, origin: { x: 0, y: 0, z: 0 } }),
|
|
1425
|
-
clientDisconnect: import_vitest5.vi.fn(),
|
|
1426
|
-
clientThink: import_vitest5.vi.fn(),
|
|
1427
|
-
respawn: import_vitest5.vi.fn(),
|
|
1428
|
-
entities: {
|
|
1429
|
-
getByIndex: import_vitest5.vi.fn(),
|
|
1430
|
-
forEachEntity: import_vitest5.vi.fn(),
|
|
1431
|
-
findByRadius: import_vitest5.vi.fn(),
|
|
1432
|
-
find: import_vitest5.vi.fn(),
|
|
1433
|
-
checkAnyCollision: import_vitest5.vi.fn(),
|
|
1434
|
-
trace: import_vitest5.vi.fn(),
|
|
1435
|
-
pointcontents: import_vitest5.vi.fn(),
|
|
1436
|
-
link: import_vitest5.vi.fn(),
|
|
1437
|
-
unlink: import_vitest5.vi.fn(),
|
|
1438
|
-
spawn: import_vitest5.vi.fn(),
|
|
1439
|
-
free: import_vitest5.vi.fn(),
|
|
1440
|
-
activeCount: 0,
|
|
1441
|
-
world: { classname: "worldspawn" }
|
|
1442
|
-
},
|
|
1443
|
-
multicast: import_vitest5.vi.fn(),
|
|
1444
|
-
unicast: import_vitest5.vi.fn(),
|
|
1445
|
-
configstring: import_vitest5.vi.fn(),
|
|
1446
|
-
serverCommand: import_vitest5.vi.fn(),
|
|
1447
|
-
sound: import_vitest5.vi.fn(),
|
|
1448
|
-
soundIndex: import_vitest5.vi.fn(),
|
|
1449
|
-
centerprintf: import_vitest5.vi.fn(),
|
|
1450
|
-
trace: import_vitest5.vi.fn(),
|
|
1451
|
-
time: 0,
|
|
1452
|
-
deathmatch: false,
|
|
1453
|
-
skill: 1,
|
|
1454
|
-
rogue: false,
|
|
1455
|
-
xatrix: false,
|
|
1456
|
-
coop: false,
|
|
1457
|
-
friendlyFire: false,
|
|
1458
|
-
random: {
|
|
1459
|
-
next: import_vitest5.vi.fn(),
|
|
1460
|
-
nextFloat: import_vitest5.vi.fn(),
|
|
1461
|
-
range: import_vitest5.vi.fn(),
|
|
1462
|
-
crandom: import_vitest5.vi.fn(),
|
|
1463
|
-
getState: import_vitest5.vi.fn(),
|
|
1464
|
-
setState: import_vitest5.vi.fn()
|
|
1465
|
-
},
|
|
1466
|
-
createSave: import_vitest5.vi.fn(),
|
|
1467
|
-
loadSave: import_vitest5.vi.fn(),
|
|
1468
|
-
serialize: import_vitest5.vi.fn(),
|
|
1469
|
-
loadState: import_vitest5.vi.fn(),
|
|
1470
|
-
setGodMode: import_vitest5.vi.fn(),
|
|
1471
|
-
setNoclip: import_vitest5.vi.fn(),
|
|
1472
|
-
setNotarget: import_vitest5.vi.fn(),
|
|
1473
|
-
giveItem: import_vitest5.vi.fn(),
|
|
1474
|
-
damage: import_vitest5.vi.fn(),
|
|
1475
|
-
teleport: import_vitest5.vi.fn(),
|
|
1476
|
-
registerHooks: import_vitest5.vi.fn(),
|
|
1477
|
-
hooks: {
|
|
1478
|
-
onMapLoad: import_vitest5.vi.fn(),
|
|
1479
|
-
onMapUnload: import_vitest5.vi.fn(),
|
|
1480
|
-
onPlayerSpawn: import_vitest5.vi.fn(),
|
|
1481
|
-
onPlayerDeath: import_vitest5.vi.fn(),
|
|
1482
|
-
register: import_vitest5.vi.fn(),
|
|
1483
|
-
onPickup: import_vitest5.vi.fn()
|
|
1484
|
-
// Added onPickup mock
|
|
1485
|
-
},
|
|
1486
|
-
setSpectator: import_vitest5.vi.fn(),
|
|
1487
|
-
registerEntitySpawn: import_vitest5.vi.fn(),
|
|
1488
|
-
unregisterEntitySpawn: import_vitest5.vi.fn(),
|
|
1489
|
-
getCustomEntities: import_vitest5.vi.fn(),
|
|
1490
|
-
...overrides
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
1450
|
// src/server/mocks/transport.ts
|
|
1495
|
-
var
|
|
1451
|
+
var import_vitest5 = require("vitest");
|
|
1496
1452
|
var MockTransport = class {
|
|
1497
1453
|
constructor() {
|
|
1498
1454
|
this.address = "127.0.0.1";
|
|
@@ -1500,11 +1456,11 @@ var MockTransport = class {
|
|
|
1500
1456
|
this.sentMessages = [];
|
|
1501
1457
|
this.receivedMessages = [];
|
|
1502
1458
|
this.listening = false;
|
|
1503
|
-
this.listenSpy =
|
|
1459
|
+
this.listenSpy = import_vitest5.vi.fn().mockImplementation(async (port) => {
|
|
1504
1460
|
this.port = port;
|
|
1505
1461
|
this.listening = true;
|
|
1506
1462
|
});
|
|
1507
|
-
this.closeSpy =
|
|
1463
|
+
this.closeSpy = import_vitest5.vi.fn().mockImplementation(() => {
|
|
1508
1464
|
this.listening = false;
|
|
1509
1465
|
});
|
|
1510
1466
|
}
|
|
@@ -1560,11 +1516,11 @@ var MockTransport = class {
|
|
|
1560
1516
|
};
|
|
1561
1517
|
function createMockUDPSocket(overrides) {
|
|
1562
1518
|
const socket = {
|
|
1563
|
-
send:
|
|
1564
|
-
on:
|
|
1565
|
-
close:
|
|
1566
|
-
bind:
|
|
1567
|
-
address:
|
|
1519
|
+
send: import_vitest5.vi.fn(),
|
|
1520
|
+
on: import_vitest5.vi.fn(),
|
|
1521
|
+
close: import_vitest5.vi.fn(),
|
|
1522
|
+
bind: import_vitest5.vi.fn(),
|
|
1523
|
+
address: import_vitest5.vi.fn().mockReturnValue({ address: "127.0.0.1", family: "IPv4", port: 0 }),
|
|
1568
1524
|
...overrides
|
|
1569
1525
|
};
|
|
1570
1526
|
return socket;
|
|
@@ -1581,13 +1537,13 @@ function createMockTransport(address = "127.0.0.1", port = 27910, overrides) {
|
|
|
1581
1537
|
}
|
|
1582
1538
|
function createMockNetDriver(overrides) {
|
|
1583
1539
|
return {
|
|
1584
|
-
connect:
|
|
1585
|
-
disconnect:
|
|
1586
|
-
send:
|
|
1587
|
-
onMessage:
|
|
1588
|
-
onClose:
|
|
1589
|
-
onError:
|
|
1590
|
-
isConnected:
|
|
1540
|
+
connect: import_vitest5.vi.fn().mockResolvedValue(void 0),
|
|
1541
|
+
disconnect: import_vitest5.vi.fn(),
|
|
1542
|
+
send: import_vitest5.vi.fn(),
|
|
1543
|
+
onMessage: import_vitest5.vi.fn(),
|
|
1544
|
+
onClose: import_vitest5.vi.fn(),
|
|
1545
|
+
onError: import_vitest5.vi.fn(),
|
|
1546
|
+
isConnected: import_vitest5.vi.fn().mockReturnValue(true),
|
|
1591
1547
|
...overrides
|
|
1592
1548
|
};
|
|
1593
1549
|
}
|
|
@@ -1632,7 +1588,7 @@ var MockNetworkTransport = class {
|
|
|
1632
1588
|
};
|
|
1633
1589
|
|
|
1634
1590
|
// src/server/mockNetDriver.ts
|
|
1635
|
-
var
|
|
1591
|
+
var import_vitest6 = require("vitest");
|
|
1636
1592
|
var MockNetDriver = class {
|
|
1637
1593
|
constructor() {
|
|
1638
1594
|
this.state = {
|
|
@@ -1642,14 +1598,14 @@ var MockNetDriver = class {
|
|
|
1642
1598
|
closeHandlers: [],
|
|
1643
1599
|
errorHandlers: []
|
|
1644
1600
|
};
|
|
1645
|
-
this.connectSpy =
|
|
1601
|
+
this.connectSpy = import_vitest6.vi.fn().mockImplementation(async (url) => {
|
|
1646
1602
|
this.state.connected = true;
|
|
1647
1603
|
});
|
|
1648
|
-
this.disconnectSpy =
|
|
1604
|
+
this.disconnectSpy = import_vitest6.vi.fn().mockImplementation(() => {
|
|
1649
1605
|
this.state.connected = false;
|
|
1650
1606
|
this.state.closeHandlers.forEach((h) => h());
|
|
1651
1607
|
});
|
|
1652
|
-
this.sendSpy =
|
|
1608
|
+
this.sendSpy = import_vitest6.vi.fn().mockImplementation((data) => {
|
|
1653
1609
|
this.state.messagesSent.push(new Uint8Array(data));
|
|
1654
1610
|
});
|
|
1655
1611
|
}
|
|
@@ -1711,7 +1667,16 @@ var MockNetDriver = class {
|
|
|
1711
1667
|
// src/server/mocks/state.ts
|
|
1712
1668
|
var import_server = require("@quake2ts/server");
|
|
1713
1669
|
var import_shared7 = require("@quake2ts/shared");
|
|
1714
|
-
var
|
|
1670
|
+
var import_vitest7 = require("vitest");
|
|
1671
|
+
function createMockGameState(overrides) {
|
|
1672
|
+
return {
|
|
1673
|
+
levelName: "test_level",
|
|
1674
|
+
time: 0,
|
|
1675
|
+
entities: [],
|
|
1676
|
+
clients: [],
|
|
1677
|
+
...overrides
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1715
1680
|
function createMockServerState(overrides) {
|
|
1716
1681
|
return {
|
|
1717
1682
|
state: import_server.ServerState.Game,
|
|
@@ -1753,13 +1718,13 @@ function createMockServerClient(clientNum, overrides) {
|
|
|
1753
1718
|
incomingSequence: 0,
|
|
1754
1719
|
outgoingSequence: 0,
|
|
1755
1720
|
lastReceived: 0,
|
|
1756
|
-
process:
|
|
1757
|
-
transmit:
|
|
1758
|
-
writeReliableByte:
|
|
1759
|
-
writeReliableShort:
|
|
1760
|
-
writeReliableLong:
|
|
1761
|
-
writeReliableString:
|
|
1762
|
-
writeReliableData:
|
|
1721
|
+
process: import_vitest7.vi.fn(),
|
|
1722
|
+
transmit: import_vitest7.vi.fn(),
|
|
1723
|
+
writeReliableByte: import_vitest7.vi.fn(),
|
|
1724
|
+
writeReliableShort: import_vitest7.vi.fn(),
|
|
1725
|
+
writeReliableLong: import_vitest7.vi.fn(),
|
|
1726
|
+
writeReliableString: import_vitest7.vi.fn(),
|
|
1727
|
+
writeReliableData: import_vitest7.vi.fn()
|
|
1763
1728
|
},
|
|
1764
1729
|
// Cast as any because NetChan might be complex to fully mock here
|
|
1765
1730
|
userInfo: "",
|
|
@@ -1801,16 +1766,16 @@ function createMockServerClient(clientNum, overrides) {
|
|
|
1801
1766
|
}
|
|
1802
1767
|
function createMockServer(overrides) {
|
|
1803
1768
|
return {
|
|
1804
|
-
start:
|
|
1805
|
-
stop:
|
|
1806
|
-
multicast:
|
|
1807
|
-
unicast:
|
|
1808
|
-
configstring:
|
|
1809
|
-
kickPlayer:
|
|
1810
|
-
changeMap:
|
|
1811
|
-
getClient:
|
|
1812
|
-
broadcast:
|
|
1813
|
-
tick:
|
|
1769
|
+
start: import_vitest7.vi.fn().mockResolvedValue(void 0),
|
|
1770
|
+
stop: import_vitest7.vi.fn(),
|
|
1771
|
+
multicast: import_vitest7.vi.fn(),
|
|
1772
|
+
unicast: import_vitest7.vi.fn(),
|
|
1773
|
+
configstring: import_vitest7.vi.fn(),
|
|
1774
|
+
kickPlayer: import_vitest7.vi.fn(),
|
|
1775
|
+
changeMap: import_vitest7.vi.fn().mockResolvedValue(void 0),
|
|
1776
|
+
getClient: import_vitest7.vi.fn().mockReturnValue(null),
|
|
1777
|
+
broadcast: import_vitest7.vi.fn(),
|
|
1778
|
+
tick: import_vitest7.vi.fn(),
|
|
1814
1779
|
...overrides
|
|
1815
1780
|
};
|
|
1816
1781
|
}
|
|
@@ -1872,19 +1837,19 @@ async function simulateHandshake(client, server) {
|
|
|
1872
1837
|
}
|
|
1873
1838
|
|
|
1874
1839
|
// src/server/mocks/commands.ts
|
|
1875
|
-
var
|
|
1840
|
+
var import_vitest8 = require("vitest");
|
|
1876
1841
|
function createMockServerConsole(overrides) {
|
|
1877
1842
|
const outputBuffer = [];
|
|
1878
1843
|
const commandBuffer = [];
|
|
1879
1844
|
return {
|
|
1880
|
-
exec:
|
|
1845
|
+
exec: import_vitest8.vi.fn((cmd) => {
|
|
1881
1846
|
commandBuffer.push(cmd);
|
|
1882
1847
|
return `Executed: ${cmd}`;
|
|
1883
1848
|
}),
|
|
1884
|
-
print:
|
|
1849
|
+
print: import_vitest8.vi.fn((text) => {
|
|
1885
1850
|
outputBuffer.push(text);
|
|
1886
1851
|
}),
|
|
1887
|
-
broadcast:
|
|
1852
|
+
broadcast: import_vitest8.vi.fn((text) => {
|
|
1888
1853
|
outputBuffer.push(`Broadcast: ${text}`);
|
|
1889
1854
|
}),
|
|
1890
1855
|
commandBuffer,
|
|
@@ -1897,13 +1862,13 @@ function createMockRConClient(password = "") {
|
|
|
1897
1862
|
connected: false,
|
|
1898
1863
|
lastCommand: "",
|
|
1899
1864
|
lastResponse: "",
|
|
1900
|
-
connect:
|
|
1865
|
+
connect: import_vitest8.vi.fn(async (address, port, pwd) => {
|
|
1901
1866
|
return pwd === password;
|
|
1902
1867
|
}),
|
|
1903
|
-
sendCommand:
|
|
1868
|
+
sendCommand: import_vitest8.vi.fn(async (cmd) => {
|
|
1904
1869
|
return `RCON Response for: ${cmd}`;
|
|
1905
1870
|
}),
|
|
1906
|
-
disconnect:
|
|
1871
|
+
disconnect: import_vitest8.vi.fn()
|
|
1907
1872
|
};
|
|
1908
1873
|
}
|
|
1909
1874
|
function simulateServerCommand(server, command) {
|
|
@@ -1972,19 +1937,19 @@ async function simulateServerRegistration(server, master) {
|
|
|
1972
1937
|
}
|
|
1973
1938
|
|
|
1974
1939
|
// src/server/mocks/physics.ts
|
|
1975
|
-
var
|
|
1940
|
+
var import_vitest9 = require("vitest");
|
|
1976
1941
|
function createMockCollisionEntityIndex(overrides) {
|
|
1977
1942
|
return {
|
|
1978
|
-
trace:
|
|
1943
|
+
trace: import_vitest9.vi.fn().mockReturnValue({
|
|
1979
1944
|
fraction: 1,
|
|
1980
1945
|
allsolid: false,
|
|
1981
1946
|
startsolid: false,
|
|
1982
1947
|
endpos: { x: 0, y: 0, z: 0 },
|
|
1983
1948
|
entityId: null
|
|
1984
1949
|
}),
|
|
1985
|
-
link:
|
|
1986
|
-
unlink:
|
|
1987
|
-
gatherTriggerTouches:
|
|
1950
|
+
link: import_vitest9.vi.fn(),
|
|
1951
|
+
unlink: import_vitest9.vi.fn(),
|
|
1952
|
+
gatherTriggerTouches: import_vitest9.vi.fn().mockReturnValue([]),
|
|
1988
1953
|
...overrides
|
|
1989
1954
|
};
|
|
1990
1955
|
}
|
|
@@ -2480,7 +2445,7 @@ function createInputInjector(target) {
|
|
|
2480
2445
|
}
|
|
2481
2446
|
|
|
2482
2447
|
// src/engine/mocks/webgl.ts
|
|
2483
|
-
var
|
|
2448
|
+
var import_vitest10 = require("vitest");
|
|
2484
2449
|
var MockWebGL2RenderingContext = class {
|
|
2485
2450
|
constructor(canvas) {
|
|
2486
2451
|
this.ARRAY_BUFFER = 34962;
|
|
@@ -2539,139 +2504,139 @@ var MockWebGL2RenderingContext = class {
|
|
|
2539
2504
|
this.calls = [];
|
|
2540
2505
|
this.uniformLocations = /* @__PURE__ */ new Map();
|
|
2541
2506
|
this.attributeLocations = /* @__PURE__ */ new Map();
|
|
2542
|
-
this.enable =
|
|
2543
|
-
this.disable =
|
|
2544
|
-
this.depthFunc =
|
|
2545
|
-
this.cullFace =
|
|
2546
|
-
this.depthMask =
|
|
2547
|
-
this.blendFuncSeparate =
|
|
2507
|
+
this.enable = import_vitest10.vi.fn((cap) => this.calls.push(`enable:${cap}`));
|
|
2508
|
+
this.disable = import_vitest10.vi.fn((cap) => this.calls.push(`disable:${cap}`));
|
|
2509
|
+
this.depthFunc = import_vitest10.vi.fn((func) => this.calls.push(`depthFunc:${func}`));
|
|
2510
|
+
this.cullFace = import_vitest10.vi.fn((mode) => this.calls.push(`cullFace:${mode}`));
|
|
2511
|
+
this.depthMask = import_vitest10.vi.fn((flag) => this.calls.push(`depthMask:${flag}`));
|
|
2512
|
+
this.blendFuncSeparate = import_vitest10.vi.fn(
|
|
2548
2513
|
(srcRGB, dstRGB, srcAlpha, dstAlpha) => this.calls.push(`blendFuncSeparate:${srcRGB}:${dstRGB}:${srcAlpha}:${dstAlpha}`)
|
|
2549
2514
|
);
|
|
2550
|
-
this.blendFunc =
|
|
2551
|
-
this.getExtension =
|
|
2552
|
-
this.viewport =
|
|
2553
|
-
this.clear =
|
|
2554
|
-
this.clearColor =
|
|
2555
|
-
this.createShader =
|
|
2556
|
-
this.shaderSource =
|
|
2557
|
-
this.compileShader =
|
|
2558
|
-
this.getShaderParameter =
|
|
2515
|
+
this.blendFunc = import_vitest10.vi.fn((sfactor, dfactor) => this.calls.push(`blendFunc:${sfactor}:${dfactor}`));
|
|
2516
|
+
this.getExtension = import_vitest10.vi.fn((name) => this.extensions.get(name) ?? null);
|
|
2517
|
+
this.viewport = import_vitest10.vi.fn((x, y, w, h) => this.calls.push(`viewport:${x}:${y}:${w}:${h}`));
|
|
2518
|
+
this.clear = import_vitest10.vi.fn((mask) => this.calls.push(`clear:${mask}`));
|
|
2519
|
+
this.clearColor = import_vitest10.vi.fn((r, g, b, a) => this.calls.push(`clearColor:${r}:${g}:${b}:${a}`));
|
|
2520
|
+
this.createShader = import_vitest10.vi.fn((type) => ({ id: ++this.shaderCounter, type }));
|
|
2521
|
+
this.shaderSource = import_vitest10.vi.fn((shader, source) => this.calls.push(`shaderSource:${shader.id}:${source}`));
|
|
2522
|
+
this.compileShader = import_vitest10.vi.fn((shader) => this.calls.push(`compileShader:${shader.id}`));
|
|
2523
|
+
this.getShaderParameter = import_vitest10.vi.fn(
|
|
2559
2524
|
(shader, pname) => pname === this.COMPILE_STATUS ? this.compileSucceeds : null
|
|
2560
2525
|
);
|
|
2561
|
-
this.getShaderInfoLog =
|
|
2562
|
-
this.deleteShader =
|
|
2563
|
-
this.createProgram =
|
|
2564
|
-
this.attachShader =
|
|
2526
|
+
this.getShaderInfoLog = import_vitest10.vi.fn(() => this.compileSucceeds ? "" : this.shaderInfoLog);
|
|
2527
|
+
this.deleteShader = import_vitest10.vi.fn((shader) => this.calls.push(`deleteShader:${shader.id}`));
|
|
2528
|
+
this.createProgram = import_vitest10.vi.fn(() => ({ id: ++this.programCounter }));
|
|
2529
|
+
this.attachShader = import_vitest10.vi.fn(
|
|
2565
2530
|
(program, shader) => this.calls.push(`attach:${program.id}:${shader.id}`)
|
|
2566
2531
|
);
|
|
2567
|
-
this.bindAttribLocation =
|
|
2532
|
+
this.bindAttribLocation = import_vitest10.vi.fn(
|
|
2568
2533
|
(program, index, name) => this.calls.push(`bindAttribLocation:${program.id}:${index}:${name}`)
|
|
2569
2534
|
);
|
|
2570
|
-
this.linkProgram =
|
|
2571
|
-
this.getProgramParameter =
|
|
2535
|
+
this.linkProgram = import_vitest10.vi.fn((program) => this.calls.push(`link:${program.id}`));
|
|
2536
|
+
this.getProgramParameter = import_vitest10.vi.fn(
|
|
2572
2537
|
(program, pname) => pname === this.LINK_STATUS ? this.linkSucceeds : null
|
|
2573
2538
|
);
|
|
2574
|
-
this.getProgramInfoLog =
|
|
2575
|
-
this.deleteProgram =
|
|
2576
|
-
this.useProgram =
|
|
2577
|
-
this.getUniformLocation =
|
|
2539
|
+
this.getProgramInfoLog = import_vitest10.vi.fn(() => this.linkSucceeds ? "" : this.programInfoLog);
|
|
2540
|
+
this.deleteProgram = import_vitest10.vi.fn((program) => this.calls.push(`deleteProgram:${program.id}`));
|
|
2541
|
+
this.useProgram = import_vitest10.vi.fn((program) => this.calls.push(`useProgram:${program?.id ?? "null"}`));
|
|
2542
|
+
this.getUniformLocation = import_vitest10.vi.fn((program, name) => {
|
|
2578
2543
|
this.calls.push(`getUniformLocation:${program.id}:${name}`);
|
|
2579
2544
|
return this.uniformLocations.get(name) ?? null;
|
|
2580
2545
|
});
|
|
2581
|
-
this.getAttribLocation =
|
|
2546
|
+
this.getAttribLocation = import_vitest10.vi.fn((program, name) => {
|
|
2582
2547
|
this.calls.push(`getAttribLocation:${program.id}:${name}`);
|
|
2583
2548
|
return this.attributeLocations.get(name) ?? -1;
|
|
2584
2549
|
});
|
|
2585
|
-
this.createBuffer =
|
|
2586
|
-
this.bindBuffer =
|
|
2587
|
-
this.bufferData =
|
|
2550
|
+
this.createBuffer = import_vitest10.vi.fn(() => ({ buffer: {} }));
|
|
2551
|
+
this.bindBuffer = import_vitest10.vi.fn((target, buffer) => this.calls.push(`bindBuffer:${target}:${!!buffer}`));
|
|
2552
|
+
this.bufferData = import_vitest10.vi.fn(
|
|
2588
2553
|
(target, data, usage) => this.calls.push(`bufferData:${target}:${usage}:${typeof data === "number" ? data : "data"}`)
|
|
2589
2554
|
);
|
|
2590
|
-
this.bufferSubData =
|
|
2555
|
+
this.bufferSubData = import_vitest10.vi.fn(
|
|
2591
2556
|
(target, offset, data) => this.calls.push(`bufferSubData:${target}:${offset}:${data.byteLength ?? "len"}`)
|
|
2592
2557
|
);
|
|
2593
|
-
this.deleteBuffer =
|
|
2594
|
-
this.createVertexArray =
|
|
2595
|
-
this.bindVertexArray =
|
|
2596
|
-
this.enableVertexAttribArray =
|
|
2597
|
-
this.vertexAttribPointer =
|
|
2558
|
+
this.deleteBuffer = import_vitest10.vi.fn((buffer) => this.calls.push(`deleteBuffer:${!!buffer}`));
|
|
2559
|
+
this.createVertexArray = import_vitest10.vi.fn(() => ({ vao: {} }));
|
|
2560
|
+
this.bindVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`bindVertexArray:${!!vao}`));
|
|
2561
|
+
this.enableVertexAttribArray = import_vitest10.vi.fn((index) => this.calls.push(`enableAttrib:${index}`));
|
|
2562
|
+
this.vertexAttribPointer = import_vitest10.vi.fn(
|
|
2598
2563
|
(index, size, type, normalized, stride, offset) => this.calls.push(`vertexAttribPointer:${index}:${size}:${type}:${normalized}:${stride}:${offset}`)
|
|
2599
2564
|
);
|
|
2600
|
-
this.vertexAttribDivisor =
|
|
2601
|
-
this.deleteVertexArray =
|
|
2602
|
-
this.createTexture =
|
|
2603
|
-
this.activeTexture =
|
|
2604
|
-
this.bindTexture =
|
|
2605
|
-
this.texParameteri =
|
|
2565
|
+
this.vertexAttribDivisor = import_vitest10.vi.fn((index, divisor) => this.calls.push(`divisor:${index}:${divisor}`));
|
|
2566
|
+
this.deleteVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`deleteVertexArray:${!!vao}`));
|
|
2567
|
+
this.createTexture = import_vitest10.vi.fn(() => ({ texture: {} }));
|
|
2568
|
+
this.activeTexture = import_vitest10.vi.fn((unit) => this.calls.push(`activeTexture:${unit}`));
|
|
2569
|
+
this.bindTexture = import_vitest10.vi.fn((target, texture) => this.calls.push(`bindTexture:${target}:${!!texture}`));
|
|
2570
|
+
this.texParameteri = import_vitest10.vi.fn(
|
|
2606
2571
|
(target, pname, param) => this.calls.push(`texParameteri:${target}:${pname}:${param}`)
|
|
2607
2572
|
);
|
|
2608
|
-
this.texImage2D =
|
|
2573
|
+
this.texImage2D = import_vitest10.vi.fn(
|
|
2609
2574
|
(target, level, internalFormat, width, height, border, format, type, pixels) => this.calls.push(
|
|
2610
2575
|
`texImage2D:${target}:${level}:${internalFormat}:${width}:${height}:${border}:${format}:${type}:${pixels ? "data" : "null"}`
|
|
2611
2576
|
)
|
|
2612
2577
|
);
|
|
2613
|
-
this.texImage3D =
|
|
2578
|
+
this.texImage3D = import_vitest10.vi.fn();
|
|
2614
2579
|
// Stub for compatibility
|
|
2615
|
-
this.deleteTexture =
|
|
2616
|
-
this.createFramebuffer =
|
|
2617
|
-
this.bindFramebuffer =
|
|
2580
|
+
this.deleteTexture = import_vitest10.vi.fn((texture) => this.calls.push(`deleteTexture:${!!texture}`));
|
|
2581
|
+
this.createFramebuffer = import_vitest10.vi.fn(() => ({ fb: {} }));
|
|
2582
|
+
this.bindFramebuffer = import_vitest10.vi.fn(
|
|
2618
2583
|
(target, framebuffer) => this.calls.push(`bindFramebuffer:${target}:${!!framebuffer}`)
|
|
2619
2584
|
);
|
|
2620
|
-
this.framebufferTexture2D =
|
|
2585
|
+
this.framebufferTexture2D = import_vitest10.vi.fn(
|
|
2621
2586
|
(target, attachment, textarget, texture, level) => this.calls.push(`framebufferTexture2D:${target}:${attachment}:${textarget}:${!!texture}:${level}`)
|
|
2622
2587
|
);
|
|
2623
|
-
this.deleteFramebuffer =
|
|
2624
|
-
this.checkFramebufferStatus =
|
|
2625
|
-
this.createRenderbuffer =
|
|
2626
|
-
this.bindRenderbuffer =
|
|
2588
|
+
this.deleteFramebuffer = import_vitest10.vi.fn((fb) => this.calls.push(`deleteFramebuffer:${!!fb}`));
|
|
2589
|
+
this.checkFramebufferStatus = import_vitest10.vi.fn((target) => this.FRAMEBUFFER_COMPLETE);
|
|
2590
|
+
this.createRenderbuffer = import_vitest10.vi.fn(() => ({ rb: {} }));
|
|
2591
|
+
this.bindRenderbuffer = import_vitest10.vi.fn(
|
|
2627
2592
|
(target, renderbuffer) => this.calls.push(`bindRenderbuffer:${target}:${!!renderbuffer}`)
|
|
2628
2593
|
);
|
|
2629
|
-
this.renderbufferStorage =
|
|
2594
|
+
this.renderbufferStorage = import_vitest10.vi.fn(
|
|
2630
2595
|
(target, internalformat, width, height) => this.calls.push(`renderbufferStorage:${target}:${internalformat}:${width}:${height}`)
|
|
2631
2596
|
);
|
|
2632
|
-
this.framebufferRenderbuffer =
|
|
2597
|
+
this.framebufferRenderbuffer = import_vitest10.vi.fn(
|
|
2633
2598
|
(target, attachment, renderbuffertarget, renderbuffer) => this.calls.push(`framebufferRenderbuffer:${target}:${attachment}:${renderbuffertarget}:${!!renderbuffer}`)
|
|
2634
2599
|
);
|
|
2635
|
-
this.deleteRenderbuffer =
|
|
2636
|
-
this.drawArrays =
|
|
2600
|
+
this.deleteRenderbuffer = import_vitest10.vi.fn((rb) => this.calls.push(`deleteRenderbuffer:${!!rb}`));
|
|
2601
|
+
this.drawArrays = import_vitest10.vi.fn(
|
|
2637
2602
|
(mode, first, count) => this.calls.push(`drawArrays:${mode}:${first}:${count}`)
|
|
2638
2603
|
);
|
|
2639
|
-
this.drawElements =
|
|
2604
|
+
this.drawElements = import_vitest10.vi.fn(
|
|
2640
2605
|
(mode, count, type, offset) => this.calls.push(`drawElements:${mode}:${count}:${type}:${offset}`)
|
|
2641
2606
|
);
|
|
2642
2607
|
// Queries
|
|
2643
|
-
this.createQuery =
|
|
2644
|
-
this.beginQuery =
|
|
2645
|
-
this.endQuery =
|
|
2646
|
-
this.deleteQuery =
|
|
2647
|
-
this.getQueryParameter =
|
|
2648
|
-
this.getParameter =
|
|
2649
|
-
this.uniform1f =
|
|
2608
|
+
this.createQuery = import_vitest10.vi.fn(() => ({}));
|
|
2609
|
+
this.beginQuery = import_vitest10.vi.fn();
|
|
2610
|
+
this.endQuery = import_vitest10.vi.fn();
|
|
2611
|
+
this.deleteQuery = import_vitest10.vi.fn();
|
|
2612
|
+
this.getQueryParameter = import_vitest10.vi.fn();
|
|
2613
|
+
this.getParameter = import_vitest10.vi.fn();
|
|
2614
|
+
this.uniform1f = import_vitest10.vi.fn(
|
|
2650
2615
|
(location, x) => this.calls.push(`uniform1f:${location ? "set" : "null"}:${x}`)
|
|
2651
2616
|
);
|
|
2652
|
-
this.uniform1i =
|
|
2617
|
+
this.uniform1i = import_vitest10.vi.fn(
|
|
2653
2618
|
(location, x) => this.calls.push(`uniform1i:${location ? "set" : "null"}:${x}`)
|
|
2654
2619
|
);
|
|
2655
|
-
this.uniform4f =
|
|
2620
|
+
this.uniform4f = import_vitest10.vi.fn(
|
|
2656
2621
|
(location, x, y, z, w) => this.calls.push(`uniform4f:${location ? "set" : "null"}:${x}:${y}:${z}:${w}`)
|
|
2657
2622
|
);
|
|
2658
|
-
this.uniform3fv =
|
|
2623
|
+
this.uniform3fv = import_vitest10.vi.fn(
|
|
2659
2624
|
(location, data) => this.calls.push(`uniform3fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
2660
2625
|
);
|
|
2661
|
-
this.uniform3f =
|
|
2626
|
+
this.uniform3f = import_vitest10.vi.fn(
|
|
2662
2627
|
(location, x, y, z) => this.calls.push(`uniform3f:${location ? "set" : "null"}:${x}:${y}:${z}`)
|
|
2663
2628
|
);
|
|
2664
|
-
this.uniform2f =
|
|
2629
|
+
this.uniform2f = import_vitest10.vi.fn(
|
|
2665
2630
|
(location, x, y) => this.calls.push(`uniform2f:${location ? "set" : "null"}:${x}:${y}`)
|
|
2666
2631
|
);
|
|
2667
|
-
this.uniform4fv =
|
|
2632
|
+
this.uniform4fv = import_vitest10.vi.fn(
|
|
2668
2633
|
(location, data) => this.calls.push(`uniform4fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
2669
2634
|
);
|
|
2670
|
-
this.uniformMatrix4fv =
|
|
2635
|
+
this.uniformMatrix4fv = import_vitest10.vi.fn(
|
|
2671
2636
|
(location, transpose, data) => this.calls.push(`uniformMatrix4fv:${location ? "set" : "null"}:${transpose}:${Array.from(data).join(",")}`)
|
|
2672
2637
|
);
|
|
2673
|
-
this.uniformBlockBinding =
|
|
2674
|
-
this.isContextLost =
|
|
2638
|
+
this.uniformBlockBinding = import_vitest10.vi.fn();
|
|
2639
|
+
this.isContextLost = import_vitest10.vi.fn(() => false);
|
|
2675
2640
|
if (canvas) {
|
|
2676
2641
|
this.canvas = canvas;
|
|
2677
2642
|
this.drawingBufferWidth = canvas.width;
|
|
@@ -3031,13 +2996,13 @@ async function createHeadlessTestContext() {
|
|
|
3031
2996
|
}
|
|
3032
2997
|
|
|
3033
2998
|
// src/engine/mocks/webgpu.ts
|
|
3034
|
-
var
|
|
2999
|
+
var import_vitest11 = require("vitest");
|
|
3035
3000
|
var import_webgpu = require("webgpu");
|
|
3036
3001
|
function setupWebGPUMocks() {
|
|
3037
3002
|
Object.assign(globalThis, import_webgpu.globals);
|
|
3038
3003
|
const mockGpu = {
|
|
3039
|
-
requestAdapter:
|
|
3040
|
-
getPreferredCanvasFormat:
|
|
3004
|
+
requestAdapter: import_vitest11.vi.fn(),
|
|
3005
|
+
getPreferredCanvasFormat: import_vitest11.vi.fn().mockReturnValue("bgra8unorm")
|
|
3041
3006
|
};
|
|
3042
3007
|
const mockAdapter = createMockGPUAdapter();
|
|
3043
3008
|
const mockDevice = createMockGPUDevice();
|
|
@@ -3066,8 +3031,8 @@ function createMockGPUAdapter(options = {}) {
|
|
|
3066
3031
|
features: /* @__PURE__ */ new Set(),
|
|
3067
3032
|
limits: {},
|
|
3068
3033
|
isFallbackAdapter: false,
|
|
3069
|
-
requestDevice:
|
|
3070
|
-
requestAdapterInfo:
|
|
3034
|
+
requestDevice: import_vitest11.vi.fn().mockResolvedValue(createMockGPUDevice()),
|
|
3035
|
+
requestAdapterInfo: import_vitest11.vi.fn().mockResolvedValue({}),
|
|
3071
3036
|
...options
|
|
3072
3037
|
};
|
|
3073
3038
|
}
|
|
@@ -3077,25 +3042,25 @@ function createMockGPUDevice(features = /* @__PURE__ */ new Set()) {
|
|
|
3077
3042
|
features,
|
|
3078
3043
|
limits: {},
|
|
3079
3044
|
queue,
|
|
3080
|
-
destroy:
|
|
3081
|
-
createBuffer:
|
|
3082
|
-
createTexture:
|
|
3083
|
-
createSampler:
|
|
3084
|
-
createBindGroupLayout:
|
|
3085
|
-
createPipelineLayout:
|
|
3086
|
-
createBindGroup:
|
|
3087
|
-
createShaderModule:
|
|
3088
|
-
createComputePipeline:
|
|
3089
|
-
createRenderPipeline:
|
|
3090
|
-
createComputePipelineAsync:
|
|
3091
|
-
createRenderPipelineAsync:
|
|
3092
|
-
createCommandEncoder:
|
|
3093
|
-
createQuerySet:
|
|
3094
|
-
pushErrorScope:
|
|
3095
|
-
popErrorScope:
|
|
3096
|
-
addEventListener:
|
|
3097
|
-
removeEventListener:
|
|
3098
|
-
dispatchEvent:
|
|
3045
|
+
destroy: import_vitest11.vi.fn(),
|
|
3046
|
+
createBuffer: import_vitest11.vi.fn((descriptor) => createMockGPUBuffer(descriptor)),
|
|
3047
|
+
createTexture: import_vitest11.vi.fn((descriptor) => createMockGPUTexture(descriptor)),
|
|
3048
|
+
createSampler: import_vitest11.vi.fn(() => createMockSampler()),
|
|
3049
|
+
createBindGroupLayout: import_vitest11.vi.fn(() => ({ label: "mock-bind-group-layout" })),
|
|
3050
|
+
createPipelineLayout: import_vitest11.vi.fn(() => ({ label: "mock-pipeline-layout" })),
|
|
3051
|
+
createBindGroup: import_vitest11.vi.fn(() => ({ label: "mock-bind-group" })),
|
|
3052
|
+
createShaderModule: import_vitest11.vi.fn((descriptor) => createMockShaderModule(descriptor)),
|
|
3053
|
+
createComputePipeline: import_vitest11.vi.fn(() => createMockComputePipeline()),
|
|
3054
|
+
createRenderPipeline: import_vitest11.vi.fn(() => createMockRenderPipeline()),
|
|
3055
|
+
createComputePipelineAsync: import_vitest11.vi.fn().mockResolvedValue(createMockComputePipeline()),
|
|
3056
|
+
createRenderPipelineAsync: import_vitest11.vi.fn().mockResolvedValue(createMockRenderPipeline()),
|
|
3057
|
+
createCommandEncoder: import_vitest11.vi.fn(() => createMockCommandEncoder()),
|
|
3058
|
+
createQuerySet: import_vitest11.vi.fn(() => ({ label: "mock-query-set" })),
|
|
3059
|
+
pushErrorScope: import_vitest11.vi.fn(),
|
|
3060
|
+
popErrorScope: import_vitest11.vi.fn().mockResolvedValue(null),
|
|
3061
|
+
addEventListener: import_vitest11.vi.fn(),
|
|
3062
|
+
removeEventListener: import_vitest11.vi.fn(),
|
|
3063
|
+
dispatchEvent: import_vitest11.vi.fn(),
|
|
3099
3064
|
onuncapturederror: null,
|
|
3100
3065
|
label: "",
|
|
3101
3066
|
lost: Promise.resolve({ reason: "destroyed", message: "Device lost" })
|
|
@@ -3103,11 +3068,11 @@ function createMockGPUDevice(features = /* @__PURE__ */ new Set()) {
|
|
|
3103
3068
|
}
|
|
3104
3069
|
function createMockQueue() {
|
|
3105
3070
|
return {
|
|
3106
|
-
submit:
|
|
3107
|
-
onSubmittedWorkDone:
|
|
3108
|
-
writeBuffer:
|
|
3109
|
-
writeTexture:
|
|
3110
|
-
copyExternalImageToTexture:
|
|
3071
|
+
submit: import_vitest11.vi.fn(),
|
|
3072
|
+
onSubmittedWorkDone: import_vitest11.vi.fn().mockResolvedValue(void 0),
|
|
3073
|
+
writeBuffer: import_vitest11.vi.fn(),
|
|
3074
|
+
writeTexture: import_vitest11.vi.fn(),
|
|
3075
|
+
copyExternalImageToTexture: import_vitest11.vi.fn(),
|
|
3111
3076
|
label: ""
|
|
3112
3077
|
};
|
|
3113
3078
|
}
|
|
@@ -3116,10 +3081,10 @@ function createMockGPUBuffer(descriptor) {
|
|
|
3116
3081
|
size: descriptor.size,
|
|
3117
3082
|
usage: descriptor.usage,
|
|
3118
3083
|
mapState: "unmapped",
|
|
3119
|
-
mapAsync:
|
|
3120
|
-
getMappedRange:
|
|
3121
|
-
unmap:
|
|
3122
|
-
destroy:
|
|
3084
|
+
mapAsync: import_vitest11.vi.fn().mockResolvedValue(void 0),
|
|
3085
|
+
getMappedRange: import_vitest11.vi.fn(() => new ArrayBuffer(descriptor.size)),
|
|
3086
|
+
unmap: import_vitest11.vi.fn(),
|
|
3087
|
+
destroy: import_vitest11.vi.fn(),
|
|
3123
3088
|
label: descriptor.label || ""
|
|
3124
3089
|
};
|
|
3125
3090
|
}
|
|
@@ -3148,8 +3113,8 @@ function createMockGPUTexture(descriptor) {
|
|
|
3148
3113
|
dimension: descriptor.dimension || "2d",
|
|
3149
3114
|
format: descriptor.format,
|
|
3150
3115
|
usage: descriptor.usage,
|
|
3151
|
-
createView:
|
|
3152
|
-
destroy:
|
|
3116
|
+
createView: import_vitest11.vi.fn(() => createMockTextureView()),
|
|
3117
|
+
destroy: import_vitest11.vi.fn(),
|
|
3153
3118
|
label: descriptor.label || ""
|
|
3154
3119
|
};
|
|
3155
3120
|
}
|
|
@@ -3165,74 +3130,74 @@ function createMockSampler() {
|
|
|
3165
3130
|
}
|
|
3166
3131
|
function createMockShaderModule(descriptor) {
|
|
3167
3132
|
return {
|
|
3168
|
-
getCompilationInfo:
|
|
3133
|
+
getCompilationInfo: import_vitest11.vi.fn().mockResolvedValue({ messages: [] }),
|
|
3169
3134
|
label: descriptor.label || ""
|
|
3170
3135
|
};
|
|
3171
3136
|
}
|
|
3172
3137
|
function createMockComputePipeline() {
|
|
3173
3138
|
return {
|
|
3174
|
-
getBindGroupLayout:
|
|
3139
|
+
getBindGroupLayout: import_vitest11.vi.fn(() => ({ label: "mock-bind-group-layout" })),
|
|
3175
3140
|
label: ""
|
|
3176
3141
|
};
|
|
3177
3142
|
}
|
|
3178
3143
|
function createMockRenderPipeline() {
|
|
3179
3144
|
return {
|
|
3180
|
-
getBindGroupLayout:
|
|
3145
|
+
getBindGroupLayout: import_vitest11.vi.fn(() => ({ label: "mock-bind-group-layout" })),
|
|
3181
3146
|
label: ""
|
|
3182
3147
|
};
|
|
3183
3148
|
}
|
|
3184
3149
|
function createMockCommandEncoder() {
|
|
3185
3150
|
return {
|
|
3186
|
-
beginRenderPass:
|
|
3187
|
-
beginComputePass:
|
|
3188
|
-
copyBufferToBuffer:
|
|
3189
|
-
copyBufferToTexture:
|
|
3190
|
-
copyTextureToBuffer:
|
|
3191
|
-
copyTextureToTexture:
|
|
3192
|
-
clearBuffer:
|
|
3193
|
-
writeTimestamp:
|
|
3194
|
-
resolveQuerySet:
|
|
3195
|
-
finish:
|
|
3196
|
-
pushDebugGroup:
|
|
3197
|
-
popDebugGroup:
|
|
3198
|
-
insertDebugMarker:
|
|
3151
|
+
beginRenderPass: import_vitest11.vi.fn(() => createMockRenderPassEncoder()),
|
|
3152
|
+
beginComputePass: import_vitest11.vi.fn(() => createMockComputePassEncoder()),
|
|
3153
|
+
copyBufferToBuffer: import_vitest11.vi.fn(),
|
|
3154
|
+
copyBufferToTexture: import_vitest11.vi.fn(),
|
|
3155
|
+
copyTextureToBuffer: import_vitest11.vi.fn(),
|
|
3156
|
+
copyTextureToTexture: import_vitest11.vi.fn(),
|
|
3157
|
+
clearBuffer: import_vitest11.vi.fn(),
|
|
3158
|
+
writeTimestamp: import_vitest11.vi.fn(),
|
|
3159
|
+
resolveQuerySet: import_vitest11.vi.fn(),
|
|
3160
|
+
finish: import_vitest11.vi.fn(() => ({ label: "mock-command-buffer" })),
|
|
3161
|
+
pushDebugGroup: import_vitest11.vi.fn(),
|
|
3162
|
+
popDebugGroup: import_vitest11.vi.fn(),
|
|
3163
|
+
insertDebugMarker: import_vitest11.vi.fn(),
|
|
3199
3164
|
label: ""
|
|
3200
3165
|
};
|
|
3201
3166
|
}
|
|
3202
3167
|
function createMockRenderPassEncoder() {
|
|
3203
3168
|
return {
|
|
3204
|
-
setPipeline:
|
|
3205
|
-
setIndexBuffer:
|
|
3206
|
-
setVertexBuffer:
|
|
3207
|
-
setBindGroup:
|
|
3208
|
-
setViewport:
|
|
3209
|
-
setScissorRect:
|
|
3210
|
-
setBlendConstant:
|
|
3211
|
-
setStencilReference:
|
|
3212
|
-
beginOcclusionQuery:
|
|
3213
|
-
endOcclusionQuery:
|
|
3214
|
-
executeBundles:
|
|
3215
|
-
draw:
|
|
3216
|
-
drawIndexed:
|
|
3217
|
-
drawIndirect:
|
|
3218
|
-
drawIndexedIndirect:
|
|
3219
|
-
end:
|
|
3220
|
-
pushDebugGroup:
|
|
3221
|
-
popDebugGroup:
|
|
3222
|
-
insertDebugMarker:
|
|
3169
|
+
setPipeline: import_vitest11.vi.fn(),
|
|
3170
|
+
setIndexBuffer: import_vitest11.vi.fn(),
|
|
3171
|
+
setVertexBuffer: import_vitest11.vi.fn(),
|
|
3172
|
+
setBindGroup: import_vitest11.vi.fn(),
|
|
3173
|
+
setViewport: import_vitest11.vi.fn(),
|
|
3174
|
+
setScissorRect: import_vitest11.vi.fn(),
|
|
3175
|
+
setBlendConstant: import_vitest11.vi.fn(),
|
|
3176
|
+
setStencilReference: import_vitest11.vi.fn(),
|
|
3177
|
+
beginOcclusionQuery: import_vitest11.vi.fn(),
|
|
3178
|
+
endOcclusionQuery: import_vitest11.vi.fn(),
|
|
3179
|
+
executeBundles: import_vitest11.vi.fn(),
|
|
3180
|
+
draw: import_vitest11.vi.fn(),
|
|
3181
|
+
drawIndexed: import_vitest11.vi.fn(),
|
|
3182
|
+
drawIndirect: import_vitest11.vi.fn(),
|
|
3183
|
+
drawIndexedIndirect: import_vitest11.vi.fn(),
|
|
3184
|
+
end: import_vitest11.vi.fn(),
|
|
3185
|
+
pushDebugGroup: import_vitest11.vi.fn(),
|
|
3186
|
+
popDebugGroup: import_vitest11.vi.fn(),
|
|
3187
|
+
insertDebugMarker: import_vitest11.vi.fn(),
|
|
3223
3188
|
label: ""
|
|
3224
3189
|
};
|
|
3225
3190
|
}
|
|
3226
3191
|
function createMockComputePassEncoder() {
|
|
3227
3192
|
return {
|
|
3228
|
-
setPipeline:
|
|
3229
|
-
setBindGroup:
|
|
3230
|
-
dispatchWorkgroups:
|
|
3231
|
-
dispatchWorkgroupsIndirect:
|
|
3232
|
-
end:
|
|
3233
|
-
pushDebugGroup:
|
|
3234
|
-
popDebugGroup:
|
|
3235
|
-
insertDebugMarker:
|
|
3193
|
+
setPipeline: import_vitest11.vi.fn(),
|
|
3194
|
+
setBindGroup: import_vitest11.vi.fn(),
|
|
3195
|
+
dispatchWorkgroups: import_vitest11.vi.fn(),
|
|
3196
|
+
dispatchWorkgroupsIndirect: import_vitest11.vi.fn(),
|
|
3197
|
+
end: import_vitest11.vi.fn(),
|
|
3198
|
+
pushDebugGroup: import_vitest11.vi.fn(),
|
|
3199
|
+
popDebugGroup: import_vitest11.vi.fn(),
|
|
3200
|
+
insertDebugMarker: import_vitest11.vi.fn(),
|
|
3236
3201
|
label: ""
|
|
3237
3202
|
};
|
|
3238
3203
|
}
|
|
@@ -3459,67 +3424,67 @@ var createMockBufferSource = (buffer) => {
|
|
|
3459
3424
|
};
|
|
3460
3425
|
|
|
3461
3426
|
// src/engine/mocks/renderer.ts
|
|
3462
|
-
var
|
|
3427
|
+
var import_vitest12 = require("vitest");
|
|
3463
3428
|
function createMockRenderer(overrides) {
|
|
3464
3429
|
return {
|
|
3465
3430
|
width: 800,
|
|
3466
3431
|
height: 600,
|
|
3467
3432
|
collisionVis: {
|
|
3468
|
-
render:
|
|
3469
|
-
clear:
|
|
3433
|
+
render: import_vitest12.vi.fn(),
|
|
3434
|
+
clear: import_vitest12.vi.fn(),
|
|
3470
3435
|
shaderSize: 0,
|
|
3471
|
-
dispose:
|
|
3436
|
+
dispose: import_vitest12.vi.fn()
|
|
3472
3437
|
},
|
|
3473
3438
|
debug: {
|
|
3474
|
-
render:
|
|
3475
|
-
clear:
|
|
3476
|
-
drawLine:
|
|
3477
|
-
drawBoundingBox:
|
|
3478
|
-
drawAxes:
|
|
3479
|
-
getLabels:
|
|
3439
|
+
render: import_vitest12.vi.fn(),
|
|
3440
|
+
clear: import_vitest12.vi.fn(),
|
|
3441
|
+
drawLine: import_vitest12.vi.fn(),
|
|
3442
|
+
drawBoundingBox: import_vitest12.vi.fn(),
|
|
3443
|
+
drawAxes: import_vitest12.vi.fn(),
|
|
3444
|
+
getLabels: import_vitest12.vi.fn().mockReturnValue([]),
|
|
3480
3445
|
shaderSize: 0,
|
|
3481
|
-
dispose:
|
|
3446
|
+
dispose: import_vitest12.vi.fn()
|
|
3482
3447
|
},
|
|
3483
3448
|
particleSystem: {
|
|
3484
|
-
update:
|
|
3485
|
-
emit:
|
|
3486
|
-
clear:
|
|
3449
|
+
update: import_vitest12.vi.fn(),
|
|
3450
|
+
emit: import_vitest12.vi.fn(),
|
|
3451
|
+
clear: import_vitest12.vi.fn(),
|
|
3487
3452
|
count: 0
|
|
3488
3453
|
},
|
|
3489
|
-
getPerformanceReport:
|
|
3490
|
-
getMemoryUsage:
|
|
3491
|
-
renderFrame:
|
|
3492
|
-
registerPic:
|
|
3493
|
-
registerTexture:
|
|
3494
|
-
begin2D:
|
|
3495
|
-
end2D:
|
|
3496
|
-
drawPic:
|
|
3497
|
-
drawString:
|
|
3498
|
-
drawCenterString:
|
|
3499
|
-
drawfillRect:
|
|
3500
|
-
setEntityHighlight:
|
|
3501
|
-
clearEntityHighlight:
|
|
3502
|
-
highlightSurface:
|
|
3503
|
-
removeSurfaceHighlight:
|
|
3504
|
-
setDebugMode:
|
|
3505
|
-
setBrightness:
|
|
3506
|
-
setGamma:
|
|
3507
|
-
setFullbright:
|
|
3508
|
-
setAmbient:
|
|
3509
|
-
setLightStyle:
|
|
3510
|
-
setUnderwaterWarp:
|
|
3511
|
-
setBloom:
|
|
3512
|
-
setBloomIntensity:
|
|
3513
|
-
setLodBias:
|
|
3514
|
-
setAreaPortalState:
|
|
3515
|
-
renderInstanced:
|
|
3516
|
-
dispose:
|
|
3454
|
+
getPerformanceReport: import_vitest12.vi.fn().mockReturnValue({}),
|
|
3455
|
+
getMemoryUsage: import_vitest12.vi.fn().mockReturnValue({}),
|
|
3456
|
+
renderFrame: import_vitest12.vi.fn(),
|
|
3457
|
+
registerPic: import_vitest12.vi.fn().mockResolvedValue({}),
|
|
3458
|
+
registerTexture: import_vitest12.vi.fn().mockReturnValue({}),
|
|
3459
|
+
begin2D: import_vitest12.vi.fn(),
|
|
3460
|
+
end2D: import_vitest12.vi.fn(),
|
|
3461
|
+
drawPic: import_vitest12.vi.fn(),
|
|
3462
|
+
drawString: import_vitest12.vi.fn(),
|
|
3463
|
+
drawCenterString: import_vitest12.vi.fn(),
|
|
3464
|
+
drawfillRect: import_vitest12.vi.fn(),
|
|
3465
|
+
setEntityHighlight: import_vitest12.vi.fn(),
|
|
3466
|
+
clearEntityHighlight: import_vitest12.vi.fn(),
|
|
3467
|
+
highlightSurface: import_vitest12.vi.fn(),
|
|
3468
|
+
removeSurfaceHighlight: import_vitest12.vi.fn(),
|
|
3469
|
+
setDebugMode: import_vitest12.vi.fn(),
|
|
3470
|
+
setBrightness: import_vitest12.vi.fn(),
|
|
3471
|
+
setGamma: import_vitest12.vi.fn(),
|
|
3472
|
+
setFullbright: import_vitest12.vi.fn(),
|
|
3473
|
+
setAmbient: import_vitest12.vi.fn(),
|
|
3474
|
+
setLightStyle: import_vitest12.vi.fn(),
|
|
3475
|
+
setUnderwaterWarp: import_vitest12.vi.fn(),
|
|
3476
|
+
setBloom: import_vitest12.vi.fn(),
|
|
3477
|
+
setBloomIntensity: import_vitest12.vi.fn(),
|
|
3478
|
+
setLodBias: import_vitest12.vi.fn(),
|
|
3479
|
+
setAreaPortalState: import_vitest12.vi.fn(),
|
|
3480
|
+
renderInstanced: import_vitest12.vi.fn(),
|
|
3481
|
+
dispose: import_vitest12.vi.fn(),
|
|
3517
3482
|
...overrides
|
|
3518
3483
|
};
|
|
3519
3484
|
}
|
|
3520
3485
|
function createMockFrameRenderer(overrides) {
|
|
3521
3486
|
return {
|
|
3522
|
-
renderFrame:
|
|
3487
|
+
renderFrame: import_vitest12.vi.fn().mockReturnValue({
|
|
3523
3488
|
batches: 0,
|
|
3524
3489
|
facesDrawn: 0,
|
|
3525
3490
|
drawCalls: 0,
|
|
@@ -3536,15 +3501,15 @@ function createMockBspPipeline(overrides) {
|
|
|
3536
3501
|
return {
|
|
3537
3502
|
gl,
|
|
3538
3503
|
program: {
|
|
3539
|
-
use:
|
|
3540
|
-
dispose:
|
|
3504
|
+
use: import_vitest12.vi.fn(),
|
|
3505
|
+
dispose: import_vitest12.vi.fn(),
|
|
3541
3506
|
sourceSize: 0,
|
|
3542
|
-
getUniformLocation:
|
|
3507
|
+
getUniformLocation: import_vitest12.vi.fn().mockReturnValue(null)
|
|
3543
3508
|
},
|
|
3544
3509
|
shaderSize: 0,
|
|
3545
|
-
bind:
|
|
3546
|
-
draw:
|
|
3547
|
-
dispose:
|
|
3510
|
+
bind: import_vitest12.vi.fn().mockReturnValue({}),
|
|
3511
|
+
draw: import_vitest12.vi.fn(),
|
|
3512
|
+
dispose: import_vitest12.vi.fn(),
|
|
3548
3513
|
...overrides
|
|
3549
3514
|
};
|
|
3550
3515
|
}
|
|
@@ -3553,15 +3518,15 @@ function createMockMd2Pipeline(overrides) {
|
|
|
3553
3518
|
return {
|
|
3554
3519
|
gl,
|
|
3555
3520
|
program: {
|
|
3556
|
-
use:
|
|
3557
|
-
dispose:
|
|
3521
|
+
use: import_vitest12.vi.fn(),
|
|
3522
|
+
dispose: import_vitest12.vi.fn(),
|
|
3558
3523
|
sourceSize: 0,
|
|
3559
|
-
getUniformLocation:
|
|
3524
|
+
getUniformLocation: import_vitest12.vi.fn().mockReturnValue(null)
|
|
3560
3525
|
},
|
|
3561
3526
|
shaderSize: 0,
|
|
3562
|
-
bind:
|
|
3563
|
-
draw:
|
|
3564
|
-
dispose:
|
|
3527
|
+
bind: import_vitest12.vi.fn(),
|
|
3528
|
+
draw: import_vitest12.vi.fn(),
|
|
3529
|
+
dispose: import_vitest12.vi.fn(),
|
|
3565
3530
|
...overrides
|
|
3566
3531
|
};
|
|
3567
3532
|
}
|
|
@@ -3570,15 +3535,15 @@ function createMockMd3Pipeline(overrides) {
|
|
|
3570
3535
|
return {
|
|
3571
3536
|
gl,
|
|
3572
3537
|
program: {
|
|
3573
|
-
use:
|
|
3574
|
-
dispose:
|
|
3538
|
+
use: import_vitest12.vi.fn(),
|
|
3539
|
+
dispose: import_vitest12.vi.fn(),
|
|
3575
3540
|
sourceSize: 0,
|
|
3576
|
-
getUniformLocation:
|
|
3541
|
+
getUniformLocation: import_vitest12.vi.fn().mockReturnValue(null)
|
|
3577
3542
|
},
|
|
3578
3543
|
shaderSize: 0,
|
|
3579
|
-
bind:
|
|
3580
|
-
drawSurface:
|
|
3581
|
-
dispose:
|
|
3544
|
+
bind: import_vitest12.vi.fn(),
|
|
3545
|
+
drawSurface: import_vitest12.vi.fn(),
|
|
3546
|
+
dispose: import_vitest12.vi.fn(),
|
|
3582
3547
|
...overrides
|
|
3583
3548
|
};
|
|
3584
3549
|
}
|
|
@@ -3587,29 +3552,29 @@ function createMockSpritePipeline(overrides) {
|
|
|
3587
3552
|
return {
|
|
3588
3553
|
gl,
|
|
3589
3554
|
program: {
|
|
3590
|
-
use:
|
|
3591
|
-
dispose:
|
|
3555
|
+
use: import_vitest12.vi.fn(),
|
|
3556
|
+
dispose: import_vitest12.vi.fn(),
|
|
3592
3557
|
sourceSize: 0,
|
|
3593
|
-
getUniformLocation:
|
|
3558
|
+
getUniformLocation: import_vitest12.vi.fn().mockReturnValue(null)
|
|
3594
3559
|
},
|
|
3595
3560
|
shaderSize: 0,
|
|
3596
3561
|
vao: {
|
|
3597
|
-
bind:
|
|
3598
|
-
dispose:
|
|
3599
|
-
configureAttributes:
|
|
3562
|
+
bind: import_vitest12.vi.fn(),
|
|
3563
|
+
dispose: import_vitest12.vi.fn(),
|
|
3564
|
+
configureAttributes: import_vitest12.vi.fn()
|
|
3600
3565
|
},
|
|
3601
3566
|
vbo: {
|
|
3602
|
-
bind:
|
|
3603
|
-
dispose:
|
|
3604
|
-
upload:
|
|
3567
|
+
bind: import_vitest12.vi.fn(),
|
|
3568
|
+
dispose: import_vitest12.vi.fn(),
|
|
3569
|
+
upload: import_vitest12.vi.fn()
|
|
3605
3570
|
},
|
|
3606
3571
|
whiteTexture: {
|
|
3607
|
-
bind:
|
|
3608
|
-
upload:
|
|
3572
|
+
bind: import_vitest12.vi.fn(),
|
|
3573
|
+
upload: import_vitest12.vi.fn()
|
|
3609
3574
|
},
|
|
3610
|
-
begin:
|
|
3611
|
-
draw:
|
|
3612
|
-
drawRect:
|
|
3575
|
+
begin: import_vitest12.vi.fn(),
|
|
3576
|
+
draw: import_vitest12.vi.fn(),
|
|
3577
|
+
drawRect: import_vitest12.vi.fn(),
|
|
3613
3578
|
...overrides
|
|
3614
3579
|
};
|
|
3615
3580
|
}
|
|
@@ -3618,69 +3583,69 @@ function createMockSkyboxPipeline(overrides) {
|
|
|
3618
3583
|
return {
|
|
3619
3584
|
gl,
|
|
3620
3585
|
program: {
|
|
3621
|
-
use:
|
|
3622
|
-
dispose:
|
|
3586
|
+
use: import_vitest12.vi.fn(),
|
|
3587
|
+
dispose: import_vitest12.vi.fn(),
|
|
3623
3588
|
sourceSize: 0,
|
|
3624
|
-
getUniformLocation:
|
|
3589
|
+
getUniformLocation: import_vitest12.vi.fn().mockReturnValue(null)
|
|
3625
3590
|
},
|
|
3626
3591
|
vao: {
|
|
3627
|
-
bind:
|
|
3628
|
-
dispose:
|
|
3629
|
-
configureAttributes:
|
|
3592
|
+
bind: import_vitest12.vi.fn(),
|
|
3593
|
+
dispose: import_vitest12.vi.fn(),
|
|
3594
|
+
configureAttributes: import_vitest12.vi.fn()
|
|
3630
3595
|
},
|
|
3631
3596
|
vbo: {
|
|
3632
|
-
bind:
|
|
3633
|
-
dispose:
|
|
3634
|
-
upload:
|
|
3597
|
+
bind: import_vitest12.vi.fn(),
|
|
3598
|
+
dispose: import_vitest12.vi.fn(),
|
|
3599
|
+
upload: import_vitest12.vi.fn()
|
|
3635
3600
|
},
|
|
3636
3601
|
cubemap: {
|
|
3637
|
-
bind:
|
|
3638
|
-
dispose:
|
|
3639
|
-
setParameters:
|
|
3640
|
-
upload:
|
|
3602
|
+
bind: import_vitest12.vi.fn(),
|
|
3603
|
+
dispose: import_vitest12.vi.fn(),
|
|
3604
|
+
setParameters: import_vitest12.vi.fn(),
|
|
3605
|
+
upload: import_vitest12.vi.fn()
|
|
3641
3606
|
},
|
|
3642
3607
|
shaderSize: 0,
|
|
3643
|
-
bind:
|
|
3644
|
-
draw:
|
|
3645
|
-
dispose:
|
|
3608
|
+
bind: import_vitest12.vi.fn(),
|
|
3609
|
+
draw: import_vitest12.vi.fn(),
|
|
3610
|
+
dispose: import_vitest12.vi.fn(),
|
|
3646
3611
|
...overrides
|
|
3647
3612
|
};
|
|
3648
3613
|
}
|
|
3649
3614
|
|
|
3650
3615
|
// src/engine/mocks/assets.ts
|
|
3651
|
-
var
|
|
3616
|
+
var import_vitest13 = require("vitest");
|
|
3652
3617
|
function createMockAssetManager(overrides) {
|
|
3653
3618
|
return {
|
|
3654
3619
|
textures: {
|
|
3655
|
-
get:
|
|
3656
|
-
set:
|
|
3657
|
-
has:
|
|
3658
|
-
clear:
|
|
3620
|
+
get: import_vitest13.vi.fn(),
|
|
3621
|
+
set: import_vitest13.vi.fn(),
|
|
3622
|
+
has: import_vitest13.vi.fn(),
|
|
3623
|
+
clear: import_vitest13.vi.fn(),
|
|
3659
3624
|
memoryUsage: 0
|
|
3660
3625
|
},
|
|
3661
3626
|
audio: {
|
|
3662
|
-
load:
|
|
3663
|
-
get:
|
|
3664
|
-
clearAll:
|
|
3627
|
+
load: import_vitest13.vi.fn(),
|
|
3628
|
+
get: import_vitest13.vi.fn(),
|
|
3629
|
+
clearAll: import_vitest13.vi.fn()
|
|
3665
3630
|
},
|
|
3666
|
-
loadTexture:
|
|
3667
|
-
registerTexture:
|
|
3668
|
-
loadSound:
|
|
3669
|
-
loadMd2Model:
|
|
3670
|
-
getMd2Model:
|
|
3671
|
-
loadMd3Model:
|
|
3672
|
-
getMd3Model:
|
|
3673
|
-
loadSprite:
|
|
3674
|
-
loadMap:
|
|
3675
|
-
getMap:
|
|
3676
|
-
loadPalette:
|
|
3677
|
-
isAssetLoaded:
|
|
3678
|
-
listFiles:
|
|
3679
|
-
resetForLevelChange:
|
|
3680
|
-
getMemoryUsage:
|
|
3681
|
-
clearCache:
|
|
3682
|
-
preloadAssets:
|
|
3683
|
-
queueLoad:
|
|
3631
|
+
loadTexture: import_vitest13.vi.fn().mockResolvedValue({}),
|
|
3632
|
+
registerTexture: import_vitest13.vi.fn(),
|
|
3633
|
+
loadSound: import_vitest13.vi.fn().mockResolvedValue({}),
|
|
3634
|
+
loadMd2Model: import_vitest13.vi.fn().mockResolvedValue({}),
|
|
3635
|
+
getMd2Model: import_vitest13.vi.fn(),
|
|
3636
|
+
loadMd3Model: import_vitest13.vi.fn().mockResolvedValue({}),
|
|
3637
|
+
getMd3Model: import_vitest13.vi.fn(),
|
|
3638
|
+
loadSprite: import_vitest13.vi.fn().mockResolvedValue({}),
|
|
3639
|
+
loadMap: import_vitest13.vi.fn().mockResolvedValue({}),
|
|
3640
|
+
getMap: import_vitest13.vi.fn(),
|
|
3641
|
+
loadPalette: import_vitest13.vi.fn().mockResolvedValue(void 0),
|
|
3642
|
+
isAssetLoaded: import_vitest13.vi.fn().mockReturnValue(true),
|
|
3643
|
+
listFiles: import_vitest13.vi.fn().mockReturnValue([]),
|
|
3644
|
+
resetForLevelChange: import_vitest13.vi.fn(),
|
|
3645
|
+
getMemoryUsage: import_vitest13.vi.fn().mockReturnValue({ textures: 0, audio: 0 }),
|
|
3646
|
+
clearCache: import_vitest13.vi.fn(),
|
|
3647
|
+
preloadAssets: import_vitest13.vi.fn().mockResolvedValue(void 0),
|
|
3648
|
+
queueLoad: import_vitest13.vi.fn().mockImplementation((path4) => Promise.resolve({})),
|
|
3684
3649
|
...overrides
|
|
3685
3650
|
};
|
|
3686
3651
|
}
|
|
@@ -3768,16 +3733,16 @@ function createMockBspMap(overrides) {
|
|
|
3768
3733
|
}
|
|
3769
3734
|
|
|
3770
3735
|
// src/engine/mocks/buffers.ts
|
|
3771
|
-
var
|
|
3736
|
+
var import_vitest14 = require("vitest");
|
|
3772
3737
|
var import_engine4 = require("@quake2ts/engine");
|
|
3773
3738
|
var import_engine5 = require("@quake2ts/engine");
|
|
3774
3739
|
function createMockVertexBuffer(data, usage) {
|
|
3775
3740
|
const gl = createMockWebGL2Context();
|
|
3776
3741
|
const vb = new import_engine4.VertexBuffer(gl, usage ?? gl.STATIC_DRAW);
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3742
|
+
import_vitest14.vi.spyOn(vb, "bind");
|
|
3743
|
+
import_vitest14.vi.spyOn(vb, "upload");
|
|
3744
|
+
import_vitest14.vi.spyOn(vb, "update");
|
|
3745
|
+
import_vitest14.vi.spyOn(vb, "dispose");
|
|
3781
3746
|
if (data) {
|
|
3782
3747
|
vb.upload(data, usage ?? gl.STATIC_DRAW);
|
|
3783
3748
|
}
|
|
@@ -3786,10 +3751,10 @@ function createMockVertexBuffer(data, usage) {
|
|
|
3786
3751
|
function createMockIndexBuffer(data, usage) {
|
|
3787
3752
|
const gl = createMockWebGL2Context();
|
|
3788
3753
|
const ib = new import_engine4.IndexBuffer(gl, usage ?? gl.STATIC_DRAW);
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3754
|
+
import_vitest14.vi.spyOn(ib, "bind");
|
|
3755
|
+
import_vitest14.vi.spyOn(ib, "upload");
|
|
3756
|
+
import_vitest14.vi.spyOn(ib, "update");
|
|
3757
|
+
import_vitest14.vi.spyOn(ib, "dispose");
|
|
3793
3758
|
if (data) {
|
|
3794
3759
|
ib.upload(data, usage ?? gl.STATIC_DRAW);
|
|
3795
3760
|
}
|
|
@@ -3802,10 +3767,10 @@ function createMockShaderProgram(overrides) {
|
|
|
3802
3767
|
fragment: "#version 300 es\nvoid main() {}"
|
|
3803
3768
|
};
|
|
3804
3769
|
const program = import_engine5.ShaderProgram.create(gl, dummySources);
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3770
|
+
import_vitest14.vi.spyOn(program, "use");
|
|
3771
|
+
import_vitest14.vi.spyOn(program, "getUniformLocation");
|
|
3772
|
+
import_vitest14.vi.spyOn(program, "getAttributeLocation");
|
|
3773
|
+
import_vitest14.vi.spyOn(program, "dispose");
|
|
3809
3774
|
if (overrides) {
|
|
3810
3775
|
Object.assign(program, overrides);
|
|
3811
3776
|
}
|
|
@@ -3821,7 +3786,7 @@ function createMockShader(vertSource, fragSource) {
|
|
|
3821
3786
|
}
|
|
3822
3787
|
|
|
3823
3788
|
// src/engine/mocks/lighting.ts
|
|
3824
|
-
var
|
|
3789
|
+
var import_vitest15 = require("vitest");
|
|
3825
3790
|
var import_engine6 = require("@quake2ts/engine");
|
|
3826
3791
|
function createMockDLight(position = { x: 0, y: 0, z: 0 }, color = { x: 1, y: 1, z: 1 }, intensity = 300) {
|
|
3827
3792
|
return {
|
|
@@ -3833,10 +3798,10 @@ function createMockDLight(position = { x: 0, y: 0, z: 0 }, color = { x: 1, y: 1,
|
|
|
3833
3798
|
}
|
|
3834
3799
|
function createMockDLightManager(overrides) {
|
|
3835
3800
|
const mockManager = {
|
|
3836
|
-
addLight:
|
|
3837
|
-
clear:
|
|
3838
|
-
update:
|
|
3839
|
-
getActiveLights:
|
|
3801
|
+
addLight: import_vitest15.vi.fn(),
|
|
3802
|
+
clear: import_vitest15.vi.fn(),
|
|
3803
|
+
update: import_vitest15.vi.fn(),
|
|
3804
|
+
getActiveLights: import_vitest15.vi.fn().mockReturnValue([]),
|
|
3840
3805
|
...overrides
|
|
3841
3806
|
};
|
|
3842
3807
|
return mockManager;
|
|
@@ -3851,7 +3816,7 @@ function createMockLightmap(width = 128, height = 128) {
|
|
|
3851
3816
|
}
|
|
3852
3817
|
|
|
3853
3818
|
// src/engine/mocks/particles.ts
|
|
3854
|
-
var
|
|
3819
|
+
var import_vitest16 = require("vitest");
|
|
3855
3820
|
var import_engine7 = require("@quake2ts/engine");
|
|
3856
3821
|
function createMockParticle(overrides) {
|
|
3857
3822
|
return {
|
|
@@ -3870,8 +3835,8 @@ function createMockParticle(overrides) {
|
|
|
3870
3835
|
}
|
|
3871
3836
|
function createMockParticleEmitter(overrides) {
|
|
3872
3837
|
return {
|
|
3873
|
-
update:
|
|
3874
|
-
emit:
|
|
3838
|
+
update: import_vitest16.vi.fn(),
|
|
3839
|
+
emit: import_vitest16.vi.fn(),
|
|
3875
3840
|
...overrides
|
|
3876
3841
|
};
|
|
3877
3842
|
}
|
|
@@ -3879,35 +3844,35 @@ function createMockParticleSystem(overrides) {
|
|
|
3879
3844
|
return {
|
|
3880
3845
|
maxParticles: 1e3,
|
|
3881
3846
|
rng: {
|
|
3882
|
-
frandom:
|
|
3847
|
+
frandom: import_vitest16.vi.fn().mockReturnValue(0.5),
|
|
3883
3848
|
// Deterministic default
|
|
3884
|
-
random:
|
|
3885
|
-
seed:
|
|
3849
|
+
random: import_vitest16.vi.fn().mockReturnValue(0.5),
|
|
3850
|
+
seed: import_vitest16.vi.fn()
|
|
3886
3851
|
},
|
|
3887
|
-
update:
|
|
3888
|
-
spawn:
|
|
3889
|
-
killAll:
|
|
3890
|
-
aliveCount:
|
|
3891
|
-
getState:
|
|
3892
|
-
buildMesh:
|
|
3852
|
+
update: import_vitest16.vi.fn(),
|
|
3853
|
+
spawn: import_vitest16.vi.fn(),
|
|
3854
|
+
killAll: import_vitest16.vi.fn(),
|
|
3855
|
+
aliveCount: import_vitest16.vi.fn().mockReturnValue(0),
|
|
3856
|
+
getState: import_vitest16.vi.fn(),
|
|
3857
|
+
buildMesh: import_vitest16.vi.fn(),
|
|
3893
3858
|
...overrides
|
|
3894
3859
|
};
|
|
3895
3860
|
}
|
|
3896
3861
|
|
|
3897
3862
|
// src/engine/rendering.ts
|
|
3898
|
-
var
|
|
3863
|
+
var import_vitest17 = require("vitest");
|
|
3899
3864
|
function createMockRenderingContext() {
|
|
3900
3865
|
const gl = createMockWebGL2Context();
|
|
3901
3866
|
const camera = {
|
|
3902
|
-
update:
|
|
3903
|
-
getViewMatrix:
|
|
3904
|
-
getProjectionMatrix:
|
|
3905
|
-
getViewProjectionMatrix:
|
|
3906
|
-
getPosition:
|
|
3907
|
-
getForward:
|
|
3908
|
-
getRight:
|
|
3909
|
-
getUp:
|
|
3910
|
-
extractFrustumPlanes:
|
|
3867
|
+
update: import_vitest17.vi.fn(),
|
|
3868
|
+
getViewMatrix: import_vitest17.vi.fn().mockReturnValue(new Float32Array(16)),
|
|
3869
|
+
getProjectionMatrix: import_vitest17.vi.fn().mockReturnValue(new Float32Array(16)),
|
|
3870
|
+
getViewProjectionMatrix: import_vitest17.vi.fn().mockReturnValue(new Float32Array(16)),
|
|
3871
|
+
getPosition: import_vitest17.vi.fn().mockReturnValue([0, 0, 0]),
|
|
3872
|
+
getForward: import_vitest17.vi.fn().mockReturnValue([0, 0, -1]),
|
|
3873
|
+
getRight: import_vitest17.vi.fn().mockReturnValue([1, 0, 0]),
|
|
3874
|
+
getUp: import_vitest17.vi.fn().mockReturnValue([0, 1, 0]),
|
|
3875
|
+
extractFrustumPlanes: import_vitest17.vi.fn(),
|
|
3911
3876
|
transform: {
|
|
3912
3877
|
origin: [0, 0, 0],
|
|
3913
3878
|
angles: [0, 0, 0],
|
|
@@ -3915,29 +3880,29 @@ function createMockRenderingContext() {
|
|
|
3915
3880
|
}
|
|
3916
3881
|
};
|
|
3917
3882
|
const md2 = {
|
|
3918
|
-
render:
|
|
3919
|
-
init:
|
|
3920
|
-
resize:
|
|
3883
|
+
render: import_vitest17.vi.fn(),
|
|
3884
|
+
init: import_vitest17.vi.fn(),
|
|
3885
|
+
resize: import_vitest17.vi.fn()
|
|
3921
3886
|
};
|
|
3922
3887
|
const bsp = {
|
|
3923
|
-
render:
|
|
3924
|
-
init:
|
|
3925
|
-
resize:
|
|
3888
|
+
render: import_vitest17.vi.fn(),
|
|
3889
|
+
init: import_vitest17.vi.fn(),
|
|
3890
|
+
resize: import_vitest17.vi.fn()
|
|
3926
3891
|
};
|
|
3927
3892
|
const sprite = {
|
|
3928
|
-
render:
|
|
3929
|
-
init:
|
|
3930
|
-
resize:
|
|
3893
|
+
render: import_vitest17.vi.fn(),
|
|
3894
|
+
init: import_vitest17.vi.fn(),
|
|
3895
|
+
resize: import_vitest17.vi.fn()
|
|
3931
3896
|
};
|
|
3932
3897
|
const poly = {
|
|
3933
|
-
render:
|
|
3934
|
-
init:
|
|
3935
|
-
resize:
|
|
3898
|
+
render: import_vitest17.vi.fn(),
|
|
3899
|
+
init: import_vitest17.vi.fn(),
|
|
3900
|
+
resize: import_vitest17.vi.fn()
|
|
3936
3901
|
};
|
|
3937
3902
|
const particle = {
|
|
3938
|
-
render:
|
|
3939
|
-
init:
|
|
3940
|
-
resize:
|
|
3903
|
+
render: import_vitest17.vi.fn(),
|
|
3904
|
+
init: import_vitest17.vi.fn(),
|
|
3905
|
+
resize: import_vitest17.vi.fn()
|
|
3941
3906
|
};
|
|
3942
3907
|
return {
|
|
3943
3908
|
gl,
|
|
@@ -4232,7 +4197,7 @@ async function runComputeAndReadback(setup, computeFn) {
|
|
|
4232
4197
|
}
|
|
4233
4198
|
|
|
4234
4199
|
// src/engine/helpers/pipeline-test-template.ts
|
|
4235
|
-
var
|
|
4200
|
+
var import_vitest18 = require("vitest");
|
|
4236
4201
|
async function testPipelineRendering(name, createPipeline, setupGeometry, expectedOutput) {
|
|
4237
4202
|
const setup = await createRenderTestSetup(256, 256);
|
|
4238
4203
|
try {
|
|
@@ -4249,9 +4214,9 @@ async function testPipelineRendering(name, createPipeline, setupGeometry, expect
|
|
|
4249
4214
|
}
|
|
4250
4215
|
});
|
|
4251
4216
|
if (expectedOutput) {
|
|
4252
|
-
(0,
|
|
4217
|
+
(0, import_vitest18.expect)(pixels).toEqual(expectedOutput);
|
|
4253
4218
|
} else {
|
|
4254
|
-
(0,
|
|
4219
|
+
(0, import_vitest18.expect)(pixels.length).toBe(256 * 256 * 4);
|
|
4255
4220
|
}
|
|
4256
4221
|
} finally {
|
|
4257
4222
|
await setup.cleanup();
|
|
@@ -4290,7 +4255,7 @@ async function testComputeShader(name, createComputePipeline, inputData, expecte
|
|
|
4290
4255
|
});
|
|
4291
4256
|
if (expectedOutput) {
|
|
4292
4257
|
const floatResult = new Float32Array(resultBuffer);
|
|
4293
|
-
(0,
|
|
4258
|
+
(0, import_vitest18.expect)(floatResult).toEqual(expectedOutput);
|
|
4294
4259
|
}
|
|
4295
4260
|
stagingBuffer.destroy();
|
|
4296
4261
|
} finally {
|
|
@@ -4402,7 +4367,7 @@ function simulateCameraMovement(camera, input, deltaTime) {
|
|
|
4402
4367
|
}
|
|
4403
4368
|
|
|
4404
4369
|
// src/client/helpers/hud.ts
|
|
4405
|
-
var
|
|
4370
|
+
var import_vitest19 = require("vitest");
|
|
4406
4371
|
function createMockHudState(overrides) {
|
|
4407
4372
|
const defaultPs = {
|
|
4408
4373
|
damageAlpha: 0,
|
|
@@ -4432,11 +4397,11 @@ function createMockHudState(overrides) {
|
|
|
4432
4397
|
defaultStats[2] = 25;
|
|
4433
4398
|
defaultStats[4] = 50;
|
|
4434
4399
|
const defaultMessages = {
|
|
4435
|
-
drawCenterPrint:
|
|
4436
|
-
drawNotifications:
|
|
4437
|
-
addCenterPrint:
|
|
4438
|
-
addNotification:
|
|
4439
|
-
clear:
|
|
4400
|
+
drawCenterPrint: import_vitest19.vi.fn(),
|
|
4401
|
+
drawNotifications: import_vitest19.vi.fn(),
|
|
4402
|
+
addCenterPrint: import_vitest19.vi.fn(),
|
|
4403
|
+
addNotification: import_vitest19.vi.fn(),
|
|
4404
|
+
clear: import_vitest19.vi.fn()
|
|
4440
4405
|
};
|
|
4441
4406
|
return {
|
|
4442
4407
|
ps: overrides?.ps ?? defaultPs,
|
|
@@ -4455,7 +4420,7 @@ function createMockHudState(overrides) {
|
|
|
4455
4420
|
function createMockScoreboard(players = []) {
|
|
4456
4421
|
return {
|
|
4457
4422
|
players,
|
|
4458
|
-
draw:
|
|
4423
|
+
draw: import_vitest19.vi.fn()
|
|
4459
4424
|
};
|
|
4460
4425
|
}
|
|
4461
4426
|
function createMockChatMessage(text, sender, timestamp = Date.now()) {
|
|
@@ -4554,12 +4519,12 @@ function createMockFogData(overrides = {}) {
|
|
|
4554
4519
|
}
|
|
4555
4520
|
|
|
4556
4521
|
// src/client/mocks/download.ts
|
|
4557
|
-
var
|
|
4522
|
+
var import_vitest20 = require("vitest");
|
|
4558
4523
|
function createMockDownloadManager(overrides) {
|
|
4559
4524
|
return {
|
|
4560
|
-
download:
|
|
4561
|
-
cancel:
|
|
4562
|
-
getProgress:
|
|
4525
|
+
download: import_vitest20.vi.fn().mockResolvedValue(new ArrayBuffer(0)),
|
|
4526
|
+
cancel: import_vitest20.vi.fn(),
|
|
4527
|
+
getProgress: import_vitest20.vi.fn().mockReturnValue(0),
|
|
4563
4528
|
...overrides
|
|
4564
4529
|
};
|
|
4565
4530
|
}
|
|
@@ -4668,20 +4633,20 @@ var createMockConnectionState = (state = "connected") => ({
|
|
|
4668
4633
|
});
|
|
4669
4634
|
|
|
4670
4635
|
// src/client/mocks/console.ts
|
|
4671
|
-
var
|
|
4636
|
+
var import_vitest21 = require("vitest");
|
|
4672
4637
|
function createMockConsole(overrides) {
|
|
4673
4638
|
const history = [];
|
|
4674
4639
|
const errors = [];
|
|
4675
4640
|
const commands = {};
|
|
4676
4641
|
const cvars = {};
|
|
4677
4642
|
return {
|
|
4678
|
-
print:
|
|
4643
|
+
print: import_vitest21.vi.fn((text) => {
|
|
4679
4644
|
history.push(text);
|
|
4680
4645
|
}),
|
|
4681
|
-
error:
|
|
4646
|
+
error: import_vitest21.vi.fn((text) => {
|
|
4682
4647
|
errors.push(text);
|
|
4683
4648
|
}),
|
|
4684
|
-
execute:
|
|
4649
|
+
execute: import_vitest21.vi.fn((text) => {
|
|
4685
4650
|
const parts = text.trim().split(/\s+/);
|
|
4686
4651
|
const cmd = parts[0];
|
|
4687
4652
|
const args = parts.slice(1);
|
|
@@ -4691,11 +4656,11 @@ function createMockConsole(overrides) {
|
|
|
4691
4656
|
history.push(`Unknown command "${cmd}"`);
|
|
4692
4657
|
}
|
|
4693
4658
|
}),
|
|
4694
|
-
addCommand:
|
|
4659
|
+
addCommand: import_vitest21.vi.fn((name, handler) => {
|
|
4695
4660
|
commands[name] = handler;
|
|
4696
4661
|
}),
|
|
4697
|
-
getCvar:
|
|
4698
|
-
setCvar:
|
|
4662
|
+
getCvar: import_vitest21.vi.fn((name) => cvars[name]),
|
|
4663
|
+
setCvar: import_vitest21.vi.fn((name, value) => {
|
|
4699
4664
|
cvars[name] = value;
|
|
4700
4665
|
}),
|
|
4701
4666
|
getHistory: () => history,
|
|
@@ -5074,10 +5039,15 @@ function throttleBandwidth(bytesPerSecond) {
|
|
|
5074
5039
|
}
|
|
5075
5040
|
|
|
5076
5041
|
// src/e2e/visual.ts
|
|
5077
|
-
var
|
|
5042
|
+
var import_pngjs2 = require("pngjs");
|
|
5043
|
+
var import_pixelmatch2 = __toESM(require("pixelmatch"), 1);
|
|
5078
5044
|
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
5079
5045
|
var import_path2 = __toESM(require("path"), 1);
|
|
5080
5046
|
async function captureGameScreenshot(page, name) {
|
|
5047
|
+
const canvasElement = page.locator("canvas");
|
|
5048
|
+
if (await canvasElement.count() > 0) {
|
|
5049
|
+
return await canvasElement.screenshot({ path: `${name}.png` });
|
|
5050
|
+
}
|
|
5081
5051
|
return await page.screenshot({ path: `${name}.png` });
|
|
5082
5052
|
}
|
|
5083
5053
|
async function takeScreenshot(canvas, filepath) {
|
|
@@ -5094,82 +5064,43 @@ async function takeScreenshot(canvas, filepath) {
|
|
|
5094
5064
|
await import_promises2.default.mkdir(import_path2.default.dirname(filepath), { recursive: true });
|
|
5095
5065
|
await import_promises2.default.writeFile(filepath, buffer);
|
|
5096
5066
|
}
|
|
5097
|
-
async function compareScreenshot(canvas, baselinePath) {
|
|
5098
|
-
try {
|
|
5099
|
-
await import_promises2.default.access(baselinePath);
|
|
5100
|
-
} catch {
|
|
5101
|
-
console.warn(`Baseline not found at ${baselinePath}, saving current as baseline.`);
|
|
5102
|
-
await takeScreenshot(canvas, baselinePath);
|
|
5103
|
-
return true;
|
|
5104
|
-
}
|
|
5105
|
-
const baselineBuffer = await import_promises2.default.readFile(baselinePath);
|
|
5106
|
-
const baselineImage = new import_canvas3.Image();
|
|
5107
|
-
baselineImage.src = baselineBuffer;
|
|
5108
|
-
const width = baselineImage.width;
|
|
5109
|
-
const height = baselineImage.height;
|
|
5110
|
-
let currentBuffer;
|
|
5111
|
-
if ("toBuffer" in canvas && typeof canvas.toBuffer === "function") {
|
|
5112
|
-
currentBuffer = canvas.toBuffer("image/png");
|
|
5113
|
-
} else if ("toDataURL" in canvas) {
|
|
5114
|
-
const dataUrl = canvas.toDataURL("image/png");
|
|
5115
|
-
currentBuffer = Buffer.from(dataUrl.replace(/^data:image\/png;base64,/, ""), "base64");
|
|
5116
|
-
} else {
|
|
5117
|
-
throw new Error("Unsupported canvas type");
|
|
5118
|
-
}
|
|
5119
|
-
if (baselineBuffer.equals(currentBuffer)) {
|
|
5120
|
-
return true;
|
|
5121
|
-
}
|
|
5122
|
-
const baselineCanvas = new import_canvas3.Canvas(width, height);
|
|
5123
|
-
const ctx = baselineCanvas.getContext("2d");
|
|
5124
|
-
ctx.drawImage(baselineImage, 0, 0);
|
|
5125
|
-
const baselineData = ctx.getImageData(0, 0, width, height).data;
|
|
5126
|
-
const currentImage = new import_canvas3.Image();
|
|
5127
|
-
currentImage.src = currentBuffer;
|
|
5128
|
-
if (currentImage.width !== width || currentImage.height !== height) {
|
|
5129
|
-
console.error(`Dimension mismatch: Baseline ${width}x${height} vs Current ${currentImage.width}x${currentImage.height}`);
|
|
5130
|
-
return false;
|
|
5131
|
-
}
|
|
5132
|
-
const currentCanvas = new import_canvas3.Canvas(width, height);
|
|
5133
|
-
const ctx2 = currentCanvas.getContext("2d");
|
|
5134
|
-
ctx2.drawImage(currentImage, 0, 0);
|
|
5135
|
-
const currentData = ctx2.getImageData(0, 0, width, height).data;
|
|
5136
|
-
let diffPixels = 0;
|
|
5137
|
-
const totalPixels = width * height;
|
|
5138
|
-
for (let i = 0; i < baselineData.length; i += 4) {
|
|
5139
|
-
if (baselineData[i] !== currentData[i] || // R
|
|
5140
|
-
baselineData[i + 1] !== currentData[i + 1] || // G
|
|
5141
|
-
baselineData[i + 2] !== currentData[i + 2] || // B
|
|
5142
|
-
baselineData[i + 3] !== currentData[i + 3]) {
|
|
5143
|
-
diffPixels++;
|
|
5144
|
-
}
|
|
5145
|
-
}
|
|
5146
|
-
if (diffPixels > 0) {
|
|
5147
|
-
console.error(`Visual regression: ${diffPixels} pixels differ (${(diffPixels / totalPixels * 100).toFixed(2)}%)`);
|
|
5148
|
-
return false;
|
|
5149
|
-
}
|
|
5150
|
-
return true;
|
|
5151
|
-
}
|
|
5152
5067
|
function compareScreenshots(baseline, current, threshold = 0.01) {
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
for (let i = 0; i < baseline.length; i++) {
|
|
5159
|
-
if (baseline[i] !== current[i]) {
|
|
5160
|
-
diffPixels++;
|
|
5068
|
+
try {
|
|
5069
|
+
const img1 = import_pngjs2.PNG.sync.read(baseline);
|
|
5070
|
+
const img2 = import_pngjs2.PNG.sync.read(current);
|
|
5071
|
+
if (img1.width !== img2.width || img1.height !== img2.height) {
|
|
5072
|
+
throw new Error(`Image dimensions do not match: ${img1.width}x${img1.height} vs ${img2.width}x${img2.height}`);
|
|
5161
5073
|
}
|
|
5074
|
+
const { width, height } = img1;
|
|
5075
|
+
const diff = new import_pngjs2.PNG({ width, height });
|
|
5076
|
+
const diffPixels = (0, import_pixelmatch2.default)(
|
|
5077
|
+
img1.data,
|
|
5078
|
+
img2.data,
|
|
5079
|
+
diff.data,
|
|
5080
|
+
width,
|
|
5081
|
+
height,
|
|
5082
|
+
{ threshold }
|
|
5083
|
+
);
|
|
5084
|
+
const diffPercentage = diffPixels / (width * height);
|
|
5085
|
+
const isMatch = diffPixels === 0;
|
|
5086
|
+
return {
|
|
5087
|
+
diffPixels,
|
|
5088
|
+
diffPercentage,
|
|
5089
|
+
isMatch,
|
|
5090
|
+
diffImage: import_pngjs2.PNG.sync.write(diff)
|
|
5091
|
+
};
|
|
5092
|
+
} catch (error) {
|
|
5093
|
+
console.error("Error comparing screenshots:", error);
|
|
5094
|
+
return {
|
|
5095
|
+
diffPixels: -1,
|
|
5096
|
+
diffPercentage: 1,
|
|
5097
|
+
isMatch: false
|
|
5098
|
+
};
|
|
5162
5099
|
}
|
|
5163
|
-
const diffPercentage = diffPixels / totalPixels;
|
|
5164
|
-
return {
|
|
5165
|
-
diffPercentage
|
|
5166
|
-
};
|
|
5167
5100
|
}
|
|
5168
5101
|
function createVisualTestScenario(sceneName) {
|
|
5169
5102
|
return {
|
|
5170
|
-
sceneName
|
|
5171
|
-
setup: async () => {
|
|
5172
|
-
}
|
|
5103
|
+
sceneName
|
|
5173
5104
|
};
|
|
5174
5105
|
}
|
|
5175
5106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -5206,7 +5137,6 @@ function createVisualTestScenario(sceneName) {
|
|
|
5206
5137
|
captureGameState,
|
|
5207
5138
|
captureTexture,
|
|
5208
5139
|
compareSaveGames,
|
|
5209
|
-
compareScreenshot,
|
|
5210
5140
|
compareScreenshots,
|
|
5211
5141
|
compareSnapshots,
|
|
5212
5142
|
createBandwidthTestScenario,
|