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
@@ -1552,101 +1552,6 @@ var EngineHost = class {
1552
1552
  }
1553
1553
  };
1554
1554
 
1555
- // src/configstrings.ts
1556
- function assertWithinBounds(index) {
1557
- if (index < 0 || index >= ConfigStringIndex.MaxConfigStrings) {
1558
- throw new RangeError(`Configstring index ${index} is out of range (0-${ConfigStringIndex.MaxConfigStrings - 1})`);
1559
- }
1560
- }
1561
- function assertLength(index, value) {
1562
- const maxLength = configStringSize(index);
1563
- if (value.length > maxLength) {
1564
- throw new RangeError(
1565
- `Configstring ${index} exceeds maximum length (${value.length} > ${maxLength}); limit is ${CS_MAX_STRING_LENGTH} chars per slot`
1566
- );
1567
- }
1568
- }
1569
- var ConfigStringRegistry = class {
1570
- constructor() {
1571
- this.values = /* @__PURE__ */ new Map();
1572
- this.modelCursor = ConfigStringIndex.Models;
1573
- this.soundCursor = ConfigStringIndex.Sounds;
1574
- this.imageCursor = ConfigStringIndex.Images;
1575
- this.lightCursor = ConfigStringIndex.Lights;
1576
- this.shadowLightCursor = ConfigStringIndex.ShadowLights;
1577
- this.itemCursor = ConfigStringIndex.Items;
1578
- this.playerSkinCursor = ConfigStringIndex.PlayerSkins;
1579
- this.generalCursor = ConfigStringIndex.General;
1580
- }
1581
- set(index, value) {
1582
- assertWithinBounds(index);
1583
- assertLength(index, value);
1584
- this.values.set(index, value);
1585
- return index;
1586
- }
1587
- get(index) {
1588
- return this.values.get(index);
1589
- }
1590
- getName(index) {
1591
- return this.get(index);
1592
- }
1593
- getAll() {
1594
- const result = new Array(MAX_CONFIGSTRINGS).fill("");
1595
- for (const [index, value] of this.values.entries()) {
1596
- result[index] = value;
1597
- }
1598
- return result;
1599
- }
1600
- modelIndex(path) {
1601
- return this.register(path, ConfigStringIndex.Models, MAX_MODELS, "modelCursor");
1602
- }
1603
- soundIndex(path) {
1604
- return this.register(path, ConfigStringIndex.Sounds, MAX_SOUNDS, "soundCursor");
1605
- }
1606
- findSoundIndex(path) {
1607
- for (let i = ConfigStringIndex.Sounds; i < ConfigStringIndex.Sounds + MAX_SOUNDS; i += 1) {
1608
- if (this.values.get(i) === path) {
1609
- return i;
1610
- }
1611
- }
1612
- return void 0;
1613
- }
1614
- imageIndex(path) {
1615
- return this.register(path, ConfigStringIndex.Images, MAX_IMAGES, "imageCursor");
1616
- }
1617
- lightIndex(definition) {
1618
- return this.register(definition, ConfigStringIndex.Lights, MAX_LIGHTSTYLES, "lightCursor");
1619
- }
1620
- shadowLightIndex(definition) {
1621
- return this.register(definition, ConfigStringIndex.ShadowLights, MAX_SHADOW_LIGHTS, "shadowLightCursor");
1622
- }
1623
- itemIndex(name) {
1624
- return this.register(name, ConfigStringIndex.Items, MAX_ITEMS, "itemCursor");
1625
- }
1626
- playerSkinIndex(name) {
1627
- return this.register(name, ConfigStringIndex.PlayerSkins, MAX_CLIENTS, "playerSkinCursor");
1628
- }
1629
- generalIndex(value) {
1630
- return this.register(value, ConfigStringIndex.General, MAX_GENERAL, "generalCursor");
1631
- }
1632
- register(value, start, maxCount, cursorKey) {
1633
- for (let i = start; i < start + maxCount; i += 1) {
1634
- if (this.values.get(i) === value) {
1635
- return i;
1636
- }
1637
- }
1638
- const next = this[cursorKey];
1639
- const limit = start + maxCount;
1640
- if (next >= limit) {
1641
- throw new RangeError(`Out of configstring slots for range starting at ${start}`);
1642
- }
1643
- assertLength(next, value);
1644
- this.values.set(next, value);
1645
- this[cursorKey] = next + 1;
1646
- return next;
1647
- }
1648
- };
1649
-
1650
1555
  // src/audio/api.ts
