map-gl-offline 0.8.6 → 0.8.8

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/index.js CHANGED
@@ -183,6 +183,23 @@ const MAPBOX_API = {
183
183
  MODELS_PATH: '/models/v1',
184
184
  PROTOCOL: 'mapbox://',
185
185
  };
186
+ /**
187
+ * Mapbox Standard sub-tilesets that are sparse-by-design across the planet.
188
+ * These only have tiles where the underlying feature (indoor venues, landmark
189
+ * POIs, 3D procedural buildings) actually exists, and return 404 for nearly
190
+ * every other coordinate. The tile downloader pre-skips any source whose tile
191
+ * URL templates reference one of these tileset IDs, so we never issue probe
192
+ * or download requests for them — eliminating the 404 noise in devtools.
193
+ *
194
+ * Matching is done against the tileset segment of the tile URL template
195
+ * (e.g. `https://api.mapbox.com/v4/mapbox.indoor-v3/{z}/{x}/{y}.vector.pbf`
196
+ * or `mapbox://mapbox.indoor-v3`).
197
+ */
198
+ const MAPBOX_STANDARD_SPARSE_TILESETS = [
199
+ 'mapbox.indoor-v3',
200
+ 'mapbox.landmark-pois-v1',
201
+ 'mapbox.procedural-buildings-v1',
202
+ ];
186
203
  // Map Providers
