@valbuild/server 0.60.6 → 0.60.8

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,26 +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
- setTimeout(push, 0); // Enqueue the next chunk asynchronously
1844
- } else if (!isClosed) {
1845
- isClosed = true;
1846
- controller.close();
1847
- }
1848
1839
  }
1849
- push();
1840
+ controller.close();
1850
1841
  }
1851
1842
  });
1852
1843
  return stream;
@@ -2111,7 +2102,6 @@ class LocalValServer extends ValServer {
2111
2102
  };
2112
2103
  }
2113
2104
  async getFiles(filePath, query) {
2114
- console.log("getfiles", query);
2115
2105
  if (query.sha256) {
2116
2106
  const fileExists = this.host.fileExists(this.getFilePath(filePath, query.sha256));
2117
2107
  if (fileExists) {
@@ -1827,26 +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
- setTimeout(push, 0); // Enqueue the next chunk asynchronously
1844
- } else if (!isClosed) {
1845
- isClosed = true;
1846
- controller.close();
1847
- }
1848
1839
  }
1849
- push();
1840
+ controller.close();
1850
1841
  }
1851
1842
  });
1852
1843
  return stream;
@@ -2111,7 +2102,6 @@ class LocalValServer extends ValServer {
2111
2102
  };
2112
2103
  }
2113
2104
  async getFiles(filePath, query) {
2114
- console.log("getfiles", query);
2115
2105
  if (query.sha256) {
2116
2106
  const fileExists = this.host.fileExists(this.getFilePath(filePath, query.sha256));
2117
2107
  if (fileExists) {
@@ -1796,26 +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
- setTimeout(push, 0); // Enqueue the next chunk asynchronously
1813
- } else if (!isClosed) {
1814
- isClosed = true;
1815
- controller.close();
1816
- }
1817
1808
  }
1818
- push();
1809
+ controller.close();
1819
1810
  }
1820
1811
  });
1821
1812
  return stream;
@@ -2080,7 +2071,6 @@ class LocalValServer extends ValServer {
2080
2071
  };
2081
2072
  }
2082
2073
  async getFiles(filePath, query) {
2083
- console.log("getfiles", query);
2084
2074
  if (query.sha256) {
2085
2075
  const fileExists = this.host.fileExists(this.getFilePath(filePath, query.sha256));
2086
2076
  if (fileExists) {
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.6",
15
+ "version": "0.60.8",
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.6",
28
- "@valbuild/shared": "~0.60.6",
29
- "@valbuild/ui": "~0.60.6",
27
+ "@valbuild/core": "~0.60.8",
28
+ "@valbuild/shared": "~0.60.8",
29
+ "@valbuild/ui": "~0.60.8",
30
30
  "express": "^4.18.2",
31
31
  "image-size": "^1.0.2",
32
32
  "minimatch": "^3.0.4",