@inweb/client 26.6.4 → 26.6.6
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.
- package/dist/client.js +38 -44
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +18 -14
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +6 -3
- package/lib/Api/File.d.ts +6 -3
- package/lib/Api/HttpClient.d.ts +1 -1
- package/lib/Api/IHttpClient.d.ts +4 -2
- package/lib/Api/Model.d.ts +5 -2
- package/package.json +2 -2
- package/src/Api/Assembly.ts +7 -4
- package/src/Api/Endpoint.ts +2 -0
- package/src/Api/File.ts +7 -4
- package/src/Api/HttpClient.ts +61 -75
- package/src/Api/IHttpClient.ts +4 -2
- package/src/Api/Model.ts +5 -2
package/dist/client.js
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
this.httpClient = httpClient;
|
|
43
43
|
this.headers = headers;
|
|
44
44
|
}
|
|
45
|
+
// Internal: append the `?version=` search param to the specified relative path.
|
|
45
46
|
appendVersionParam(relativePath) {
|
|
46
47
|
if (this._useVersion === undefined)
|
|
47
48
|
return relativePath;
|
|
@@ -443,8 +444,11 @@
|
|
|
443
444
|
* or geometry data.
|
|
444
445
|
*
|
|
445
446
|
* @param dataId - Resource file name.
|
|
446
|
-
* @param ranges - A
|
|
447
|
-
*
|
|
447
|
+
* @param ranges - A ranges of resource file contents to download. See
|
|
448
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Guides/Range_requests | HTTP range requests} for
|
|
449
|
+
* more details.
|
|
450
|
+
* @param requestId - Specify a non-empty `requestId` to append the `?requestId=` search parameter to
|
|
451
|
+
* the server request. If specified, server-side caching may not work.
|
|
448
452
|
* @param onProgress - Download progress callback.
|
|
449
453
|
* @param signal - An
|
|
450
454
|
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
|
|
@@ -1201,8 +1205,11 @@
|
|
|
1201
1205
|
* descriptions, or geometry data.
|
|
1202
1206
|
*
|
|
1203
1207
|
* @param dataId - Resource file name.
|
|
1204
|
-
* @param ranges - A
|
|
1205
|
-
*
|
|
1208
|
+
* @param ranges - A ranges of resource file contents to download. See
|
|
1209
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Guides/Range_requests | HTTP range requests} for
|
|
1210
|
+
* more details.
|
|
1211
|
+
* @param requestId - Specify a non-empty `requestId` to append the `?requestId=` search parameter to
|
|
1212
|
+
* the server request. If specified, server-side caching may not work.
|
|
1206
1213
|
* @param onProgress - Download progress callback.
|
|
1207
1214
|
* @param signal - An
|
|
1208
1215
|
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
|
|
@@ -1210,7 +1217,7 @@
|
|
|
1210
1217
|
*/
|
|
1211
1218
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
1212
1219
|
return this.httpClient
|
|
1213
|
-
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}?requestId
|
|
1220
|
+
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}${requestId ? "?requestId=" + requestId : ""}`), requestId, ranges, onProgress, { signal, headers: this.headers })
|
|
1214
1221
|
.then((response) => response.arrayBuffer());
|
|
1215
1222
|
}
|
|
1216
1223
|
/**
|
|
@@ -1665,32 +1672,13 @@
|
|
|
1665
1672
|
uploadProgress: onProgress,
|
|
1666
1673
|
});
|
|
1667
1674
|
}
|
|
1668
|
-
// async downloadFile(
|
|
1669
|
-
// relativePath: string,
|
|
1670
|
-
// onProgress?: (progress: number, chunk: Uint8Array) => void,
|
|
1671
|
-
// init: RequestInit = {}
|
|
1672
|
-
// ): Promise<Response> {
|
|
1673
|
-
// const response = await this.get(relativePath, init);
|
|
1674
|
-
// const teedOff = response.body.tee();
|
|
1675
|
-
// if (onProgress) {
|
|
1676
|
-
// const contentLength = response.headers.get("Content-Length");
|
|
1677
|
-
// const total = parseInt(contentLength, 10) || 1;
|
|
1678
|
-
// let loaded = 0;
|
|
1679
|
-
// const reader = teedOff[0].getReader();
|
|
1680
|
-
// reader.read().then(function processChunk({ done, value }) {
|
|
1681
|
-
// if (done) return;
|
|
1682
|
-
// loaded += value.length;
|
|
1683
|
-
// onProgress(loaded / total, value);
|
|
1684
|
-
// reader.read().then(processChunk);
|
|
1685
|
-
// });
|
|
1686
|
-
// }
|
|
1687
|
-
// return new Response(teedOff[1]);
|
|
1688
|
-
// }
|
|
1689
1675
|
async downloadFile(relativePath, onProgress, init = {}) {
|
|
1690
1676
|
const response = await this.get(relativePath, init);
|
|
1677
|
+
if (!onProgress)
|
|
1678
|
+
return response;
|
|
1691
1679
|
const contentLength = response.headers.get("Content-Length");
|
|
1692
1680
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
1693
|
-
|
|
1681
|
+
const stream = new ReadableStream({
|
|
1694
1682
|
async start(controller) {
|
|
1695
1683
|
const reader = response.body.getReader();
|
|
1696
1684
|
let loaded = 0;
|
|
@@ -1700,20 +1688,24 @@
|
|
|
1700
1688
|
break;
|
|
1701
1689
|
controller.enqueue(value);
|
|
1702
1690
|
loaded += value.length;
|
|
1703
|
-
|
|
1704
|
-
onProgress(loaded / total, value);
|
|
1691
|
+
onProgress(loaded / total, value);
|
|
1705
1692
|
}
|
|
1706
1693
|
controller.close();
|
|
1707
1694
|
},
|
|
1708
|
-
})
|
|
1695
|
+
});
|
|
1696
|
+
return new Response(stream);
|
|
1709
1697
|
}
|
|
1710
1698
|
async downloadFileRange(relativePath, reserved, ranges, onProgress, init = {}) {
|
|
1711
|
-
const headers = {
|
|
1712
|
-
|
|
1699
|
+
const headers = {
|
|
1700
|
+
...init.headers,
|
|
1701
|
+
Range: "bytes=" + ranges.map((x) => `${x.begin}-${x.end}`).join(","),
|
|
1702
|
+
};
|
|
1713
1703
|
const response = await this.get(relativePath, { ...init, headers });
|
|
1704
|
+
if (!onProgress)
|
|
1705
|
+
return response;
|
|
1714
1706
|
const contentLength = response.headers.get("content-length");
|
|
1715
1707
|
const total = parseInt(contentLength || "", 10) || 1;
|
|
1716
|
-
|
|
1708
|
+
const stream = new ReadableStream({
|
|
1717
1709
|
async start(controller) {
|
|
1718
1710
|
const reader = response.body.getReader();
|
|
1719
1711
|
let loaded = 0;
|
|
@@ -1729,18 +1721,16 @@
|
|
|
1729
1721
|
let chunkPos = 0;
|
|
1730
1722
|
while (chunkLeft > 0) {
|
|
1731
1723
|
const range = ranges[rangedIndex];
|
|
1732
|
-
const rangeLeft = range.end - range.begin - rangePos;
|
|
1724
|
+
const rangeLeft = range.end - range.begin + 1 - rangePos;
|
|
1733
1725
|
if (chunkLeft < rangeLeft) {
|
|
1734
1726
|
const chunk = value.subarray(chunkPos, chunkPos + chunkLeft);
|
|
1735
|
-
|
|
1736
|
-
onProgress(loaded / total, chunk, range.requestId);
|
|
1727
|
+
onProgress(loaded / total, chunk, range.requestId);
|
|
1737
1728
|
rangePos += chunkLeft;
|
|
1738
1729
|
chunkLeft = 0;
|
|
1739
1730
|
}
|
|
1740
1731
|
else {
|
|
1741
1732
|
const chunk = value.subarray(chunkPos, chunkPos + rangeLeft);
|
|
1742
|
-
|
|
1743
|
-
onProgress(loaded / total, chunk, range.requestId);
|
|
1733
|
+
onProgress(loaded / total, chunk, range.requestId);
|
|
1744
1734
|
chunkPos += rangeLeft;
|
|
1745
1735
|
chunkLeft -= rangeLeft;
|
|
1746
1736
|
rangedIndex++;
|
|
@@ -1750,7 +1740,8 @@
|
|
|
1750
1740
|
}
|
|
1751
1741
|
controller.close();
|
|
1752
1742
|
},
|
|
1753
|
-
})
|
|
1743
|
+
});
|
|
1744
|
+
return new Response(stream);
|
|
1754
1745
|
}
|
|
1755
1746
|
}
|
|
1756
1747
|
|
|
@@ -2784,8 +2775,11 @@
|
|
|
2784
2775
|
* contain model scene descriptions, or geometry data, or exported files.
|
|
2785
2776
|
*
|
|
2786
2777
|
* @param dataId - Resource file name.
|
|
2787
|
-
* @param ranges - A
|
|
2788
|
-
*
|
|
2778
|
+
* @param ranges - A ranges of resource file contents to download. See
|
|
2779
|
+
* {@link https://developer.mozilla.org/docs/Web/HTTP/Guides/Range_requests | HTTP range requests} for
|
|
2780
|
+
* more details.
|
|
2781
|
+
* @param requestId - Specify a non-empty `requestId` to append the `?requestId=` search parameter to
|
|
2782
|
+
* the server request. If specified, server-side caching may not work.
|
|
2789
2783
|
* @param onProgress - Download progress callback.
|
|
2790
2784
|
* @param signal - An
|
|
2791
2785
|
* {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} signal. Allows
|
|
@@ -2793,7 +2787,7 @@
|
|
|
2793
2787
|
*/
|
|
2794
2788
|
downloadResourceRange(dataId, requestId, ranges, onProgress, signal) {
|
|
2795
2789
|
return this.httpClient
|
|
2796
|
-
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}?requestId
|
|
2790
|
+
.downloadFileRange(this.getEndpointPath(`/downloads/${dataId}${requestId ? "?requestId=" + requestId : ""}`), requestId, ranges, onProgress, { signal, headers: this.headers })
|
|
2797
2791
|
.then((response) => response.arrayBuffer());
|
|
2798
2792
|
}
|
|
2799
2793
|
/**
|
|
@@ -4631,7 +4625,7 @@
|
|
|
4631
4625
|
.then((data) => ({
|
|
4632
4626
|
...data,
|
|
4633
4627
|
server: data.version,
|
|
4634
|
-
client: "26.6.
|
|
4628
|
+
client: "26.6.6",
|
|
4635
4629
|
}));
|
|
4636
4630
|
}
|
|
4637
4631
|
/**
|
|
@@ -5530,7 +5524,7 @@
|
|
|
5530
5524
|
// By use of this software, its documentation or related materials, you
|
|
5531
5525
|
// acknowledge and accept the above terms.
|
|
5532
5526
|
///////////////////////////////////////////////////////////////////////////////
|
|
5533
|
-
const version = "26.6.
|
|
5527
|
+
const version = "26.6.6";
|
|
5534
5528
|
|
|
5535
5529
|
exports.Assembly = Assembly;
|
|
5536
5530
|
exports.ClashTest = ClashTest;
|