map-gl-offline 0.5.2 → 0.5.5

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 (55) hide show
  1. package/README.md +58 -80
  2. package/dist/index.esm.js +4513 -11254
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +4517 -11258
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.umd.js +4516 -11262
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/managers/offlineMapManager/analyticsManagement.d.ts +1 -1
  9. package/dist/managers/offlineMapManager/base.d.ts +5 -5
  10. package/dist/managers/offlineMapManager/cleanupManagement.d.ts +1 -1
  11. package/dist/managers/offlineMapManager/importExportManagement.d.ts +1 -1
  12. package/dist/managers/offlineMapManager/maintenanceManagement.d.ts +2 -2
  13. package/dist/managers/offlineMapManager/regionManagement.d.ts +1 -1
  14. package/dist/managers/offlineMapManager/resourceManagement.d.ts +1 -1
  15. package/dist/managers/offlineMapManager/styleManagement.d.ts +1 -1
  16. package/dist/services/analyticsService.d.ts +1 -1
  17. package/dist/services/cleanupService.d.ts +1 -1
  18. package/dist/services/fontService.d.ts +1 -1
  19. package/dist/services/glyphService.d.ts +1 -3
  20. package/dist/services/importExportService.d.ts +3 -3
  21. package/dist/services/maintenanceService.d.ts +2 -2
  22. package/dist/services/regionService.d.ts +1 -1
  23. package/dist/services/resourceService.d.ts +2 -2
  24. package/dist/services/spriteService.d.ts +1 -3
  25. package/dist/services/styleService.d.ts +2 -2
  26. package/dist/services/tileService.d.ts +1 -1
  27. package/dist/storage/indexedDbManager.d.ts +1 -1
  28. package/dist/style.css +1 -1
  29. package/dist/types/maintenance.d.ts +1 -1
  30. package/dist/types/region.d.ts +28 -0
  31. package/dist/ui/components/PanelActions.d.ts +1 -1
  32. package/dist/ui/components/PanelHeader.d.ts +1 -1
  33. package/dist/ui/components/RegionList.d.ts +1 -1
  34. package/dist/ui/components/shared/LanguageSelector.d.ts +1 -1
  35. package/dist/ui/components/shared/MapControlButton.d.ts +1 -1
  36. package/dist/ui/components/shared/PanelContent.d.ts +3 -3
  37. package/dist/ui/components/shared/RegionDrawingTool.d.ts +2 -2
  38. package/dist/ui/controls/polygonControl.d.ts +1 -1
  39. package/dist/ui/controls/regionControl.d.ts +14 -3
  40. package/dist/ui/managers/ControlButtonManager.d.ts +1 -1
  41. package/dist/ui/managers/PanelManager.d.ts +3 -3
  42. package/dist/ui/managers/downloadManager.d.ts +2 -2
  43. package/dist/ui/modals/importExportModal.d.ts +1 -1
  44. package/dist/ui/modals/regionDetailsModal.d.ts +1 -1
  45. package/dist/ui/modals/regionFormModal.d.ts +30 -0
  46. package/dist/ui/offlineManagerControl.d.ts +1 -1
  47. package/dist/ui/translations/ar.d.ts +8 -0
  48. package/dist/ui/translations/en.d.ts +8 -0
  49. package/dist/utils/convertStyleForSW.d.ts +1 -1
  50. package/dist/utils/download.d.ts +1 -1
  51. package/dist/utils/importResolver.d.ts +1 -1
  52. package/dist/utils/styleProviderUtils.d.ts +1 -1
  53. package/dist/utils/styleUtils.d.ts +1 -1
  54. package/dist/utils/validation.d.ts +1 -1
  55. package/package.json +13 -15
package/README.md CHANGED
@@ -20,6 +20,7 @@ A comprehensive **TypeScript** library for **MapLibre GL JS** and **Mapbox GL JS
20
20
 
21
21
  - 🗺️ **Complete Offline Maps**: Download and store entire map regions with polygon-based selection
22
22
  - 🎯 **Smart Tile Management**: Efficient vector/raster tile downloading, caching, and retrieval with zoom-level optimization
23
+ - 🧩 **Extra Tile Sources**: Save additional vector (MVT/PBF) and raster tile layers alongside the style's own sources
23
24
  - 🔤 **Font & Glyph Support**: Comprehensive font and glyph management with Unicode range support
24
25
  - 🎨 **Sprite Management**: Handle map sprites and icons offline with multi-resolution support (@1x, @2x)
