geotiff 3.0.0 → 3.0.1

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 (164) hide show
  1. package/dist-browser/geotiff.js +3 -2
  2. package/dist-browser/geotiff.js.map +1 -1
  3. package/dist-module/compression/basedecoder.d.ts +4 -0
  4. package/dist-module/compression/basedecoder.d.ts.map +1 -1
  5. package/dist-module/compression/basedecoder.js +6 -0
  6. package/dist-module/compression/index.d.ts +4 -4
  7. package/dist-module/compression/index.d.ts.map +1 -1
  8. package/dist-module/compression/index.js +4 -4
  9. package/dist-module/compression/jpeg.d.ts +6 -1
  10. package/dist-module/compression/jpeg.d.ts.map +1 -1
  11. package/dist-module/compression/jpeg.js +50 -5
  12. package/dist-module/compression/lzw.js +1 -1
  13. package/dist-module/compression/webimage.d.ts +1 -1
  14. package/dist-module/compression/webimage.d.ts.map +1 -1
  15. package/dist-module/compression/webimage.js +1 -1
  16. package/dist-module/dataslice.d.ts.map +1 -1
  17. package/dist-module/dataslice.js +2 -2
  18. package/dist-module/dataview64.d.ts +2 -2
  19. package/dist-module/dataview64.d.ts.map +1 -1
  20. package/dist-module/dataview64.js +4 -4
  21. package/dist-module/geotiff.d.ts +161 -45
  22. package/dist-module/geotiff.d.ts.map +1 -1
  23. package/dist-module/geotiff.js +111 -20
  24. package/dist-module/geotiffimage.d.ts +76 -110
  25. package/dist-module/geotiffimage.d.ts.map +1 -1
  26. package/dist-module/geotiffimage.js +98 -70
  27. package/dist-module/geotiffwriter.js +2 -2
  28. package/dist-module/globals.d.ts +48 -40
  29. package/dist-module/globals.d.ts.map +1 -1
  30. package/dist-module/globals.js +14 -10
  31. package/dist-module/imagefiledirectory.d.ts +2 -2
  32. package/dist-module/imagefiledirectory.d.ts.map +1 -1
  33. package/dist-module/imagefiledirectory.js +23 -12
  34. package/dist-module/logging.js +7 -7
  35. package/dist-module/pool.d.ts +2 -3
  36. package/dist-module/pool.d.ts.map +1 -1
  37. package/dist-module/pool.js +18 -16
  38. package/dist-module/predictor.js +1 -1
  39. package/dist-module/resample.d.ts +18 -18
  40. package/dist-module/resample.d.ts.map +1 -1
  41. package/dist-module/resample.js +12 -12
  42. package/dist-module/source/basesource.d.ts +7 -7
  43. package/dist-module/source/basesource.d.ts.map +1 -1
  44. package/dist-module/source/basesource.js +7 -7
  45. package/dist-module/source/blockedsource.d.ts +10 -10
  46. package/dist-module/source/blockedsource.d.ts.map +1 -1
  47. package/dist-module/source/blockedsource.js +12 -9
  48. package/dist-module/source/client/base.d.ts +8 -10
  49. package/dist-module/source/client/base.d.ts.map +1 -1
  50. package/dist-module/source/client/base.js +4 -3
  51. package/dist-module/source/client/fetch.d.ts +2 -7
  52. package/dist-module/source/client/fetch.d.ts.map +1 -1
  53. package/dist-module/source/client/fetch.js +7 -2
  54. package/dist-module/source/client/http.d.ts +4 -1
  55. package/dist-module/source/client/http.d.ts.map +1 -1
  56. package/dist-module/source/client/http.js +4 -4
  57. package/dist-module/source/client/xhr.d.ts +4 -1
  58. package/dist-module/source/client/xhr.d.ts.map +1 -1
  59. package/dist-module/source/client/xhr.js +1 -1
  60. package/dist-module/source/file.js +4 -4
  61. package/dist-module/source/filereader.js +1 -1
  62. package/dist-module/source/httputils.d.ts +14 -6
  63. package/dist-module/source/httputils.d.ts.map +1 -1
  64. package/dist-module/source/httputils.js +13 -12
  65. package/dist-module/source/remote.d.ts +31 -22
  66. package/dist-module/source/remote.d.ts.map +1 -1
  67. package/dist-module/source/remote.js +37 -13
  68. package/dist-module/utils.d.ts +7 -1
  69. package/dist-module/utils.d.ts.map +1 -1
  70. package/dist-module/utils.js +6 -0
  71. package/dist-module/worker/create.js +1 -1
  72. package/dist-node/compression/basedecoder.d.ts +4 -0
  73. package/dist-node/compression/basedecoder.d.ts.map +1 -1
  74. package/dist-node/compression/basedecoder.js +6 -0
  75. package/dist-node/compression/basedecoder.js.map +1 -1
  76. package/dist-node/compression/index.d.ts +4 -4
  77. package/dist-node/compression/index.d.ts.map +1 -1
  78. package/dist-node/compression/index.js +4 -4
  79. package/dist-node/compression/jpeg.d.ts +6 -1
  80. package/dist-node/compression/jpeg.d.ts.map +1 -1
  81. package/dist-node/compression/jpeg.js +50 -5
  82. package/dist-node/compression/jpeg.js.map +1 -1
  83. package/dist-node/compression/lzw.js +1 -1
  84. package/dist-node/compression/lzw.js.map +1 -1
  85. package/dist-node/compression/webimage.js +1 -1
  86. package/dist-node/compression/webimage.js.map +1 -1
  87. package/dist-node/dataslice.js +2 -2
  88. package/dist-node/dataslice.js.map +1 -1
  89. package/dist-node/dataview64.d.ts +2 -2
  90. package/dist-node/dataview64.d.ts.map +1 -1
  91. package/dist-node/dataview64.js +4 -4
  92. package/dist-node/dataview64.js.map +1 -1
  93. package/dist-node/geotiff.d.ts +161 -45
  94. package/dist-node/geotiff.d.ts.map +1 -1
  95. package/dist-node/geotiff.js +110 -20
  96. package/dist-node/geotiff.js.map +1 -1
  97. package/dist-node/geotiffimage.d.ts +77 -111
  98. package/dist-node/geotiffimage.d.ts.map +1 -1
  99. package/dist-node/geotiffimage.js +98 -70
  100. package/dist-node/geotiffimage.js.map +1 -1
  101. package/dist-node/geotiffwriter.js +2 -2
  102. package/dist-node/geotiffwriter.js.map +1 -1
  103. package/dist-node/globals.d.ts +48 -40
  104. package/dist-node/globals.d.ts.map +1 -1
  105. package/dist-node/globals.js +14 -10
  106. package/dist-node/globals.js.map +1 -1
  107. package/dist-node/imagefiledirectory.d.ts +2 -2
  108. package/dist-node/imagefiledirectory.d.ts.map +1 -1
  109. package/dist-node/imagefiledirectory.js +23 -12
  110. package/dist-node/imagefiledirectory.js.map +1 -1
  111. package/dist-node/logging.js +7 -7
  112. package/dist-node/logging.js.map +1 -1
  113. package/dist-node/pool.d.ts +2 -3
  114. package/dist-node/pool.d.ts.map +1 -1
  115. package/dist-node/pool.js +18 -16
  116. package/dist-node/pool.js.map +1 -1
  117. package/dist-node/predictor.js +1 -1
  118. package/dist-node/predictor.js.map +1 -1
  119. package/dist-node/resample.d.ts +18 -18
  120. package/dist-node/resample.d.ts.map +1 -1
  121. package/dist-node/resample.js +12 -12
  122. package/dist-node/source/basesource.d.ts +7 -7
  123. package/dist-node/source/basesource.d.ts.map +1 -1
  124. package/dist-node/source/basesource.js +7 -7
  125. package/dist-node/source/basesource.js.map +1 -1
  126. package/dist-node/source/blockedsource.d.ts +10 -10
  127. package/dist-node/source/blockedsource.d.ts.map +1 -1
  128. package/dist-node/source/blockedsource.js +12 -9
  129. package/dist-node/source/blockedsource.js.map +1 -1
  130. package/dist-node/source/client/base.d.ts +8 -10
  131. package/dist-node/source/client/base.d.ts.map +1 -1
  132. package/dist-node/source/client/base.js +4 -3
  133. package/dist-node/source/client/base.js.map +1 -1
  134. package/dist-node/source/client/fetch.d.ts +2 -6
  135. package/dist-node/source/client/fetch.d.ts.map +1 -1
  136. package/dist-node/source/client/fetch.js +7 -2
  137. package/dist-node/source/client/fetch.js.map +1 -1
  138. package/dist-node/source/client/http.d.ts +4 -1
  139. package/dist-node/source/client/http.d.ts.map +1 -1
  140. package/dist-node/source/client/http.js +4 -4
  141. package/dist-node/source/client/http.js.map +1 -1
  142. package/dist-node/source/client/xhr.d.ts +4 -1
  143. package/dist-node/source/client/xhr.d.ts.map +1 -1
  144. package/dist-node/source/client/xhr.js +1 -1
  145. package/dist-node/source/client/xhr.js.map +1 -1
  146. package/dist-node/source/file.js +4 -4
  147. package/dist-node/source/file.js.map +1 -1
  148. package/dist-node/source/filereader.js +1 -1
  149. package/dist-node/source/filereader.js.map +1 -1
  150. package/dist-node/source/httputils.d.ts +14 -6
  151. package/dist-node/source/httputils.d.ts.map +1 -1
  152. package/dist-node/source/httputils.js +13 -12
  153. package/dist-node/source/httputils.js.map +1 -1
  154. package/dist-node/source/remote.d.ts +31 -22
  155. package/dist-node/source/remote.d.ts.map +1 -1
  156. package/dist-node/source/remote.js +37 -13
  157. package/dist-node/source/remote.js.map +1 -1
  158. package/dist-node/utils.d.ts +7 -1
  159. package/dist-node/utils.d.ts.map +1 -1
  160. package/dist-node/utils.js +6 -0
  161. package/dist-node/utils.js.map +1 -1
  162. package/dist-node/worker/create.js +1 -1
  163. package/dist-node/worker/create.js.map +1 -1
  164. package/package.json +3 -54
