@loaders.gl/pmtiles 4.3.4 → 4.4.0-alpha.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/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 = {};
@@ -1313,20 +1336,29 @@ var __exports__ = (() => {
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,8 +1377,17 @@ 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
- const fetchFunction = options?.fetch;
1390
+ const fetchFunction = options?.core?.fetch;
1350
1391
  if (fetchFunction && typeof fetchFunction === "function") {
1351
1392
  return (url, fetchOptions2) => fetchFunction(url, fetchOptions2);
1352
1393
  }
@@ -1496,7 +1537,6 @@ var __exports__ = (() => {
1496
1537
  }
1497
1538
 
1498
1539
  // ../images/src/lib/parsers/parse-to-image-bitmap.ts
1499
- var EMPTY_OBJECT = {};
1500
1540
  var imagebitmapOptionsSupported = true;
1501
1541
  async function parseToImageBitmap(arrayBuffer, options, url) {
1502
1542
  let blob;
@@ -1524,8 +1564,13 @@ var __exports__ = (() => {
1524
1564
  return await createImageBitmap(blob);
1525
1565
  }
1526
1566
  function isEmptyObject(object) {
1527
- for (const key in object || EMPTY_OBJECT) {
1528
- return false;
1567
+ if (!object) {
1568
+ return true;
1569
+ }
1570
+ for (const key in object) {
1571
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
1572
+ return false;
1573
+ }
1529
1574
  }
1530
1575
  return true;
1531
1576
  }
@@ -2556,8 +2601,8 @@ var __exports__ = (() => {
2556
2601
  }
2557
2602
  };
2558
2603
 
2559
- // ../gis/src/lib/binary-features/flat-geojson-to-binary.ts
2560
- function flatGeojsonToBinary(features, geometryInfo, options) {
2604
+ // ../gis/src/lib/feature-collection-converters/convert-flat-geojson-to-binary-features.ts
2605
+ function convertFlatGeojsonToBinaryFeatureCollection(features, geometryInfo, options) {
2561
2606
  const propArrayTypes = extractNumericPropTypes(features);
2562
2607
  const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
2563
2608
  return fillArrays(
@@ -3416,7 +3461,7 @@ var __exports__ = (() => {
3416
3461
  }
3417
3462
  function parseToBinary(arrayBuffer, options) {
3418
3463
  const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);
3419
- const binaryData = flatGeojsonToBinary(flatGeoJsonFeatures, geometryInfo);
3464
+ const binaryData = convertFlatGeojsonToBinaryFeatureCollection(flatGeoJsonFeatures, geometryInfo);
3420
3465
  binaryData.byteLength = arrayBuffer.byteLength;
3421
3466
  return binaryData;
3422
3467
  }
@@ -3503,15 +3548,11 @@ var __exports__ = (() => {
3503
3548
  return decodedFeature;
3504
3549
  }
3505
3550
 
3506
- // ../mvt/src/mvt-loader.ts
3507
- var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3508
- var MVTWorkerLoader = {
3509
- dataType: null,
3510
- batchType: null,
3551
+ // ../mvt/src/mvt-format.ts
3552
+ var MVTFormat = {
3511
3553
  name: "Mapbox Vector Tile",
3512
3554
  id: "mvt",
3513
3555
  module: "mvt",
3514
- version: VERSION5,
3515
3556
  // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
3516
3557
  extensions: ["mvt", "pbf"],
3517
3558
  mimeTypes: [
@@ -3520,8 +3561,17 @@ var __exports__ = (() => {
3520
3561
  "application/x-protobuf"
3521
3562
  // 'application/octet-stream'
3522
3563
  ],
3564
+ category: "geometry"
3565
+ };
3566
+
3567
+ // ../mvt/src/mvt-loader.ts
3568
+ var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3569
+ var MVTWorkerLoader = {
3570
+ ...MVTFormat,
3571
+ dataType: null,
3572
+ batchType: null,
3573
+ version: VERSION5,
3523
3574
  worker: true,
3524
- category: "geometry",
3525
3575
  options: {
3526
3576
  mvt: {
3527
3577
  shape: "geojson",
@@ -3539,6 +3589,16 @@ var __exports__ = (() => {
3539
3589
  binary: true
3540
3590
  };
3541
3591
 
3592
+ // src/pmtiles-format.ts
3593
+ var PMTilesFormat = {
3594
+ name: "PMTiles",
3595
+ id: "pmtiles",
3596
+ module: "pmtiles",
3597
+ extensions: ["pmtiles"],
3598
+ mimeTypes: ["application/octet-stream"],
3599
+ tests: ["PMTiles"]
3600
+ };
3601
+
3542
3602
  // ../../node_modules/pmtiles/dist/index.js
3543
3603
  var dist_exports = {};
3544
3604
  __export(dist_exports, {
@@ -5324,31 +5384,25 @@ var __exports__ = (() => {
5324
5384
  var { PMTiles: PMTiles2 } = dist_exports;
5325
5385
  var VERSION6 = "1.0.0";
5326
5386
  var PMTilesSource = {
5327
- name: "PMTiles",
5328
- id: "pmtiles",
5329
- module: "pmtiles",
5387
+ ...PMTilesFormat,
5330
5388
  version: VERSION6,
5331
- extensions: ["pmtiles"],
5332
- mimeTypes: ["application/octet-stream"],
5333
- options: { url: void 0, pmtiles: {} },
5334
5389
  type: "pmtiles",
5335
5390
  fromUrl: true,
5336
5391
  fromBlob: true,
5392
+ defaultOptions: {
5393
+ pmtiles: {}
5394
+ },
5337
5395
  testURL: (url) => url.endsWith(".pmtiles"),
5338
- createDataSource: (url, props) => new PMTilesTileSource(url, props)
5396
+ createDataSource: (url, options) => new PMTilesTileSource(url, options)
5339
5397
  };
5340
5398
  var PMTilesTileSource = class extends DataSource {
5341
- data;
5342
- props;
5343
5399
  mimeType = null;
5344
5400
  pmtiles;
5345
5401
  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);
5402
+ constructor(data, options) {
5403
+ super(data, options, PMTilesSource.defaultOptions);
5404
+ const urlOrBlob = typeof data === "string" ? resolvePath(data) : new BlobSource(data, "pmtiles");
5405
+ this.pmtiles = new PMTiles2(urlOrBlob);
5352
5406
  this.getTileData = this.getTileData.bind(this);
5353
5407
  this.metadata = this.getMetadata();
5354
5408
  }
@@ -5364,8 +5418,11 @@ var __exports__ = (() => {
5364
5418
  { includeFormatHeader: false },
5365
5419
  this.loadOptions
5366
5420
  );
5367
- if (this.props.attributions) {
5368
- metadata.attributions = [...this.props.attributions, ...metadata.attributions || []];
5421
+ if (this.options.attributions) {
5422
+ metadata.attributions = [
5423
+ ...this.options.core?.attributions || [],
5424
+ ...metadata.attributions || []
5425
+ ];
5369
5426
  }
5370
5427
  if (metadata?.tileMIMEType) {
5371
5428
  this.mimeType = metadata?.tileMIMEType;
@@ -5402,8 +5459,8 @@ var __exports__ = (() => {
5402
5459
  async getVectorTile(tileParams) {
5403
5460
  const arrayBuffer = await this.getTile(tileParams);
5404
5461
  const loadOptions = {
5405
- shape: "geojson-table",
5406
5462
  mvt: {
5463
+ shape: "geojson-table",
5407
5464
  coordinates: "wgs84",
5408
5465
  tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.z },
5409
5466
  ...this.loadOptions?.mvt
@@ -5419,13 +5476,8 @@ var __exports__ = (() => {
5419
5476
 
5420
5477
  // src/pmtiles-loader.ts
5421
5478
  var PMTilesLoader = {
5422
- name: "PMTiles",
5423
- id: "pmtiles",
5424
- module: "pmtiles",
5479
+ ...PMTilesFormat,
5425
5480
  version: VERSION7,
5426
- extensions: ["pmtiles"],
5427
- mimeTypes: ["application/octet-stream"],
5428
- tests: ["PMTiles"],
5429
5481
  options: {
5430
5482
  pmtiles: {}
5431
5483
  },