1651
1556
  var AudioApi = class {
1652
1557
  constructor(options) {
@@ -1773,6 +1678,101 @@ function createEngineRuntime(engine, game, client, audioOptions, options) {
1773
1678
  return { runtime, audio };
1774
1679
  }
1775
1680
 
1681
+ // src/configstrings.ts
1682
+ function assertWithinBounds(index) {
1683
+ if (index < 0 || index >= ConfigStringIndex.MaxConfigStrings) {
1684
+ throw new RangeError(`Configstring index ${index} is out of range (0-${ConfigStringIndex.MaxConfigStrings - 1})`);
1685
+ }
1686
+ }
1687
+ function assertLength(index, value) {
1688
+ const maxLength = configStringSize(index);
1689
+ if (value.length > maxLength) {
1690
+ throw new RangeError(
1691
+ `Configstring ${index} exceeds maximum length (${value.length} > ${maxLength}); limit is ${CS_MAX_STRING_LENGTH} chars per slot`
1692
+ );
1693
+ }
1694
+ }
1695
+ var ConfigStringRegistry = class {
1696
+ constructor() {
1697
+ this.values = /* @__PURE__ */ new Map();
1698
+ this.modelCursor = ConfigStringIndex.Models;
1699
+ this.soundCursor = ConfigStringIndex.Sounds;
1700
+ this.imageCursor = ConfigStringIndex.Images;
1701
+ this.lightCursor = ConfigStringIndex.Lights;
1702
+ this.shadowLightCursor = ConfigStringIndex.ShadowLights;
1703
+ this.itemCursor = ConfigStringIndex.Items;
1704
+ this.playerSkinCursor = ConfigStringIndex.PlayerSkins;
1705
+ this.generalCursor = ConfigStringIndex.General;
1706
+ }
1707
+ set(index, value) {
1708
+ assertWithinBounds(index);
1709
+ assertLength(index, value);
1710
+ this.values.set(index, value);
1711
+ return index;
1712
+ }
1713
+ get(index) {
1714
+ return this.values.get(index);
1715
+ }
1716
+ getName(index) {
1717
+ return this.get(index);
1718
+ }
1719
+ getAll() {
1720
+ const result = new Array(MAX_CONFIGSTRINGS).fill("");
1721
+ for (const [index, value] of this.values.entries()) {
1722
+ result[index] = value;
1723
+ }
1724
+ return result;
1725
+ }
1726
+ modelIndex(path) {
1727
+ return this.register(path, ConfigStringIndex.Models, MAX_MODELS, "modelCursor");
1728
+ }
1729
+ soundIndex(path) {
1730
+ return this.register(path, ConfigStringIndex.Sounds, MAX_SOUNDS, "soundCursor");
1731
+ }
1732
+ findSoundIndex(path) {
1733
+ for (let i = ConfigStringIndex.Sounds; i < ConfigStringIndex.Sounds + MAX_SOUNDS; i += 1) {
1734
+ if (this.values.get(i) === path) {
1735
+ return i;
1736
+ }
1737
+ }
1738
+ return void 0;
1739
+ }
1740
+ imageIndex(path) {
1741
+ return this.register(path, ConfigStringIndex.Images, MAX_IMAGES, "imageCursor");
1742
+ }
1743
+ lightIndex(definition) {
1744
+ return this.register(definition, ConfigStringIndex.Lights, MAX_LIGHTSTYLES, "lightCursor");
1745
+ }
1746
+ shadowLightIndex(definition) {
1747
+ return this.register(definition, ConfigStringIndex.ShadowLights, MAX_SHADOW_LIGHTS, "shadowLightCursor");
1748
+ }
1749
+ itemIndex(name) {
1750
+ return this.register(name, ConfigStringIndex.Items, MAX_ITEMS, "itemCursor");
1751
+ }
1752
+ playerSkinIndex(name) {
1753
+ return this.register(name, ConfigStringIndex.PlayerSkins, MAX_CLIENTS, "playerSkinCursor");
1754
+ }
1755
+ generalIndex(value) {
1756
+ return this.register(value, ConfigStringIndex.General, MAX_GENERAL, "generalCursor");
1757
+ }
1758
+ register(value, start, maxCount, cursorKey) {
1759
+ for (let i = start; i < start + maxCount; i += 1) {
1760
+ if (this.values.get(i) === value) {
1761
+ return i;
1762
+ }
1763
+ }
1764
+ const next = this[cursorKey];
1765
+ const limit = start + maxCount;
1766
+ if (next >= limit) {
1767
+ throw new RangeError(`Out of configstring slots for range starting at ${start}`);
1768
+ }
1769
+ assertLength(next, value);
1770
+ this.values.set(next, value);
1771
+ this[cursorKey] = next + 1;
1772
+ return next;
1773
+ }
1774
+ };
1775
+
1776
1776
  // src/assets/pak.ts
1777
1777
  var PAK_MAGIC = "PACK";
1778
1778
  var HEADER_SIZE = 12;
@@ -17764,55 +17764,43 @@ async function createWebGPUContext(canvas, options) {
17764
17764
  if (!navigator.gpu) {
17765
17765
  throw new Error("WebGPU is not supported in this environment");
17766
17766
  }
17767
- const adapterOptions = {
17768
- powerPreference: options?.powerPreference ?? "high-performance",
17769
- forceFallbackAdapter: options?.forceFallbackAdapter
17770
- };
17771
- const adapter = await navigator.gpu.requestAdapter(adapterOptions);
17767
+ const adapter = await navigator.gpu.requestAdapter({
17768
+ powerPreference: options?.powerPreference || "high-performance"
17769
+ });
17772
17770
  if (!adapter) {
17773
- console.error("WebGPU Adapter Request Failed");
17774
- console.error("Options:", JSON.stringify(adapterOptions));
17775
- console.error("Navigator.gpu:", navigator.gpu);
17776
- if (typeof process !== "undefined" && process.env) {
17777
- console.error("Environment:", {
17778
- VK_ICD_FILENAMES: process.env.VK_ICD_FILENAMES,
17779
- DISPLAY: process.env.DISPLAY
17780
- });
17781
- }
17782
- throw new Error("Failed to request WebGPU adapter");
17771
+ throw new Error("No appropriate GPUAdapter found");
17783
17772
  }
17784
17773
  if (options?.requiredFeatures) {
17785
17774
  for (const feature of options.requiredFeatures) {
17786
17775
  if (!adapter.features.has(feature)) {
17787
- throw new Error(`Required WebGPU feature '${feature}' is not supported by the adapter`);
17776
+ throw new Error(`Required feature not available: ${feature}`);
17788
17777
  }
17789
17778
  }
17790
17779
  }
17791
- const device = await adapter.requestDevice({
17780
+ const deviceDescriptor = {
17792
17781
  requiredFeatures: options?.requiredFeatures,
17793
17782
  requiredLimits: options?.requiredLimits
17794
- });
17795
- if (!device) {
17796
- throw new Error("Failed to request WebGPU device");
17797
- }
17783
+ };
17784
+ const device = await adapter.requestDevice(deviceDescriptor);
17798
17785
  let context;
17799
- let format;
17786
+ let format = "bgra8unorm";
17787
+ let isHeadless = true;
17800
17788
  if (canvas) {
17801
17789
  context = canvas.getContext("webgpu");
17802
17790
  if (!context) {
17803
17791
  throw new Error("Failed to get WebGPU context from canvas");
17804
17792
  }
17793
+ isHeadless = false;
17805
17794
  format = navigator.gpu.getPreferredCanvasFormat();
17806
17795
  context.configure({
17807
17796
  device,
17808
17797
  format,
17809
- alphaMode: "premultiplied"
17798
+ alphaMode: "opaque"
17799
+ // Standard for game rendering
17810
17800
  });
17811
- } else {
17812
- format = "rgba8unorm";
17813
17801
  }
17814
17802
  const features = /* @__PURE__ */ new Set();
17815
- for (const feature of device.features) {
17803
+ for (const feature of adapter.features) {
17816
17804
  features.add(feature);
17817
17805
  }
17818
17806
  return {
@@ -17822,7 +17810,7 @@ async function createWebGPUContext(canvas, options) {
17822
17810
  format,
17823
17811
  features,
17824
17812
  limits: device.limits,
17825
- isHeadless: !canvas
17813
+ isHeadless
17826
17814
  };
17827
17815
  }
17828
17816
  function queryCapabilities(state) {
@@ -17842,10 +17830,11 @@ function queryCapabilities(state) {
17842
17830
 
17843
17831
  // src/render/webgpu/headless.ts
17844
17832
  function createHeadlessRenderTarget(device, width, height, format = "rgba8unorm") {
17833
+ const usage = typeof GPUTextureUsage !== "undefined" ? GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC : 17;
17845
17834
  const texture = device.createTexture({
17846
17835
  size: { width, height, depthOrArrayLayers: 1 },
17847
17836
  format,
17848
- usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC
17837
+ usage
17849
17838
  });
17850
17839
  const view = texture.createView();
17851
17840
  return {
@@ -17863,9 +17852,10 @@ async function captureRenderTarget(device, texture) {
17863
17852
  const align = 256;
17864
17853
  const paddedBytesPerRow = Math.max(bytesPerPixel * width, Math.ceil(width * bytesPerPixel / align) * align);
17865
17854
  const bufferSize = paddedBytesPerRow * height;
17855
+ const usage = typeof GPUBufferUsage !== "undefined" ? GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ : 9;
17866
17856
  const outputBuffer = device.createBuffer({
17867
17857
  size: bufferSize,
17868
- usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ
17858
+ usage
17869
17859
  });
17870
17860
  const commandEncoder = device.createCommandEncoder();
17871
17861
  commandEncoder.copyTextureToBuffer(
@@ -17883,7 +17873,8 @@ async function captureRenderTarget(device, texture) {
17883
17873
  }
17884
17874
  );
17885
17875
  device.queue.submit([commandEncoder.finish()]);
17886
- await outputBuffer.mapAsync(GPUMapMode.READ);
17876
+ const mapMode = typeof GPUMapMode !== "undefined" ? GPUMapMode.READ : 1;
17877
+ await outputBuffer.mapAsync(mapMode);
17887
17878
  const mappedRange = outputBuffer.getMappedRange();
17888
17879
  const data = new Uint8Array(mappedRange);
17889
17880
  const result = new Uint8ClampedArray(width * height * 4);