quake2ts 0.0.593 → 0.0.596

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.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/packages/client/dist/browser/index.global.js.map +1 -1
  3. package/packages/client/dist/cjs/index.cjs.map +1 -1
  4. package/packages/client/dist/esm/index.js.map +1 -1
  5. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  6. package/packages/engine/dist/browser/index.global.js +3 -3
  7. package/packages/engine/dist/browser/index.global.js.map +1 -1
  8. package/packages/engine/dist/cjs/index.cjs +116 -125
  9. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  10. package/packages/engine/dist/esm/index.js +116 -125
  11. package/packages/engine/dist/esm/index.js.map +1 -1
  12. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  13. package/packages/engine/dist/types/index.d.ts +3 -4
  14. package/packages/engine/dist/types/index.d.ts.map +1 -1
  15. package/packages/engine/dist/types/render/interface.d.ts +20 -28
  16. package/packages/engine/dist/types/render/interface.d.ts.map +1 -1
  17. package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
  18. package/packages/engine/dist/types/render/webgpu/context.d.ts +11 -5
  19. package/packages/engine/dist/types/render/webgpu/context.d.ts.map +1 -1
  20. package/packages/engine/dist/types/render/webgpu/headless.d.ts.map +1 -1
  21. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  22. package/packages/test-utils/dist/index.cjs +108 -88
  23. package/packages/test-utils/dist/index.cjs.map +1 -1
  24. package/packages/test-utils/dist/index.d.cts +23 -57
  25. package/packages/test-utils/dist/index.d.ts +23 -57
  26. package/packages/test-utils/dist/index.js +93 -78
  27. package/packages/test-utils/dist/index.js.map +1 -1
  28. package/packages/tools/dist/browser/index.global.js.map +1 -1
  29. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
@@ -1773,101 +1773,6 @@ var EngineHost = class {
1773
1773
  }
1774
1774
  };
1775
1775
 
1776
- // src/configstrings.ts
1777
- function assertWithinBounds(index) {
1778
- if (index < 0 || index >= ConfigStringIndex.MaxConfigStrings) {
1779
- throw new RangeError(`Configstring index ${index} is out of range (0-${ConfigStringIndex.MaxConfigStrings - 1})`);
1780
- }
1781
- }
1782
- function assertLength(index, value) {
1783
- const maxLength = configStringSize(index);
1784
- if (value.length > maxLength) {
1785
- throw new RangeError(
1786
- `Configstring ${index} exceeds maximum length (${value.length} > ${maxLength}); limit is ${CS_MAX_STRING_LENGTH} chars per slot`
1787
- );
1788
- }
1789
- }
1790
- var ConfigStringRegistry = class {
1791
- constructor() {
1792
- this.values = /* @__PURE__ */ new Map();
1793
- this.modelCursor = ConfigStringIndex.Models;
1794
- this.soundCursor = ConfigStringIndex.Sounds;
1795
- this.imageCursor = ConfigStringIndex.Images;
1796
- this.lightCursor = ConfigStringIndex.Lights;
1797
- this.shadowLightCursor = ConfigStringIndex.ShadowLights;
1798
- this.itemCursor = ConfigStringIndex.Items;
1799
- this.playerSkinCursor = ConfigStringIndex.PlayerSkins;
1800
- this.generalCursor = ConfigStringIndex.General;
1801
- }
1802
- set(index, value) {
1803
- assertWithinBounds(index);
1804
- assertLength(index, value);
1805
- this.values.set(index, value);
1806
- return index;
1807
- }
1808
- get(index) {
1809
- return this.values.get(index);
1810
- }
1811
- getName(index) {
1812
- return this.get(index);
1813
- }
1814
- getAll() {
1815
- const result = new Array(MAX_CONFIGSTRINGS).fill("");
1816
- for (const [index, value] of this.values.entries()) {
1817
- result[index] = value;
1818
- }
1819
- return result;
1820
- }
1821
- modelIndex(path) {
1822
- return this.register(path, ConfigStringIndex.Models, MAX_MODELS, "modelCursor");
1823
- }
1824
- soundIndex(path) {
1825
- return this.register(path, ConfigStringIndex.Sounds, MAX_SOUNDS, "soundCursor");
1826
- }
1827
- findSoundIndex(path) {
1828
- for (let i = ConfigStringIndex.Sounds; i < ConfigStringIndex.Sounds + MAX_SOUNDS; i += 1) {
1829
- if (this.values.get(i) === path) {
1830
- return i;
1831
- }
1832
- }
1833
- return void 0;
1834
- }
1835
- imageIndex(path) {
1836
- return this.register(path, ConfigStringIndex.Images, MAX_IMAGES, "imageCursor");
1837
- }
1838
- lightIndex(definition) {
1839
- return this.register(definition, ConfigStringIndex.Lights, MAX_LIGHTSTYLES, "lightCursor");
1840
- }
1841
- shadowLightIndex(definition) {
1842
- return this.register(definition, ConfigStringIndex.ShadowLights, MAX_SHADOW_LIGHTS, "shadowLightCursor");
1843
- }
1844
- itemIndex(name) {
1845
- return this.register(name, ConfigStringIndex.Items, MAX_ITEMS, "itemCursor");
1846
- }
1847
- playerSkinIndex(name) {
1848
- return this.register(name, ConfigStringIndex.PlayerSkins, MAX_CLIENTS, "playerSkinCursor");
1849
- }
1850
- generalIndex(value) {
1851
- return this.register(value, ConfigStringIndex.General, MAX_GENERAL, "generalCursor");
1852
- }
1853
- register(value, start, maxCount, cursorKey) {
1854
- for (let i = start; i < start + maxCount; i += 1) {
1855
- if (this.values.get(i) === value) {
1856
- return i;
1857
- }
1858
- }
1859
- const next = this[cursorKey];
1860
- const limit = start + maxCount;
1861
- if (next >= limit) {
1862
- throw new RangeError(`Out of configstring slots for range starting at ${start}`);
1863
- }
1864
- assertLength(next, value);
1865
- this.values.set(next, value);
1866
- this[cursorKey] = next + 1;
1867
- return next;
1868
- }
1869
- };
1870
-
1871
1776
  // src/audio/api.ts
