map-gl-offline 0.8.8 → 0.8.9

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 CHANGED
@@ -25,7 +25,7 @@ TypeScript offline-map library for **MapLibre GL JS** and **Mapbox GL JS**. Down
25
25
  npm install map-gl-offline
26
26
  ```
27
27
 
28
- Or via CDN as the `mapgloffline` global:
28
+ Or via CDN as the `mapgloffline` global. The UMD build is self-contained — only your map library needs to be on the page:
29
29
 
30
30
  ```html
31
31
  <script src="https://unpkg.com/map-gl-offline/dist/index.umd.js"></script>
@@ -200,7 +200,7 @@ for (const city of cities) {
200
200
 
201
201
  For composite styles (e.g. Mapbox Standard) that reference sparse tilesets like `indoor-v3` or `landmark-pois-v1`, the tile downloader probes start/middle/end tiles per source and drops any that return majority-404. Disable with `tileOptions: { probeSourcesBeforeDownload: false }`.
202
202
 
203
- Three Mapbox Standard sub-tilesets are sparse-by-design across the planet — `mapbox.indoor-v3`, `mapbox.landmark-pois-v1`, `mapbox.procedural-buildings-v1`. Since 0.8.8 these are hard-skipped **before** the probe step so no network request is issued (and no 404s land in devtools). Opt out with `tileOptions: { skipKnownSparseSources: false }` to run them through the probe path instead.
203
+ Three Mapbox Standard sub-tilesets are sparse-by-design across the planet — `mapbox.indoor-v3`, `mapbox.mapbox-landmark-pois-v1`, `mapbox.procedural-buildings-v1`. Since 0.8.8 these are hard-skipped **before** the probe step so no network request is issued (and no 404s land in devtools). Opt out with `tileOptions: { skipKnownSparseSources: false }` to run them through the probe path instead.
204
204
 
205
205
  ### Recovering from an incompatible DB
206
206
 
@@ -226,6 +226,7 @@ try {
226
226
  ## API at a glance
227
227
 
228
228
  - **Regions** — `downloadRegion`, `loadRegion`, `addRegion`, `getStoredRegion`, `listStoredRegions`, `listRegions`, `deleteRegion`
229
+ - **Styles** — `downloadStyle`, `downloadMapboxStyle`, `downloadMapLibreStyle`, `downloadStyleWithAutoDetection`, `listStyles`, `loadStyleById`, `getStyleStats`, `deleteStyle`, `cleanupOldStyles`
229
230
  - **Analytics** — `getComprehensiveStorageAnalytics`, `getRegionAnalytics`, `getTileStats`, `getFontStats`, `getSpriteStats`, `getGlyphStats`
230
231
  - **Cleanup** — `cleanupExpiredRegions`, `performSmartCleanup`, `cleanupOld{Fonts,Sprites,Glyphs}`, `verifyAndRepair{Fonts,Sprites,Glyphs}`, `setupAutoCleanup`, `performCompleteMaintenance`
231
232
  - **Import / Export** — `exportRegionAsMBTiles`, `importRegion`, `downloadExportedRegion` (binary SQLite MBTiles, QGIS/tippecanoe-compatible)
package/dist/index.esm.js CHANGED
@@ -171,10 +171,15 @@ const MAPBOX_API = {
171
171
  * Matching is done against the tileset segment of the tile URL template
172
172
  * (e.g. `https://api.mapbox.com/v4/mapbox.indoor-v3/{z}/{x}/{y}.vector.pbf`
173
173
  * or `mapbox://mapbox.indoor-v3`).
174
+ *
175
+ * The ids below are the ones the live Mapbox Standard style declares — note
176
+ * that the landmark-POI tileset is `mapbox.mapbox-landmark-pois-v1` (doubled
177
+ * `mapbox` segment), unlike the other two. The matcher is delimiter-anchored,
178
+ * so an approximate id silently never matches.
174
179
  */
175
180
  const MAPBOX_STANDARD_SPARSE_TILESETS = [
176
181
  'mapbox.indoor-v3',
177
- 'mapbox.landmark-pois-v1',
182
+ 'mapbox.mapbox-landmark-pois-v1',
178
183
  'mapbox.procedural-buildings-v1',
179
184
  ];
180
185
  // Map Providers
@@ -3279,15 +3284,42 @@ function configureSqlJs(config) {
3279
3284
  sqlJsPromise = null;
3280
3285
  }
3281
3286
  /**
3282
- * Lazily initialise `sql.js`. The underlying module is loaded via dynamic
3283
- * `import()` so it only ships with bundles that actually call MBTiles code.
3287
+ * Resolve the `initSqlJs` factory.
3288
+ *
3289
+ * Bundler builds resolve the npm package via dynamic `import()`, so `sql.js`
3290
+ * only ships with bundles that actually call MBTiles code. The UMD/CDN build
3291
+ * has no module resolver, so the import throws there — fall back to the
3292
+ * `initSqlJs` global that sql.js's own `<script>` build defines.
3293
+ */
3294
+ async function resolveInitSqlJs() {
3295
+ let importError;
3296
+ try {
3297
+ const mod = (await import('sql.js'));
3298
+ if (typeof mod?.default === 'function')
3299
+ return mod.default;
3300
+ }
3301
+ catch (error) {
3302
+ // Bare specifier not resolvable (UMD/CDN), or the module threw while
3303
+ // initialising. Either way, try the global before giving up.
3304
+ importError = error;
3305
+ }
3306
+ const globalInit = globalThis.initSqlJs;
3307
+ if (typeof globalInit === 'function')
3308
+ return globalInit;
3309
+ // Preserve the original failure — a module that resolved but threw is a
3310
+ // very different problem from one that couldn't be resolved at all.
3311
+ throw new Error('sql.js could not be loaded. Install `sql.js` when bundling, or load ' +
3312
+ 'https://cdn.jsdelivr.net/npm/sql.js/dist/sql-wasm.js before map-gl-offline ' +
3313
+ 'when using the UMD build.', importError !== undefined ? { cause: importError } : undefined);
3314
+ }
3315
+ /**
3316
+ * Lazily initialise `sql.js`.
3284
3317
  */
3285
3318
  async function getSqlJs() {
3286
3319
  if (sqlJsPromise)
3287
3320
  return sqlJsPromise;
3288
3321
  sqlJsPromise = (async () => {
3289
- const mod = (await import('sql.js'));
3290
- const initSqlJs = mod.default;
3322
+ const initSqlJs = await resolveInitSqlJs();
3291
3323
  const options = {};
3292
3324
  if (currentConfig.wasmBinary) {
3293
3325
  options.wasmBinary = currentConfig.wasmBinary;