quake2ts 0.0.579 → 0.0.581

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.
@@ -1521,128 +1521,221 @@ function createInputInjector(target) {
1521
1521
  return new InputInjector(doc, win);
1522
1522
  }
1523
1523
 
1524
- // src/setup/webgl.ts
1525
- function createMockWebGL2Context(canvas) {
1526
- const gl = {
1527
- canvas,
1528
- drawingBufferWidth: canvas.width,
1529
- drawingBufferHeight: canvas.height,
1530
- // Constants
1531
- VERTEX_SHADER: 35633,
1532
- FRAGMENT_SHADER: 35632,
1533
- COMPILE_STATUS: 35713,
1534
- LINK_STATUS: 35714,
1535
- ARRAY_BUFFER: 34962,
1536
- ELEMENT_ARRAY_BUFFER: 34963,
1537
- STATIC_DRAW: 35044,
1538
- DYNAMIC_DRAW: 35048,
1539
- FLOAT: 5126,
1540
- DEPTH_TEST: 2929,
1541
- BLEND: 3042,
1542
- SRC_ALPHA: 770,
1543
- ONE_MINUS_SRC_ALPHA: 771,
1544
- TEXTURE_2D: 3553,
1545
- RGBA: 6408,
1546
- UNSIGNED_BYTE: 5121,
1547
- COLOR_BUFFER_BIT: 16384,
1548
- DEPTH_BUFFER_BIT: 256,
1549
- TRIANGLES: 4,
1550
- TRIANGLE_STRIP: 5,
1551
- TRIANGLE_FAN: 6,
1552
- // Methods
1553
- createShader: () => ({}),
1554
- shaderSource: () => {
1555
- },
1556
- compileShader: () => {
1557
- },
1558
- getShaderParameter: (_, param) => {
1559
- if (param === 35713) return true;
1560
- return true;
1561
- },
1562
- getShaderInfoLog: () => "",
1563
- createProgram: () => ({}),
1564
- attachShader: () => {
1565
- },
1566
- linkProgram: () => {
1567
- },
1568
- getProgramParameter: (_, param) => {
1569
- if (param === 35714) return true;
1570
- return true;
1571
- },
1572
- getProgramInfoLog: () => "",
1573
- useProgram: () => {
1574
- },
1575
- createBuffer: () => ({}),
1576
- bindBuffer: () => {
1577
- },
1578
- bufferData: () => {
1579
- },
1580
- enableVertexAttribArray: () => {
1581
- },
1582
- vertexAttribPointer: () => {
1583
- },
1584
- enable: () => {
1585
- },
1586
- disable: () => {
1587
- },
1588
- depthMask: () => {
1589
- },
1590
- blendFunc: () => {
1591
- },
1592
- viewport: () => {
1593
- },
1594
- clearColor: () => {
1595
- },
1596
- clear: () => {
1597
- },
1598
- createTexture: () => ({}),
1599
- bindTexture: () => {
1600
- },
1601
- texImage2D: () => {
1602
- },
1603
- texParameteri: () => {
1604
- },
1605
- activeTexture: () => {
1606
- },
1607
- uniform1i: () => {
1608
- },
1609
- uniform1f: () => {
1610
- },
1611
- uniform2f: () => {
1612
- },
1613
- uniform3f: () => {
1614
- },
1615
- uniform4f: () => {
1616
- },
1617
- uniformMatrix4fv: () => {
1618
- },
1619
- getUniformLocation: () => ({}),
1620
- getAttribLocation: () => 0,
1621
- drawArrays: () => {
1622
- },
1623
- drawElements: () => {
1624
- },
1625
- createVertexArray: () => ({}),
1626
- bindVertexArray: () => {
1627
- },
1628
- deleteShader: () => {
1629
- },
1630
- deleteProgram: () => {
1631
- },
1632
- deleteBuffer: () => {
1633
- },
1634
- deleteTexture: () => {
1635
- },
1636
- deleteVertexArray: () => {
1637
- },
1638
- // WebGL2 specific
1639
- texImage3D: () => {
1640
- },
1641
- uniformBlockBinding: () => {
1642
- },
1643
- getExtension: () => null
1644
- };
1645
- return gl;
1524
+ // src/engine/mocks/webgl.ts
1525
+ import { vi as vi10 } from "vitest";
1526
+ var MockWebGL2RenderingContext = class {
1527
+ constructor(canvas) {
1528
+ this.ARRAY_BUFFER = 34962;
1529
+ this.ELEMENT_ARRAY_BUFFER = 34963;
1530
+ this.STATIC_DRAW = 35044;
1531
+ this.DYNAMIC_DRAW = 35048;
1532
+ this.FLOAT = 5126;
1533
+ this.UNSIGNED_SHORT = 5123;
1534
+ this.TEXTURE_2D = 3553;
1535
+ this.TEXTURE_CUBE_MAP = 34067;
1536
+ this.TEXTURE_CUBE_MAP_POSITIVE_X = 34069;
1537
+ this.TEXTURE0 = 33984;
1538
+ this.TEXTURE_WRAP_S = 10242;
1539
+ this.TEXTURE_WRAP_T = 10243;
1540
+ this.TEXTURE_MIN_FILTER = 10241;
1541
+ this.TEXTURE_MAG_FILTER = 10240;
1542
+ this.LINEAR = 9729;
1543
+ this.NEAREST = 9728;
1544
+ this.CLAMP_TO_EDGE = 33071;
1545
+ this.RGBA = 6408;
1546
+ this.UNSIGNED_BYTE = 5121;
1547
+ this.FRAMEBUFFER = 36160;
1548
+ this.COLOR_ATTACHMENT0 = 36064;
1549
+ this.DEPTH_ATTACHMENT = 36096;
1550
+ this.RENDERBUFFER = 36161;
1551
+ this.DEPTH_COMPONENT24 = 33190;
1552
+ this.FRAMEBUFFER_COMPLETE = 36053;
1553
+ this.TRIANGLES = 4;
1554
+ this.DEPTH_TEST = 2929;
1555
+ this.CULL_FACE = 2884;
1556
+ this.BLEND = 3042;
1557
+ this.SRC_ALPHA = 770;
1558
+ this.ONE_MINUS_SRC_ALPHA = 771;
1559
+ this.ONE = 1;
1560
+ this.BACK = 1029;
1561
+ this.LEQUAL = 515;
1562
+ this.VERTEX_SHADER = 35633;
1563
+ this.FRAGMENT_SHADER = 35632;
1564
+ this.COMPILE_STATUS = 35713;
1565
+ this.LINK_STATUS = 35714;
1566
+ this.ONE_MINUS_SRC_COLOR = 769;
1567
+ this.TRIANGLE_STRIP = 5;
1568
+ this.QUERY_RESULT_AVAILABLE = 34919;
1569
+ this.QUERY_RESULT = 34918;
1570
+ // Constants commonly used in setup/webgl.ts
1571
+ this.TRIANGLE_FAN = 6;
1572
+ this.COLOR_BUFFER_BIT = 16384;
1573
+ this.DEPTH_BUFFER_BIT = 256;
1574
+ this.shaderCounter = 0;
1575
+ this.programCounter = 0;
1576
+ this.compileSucceeds = true;
1577
+ this.linkSucceeds = true;
1578
+ this.shaderInfoLog = "shader failed";
1579
+ this.programInfoLog = "program failed";
1580
+ this.extensions = /* @__PURE__ */ new Map();
1581
+ this.calls = [];
1582
+ this.uniformLocations = /* @__PURE__ */ new Map();
1583
+ this.attributeLocations = /* @__PURE__ */ new Map();
1584
+ this.enable = vi10.fn((cap) => this.calls.push(`enable:${cap}`));
1585
+ this.disable = vi10.fn((cap) => this.calls.push(`disable:${cap}`));
1586
+ this.depthFunc = vi10.fn((func) => this.calls.push(`depthFunc:${func}`));
1587
+ this.cullFace = vi10.fn((mode) => this.calls.push(`cullFace:${mode}`));
1588
+ this.depthMask = vi10.fn((flag) => this.calls.push(`depthMask:${flag}`));
1589
+ this.blendFuncSeparate = vi10.fn(
1590
+ (srcRGB, dstRGB, srcAlpha, dstAlpha) => this.calls.push(`blendFuncSeparate:${srcRGB}:${dstRGB}:${srcAlpha}:${dstAlpha}`)
1591
+ );
1592
+ this.blendFunc = vi10.fn((sfactor, dfactor) => this.calls.push(`blendFunc:${sfactor}:${dfactor}`));
1593
+ this.getExtension = vi10.fn((name) => this.extensions.get(name) ?? null);
1594
+ this.viewport = vi10.fn((x, y, w, h) => this.calls.push(`viewport:${x}:${y}:${w}:${h}`));
1595
+ this.clear = vi10.fn((mask) => this.calls.push(`clear:${mask}`));
1596
+ this.clearColor = vi10.fn((r, g, b, a) => this.calls.push(`clearColor:${r}:${g}:${b}:${a}`));
1597
+ this.createShader = vi10.fn((type) => ({ id: ++this.shaderCounter, type }));
1598
+ this.shaderSource = vi10.fn((shader, source) => this.calls.push(`shaderSource:${shader.id}:${source}`));
1599
+ this.compileShader = vi10.fn((shader) => this.calls.push(`compileShader:${shader.id}`));
1600
+ this.getShaderParameter = vi10.fn(
1601
+ (shader, pname) => pname === this.COMPILE_STATUS ? this.compileSucceeds : null
1602
+ );
1603
+ this.getShaderInfoLog = vi10.fn(() => this.compileSucceeds ? "" : this.shaderInfoLog);
1604
+ this.deleteShader = vi10.fn((shader) => this.calls.push(`deleteShader:${shader.id}`));
1605
+ this.createProgram = vi10.fn(() => ({ id: ++this.programCounter }));
1606
+ this.attachShader = vi10.fn(
1607
+ (program, shader) => this.calls.push(`attach:${program.id}:${shader.id}`)
1608
+ );
1609
+ this.bindAttribLocation = vi10.fn(
1610
+ (program, index, name) => this.calls.push(`bindAttribLocation:${program.id}:${index}:${name}`)
1611
+ );
1612
+ this.linkProgram = vi10.fn((program) => this.calls.push(`link:${program.id}`));
1613
+ this.getProgramParameter = vi10.fn(
1614
+ (program, pname) => pname === this.LINK_STATUS ? this.linkSucceeds : null
1615
+ );
1616
+ this.getProgramInfoLog = vi10.fn(() => this.linkSucceeds ? "" : this.programInfoLog);
1617
+ this.deleteProgram = vi10.fn((program) => this.calls.push(`deleteProgram:${program.id}`));
1618
+ this.useProgram = vi10.fn((program) => this.calls.push(`useProgram:${program?.id ?? "null"}`));
1619
+ this.getUniformLocation = vi10.fn((program, name) => {
1620
+ this.calls.push(`getUniformLocation:${program.id}:${name}`);
1621
+ return this.uniformLocations.get(name) ?? null;
1622
+ });
1623
+ this.getAttribLocation = vi10.fn((program, name) => {
1624
+ this.calls.push(`getAttribLocation:${program.id}:${name}`);
1625
+ return this.attributeLocations.get(name) ?? -1;
1626
+ });
1627
+ this.createBuffer = vi10.fn(() => ({ buffer: {} }));
1628
+ this.bindBuffer = vi10.fn((target, buffer) => this.calls.push(`bindBuffer:${target}:${!!buffer}`));
1629
+ this.bufferData = vi10.fn(
1630
+ (target, data, usage) => this.calls.push(`bufferData:${target}:${usage}:${typeof data === "number" ? data : "data"}`)
1631
+ );
1632
+ this.bufferSubData = vi10.fn(
1633
+ (target, offset, data) => this.calls.push(`bufferSubData:${target}:${offset}:${data.byteLength ?? "len"}`)
1634
+ );
1635
+ this.deleteBuffer = vi10.fn((buffer) => this.calls.push(`deleteBuffer:${!!buffer}`));
1636
+ this.createVertexArray = vi10.fn(() => ({ vao: {} }));
1637
+ this.bindVertexArray = vi10.fn((vao) => this.calls.push(`bindVertexArray:${!!vao}`));
1638
+ this.enableVertexAttribArray = vi10.fn((index) => this.calls.push(`enableAttrib:${index}`));
1639
+ this.vertexAttribPointer = vi10.fn(
1640
+ (index, size, type, normalized, stride, offset) => this.calls.push(`vertexAttribPointer:${index}:${size}:${type}:${normalized}:${stride}:${offset}`)
1641
+ );
1642
+ this.vertexAttribDivisor = vi10.fn((index, divisor) => this.calls.push(`divisor:${index}:${divisor}`));
1643
+ this.deleteVertexArray = vi10.fn((vao) => this.calls.push(`deleteVertexArray:${!!vao}`));
1644
+ this.createTexture = vi10.fn(() => ({ texture: {} }));
1645
+ this.activeTexture = vi10.fn((unit) => this.calls.push(`activeTexture:${unit}`));
1646
+ this.bindTexture = vi10.fn((target, texture) => this.calls.push(`bindTexture:${target}:${!!texture}`));
1647
+ this.texParameteri = vi10.fn(
1648
+ (target, pname, param) => this.calls.push(`texParameteri:${target}:${pname}:${param}`)
1649
+ );
1650
+ this.texImage2D = vi10.fn(
1651
+ (target, level, internalFormat, width, height, border, format, type, pixels) => this.calls.push(
1652
+ `texImage2D:${target}:${level}:${internalFormat}:${width}:${height}:${border}:${format}:${type}:${pixels ? "data" : "null"}`
1653
+ )
1654
+ );
1655
+ this.texImage3D = vi10.fn();
1656
+ // Stub for compatibility
1657
+ this.deleteTexture = vi10.fn((texture) => this.calls.push(`deleteTexture:${!!texture}`));
1658
+ this.createFramebuffer = vi10.fn(() => ({ fb: {} }));
1659
+ this.bindFramebuffer = vi10.fn(
1660
+ (target, framebuffer) => this.calls.push(`bindFramebuffer:${target}:${!!framebuffer}`)
1661
+ );
1662
+ this.framebufferTexture2D = vi10.fn(
1663
+ (target, attachment, textarget, texture, level) => this.calls.push(`framebufferTexture2D:${target}:${attachment}:${textarget}:${!!texture}:${level}`)
1664
+ );
1665
+ this.deleteFramebuffer = vi10.fn((fb) => this.calls.push(`deleteFramebuffer:${!!fb}`));
1666
+ this.checkFramebufferStatus = vi10.fn((target) => this.FRAMEBUFFER_COMPLETE);
1667
+ this.createRenderbuffer = vi10.fn(() => ({ rb: {} }));
1668
+ this.bindRenderbuffer = vi10.fn(
1669
+ (target, renderbuffer) => this.calls.push(`bindRenderbuffer:${target}:${!!renderbuffer}`)
1670
+ );
1671
+ this.renderbufferStorage = vi10.fn(
1672
+ (target, internalformat, width, height) => this.calls.push(`renderbufferStorage:${target}:${internalformat}:${width}:${height}`)
1673
+ );
1674
+ this.framebufferRenderbuffer = vi10.fn(
1675
+ (target, attachment, renderbuffertarget, renderbuffer) => this.calls.push(`framebufferRenderbuffer:${target}:${attachment}:${renderbuffertarget}:${!!renderbuffer}`)
1676
+ );
1677
+ this.deleteRenderbuffer = vi10.fn((rb) => this.calls.push(`deleteRenderbuffer:${!!rb}`));
1678
+ this.drawArrays = vi10.fn(
1679
+ (mode, first, count) => this.calls.push(`drawArrays:${mode}:${first}:${count}`)
1680
+ );
1681
+ this.drawElements = vi10.fn(
1682
+ (mode, count, type, offset) => this.calls.push(`drawElements:${mode}:${count}:${type}:${offset}`)
1683
+ );
1684
+ // Queries
1685
+ this.createQuery = vi10.fn(() => ({}));
1686
+ this.beginQuery = vi10.fn();
1687
+ this.endQuery = vi10.fn();
1688
+ this.deleteQuery = vi10.fn();
1689
+ this.getQueryParameter = vi10.fn();
1690
+ this.getParameter = vi10.fn();
1691
+ this.uniform1f = vi10.fn(
1692
+ (location, x) => this.calls.push(`uniform1f:${location ? "set" : "null"}:${x}`)
1693
+ );
1694
+ this.uniform1i = vi10.fn(
1695
+ (location, x) => this.calls.push(`uniform1i:${location ? "set" : "null"}:${x}`)
1696
+ );
1697
+ this.uniform4f = vi10.fn(
1698
+ (location, x, y, z, w) => this.calls.push(`uniform4f:${location ? "set" : "null"}:${x}:${y}:${z}:${w}`)
1699
+ );
1700
+ this.uniform3fv = vi10.fn(
1701
+ (location, data) => this.calls.push(`uniform3fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
1702
+ );
1703
+ this.uniform3f = vi10.fn(
1704
+ (location, x, y, z) => this.calls.push(`uniform3f:${location ? "set" : "null"}:${x}:${y}:${z}`)
1705
+ );
1706
+ this.uniform2f = vi10.fn(
1707
+ (location, x, y) => this.calls.push(`uniform2f:${location ? "set" : "null"}:${x}:${y}`)
1708
+ );
1709
+ this.uniform4fv = vi10.fn(
1710
+ (location, data) => this.calls.push(`uniform4fv:${location ? "set" : "null"}:${Array.from(data).join(",")}`)
1711
+ );
1712
+ this.uniformMatrix4fv = vi10.fn(
1713
+ (location, transpose, data) => this.calls.push(`uniformMatrix4fv:${location ? "set" : "null"}:${transpose}:${Array.from(data).join(",")}`)
1714
+ );
1715
+ this.uniformBlockBinding = vi10.fn();
1716
+ this.isContextLost = vi10.fn(() => false);
1717
+ if (canvas) {
1718
+ this.canvas = canvas;
1719
+ this.drawingBufferWidth = canvas.width;
1720
+ this.drawingBufferHeight = canvas.height;
1721
+ } else {
1722
+ this.canvas = { width: 800, height: 600 };
1723
+ this.drawingBufferWidth = 800;
1724
+ this.drawingBufferHeight = 600;
1725
+ }
1726
+ }
1727
+ };
1728
+ function createMockWebGL2Context(overridesOrCanvas) {
1729
+ let context;
1730
+ if (overridesOrCanvas instanceof Object && "width" in overridesOrCanvas && "height" in overridesOrCanvas && "getContext" in overridesOrCanvas) {
1731
+ context = new MockWebGL2RenderingContext(overridesOrCanvas);
1732
+ } else {
1733
+ context = new MockWebGL2RenderingContext();
1734
+ if (overridesOrCanvas) {
1735
+ Object.assign(context, overridesOrCanvas);
1736
+ }
1737
+ }
1738
+ return context;
1646
1739
  }
1647
1740
 
1648
1741
  // src/setup/browser.ts
@@ -1900,10 +1993,10 @@ function createMockImage(width, height, src) {
1900
1993
  }
1901
1994
 
1902
1995
  // src/engine/mocks/webgpu.ts
1903
- import { vi as vi10 } from "vitest";
1996
+ import { vi as vi11 } from "vitest";
1904
1997
  function createMockGPUAdapter() {
1905
1998
  return {
1906
- requestDevice: vi10.fn().mockResolvedValue(createMockGPUDevice()),
1999
+ requestDevice: vi11.fn().mockResolvedValue(createMockGPUDevice()),
1907
2000
  features: /* @__PURE__ */ new Set(),
1908
2001
  limits: {}
1909
2002
  };
@@ -1913,40 +2006,40 @@ function createMockGPUDevice() {
1913
2006
  features: /* @__PURE__ */ new Set(),
1914
2007
  limits: {},
1915
2008
  queue: {
1916
- submit: vi10.fn(),
1917
- writeBuffer: vi10.fn(),
1918
- writeTexture: vi10.fn(),
1919
- copyExternalImageToTexture: vi10.fn()
1920
- },
1921
- createCommandEncoder: vi10.fn().mockReturnValue({
1922
- beginRenderPass: vi10.fn().mockReturnValue({
1923
- setPipeline: vi10.fn(),
1924
- draw: vi10.fn(),
1925
- end: vi10.fn()
2009
+ submit: vi11.fn(),
2010
+ writeBuffer: vi11.fn(),
2011
+ writeTexture: vi11.fn(),
2012
+ copyExternalImageToTexture: vi11.fn()
2013
+ },
2014
+ createCommandEncoder: vi11.fn().mockReturnValue({
2015
+ beginRenderPass: vi11.fn().mockReturnValue({
2016
+ setPipeline: vi11.fn(),
2017
+ draw: vi11.fn(),
2018
+ end: vi11.fn()
1926
2019
  }),
1927
- finish: vi10.fn()
2020
+ finish: vi11.fn()
1928
2021
  }),
1929
- createRenderPipeline: vi10.fn(),
1930
- createShaderModule: vi10.fn(),
1931
- createBindGroup: vi10.fn(),
1932
- createBindGroupLayout: vi10.fn(),
1933
- createBuffer: vi10.fn(),
1934
- createTexture: vi10.fn(),
1935
- createSampler: vi10.fn()
2022
+ createRenderPipeline: vi11.fn(),
2023
+ createShaderModule: vi11.fn(),
2024
+ createBindGroup: vi11.fn(),
2025
+ createBindGroupLayout: vi11.fn(),
2026
+ createBuffer: vi11.fn(),
2027
+ createTexture: vi11.fn(),
2028
+ createSampler: vi11.fn()
1936
2029
  };
1937
2030
  }
1938
2031
  function createMockGPUCanvasContext() {
1939
2032
  return {
1940
- configure: vi10.fn(),
1941
- unconfigure: vi10.fn(),
1942
- getCurrentTexture: vi10.fn()
2033
+ configure: vi11.fn(),
2034
+ unconfigure: vi11.fn(),
2035
+ getCurrentTexture: vi11.fn()
1943
2036
  };
1944
2037
  }
1945
2038
  function setupWebGPUMocks() {
1946
2039
  const mockAdapter = createMockGPUAdapter();
1947
2040
  const mockGpu = {
1948
- requestAdapter: vi10.fn().mockResolvedValue(mockAdapter),
1949
- getPreferredCanvasFormat: vi10.fn().mockReturnValue("bgra8unorm")
2041
+ requestAdapter: vi11.fn().mockResolvedValue(mockAdapter),
2042
+ getPreferredCanvasFormat: vi11.fn().mockReturnValue("bgra8unorm")
1950
2043
  };
1951
2044
  Object.defineProperty(global.navigator, "gpu", {
1952
2045
  value: mockGpu,
@@ -3041,6 +3134,7 @@ export {
3041
3134
  InputInjector,
3042
3135
  MockPointerLock,
3043
3136
  MockTransport,
3137
+ MockWebGL2RenderingContext,
3044
3138
  captureAudioEvents,
3045
3139
  captureCanvasDrawCalls,
3046
3140
  captureGameScreenshot,