@valbuild/server 0.60.7 → 0.60.9

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.
@@ -1827,28 +1827,17 @@ class ValServer {
1827
1827
 
1828
1828
  /* Abstract patch endpoints: */
1829
1829
  }
1830
-
1831
- // From slightly modified ChatGPT generated
1830
+ const chunkSize = 1024 * 1024;
1832
1831
  function bufferToReadableStream(buffer) {
1833
1832
  const stream = new ReadableStream({
1834
1833
  start(controller) {
1835
- const chunkSize = 1024; // Adjust the chunk size as needed
1836
1834
  let offset = 0;
1837
- let isClosed = false;
1838
- function push() {
1835
+ while (offset < buffer.length) {
1839
1836
  const chunk = buffer.subarray(offset, offset + chunkSize);
1837
+ controller.enqueue(chunk);
1840
1838
  offset += chunkSize;
1841
- if (chunk.length > 0) {
1842
- controller.enqueue(new Uint8Array(chunk));
1843
- // TODO: evaluate if we need to enqueue the next chunk asynchronously - this should help performance (perhaps?), but we suspect it leads to issues as well
1844
- // setTimeout(push, 0); // Enqueue the next chunk asynchronously
1845
- push();
1846
- } else if (!isClosed) {
1847
- isClosed = true;
1848
- controller.close();
1849
- }
1850
1839
  }
1851
- push();
1840
+ controller.close();
1852
1841
  }
1853
1842
  });
1854
1843
  return stream;
@@ -1827,28 +1827,17 @@ class ValServer {
1827
1827
 
1828
1828
  /* Abstract patch endpoints: */
1829
1829
  }
1830
-
1831
- // From slightly modified ChatGPT generated
1830
+ const chunkSize = 1024 * 1024;
1832
1831
  function bufferToReadableStream(buffer) {
1833
1832
  const stream = new ReadableStream({
1834
1833
  start(controller) {
1835
- const chunkSize = 1024; // Adjust the chunk size as needed
1836
1834
  let offset = 0;
1837
- let isClosed = false;
1838
- function push() {
1835
+ while (offset < buffer.length) {
1839
1836
  const chunk = buffer.subarray(offset, offset + chunkSize);
1837
+ controller.enqueue(chunk);
1840
1838
  offset += chunkSize;
1841
- if (chunk.length > 0) {
1842
- controller.enqueue(new Uint8Array(chunk));
1843
- // TODO: evaluate if we need to enqueue the next chunk asynchronously - this should help performance (perhaps?), but we suspect it leads to issues as well
1844
- // setTimeout(push, 0); // Enqueue the next chunk asynchronously
1845
- push();
1846
- } else if (!isClosed) {
1847
- isClosed = true;
1848
- controller.close();
1849
- }
1850
1839
  }
1851
- push();
1840
+ controller.close();
1852
1841
  }
1853
1842
  });
1854
1843
  return stream;
@@ -1796,28 +1796,17 @@ class ValServer {
1796
1796
 
1797
1797
  /* Abstract patch endpoints: */
1798
1798
  }
1799
-
1800
- // From slightly modified ChatGPT generated
1799
+ const chunkSize = 1024 * 1024;
1801
1800
  function bufferToReadableStream(buffer) {
1802
1801
  const stream = new ReadableStream({
1803
1802
  start(controller) {
1804
- const chunkSize = 1024; // Adjust the chunk size as needed
1805
1803
  let offset = 0;
1806
- let isClosed = false;
1807
- function push() {
1804
+ while (offset < buffer.length) {
1808
1805
  const chunk = buffer.subarray(offset, offset + chunkSize);
1806
+ controller.enqueue(chunk);
1809
1807
  offset += chunkSize;
1810
- if (chunk.length > 0) {
1811
- controller.enqueue(new Uint8Array(chunk));
1812
- // TODO: evaluate if we need to enqueue the next chunk asynchronously - this should help performance (perhaps?), but we suspect it leads to issues as well
1813
- // setTimeout(push, 0); // Enqueue the next chunk asynchronously
1814
- push();
1815
- } else if (!isClosed) {
1816
- isClosed = true;
1817
- controller.close();
1818
- }
1819
1808
  }
1820
- push();
1809
+ controller.close();
1821
1810
  }
1822
1811
  });
1823
1812
  return stream;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "./package.json": "./package.json"
13
13
  },
14
14
  "types": "dist/valbuild-server.cjs.d.ts",
15
- "version": "0.60.7",
15
+ "version": "0.60.9",
16
16
  "scripts": {
17
17
  "typecheck": "tsc --noEmit",
18
18
  "test": "jest",
@@ -24,9 +24,9 @@
24
24
  "concurrently": "^7.6.0"
25
25
  },
26
26
  "dependencies": {
27
- "@valbuild/core": "~0.60.7",
28
- "@valbuild/shared": "~0.60.7",
29
- "@valbuild/ui": "~0.60.7",
27
+ "@valbuild/core": "~0.60.9",
28
+ "@valbuild/shared": "~0.60.9",
29
+ "@valbuild/ui": "~0.60.9",
30
30
  "express": "^4.18.2",
31
31
  "image-size": "^1.0.2",
32
32
  "minimatch": "^3.0.4",