25
26
  - 📊 **Real-time Analytics**: Detailed storage analytics, performance metrics, and optimization recommendations
@@ -171,7 +172,8 @@ map.on('load', () => {
171
172
  theme: 'dark',
172
173
  showBbox: true,
173
174
  accessToken: mapboxgl.accessToken,
174
- mapLib: mapboxgl, // Mapbox GL lacks addProtocol, so the library auto-registers a Service Worker
175
+ // No mapLib needed - Mapbox GL JS v3 lacks addProtocol,
176
+ // so the library auto-registers a Service Worker fallback
175
177
  });
176
178
  map.addControl(control, 'top-right');
177
179
  });
@@ -346,9 +348,45 @@ interface OfflineRegionOptions {
346
348
  deleteOnExpiry?: boolean; // Auto-delete on expiration
347
349
  multipleRegions?: boolean; // Part of a multi-region download
348
350
  tileExtension?: string; // Tile extension (pbf, mvt, png, etc.)
351
+ extraSources?: ExtraSource[]; // Additional tile sources to download alongside the style
349
352
  }
353
+
354
+ interface ExtraSource {
355
+ id: string; // Unique source identifier
356
+ type?: 'vector' | 'raster' | 'raster-dem'; // Defaults to 'vector'
357
+ tiles: string[]; // Tile URL templates with {z}/{x}/{y}
358
+ minzoom?: number;
359
+ maxzoom?: number;
360
+ attribution?: string;
361
+ }
362
+ ```
363
+
364
+ ### Extra Tile Sources
365
+
366
+ Save additional vector or raster layers (e.g. custom overlays) alongside the style's own sources:
367
+
368
+ ```typescript
369
+ await manager.addRegion({
370
+ id: 'downtown',
371
+ name: 'Downtown',
372
+ bounds: [[-74.05, 40.71], [-74.00, 40.76]],
373
+ minZoom: 10,
374
+ maxZoom: 16,
375
+ styleUrl: 'https://example.com/style.json',
376
+ extraSources: [
377
+ {
378
+ id: 'buildings',
379
+ type: 'vector',
380
+ tiles: ['https://tiles.example.com/buildings/{z}/{x}/{y}.pbf'],
381
+ minzoom: 13,
382
+ maxzoom: 16,
383
+ },
384
+ ],
385
+ });
350
386
  ```
351
387
 
388
+ When using the `OfflineManagerControl`, the region download form auto-discovers tile sources on the live map and shows them as checkboxes — users pick which extra layers to include.
389
+
352
390
  ## 🎯 Use Cases
353
391
 
354
392
  - 🏔️ **Outdoor & Recreation Apps**: Hiking, camping, and adventure apps with offline trail maps
@@ -406,60 +444,6 @@ try {
406
444
  }
407
445
  ```
408
446
 
409
- ### Storage Management
410
-
411
- ```typescript
412
- // Check available storage
413
- if ('storage' in navigator && 'estimate' in navigator.storage) {
414
- const { usage, quota } = await navigator.storage.estimate();
415
- console.log(`Used: ${usage} / ${quota} bytes`);
416
- }
417
-
418
- // Regular cleanup
419
- await manager.cleanupExpiredRegions();
420
-
421
- // Auto-cleanup on startup
422
- await manager.setupAutoCleanup({
423
- intervalHours: 24, // Daily
424
- maxAge: 30, // 30 days
425
- });
426
- ```
427
-
428
- ## 🔍 Troubleshooting
429
-
430
- ### Storage Quota Issues
431
-
432
- ```typescript
433
- // Check quota
434
- const { usage, quota } = await navigator.storage.estimate();
435
- if (usage / quota > 0.9) {
436
- await manager.cleanupExpiredRegions();
437
- }
438
-
439
- // Request persistent storage
440
- if (navigator.storage?.persist) {
441
- const isPersisted = await navigator.storage.persist();
442
- console.log(`Persistent storage: ${isPersisted}`);
443
- }
444
- ```
445
-
446
- ### Performance Issues
447
-
448
- ```typescript
449
- // Reduce concurrency for slower devices
450
- const lightOptions = {
451
- maxConcurrency: 2,
452
- batchSize: 10,
453
- timeout: 30000,
454
- };
455
-
456
- // Use smaller regions
457
- const smallerRegion = {
458
- minZoom: 11, // Start at higher zoom
459
- maxZoom: 15, // End at lower zoom
460
- };
461
- ```
462
-
463
447
  ## 🌐 Browser Compatibility
464
448
 
465
449
  | Browser | Version | Support |
