@loaders.gl/core 4.0.0-alpha.6 → 4.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +97 -65
- package/dist/es5/lib/api/load.js.map +1 -1
- package/dist/es5/lib/api/parse-in-batches.js +15 -14
- package/dist/es5/lib/api/parse-in-batches.js.map +1 -1
- package/dist/es5/lib/api/parse-sync.js +3 -4
- package/dist/es5/lib/api/parse-sync.js.map +1 -1
- package/dist/es5/lib/api/parse.js +3 -3
- package/dist/es5/lib/api/parse.js.map +1 -1
- package/dist/es5/lib/api/select-loader.js +6 -7
- package/dist/es5/lib/api/select-loader.js.map +1 -1
- package/dist/es5/lib/init.js +1 -1
- package/dist/es5/lib/loader-utils/loader-context.js +16 -8
- package/dist/es5/lib/loader-utils/loader-context.js.map +1 -1
- package/dist/es5/lib/utils/resource-utils.js +31 -27
- package/dist/es5/lib/utils/resource-utils.js.map +1 -1
- package/dist/es5/lib/utils/response-utils.js +6 -5
- package/dist/es5/lib/utils/response-utils.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +16 -0
- package/dist/es5/lib/utils/url-utils.js.map +1 -0
- package/dist/es5/null-loader.js +1 -1
- package/dist/esm/lib/api/load.js.map +1 -1
- package/dist/esm/lib/api/parse-in-batches.js +6 -7
- package/dist/esm/lib/api/parse-in-batches.js.map +1 -1
- package/dist/esm/lib/api/parse-sync.js +4 -6
- package/dist/esm/lib/api/parse-sync.js.map +1 -1
- package/dist/esm/lib/api/parse.js +3 -5
- package/dist/esm/lib/api/parse.js.map +1 -1
- package/dist/esm/lib/api/select-loader.js +7 -10
- package/dist/esm/lib/api/select-loader.js.map +1 -1
- package/dist/esm/lib/init.js +1 -1
- package/dist/esm/lib/loader-utils/loader-context.js +16 -8
- package/dist/esm/lib/loader-utils/loader-context.js.map +1 -1
- package/dist/esm/lib/utils/resource-utils.js +29 -26
- package/dist/esm/lib/utils/resource-utils.js.map +1 -1
- package/dist/esm/lib/utils/response-utils.js +3 -5
- package/dist/esm/lib/utils/response-utils.js.map +1 -1
- package/dist/esm/lib/utils/url-utils.js +9 -0
- package/dist/esm/lib/utils/url-utils.js.map +1 -0
- package/dist/esm/null-loader.js +1 -1
- package/dist/lib/api/load.d.ts +2 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +4 -7
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +3 -3
- package/dist/lib/api/parse.js +2 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +6 -3
- package/dist/lib/fetch/fetch-file.js +1 -1
- package/dist/lib/loader-utils/loader-context.d.ts +1 -1
- package/dist/lib/loader-utils/loader-context.d.ts.map +1 -1
- package/dist/lib/loader-utils/loader-context.js +17 -7
- package/dist/lib/utils/resource-utils.d.ts +17 -8
- package/dist/lib/utils/resource-utils.d.ts.map +1 -1
- package/dist/lib/utils/resource-utils.js +46 -34
- package/dist/lib/utils/response-utils.d.ts.map +1 -1
- package/dist/lib/utils/response-utils.js +2 -1
- package/dist/lib/utils/url-utils.d.ts +3 -0
- package/dist/lib/utils/url-utils.d.ts.map +1 -0
- package/dist/lib/utils/url-utils.js +14 -0
- package/dist/null-worker-node.js +234 -0
- package/dist/null-worker.js +1 -1
- package/package.json +7 -6
- package/src/lib/api/load.ts +1 -1
- package/src/lib/api/parse-in-batches.ts +8 -9
- package/src/lib/api/parse-sync.ts +8 -4
- package/src/lib/api/parse.ts +3 -3
- package/src/lib/api/select-loader.ts +7 -4
- package/src/lib/loader-utils/loader-context.ts +19 -8
- package/src/lib/utils/resource-utils.ts +54 -34
- package/src/lib/utils/response-utils.ts +3 -2
- package/src/lib/utils/url-utils.ts +12 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-utils.js","names":["isResponse","getResourceContentLength","
|
|
1
|
+
{"version":3,"file":"response-utils.js","names":["isResponse","getResourceContentLength","getResourceUrl","getResourceMIMEType","makeResponse","resource","headers","contentLength","String","url","type","initialDataUrl","getInitialDataUrl","TextEncoder","encode","response","Response","Object","defineProperty","value","checkResponse","ok","message","getResponseError","Error","checkResponseSync","concat","status","statusText","length","slice","contentType","get","text","includes","error","INITIAL_DATA_LENGTH","Blob","blobSlice","Promise","resolve","reader","FileReader","onload","event","_event$target","target","result","readAsDataURL","ArrayBuffer","base64","arrayBufferToBase64","buffer","binary","bytes","Uint8Array","i","byteLength","fromCharCode","btoa"],"sources":["../../../../src/lib/utils/response-utils.ts"],"sourcesContent":["import {isResponse} from '../../javascript-utils/is-type';\nimport {getResourceContentLength, getResourceUrl, getResourceMIMEType} from './resource-utils';\n\n/**\n * Returns a Response object\n * Adds content-length header when possible\n *\n * @param resource\n */\nexport async function makeResponse(resource: any): Promise<Response> {\n if (isResponse(resource)) {\n return resource;\n }\n\n // Add content-length header if possible\n const headers: {[header: string]: string} = {};\n\n const contentLength = getResourceContentLength(resource);\n if (contentLength >= 0) {\n headers['content-length'] = String(contentLength);\n }\n\n // `new Response(File)` does not preserve content-type and URL\n // so we add them here\n const url = getResourceUrl(resource);\n const type = getResourceMIMEType(resource);\n if (type) {\n headers['content-type'] = type;\n }\n\n // Add a custom header with initial bytes if available\n const initialDataUrl = await getInitialDataUrl(resource);\n if (initialDataUrl) {\n headers['x-first-bytes'] = initialDataUrl;\n }\n\n // TODO - is this the best way of handling strings?\n // Maybe package as data URL instead?\n if (typeof resource === 'string') {\n // Convert to ArrayBuffer to avoid Response treating it as a URL\n resource = new TextEncoder().encode(resource);\n }\n\n // Attempt to create a Response from the resource, adding headers and setting url\n const response = new Response(resource, {headers});\n // We can't control `Response.url` via constructor, use a property override to record URL.\n Object.defineProperty(response, 'url', {value: url});\n return response;\n}\n\n/**\n * Checks response status (async) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport async function checkResponse(response: Response): Promise<void> {\n if (!response.ok) {\n const message = await getResponseError(response);\n throw new Error(message);\n }\n}\n\n/**\n * Checks response status (sync) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport function checkResponseSync(response: Response): void {\n if (!response.ok) {\n let message = `${response.status} ${response.statusText}`;\n message = message.length > 60 ? `${message.slice(0, 60)}...` : message;\n throw new Error(message);\n }\n}\n\n// HELPERS\n\nasync function getResponseError(response): Promise<string> {\n let message = `Failed to fetch resource ${response.url} (${response.status}): `;\n try {\n const contentType = response.headers.get('Content-Type');\n let text = response.statusText;\n if (contentType.includes('application/json')) {\n text += ` ${await response.text()}`;\n }\n message += text;\n message = message.length > 60 ? `${message.slice(0, 60)}...` : message;\n } catch (error) {\n // eslint forbids return in a finally statement, so we just catch here\n }\n return message;\n}\n\nasync function getInitialDataUrl(resource): Promise<string | null> {\n const INITIAL_DATA_LENGTH = 5;\n if (typeof resource === 'string') {\n return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;\n }\n if (resource instanceof Blob) {\n const blobSlice = resource.slice(0, 5);\n return await new Promise((resolve) => {\n const reader = new FileReader();\n reader.onload = (event) => resolve(event?.target?.result as string);\n reader.readAsDataURL(blobSlice);\n });\n }\n if (resource instanceof ArrayBuffer) {\n const slice = resource.slice(0, INITIAL_DATA_LENGTH);\n const base64 = arrayBufferToBase64(slice);\n return `data:base64,${base64}`;\n }\n return null;\n}\n\n// https://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string\nfunction arrayBufferToBase64(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const QUERY_STRING_PATTERN = /\?.*/;
|
|
2
|
+
export function extractQueryString(url) {
|
|
3
|
+
const matches = url.match(QUERY_STRING_PATTERN);
|
|
4
|
+
return matches && matches[0];
|
|
5
|
+
}
|
|
6
|
+
export function stripQueryString(url) {
|
|
7
|
+
return url.replace(QUERY_STRING_PATTERN, '');
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=url-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-utils.js","names":["QUERY_STRING_PATTERN","extractQueryString","url","matches","match","stripQueryString","replace"],"sources":["../../../../src/lib/utils/url-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nconst QUERY_STRING_PATTERN = /\\?.*/;\n\nexport function extractQueryString(url): string {\n const matches = url.match(QUERY_STRING_PATTERN);\n return matches && matches[0];\n}\n\nexport function stripQueryString(url): string {\n return url.replace(QUERY_STRING_PATTERN, '');\n}\n"],"mappings":"AAEA,MAAMA,oBAAoB,GAAG,MAAM;AAEnC,OAAO,SAASC,kBAAkBA,CAACC,GAAG,EAAU;EAC9C,MAAMC,OAAO,GAAGD,GAAG,CAACE,KAAK,CAACJ,oBAAoB,CAAC;EAC/C,OAAOG,OAAO,IAAIA,OAAO,CAAC,CAAC,CAAC;AAC9B;AAEA,OAAO,SAASE,gBAAgBA,CAACH,GAAG,EAAU;EAC5C,OAAOA,GAAG,CAACI,OAAO,CAACN,oBAAoB,EAAE,EAAE,CAAC;AAC9C"}
|
package/dist/esm/null-loader.js
CHANGED
package/dist/lib/api/load.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ import type { LoaderOptionsType, LoaderReturnType } from '@loaders.gl/loader-uti
|
|
|
10
10
|
* @param context
|
|
11
11
|
*/
|
|
12
12
|
export declare function load<LoaderT extends Loader>(url: string | DataType, loader: LoaderT, options?: LoaderOptionsType<LoaderT>, context?: LoaderContext): Promise<LoaderReturnType<LoaderT>>;
|
|
13
|
-
export declare function load<LoaderT extends Loader,
|
|
13
|
+
export declare function load<LoaderT extends Loader, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
+
LoaderOptionsT extends LoaderOptions = LoaderOptions>(url: string | DataType, loaders: Loader[] | LoaderOptions, options?: LoaderOptionsT, context?: LoaderContext): Promise<any>;
|
|
14
15
|
//# sourceMappingURL=load.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/lib/api/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC7F,OAAO,KAAK,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAOlF;;;;;;;;GAQG;AAEH,wBAAsB,IAAI,CAAC,OAAO,SAAS,MAAM,EAC/C,GAAG,EAAE,MAAM,GAAG,QAAQ,EACtB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,EACpC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEtC,wBAAsB,IAAI,CACxB,OAAO,SAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/lib/api/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC7F,OAAO,KAAK,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAOlF;;;;;;;;GAQG;AAEH,wBAAsB,IAAI,CAAC,OAAO,SAAS,MAAM,EAC/C,GAAG,EAAE,MAAM,GAAG,QAAQ,EACtB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,EACpC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEtC,wBAAsB,IAAI,CACxB,OAAO,SAAS,MAAM,EAAE,yDAAyD;AACjF,cAAc,SAAS,aAAa,GAAG,aAAa,EAEpD,GAAG,EAAE,MAAM,GAAG,QAAQ,EACtB,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,EACjC,OAAO,CAAC,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-in-batches.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-in-batches.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,EAEN,aAAa,EACb,aAAa,EACd,MAAM,0BAA0B,CAAC;AAYlC;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"parse-in-batches.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-in-batches.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,EAEN,aAAa,EACb,aAAa,EACd,MAAM,0BAA0B,CAAC;AAYlC;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAoC7B"}
|
|
@@ -19,6 +19,7 @@ const parse_1 = require("./parse");
|
|
|
19
19
|
*/
|
|
20
20
|
async function parseInBatches(data, loaders, options, context) {
|
|
21
21
|
(0, loader_utils_1.assert)(!context || typeof context === 'object'); // parseInBatches no longer accepts final url
|
|
22
|
+
const loaderArray = Array.isArray(loaders) ? loaders : undefined;
|
|
22
23
|
// Signature: parseInBatches(data, options, url) - Uses registered loaders
|
|
23
24
|
if (!Array.isArray(loaders) && !(0, normalize_loader_1.isLoaderObject)(loaders)) {
|
|
24
25
|
context = undefined; // context not supported in short signature
|
|
@@ -28,7 +29,7 @@ async function parseInBatches(data, loaders, options, context) {
|
|
|
28
29
|
data = await data; // Resolve any promise
|
|
29
30
|
options = options || {};
|
|
30
31
|
// Extract a url for auto detection
|
|
31
|
-
const
|
|
32
|
+
const url = (0, resource_utils_1.getResourceUrl)(data);
|
|
32
33
|
// Chooses a loader and normalizes it
|
|
33
34
|
// Note - only uses URL and contentType for streams and iterator inputs
|
|
34
35
|
const loader = await (0, select_loader_1.selectLoader)(data, loaders, options);
|
|
@@ -38,12 +39,8 @@ async function parseInBatches(data, loaders, options, context) {
|
|
|
38
39
|
return null;
|
|
39
40
|
}
|
|
40
41
|
// Normalize options
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
context = (0, loader_context_1.getLoaderContext)(
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
{ url, parseInBatches, parse: parse_1.parse, loaders: loaders }, options, context);
|
|
42
|
+
options = (0, option_utils_1.normalizeOptions)(options, loader, loaderArray, url);
|
|
43
|
+
context = (0, loader_context_1.getLoaderContext)({ url, parseInBatches, parse: parse_1.parse, loaders: loaderArray }, options, context || null);
|
|
47
44
|
return await parseWithLoaderInBatches(loader, data, options, context);
|
|
48
45
|
}
|
|
49
46
|
exports.parseInBatches = parseInBatches;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-sync.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EAEN,aAAa,EACb,aAAa,EACd,MAAM,0BAA0B,CAAC;AASlC;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,GAAG,
|
|
1
|
+
{"version":3,"file":"parse-sync.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EAEN,aAAa,EACb,aAAa,EACd,MAAM,0BAA0B,CAAC;AASlC;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,aAAa,EAC3C,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,GAAG,CAuCL"}
|
|
@@ -37,11 +37,11 @@ function parseSync(data, loaders, options, context) {
|
|
|
37
37
|
// Normalize options
|
|
38
38
|
options = (0, option_utils_1.normalizeOptions)(options, loader, candidateLoaders);
|
|
39
39
|
// Extract a url for auto detection
|
|
40
|
-
const
|
|
40
|
+
const url = (0, resource_utils_1.getResourceUrl)(data);
|
|
41
41
|
const parse = () => {
|
|
42
|
-
throw new Error('parseSync called parse');
|
|
42
|
+
throw new Error('parseSync called parse (which is async');
|
|
43
43
|
};
|
|
44
|
-
context = (0, loader_context_1.getLoaderContext)({ url, parseSync, parse, loaders: loaders }, options);
|
|
44
|
+
context = (0, loader_context_1.getLoaderContext)({ url, parseSync, parse, loaders: loaders }, options, context || null);
|
|
45
45
|
return parseWithLoaderSync(loader, data, options, context);
|
|
46
46
|
}
|
|
47
47
|
exports.parseSync = parseSync;
|
package/dist/lib/api/parse.js
CHANGED
|
@@ -31,7 +31,7 @@ async function parse(data, loaders, options, context) {
|
|
|
31
31
|
data = await data; // Resolve any promise
|
|
32
32
|
options = options || {}; // Could be invalid...
|
|
33
33
|
// Extract a url for auto detection
|
|
34
|
-
const
|
|
34
|
+
const url = (0, resource_utils_1.getResourceUrl)(data);
|
|
35
35
|
// Chooses a loader (and normalizes it)
|
|
36
36
|
// Also use any loaders in the context, new loaders take priority
|
|
37
37
|
const typedLoaders = loaders;
|
|
@@ -45,7 +45,7 @@ async function parse(data, loaders, options, context) {
|
|
|
45
45
|
// Normalize options
|
|
46
46
|
options = (0, option_utils_1.normalizeOptions)(options, loader, candidateLoaders, url); // Could be invalid...
|
|
47
47
|
// Get a context (if already present, will be unchanged)
|
|
48
|
-
context = (0, loader_context_1.getLoaderContext)({ url, parse, loaders: candidateLoaders }, options, context);
|
|
48
|
+
context = (0, loader_context_1.getLoaderContext)({ url, parse, loaders: candidateLoaders }, options, context || null);
|
|
49
49
|
return await parseWithLoader(loader, data, options, context);
|
|
50
50
|
}
|
|
51
51
|
exports.parse = parse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/api/select-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"select-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/api/select-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAenF;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,WAAW,GAAG,MAAM,EAC5C,OAAO,GAAE,MAAM,EAAE,GAAG,MAAW,EAC/B,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAwBxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,WAAW,GAAG,MAAM,EAC5C,OAAO,GAAE,MAAM,EAAE,GAAG,MAAW,EAC/B,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,MAAM,GAAG,IAAI,CAmCf"}
|
|
@@ -7,6 +7,7 @@ const log_1 = require("../utils/log");
|
|
|
7
7
|
const resource_utils_1 = require("../utils/resource-utils");
|
|
8
8
|
const register_loaders_1 = require("./register-loaders");
|
|
9
9
|
const is_type_1 = require("../../javascript-utils/is-type");
|
|
10
|
+
const url_utils_1 = require("../utils/url-utils");
|
|
10
11
|
const EXT_PATTERN = /\.([^.]+)$/;
|
|
11
12
|
// TODO - Need a variant that peeks at streams for parseInBatches
|
|
12
13
|
// TODO - Detect multiple matching loaders? Use heuristics to grade matches?
|
|
@@ -85,8 +86,9 @@ exports.selectLoaderSync = selectLoaderSync;
|
|
|
85
86
|
/** Implements loaders selection logic */
|
|
86
87
|
// eslint-disable-next-line complexity
|
|
87
88
|
function selectLoaderInternal(data, loaders, options, context) {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
89
|
+
const url = (0, resource_utils_1.getResourceUrl)(data);
|
|
90
|
+
const type = (0, resource_utils_1.getResourceMIMEType)(data);
|
|
91
|
+
const testUrl = (0, url_utils_1.stripQueryString)(url) || context?.url;
|
|
90
92
|
let loader = null;
|
|
91
93
|
let reason = '';
|
|
92
94
|
// if options.mimeType is supplied, it takes precedence
|
|
@@ -124,7 +126,8 @@ function validHTTPResponse(data) {
|
|
|
124
126
|
}
|
|
125
127
|
/** Generate a helpful message to help explain why loader selection failed. */
|
|
126
128
|
function getNoValidLoaderMessage(data) {
|
|
127
|
-
const
|
|
129
|
+
const url = (0, resource_utils_1.getResourceUrl)(data);
|
|
130
|
+
const type = (0, resource_utils_1.getResourceMIMEType)(data);
|
|
128
131
|
let message = 'No valid loader found (';
|
|
129
132
|
message += url ? `${loader_utils_1.path.filename(url)}, ` : 'no url provided, ';
|
|
130
133
|
message += `MIME type: ${type ? `"${type}"` : 'not provided'}, `;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchFile = void 0;
|
|
4
4
|
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
5
5
|
const response_utils_1 = require("../utils/response-utils");
|
|
6
|
-
// import {getErrorMessageFromResponse} from './fetch-error-message
|
|
6
|
+
// import {getErrorMessageFromResponse} from './fetch-error-message';
|
|
7
7
|
/**
|
|
8
8
|
* fetch compatible function
|
|
9
9
|
* Reads file data from:
|
|
@@ -8,6 +8,6 @@ import type { Loader, LoaderOptions, LoaderContext } from '@loaders.gl/loader-ut
|
|
|
8
8
|
* @param options
|
|
9
9
|
* @param previousContext
|
|
10
10
|
*/
|
|
11
|
-
export declare function getLoaderContext(context: Omit<LoaderContext, 'fetch'> & Partial<Pick<LoaderContext, 'fetch'>>, options
|
|
11
|
+
export declare function getLoaderContext(context: Omit<LoaderContext, 'fetch'> & Partial<Pick<LoaderContext, 'fetch'>>, options: LoaderOptions, parentContext: LoaderContext | null): LoaderContext;
|
|
12
12
|
export declare function getLoadersFromContext(loaders: Loader[] | Loader | undefined, context?: LoaderContext): any;
|
|
13
13
|
//# sourceMappingURL=loader-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-context.d.ts","sourceRoot":"","sources":["../../../src/lib/loader-utils/loader-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"loader-context.d.ts","sourceRoot":"","sources":["../../../src/lib/loader-utils/loader-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAKnF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,EAC7E,OAAO,EAAE,aAAa,EACtB,aAAa,EAAE,aAAa,GAAG,IAAI,GAClC,aAAa,CA2Bf;AAGD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,EACtC,OAAO,CAAC,EAAE,aAAa,OAkBxB"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLoadersFromContext = exports.getLoaderContext = void 0;
|
|
4
4
|
const get_fetch_function_1 = require("./get-fetch-function");
|
|
5
|
+
const url_utils_1 = require("../utils/url-utils");
|
|
6
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
5
7
|
/**
|
|
6
8
|
* "sub" loaders invoked by other loaders get a "context" injected on `this`
|
|
7
9
|
* The context will inject core methods like `parse` and contain information
|
|
@@ -11,21 +13,29 @@ const get_fetch_function_1 = require("./get-fetch-function");
|
|
|
11
13
|
* @param options
|
|
12
14
|
* @param previousContext
|
|
13
15
|
*/
|
|
14
|
-
function getLoaderContext(context, options,
|
|
16
|
+
function getLoaderContext(context, options, parentContext) {
|
|
15
17
|
// For recursive calls, we already have a context
|
|
16
18
|
// TODO - add any additional loaders to context?
|
|
17
|
-
if (
|
|
18
|
-
return
|
|
19
|
+
if (parentContext) {
|
|
20
|
+
return parentContext;
|
|
19
21
|
}
|
|
20
|
-
const
|
|
22
|
+
const newContext = {
|
|
21
23
|
fetch: (0, get_fetch_function_1.getFetchFunction)(options, context),
|
|
22
24
|
...context
|
|
23
25
|
};
|
|
26
|
+
// Parse URLs so that subloaders can easily generate correct strings
|
|
27
|
+
if (newContext.url) {
|
|
28
|
+
const baseUrl = (0, url_utils_1.stripQueryString)(newContext.url);
|
|
29
|
+
newContext.baseUrl = baseUrl;
|
|
30
|
+
newContext.queryString = (0, url_utils_1.extractQueryString)(newContext.url);
|
|
31
|
+
newContext.filename = loader_utils_1.path.filename(baseUrl);
|
|
32
|
+
newContext.baseUrl = loader_utils_1.path.dirname(baseUrl);
|
|
33
|
+
}
|
|
24
34
|
// Recursive loading does not use single loader
|
|
25
|
-
if (!Array.isArray(
|
|
26
|
-
|
|
35
|
+
if (!Array.isArray(newContext.loaders)) {
|
|
36
|
+
newContext.loaders = null;
|
|
27
37
|
}
|
|
28
|
-
return
|
|
38
|
+
return newContext;
|
|
29
39
|
}
|
|
30
40
|
exports.getLoaderContext = getLoaderContext;
|
|
31
41
|
// eslint-disable-next-line complexity
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* A loadable resource. Includes:
|
|
3
|
+
* `Response`, `Blob` (`File` is a subclass), string URLs and data URLs
|
|
4
|
+
*/
|
|
5
|
+
export type Resource = Response | Blob | string;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the URL associated with this resource.
|
|
8
|
+
* The returned value may include a query string and need further processing.
|
|
9
|
+
* If it cannot determine url, the corresponding value will be an empty string
|
|
4
10
|
*
|
|
5
|
-
* @
|
|
11
|
+
* @todo string parameters are assumed to be URLs
|
|
12
|
+
*/
|
|
13
|
+
export declare function getResourceUrl(resource: unknown): string;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the URL associated with this resource.
|
|
16
|
+
* The returned value may include a query string and need further processing.
|
|
17
|
+
* If it cannot determine url, the corresponding value will be an empty string
|
|
6
18
|
*
|
|
7
19
|
* @todo string parameters are assumed to be URLs
|
|
8
20
|
*/
|
|
9
|
-
export declare function
|
|
10
|
-
url: string;
|
|
11
|
-
type: string;
|
|
12
|
-
};
|
|
21
|
+
export declare function getResourceMIMEType(resource: unknown): string;
|
|
13
22
|
/**
|
|
14
23
|
* Returns (approximate) content length for a resource if it can be determined.
|
|
15
24
|
* Returns -1 if content length cannot be determined.
|
|
@@ -17,5 +26,5 @@ export declare function getResourceUrlAndType(resource: any): {
|
|
|
17
26
|
|
|
18
27
|
* @note string parameters are NOT assumed to be URLs
|
|
19
28
|
*/
|
|
20
|
-
export declare function getResourceContentLength(resource:
|
|
29
|
+
export declare function getResourceContentLength(resource: unknown): number;
|
|
21
30
|
//# sourceMappingURL=resource-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/resource-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/resource-utils.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC;AAEhD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqBxD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqB7D;AAED;;;;;;IAMI;AACJ,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAoBlE"}
|
|
@@ -1,51 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getResourceContentLength = exports.
|
|
4
|
+
exports.getResourceContentLength = exports.getResourceMIMEType = exports.getResourceUrl = void 0;
|
|
4
5
|
const is_type_1 = require("../../javascript-utils/is-type");
|
|
5
6
|
const mime_type_utils_1 = require("./mime-type-utils");
|
|
6
|
-
const
|
|
7
|
+
const url_utils_1 = require("./url-utils");
|
|
7
8
|
/**
|
|
8
|
-
* Returns
|
|
9
|
-
*
|
|
9
|
+
* Returns the URL associated with this resource.
|
|
10
|
+
* The returned value may include a query string and need further processing.
|
|
11
|
+
* If it cannot determine url, the corresponding value will be an empty string
|
|
10
12
|
*
|
|
11
|
-
* @
|
|
13
|
+
* @todo string parameters are assumed to be URLs
|
|
14
|
+
*/
|
|
15
|
+
function getResourceUrl(resource) {
|
|
16
|
+
// If resource is a `Response`, it contains the information directly as a field
|
|
17
|
+
if ((0, is_type_1.isResponse)(resource)) {
|
|
18
|
+
const response = resource;
|
|
19
|
+
return response.url;
|
|
20
|
+
}
|
|
21
|
+
// If the resource is a Blob or a File (subclass of Blob)
|
|
22
|
+
if ((0, is_type_1.isBlob)(resource)) {
|
|
23
|
+
const blob = resource;
|
|
24
|
+
// File objects have a "name" property. Blob objects don't have any
|
|
25
|
+
// url (name) information
|
|
26
|
+
return blob.name || '';
|
|
27
|
+
}
|
|
28
|
+
if (typeof resource === 'string') {
|
|
29
|
+
return resource;
|
|
30
|
+
}
|
|
31
|
+
// Unknown
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
exports.getResourceUrl = getResourceUrl;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the URL associated with this resource.
|
|
37
|
+
* The returned value may include a query string and need further processing.
|
|
38
|
+
* If it cannot determine url, the corresponding value will be an empty string
|
|
12
39
|
*
|
|
13
40
|
* @todo string parameters are assumed to be URLs
|
|
14
41
|
*/
|
|
15
|
-
function
|
|
42
|
+
function getResourceMIMEType(resource) {
|
|
16
43
|
// If resource is a response, it contains the information directly
|
|
17
44
|
if ((0, is_type_1.isResponse)(resource)) {
|
|
18
|
-
const
|
|
19
|
-
const contentTypeHeader =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: (0, mime_type_utils_1.parseMIMEType)(contentTypeHeader) || (0, mime_type_utils_1.parseMIMETypeFromURL)(url)
|
|
23
|
-
};
|
|
45
|
+
const response = resource;
|
|
46
|
+
const contentTypeHeader = response.headers.get('content-type') || '';
|
|
47
|
+
const noQueryUrl = (0, url_utils_1.stripQueryString)(response.url);
|
|
48
|
+
return (0, mime_type_utils_1.parseMIMEType)(contentTypeHeader) || (0, mime_type_utils_1.parseMIMETypeFromURL)(noQueryUrl);
|
|
24
49
|
}
|
|
25
50
|
// If the resource is a Blob or a File (subclass of Blob)
|
|
26
51
|
if ((0, is_type_1.isBlob)(resource)) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// url (name) information
|
|
30
|
-
url: stripQueryString(resource.name || ''),
|
|
31
|
-
type: resource.type || ''
|
|
32
|
-
};
|
|
52
|
+
const blob = resource;
|
|
53
|
+
return blob.type || '';
|
|
33
54
|
}
|
|
34
55
|
if (typeof resource === 'string') {
|
|
35
|
-
return
|
|
36
|
-
// TODO this could mess up data URL but it doesn't matter as it is just used for inference
|
|
37
|
-
url: stripQueryString(resource),
|
|
38
|
-
// If a data url
|
|
39
|
-
type: (0, mime_type_utils_1.parseMIMETypeFromURL)(resource)
|
|
40
|
-
};
|
|
56
|
+
return (0, mime_type_utils_1.parseMIMETypeFromURL)(resource);
|
|
41
57
|
}
|
|
42
58
|
// Unknown
|
|
43
|
-
return
|
|
44
|
-
url: '',
|
|
45
|
-
type: ''
|
|
46
|
-
};
|
|
59
|
+
return '';
|
|
47
60
|
}
|
|
48
|
-
exports.
|
|
61
|
+
exports.getResourceMIMEType = getResourceMIMEType;
|
|
49
62
|
/**
|
|
50
63
|
* Returns (approximate) content length for a resource if it can be determined.
|
|
51
64
|
* Returns -1 if content length cannot be determined.
|
|
@@ -55,10 +68,12 @@ exports.getResourceUrlAndType = getResourceUrlAndType;
|
|
|
55
68
|
*/
|
|
56
69
|
function getResourceContentLength(resource) {
|
|
57
70
|
if ((0, is_type_1.isResponse)(resource)) {
|
|
58
|
-
|
|
71
|
+
const response = resource;
|
|
72
|
+
return response.headers['content-length'] || -1;
|
|
59
73
|
}
|
|
60
74
|
if ((0, is_type_1.isBlob)(resource)) {
|
|
61
|
-
|
|
75
|
+
const blob = resource;
|
|
76
|
+
return blob.size;
|
|
62
77
|
}
|
|
63
78
|
if (typeof resource === 'string') {
|
|
64
79
|
// TODO - handle data URL?
|
|
@@ -73,6 +88,3 @@ function getResourceContentLength(resource) {
|
|
|
73
88
|
return -1;
|
|
74
89
|
}
|
|
75
90
|
exports.getResourceContentLength = getResourceContentLength;
|
|
76
|
-
function stripQueryString(url) {
|
|
77
|
-
return url.replace(QUERY_STRING_PATTERN, '');
|
|
78
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/response-utils.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"response-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/response-utils.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuCnE;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAM1D"}
|
|
@@ -21,7 +21,8 @@ async function makeResponse(resource) {
|
|
|
21
21
|
}
|
|
22
22
|
// `new Response(File)` does not preserve content-type and URL
|
|
23
23
|
// so we add them here
|
|
24
|
-
const
|
|
24
|
+
const url = (0, resource_utils_1.getResourceUrl)(resource);
|
|
25
|
+
const type = (0, resource_utils_1.getResourceMIMEType)(resource);
|
|
25
26
|
if (type) {
|
|
26
27
|
headers['content-type'] = type;
|
|
27
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/url-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,GAAG,KAAA,GAAG,MAAM,CAG9C;AAED,wBAAgB,gBAAgB,CAAC,GAAG,KAAA,GAAG,MAAM,CAE5C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.stripQueryString = exports.extractQueryString = void 0;
|
|
5
|
+
const QUERY_STRING_PATTERN = /\?.*/;
|
|
6
|
+
function extractQueryString(url) {
|
|
7
|
+
const matches = url.match(QUERY_STRING_PATTERN);
|
|
8
|
+
return matches && matches[0];
|
|
9
|
+
}
|
|
10
|
+
exports.extractQueryString = extractQueryString;
|
|
11
|
+
function stripQueryString(url) {
|
|
12
|
+
return url.replace(QUERY_STRING_PATTERN, '');
|
|
13
|
+
}
|
|
14
|
+
exports.stripQueryString = stripQueryString;
|