1872
1777
  var AudioApi = class {
1873
1778
  constructor(options) {
@@ -1994,6 +1899,101 @@ function createEngineRuntime(engine, game, client, audioOptions, options) {
1994
1899
  return { runtime, audio };
1995
1900
  }
1996
1901
 
1902
+ // src/configstrings.ts
1903
+ function assertWithinBounds(index) {
1904
+ if (index < 0 || index >= ConfigStringIndex.MaxConfigStrings) {
1905
+ throw new RangeError(`Configstring index ${index} is out of range (0-${ConfigStringIndex.MaxConfigStrings - 1})`);
1906
+ }
1907
+ }
1908
+ function assertLength(index, value) {
1909
+ const maxLength = configStringSize(index);
1910
+ if (value.length > maxLength) {
1911
+ throw new RangeError(
1912
+ `Configstring ${index} exceeds maximum length (${value.length} > ${maxLength}); limit is ${CS_MAX_STRING_LENGTH} chars per slot`
1913
+ );
1914
+ }
1915
+ }
1916
+ var ConfigStringRegistry = class {
1917
+ constructor() {
1918
+ this.values = /* @__PURE__ */ new Map();
1919
+ this.modelCursor = ConfigStringIndex.Models;
1920
+ this.soundCursor = ConfigStringIndex.Sounds;
1921
+ this.imageCursor = ConfigStringIndex.Images;
1922
+ this.lightCursor = ConfigStringIndex.Lights;
1923
+ this.shadowLightCursor = ConfigStringIndex.ShadowLights;
1924
+ this.itemCursor = ConfigStringIndex.Items;
1925
+ this.playerSkinCursor = ConfigStringIndex.PlayerSkins;
1926
+ this.generalCursor = ConfigStringIndex.General;
1927
+ }
1928
+ set(index, value) {
1929
+ assertWithinBounds(index);
1930
+ assertLength(index, value);
1931
+ this.values.set(index, value);
1932
+ return index;
1933
+ }
1934
+ get(index) {
1935
+ return this.values.get(index);
1936
+ }
1937
+ getName(index) {
1938
+ return this.get(index);
1939
+ }
1940
+ getAll() {
1941
+ const result = new Array(MAX_CONFIGSTRINGS).fill("");
1942
+ for (const [index, value] of this.values.entries()) {
1943
+ result[index] = value;
1944
+ }
1945
+ return result;
1946
+ }
1947
+ modelIndex(path) {
1948
+ return this.register(path, ConfigStringIndex.Models, MAX_MODELS, "modelCursor");
1949
+ }
1950
+ soundIndex(path) {
1951
+ return this.register(path, ConfigStringIndex.Sounds, MAX_SOUNDS, "soundCursor");
1952
+ }
1953
+ findSoundIndex(path) {
1954
+ for (let i = ConfigStringIndex.Sounds; i < ConfigStringIndex.Sounds + MAX_SOUNDS; i += 1) {
1955
+ if (this.values.get(i) === path) {
1956
+ return i;
1957
+ }
1958
+ }
1959
+ return void 0;
1960
+ }
1961
+ imageIndex(path) {
1962
+ return this.register(path, ConfigStringIndex.Images, MAX_IMAGES, "imageCursor");
1963
+ }
1964
+ lightIndex(definition) {
1965
+ return this.register(definition, ConfigStringIndex.Lights, MAX_LIGHTSTYLES, "lightCursor");
1966
+ }
1967
+ shadowLightIndex(definition) {
1968
+ return this.register(definition, ConfigStringIndex.ShadowLights, MAX_SHADOW_LIGHTS, "shadowLightCursor");
1969
+ }
1970
+ itemIndex(name) {
1971
+ return this.register(name, ConfigStringIndex.Items, MAX_ITEMS, "itemCursor");
1972
+ }
1973
+ playerSkinIndex(name) {
1974
+ return this.register(name, ConfigStringIndex.PlayerSkins, MAX_CLIENTS, "playerSkinCursor");
1975
+ }
1976
+ generalIndex(value) {
1977
+ return this.register(value, ConfigStringIndex.General, MAX_GENERAL, "generalCursor");
1978
+ }
1979
+ register(value, start, maxCount, cursorKey) {
1980
+ for (let i = start; i < start + maxCount; i += 1) {
1981
+ if (this.values.get(i) === value) {
1982
+ return i;
1983
+ }
1984
+ }
1985
+ const next = this[cursorKey];
1986
+ const limit = start + maxCount;
1987
+ if (next >= limit) {
1988
+ throw new RangeError(`Out of configstring slots for range starting at ${start}`);
1989
+ }
1990
+ assertLength(next, value);
1991
+ this.values.set(next, value);
1992
+ this[cursorKey] = next + 1;
1993
+ return next;
1994
+ }
1995
+ };
1996
+
1997
1997
  // src/assets/pak.ts
1998
1998
  var PAK_MAGIC = "PACK";
1999
1999
  var HEADER_SIZE = 12;
@@ -17985,55 +17985,43 @@ async function createWebGPUContext(canvas, options) {
17985
17985
  if (!navigator.gpu) {
17986
17986
  throw new Error("WebGPU is not supported in this environment");
17987
17987
  }
17988
- const adapterOptions = {
17989
- powerPreference: options?.powerPreference ?? "high-performance",
17990
- forceFallbackAdapter: options?.forceFallbackAdapter
17991
- };
17992
- const adapter = await navigator.gpu.requestAdapter(adapterOptions);
17988
+ const adapter = await navigator.gpu.requestAdapter({
17989
+ powerPreference: options?.powerPreference || "high-performance"
17990
+ });
17993
17991
  if (!adapter) {
17994
- console.error("WebGPU Adapter Request Failed");
17995
- console.error("Options:", JSON.stringify(adapterOptions));
17996
- console.error("Navigator.gpu:", navigator.gpu);
17997
- if (typeof process !== "undefined" && process.env) {
17998
- console.error("Environment:", {
17999
- VK_ICD_FILENAMES: process.env.VK_ICD_FILENAMES,
18000
- DISPLAY: process.env.DISPLAY
18001
- });
18002
- }
18003
- throw new Error("Failed to request WebGPU adapter");
17992
+ throw new Error("No appropriate GPUAdapter found");
18004
17993
  }
18005
17994
  if (options?.requiredFeatures) {
18006
17995
  for (const feature of options.requiredFeatures) {
18007
17996
  if (!adapter.features.has(feature)) {
18008
- throw new Error(`Required WebGPU feature '${feature}' is not supported by the adapter`);
17997
+ throw new Error(`Required feature not available: ${feature}`);
18009
17998
  }
18010
17999
  }
18011
18000
  }
18012
- const device = await adapter.requestDevice({
18001
+ const deviceDescriptor = {
18013
18002
  requiredFeatures: options?.requiredFeatures,
18014
18003
  requiredLimits: options?.requiredLimits
18015
- });
18016
- if (!device) {
18017
- throw new Error("Failed to request WebGPU device");
18018
- }
18004
+ };
18005
+ const device = await adapter.requestDevice(deviceDescriptor);
18019
18006
  let context;
18020
- let format;
18007
+ let format = "bgra8unorm";
18008
+ let isHeadless = true;
18021
18009
  if (canvas) {
18022
18010
  context = canvas.getContext("webgpu");
18023
18011
  if (!context) {
18024
18012
  throw new Error("Failed to get WebGPU context from canvas");
18025
18013
  }
18014
+ isHeadless = false;
18026
18015
  format = navigator.gpu.getPreferredCanvasFormat();
18027
18016
  context.configure({
18028
18017
  device,
18029
18018
  format,
18030
- alphaMode: "premultiplied"
18019
+ alphaMode: "opaque"
18020
+ // Standard for game rendering
18031
18021
  });
18032
- } else {
18033
- format = "rgba8unorm";
18034
18022
  }
18035
18023
  const features = /* @__PURE__ */ new Set();
18036
- for (const feature of device.features) {
18024
+ for (const feature of adapter.features) {
18037
18025
  features.add(feature);
18038
18026
  }
18039
18027
  return {
@@ -18043,7 +18031,7 @@ async function createWebGPUContext(canvas, options) {
18043
18031
  format,
18044
18032
  features,
18045
18033
  limits: device.limits,
18046
- isHeadless: !canvas
18034
+ isHeadless
18047
18035
  };
18048
18036
  }
18049
18037
  function queryCapabilities(state) {
@@ -18063,10 +18051,11 @@ function queryCapabilities(state) {
18063
18051
 
18064
18052
  // src/render/webgpu/headless.ts
18065
18053
  function createHeadlessRenderTarget(device, width, height, format = "rgba8unorm") {
18054
+ const usage = typeof GPUTextureUsage !== "undefined" ? GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC : 17;
18066
18055
  const texture = device.createTexture({
18067
18056
  size: { width, height, depthOrArrayLayers: 1 },
18068
18057
  format,
18069
- usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
18058
+ usage
18070
18059
  });
18071
18060
  const view = texture.createView();
18072
18061
  return {
@@ -18084,9 +18073,10 @@ async function captureRenderTarget(device, texture) {
18084
18073
  const align = 256;
18085
18074
  const paddedBytesPerRow = Math.max(bytesPerPixel * width, Math.ceil(width * bytesPerPixel / align) * align);
18086
18075
  const bufferSize = paddedBytesPerRow * height;
18076
+ const usage = typeof GPUBufferUsage !== "undefined" ? GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ : 9;
18087
18077
  const outputBuffer = device.createBuffer({
18088
18078
  size: bufferSize,
18089
- usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
18079
+ usage
18090
18080
  });
18091
18081
  const commandEncoder = device.createCommandEncoder();
18092
18082
  commandEncoder.copyTextureToBuffer(
@@ -18104,7 +18094,8 @@ async function captureRenderTarget(device, texture) {
18104
18094
  }
18105
18095
  );
18106
18096
  device.queue.submit([commandEncoder.finish()]);
18107
- await outputBuffer.mapAsync(GPUMapMode.READ);
18097
+ const mapMode = typeof GPUMapMode !== "undefined" ? GPUMapMode.READ : 1;
18098
+ await outputBuffer.mapAsync(mapMode);
18108
18099
  const mappedRange = outputBuffer.getMappedRange();
18109
18100
  const data = new Uint8Array(mappedRange);
18110
18101
  const result = new Uint8ClampedArray(width * height * 4);