@mapvx/web-kit 1.2.0-develop.11 → 1.2.0-develop.13

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.
Files changed (48) hide show
  1. package/dist/cjs/chunks/{DRACOLoader-CjN7nfMz.cjs → DRACOLoader-gEI4jG0V.cjs} +2 -2
  2. package/dist/cjs/chunks/{GLTFLoader-C33v_eKh.cjs → GLTFLoader-Cd9ix-wY.cjs} +2 -2
  3. package/dist/cjs/chunks/{KTX2Loader-GfgRciKI.cjs → KTX2Loader-Dk2GlCFI.cjs} +2 -2
  4. package/dist/cjs/chunks/{accessibility-CamvBQ8h.cjs → accessibility-C9U1mv_p.cjs} +2 -2
  5. package/dist/cjs/chunks/{back_arrow-BrByZltA.cjs → back_arrow-tpfWrGJ9.cjs} +2 -2
  6. package/dist/cjs/chunks/{debug-hooks-C_m1SbH2.cjs → debug-hooks-xLx1YP8n.cjs} +2 -2
  7. package/dist/cjs/chunks/{dist-B3zxScE2.cjs → dist-1oZjernx.cjs} +2 -2
  8. package/dist/cjs/chunks/{dist-DRfr3UXp.cjs → dist-CYGLkXos.cjs} +2 -2
  9. package/dist/cjs/chunks/{dist-CpCOzc73.cjs → dist-ENDZf7Zh.cjs} +2 -2
  10. package/dist/cjs/chunks/{expression-EUvjFYH4.cjs → expression-q70ZQCYv.cjs} +2 -2
  11. package/dist/cjs/chunks/{globe-viewport-SZrSWKdf.cjs → globe-viewport-CIe_h8dV.cjs} +2 -2
  12. package/dist/cjs/chunks/{icon-origin-point-DW7v7TzN.cjs → icon-origin-point-D_DBb1gM.cjs} +2 -2
  13. package/dist/cjs/chunks/{meshopt_decoder.module-Dk924uu3.cjs → meshopt_decoder.module-B5j8Tze_.cjs} +2 -2
  14. package/dist/cjs/chunks/{repeat_icon-Bpef1DPh.cjs → repeat_icon-F6Q7hnPl.cjs} +2 -2
  15. package/dist/cjs/chunks/{rolldown-runtime-1If4f64F.cjs → rolldown-runtime-BOxlEPsq.cjs} +2 -2
  16. package/dist/cjs/chunks/{shader-type-decoder-BqFbHaKB.cjs → shader-type-decoder-B16cQ7H3.cjs} +2 -2
  17. package/dist/cjs/chunks/{styles-DP9KZtXl.cjs → styles-zP5lXn9p.cjs} +2 -2
  18. package/dist/cjs/chunks/{three.module-Drz560ge.cjs → three.module-BHURJnCD.cjs} +2 -2
  19. package/dist/cjs/chunks/{walking-BfKvsH3Y.cjs → walking-CMpmZTw3.cjs} +2 -2
  20. package/dist/cjs/chunks/{webgl-CxZNw2p_.cjs → webgl-CJbVWdD9.cjs} +2 -2
  21. package/dist/cjs/chunks/{webgl-device-Dpif38ir.cjs → webgl-device-D7wKHxQy.cjs} +2 -2
  22. package/dist/cjs/web-kit.cjs +22 -22
  23. package/dist/es/chunks/{DRACOLoader-CudX8012.js → DRACOLoader-r8VXQ8hj.js} +2 -2
  24. package/dist/es/chunks/{GLTFLoader-BLc_n6C7.js → GLTFLoader-IbJ3eCNr.js} +2 -2
  25. package/dist/es/chunks/{KTX2Loader-CnBac9vX.js → KTX2Loader-DZlQyAGv.js} +2 -2
  26. package/dist/es/chunks/{accessibility-BTRW5qzF.js → accessibility-BldDqm74.js} +2 -2
  27. package/dist/es/chunks/{back_arrow-DaE2mYq8.js → back_arrow-BeeCYF4P.js} +2 -2
  28. package/dist/es/chunks/{debug-hooks-A7fGcVSJ.js → debug-hooks-NzJ2oy3C.js} +2 -2
  29. package/dist/es/chunks/{dist-B8bewEN3.js → dist-B3-nPsaF.js} +2 -2
  30. package/dist/es/chunks/{dist-Cq65fMeu.js → dist-DNNWa2bQ.js} +2 -2
  31. package/dist/es/chunks/{dist-CeI9yzhC.js → dist-DOcsJa1u.js} +2 -2
  32. package/dist/es/chunks/{expression-BFfy7ZSj.js → expression-Dpos4VqC.js} +2 -2
  33. package/dist/es/chunks/{globe-viewport-C_lLyBu9.js → globe-viewport-BmqhgdhG.js} +2 -2
  34. package/dist/es/chunks/{icon-origin-point-bHQmYXyG.js → icon-origin-point-CkHTMtFu.js} +2 -2
  35. package/dist/es/chunks/{meshopt_decoder.module-ClKO_vyv.js → meshopt_decoder.module-YGVnWwV0.js} +2 -2
  36. package/dist/es/chunks/{repeat_icon-BDjNCPIN.js → repeat_icon-B_t3ecTa.js} +2 -2
  37. package/dist/es/chunks/{rolldown-runtime-CGJB3Nua.js → rolldown-runtime-BSTMnvUK.js} +2 -2
  38. package/dist/es/chunks/{shader-type-decoder-DV9QwQh3.js → shader-type-decoder-CFX5sij5.js} +2 -2
  39. package/dist/es/chunks/{styles-BPMrJs_x.js → styles-DTTMB3rI.js} +2 -2
  40. package/dist/es/chunks/{three.module-DUnMDXpm.js → three.module-Cj5xe6gn.js} +2 -2
  41. package/dist/es/chunks/{walking-CUOW_o2S.js → walking--SMEsH_B.js} +2 -2
  42. package/dist/es/chunks/{webgl-B16MrmDy.js → webgl-ZcaUll7k.js} +2 -2
  43. package/dist/es/chunks/{webgl-device-Bht0bA0i.js → webgl-device-KnEQ5CNv.js} +2 -2
  44. package/dist/es/web-kit.mjs +25 -25
  45. package/dist/iife/web-kit.iife.js +22 -22
  46. package/dist/sw/mvx-tiles-sw.js +97 -49
  47. package/dist/types/index.d.ts +40 -42
  48. package/package.json +1 -1
