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/dist/index.js CHANGED
@@ -194,10 +194,15 @@ const MAPBOX_API = {
194
194
  * Matching is done against the tileset segment of the tile URL template
195
195
  * (e.g. `https://api.mapbox.com/v4/mapbox.indoor-v3/{z}/{x}/{y}.vector.pbf`
196
196
  * or `mapbox://mapbox.indoor-v3`).
197
+ *
198
+ * The ids below are the ones the live Mapbox Standard style declares — note
199
+ * that the landmark-POI tileset is `mapbox.mapbox-landmark-pois-v1` (doubled
200
+ * `mapbox` segment), unlike the other two. The matcher is delimiter-anchored,
201
+ * so an approximate id silently never matches.
197
202
  */
198
203
  const MAPBOX_STANDARD_SPARSE_TILESETS = [
199
204
  'mapbox.indoor-v3',
200
- 'mapbox.landmark-pois-v1',
205
+ 'mapbox.mapbox-landmark-pois-v1',
201
206
  'mapbox.procedural-buildings-v1',
202
207
  ];
203
208
  // Map Providers
@@ -3302,15 +3307,42 @@ function configureSqlJs(config) {
3302
3307
  sqlJsPromise = null;
3303
3308
  }
3304
3309
  /**
3305
- * Lazily initialise `sql.js`. The underlying module is loaded via dynamic
3306
- * `import()` so it only ships with bundles that actually call MBTiles code.
3310
+ * Resolve the `initSqlJs` factory.
3311
+ *
3312
+ * Bundler builds resolve the npm package via dynamic `import()`, so `sql.js`
3313
+ * only ships with bundles that actually call MBTiles code. The UMD/CDN build
3314
+ * has no module resolver, so the import throws there — fall back to the
3315
+ * `initSqlJs` global that sql.js's own `<script>` build defines.
3316
+ */
3317
+ async function resolveInitSqlJs() {
3318
+ let importError;
3319
+ try {
3320
+ const mod = (await import('sql.js'));
3321
+ if (typeof mod?.default === 'function')
3322
+ return mod.default;
3323
+ }
3324
+ catch (error) {
3325
+ // Bare specifier not resolvable (UMD/CDN), or the module threw while
3326
+ // initialising. Either way, try the global before giving up.
3327
+ importError = error;
3328
+ }
3329
+ const globalInit = globalThis.initSqlJs;
3330
+ if (typeof globalInit === 'function')
3331
+ return globalInit;
3332
+ // Preserve the original failure — a module that resolved but threw is a
3333
+ // very different problem from one that couldn't be resolved at all.
3334
+ throw new Error('sql.js could not be loaded. Install `sql.js` when bundling, or load ' +
3335
+ 'https://cdn.jsdelivr.net/npm/sql.js/dist/sql-wasm.js before map-gl-offline ' +
3336
+ 'when using the UMD build.', importError !== undefined ? { cause: importError } : undefined);
3337
+ }
3338
+ /**
3339
+ * Lazily initialise `sql.js`.
3307
3340
  */
3308
3341
  async function getSqlJs() {
3309
3342
  if (sqlJsPromise)
3310
3343
  return sqlJsPromise;
3311
3344
  sqlJsPromise = (async () => {
3312
- const mod = (await import('sql.js'));
3313
- const initSqlJs = mod.default;
3345
+ const initSqlJs = await resolveInitSqlJs();
3314
3346
  const options = {};
3315
3347
  if (currentConfig.wasmBinary) {
3316
3348
  options.wasmBinary = currentConfig.wasmBinary;