@loaders.gl/core 5.0.0-beta.1 → 5.0.0-beta.10
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/GEOARROW-README.md +1 -1
- package/README.md +4 -2
- package/SCAN-README.md +1 -1
- package/SCHEMA-UTILS-README.md +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/binary-geometry-to-wkb.js +1 -1
- package/dist/arrow-geometry/binary-geometry-to-wkb.js.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs +5 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +5 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +6 -2
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +6 -2
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/geojson-table.cjs +295 -18
- package/dist/arrow-geometry/geojson-table.cjs.map +3 -3
- package/dist/arrow-geometry/geojson-table.d.ts +10 -3
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +23 -13
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.cjs +6 -6
- package/dist/arrow-geometry/geometry-codecs.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-codecs.js +1 -1
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.cjs +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.cjs.map +2 -2
- package/dist/arrow-geometry/geometry-to-wkt.js +1 -1
- package/dist/arrow-geometry/geometry-to-wkt.js.map +1 -1
- package/dist/arrow-geometry/index.cjs +0 -11
- package/dist/arrow-geometry/index.cjs.map +2 -2
- package/dist/arrow-geometry/index.d.ts +0 -1
- package/dist/arrow-geometry/index.d.ts.map +1 -1
- package/dist/arrow-geometry/index.js +0 -1
- package/dist/arrow-geometry/index.js.map +1 -1
- package/dist/arrow-geometry/wkb-builder.cjs +3 -3
- package/dist/arrow-geometry/wkb-builder.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-builder.d.ts +1 -1
- package/dist/arrow-geometry/wkb-builder.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-builder.js +1 -1
- package/dist/arrow-geometry/wkb-builder.js.map +1 -1
- package/dist/arrow-geometry/wkb-statistics.cjs +2 -2
- package/dist/arrow-geometry/wkb-statistics.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-statistics.js +1 -1
- package/dist/arrow-geometry/wkb-statistics.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +173 -0
- package/dist/arrow-worker-transport.cjs.map +6 -0
- package/dist/arrow-worker-transport.d.ts +15 -0
- package/dist/arrow-worker-transport.d.ts.map +1 -0
- package/dist/arrow-worker-transport.js +151 -0
- package/dist/arrow-worker-transport.js.map +1 -0
- package/dist/cluster-source.cjs +6874 -0
- package/dist/cluster-source.cjs.map +6 -0
- package/dist/cluster-source.d.ts +2 -0
- package/dist/cluster-source.d.ts.map +1 -0
- package/dist/cluster-source.js +2 -0
- package/dist/cluster-source.js.map +1 -0
- package/dist/dist.dev.js +3035 -823
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +2447 -0
- package/dist/federated-table-scan-source.cjs.map +6 -0
- package/dist/federated-table-scan-source.d.ts +2 -0
- package/dist/federated-table-scan-source.d.ts.map +1 -0
- package/dist/federated-table-scan-source.js +2 -0
- package/dist/federated-table-scan-source.js.map +1 -0
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js +1 -1
- package/dist/geoarrow/binary-polygon-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.cjs +4 -7
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +1 -4
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +1 -0
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +2 -0
- package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-bounds.cjs +7 -7
- package/dist/geoarrow/geoarrow-bounds.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-bounds.js +3 -3
- package/dist/geoarrow/geoarrow-bounds.js.map +1 -1
- package/dist/geoarrow/geoarrow-capabilities.cjs +2 -2
- package/dist/geoarrow/geoarrow-capabilities.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-capabilities.js +1 -1
- package/dist/geoarrow/geoarrow-capabilities.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +8 -8
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +6 -4
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +9 -4
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +6 -4
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +6 -4
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
- package/dist/geoarrow/geoarrow-inspection.cjs +2 -2
- package/dist/geoarrow/geoarrow-inspection.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-inspection.js +1 -1
- package/dist/geoarrow/geoarrow-inspection.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.js +1 -1
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.js +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs +4 -4
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -3
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs +3 -3
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js +1 -1
- package/dist/geoarrow/lib/kernels/encode-geoarrow-box.js.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs +0 -6
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +2 -3
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js +0 -6
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +738 -1372
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +20 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +15 -19
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +17 -67
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +61 -6
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +47 -53
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/loader-utils/get-fetch-function.js +2 -2
- package/dist/lib/loader-utils/get-fetch-function.js.map +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +16 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +84 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.d.ts +3 -2
- package/dist/lib/loader-utils/option-defaults.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-defaults.js +9 -10
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts +0 -6
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +31 -114
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/format-types.d.ts +3 -0
- package/dist/loader-utils/format-types.d.ts.map +1 -1
- package/dist/loader-utils/index.cjs +838 -1284
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +16 -7
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +8 -4
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.d.ts +4 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.js +45 -1
- package/dist/loader-utils/lib/files/http-file-transport.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-types.d.ts +2 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/read-range-response.d.ts +3 -0
- package/dist/loader-utils/lib/files/read-range-response.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/read-range-response.js +62 -0
- package/dist/loader-utils/lib/files/read-range-response.js.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.d.ts +23 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/pace-batch-iterator.d.ts +14 -0
- package/dist/loader-utils/lib/pace-batch-iterator.d.ts.map +1 -0
- package/dist/loader-utils/lib/pace-batch-iterator.js +51 -0
- package/dist/loader-utils/lib/pace-batch-iterator.js.map +1 -0
- package/dist/loader-utils/lib/request-utils/request-credentials.js +1 -1
- package/dist/loader-utils/lib/request-utils/request-credentials.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +43 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +104 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.d.ts → query-options.d.ts} +5 -8
- package/dist/loader-utils/lib/scan-utils/query-options.d.ts.map +1 -0
- package/dist/{schema-utils/lib/table/batch-builder/table-batch-aggregator.js → loader-utils/lib/scan-utils/query-options.js} +1 -1
- package/dist/loader-utils/lib/scan-utils/query-options.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +54 -18
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +16 -6
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +54 -3
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -3
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +33 -18
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +53 -14
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/sources/image-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +30 -0
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -0
- package/dist/loader-utils/lib/{scan-utils/experimental-scan-options.js → sources/table-source-collection.js} +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.js.map +1 -0
- package/dist/loader-utils/lib/sources/utils/utils.js +1 -1
- package/dist/loader-utils/lib/sources/utils/utils.js.map +1 -1
- package/dist/loader-utils/lib/sources/vector-source.d.ts +4 -3
- package/dist/loader-utils/lib/sources/vector-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -2
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js +2 -5
- package/dist/loader-utils/lib/worker-loader-utils/encode-with-worker.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +40 -21
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +120 -91
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/source-types.d.ts +7 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +9 -1
- package/dist/loader-utils/source-types.js.map +1 -1
- package/dist/null-loader.d.ts +0 -18
- package/dist/null-loader.d.ts.map +1 -1
- package/dist/null-loader.js +1 -19
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +771 -82
- package/dist/null-worker.js +742 -81
- package/dist/polyfills/images/encode-image-node.d.ts +18 -15
- package/dist/polyfills/images/encode-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/encode-image-node.js +19 -33
- package/dist/polyfills/images/encode-image-node.js.map +1 -1
- package/dist/polyfills/images/image-codecs-node.d.ts +2 -6
- package/dist/polyfills/images/image-codecs-node.d.ts.map +1 -1
- package/dist/polyfills/images/image-codecs-node.js +2 -24
- package/dist/polyfills/images/image-codecs-node.js.map +1 -1
- package/dist/polyfills/images/load-sharp.d.ts +3 -0
- package/dist/polyfills/images/load-sharp.d.ts.map +1 -0
- package/dist/polyfills/images/load-sharp.js +11 -0
- package/dist/polyfills/images/load-sharp.js.map +1 -0
- package/dist/polyfills/images/node-image-bitmap.d.ts +1 -1
- package/dist/polyfills/images/node-image-bitmap.js +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts +1 -1
- package/dist/polyfills/images/node-image-formats.d.ts.map +1 -1
- package/dist/polyfills/images/node-image-formats.js +10 -4
- package/dist/polyfills/images/node-image-formats.js.map +1 -1
- package/dist/polyfills/images/parse-image-node.d.ts +10 -2
- package/dist/polyfills/images/parse-image-node.d.ts.map +1 -1
- package/dist/polyfills/images/parse-image-node.js +20 -32
- package/dist/polyfills/images/parse-image-node.js.map +1 -1
- package/dist/polyfills/index.cjs +76 -151
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +134 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +11 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +86 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +255 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +18 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js +224 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs +70 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +8 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.js +39 -0
- package/dist/scan/arrow-execution/project-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution.cjs +34 -0
- package/dist/scan/arrow-execution.cjs.map +7 -0
- package/dist/scan/arrow-execution.d.ts +4 -0
- package/dist/scan/arrow-execution.d.ts.map +1 -0
- package/dist/scan/arrow-execution.js +6 -0
- package/dist/scan/arrow-execution.js.map +1 -0
- package/dist/scan/arrow-query.cjs.map +1 -1
- package/dist/scan/arrow-query.d.ts +1 -1
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/catalog-query-source.cjs +122 -0
- package/dist/scan/catalog-query-source.cjs.map +7 -0
- package/dist/scan/catalog-query-source.d.ts +6 -0
- package/dist/scan/catalog-query-source.d.ts.map +1 -0
- package/dist/scan/catalog-query-source.js +115 -0
- package/dist/scan/catalog-query-source.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +38 -38
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts +6 -10
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +35 -35
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +208 -4
- package/dist/scan/index.cjs.map +4 -4
- package/dist/scan/index.d.ts +13 -3
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +6 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +6 -9
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -314
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.cjs +75 -0
- package/dist/scan/query-arrow-table-in-batches.cjs.map +7 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts +8 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.js +54 -0
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -0
- package/dist/scan/query-arrow-table.cjs +65 -202
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +7 -40
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +51 -211
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query-open-source.cjs +52 -0
- package/dist/scan/query-open-source.cjs.map +7 -0
- package/dist/scan/query-open-source.d.ts +4 -0
- package/dist/scan/query-open-source.d.ts.map +1 -0
- package/dist/scan/query-open-source.js +26 -0
- package/dist/scan/query-open-source.js.map +1 -0
- package/dist/scan/query-progressive.cjs +190 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +173 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query-pushdown.cjs +140 -0
- package/dist/scan/query-pushdown.cjs.map +7 -0
- package/dist/scan/query-pushdown.d.ts +14 -0
- package/dist/scan/query-pushdown.d.ts.map +1 -0
- package/dist/scan/query-pushdown.js +136 -0
- package/dist/scan/query-pushdown.js.map +1 -0
- package/dist/scan/query.cjs +381 -0
- package/dist/scan/query.cjs.map +7 -0
- package/dist/scan/query.d.ts +64 -0
- package/dist/scan/query.d.ts.map +1 -0
- package/dist/scan/query.js +419 -0
- package/dist/scan/query.js.map +1 -0
- package/dist/scan/resolve-query-source.cjs +59 -0
- package/dist/scan/resolve-query-source.cjs.map +7 -0
- package/dist/scan/resolve-query-source.d.ts +6 -0
- package/dist/scan/resolve-query-source.d.ts.map +1 -0
- package/dist/scan/resolve-query-source.js +37 -0
- package/dist/scan/resolve-query-source.js.map +1 -0
- package/dist/scan/rows-to-arrow.cjs +1 -28
- package/dist/scan/rows-to-arrow.cjs.map +2 -2
- package/dist/scan/rows-to-arrow.d.ts +3 -3
- package/dist/scan/rows-to-arrow.d.ts.map +1 -1
- package/dist/scan/rows-to-arrow.js +2 -32
- package/dist/scan/rows-to-arrow.js.map +1 -1
- package/dist/scan/scan-engine.cjs.map +2 -2
- package/dist/scan/scan-engine.d.ts +5 -5
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/sql-catalog.cjs +110 -0
- package/dist/scan/sql-catalog.cjs.map +7 -0
- package/dist/scan/sql-catalog.d.ts +47 -0
- package/dist/scan/sql-catalog.d.ts.map +1 -0
- package/dist/scan/sql-catalog.js +97 -0
- package/dist/scan/sql-catalog.js.map +1 -0
- package/dist/scan/table-query.cjs.map +2 -2
- package/dist/scan/table-query.d.ts +4 -1
- package/dist/scan/table-query.d.ts.map +1 -1
- package/dist/scan/table-query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +14 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +6 -5
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +17 -14
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/geometry/geoarrow.d.ts +3 -6
- package/dist/schema/geometry/geoarrow.d.ts.map +1 -1
- package/dist/schema/index.cjs +11 -7
- package/dist/schema/index.cjs.map +2 -2
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/schema/index.js.map +1 -1
- package/dist/schema-utils/index.cjs +690 -823
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +6 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +6 -4
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +17 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +106 -0
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -0
- package/dist/schema-utils/lib/converters/convert.js +9 -2
- package/dist/schema-utils/lib/converters/convert.js.map +1 -1
- package/dist/schema-utils/lib/converters/types.d.ts +2 -0
- package/dist/schema-utils/lib/converters/types.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +4 -3
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +4 -4
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -3
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +9 -2
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.d.ts +14 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.d.ts.map +1 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.js +39 -0
- package/dist/schema-utils/lib/mesh/get-mesh-bounding-box.js.map +1 -0
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts +2 -14
- package/dist/schema-utils/lib/mesh/mesh-utils.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/mesh-utils.js +1 -35
- package/dist/schema-utils/lib/mesh/mesh-utils.js.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +6 -5
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts +9 -9
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js +13 -46
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-builder.js.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts +9 -20
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js +61 -73
- package/dist/schema-utils/lib/table/batch-builder/table-batch-builder.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts +4 -3
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +30 -9
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +6 -9
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +26 -15
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +4 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +33 -9
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts +3 -3
- package/dist/schema-utils/lib/table/query-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/query-arrow-table.js +9 -23
- package/dist/schema-utils/lib/table/query-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +27 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +23 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +12 -10
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +15 -26
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts +6 -36
- package/dist/schema-utils/lib/table/tables/convert-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-table.js +5 -42
- package/dist/schema-utils/lib/table/tables/convert-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.d.ts +3 -55
- package/dist/schema-utils/lib/table/tables/make-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +3 -59
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts +18 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +42 -31
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts +6 -5
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/convert-tables.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +3 -3
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +7 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +1760 -0
- package/dist/vector-table-scan-source.cjs.map +6 -0
- package/dist/vector-table-scan-source.d.ts +2 -0
- package/dist/vector-table-scan-source.d.ts.map +1 -0
- package/dist/vector-table-scan-source.js +2 -0
- package/dist/vector-table-scan-source.js.map +1 -0
- package/dist/worker-utils/index.cjs +407 -1184
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/index.d.ts +2 -8
- package/dist/worker-utils/index.d.ts.map +1 -1
- package/dist/worker-utils/index.js +1 -10
- package/dist/worker-utils/index.js.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +3 -2
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts +5 -7
- package/dist/worker-utils/lib/worker-api/create-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/create-worker.js +76 -146
- package/dist/worker-utils/lib/worker-api/create-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +17 -45
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +214 -312
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts +36 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.d.ts.map +1 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.js +23 -0
- package/dist/worker-utils/lib/worker-api/task-runtime.js.map +1 -0
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts +1 -0
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js +3 -1
- package/dist/worker-utils/lib/worker-utils/get-transfer-list.js.map +1 -1
- package/dist/worker-utils/null-worker-node.js +836 -147
- package/dist/worker-utils/null-worker-node.js.map +4 -4
- package/dist/worker-utils/null-worker.js +804 -143
- package/dist/worker-utils/null-worker.js.map +4 -4
- package/dist/worker-utils/types.d.ts +55 -72
- package/dist/worker-utils/types.d.ts.map +1 -1
- package/package.json +126 -35
- package/src/arrow-geometry/binary-geometry-to-wkb.ts +1 -1
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -1
- package/src/arrow-geometry/feature-table.ts +6 -2
- package/src/arrow-geometry/geojson-table.ts +32 -21
- package/src/arrow-geometry/geometry-codecs.ts +2 -2
- package/src/arrow-geometry/geometry-to-wkt.ts +2 -2
- package/src/arrow-geometry/index.ts +0 -9
- package/src/arrow-geometry/wkb-builder.ts +2 -2
- package/src/arrow-geometry/wkb-statistics.ts +2 -2
- package/src/arrow-worker-transport.ts +225 -0
- package/src/cluster-source.ts +1 -0
- package/src/federated-table-scan-source.ts +1 -0
- package/src/geoarrow/binary-polygon-to-geoarrow.ts +2 -2
- package/src/geoarrow/clustering/cluster-source.ts +4 -7
- package/src/geoarrow/convert-table-to-geoarrow.ts +3 -1
- package/src/geoarrow/geoarrow-bounds.ts +3 -3
- package/src/geoarrow/geoarrow-capabilities.ts +1 -1
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +3 -3
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +14 -9
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +9 -6
- package/src/geoarrow/geoarrow-inspection.ts +2 -2
- package/src/geoarrow/geoarrow-stream.ts +1 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +1 -1
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- package/src/geoarrow/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +2 -2
- package/src/geoarrow/lib/kernels/encode-geoarrow-box.ts +1 -1
- package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +8 -10
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -5
- package/src/lib/api/create-data-source.ts +148 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +22 -21
- package/src/lib/api/load.ts +61 -127
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +122 -17
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +54 -69
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/get-fetch-function.ts +2 -2
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +109 -0
- package/src/lib/loader-utils/option-defaults.ts +9 -10
- package/src/lib/loader-utils/option-utils.ts +33 -122
- package/src/loader-utils/format-types.ts +4 -0
- package/src/loader-utils/index.ts +50 -9
- package/src/loader-utils/lib/files/http-file-transport.ts +65 -1
- package/src/loader-utils/lib/files/http-file-types.ts +2 -0
- package/src/loader-utils/lib/files/read-range-response.ts +66 -0
- package/src/loader-utils/lib/log-utils/log.ts +36 -1
- package/src/loader-utils/lib/pace-batch-iterator.ts +66 -0
- package/src/loader-utils/lib/request-utils/request-credentials.ts +1 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +174 -0
- package/src/loader-utils/lib/scan-utils/query-options.ts +44 -0
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +80 -28
- package/src/loader-utils/lib/scan-utils/table-query.ts +76 -8
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +54 -29
- package/src/loader-utils/lib/sources/data-source.ts +57 -16
- package/src/loader-utils/lib/sources/image-source.ts +1 -1
- package/src/loader-utils/lib/sources/table-source-collection.ts +38 -0
- package/src/loader-utils/lib/sources/utils/utils.ts +1 -1
- package/src/loader-utils/lib/sources/vector-source.ts +3 -3
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -2
- package/src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts +5 -6
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +41 -24
- package/src/loader-utils/loader-types.ts +190 -111
- package/src/loader-utils/source-types.ts +17 -6
- package/src/null-loader.ts +1 -20
- package/src/polyfills/README.md +2 -2
- package/src/polyfills/images/encode-image-node.ts +44 -37
- package/src/polyfills/images/image-codecs-node.ts +2 -37
- package/src/polyfills/images/load-sharp.ts +13 -0
- package/src/polyfills/images/node-image-bitmap.ts +1 -1
- package/src/polyfills/images/node-image-formats.ts +10 -4
- package/src/polyfills/images/parse-image-node.ts +31 -40
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +116 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +298 -0
- package/src/scan/arrow-execution/project-arrow-table.ts +53 -0
- package/src/scan/arrow-execution.ts +7 -0
- package/src/scan/arrow-query.ts +3 -0
- package/src/scan/catalog-query-source.ts +132 -0
- package/src/scan/federated-table-scan-source.ts +64 -72
- package/src/scan/index.ts +57 -5
- package/src/scan/parse-sql-predicate.ts +14 -367
- package/src/scan/query-arrow-table-in-batches.ts +55 -0
- package/src/scan/query-arrow-table.ts +81 -271
- package/src/scan/query-open-source.ts +39 -0
- package/src/scan/query-progressive.ts +229 -0
- package/src/scan/query-pushdown.ts +184 -0
- package/src/scan/query.ts +597 -0
- package/src/scan/resolve-query-source.ts +47 -0
- package/src/scan/rows-to-arrow.ts +3 -39
- package/src/scan/scan-engine.ts +6 -6
- package/src/scan/sql-catalog.ts +167 -0
- package/src/scan/table-query.ts +6 -1
- package/src/scan/vector-table-scan-source.ts +22 -18
- package/src/schema/geometry/geoarrow.ts +8 -19
- package/src/schema/index.ts +3 -2
- package/src/schema-utils/index.ts +23 -8
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +136 -0
- package/src/schema-utils/lib/converters/convert.ts +7 -2
- package/src/schema-utils/lib/converters/types.ts +2 -0
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +7 -9
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +10 -4
- package/src/schema-utils/lib/mesh/get-mesh-bounding-box.ts +52 -0
- package/src/schema-utils/lib/mesh/mesh-utils.ts +3 -49
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +18 -8
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts +21 -51
- package/src/schema-utils/lib/table/batch-builder/table-batch-builder.ts +68 -83
- package/src/schema-utils/lib/table/batches/convert-batches.ts +41 -21
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +33 -19
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +48 -7
- package/src/schema-utils/lib/table/query-arrow-table.ts +14 -32
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +54 -0
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +30 -35
- package/src/schema-utils/lib/table/tables/convert-table.ts +11 -57
- package/src/schema-utils/lib/table/tables/make-table.ts +6 -70
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +66 -49
- package/src/schema-utils/lib/table/tables/table-converter/convert-tables.ts +12 -14
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +13 -10
- package/src/vector-table-scan-source.ts +1 -0
- package/src/worker-utils/index.ts +2 -18
- package/src/worker-utils/lib/library-utils/library-utils.ts +3 -2
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/create-worker.ts +89 -188
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +246 -402
- package/src/worker-utils/lib/worker-api/task-runtime.ts +66 -0
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
- package/src/worker-utils/lib/worker-utils/get-transfer-list.ts +2 -0
- package/src/worker-utils/types.ts +74 -109
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs +0 -477
- package/dist/arrow-geometry/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts +0 -29
- package/dist/arrow-geometry/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js +0 -434
- package/dist/arrow-geometry/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs +0 -39
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.cjs.map +0 -7
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts +0 -2
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.d.ts.map +0 -1
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js +0 -5
- package/dist/geoarrow/lib/arrow-geoarrow-adapter.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts +0 -40
- package/dist/loader-utils/lib/file-provider/data-view-file.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/data-view-file.js +0 -68
- package/dist/loader-utils/lib/file-provider/data-view-file.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts +0 -54
- package/dist/loader-utils/lib/file-provider/file-handle-file.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-handle-file.js +0 -102
- package/dist/loader-utils/lib/file-provider/file-handle-file.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts +0 -45
- package/dist/loader-utils/lib/file-provider/file-provider-interface.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js +0 -13
- package/dist/loader-utils/lib/file-provider/file-provider-interface.js.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts +0 -57
- package/dist/loader-utils/lib/file-provider/file-provider.d.ts.map +0 -1
- package/dist/loader-utils/lib/file-provider/file-provider.js +0 -114
- package/dist/loader-utils/lib/file-provider/file-provider.js.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js.map +0 -1
- package/dist/schema/deprecated/mesh-utils.d.ts +0 -12
- package/dist/schema/deprecated/mesh-utils.d.ts.map +0 -1
- package/dist/schema/deprecated/mesh-utils.js +0 -37
- package/dist/schema/deprecated/mesh-utils.js.map +0 -1
- package/dist/schema-utils/arrow-transport.cjs +0 -691
- package/dist/schema-utils/arrow-transport.cjs.map +0 -6
- package/dist/schema-utils/arrow-transport.d.ts +0 -4
- package/dist/schema-utils/arrow-transport.d.ts.map +0 -1
- package/dist/schema-utils/arrow-transport.js +0 -7
- package/dist/schema-utils/arrow-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts +0 -76
- package/dist/schema-utils/lib/arrow/arrow-table-transport.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js +0 -182
- package/dist/schema-utils/lib/arrow/arrow-table-transport.js.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts +0 -33
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.d.ts.map +0 -1
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js +0 -134
- package/dist/schema-utils/lib/arrow/split-arrow-buffers.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts +0 -10
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js +0 -71
- package/dist/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts +0 -19
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js +0 -64
- package/dist/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts +0 -20
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js +0 -83
- package/dist/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts +0 -21
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js +0 -86
- package/dist/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.js.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts +0 -24
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/batch-builder/table-batch-aggregator.js.map +0 -1
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts +0 -32
- package/dist/worker-utils/lib/async-queue/async-queue.d.ts.map +0 -1
- package/dist/worker-utils/lib/async-queue/async-queue.js +0 -91
- package/dist/worker-utils/lib/async-queue/async-queue.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts +0 -20
- package/dist/worker-utils/lib/worker-farm/worker-body.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-body.js +0 -131
- package/dist/worker-utils/lib/worker-farm/worker-body.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts +0 -58
- package/dist/worker-utils/lib/worker-farm/worker-farm.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-farm.js +0 -116
- package/dist/worker-utils/lib/worker-farm/worker-farm.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts +0 -34
- package/dist/worker-utils/lib/worker-farm/worker-job.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-job.js +0 -74
- package/dist/worker-utils/lib/worker-farm/worker-job.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts +0 -94
- package/dist/worker-utils/lib/worker-farm/worker-pool.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-pool.js +0 -246
- package/dist/worker-utils/lib/worker-farm/worker-pool.js.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts +0 -67
- package/dist/worker-utils/lib/worker-farm/worker-thread.d.ts.map +0 -1
- package/dist/worker-utils/lib/worker-farm/worker-thread.js +0 -175
- package/dist/worker-utils/lib/worker-farm/worker-thread.js.map +0 -1
- package/src/arrow-geometry/arrow-geoarrow-adapter.ts +0 -568
- package/src/geoarrow/lib/arrow-geoarrow-adapter.ts +0 -12
- package/src/loader-utils/lib/file-provider/data-view-file.ts +0 -83
- package/src/loader-utils/lib/file-provider/file-handle-file.ts +0 -114
- package/src/loader-utils/lib/file-provider/file-provider-interface.ts +0 -60
- package/src/loader-utils/lib/file-provider/file-provider.ts +0 -130
- package/src/loader-utils/lib/scan-utils/experimental-scan-options.ts +0 -46
- package/src/polyfills/images/encode-image.node.ts.disabled +0 -41
- package/src/polyfills/images/parse-image.node.ts.disabled +0 -55
- package/src/schema/deprecated/mesh-utils.ts +0 -46
- package/src/schema-utils/arrow-transport.ts +0 -7
- package/src/schema-utils/lib/arrow/arrow-table-transport.ts +0 -282
- package/src/schema-utils/lib/arrow/split-arrow-buffers.ts +0 -247
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator-builders.ts.disabled +0 -190
- package/src/schema-utils/lib/table/batch-builder/arrow-table-batch-aggregator.ts +0 -85
- package/src/schema-utils/lib/table/batch-builder/base-table-batch-aggregator.ts +0 -82
- package/src/schema-utils/lib/table/batch-builder/columnar-table-batch-aggregator.ts +0 -103
- package/src/schema-utils/lib/table/batch-builder/row-table-batch-aggregator.ts +0 -108
- package/src/schema-utils/lib/table/batch-builder/table-batch-aggregator.ts +0 -28
- package/src/worker-utils/lib/async-queue/async-queue.ts +0 -100
- package/src/worker-utils/lib/worker-farm/worker-body.ts +0 -145
- package/src/worker-utils/lib/worker-farm/worker-farm.ts +0 -144
- package/src/worker-utils/lib/worker-farm/worker-job.ts +0 -85
- package/src/worker-utils/lib/worker-farm/worker-pool.ts +0 -316
- package/src/worker-utils/lib/worker-farm/worker-thread.ts +0 -206
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(index_exports, {
|
|
|
23
23
|
FetchError: () => FetchError,
|
|
24
24
|
JSONLoader: () => JSONLoader,
|
|
25
25
|
NullLoader: () => NullLoader,
|
|
26
|
-
NullWorkerLoader: () => NullWorkerLoader,
|
|
27
26
|
RequestScheduler: () => RequestScheduler,
|
|
28
27
|
_BrowserFileSystem: () => BrowserFileSystem,
|
|
29
28
|
_fetchProgress: () => fetchProgress,
|
|
@@ -33,6 +32,7 @@ __export(index_exports, {
|
|
|
33
32
|
concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
|
|
34
33
|
coreApi: () => coreApi,
|
|
35
34
|
createDataSource: () => createDataSource,
|
|
35
|
+
createDataSourceSync: () => createDataSourceSync,
|
|
36
36
|
document: () => document_,
|
|
37
37
|
encode: () => encode,
|
|
38
38
|
encodeInBatches: () => encodeInBatches,
|
|
@@ -115,15 +115,45 @@ var import_log = require("probe.gl/log");
|
|
|
115
115
|
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
116
116
|
var version = VERSION[0] >= "0" && VERSION[0] <= "9" ? `v${VERSION}` : "";
|
|
117
117
|
function createLog() {
|
|
118
|
-
const
|
|
118
|
+
const log3 = new import_log.Log({ id: "loaders.gl" });
|
|
119
119
|
globalThis.loaders ||= {};
|
|
120
|
-
globalThis.loaders.log =
|
|
120
|
+
globalThis.loaders.log = log3;
|
|
121
121
|
globalThis.loaders.version = version;
|
|
122
122
|
globalThis.probe ||= {};
|
|
123
|
-
globalThis.probe.loaders =
|
|
124
|
-
return
|
|
123
|
+
globalThis.probe.loaders = log3;
|
|
124
|
+
return log3;
|
|
125
125
|
}
|
|
126
126
|
var log = createLog();
|
|
127
|
+
var NullLog = class {
|
|
128
|
+
/** Discards debug messages. */
|
|
129
|
+
log() {
|
|
130
|
+
return ignoreMessage;
|
|
131
|
+
}
|
|
132
|
+
/** Discards informational messages. */
|
|
133
|
+
info() {
|
|
134
|
+
return ignoreMessage;
|
|
135
|
+
}
|
|
136
|
+
/** Discards messages marked to be emitted once. */
|
|
137
|
+
once() {
|
|
138
|
+
return ignoreMessage;
|
|
139
|
+
}
|
|
140
|
+
/** Discards warnings. */
|
|
141
|
+
warn() {
|
|
142
|
+
return ignoreMessage;
|
|
143
|
+
}
|
|
144
|
+
/** Discards errors. */
|
|
145
|
+
error() {
|
|
146
|
+
return ignoreMessage;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
function ignoreMessage() {
|
|
150
|
+
}
|
|
151
|
+
var nullLog = new NullLog();
|
|
152
|
+
function getLoaderLog(options) {
|
|
153
|
+
var _a;
|
|
154
|
+
const logger = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a.log;
|
|
155
|
+
return logger === null ? nullLog : logger || log;
|
|
156
|
+
}
|
|
127
157
|
|
|
128
158
|
// src/loader-utils/lib/javascript-utils/is-type.ts
|
|
129
159
|
var isBoolean = (value) => typeof value === "boolean";
|
|
@@ -183,10 +213,10 @@ var NPM_TAG = "beta";
|
|
|
183
213
|
|
|
184
214
|
// src/worker-utils/lib/env-utils/version.ts
|
|
185
215
|
function getVersion() {
|
|
186
|
-
const
|
|
216
|
+
const version3 = typeof __VERSION__ === "undefined" ? NPM_TAG : __VERSION__;
|
|
187
217
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
188
|
-
globalThis._loadersgl_.version ||=
|
|
189
|
-
return
|
|
218
|
+
globalThis._loadersgl_.version ||= version3;
|
|
219
|
+
return version3;
|
|
190
220
|
}
|
|
191
221
|
var VERSION2 = getVersion();
|
|
192
222
|
|
|
@@ -216,130 +246,69 @@ var isMobile = typeof window !== "undefined" && typeof window.orientation !== "u
|
|
|
216
246
|
var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
217
247
|
var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
|
|
218
248
|
|
|
219
|
-
// src/worker-utils/lib/worker-
|
|
220
|
-
var
|
|
221
|
-
name;
|
|
222
|
-
workerThread;
|
|
223
|
-
isRunning = true;
|
|
224
|
-
/** Promise that resolves when Job is done */
|
|
225
|
-
result;
|
|
226
|
-
_resolve = () => {
|
|
227
|
-
};
|
|
228
|
-
_reject = () => {
|
|
229
|
-
};
|
|
230
|
-
constructor(jobName, workerThread) {
|
|
231
|
-
this.name = jobName;
|
|
232
|
-
this.workerThread = workerThread;
|
|
233
|
-
this.result = new Promise((resolve2, reject) => {
|
|
234
|
-
this._resolve = resolve2;
|
|
235
|
-
this._reject = reject;
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Send a message to the job's worker thread
|
|
240
|
-
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
241
|
-
*/
|
|
242
|
-
postMessage(type, payload) {
|
|
243
|
-
if (!this.isRunning) return;
|
|
244
|
-
this.workerThread.postMessage({
|
|
245
|
-
source: "loaders.gl",
|
|
246
|
-
// Lets worker ignore unrelated messages
|
|
247
|
-
type,
|
|
248
|
-
payload
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Call to resolve the `result` Promise with the supplied value
|
|
253
|
-
*/
|
|
254
|
-
done(value) {
|
|
255
|
-
if (!this.isRunning) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
this.isRunning = false;
|
|
259
|
-
this._resolve(value);
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Call to reject the `result` Promise with the supplied error
|
|
263
|
-
*/
|
|
264
|
-
error(error) {
|
|
265
|
-
if (!this.isRunning) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
this.isRunning = false;
|
|
269
|
-
this._reject(error);
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Terminates the worker executing this job and rejects its result.
|
|
273
|
-
* @param reason Abort reason supplied by the caller, or a cross-runtime `AbortError`.
|
|
274
|
-
*/
|
|
275
|
-
abort(reason) {
|
|
276
|
-
if (!this.isRunning) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
this.workerThread.destroy();
|
|
280
|
-
this.error(
|
|
281
|
-
arguments.length ? reason : createAbortError(`Worker job "${this.name}" was aborted`)
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
function createAbortError(message) {
|
|
286
|
-
const error = new Error(message);
|
|
287
|
-
error.name = "AbortError";
|
|
288
|
-
return error;
|
|
289
|
-
}
|
|
249
|
+
// src/worker-utils/lib/worker-api/process-on-worker.ts
|
|
250
|
+
var import_tasks2 = require("@math.gl/tasks");
|
|
290
251
|
|
|
291
|
-
// src/worker-utils/lib/
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
252
|
+
// src/worker-utils/lib/worker-api/get-worker-url.ts
|
|
253
|
+
var warnedWorkerVersionFallbacks = /* @__PURE__ */ new Set();
|
|
254
|
+
function getCustomWorkerURL(worker, options = {}) {
|
|
255
|
+
var _a, _b;
|
|
256
|
+
const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
|
|
257
|
+
let url = getConfiguredWorkerURL(worker, options);
|
|
258
|
+
const workerType = options._workerType || ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._workerType);
|
|
259
|
+
if (!url && workerType === "test") {
|
|
260
|
+
if (isBrowser2) {
|
|
261
|
+
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
262
|
+
} else {
|
|
263
|
+
const workerSourceDirectory = worker.module === "core" && ((_b = worker.workerNode) == null ? void 0 : _b.startsWith("worker-utils/")) ? "worker-utils/workers" : "workers";
|
|
264
|
+
const workerSourceNode = worker.workerSourceNode || `${workerSourceDirectory}/${worker.id}-worker-node.ts`;
|
|
265
|
+
url = `modules/${worker.module}/src/${workerSourceNode}`;
|
|
300
266
|
}
|
|
301
267
|
}
|
|
302
|
-
|
|
303
|
-
|
|
268
|
+
return url || null;
|
|
269
|
+
}
|
|
270
|
+
function getConfiguredWorkerURL(worker, options = {}) {
|
|
271
|
+
const workerOptions = options[worker.id] || {};
|
|
272
|
+
return workerOptions.workerUrl || (worker.id === "compression" ? options.workerUrl : null) || null;
|
|
273
|
+
}
|
|
274
|
+
function getWorkerURL(worker, options = {}) {
|
|
275
|
+
const customWorkerUrl = getCustomWorkerURL(worker, options);
|
|
276
|
+
const descriptorWorkerUrl = typeof worker.worker === "string" ? worker.worker : null;
|
|
277
|
+
const url = customWorkerUrl || descriptorWorkerUrl || getDefaultWorkerURL(worker, true);
|
|
278
|
+
assert2(url);
|
|
279
|
+
return url;
|
|
280
|
+
}
|
|
281
|
+
function getDefaultWorkerURL(worker, warn = false) {
|
|
282
|
+
const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
|
|
283
|
+
let version3 = worker.version;
|
|
284
|
+
if (version3 === "latest") {
|
|
285
|
+
version3 = NPM_TAG;
|
|
304
286
|
}
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
function getLoadableWorkerURL(props) {
|
|
310
|
-
assert2(props.source && !props.url || !props.source && props.url);
|
|
311
|
-
let workerURL = workerURLCache.get(props.source || props.url);
|
|
312
|
-
if (!workerURL) {
|
|
313
|
-
if (props.url) {
|
|
314
|
-
workerURL = getLoadableWorkerURLFromURL(props.url);
|
|
315
|
-
workerURLCache.set(props.url, workerURL);
|
|
316
|
-
}
|
|
317
|
-
if (props.source) {
|
|
318
|
-
workerURL = getLoadableWorkerURLFromSource(props.source);
|
|
319
|
-
workerURLCache.set(props.source, workerURL);
|
|
320
|
-
}
|
|
287
|
+
const versionTag = version3 ? `@${version3}` : "";
|
|
288
|
+
const url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
289
|
+
if (warn) {
|
|
290
|
+
warnIfUsingNpmTagFallback(worker, url);
|
|
321
291
|
}
|
|
322
|
-
|
|
323
|
-
return workerURL;
|
|
292
|
+
return url;
|
|
324
293
|
}
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
327
|
-
return
|
|
294
|
+
function warnIfUsingNpmTagFallback(worker, url) {
|
|
295
|
+
if (worker.version !== "latest") {
|
|
296
|
+
return;
|
|
328
297
|
}
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
298
|
+
const workerId = `${worker.module}:${worker.id}`;
|
|
299
|
+
if (warnedWorkerVersionFallbacks.has(workerId)) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
warnedWorkerVersionFallbacks.add(workerId);
|
|
303
|
+
log.warn(
|
|
304
|
+
`loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
|
|
305
|
+
)();
|
|
335
306
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
throw error;
|
|
342
|
-
}`;
|
|
307
|
+
|
|
308
|
+
// src/worker-utils/lib/worker-api/task-runtime.ts
|
|
309
|
+
var import_tasks = require("@math.gl/tasks");
|
|
310
|
+
function normalizeTaskProgress(progress) {
|
|
311
|
+
return { ...progress, phase: progress.phase ?? "process", unit: progress.unit ?? "items" };
|
|
343
312
|
}
|
|
344
313
|
|
|
345
314
|
// src/worker-utils/lib/worker-utils/get-transfer-list.ts
|
|
@@ -382,7 +351,7 @@ function getTransferListForWriter(object) {
|
|
|
382
351
|
}
|
|
383
352
|
const clone = Object.assign({}, object);
|
|
384
353
|
Object.keys(clone).forEach((key) => {
|
|
385
|
-
if (typeof object[key] === "object" && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
|
|
354
|
+
if (object[key] !== null && typeof object[key] === "object" && !ArrayBuffer.isView(object[key]) && !(object[key] instanceof Array)) {
|
|
386
355
|
clone[key] = getTransferListForWriter(object[key]);
|
|
387
356
|
} else if (typeof clone[key] === "function" || clone[key] instanceof RegExp) {
|
|
388
357
|
clone[key] = {};
|
|
@@ -393,866 +362,224 @@ function getTransferListForWriter(object) {
|
|
|
393
362
|
return clone;
|
|
394
363
|
}
|
|
395
364
|
|
|
396
|
-
// src/worker-utils/lib/worker-farm/worker-thread.ts
|
|
397
|
-
var NOOP = () => {
|
|
398
|
-
};
|
|
399
|
-
var WorkerThread = class {
|
|
400
|
-
name;
|
|
401
|
-
source;
|
|
402
|
-
url;
|
|
403
|
-
/** Lazily resolves the classic worker URL used as a fallback. */
|
|
404
|
-
getUrl;
|
|
405
|
-
/** Creates a browser Worker directly. */
|
|
406
|
-
loadWorker;
|
|
407
|
-
terminated = false;
|
|
408
|
-
worker;
|
|
409
|
-
onMessage;
|
|
410
|
-
onError;
|
|
411
|
-
_loadableURL = "";
|
|
412
|
-
/** Checks if workers are supported on this platform */
|
|
413
|
-
static isSupported() {
|
|
414
|
-
return typeof Worker !== "undefined" && isBrowser2 || typeof NodeWorker !== "undefined" && !isBrowser2;
|
|
415
|
-
}
|
|
416
|
-
constructor(props) {
|
|
417
|
-
const { name, source, url, getUrl, loadWorker } = props;
|
|
418
|
-
assert2(source || url || getUrl || loadWorker);
|
|
419
|
-
this.name = name;
|
|
420
|
-
this.source = source;
|
|
421
|
-
this.url = url;
|
|
422
|
-
this.getUrl = getUrl;
|
|
423
|
-
this.loadWorker = loadWorker;
|
|
424
|
-
this.onMessage = NOOP;
|
|
425
|
-
this.onError = (error) => console.log(error);
|
|
426
|
-
this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Terminate this worker thread
|
|
430
|
-
* @note Can free up significant memory
|
|
431
|
-
*/
|
|
432
|
-
destroy() {
|
|
433
|
-
this.onMessage = NOOP;
|
|
434
|
-
this.onError = NOOP;
|
|
435
|
-
this.worker.terminate();
|
|
436
|
-
this.terminated = true;
|
|
437
|
-
}
|
|
438
|
-
/** Keeps this worker from preventing Node.js process exit while idle. */
|
|
439
|
-
unref() {
|
|
440
|
-
if (!isBrowser2 && typeof this.worker.unref === "function") {
|
|
441
|
-
this.worker.unref();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
/** Keeps this worker alive while it is actively processing a job. */
|
|
445
|
-
ref() {
|
|
446
|
-
if (!isBrowser2 && typeof this.worker.ref === "function") {
|
|
447
|
-
this.worker.ref();
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
get isRunning() {
|
|
451
|
-
return Boolean(this.onMessage);
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Send a message to this worker thread
|
|
455
|
-
* @param data any data structure, ideally consisting mostly of transferrable objects
|
|
456
|
-
* @param transferList If not supplied, calculated automatically by traversing data
|
|
457
|
-
*/
|
|
458
|
-
postMessage(data, transferList) {
|
|
459
|
-
transferList = transferList || getTransferList(data);
|
|
460
|
-
this.worker.postMessage(data, transferList);
|
|
461
|
-
}
|
|
462
|
-
// PRIVATE
|
|
463
|
-
/**
|
|
464
|
-
* Generate a standard Error from an ErrorEvent
|
|
465
|
-
* @param event
|
|
466
|
-
*/
|
|
467
|
-
_getErrorFromErrorEvent(event) {
|
|
468
|
-
let message = "Failed to load ";
|
|
469
|
-
message += `worker ${this.name} from ${this.url || "built-in worker factory"}. `;
|
|
470
|
-
if (event.message) {
|
|
471
|
-
message += `${event.message} in `;
|
|
472
|
-
}
|
|
473
|
-
if (event.lineno) {
|
|
474
|
-
message += `:${event.lineno}:${event.colno}`;
|
|
475
|
-
}
|
|
476
|
-
return new Error(message);
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Creates a worker thread on the browser
|
|
480
|
-
*/
|
|
481
|
-
_createBrowserWorker() {
|
|
482
|
-
var _a;
|
|
483
|
-
if (this.loadWorker) {
|
|
484
|
-
try {
|
|
485
|
-
const worker2 = this.loadWorker();
|
|
486
|
-
if (worker2) {
|
|
487
|
-
return this._initializeBrowserWorker(worker2);
|
|
488
|
-
}
|
|
489
|
-
} catch (error) {
|
|
490
|
-
if (!this.source && !this.url && !this.getUrl) {
|
|
491
|
-
throw error;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
const url = this.url || ((_a = this.getUrl) == null ? void 0 : _a.call(this));
|
|
496
|
-
this._loadableURL = getLoadableWorkerURL({ source: this.source, url });
|
|
497
|
-
const worker = new Worker(this._loadableURL, { name: this.name });
|
|
498
|
-
return this._initializeBrowserWorker(worker);
|
|
499
|
-
}
|
|
500
|
-
/** Attaches protocol handlers to a browser worker. */
|
|
501
|
-
_initializeBrowserWorker(worker) {
|
|
502
|
-
worker.onmessage = (event) => {
|
|
503
|
-
if (!event.data) {
|
|
504
|
-
this.onError(new Error("No data received"));
|
|
505
|
-
} else {
|
|
506
|
-
this.onMessage(event.data);
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
worker.onerror = (error) => {
|
|
510
|
-
this.onError(this._getErrorFromErrorEvent(error));
|
|
511
|
-
this.terminated = true;
|
|
512
|
-
};
|
|
513
|
-
worker.onmessageerror = (event) => console.error(event);
|
|
514
|
-
return worker;
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Creates a worker thread in node.js
|
|
518
|
-
* @todo https://nodejs.org/api/async_hooks.html#async-resource-worker-pool
|
|
519
|
-
*/
|
|
520
|
-
_createNodeWorker() {
|
|
521
|
-
let worker;
|
|
522
|
-
if (this.url) {
|
|
523
|
-
const absolute = this.url.includes(":/") || this.url.startsWith("/");
|
|
524
|
-
const url = absolute ? this.url : `./${this.url}`;
|
|
525
|
-
const workerUrl = url.startsWith("file:") ? new URL(url) : url;
|
|
526
|
-
const type = this.url.endsWith(".ts") || this.url.endsWith(".mjs") ? "module" : "commonjs";
|
|
527
|
-
worker = new NodeWorker(workerUrl, { eval: false, type });
|
|
528
|
-
} else if (this.source) {
|
|
529
|
-
worker = new NodeWorker(this.source, { eval: true });
|
|
530
|
-
} else {
|
|
531
|
-
throw new Error("no worker");
|
|
532
|
-
}
|
|
533
|
-
worker.on("message", (data) => {
|
|
534
|
-
this.onMessage(data);
|
|
535
|
-
});
|
|
536
|
-
worker.on("error", (error) => {
|
|
537
|
-
this.onError(error);
|
|
538
|
-
});
|
|
539
|
-
worker.on("exit", (_code) => {
|
|
540
|
-
});
|
|
541
|
-
return worker;
|
|
542
|
-
}
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
// src/worker-utils/lib/worker-farm/worker-pool.ts
|
|
546
|
-
var WorkerPool = class {
|
|
547
|
-
name = "unnamed";
|
|
548
|
-
source;
|
|
549
|
-
// | Function;
|
|
550
|
-
url;
|
|
551
|
-
/** Lazily resolves a classic worker fallback URL. */
|
|
552
|
-
getUrl;
|
|
553
|
-
/** Creates a browser Worker directly. */
|
|
554
|
-
loadWorker;
|
|
555
|
-
maxConcurrency = 1;
|
|
556
|
-
maxMobileConcurrency = 1;
|
|
557
|
-
onDebug = () => {
|
|
558
|
-
};
|
|
559
|
-
reuseWorkers = true;
|
|
560
|
-
props = {};
|
|
561
|
-
jobQueue = [];
|
|
562
|
-
idleQueue = [];
|
|
563
|
-
activeJobs = /* @__PURE__ */ new Set();
|
|
564
|
-
count = 0;
|
|
565
|
-
isDestroyed = false;
|
|
566
|
-
/** Checks if workers are supported on this platform */
|
|
567
|
-
static isSupported() {
|
|
568
|
-
return WorkerThread.isSupported();
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* @param processor - worker function
|
|
572
|
-
* @param maxConcurrency - max count of workers
|
|
573
|
-
*/
|
|
574
|
-
constructor(props) {
|
|
575
|
-
this.source = props.source;
|
|
576
|
-
this.url = props.url;
|
|
577
|
-
this.getUrl = props.getUrl;
|
|
578
|
-
this.loadWorker = props.loadWorker;
|
|
579
|
-
this.setProps(props);
|
|
580
|
-
}
|
|
581
|
-
/**
|
|
582
|
-
* Terminates all workers in the pool and aborts active jobs.
|
|
583
|
-
* @param reason Optional error delivered to active jobs.
|
|
584
|
-
* @note Can free up significant memory
|
|
585
|
-
*/
|
|
586
|
-
destroy(reason = new Error("Worker pool was destroyed")) {
|
|
587
|
-
this.isDestroyed = true;
|
|
588
|
-
this.activeJobs.forEach((job) => job.abort(reason));
|
|
589
|
-
const queuedJobs = this.jobQueue.splice(0);
|
|
590
|
-
queuedJobs.forEach((queuedJob) => {
|
|
591
|
-
queuedJob.removeAbortListener();
|
|
592
|
-
queuedJob.onReject(reason);
|
|
593
|
-
});
|
|
594
|
-
this.idleQueue.forEach((worker) => worker.destroy());
|
|
595
|
-
this.isDestroyed = true;
|
|
596
|
-
}
|
|
597
|
-
setProps(props) {
|
|
598
|
-
this.props = { ...this.props, ...props };
|
|
599
|
-
if (props.name !== void 0) {
|
|
600
|
-
this.name = props.name;
|
|
601
|
-
}
|
|
602
|
-
if (props.maxConcurrency !== void 0) {
|
|
603
|
-
this.maxConcurrency = props.maxConcurrency;
|
|
604
|
-
}
|
|
605
|
-
if (props.maxMobileConcurrency !== void 0) {
|
|
606
|
-
this.maxMobileConcurrency = props.maxMobileConcurrency;
|
|
607
|
-
}
|
|
608
|
-
if (props.reuseWorkers !== void 0) {
|
|
609
|
-
this.reuseWorkers = props.reuseWorkers;
|
|
610
|
-
}
|
|
611
|
-
if (props.onDebug !== void 0) {
|
|
612
|
-
this.onDebug = props.onDebug;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
async startJob(name, onMessage2 = (job, type, data) => job.done(data), onError = (job, error) => job.error(error), signal) {
|
|
616
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
617
|
-
throw signal.reason;
|
|
618
|
-
}
|
|
619
|
-
if (this.isDestroyed) {
|
|
620
|
-
return Promise.reject(new Error("Worker pool was destroyed"));
|
|
621
|
-
}
|
|
622
|
-
const startPromise = new Promise((onStart, onReject) => {
|
|
623
|
-
const abortQueuedJob = () => {
|
|
624
|
-
const index = this.jobQueue.indexOf(queuedJob);
|
|
625
|
-
if (index >= 0) {
|
|
626
|
-
this.jobQueue.splice(index, 1);
|
|
627
|
-
queuedJob.removeAbortListener();
|
|
628
|
-
onReject(signal == null ? void 0 : signal.reason);
|
|
629
|
-
}
|
|
630
|
-
};
|
|
631
|
-
const queuedJob = {
|
|
632
|
-
name,
|
|
633
|
-
onMessage: onMessage2,
|
|
634
|
-
onError,
|
|
635
|
-
onStart,
|
|
636
|
-
onReject,
|
|
637
|
-
signal,
|
|
638
|
-
removeAbortListener: () => signal == null ? void 0 : signal.removeEventListener("abort", abortQueuedJob)
|
|
639
|
-
};
|
|
640
|
-
this.jobQueue.push(queuedJob);
|
|
641
|
-
signal == null ? void 0 : signal.addEventListener("abort", abortQueuedJob, { once: true });
|
|
642
|
-
return this;
|
|
643
|
-
});
|
|
644
|
-
this._startQueuedJob();
|
|
645
|
-
return await startPromise;
|
|
646
|
-
}
|
|
647
|
-
// PRIVATE
|
|
648
|
-
/**
|
|
649
|
-
* Starts first queued job if worker is available or can be created
|
|
650
|
-
* Called when job is started and whenever a worker returns to the idleQueue
|
|
651
|
-
*/
|
|
652
|
-
async _startQueuedJob() {
|
|
653
|
-
var _a, _b, _c;
|
|
654
|
-
if (!this.jobQueue.length) {
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
let workerThread;
|
|
658
|
-
try {
|
|
659
|
-
workerThread = this._getAvailableWorker();
|
|
660
|
-
} catch (error) {
|
|
661
|
-
const queuedJob2 = this.jobQueue.shift();
|
|
662
|
-
queuedJob2 == null ? void 0 : queuedJob2.removeAbortListener();
|
|
663
|
-
queuedJob2 == null ? void 0 : queuedJob2.onReject(error);
|
|
664
|
-
void this._startQueuedJob();
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
if (!workerThread) {
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
const queuedJob = this.jobQueue.shift();
|
|
671
|
-
if (queuedJob) {
|
|
672
|
-
this.onDebug({
|
|
673
|
-
message: "Starting job",
|
|
674
|
-
name: queuedJob.name,
|
|
675
|
-
workerThread,
|
|
676
|
-
backlog: this.jobQueue.length
|
|
677
|
-
});
|
|
678
|
-
const job = new WorkerJob(queuedJob.name, workerThread);
|
|
679
|
-
queuedJob.removeAbortListener();
|
|
680
|
-
const abortJob = () => {
|
|
681
|
-
var _a2;
|
|
682
|
-
return job.abort((_a2 = queuedJob.signal) == null ? void 0 : _a2.reason);
|
|
683
|
-
};
|
|
684
|
-
(_a = queuedJob.signal) == null ? void 0 : _a.addEventListener("abort", abortJob, { once: true });
|
|
685
|
-
if ((_b = queuedJob.signal) == null ? void 0 : _b.aborted) abortJob();
|
|
686
|
-
this.activeJobs.add(job);
|
|
687
|
-
workerThread.ref();
|
|
688
|
-
workerThread.onMessage = (data) => {
|
|
689
|
-
if (job.isRunning) queuedJob.onMessage(job, data.type, data.payload);
|
|
690
|
-
};
|
|
691
|
-
workerThread.onError = (error) => queuedJob.onError(job, error);
|
|
692
|
-
queuedJob.onStart(job);
|
|
693
|
-
try {
|
|
694
|
-
await job.result;
|
|
695
|
-
} catch {
|
|
696
|
-
} finally {
|
|
697
|
-
(_c = queuedJob.signal) == null ? void 0 : _c.removeEventListener("abort", abortJob);
|
|
698
|
-
this.activeJobs.delete(job);
|
|
699
|
-
this.returnWorkerToQueue(workerThread);
|
|
700
|
-
}
|
|
701
|
-
} else {
|
|
702
|
-
this.returnWorkerToQueue(workerThread);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* Returns a worker to the idle queue
|
|
707
|
-
* Destroys the worker if
|
|
708
|
-
* - pool is destroyed
|
|
709
|
-
* - if this pool doesn't reuse workers
|
|
710
|
-
* - if maxConcurrency has been lowered
|
|
711
|
-
* @param worker
|
|
712
|
-
*/
|
|
713
|
-
returnWorkerToQueue(worker) {
|
|
714
|
-
const shouldDestroyWorker = (
|
|
715
|
-
// Aborted jobs terminate their worker immediately.
|
|
716
|
-
worker.terminated || // If the pool is destroyed, there is no reason to keep the worker around
|
|
717
|
-
this.isDestroyed || // If the app has disabled worker reuse, any completed workers should be destroyed
|
|
718
|
-
!this.reuseWorkers || // If concurrency has been lowered, this worker might be surplus to requirements
|
|
719
|
-
this.count > this._getMaxConcurrency()
|
|
720
|
-
);
|
|
721
|
-
if (shouldDestroyWorker) {
|
|
722
|
-
if (!worker.terminated) {
|
|
723
|
-
worker.destroy();
|
|
724
|
-
}
|
|
725
|
-
this.count--;
|
|
726
|
-
} else {
|
|
727
|
-
worker.unref();
|
|
728
|
-
this.idleQueue.push(worker);
|
|
729
|
-
}
|
|
730
|
-
if (!this.isDestroyed) {
|
|
731
|
-
this._startQueuedJob();
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
/**
|
|
735
|
-
* Returns idle worker or creates new worker if maxConcurrency has not been reached
|
|
736
|
-
*/
|
|
737
|
-
_getAvailableWorker() {
|
|
738
|
-
if (this.idleQueue.length > 0) {
|
|
739
|
-
return this.idleQueue.shift() || null;
|
|
740
|
-
}
|
|
741
|
-
if (this.count < this._getMaxConcurrency()) {
|
|
742
|
-
this.count++;
|
|
743
|
-
const name = `${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;
|
|
744
|
-
try {
|
|
745
|
-
return new WorkerThread({
|
|
746
|
-
name,
|
|
747
|
-
source: this.source,
|
|
748
|
-
url: this.url,
|
|
749
|
-
getUrl: this.getUrl,
|
|
750
|
-
loadWorker: this.loadWorker
|
|
751
|
-
});
|
|
752
|
-
} catch (error) {
|
|
753
|
-
this.count--;
|
|
754
|
-
throw error;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
return null;
|
|
758
|
-
}
|
|
759
|
-
_getMaxConcurrency() {
|
|
760
|
-
return isMobile ? this.maxMobileConcurrency : this.maxConcurrency;
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
|
-
|
|
764
|
-
// src/worker-utils/lib/worker-farm/worker-farm.ts
|
|
765
|
-
var DEFAULT_PROPS = {
|
|
766
|
-
maxConcurrency: 3,
|
|
767
|
-
maxMobileConcurrency: 1,
|
|
768
|
-
reuseWorkers: true,
|
|
769
|
-
onDebug: () => {
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
var loadWorkerIds = /* @__PURE__ */ new WeakMap();
|
|
773
|
-
var nextLoadWorkerId = 1;
|
|
774
|
-
var WorkerFarm = class _WorkerFarm {
|
|
775
|
-
props;
|
|
776
|
-
workerPools = /* @__PURE__ */ new Map();
|
|
777
|
-
// singleton
|
|
778
|
-
static _workerFarm;
|
|
779
|
-
/** Checks if workers are supported on this platform */
|
|
780
|
-
static isSupported() {
|
|
781
|
-
return WorkerThread.isSupported();
|
|
782
|
-
}
|
|
783
|
-
/** Get the singleton instance of the global worker farm */
|
|
784
|
-
static getWorkerFarm(props = {}) {
|
|
785
|
-
_WorkerFarm._workerFarm = _WorkerFarm._workerFarm || new _WorkerFarm({});
|
|
786
|
-
_WorkerFarm._workerFarm.setProps(props);
|
|
787
|
-
return _WorkerFarm._workerFarm;
|
|
788
|
-
}
|
|
789
|
-
/** get global instance with WorkerFarm.getWorkerFarm() */
|
|
790
|
-
constructor(props) {
|
|
791
|
-
this.props = { ...DEFAULT_PROPS };
|
|
792
|
-
this.setProps(props);
|
|
793
|
-
this.workerPools = /* @__PURE__ */ new Map();
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Terminate all workers in the farm and abort active jobs.
|
|
797
|
-
* @param reason Optional error delivered to active jobs.
|
|
798
|
-
* @note Can free up significant memory
|
|
799
|
-
*/
|
|
800
|
-
destroy(reason) {
|
|
801
|
-
for (const workerPool of this.workerPools.values()) {
|
|
802
|
-
workerPool.destroy(reason);
|
|
803
|
-
}
|
|
804
|
-
this.workerPools = /* @__PURE__ */ new Map();
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Set props used when initializing worker pools
|
|
808
|
-
* @param props
|
|
809
|
-
*/
|
|
810
|
-
setProps(props) {
|
|
811
|
-
this.props = { ...this.props, ...props };
|
|
812
|
-
for (const workerPool of this.workerPools.values()) {
|
|
813
|
-
workerPool.setProps(this._getWorkerPoolProps());
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
* Returns a worker pool for the specified worker
|
|
818
|
-
* @param options Worker target used to identify and initialize the pool.
|
|
819
|
-
* @param options.name Worker name used as the base pool identity.
|
|
820
|
-
* @param options.url Worker script URL.
|
|
821
|
-
* @param options.source Inline worker source.
|
|
822
|
-
* @param options.loadWorker Built-in browser worker factory.
|
|
823
|
-
* @example
|
|
824
|
-
* const job = WorkerFarm.getWorkerFarm().getWorkerPool({name, url}).startJob(...);
|
|
825
|
-
*/
|
|
826
|
-
getWorkerPool(options) {
|
|
827
|
-
const { name, source, url, getUrl, loadWorker } = options;
|
|
828
|
-
const workerPoolKey = getWorkerPoolKey(options);
|
|
829
|
-
let workerPool = this.workerPools.get(workerPoolKey);
|
|
830
|
-
if (!workerPool) {
|
|
831
|
-
workerPool = new WorkerPool({
|
|
832
|
-
name,
|
|
833
|
-
source,
|
|
834
|
-
url,
|
|
835
|
-
getUrl,
|
|
836
|
-
loadWorker
|
|
837
|
-
});
|
|
838
|
-
workerPool.setProps(this._getWorkerPoolProps());
|
|
839
|
-
this.workerPools.set(workerPoolKey, workerPool);
|
|
840
|
-
}
|
|
841
|
-
return workerPool;
|
|
842
|
-
}
|
|
843
|
-
_getWorkerPoolProps() {
|
|
844
|
-
return {
|
|
845
|
-
maxConcurrency: this.props.maxConcurrency,
|
|
846
|
-
maxMobileConcurrency: this.props.maxMobileConcurrency,
|
|
847
|
-
reuseWorkers: this.props.reuseWorkers,
|
|
848
|
-
onDebug: this.props.onDebug
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
function getWorkerPoolKey(options) {
|
|
853
|
-
const { name, source, url, urlKey, loadWorker } = options;
|
|
854
|
-
const sourceKey = source ? `source:${source}` : "";
|
|
855
|
-
const urlKeyPart = url || urlKey ? `url:${url || urlKey}` : "";
|
|
856
|
-
const loadWorkerKey = loadWorker ? `loadWorker:${getLoadWorkerId(loadWorker)}` : "";
|
|
857
|
-
return [name, sourceKey, urlKeyPart, loadWorkerKey].filter(Boolean).join("|");
|
|
858
|
-
}
|
|
859
|
-
function getLoadWorkerId(loadWorker) {
|
|
860
|
-
let loadWorkerId = loadWorkerIds.get(loadWorker);
|
|
861
|
-
if (!loadWorkerId) {
|
|
862
|
-
loadWorkerId = nextLoadWorkerId++;
|
|
863
|
-
loadWorkerIds.set(loadWorker, loadWorkerId);
|
|
864
|
-
}
|
|
865
|
-
return loadWorkerId;
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
// src/worker-utils/lib/async-queue/async-queue.ts
|
|
869
|
-
var AsyncQueue = class {
|
|
870
|
-
_values;
|
|
871
|
-
_settlers;
|
|
872
|
-
_closed;
|
|
873
|
-
constructor() {
|
|
874
|
-
this._values = [];
|
|
875
|
-
this._settlers = [];
|
|
876
|
-
this._closed = false;
|
|
877
|
-
}
|
|
878
|
-
/** Return an async iterator for this queue */
|
|
879
|
-
[Symbol.asyncIterator]() {
|
|
880
|
-
return this;
|
|
881
|
-
}
|
|
882
|
-
/** Push a new value - the async iterator will yield a promise resolved to this value */
|
|
883
|
-
push(value) {
|
|
884
|
-
return this.enqueue(value);
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Push a new value - the async iterator will yield a promise resolved to this value
|
|
888
|
-
* Add an error - the async iterator will yield a promise rejected with this value
|
|
889
|
-
*/
|
|
890
|
-
enqueue(value) {
|
|
891
|
-
if (this._closed) {
|
|
892
|
-
throw new Error("Closed");
|
|
893
|
-
}
|
|
894
|
-
if (this._settlers.length > 0) {
|
|
895
|
-
if (this._values.length > 0) {
|
|
896
|
-
throw new Error("Illegal internal state");
|
|
897
|
-
}
|
|
898
|
-
const settler = this._settlers.shift();
|
|
899
|
-
if (value instanceof Error) {
|
|
900
|
-
settler.reject(value);
|
|
901
|
-
} else {
|
|
902
|
-
settler.resolve({ value });
|
|
903
|
-
}
|
|
904
|
-
} else {
|
|
905
|
-
this._values.push(value);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
/** Indicate that we not waiting for more values - The async iterator will be done */
|
|
909
|
-
close() {
|
|
910
|
-
while (this._settlers.length > 0) {
|
|
911
|
-
const settler = this._settlers.shift();
|
|
912
|
-
settler.resolve({ done: true });
|
|
913
|
-
}
|
|
914
|
-
this._closed = true;
|
|
915
|
-
}
|
|
916
|
-
// ITERATOR IMPLEMENTATION
|
|
917
|
-
/** @returns a Promise for an IteratorResult */
|
|
918
|
-
next() {
|
|
919
|
-
if (this._values.length > 0) {
|
|
920
|
-
const value = this._values.shift();
|
|
921
|
-
if (value instanceof Error) {
|
|
922
|
-
return Promise.reject(value);
|
|
923
|
-
}
|
|
924
|
-
return Promise.resolve({ done: false, value });
|
|
925
|
-
}
|
|
926
|
-
if (this._closed) {
|
|
927
|
-
if (this._settlers.length > 0) {
|
|
928
|
-
throw new Error("Illegal internal state");
|
|
929
|
-
}
|
|
930
|
-
return Promise.resolve({ done: true, value: void 0 });
|
|
931
|
-
}
|
|
932
|
-
return new Promise((resolve2, reject) => {
|
|
933
|
-
this._settlers.push({ resolve: resolve2, reject });
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
// src/worker-utils/lib/worker-api/get-worker-url.ts
|
|
939
|
-
var warnedWorkerVersionFallbacks = /* @__PURE__ */ new Set();
|
|
940
|
-
function getWorkerName(worker) {
|
|
941
|
-
const warning = worker.version !== VERSION2 ? ` (worker-utils@${VERSION2})` : "";
|
|
942
|
-
return `${worker.name}@${worker.version}${warning}`;
|
|
943
|
-
}
|
|
944
|
-
function getCustomWorkerURL(worker, options = {}) {
|
|
945
|
-
var _a, _b;
|
|
946
|
-
const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
|
|
947
|
-
let url = getConfiguredWorkerURL(worker, options);
|
|
948
|
-
const workerType = options._workerType || ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._workerType);
|
|
949
|
-
if (!url && workerType === "test") {
|
|
950
|
-
if (isBrowser2) {
|
|
951
|
-
url = `modules/${worker.module}/dist/${workerFile}`;
|
|
952
|
-
} else {
|
|
953
|
-
const workerSourceDirectory = worker.module === "core" && ((_b = worker.workerNode) == null ? void 0 : _b.startsWith("worker-utils/")) ? "worker-utils/workers" : "workers";
|
|
954
|
-
const workerSourceNode = worker.workerSourceNode || `${workerSourceDirectory}/${worker.id}-worker-node.ts`;
|
|
955
|
-
url = `modules/${worker.module}/src/${workerSourceNode}`;
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
return url || null;
|
|
959
|
-
}
|
|
960
|
-
function getConfiguredWorkerURL(worker, options = {}) {
|
|
961
|
-
const workerOptions = options[worker.id] || {};
|
|
962
|
-
return workerOptions.workerUrl || (worker.id === "compression" ? options.workerUrl : null) || null;
|
|
963
|
-
}
|
|
964
|
-
function getWorkerURL(worker, options = {}) {
|
|
965
|
-
const customWorkerUrl = getCustomWorkerURL(worker, options);
|
|
966
|
-
const descriptorWorkerUrl = typeof worker.worker === "string" ? worker.worker : null;
|
|
967
|
-
const url = customWorkerUrl || descriptorWorkerUrl || getDefaultWorkerURL(worker, true);
|
|
968
|
-
assert2(url);
|
|
969
|
-
return url;
|
|
970
|
-
}
|
|
971
|
-
function getDefaultWorkerURL(worker, warn = false) {
|
|
972
|
-
const workerFile = isBrowser2 ? worker.workerFile || `${worker.id}-worker.js` : worker.workerNode || `${worker.id}-worker-node.js`;
|
|
973
|
-
let version2 = worker.version;
|
|
974
|
-
if (version2 === "latest") {
|
|
975
|
-
version2 = NPM_TAG;
|
|
976
|
-
}
|
|
977
|
-
const versionTag = version2 ? `@${version2}` : "";
|
|
978
|
-
const url = `https://unpkg.com/@loaders.gl/${worker.module}${versionTag}/dist/${workerFile}`;
|
|
979
|
-
if (warn) {
|
|
980
|
-
warnIfUsingNpmTagFallback(worker, url);
|
|
981
|
-
}
|
|
982
|
-
return url;
|
|
983
|
-
}
|
|
984
|
-
function warnIfUsingNpmTagFallback(worker, url) {
|
|
985
|
-
if (worker.version !== "latest") {
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
const workerId = `${worker.module}:${worker.id}`;
|
|
989
|
-
if (warnedWorkerVersionFallbacks.has(workerId)) {
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
warnedWorkerVersionFallbacks.add(workerId);
|
|
993
|
-
console.warn(
|
|
994
|
-
`loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
|
|
995
|
-
);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
365
|
// src/worker-utils/lib/worker-api/process-on-worker.ts
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
const
|
|
366
|
+
var runners = /* @__PURE__ */ new WeakMap();
|
|
367
|
+
var activeRunners = /* @__PURE__ */ new Set();
|
|
368
|
+
var moduleWorkerUrls = /* @__PURE__ */ new Map();
|
|
369
|
+
function canProcessOnWorker(worker, options = {}) {
|
|
370
|
+
const supported = isBrowser2 ? typeof Worker !== "undefined" : Boolean(options._nodeWorkers);
|
|
1004
371
|
return Boolean(
|
|
1005
|
-
(worker.worker || worker.loadWorker || (
|
|
372
|
+
supported && options.worker && (worker.worker || worker.loadWorker || getConfiguredWorkerURL(worker, options))
|
|
1006
373
|
);
|
|
1007
374
|
}
|
|
1008
375
|
function canProcessOnWorkerInBatches(worker, options = {}) {
|
|
1009
376
|
if (!canProcessOnWorker(worker, options)) return false;
|
|
1010
377
|
if (options.workerInBatches !== void 0) return options.workerInBatches;
|
|
1011
|
-
return Boolean(
|
|
1012
|
-
worker.workerInBatches && !options.source && !getConfiguredWorkerURL(worker, options)
|
|
1013
|
-
);
|
|
378
|
+
return Boolean(worker.workerInBatches && !getConfiguredWorkerURL(worker, options));
|
|
1014
379
|
}
|
|
1015
380
|
async function processOnWorker(worker, data, options = {}, context = {}, jobContext = {}) {
|
|
1016
|
-
|
|
1017
|
-
throwIfAborted(options.signal);
|
|
1018
|
-
const name = getWorkerName(worker);
|
|
1019
|
-
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1020
|
-
const workerPool = workerFarm.getWorkerPool(getWorkerPoolTarget(worker, options, name));
|
|
1021
|
-
const jobName = options.jobName || worker.name;
|
|
1022
|
-
const job = await workerPool.startJob(
|
|
1023
|
-
jobName,
|
|
1024
|
-
// eslint-disable-next-line
|
|
1025
|
-
onMessage.bind(null, context, options),
|
|
1026
|
-
void 0,
|
|
1027
|
-
options.signal
|
|
1028
|
-
);
|
|
1029
|
-
try {
|
|
1030
|
-
if ((_a = options.signal) == null ? void 0 : _a.aborted) job.abort(getAbortReason(options.signal));
|
|
1031
|
-
const { signal: _signal, onProgress: _onProgress, ...workerOptions } = options;
|
|
1032
|
-
const transferableOptions = getTransferListForWriter(workerOptions);
|
|
1033
|
-
const transferableContext = getTransferListForWriter(jobContext);
|
|
1034
|
-
if (job.isRunning) {
|
|
1035
|
-
job.postMessage("process", {
|
|
1036
|
-
input: data,
|
|
1037
|
-
options: transferableOptions,
|
|
1038
|
-
context: transferableContext
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
const result = await job.result;
|
|
1042
|
-
return result.result;
|
|
1043
|
-
} catch (error) {
|
|
1044
|
-
job.abort(error);
|
|
1045
|
-
throw error;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
function processOnWorkerInBatches(worker, input, options = {}, context = {}, jobContext = {}) {
|
|
1049
|
-
return processOnWorkerInBatchesIterator(worker, input, options, context, jobContext);
|
|
1050
|
-
}
|
|
1051
|
-
async function* processOnWorkerInBatchesIterator(worker, input, options, context, jobContext) {
|
|
1052
|
-
throwIfAborted(options.signal);
|
|
1053
|
-
const name = getWorkerName(worker);
|
|
1054
|
-
const workerFarm = WorkerFarm.getWorkerFarm(options);
|
|
1055
|
-
const workerPool = workerFarm.getWorkerPool(getWorkerPoolTarget(worker, options, name));
|
|
1056
|
-
const outputBatches = new AsyncQueue();
|
|
1057
|
-
const inputIterator = getAsyncIterator(input);
|
|
1058
|
-
let outputFinished = false;
|
|
1059
|
-
let inputFinished = false;
|
|
1060
|
-
let inputCleanupRequested = false;
|
|
1061
|
-
let inputRequest = Promise.resolve();
|
|
1062
|
-
const batchJobFailed = new Error("Worker batch job failed");
|
|
1063
|
-
const closeJobInput = () => {
|
|
1064
|
-
if (!inputFinished && !inputCleanupRequested) {
|
|
1065
|
-
inputCleanupRequested = true;
|
|
1066
|
-
closeInputIterator(inputIterator);
|
|
1067
|
-
}
|
|
1068
|
-
};
|
|
1069
|
-
const finishOutput = () => {
|
|
1070
|
-
if (!outputFinished) {
|
|
1071
|
-
outputFinished = true;
|
|
1072
|
-
outputBatches.close();
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
const failOutput = (_error) => {
|
|
1076
|
-
if (!outputFinished) {
|
|
1077
|
-
outputFinished = true;
|
|
1078
|
-
outputBatches.enqueue(batchJobFailed);
|
|
1079
|
-
outputBatches.close();
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
const job = await workerPool.startJob(
|
|
1083
|
-
options.jobName || worker.name,
|
|
1084
|
-
(activeJob, type, payload) => {
|
|
1085
|
-
switch (type) {
|
|
1086
|
-
case "progress":
|
|
1087
|
-
reportProgress(activeJob, options, payload);
|
|
1088
|
-
break;
|
|
1089
|
-
case "input-request":
|
|
1090
|
-
inputRequest = inputRequest.then(async () => {
|
|
1091
|
-
if (!activeJob.isRunning) return;
|
|
1092
|
-
const nextBatch = await inputIterator.next();
|
|
1093
|
-
if (!activeJob.isRunning) {
|
|
1094
|
-
return;
|
|
1095
|
-
}
|
|
1096
|
-
if (nextBatch.done) {
|
|
1097
|
-
inputFinished = true;
|
|
1098
|
-
activeJob.postMessage("input-done", {});
|
|
1099
|
-
} else {
|
|
1100
|
-
activeJob.postMessage("input-batch", { input: nextBatch.value });
|
|
1101
|
-
}
|
|
1102
|
-
}).catch((error) => activeJob.abort(error));
|
|
1103
|
-
break;
|
|
1104
|
-
case "output-batch":
|
|
1105
|
-
outputBatches.push(payload.result);
|
|
1106
|
-
break;
|
|
1107
|
-
case "done":
|
|
1108
|
-
activeJob.done(payload);
|
|
1109
|
-
finishOutput();
|
|
1110
|
-
break;
|
|
1111
|
-
case "error": {
|
|
1112
|
-
const error = new Error(payload.error || "Worker batch processing failed");
|
|
1113
|
-
activeJob.error(error);
|
|
1114
|
-
failOutput(error);
|
|
1115
|
-
break;
|
|
1116
|
-
}
|
|
1117
|
-
case "process":
|
|
1118
|
-
void onMessage(context, options, activeJob, type, payload);
|
|
1119
|
-
break;
|
|
1120
|
-
default: {
|
|
1121
|
-
const error = new Error(`Unexpected worker batch message: ${type}`);
|
|
1122
|
-
activeJob.error(error);
|
|
1123
|
-
failOutput(error);
|
|
1124
|
-
break;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
},
|
|
1128
|
-
void 0,
|
|
1129
|
-
options.signal
|
|
1130
|
-
).catch((error) => {
|
|
1131
|
-
closeJobInput();
|
|
1132
|
-
throw error;
|
|
1133
|
-
});
|
|
1134
|
-
void job.result.catch((error) => {
|
|
1135
|
-
failOutput(error);
|
|
1136
|
-
closeJobInput();
|
|
1137
|
-
});
|
|
381
|
+
const session = await openSession(worker, options, context, jobContext);
|
|
1138
382
|
try {
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
options
|
|
1143
|
-
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
try {
|
|
1147
|
-
for await (const outputBatch of outputBatches) {
|
|
1148
|
-
yield outputBatch;
|
|
1149
|
-
if (job.isRunning) {
|
|
1150
|
-
job.postMessage("output-ack", {});
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
} catch (error) {
|
|
1154
|
-
if (error === batchJobFailed) {
|
|
1155
|
-
await job.result;
|
|
383
|
+
const result = await session.handle.runTask(
|
|
384
|
+
{ value: data },
|
|
385
|
+
{
|
|
386
|
+
...getControls(options),
|
|
387
|
+
options: getParserOptions(options)
|
|
1156
388
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
await job.result;
|
|
389
|
+
);
|
|
390
|
+
return result.value;
|
|
1160
391
|
} finally {
|
|
1161
|
-
|
|
1162
|
-
job.abort(createAbortError2("Worker batch iterator was closed"));
|
|
1163
|
-
}
|
|
1164
|
-
closeJobInput();
|
|
392
|
+
await session.close();
|
|
1165
393
|
}
|
|
1166
394
|
}
|
|
1167
|
-
function
|
|
1168
|
-
|
|
1169
|
-
|
|
395
|
+
async function* processOnWorkerInBatches(worker, input, options = {}, context = {}, jobContext = {}) {
|
|
396
|
+
var _a;
|
|
397
|
+
const taskInput = wrapInput(input);
|
|
398
|
+
let session;
|
|
399
|
+
try {
|
|
400
|
+
session = await openSession(worker, options, context, jobContext);
|
|
401
|
+
for await (const result of session.handle.runTaskInBatches(taskInput, {
|
|
402
|
+
...getControls(options),
|
|
403
|
+
options: getParserOptions(options)
|
|
404
|
+
}))
|
|
405
|
+
yield result.value;
|
|
406
|
+
} finally {
|
|
407
|
+
const closingInput = (_a = taskInput.return) == null ? void 0 : _a.call(taskInput);
|
|
408
|
+
void (closingInput == null ? void 0 : closingInput.catch(() => {
|
|
409
|
+
}));
|
|
410
|
+
await (session == null ? void 0 : session.close());
|
|
1170
411
|
}
|
|
1171
|
-
throw getAbortReason(signal);
|
|
1172
|
-
}
|
|
1173
|
-
function getAbortReason(signal) {
|
|
1174
|
-
return signal ? signal.reason : createAbortError2("Worker job was aborted");
|
|
1175
412
|
}
|
|
1176
|
-
function
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
413
|
+
function getTask(worker, options) {
|
|
414
|
+
var _a;
|
|
415
|
+
if (options.source || ((_a = options.core) == null ? void 0 : _a.source))
|
|
416
|
+
throw new Error(
|
|
417
|
+
"Inline legacy worker source is unsupported; use a TaskRunner worker URL or factory"
|
|
418
|
+
);
|
|
419
|
+
const create = !getCustomWorkerURL(worker, options) && isBrowser2 ? worker.loadWorker : void 0;
|
|
420
|
+
const url = getWorkerURL(worker, options);
|
|
421
|
+
return {
|
|
422
|
+
id: `${worker.module}:${worker.id}`,
|
|
423
|
+
initialize: (state) => state,
|
|
424
|
+
worker: {
|
|
425
|
+
...create ? { create: () => create() ?? createModuleWorker(url) } : { url },
|
|
426
|
+
capabilities: { atomic: true, streaming: true }
|
|
427
|
+
}
|
|
428
|
+
};
|
|
1180
429
|
}
|
|
1181
|
-
function
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
430
|
+
function getControls(options) {
|
|
431
|
+
return {
|
|
432
|
+
execution: "worker",
|
|
433
|
+
signal: options.signal,
|
|
434
|
+
inputOwnership: options.inputOwnership ?? "transfer",
|
|
435
|
+
outputOwnership: options.outputOwnership ?? "transfer",
|
|
436
|
+
onProgress: options.onProgress ? (progress) => {
|
|
437
|
+
var _a;
|
|
438
|
+
return (_a = options.onProgress) == null ? void 0 : _a.call(options, normalizeTaskProgress(progress));
|
|
439
|
+
} : void 0
|
|
440
|
+
};
|
|
1188
441
|
}
|
|
1189
|
-
function
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
void Promise.resolve((_a = inputIterator.return) == null ? void 0 : _a.call(inputIterator)).catch(() => void 0);
|
|
1193
|
-
} catch {
|
|
1194
|
-
}
|
|
442
|
+
function getParserOptions(options) {
|
|
443
|
+
const { signal, onProgress, parserOptions, ...workerOptions } = options;
|
|
444
|
+
return getTransferListForWriter(parserOptions ?? workerOptions);
|
|
1195
445
|
}
|
|
1196
|
-
function
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
if (
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
loadWorker: worker.loadWorker,
|
|
1208
|
-
getUrl: () => getWorkerURL(worker, options),
|
|
1209
|
-
urlKey: getDefaultWorkerURL(worker)
|
|
446
|
+
async function openSession(worker, options, context, jobContext) {
|
|
447
|
+
var _a, _b;
|
|
448
|
+
(_a = options.signal) == null ? void 0 : _a.throwIfAborted();
|
|
449
|
+
const task = getTask(worker, options);
|
|
450
|
+
let state = runners.get(worker);
|
|
451
|
+
if (!state) {
|
|
452
|
+
state = {
|
|
453
|
+
runner: new import_tasks2.TaskRunner({
|
|
454
|
+
maxConcurrency: isMobile ? options.maxMobileConcurrency ?? 1 : options.maxConcurrency ?? 3
|
|
455
|
+
}),
|
|
456
|
+
requests: 0
|
|
1210
457
|
};
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
458
|
+
runners.set(worker, state);
|
|
459
|
+
}
|
|
460
|
+
const runnerState = state;
|
|
461
|
+
const channel = context.process ? new MessageChannel() : void 0;
|
|
462
|
+
const callbackController = new AbortController();
|
|
463
|
+
let channelClosed = false;
|
|
464
|
+
const abortCallbacks = () => {
|
|
465
|
+
var _a2;
|
|
466
|
+
return callbackController.abort((_a2 = options.signal) == null ? void 0 : _a2.reason);
|
|
467
|
+
};
|
|
468
|
+
(_b = options.signal) == null ? void 0 : _b.addEventListener("abort", abortCallbacks, { once: true });
|
|
469
|
+
const closeChannel = () => {
|
|
470
|
+
var _a2;
|
|
471
|
+
channelClosed = true;
|
|
472
|
+
(_a2 = options.signal) == null ? void 0 : _a2.removeEventListener("abort", abortCallbacks);
|
|
473
|
+
callbackController.abort();
|
|
474
|
+
channel == null ? void 0 : channel.port1.close();
|
|
475
|
+
channel == null ? void 0 : channel.port2.close();
|
|
476
|
+
};
|
|
477
|
+
if (channel) {
|
|
478
|
+
channel.port1.onmessage = async ({ data }) => {
|
|
479
|
+
try {
|
|
480
|
+
const value = await context.process(
|
|
481
|
+
data.input,
|
|
482
|
+
data.options,
|
|
483
|
+
{
|
|
484
|
+
signal: callbackController.signal,
|
|
485
|
+
throwIfAborted: () => callbackController.signal.throwIfAborted()
|
|
486
|
+
},
|
|
487
|
+
data.context
|
|
488
|
+
);
|
|
489
|
+
if (!channelClosed && !callbackController.signal.aborted)
|
|
490
|
+
channel.port1.postMessage({ identifier: data.identifier, value }, getTransferList(value));
|
|
491
|
+
} catch (error) {
|
|
492
|
+
if (channelClosed || callbackController.signal.aborted) return;
|
|
493
|
+
channel.port1.postMessage({
|
|
494
|
+
identifier: data.identifier,
|
|
495
|
+
error: {
|
|
496
|
+
name: error instanceof Error ? error.name : "Error",
|
|
497
|
+
message: error instanceof Error ? error.message : String(error)
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
channel.port1.start();
|
|
503
|
+
}
|
|
504
|
+
runnerState.requests++;
|
|
505
|
+
activeRunners.add(runnerState);
|
|
506
|
+
let released = false;
|
|
507
|
+
const releaseRunner = () => {
|
|
508
|
+
if (released) return;
|
|
509
|
+
released = true;
|
|
510
|
+
runnerState.requests--;
|
|
511
|
+
if (!runnerState.requests) activeRunners.delete(runnerState);
|
|
512
|
+
};
|
|
513
|
+
let handle;
|
|
514
|
+
try {
|
|
515
|
+
handle = await runnerState.runner.initializeTask(
|
|
516
|
+
task,
|
|
517
|
+
{
|
|
518
|
+
context: structuredClone(jobContext),
|
|
519
|
+
...channel ? { port: channel.port2 } : {}
|
|
520
|
+
},
|
|
521
|
+
// The callback port is setup state, independent of the caller's payload ownership.
|
|
522
|
+
{ ...getControls(options), inputOwnership: "transfer" }
|
|
523
|
+
);
|
|
524
|
+
} catch (error) {
|
|
525
|
+
releaseRunner();
|
|
526
|
+
closeChannel();
|
|
527
|
+
throw error;
|
|
528
|
+
}
|
|
529
|
+
return {
|
|
530
|
+
handle,
|
|
531
|
+
/** Releases the worker and callback channel on success, failure, and early stream return. */
|
|
532
|
+
async close() {
|
|
1227
533
|
try {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
const result = await context.process(
|
|
1233
|
-
input,
|
|
1234
|
-
{ ...processOptions, signal: options.signal, onProgress: options.onProgress },
|
|
1235
|
-
void 0,
|
|
1236
|
-
payload.context || {}
|
|
1237
|
-
);
|
|
1238
|
-
job.postMessage("done", { id, result });
|
|
1239
|
-
} catch (error) {
|
|
1240
|
-
const message = error instanceof Error ? error.message : "unknown error";
|
|
1241
|
-
job.postMessage("error", { id, error: message });
|
|
534
|
+
await handle.close();
|
|
535
|
+
} finally {
|
|
536
|
+
closeChannel();
|
|
537
|
+
releaseRunner();
|
|
1242
538
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function wrapInput(input) {
|
|
543
|
+
const iterator = Symbol.asyncIterator in input ? input[Symbol.asyncIterator]() : input[Symbol.iterator]();
|
|
544
|
+
let inputClosed = false;
|
|
545
|
+
return {
|
|
546
|
+
[Symbol.asyncIterator]() {
|
|
547
|
+
return this;
|
|
548
|
+
},
|
|
549
|
+
async next() {
|
|
550
|
+
if (inputClosed) return { done: true, value: void 0 };
|
|
551
|
+
const next = await iterator.next();
|
|
552
|
+
if (next.done || inputClosed) {
|
|
553
|
+
inputClosed = true;
|
|
554
|
+
return { done: true, value: void 0 };
|
|
555
|
+
}
|
|
556
|
+
return { done: false, value: { value: next.value } };
|
|
557
|
+
},
|
|
558
|
+
async return() {
|
|
559
|
+
var _a;
|
|
560
|
+
if (!inputClosed) {
|
|
561
|
+
inputClosed = true;
|
|
562
|
+
await ((_a = iterator.return) == null ? void 0 : _a.call(iterator));
|
|
563
|
+
}
|
|
564
|
+
return { done: true, value: void 0 };
|
|
565
|
+
}
|
|
566
|
+
};
|
|
1247
567
|
}
|
|
1248
|
-
function
|
|
568
|
+
function createModuleWorker(url) {
|
|
1249
569
|
var _a;
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
570
|
+
const resolved = new URL(url, ((_a = globalThis.document) == null ? void 0 : _a.baseURI) ?? globalThis.location.href);
|
|
571
|
+
let workerUrl = resolved.href;
|
|
572
|
+
if (/^https?:$/.test(resolved.protocol) && resolved.origin !== globalThis.location.origin) {
|
|
573
|
+
let shimUrl = moduleWorkerUrls.get(resolved.href);
|
|
574
|
+
if (!shimUrl) {
|
|
575
|
+
shimUrl = URL.createObjectURL(
|
|
576
|
+
new Blob([`import ${JSON.stringify(resolved.href)};`], { type: "application/javascript" })
|
|
577
|
+
);
|
|
578
|
+
moduleWorkerUrls.set(resolved.href, shimUrl);
|
|
579
|
+
}
|
|
580
|
+
workerUrl = shimUrl;
|
|
1255
581
|
}
|
|
582
|
+
return new Worker(workerUrl, { type: "module" });
|
|
1256
583
|
}
|
|
1257
584
|
|
|
1258
585
|
// src/worker-utils/lib/worker-api/validate-worker-version.ts
|
|
@@ -1275,8 +602,7 @@ function canParseWithWorker(loader, options) {
|
|
|
1275
602
|
(credential) => credential.type === "request" || "token" in credential && typeof credential.token === "function"
|
|
1276
603
|
))
|
|
1277
604
|
return false;
|
|
1278
|
-
if (loader.id === "shapefile" &&
|
|
1279
|
-
return false;
|
|
605
|
+
if (loader.id === "shapefile" && typeof ((_e = options == null ? void 0 : options.core) == null ? void 0 : _e.fetch) === "function") return false;
|
|
1280
606
|
const workerOptions = getWorkerOptions(options);
|
|
1281
607
|
const nodeWorkers = workerOptions._nodeWorkers;
|
|
1282
608
|
if (!isBrowser2 && !nodeWorkers) {
|
|
@@ -1325,12 +651,16 @@ async function parseWithWorker(loader, data, options, context, parseOnMainThread
|
|
|
1325
651
|
onProgress: (options == null ? void 0 : options.onProgress) || (context == null ? void 0 : context.reportProgress)
|
|
1326
652
|
},
|
|
1327
653
|
{
|
|
1328
|
-
process: async (input, processOptions,
|
|
654
|
+
process: async (input, processOptions, workerContext, parseContext) => {
|
|
1329
655
|
if (!parseOnMainThread) {
|
|
1330
656
|
throw new Error("Worker not set up to parse on main thread");
|
|
1331
657
|
}
|
|
1332
658
|
const { _loaderIds, _loaderIsArray, ...workerParseContext } = parseContext || {};
|
|
1333
|
-
const mainThreadContext = context || parseContext
|
|
659
|
+
const mainThreadContext = context || parseContext || (workerContext == null ? void 0 : workerContext.signal) ? {
|
|
660
|
+
...context,
|
|
661
|
+
...workerParseContext,
|
|
662
|
+
signal: (workerContext == null ? void 0 : workerContext.signal) ?? (context == null ? void 0 : context.signal)
|
|
663
|
+
} : void 0;
|
|
1334
664
|
return await callParseOnMainThread(
|
|
1335
665
|
parseOnMainThread,
|
|
1336
666
|
input,
|
|
@@ -1355,12 +685,16 @@ async function* parseWithWorkerInBatches(loader, inputIterator, options, context
|
|
|
1355
685
|
onProgress: (options == null ? void 0 : options.onProgress) || (context == null ? void 0 : context.reportProgress)
|
|
1356
686
|
},
|
|
1357
687
|
{
|
|
1358
|
-
process: async (input, processOptions,
|
|
688
|
+
process: async (input, processOptions, workerContext, parseContext) => {
|
|
1359
689
|
if (!parseOnMainThread) {
|
|
1360
690
|
throw new Error("Worker not set up to parse on main thread");
|
|
1361
691
|
}
|
|
1362
692
|
const { _loaderIds, _loaderIsArray, ...workerParseContext } = parseContext || {};
|
|
1363
|
-
const mainThreadContext = context || parseContext
|
|
693
|
+
const mainThreadContext = context || parseContext || (workerContext == null ? void 0 : workerContext.signal) ? {
|
|
694
|
+
...context,
|
|
695
|
+
...workerParseContext,
|
|
696
|
+
signal: (workerContext == null ? void 0 : workerContext.signal) ?? (context == null ? void 0 : context.signal)
|
|
697
|
+
} : void 0;
|
|
1364
698
|
return await callParseOnMainThread(
|
|
1365
699
|
parseOnMainThread,
|
|
1366
700
|
input,
|
|
@@ -1421,13 +755,19 @@ function resolveWorkerLoaders(loader, loaderIds, loaderIsArray, context, options
|
|
|
1421
755
|
}
|
|
1422
756
|
}
|
|
1423
757
|
function getWorkerOptions(options = {}, loader) {
|
|
1424
|
-
var _a;
|
|
758
|
+
var _a, _b;
|
|
1425
759
|
const portableOptions = ((_a = loader == null ? void 0 : loader.serializeWorkerOptions) == null ? void 0 : _a.call(loader, options)) || options;
|
|
1426
760
|
const optionsToSerialize = {
|
|
1427
761
|
...portableOptions,
|
|
1428
762
|
signal: void 0,
|
|
1429
763
|
onProgress: void 0,
|
|
1430
|
-
...portableOptions.core ? {
|
|
764
|
+
...portableOptions.core ? {
|
|
765
|
+
core: {
|
|
766
|
+
...portableOptions.core,
|
|
767
|
+
authentications: void 0,
|
|
768
|
+
log: isDisabledLog(portableOptions.core.log) ? null : void 0
|
|
769
|
+
}
|
|
770
|
+
} : {}
|
|
1431
771
|
};
|
|
1432
772
|
const serializedOptions = JSON.parse(
|
|
1433
773
|
JSON.stringify(optionsToSerialize, (_key, value) => {
|
|
@@ -1438,17 +778,17 @@ function getWorkerOptions(options = {}, loader) {
|
|
|
1438
778
|
})
|
|
1439
779
|
);
|
|
1440
780
|
restoreBigIntOptions(optionsToSerialize, serializedOptions);
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
...serializedOptions
|
|
1444
|
-
};
|
|
1445
|
-
if (workerOptions.worker === "auto") {
|
|
1446
|
-
workerOptions.worker = true;
|
|
781
|
+
if (((_b = serializedOptions.core) == null ? void 0 : _b.worker) === "auto") {
|
|
782
|
+
serializedOptions.core.worker = true;
|
|
1447
783
|
}
|
|
1448
784
|
if (loader) {
|
|
1449
|
-
|
|
785
|
+
serializedOptions._workerLoaderId = loader.id;
|
|
1450
786
|
}
|
|
1451
|
-
return
|
|
787
|
+
return {
|
|
788
|
+
...serializedOptions,
|
|
789
|
+
...serializedOptions.core,
|
|
790
|
+
parserOptions: serializedOptions
|
|
791
|
+
};
|
|
1452
792
|
}
|
|
1453
793
|
function restoreBigIntOptions(original, serialized) {
|
|
1454
794
|
if (!serialized || typeof serialized !== "object") return;
|
|
@@ -1467,7 +807,7 @@ function getSerializableLoaderContext(context) {
|
|
|
1467
807
|
loaders,
|
|
1468
808
|
coreApi: coreApi2,
|
|
1469
809
|
signal,
|
|
1470
|
-
reportProgress
|
|
810
|
+
reportProgress,
|
|
1471
811
|
_parse,
|
|
1472
812
|
_parseSync,
|
|
1473
813
|
_parseInBatches,
|
|
@@ -1478,24 +818,27 @@ function getSerializableLoaderContext(context) {
|
|
|
1478
818
|
function shouldParseCSVWithWorker(options) {
|
|
1479
819
|
var _a, _b;
|
|
1480
820
|
const csvOptions = options;
|
|
1481
|
-
return (((_a = csvOptions == null ? void 0 : csvOptions.csv) == null ? void 0 : _a.shape) ?? ((_b = csvOptions == null ? void 0 : csvOptions.core) == null ? void 0 : _b.shape)) === "arrow
|
|
821
|
+
return (((_a = csvOptions == null ? void 0 : csvOptions.csv) == null ? void 0 : _a.shape) ?? ((_b = csvOptions == null ? void 0 : csvOptions.core) == null ? void 0 : _b.shape)) === "arrow";
|
|
1482
822
|
}
|
|
1483
823
|
function isLoaderWithWorkerResultDeserializer(loader) {
|
|
1484
824
|
return typeof loader.deserializeWorkerResult === "function";
|
|
1485
825
|
}
|
|
826
|
+
function isDisabledLog(logger) {
|
|
827
|
+
return logger === null || logger instanceof NullLog;
|
|
828
|
+
}
|
|
1486
829
|
|
|
1487
830
|
// src/loader-utils/lib/worker-loader-utils/encode-with-worker.ts
|
|
1488
831
|
function canEncodeWithWorker(writer, options) {
|
|
1489
832
|
var _a, _b;
|
|
1490
|
-
if (!WorkerFarm.isSupported()) {
|
|
1491
|
-
return false;
|
|
1492
|
-
}
|
|
1493
833
|
const nodeWorkers = (options == null ? void 0 : options._nodeWorkers) ?? ((_a = options == null ? void 0 : options.core) == null ? void 0 : _a._nodeWorkers);
|
|
1494
834
|
const useWorkers = (options == null ? void 0 : options.worker) ?? ((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.worker);
|
|
1495
835
|
if (!isBrowser && !nodeWorkers) {
|
|
1496
836
|
return false;
|
|
1497
837
|
}
|
|
1498
|
-
return
|
|
838
|
+
return canProcessOnWorker(
|
|
839
|
+
{ ...writer, options: writer.options || {} },
|
|
840
|
+
{ worker: Boolean(useWorkers), _nodeWorkers: Boolean(nodeWorkers) }
|
|
841
|
+
);
|
|
1499
842
|
}
|
|
1500
843
|
|
|
1501
844
|
// src/loader-utils/lib/binary-utils/array-buffer-utils.ts
|
|
@@ -1658,7 +1001,7 @@ var STAT_ACTIVE_REQUESTS = "Active Requests";
|
|
|
1658
1001
|
var STAT_CANCELLED_REQUESTS = "Cancelled Requests";
|
|
1659
1002
|
var STAT_QUEUED_REQUESTS_EVER = "Queued Requests Ever";
|
|
1660
1003
|
var STAT_ACTIVE_REQUESTS_EVER = "Active Requests Ever";
|
|
1661
|
-
var
|
|
1004
|
+
var DEFAULT_PROPS = {
|
|
1662
1005
|
id: "request-scheduler",
|
|
1663
1006
|
/** Specifies if the request scheduler should throttle incoming requests, mainly for comparative testing. */
|
|
1664
1007
|
throttleRequests: true,
|
|
@@ -1680,7 +1023,7 @@ var RequestScheduler = class {
|
|
|
1680
1023
|
/** Pending arrival debounce or next-tick refill; only new arrivals replace this timer. */
|
|
1681
1024
|
updateTimer = null;
|
|
1682
1025
|
constructor(props = {}) {
|
|
1683
|
-
this.props = { ...
|
|
1026
|
+
this.props = { ...DEFAULT_PROPS, ...props };
|
|
1684
1027
|
this.stats = new import_stats.Stats({ id: this.props.id });
|
|
1685
1028
|
this.stats.get(STAT_QUEUED_REQUESTS);
|
|
1686
1029
|
this.stats.get(STAT_ACTIVE_REQUESTS);
|
|
@@ -2399,9 +1742,50 @@ var NodeFileFacade = class {
|
|
|
2399
1742
|
}
|
|
2400
1743
|
};
|
|
2401
1744
|
|
|
2402
|
-
// src/loader-utils/
|
|
2403
|
-
function
|
|
2404
|
-
|
|
1745
|
+
// src/loader-utils/lib/pace-batch-iterator.ts
|
|
1746
|
+
function validateBatchDeliveryRate(rate) {
|
|
1747
|
+
if (!Number.isFinite(rate) || rate < 0) {
|
|
1748
|
+
throw new RangeError("core.batchMaxRowsPerSecond must be a finite nonnegative number");
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
async function* paceBatchIterator(batches, { batchMaxRowsPerSecond = 0, getRowCount, signal }) {
|
|
1752
|
+
validateBatchDeliveryRate(batchMaxRowsPerSecond);
|
|
1753
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
1754
|
+
if (batchMaxRowsPerSecond === 0) {
|
|
1755
|
+
yield* batches;
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
let deadline = 0;
|
|
1759
|
+
for await (const batch of batches) {
|
|
1760
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
1761
|
+
const rowCount = getRowCount(batch);
|
|
1762
|
+
if (rowCount !== void 0 && rowCount > 0) {
|
|
1763
|
+
let remaining = deadline - performance.now();
|
|
1764
|
+
while (remaining > 0) {
|
|
1765
|
+
await waitForBatch(Math.min(Math.ceil(remaining), 2 ** 31 - 1), signal);
|
|
1766
|
+
remaining = deadline - performance.now();
|
|
1767
|
+
}
|
|
1768
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
1769
|
+
deadline = performance.now() + rowCount / batchMaxRowsPerSecond * 1e3;
|
|
1770
|
+
}
|
|
1771
|
+
yield batch;
|
|
1772
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
function waitForBatch(delay, signal) {
|
|
1776
|
+
signal == null ? void 0 : signal.throwIfAborted();
|
|
1777
|
+
return new Promise((resolve2, reject) => {
|
|
1778
|
+
const timer = setTimeout(() => {
|
|
1779
|
+
signal == null ? void 0 : signal.removeEventListener("abort", abort);
|
|
1780
|
+
resolve2();
|
|
1781
|
+
}, delay);
|
|
1782
|
+
function abort() {
|
|
1783
|
+
clearTimeout(timer);
|
|
1784
|
+
signal == null ? void 0 : signal.removeEventListener("abort", abort);
|
|
1785
|
+
reject(signal == null ? void 0 : signal.reason);
|
|
1786
|
+
}
|
|
1787
|
+
signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
|
|
1788
|
+
});
|
|
2405
1789
|
}
|
|
2406
1790
|
|
|
2407
1791
|
// dist/lib/fetch/fetch-error.js
|
|
@@ -2628,71 +2012,47 @@ async function readBlob(blob) {
|
|
|
2628
2012
|
}
|
|
2629
2013
|
|
|
2630
2014
|
// dist/lib/loader-utils/loggers.js
|
|
2631
|
-
var
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2015
|
+
var import_log6 = require("probe.gl/log");
|
|
2016
|
+
|
|
2017
|
+
// dist/loader-utils/lib/log-utils/log.js
|
|
2018
|
+
var import_log5 = require("probe.gl/log");
|
|
2019
|
+
var VERSION4 = true ? "5.0.0-beta.10" : "latest";
|
|
2020
|
+
var version2 = VERSION4[0] >= "0" && VERSION4[0] <= "9" ? `v${VERSION4}` : "";
|
|
2021
|
+
function createLog2() {
|
|
2022
|
+
const log3 = new import_log5.Log({ id: "loaders.gl" });
|
|
2023
|
+
globalThis.loaders ||= {};
|
|
2024
|
+
globalThis.loaders.log = log3;
|
|
2025
|
+
globalThis.loaders.version = version2;
|
|
2026
|
+
globalThis.probe ||= {};
|
|
2027
|
+
globalThis.probe.loaders = log3;
|
|
2028
|
+
return log3;
|
|
2029
|
+
}
|
|
2030
|
+
var log2 = createLog2();
|
|
2031
|
+
var NullLog2 = class {
|
|
2032
|
+
/** Discards debug messages. */
|
|
2635
2033
|
log() {
|
|
2636
|
-
return
|
|
2637
|
-
};
|
|
2034
|
+
return ignoreMessage2;
|
|
2638
2035
|
}
|
|
2639
|
-
/**
|
|
2036
|
+
/** Discards informational messages. */
|
|
2640
2037
|
info() {
|
|
2641
|
-
return
|
|
2642
|
-
};
|
|
2038
|
+
return ignoreMessage2;
|
|
2643
2039
|
}
|
|
2644
|
-
/**
|
|
2040
|
+
/** Discards messages marked to be emitted once. */
|
|
2645
2041
|
once() {
|
|
2646
|
-
return
|
|
2647
|
-
};
|
|
2042
|
+
return ignoreMessage2;
|
|
2648
2043
|
}
|
|
2649
|
-
/**
|
|
2044
|
+
/** Discards warnings. */
|
|
2650
2045
|
warn() {
|
|
2651
|
-
return
|
|
2652
|
-
};
|
|
2046
|
+
return ignoreMessage2;
|
|
2653
2047
|
}
|
|
2654
|
-
/**
|
|
2048
|
+
/** Discards errors. */
|
|
2655
2049
|
error() {
|
|
2656
|
-
return
|
|
2657
|
-
};
|
|
2658
|
-
}
|
|
2659
|
-
};
|
|
2660
|
-
var ConsoleLog = class {
|
|
2661
|
-
/** Console-like object used for message output. */
|
|
2662
|
-
console;
|
|
2663
|
-
/** Messages already emitted through `once`. */
|
|
2664
|
-
onceMessages = /* @__PURE__ */ new Set();
|
|
2665
|
-
/** Creates a console-backed logger. */
|
|
2666
|
-
constructor() {
|
|
2667
|
-
this.console = console;
|
|
2668
|
-
}
|
|
2669
|
-
/** Logs a message to the console. */
|
|
2670
|
-
log(...args) {
|
|
2671
|
-
return this.console.log.bind(this.console, ...args);
|
|
2672
|
-
}
|
|
2673
|
-
/** Logs an informational message to the console. */
|
|
2674
|
-
info(...args) {
|
|
2675
|
-
return this.console.info.bind(this.console, ...args);
|
|
2676
|
-
}
|
|
2677
|
-
/** Logs one message once to the console. */
|
|
2678
|
-
once(...args) {
|
|
2679
|
-
const message = String(args[0]);
|
|
2680
|
-
if (this.onceMessages.has(message)) {
|
|
2681
|
-
return () => {
|
|
2682
|
-
};
|
|
2683
|
-
}
|
|
2684
|
-
this.onceMessages.add(message);
|
|
2685
|
-
return this.console.info.bind(this.console, ...args);
|
|
2686
|
-
}
|
|
2687
|
-
/** Logs a warning message to the console. */
|
|
2688
|
-
warn(...args) {
|
|
2689
|
-
return this.console.warn.bind(this.console, ...args);
|
|
2690
|
-
}
|
|
2691
|
-
/** Logs an error message to the console. */
|
|
2692
|
-
error(...args) {
|
|
2693
|
-
return this.console.error.bind(this.console, ...args);
|
|
2050
|
+
return ignoreMessage2;
|
|
2694
2051
|
}
|
|
2695
2052
|
};
|
|
2053
|
+
function ignoreMessage2() {
|
|
2054
|
+
}
|
|
2055
|
+
var nullLog2 = new NullLog2();
|
|
2696
2056
|
|
|
2697
2057
|
// dist/lib/loader-utils/option-defaults.js
|
|
2698
2058
|
var DEFAULT_LOADER_OPTIONS = {
|
|
@@ -2706,8 +2066,7 @@ var DEFAULT_LOADER_OPTIONS = {
|
|
|
2706
2066
|
ignoreRegisteredLoaders: void 0,
|
|
2707
2067
|
nothrow: false,
|
|
2708
2068
|
shape: void 0,
|
|
2709
|
-
log:
|
|
2710
|
-
// A probe.gl compatible (`log.log()()` syntax) that just logs to console
|
|
2069
|
+
log: log2,
|
|
2711
2070
|
useLocalLibraries: false,
|
|
2712
2071
|
subloaders: void 0,
|
|
2713
2072
|
CDN: "https://unpkg.com/@loaders.gl",
|
|
@@ -2725,18 +2084,17 @@ var DEFAULT_LOADER_OPTIONS = {
|
|
|
2725
2084
|
// By default do not support node workers
|
|
2726
2085
|
_workerType: "",
|
|
2727
2086
|
// 'test' to use locally generated workers
|
|
2728
|
-
limit: 0,
|
|
2729
|
-
_limitMB: 0,
|
|
2730
2087
|
batchSize: "auto",
|
|
2731
|
-
|
|
2088
|
+
batchMaxRowsPerSecond: 0,
|
|
2732
2089
|
metadata: false,
|
|
2733
2090
|
// TODO - currently only implemented for parseInBatches, adds initial metadata batch,
|
|
2734
2091
|
transforms: []
|
|
2735
2092
|
}
|
|
2736
2093
|
};
|
|
2737
2094
|
var REMOVED_LOADER_OPTIONS = {
|
|
2738
|
-
//
|
|
2095
|
+
// Removed top-level aliases
|
|
2739
2096
|
baseUri: "core.baseUrl",
|
|
2097
|
+
baseUrl: "core.baseUrl",
|
|
2740
2098
|
fetch: "core.fetch",
|
|
2741
2099
|
mimeType: "core.mimeType",
|
|
2742
2100
|
fallbackMimeType: "core.fallbackMimeType",
|
|
@@ -2746,17 +2104,17 @@ var REMOVED_LOADER_OPTIONS = {
|
|
|
2746
2104
|
useLocalLibraries: "core.useLocalLibraries",
|
|
2747
2105
|
CDN: "core.CDN",
|
|
2748
2106
|
worker: "core.worker",
|
|
2107
|
+
workerThreshold: "core.workerThreshold",
|
|
2108
|
+
workerTransferBufferCopy: "core.workerTransferBufferCopy",
|
|
2749
2109
|
maxConcurrency: "core.maxConcurrency",
|
|
2750
2110
|
maxMobileConcurrency: "core.maxMobileConcurrency",
|
|
2751
2111
|
reuseWorkers: "core.reuseWorkers",
|
|
2752
|
-
_nodeWorkers: "core.
|
|
2112
|
+
_nodeWorkers: "core._nodeWorkers",
|
|
2753
2113
|
_workerType: "core._workerType",
|
|
2754
2114
|
_worker: "core._workerType",
|
|
2755
|
-
limit: "core.limit",
|
|
2756
|
-
_limitMB: "core._limitMB",
|
|
2757
2115
|
shape: "core.shape",
|
|
2758
2116
|
batchSize: "core.batchSize",
|
|
2759
|
-
batchDebounceMs: "core.
|
|
2117
|
+
batchDebounceMs: "(removed; use core.batchMaxRowsPerSecond)",
|
|
2760
2118
|
metadata: "core.metadata",
|
|
2761
2119
|
transforms: "core.transforms",
|
|
2762
2120
|
// Older deprecations
|
|
@@ -2778,33 +2136,66 @@ var REMOVED_LOADER_OPTIONS = {
|
|
|
2778
2136
|
signal: "core.fetch.signal"
|
|
2779
2137
|
};
|
|
2780
2138
|
|
|
2139
|
+
// dist/lib/loader-utils/native-arrow.js
|
|
2140
|
+
function getShapeOptionKey(loader) {
|
|
2141
|
+
const keys = Object.keys(loader.options || {}).filter((key) => {
|
|
2142
|
+
var _a;
|
|
2143
|
+
const value = (_a = loader.options) == null ? void 0 : _a[key];
|
|
2144
|
+
return key !== "core" && value && typeof value === "object" && "shape" in value;
|
|
2145
|
+
});
|
|
2146
|
+
return keys.includes(loader.id) ? loader.id : keys.length === 1 ? keys[0] : void 0;
|
|
2147
|
+
}
|
|
2148
|
+
function getNativeArrowOptions(loader, options, inBatches = false) {
|
|
2149
|
+
var _a, _b;
|
|
2150
|
+
const key = getShapeOptionKey(loader);
|
|
2151
|
+
const scopedOptions = key && options[key];
|
|
2152
|
+
if (loader.supportsNativeArrow && scopedOptions && typeof scopedOptions === "object" && "shape" in scopedOptions && scopedOptions.shape === "arrow-table") {
|
|
2153
|
+
throw new Error('This loader uses shape: "arrow" for native Arrow output');
|
|
2154
|
+
}
|
|
2155
|
+
if (!scopedOptions || typeof scopedOptions !== "object" || !("shape" in scopedOptions) || scopedOptions.shape !== "arrow") {
|
|
2156
|
+
return null;
|
|
2157
|
+
}
|
|
2158
|
+
if (inBatches && ((_a = options.core) == null ? void 0 : _a.metadata)) {
|
|
2159
|
+
throw new Error('shape: "arrow" carries metadata in the Arrow schema and does not support core.metadata envelopes');
|
|
2160
|
+
}
|
|
2161
|
+
if (loader.supportsNativeArrow)
|
|
2162
|
+
return options;
|
|
2163
|
+
return {
|
|
2164
|
+
...options,
|
|
2165
|
+
core: { ...options.core, ...((_b = options.core) == null ? void 0 : _b.shape) === "arrow" ? { shape: "arrow-table" } : {} },
|
|
2166
|
+
[key]: { ...scopedOptions, shape: "arrow-table" }
|
|
2167
|
+
};
|
|
2168
|
+
}
|
|
2169
|
+
function unwrapArrowTable(result, nativeParser) {
|
|
2170
|
+
var _a;
|
|
2171
|
+
const table = result;
|
|
2172
|
+
if ((table == null ? void 0 : table.shape) === "arrow-table" && Array.isArray((_a = table.data) == null ? void 0 : _a.batches))
|
|
2173
|
+
return table.data;
|
|
2174
|
+
if (nativeParser || isNativeArrowTable(result))
|
|
2175
|
+
return result;
|
|
2176
|
+
throw new Error('shape: "arrow" requires a loader that supports "arrow-table" output');
|
|
2177
|
+
}
|
|
2178
|
+
async function* unwrapArrowBatches(batches) {
|
|
2179
|
+
for await (const batch of batches) {
|
|
2180
|
+
const batchType = batch == null ? void 0 : batch.batchType;
|
|
2181
|
+
if (batchType === "metadata" || batchType === "partial-result" || batchType === "final-result") {
|
|
2182
|
+
continue;
|
|
2183
|
+
}
|
|
2184
|
+
if (isNativeArrowRecordBatch(batch)) {
|
|
2185
|
+
yield batch;
|
|
2186
|
+
} else {
|
|
2187
|
+
yield* unwrapArrowTable(batch).batches;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
function isNativeArrowTable(value) {
|
|
2192
|
+
return Boolean(value && typeof value === "object" && "schema" in value && "batches" in value && Array.isArray(value.batches) && "numRows" in value && typeof value.numRows === "number" && "getChildAt" in value && typeof value.getChildAt === "function");
|
|
2193
|
+
}
|
|
2194
|
+
function isNativeArrowRecordBatch(value) {
|
|
2195
|
+
return Boolean(value && typeof value === "object" && value[/* @__PURE__ */ Symbol.for("apache-arrow/RecordBatch")] === true);
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2781
2198
|
// dist/lib/loader-utils/option-utils.js
|
|
2782
|
-
var CORE_LOADER_OPTION_KEYS = [
|
|
2783
|
-
"baseUrl",
|
|
2784
|
-
"fetch",
|
|
2785
|
-
"mimeType",
|
|
2786
|
-
"fallbackMimeType",
|
|
2787
|
-
"ignoreRegisteredLoaders",
|
|
2788
|
-
"nothrow",
|
|
2789
|
-
"log",
|
|
2790
|
-
"useLocalLibraries",
|
|
2791
|
-
"CDN",
|
|
2792
|
-
"worker",
|
|
2793
|
-
"workerThreshold",
|
|
2794
|
-
"maxConcurrency",
|
|
2795
|
-
"maxMobileConcurrency",
|
|
2796
|
-
"reuseWorkers",
|
|
2797
|
-
"workerTransferBufferCopy",
|
|
2798
|
-
"_nodeWorkers",
|
|
2799
|
-
"_workerType",
|
|
2800
|
-
"limit",
|
|
2801
|
-
"_limitMB",
|
|
2802
|
-
"shape",
|
|
2803
|
-
"batchSize",
|
|
2804
|
-
"batchDebounceMs",
|
|
2805
|
-
"metadata",
|
|
2806
|
-
"transforms"
|
|
2807
|
-
];
|
|
2808
2199
|
function applySearchParamsToUrl(url, options) {
|
|
2809
2200
|
const searchParams = options == null ? void 0 : options.searchParams;
|
|
2810
2201
|
if (!searchParams || Object.keys(searchParams).length === 0 || /^(?:data|blob):/i.test(url)) {
|
|
@@ -2840,12 +2231,15 @@ function getGlobalLoaderOptions() {
|
|
|
2840
2231
|
...DEFAULT_LOADER_OPTIONS,
|
|
2841
2232
|
core: { ...DEFAULT_LOADER_OPTIONS.core }
|
|
2842
2233
|
};
|
|
2843
|
-
return
|
|
2234
|
+
return cloneLoaderOptions(state.globalOptions);
|
|
2844
2235
|
}
|
|
2845
2236
|
function setGlobalOptions(options) {
|
|
2846
2237
|
const state = getGlobalLoaderState();
|
|
2847
2238
|
const globalOptions = getGlobalLoaderOptions();
|
|
2848
|
-
|
|
2239
|
+
validateOptions(options, []);
|
|
2240
|
+
validateWorkerThreshold(options);
|
|
2241
|
+
mergeNestedFields(globalOptions, options);
|
|
2242
|
+
state.globalOptions = globalOptions;
|
|
2849
2243
|
registerJSModules(options.modules);
|
|
2850
2244
|
}
|
|
2851
2245
|
function normalizeOptions(options, loader, loaders, url) {
|
|
@@ -2853,23 +2247,10 @@ function normalizeOptions(options, loader, loaders, url) {
|
|
|
2853
2247
|
loaders = Array.isArray(loaders) ? loaders : [loaders];
|
|
2854
2248
|
validateOptions(options, loaders);
|
|
2855
2249
|
validateWorkerThreshold(options);
|
|
2856
|
-
const normalizedOptions =
|
|
2250
|
+
const normalizedOptions = normalizeOptionsInternal(loader, options, url);
|
|
2857
2251
|
validateWorkerThreshold(normalizedOptions);
|
|
2858
2252
|
return normalizedOptions;
|
|
2859
2253
|
}
|
|
2860
|
-
function normalizeLoaderOptions(options) {
|
|
2861
|
-
const normalized = cloneLoaderOptions(options);
|
|
2862
|
-
moveDeprecatedTopLevelOptionsToCore(normalized);
|
|
2863
|
-
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
2864
|
-
if (normalized.core && normalized.core[key] !== void 0) {
|
|
2865
|
-
delete normalized[key];
|
|
2866
|
-
}
|
|
2867
|
-
}
|
|
2868
|
-
if (normalized.core && normalized.core._workerType !== void 0) {
|
|
2869
|
-
delete normalized._worker;
|
|
2870
|
-
}
|
|
2871
|
-
return normalized;
|
|
2872
|
-
}
|
|
2873
2254
|
function validateOptions(options, loaders) {
|
|
2874
2255
|
validateOptionsObject(options, null, DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS, loaders);
|
|
2875
2256
|
for (const loader of loaders) {
|
|
@@ -2891,17 +2272,17 @@ function validateOptionsObject(options, id, defaultOptions, deprecatedOptions, l
|
|
|
2891
2272
|
const prefix = id ? `${id}.` : "";
|
|
2892
2273
|
for (const key in options) {
|
|
2893
2274
|
const isSubOptions = !id && isObject(options[key]);
|
|
2894
|
-
const
|
|
2275
|
+
const isLifecycleOption = !id && ["signal", "onProgress"].includes(key);
|
|
2895
2276
|
const isWorkerUrlOption = key === "workerUrl" && id;
|
|
2896
|
-
if (!(key in defaultOptions) && !
|
|
2277
|
+
if (!(key in defaultOptions) && !isLifecycleOption && !isWorkerUrlOption) {
|
|
2897
2278
|
if (key in deprecatedOptions) {
|
|
2898
|
-
if (
|
|
2899
|
-
|
|
2279
|
+
if (log2.level > 0) {
|
|
2280
|
+
log2.warn(`${loaderName} loader option '${prefix}${key}' no longer supported, use '${deprecatedOptions[key]}'`)();
|
|
2900
2281
|
}
|
|
2901
2282
|
} else if (!isSubOptions) {
|
|
2902
|
-
if (
|
|
2283
|
+
if (log2.level > 0) {
|
|
2903
2284
|
const suggestion = findSimilarOption(key, loaders);
|
|
2904
|
-
|
|
2285
|
+
log2.warn(`${loaderName} loader option '${prefix}${key}' not recognized. ${suggestion}`)();
|
|
2905
2286
|
}
|
|
2906
2287
|
}
|
|
2907
2288
|
}
|
|
@@ -2931,16 +2312,20 @@ function normalizeOptionsInternal(loader, options, url) {
|
|
|
2931
2312
|
if (loaderDefaultOptions.core) {
|
|
2932
2313
|
mergedOptions.core = { ...loaderDefaultOptions.core };
|
|
2933
2314
|
}
|
|
2934
|
-
|
|
2315
|
+
const shapeKey = loader.defaultShape && getShapeOptionKey(loader);
|
|
2316
|
+
if (shapeKey) {
|
|
2317
|
+
mergedOptions[shapeKey] = {
|
|
2318
|
+
...loaderDefaultOptions[shapeKey],
|
|
2319
|
+
shape: loader.defaultShape
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
mergeNestedFields(mergedOptions, getGlobalLoaderOptions());
|
|
2323
|
+
mergeNestedFields(mergedOptions, options);
|
|
2324
|
+
applyCoreShapeDefault(mergedOptions, options, loader);
|
|
2935
2325
|
if (((_a = mergedOptions.core) == null ? void 0 : _a.log) === null) {
|
|
2936
|
-
mergedOptions.core = { ...mergedOptions.core, log:
|
|
2326
|
+
mergedOptions.core = { ...mergedOptions.core, log: getLoaderLog(mergedOptions) };
|
|
2937
2327
|
}
|
|
2938
|
-
mergeNestedFields(mergedOptions, normalizeLoaderOptions(getGlobalLoaderOptions()));
|
|
2939
|
-
const userOptions = normalizeLoaderOptions(options);
|
|
2940
|
-
mergeNestedFields(mergedOptions, userOptions);
|
|
2941
|
-
applyCoreShapeDefault(mergedOptions, userOptions, loader);
|
|
2942
2328
|
addUrlOptions(mergedOptions, url);
|
|
2943
|
-
addDeprecatedTopLevelOptions(mergedOptions);
|
|
2944
2329
|
return mergedOptions;
|
|
2945
2330
|
}
|
|
2946
2331
|
function applyCoreShapeDefault(mergedOptions, userOptions, loader) {
|
|
@@ -2949,20 +2334,24 @@ function applyCoreShapeDefault(mergedOptions, userOptions, loader) {
|
|
|
2949
2334
|
if (coreShape === void 0) {
|
|
2950
2335
|
return;
|
|
2951
2336
|
}
|
|
2952
|
-
const
|
|
2337
|
+
const shapeOptionKey = getShapeOptionKey(loader);
|
|
2338
|
+
if (!shapeOptionKey) {
|
|
2339
|
+
return;
|
|
2340
|
+
}
|
|
2341
|
+
const loaderScopedDefaults = (_b = loader.options) == null ? void 0 : _b[shapeOptionKey];
|
|
2953
2342
|
if (!isPureObject(loaderScopedDefaults) || !("shape" in loaderScopedDefaults)) {
|
|
2954
2343
|
return;
|
|
2955
2344
|
}
|
|
2956
|
-
const globalLoaderScopedOptions = getGlobalLoaderOptions()[
|
|
2345
|
+
const globalLoaderScopedOptions = getGlobalLoaderOptions()[shapeOptionKey];
|
|
2957
2346
|
if (isPureObject(globalLoaderScopedOptions) && "shape" in globalLoaderScopedOptions) {
|
|
2958
2347
|
return;
|
|
2959
2348
|
}
|
|
2960
|
-
const userLoaderScopedOptions = userOptions[
|
|
2349
|
+
const userLoaderScopedOptions = userOptions[shapeOptionKey];
|
|
2961
2350
|
if (isPureObject(userLoaderScopedOptions) && "shape" in userLoaderScopedOptions) {
|
|
2962
2351
|
return;
|
|
2963
2352
|
}
|
|
2964
|
-
const loaderScopedOptions = mergedOptions[
|
|
2965
|
-
mergedOptions[
|
|
2353
|
+
const loaderScopedOptions = mergedOptions[shapeOptionKey];
|
|
2354
|
+
mergedOptions[shapeOptionKey] = {
|
|
2966
2355
|
...isPureObject(loaderScopedOptions) ? loaderScopedOptions : {},
|
|
2967
2356
|
shape: coreShape
|
|
2968
2357
|
};
|
|
@@ -3000,42 +2389,6 @@ function cloneLoaderOptions(options) {
|
|
|
3000
2389
|
}
|
|
3001
2390
|
return clonedOptions;
|
|
3002
2391
|
}
|
|
3003
|
-
function moveDeprecatedTopLevelOptionsToCore(options) {
|
|
3004
|
-
if (options.baseUri !== void 0) {
|
|
3005
|
-
options.core ||= {};
|
|
3006
|
-
if (options.core.baseUrl === void 0) {
|
|
3007
|
-
options.core.baseUrl = options.baseUri;
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
3010
|
-
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
3011
|
-
if (options[key] !== void 0) {
|
|
3012
|
-
options.core ||= {};
|
|
3013
|
-
const coreOptions = options.core;
|
|
3014
|
-
const coreRecord = coreOptions;
|
|
3015
|
-
if (coreRecord[key] === void 0) {
|
|
3016
|
-
coreRecord[key] = options[key];
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
const workerTypeAlias = options._worker;
|
|
3021
|
-
if (workerTypeAlias !== void 0) {
|
|
3022
|
-
options.core ||= {};
|
|
3023
|
-
if (options.core._workerType === void 0) {
|
|
3024
|
-
options.core._workerType = workerTypeAlias;
|
|
3025
|
-
}
|
|
3026
|
-
}
|
|
3027
|
-
}
|
|
3028
|
-
function addDeprecatedTopLevelOptions(options) {
|
|
3029
|
-
const coreOptions = options.core;
|
|
3030
|
-
if (!coreOptions) {
|
|
3031
|
-
return;
|
|
3032
|
-
}
|
|
3033
|
-
for (const key of CORE_LOADER_OPTION_KEYS) {
|
|
3034
|
-
if (coreOptions[key] !== void 0) {
|
|
3035
|
-
options[key] = coreOptions[key];
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
2392
|
|
|
3040
2393
|
// dist/lib/loader-utils/normalize-loader.js
|
|
3041
2394
|
function isLoaderObject(loader) {
|
|
@@ -3095,32 +2448,30 @@ function _unregisterLoaders() {
|
|
|
3095
2448
|
|
|
3096
2449
|
// dist/lib/api/select-loader.js
|
|
3097
2450
|
var EXT_PATTERN = /\.([^.]+)$/;
|
|
3098
|
-
async function selectLoader(data, loaders = [], options, context) {
|
|
2451
|
+
async function selectLoader(data, loaders = [], options, context, operation = "parse") {
|
|
2452
|
+
var _a, _b;
|
|
3099
2453
|
if (!validHTTPResponse(data)) {
|
|
3100
2454
|
return null;
|
|
3101
2455
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
if (data instanceof Response && mayContainText(data)) {
|
|
3105
|
-
const text = await data.clone().text();
|
|
3106
|
-
const textLoader = selectLoaderSync(text, loaders, { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } }, context);
|
|
3107
|
-
if (textLoader) {
|
|
3108
|
-
return textLoader;
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
let loader = selectLoaderSync(data, loaders, { ...normalizedOptions, core: { ...normalizedOptions.core, nothrow: true } }, context);
|
|
3112
|
-
if (loader) {
|
|
3113
|
-
return loader;
|
|
2456
|
+
if (loaders && !Array.isArray(loaders)) {
|
|
2457
|
+
return normalizeLoader(loaders);
|
|
3114
2458
|
}
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
2459
|
+
const text = data instanceof Response && mayContainText(data) ? await data.clone().text() : null;
|
|
2460
|
+
let initialBytes;
|
|
2461
|
+
async function matchCandidates(candidates) {
|
|
2462
|
+
normalizeLoaders(candidates);
|
|
2463
|
+
const loader2 = text !== null && selectLoaderInternal(text, candidates, options, context, operation) || selectLoaderInternal(data, candidates, options, context, operation);
|
|
2464
|
+
if (!loader2 && isBlob(data) && candidates.length) {
|
|
2465
|
+
initialBytes ??= await data.slice(0, 10).arrayBuffer();
|
|
2466
|
+
return selectLoaderInternal(initialBytes, candidates, options, context, operation);
|
|
2467
|
+
}
|
|
2468
|
+
return loader2;
|
|
3118
2469
|
}
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
loader =
|
|
2470
|
+
let loader = await matchCandidates(loaders || []);
|
|
2471
|
+
if (!loader && !((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.ignoreRegisteredLoaders)) {
|
|
2472
|
+
loader = await matchCandidates(getRegisteredLoaders());
|
|
3122
2473
|
}
|
|
3123
|
-
if (!loader && !
|
|
2474
|
+
if (!loader && !((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.nothrow)) {
|
|
3124
2475
|
throw new Error(getNoValidLoaderMessage(data));
|
|
3125
2476
|
}
|
|
3126
2477
|
return loader;
|
|
@@ -3129,30 +2480,26 @@ function mayContainText(response) {
|
|
|
3129
2480
|
const mimeType = getResourceMIMEType(response);
|
|
3130
2481
|
return Boolean(mimeType && (mimeType.startsWith("text/") || mimeType === "application/json" || mimeType.endsWith("+json")));
|
|
3131
2482
|
}
|
|
3132
|
-
function selectLoaderSync(data, loaders = [], options, context) {
|
|
2483
|
+
function selectLoaderSync(data, loaders = [], options, context, operation = "parse") {
|
|
2484
|
+
var _a, _b;
|
|
3133
2485
|
if (!validHTTPResponse(data)) {
|
|
3134
2486
|
return null;
|
|
3135
2487
|
}
|
|
3136
|
-
const normalizedOptions = normalizeLoaderOptions(options || {});
|
|
3137
|
-
normalizedOptions.core ||= {};
|
|
3138
2488
|
if (loaders && !Array.isArray(loaders)) {
|
|
3139
2489
|
return normalizeLoader(loaders);
|
|
3140
2490
|
}
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
candidateLoaders.push(...getRegisteredLoaders());
|
|
2491
|
+
const candidates = loaders || [];
|
|
2492
|
+
normalizeLoaders(candidates);
|
|
2493
|
+
let loader = selectLoaderInternal(data, candidates, options, context, operation);
|
|
2494
|
+
if (!loader && !((_a = options == null ? void 0 : options.core) == null ? void 0 : _a.ignoreRegisteredLoaders)) {
|
|
2495
|
+
loader = selectLoaderInternal(data, getRegisteredLoaders(), options, context, operation);
|
|
3147
2496
|
}
|
|
3148
|
-
|
|
3149
|
-
const loader = selectLoaderInternal(data, candidateLoaders, normalizedOptions, context);
|
|
3150
|
-
if (!loader && !normalizedOptions.core.nothrow) {
|
|
2497
|
+
if (!loader && !((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.nothrow)) {
|
|
3151
2498
|
throw new Error(getNoValidLoaderMessage(data));
|
|
3152
2499
|
}
|
|
3153
2500
|
return loader;
|
|
3154
2501
|
}
|
|
3155
|
-
function selectLoaderInternal(data, loaders, options, context) {
|
|
2502
|
+
function selectLoaderInternal(data, loaders, options, context, operation = "parse") {
|
|
3156
2503
|
var _a, _b, _c, _d, _e;
|
|
3157
2504
|
const url = getResourceUrl(data);
|
|
3158
2505
|
const type = getResourceMIMEType(data);
|
|
@@ -3168,20 +2515,27 @@ function selectLoaderInternal(data, loaders, options, context) {
|
|
|
3168
2515
|
loader = findLoaderByMIMEType(loaders, (_b = options == null ? void 0 : options.core) == null ? void 0 : _b.mimeType);
|
|
3169
2516
|
reason = `match forced by supplied MIME type ${(_c = options == null ? void 0 : options.core) == null ? void 0 : _c.mimeType}`;
|
|
3170
2517
|
}
|
|
3171
|
-
loader
|
|
3172
|
-
|
|
3173
|
-
|
|
2518
|
+
if (!loader && operation === "source") {
|
|
2519
|
+
loader = findSourceLoaderByTestURL(loaders, testUrl);
|
|
2520
|
+
reason = loader ? `matched source url ${testUrl}` : "";
|
|
2521
|
+
}
|
|
2522
|
+
const fallbackLoaders = operation === "source" && testUrl ? loaders.filter((candidate) => !candidate.testURL) : loaders;
|
|
2523
|
+
loader = loader || findLoaderByUrl(fallbackLoaders, testUrl);
|
|
3174
2524
|
reason = reason || (loader ? `matched url ${testUrl}` : "");
|
|
3175
|
-
loader
|
|
2525
|
+
if (!loader && operation === "parse") {
|
|
2526
|
+
loader = findSourceLoaderByTestURL(loaders, testUrl);
|
|
2527
|
+
reason = loader ? `matched source url ${testUrl}` : "";
|
|
2528
|
+
}
|
|
2529
|
+
loader = loader || findLoaderByMIMEType(fallbackLoaders, type);
|
|
3176
2530
|
reason = reason || (loader ? `matched MIME type ${type}` : "");
|
|
3177
|
-
loader = loader || findLoaderByInitialBytes(
|
|
2531
|
+
loader = loader || findLoaderByInitialBytes(fallbackLoaders, data);
|
|
3178
2532
|
reason = reason || (loader ? `matched initial data ${getFirstCharacters(data)}` : "");
|
|
3179
2533
|
if (!loader && isBlob(data)) {
|
|
3180
2534
|
loader = findSourceLoaderByTestData(loaders, data);
|
|
3181
2535
|
reason = reason || (loader ? "matched source testData" : "");
|
|
3182
2536
|
}
|
|
3183
2537
|
if ((_d = options == null ? void 0 : options.core) == null ? void 0 : _d.fallbackMimeType) {
|
|
3184
|
-
loader = loader || findLoaderByMIMEType(
|
|
2538
|
+
loader = loader || findLoaderByMIMEType(fallbackLoaders, (_e = options == null ? void 0 : options.core) == null ? void 0 : _e.fallbackMimeType);
|
|
3185
2539
|
reason = reason || (loader ? `matched fallback MIME type ${type}` : "");
|
|
3186
2540
|
}
|
|
3187
2541
|
if (reason) {
|
|
@@ -3231,18 +2585,19 @@ function findLoaderByExtension(loaders, extension) {
|
|
|
3231
2585
|
}
|
|
3232
2586
|
function findSourceLoaderByType(loaders, type) {
|
|
3233
2587
|
for (const loader of loaders) {
|
|
3234
|
-
if (
|
|
2588
|
+
if ((loader.type ?? loader.id) === type) {
|
|
3235
2589
|
return loader;
|
|
3236
2590
|
}
|
|
3237
2591
|
}
|
|
3238
2592
|
return null;
|
|
3239
2593
|
}
|
|
3240
2594
|
function findSourceLoaderByTestURL(loaders, url) {
|
|
2595
|
+
var _a;
|
|
3241
2596
|
if (!url) {
|
|
3242
2597
|
return null;
|
|
3243
2598
|
}
|
|
3244
2599
|
for (const loader of loaders) {
|
|
3245
|
-
if (
|
|
2600
|
+
if ((_a = loader.testURL) == null ? void 0 : _a.call(loader, url)) {
|
|
3246
2601
|
return loader;
|
|
3247
2602
|
}
|
|
3248
2603
|
}
|
|
@@ -3251,7 +2606,7 @@ function findSourceLoaderByTestURL(loaders, url) {
|
|
|
3251
2606
|
function findSourceLoaderByTestData(loaders, data) {
|
|
3252
2607
|
var _a;
|
|
3253
2608
|
for (const loader of loaders) {
|
|
3254
|
-
if (
|
|
2609
|
+
if (loader.testData) {
|
|
3255
2610
|
if ((_a = loader.testData) == null ? void 0 : _a.call(loader, data)) {
|
|
3256
2611
|
return loader;
|
|
3257
2612
|
}
|
|
@@ -3585,7 +2940,7 @@ function getFetchFunction(options, context) {
|
|
|
3585
2940
|
var _a, _b, _c;
|
|
3586
2941
|
const globalOptions = getGlobalLoaderOptions();
|
|
3587
2942
|
const loaderOptions = options || globalOptions;
|
|
3588
|
-
const fetchOption =
|
|
2943
|
+
const fetchOption = (_a = loaderOptions.core) == null ? void 0 : _a.fetch;
|
|
3589
2944
|
let fetchFunction;
|
|
3590
2945
|
if (typeof fetchOption === "function") {
|
|
3591
2946
|
fetchFunction = fetchOption;
|
|
@@ -3611,14 +2966,7 @@ var loaderImplementationPromises = /* @__PURE__ */ new Map();
|
|
|
3611
2966
|
var loaderImplementations = /* @__PURE__ */ new Map();
|
|
3612
2967
|
async function getLoaderImplementation(loader, options, url) {
|
|
3613
2968
|
var _a;
|
|
3614
|
-
if (
|
|
3615
|
-
const source = loader.preload ? await loader.preload(url || "", options) : loader;
|
|
3616
|
-
if (!isSourceLoader(source)) {
|
|
3617
|
-
throw new Error(`${loader.id} source loader preload() did not return a runtime source loader`);
|
|
3618
|
-
}
|
|
3619
|
-
return source;
|
|
3620
|
-
}
|
|
3621
|
-
if (isLoaderWithParser(loader)) {
|
|
2969
|
+
if (isLoaderWithParser(loader) || !loader.preload && loader.createDataSourceSync) {
|
|
3622
2970
|
return loader;
|
|
3623
2971
|
}
|
|
3624
2972
|
const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
|
|
@@ -3652,7 +3000,7 @@ async function getLoaderImplementation(loader, options, url) {
|
|
|
3652
3000
|
}
|
|
3653
3001
|
return await loaderImplementationPromise;
|
|
3654
3002
|
}
|
|
3655
|
-
function getLoaderImplementationSync(loader) {
|
|
3003
|
+
function getLoaderImplementationSync(loader, options) {
|
|
3656
3004
|
var _a;
|
|
3657
3005
|
if (loader.subloaders && !preparedLoaders.has(loader)) {
|
|
3658
3006
|
const prepared = preparedDefaults.get(loader);
|
|
@@ -3661,30 +3009,30 @@ function getLoaderImplementationSync(loader) {
|
|
|
3661
3009
|
if (!isLoaderWithParser(loader))
|
|
3662
3010
|
return null;
|
|
3663
3011
|
}
|
|
3664
|
-
if (isLoaderWithParser(loader)) {
|
|
3012
|
+
if (isLoaderWithParser(loader) || !loader.preload && loader.createDataSourceSync) {
|
|
3665
3013
|
return loader;
|
|
3666
3014
|
}
|
|
3667
|
-
const implementationCacheKey = getLoaderImplementationCacheKey(loader);
|
|
3015
|
+
const implementationCacheKey = getLoaderImplementationCacheKey(loader, options);
|
|
3668
3016
|
return ((_a = loaderImplementations.get(loader)) == null ? void 0 : _a.get(implementationCacheKey)) || null;
|
|
3669
3017
|
}
|
|
3670
3018
|
function isLoaderWithParser(loader) {
|
|
3671
3019
|
const candidate = loader;
|
|
3672
|
-
return Boolean(candidate.parse || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches);
|
|
3020
|
+
return Boolean(candidate.parse || candidate.parseBlob || candidate.parseUrl || candidate.parseSync || candidate.parseInBatches || candidate.parseText || candidate.parseTextSync || candidate.parseFile || candidate.parseFileInBatches);
|
|
3673
3021
|
}
|
|
3674
3022
|
async function resolveLoaderImplementation(loader, options, url) {
|
|
3675
3023
|
if (loader.preload) {
|
|
3676
3024
|
const preloadedLoader = await loader.preload(url || "", options);
|
|
3677
|
-
if (isLoaderWithParser(preloadedLoader)) {
|
|
3025
|
+
if (preloadedLoader && (isLoaderWithParser(preloadedLoader) || preloadedLoader.createDataSourceSync)) {
|
|
3678
3026
|
return preloadedLoader;
|
|
3679
3027
|
}
|
|
3680
|
-
throw new Error(`${loader.id} loader preload() did not return a parser-bearing loader`);
|
|
3028
|
+
throw new Error(`${loader.id} loader preload() did not return a parser-bearing loader or a source factory`);
|
|
3681
3029
|
}
|
|
3682
3030
|
const implementationSpecifier = getLoaderImplementationSpecifier(loader, options);
|
|
3683
3031
|
return await importLoaderImplementation(implementationSpecifier, loader.id);
|
|
3684
3032
|
}
|
|
3685
3033
|
function getLoaderImplementationSpecifier(loader, options) {
|
|
3686
3034
|
var _a;
|
|
3687
|
-
const workerType = (
|
|
3035
|
+
const workerType = (_a = options == null ? void 0 : options.core) == null ? void 0 : _a._workerType;
|
|
3688
3036
|
if (workerType === "test") {
|
|
3689
3037
|
const sourcePath = `modules/${loader.module}/src/${loader.id}-loader.ts`;
|
|
3690
3038
|
if (typeof window !== "undefined") {
|
|
@@ -3773,7 +3121,7 @@ async function bindSubloaders(loader, options, url) {
|
|
|
3773
3121
|
prepared.worker = false;
|
|
3774
3122
|
for (const method of [
|
|
3775
3123
|
"parseBlob",
|
|
3776
|
-
"
|
|
3124
|
+
"createDataSourceSync",
|
|
3777
3125
|
"parse",
|
|
3778
3126
|
"parseSync",
|
|
3779
3127
|
"parseText",
|
|
@@ -3821,28 +3169,29 @@ async function parseFile(file, loaders, options, context) {
|
|
|
3821
3169
|
if (!loader) {
|
|
3822
3170
|
return null;
|
|
3823
3171
|
}
|
|
3824
|
-
if (isSourceLoader(loader)) {
|
|
3825
|
-
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseFile().`);
|
|
3826
|
-
}
|
|
3827
3172
|
const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
3828
3173
|
const authenticationLoader = !loader.getAuthentications && ((_c = (_b = normalizedOptions.core) == null ? void 0 : _b.credentials) == null ? void 0 : _c.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
|
|
3829
3174
|
const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url, normalizedOptions);
|
|
3175
|
+
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
|
|
3830
3176
|
context = getLoaderContext(
|
|
3831
3177
|
// @ts-expect-error candidateLoaders may be a single forced loader
|
|
3832
3178
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
3833
|
-
strictOptions,
|
|
3179
|
+
nativeArrowOptions || strictOptions,
|
|
3834
3180
|
context || null
|
|
3835
3181
|
);
|
|
3836
|
-
|
|
3182
|
+
const result = await parseFileWithLoader(loader, file, nativeArrowOptions || strictOptions, context);
|
|
3183
|
+
return nativeArrowOptions ? unwrapArrowTable(result) : result;
|
|
3837
3184
|
}
|
|
3838
3185
|
async function parseFileWithLoader(loader, file, options, context) {
|
|
3839
|
-
var _a;
|
|
3186
|
+
var _a, _b;
|
|
3840
3187
|
(_a = options.signal || context.signal) == null ? void 0 : _a.throwIfAborted();
|
|
3841
3188
|
validateWorkerVersion(loader);
|
|
3842
3189
|
options = mergeOptions(loader.options, options);
|
|
3843
3190
|
const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
|
|
3844
3191
|
if (loaderWithParser.parseFile) {
|
|
3845
|
-
|
|
3192
|
+
const output = (_b = loaderWithParser.prepareParseOutput) == null ? void 0 : _b.call(loaderWithParser, options);
|
|
3193
|
+
const result = await loaderWithParser.parseFile(file, (output == null ? void 0 : output.options) ?? options, context);
|
|
3194
|
+
return output ? output.convert(result) : result;
|
|
3846
3195
|
}
|
|
3847
3196
|
const parseFunction = loaderWithParser.parse;
|
|
3848
3197
|
if (parseFunction) {
|
|
@@ -3853,6 +3202,9 @@ async function parseFileWithLoader(loader, file, options, context) {
|
|
|
3853
3202
|
const data = await file.read(0n, length);
|
|
3854
3203
|
return await parse(data, loaderWithParser, options, context);
|
|
3855
3204
|
}
|
|
3205
|
+
if (loaderWithParser.createDataSourceSync) {
|
|
3206
|
+
throw new Error(`${loader.id} has no file parser. Use createDataSource() to open a source.`);
|
|
3207
|
+
}
|
|
3856
3208
|
throw new Error(`${loader.id} loader - no file parser found`);
|
|
3857
3209
|
}
|
|
3858
3210
|
|
|
@@ -3870,17 +3222,16 @@ function parseSync(data, loaders, options, context) {
|
|
|
3870
3222
|
if (!loader) {
|
|
3871
3223
|
return null;
|
|
3872
3224
|
}
|
|
3873
|
-
if (isSourceLoader(loader)) {
|
|
3874
|
-
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parseSync().`);
|
|
3875
|
-
}
|
|
3876
3225
|
const strictOptions = normalizeOptions(options, loader, candidateLoaders);
|
|
3877
3226
|
const url = getResourceUrl(data);
|
|
3878
3227
|
const parse2 = () => {
|
|
3879
3228
|
throw new Error("parseSync called parse (which is async");
|
|
3880
3229
|
};
|
|
3881
|
-
|
|
3230
|
+
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
|
|
3231
|
+
context = getLoaderContext({ url, _parseSync: parse2, _parse: parse2, loaders }, nativeArrowOptions || strictOptions, context || null);
|
|
3882
3232
|
const loaderWithParser = getLoaderImplementationSync(loader);
|
|
3883
|
-
|
|
3233
|
+
const result = parseWithLoaderSync(loaderWithParser || loader, data, nativeArrowOptions || strictOptions, context);
|
|
3234
|
+
return nativeArrowOptions ? unwrapArrowTable(result, loader.supportsNativeArrow) : result;
|
|
3884
3235
|
}
|
|
3885
3236
|
function parseWithLoaderSync(loader, data, options, context) {
|
|
3886
3237
|
data = getArrayBufferOrStringFromDataSync(data, loader, options);
|
|
@@ -3893,6 +3244,9 @@ function parseWithLoaderSync(loader, data, options, context) {
|
|
|
3893
3244
|
if (loader.preload) {
|
|
3894
3245
|
throw new Error(`${loader.name} loader: 'parseSync' requires a parser-bearing loader. Import the loader implementation directly, or call preload(loader) before parseSync(). ${context.url || ""}`);
|
|
3895
3246
|
}
|
|
3247
|
+
if (loader.createDataSourceSync) {
|
|
3248
|
+
throw new Error(`${loader.id} has no synchronous parser. Use createDataSource() to open a source.`);
|
|
3249
|
+
}
|
|
3896
3250
|
throw new Error(`${loader.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ""}`);
|
|
3897
3251
|
}
|
|
3898
3252
|
|
|
@@ -3917,14 +3271,29 @@ async function parseInBatches(data, loaders, options, context) {
|
|
|
3917
3271
|
const normalizedOptions = normalizeOptions(options, loader, loaderArray, url);
|
|
3918
3272
|
const authenticationLoader = !loader.getAuthentications && ((_d = (_c = normalizedOptions.core) == null ? void 0 : _c.credentials) == null ? void 0 : _d.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
|
|
3919
3273
|
const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url || "", normalizedOptions);
|
|
3920
|
-
|
|
3274
|
+
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, true);
|
|
3275
|
+
context = getLoaderContext({ url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray }, nativeArrowOptions || strictOptions, context || null);
|
|
3921
3276
|
const loaderWithParser = await getLoaderImplementation(loader, strictOptions, context.url);
|
|
3922
|
-
|
|
3277
|
+
const batches = await parseWithLoaderInBatches(loader, loaderWithParser, data, nativeArrowOptions || strictOptions, context);
|
|
3278
|
+
return nativeArrowOptions ? unwrapArrowBatches(batches) : batches;
|
|
3923
3279
|
}
|
|
3924
3280
|
async function parseWithLoaderInBatches(originalLoader, loader, data, options, context) {
|
|
3925
|
-
var _a;
|
|
3926
|
-
const
|
|
3927
|
-
|
|
3281
|
+
var _a, _b;
|
|
3282
|
+
const { batchMaxRowsPerSecond = 0, batchSize } = options.core ?? {};
|
|
3283
|
+
validateBatchDeliveryRate(batchMaxRowsPerSecond);
|
|
3284
|
+
if (batchSize !== void 0 && batchSize !== "auto" && (!Number.isSafeInteger(batchSize) || batchSize < 1)) {
|
|
3285
|
+
throw new RangeError('core.batchSize must be a positive integer or "auto"');
|
|
3286
|
+
}
|
|
3287
|
+
const parserOptions = batchMaxRowsPerSecond ? { ...options, core: { ...options.core, batchMaxRowsPerSecond: 0 } } : options;
|
|
3288
|
+
const output = loader.parseInBatches ? (_a = loader.prepareParseBatchOutput) == null ? void 0 : _a.call(loader, parserOptions) : null;
|
|
3289
|
+
const decoded = await parseToOutputIterator(loader, data, (output == null ? void 0 : output.options) ?? parserOptions, context);
|
|
3290
|
+
const batches = output ? convertOutputBatches(decoded, output.convert) : decoded;
|
|
3291
|
+
const outputIterator = batchMaxRowsPerSecond ? paceBatchIterator(batches, {
|
|
3292
|
+
batchMaxRowsPerSecond,
|
|
3293
|
+
getRowCount: (batch) => getBatchRowCount(batch, loader.module),
|
|
3294
|
+
signal: options.signal ?? context.signal
|
|
3295
|
+
}) : batches;
|
|
3296
|
+
if (!((_b = options == null ? void 0 : options.core) == null ? void 0 : _b.metadata)) {
|
|
3928
3297
|
return outputIterator;
|
|
3929
3298
|
}
|
|
3930
3299
|
const metadataBatch = {
|
|
@@ -3944,6 +3313,11 @@ async function parseWithLoaderInBatches(originalLoader, loader, data, options, c
|
|
|
3944
3313
|
}
|
|
3945
3314
|
return makeMetadataBatchIterator(outputIterator);
|
|
3946
3315
|
}
|
|
3316
|
+
async function* convertOutputBatches(batches, convert) {
|
|
3317
|
+
for await (const batch of batches) {
|
|
3318
|
+
yield convert(batch);
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3947
3321
|
async function parseToOutputIterator(loader, data, options, context) {
|
|
3948
3322
|
var _a;
|
|
3949
3323
|
const inputIterator = await getAsyncIterableFromData(data, options);
|
|
@@ -3965,6 +3339,10 @@ async function* parseChunkInBatches(transformedIterator, loader, options, contex
|
|
|
3965
3339
|
{ ...options, core: { ...options == null ? void 0 : options.core, mimeType: loader.mimeTypes[0] } },
|
|
3966
3340
|
context
|
|
3967
3341
|
);
|
|
3342
|
+
if (isNativeArrowTable(parsedData)) {
|
|
3343
|
+
yield* parsedData.batches;
|
|
3344
|
+
return;
|
|
3345
|
+
}
|
|
3968
3346
|
const batch = convertDataToBatch(parsedData, loader);
|
|
3969
3347
|
yield batch;
|
|
3970
3348
|
}
|
|
@@ -4020,38 +3398,21 @@ async function applyInputTransforms(inputIterator, transforms = []) {
|
|
|
4020
3398
|
}
|
|
4021
3399
|
return iteratorChain;
|
|
4022
3400
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
if (
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
loadersArray = loaders;
|
|
4033
|
-
}
|
|
4034
|
-
if (!Array.isArray(files)) {
|
|
4035
|
-
return loadOneFileInBatches(files, loadersArray, options || {});
|
|
4036
|
-
}
|
|
4037
|
-
const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
|
|
4038
|
-
return promises;
|
|
4039
|
-
}
|
|
4040
|
-
async function loadOneFileInBatches(file, loaders, options) {
|
|
4041
|
-
var _a, _b;
|
|
4042
|
-
if (typeof file === "string") {
|
|
4043
|
-
const url = file;
|
|
4044
|
-
const loader = await selectLoader(url, loaders, {
|
|
4045
|
-
...options,
|
|
4046
|
-
core: { ...options.core, nothrow: true }
|
|
4047
|
-
});
|
|
4048
|
-
const authenticationLoader = loader && !loader.getAuthentications && ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, options, url) : loader;
|
|
4049
|
-
options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
|
|
4050
|
-
const fetch2 = getFetchFunction(options);
|
|
4051
|
-
const response = await fetch2(applySearchParamsToUrl(url, options));
|
|
4052
|
-
return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
|
|
3401
|
+
function getBatchRowCount(batch, module2) {
|
|
3402
|
+
var _a, _b, _c;
|
|
3403
|
+
if (!batch || typeof batch !== "object")
|
|
3404
|
+
return void 0;
|
|
3405
|
+
if (module2 === "geospatial" && Array.isArray(batch))
|
|
3406
|
+
return batch.length;
|
|
3407
|
+
const result = batch;
|
|
3408
|
+
if (module2 === "traces" && result.table !== void 0 && result.table !== "spans" && result.table !== "slices") {
|
|
3409
|
+
return void 0;
|
|
4053
3410
|
}
|
|
4054
|
-
|
|
3411
|
+
if (result.batchType !== void 0 && result.batchType !== "data")
|
|
3412
|
+
return void 0;
|
|
3413
|
+
if (result.shape === "unknown")
|
|
3414
|
+
return void 0;
|
|
3415
|
+
return ((_a = result.data) == null ? void 0 : _a.numRows) ?? result.numRows ?? ((_b = result.header) == null ? void 0 : _b.vertexCount) ?? ((_c = result.features) == null ? void 0 : _c.length) ?? result.length;
|
|
4055
3416
|
}
|
|
4056
3417
|
|
|
4057
3418
|
// dist/lib/api/load.js
|
|
@@ -4068,59 +3429,23 @@ async function load(url, loaders, options, context) {
|
|
|
4068
3429
|
resolvedOptions = options;
|
|
4069
3430
|
}
|
|
4070
3431
|
resolvedOptions ||= getGlobalLoaderOptions();
|
|
4071
|
-
if (!Array.isArray(resolvedLoaders) && isSourceLoader(resolvedLoaders)) {
|
|
4072
|
-
const sourceLoader = await resolveSourceLoader(resolvedLoaders, url, resolvedOptions);
|
|
4073
|
-
resolvedOptions = await resolveLoaderAuthenticationOptions(resolvedLoaders.getAuthentications ? resolvedLoaders : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
|
|
4074
|
-
const runtimeCoreApi = {
|
|
4075
|
-
fetchFile,
|
|
4076
|
-
parse,
|
|
4077
|
-
parseFile,
|
|
4078
|
-
parseSync,
|
|
4079
|
-
parseInBatches,
|
|
4080
|
-
load,
|
|
4081
|
-
loadInBatches
|
|
4082
|
-
};
|
|
4083
|
-
return sourceLoader.createDataSource(url, resolvedOptions || {}, runtimeCoreApi);
|
|
4084
|
-
}
|
|
4085
|
-
if (Array.isArray(resolvedLoaders) && resolvedLoaders.length === 1 && isSourceLoader(resolvedLoaders[0])) {
|
|
4086
|
-
const sourceLoader = await resolveSourceLoader(resolvedLoaders[0], url, resolvedOptions);
|
|
4087
|
-
resolvedOptions = await resolveLoaderAuthenticationOptions(resolvedLoaders[0].getAuthentications ? resolvedLoaders[0] : sourceLoader, typeof url === "string" ? url : "", resolvedOptions || {});
|
|
4088
|
-
const runtimeCoreApi = {
|
|
4089
|
-
fetchFile,
|
|
4090
|
-
parse,
|
|
4091
|
-
parseFile,
|
|
4092
|
-
parseSync,
|
|
4093
|
-
parseInBatches,
|
|
4094
|
-
load,
|
|
4095
|
-
loadInBatches
|
|
4096
|
-
};
|
|
4097
|
-
return sourceLoader.createDataSource(url, resolvedOptions || {}, runtimeCoreApi);
|
|
4098
|
-
}
|
|
4099
3432
|
if (typeof url === "string" || isBlob(url)) {
|
|
4100
3433
|
const selectedLoader = await selectLoader(url, resolvedLoaders, {
|
|
4101
3434
|
...resolvedOptions,
|
|
4102
3435
|
core: { ...resolvedOptions == null ? void 0 : resolvedOptions.core, nothrow: true }
|
|
4103
3436
|
});
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
return sourceLoader.createDataSource(url, resolvedOptions || {}, {
|
|
4108
|
-
fetchFile,
|
|
4109
|
-
parse,
|
|
4110
|
-
parseFile,
|
|
4111
|
-
parseSync,
|
|
4112
|
-
parseInBatches,
|
|
4113
|
-
load,
|
|
4114
|
-
loadInBatches
|
|
4115
|
-
});
|
|
3437
|
+
const loaderImplementation = selectedLoader && (typeof url === "string" || selectedLoader.createDataSourceSync) ? await getLoaderImplementation(selectedLoader, resolvedOptions, typeof url === "string" ? url : void 0) : null;
|
|
3438
|
+
if (selectedLoader && (loaderImplementation == null ? void 0 : loaderImplementation.createDataSourceSync) && !isLoaderWithParser(loaderImplementation)) {
|
|
3439
|
+
throw new Error(`${selectedLoader.id} creates sources. Use createDataSource() instead of load().`);
|
|
4116
3440
|
}
|
|
4117
|
-
if (selectedLoader && typeof url === "string") {
|
|
4118
|
-
const loaderImplementation = await getLoaderImplementation(selectedLoader, resolvedOptions, url);
|
|
3441
|
+
if (selectedLoader && loaderImplementation && typeof url === "string") {
|
|
4119
3442
|
resolvedOptions = await resolveLoaderAuthenticationOptions(selectedLoader.getAuthentications ? selectedLoader : loaderImplementation, url, resolvedOptions || {});
|
|
4120
|
-
const parseUrl = loaderImplementation
|
|
3443
|
+
const { parseUrl } = loaderImplementation;
|
|
4121
3444
|
if (parseUrl) {
|
|
4122
3445
|
const requestUrl = applySearchParamsToUrl(url, resolvedOptions);
|
|
4123
|
-
|
|
3446
|
+
const nativeOptions = getNativeArrowOptions(selectedLoader, normalizeOptions(resolvedOptions, selectedLoader, [selectedLoader], url));
|
|
3447
|
+
const result = await parseUrl(requestUrl, nativeOptions || resolvedOptions, context);
|
|
3448
|
+
return nativeOptions ? unwrapArrowTable(result) : result;
|
|
4124
3449
|
}
|
|
4125
3450
|
}
|
|
4126
3451
|
}
|
|
@@ -4135,8 +3460,7 @@ async function load(url, loaders, options, context) {
|
|
|
4135
3460
|
data = await fetch2(url);
|
|
4136
3461
|
}
|
|
4137
3462
|
if (typeof url === "string") {
|
|
4138
|
-
|
|
4139
|
-
if (!((_a = normalizedOptions.core) == null ? void 0 : _a.baseUrl)) {
|
|
3463
|
+
if (!((_a = resolvedOptions == null ? void 0 : resolvedOptions.core) == null ? void 0 : _a.baseUrl)) {
|
|
4140
3464
|
resolvedOptions = {
|
|
4141
3465
|
...resolvedOptions,
|
|
4142
3466
|
core: {
|
|
@@ -4148,15 +3472,38 @@ async function load(url, loaders, options, context) {
|
|
|
4148
3472
|
}
|
|
4149
3473
|
return Array.isArray(resolvedLoaders) ? await parse(data, resolvedLoaders, resolvedOptions, context) : await parse(data, resolvedLoaders, resolvedOptions, context);
|
|
4150
3474
|
}
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
3475
|
+
|
|
3476
|
+
// dist/lib/api/load-in-batches.js
|
|
3477
|
+
function loadInBatches(files, loaders, options, context) {
|
|
3478
|
+
let loadersArray;
|
|
3479
|
+
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
|
|
3480
|
+
context = void 0;
|
|
3481
|
+
options = loaders;
|
|
3482
|
+
loadersArray = void 0;
|
|
3483
|
+
} else {
|
|
3484
|
+
loadersArray = loaders;
|
|
3485
|
+
}
|
|
3486
|
+
if (!Array.isArray(files)) {
|
|
3487
|
+
return loadOneFileInBatches(files, loadersArray, options || {});
|
|
4154
3488
|
}
|
|
4155
|
-
const
|
|
4156
|
-
|
|
4157
|
-
|
|
3489
|
+
const promises = files.map((file) => loadOneFileInBatches(file, loadersArray, options || {}));
|
|
3490
|
+
return promises;
|
|
3491
|
+
}
|
|
3492
|
+
async function loadOneFileInBatches(file, loaders, options) {
|
|
3493
|
+
var _a, _b;
|
|
3494
|
+
if (typeof file === "string") {
|
|
3495
|
+
const url = file;
|
|
3496
|
+
const loader = await selectLoader(url, loaders, {
|
|
3497
|
+
...options,
|
|
3498
|
+
core: { ...options.core, nothrow: true }
|
|
3499
|
+
});
|
|
3500
|
+
const authenticationLoader = loader && !loader.getAuthentications && ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? await getLoaderImplementation(loader, options, url) : loader;
|
|
3501
|
+
options = await resolveLoaderAuthenticationOptions(authenticationLoader, url, options);
|
|
3502
|
+
const fetch2 = getFetchFunction(options);
|
|
3503
|
+
const response = await fetch2(applySearchParamsToUrl(url, options));
|
|
3504
|
+
return Array.isArray(loaders) ? await parseInBatches(response, loaders, options) : await parseInBatches(response, loaders, options);
|
|
4158
3505
|
}
|
|
4159
|
-
return
|
|
3506
|
+
return Array.isArray(loaders) ? await parseInBatches(file, loaders, options) : await parseInBatches(file, loaders, options);
|
|
4160
3507
|
}
|
|
4161
3508
|
|
|
4162
3509
|
// dist/lib/api/core-api.js
|
|
@@ -4235,22 +3582,21 @@ async function parse(data, loaders, options, context) {
|
|
|
4235
3582
|
if (!loader) {
|
|
4236
3583
|
return null;
|
|
4237
3584
|
}
|
|
4238
|
-
if (isSourceLoader(loader)) {
|
|
4239
|
-
throw new Error(`${loader.id} is a SourceLoader. Use load() to create a runtime source object instead of parse().`);
|
|
4240
|
-
}
|
|
4241
3585
|
const normalizedOptions = normalizeOptions(options, loader, candidateLoaders, url);
|
|
4242
3586
|
const authenticationLoader = !loader.getAuthentications && ((_d = (_c = normalizedOptions.core) == null ? void 0 : _c.credentials) == null ? void 0 : _d.length) ? await getLoaderImplementation(loader, normalizedOptions, url || (context == null ? void 0 : context.url)) : loader;
|
|
4243
3587
|
const strictOptions = await resolveLoaderAuthenticationOptions(authenticationLoader, url || "", normalizedOptions);
|
|
3588
|
+
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
|
|
4244
3589
|
context = getLoaderContext(
|
|
4245
3590
|
// @ts-expect-error
|
|
4246
3591
|
{ url, _parse: parse, loaders: candidateLoaders },
|
|
4247
|
-
strictOptions,
|
|
3592
|
+
nativeArrowOptions || strictOptions,
|
|
4248
3593
|
context || null
|
|
4249
3594
|
);
|
|
4250
|
-
|
|
3595
|
+
const result = await parseWithLoader(loader, data, nativeArrowOptions || strictOptions, context);
|
|
3596
|
+
return nativeArrowOptions ? unwrapArrowTable(result, loader.supportsNativeArrow) : result;
|
|
4251
3597
|
}
|
|
4252
3598
|
async function parseWithLoader(loader, data, options, context) {
|
|
4253
|
-
var _a;
|
|
3599
|
+
var _a, _b;
|
|
4254
3600
|
(_a = options.signal || context.signal) == null ? void 0 : _a.throwIfAborted();
|
|
4255
3601
|
validateWorkerVersion(loader);
|
|
4256
3602
|
options = mergeOptions(loader.options, options);
|
|
@@ -4260,15 +3606,22 @@ async function parseWithLoader(loader, data, options, context) {
|
|
|
4260
3606
|
context.response = { headers, ok, redirected, status, statusText, type, url };
|
|
4261
3607
|
}
|
|
4262
3608
|
const loaderWithParser = await getLoaderImplementation(loader, options, context.url);
|
|
4263
|
-
if (
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
3609
|
+
if (loaderWithParser.createDataSourceSync && !isLoaderWithParser(loaderWithParser)) {
|
|
3610
|
+
throw new Error(`${loader.id} creates sources. Use createDataSource() to open a source.`);
|
|
3611
|
+
}
|
|
3612
|
+
const output = (_b = loaderWithParser.prepareParseOutput) == null ? void 0 : _b.call(loaderWithParser, options);
|
|
3613
|
+
const parseOptions = (output == null ? void 0 : output.options) ?? options;
|
|
3614
|
+
let result;
|
|
3615
|
+
if (shouldParseWithWorker(loaderWithParser, data, parseOptions, context, loader)) {
|
|
3616
|
+
data = await getArrayBufferFromData(data, parseOptions);
|
|
3617
|
+
result = await parseWithWorker(loaderWithParser, data, parseOptions, context, parse);
|
|
3618
|
+
} else if (isBlob(data) && loaderWithParser.parseBlob) {
|
|
3619
|
+
result = await loaderWithParser.parseBlob(data, parseOptions, context);
|
|
3620
|
+
} else {
|
|
3621
|
+
data = await getArrayBufferOrStringFromData(data, loader, parseOptions);
|
|
3622
|
+
result = await parseWithLoaderImplementation(loaderWithParser, data, parseOptions, context);
|
|
4269
3623
|
}
|
|
4270
|
-
|
|
4271
|
-
return await parseWithLoaderImplementation(loaderWithParser, data, options, context);
|
|
3624
|
+
return output ? output.convert(result) : result;
|
|
4272
3625
|
}
|
|
4273
3626
|
async function parseWithLoaderImplementation(loader, data, options, context) {
|
|
4274
3627
|
if (loader.parseText && typeof data === "string") {
|
|
@@ -4283,6 +3636,9 @@ async function parseWithLoaderImplementation(loader, data, options, context) {
|
|
|
4283
3636
|
if (loader.parseSync) {
|
|
4284
3637
|
throw new Error(`${loader.name} loader: 'parse' not available on parser-bearing sync loader. Add an async 'parse' function to this loader, or call preload(loader) before parseSync(). ${context.url || ""}`);
|
|
4285
3638
|
}
|
|
3639
|
+
if (loader.createDataSourceSync) {
|
|
3640
|
+
throw new Error(`${loader.id} creates sources. Use createDataSource() to open a source.`);
|
|
3641
|
+
}
|
|
4286
3642
|
throw new Error(`${loader.id} loader - no parser found and worker is disabled`);
|
|
4287
3643
|
}
|
|
4288
3644
|
|
|
@@ -4381,8 +3737,15 @@ function encodeTextSync(data, writer, options) {
|
|
|
4381
3737
|
}
|
|
4382
3738
|
function encodeInBatches(data, writer, options) {
|
|
4383
3739
|
if (writer.encodeInBatches) {
|
|
4384
|
-
|
|
4385
|
-
|
|
3740
|
+
let dataIterator;
|
|
3741
|
+
if (data && typeof data === "object") {
|
|
3742
|
+
if ("numRows" in data && "schema" in data) {
|
|
3743
|
+
dataIterator = [data];
|
|
3744
|
+
} else if (Symbol.iterator in data || Symbol.asyncIterator in data) {
|
|
3745
|
+
dataIterator = data;
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
return writer.encodeInBatches(dataIterator ?? getIterator2(data), options);
|
|
4386
3749
|
}
|
|
4387
3750
|
throw new Error(`Writer ${writer.name} could not encode in batches`);
|
|
4388
3751
|
}
|
|
@@ -4416,44 +3779,62 @@ function getTemporaryFilename(filename2) {
|
|
|
4416
3779
|
}
|
|
4417
3780
|
|
|
4418
3781
|
// dist/lib/api/create-data-source.js
|
|
4419
|
-
function createDataSource(data,
|
|
4420
|
-
var _a, _b, _c
|
|
4421
|
-
|
|
4422
|
-
const
|
|
4423
|
-
const
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
3782
|
+
async function createDataSource(data, loaders, options = {}) {
|
|
3783
|
+
var _a, _b, _c;
|
|
3784
|
+
(_a = options.signal) == null ? void 0 : _a.throwIfAborted();
|
|
3785
|
+
const candidates = getCandidates(loaders, options);
|
|
3786
|
+
const loader = candidates.length === 1 ? candidates[0] : await selectLoader(data, candidates, getSelectionOptions(options), void 0, "source");
|
|
3787
|
+
if (!loader) {
|
|
3788
|
+
throw new Error("No explicit source loader matches the input");
|
|
3789
|
+
}
|
|
3790
|
+
const url = typeof data === "string" ? data : "";
|
|
3791
|
+
const implementation = await preload(loader, options, url);
|
|
3792
|
+
(_b = options.signal) == null ? void 0 : _b.throwIfAborted();
|
|
3793
|
+
const authenticatedOptions = await resolveLoaderAuthenticationOptions(loader.getAuthentications ? loader : implementation, url, options);
|
|
3794
|
+
(_c = options.signal) == null ? void 0 : _c.throwIfAborted();
|
|
3795
|
+
return constructSource(implementation, data, authenticatedOptions);
|
|
3796
|
+
}
|
|
3797
|
+
function createDataSourceSync(data, loaders, options = {}) {
|
|
3798
|
+
var _a, _b, _c, _d;
|
|
3799
|
+
const candidates = getCandidates(loaders, options);
|
|
3800
|
+
const loader = candidates.length === 1 ? candidates[0] : selectLoaderSync(data, candidates, getSelectionOptions(options), void 0, "source");
|
|
3801
|
+
if (!loader) {
|
|
3802
|
+
throw new Error("No explicit source loader matches the input");
|
|
3803
|
+
}
|
|
3804
|
+
const implementation = getLoaderImplementationSync(loader, options);
|
|
3805
|
+
if (!implementation) {
|
|
3806
|
+
throw new Error(`${loader.id} has no synchronous source factory available. Call preload() first.`);
|
|
3807
|
+
}
|
|
3808
|
+
const authenticationLoader = loader.getAuthentications ? loader : implementation;
|
|
3809
|
+
const contributions = ((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length) ? (_c = authenticationLoader.getAuthentications) == null ? void 0 : _c.call(authenticationLoader, typeof data === "string" ? data : "", options) : void 0;
|
|
4433
3810
|
if (contributions && "then" in contributions) {
|
|
4434
3811
|
void contributions.catch(() => {
|
|
4435
3812
|
});
|
|
4436
|
-
throw new Error("Use
|
|
3813
|
+
throw new Error("Use createDataSource() with an asynchronous getAuthentications() hook.");
|
|
4437
3814
|
}
|
|
4438
3815
|
const authenticatedOptions = resolveAuthenticationOptions((contributions == null ? void 0 : contributions.length) ? {
|
|
4439
|
-
...
|
|
3816
|
+
...options,
|
|
4440
3817
|
core: {
|
|
4441
|
-
...
|
|
4442
|
-
authentications: [
|
|
4443
|
-
...((_e = resolvedOptions.core) == null ? void 0 : _e.authentications) || [],
|
|
4444
|
-
...contributions || []
|
|
4445
|
-
]
|
|
3818
|
+
...options.core,
|
|
3819
|
+
authentications: [...((_d = options.core) == null ? void 0 : _d.authentications) || [], ...contributions]
|
|
4446
3820
|
}
|
|
4447
|
-
} :
|
|
4448
|
-
return
|
|
3821
|
+
} : options);
|
|
3822
|
+
return constructSource(implementation, data, authenticatedOptions);
|
|
4449
3823
|
}
|
|
4450
|
-
function
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
3824
|
+
function getCandidates(loaders, options) {
|
|
3825
|
+
var _a;
|
|
3826
|
+
const candidates = Array.isArray(loaders) ? [...loaders] : [loaders];
|
|
3827
|
+
const type = ((_a = options.core) == null ? void 0 : _a.type) || options.type;
|
|
3828
|
+
return candidates.length > 1 && type && type !== "auto" ? candidates.filter((loader) => (loader.type ?? loader.id) === type) : candidates;
|
|
3829
|
+
}
|
|
3830
|
+
function getSelectionOptions(options) {
|
|
3831
|
+
return { ...options, core: { ...options.core, ignoreRegisteredLoaders: true, nothrow: true } };
|
|
3832
|
+
}
|
|
3833
|
+
function constructSource(loader, data, options) {
|
|
3834
|
+
if (loader.createDataSourceSync) {
|
|
3835
|
+
return loader.createDataSourceSync(data, options, coreApi);
|
|
4455
3836
|
}
|
|
4456
|
-
|
|
3837
|
+
throw new Error(`${loader.id} has no synchronous source factory. Use createDataSource() to preload the loader.`);
|
|
4457
3838
|
}
|
|
4458
3839
|
|
|
4459
3840
|
// dist/lib/api/select-source.js
|
|
@@ -4461,16 +3842,16 @@ function selectSource(url, sources, options) {
|
|
|
4461
3842
|
const type = (options == null ? void 0 : options.type) || "auto";
|
|
4462
3843
|
let selectedSource = null;
|
|
4463
3844
|
if (type === "auto") {
|
|
4464
|
-
selectedSource = selectLoaderSync(url, sources, { core: { nothrow: true } });
|
|
3845
|
+
selectedSource = selectLoaderSync(url, sources, { core: { nothrow: true } }, void 0, "source");
|
|
4465
3846
|
} else {
|
|
4466
|
-
selectedSource =
|
|
3847
|
+
selectedSource = getSourceOfType(type, sources);
|
|
4467
3848
|
}
|
|
4468
3849
|
if (!selectedSource && !(options == null ? void 0 : options.nothrow)) {
|
|
4469
3850
|
throw new Error("Not a valid image source type");
|
|
4470
3851
|
}
|
|
4471
3852
|
return selectedSource;
|
|
4472
3853
|
}
|
|
4473
|
-
function
|
|
3854
|
+
function getSourceOfType(type, sources) {
|
|
4474
3855
|
for (const service of sources) {
|
|
4475
3856
|
if (service.type === type) {
|
|
4476
3857
|
return service;
|
|
@@ -4519,29 +3900,14 @@ function makeStream(source, options) {
|
|
|
4519
3900
|
}
|
|
4520
3901
|
|
|
4521
3902
|
// dist/null-loader.js
|
|
4522
|
-
var
|
|
4523
|
-
var NullWorkerLoader = {
|
|
4524
|
-
dataType: null,
|
|
4525
|
-
batchType: null,
|
|
4526
|
-
name: "Null loader",
|
|
4527
|
-
id: "null",
|
|
4528
|
-
module: "core",
|
|
4529
|
-
version: VERSION4,
|
|
4530
|
-
worker: true,
|
|
4531
|
-
mimeTypes: ["application/x.empty"],
|
|
4532
|
-
extensions: ["null"],
|
|
4533
|
-
tests: [() => false],
|
|
4534
|
-
options: {
|
|
4535
|
-
null: {}
|
|
4536
|
-
}
|
|
4537
|
-
};
|
|
3903
|
+
var VERSION5 = true ? "5.0.0-beta.10" : "latest";
|
|
4538
3904
|
var NullLoader = {
|
|
4539
3905
|
dataType: null,
|
|
4540
3906
|
batchType: null,
|
|
4541
3907
|
name: "Null loader",
|
|
4542
3908
|
id: "null",
|
|
4543
3909
|
module: "core",
|
|
4544
|
-
version:
|
|
3910
|
+
version: VERSION5,
|
|
4545
3911
|
mimeTypes: ["application/x.empty"],
|
|
4546
3912
|
extensions: ["null"],
|
|
4547
3913
|
parse: async (arrayBuffer, options, context) => parseSync2(arrayBuffer, options || {}, context),
|