@@ -6,7 +6,7 @@ import { AbortError } from '../../utils.js';
6
6
  class HttpResponse extends BaseResponse {
7
7
  /**
8
8
  * BaseResponse facade for node HTTP/HTTPS API Response
9
- * @param {http.ServerResponse} response
9
+ * @param {import('http').IncomingMessage} response
10
10
  */
11
11
  constructor(response, dataPromise) {
12
12
  super();
@@ -14,10 +14,10 @@ class HttpResponse extends BaseResponse {
14
14
  this.dataPromise = dataPromise;
15
15
  }
16
16
  get status() {
17
- return this.response.statusCode;
17
+ return /** @type {number} */ (this.response.statusCode);
18
18
  }
19
19
  getHeader(name) {
20
- return this.response.headers[name];
20
+ return /** @type {string|null} */ (this.response.headers[name]);
21
21
  }
22
22
  async getData() {
23
23
  const data = await this.dataPromise;
@@ -60,7 +60,7 @@ export class HttpClient extends BaseClient {
60
60
  }
61
61
  });
62
62
  }
63
- async request({ headers, signal } = {}) {
63
+ async request({ headers = undefined, signal = undefined } = {}) {
64
64
  const response = await this.constructRequest(headers, signal);
65
65
  return response;
66
66
  }
@@ -1,6 +1,9 @@
1
1
  export class XHRClient extends BaseClient {
2
2
  constructRequest(headers: any, signal: any): Promise<any>;
3
- request({ headers, signal }?: {}): Promise<any>;
3
+ request({ headers, signal }?: {
4
+ headers?: undefined;
5
+ signal?: undefined;
6
+ }): Promise<any>;
4
7
  }
5
8
  import { BaseClient } from './base.js';
6
9
  //# sourceMappingURL=xhr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../src/source/client/xhr.js"],"names":[],"mappings":"AA4BA;IACE,0DAyBC;IAED,gDAGC;CACF;2BA5DwC,WAAW"}
1
+ {"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["../../../src/source/client/xhr.js"],"names":[],"mappings":"AA4BA;IACE,0DAyBC;IAED;;;qBAGC;CACF;2BA5DwC,WAAW"}
@@ -46,7 +46,7 @@ export class XHRClient extends BaseClient {
46
46
  }
47
47
  });