@@ -479,7 +463,7 @@ const smallerRegion = {
479
463
 
480
464
  ## 🤝 Contributing
481
465
 
482
- Contributions are welcome! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
466
+ Contributions are welcome!
483
467
 
484
468
  ### Development Setup
485
469
 
@@ -489,21 +473,21 @@ git clone https://github.com/muimsd/map-gl-offline.git
489
473
  cd map-gl-offline
490
474
 
491
475
  # Install dependencies
492
- pnpm install
476
+ npm install
493
477
 
494
478
  # Run development server
495
- pnpm dev
479
+ npm run dev
496
480
 
497
481
  # Run tests
498
- pnpm test
482
+ npm test
499
483
 
500
484
  # Build library
501
- pnpm build
485
+ npm run build
502
486
 
503
- # Run example app
487
+ # Run MapLibre example app
504
488
  cd examples/maplibre
505
- pnpm install
506
- pnpm dev
489
+ npm install
490
+ npm run dev
507
491
  ```
508
492
 
509
493
  ### Project Structure
@@ -518,8 +502,11 @@ map-gl-offline/
518
502
  │ │ └── translations/ # i18n (English, Arabic)
519
503
  │ ├── utils/ # Utilities & helpers
520
504
  │ └── types/ # TypeScript definitions
505
+ ├── bin/ # CLI (map-gl-offline init) & Vite plugin
521
506
  ├── examples/
522
- └── maplibre/ # Live example app
507
+ ├── maplibre/ # MapLibre GL JS example app
508
+ │ └── mapbox-gl/ # Mapbox GL JS example app
509
+ ├── docs/ # Docusaurus documentation site
523
510
  └── tests/ # Test suites
524
511
  ```
525
512
 
@@ -534,26 +521,15 @@ map-gl-offline/
534
521
 
535
522
  ## 🔄 Recent Updates
536
523
 
537
- ### v0.5.0 (Latest)
524
+ See [CHANGELOG.md](CHANGELOG.md) for complete version history.
538
525
 
539
- - ✅ **Mapbox GL JS Support**: Full support for Mapbox styles, including `mapbox://` protocol URL resolution
540
- - ✅ **Mapbox Standard Style**: 3D models, raster-dem terrain, and import-based style resolution
541
- - ✅ **Day/Night Light Presets**: Toggle between day and night lighting for Mapbox Standard
542
- - ✅ **Rain & Snow Weather**: Weather effect controls for Mapbox Standard style
543
- - ✅ **Import Resolver**: Automatic resolution of Mapbox Standard `imports` in styles
544
- - ✅ **Internationalization**: English and Arabic language support with full RTL layout
545
- - ✅ **Auto-detection**: Automatically detects Mapbox vs MapLibre styles
526
+ **v0.5.5 (Latest):** Extra tile source selection for offline regions pick additional vector/raster layers to download alongside the style's own sources.
546
527
 
547
- ### v0.1.0
528
+ **v0.5.3:** 28% bundle size reduction (783 KB to 565 KB), 20+ bug fixes, XSS prevention, import atomicity, `@/` path alias for all imports.
548
529
 
549
- - **Fractional Zoom Fix**: Fixed tile loading at fractional zoom levels
550
- - ✅ **Modern UI**: Glassmorphic design with dark/light theme
551
- - ✅ **Polygon Drawing**: Interactive region selection tool
552
- - ✅ **Enhanced Analytics**: Comprehensive storage insights
553
- - ✅ **Performance**: Optimized downloads and memory usage
554
- - ✅ **TypeScript**: Full type safety throughout
530
+ **v0.5.2:** CLI command (`npx map-gl-offline init`), Vite plugin for Service Worker, Mapbox GL example app.
555
531
 
556
- See [CHANGELOG.md](CHANGELOG.md) for complete version history.
532
+ **v0.5.0:** Mapbox GL JS support, Standard style with 3D/terrain, day/night presets, rain/snow, i18n (English & Arabic with RTL).
557
533
 
558
534
  ## 🙏 Acknowledgments
559
535
 
@@ -575,4 +551,6 @@ MIT © [Muhammad Imran Siddique](https://github.com/muimsd)
575
551
 
576
552
  [📖 Documentation](https://map-gl-offline.netlify.app) • [🎮 Live Demo](https://map-gl-offline-demo.netlify.app) • [⭐ Star on GitHub](https://github.com/muimsd/map-gl-offline)
577
553
 
554
+ <a href="https://www.buymeacoffee.com/muimsd" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
555
+
578
556
  </div>