geotiff 3.0.2 → 3.0.4-beta.0

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 (279) hide show
  1. package/dist-browser/geotiff.js +3 -3
  2. package/dist-browser/geotiff.js.map +1 -1
  3. package/dist-module/compression/basedecoder.d.ts +30 -4
  4. package/dist-module/compression/basedecoder.d.ts.map +1 -1
  5. package/dist-module/compression/basedecoder.js +22 -1
  6. package/dist-module/compression/basedecoder.js.map +1 -0
  7. package/dist-module/compression/deflate.d.ts +2 -1
  8. package/dist-module/compression/deflate.d.ts.map +1 -1
  9. package/dist-module/compression/deflate.js +2 -0
  10. package/dist-module/compression/deflate.js.map +1 -0
  11. package/dist-module/compression/index.d.ts +14 -22
  12. package/dist-module/compression/index.d.ts.map +1 -1
  13. package/dist-module/compression/index.js +36 -25
  14. package/dist-module/compression/index.js.map +1 -0
  15. package/dist-module/compression/jpeg.d.ts +55 -15
  16. package/dist-module/compression/jpeg.d.ts.map +1 -1
  17. package/dist-module/compression/jpeg.js +187 -16
  18. package/dist-module/compression/jpeg.js.map +1 -0
  19. package/dist-module/compression/lerc.d.ts +11 -1
  20. package/dist-module/compression/lerc.d.ts.map +1 -1
  21. package/dist-module/compression/lerc.js +16 -4
  22. package/dist-module/compression/lerc.js.map +1 -0
  23. package/dist-module/compression/lzw.d.ts +2 -1
  24. package/dist-module/compression/lzw.d.ts.map +1 -1
  25. package/dist-module/compression/lzw.js +29 -1
  26. package/dist-module/compression/lzw.js.map +1 -0
  27. package/dist-module/compression/packbits.d.ts +2 -1
  28. package/dist-module/compression/packbits.d.ts.map +1 -1
  29. package/dist-module/compression/packbits.js +2 -0
  30. package/dist-module/compression/packbits.js.map +1 -0
  31. package/dist-module/compression/raw.d.ts +2 -1
  32. package/dist-module/compression/raw.d.ts.map +1 -1
  33. package/dist-module/compression/raw.js +2 -0
  34. package/dist-module/compression/raw.js.map +1 -0
  35. package/dist-module/compression/webimage.d.ts +2 -1
  36. package/dist-module/compression/webimage.d.ts.map +1 -1
  37. package/dist-module/compression/webimage.js +5 -0
  38. package/dist-module/compression/webimage.js.map +1 -0
  39. package/dist-module/compression/zstd.d.ts +4 -2
  40. package/dist-module/compression/zstd.d.ts.map +1 -1
  41. package/dist-module/compression/zstd.js +3 -1
  42. package/dist-module/compression/zstd.js.map +1 -0
  43. package/dist-module/dataslice.d.ts +78 -22
  44. package/dist-module/dataslice.d.ts.map +1 -1
  45. package/dist-module/dataslice.js +57 -1
  46. package/dist-module/dataslice.js.map +1 -0
  47. package/dist-module/dataview64.d.ts +71 -14
  48. package/dist-module/dataview64.d.ts.map +1 -1
  49. package/dist-module/dataview64.js +58 -1
  50. package/dist-module/dataview64.js.map +1 -0
  51. package/dist-module/geotiff.d.ts +61 -12
  52. package/dist-module/geotiff.d.ts.map +1 -1
  53. package/dist-module/geotiff.js +73 -14
  54. package/dist-module/geotiff.js.map +1 -0
  55. package/dist-module/geotiffimage.d.ts +41 -15
  56. package/dist-module/geotiffimage.d.ts.map +1 -1
  57. package/dist-module/geotiffimage.js +132 -52
  58. package/dist-module/geotiffimage.js.map +1 -0
  59. package/dist-module/geotiffwriter.d.ts +28 -1
  60. package/dist-module/geotiffwriter.d.ts.map +1 -1
  61. package/dist-module/geotiffwriter.js +206 -84
  62. package/dist-module/geotiffwriter.js.map +1 -0
  63. package/dist-module/globals.d.ts +912 -92
  64. package/dist-module/globals.d.ts.map +1 -1
  65. package/dist-module/globals.js +201 -227
  66. package/dist-module/globals.js.map +1 -0
  67. package/dist-module/imagefiledirectory.d.ts +72 -19
  68. package/dist-module/imagefiledirectory.d.ts.map +1 -1
  69. package/dist-module/imagefiledirectory.js +51 -26
  70. package/dist-module/imagefiledirectory.js.map +1 -0
  71. package/dist-module/logging.d.ts +36 -10
  72. package/dist-module/logging.d.ts.map +1 -1
  73. package/dist-module/logging.js +16 -2
  74. package/dist-module/logging.js.map +1 -0
  75. package/dist-module/pool.d.ts +15 -8
  76. package/dist-module/pool.d.ts.map +1 -1
  77. package/dist-module/pool.js +11 -3
  78. package/dist-module/pool.js.map +1 -0
  79. package/dist-module/predictor.d.ts +10 -1
  80. package/dist-module/predictor.d.ts.map +1 -1
  81. package/dist-module/predictor.js +19 -0
  82. package/dist-module/predictor.js.map +1 -0
  83. package/dist-module/resample.d.ts.map +1 -1
  84. package/dist-module/resample.js +12 -0
  85. package/dist-module/resample.js.map +1 -0
  86. package/dist-module/rgb.js +1 -0
  87. package/dist-module/rgb.js.map +1 -0
  88. package/dist-module/source/arraybuffer.d.ts +7 -4
  89. package/dist-module/source/arraybuffer.d.ts.map +1 -1
  90. package/dist-module/source/arraybuffer.js +15 -1
  91. package/dist-module/source/arraybuffer.js.map +1 -0
  92. package/dist-module/source/basesource.d.ts +11 -6
  93. package/dist-module/source/basesource.d.ts.map +1 -1
  94. package/dist-module/source/basesource.js +7 -4
  95. package/dist-module/source/basesource.js.map +1 -0
  96. package/dist-module/source/blockedsource.d.ts +2 -2
  97. package/dist-module/source/blockedsource.d.ts.map +1 -1
  98. package/dist-module/source/blockedsource.js +8 -5
  99. package/dist-module/source/blockedsource.js.map +1 -0
  100. package/dist-module/source/client/base.d.ts +8 -7
  101. package/dist-module/source/client/base.d.ts.map +1 -1
  102. package/dist-module/source/client/base.js +7 -5
  103. package/dist-module/source/client/base.js.map +1 -0
  104. package/dist-module/source/client/fetch.d.ts +6 -2
  105. package/dist-module/source/client/fetch.d.ts.map +1 -1
  106. package/dist-module/source/client/fetch.js +7 -2
  107. package/dist-module/source/client/fetch.js.map +1 -0
  108. package/dist-module/source/client/http.d.ts +27 -5
  109. package/dist-module/source/client/http.d.ts.map +1 -1
  110. package/dist-module/source/client/http.js +16 -2
  111. package/dist-module/source/client/http.js.map +1 -0
  112. package/dist-module/source/client/xhr.d.ts +22 -3
  113. package/dist-module/source/client/xhr.d.ts.map +1 -1
  114. package/dist-module/source/client/xhr.js +12 -2
  115. package/dist-module/source/client/xhr.js.map +1 -0
  116. package/dist-module/source/file.d.ts +8 -5
  117. package/dist-module/source/file.d.ts.map +1 -1
  118. package/dist-module/source/file.js +40 -8
  119. package/dist-module/source/file.js.map +1 -0
  120. package/dist-module/source/filereader.d.ts +12 -4
  121. package/dist-module/source/filereader.d.ts.map +1 -1
  122. package/dist-module/source/filereader.js +15 -2
  123. package/dist-module/source/filereader.js.map +1 -0
  124. package/dist-module/source/httputils.d.ts +16 -9
  125. package/dist-module/source/httputils.d.ts.map +1 -1
  126. package/dist-module/source/httputils.js +19 -12
  127. package/dist-module/source/httputils.js.map +1 -0
  128. package/dist-module/source/remote.d.ts.map +1 -1
  129. package/dist-module/source/remote.js +19 -7
  130. package/dist-module/source/remote.js.map +1 -0
  131. package/dist-module/utils.d.ts +36 -41
  132. package/dist-module/utils.d.ts.map +1 -1
  133. package/dist-module/utils.js +17 -12
  134. package/dist-module/utils.js.map +1 -0
  135. package/dist-module/worker/create.js +1 -1
  136. package/dist-module/worker/create.js.map +1 -0
  137. package/dist-module/worker/decoder.d.ts +2 -0
  138. package/dist-module/worker/decoder.d.ts.map +1 -0
  139. package/dist-module/worker/decoder.js +21 -0
  140. package/dist-module/worker/decoder.js.map +1 -0
  141. package/dist-node/compression/basedecoder.d.ts +30 -4
  142. package/dist-node/compression/basedecoder.d.ts.map +1 -1
  143. package/dist-node/compression/basedecoder.js +22 -1
  144. package/dist-node/compression/basedecoder.js.map +1 -1
  145. package/dist-node/compression/deflate.d.ts +2 -1
  146. package/dist-node/compression/deflate.d.ts.map +1 -1
  147. package/dist-node/compression/deflate.js +2 -0
  148. package/dist-node/compression/deflate.js.map +1 -1
  149. package/dist-node/compression/index.d.ts +14 -22
  150. package/dist-node/compression/index.d.ts.map +1 -1
  151. package/dist-node/compression/index.js +36 -25
  152. package/dist-node/compression/index.js.map +1 -1
  153. package/dist-node/compression/jpeg.d.ts +55 -16
  154. package/dist-node/compression/jpeg.d.ts.map +1 -1
  155. package/dist-node/compression/jpeg.js +187 -16
  156. package/dist-node/compression/jpeg.js.map +1 -1
  157. package/dist-node/compression/lerc.d.ts +11 -1
  158. package/dist-node/compression/lerc.d.ts.map +1 -1
  159. package/dist-node/compression/lerc.js +16 -4
  160. package/dist-node/compression/lerc.js.map +1 -1
  161. package/dist-node/compression/lzw.d.ts +2 -1
  162. package/dist-node/compression/lzw.d.ts.map +1 -1
  163. package/dist-node/compression/lzw.js +29 -1
  164. package/dist-node/compression/lzw.js.map +1 -1
  165. package/dist-node/compression/packbits.d.ts +2 -1
  166. package/dist-node/compression/packbits.d.ts.map +1 -1
  167. package/dist-node/compression/packbits.js +2 -0
  168. package/dist-node/compression/packbits.js.map +1 -1
  169. package/dist-node/compression/raw.d.ts +2 -1
  170. package/dist-node/compression/raw.d.ts.map +1 -1
  171. package/dist-node/compression/raw.js +2 -0
  172. package/dist-node/compression/raw.js.map +1 -1
  173. package/dist-node/compression/webimage.d.ts +2 -2
  174. package/dist-node/compression/webimage.d.ts.map +1 -1
  175. package/dist-node/compression/webimage.js +5 -0
  176. package/dist-node/compression/webimage.js.map +1 -1
  177. package/dist-node/compression/zstd.d.ts +2 -1
  178. package/dist-node/compression/zstd.d.ts.map +1 -1
  179. package/dist-node/compression/zstd.js +3 -1
  180. package/dist-node/compression/zstd.js.map +1 -1
  181. package/dist-node/dataslice.d.ts +78 -22
  182. package/dist-node/dataslice.d.ts.map +1 -1
  183. package/dist-node/dataslice.js +57 -1
  184. package/dist-node/dataslice.js.map +1 -1
  185. package/dist-node/dataview64.d.ts +71 -14
  186. package/dist-node/dataview64.d.ts.map +1 -1
  187. package/dist-node/dataview64.js +58 -1
  188. package/dist-node/dataview64.js.map +1 -1
  189. package/dist-node/geotiff.d.ts +61 -12
  190. package/dist-node/geotiff.d.ts.map +1 -1
  191. package/dist-node/geotiff.js +75 -15
  192. package/dist-node/geotiff.js.map +1 -1
  193. package/dist-node/geotiffimage.d.ts +41 -15
  194. package/dist-node/geotiffimage.d.ts.map +1 -1
  195. package/dist-node/geotiffimage.js +132 -52
  196. package/dist-node/geotiffimage.js.map +1 -1
  197. package/dist-node/geotiffwriter.d.ts +28 -1
  198. package/dist-node/geotiffwriter.d.ts.map +1 -1
  199. package/dist-node/geotiffwriter.js +206 -84
  200. package/dist-node/geotiffwriter.js.map +1 -1
  201. package/dist-node/globals.d.ts +910 -90
  202. package/dist-node/globals.d.ts.map +1 -1
  203. package/dist-node/globals.js +202 -228
  204. package/dist-node/globals.js.map +1 -1
  205. package/dist-node/imagefiledirectory.d.ts +72 -19
  206. package/dist-node/imagefiledirectory.d.ts.map +1 -1
  207. package/dist-node/imagefiledirectory.js +51 -26
  208. package/dist-node/imagefiledirectory.js.map +1 -1
  209. package/dist-node/logging.d.ts +36 -10
  210. package/dist-node/logging.d.ts.map +1 -1
  211. package/dist-node/logging.js +16 -2
  212. package/dist-node/logging.js.map +1 -1
  213. package/dist-node/pool.d.ts +15 -8
  214. package/dist-node/pool.d.ts.map +1 -1
  215. package/dist-node/pool.js +11 -3
  216. package/dist-node/pool.js.map +1 -1
  217. package/dist-node/predictor.d.ts +10 -1
  218. package/dist-node/predictor.d.ts.map +1 -1
  219. package/dist-node/predictor.js +19 -0
  220. package/dist-node/predictor.js.map +1 -1
  221. package/dist-node/resample.d.ts.map +1 -1
  222. package/dist-node/resample.js +12 -0
  223. package/dist-node/resample.js.map +1 -1
  224. package/dist-node/rgb.js +1 -0
  225. package/dist-node/rgb.js.map +1 -1
  226. package/dist-node/source/arraybuffer.d.ts +7 -4
  227. package/dist-node/source/arraybuffer.d.ts.map +1 -1
  228. package/dist-node/source/arraybuffer.js +15 -1
  229. package/dist-node/source/arraybuffer.js.map +1 -1
  230. package/dist-node/source/basesource.d.ts +11 -6
  231. package/dist-node/source/basesource.d.ts.map +1 -1
  232. package/dist-node/source/basesource.js +7 -4
  233. package/dist-node/source/basesource.js.map +1 -1
  234. package/dist-node/source/blockedsource.d.ts +2 -2
  235. package/dist-node/source/blockedsource.d.ts.map +1 -1
  236. package/dist-node/source/blockedsource.js +8 -5
  237. package/dist-node/source/blockedsource.js.map +1 -1
  238. package/dist-node/source/client/base.d.ts +8 -7
  239. package/dist-node/source/client/base.d.ts.map +1 -1
  240. package/dist-node/source/client/base.js +7 -5
  241. package/dist-node/source/client/base.js.map +1 -1
  242. package/dist-node/source/client/fetch.d.ts +5 -2
  243. package/dist-node/source/client/fetch.d.ts.map +1 -1
  244. package/dist-node/source/client/fetch.js +7 -2
  245. package/dist-node/source/client/fetch.js.map +1 -1
  246. package/dist-node/source/client/http.d.ts +22 -4
  247. package/dist-node/source/client/http.d.ts.map +1 -1
  248. package/dist-node/source/client/http.js +16 -2
  249. package/dist-node/source/client/http.js.map +1 -1
  250. package/dist-node/source/client/xhr.d.ts +23 -3
  251. package/dist-node/source/client/xhr.d.ts.map +1 -1
  252. package/dist-node/source/client/xhr.js +12 -2
  253. package/dist-node/source/client/xhr.js.map +1 -1
  254. package/dist-node/source/file.d.ts +8 -5
  255. package/dist-node/source/file.d.ts.map +1 -1
  256. package/dist-node/source/file.js +40 -8
  257. package/dist-node/source/file.js.map +1 -1
  258. package/dist-node/source/filereader.d.ts +12 -4
  259. package/dist-node/source/filereader.d.ts.map +1 -1
  260. package/dist-node/source/filereader.js +15 -2
  261. package/dist-node/source/filereader.js.map +1 -1
  262. package/dist-node/source/httputils.d.ts +16 -9
  263. package/dist-node/source/httputils.d.ts.map +1 -1
  264. package/dist-node/source/httputils.js +19 -12
  265. package/dist-node/source/httputils.js.map +1 -1
  266. package/dist-node/source/remote.d.ts.map +1 -1
  267. package/dist-node/source/remote.js +19 -7
  268. package/dist-node/source/remote.js.map +1 -1
  269. package/dist-node/utils.d.ts +9 -8
  270. package/dist-node/utils.d.ts.map +1 -1
  271. package/dist-node/utils.js +17 -12
  272. package/dist-node/utils.js.map +1 -1
  273. package/dist-node/worker/create.js +1 -1
  274. package/dist-node/worker/create.js.map +1 -1
  275. package/dist-node/worker/decoder.d.ts +2 -0
  276. package/dist-node/worker/decoder.d.ts.map +1 -0
  277. package/dist-node/worker/decoder.js +24 -0
  278. package/dist-node/worker/decoder.js.map +1 -0
  279. package/package.json +5 -3
