@loaders.gl/pmtiles 4.3.2 → 4.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -824,14 +824,14 @@ var __exports__ = (() => {
824
824
  var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
825
825
  var nodeVersion = matches && parseFloat(matches[1]) || 0;
826
826
 
827
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
827
+ // ../../node_modules/@probe.gl/env/dist/lib/globals.js
828
828
  var window_2 = globalThis;
829
829
  var document_2 = globalThis.document || {};
830
830
  var process_ = globalThis.process || {};
831
831
  var console_ = globalThis.console;
832
832
  var navigator_ = globalThis.navigator || {};
833
833
 
834
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
834
+ // ../../node_modules/@probe.gl/env/dist/lib/is-electron.js
835
835
  function isElectron(mockUserAgent) {
836
836
  if (typeof window !== "undefined" && window.process?.type === "renderer") {
837
837
  return true;
@@ -844,7 +844,7 @@ var __exports__ = (() => {
844
844
  return Boolean(userAgent && userAgent.indexOf("Electron") >= 0);
845
845
  }
846
846
 
847
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
847
+ // ../../node_modules/@probe.gl/env/dist/lib/is-browser.js
848
848
  function isBrowser2() {
849
849
  const isNode = (
850
850
  // @ts-expect-error
@@ -853,7 +853,7 @@ var __exports__ = (() => {
853
853
  return !isNode || isElectron();
854
854
  }
855
855
 
856
- // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/index.js
856
+ // ../../node_modules/@probe.gl/env/dist/index.js
857
857
  var VERSION = true ? "4.0.7" : "untranspiled source";
858
858
 
859
859
  // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
@@ -1269,6 +1269,29 @@ var __exports__ = (() => {
1269
1269
  }
1270
1270
  var log = createLog();
1271
1271
 
1272
+ // ../loader-utils/src/lib/option-utils/merge-options.ts
1273
+ function mergeOptions(baseOptions, newOptions) {
1274
+ return mergeOptionsRecursively(baseOptions || {}, newOptions);
1275
+ }
1276
+ function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
1277
+ if (level > 3) {
1278
+ return newOptions;
1279
+ }
1280
+ const options = { ...baseOptions };
1281
+ for (const [key, newValue] of Object.entries(newOptions)) {
1282
+ if (newValue && typeof newValue === "object" && !Array.isArray(newValue)) {
1283
+ options[key] = mergeOptionsRecursively(
1284
+ options[key] || {},
1285
+ newOptions[key],
1286
+ level + 1
1287
+ );
1288
+ } else {
1289
+ options[key] = newOptions[key];
1290
+ }
1291
+ }
1292
+ return options;
1293
+ }
1294
+
1272
1295
  // ../loader-utils/src/lib/path-utils/file-aliases.ts
1273
1296
  var pathPrefix = "";
1274
1297
  var fileAliases = {};
@@ -1307,26 +1330,35 @@ var __exports__ = (() => {
1307
1330
  };
1308
1331
  }
1309
1332
  async read(start, length) {
1310
- const arrayBuffer = await this.handle.slice(start, start + length).arrayBuffer();
1333
+ const arrayBuffer = await this.handle.slice(Number(start), Number(start) + Number(length)).arrayBuffer();
1311
1334
  return arrayBuffer;
1312
1335
  }
1313
1336
  };
1314
1337
 
1315
1338
  // ../loader-utils/src/lib/sources/data-source.ts
1316
- var DataSource = class {
1317
- /** A resolved fetch function extracted from loadOptions prop */
1318
- fetch;
1339
+ var _DataSource = class {
1340
+ optionsType;
1341
+ options;
1342
+ data;
1343
+ url;
1319
1344
  /** The actual load options, if calling a loaders.gl loader */
1320
1345
  loadOptions;
1346
+ /** A resolved fetch function extracted from loadOptions prop */
1347
+ fetch;
1321
1348
  _needsRefresh = true;
1322
- props;
1323
- constructor(props) {
1324
- this.props = { ...props };
1325
- this.loadOptions = { ...props.loadOptions };
1349
+ constructor(data, options, defaultOptions) {
1350
+ if (defaultOptions) {
1351
+ this.options = mergeOptions({ ...defaultOptions, core: _DataSource.defaultOptions }, options);
1352
+ } else {
1353
+ this.options = { ...options };
1354
+ }
1355
+ this.data = data;
1356
+ this.url = typeof data === "string" ? resolvePath(data) : "";
1357
+ this.loadOptions = { ...this.options.core?.loadOptions };
1326
1358
  this.fetch = getFetchFunction(this.loadOptions);
1327
1359
  }
1328
- setProps(props) {
1329
- this.props = Object.assign(this.props, props);
1360
+ setProps(options) {
1361
+ this.options = Object.assign(this.options, options);
1330
1362
  this.setNeedsRefresh();
1331
1363
  }
1332
1364
  /** Mark this data source as needing a refresh (redraw) */
@@ -1345,6 +1377,15 @@ var __exports__ = (() => {
1345
1377
  return needsRefresh;
1346
1378
  }
1347
1379
  };
1380
+ var DataSource = _DataSource;
1381
+ __publicField(DataSource, "defaultOptions", {
1382
+ core: {
1383
+ type: "auto",
1384
+ attributions: [],
1385
+ loadOptions: {},
1386
+ loaders: []
1387
+ }
1388
+ });
1348
1389
  function getFetchFunction(options) {
1349
1390
  const fetchFunction = options?.fetch;
1350
1391
  if (fetchFunction && typeof fetchFunction === "function") {
@@ -2556,8 +2597,8 @@ var __exports__ = (() => {
2556
2597
  }
2557
2598
  };
2558
2599
 
2559
- // ../gis/src/lib/binary-features/flat-geojson-to-binary.ts
2560
- function flatGeojsonToBinary(features, geometryInfo, options) {
2600
+ // ../gis/src/lib/feature-collection-converters/convert-flat-geojson-to-binary-features.ts
2601
+ function convertFlatGeojsonToBinaryFeatureCollection(features, geometryInfo, options) {
2561
2602
  const propArrayTypes = extractNumericPropTypes(features);
2562
2603
  const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
2563
2604
  return fillArrays(
@@ -3416,7 +3457,7 @@ var __exports__ = (() => {
3416
3457
  }
3417
3458
  function parseToBinary(arrayBuffer, options) {
3418
3459
  const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);
3419
- const binaryData = flatGeojsonToBinary(flatGeoJsonFeatures, geometryInfo);
3460
+ const binaryData = convertFlatGeojsonToBinaryFeatureCollection(flatGeoJsonFeatures, geometryInfo);
3420
3461
  binaryData.byteLength = arrayBuffer.byteLength;
3421
3462
  return binaryData;
3422
3463
  }
@@ -3503,15 +3544,11 @@ var __exports__ = (() => {
3503
3544
  return decodedFeature;
3504
3545
  }
3505
3546
 
3506
- // ../mvt/src/mvt-loader.ts
3507
- var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3508
- var MVTWorkerLoader = {
3509
- dataType: null,
3510
- batchType: null,
3547
+ // ../mvt/src/mvt-format.ts
3548
+ var MVTFormat = {
3511
3549
  name: "Mapbox Vector Tile",
3512
3550
  id: "mvt",
3513
3551
  module: "mvt",
3514
- version: VERSION5,
3515
3552
  // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
3516
3553
  extensions: ["mvt", "pbf"],
3517
3554
  mimeTypes: [
@@ -3520,8 +3557,17 @@ var __exports__ = (() => {
3520
3557
  "application/x-protobuf"
3521
3558
  // 'application/octet-stream'
3522
3559
  ],
3560
+ category: "geometry"
3561
+ };
3562
+
3563
+ // ../mvt/src/mvt-loader.ts
3564
+ var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3565
+ var MVTWorkerLoader = {
3566
+ ...MVTFormat,
3567
+ dataType: null,
3568
+ batchType: null,
3569
+ version: VERSION5,
3523
3570
  worker: true,
3524
- category: "geometry",
3525
3571
  options: {
3526
3572
  mvt: {
3527
3573
  shape: "geojson",
@@ -3539,6 +3585,16 @@ var __exports__ = (() => {
3539
3585
  binary: true
3540
3586
  };
3541
3587
 
3588
+ // src/pmtiles-format.ts
3589
+ var PMTilesFormat = {
3590
+ name: "PMTiles",
3591
+ id: "pmtiles",
3592
+ module: "pmtiles",
3593
+ extensions: ["pmtiles"],
3594
+ mimeTypes: ["application/octet-stream"],
3595
+ tests: ["PMTiles"]
3596
+ };
3597
+
3542
3598
  // ../../node_modules/pmtiles/dist/index.js
3543
3599
  var dist_exports = {};
3544
3600
  __export(dist_exports, {
@@ -5324,31 +5380,25 @@ var __exports__ = (() => {
5324
5380
  var { PMTiles: PMTiles2 } = dist_exports;
5325
5381
  var VERSION6 = "1.0.0";
5326
5382
  var PMTilesSource = {
5327
- name: "PMTiles",
5328
- id: "pmtiles",
5329
- module: "pmtiles",
5383
+ ...PMTilesFormat,
5330
5384
  version: VERSION6,
5331
- extensions: ["pmtiles"],
5332
- mimeTypes: ["application/octet-stream"],
5333
- options: { url: void 0, pmtiles: {} },
5334
5385
  type: "pmtiles",
5335
5386
  fromUrl: true,
5336
5387
  fromBlob: true,
5388
+ defaultOptions: {
5389
+ pmtiles: {}
5390
+ },
5337
5391
  testURL: (url) => url.endsWith(".pmtiles"),
5338
- createDataSource: (url, props) => new PMTilesTileSource(url, props)
5392
+ createDataSource: (url, options) => new PMTilesTileSource(url, options)
5339
5393
  };
5340
5394
  var PMTilesTileSource = class extends DataSource {
5341
- data;
5342
- props;
5343
5395
  mimeType = null;
5344
5396
  pmtiles;
5345
5397
  metadata;
5346
- constructor(data, props) {
5347
- super(props);
5348
- this.props = props;
5349
- const url = typeof data === "string" ? resolvePath(data) : new BlobSource(data, "pmtiles");
5350
- this.data = data;
5351
- this.pmtiles = new PMTiles2(url);
5398
+ constructor(data, options) {
5399
+ super(data, options, PMTilesSource.defaultOptions);
5400
+ const urlOrBlob = typeof data === "string" ? resolvePath(data) : new BlobSource(data, "pmtiles");
5401
+ this.pmtiles = new PMTiles2(urlOrBlob);
5352
5402
  this.getTileData = this.getTileData.bind(this);
5353
5403
  this.metadata = this.getMetadata();
5354
5404
  }
@@ -5364,8 +5414,11 @@ var __exports__ = (() => {
5364
5414
  { includeFormatHeader: false },
5365
5415
  this.loadOptions
5366
5416
  );
5367
- if (this.props.attributions) {
5368
- metadata.attributions = [...this.props.attributions, ...metadata.attributions || []];
5417
+ if (this.options.attributions) {
5418
+ metadata.attributions = [
5419
+ ...this.options.core?.attributions || [],
5420
+ ...metadata.attributions || []
5421
+ ];
5369
5422
  }
5370
5423
  if (metadata?.tileMIMEType) {
5371
5424
  this.mimeType = metadata?.tileMIMEType;
@@ -5419,13 +5472,8 @@ var __exports__ = (() => {
5419
5472
 
5420
5473
  // src/pmtiles-loader.ts
5421
5474
  var PMTilesLoader = {
5422
- name: "PMTiles",
5423
- id: "pmtiles",
5424
- module: "pmtiles",
5475
+ ...PMTilesFormat,
5425
5476
  version: VERSION7,
5426
- extensions: ["pmtiles"],
5427
- mimeTypes: ["application/octet-stream"],
5428
- tests: ["PMTiles"],
5429
5477
  options: {
5430
5478
  pmtiles: {}
5431
5479
  },