@quake2ts/test-utils 0.0.869 → 0.0.873
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 +278 -281
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +279 -282
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -1702,20 +1702,20 @@ function createMockPowerupItem(id, duration, overrides = {}) {
|
|
|
1702
1702
|
// src/server/mocks/transport.ts
|
|
1703
1703
|
var import_vitest6 = require("vitest");
|
|
1704
1704
|
var MockTransport = class {
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1705
|
+
onConnectionCallback;
|
|
1706
|
+
onErrorCallback;
|
|
1707
|
+
address = "127.0.0.1";
|
|
1708
|
+
port = 27910;
|
|
1709
|
+
sentMessages = [];
|
|
1710
|
+
receivedMessages = [];
|
|
1711
|
+
listening = false;
|
|
1712
|
+
listenSpy = legacyFn(async (port) => {
|
|
1713
|
+
this.port = port;
|
|
1714
|
+
this.listening = true;
|
|
1715
|
+
});
|
|
1716
|
+
closeSpy = legacyFn(() => {
|
|
1710
1717
|
this.listening = false;
|
|
1711
|
-
|
|
1712
|
-
this.port = port;
|
|
1713
|
-
this.listening = true;
|
|
1714
|
-
});
|
|
1715
|
-
this.closeSpy = legacyFn(() => {
|
|
1716
|
-
this.listening = false;
|
|
1717
|
-
});
|
|
1718
|
-
}
|
|
1718
|
+
});
|
|
1719
1719
|
/**
|
|
1720
1720
|
* Start listening on the specified port.
|
|
1721
1721
|
*/
|
|
@@ -1803,9 +1803,10 @@ function createMockNetDriver(overrides) {
|
|
|
1803
1803
|
// src/server/mockTransport.ts
|
|
1804
1804
|
var import_shared7 = require("@quake2ts/shared");
|
|
1805
1805
|
var MockNetworkTransport = class {
|
|
1806
|
+
netchan;
|
|
1807
|
+
recordedPackets = [];
|
|
1808
|
+
sentPackets = [];
|
|
1806
1809
|
constructor() {
|
|
1807
|
-
this.recordedPackets = [];
|
|
1808
|
-
this.sentPackets = [];
|
|
1809
1810
|
this.netchan = new import_shared7.NetChan();
|
|
1810
1811
|
this.netchan.setup(1234, { type: "loopback", port: 0 });
|
|
1811
1812
|
}
|
|
@@ -1841,25 +1842,23 @@ var MockNetworkTransport = class {
|
|
|
1841
1842
|
|
|
1842
1843
|
// src/server/mockNetDriver.ts
|
|
1843
1844
|
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
|
-
}
|
|
1845
|
+
state = {
|
|
1846
|
+
connected: false,
|
|
1847
|
+
messagesSent: [],
|
|
1848
|
+
messageHandlers: [],
|
|
1849
|
+
closeHandlers: [],
|
|
1850
|
+
errorHandlers: []
|
|
1851
|
+
};
|
|
1852
|
+
connectSpy = legacyFn(async (url) => {
|
|
1853
|
+
this.state.connected = true;
|
|
1854
|
+
});
|
|
1855
|
+
disconnectSpy = legacyFn(() => {
|
|
1856
|
+
this.state.connected = false;
|
|
1857
|
+
this.state.closeHandlers.forEach((h) => h());
|
|
1858
|
+
});
|
|
1859
|
+
sendSpy = legacyFn((data) => {
|
|
1860
|
+
this.state.messagesSent.push(new Uint8Array(data));
|
|
1861
|
+
});
|
|
1863
1862
|
connect(url) {
|
|
1864
1863
|
return this.connectSpy(url);
|
|
1865
1864
|
}
|
|
@@ -2563,6 +2562,7 @@ function createMockWheelEvent(deltaX = 0, deltaY = 0) {
|
|
|
2563
2562
|
});
|
|
2564
2563
|
}
|
|
2565
2564
|
var MockPointerLock = class {
|
|
2565
|
+
_doc;
|
|
2566
2566
|
constructor(doc = document) {
|
|
2567
2567
|
this._doc = doc;
|
|
2568
2568
|
this.setup();
|
|
@@ -2699,196 +2699,66 @@ function createInputInjector(target) {
|
|
|
2699
2699
|
// src/engine/mocks/webgl.ts
|
|
2700
2700
|
var import_vitest10 = require("vitest");
|
|
2701
2701
|
var MockWebGL2RenderingContext = class {
|
|
2702
|
+
ARRAY_BUFFER = 34962;
|
|
2703
|
+
ELEMENT_ARRAY_BUFFER = 34963;
|
|
2704
|
+
STATIC_DRAW = 35044;
|
|
2705
|
+
DYNAMIC_DRAW = 35048;
|
|
2706
|
+
FLOAT = 5126;
|
|
2707
|
+
UNSIGNED_SHORT = 5123;
|
|
2708
|
+
TEXTURE_2D = 3553;
|
|
2709
|
+
TEXTURE_CUBE_MAP = 34067;
|
|
2710
|
+
TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
|
|
2711
|
+
TEXTURE0 = 33984;
|
|
2712
|
+
TEXTURE_WRAP_S = 10242;
|
|
2713
|
+
TEXTURE_WRAP_T = 10243;
|
|
2714
|
+
TEXTURE_MIN_FILTER = 10241;
|
|
2715
|
+
TEXTURE_MAG_FILTER = 10240;
|
|
2716
|
+
LINEAR = 9729;
|
|
2717
|
+
NEAREST = 9728;
|
|
2718
|
+
CLAMP_TO_EDGE = 33071;
|
|
2719
|
+
RGBA = 6408;
|
|
2720
|
+
UNSIGNED_BYTE = 5121;
|
|
2721
|
+
FRAMEBUFFER = 36160;
|
|
2722
|
+
COLOR_ATTACHMENT0 = 36064;
|
|
2723
|
+
DEPTH_ATTACHMENT = 36096;
|
|
2724
|
+
RENDERBUFFER = 36161;
|
|
2725
|
+
DEPTH_COMPONENT24 = 33190;
|
|
2726
|
+
FRAMEBUFFER_COMPLETE = 36053;
|
|
2727
|
+
TRIANGLES = 4;
|
|
2728
|
+
DEPTH_TEST = 2929;
|
|
2729
|
+
CULL_FACE = 2884;
|
|
2730
|
+
BLEND = 3042;
|
|
2731
|
+
SRC_ALPHA = 770;
|
|
2732
|
+
ONE_MINUS_SRC_ALPHA = 771;
|
|
2733
|
+
ONE = 1;
|
|
2734
|
+
BACK = 1029;
|
|
2735
|
+
LEQUAL = 515;
|
|
2736
|
+
VERTEX_SHADER = 35633;
|
|
2737
|
+
FRAGMENT_SHADER = 35632;
|
|
2738
|
+
COMPILE_STATUS = 35713;
|
|
2739
|
+
LINK_STATUS = 35714;
|
|
2740
|
+
ONE_MINUS_SRC_COLOR = 769;
|
|
2741
|
+
TRIANGLE_STRIP = 5;
|
|
2742
|
+
QUERY_RESULT_AVAILABLE = 34919;
|
|
2743
|
+
QUERY_RESULT = 34918;
|
|
2744
|
+
// Constants commonly used in setup/webgl.ts
|
|
2745
|
+
TRIANGLE_FAN = 6;
|
|
2746
|
+
COLOR_BUFFER_BIT = 16384;
|
|
2747
|
+
DEPTH_BUFFER_BIT = 256;
|
|
2748
|
+
canvas;
|
|
2749
|
+
drawingBufferWidth;
|
|
2750
|
+
drawingBufferHeight;
|
|
2751
|
+
shaderCounter = 0;
|
|
2752
|
+
programCounter = 0;
|
|
2753
|
+
compileSucceeds = true;
|
|
2754
|
+
linkSucceeds = true;
|
|
2755
|
+
shaderInfoLog = "shader failed";
|
|
2756
|
+
programInfoLog = "program failed";
|
|
2757
|
+
extensions = /* @__PURE__ */ new Map();
|
|
2758
|
+
calls = [];
|
|
2759
|
+
uniformLocations = /* @__PURE__ */ new Map();
|
|
2760
|
+
attributeLocations = /* @__PURE__ */ new Map();
|
|
2702
2761
|
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
2762
|
if (canvas) {
|
|
2893
2763
|
this.canvas = canvas;
|
|
2894
2764
|
this.drawingBufferWidth = canvas.width;
|
|
@@ -2899,6 +2769,139 @@ var MockWebGL2RenderingContext = class {
|
|
|
2899
2769
|
this.drawingBufferHeight = 600;
|
|
2900
2770
|
}
|
|
2901
2771
|
}
|
|
2772
|
+
enable = import_vitest10.vi.fn((cap) => this.calls.push(`enable:${cap}`));
|
|
2773
|
+
disable = import_vitest10.vi.fn((cap) => this.calls.push(`disable:${cap}`));
|
|
2774
|
+
depthFunc = import_vitest10.vi.fn((func) => this.calls.push(`depthFunc:${func}`));
|
|
2775
|
+
cullFace = import_vitest10.vi.fn((mode) => this.calls.push(`cullFace:${mode}`));
|
|
2776
|
+
depthMask = import_vitest10.vi.fn((flag) => this.calls.push(`depthMask:${flag}`));
|
|
2777
|
+
blendFuncSeparate = import_vitest10.vi.fn(
|
|
2778
|
+
(srcRGB, dstRGB, srcAlpha, dstAlpha) => this.calls.push(`blendFuncSeparate:${srcRGB}:${dstRGB}:${srcAlpha}:${dstAlpha}`)
|
|
2779
|
+
);
|
|
2780
|
+
blendFunc = import_vitest10.vi.fn((sfactor, dfactor) => this.calls.push(`blendFunc:${sfactor}:${dfactor}`));
|
|
2781
|
+
getExtension = import_vitest10.vi.fn((name) => this.extensions.get(name) ?? null);
|
|
2782
|
+
viewport = import_vitest10.vi.fn((x, y, w, h) => this.calls.push(`viewport:${x}:${y}:${w}:${h}`));
|
|
2783
|
+
clear = import_vitest10.vi.fn((mask) => this.calls.push(`clear:${mask}`));
|
|
2784
|
+
clearColor = import_vitest10.vi.fn((r, g, b, a) => this.calls.push(`clearColor:${r}:${g}:${b}:${a}`));
|
|
2785
|
+
createShader = import_vitest10.vi.fn((type) => ({ id: ++this.shaderCounter, type }));
|
|
2786
|
+
shaderSource = import_vitest10.vi.fn((shader, source) => this.calls.push(`shaderSource:${shader.id}:${source}`));
|
|
2787
|
+
compileShader = import_vitest10.vi.fn((shader) => this.calls.push(`compileShader:${shader.id}`));
|
|
2788
|
+
getShaderParameter = import_vitest10.vi.fn(
|
|
2789
|
+
(shader, pname) => pname === this.COMPILE_STATUS ? this.compileSucceeds : null
|
|
2790
|
+
);
|
|
2791
|
+
getShaderInfoLog = import_vitest10.vi.fn(() => this.compileSucceeds ? "" : this.shaderInfoLog);
|
|
2792
|
+
deleteShader = import_vitest10.vi.fn((shader) => this.calls.push(`deleteShader:${shader.id}`));
|
|
2793
|
+
createProgram = import_vitest10.vi.fn(() => ({ id: ++this.programCounter }));
|
|
2794
|
+
attachShader = import_vitest10.vi.fn(
|
|
2795
|
+
(program, shader) => this.calls.push(`attach:${program.id}:${shader.id}`)
|
|
2796
|
+
);
|
|
2797
|
+
bindAttribLocation = import_vitest10.vi.fn(
|
|
2798
|
+
(program, index, name) => this.calls.push(`bindAttribLocation:${program.id}:${index}:${name}`)
|
|
2799
|
+
);
|
|
2800
|
+
linkProgram = import_vitest10.vi.fn((program) => this.calls.push(`link:${program.id}`));
|
|
2801
|
+
getProgramParameter = import_vitest10.vi.fn(
|
|
2802
|
+
(program, pname) => pname === this.LINK_STATUS ? this.linkSucceeds : null
|
|
2803
|
+
);
|
|
2804
|
+
getProgramInfoLog = import_vitest10.vi.fn(() => this.linkSucceeds ? "" : this.programInfoLog);
|
|
2805
|
+
deleteProgram = import_vitest10.vi.fn((program) => this.calls.push(`deleteProgram:${program.id}`));
|
|
2806
|
+
useProgram = import_vitest10.vi.fn((program) => this.calls.push(`useProgram:${program?.id ?? "null"}`));
|
|
2807
|
+
getUniformLocation = import_vitest10.vi.fn((program, name) => {
|
|
2808
|
+
this.calls.push(`getUniformLocation:${program.id}:${name}`);
|
|
2809
|
+
return this.uniformLocations.get(name) ?? null;
|
|
2810
|
+
});
|
|
2811
|
+
getAttribLocation = import_vitest10.vi.fn((program, name) => {
|
|
2812
|
+
this.calls.push(`getAttribLocation:${program.id}:${name}`);
|
|
2813
|
+
return this.attributeLocations.get(name) ?? -1;
|
|
2814
|
+
});
|
|
2815
|
+
createBuffer = import_vitest10.vi.fn(() => ({ buffer: {} }));
|
|
2816
|
+
bindBuffer = import_vitest10.vi.fn((target, buffer) => this.calls.push(`bindBuffer:${target}:${!!buffer}`));
|
|
2817
|
+
bufferData = import_vitest10.vi.fn(
|
|
2818
|
+
(target, data, usage) => this.calls.push(`bufferData:${target}:${usage}:${typeof data === "number" ? data : "data"}`)
|
|
2819
|
+
);
|
|
2820
|
+
bufferSubData = import_vitest10.vi.fn(
|
|
2821
|
+
(target, offset, data) => this.calls.push(`bufferSubData:${target}:${offset}:${data.byteLength ?? "len"}`)
|
|
2822
|
+
);
|
|
2823
|
+
deleteBuffer = import_vitest10.vi.fn((buffer) => this.calls.push(`deleteBuffer:${!!buffer}`));
|
|
2824
|
+
createVertexArray = import_vitest10.vi.fn(() => ({ vao: {} }));
|
|
2825
|
+
bindVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`bindVertexArray:${!!vao}`));
|
|
2826
|
+
enableVertexAttribArray = import_vitest10.vi.fn((index) => this.calls.push(`enableAttrib:${index}`));
|
|
2827
|
+
vertexAttribPointer = import_vitest10.vi.fn(
|
|
2828
|
+
(index, size, type, normalized, stride, offset) => this.calls.push(`vertexAttribPointer:${index}:${size}:${type}:${normalized}:${stride}:${offset}`)
|
|
2829
|
+
);
|
|
2830
|
+
vertexAttribDivisor = import_vitest10.vi.fn((index, divisor) => this.calls.push(`divisor:${index}:${divisor}`));
|
|
2831
|
+
deleteVertexArray = import_vitest10.vi.fn((vao) => this.calls.push(`deleteVertexArray:${!!vao}`));
|
|
2832
|
+
createTexture = import_vitest10.vi.fn(() => ({ texture: {} }));
|
|
2833
|
+
activeTexture = import_vitest10.vi.fn((unit) => this.calls.push(`activeTexture:${unit}`));
|
|
2834
|
+
bindTexture = import_vitest10.vi.fn((target, texture) => this.calls.push(`bindTexture:${target}:${!!texture}`));
|
|
2835
|
+
texParameteri = import_vitest10.vi.fn(
|
|
2836
|
+
(target, pname, param) => this.calls.push(`texParameteri:${target}:${pname}:${param}`)
|
|
2837
|
+
);
|
|
2838
|
+
texImage2D = import_vitest10.vi.fn(
|
|
2839
|
+
(target, level, internalFormat, width, height, border, format, type, pixels) => this.calls.push(
|
|
2840
|
+
`texImage2D:${target}:${level}:${internalFormat}:${width}:${height}:${border}:${format}:${type}:${pixels ? "data" : "null"}`
|
|
2841
|
+
)
|
|
2842
|
+
);
|
|
2843
|
+
// Explicitly typing this one with legacyFn or manually typing it to avoid inference errors
|
|
2844
|
+
texImage3D = legacyFn();
|
|
2845
|
+
deleteTexture = import_vitest10.vi.fn((texture) => this.calls.push(`deleteTexture:${!!texture}`));
|
|
2846
|
+
createFramebuffer = import_vitest10.vi.fn(() => ({ fb: {} }));
|
|
2847
|
+
bindFramebuffer = import_vitest10.vi.fn(
|
|
2848
|
+
(target, framebuffer) => this.calls.push(`bindFramebuffer:${target}:${!!framebuffer}`)
|
|
2849
|
+
);
|
|
2850
|
+
framebufferTexture2D = import_vitest10.vi.fn(
|
|
2851
|
+
(target, attachment, textarget, texture, level) => this.calls.push(`framebufferTexture2D:${target}:${attachment}:${textarget}:${!!texture}:${level}`)
|
|
2852
|
+
);
|
|
2853
|
+
deleteFramebuffer = import_vitest10.vi.fn((fb) => this.calls.push(`deleteFramebuffer:${!!fb}`));
|
|
2854
|
+
checkFramebufferStatus = import_vitest10.vi.fn((target) => this.FRAMEBUFFER_COMPLETE);
|
|
2855
|
+
createRenderbuffer = import_vitest10.vi.fn(() => ({ rb: {} }));
|
|
2856
|
+
bindRenderbuffer = import_vitest10.vi.fn(
|
|
2857
|
+
(target, renderbuffer) => this.calls.push(`bindRenderbuffer:${target}:${!!renderbuffer}`)
|
|
2858
|
+
);
|
|
2859
|
+
renderbufferStorage = import_vitest10.vi.fn(
|
|
2860
|
+
(target, internalformat, width, height) => this.calls.push(`renderbufferStorage:${target}:${internalformat}:${width}:${height}`)
|
|
2861
|
+
);
|
|
2862
|
+
framebufferRenderbuffer = import_vitest10.vi.fn(
|
|
2863
|
+
(target, attachment, renderbuffertarget, renderbuffer) => this.calls.push(`framebufferRenderbuffer:${target}:${attachment}:${renderbuffertarget}:${!!renderbuffer}`)
|
|
2864
|
+
);
|
|
2865
|
+
deleteRenderbuffer = import_vitest10.vi.fn((rb) => this.calls.push(`deleteRenderbuffer:${!!rb}`));
|
|
2866
|
+
drawArrays = import_vitest10.vi.fn(
|
|
2867
|
+
(mode, first, count) => this.calls.push(`drawArrays:${mode}:${first}:${count}`)
|
|
2868
|
+
);
|
|
2869
|
+
drawElements = import_vitest10.vi.fn(
|
|
2870
|
+
(mode, count, type, offset) => this.calls.push(`drawElements:${mode}:${count}:${type}:${offset}`)
|
|
2871
|
+
);
|
|
2872
|
+
// Queries
|
|
2873
|
+
createQuery = import_vitest10.vi.fn(() => ({}));
|
|
2874
|
+
beginQuery = legacyFn();
|
|
2875
|
+
endQuery = legacyFn();
|
|
2876
|
+
deleteQuery = legacyFn();
|
|
2877
|
+
getQueryParameter = legacyFn();
|
|
2878
|
+
getParameter = legacyFn();
|
|
2879
|
+
uniform1f = import_vitest10.vi.fn(
|
|
2880
|
+
(location, x) => this.calls.push(`uniform1f:${location ? "set" : "null"}:${x}`)
|
|
2881
|
+
);
|
|
2882
|
+
uniform1i = import_vitest10.vi.fn(
|
|
2883
|
+
(location, x) => this.calls.push(`uniform1i:${location ? "set" : "null"}:${x}`)
|
|
2884
|
+
);
|
|
2885
|
+
uniform4f = import_vitest10.vi.fn(
|
|
2886
|
+
(location, x, y, z, w) => this.calls.push(`uniform4f:${location ? "set" : "null"}:${x}:${y}:${z}:${w}`)
|
|
2887
|
+
);
|
|
2888
|
+
uniform3fv = import_vitest10.vi.fn(
|
|
2889
|
+
(location, data) => this.calls.push(`uniform3fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
2890
|
+
);
|
|
2891
|
+
uniform3f = import_vitest10.vi.fn(
|
|
2892
|
+
(location, x, y, z) => this.calls.push(`uniform3f:${location ? "set" : "null"}:${x}:${y}:${z}`)
|
|
2893
|
+
);
|
|
2894
|
+
uniform2f = import_vitest10.vi.fn(
|
|
2895
|
+
(location, x, y) => this.calls.push(`uniform2f:${location ? "set" : "null"}:${x}:${y}`)
|
|
2896
|
+
);
|
|
2897
|
+
uniform4fv = import_vitest10.vi.fn(
|
|
2898
|
+
(location, data) => this.calls.push(`uniform4fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
|
|
2899
|
+
);
|
|
2900
|
+
uniformMatrix4fv = import_vitest10.vi.fn(
|
|
2901
|
+
(location, transpose, data) => this.calls.push(`uniformMatrix4fv:${location ? "set" : "null"}:${transpose}:${Array.from(data).join(",")}`)
|
|
2902
|
+
);
|
|
2903
|
+
uniformBlockBinding = legacyFn();
|
|
2904
|
+
isContextLost = import_vitest10.vi.fn(() => false);
|
|
2902
2905
|
};
|
|
2903
2906
|
function createMockWebGL2Context(overridesOrCanvas) {
|
|
2904
2907
|
let context;
|
|
@@ -3665,43 +3668,35 @@ var FakeAudioParam = class {
|
|
|
3665
3668
|
}
|
|
3666
3669
|
};
|
|
3667
3670
|
var FakeAudioNode = class {
|
|
3668
|
-
|
|
3669
|
-
this.connections = [];
|
|
3670
|
-
}
|
|
3671
|
+
connections = [];
|
|
3671
3672
|
connect(destination) {
|
|
3672
3673
|
this.connections.push(destination);
|
|
3673
3674
|
}
|
|
3674
3675
|
};
|
|
3675
3676
|
var FakeGainNode = class extends FakeAudioNode {
|
|
3676
|
-
|
|
3677
|
-
super(...arguments);
|
|
3678
|
-
this.gain = new FakeAudioParam(1);
|
|
3679
|
-
}
|
|
3677
|
+
gain = new FakeAudioParam(1);
|
|
3680
3678
|
};
|
|
3681
3679
|
var FakePannerNode = class extends FakeAudioNode {
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3680
|
+
positionX = new FakeAudioParam(0);
|
|
3681
|
+
positionY = new FakeAudioParam(0);
|
|
3682
|
+
positionZ = new FakeAudioParam(0);
|
|
3683
|
+
refDistance;
|
|
3684
|
+
maxDistance;
|
|
3685
|
+
rolloffFactor;
|
|
3686
|
+
distanceModel;
|
|
3688
3687
|
};
|
|
3689
3688
|
var FakeBiquadFilterNode = class extends FakeAudioNode {
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
this.Q = new FakeAudioParam(0);
|
|
3694
|
-
this.type = "lowpass";
|
|
3695
|
-
}
|
|
3689
|
+
frequency = new FakeAudioParam(0);
|
|
3690
|
+
Q = new FakeAudioParam(0);
|
|
3691
|
+
type = "lowpass";
|
|
3696
3692
|
};
|
|
3697
3693
|
var FakeBufferSource = class extends FakeAudioNode {
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
}
|
|
3694
|
+
buffer = null;
|
|
3695
|
+
loop = false;
|
|
3696
|
+
playbackRate = new FakeAudioParam(1);
|
|
3697
|
+
onended = null;
|
|
3698
|
+
startedAt;
|
|
3699
|
+
stoppedAt;
|
|
3705
3700
|
start(when = 0, offset, duration) {
|
|
3706
3701
|
this.startedAt = when;
|
|
3707
3702
|
this.offset = offset;
|
|
@@ -3711,19 +3706,23 @@ var FakeBufferSource = class extends FakeAudioNode {
|
|
|
3711
3706
|
this.stoppedAt = when;
|
|
3712
3707
|
this.onended?.();
|
|
3713
3708
|
}
|
|
3709
|
+
offset;
|
|
3710
|
+
duration;
|
|
3714
3711
|
};
|
|
3715
3712
|
var FakeDestination = class extends FakeAudioNode {
|
|
3716
3713
|
};
|
|
3717
3714
|
var FakeAudioContext = class {
|
|
3715
|
+
destination = new FakeDestination();
|
|
3716
|
+
state = "suspended";
|
|
3717
|
+
currentTime = 0;
|
|
3718
|
+
resumeCalls = 0;
|
|
3719
|
+
gains = [];
|
|
3720
|
+
sources = [];
|
|
3721
|
+
panners = [];
|
|
3722
|
+
filters = [];
|
|
3723
|
+
lastDecoded;
|
|
3724
|
+
createPanner;
|
|
3718
3725
|
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
3726
|
if (enablePanner) {
|
|
3728
3727
|
this.createPanner = () => {
|
|
3729
3728
|
const node = new FakePannerNode();
|
|
@@ -4324,26 +4323,24 @@ function createStorageTestScenario(storageType = "local") {
|
|
|
4324
4323
|
// src/setup/audio.ts
|
|
4325
4324
|
function setupMockAudioContext() {
|
|
4326
4325
|
class MockAudioContext {
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
};
|
|
4346
|
-
}
|
|
4326
|
+
state = "suspended";
|
|
4327
|
+
destination = {};
|
|
4328
|
+
currentTime = 0;
|
|
4329
|
+
listener = {
|
|
4330
|
+
positionX: { value: 0 },
|
|
4331
|
+
positionY: { value: 0 },
|
|
4332
|
+
positionZ: { value: 0 },
|
|
4333
|
+
forwardX: { value: 0 },
|
|
4334
|
+
forwardY: { value: 0 },
|
|
4335
|
+
forwardZ: { value: 0 },
|
|
4336
|
+
upX: { value: 0 },
|
|
4337
|
+
upY: { value: 0 },
|
|
4338
|
+
upZ: { value: 0 },
|
|
4339
|
+
setOrientation: () => {
|
|
4340
|
+
},
|
|
4341
|
+
setPosition: () => {
|
|
4342
|
+
}
|
|
4343
|
+
};
|
|
4347
4344
|
createGain() {
|
|
4348
4345
|
return {
|
|
4349
4346
|
gain: { value: 1, linearRampToValueAtTime: () => {
|
|
@@ -6141,11 +6138,11 @@ var MAX_MODELS = 256;
|
|
|
6141
6138
|
var MAX_SOUNDS = 256;
|
|
6142
6139
|
var MAX_IMAGES = 256;
|
|
6143
6140
|
var MockClientConfigStrings = class {
|
|
6141
|
+
strings = /* @__PURE__ */ new Map();
|
|
6142
|
+
models = [];
|
|
6143
|
+
sounds = [];
|
|
6144
|
+
images = [];
|
|
6144
6145
|
constructor() {
|
|
6145
|
-
this.strings = /* @__PURE__ */ new Map();
|
|
6146
|
-
this.models = [];
|
|
6147
|
-
this.sounds = [];
|
|
6148
|
-
this.images = [];
|
|
6149
6146
|
}
|
|
6150
6147
|
set(index, value) {
|
|
6151
6148
|
this.strings.set(index, value);
|