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.
- package/dist-browser/geotiff.js +3 -2
- package/dist-browser/geotiff.js.map +1 -1
- package/dist-module/compression/basedecoder.d.ts +4 -0
- package/dist-module/compression/basedecoder.d.ts.map +1 -1
- package/dist-module/compression/basedecoder.js +6 -0
- package/dist-module/compression/index.d.ts +4 -4
- package/dist-module/compression/index.d.ts.map +1 -1
- package/dist-module/compression/index.js +4 -4
- package/dist-module/compression/jpeg.d.ts +6 -1
- package/dist-module/compression/jpeg.d.ts.map +1 -1
- package/dist-module/compression/jpeg.js +50 -5
- package/dist-module/compression/lzw.js +1 -1
- package/dist-module/compression/webimage.d.ts +1 -1
- package/dist-module/compression/webimage.d.ts.map +1 -1
- package/dist-module/compression/webimage.js +1 -1
- package/dist-module/dataslice.d.ts.map +1 -1
- package/dist-module/dataslice.js +2 -2
- package/dist-module/dataview64.d.ts +2 -2
- package/dist-module/dataview64.d.ts.map +1 -1
- package/dist-module/dataview64.js +4 -4
- package/dist-module/geotiff.d.ts +161 -45
- package/dist-module/geotiff.d.ts.map +1 -1
- package/dist-module/geotiff.js +111 -20
- package/dist-module/geotiffimage.d.ts +76 -110
- package/dist-module/geotiffimage.d.ts.map +1 -1
- package/dist-module/geotiffimage.js +98 -70
- package/dist-module/geotiffwriter.js +2 -2
- package/dist-module/globals.d.ts +48 -40
- package/dist-module/globals.d.ts.map +1 -1
- package/dist-module/globals.js +14 -10
- package/dist-module/imagefiledirectory.d.ts +2 -2
- package/dist-module/imagefiledirectory.d.ts.map +1 -1
- package/dist-module/imagefiledirectory.js +23 -12
- package/dist-module/logging.js +7 -7
- package/dist-module/pool.d.ts +2 -3
- package/dist-module/pool.d.ts.map +1 -1
- package/dist-module/pool.js +18 -16
- package/dist-module/predictor.js +1 -1
- package/dist-module/resample.d.ts +18 -18
- package/dist-module/resample.d.ts.map +1 -1
- package/dist-module/resample.js +12 -12
- package/dist-module/source/basesource.d.ts +7 -7
- package/dist-module/source/basesource.d.ts.map +1 -1
- package/dist-module/source/basesource.js +7 -7
- package/dist-module/source/blockedsource.d.ts +10 -10
- package/dist-module/source/blockedsource.d.ts.map +1 -1
- package/dist-module/source/blockedsource.js +12 -9
- package/dist-module/source/client/base.d.ts +8 -10
- package/dist-module/source/client/base.d.ts.map +1 -1
- package/dist-module/source/client/base.js +4 -3
- package/dist-module/source/client/fetch.d.ts +2 -7
- package/dist-module/source/client/fetch.d.ts.map +1 -1
- package/dist-module/source/client/fetch.js +7 -2
- package/dist-module/source/client/http.d.ts +4 -1
- package/dist-module/source/client/http.d.ts.map +1 -1
- package/dist-module/source/client/http.js +4 -4
- package/dist-module/source/client/xhr.d.ts +4 -1
- package/dist-module/source/client/xhr.d.ts.map +1 -1
- package/dist-module/source/client/xhr.js +1 -1
- package/dist-module/source/file.js +4 -4
- package/dist-module/source/filereader.js +1 -1
- package/dist-module/source/httputils.d.ts +14 -6
- package/dist-module/source/httputils.d.ts.map +1 -1
- package/dist-module/source/httputils.js +13 -12
- package/dist-module/source/remote.d.ts +31 -22
- package/dist-module/source/remote.d.ts.map +1 -1
- package/dist-module/source/remote.js +37 -13
- package/dist-module/utils.d.ts +7 -1
- package/dist-module/utils.d.ts.map +1 -1
- package/dist-module/utils.js +6 -0
- package/dist-module/worker/create.js +1 -1
- package/dist-node/compression/basedecoder.d.ts +4 -0
- package/dist-node/compression/basedecoder.d.ts.map +1 -1
- package/dist-node/compression/basedecoder.js +6 -0
- package/dist-node/compression/basedecoder.js.map +1 -1
- package/dist-node/compression/index.d.ts +4 -4
- package/dist-node/compression/index.d.ts.map +1 -1
- package/dist-node/compression/index.js +4 -4
- package/dist-node/compression/jpeg.d.ts +6 -1
- package/dist-node/compression/jpeg.d.ts.map +1 -1
- package/dist-node/compression/jpeg.js +50 -5
- package/dist-node/compression/jpeg.js.map +1 -1
- package/dist-node/compression/lzw.js +1 -1
- package/dist-node/compression/lzw.js.map +1 -1
- package/dist-node/compression/webimage.js +1 -1
- package/dist-node/compression/webimage.js.map +1 -1
- package/dist-node/dataslice.js +2 -2
- package/dist-node/dataslice.js.map +1 -1
- package/dist-node/dataview64.d.ts +2 -2
- package/dist-node/dataview64.d.ts.map +1 -1
- package/dist-node/dataview64.js +4 -4
- package/dist-node/dataview64.js.map +1 -1
- package/dist-node/geotiff.d.ts +161 -45
- package/dist-node/geotiff.d.ts.map +1 -1
- package/dist-node/geotiff.js +110 -20
- package/dist-node/geotiff.js.map +1 -1
- package/dist-node/geotiffimage.d.ts +77 -111
- package/dist-node/geotiffimage.d.ts.map +1 -1
- package/dist-node/geotiffimage.js +98 -70
- package/dist-node/geotiffimage.js.map +1 -1
- package/dist-node/geotiffwriter.js +2 -2
- package/dist-node/geotiffwriter.js.map +1 -1
- package/dist-node/globals.d.ts +48 -40
- package/dist-node/globals.d.ts.map +1 -1
- package/dist-node/globals.js +14 -10
- package/dist-node/globals.js.map +1 -1
- package/dist-node/imagefiledirectory.d.ts +2 -2
- package/dist-node/imagefiledirectory.d.ts.map +1 -1
- package/dist-node/imagefiledirectory.js +23 -12
- package/dist-node/imagefiledirectory.js.map +1 -1
- package/dist-node/logging.js +7 -7
- package/dist-node/logging.js.map +1 -1
- package/dist-node/pool.d.ts +2 -3
- package/dist-node/pool.d.ts.map +1 -1
- package/dist-node/pool.js +18 -16
- package/dist-node/pool.js.map +1 -1
- package/dist-node/predictor.js +1 -1
- package/dist-node/predictor.js.map +1 -1
- package/dist-node/resample.d.ts +18 -18
- package/dist-node/resample.d.ts.map +1 -1
- package/dist-node/resample.js +12 -12
- package/dist-node/source/basesource.d.ts +7 -7
- package/dist-node/source/basesource.d.ts.map +1 -1
- package/dist-node/source/basesource.js +7 -7
- package/dist-node/source/basesource.js.map +1 -1
- package/dist-node/source/blockedsource.d.ts +10 -10
- package/dist-node/source/blockedsource.d.ts.map +1 -1
- package/dist-node/source/blockedsource.js +12 -9
- package/dist-node/source/blockedsource.js.map +1 -1
- package/dist-node/source/client/base.d.ts +8 -10
- package/dist-node/source/client/base.d.ts.map +1 -1
- package/dist-node/source/client/base.js +4 -3
- package/dist-node/source/client/base.js.map +1 -1
- package/dist-node/source/client/fetch.d.ts +2 -6
- package/dist-node/source/client/fetch.d.ts.map +1 -1
- package/dist-node/source/client/fetch.js +7 -2
- package/dist-node/source/client/fetch.js.map +1 -1
- package/dist-node/source/client/http.d.ts +4 -1
- package/dist-node/source/client/http.d.ts.map +1 -1
- package/dist-node/source/client/http.js +4 -4
- package/dist-node/source/client/http.js.map +1 -1
- package/dist-node/source/client/xhr.d.ts +4 -1
- package/dist-node/source/client/xhr.d.ts.map +1 -1
- package/dist-node/source/client/xhr.js +1 -1
- package/dist-node/source/client/xhr.js.map +1 -1
- package/dist-node/source/file.js +4 -4
- package/dist-node/source/file.js.map +1 -1
- package/dist-node/source/filereader.js +1 -1
- package/dist-node/source/filereader.js.map +1 -1
- package/dist-node/source/httputils.d.ts +14 -6
- package/dist-node/source/httputils.d.ts.map +1 -1
- package/dist-node/source/httputils.js +13 -12
- package/dist-node/source/httputils.js.map +1 -1
- package/dist-node/source/remote.d.ts +31 -22
- package/dist-node/source/remote.d.ts.map +1 -1
- package/dist-node/source/remote.js +37 -13
- package/dist-node/source/remote.js.map +1 -1
- package/dist-node/utils.d.ts +7 -1
- package/dist-node/utils.d.ts.map +1 -1
- package/dist-node/utils.js +6 -0
- package/dist-node/utils.js.map +1 -1
- package/dist-node/worker/create.js +1 -1
- package/dist-node/worker/create.js.map +1 -1
- 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.
|
|
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 }?: {
|
|
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
|
|
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(
|
|
27
|
+
function readAsync(_fd, _buffer, _offset, _length, _position) {
|
|
28
28
|
return new Promise((resolve, reject) => {
|
|
29
|
-
fs.read(
|
|
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 = (
|
|
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 {
|
|
4
|
-
* @returns {
|
|
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):
|
|
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 {
|
|
10
|
-
* @returns {
|
|
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):
|
|
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
|
|
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 {
|
|
33
|
-
* @returns {
|
|
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 {
|
|
43
|
-
* @returns {
|
|
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 =
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}):
|
|
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 {
|
|
30
|
+
* @param {RemoteSourceOptions} options
|
|
25
31
|
*/
|
|
26
|
-
export function makeRemoteSource(url: string, { forceXHR, ...clientOptions }?:
|
|
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":"
|
|
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 {
|
|
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 {
|
|
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 {
|
|
189
|
+
* @param {RemoteSourceOptions} options
|
|
166
190
|
*/
|
|
167
191
|
export function makeRemoteSource(url, { forceXHR = false, ...clientOptions } = {}) {
|
|
168
192
|
if (typeof fetch === 'function' && !forceXHR) {
|
package/dist-module/utils.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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"}
|
package/dist-module/utils.js
CHANGED
|
@@ -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);
|