@mapvx/web-components 0.0.25 → 0.0.27
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 +16 -3
- package/dist/cjs/{base-floor-selector-C1G5K9Er.cjs → base-floor-selector-CLFTtgbp.cjs} +2 -2
- package/dist/cjs/{class-map-BQQ7MXll.cjs → class-map-BTH_74Qs.cjs} +2 -2
- package/dist/cjs/{compact-floor-selector-DsMWGOFg.cjs → compact-floor-selector-CUgAJzTC.cjs} +2 -2
- package/dist/cjs/{consume-DRj4CYCX.cjs → consume-DvEpk7ME.cjs} +2 -2
- package/dist/cjs/custom-map-BT2xrMK_.cjs +97 -0
- package/dist/cjs/{floor-selector-CDmDuSiD.cjs → floor-selector-_ZGeTisd.cjs} +2 -2
- package/dist/cjs/{lazy-load-Dn0YjnPb.cjs → lazy-load-C0UlvHkw.cjs} +2 -2
- package/dist/cjs/map-view-with-modal.cjs +6 -6
- package/dist/cjs/{qr-modal-DViSVtZI.cjs → qr-modal-dwEr6sDk.cjs} +2 -2
- package/dist/cjs/{route-options-CyEO6vv_.cjs → route-options-5hZvnUEf.cjs} +2 -2
- package/dist/cjs/route-view-totems.cjs +3 -3
- package/dist/es/assets/{compact-floor-selector-CoQYAD6z.js → compact-floor-selector-oq3Ovsm1.js} +3 -3
- package/dist/es/assets/{components-BQGHQSdV.js → components-BT9NDTry.js} +53 -14
- package/dist/es/assets/{map-view-with-modal-SkmapEWH.js → map-view-with-modal-DiR8q30Q.js} +46 -4
- package/dist/es/assets/{route-view-totems-eQTxU-id.js → route-view-totems-CdM6PRGO.js} +57 -9
- package/dist/es/assets/{utils-CWtvoL4a.js → utils-DM-AJZn2.js} +136 -28
- package/dist/es/index.js +2 -2
- package/dist/es/route-view-totems.js +2 -2
- package/dist/iife/map-view-with-modal.js +2 -2
- package/dist/iife/route-view-totems.js +4 -4
- package/dist/sw/mvx-tiles-sw.js +63 -0
- package/package.json +3 -2
- package/dist/cjs/custom-map-DDdkf9Am.cjs +0 -97
- package/dist/components/custom-map.d.ts +0 -13
- package/dist/components/custom-map.js +0 -64
- package/dist/components/floor-selector.d.ts +0 -6
- package/dist/components/floor-selector.js +0 -40
- package/dist/components/qr-modal.d.ts +0 -7
- package/dist/components/qr-modal.js +0 -69
- package/dist/components/route-options.d.ts +0 -6
- package/dist/components/route-options.js +0 -51
- package/dist/components/zoom-controls.d.ts +0 -6
- package/dist/components/zoom-controls.js +0 -40
- package/dist/route-view-totems.d.ts +0 -16
- package/dist/route-view-totems.js +0 -58
- package/dist/utils/styles.d.ts +0 -2
- package/dist/utils/styles.js +0 -5
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MapVX Tiles Service Worker (Workbox)
|
|
3
|
+
- Cache-first for PBF tiles
|
|
4
|
+
- Stale-while-revalidate for other assets
|
|
5
|
+
- Restricted to lazarillo.app and mapvx.com (any subdomain)
|
|
6
|
+
|
|
7
|
+
How to use:
|
|
8
|
+
1) Copy this file to your site root as "/mvx-tiles-sw.js"
|
|
9
|
+
2) Ensure the site is served over HTTPS
|
|
10
|
+
3) Our Web Components will attempt to register it at load time
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* eslint-env serviceworker */
|
|
14
|
+
/* global workbox, importScripts */
|
|
15
|
+
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.4.1/workbox-sw.js');
|
|
16
|
+
|
|
17
|
+
const { registerRoute } = workbox.routing;
|
|
18
|
+
const { CacheFirst, StaleWhileRevalidate } = workbox.strategies;
|
|
19
|
+
const { CacheableResponsePlugin } = workbox.cacheableResponse;
|
|
20
|
+
const { ExpirationPlugin } = workbox.expiration;
|
|
21
|
+
|
|
22
|
+
// Preload modules as recommended by Workbox (avoid async imports inside handlers)
|
|
23
|
+
workbox.loadModule('workbox-routing');
|
|
24
|
+
workbox.loadModule('workbox-strategies');
|
|
25
|
+
workbox.loadModule('workbox-cacheable-response');
|
|
26
|
+
workbox.loadModule('workbox-expiration');
|
|
27
|
+
|
|
28
|
+
const ALLOWED_HOSTS = ['mapvx.com', 'lazarillo.app'];
|
|
29
|
+
const isAllowedHost = hostname => ALLOWED_HOSTS.some(host => hostname.endsWith(host));
|
|
30
|
+
|
|
31
|
+
// API cache for mapvx. Adjust the pattern if needed for additional endpoints
|
|
32
|
+
registerRoute(
|
|
33
|
+
({ url }) => url.hostname === 'api.mapvx.com',
|
|
34
|
+
new workbox.strategies.NetworkFirst({
|
|
35
|
+
cacheName: 'api-cache',
|
|
36
|
+
plugins: [
|
|
37
|
+
new workbox.cacheableResponse.CacheableResponsePlugin({
|
|
38
|
+
statuses: [0, 200],
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// PBF tiles → CacheFirst
|
|
45
|
+
registerRoute(
|
|
46
|
+
({ url }) => isAllowedHost(url.hostname) && /\.pbf($|\?)/.test(url.pathname),
|
|
47
|
+
new CacheFirst({
|
|
48
|
+
cacheName: 'tiles-pbf',
|
|
49
|
+
plugins: [
|
|
50
|
+
new CacheableResponsePlugin({ statuses: [0, 200] }),
|
|
51
|
+
new ExpirationPlugin({ maxEntries: 10000, maxAgeSeconds: 60 * 60 * 24 }),
|
|
52
|
+
],
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Other assets → Stale-While-Revalidate
|
|
57
|
+
registerRoute(
|
|
58
|
+
({ url }) => isAllowedHost(url.hostname) && !/\.pbf($|\?)/.test(url.pathname),
|
|
59
|
+
new StaleWhileRevalidate({
|
|
60
|
+
cacheName: 'map-assets',
|
|
61
|
+
plugins: [new CacheableResponsePlugin({ statuses: [0, 200] })],
|
|
62
|
+
})
|
|
63
|
+
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapvx/web-components",
|
|
3
3
|
"description": "MapVX Web Components is a web components library that provides interactive and accessible mapping solutions. Built with Lit, it offers a modern, lightweight, and framework-agnostic way to integrate maps into any web application.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.27",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Mapvx",
|
|
7
7
|
"homepage": "https://mapvx.com",
|
|
@@ -37,10 +37,11 @@
|
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"dev": "vite --force",
|
|
40
|
-
"build": "npm run build:es && npm run build:cjs && npm run build:iife",
|
|
40
|
+
"build": "npm run build:es && npm run build:cjs && npm run build:iife && npm run build:copy-sw",
|
|
41
41
|
"build:es": "BUILD_FORMAT=es vite build",
|
|
42
42
|
"build:cjs": "BUILD_FORMAT=cjs vite build",
|
|
43
43
|
"build:iife": "BUILD_FORMAT=iife-route-view-totems vite build && BUILD_FORMAT=iife-map-view-with-modal vite build",
|
|
44
|
+
"build:copy-sw": "mkdir -p dist/sw && cp src/sw/mvx-tiles-sw.js dist/sw/mvx-tiles-sw.js",
|
|
44
45
|
"preview": "vite preview",
|
|
45
46
|
"lint": "eslint . --ext .ts",
|
|
46
47
|
"lint:fix": "eslint . --ext .ts --fix",
|