48
48
  }
49
- async request({ headers, signal } = {}) {
49
+ async request({ headers = undefined, signal = undefined } = {}) {
50
50
  const response = await this.constructRequest(headers, signal);
51
51
  return response;
52
52
  }
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import { BaseSource } from './basesource.js';
3
3
  function closeAsync(fd) {
4
- return new Promise((resolve, reject) => {
4
+ return /** @type{Promise<void>} */ (new Promise((resolve, reject) => {
5
5
  fs.close(fd, (err) => {
6
6
  if (err) {
7
7
  reject(err);
@@ -10,7 +10,7 @@ function closeAsync(fd) {
10
10
  resolve();
11
11
  }
12
12
  });
13
- });
13
+ }));
14
14
  }
15
15
  function openAsync(path, flags, mode = undefined) {
16
16
  return new Promise((resolve, reject) => {
@@ -24,9 +24,9 @@ function openAsync(path, flags, mode = undefined) {
24
24
  });
25
25
  });
26
26
  }
27
- function readAsync(...args) {
27
+ function readAsync(_fd, _buffer, _offset, _length, _position) {
28
28
  return new Promise((resolve, reject) => {
29
- fs.read(...args, (err, bytesRead, buffer) => {
29
+ fs.read(_fd, _buffer, _offset, _length, _position, (err, bytesRead, buffer) => {
30
30
  if (err) {
31
31
  reject(err);
32
32
  }
@@ -8,7 +8,7 @@ class FileReaderSource extends BaseSource {
8
8
  return new Promise((resolve, reject) => {
9
9
  const blob = this.file.slice(slice.offset, slice.offset + slice.length);
10
10
  const reader = new FileReader();
11
- reader.onload = (event) => resolve(event.target.result);
11
+ reader.onload = () => resolve(reader.result);
12
12
  reader.onerror = reject;
13
13
  reader.onabort = reject;
14
14
  reader.readAsArrayBuffer(blob);
@@ -1,15 +1,23 @@
1
1
  /**
2
2
  * Parse a 'Content-Type' header value to the content-type and parameters
3
- * @param {String} rawContentType the raw string to parse from
4
- * @returns {Object} the parsed content type with the fields: type and params
3
+ * @param {string|null} rawContentType the raw string to parse from
4
+ * @returns {{type: string|null, params: Object}}}
5
+ * the parsed content type with the fields: type and params
5
6
  */
6
- export function parseContentType(rawContentType: string): Object;
7
+ export function parseContentType(rawContentType: string | null): {
8
+ type: string | null;
9
+ params: Object;
10
+ };
7
11
  /**
8
12
  * Parse a 'Content-Range' header value to its start, end, and total parts
9
- * @param {String} rawContentRange the raw string to parse from
10
- * @returns {Object} the parsed parts
13
+ * @param {string|null} rawContentRange the raw string to parse from
14
+ * @returns {{start: number, end: number, total: number}} the parsed parts
11
15
  */
12
- export function parseContentRange(rawContentRange: string): Object;
16
+ export function parseContentRange(rawContentRange: string | null): {
17
+ start: number;
18
+ end: number;
19
+ total: number;
20
+ };
13
21
  /**
14
22
  * Parses a list of byteranges from the given 'multipart/byteranges' HTTP response.
15
23
  * Each item in the list has the following properties:
@@ -1 +1 @@
1
- {"version":3,"file":"httputils.d.ts","sourceRoot":"","sources":["../../src/source/httputils.js"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,0DAFa,MAAM,CAMlB;AAED;;;;GAIG;AACH,4DAFa,MAAM,CAelB;AAED;;;;;;;;;;GAUG;AACH,qDAJW,WAAW,qBAET,MAAM,EAAE,CAuEpB"}
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"}
@@ -29,28 +29,29 @@ function parseHeaders(text) {
29
29
  }
30
30
  /**
31
31
  * Parse a 'Content-Type' header value to the content-type and parameters
32
- * @param {String} rawContentType the raw string to parse from
33
- * @returns {Object} the parsed content type with the fields: type and params
32
+ * @param {string|null} rawContentType the raw string to parse from
33
+ * @returns {{type: string|null, params: Object}}}
34
+ * the parsed content type with the fields: type and params
34
35
  */
35
36
  export function parseContentType(rawContentType) {
37
+ if (!rawContentType) {
38
+ return { type: null, params: {} };
39
+ }
36
40
  const [type, ...rawParams] = rawContentType.split(';').map((s) => s.trim());
37
41
  const paramsItems = rawParams.map((param) => param.split('='));
38
42
  return { type, params: itemsToObject(paramsItems) };
39
43
  }
40
44
  /**
41
45
  * Parse a 'Content-Range' header value to its start, end, and total parts
42
- * @param {String} rawContentRange the raw string to parse from
43
- * @returns {Object} the parsed parts
46
+ * @param {string|null} rawContentRange the raw string to parse from
47
+ * @returns {{start: number, end: number, total: number}} the parsed parts
44
48
  */
45
49
  export function parseContentRange(rawContentRange) {
46
- let start;
47
- let end;
48
- let total;
50
+ let start = NaN;
51
+ let end = NaN;
52
+ let total = NaN;
49
53
  if (rawContentRange) {
50
- [, start, end, total] = rawContentRange.match(/bytes (\d+)-(\d+)\/(\d+)/);
51
- start = parseInt(start, 10);
52
- end = parseInt(end, 10);
53
- total = parseInt(total, 10);
54
+ [, start, end, total] = (rawContentRange.match(/bytes (\d+)-(\d+)\/(\d+)/) || []).map(Number);
54
55
  }
55
56
  return { start, end, total };
56
57
  }
@@ -104,7 +105,7 @@ export function parseByteRanges(responseArrayBuffer, boundary) {
104
105
  const { start, end, total } = parseContentRange(headers['content-range']);
105
106
  // calculate the length of the slice and the next offset
106
107
  const startOfData = offset + startBoundary.length + endOfHeaders + CRLFCRLF.length;
107
- const length = parseInt(end, 10) + 1 - parseInt(start, 10);
108
+ const length = end + 1 - start;
108
109
  out.push({
109
110
  headers,
110
111
  data: responseArrayBuffer.slice(startOfData, startOfData + length),
@@ -1,27 +1,36 @@
1
- export function makeFetchSource(url: any, { headers, credentials, maxRanges, allowFullFile, ...blockOptions }?: {
2
- headers?: {} | undefined;
3
- maxRanges?: number | undefined;
4
- allowFullFile?: boolean | undefined;
5
- }): any;
6
- export function makeXHRSource(url: any, { headers, maxRanges, allowFullFile, ...blockOptions }?: {
7
- headers?: {} | undefined;
8
- maxRanges?: number | undefined;
9
- allowFullFile?: boolean | undefined;
10
- }): any;
11
- export function makeHttpSource(url: any, { headers, maxRanges, allowFullFile, ...blockOptions }?: {
12
- headers?: {} | undefined;
13
- maxRanges?: number | undefined;
14
- allowFullFile?: boolean | undefined;
15
- }): any;
16
- export function makeCustomSource(client: any, { headers, maxRanges, allowFullFile, ...blockOptions }?: {
17
- headers?: {} | undefined;
18
- maxRanges?: number | undefined;
19
- allowFullFile?: boolean | undefined;
20
- }): any;
1
+ /**
2
+ * @param {string} url
3
+ * @param {RemoteSourceOptions & BlockedSourceOptions & { credentials?: RequestCredentials}} [param1]
4
+ * @returns {BaseSource}
5
+ */
6
+ export function makeFetchSource(url: string, { headers, credentials, maxRanges, allowFullFile, ...blockOptions }?: RemoteSourceOptions & BlockedSourceOptions & {
7
+ credentials?: RequestCredentials;
8
+ }): BaseSource;
9
+ /**
10
+ * @param {string} url
11
+ * @param {RemoteSourceOptions & BlockedSourceOptions} [param1]
12
+ * @returns {BaseSource}
13
+ */
14
+ export function makeXHRSource(url: string, { headers, maxRanges, allowFullFile, ...blockOptions }?: RemoteSourceOptions & BlockedSourceOptions): BaseSource;
15
+ /**
16
+ * @param {string} url
17
+ * @param {RemoteSourceOptions & BlockedSourceOptions} [param1]
18
+ * @returns {BaseSource}
19
+ */
20
+ export function makeHttpSource(url: string, { headers, maxRanges, allowFullFile, ...blockOptions }?: RemoteSourceOptions & BlockedSourceOptions): BaseSource;
21
+ /**
22
+ * @param {import("../geotiff").BaseClient} client
23
+ * @param {RemoteSourceOptions & BlockedSourceOptions} [param1]
24
+ * @returns {BaseSource}
25
+ */
26
+ export function makeCustomSource(client: import("../geotiff").BaseClient, { headers, maxRanges, allowFullFile, ...blockOptions }?: RemoteSourceOptions & BlockedSourceOptions): BaseSource;
21
27
  /**
22
28
  *
23
29
  * @param {string} url
24
- * @param {object} options
30
+ * @param {RemoteSourceOptions} options
25
31
  */
26
- export function makeRemoteSource(url: string, { forceXHR, ...clientOptions }?: object): any;
32
+ export function makeRemoteSource(url: string, { forceXHR, ...clientOptions }?: RemoteSourceOptions): BaseSource;
33
+ import type { RemoteSourceOptions } from '../geotiff.js';
34
+ import type { BlockedSourceOptions } from '../geotiff.js';
35
+ import { BaseSource } from './basesource.js';
27
36
  //# sourceMappingURL=remote.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/source/remote.js"],"names":[],"mappings":"AA+JA;;;;QAIC;AAED;;;;QAIC;AAED;;;;QAIC;AAED;;;;QAGC;AAED;;;;GAIG;AACH,sCAHW,MAAM,mCACN,MAAM,OAUhB"}
1
+ {"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/source/remote.js"],"names":[],"mappings":"AAoKA;;;;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;yCApN8D,eAAe;0CAAf,eAAe;2BAPnD,iBAAiB"}
@@ -4,15 +4,13 @@ import { BlockedSource } from './blockedsource.js';
4
4
  import { FetchClient } from './client/fetch.js';
5
5
  import { XHRClient } from './client/xhr.js';
6
6
  import { HttpClient } from './client/http.js';
7
+ /** @import { RemoteSourceOptions, BlockedSourceOptions } from '../geotiff.js' */
7
8
  class RemoteSource extends BaseSource {
8
9
  /**
9
- *
10
- * @param {BaseClient} client
11
- * @param {object} headers
12
- * @param {numbers} maxRanges
13
- * @param {boolean} allowFullFile
10
+ * @param {import("../geotiff").BaseClient} client
11
+ * @param {RemoteSourceOptions} options
14
12
  */
15
- constructor(client, headers, maxRanges, allowFullFile) {
13
+ constructor(client, { headers, maxRanges = 0, allowFullFile } = {}) {
16
14
  super();
17
15
  this.client = client;
18
16
  this.headers = headers;
@@ -21,8 +19,9 @@ class RemoteSource extends BaseSource {
21
19
  this._fileSize = null;
22
20
  }
23
21
  /**
24
- *
25
- * @param {Slice[]} slices
22
+ * @param {import('./basesource.js').Slice[]} slices
23
+ * @param {AbortSignal} [signal]
24
+ * @returns {Promise<*[]>}
26
25
  */
27
26
  async fetch(slices, signal) {
28
27
  // if we allow multi-ranges, split the incoming request into that many sub-requests
@@ -134,35 +133,60 @@ class RemoteSource extends BaseSource {
134
133
  return this._fileSize;
135
134
  }
136
135
  }
136
+ /**
137
+ * @param {BaseSource} source
138
+ * @param {BlockedSourceOptions} blockedSourceOptions
139
+ * @returns {BaseSource}
140
+ */
137
141
  function maybeWrapInBlockedSource(source, { blockSize, cacheSize }) {
138
142
  if (blockSize === null) {
139
143
  return source;
140
144
  }
141
145
  return new BlockedSource(source, { blockSize, cacheSize });
142
146
  }
147
+ /**
148
+ * @param {string} url
149
+ * @param {RemoteSourceOptions & BlockedSourceOptions & { credentials?: RequestCredentials}} [param1]
150
+ * @returns {BaseSource}
151
+ */
143
152
  export function makeFetchSource(url, { headers = {}, credentials, maxRanges = 0, allowFullFile = false, ...blockOptions } = {}) {
144
153
  const client = new FetchClient(url, credentials);
145
- const source = new RemoteSource(client, headers, maxRanges, allowFullFile);
154
+ const source = new RemoteSource(client, { headers, maxRanges, allowFullFile });
146
155
  return maybeWrapInBlockedSource(source, blockOptions);
147
156
  }
157
+ /**
158
+ * @param {string} url
159
+ * @param {RemoteSourceOptions & BlockedSourceOptions} [param1]
160
+ * @returns {BaseSource}
161
+ */
148
162
  export function makeXHRSource(url, { headers = {}, maxRanges = 0, allowFullFile = false, ...blockOptions } = {}) {
149
163
  const client = new XHRClient(url);
150
- const source = new RemoteSource(client, headers, maxRanges, allowFullFile);
164
+ const source = new RemoteSource(client, { headers, maxRanges, allowFullFile });
151
165
  return maybeWrapInBlockedSource(source, blockOptions);
152
166
  }
167
+ /**
168
+ * @param {string} url
169
+ * @param {RemoteSourceOptions & BlockedSourceOptions} [param1]
170
+ * @returns {BaseSource}
171
+ */
153
172
  export function makeHttpSource(url, { headers = {}, maxRanges = 0, allowFullFile = false, ...blockOptions } = {}) {
154
173
  const client = new HttpClient(url);
155
- const source = new RemoteSource(client, headers, maxRanges, allowFullFile);
174
+ const source = new RemoteSource(client, { headers, maxRanges, allowFullFile });
156
175
  return maybeWrapInBlockedSource(source, blockOptions);
157
176
  }
177
+ /**
178
+ * @param {import("../geotiff").BaseClient} client
179
+ * @param {RemoteSourceOptions & BlockedSourceOptions} [param1]
180
+ * @returns {BaseSource}
181
+ */
158
182
  export function makeCustomSource(client, { headers = {}, maxRanges = 0, allowFullFile = false, ...blockOptions } = {}) {
159
- const source = new RemoteSource(client, headers, maxRanges, allowFullFile);
183
+ const source = new RemoteSource(client, { headers, maxRanges, allowFullFile });
160
184
  return maybeWrapInBlockedSource(source, blockOptions);
161
185
  }
162
186
  /**
163
187
  *
164
188
  * @param {string} url
165
- * @param {object} options
189
+ * @param {RemoteSourceOptions} options
166
190
  */
167
191
  export function makeRemoteSource(url, { forceXHR = false, ...clientOptions } = {}) {
168
192
  if (typeof fetch === 'function' && !forceXHR) {
@@ -19,7 +19,13 @@ export function parseContentRange(headerValue: any): {
19
19
  length: number | null;
20
20
  } | null;
21
21
  export function wait(milliseconds: any): Promise<any>;
22
- export function zip(a: any, b: any): any[][];
22
+ /**
23
+ * @template T,U
24
+ * @param {Iterable<T>} a
25
+ * @param {Iterable<U>} b
26
+ * @returns {Array<[T, U]>}
27
+ */
28
+ export function zip<T, U>(a: Iterable<T>, b: Iterable<U>): Array<[T, U]>;
23
29
  export function isTypedFloatArray(input: any): boolean;
24
30
  export function isTypedIntArray(input: any): boolean;
25
31
  export function isTypedUintArray(input: any): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAAA,uDAMC;AAED,2DAWC;AAED,oEAMC;AAED,wDAKC;AAED,wCASC;AAED,wCAMC;AAED,uDAMC;AAED,8CAOC;AAED,oDAKC;AAGD;;;;;;;;;;SAsCC;AAKD,sDAEC;AAED,6CAIC;AA4BD,uDAQC;AAED,qDAQC;AAED,sDAQC;AArDD;IACE,yBAUC;CACF;AAED;IACE,uCAKC;IAHC,YAAoB;IACpB,aAAsB;CAGzB;AAED,yDAAmD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAAA,uDAMC;AAED,2DAWC;AAED,oEAMC;AAED,wDAKC;AAED,wCASC;AAED,wCAMC;AAED,uDAMC;AAED,8CAOC;AAED,oDAKC;AAGD;;;;;;;;;;SAsCC;AAKD,sDAEC;AAED;;;;;GAKG;AACH,oBALa,CAAC,EAAC,CAAC,KACL,QAAQ,CAAC,CAAC,CAAC,KACX,QAAQ,CAAC,CAAC,CAAC,GACT,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAMzB;AA4BD,uDAQC;AAED,qDAQC;AAED,sDAQC;AArDD;IACE,yBAUC;CACF;AAED;IACE,uCAKC;IAHC,YAAoB;IACpB,aAAsB;CAGzB;AAED,yDAAmD"}
@@ -108,6 +108,12 @@ export function parseContentRange(headerValue) {
108
108
  export async function wait(milliseconds) {
109
109
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
110
110
  }
111
+ /**
112
+ * @template T,U
113
+ * @param {Iterable<T>} a
114
+ * @param {Iterable<U>} b
115
+ * @returns {Array<[T, U]>}
116
+ */
111
117
  export function zip(a, b) {
112
118
  const A = Array.isArray(a) ? a : Array.from(a);
113
119
  const B = Array.isArray(b) ? b : Array.from(b);