@quake2ts/test-utils 0.0.869 → 0.0.874
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 +443 -289
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +438 -297
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/engine/helpers/webgl-playwright.ts +56 -6
- package/src/index.ts +1 -1
- package/src/setup/headless-webgl.ts +3 -2
- package/src/shared/md2.ts +143 -0
package/dist/index.cjs
CHANGED
|
@@ -229,6 +229,7 @@ __export(index_exports, {
|
|
|
229
229
|
createRenderTestSetup: () => createRenderTestSetup,
|
|
230
230
|
createSaveGameSnapshot: () => createSaveGameSnapshot,
|
|
231
231
|
createServerSnapshot: () => createServerSnapshot,
|
|
232
|
+
createSimpleMd2Model: () => createSimpleMd2Model,
|
|
232
233
|
createSolidTexture: () => createSolidTexture,
|
|
233
234
|
createSpawnRegistry: () => createSpawnRegistry,
|
|
234
235
|
createSpawnTestContext: () => createSpawnTestContext,
|
|
@@ -258,6 +259,7 @@ __export(index_exports, {
|
|
|
258
259
|
intersects: () => import_shared3.intersects,
|
|
259
260
|
ladderTrace: () => import_shared3.ladderTrace,
|
|
260
261
|
loadMapFromPak: () => loadMapFromPak,
|
|
262
|
+
loadMd2Model: () => loadMd2Model,
|
|
261
263
|
loadPNG: () => loadPNG,
|
|
262
264
|
makeAxisBrush: () => makeAxisBrush,
|
|
263
265
|
makeBrushFromMinsMaxs: () => makeBrushFromMinsMaxs,
|
|
@@ -324,6 +326,10 @@ __export(index_exports, {
|
|
|
324
326
|
});
|
|
325
327
|
module.exports = __toCommonJS(index_exports);
|
|
326
328
|
|
|
329
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_postcss@8.5.6_tsx@4.21.0_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
|
|
330
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
331
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
332
|
+
|
|
327
333
|
// src/shared/mocks.ts
|
|
328
334
|
var import_vitest2 = require("vitest");
|
|
329
335
|
|
|
@@ -784,6 +790,127 @@ function createMockPlayerState(overrides) {
|
|
|
784
790
|
};
|
|
785
791
|
}
|
|
786
792
|
|
|
793
|
+
// src/shared/md2.ts
|
|
794
|
+
function createSimpleMd2Model() {
|
|
795
|
+
const scale = { x: 1, y: 1, z: 1 };
|
|
796
|
+
const translate = { x: 0, y: 0, z: 0 };
|
|
797
|
+
const basePositions = [
|
|
798
|
+
{ x: -10, y: -10, z: -10 },
|
|
799
|
+
// 0
|
|
800
|
+
{ x: 10, y: -10, z: -10 },
|
|
801
|
+
// 1
|
|
802
|
+
{ x: 10, y: 10, z: -10 },
|
|
803
|
+
// 2
|
|
804
|
+
{ x: -10, y: 10, z: -10 },
|
|
805
|
+
// 3
|
|
806
|
+
{ x: -10, y: -10, z: 10 },
|
|
807
|
+
// 4
|
|
808
|
+
{ x: 10, y: -10, z: 10 },
|
|
809
|
+
// 5
|
|
810
|
+
{ x: 10, y: 10, z: 10 },
|
|
811
|
+
// 6
|
|
812
|
+
{ x: -10, y: 10, z: 10 }
|
|
813
|
+
// 7
|
|
814
|
+
];
|
|
815
|
+
const createFrame = (name, offset) => {
|
|
816
|
+
const vertices = basePositions.map((pos, index) => {
|
|
817
|
+
const modPos = {
|
|
818
|
+
x: pos.x + (index % 2 === 0 ? offset : -offset),
|
|
819
|
+
y: pos.y,
|
|
820
|
+
z: pos.z
|
|
821
|
+
};
|
|
822
|
+
return {
|
|
823
|
+
position: modPos,
|
|
824
|
+
normalIndex: 0,
|
|
825
|
+
// Dummy normal index
|
|
826
|
+
normal: { x: 0, y: 0, z: 1 }
|
|
827
|
+
// Dummy normal
|
|
828
|
+
};
|
|
829
|
+
});
|
|
830
|
+
return {
|
|
831
|
+
name,
|
|
832
|
+
vertices,
|
|
833
|
+
minBounds: { x: -20, y: -20, z: -20 },
|
|
834
|
+
maxBounds: { x: 20, y: 20, z: 20 }
|
|
835
|
+
};
|
|
836
|
+
};
|
|
837
|
+
const frames = [];
|
|
838
|
+
for (let i = 0; i < 20; i++) {
|
|
839
|
+
frames.push(createFrame(`frame${i}`, i * 0.5));
|
|
840
|
+
}
|
|
841
|
+
const triangles = [
|
|
842
|
+
// Front
|
|
843
|
+
{ vertexIndices: [0, 1, 2], texCoordIndices: [0, 1, 2] },
|
|
844
|
+
{ vertexIndices: [0, 2, 3], texCoordIndices: [0, 2, 3] },
|
|
845
|
+
// Back
|
|
846
|
+
{ vertexIndices: [5, 4, 7], texCoordIndices: [1, 0, 3] },
|
|
847
|
+
{ vertexIndices: [5, 7, 6], texCoordIndices: [1, 3, 2] },
|
|
848
|
+
// Top
|
|
849
|
+
{ vertexIndices: [3, 2, 6], texCoordIndices: [0, 1, 2] },
|
|
850
|
+
{ vertexIndices: [3, 6, 7], texCoordIndices: [0, 2, 3] },
|
|
851
|
+
// Bottom
|
|
852
|
+
{ vertexIndices: [4, 5, 1], texCoordIndices: [0, 1, 2] },
|
|
853
|
+
{ vertexIndices: [4, 1, 0], texCoordIndices: [0, 2, 3] },
|
|
854
|
+
// Right
|
|
855
|
+
{ vertexIndices: [1, 5, 6], texCoordIndices: [0, 1, 2] },
|
|
856
|
+
{ vertexIndices: [1, 6, 2], texCoordIndices: [0, 2, 3] },
|
|
857
|
+
// Left
|
|
858
|
+
{ vertexIndices: [4, 0, 3], texCoordIndices: [0, 1, 2] },
|
|
859
|
+
{ vertexIndices: [4, 3, 7], texCoordIndices: [0, 2, 3] }
|
|
860
|
+
];
|
|
861
|
+
const glCommands = triangles.map((t) => ({
|
|
862
|
+
mode: "strip",
|
|
863
|
+
// or 'fan', doesn't matter for 3 verts
|
|
864
|
+
vertices: [
|
|
865
|
+
{ s: 0, t: 0, vertexIndex: t.vertexIndices[0] },
|
|
866
|
+
{ s: 1, t: 0, vertexIndex: t.vertexIndices[1] },
|
|
867
|
+
{ s: 1, t: 1, vertexIndex: t.vertexIndices[2] }
|
|
868
|
+
]
|
|
869
|
+
}));
|
|
870
|
+
const header = {
|
|
871
|
+
ident: 844121161,
|
|
872
|
+
version: 8,
|
|
873
|
+
skinWidth: 32,
|
|
874
|
+
skinHeight: 32,
|
|
875
|
+
frameSize: 40 + 8 * 4,
|
|
876
|
+
// header + verts * 4
|
|
877
|
+
numSkins: 1,
|
|
878
|
+
numVertices: 8,
|
|
879
|
+
numTexCoords: 4,
|
|
880
|
+
// Simplified
|
|
881
|
+
numTriangles: 12,
|
|
882
|
+
numGlCommands: 12,
|
|
883
|
+
// One per triangle for simplicity
|
|
884
|
+
numFrames: 20,
|
|
885
|
+
offsetSkins: 0,
|
|
886
|
+
offsetTexCoords: 0,
|
|
887
|
+
offsetTriangles: 0,
|
|
888
|
+
offsetFrames: 0,
|
|
889
|
+
offsetGlCommands: 0,
|
|
890
|
+
offsetEnd: 0,
|
|
891
|
+
magic: 844121161
|
|
892
|
+
};
|
|
893
|
+
return {
|
|
894
|
+
header,
|
|
895
|
+
skins: [{ name: "skin.pcx" }],
|
|
896
|
+
texCoords: [
|
|
897
|
+
{ s: 0, t: 0 },
|
|
898
|
+
{ s: 32, t: 0 },
|
|
899
|
+
{ s: 32, t: 32 },
|
|
900
|
+
{ s: 0, t: 32 }
|
|
901
|
+
],
|
|
902
|
+
triangles,
|
|
903
|
+
frames,
|
|
904
|
+
glCommands
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
async function loadMd2Model(filename) {
|
|
908
|
+
if (filename === "simple-cube.md2") {
|
|
909
|
+
return createSimpleMd2Model();
|
|
910
|
+
}
|
|
911
|
+
throw new Error(`Model ${filename} not found in test fixtures`);
|
|
912
|
+
}
|
|
913
|
+
|
|
787
914
|
// src/game/factories.ts
|
|
788
915
|
var import_game = require("@quake2ts/game");
|
|
789
916
|
var createPlayerStateFactory = (overrides) => ({
|
|
@@ -1702,20 +1829,20 @@ function createMockPowerupItem(id, duration, overrides = {}) {
|
|
|
1702
1829
|
// src/server/mocks/transport.ts
|
|
1703
1830
|
var import_vitest6 = require("vitest");
|
|
1704
1831
|
var MockTransport = class {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1832
|
+
onConnectionCallback;
|
|
1833
|
+
onErrorCallback;
|
|
1834
|
+
address = "127.0.0.1";
|
|
1835
|
+
port = 27910;
|
|
1836
|
+
sentMessages = [];
|
|
1837
|
+
receivedMessages = [];
|
|
1838
|
+
listening = false;
|
|
1839
|
+
listenSpy = legacyFn(async (port) => {
|
|
1840
|
+
this.port = port;
|
|
1841
|
+
this.listening = true;
|
|
1842
|
+
});
|
|
1843
|
+
closeSpy = legacyFn(() => {
|
|
1710
1844
|
this.listening = false;
|
|
1711
|
-
|
|
1712
|
-
this.port = port;
|
|
1713
|
-
this.listening = true;
|
|
1714
|
-
});
|
|
1715
|
-
this.closeSpy = legacyFn(() => {
|
|
1716
|
-
this.listening = false;
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1845
|
+
});
|
|
1719
1846
|
/**
|
|
1720
1847
|
* Start listening on the specified port.
|
|
1721
1848
|
*/
|
|
@@ -1803,9 +1930,10 @@ function createMockNetDriver(overrides) {
|
|
|
1803
1930
|
// src/server/mockTransport.ts
|
|
1804
1931
|
var import_shared7 = require("@quake2ts/shared");
|
|
1805
1932
|
var MockNetworkTransport = class {
|
|
1933
|
+
netchan;
|
|
1934
|
+
recordedPackets = [];
|
|
1935
|
+
sentPackets = [];
|
|
1806
1936
|
constructor() {
|
|
1807
|
-
this.recordedPackets = [];
|
|
1808
|
-
this.sentPackets = [];
|
|
1809
1937
|
this.netchan = new import_shared7.NetChan();
|
|
1810
1938
|
this.netchan.setup(1234, { type: "loopback", port: 0 });
|
|
1811
1939
|
}
|
|
@@ -1841,25 +1969,23 @@ var MockNetworkTransport = class {
|
|
|
1841
1969
|
|
|
1842
1970
|
// src/server/mockNetDriver.ts
|
|
1843
1971
|
var MockNetDriver = class {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
this.
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
this.
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
this.
|
|
1860
|
-
|
|
1861
|
-
});
|
|
1862
|
-
}
|
|
1972
|
+
state = {
|
|
1973
|
+
connected: false,
|
|
1974
|
+
messagesSent: [],
|
|
1975
|
+
messageHandlers: [],
|
|
1976
|
+
closeHandlers: [],
|
|
1977
|
+
errorHandlers: []
|
|
1978
|
+
};
|
|
1979
|
+
connectSpy = legacyFn(async (url) => {
|
|
1980
|
+
this.state.connected = true;
|
|
1981
|
+
});
|
|
1982
|
+
disconnectSpy = legacyFn(() => {
|
|
1983
|
+
this.state.connected = false;
|
|
1984
|
+
this.state.closeHandlers.forEach((h) => h());
|
|
1985
|
+
});
|
|
1986
|
+
sendSpy = legacyFn((data) => {
|
|
1987
|
+
this.state.messagesSent.push(new Uint8Array(data));
|
|
1988
|
+
});
|
|
1863
1989
|
connect(url) {
|
|
1864
1990
|
return this.connectSpy(url);
|
|
1865
1991
|
}
|
|
@@ -2563,6 +2689,7 @@ function createMockWheelEvent(deltaX = 0, deltaY = 0) {
|
|
|
2563
2689
|
});
|
|
2564
2690
|
}
|
|
2565
2691
|
var MockPointerLock = class {
|
|
2692
|
+
_doc;
|
|
2566
2693
|
constructor(doc = document) {
|
|
2567
2694
|
this._doc = doc;
|
|
2568
2695
|
this.setup();
|
|
@@ -2699,196 +2826,66 @@ function createInputInjector(target) {
|
|
|
2699
2826
|
// src/engine/mocks/webgl.ts
|
|
2700
2827
|
var import_vitest10 = require("vitest");
|
|
2701
2828
|
var MockWebGL2RenderingContext = class {
|
|
2829
|
+
ARRAY_BUFFER = 34962;
|
|
2830
|
+
ELEMENT_ARRAY_BUFFER = 34963;
|
|
2831
|
+
STATIC_DRAW = 35044;
|
|
2832
|
+
DYNAMIC_DRAW = 35048;
|
|
2833
|
+
FLOAT = 5126;
|
|
2834
|
+
UNSIGNED_SHORT = 5123;
|
|
2835
|
+
TEXTURE_2D = 3553;
|
|
2836
|
+
TEXTURE_CUBE_MAP = 34067;
|
|
2837
|
+
TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
2838
|
+
TEXTURE0 = 33984;
|
|
2839
|
+
TEXTURE_WRAP_S = 10242;
|
|
2840
|
+
TEXTURE_WRAP_T = 10243;
|
|
2841
|
+
TEXTURE_MIN_FILTER = 10241;
|
|
2842
|
+
TEXTURE_MAG_FILTER = 10240;
|
|
2843
|
+
LINEAR = 9729;
|
|
2844
|
+
NEAREST = 9728;
|
|
2845
|
+
CLAMP_TO_EDGE = 33071;
|
|
2846
|
+
RGBA = 6408;
|
|
2847
|
+
UNSIGNED_BYTE = 5121;
|
|
2848
|
+
FRAMEBUFFER = 36160;
|
|
2849
|
+
COLOR_ATTACHMENT0 = 36064;
|
|
2850
|
+
DEPTH_ATTACHMENT = 36096;
|
|
2851
|
+
RENDERBUFFER = 36161;
|
|
2852
|
+
DEPTH_COMPONENT24 = 33190;
|
|
2853
|
+
FRAMEBUFFER_COMPLETE = 36053;
|
|
2854
|
+
TRIANGLES = 4;
|
|
2855
|
+
DEPTH_TEST = 2929;
|
|
2856
|
+
CULL_FACE = 2884;
|
|
2857
|
+
BLEND = 3042;
|
|
2858
|
+
SRC_ALPHA = 770;
|
|
2859
|
+
ONE_MINUS_SRC_ALPHA = 771;
|
|
2860
|
+
ONE = 1;
|
|
2861
|
+
BACK = 1029;
|
|
2862
|
+
LEQUAL = 515;
|
|
2863
|
+
VERTEX_SHADER = 35633;
|
|
2864
|
+
FRAGMENT_SHADER = 35632;
|
|
2865
|
+
COMPILE_STATUS = 35713;
|
|
2866
|
+
LINK_STATUS = 35714;
|
|
2867
|
+
ONE_MINUS_SRC_COLOR = 769;
|
|
2868
|
+
TRIANGLE_STRIP = 5;
|
|
2869
|
+
QUERY_RESULT_AVAILABLE = 34919;
|
|
2870
|
+
QUERY_RESULT = 34918;
|
|
2871
|
+
// Constants commonly used in setup/webgl.ts
|
|
2872
|
+
TRIANGLE_FAN = 6;
|
|
2873
|
+
COLOR_BUFFER_BIT = 16384;
|
|
2874
|
+
DEPTH_BUFFER_BIT = 256;
|
|
2875
|
+
canvas;
|
|
2876
|
+
drawingBufferWidth;
|
|
2877
|
+
drawingBufferHeight;
|
|
2878
|
+
shaderCounter = 0;
|
|
2879
|
+
programCounter = 0;
|
|
2880
|
+
compileSucceeds = true;
|
|
2881
|
+
linkSucceeds = true;
|
|
2882
|
+
shaderInfoLog = "shader failed";
|
|
2883
|
+
programInfoLog = "program failed";
|
|
2884
|
+
extensions = /* @__PURE__ */ new Map();
|
|
2885
|
+
calls = [];
|
|
2886
|
+
uniformLocations = /* @__PURE__ */ new Map();
|
|
2887
|
+
attributeLocations = /* @__PURE__ */ new Map();
|
|
2702
2888
|
constructor(canvas) {
|
|
2703
|
-
this.ARRAY_BUFFER = 34962;
|
|
2704
|
-
this.ELEMENT_ARRAY_BUFFER = 34963;
|
|
2705
|
-
this.STATIC_DRAW = 35044;
|
|
2706
|
-
this.DYNAMIC_DRAW = 35048;
|
|
2707
|
-
this.FLOAT = 5126;
|
|
2708
|
-
this.UNSIGNED_SHORT = 5123;
|
|
2709
|
-
this.TEXTURE_2D = 3553;
|
|
2710
|
-
this.TEXTURE_CUBE_MAP = 34067;
|
|
2711
|
-
this.TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
2712
|
-
this.TEXTURE0 = 33984;
|
|
2713
|
-
this.TEXTURE_WRAP_S = 10242;
|
|
2714
|
-
this.TEXTURE_WRAP_T = 10243;
|
|
2715
|
-
this.TEXTURE_MIN_FILTER = 10241;
|
|
2716
|
-
this.TEXTURE_MAG_FILTER = 10240;
|
|
2717
|
-
this.LINEAR = 9729;
|
|
2718
|
-
this.NEAREST = 9728;
|
|
2719
|
-
this.CLAMP_TO_EDGE = 33071;
|
|
2720
|
-
this.RGBA = 6408;
|
|
2721
|
-
this.UNSIGNED_BYTE = 5121;
|
|
2722
|
-
this.FRAMEBUFFER = 36160;
|
|
2723
|
-
this.COLOR_ATTACHMENT0 = 36064;
|
|
2724
|
-
this.DEPTH_ATTACHMENT = 36096;
|
|
2725
|
-
this.RENDERBUFFER = 36161;
|
|
2726
|
-
this.DEPTH_COMPONENT24 = 33190;
|
|
2727
|
-
this.FRAMEBUFFER_COMPLETE = 36053;
|
|
2728
|
-
this.TRIANGLES = 4;
|
|
2729
|
-
this.DEPTH_TEST = 2929;
|
|
2730
|
-
this.CULL_FACE = 2884;
|
|
2731
|
-
this.BLEND = 3042;
|
|
2732
|
-
this.SRC_ALPHA = 770;
|
|
2733
|
-
this.ONE_MINUS_SRC_ALPHA = 771;
|
|
2734
|
-
this.ONE = 1;
|
|
2735
|
-
this.BACK = 1029;
|
|
2736
|
-
this.LEQUAL = 515;
|
|
2737
|
-
this.VERTEX_SHADER = 35633;
|
|
2738
|
-
this.FRAGMENT_SHADER = 35632;
|
|
2739
|
-
this.COMPILE_STATUS = 35713;
|
|
2740
|
-
this.LINK_STATUS = 35714;
|
|
2741
|
-
this.ONE_MINUS_SRC_COLOR = 769;
|
|
2742
|
-
this.TRIANGLE_STRIP = 5;
|
|
2743
|
-
this.QUERY_RESULT_AVAILABLE = 34919;
|
|
2744
|
-
this.QUERY_RESULT = 34918;
|
|
2745
|
-
// Constants commonly used in setup/webgl.ts
|
|
2746
|
-
this.TRIANGLE_FAN = 6;
|
|
2747
|
-
this.COLOR_BUFFER_BIT = 16384;
|
|
2748
|
-
this.DEPTH_BUFFER_BIT = 256;
|
|
2749
|
-
this.shaderCounter = 0;
|
|
2750
|
-
this.programCounter = 0;
|
|
2751
|
-
this.compileSucceeds = true;
|
|
2752
|
-
this.linkSucceeds = true;
|
|
2753
|
-
this.shaderInfoLog = "shader failed";
|
|
2754
|
-
this.programInfoLog = "program failed";
|
|
2755
|
-
this.extensions = /* @__PURE__ */ new Map();
|
|
2756
|
-
this.calls = [];
|
|
2757
|
-
this.uniformLocations = /* @__PURE__ */ new Map();
|
|
2758
|
-
this.attributeLocations = /* @__PURE__ */ new Map();
|
|
2759
|
-
this.enable = import_vitest10.vi.fn((cap) => this.calls.push(`enable:${cap}`));
|
|
2760
|
-
this.disable = import_vitest10.vi.fn((cap) => this.calls.push(`disable:${cap}`));
|
|
2761
|
-
this.depthFunc = import_vitest10.vi.fn((func) => this.calls.push(`depthFunc:${func}`));
|
|
2762
|
-
this.cullFace = import_vitest10.vi.fn((mode) => this.calls.push(`cullFace:${mode}`));
|
|
2763
|
-
this.depthMask = import_vitest10.vi.fn((flag) => this.calls.push(`depthMask:${flag}`));
|
|
2764
|
-
this.blendFuncSeparate = import_vitest10.vi.fn(
|
|
2765
|
-
(srcRGB, dstRGB, srcAlpha, dstAlpha) => this.calls.push(`blendFuncSeparate:${srcRGB}:${dstRGB}:${srcAlpha}:${dstAlpha}`)
|
|
2766
|
-
);
|
|
2767
|
-
this.blendFunc = import_vitest10.vi.fn((sfactor, dfactor) => this.calls.push(`blendFunc:${sfactor}:${dfactor}`));
|
|
2768
|
-
this.getExtension = import_vitest10.vi.fn((name) => this.extensions.get(name) ?? null);
|
|
2769
|
-
this.viewport = import_vitest10.vi.fn((x, y, w, h) => this.calls.push(`viewport:${x}:${y}:${w}:${h}`));
|
|
2770
|
-
this.clear = import_vitest10.vi.fn((mask) => this.calls.push(`clear:${mask}`));
|
|
2771
|
-
this.clearColor = import_vitest10.vi.fn((r, g, b, a) => this.calls.push(`clearColor:${r}:${g}:${b}:${a}`));
|
|
2772
|
-
this.createShader = import_vitest10.vi.fn((type) => ({ id: ++this.shaderCounter, type }));
|
|
2773
|
-
this.shaderSource = import_vitest10.vi.fn((shader, source) => this.calls.push(`shaderSource:${shader.id}:${source}`));
|
|
2774
|
-
this.compileShader = import_vitest10.vi.fn((shader) => this.calls.push(`compileShader:${shader.id}`));
|
|
2775
|
-
this.getShaderParameter = import_vitest10.vi.fn(
|
|
2776
|
-
(shader, pname) => pname === this.COMPILE_STATUS ? this.compileSucceeds : null
|
|
2777
|
-
);
|
|
2778
|
-
this.getShaderInfoLog = import_vitest10.vi.fn(() => this.compileSucceeds ? "" : this.shaderInfoLog);
|
|
2779
|
-
this.deleteShader = import_vitest10.vi.fn((shader) => this.calls.push(`deleteShader:${shader.id}`));
|
|
2780
|
-
this.createProgram = import_vitest10.vi.fn(() => ({ id: ++this.programCounter }));
|
|
2781
|
-
this.attachShader = import_vitest10.vi.fn(
|
|
2782
|
-
(program, shader) => this.calls.push(`attach:${program.id}:${shader.id}`)
|
|
2783
|
-
);
|
|
2784
|
-
this.bindAttribLocation = import_vitest10.vi.fn(
|
|
2785
|
-
(program, index, name) => this.calls.push(`bindAttribLocation:${program.id}:${index}:${name}`)
|
|
2786
|
-
);
|
|
2787
|
-
this.linkProgram = import_vitest10.vi.fn((program) => this.calls.push(`link:${program.id}`));
|
|
2788
|
-
this.getProgramParameter = import_vitest10.vi.fn(
|
|
2789
|
-
(program, pname) => pname === this.LINK_STATUS ? this.linkSucceeds : null
|
|
2790
|
-
);
|
|
2791
|
-
this.getProgramInfoLog = import_vitest10.vi.fn(() => this.linkSucceeds ? "" : this.programInfoLog);
|
|
2792
|
-
this.deleteProgram = import_vitest10.vi.fn((program) => this.calls.push(`deleteProgram:${program.id}`));
|
|
2793
|
-
this.useProgram = import_vitest10.vi.fn((program) => this.calls.push(`useProgram:${program?.id ?? "null"}`));
|
|
2794
|
-
this.getUniformLocation = import_vitest10.vi.fn((program, name) => {
|
|
2795
|
-
this.calls.push(`getUniformLocation:${program.id}:${name}`);
|
|
2796
|
-
return this.uniformLocations.get(name) ?? null;
|
|
2797
|
-
});
|
|
2798
|
-
this.getAttribLocation = import_vitest10.vi.fn((program, name) => {
|
|
2799
|
-
this.calls.push(`getAttribLocation:${program.id}:${name}`);
|
|
2800
|
-
return this.attributeLocations.get(name) ?? -1;
|
|
2801
|
-
});
|
|
2802
|
-
this.createBuffer = import_vitest10.vi.fn(() => ({ buffer: {} }));
|
|
2803
|
-
this.bindBuffer = import_vitest10.vi.fn((target, buffer) => this.calls.push(`bindBuffer:${target}:${!!buffer}`));
|
|
2804
|
-
this.bufferData = import_vitest10.vi.fn(
|
|
2805
|
-
(target, data, usage) => this.calls.push(`bufferData:${target}:${usage}:${typeof data === "number" ? data : "data"}`)
|
|
2806
|
-
);
|
|
2807
|
-
this.bufferSubData = import_vitest10.vi.fn(
|
|
2808
|
-
(target, offset, data) => this.calls.push(`bufferSubData:${target}:${offset}:${data.byteLength ?? "len"}`)
|
|
2809
|
-
);
|
|
2810
|
-
this.deleteBuffer = import_vitest10.vi.fn((buffer) => this.calls.push(`deleteBuffer:${!!buffer}`));
|
|
2811
|
-
this.createVertexArray = import_vitest10.vi.fn(() => ({ vao: {} }));
|
|
2812
|
-
this.bindVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`bindVertexArray:${!!vao}`));
|
|
2813
|
-
this.enableVertexAttribArray = import_vitest10.vi.fn((index) => this.calls.push(`enableAttrib:${index}`));
|
|
2814
|
-
this.vertexAttribPointer = import_vitest10.vi.fn(
|
|
2815
|
-
(index, size, type, normalized, stride, offset) => this.calls.push(`vertexAttribPointer:${index}:${size}:${type}:${normalized}:${stride}:${offset}`)
|
|
2816
|
-
);
|
|
2817
|
-
this.vertexAttribDivisor = import_vitest10.vi.fn((index, divisor) => this.calls.push(`divisor:${index}:${divisor}`));
|
|
2818
|
-
this.deleteVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`deleteVertexArray:${!!vao}`));
|
|
2819
|
-
this.createTexture = import_vitest10.vi.fn(() => ({ texture: {} }));
|
|
2820
|
-
this.activeTexture = import_vitest10.vi.fn((unit) => this.calls.push(`activeTexture:${unit}`));
|
|
2821
|
-
this.bindTexture = import_vitest10.vi.fn((target, texture) => this.calls.push(`bindTexture:${target}:${!!texture}`));
|
|
2822
|
-
this.texParameteri = import_vitest10.vi.fn(
|
|
2823
|
-
(target, pname, param) => this.calls.push(`texParameteri:${target}:${pname}:${param}`)
|
|
2824
|
-
);
|
|
2825
|
-
this.texImage2D = import_vitest10.vi.fn(
|
|
2826
|
-
(target, level, internalFormat, width, height, border, format, type, pixels) => this.calls.push(
|
|
2827
|
-
`texImage2D:${target}:${level}:${internalFormat}:${width}:${height}:${border}:${format}:${type}:${pixels ? "data" : "null"}`
|
|
2828
|
-
)
|
|
2829
|
-
);
|
|
2830
|
-
// Explicitly typing this one with legacyFn or manually typing it to avoid inference errors
|
|
2831
|
-
this.texImage3D = legacyFn();
|
|
2832
|
-
this.deleteTexture = import_vitest10.vi.fn((texture) => this.calls.push(`deleteTexture:${!!texture}`));
|
|
2833
|
-
this.createFramebuffer = import_vitest10.vi.fn(() => ({ fb: {} }));
|
|
2834
|
-
this.bindFramebuffer = import_vitest10.vi.fn(
|
|
2835
|
-
(target, framebuffer) => this.calls.push(`bindFramebuffer:${target}:${!!framebuffer}`)
|
|
2836
|
-
);
|
|
2837
|
-
this.framebufferTexture2D = import_vitest10.vi.fn(
|
|
2838
|
-
(target, attachment, textarget, texture, level) => this.calls.push(`framebufferTexture2D:${target}:${attachment}:${textarget}:${!!texture}:${level}`)
|
|
2839
|
-
);
|
|
2840
|
-
this.deleteFramebuffer = import_vitest10.vi.fn((fb) => this.calls.push(`deleteFramebuffer:${!!fb}`));
|
|
2841
|
-
this.checkFramebufferStatus = import_vitest10.vi.fn((target) => this.FRAMEBUFFER_COMPLETE);
|
|
2842
|
-
this.createRenderbuffer = import_vitest10.vi.fn(() => ({ rb: {} }));
|
|
2843
|
-
this.bindRenderbuffer = import_vitest10.vi.fn(
|
|
2844
|
-
(target, renderbuffer) => this.calls.push(`bindRenderbuffer:${target}:${!!renderbuffer}`)
|
|
2845
|
-
);
|
|
2846
|
-
this.renderbufferStorage = import_vitest10.vi.fn(
|
|
2847
|
-
(target, internalformat, width, height) => this.calls.push(`renderbufferStorage:${target}:${internalformat}:${width}:${height}`)
|
|
2848
|
-
);
|
|
2849
|
-
this.framebufferRenderbuffer = import_vitest10.vi.fn(
|
|
2850
|
-
(target, attachment, renderbuffertarget, renderbuffer) => this.calls.push(`framebufferRenderbuffer:${target}:${attachment}:${renderbuffertarget}:${!!renderbuffer}`)
|
|
2851
|
-
);
|
|
2852
|
-
this.deleteRenderbuffer = import_vitest10.vi.fn((rb) => this.calls.push(`deleteRenderbuffer:${!!rb}`));
|
|
2853
|
-
this.drawArrays = import_vitest10.vi.fn(
|
|
2854
|
-
(mode, first, count) => this.calls.push(`drawArrays:${mode}:${first}:${count}`)
|
|
2855
|
-
);
|
|
2856
|
-
this.drawElements = import_vitest10.vi.fn(
|
|
2857
|
-
(mode, count, type, offset) => this.calls.push(`drawElements:${mode}:${count}:${type}:${offset}`)
|
|
2858
|
-
);
|
|
2859
|
-
// Queries
|
|
2860
|
-
this.createQuery = import_vitest10.vi.fn(() => ({}));
|
|
2861
|
-
this.beginQuery = legacyFn();
|
|
2862
|
-
this.endQuery = legacyFn();
|
|
2863
|
-
this.deleteQuery = legacyFn();
|
|
2864
|
-
this.getQueryParameter = legacyFn();
|
|
2865
|
-
this.getParameter = legacyFn();
|
|
2866
|
-
this.uniform1f = import_vitest10.vi.fn(
|
|
2867
|
-
(location, x) => this.calls.push(`uniform1f:${location ? "set" : "null"}:${x}`)
|
|
2868
|
-
);
|
|
2869
|
-
this.uniform1i = import_vitest10.vi.fn(
|
|
2870
|
-
(location, x) => this.calls.push(`uniform1i:${location ? "set" : "null"}:${x}`)
|
|
2871
|
-
);
|
|
2872
|
-
this.uniform4f = import_vitest10.vi.fn(
|
|
2873
|
-
(location, x, y, z, w) => this.calls.push(`uniform4f:${location ? "set" : "null"}:${x}:${y}:${z}:${w}`)
|
|
2874
|
-
);
|
|
2875
|
-
this.uniform3fv = import_vitest10.vi.fn(
|
|
2876
|
-
(location, data) => this.calls.push(`uniform3fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
2877
|
-
);
|
|
2878
|
-
this.uniform3f = import_vitest10.vi.fn(
|
|
2879
|
-
(location, x, y, z) => this.calls.push(`uniform3f:${location ? "set" : "null"}:${x}:${y}:${z}`)
|
|
2880
|
-
);
|
|
2881
|
-
this.uniform2f = import_vitest10.vi.fn(
|
|
2882
|
-
(location, x, y) => this.calls.push(`uniform2f:${location ? "set" : "null"}:${x}:${y}`)
|
|
2883
|
-
);
|
|
2884
|
-
this.uniform4fv = import_vitest10.vi.fn(
|
|
2885
|
-
(location, data) => this.calls.push(`uniform4fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
2886
|
-
);
|
|
2887
|
-
this.uniformMatrix4fv = import_vitest10.vi.fn(
|
|
2888
|
-
(location, transpose, data) => this.calls.push(`uniformMatrix4fv:${location ? "set" : "null"}:${transpose}:${Array.from(data).join(",")}`)
|
|
2889
|
-
);
|
|
2890
|
-
this.uniformBlockBinding = legacyFn();
|
|
2891
|
-
this.isContextLost = import_vitest10.vi.fn(() => false);
|
|
2892
2889
|
if (canvas) {
|
|
2893
2890
|
this.canvas = canvas;
|
|
2894
2891
|
this.drawingBufferWidth = canvas.width;
|
|
@@ -2899,6 +2896,139 @@ var MockWebGL2RenderingContext = class {
|
|
|
2899
2896
|
this.drawingBufferHeight = 600;
|
|
2900
2897
|
}
|
|
2901
2898
|
}
|
|
2899
|
+
enable = import_vitest10.vi.fn((cap) => this.calls.push(`enable:${cap}`));
|
|
2900
|
+
disable = import_vitest10.vi.fn((cap) => this.calls.push(`disable:${cap}`));
|
|
2901
|
+
depthFunc = import_vitest10.vi.fn((func) => this.calls.push(`depthFunc:${func}`));
|
|
2902
|
+
cullFace = import_vitest10.vi.fn((mode) => this.calls.push(`cullFace:${mode}`));
|
|
2903
|
+
depthMask = import_vitest10.vi.fn((flag) => this.calls.push(`depthMask:${flag}`));
|
|
2904
|
+
blendFuncSeparate = import_vitest10.vi.fn(
|
|
2905
|
+
(srcRGB, dstRGB, srcAlpha, dstAlpha) => this.calls.push(`blendFuncSeparate:${srcRGB}:${dstRGB}:${srcAlpha}:${dstAlpha}`)
|
|
2906
|
+
);
|
|
2907
|
+
blendFunc = import_vitest10.vi.fn((sfactor, dfactor) => this.calls.push(`blendFunc:${sfactor}:${dfactor}`));
|
|
2908
|
+
getExtension = import_vitest10.vi.fn((name) => this.extensions.get(name) ?? null);
|
|
2909
|
+
viewport = import_vitest10.vi.fn((x, y, w, h) => this.calls.push(`viewport:${x}:${y}:${w}:${h}`));
|
|
2910
|
+
clear = import_vitest10.vi.fn((mask) => this.calls.push(`clear:${mask}`));
|
|
2911
|
+
clearColor = import_vitest10.vi.fn((r, g, b, a) => this.calls.push(`clearColor:${r}:${g}:${b}:${a}`));
|
|
2912
|
+
createShader = import_vitest10.vi.fn((type) => ({ id: ++this.shaderCounter, type }));
|
|
2913
|
+
shaderSource = import_vitest10.vi.fn((shader, source) => this.calls.push(`shaderSource:${shader.id}:${source}`));
|
|
2914
|
+
compileShader = import_vitest10.vi.fn((shader) => this.calls.push(`compileShader:${shader.id}`));
|
|
2915
|
+
getShaderParameter = import_vitest10.vi.fn(
|
|
2916
|
+
(shader, pname) => pname === this.COMPILE_STATUS ? this.compileSucceeds : null
|
|
2917
|
+
);
|
|
2918
|
+
getShaderInfoLog = import_vitest10.vi.fn(() => this.compileSucceeds ? "" : this.shaderInfoLog);
|
|
2919
|
+
deleteShader = import_vitest10.vi.fn((shader) => this.calls.push(`deleteShader:${shader.id}`));
|
|
2920
|
+
createProgram = import_vitest10.vi.fn(() => ({ id: ++this.programCounter }));
|
|
2921
|
+
attachShader = import_vitest10.vi.fn(
|
|
2922
|
+
(program, shader) => this.calls.push(`attach:${program.id}:${shader.id}`)
|
|
2923
|
+
);
|
|
2924
|
+
bindAttribLocation = import_vitest10.vi.fn(
|
|
2925
|
+
(program, index, name) => this.calls.push(`bindAttribLocation:${program.id}:${index}:${name}`)
|
|
2926
|
+
);
|
|
2927
|
+
linkProgram = import_vitest10.vi.fn((program) => this.calls.push(`link:${program.id}`));
|
|
2928
|
+
getProgramParameter = import_vitest10.vi.fn(
|
|
2929
|
+
(program, pname) => pname === this.LINK_STATUS ? this.linkSucceeds : null
|
|
2930
|
+
);
|
|
2931
|
+
getProgramInfoLog = import_vitest10.vi.fn(() => this.linkSucceeds ? "" : this.programInfoLog);
|
|
2932
|
+
deleteProgram = import_vitest10.vi.fn((program) => this.calls.push(`deleteProgram:${program.id}`));
|
|
2933
|
+
useProgram = import_vitest10.vi.fn((program) => this.calls.push(`useProgram:${program?.id ?? "null"}`));
|
|
2934
|
+
getUniformLocation = import_vitest10.vi.fn((program, name) => {
|
|
2935
|
+
this.calls.push(`getUniformLocation:${program.id}:${name}`);
|
|
2936
|
+
return this.uniformLocations.get(name) ?? null;
|
|
2937
|
+
});
|
|
2938
|
+
getAttribLocation = import_vitest10.vi.fn((program, name) => {
|
|
2939
|
+
this.calls.push(`getAttribLocation:${program.id}:${name}`);
|
|
2940
|
+
return this.attributeLocations.get(name) ?? -1;
|
|
2941
|
+
});
|
|
2942
|
+
createBuffer = import_vitest10.vi.fn(() => ({ buffer: {} }));
|
|
2943
|
+
bindBuffer = import_vitest10.vi.fn((target, buffer) => this.calls.push(`bindBuffer:${target}:${!!buffer}`));
|
|
2944
|
+
bufferData = import_vitest10.vi.fn(
|
|
2945
|
+
(target, data, usage) => this.calls.push(`bufferData:${target}:${usage}:${typeof data === "number" ? data : "data"}`)
|
|
2946
|
+
);
|
|
2947
|
+
bufferSubData = import_vitest10.vi.fn(
|
|
2948
|
+
(target, offset, data) => this.calls.push(`bufferSubData:${target}:${offset}:${data.byteLength ?? "len"}`)
|
|
2949
|
+
);
|
|
2950
|
+
deleteBuffer = import_vitest10.vi.fn((buffer) => this.calls.push(`deleteBuffer:${!!buffer}`));
|
|
2951
|
+
createVertexArray = import_vitest10.vi.fn(() => ({ vao: {} }));
|
|
2952
|
+
bindVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`bindVertexArray:${!!vao}`));
|
|
2953
|
+
enableVertexAttribArray = import_vitest10.vi.fn((index) => this.calls.push(`enableAttrib:${index}`));
|
|
2954
|
+
vertexAttribPointer = import_vitest10.vi.fn(
|
|
2955
|
+
(index, size, type, normalized, stride, offset) => this.calls.push(`vertexAttribPointer:${index}:${size}:${type}:${normalized}:${stride}:${offset}`)
|
|
2956
|
+
);
|
|
2957
|
+
vertexAttribDivisor = import_vitest10.vi.fn((index, divisor) => this.calls.push(`divisor:${index}:${divisor}`));
|
|
2958
|
+
deleteVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`deleteVertexArray:${!!vao}`));
|
|
2959
|
+
createTexture = import_vitest10.vi.fn(() => ({ texture: {} }));
|
|
2960
|
+
activeTexture = import_vitest10.vi.fn((unit) => this.calls.push(`activeTexture:${unit}`));
|
|
2961
|
+
bindTexture = import_vitest10.vi.fn((target, texture) => this.calls.push(`bindTexture:${target}:${!!texture}`));
|
|
2962
|
+
texParameteri = import_vitest10.vi.fn(
|
|
2963
|
+
(target, pname, param) => this.calls.push(`texParameteri:${target}:${pname}:${param}`)
|
|
2964
|
+
);
|
|
2965
|
+
texImage2D = import_vitest10.vi.fn(
|
|
2966
|
+
(target, level, internalFormat, width, height, border, format, type, pixels) => this.calls.push(
|
|
2967
|
+
`texImage2D:${target}:${level}:${internalFormat}:${width}:${height}:${border}:${format}:${type}:${pixels ? "data" : "null"}`
|
|
2968
|
+
)
|
|
2969
|
+
);
|
|
2970
|
+
// Explicitly typing this one with legacyFn or manually typing it to avoid inference errors
|
|
2971
|
+
texImage3D = legacyFn();
|
|
2972
|
+
deleteTexture = import_vitest10.vi.fn((texture) => this.calls.push(`deleteTexture:${!!texture}`));
|
|
2973
|
+
createFramebuffer = import_vitest10.vi.fn(() => ({ fb: {} }));
|
|
2974
|
+
bindFramebuffer = import_vitest10.vi.fn(
|
|
2975
|
+
(target, framebuffer) => this.calls.push(`bindFramebuffer:${target}:${!!framebuffer}`)
|
|
2976
|
+
);
|
|
2977
|
+
framebufferTexture2D = import_vitest10.vi.fn(
|
|
2978
|
+
(target, attachment, textarget, texture, level) => this.calls.push(`framebufferTexture2D:${target}:${attachment}:${textarget}:${!!texture}:${level}`)
|
|
2979
|
+
);
|
|
2980
|
+
deleteFramebuffer = import_vitest10.vi.fn((fb) => this.calls.push(`deleteFramebuffer:${!!fb}`));
|
|
2981
|
+
checkFramebufferStatus = import_vitest10.vi.fn((target) => this.FRAMEBUFFER_COMPLETE);
|
|
2982
|
+
createRenderbuffer = import_vitest10.vi.fn(() => ({ rb: {} }));
|
|
2983
|
+
bindRenderbuffer = import_vitest10.vi.fn(
|
|
2984
|
+
(target, renderbuffer) => this.calls.push(`bindRenderbuffer:${target}:${!!renderbuffer}`)
|
|
2985
|
+
);
|
|
2986
|
+
renderbufferStorage = import_vitest10.vi.fn(
|
|
2987
|
+
(target, internalformat, width, height) => this.calls.push(`renderbufferStorage:${target}:${internalformat}:${width}:${height}`)
|
|
2988
|
+
);
|
|
2989
|
+
framebufferRenderbuffer = import_vitest10.vi.fn(
|
|
2990
|
+
(target, attachment, renderbuffertarget, renderbuffer) => this.calls.push(`framebufferRenderbuffer:${target}:${attachment}:${renderbuffertarget}:${!!renderbuffer}`)
|
|
2991
|
+
);
|
|
2992
|
+
deleteRenderbuffer = import_vitest10.vi.fn((rb) => this.calls.push(`deleteRenderbuffer:${!!rb}`));
|
|
2993
|
+
drawArrays = import_vitest10.vi.fn(
|
|
2994
|
+
(mode, first, count) => this.calls.push(`drawArrays:${mode}:${first}:${count}`)
|
|
2995
|
+
);
|
|
2996
|
+
drawElements = import_vitest10.vi.fn(
|
|
2997
|
+
(mode, count, type, offset) => this.calls.push(`drawElements:${mode}:${count}:${type}:${offset}`)
|
|
2998
|
+
);
|
|
2999
|
+
// Queries
|
|
3000
|
+
createQuery = import_vitest10.vi.fn(() => ({}));
|
|
3001
|
+
beginQuery = legacyFn();
|
|
3002
|
+
endQuery = legacyFn();
|
|
3003
|
+
deleteQuery = legacyFn();
|
|
3004
|
+
getQueryParameter = legacyFn();
|
|
3005
|
+
getParameter = legacyFn();
|
|
3006
|
+
uniform1f = import_vitest10.vi.fn(
|
|
3007
|
+
(location, x) => this.calls.push(`uniform1f:${location ? "set" : "null"}:${x}`)
|
|
3008
|
+
);
|
|
3009
|
+
uniform1i = import_vitest10.vi.fn(
|
|
3010
|
+
(location, x) => this.calls.push(`uniform1i:${location ? "set" : "null"}:${x}`)
|
|
3011
|
+
);
|
|
3012
|
+
uniform4f = import_vitest10.vi.fn(
|
|
3013
|
+
(location, x, y, z, w) => this.calls.push(`uniform4f:${location ? "set" : "null"}:${x}:${y}:${z}:${w}`)
|
|
3014
|
+
);
|
|
3015
|
+
uniform3fv = import_vitest10.vi.fn(
|
|
3016
|
+
(location, data) => this.calls.push(`uniform3fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
3017
|
+
);
|
|
3018
|
+
uniform3f = import_vitest10.vi.fn(
|
|
3019
|
+
(location, x, y, z) => this.calls.push(`uniform3f:${location ? "set" : "null"}:${x}:${y}:${z}`)
|
|
3020
|
+
);
|
|
3021
|
+
uniform2f = import_vitest10.vi.fn(
|
|
3022
|
+
(location, x, y) => this.calls.push(`uniform2f:${location ? "set" : "null"}:${x}:${y}`)
|
|
3023
|
+
);
|
|
3024
|
+
uniform4fv = import_vitest10.vi.fn(
|
|
3025
|
+
(location, data) => this.calls.push(`uniform4fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
3026
|
+
);
|
|
3027
|
+
uniformMatrix4fv = import_vitest10.vi.fn(
|
|
3028
|
+
(location, transpose, data) => this.calls.push(`uniformMatrix4fv:${location ? "set" : "null"}:${transpose}:${Array.from(data).join(",")}`)
|
|
3029
|
+
);
|
|
3030
|
+
uniformBlockBinding = legacyFn();
|
|
3031
|
+
isContextLost = import_vitest10.vi.fn(() => false);
|
|
2902
3032
|
};
|
|
2903
3033
|
function createMockWebGL2Context(overridesOrCanvas) {
|
|
2904
3034
|
let context;
|
|
@@ -3301,14 +3431,16 @@ function createWebGPULifecycle() {
|
|
|
3301
3431
|
}
|
|
3302
3432
|
|
|
3303
3433
|
// src/setup/headless-webgl.ts
|
|
3434
|
+
var import_module = require("module");
|
|
3304
3435
|
function createHeadlessWebGL(options = {}) {
|
|
3305
3436
|
const width = options.width ?? 256;
|
|
3306
3437
|
const height = options.height ?? 256;
|
|
3307
3438
|
let createGL;
|
|
3308
3439
|
try {
|
|
3309
|
-
|
|
3440
|
+
const require2 = (0, import_module.createRequire)(importMetaUrl);
|
|
3441
|
+
createGL = require2("gl");
|
|
3310
3442
|
} catch (e) {
|
|
3311
|
-
throw new Error("gl package not found or failed to load. Install it to run WebGL tests.");
|
|
3443
|
+
throw new Error("gl package not found or failed to load. Install it to run WebGL tests. Error: " + e);
|
|
3312
3444
|
}
|
|
3313
3445
|
const glContext = createGL(width, height, {
|
|
3314
3446
|
antialias: options.antialias ?? false,
|
|
@@ -3665,43 +3797,35 @@ var FakeAudioParam = class {
|
|
|
3665
3797
|
}
|
|
3666
3798
|
};
|
|
3667
3799
|
var FakeAudioNode = class {
|
|
3668
|
-
|
|
3669
|
-
this.connections = [];
|
|
3670
|
-
}
|
|
3800
|
+
connections = [];
|
|
3671
3801
|
connect(destination) {
|
|
3672
3802
|
this.connections.push(destination);
|
|
3673
3803
|
}
|
|
3674
3804
|
};
|
|
3675
3805
|
var FakeGainNode = class extends FakeAudioNode {
|
|
3676
|
-
|
|
3677
|
-
super(...arguments);
|
|
3678
|
-
this.gain = new FakeAudioParam(1);
|
|
3679
|
-
}
|
|
3806
|
+
gain = new FakeAudioParam(1);
|
|
3680
3807
|
};
|
|
3681
3808
|
var FakePannerNode = class extends FakeAudioNode {
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3809
|
+
positionX = new FakeAudioParam(0);
|
|
3810
|
+
positionY = new FakeAudioParam(0);
|
|
3811
|
+
positionZ = new FakeAudioParam(0);
|
|
3812
|
+
refDistance;
|
|
3813
|
+
maxDistance;
|
|
3814
|
+
rolloffFactor;
|
|
3815
|
+
distanceModel;
|
|
3688
3816
|
};
|
|
3689
3817
|
var FakeBiquadFilterNode = class extends FakeAudioNode {
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
this.Q = new FakeAudioParam(0);
|
|
3694
|
-
this.type = "lowpass";
|
|
3695
|
-
}
|
|
3818
|
+
frequency = new FakeAudioParam(0);
|
|
3819
|
+
Q = new FakeAudioParam(0);
|
|
3820
|
+
type = "lowpass";
|
|
3696
3821
|
};
|
|
3697
3822
|
var FakeBufferSource = class extends FakeAudioNode {
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
}
|
|
3823
|
+
buffer = null;
|
|
3824
|
+
loop = false;
|
|
3825
|
+
playbackRate = new FakeAudioParam(1);
|
|
3826
|
+
onended = null;
|
|
3827
|
+
startedAt;
|
|
3828
|
+
stoppedAt;
|
|
3705
3829
|
start(when = 0, offset, duration) {
|
|
3706
3830
|
this.startedAt = when;
|
|
3707
3831
|
this.offset = offset;
|
|
@@ -3711,19 +3835,23 @@ var FakeBufferSource = class extends FakeAudioNode {
|
|
|
3711
3835
|
this.stoppedAt = when;
|
|
3712
3836
|
this.onended?.();
|
|
3713
3837
|
}
|
|
3838
|
+
offset;
|
|
3839
|
+
duration;
|
|
3714
3840
|
};
|
|
3715
3841
|
var FakeDestination = class extends FakeAudioNode {
|
|
3716
3842
|
};
|
|
3717
3843
|
var FakeAudioContext = class {
|
|
3844
|
+
destination = new FakeDestination();
|
|
3845
|
+
state = "suspended";
|
|
3846
|
+
currentTime = 0;
|
|
3847
|
+
resumeCalls = 0;
|
|
3848
|
+
gains = [];
|
|
3849
|
+
sources = [];
|
|
3850
|
+
panners = [];
|
|
3851
|
+
filters = [];
|
|
3852
|
+
lastDecoded;
|
|
3853
|
+
createPanner;
|
|
3718
3854
|
constructor(enablePanner = true) {
|
|
3719
|
-
this.destination = new FakeDestination();
|
|
3720
|
-
this.state = "suspended";
|
|
3721
|
-
this.currentTime = 0;
|
|
3722
|
-
this.resumeCalls = 0;
|
|
3723
|
-
this.gains = [];
|
|
3724
|
-
this.sources = [];
|
|
3725
|
-
this.panners = [];
|
|
3726
|
-
this.filters = [];
|
|
3727
3855
|
if (enablePanner) {
|
|
3728
3856
|
this.createPanner = () => {
|
|
3729
3857
|
const node = new FakePannerNode();
|
|
@@ -4324,26 +4452,24 @@ function createStorageTestScenario(storageType = "local") {
|
|
|
4324
4452
|
// src/setup/audio.ts
|
|
4325
4453
|
function setupMockAudioContext() {
|
|
4326
4454
|
class MockAudioContext {
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
};
|
|
4346
|
-
}
|
|
4455
|
+
state = "suspended";
|
|
4456
|
+
destination = {};
|
|
4457
|
+
currentTime = 0;
|
|
4458
|
+
listener = {
|
|
4459
|
+
positionX: { value: 0 },
|
|
4460
|
+
positionY: { value: 0 },
|
|
4461
|
+
positionZ: { value: 0 },
|
|
4462
|
+
forwardX: { value: 0 },
|
|
4463
|
+
forwardY: { value: 0 },
|
|
4464
|
+
forwardZ: { value: 0 },
|
|
4465
|
+
upX: { value: 0 },
|
|
4466
|
+
upY: { value: 0 },
|
|
4467
|
+
upZ: { value: 0 },
|
|
4468
|
+
setOrientation: () => {
|
|
4469
|
+
},
|
|
4470
|
+
setPosition: () => {
|
|
4471
|
+
}
|
|
4472
|
+
};
|
|
4347
4473
|
createGain() {
|
|
4348
4474
|
return {
|
|
4349
4475
|
gain: { value: 1, linearRampToValueAtTime: () => {
|
|
@@ -4966,6 +5092,7 @@ async function expectAnimationSnapshot(renderAndCaptureFrame, options) {
|
|
|
4966
5092
|
var import_http = require("http");
|
|
4967
5093
|
var import_path3 = __toESM(require("path"), 1);
|
|
4968
5094
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
5095
|
+
var sharedSetup;
|
|
4969
5096
|
function findWorkspaceRoot(startDir) {
|
|
4970
5097
|
let currentDir = startDir;
|
|
4971
5098
|
while (currentDir !== import_path3.default.parse(currentDir).root) {
|
|
@@ -4980,6 +5107,25 @@ async function createWebGLPlaywrightSetup(options = {}) {
|
|
|
4980
5107
|
const width = options.width ?? 256;
|
|
4981
5108
|
const height = options.height ?? 256;
|
|
4982
5109
|
const headless = options.headless ?? true;
|
|
5110
|
+
if (sharedSetup) {
|
|
5111
|
+
const { page: page2, browser: browser2, context: context2, server } = sharedSetup;
|
|
5112
|
+
if (!page2.isClosed()) {
|
|
5113
|
+
await page2.setViewportSize({ width, height });
|
|
5114
|
+
return {
|
|
5115
|
+
browser: browser2,
|
|
5116
|
+
context: context2,
|
|
5117
|
+
page: page2,
|
|
5118
|
+
width,
|
|
5119
|
+
height,
|
|
5120
|
+
server,
|
|
5121
|
+
// No-op cleanup for shared instance to keep it alive for next test
|
|
5122
|
+
cleanup: async () => {
|
|
5123
|
+
}
|
|
5124
|
+
};
|
|
5125
|
+
} else {
|
|
5126
|
+
sharedSetup = void 0;
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
4983
5129
|
let chromium;
|
|
4984
5130
|
let handler;
|
|
4985
5131
|
try {
|
|
@@ -5036,7 +5182,6 @@ async function createWebGLPlaywrightSetup(options = {}) {
|
|
|
5036
5182
|
const page = await context.newPage();
|
|
5037
5183
|
page.on("console", (msg) => {
|
|
5038
5184
|
if (msg.type() === "error") console.error(`[Browser Error] ${msg.text()}`);
|
|
5039
|
-
else console.log(`[Browser] ${msg.text()}`);
|
|
5040
5185
|
});
|
|
5041
5186
|
page.on("pageerror", (err) => {
|
|
5042
5187
|
console.error(`[Browser Page Error] ${err.message}`);
|
|
@@ -5044,9 +5189,14 @@ async function createWebGLPlaywrightSetup(options = {}) {
|
|
|
5044
5189
|
await page.goto(serverUrl, { waitUntil: "domcontentloaded" });
|
|
5045
5190
|
await page.evaluate(`window.createRendererTest()`);
|
|
5046
5191
|
await page.waitForFunction(() => window.testRenderer !== void 0, { timeout: 5e3 });
|
|
5192
|
+
sharedSetup = {
|
|
5193
|
+
browser,
|
|
5194
|
+
context,
|
|
5195
|
+
page,
|
|
5196
|
+
server: staticServer,
|
|
5197
|
+
serverUrl
|
|
5198
|
+
};
|
|
5047
5199
|
const cleanup = async () => {
|
|
5048
|
-
await browser.close();
|
|
5049
|
-
staticServer.close();
|
|
5050
5200
|
};
|
|
5051
5201
|
return {
|
|
5052
5202
|
browser,
|
|
@@ -5068,9 +5218,11 @@ async function renderAndCaptureWebGLPlaywright(page, renderFn, width, height, fr
|
|
|
5068
5218
|
throw new Error("Renderer not initialized");
|
|
5069
5219
|
}
|
|
5070
5220
|
if (width2 !== void 0 && height2 !== void 0) {
|
|
5071
|
-
canvas.width
|
|
5072
|
-
|
|
5073
|
-
|
|
5221
|
+
if (canvas.width !== width2 || canvas.height !== height2) {
|
|
5222
|
+
canvas.width = width2;
|
|
5223
|
+
canvas.height = height2;
|
|
5224
|
+
gl.viewport(0, 0, width2, height2);
|
|
5225
|
+
}
|
|
5074
5226
|
}
|
|
5075
5227
|
try {
|
|
5076
5228
|
const fn = new Function("renderer", "gl", "frameIndex", code);
|
|
@@ -6141,11 +6293,11 @@ var MAX_MODELS = 256;
|
|
|
6141
6293
|
var MAX_SOUNDS = 256;
|
|
6142
6294
|
var MAX_IMAGES = 256;
|
|
6143
6295
|
var MockClientConfigStrings = class {
|
|
6296
|
+
strings = /* @__PURE__ */ new Map();
|
|
6297
|
+
models = [];
|
|
6298
|
+
sounds = [];
|
|
6299
|
+
images = [];
|
|
6144
6300
|
constructor() {
|
|
6145
|
-
this.strings = /* @__PURE__ */ new Map();
|
|
6146
|
-
this.models = [];
|
|
6147
|
-
this.sounds = [];
|
|
6148
|
-
this.images = [];
|
|
6149
6301
|
}
|
|
6150
6302
|
set(index, value) {
|
|
6151
6303
|
this.strings.set(index, value);
|
|
@@ -6796,6 +6948,7 @@ function createVisualTestScenario(sceneName) {
|
|
|
6796
6948
|
createRenderTestSetup,
|
|
6797
6949
|
createSaveGameSnapshot,
|
|
6798
6950
|
createServerSnapshot,
|
|
6951
|
+
createSimpleMd2Model,
|
|
6799
6952
|
createSolidTexture,
|
|
6800
6953
|
createSpawnRegistry,
|
|
6801
6954
|
createSpawnTestContext,
|
|
@@ -6825,6 +6978,7 @@ function createVisualTestScenario(sceneName) {
|
|
|
6825
6978
|
intersects,
|
|
6826
6979
|
ladderTrace,
|
|
6827
6980
|
loadMapFromPak,
|
|
6981
|
+
loadMd2Model,
|
|
6828
6982
|
loadPNG,
|
|
6829
6983
|
makeAxisBrush,
|
|
6830
6984
|
makeBrushFromMinsMaxs,
|