map-gl-offline 0.6.0 → 0.8.2

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 (39) hide show
  1. package/README.md +3 -1
  2. package/dist/idb-offline-sw.js +313 -360
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.esm.js +1359 -1021
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.js +1373 -1020
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.umd.js +1373 -1020
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/managers/offlineMapManager/importExportManagement.d.ts +5 -3
  11. package/dist/managers/offlineMapManager/resourceManagement.d.ts +4 -0
  12. package/dist/services/fontService.d.ts +12 -2
  13. package/dist/services/glyphService.d.ts +11 -2
  14. package/dist/services/importExportService.d.ts +11 -26
  15. package/dist/services/modelService.d.ts +57 -0
  16. package/dist/services/resourceService.d.ts +11 -1
  17. package/dist/services/spriteService.d.ts +10 -3
  18. package/dist/style.css +1 -1
  19. package/dist/sw/offline-sw.d.ts +17 -0
  20. package/dist/sw/shared.d.ts +108 -0
  21. package/dist/types/database.d.ts +9 -0
  22. package/dist/types/import-export.d.ts +7 -28
  23. package/dist/types/index.d.ts +1 -0
  24. package/dist/types/model.d.ts +62 -0
  25. package/dist/types/region.d.ts +11 -1
  26. package/dist/types/style.d.ts +11 -2
  27. package/dist/ui/components/shared/PanelContent.d.ts +0 -1
  28. package/dist/ui/managers/PanelManager.d.ts +1 -1
  29. package/dist/ui/managers/downloadManager.d.ts +1 -1
  30. package/dist/ui/modals/{importExportModal.d.ts → mbtilesModal.d.ts} +18 -17
  31. package/dist/ui/translations/ar.d.ts +23 -37
  32. package/dist/ui/translations/en.d.ts +23 -37
  33. package/dist/utils/constants.d.ts +2 -1
  34. package/dist/utils/importResolver.d.ts +10 -0
  35. package/dist/utils/index.d.ts +1 -0
  36. package/dist/utils/sqlJsLoader.d.ts +17 -0
  37. package/dist/utils/styleProviderUtils.d.ts +16 -0
  38. package/dist/utils/tileKey.d.ts +13 -0
  39. package/package.json +7 -4
@@ -7,6 +7,22 @@ import type { BaseStyle, StyleProvider } from '@/types/style';
7
7
  * Check if a URL uses the mapbox:// protocol
8
8
  */
9
9
  export declare function isMapboxProtocol(url: string): boolean;
10
+ /**
11
+ * Parse a URL and return its hostname, or null if the URL is malformed.
12
+ * Accepts relative URLs when `base` is provided.
13
+ */
14
+ export declare function getUrlHostname(url: string, base?: string): string | null;
15
+ /**
16
+ * True if `url`'s hostname equals `host` or is a subdomain of `host`.
17
+ * Uses URL parsing (not substring matching) to avoid false positives like
18
+ * `https://evil.com/?x=mapbox.com` matching `mapbox.com`.
19
+ */
20
+ export declare function hostMatches(url: string, host: string, base?: string): boolean;
21
+ /**
22
+ * True for any host under the mapbox.com domain (including api.mapbox.com,
23
+ * *.tiles.mapbox.com, etc.). Used by provider detection.
24
+ */
25
+ export declare function isMapboxHost(url: string, base?: string): boolean;
10
26
  /**
11
27
  * Resolve a mapbox:// URL to its HTTPS API equivalent
12
28
  *
@@ -18,6 +18,19 @@ export declare function parseTileKey(key: string): {
18
18
  y: number;
19
19
  ext: string;
20
20
  } | null;
21
+ /**
22
+ * Extract the extension (the last dotted segment before `?`, `#`, or end) from
23
+ * a tile URL or tile URL template. Defaults to `"pbf"` when no extension can
24
+ * be parsed. For multi-extension URLs like Mapbox v4's `{y}.vector.pbf` this
25
+ * returns `"pbf"`, matching the key used when the tile is stored.
26
+ *
27
+ * Keeping extraction logic in one place ensures patchStyleForOffline (which
28
+ * rewrites tile URLs to `idb://` at load time) derives the same extension
29
+ * that tileService.extractExtension used at store time — otherwise the
30
+ * first-try lookup in idbFetchHandler misses and has to fall through its
31
+ * pbf/mvt/png/jpg/webp fallback loop.
32
+ */
33
+ export declare function extractTileExtensionFromUrl(url: string): string;
21
34
  /**
22
35
  * Derive tile extension from tile URL templates
23
36
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "map-gl-offline",
3
- "version": "0.6.0",
3
+ "version": "0.8.2",
4
4
  "description": "A TypeScript-compatible npm package for MapLibre GL JS that enables comprehensive offline storage and usage of vector/raster tiles, sprites, styles, fonts (glyphs), and entire map regions with advanced analytics, import/export capabilities, and intelligent cleanup.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -36,11 +36,12 @@
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "vite",
39
- "build": "npm run build:clean && npm run build:lib && npm run build:types && npm run build:css && npm run build:sw",
39
+ "build": "npm run build:clean && npm run build:sw-src && npm run build:lib && npm run build:types && npm run build:css && npm run build:sw",
40
40
  "build:clean": "rimraf dist",
41
41
  "build:lib": "rollup -c",
42
42
  "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
43
43
  "build:css": "tailwindcss -i src/styles/style.css -o dist/style.css --minify",
44
+ "build:sw-src": "node scripts/build-sw.mjs",
44
45
  "build:sw": "cp public/idb-offline-sw.js dist/idb-offline-sw.js && cp bin/vite-plugin.js dist/vite-plugin.js",
45
46
  "build:watch": "rollup -c -w",
46
47
  "build:dev": "npm run build:clean && npm run build:lib",
@@ -86,7 +87,6 @@
86
87
  "sprites",
87
88
  "fonts",
88
89
  "glyphs",
89
- "pmtiles",
90
90
  "mbtiles",
91
91
  "import",
92
92
  "export",
@@ -107,7 +107,8 @@
107
107
  "@turf/difference": "^7.3.4",
108
108
  "@turf/helpers": "^7.3.4",
109
109
  "i18next": "^25.8.11",
110
- "idb": "^8.0.3"
110
+ "idb": "^8.0.3",
111
+ "sql.js": "^1.14.1"
111
112
  },
112
113
  "peerDependencies": {
113
114
  "mapbox-gl": ">=2.0.0",
@@ -134,7 +135,9 @@
134
135
  "@types/mapbox-gl": "^3.4.1",
135
136
  "@types/maplibre-gl": "^1.14.0",
136
137
  "@types/node": "^25.3.0",
138
+ "@types/sql.js": "^1.4.11",
137
139
  "autoprefixer": "^10.4.24",
140
+ "esbuild": "^0.27.3",
138
141
  "eslint": "^10.0.0",
139
142
  "fake-indexeddb": "^6.2.5",
140
143
  "husky": "^9.1.7",