@@ -51,7 +51,7 @@ const TILE_PREFETCH = {
51
51
 
52
52
  function delay(ms) {
53
53
  return new Promise((resolve) => {
54
- self.setTimeout(resolve, ms)
54
+ globalThis.setTimeout(resolve, ms)
55
55
  })
56
56
  }
57
57
 
@@ -177,6 +177,72 @@ async function prefetchUrlsInBatches(cache, urls, signal) {
177
177
  }
178
178
  }
179
179
 
180
+ /** Fetches the tiles around `center` at `initialZoom`. Returns the budget left after phase 1. */
181
+ async function prefetchInitialZoomTiles(
182
+ cache,
183
+ center,
184
+ initialZoom,
185
+ trimmedKey,
186
+ vectorTilesBase,
187
+ budget,
188
+ signal,
189
+ ) {
190
+ const phaseOne = tilesAroundCenter(center, initialZoom, TILE_PREFETCH.initialRadiusTiles)
191
+ const urlsPhaseOne = phaseOne
192
+ .slice(0, budget)
193
+ .map(({ z, x, y }) => buildVectorTileUrl(vectorTilesBase, z, x, y, trimmedKey))
194
+
195
+ console.log('[MVX-SW] Tile prefetch phase 1 (initial zoom only)', {
196
+ initialZoom,
197
+ tiles: urlsPhaseOne.length,
198
+ })
199
+ await prefetchUrlsInBatches(cache, urlsPhaseOne, signal)
200
+ return budget - urlsPhaseOne.length
201
+ }
202
+
203
+ /** Progressively widens the prefetch to every other zoom level, closest to `initialZoom` first. */
204
+ async function prefetchRemainingZoomLevels(
205
+ cache,
206
+ center,
207
+ initialZoom,
208
+ minZoom,
209
+ maxZoom,
210
+ trimmedKey,
211
+ vectorTilesBase,
212
+ budget,
213
+ signal,
214
+ ) {
215
+ const otherZoomLevels = []
216
+ for (let z = minZoom; z <= maxZoom; z++) {
217
+ if (z !== initialZoom) {
218
+ otherZoomLevels.push(z)
219
+ }
220
+ }
221
+ otherZoomLevels.sort((a, b) => Math.abs(a - initialZoom) - Math.abs(b - initialZoom))
222
+
223
+ for (const zoom of otherZoomLevels) {
224
+ if (signal.aborted || budget <= 0) {
225
+ break
226
+ }
227
+ await delay(TILE_PREFETCH.zoomLevelGapMs)
228
+ if (signal.aborted) {
229
+ break
230
+ }
231
+
232
+ const ring = tilesAroundCenter(center, zoom, TILE_PREFETCH.progressiveRadiusTiles)
233
+ const urls = ring
234
+ .slice(0, budget)
235
+ .map(({ z: zz, x, y }) => buildVectorTileUrl(vectorTilesBase, zz, x, y, trimmedKey))
236
+ budget -= urls.length
237
+
238
+ console.log('[MVX-SW] Tile prefetch background zoom', {
239
+ zoom,
240
+ tiles: urls.length,
241
+ })
242
+ await prefetchUrlsInBatches(cache, urls, signal)
243
+ }
244
+ }
245
+
180
246
  async function progressivePrefetchTiles(apiKey, placeId, tilesBaseUrl) {
181
247
  const trimmedKey = typeof apiKey === 'string' ? apiKey.trim() : ''
182
248
  if (trimmedKey === '') {
@@ -221,54 +287,32 @@ async function progressivePrefetchTiles(apiKey, placeId, tilesBaseUrl) {
221
287
  const maxZoom = Math.ceil(configuration.limitZoomIn ?? initialZoom + 2)
222
288
 
223
289
  const cache = await caches.open(CACHE_TILES)
224
- let budget = TILE_PREFETCH.maxTilesPerRun
225
-
226
- const phaseOne = tilesAroundCenter(center, initialZoom, TILE_PREFETCH.initialRadiusTiles)
227
- const urlsPhaseOne = phaseOne
228
- .slice(0, budget)
229
- .map(({ z, x, y }) => buildVectorTileUrl(vectorTilesBase, z, x, y, trimmedKey))
230
- budget -= urlsPhaseOne.length
231
-
232
- console.log('[MVX-SW] Tile prefetch phase 1 (initial zoom only)', {
290
+ const budgetAfterPhaseOne = await prefetchInitialZoomTiles(
291
+ cache,
292
+ center,
233
293
  initialZoom,
234
- tiles: urlsPhaseOne.length,
235
- })
236
- await prefetchUrlsInBatches(cache, urlsPhaseOne, signal)
294
+ trimmedKey,
295
+ vectorTilesBase,
296
+ TILE_PREFETCH.maxTilesPerRun,
297
+ signal,
298
+ )
237
299
 
238
- if (signal.aborted || budget <= 0) {
300
+ if (signal.aborted || budgetAfterPhaseOne <= 0) {
239
301
  console.log('[MVX-SW] Tile prefetch stopped after phase 1')
240
302
  return
241
303
  }
242
304
 
243
- const otherZoomLevels = []
244
- for (let z = minZoom; z <= maxZoom; z++) {
245
- if (z !== initialZoom) {
246
- otherZoomLevels.push(z)
247
- }
248
- }
249
- otherZoomLevels.sort((a, b) => Math.abs(a - initialZoom) - Math.abs(b - initialZoom))
250
-
251
- for (const zoom of otherZoomLevels) {
252
- if (signal.aborted || budget <= 0) {
253
- break
254
- }
255
- await delay(TILE_PREFETCH.zoomLevelGapMs)
256
- if (signal.aborted) {
257
- break
258
- }
259
-
260
- const ring = tilesAroundCenter(center, zoom, TILE_PREFETCH.progressiveRadiusTiles)
261
- const urls = ring
262
- .slice(0, budget)
263
- .map(({ z: zz, x, y }) => buildVectorTileUrl(vectorTilesBase, zz, x, y, trimmedKey))
264
- budget -= urls.length
265
-
266
- console.log('[MVX-SW] Tile prefetch background zoom', {
267
- zoom,
268
- tiles: urls.length,
269
- })
270
- await prefetchUrlsInBatches(cache, urls, signal)
271
- }
305
+ await prefetchRemainingZoomLevels(
306
+ cache,
307
+ center,
308
+ initialZoom,
309
+ minZoom,
310
+ maxZoom,
311
+ trimmedKey,
312
+ vectorTilesBase,
313
+ budgetAfterPhaseOne,
314
+ signal,
315
+ )
272
316
 
273
317
  console.log('[MVX-SW] Progressive tile prefetch finished')
274
318
  } catch (err) {
@@ -300,12 +344,12 @@ async function resetAndUnregister() {
300
344
  console.warn('[MVX-SW] resetAndUnregister: clear caches failed', err)
301
345
  }
302
346
  try {
303
- await self.registration.unregister()
347
+ await globalThis.registration.unregister()
304
348
  } catch (err) {
305
349
  console.warn('[MVX-SW] resetAndUnregister: unregister failed', err)
306
350
  }
307
351
  try {
308
- const clients = await self.clients.matchAll({ type: 'window' })
352
+ const clients = await globalThis.clients.matchAll({ type: 'window' })
309
353
  for (const client of clients) {
310
354
  try {
311
355
  client.postMessage({ type: 'SW_RESET_DONE' })
@@ -319,7 +363,7 @@ async function resetAndUnregister() {
319
363
  }
320
364
 
321
365
  function notifyClients(message) {
322
- self.clients
366
+ globalThis.clients
323
367
  .matchAll({ includeUncontrolled: true })
324
368
  .then((clients) => {
325
369
  clients.forEach((client) => {
@@ -343,7 +387,7 @@ const ALLOWED_HOSTS = [
343
387
  ]
344
388
  const isAllowedHost = (hostname) => ALLOWED_HOSTS.some((host) => hostname.endsWith(host))
345
389
 
346
- self.skipWaiting()
390
+ globalThis.skipWaiting()
347
391
  workbox.core.clientsClaim()
348
392
  workbox.core.setCacheNameDetails({ prefix: 'mvx' })
349
393
  workbox.precaching.cleanupOutdatedCaches()
@@ -504,7 +548,7 @@ registerRoute(
504
548
  }),
505
549
  )
506
550
 
507
- self.addEventListener('activate', (event) => {
551
+ globalThis.addEventListener('activate', (event) => {
508
552
  event.waitUntil(
509
553
  (async () => {
510
554
  try {
@@ -530,7 +574,11 @@ self.addEventListener('activate', (event) => {
530
574
  )
531
575
  })
532
576
 
533
- self.addEventListener('message', (event) => {
577
+ globalThis.addEventListener('message', (event) => {
578
+ // A controlled client can only ever be same-origin with its service worker, but Workbox's own
579
+ // message listeners don't check this, and neither did this file until now -- check it anyway,
580
+ // defense in depth against whatever reaches this handler.
581
+ if (event.origin !== globalThis.location.origin) return
534
582
  if (!isValidMessage(event.data)) return
535
583
 
536
584
  switch (event.data.type) {
@@ -298,8 +298,8 @@ declare const FLOOR_SELECTOR_POSITIONS: readonly ["top-left", "top-center", "top
298
298
  * Controller for managing floor-related operations.
299
299
  */
300
300
  declare class FloorController implements ReactiveController {
301
- private host;
302
- private contextManager;
301
+ private readonly host;
302
+ private readonly contextManager;
303
303
  constructor(host: ReactiveControllerHost, contextManager: ContextManager);
304
304
  hostConnected(): void;
305
305
  hostDisconnected(): void;
@@ -417,7 +417,7 @@ declare class FloorSelectorSizeController implements ReactiveController {
417
417
  }
418
418
 
419
419
  export declare class MapViewWithModal extends LitElement {
420
- static styles: CSSResult[];
420
+ static readonly styles: CSSResult[];
421
421
  apiKey: string;
422
422
  parentPlaceId: string;
423
423
  locale: string;
@@ -527,8 +527,8 @@ export declare class MapViewWithModal extends LitElement {
527
527
  firstUpdated(): void;
528
528
  /** Same shape as the reference's own `baseParams()`: no route, so no destination/origin fields. */
529
529
  private baseParams;
530
- private _mapReadyHandler;
531
- private _cameraInitializedHandler;
530
+ private readonly _mapReadyHandler;
531
+ private readonly _cameraInitializedHandler;
532
532
  /**
533
533
  * The floor id this handler last reported `floor_change` analytics for — this element's own
534
534
  * dedupe, independent of `FloorController.setFloor()`'s return value (review round 1, finding 1).
@@ -552,7 +552,7 @@ export declare class MapViewWithModal extends LitElement {
552
552
  * side rather than through the controller (see Task 9's identical wiring and its own doc comment).
553
553
  * Safe to call for either source: idempotent on an already-applied floor.
554
554
  */
555
- private _floorChangeHandler;
555
+ private readonly _floorChangeHandler;
556
556
  updated(changedProperties: PropertyValues): void;
557
557
  /** The `placeId` last passed to {@link PlaceController.setOriginAndDestination}, or `undefined`. */
558
558
  private _placeIdRequestedFor;
@@ -757,8 +757,8 @@ declare interface PlaceContextType {
757
757
  * Controller for managing place-related operations.
758
758
  */
759
759
  declare class PlaceController implements ReactiveController {
760
- private host;
761
- private contextManager;
760
+ private readonly host;
761
+ private readonly contextManager;
762
762
  private connected;
763
763
  /**
764
764
  * Request counter, the reference's `placesRequest`. Every pair load bumps it and keeps the value it
@@ -1110,7 +1110,7 @@ declare class RouteController implements ReactiveController {
1110
1110
  export declare type RoutePanelVariant = 'full' | 'compact';
1111
1111
 
1112
1112
  export declare class RouteViewTotems extends LitElement {
1113
- static styles: CSSResult[];
1113
+ static readonly styles: CSSResult[];
1114
1114
  apiKey: string;
1115
1115
  parentPlaceId: string;
1116
1116
  /**
@@ -1348,16 +1348,16 @@ export declare class RouteViewTotems extends LitElement {
1348
1348
  private _customMap;
1349
1349
  firstUpdated(): void;
1350
1350
  private sendEvent;
1351
- private _mapReadyHandler;
1352
- private _cameraInitializedHandler;
1351
+ private readonly _mapReadyHandler;
1352
+ private readonly _cameraInitializedHandler;
1353
1353
  willUpdate(changedProperties: PropertyValues): void;
1354
1354
  updated(changedProperties: PropertyValues): void;
1355
1355
  render(): TemplateResult<1>;
1356
- private _floorChangeHandler;
1357
- private _accessibilityChangeHandler;
1358
- private _repeatRouteHandler;
1359
- private _generateRouteHandler;
1360
- private _backHandler;
1356
+ private readonly _floorChangeHandler;
1357
+ private readonly _accessibilityChangeHandler;
1358
+ private readonly _repeatRouteHandler;
1359
+ private readonly _generateRouteHandler;
1360
+ private readonly _backHandler;
1361
1361
  /**
1362
1362
  * Turns `<custom-map>`'s `startRouteAnimation`/`routeAnimationFinished` events, and
1363
1363
  * `<route-options>`'s `repeatRoute` event, into the matching `RouteController` call. This is the
@@ -1367,9 +1367,9 @@ export declare class RouteViewTotems extends LitElement {
1367
1367
  * `route-view-totems.test.ts`'s "route animation wiring" suite for the regression test proving a
1368
1368
  * natural finish does not trigger a restart.
1369
1369
  */
1370
- private _startRouteAnimationHandler;
1371
- private _routeAnimationFinishedHandler;
1372
- private _dismissRouteErrorHandler;
1370
+ private readonly _startRouteAnimationHandler;
1371
+ private readonly _routeAnimationFinishedHandler;
1372
+ private readonly _dismissRouteErrorHandler;
1373
1373
  /**
1374
1374
  * Updates the component's origin/destination/floor/route-type without requiring a "back" event.
1375
1375
  * Delegates to the inner `<custom-map>`'s own `updateComponent()` (see this class's doc comment for
@@ -1662,13 +1662,6 @@ export declare const WEB_CACHE_CONFIG: CacheConfig;
1662
1662
  export { }
1663
1663
 
1664
1664
 
1665
- declare global {
1666
- interface HTMLElementTagNameMap {
1667
- 'route-view-totems': RouteViewTotems;
1668
- }
1669
- }
1670
-
1671
-
1672
1665
  declare global {
1673
1666
  interface HTMLElementTagNameMap {
1674
1667
  'map-view-with-modal': MapViewWithModal;
@@ -1712,54 +1705,59 @@ declare global {
1712
1705
 
1713
1706
  declare global {
1714
1707
  interface HTMLElementTagNameMap {
1715
- 'compact-floor-selector': CompactFloorSelector;
1708
+ 'route-view-totems': RouteViewTotems;
1716
1709
  }
1717
1710
  }
1718
1711
 
1719
1712
 
1720
1713
  declare global {
1721
1714
  interface HTMLElementTagNameMap {
1722
- 'floor-selector': FloorSelector;
1715
+ 'compact-floor-selector': CompactFloorSelector;
1723
1716
  }
1724
1717
  }
1725
1718
 
1726
1719
 
1727
1720
  declare global {
1728
- interface HTMLElementTagNameMap {
1729
- 'route-options': RouteOptions;
1721
+ var dataLayer: unknown[];
1722
+ var gtag: (...args: unknown[]) => void;
1723
+ }
1724
+
1725
+
1726
+ declare global {
1727
+ interface HTMLElementEventMap {
1728
+ /**
1729
+ * The loading state changed, with the phase that caused it. One event per transition, and
1730
+ * `detail.loading === false` is the end of the load — the same moment the built-in indicator
1731
+ * goes down.
1732
+ */
1733
+ mvxLoadingChange: CustomEvent<MvxLoadingChangeDetail>;
1730
1734
  }
1731
1735
  }
1732
1736
 
1733
1737
 
1734
1738
  declare global {
1735
1739
  interface HTMLElementTagNameMap {
1736
- 'qr-modal': QRModal;
1740
+ 'map-loading-overlay': MapLoadingOverlay;
1737
1741
  }
1738
1742
  }
1739
1743
 
1740
1744
 
1741
1745
  declare global {
1742
- interface Window {
1743
- dataLayer: unknown[];
1744
- gtag: (...args: unknown[]) => void;
1746
+ interface HTMLElementTagNameMap {
1747
+ 'floor-selector': FloorSelector;
1745
1748
  }
1746
1749
  }
1747
1750
 
1748
1751
 
1749
1752
  declare global {
1750
- interface HTMLElementEventMap {
1751
- /**
1752
- * The loading state changed, with the phase that caused it. One event per transition, and
1753
- * `detail.loading === false` is the end of the load — the same moment the built-in indicator
1754
- * goes down.
1755
- */
1756
- mvxLoadingChange: CustomEvent<MvxLoadingChangeDetail>;
1753
+ interface HTMLElementTagNameMap {
1754
+ 'route-options': RouteOptions;
1757
1755
  }
1758
1756
  }
1759
1757
 
1760
1758
 
1761
1759
  declare global {
1762
1760
  interface HTMLElementTagNameMap {
1763
- 'map-loading-overlay': MapLoadingOverlay;
1761
+ 'qr-modal': QRModal;
1764
1762
  }
1765
1763
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mapvx/web-kit",
3
3
  "description": "A web component library for building interactive maps.",
4
- "version": "1.2.0-develop.11",
4
+ "version": "1.2.0-develop.13",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
7
  "publishConfig": {