map-gl-offline 0.1.2 → 0.5.0

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 (51) hide show
  1. package/README.md +80 -22
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.esm.js +1833 -739
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +1850 -763
  6. package/dist/index.js.map +1 -1
  7. package/dist/main.d.ts +1 -0
  8. package/dist/services/cleanupService.d.ts +31 -0
  9. package/dist/services/maintenanceService.d.ts +1 -1
  10. package/dist/services/spriteService.d.ts +6 -0
  11. package/dist/services/tileService.d.ts +1 -0
  12. package/dist/style.css +2 -145
  13. package/dist/types/font.d.ts +2 -0
  14. package/dist/types/glyph.d.ts +7 -2
  15. package/dist/types/sprite.d.ts +4 -0
  16. package/dist/types/style.d.ts +17 -2
  17. package/dist/types/tile.d.ts +7 -5
  18. package/dist/ui/components/shared/BaseComponent.d.ts +1 -0
  19. package/dist/ui/components/shared/LanguageSelector.d.ts +1 -0
  20. package/dist/ui/components/shared/MapControlButton.d.ts +2 -0
  21. package/dist/ui/components/shared/Modal.d.ts +2 -0
  22. package/dist/ui/components/shared/RegionDrawingTool.d.ts +1 -0
  23. package/dist/ui/controls/polygonControl.d.ts +2 -0
  24. package/dist/ui/controls/regionControl.d.ts +3 -0
  25. package/dist/ui/managers/ControlButtonManager.d.ts +2 -0
  26. package/dist/ui/managers/PanelManager.d.ts +5 -0
  27. package/dist/ui/managers/downloadManager.d.ts +5 -0
  28. package/dist/ui/modals/regionFormModal.d.ts +1 -0
  29. package/dist/ui/offlineManagerControl.d.ts +26 -0
  30. package/dist/utils/constants.d.ts +21 -1
  31. package/dist/utils/convertStyleForSW.d.ts +13 -0
  32. package/dist/utils/cssPrefix.d.ts +16 -0
  33. package/dist/utils/download.d.ts +7 -4
  34. package/dist/utils/errorHandling.d.ts +2 -25
  35. package/dist/utils/formatting.d.ts +2 -14
  36. package/dist/utils/idbFetchHandler.d.ts +1 -6
  37. package/dist/utils/importResolver.d.ts +33 -0
  38. package/dist/utils/index.d.ts +4 -0
  39. package/dist/utils/proxyConfig.d.ts +0 -12
  40. package/dist/utils/styleProviderUtils.d.ts +28 -13
  41. package/dist/utils/styleUtils.d.ts +16 -13
  42. package/dist/utils/swRegistration.d.ts +17 -0
  43. package/dist/utils/validation.d.ts +0 -41
  44. package/package.json +29 -27
  45. package/dist/ui/components/shared/Dropdown.d.ts +0 -64
  46. package/dist/ui/components/shared/EmptyState.d.ts +0 -20
  47. package/dist/ui/components/shared/ErrorState.d.ts +0 -32
  48. package/dist/ui/components/shared/LoadingState.d.ts +0 -22
  49. package/dist/ui/components/shared/Toast.d.ts +0 -62
  50. package/dist/ui/components/shared/Tooltip.d.ts +0 -51
  51. package/dist/ui/utils/formValidation.d.ts +0 -167
package/README.md CHANGED
@@ -6,9 +6,7 @@
6
6
 
