map-gl-offline 0.8.7 → 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/README.md +2 -0
- package/dist/index.esm.js +51 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +52 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +52 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/services/tileService.d.ts +9 -0
- package/dist/types/tile.d.ts +14 -0
- package/dist/utils/constants.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -177,6 +177,23 @@
|
|
|
177
177
|
MODELS_PATH: '/models/v1',
|
|
178
178
|
PROTOCOL: 'mapbox://',
|
|
179
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* Mapbox Standard sub-tilesets that are sparse-by-design across the planet.
|
|
182
|
+
* These only have tiles where the underlying feature (indoor venues, landmark
|
|
183
|
+
* POIs, 3D procedural buildings) actually exists, and return 404 for nearly
|
|
184
|
+
* every other coordinate. The tile downloader pre-skips any source whose tile
|
|
185
|
+
* URL templates reference one of these tileset IDs, so we never issue probe
|
|
186
|
+
* or download requests for them — eliminating the 404 noise in devtools.
|
|
187
|
+
*
|
|
188
|
+
* Matching is done against the tileset segment of the tile URL template
|
|
189
|
+
* (e.g. `https://api.mapbox.com/v4/mapbox.indoor-v3/{z}/{x}/{y}.vector.pbf`
|
|
190
|
+
* or `mapbox://mapbox.indoor-v3`).
|
|
191
|
+
*/
|
|
192
|
+
const MAPBOX_STANDARD_SPARSE_TILESETS = [
|
|
193
|
+
'mapbox.indoor-v3',
|
|
194
|
+
'mapbox.landmark-pois-v1',
|
|
195
|
+
'mapbox.procedural-buildings-v1',
|
|
196
|
+
];
|
|
180
197
|
// Map Providers
|
|
181
198
|
const MAP_PROVIDERS = {
|
|
182
199
|
AUTO: 'auto',
|
|
@@ -6141,6 +6158,26 @@
|
|
|
6141
6158
|
const cleanupExpiredTiles = (styleId) => cleanupService.cleanupExpiredTiles(styleId);
|
|
6142
6159
|
|
|
6143
6160
|
const tileLogger = logger.scope('TileService');
|
|
6161
|
+
/**
|
|
6162
|
+
* Match a tile-URL template against the known-sparse Mapbox Standard
|
|
6163
|
+
* sub-tilesets. Catches:
|
|
6164
|
+
* - `mapbox://<tileset>` — original style source URL.
|
|
6165
|
+
* - `.../v4/<tileset>.json...` — resolved TileJSON URL produced when the
|
|
6166
|
+
* library resolves a `mapbox://` source URL into an HTTPS one.
|
|
6167
|
+
* - `.../v4/<tileset>/{z}/{x}/{y}...` — resolved tile-template URL.
|
|
6168
|
+
*/
|
|
6169
|
+
function urlReferencesKnownSparseTileset(template) {
|
|
6170
|
+
return MAPBOX_STANDARD_SPARSE_TILESETS.some(tileset => {
|
|
6171
|
+
if (template.includes(`mapbox://${tileset}`))
|
|
6172
|
+
return true;
|
|
6173
|
+
// `/v4/<tileset>` followed by `/` (tile template) or `.` (e.g. `.json`)
|
|
6174
|
+
const idx = template.indexOf(`/${tileset}`);
|
|
6175
|
+
if (idx === -1)
|
|
6176
|
+
return false;
|
|
6177
|
+
const next = template[idx + tileset.length + 1];
|
|
6178
|
+
return next === '/' || next === '.';
|
|
6179
|
+
});
|
|
6180
|
+
}
|
|
6144
6181
|
/**
|
|
6145
6182
|
* Service for managing offline map tiles
|
|
6146
6183
|
* Handles downloading, storing, and retrieving map tiles from IndexedDB
|
|
@@ -6158,7 +6195,7 @@
|
|
|
6158
6195
|
*/
|
|
6159
6196
|
async downloadTiles(region, style, styleId, options = {}) {
|
|
6160
6197
|
const db = await this.db;
|
|
6161
|
-
const { onProgress, batchSize = 10, maxRetries = 3, skipExisting = true, timeout = 10000, retryDelay = 1000, priorityZoomLevels = [], storageQuotaCheck = true, validateTiles = false, compressTiles = false, bandwidthLimit, probeSourcesBeforeDownload = true, } = options;
|
|
6198
|
+
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;
|
|
6162
6199
|
const startTime = Date.now();
|
|
6163
6200
|
let totalSize = 0;
|
|
6164
6201
|
let downloadedTiles = 0;
|
|
@@ -6262,6 +6299,16 @@
|
|
|
6262
6299
|
tileLogger.debug(`Skipping source ${sourceId}: no tiles array`);
|
|
6263
6300
|
continue;
|
|
6264
6301
|
}
|
|
6302
|
+
// Pre-skip Mapbox Standard sparse sub-tilesets (indoor-v3 etc.) before
|
|
6303
|
+
// issuing any network request. They 404 for nearly every coord in a
|
|
6304
|
+
// typical region; the downstream probe step would catch them, but the
|
|
6305
|
+
// probe itself logs 404s in devtools. Matching here keeps the console
|
|
6306
|
+
// clean.
|
|
6307
|
+
if (skipKnownSparseSources &&
|
|
6308
|
+
tiles.some(template => urlReferencesKnownSparseTileset(template))) {
|
|
6309
|
+
tileLogger.info(`Skipping source "${sourceId}" — references a known sparse Mapbox Standard sub-tileset (no probe/download issued)`);
|
|
6310
|
+
continue;
|
|
6311
|
+
}
|
|
6265
6312
|
const sourceMinZ = Math.ceil(sourceConfig.minzoom ?? region.minZoom);
|
|
6266
6313
|
const sourceMaxZ = Math.floor(sourceConfig.maxzoom ?? region.maxZoom);
|
|
6267
6314
|
let coordsForSource = tileCoords.filter(coord => coord.z >= sourceMinZ && coord.z <= sourceMaxZ);
|
|
@@ -7039,7 +7086,8 @@
|
|
|
7039
7086
|
downloadTiles: downloadTiles,
|
|
7040
7087
|
getTileAnalytics: getTileAnalytics,
|
|
7041
7088
|
getTileStats: getTileStats,
|
|
7042
|
-
tileService: tileService
|
|
7089
|
+
tileService: tileService,
|
|
7090
|
+
urlReferencesKnownSparseTileset: urlReferencesKnownSparseTileset
|
|
7043
7091
|
});
|
|
7044
7092
|
|
|
7045
7093
|
const glyphLogger = logger.scope('GlyphService');
|
|
@@ -14011,6 +14059,7 @@
|
|
|
14011
14059
|
exports.MAPBOX_API = MAPBOX_API;
|
|
14012
14060
|
exports.MAPBOX_CACHE_TTL = MAPBOX_CACHE_TTL;
|
|
14013
14061
|
exports.MAPBOX_CLASSIC_STYLES = MAPBOX_CLASSIC_STYLES;
|
|
14062
|
+
exports.MAPBOX_STANDARD_SPARSE_TILESETS = MAPBOX_STANDARD_SPARSE_TILESETS;
|
|
14014
14063
|
exports.MAP_PROVIDERS = MAP_PROVIDERS;
|
|
14015
14064
|
exports.MAX_GLYPH_CODEPOINT = MAX_GLYPH_CODEPOINT;
|
|
14016
14065
|
exports.MaintenanceService = MaintenanceService;
|
|
@@ -14131,6 +14180,7 @@
|
|
|
14131
14180
|
exports.t = t;
|
|
14132
14181
|
exports.tileService = tileService;
|
|
14133
14182
|
exports.unregisterOfflineServiceWorker = unregisterOfflineServiceWorker;
|
|
14183
|
+
exports.urlReferencesKnownSparseTileset = urlReferencesKnownSparseTileset;
|
|
14134
14184
|
exports.validateBounds = validateBounds;
|
|
14135
14185
|
exports.validateRegionOptions = validateRegionOptions;
|
|
14136
14186
|
exports.validateResource = validateResource;
|