187
204
  const MAP_PROVIDERS = {
188
205
  AUTO: 'auto',
@@ -6147,6 +6164,26 @@ const getExpiredResourceCount = () => cleanupService.getExpiredResourceCount();
6147
6164
  const cleanupExpiredTiles = (styleId) => cleanupService.cleanupExpiredTiles(styleId);
6148
6165
 
6149
6166
  const tileLogger = logger.scope('TileService');
6167
+ /**
6168
+ * Match a tile-URL template against the known-sparse Mapbox Standard
6169
+ * sub-tilesets. Catches:
6170
+ * - `mapbox://<tileset>` — original style source URL.
6171
+ * - `.../v4/<tileset>.json...` — resolved TileJSON URL produced when the
6172
+ * library resolves a `mapbox://` source URL into an HTTPS one.
6173
+ * - `.../v4/<tileset>/{z}/{x}/{y}...` — resolved tile-template URL.
6174
+ */
6175
+ function urlReferencesKnownSparseTileset(template) {
6176
+ return MAPBOX_STANDARD_SPARSE_TILESETS.some(tileset => {
6177
+ if (template.includes(`mapbox://${tileset}`))
6178
+ return true;
6179
+ // `/v4/<tileset>` followed by `/` (tile template) or `.` (e.g. `.json`)
6180
+ const idx = template.indexOf(`/${tileset}`);
6181
+ if (idx === -1)
6182
+ return false;
6183
+ const next = template[idx + tileset.length + 1];
6184
+ return next === '/' || next === '.';
6185
+ });
6186
+ }
6150
6187
  /**
6151
6188
  * Service for managing offline map tiles
6152
6189
  * Handles downloading, storing, and retrieving map tiles from IndexedDB
@@ -6164,7 +6201,7 @@ class TileService {
6164
6201
  */
6165
6202
  async downloadTiles(region, style, styleId, options = {}) {
6166
6203
  const db = await this.db;
6167
- const { onProgress, batchSize = 10, maxRetries = 3, skipExisting = true, timeout = 10000, retryDelay = 1000, priorityZoomLevels = [], storageQuotaCheck = true, validateTiles = false, compressTiles = false, bandwidthLimit, probeSourcesBeforeDownload = true, } = options;
6204
+ const { onProgress, batchSize = 10, maxRetries = 3, skipExisting = true, timeout = 10000, retryDelay = 1000, priorityZoomLevels = [], storageQuotaCheck = true, validateTiles = false, compressTiles = false, bandwidthLimit, probeSourcesBeforeDownload = true, skipKnownSparseSources = true, } = options;
6168
6205
  const startTime = Date.now();
6169
6206
  let totalSize = 0;
6170
6207
  let downloadedTiles = 0;
@@ -6268,6 +6305,16 @@ class TileService {
6268
6305
  tileLogger.debug(`Skipping source ${sourceId}: no tiles array`);
6269
6306
  continue;
6270
6307
  }
6308
+ // Pre-skip Mapbox Standard sparse sub-tilesets (indoor-v3 etc.) before
6309
+ // issuing any network request. They 404 for nearly every coord in a
6310
+ // typical region; the downstream probe step would catch them, but the
6311
+ // probe itself logs 404s in devtools. Matching here keeps the console
6312
+ // clean.
6313
+ if (skipKnownSparseSources &&
6314
+ tiles.some(template => urlReferencesKnownSparseTileset(template))) {
6315
+ tileLogger.info(`Skipping source "${sourceId}" — references a known sparse Mapbox Standard sub-tileset (no probe/download issued)`);
6316
+ continue;
6317
+ }
6271
6318
  const sourceMinZ = Math.ceil(sourceConfig.minzoom ?? region.minZoom);
6272
6319
  const sourceMaxZ = Math.floor(sourceConfig.maxzoom ?? region.maxZoom);
6273
6320
  let coordsForSource = tileCoords.filter(coord => coord.z >= sourceMinZ && coord.z <= sourceMaxZ);
@@ -7045,7 +7092,8 @@ var tileService$1 = /*#__PURE__*/Object.freeze({
7045
7092
  downloadTiles: downloadTiles,
7046
7093
  getTileAnalytics: getTileAnalytics,
7047
7094
  getTileStats: getTileStats,
7048
- tileService: tileService
7095
+ tileService: tileService,
7096
+ urlReferencesKnownSparseTileset: urlReferencesKnownSparseTileset
7049
7097
  });
7050
7098
 
7051
7099
  const glyphLogger = logger.scope('GlyphService');
@@ -11388,7 +11436,7 @@ class PanelRenderer extends BaseComponent {
11388
11436
  try {
11389
11437
  const { loadStyleById } = await Promise.resolve().then(function () { return styleService; });
11390
11438
  const styleEntry = await loadStyleById(region.styleId);
11391
- accessToken = styleEntry?.accessToken;
11439
+ accessToken = styleEntry?.accessToken ?? undefined;
11392
11440
  }
11393
11441
  catch {
11394
11442
  panelLogger.warn('Could not retrieve access token from stored style');
@@ -14017,6 +14065,7 @@ exports.ImportExportService = ImportExportService;
14017
14065
  exports.MAPBOX_API = MAPBOX_API;
14018
14066
  exports.MAPBOX_CACHE_TTL = MAPBOX_CACHE_TTL;
14019
14067
  exports.MAPBOX_CLASSIC_STYLES = MAPBOX_CLASSIC_STYLES;
14068
+ exports.MAPBOX_STANDARD_SPARSE_TILESETS = MAPBOX_STANDARD_SPARSE_TILESETS;
14020
14069
  exports.MAP_PROVIDERS = MAP_PROVIDERS;
14021
14070
  exports.MAX_GLYPH_CODEPOINT = MAX_GLYPH_CODEPOINT;
14022
14071
  exports.MaintenanceService = MaintenanceService;
@@ -14137,6 +14186,7 @@ exports.stopAutoCleanup = stopAutoCleanup;
14137
14186
  exports.t = t;
14138
14187
  exports.tileService = tileService;
14139
14188
  exports.unregisterOfflineServiceWorker = unregisterOfflineServiceWorker;
14189
+ exports.urlReferencesKnownSparseTileset = urlReferencesKnownSparseTileset;
14140
14190
  exports.validateBounds = validateBounds;
14141
14191
  exports.validateRegionOptions = validateRegionOptions;
14142
14192
  exports.validateResource = validateResource;