7
7
  **[Documentation](https://map-gl-offline.netlify.app)** | **[Live Demo](https://map-gl-offline-demo.netlify.app)**
8
8
 
9
- > **⚠️ Development Notice**: This package is currently under active development and is optimized for **MapLibre GL JS**. Mapbox GL JS support is planned for future releases.
10
-
11
- A comprehensive **TypeScript** library for **MapLibre GL JS** that enables complete offline map functionality with vector/raster tiles, styles, fonts, sprites, and glyphs stored in IndexedDB. Features include advanced analytics, intelligent cleanup, and a modern glassmorphic UI control.
9
+ A comprehensive **TypeScript** library for **MapLibre GL JS** and **Mapbox GL JS** that enables complete offline map functionality with vector/raster tiles, styles, fonts, sprites, and glyphs stored in IndexedDB. Features include Mapbox Standard style support, advanced analytics, intelligent cleanup, i18n (English & Arabic with RTL), and a modern glassmorphic UI control.
12
10
 
13
11
  ## 🎬 Demo
14
12
 
@@ -26,6 +24,14 @@ A comprehensive **TypeScript** library for **MapLibre GL JS** that enables compl
26
24
  - 🎨 **Sprite Management**: Handle map sprites and icons offline with multi-resolution support (@1x, @2x)
27
25
  - 📊 **Real-time Analytics**: Detailed storage analytics, performance metrics, and optimization recommendations
28
26
 
27
+ ### 🌐 Mapbox GL JS Support
28
+
29
+ - 🔗 **mapbox:// Protocol Resolution**: Automatic resolution of `mapbox://` style, source, sprite, and glyph URLs
30
+ - 🏙️ **Mapbox Standard Style**: Full support including 3D models, raster-dem terrain, and import-based style resolution
31
+ - 🌅 **Day/Night Light Presets**: Toggle between day and night lighting in Mapbox Standard style
32
+ - 🌧️ **Weather Controls**: Rain and snow effects for Mapbox Standard style
33
+ - 🔍 **Auto-detection**: Automatically detects whether a style is Mapbox or MapLibre and applies the correct handling
34
+
29
35
  ### 🎨 Modern UI Control
30
36
 
31
37
  - 🖼️ **Glassmorphic Design**: Beautiful modern interface with glassmorphism effects and smooth animations
@@ -34,6 +40,7 @@ A comprehensive **TypeScript** library for **MapLibre GL JS** that enables compl
34
40
  - 📊 **Live Progress**: Real-time download progress with detailed statistics
35
41
  - 🎯 **Region Management**: Easy-to-use interface for managing multiple offline regions
36
42
  - ⚡ **Responsive**: Mobile-friendly design that adapts to all screen sizes
43
+ - 🌍 **Internationalization**: English and Arabic language support with full RTL layout
37
44
 
38
45
  ### 🛠️ Technical Excellence
39
46
 
@@ -64,30 +71,67 @@ VITE_MAPTILER_API_KEY=your_api_key_here
64
71
 
65
72
  Get a free API key from [Maptiler](https://www.maptiler.com/).
66
73
 
74
+ For Mapbox styles, you will also need a Mapbox access token from [Mapbox](https://www.mapbox.com/).
75
+
67
76
  ## 🚀 Quick Start
68
77
 
69
- ### Basic Usage with UI Control
78
+ ### MapLibre GL JS
70
79
 
71
80
  ```typescript
72
81
  import maplibregl from 'maplibre-gl';
73
- import { OfflineManagerControl } from 'map-gl-offline';
82
+ import { OfflineMapManager, OfflineManagerControl } from 'map-gl-offline';
74
83
  import 'maplibre-gl/dist/maplibre-gl.css';
75
- import 'map-gl-offline/dist/style.css'; // Import UI styles
84
+ import 'map-gl-offline/dist/style.css';
85
+
86
+ const styleUrl = 'https://api.maptiler.com/maps/streets/style.json?key=YOUR_API_KEY';
76
87
 
77
- // Initialize map
78
88
  const map = new maplibregl.Map({
79
89
  container: 'map',
80
- style: 'https://api.maptiler.com/maps/streets/style.json?key=YOUR_API_KEY',
90
+ style: styleUrl,
91
+ center: [-74.006, 40.7128],
92
+ zoom: 12,
93
+ });
94
+
95
+ const offlineManager = new OfflineMapManager();
96
+
97
+ map.on('load', () => {
98
+ const control = new OfflineManagerControl(offlineManager, {
99
+ styleUrl,
100
+ theme: 'dark',
101
+ showBbox: true,
102
+ mapLib: maplibregl, // enables idb:// protocol in web workers
103
+ });
104
+ map.addControl(control, 'top-right');
105
+ });
106
+ ```
107
+
108
+ ### Mapbox GL JS
109
+
110
+ ```typescript
111
+ import mapboxgl from 'mapbox-gl';
112
+ import { OfflineMapManager, OfflineManagerControl } from 'map-gl-offline';
113
+ import 'mapbox-gl/dist/mapbox-gl.css';
114
+ import 'map-gl-offline/dist/style.css';
115
+
116
+ mapboxgl.accessToken = 'YOUR_MAPBOX_TOKEN';
117
+
118
+ const map = new mapboxgl.Map({
119
+ container: 'map',
120
+ style: 'mapbox://styles/mapbox/standard',
81
121
  center: [-74.006, 40.7128],
82
122
  zoom: 12,
83
123
  });
84
124
 
85
- // Add offline control to map
125
+ const offlineManager = new OfflineMapManager();
126
+
86
127
  map.on('load', () => {
87
- const offlineControl = new OfflineManagerControl({
88
- position: 'top-right',
128
+ const control = new OfflineManagerControl(offlineManager, {
129
+ styleUrl: 'mapbox://styles/mapbox/standard',
130
+ theme: 'dark',
131
+ showBbox: true,
132
+ accessToken: mapboxgl.accessToken,
89
133
  });
90
- map.addControl(offlineControl);
134
+ map.addControl(control, 'top-right');
91
135
  });
92
136
  ```
93
137
 
@@ -98,6 +142,7 @@ The UI control provides:
98
142
  - 🗂️ **Region management** (view, delete)
99
143
  - 🌓 **Theme toggle** (dark/light mode)
100
144
  - 📈 **Storage analytics**
145
+ - 🌍 **Language switcher** (English / Arabic with RTL)
101
146
 
102
147
  ### Programmatic Usage
103
148
 
@@ -210,14 +255,19 @@ const manager = new OfflineMapManager(options?: {
210
255
 
211
256
  ### OfflineManagerControl
212
257
 
213
- UI control for MapLibre GL with glassmorphic design.
258
+ UI control for MapLibre GL JS and Mapbox GL JS with glassmorphic design.
214
259
 
215
260
  **Constructor:**
216
261
 
217
262
  ```typescript
218
- const control = new OfflineManagerControl({
219
- position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
220
- theme?: 'light' | 'dark' | 'auto';
263
+ const offlineManager = new OfflineMapManager();
264
+
265
+ const control = new OfflineManagerControl(offlineManager, {
266
+ styleUrl: 'https://example.com/style.json', // Map style URL (required)
267
+ theme?: 'light' | 'dark', // UI theme (default: 'dark')
268
+ showBbox?: boolean, // Show region bounding boxes (default: false)
269
+ accessToken?: string, // Mapbox access token (for mapbox:// URLs)
270
+ mapLib?: MapLibProtocol, // Map library module (e.g. maplibregl) for idb:// protocol
221
271
  });
222
272
  ```
223
273
 
@@ -228,6 +278,7 @@ const control = new OfflineManagerControl({
228
278
  - Region management (view, delete)
229
279
  - Theme toggle (dark/light mode)
230
280
  - Storage analytics display
281
+ - Language switcher (English / Arabic with RTL support)
231
282
  - Responsive mobile-friendly design
232
283
 
233
284
  ## 🔧 Configuration Options
@@ -377,10 +428,6 @@ const smallerRegion = {
377
428
  - Async/await support
378
429
  - Web Workers (optional, for background tasks)
379
430
 
380
- ## 📄 License
381
-
382
- MIT © [Muhammad Imran Siddique](https://github.com/muimsd)
383
-
384
431
  ## 🤝 Contributing
385
432
 
386
433
  Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
@@ -419,6 +466,7 @@ map-gl-offline/
419
466
  │ ├── services/ # Tile, font, sprite services
420
467
  │ ├── storage/ # IndexedDB management
421
468
  │ ├── ui/ # UI components & controls
469
+ │ │ └── translations/ # i18n (English, Arabic)
422
470
  │ ├── utils/ # Utilities & helpers
423
471
  │ └── types/ # TypeScript definitions
424
472
  ├── examples/
@@ -437,7 +485,17 @@ map-gl-offline/
437
485
 
438
486
  ## 🔄 Recent Updates
439
487
 
440
- ### v0.1.0 (Latest)
488
+ ### v0.2.0 (Latest)
489
+
490
+ - ✅ **Mapbox GL JS Support**: Full support for Mapbox styles, including `mapbox://` protocol URL resolution
491
+ - ✅ **Mapbox Standard Style**: 3D models, raster-dem terrain, and import-based style resolution
492
+ - ✅ **Day/Night Light Presets**: Toggle between day and night lighting for Mapbox Standard
493
+ - ✅ **Rain & Snow Weather**: Weather effect controls for Mapbox Standard style
494
+ - ✅ **Import Resolver**: Automatic resolution of Mapbox Standard `imports` in styles
495
+ - ✅ **Internationalization**: English and Arabic language support with full RTL layout
496
+ - ✅ **Auto-detection**: Automatically detects Mapbox vs MapLibre styles
497
+
498
+ ### v0.1.0
441
499
 
442
500
  - ✅ **Fractional Zoom Fix**: Fixed tile loading at fractional zoom levels
443
501
  - ✅ **Modern UI**: Glassmorphic design with dark/light theme
@@ -451,9 +509,9 @@ See [CHANGELOG.md](CHANGELOG.md) for complete version history.
451
509
  ## 🙏 Acknowledgments
452
510
 
453
511
  - [MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js) - Open-source map rendering engine
512
+ - [Mapbox GL JS](https://github.com/mapbox/mapbox-gl-js) - Commercial map rendering engine
454
513
  - [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) - Browser storage API
455
514
  - [Tilebelt](https://github.com/mapbox/tilebelt) - Tile coordinate utilities
456
-
457
515
  - [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
458
516
 
459
517
  ## 📄 License
package/dist/index.d.ts CHANGED
@@ -55,5 +55,6 @@ export * from './types';
55
55
  export * from './utils';
56
56
  export { OfflineMapManager as default } from './managers/offlineMapManager';
57
57
  export { OfflineManagerControl } from './ui/offlineManagerControl';
58
+ export type { MapLibProtocol } from './ui/offlineManagerControl';
58
59
  export { i18n, t } from './ui/translations';
59
60
  export type { SupportedLanguage, TranslationKey } from './ui/translations';