@loaders.gl/core 5.0.0 → 5.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/api.cjs +4129 -0
- package/dist/api.cjs.map +6 -0
- package/dist/api.d.ts +34 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +50 -0
- package/dist/api.js.map +1 -0
- package/dist/arrow-geometry/index.cjs +5 -2
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +1 -0
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +1 -0
- package/dist/arrow-geometry/index.js.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.cjs +100 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.cjs.map +7 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.d.ts +15 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.d.ts.map +1 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.js +87 -0
- package/dist/arrow-geometry/triangulate-wkb-geometry-column.js.map +1 -0
- package/dist/dist.dev.js +458 -539
- package/dist/dist.min.js +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/index.cjs +1 -1
- package/dist/geoarrow/index.cjs.map +1 -1
- package/dist/geoarrow/index.d.ts +2 -2
- package/dist/geoarrow/index.d.ts.map +1 -1
- package/dist/geoarrow/index.js +1 -1
- package/dist/geoarrow/index.js.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js.map +1 -1
- package/dist/index.cjs +67 -4114
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -33
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -46
- package/dist/index.js.map +1 -1
- package/dist/lib/api/encode-table.d.ts +4 -4
- package/dist/lib/api/encode-table.d.ts.map +1 -1
- package/dist/lib/api/encode-table.js +21 -3
- package/dist/lib/api/encode-table.js.map +1 -1
- package/dist/lib/api/encode.d.ts +6 -6
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +46 -7
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +67 -24
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader-metadata.cjs +85 -0
- package/dist/loader-utils/json-loader-metadata.cjs.map +6 -0
- package/dist/loader-utils/json-loader-metadata.d.ts +51 -0
- package/dist/loader-utils/json-loader-metadata.d.ts.map +1 -0
- package/dist/loader-utils/json-loader-metadata.js +31 -0
- package/dist/loader-utils/json-loader-metadata.js.map +1 -0
- package/dist/loader-utils/json-loader.cjs +80 -0
- package/dist/loader-utils/json-loader.cjs.map +6 -0
- package/dist/loader-utils/json-loader.d.ts +4 -4
- package/dist/loader-utils/json-loader.d.ts.map +1 -1
- package/dist/loader-utils/json-loader.js +3 -17
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/request-utils/authentication.d.ts +2 -0
- package/dist/loader-utils/lib/request-utils/authentication.d.ts.map +1 -1
- package/dist/loader-utils/lib/request-utils/authentication.js +12 -0
- package/dist/loader-utils/lib/request-utils/authentication.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/raster-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/raster-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.d.ts +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.d.ts.map +1 -1
- package/dist/loader-utils/tile-grid.d.ts +2 -1
- package/dist/loader-utils/tile-grid.d.ts.map +1 -1
- package/dist/loader-utils/tile-grid.js +1 -1
- package/dist/loader-utils/tile-grid.js.map +1 -1
- package/dist/loader-utils/writer-types.d.ts +2 -0
- package/dist/loader-utils/writer-types.d.ts.map +1 -1
- package/dist/null-loader-metadata.cjs +89 -0
- package/dist/null-loader-metadata.cjs.map +6 -0
- package/dist/null-loader-metadata.d.ts +48 -0
- package/dist/null-loader-metadata.d.ts.map +1 -0
- package/dist/null-loader-metadata.js +30 -0
- package/dist/null-loader-metadata.js.map +1 -0
- package/dist/null-loader.cjs +84 -0
- package/dist/null-loader.cjs.map +6 -0
- package/dist/null-loader.d.ts +6 -6
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +2 -15
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +58 -28
- package/dist/null-worker.js +58 -28
- package/dist/scan/arrow-execution/expressions.d.ts +1 -1
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/index.cjs +16 -4
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +5 -2
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +4 -2
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/plan-arrow-table-query.d.ts +1 -1
- package/dist/scan/plan-arrow-table-query.d.ts.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.cjs +7 -19
- package/dist/scan/query-arrow-table-in-batches.cjs.map +2 -2
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.js +7 -22
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -1
- package/dist/scan/query-executor.cjs +202 -0
- package/dist/scan/query-executor.cjs.map +7 -0
- package/dist/scan/query-executor.d.ts +27 -0
- package/dist/scan/query-executor.d.ts.map +1 -0
- package/dist/scan/query-executor.js +203 -0
- package/dist/scan/query-executor.js.map +1 -0
- package/dist/scan/query.cjs +92 -205
- package/dist/scan/query.cjs.map +3 -3
- package/dist/scan/query.d.ts +5 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +94 -238
- package/dist/scan/query.js.map +1 -1
- package/dist/schema-utils/index.cjs +182 -0
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +3 -0
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +3 -0
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-converter.d.ts +24 -0
- package/dist/schema-utils/lib/arrow/arrow-converter.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-converter.js +43 -0
- package/dist/schema-utils/lib/arrow/arrow-converter.js.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.d.ts +29 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.js +89 -0
- package/dist/schema-utils/lib/arrow/convert-arrow-variable-width.js.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.d.ts +17 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.js +24 -0
- package/dist/schema-utils/lib/arrow/convert-arrow.js.map +1 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.d.ts +4 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.js +51 -0
- package/dist/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.js.map +1 -0
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/package.json +49 -23
- package/src/api.ts +99 -0
- package/src/arrow-geometry/index.ts +5 -0
- package/src/arrow-geometry/triangulate-wkb-geometry-column.ts +122 -0
- package/src/geoarrow/index.ts +2 -2
- package/src/geoarrow/lib/kernels/decode-wkt-native.ts +1 -1
- package/src/index.ts +2 -94
- package/src/lib/api/encode-table.ts +31 -6
- package/src/lib/api/encode.ts +61 -11
- package/src/loader-utils/index.ts +1 -0
- package/src/loader-utils/json-loader-metadata.ts +35 -0
- package/src/loader-utils/json-loader.ts +3 -18
- package/src/loader-utils/lib/request-utils/authentication.ts +17 -0
- package/src/loader-utils/lib/sources/raster-source.ts +4 -0
- package/src/loader-utils/tile-grid.ts +16 -1
- package/src/loader-utils/writer-types.ts +2 -0
- package/src/null-loader-metadata.ts +32 -0
- package/src/null-loader.ts +2 -17
- package/src/scan/index.ts +22 -2
- package/src/scan/query-arrow-table-in-batches.ts +7 -24
- package/src/scan/query-executor.ts +286 -0
- package/src/scan/query.ts +112 -299
- package/src/schema-utils/index.ts +14 -0
- package/src/schema-utils/lib/arrow/arrow-converter.ts +74 -0
- package/src/schema-utils/lib/arrow/convert-arrow-variable-width.ts +121 -0
- package/src/schema-utils/lib/arrow/convert-arrow.ts +52 -0
- package/src/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.ts +83 -0
- package/dist/cluster-source.cjs +0 -6360
- package/dist/cluster-source.cjs.map +0 -6
- package/dist/cluster-source.d.ts +0 -2
- package/dist/cluster-source.d.ts.map +0 -1
- package/dist/cluster-source.js +0 -2
- package/dist/cluster-source.js.map +0 -1
- package/dist/federated-table-scan-source.cjs +0 -1905
- package/dist/federated-table-scan-source.cjs.map +0 -6
- package/dist/federated-table-scan-source.d.ts +0 -2
- package/dist/federated-table-scan-source.d.ts.map +0 -1
- package/dist/federated-table-scan-source.js +0 -2
- package/dist/federated-table-scan-source.js.map +0 -1
- package/dist/geoarrow/geoarrow-builder.cjs +0 -31
- package/dist/geoarrow/geoarrow-builder.cjs.map +0 -7
- package/dist/geoarrow/geoarrow-builder.d.ts +0 -3
- package/dist/geoarrow/geoarrow-builder.d.ts.map +0 -1
- package/dist/geoarrow/geoarrow-builder.js +0 -5
- package/dist/geoarrow/geoarrow-builder.js.map +0 -1
- package/dist/vector-table-scan-source.cjs +0 -1200
- package/dist/vector-table-scan-source.cjs.map +0 -6
- package/dist/vector-table-scan-source.d.ts +0 -2
- package/dist/vector-table-scan-source.d.ts.map +0 -1
- package/dist/vector-table-scan-source.js +0 -2
- package/dist/vector-table-scan-source.js.map +0 -1
- package/src/cluster-source.ts +0 -1
- package/src/federated-table-scan-source.ts +0 -1
- package/src/geoarrow/geoarrow-builder.ts +0 -21
- package/src/vector-table-scan-source.ts +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { convertArrow, isApacheArrowTable } from "./convert-arrow.js";
|
|
5
|
+
const convertArrowUnchecked = convertArrow;
|
|
6
|
+
/**
|
|
7
|
+
* Leaf converter for Apache Arrow table interop.
|
|
8
|
+
*/
|
|
9
|
+
export const ArrowConverter = {
|
|
10
|
+
id: 'arrow',
|
|
11
|
+
from: ['arrow', 'object-row-table', 'array-row-table', 'columnar-table', 'geojson-table'],
|
|
12
|
+
to: ['arrow', 'object-row-table', 'array-row-table', 'columnar-table', 'geojson-table'],
|
|
13
|
+
canConvert(sourceShape, targetShape) {
|
|
14
|
+
const sourceIsArrow = sourceShape === 'arrow';
|
|
15
|
+
const targetIsArrow = targetShape === 'arrow';
|
|
16
|
+
return sourceIsArrow !== targetIsArrow;
|
|
17
|
+
},
|
|
18
|
+
detectInputShape(input) {
|
|
19
|
+
return isApacheArrowTable(input) ? 'arrow' : null;
|
|
20
|
+
},
|
|
21
|
+
convert(input, targetShape, options) {
|
|
22
|
+
switch (targetShape) {
|
|
23
|
+
case 'arrow':
|
|
24
|
+
return convertArrowUnchecked(input, 'arrow', options);
|
|
25
|
+
case 'object-row-table':
|
|
26
|
+
return convertArrowUnchecked(input, 'object-row-table', options);
|
|
27
|
+
case 'array-row-table':
|
|
28
|
+
return convertArrowUnchecked(input, 'array-row-table', options);
|
|
29
|
+
case 'columnar-table':
|
|
30
|
+
return convertArrowUnchecked(input, 'columnar-table', options);
|
|
31
|
+
case 'geojson-table':
|
|
32
|
+
return convertArrowUnchecked(input, 'geojson-table', options);
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Unsupported Arrow conversion target: ${targetShape}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Opt-in converter bundle for Apache Arrow conversions.
|
|
40
|
+
*/
|
|
41
|
+
export const ARROW_CONVERTERS = [ArrowConverter];
|
|
42
|
+
export { convertArrow };
|
|
43
|
+
//# sourceMappingURL=arrow-converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrow-converter.js","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/arrow-converter.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,YAAY,EAAE,kBAAkB,EAAC,2BAAwB;AAEjE,MAAM,qBAAqB,GAAG,YASlB,CAAC;AAgBb;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAGvB;IACF,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,CAAC;IACzF,EAAE,EAAE,C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ema/convert-arrow-schema.js";
|
|
3
|
+
/** Options controlling conversion between standard and view-based Arrow variable-width types. */
|
|
4
|
+
export type ConvertArrowVariableWidthOptions = ArrowSchemaConversionOptions;
|
|
5
|
+
/**
|
|
6
|
+
* Converts an Arrow Utf8, Utf8View, Binary, or BinaryView vector to the requested storage layout.
|
|
7
|
+
*
|
|
8
|
+
* `viewTypes: 'never'` produces Utf8 or Binary. `viewTypes: 'prefer'` produces the corresponding
|
|
9
|
+
* view type when the installed Arrow runtime supports it and otherwise produces the standard
|
|
10
|
+
* type. `viewTypes: 'require'` produces a view type or throws when the runtime lacks support.
|
|
11
|
+
* Existing vectors already using the selected type are returned without copying.
|
|
12
|
+
*
|
|
13
|
+
* @param vector - Arrow variable-width vector to convert.
|
|
14
|
+
* @param options - Target variable-width storage layout.
|
|
15
|
+
* @returns The original vector or a converted vector with the same values and chunk boundaries.
|
|
16
|
+
*/
|
|
17
|
+
export declare function convertArrowVariableWidthVector(vector: arrow.Vector, options?: ConvertArrowVariableWidthOptions): arrow.Vector;
|
|
18
|
+
/**
|
|
19
|
+
* Converts every top-level Utf8, Utf8View, Binary, and BinaryView column in an Arrow table.
|
|
20
|
+
*
|
|
21
|
+
* Non-variable-width columns are preserved without copying. Table schema metadata, field metadata,
|
|
22
|
+
* nullability, row values, and source chunk boundaries are retained.
|
|
23
|
+
*
|
|
24
|
+
* @param table - Arrow table whose top-level variable-width columns should be converted.
|
|
25
|
+
* @param options - Target variable-width storage layout.
|
|
26
|
+
* @returns The original table when no column changes, otherwise a table with converted columns.
|
|
27
|
+
*/
|
|
28
|
+
export declare function convertArrowTableVariableWidthTypes(table: arrow.Table, options?: ConvertArrowVariableWidthOptions): arrow.Table;
|
|
29
|
+
//# sourceMappingURL=convert-arrow-variable-width.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-arrow-variable-width.d.ts","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/convert-arrow-variable-width.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAGL,KAAK,4BAA4B,EAClC,0CAAuC;AAExC,iGAAiG;AACjG,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,CAAC;AAI5E;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,OAAO,GAAE,gCAAqC,GAC7C,KAAK,CAAC,MAAM,CAed;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,GAAE,gCAAqC,GAC7C,KAAK,CAAC,KAAK,CA6Bb"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import * as arrow from 'apache-arrow';
|
|
5
|
+
import { deserializeArrowType, serializeArrowType } from "../schema/convert-arrow-schema.js";
|
|
6
|
+
/**
|
|
7
|
+
* Converts an Arrow Utf8, Utf8View, Binary, or BinaryView vector to the requested storage layout.
|
|
8
|
+
*
|
|
9
|
+
* `viewTypes: 'never'` produces Utf8 or Binary. `viewTypes: 'prefer'` produces the corresponding
|
|
10
|
+
* view type when the installed Arrow runtime supports it and otherwise produces the standard
|
|
11
|
+
* type. `viewTypes: 'require'` produces a view type or throws when the runtime lacks support.
|
|
12
|
+
* Existing vectors already using the selected type are returned without copying.
|
|
13
|
+
*
|
|
14
|
+
* @param vector - Arrow variable-width vector to convert.
|
|
15
|
+
* @param options - Target variable-width storage layout.
|
|
16
|
+
* @returns The original vector or a converted vector with the same values and chunk boundaries.
|
|
17
|
+
*/
|
|
18
|
+
export function convertArrowVariableWidthVector(vector, options = {}) {
|
|
19
|
+
const sourceTypeName = getArrowVariableWidthTypeName(vector.type);
|
|
20
|
+
const targetTypeName = getTargetArrowVariableWidthTypeName(sourceTypeName);
|
|
21
|
+
const targetType = deserializeArrowType(targetTypeName, options);
|
|
22
|
+
if (vector.type.typeId === targetType.typeId) {
|
|
23
|
+
return vector;
|
|
24
|
+
}
|
|
25
|
+
const convertedData = vector.data.flatMap(data => {
|
|
26
|
+
const chunk = new arrow.Vector([data]);
|
|
27
|
+
return arrow.vectorFromArray(Array.from(chunk), targetType).data;
|
|
28
|
+
});
|
|
29
|
+
return new arrow.Vector(convertedData);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts every top-level Utf8, Utf8View, Binary, and BinaryView column in an Arrow table.
|
|
33
|
+
*
|
|
34
|
+
* Non-variable-width columns are preserved without copying. Table schema metadata, field metadata,
|
|
35
|
+
* nullability, row values, and source chunk boundaries are retained.
|
|
36
|
+
*
|
|
37
|
+
* @param table - Arrow table whose top-level variable-width columns should be converted.
|
|
38
|
+
* @param options - Target variable-width storage layout.
|
|
39
|
+
* @returns The original table when no column changes, otherwise a table with converted columns.
|
|
40
|
+
*/
|
|
41
|
+
export function convertArrowTableVariableWidthTypes(table, options = {}) {
|
|
42
|
+
const columns = {};
|
|
43
|
+
const fields = [];
|
|
44
|
+
let changed = false;
|
|
45
|
+
for (const field of table.schema.fields) {
|
|
46
|
+
const column = table.getChild(field.name);
|
|
47
|
+
if (!column) {
|
|
48
|
+
throw new Error(`Missing Arrow column for ${field.name}`);
|
|
49
|
+
}
|
|
50
|
+
const convertedColumn = isArrowVariableWidthType(field.type)
|
|
51
|
+
? convertArrowVariableWidthVector(column, options)
|
|
52
|
+
: column;
|
|
53
|
+
changed ||= convertedColumn !== column;
|
|
54
|
+
columns[field.name] = convertedColumn;
|
|
55
|
+
fields.push(convertedColumn === column
|
|
56
|
+
? field
|
|
57
|
+
: new arrow.Field(field.name, convertedColumn.type, field.nullable, field.metadata));
|
|
58
|
+
}
|
|
59
|
+
if (!changed) {
|
|
60
|
+
return table;
|
|
61
|
+
}
|
|
62
|
+
const schema = new arrow.Schema(fields, table.schema.metadata);
|
|
63
|
+
return new arrow.Table(schema, columns);
|
|
64
|
+
}
|
|
65
|
+
function isArrowVariableWidthType(type) {
|
|
66
|
+
try {
|
|
67
|
+
getArrowVariableWidthTypeName(type);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function getArrowVariableWidthTypeName(type) {
|
|
75
|
+
const typeName = serializeArrowType(type);
|
|
76
|
+
switch (typeName) {
|
|
77
|
+
case 'binary':
|
|
78
|
+
case 'binary-view':
|
|
79
|
+
case 'utf8':
|
|
80
|
+
case 'utf8-view':
|
|
81
|
+
return typeName;
|
|
82
|
+
default:
|
|
83
|
+
throw new Error(`Expected an Arrow Utf8, Utf8View, Binary, or BinaryView vector, received ${type}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getTargetArrowVariableWidthTypeName(sourceTypeName) {
|
|
87
|
+
return sourceTypeName === 'binary' || sourceTypeName === 'binary-view' ? 'binary' : 'utf8';
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=convert-arrow-variable-width.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-arrow-variable-width.js","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/convert-arrow-variable-width.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAEnB,0CAAuC;AAOxC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,+BAA+B,CAC7C,MAAoB,EACpB,UAA4C,EAAE;IAE9C,MAAM,cAAc,GAAG,6BAA6B,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClE,MAAM,cAAc,GAAG,mCAAmC,CAAC,cAAc,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,oBAAoB,CAAC,cAAc,E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|
2
|
+
import type { Table, ArrayRowTable, ObjectRowTable, ColumnarTable, GeoJSONTable } from '@loaders.gl/core/schema';
|
|
3
|
+
import type { ArrowConvertFromOptions } from "./arrow-converter.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts between Apache Arrow tables and loaders.gl table shapes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function convertArrow(input: arrow.Table, shape: 'arrow'): arrow.Table;
|
|
8
|
+
export declare function convertArrow(input: arrow.Table, shape: 'array-row-table'): ArrayRowTable;
|
|
9
|
+
export declare function convertArrow(input: arrow.Table, shape: 'object-row-table'): ObjectRowTable;
|
|
10
|
+
export declare function convertArrow(input: arrow.Table, shape: 'columnar-table'): ColumnarTable;
|
|
11
|
+
export declare function convertArrow(input: arrow.Table, shape: 'geojson-table'): GeoJSONTable;
|
|
12
|
+
export declare function convertArrow(input: Table, shape: 'arrow', options?: ArrowConvertFromOptions): arrow.Table;
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether a value is an Apache Arrow table instance rather than a loaders.gl table wrapper.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isApacheArrowTable(input: arrow.Table | Table): input is arrow.Table;
|
|
17
|
+
//# sourceMappingURL=convert-arrow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-arrow.d.ts","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/convert-arrow.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACb,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAC,uBAAuB,EAAwB,6BAA0B;AAEtF;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;AAC9E,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,iBAAiB,GAAG,aAAa,CAAC;AAC1F,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,kBAAkB,GAAG,cAAc,CAAC;AAC5F,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,gBAAgB,GAAG,aAAa,CAAC;AACzF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,GAAG,YAAY,CAAC;AACvF,wBAAgB,YAAY,CAC1B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,uBAAuB,GAChC,KAAK,CAAC,KAAK,CAAC;AAkBf;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK,CAEnF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { convertArrowToTable, convertTableToArrow } from "../../deprecated.js";
|
|
5
|
+
import { isArrowTable } from "../../../lib/loader-utils/native-arrow.js";
|
|
6
|
+
export function convertArrow(input, shape, options) {
|
|
7
|
+
if (isApacheArrowTable(input)) {
|
|
8
|
+
if (shape === 'arrow') {
|
|
9
|
+
return input;
|
|
10
|
+
}
|
|
11
|
+
return convertArrowToTable(input, shape);
|
|
12
|
+
}
|
|
13
|
+
if (shape !== 'arrow') {
|
|
14
|
+
throw new Error(`Unsupported Arrow conversion target: ${shape}`);
|
|
15
|
+
}
|
|
16
|
+
return convertTableToArrow(input, options);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checks whether a value is an Apache Arrow table instance rather than a loaders.gl table wrapper.
|
|
20
|
+
*/
|
|
21
|
+
export function isApacheArrowTable(input) {
|
|
22
|
+
return isArrowTable(input);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=convert-arrow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-arrow.js","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/convert-arrow.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAUpC,OAAO,EAAC,mBAAmB,EAAE,mBAAmB,EAAC,4BAAyB;AAC1E,OAAO,EAAC,YAAY,EAAC,kDAA+C;AAgBpE,MAAM,UAAU,YAAY,CAC1B,KAA0B,EAC1B,KAA4F,EAC5F,OAAyD;IAEzD,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,wCAAwC,KAAK,EAAE,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,mBAAmB,CAAC,KAAK,EAAE,OAA8C,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA0B;IAC3D,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
|
+
/** Updates nullable Arrow table fields to non-nullable when their columns contain no null values. */
|
|
3
|
+
export declare function tightenArrowTableSchemaNullability(table: arrow.Table): arrow.Table;
|
|
4
|
+
//# sourceMappingURL=tighten-arrow-table-schema-nullability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tighten-arrow-table-schema-nullability.d.ts","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,qGAAqG;AACrG,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAelF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import * as arrow from 'apache-arrow';
|
|
5
|
+
/** Updates nullable Arrow table fields to non-nullable when their columns contain no null values. */
|
|
6
|
+
export function tightenArrowTableSchemaNullability(table) {
|
|
7
|
+
const fieldNullability = getTightenedArrowFieldNullability(table);
|
|
8
|
+
if (!doesSchemaHaveTightenedFieldNullability(table.schema, fieldNullability)) {
|
|
9
|
+
return table;
|
|
10
|
+
}
|
|
11
|
+
const schema = tightenApacheArrowSchemaNullability(table.schema, fieldNullability);
|
|
12
|
+
const batches = table.batches.map(batch => new arrow.RecordBatch(tightenApacheArrowSchemaNullability(batch.schema, fieldNullability), batch.data, new Map(batch.metadata)));
|
|
13
|
+
return new arrow.Table(schema, batches);
|
|
14
|
+
}
|
|
15
|
+
/** Returns true when a nullable field can be marked as non-nullable. */
|
|
16
|
+
function doesSchemaHaveTightenedFieldNullability(arrowSchema, fieldNullability) {
|
|
17
|
+
return arrowSchema.fields.some((field, fieldIndex) => field.nullable && !fieldNullability[fieldIndex]);
|
|
18
|
+
}
|
|
19
|
+
/** Returns field nullability after checking nullable columns for actual null values. */
|
|
20
|
+
function getTightenedArrowFieldNullability(arrowTable) {
|
|
21
|
+
return arrowTable.schema.fields.map((field, fieldIndex) => {
|
|
22
|
+
if (!field.nullable) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const column = arrowTable.getChildAt(fieldIndex);
|
|
26
|
+
return column ? doesArrowColumnHaveNulls(column) : true;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Returns true when an Arrow vector contains at least one null value. */
|
|
30
|
+
function doesArrowColumnHaveNulls(column) {
|
|
31
|
+
if (column.nullCount === 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (column.nullCount > 0) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {
|
|
38
|
+
if (!column.isValid(rowIndex)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
/** Returns an Apache Arrow schema with matching fields marked non-nullable. */
|
|
45
|
+
function tightenApacheArrowSchemaNullability(arrowSchema, fieldNullability) {
|
|
46
|
+
const fields = arrowSchema.fields.map((field, fieldIndex) => field.nullable === fieldNullability[fieldIndex]
|
|
47
|
+
? field
|
|
48
|
+
: field.clone({ nullable: fieldNullability[fieldIndex] }));
|
|
49
|
+
return new arrow.Schema(fields, new Map(arrowSchema.metadata), new Map(arrowSchema.dictionaries), arrowSchema.metadataVersion);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=tighten-arrow-table-schema-nullability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tighten-arrow-table-schema-nullability.js","sourceRoot":"","sources":["../../../../src/schema-utils/lib/arrow/tighten-arrow-table-schema-nullability.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,qGAAqG;AACrG,MAAM,UAAU,kCAAkC,CAAC,KAAkB;IACnE,MAAM,gBAAgB,GAAG,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAClE,IAAI,CAAC,uCAAuC,CAAC,KAAK,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,CAAC;QAC7E,OAAO,KAAK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CAAC;IAED,IAAI,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+EAA+E;AAC/E,SAAS,mCAAmC,CAC1C,WAAyB,EACzB,gBAA2B;IAE3B,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAC1D,KAAK,CAAC,QAAQ,KAAK,gBAAgB,CAAC,UAAU,CAAC;QAC7C,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,EAAC,CAAC,CAC1D,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,MAAM,CACrB,MAAM,EACN,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,EAC7B,IAAI,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,EACjC,WAAW,CAAC,eAAe,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -86,7 +86,7 @@ var NPM_TAG = "latest";
|
|
|
86
86
|
|
|
87
87
|
// dist/worker-utils/lib/env-utils/version.js
|
|
88
88
|
function getVersion() {
|
|
89
|
-
const version2 = false ? NPM_TAG : "5.0.
|
|
89
|
+
const version2 = false ? NPM_TAG : "5.0.1";
|
|
90
90
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
91
91
|
globalThis._loadersgl_.version ||= version2;
|
|
92
92
|
return version2;
|
|
@@ -125,7 +125,7 @@ var import_tasks2 = require("@math.gl/tasks");
|
|
|
125
125
|
|
|
126
126
|
// dist/loader-utils/lib/log-utils/log.js
|
|
127
127
|
var import_log = require("probe.gl/log");
|
|
128
|
-
var VERSION2 = true ? "5.0.
|
|
128
|
+
var VERSION2 = true ? "5.0.1" : "latest";
|
|
129
129
|
var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
130
130
|
function createLog() {
|
|
131
131
|
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { NPM_TAG } from "../npm-tag.js";
|
|
5
5
|
/** Return this package's injected version, independent of other loaded versions. */
|
|
6
6
|
function getVersion() {
|
|
7
|
-
const version = typeof "5.0.
|
|
7
|
+
const version = typeof "5.0.1" === 'undefined' ? NPM_TAG : "5.0.1";
|
|
8
8
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
9
9
|
globalThis._loadersgl_.version ||= version;
|
|
10
10
|
return version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Core loading and writing APIs, workers, schemas, and geometry utilities for loaders.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"import": "./dist/index.js",
|
|
40
40
|
"require": "./dist/index.cjs"
|
|
41
41
|
},
|
|
42
|
+
"./api": {
|
|
43
|
+
"types": "./dist/api.d.ts",
|
|
44
|
+
"import": "./dist/api.js",
|
|
45
|
+
"require": "./dist/api.cjs"
|
|
46
|
+
},
|
|
42
47
|
"./loader-utils/tile-grid": {
|
|
43
48
|
"types": "./dist/loader-utils/tile-grid.d.ts",
|
|
44
49
|
"import": "./dist/loader-utils/tile-grid.js",
|
|
@@ -160,9 +165,9 @@
|
|
|
160
165
|
"require": "./dist/geoarrow/clustering/cluster-index.cjs"
|
|
161
166
|
},
|
|
162
167
|
"./cluster-source": {
|
|
163
|
-
"types": "./dist/cluster-source.d.ts",
|
|
164
|
-
"import": "./dist/cluster-source.js",
|
|
165
|
-
"require": "./dist/cluster-source.cjs"
|
|
168
|
+
"types": "./dist/geoarrow/clustering/cluster-source.d.ts",
|
|
169
|
+
"import": "./dist/geoarrow/clustering/cluster-source.js",
|
|
170
|
+
"require": "./dist/geoarrow/clustering/cluster-source.cjs"
|
|
166
171
|
},
|
|
167
172
|
"./geoarrow/get-representative-point": {
|
|
168
173
|
"types": "./dist/geoarrow/clustering/get-representative-point.d.ts",
|
|
@@ -220,9 +225,9 @@
|
|
|
220
225
|
"require": "./dist/geoarrow/geoarrow-converter/geoarrow-geometry-converter.cjs"
|
|
221
226
|
},
|
|
222
227
|
"./geoarrow/geoarrow-builder": {
|
|
223
|
-
"types": "./dist/
|
|
224
|
-
"import": "./dist/
|
|
225
|
-
"require": "./dist/
|
|
228
|
+
"types": "./dist/arrow-geometry/geoarrow-builder.d.ts",
|
|
229
|
+
"import": "./dist/arrow-geometry/geoarrow-builder.js",
|
|
230
|
+
"require": "./dist/arrow-geometry/geoarrow-builder.cjs"
|
|
226
231
|
},
|
|
227
232
|
"./query": {
|
|
228
233
|
"types": "./dist/scan/index.d.ts",
|
|
@@ -315,14 +320,14 @@
|
|
|
315
320
|
"require": "./dist/scan/scan-query.cjs"
|
|
316
321
|
},
|
|
317
322
|
"./federated-table-scan-source": {
|
|
318
|
-
"types": "./dist/federated-table-scan-source.d.ts",
|
|
319
|
-
"import": "./dist/federated-table-scan-source.js",
|
|
320
|
-
"require": "./dist/federated-table-scan-source.cjs"
|
|
323
|
+
"types": "./dist/scan/federated-table-scan-source.d.ts",
|
|
324
|
+
"import": "./dist/scan/federated-table-scan-source.js",
|
|
325
|
+
"require": "./dist/scan/federated-table-scan-source.cjs"
|
|
321
326
|
},
|
|
322
327
|
"./vector-table-scan-source": {
|
|
323
|
-
"types": "./dist/vector-table-scan-source.d.ts",
|
|
324
|
-
"import": "./dist/vector-table-scan-source.js",
|
|
325
|
-
"require": "./dist/vector-table-scan-source.cjs"
|
|
328
|
+
"types": "./dist/scan/vector-table-scan-source.d.ts",
|
|
329
|
+
"import": "./dist/scan/vector-table-scan-source.js",
|
|
330
|
+
"require": "./dist/scan/vector-table-scan-source.cjs"
|
|
326
331
|
},
|
|
327
332
|
"./wkt": {
|
|
328
333
|
"types": "./dist/wkt/index.d.ts",
|
|
@@ -348,6 +353,26 @@
|
|
|
348
353
|
"types": "./dist/scan/arrow-execution.d.ts",
|
|
349
354
|
"import": "./dist/scan/arrow-execution.js",
|
|
350
355
|
"require": "./dist/scan/arrow-execution.cjs"
|
|
356
|
+
},
|
|
357
|
+
"./null": {
|
|
358
|
+
"types": "./dist/null-loader-metadata.d.ts",
|
|
359
|
+
"import": "./dist/null-loader-metadata.js",
|
|
360
|
+
"require": "./dist/null-loader-metadata.cjs"
|
|
361
|
+
},
|
|
362
|
+
"./null/bundled": {
|
|
363
|
+
"types": "./dist/null-loader.d.ts",
|
|
364
|
+
"import": "./dist/null-loader.js",
|
|
365
|
+
"require": "./dist/null-loader.cjs"
|
|
366
|
+
},
|
|
367
|
+
"./json": {
|
|
368
|
+
"types": "./dist/loader-utils/json-loader-metadata.d.ts",
|
|
369
|
+
"import": "./dist/loader-utils/json-loader-metadata.js",
|
|
370
|
+
"require": "./dist/loader-utils/json-loader-metadata.cjs"
|
|
371
|
+
},
|
|
372
|
+
"./json/bundled": {
|
|
373
|
+
"types": "./dist/loader-utils/json-loader.d.ts",
|
|
374
|
+
"import": "./dist/loader-utils/json-loader.js",
|
|
375
|
+
"require": "./dist/loader-utils/json-loader.cjs"
|
|
351
376
|
}
|
|
352
377
|
},
|
|
353
378
|
"sideEffects": [
|
|
@@ -390,9 +415,9 @@
|
|
|
390
415
|
"third-party-licenses"
|
|
391
416
|
],
|
|
392
417
|
"scripts": {
|
|
393
|
-
"pre-build": "npm run build-bundle && npm run build-bundle-dev && npm run build-worker && npm run build-worker-node && npm run build-worker-utils-worker && npm run build-worker-utils-worker-node && npm run build-polyfills-node-entrypoint && npm run build-schema-subpaths && npm run generate-json-schema && npm run build-utility-subpaths && npm run build-constants",
|
|
394
|
-
"build-bundle": "
|
|
395
|
-
"build-bundle-dev": "
|
|
418
|
+
"pre-build": "npm run build-bundle && npm run build-bundle-dev && npm run build-worker && npm run build-worker-node && npm run build-worker-utils-worker && npm run build-worker-utils-worker-node && npm run build-polyfills-node-entrypoint && npm run build-schema-subpaths && npm run generate-json-schema && npm run build-utility-subpaths && npm run build-constants && npm run build-compatibility-entry",
|
|
419
|
+
"build-bundle": "node ../../scripts/build-codec-bundle.mjs ./bundle.ts --output=dist/dist.min.js",
|
|
420
|
+
"build-bundle-dev": "node ../../scripts/build-codec-bundle.mjs ./bundle.ts --env=dev --output=dist/dist.dev.js",
|
|
396
421
|
"build-worker": "esbuild src/workers/null-worker.ts --outfile=dist/null-worker.js --bundle --target=esnext --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
397
422
|
"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\\\"",
|
|
398
423
|
"build-worker-utils-worker": "esbuild src/worker-utils/workers/null-worker.ts --outfile=dist/worker-utils/null-worker.js --target=esnext --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
@@ -401,20 +426,21 @@
|
|
|
401
426
|
"build-schema-subpaths": "esbuild src/schema/index.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/schema/index.cjs && esbuild src/schema/geospatial-metadata-zod-schema.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/schema/geospatial-metadata-zod-schema.cjs && esbuild src/schema-utils/index.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/schema-utils/index.cjs && esbuild src/arrow-worker-transport.ts --bundle --packages=external --platform=node --format=cjs --outfile=dist/arrow-worker-transport.cjs",
|
|
402
427
|
"generate-json-schema": "node ../../scripts/generate-json-schema.mjs --schema ./dist/schema/geospatial-metadata-zod-schema.js --export GeoParquetMetadataSchema --output ./dist/schema/geoparquet.schema.json --id https://unpkg.com/@loaders.gl/core/schema/geoparquet.schema.json --title 'loaders.gl GeoParquet metadata' && node ../../scripts/generate-json-schema.mjs --schema ./dist/schema/geospatial-metadata-zod-schema.js --export GeoArrowMetadataSchema --output ./dist/schema/geoarrow-metadata.schema.json --id https://unpkg.com/@loaders.gl/core/schema/geoarrow-metadata.schema.json --title 'loaders.gl GeoArrow field metadata'",
|
|
403
428
|
"build-utility-subpaths": "node ../../scripts/build-core-utility-subpaths.mjs",
|
|
404
|
-
"build-constants": "esbuild src/constants/index.ts --bundle --platform=node --format=cjs --outfile=dist/constants/index.cjs"
|
|
429
|
+
"build-constants": "esbuild src/constants/index.ts --bundle --platform=node --format=cjs --outfile=dist/constants/index.cjs",
|
|
430
|
+
"build-compatibility-entry": "esbuild dist/index.js --bundle --packages=external --external:@loaders.gl/core/* --platform=node --format=cjs --outfile=dist/index.cjs"
|
|
405
431
|
},
|
|
406
432
|
"dependencies": {
|
|
407
|
-
"@math.gl/core": "^5.0.
|
|
408
|
-
"@math.gl/geometry": "^5.0.
|
|
409
|
-
"@math.gl/geospatial": "^5.0.
|
|
410
|
-
"@math.gl/sql": "^5.0.
|
|
411
|
-
"@math.gl/tasks": "^5.0.
|
|
433
|
+
"@math.gl/core": "^5.0.4",
|
|
434
|
+
"@math.gl/geometry": "^5.0.4",
|
|
435
|
+
"@math.gl/geospatial": "^5.0.4",
|
|
436
|
+
"@math.gl/sql": "^5.0.4",
|
|
437
|
+
"@math.gl/tasks": "^5.0.4",
|
|
412
438
|
"@types/geojson": "^7946.0.7",
|
|
413
439
|
"apache-arrow": ">= 17.0.0",
|
|
414
440
|
"probe.gl": "^5.0.0",
|
|
415
441
|
"zod": "^4.1.12"
|
|
416
442
|
},
|
|
417
|
-
"gitHead": "
|
|
443
|
+
"gitHead": "e28aef9d87913a5f04901ed503aefefb85e2e700",
|
|
418
444
|
"peerDependencies": {
|
|
419
445
|
"sharp": "^0.35.5"
|
|
420
446
|
},
|
package/src/api.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// TYPES
|
|
6
|
+
export type {
|
|
7
|
+
Loader,
|
|
8
|
+
LoaderWithParser,
|
|
9
|
+
LoaderContext,
|
|
10
|
+
CoreAPI,
|
|
11
|
+
LoaderOptions,
|
|
12
|
+
Writer,
|
|
13
|
+
WriterWithEncoder,
|
|
14
|
+
WriterOptions,
|
|
15
|
+
DataType,
|
|
16
|
+
SyncDataType,
|
|
17
|
+
BatchableDataType,
|
|
18
|
+
ReadableFile,
|
|
19
|
+
WritableFile,
|
|
20
|
+
Stat,
|
|
21
|
+
FileSystem,
|
|
22
|
+
RandomAccessFileSystem
|
|
23
|
+
} from '@loaders.gl/core/loader-utils';
|
|
24
|
+
export type {SourceLoader} from '@loaders.gl/core/loader-utils';
|
|
25
|
+
|
|
26
|
+
// FILE READING AND WRITING
|
|
27
|
+
export {fetchFile} from './lib/fetch/fetch-file';
|
|
28
|
+
export {FetchError} from './lib/fetch/fetch-error';
|
|
29
|
+
|
|
30
|
+
export {readArrayBuffer} from './lib/fetch/read-array-buffer';
|
|
31
|
+
// export {readFileSync} from './lib/fetch/read-file';
|
|
32
|
+
// export {writeFile, writeFileSync} from './lib/fetch/write-file';
|
|
33
|
+
|
|
34
|
+
// CONFIGURATION
|
|
35
|
+
export {setLoaderOptions, getLoaderOptions, compareLoaderOptions} from './lib/api/loader-options';
|
|
36
|
+
export {registerLoaders} from './lib/api/register-loaders';
|
|
37
|
+
export {selectLoader, selectLoaderSync} from './lib/api/select-loader';
|
|
38
|
+
|
|
39
|
+
// LOADING (READING + PARSING)
|
|
40
|
+
export {parse} from './lib/api/parse';
|
|
41
|
+
export {parseFile} from './lib/api/parse-file';
|
|
42
|
+
export {parseSync} from './lib/api/parse-sync';
|
|
43
|
+
export {parseInBatches} from './lib/api/parse-in-batches';
|
|
44
|
+
export {preload, preloadSync} from './lib/api/preload';
|
|
45
|
+
export {coreApi} from './lib/api/core-api';
|
|
46
|
+
|
|
47
|
+
export {load} from './lib/api/load';
|
|
48
|
+
export {loadInBatches} from './lib/api/load-in-batches';
|
|
49
|
+
|
|
50
|
+
// ENCODING (ENCODING AND WRITING)
|
|
51
|
+
export {encodeTable, encodeTableAsText, encodeTableInBatches} from './lib/api/encode-table';
|
|
52
|
+
export {encode, encodeSync, encodeInBatches, encodeURLtoURL} from './lib/api/encode';
|
|
53
|
+
export {encodeText, encodeTextSync} from './lib/api/encode';
|
|
54
|
+
|
|
55
|
+
// SERVICES AND SOURCES
|
|
56
|
+
export {createDataSource, createDataSourceSync} from './lib/api/create-data-source';
|
|
57
|
+
export {selectSource as _selectSource} from './lib/api/select-source';
|
|
58
|
+
|
|
59
|
+
// CORE UTILS SHARED WITH LOADERS (RE-EXPORTED FROM LOADER-UTILS)
|
|
60
|
+
export {setPathPrefix, getPathPrefix, resolvePath} from '@loaders.gl/core/loader-utils';
|
|
61
|
+
export {RequestScheduler} from '@loaders.gl/core/loader-utils';
|
|
62
|
+
|
|
63
|
+
// ITERATOR UTILS
|
|
64
|
+
export {makeIterator} from './iterators/make-iterator/make-iterator';
|
|
65
|
+
export {makeStream} from './iterators/make-stream/make-stream';
|
|
66
|
+
|
|
67
|
+
// EXPERIMENTAL
|
|
68
|
+
export {fetchProgress as _fetchProgress} from './lib/progress/fetch-progress';
|
|
69
|
+
export {BrowserFileSystem as _BrowserFileSystem} from './lib/filesystems/browser-filesystem';
|
|
70
|
+
|
|
71
|
+
// FOR TESTING
|
|
72
|
+
export {_unregisterLoaders} from './lib/api/register-loaders';
|
|
73
|
+
|
|
74
|
+
//
|
|
75
|
+
// TODO - MOVE TO LOADER-UTILS AND DEPRECATE IN CORE?
|
|
76
|
+
//
|
|
77
|
+
|
|
78
|
+
export {isBrowser, isWorker, self, window, global, document} from '@loaders.gl/core/loader-utils';
|
|
79
|
+
export {assert} from '@loaders.gl/core/loader-utils';
|
|
80
|
+
export {forEach, concatenateArrayBuffersAsync} from '@loaders.gl/core/loader-utils';
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
makeTextDecoderIterator,
|
|
84
|
+
makeTextEncoderIterator,
|
|
85
|
+
makeLineIterator,
|
|
86
|
+
makeNumberedLineIterator
|
|
87
|
+
} from '@loaders.gl/core/loader-utils';
|
|
88
|
+
|
|
89
|
+
// "JAVASCRIPT" UTILS - move to loader-utils?
|
|
90
|
+
export {
|
|
91
|
+
isPureObject,
|
|
92
|
+
isPromise,
|
|
93
|
+
isIterable,
|
|
94
|
+
isAsyncIterable,
|
|
95
|
+
isIterator,
|
|
96
|
+
isResponse,
|
|
97
|
+
isReadableStream,
|
|
98
|
+
isWritableStream
|
|
99
|
+
} from '@loaders.gl/core/loader-utils';
|