@loaders.gl/core 4.3.1 → 4.4.0-alpha.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/dist.dev.js +18 -16
- package/dist/dist.min.js +3 -3
- package/dist/index.cjs +9 -8
- package/dist/index.cjs.map +2 -2
- package/dist/lib/api/create-data-source.d.ts +2 -5
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +6 -4
- package/dist/lib/api/encode-table.d.ts +1 -1
- package/dist/lib/api/encode-table.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 -2
- package/dist/lib/api/parse.js +2 -2
- package/dist/lib/init.js +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/package.json +6 -5
- package/src/lib/api/create-data-source.ts +16 -11
- package/src/lib/api/encode-table.ts +1 -1
- package/src/lib/api/parse-in-batches.ts +6 -4
- package/src/lib/api/parse.ts +2 -2
- package/src/lib/api/select-loader.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DataSource, Source } from '@loaders.gl/loader-utils';
|
|
1
|
+
import { Source, SourceArrayOptionsType, SourceArrayDataSourceType } from '@loaders.gl/loader-utils';
|
|
3
2
|
/**
|
|
4
3
|
* Creates a source from a service
|
|
5
4
|
* If type is not supplied, will try to automatically detect the the
|
|
@@ -7,7 +6,5 @@ import { DataSource, Source } from '@loaders.gl/loader-utils';
|
|
|
7
6
|
* @param type type of source. if not known, set to 'auto'
|
|
8
7
|
* @returns an DataSource instance
|
|
9
8
|
*/
|
|
10
|
-
export declare function createDataSource<
|
|
11
|
-
type?: string;
|
|
12
|
-
}): DataSourceT;
|
|
9
|
+
export declare function createDataSource<SourceArrayT extends Source[]>(data: string | Blob, sources: Readonly<SourceArrayT>, options: Readonly<SourceArrayOptionsType<SourceArrayT>>): SourceArrayDataSourceType<SourceArrayT>;
|
|
13
10
|
//# sourceMappingURL=create-data-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-data-source.d.ts","sourceRoot":"","sources":["../../../src/lib/api/create-data-source.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"create-data-source.d.ts","sourceRoot":"","sources":["../../../src/lib/api/create-data-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,sBAAsB,EAAE,yBAAyB,EAAC,MAAM,0BAA0B,CAAC;AAEnG;;;;;;GAMG;AAGH,wBAAgB,gBAAgB,CAAC,YAAY,SAAS,MAAM,EAAE,EAC5D,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC/B,OAAO,EAAE,QAAQ,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,GACtD,yBAAyB,CAAC,YAAY,CAAC,CAQzC"}
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
* @param type type of source. if not known, set to 'auto'
|
|
9
9
|
* @returns an DataSource instance
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// DataSourceOptionsT extends DataSourceOptions = DataSourceOptions,
|
|
12
|
+
// DataSourceT extends DataSource = DataSource
|
|
13
|
+
export function createDataSource(data, sources, options) {
|
|
14
|
+
const type = options?.core?.type || options.type || 'auto';
|
|
13
15
|
const source = type === 'auto' ? selectSource(data, sources) : getSourceOfType(type, sources);
|
|
14
16
|
if (!source) {
|
|
15
|
-
throw new Error('Not a valid
|
|
17
|
+
throw new Error('Not a valid source type');
|
|
16
18
|
}
|
|
17
|
-
return source.createDataSource(data,
|
|
19
|
+
return source.createDataSource(data, options);
|
|
18
20
|
}
|
|
19
21
|
// TODO - use selectSource...
|
|
20
22
|
/** Guess service type from URL */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WriterOptionsType, WriterWithEncoder } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { Table } from '@loaders.gl/schema';
|
|
2
|
+
import type { Table } from '@loaders.gl/schema';
|
|
3
3
|
export declare function encodeTable<WriterT extends WriterWithEncoder = WriterWithEncoder>(data: Table, writer: WriterT, options?: WriterOptionsType<WriterT>): Promise<ArrayBuffer>;
|
|
4
4
|
export declare function encodeTableAsText<WriterT extends WriterWithEncoder = WriterWithEncoder>(data: Table, writer: WriterT, options?: WriterOptionsType<WriterT>): Promise<string>;
|
|
5
5
|
export declare function encodeTableInBatches<WriterT extends WriterWithEncoder = WriterWithEncoder>(data: Table, writer: WriterT, options?: WriterOptionsType<WriterT>): AsyncIterable<ArrayBuffer>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-table.d.ts","sourceRoot":"","sources":["../../../src/lib/api/encode-table.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"encode-table.d.ts","sourceRoot":"","sources":["../../../src/lib/api/encode-table.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAE9C,wBAAsB,WAAW,CAAC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,EACrF,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACnC,OAAO,CAAC,WAAW,CAAC,CAwBtB;AAED,wBAAsB,iBAAiB,CAAC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,EAC3F,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACnC,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,EACxF,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACnC,aAAa,CAAC,WAAW,CAAC,CAQ5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-in-batches.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-in-batches.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-in-batches.d.ts","sourceRoot":"","sources":["../../../src/lib/api/parse-in-batches.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,MAAM,EAEN,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAYlC;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,SAAS,MAAM,EACtB,QAAQ,SAAS,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAE3D,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEpD;;GAEG;AACH,wBAAsB,cAAc,CAClC,YAAY,SAAS,MAAM,EAAE,EAC7B,QAAQ,SAAS,aAAa,GAAG,sBAAsB,CAAC,YAAY,CAAC,EAErE,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC;AAE/C;;;GAGG;AAEH,wBAAsB,cAAc,CAClC,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { isTable, makeBatchFromTable } from '@loaders.gl/schema';
|
|
4
|
+
import { isTable, makeBatchFromTable } from '@loaders.gl/schema-utils';
|
|
5
5
|
import { concatenateArrayBuffersAsync } from '@loaders.gl/loader-utils';
|
|
6
6
|
import { isLoaderObject } from "../loader-utils/normalize-loader.js";
|
|
7
7
|
import { normalizeOptions } from "../loader-utils/option-utils.js";
|
|
@@ -18,7 +18,9 @@ import { parse } from "./parse.js";
|
|
|
18
18
|
* @param options
|
|
19
19
|
* @param context
|
|
20
20
|
*/
|
|
21
|
-
export async function parseInBatches(data, loaders,
|
|
21
|
+
export async function parseInBatches(data, loaders, // LoaderOptions
|
|
22
|
+
options, // LoaderContext
|
|
23
|
+
context) {
|
|
22
24
|
const loaderArray = Array.isArray(loaders) ? loaders : undefined;
|
|
23
25
|
// Signature: parseInBatches(data, options, url) - Uses registered loaders
|
|
24
26
|
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
package/dist/lib/api/parse.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// loaders.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { parseWithWorker, canParseWithWorker,
|
|
4
|
+
import { parseWithWorker, canParseWithWorker, mergeOptions } from '@loaders.gl/loader-utils';
|
|
5
5
|
import { assert, validateWorkerVersion } from '@loaders.gl/worker-utils';
|
|
6
6
|
import { isLoaderObject } from "../loader-utils/normalize-loader.js";
|
|
7
7
|
import { isResponse } from "../../javascript-utils/is-type.js";
|
|
@@ -53,7 +53,7 @@ export async function parse(data, loaders, options, context) {
|
|
|
53
53
|
// TODO - should accept loader.parseAsyncIterator and concatenate.
|
|
54
54
|
async function parseWithLoader(loader, data, options, context) {
|
|
55
55
|
validateWorkerVersion(loader);
|
|
56
|
-
options =
|
|
56
|
+
options = mergeOptions(loader.options, options);
|
|
57
57
|
if (isResponse(data)) {
|
|
58
58
|
// Serialize to support passing the response to web worker
|
|
59
59
|
const response = data;
|
package/dist/lib/init.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { log } from '@loaders.gl/loader-utils';
|
|
5
5
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const version = typeof "4.
|
|
6
|
+
const version = typeof "4.4.0-alpha.0" !== 'undefined' ? "4.4.0-alpha.0" : '';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
if (!globalThis.loaders) {
|
|
9
9
|
log.log(1, `loaders.gl ${version}`)();
|
package/dist/null-loader.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
5
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
-
const VERSION = typeof "4.
|
|
6
|
+
const VERSION = typeof "4.4.0-alpha.0" !== 'undefined' ? "4.4.0-alpha.0" : 'latest';
|
|
7
7
|
/**
|
|
8
8
|
* Loads any data and returns null (or optionally passes through data unparsed)
|
|
9
9
|
*/
|
package/dist/null-worker-node.js
CHANGED
package/dist/null-worker.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0-alpha.1",
|
|
4
4
|
"description": "The core API for working with loaders.gl loaders and writers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -55,10 +55,11 @@
|
|
|
55
55
|
"build-worker-node": "esbuild src/workers/null-worker.ts --outfile=dist/null-worker-node.js --bundle --platform=node --target=node16 --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@loaders.gl/loader-utils": "4.
|
|
59
|
-
"@loaders.gl/schema": "4.
|
|
60
|
-
"@loaders.gl/
|
|
58
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.1",
|
|
59
|
+
"@loaders.gl/schema": "4.4.0-alpha.1",
|
|
60
|
+
"@loaders.gl/schema-utils": "4.4.0-alpha.1",
|
|
61
|
+
"@loaders.gl/worker-utils": "4.4.0-alpha.1",
|
|
61
62
|
"@probe.gl/log": "^4.0.2"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "f1732de45907bd500bf4eedb4803beca8bf4bfb0"
|
|
64
65
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import {DataSource, Source} from '@loaders.gl/loader-utils';
|
|
5
|
+
import {Source, SourceArrayOptionsType, SourceArrayDataSourceType} from '@loaders.gl/loader-utils';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Creates a source from a service
|
|
@@ -12,23 +11,29 @@ import {DataSource, Source} from '@loaders.gl/loader-utils';
|
|
|
12
11
|
* @param type type of source. if not known, set to 'auto'
|
|
13
12
|
* @returns an DataSource instance
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
// DataSourceOptionsT extends DataSourceOptions = DataSourceOptions,
|
|
15
|
+
// DataSourceT extends DataSource = DataSource
|
|
16
|
+
export function createDataSource<SourceArrayT extends Source[]>(
|
|
17
|
+
data: string | Blob,
|
|
18
|
+
sources: Readonly<SourceArrayT>,
|
|
19
|
+
options: Readonly<SourceArrayOptionsType<SourceArrayT>>
|
|
20
|
+
): SourceArrayDataSourceType<SourceArrayT> {
|
|
21
|
+
const type = options?.core?.type || (options.type as unknown as string) || 'auto';
|
|
20
22
|
const source = type === 'auto' ? selectSource(data, sources) : getSourceOfType(type, sources);
|
|
21
23
|
|
|
22
24
|
if (!source) {
|
|
23
|
-
throw new Error('Not a valid
|
|
25
|
+
throw new Error('Not a valid source type');
|
|
24
26
|
}
|
|
25
|
-
return source.createDataSource(data,
|
|
27
|
+
return source.createDataSource(data, options);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
// TODO - use selectSource...
|
|
29
31
|
|
|
30
32
|
/** Guess service type from URL */
|
|
31
|
-
function selectSource
|
|
33
|
+
function selectSource<SourceArrayT extends Source[]>(
|
|
34
|
+
url: string | Blob,
|
|
35
|
+
sources: Readonly<SourceArrayT>
|
|
36
|
+
): SourceArrayT[number] | null {
|
|
32
37
|
for (const service of sources) {
|
|
33
38
|
// @ts-expect-error
|
|
34
39
|
if (service.testURL && service.testURL(url)) {
|
|
@@ -40,7 +45,7 @@ function selectSource(url: string | Blob, sources: Source[]): Source | null {
|
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
/** Guess service type from URL */
|
|
43
|
-
function getSourceOfType(type: string, sources: Source[]): Source | null {
|
|
48
|
+
function getSourceOfType(type: string, sources: Readonly<Source[]>): Source | null {
|
|
44
49
|
for (const service of sources) {
|
|
45
50
|
if (service.type === type) {
|
|
46
51
|
return service;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
WriterOptionsType,
|
|
10
10
|
WriterWithEncoder
|
|
11
11
|
} from '@loaders.gl/loader-utils';
|
|
12
|
-
import {Table} from '@loaders.gl/schema';
|
|
12
|
+
import type {Table} from '@loaders.gl/schema';
|
|
13
13
|
|
|
14
14
|
export async function encodeTable<WriterT extends WriterWithEncoder = WriterWithEncoder>(
|
|
15
15
|
data: Table,
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type {Batch} from '@loaders.gl/schema';
|
|
6
|
+
import {isTable, makeBatchFromTable} from '@loaders.gl/schema-utils';
|
|
6
7
|
import type {
|
|
7
8
|
Loader,
|
|
8
9
|
LoaderWithParser,
|
|
@@ -55,6 +56,7 @@ export async function parseInBatches<
|
|
|
55
56
|
* Parses `data` in batches by selecting a pre-registered loader
|
|
56
57
|
* @deprecated Loader registration is deprecated, use parseInBatches(data, loaders, options) instead
|
|
57
58
|
*/
|
|
59
|
+
// @ts-expect-error
|
|
58
60
|
export async function parseInBatches(
|
|
59
61
|
data: BatchableDataType,
|
|
60
62
|
options?: LoaderOptions
|
|
@@ -69,8 +71,8 @@ export async function parseInBatches(
|
|
|
69
71
|
*/
|
|
70
72
|
export async function parseInBatches(
|
|
71
73
|
data: BatchableDataType,
|
|
72
|
-
loaders?: Loader | Loader[]
|
|
73
|
-
options?: LoaderOptions,
|
|
74
|
+
loaders?: Loader | Loader[], // LoaderOptions
|
|
75
|
+
options?: LoaderOptions, // LoaderContext
|
|
74
76
|
context?: LoaderContext
|
|
75
77
|
): Promise<AsyncIterable<unknown> | Iterable<unknown>> {
|
|
76
78
|
const loaderArray = Array.isArray(loaders) ? loaders : undefined;
|
|
@@ -90,7 +92,7 @@ export async function parseInBatches(
|
|
|
90
92
|
|
|
91
93
|
// Chooses a loader and normalizes it
|
|
92
94
|
// Note - only uses URL and contentType for streams and iterator inputs
|
|
93
|
-
const loader = await selectLoader(data as ArrayBuffer, loaders
|
|
95
|
+
const loader = await selectLoader(data as ArrayBuffer, loaders, options);
|
|
94
96
|
// Note: if options.nothrow was set, it is possible that no loader was found, if so just return null
|
|
95
97
|
if (!loader) {
|
|
96
98
|
return [];
|
package/src/lib/api/parse.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
LoaderArrayOptionsType,
|
|
14
14
|
LoaderArrayReturnType
|
|
15
15
|
} from '@loaders.gl/loader-utils';
|
|
16
|
-
import {parseWithWorker, canParseWithWorker,
|
|
16
|
+
import {parseWithWorker, canParseWithWorker, mergeOptions} from '@loaders.gl/loader-utils';
|
|
17
17
|
import {assert, validateWorkerVersion} from '@loaders.gl/worker-utils';
|
|
18
18
|
import {isLoaderObject} from '../loader-utils/normalize-loader';
|
|
19
19
|
import {isResponse} from '../../javascript-utils/is-type';
|
|
@@ -124,7 +124,7 @@ async function parseWithLoader(
|
|
|
124
124
|
): Promise<unknown> {
|
|
125
125
|
validateWorkerVersion(loader);
|
|
126
126
|
|
|
127
|
-
options =
|
|
127
|
+
options = mergeOptions(loader.options, options);
|
|
128
128
|
|
|
129
129
|
if (isResponse(data)) {
|
|
130
130
|
// Serialize to support passing the response to web worker
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import type {LoaderContext, LoaderOptions, Loader} from '@loaders.gl/loader-utils';
|
|
6
6
|
import {compareArrayBuffers, path, log} from '@loaders.gl/loader-utils';
|
|
7
|
+
import {TypedArray} from '@loaders.gl/schema';
|
|
7
8
|
import {normalizeLoader} from '../loader-utils/normalize-loader';
|
|
8
9
|
import {getResourceUrl, getResourceMIMEType} from '../utils/resource-utils';
|
|
9
10
|
import {compareMIMETypes} from '../utils/mime-type-utils';
|
|
10
11
|
import {getRegisteredLoaders} from './register-loaders';
|
|
11
12
|
import {isBlob} from '../../javascript-utils/is-type';
|
|
12
13
|
import {stripQueryString} from '../utils/url-utils';
|
|
13
|
-
import {TypedArray} from '@loaders.gl/schema';
|
|
14
14
|
|
|
15
15
|
const EXT_PATTERN = /\.([^.]+)$/;
|
|
16
16
|
|