@@ -14,14 +14,23 @@ class XHRResponse extends BaseResponse {
14
14
  get status() {
15
15
  return this.xhr.status;
16
16
  }
17
+ /**
18
+ * @param {string} name
19
+ * @returns {string|undefined}
20
+ */
17
21
  getHeader(name) {
18
- return this.xhr.getResponseHeader(name);
22
+ return this.xhr.getResponseHeader(name) || undefined;
19
23
  }
20
24
  async getData() {
21
25
  return this.data;
22
26
  }
23
27
  }
24
28
  export class XHRClient extends BaseClient {
29
+ /**
30
+ * @param {Object<string, string>} headers
31
+ * @param {AbortSignal} [signal]
32
+ * @returns {Promise<XHRResponse>}
33
+ */
25
34
  constructRequest(headers, signal) {
26
35
  return new Promise((resolve, reject) => {
27
36
  const xhr = new XMLHttpRequest();
@@ -46,8 +55,9 @@ export class XHRClient extends BaseClient {
46
55
  }
47
56
  });
48
57
  }
49
- async request({ headers = undefined, signal = undefined } = {}) {
58
+ async request({ headers = {}, signal = undefined } = {}) {
50
59
  const response = await this.constructRequest(headers, signal);
51
60
  return response;
52
61
  }
53
62
  }
63
+ //# sourceMappingURL=xhr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xhr.js","sourceRoot":"","sources":["../../../src/source/client/xhr.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,WAAY,SAAQ,YAAY;IACpC;;;;OAIG;IACH,YAAY,GAAG,EAAE,IAAI;QACnB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,IAAI;QACZ,OAAO,IAAI,C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CAAC,CAAC;YACtD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE;QACrD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9D,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -1,9 +1,12 @@
1
- export function makeFileSource(path: any): FileSource;
1
+ /** @param {string} path */
2
+ export function makeFileSource(path: string): FileSource;
2
3
  declare class FileSource extends BaseSource {
3
- constructor(path: any);
4
- path: any;
5
- openRequest: Promise<any>;
6
- fetchSlice(slice: any): Promise<any>;
4
+ /**
5
+ * @param {string} path
6
+ */
7
+ constructor(path: string);
8
+ path: string;
9
+ openRequest: Promise<number>;
7
10
  }
8
11
  import { BaseSource } from './basesource.js';
9
12
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/source/file.js"],"names":[],"mappings":"AAiEA,sDAEC;AA5BD;IACE,uBAIC;IAFC,UAAgB;IAChB,0BAAuC;IAGzC,qCAWC;CAMF;2BA9D0B,iBAAiB"}
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/source/file.js"],"names":[],"mappings":"AA+FA,2BAA2B;AAC3B,qCADY,MAAM,cAGjB;AAzCD;IACE;;OAEG;IACH,kBAFW,MAAM,EAMhB;IAFC,aAAgB;IAChB,6BAAuC;CA6B1C;2BA5F0B,iBAAiB"}
@@ -1,7 +1,11 @@
1
1
  import fs from 'fs';
2
2
  import { BaseSource } from './basesource.js';
3
+ /**
4
+ * @param {number} fd
5
+ * @returns {Promise<void>}
6
+ */
3
7
  function closeAsync(fd) {
4
- return /** @type{Promise<void>} */ (new Promise((resolve, reject) => {
8
+ return new Promise((resolve, reject) => {
5
9
  fs.close(fd, (err) => {
6
10
  if (err) {
7
11
  reject(err);
@@ -10,8 +14,14 @@ function closeAsync(fd) {
10
14
  resolve();
11
15
  }
12
16
  });
13
- }));
17
+ });
14
18
  }
19
+ /**
20
+ * @param {string} path
21
+ * @param {string} flags
22
+ * @param {number|undefined} mode
23
+ * @returns {Promise<number>}
24
+ */
15
25
  function openAsync(path, flags, mode = undefined) {
16
26
  return new Promise((resolve, reject) => {
17
27
  fs.open(path, flags, mode, (err, fd) => {
@@ -24,35 +34,57 @@ function openAsync(path, flags, mode = undefined) {
24
34
  });
25
35
  });
26
36
  }
27
- function readAsync(_fd, _buffer, _offset, _length, _position) {
37
+ /**
38
+ * @param {number} fd
39
+ * @param {Uint8Array} buffer
40
+ * @param {number} offset
41
+ * @param {number} length
42
+ * @param {number} position
43
+ * @returns {Promise<{bytesRead: number, buffer: Uint8Array}>}
44
+ */
45
+ function readAsync(fd, buffer, offset, length, position) {
28
46
  return new Promise((resolve, reject) => {
29
- fs.read(_fd, _buffer, _offset, _length, _position, (err, bytesRead, buffer) => {
47
+ fs.read(fd, buffer, offset, length, position, (err, bytesRead, outBuffer) => {
30
48
  if (err) {
31
49
  reject(err);
32
50
  }
33
51
  else {
34
- resolve({ bytesRead, buffer });
52
+ resolve({ bytesRead, buffer: outBuffer });
35
53
  }
36
54
  });
37
55
  });
38
56
  }
39
57
  class FileSource extends BaseSource {
58
+ /**
59
+ * @param {string} path
60
+ */
40
61
  constructor(path) {
41
62
  super();
42
63
  this.path = path;
43
64
  this.openRequest = openAsync(path, 'r');
44
65
  }
45
- async fetchSlice(slice) {
66
+ /**
67
+ * @param {import('./basesource.js').Slice} slice
68
+ * @param {AbortSignal} [_signal] not implemented
69
+ * @returns {Promise<import('./basesource.js').SliceWithData>}
70
+ */
71
+ async fetchSlice(slice, _signal) {
46
72
  // TODO: use `signal`
47
73
  const fd = await this.openRequest;
48
- const { buffer } = await readAsync(fd, Buffer.alloc(slice.length), 0, slice.length, slice.offset);
49
- return buffer.buffer;
74
+ const { buffer } = await readAsync(fd, new Uint8Array(slice.length), 0, slice.length, slice.offset);
75
+ return {
76
+ data: buffer.buffer,
77
+ offset: slice.offset,
78
+ length: slice.length,
79
+ };
50
80
  }
51
81
  async close() {
52
82
  const fd = await this.openRequest;
53
83
  await closeAsync(fd);
54
84
  }
55
85
  }
86
+ /** @param {string} path */
56
87
  export function makeFileSource(path) {
57
88
  return new FileSource(path);
58
89
  }
90
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/source/file.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;GAGG;AACH,SAAS,UAAU,CAAC,EAAE;IACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,SAAS;IAC9C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;YACrC,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,EAAE,CAAC,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAA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EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC;QAClC,MAAM,UAAU,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;CACF;AAED,2BAA2B;AAC3B,MAAM,UAAU,cAAc,CAAC,IAAI;IACjC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -1,13 +1,21 @@
1
1
  /**
2
2
  * Create a new source from a given file/blob.
3
3
  * @param {Blob} file The file or blob to read from.
4
- * @returns The constructed source
4
+ * @returns {FileReaderSource} The constructed source
5
5
  */
6
6
  export function makeFileReaderSource(file: Blob): FileReaderSource;
7
7
  declare class FileReaderSource extends BaseSource {
8
- constructor(file: any);
9
- file: any;
10
- fetchSlice(slice: any, signal: any): Promise<any>;
8
+ /**
9
+ * @param {Blob} file
10
+ */
11
+ constructor(file: Blob);
12
+ file: Blob;
13
+ /**
14
+ * @param {import('./basesource.js').Slice} slice
15
+ * @param {AbortSignal} signal
16
+ * @returns {Promise<import('./basesource.js').SliceWithData>}
17
+ */
18
+ fetchSlice(slice: import("./basesource.js").Slice, signal: AbortSignal): Promise<import("./basesource.js").SliceWithData>;
11
19
  }
12
20
  import { BaseSource } from './basesource.js';
13
21
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"filereader.d.ts","sourceRoot":"","sources":["../../src/source/filereader.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH,2CAHW,IAAI,oBAKd;AA7BD;IACE,uBAGC;IADC,UAAgB;IAGlB,kDAaC;CACF;2BAtB0B,iBAAiB"}
1
+ {"version":3,"file":"filereader.d.ts","sourceRoot":"","sources":["../../src/source/filereader.js"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH,2CAHW,IAAI,GACF,gBAAgB,CAI5B;AAzCD;IACE;;OAEG;IACH,kBAFW,IAAI,EAKd;IADC,WAAgB;IAGlB;;;;OAIG;IACH,kBAJW,OAAO,iBAAiB,EAAE,KAAK,UAC/B,WAAW,GACT,OAAO,CAAC,OAAO,iBAAiB,EAAE,aAAa,CAAC,CAmB5D;CACF;2BAlC0B,iBAAiB"}
@@ -1,14 +1,26 @@
1
1
  import { BaseSource } from './basesource.js';
2
2
  class FileReaderSource extends BaseSource {
3
+ /**
4
+ * @param {Blob} file
5
+ */
3
6
  constructor(file) {
4
7
  super();
5
8
  this.file = file;
6
9
  }
10
+ /**
11
+ * @param {import('./basesource.js').Slice} slice
12
+ * @param {AbortSignal} signal
13
+ * @returns {Promise<import('./basesource.js').SliceWithData>}
14
+ */
7
15
  async fetchSlice(slice, signal) {
8
16
  return new Promise((resolve, reject) => {
9
17
  const blob = this.file.slice(slice.offset, slice.offset + slice.length);
10
18
  const reader = new FileReader();
11
- reader.onload = () => resolve(reader.result);
19
+ reader.onload = () => resolve({
20
+ data: /** @type {ArrayBuffer} */ (reader.result),
21
+ offset: slice.offset,
22
+ length: slice.length,
23
+ });
12
24
  reader.onerror = reject;
13
25
  reader.onabort = reject;
14
26
  reader.readAsArrayBuffer(blob);
@@ -21,8 +33,9 @@ class FileReaderSource extends BaseSource {
21
33
  /**
22
34
  * Create a new source from a given file/blob.
23
35
  * @param {Blob} file The file or blob to read from.
24
- * @returns The constructed source
36
+ * @returns {FileReaderSource} The constructed source
25
37
  */
26
38
  export function makeFileReaderSource(file) {
27
39
  return new FileReaderSource(file);
28
40
  }
41
+ //# sourceMappingURL=filereader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filereader.js","sourceRoot":"","sources":["../../src/source/filereader.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,gBAAiB,SAAQ,UAAU;IACvC;;OAEG;IACH,YAAY,IAAI;QACd,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM;QAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACxE,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC;gBAC5B,IAAI,EAAE,0BAA0B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;gBAChD,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;YACH,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;YACxB,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAE/B,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAI;IACvC,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC"}
@@ -1,19 +1,19 @@
1
1
  /**
2
2
  * Parse a 'Content-Type' header value to the content-type and parameters
3
- * @param {string|null} rawContentType the raw string to parse from
4
- * @returns {{type: string|null, params: Object}}}
3
+ * @param {string|undefined} rawContentType the raw string to parse from
4
+ * @returns {{type: string|null, params: Record<string, string>}}
5
5
  * the parsed content type with the fields: type and params
6
6
  */
7
- export function parseContentType(rawContentType: string | null): {
7
+ export function parseContentType(rawContentType: string | undefined): {
8
8
  type: string | null;
9
- params: Object;
9
+ params: Record<string, string>;
10
10
  };
11
11
  /**
12
12
  * Parse a 'Content-Range' header value to its start, end, and total parts
13
- * @param {string|null} rawContentRange the raw string to parse from
13
+ * @param {string|undefined} rawContentRange the raw string to parse from
14
14
  * @returns {{start: number, end: number, total: number}} the parsed parts
15
15
  */
16
- export function parseContentRange(rawContentRange: string | null): {
16
+ export function parseContentRange(rawContentRange: string | undefined): {
17
17
  start: number;
18
18
  end: number;
19
19
  total: number;
@@ -26,8 +26,15 @@ export function parseContentRange(rawContentRange: string | null): {
26
26
  * - offset: the offset of the byterange within its originating file
27
27
  * - length: the length of the byterange
28
28
  * @param {ArrayBuffer} responseArrayBuffer the response to be parsed and split
29
- * @param {String} boundary the boundary string used to split the sections
30
- * @returns {Object[]} the parsed byteranges
29
+ * @param {string} boundary the boundary string used to split the sections
30
+ * @returns {Array<{headers: Record<string, string>, data: ArrayBuffer, offset: number, length: number, fileSize: number}>}
31
+ * the parsed byteranges
31
32
  */
32
- export function parseByteRanges(responseArrayBuffer: ArrayBuffer, boundary: string): Object[];
33
+ export function parseByteRanges(responseArrayBuffer: ArrayBuffer, boundary: string): Array<{
34
+ headers: Record<string, string>;
35
+ data: ArrayBuffer;
36
+ offset: number;
37
+ length: number;
38
+ fileSize: number;
39
+ }>;
33
40
  //# sourceMappingURL=httputils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httputils.d.ts","sourceRoot":"","sources":["../../src/source/httputils.js"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,iDAJW,MAAM,GAAC,IAAI,GACT;IAAC,IAAI,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAU/C;AAED;;;;GAIG;AACH,mDAHW,MAAM,GAAC,IAAI,GACT;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAYvD;AAED;;;;;;;;;;GAUG;AACH,qDAJW,WAAW,qBAET,MAAM,EAAE,CAuEpB"}
1
+ {"version":3,"file":"httputils.d.ts","sourceRoot":"","sources":["../../src/source/httputils.js"],"names":[],"mappings":"AAsCA;;;;;GAKG;AACH,iDAJW,MAAM,GAAC,SAAS,GACd;IAAC,IAAI,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAC,CAU/D;AAED;;;;GAIG;AACH,mDAHW,MAAM,GAAC,SAAS,GACd;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAYvD;AAED;;;;;;;;;;;GAWG;AACH,qDALW,WAAW,YACX,MAAM,GACJ,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC,CAwEzH"}
@@ -1,11 +1,15 @@
1
1
  const CRLFCRLF = '\r\n\r\n';
2
- /*
2
+ /**
3
3
  * Shim for 'Object.fromEntries'
4
+ * @template T
5
+ * @param {Array<[string, T]>} items
6
+ * @return {Record<string, T>}
4
7
  */
5
8
  function itemsToObject(items) {
6
9
  if (typeof Object.fromEntries !== 'undefined') {
7
10
  return Object.fromEntries(items);
8
11
  }
12
+ /** @type {Record<string, T>} */
9
13
  const obj = {};
10
14
  for (const [key, value] of items) {
11
15
  obj[key.toLowerCase()] = value;
@@ -14,14 +18,15 @@ function itemsToObject(items) {
14
18
  }
15
19
  /**
16
20
  * Parse HTTP headers from a given string.
17
- * @param {String} text the text to parse the headers from
18
- * @returns {Object} the parsed headers with lowercase keys
21
+ * @param {string} text the text to parse the headers from
22
+ * @returns {Record<string, string>} the parsed headers with lowercase keys
19
23
  */
20
24
  function parseHeaders(text) {
25
+ /** @type {Array<[string, string]>} */
21
26
  const items = text
22
27
  .split('\r\n')
23
28
  .map((line) => {
24
- const kv = line.split(':').map((str) => str.trim());
29
+ const kv = /** @type {[string, string]} */ (line.split(':').map((str) => str.trim()));
25
30
  kv[0] = kv[0].toLowerCase();
26
31
  return kv;
27
32
  });
@@ -29,8 +34,8 @@ function parseHeaders(text) {
29
34
  }
30
35
  /**
31
36
  * Parse a 'Content-Type' header value to the content-type and parameters
32
- * @param {string|null} rawContentType the raw string to parse from
33
- * @returns {{type: string|null, params: Object}}}
37
+ * @param {string|undefined} rawContentType the raw string to parse from
38
+ * @returns {{type: string|null, params: Record<string, string>}}
34
39
  * the parsed content type with the fields: type and params
35
40
  */
36
41
  export function parseContentType(rawContentType) {
@@ -38,12 +43,12 @@ export function parseContentType(rawContentType) {
38
43
  return { type: null, params: {} };
39
44
  }
40
45
  const [type, ...rawParams] = rawContentType.split(';').map((s) => s.trim());
41
- const paramsItems = rawParams.map((param) => param.split('='));
46
+ const paramsItems = /** @type {Array<[string, string]>} */ (rawParams.map((param) => param.split('=')));
42
47
  return { type, params: itemsToObject(paramsItems) };
43
48
  }
44
49
  /**
45
50
  * Parse a 'Content-Range' header value to its start, end, and total parts
46
- * @param {string|null} rawContentRange the raw string to parse from
51
+ * @param {string|undefined} rawContentRange the raw string to parse from
47
52
  * @returns {{start: number, end: number, total: number}} the parsed parts
48
53
  */
49
54
  export function parseContentRange(rawContentRange) {
@@ -63,11 +68,12 @@ export function parseContentRange(rawContentRange) {
63
68
  * - offset: the offset of the byterange within its originating file
64
69
  * - length: the length of the byterange
65
70
  * @param {ArrayBuffer} responseArrayBuffer the response to be parsed and split
66
- * @param {String} boundary the boundary string used to split the sections
67
- * @returns {Object[]} the parsed byteranges
71
+ * @param {string} boundary the boundary string used to split the sections
72
+ * @returns {Array<{headers: Record<string, string>, data: ArrayBuffer, offset: number, length: number, fileSize: number}>}
73
+ * the parsed byteranges
68
74
  */
69
75
  export function parseByteRanges(responseArrayBuffer, boundary) {
70
- let offset = null;
76
+ let offset = -1;
71
77
  const decoder = new TextDecoder('ascii');
72
78
  const out = [];
73
79
  const startBoundary = `--${boundary}`;
@@ -80,7 +86,7 @@ export function parseByteRanges(responseArrayBuffer, boundary) {
80
86
  offset = i;
81
87
  }
82
88
  }
83
- if (offset === null) {
89
+ if (offset === -1) {
84
90
  throw new Error('Could not find initial boundary');
85
91
  }
86
92
  while (offset < responseArrayBuffer.byteLength) {
@@ -117,3 +123,4 @@ export function parseByteRanges(responseArrayBuffer, boundary) {
117
123
  }
118
124
  return out;
119
125
  }
126
+ //# sourceMappingURL=httputils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httputils.js","sourceRoot":"","sources":["../../src/source/httputils.js"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAK;IAC1B,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IACD,gCAAgC;IAChC,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;QACjC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,IAAI;IACxB,sCAAsC;IACtC,MAAM,KAAK,GAAG,IAAI;SACf,KAAK,CAAC,MAAM,CAAC;SACb,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,EAAE,GAAG,+BAA+B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACtF,EAAE,CAAC,CAAC,CAAC,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,MAAM,2DACN,mBAAmB,GAAG,oBAAoB,GACxC,UAAU,CAMtB;AAED;;;;GAIG;AACH,oCAJW,MAAM,2DACN,mBAAmB,GAAG,oBAAoB,GACxC,UAAU,CAMtB;AAED;;;;GAIG;AACH,yCAJW,OAAO,YAAY,EAAE,UAAU,2DAC/B,mBAAmB,GAAG,oBAAoB,GACxC,UAAU,CAKtB;AAED;;;;GAIG;AACH,sCAHW,MAAM,mCACN,mBAAmB,cAU7B;yCApN8D,eAAe;0CAAf,eAAe;2BAPnD,iBAAiB"}
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/source/remote.js"],"names":[],"mappings":"AA+KA;;;;GAIG;AACH,qCAJW,MAAM,wEACN,mBAAmB,GAAG,oBAAoB,GAAG;IAAE,WAAW,CAAC,EAAE,kBAAkB,CAAA;CAAC,GAC9E,UAAU,CAMtB;AAED;;;;GAIG;AACH,mCAJW,MAAM,2DACN,mBAAmB,GAAG,oBAAoB,GACxC,UAAU,CAMtB;AAED;;;;GAIG;AACH,oCAJW,MAAM,2DACN,mBAAmB,GAAG,oBAAoB,GACxC,UAAU,CAMtB;AAED;;;;GAIG;AACH,yCAJW,OAAO,YAAY,EAAE,UAAU,2DAC/B,mBAAmB,GAAG,oBAAoB,GACxC,UAAU,CAKtB;AAED;;;;GAIG;AACH,sCAHW,MAAM,mCACN,mBAAmB,cAU7B;yCA/N8D,eAAe;0CAAf,eAAe;2BAPnD,iBAAiB"}
@@ -21,13 +21,13 @@ class RemoteSource extends BaseSource {
21
21
  /**
22
22
  * @param {import('./basesource.js').Slice[]} slices
23
23
  * @param {AbortSignal} [signal]
24
- * @returns {Promise<*[]>}
24
+ * @returns {Promise<ArrayBufferLike[]>}
25
25
  */
26
26
  async fetch(slices, signal) {
27
27
  // if we allow multi-ranges, split the incoming request into that many sub-requests
28
28
  // and join them afterwards
29
29
  if (this.maxRanges >= slices.length) {
30
- return this.fetchSlices(slices, signal);
30
+ return this.fetchSlices(slices, signal).then((results) => results.map((r) => r.data));
31
31
  }
32
32
  else if (this.maxRanges > 0 && slices.length > 1) {
33
33
  // TODO: split into multiple multi-range requests
@@ -40,14 +40,19 @@ class RemoteSource extends BaseSource {
40
40
  // return (await Promise.all(subSlicesRequests)).flat();
41
41
  }
42
42
  // otherwise make a single request for each slice
43
- return Promise.all(slices.map((slice) => this.fetchSlice(slice, signal)));
43
+ return Promise.all(slices.map(async (slice) => (await this.fetchSlice(slice, signal)).data));
44
44
  }
45
+ /**
46
+ * @param {Array<import('./basesource.js').Slice>} slices
47
+ * @param {AbortSignal} [signal]
48
+ * @returns {Promise<Array<import('./basesource.js').SliceWithData>>}
49
+ */
45
50
  async fetchSlices(slices, signal) {
46
51
  const response = await this.client.request({
47
52
  headers: {
48
53
  ...this.headers,
49
54
  Range: `bytes=${slices
50
- .map(({ offset, length }) => `${offset}-${offset + length}`)
55
+ .map(({ offset, length }) => `${offset}-${offset + length - 1}`)
51
56
  .join(',')}`,
52
57
  },
53
58
  signal,
@@ -65,10 +70,11 @@ class RemoteSource extends BaseSource {
65
70
  const data = await response.getData();
66
71
  const { start, end, total } = parseContentRange(response.getHeader('content-range'));
67
72
  this._fileSize = total || null;
73
+ /** @type {import('./basesource.js').SliceWithData[]} */
68
74
  const first = [{
69
75
  data,
70
76
  offset: start,
71
- length: end - start,
77
+ length: end + 1 - start,
72
78
  }];
73
79
  if (slices.length > 1) {
74
80
  // we requested more than one slice, but got only the first
@@ -93,12 +99,17 @@ class RemoteSource extends BaseSource {
93
99
  }];
94
100
  }
95
101
  }
102
+ /**
103
+ * @param {import('./basesource.js').Slice} slice
104
+ * @param {AbortSignal} [signal]
105
+ * @returns {Promise<import('./basesource.js').SliceWithData>}
106
+ */
96
107
  async fetchSlice(slice, signal) {
97
108
  const { offset, length } = slice;
98
109
  const response = await this.client.request({
99
110
  headers: {
100
111
  ...this.headers,
101
- Range: `bytes=${offset}-${offset + length}`,
112
+ Range: `bytes=${offset}-${offset + length - 1}`,
102
113
  },
103
114
  signal,
104
115
  });
@@ -139,7 +150,7 @@ class RemoteSource extends BaseSource {
139
150
  * @returns {BaseSource}
140
151
  */
141
152
  function maybeWrapInBlockedSource(source, { blockSize, cacheSize }) {
142
- if (blockSize === null) {
153
+ if (blockSize === undefined) {
143
154
  return source;
144
155
  }
145
156
  return new BlockedSource(source, { blockSize, cacheSize });
@@ -197,3 +208,4 @@ export function makeRemoteSource(url, { forceXHR = false, ...clientOptions } = {
197
208
  }
198
209
  return makeHttpSource(url, clientOptions);
199
210
  }
211
+ //# sourceMappingURL=remote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote.js","sourceRoot":"","sources":["../../src/source/remote.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,iFAAiF;AAEjF,MAAM,YAAa,SAAQ,UAAU;IACnC;;;OAGG;IACH,YAAY,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,GAAG,CAAC,EAAE,aAAa,EAAE,GAAG,EAAE;QAChE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;QACxB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QAC7C,OAAO,eAAe,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;QAC1C,OAAO,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,cAAc,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AAC5C,CAAC"}
@@ -1,48 +1,43 @@
1
- export function assign(target: any, source: any): void;
2
- export function chunk(iterable: any, length: any): any[][];
3
- export function endsWith(string: any, expectedEnding: any): boolean;
4
- export function forEach(iterable: any, func: any): void;
5
- export function invert(oldObj: any): {};
6
- export function range(n: any): number[];
7
- export function times(numTimes: any, func: any): any[];
8
- export function toArray(iterable: any): any[];
9
- export function toArrayRecursively(input: any): any;
10
- export function parseContentRange(headerValue: any): {
1
+ export declare function assign<T extends Record<string, unknown>, S extends Record<string, unknown>>(target: T, source: S): T & S;
2
+ export declare function chunk<T>(iterable: ArrayLike<T>, length: number): T[][];
3
+ export declare function endsWith(string: string, expectedEnding: string): boolean;
4
+ export declare function forEach<T>(iterable: ArrayLike<T>, func: (item: T, index: number) => void): void;
5
+ export declare function invert<K extends string | number, V extends string | number>(oldObj: Record<K, V>): Record<V, K>;
6
+ export declare function range(n: number): number[];
7
+ export declare function times<T>(numTimes: number, func: (index: number) => T): T[];
8
+ export declare function toArray<T>(iterable: ArrayLike<T>): T[];
9
+ export declare function toArrayRecursively(input: unknown): unknown;
10
+ /** Copied from https://github.com/academia-de-codigo/parse-content-range-header/blob/master/index.js */
11
+ export declare function parseContentRange(headerValue: string): null | {
11
12
  unit: string | null;
12
- first: number;
13
- last: number;
13
+ first: number | null;
14
+ last: number | null;
14
15
  length: number | null;
15
- } | {
16
- unit: string | null;
17
- first: null;
18
- last: null;
19
- length: number | null;
20
- } | null;
21
- export function wait(milliseconds: any): Promise<any>;
16
+ };
22
17
  /**
23
- * @template T,U
24
- * @param {Iterable<T>} a
25
- * @param {Iterable<U>} b
26
- * @returns {Array<[T, U]>}
18
+ * Promisified wrapper around 'setTimeout' to allow 'await'
19
+ * @param {number} [milliseconds]
20
+ * @returns {Promise<void>}
27
21
  */
28
- export function zip<T, U>(a: Iterable<T>, b: Iterable<U>): Array<[T, U]>;
29
- export function isTypedFloatArray(input: any): boolean;
30
- export function isTypedIntArray(input: any): boolean;
31
- export function isTypedUintArray(input: any): boolean;
32
- export class AbortError extends Error {
33
- constructor(params: any);
34
- }
35
- export class CustomAggregateError extends Error {
36
- constructor(errors: any, message: any);
37
- errors: any;
38
- message: any;
22
+ export declare function wait(milliseconds?: number): Promise<void>;
23
+ export declare function zip<T, U>(a: Iterable<T>, b: Iterable<U>): [T, U][];
24
+ export declare class AbortError extends Error {
25
+ signal?: AbortSignal;
26
+ constructor(...args: any[]);
39
27
  }
40
- export const AggregateError: typeof CustomAggregateError;
41
- export namespace typeMap {
42
- let Float64Array: Float64ArrayConstructor;
43
- let Float32Array: Float32ArrayConstructor;
44
- let Uint32Array: Uint32ArrayConstructor;
45
- let Uint16Array: Uint16ArrayConstructor;
46
- let Uint8Array: Uint8ArrayConstructor;
28
+ export declare class CustomAggregateError extends Error {
29
+ errors: Error[];
30
+ constructor(errors: Error[], message: string);
47
31
  }
32
+ export declare const AggregateError: typeof CustomAggregateError;
33
+ export declare function isTypedFloatArray(input: unknown): input is Float32Array | Float64Array;
34
+ export declare function isTypedIntArray(input: unknown): input is Int8Array | Int16Array | Int32Array;
35
+ export declare function isTypedUintArray(input: unknown): input is Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray;
36
+ export declare const typeMap: {
37
+ Float64Array: Float64ArrayConstructor;
38
+ Float32Array: Float32ArrayConstructor;
39
+ Uint32Array: Uint32ArrayConstructor;
40
+ Uint16Array: Uint16ArrayConstructor;
41
+ Uint8Array: Uint8ArrayConstructor;
42
+ };
48
43
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["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