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
@@ -3,7 +3,7 @@
3
3
  * Refactored from ButtonManager to be more reusable
4
4
  */
5
5
  import { BaseComponent, ComponentConfig } from './BaseComponent';
6
- import type { CssPrefix } from '../../../utils/cssPrefix';
6
+ import type { CssPrefix } from '@/utils/cssPrefix';
7
7
  export interface ControlButtonConfig extends ComponentConfig {
8
8
  title?: string;
9
9
  icon?: string;
@@ -3,9 +3,9 @@
3
3
  * Refactored from PanelRenderer to be more focused and reusable
4
4
  */
5
5
  import { BaseComponent } from './BaseComponent';
6
- import { OfflineMapManager } from '../../../managers/offlineMapManager';
7
- import { DownloadManager } from '../../managers/downloadManager';
8
- import { ModalManager } from '../../modals/modalManager';
6
+ import { OfflineMapManager } from '@/managers/offlineMapManager';
7
+ import { DownloadManager } from '@/ui/managers/downloadManager';
8
+ import { ModalManager } from '@/ui/modals/modalManager';
9
9
  export interface ContentRendererConfig {
10
10
  offlineManager: OfflineMapManager;
11
11
  downloadManager: DownloadManager;
@@ -4,8 +4,8 @@
4
4
  */
5
5
  import { BaseComponent } from './BaseComponent';
6
6
  import type { Map as MaplibreMap } from 'maplibre-gl';
7
- import { DownloadManager } from '../../managers/downloadManager';
8
- import { ModalManager } from '../../modals/modalManager';
7
+ import { DownloadManager } from '@/ui/managers/downloadManager';
8
+ import { ModalManager } from '@/ui/modals/modalManager';
9
9
  export interface RegionDrawingConfig {
10
10
  map: MaplibreMap;
11
11
  downloadManager: DownloadManager;
@@ -3,7 +3,7 @@
3
3
  * Handles polygon drawing, area calculation, and map visualization
4
4
  */
5
5
  import type { Map as MaplibreMap } from 'maplibre-gl';
6
- import type { CssPrefix } from '../../utils/cssPrefix';
6
+ import type { CssPrefix } from '@/utils/cssPrefix';
7
7
  export interface PolygonControlOptions {
8
8
  onSave: (bounds: [number, number, number, number], area: number) => void;
9
9
  onCancel: () => void;
@@ -3,9 +3,9 @@
3
3
  * Manages region selection, form modal, and saves
4
4
  */
5
5
  import type { Map as MaplibreMap } from 'maplibre-gl';
6
- import { DownloadManager } from '../managers/downloadManager';
7
- import { ModalManager } from '../modals/modalManager';
8
- import type { CssPrefix } from '../../utils/cssPrefix';
6
+ import { DownloadManager } from '@/ui/managers/downloadManager';
7
+ import { ModalManager } from '@/ui/modals/modalManager';
8
+ import type { CssPrefix } from '@/utils/cssPrefix';
9
9
  export interface RegionControlOptions {
10
10
  map: MaplibreMap;
11
11
  downloadManager: DownloadManager;
@@ -48,6 +48,17 @@ export declare class RegionControl {
48
48
  * Handle save button click
49
49
  */
50
50
  private handleSaveClick;
51
+ /**
52
+ * Get the source IDs that belong to the current style URL.
53
+ * These are the sources the style already includes and will be downloaded automatically.
54
+ */
55
+ private getStyleSourceIds;
56
+ /**
57
+ * Extract tile sources from the live map instance that are NOT part of the current style.
58
+ * Returns vector, raster, and raster-dem sources that have tile URLs,
59
+ * excluding sources that already belong to the style (those are downloaded automatically).
60
+ */
61
+ private extractExtraMapSources;
51
62
  /**
52
63
  * Show region form modal
53
64
  */
@@ -3,7 +3,7 @@
3
3
  * Manages the main control button and progress badge states
4
4
  * Refactored to use modular Button component
5
5
  */
6
- import type { CssPrefix } from '../../utils/cssPrefix';
6
+ import type { CssPrefix } from '@/utils/cssPrefix';
7
7
  export interface ButtonManagerOptions {
8
8
  onTogglePanel: () => void;
9
9
  cssPrefix?: CssPrefix;
@@ -3,10 +3,10 @@
3
3
  * Handles rendering of the main offline manager panel
4
4
  * Refactored to use modular components
5
5
  */
6
- import { OfflineMapManager } from '../../managers/offlineMapManager';
6
+ import { OfflineMapManager } from '@/managers/offlineMapManager';
7
7
  import { DownloadManager } from './downloadManager';
8
- import { ModalManager } from '../modals/modalManager';
9
- import { BaseComponent } from '../components/shared/BaseComponent';
8
+ import { ModalManager } from '@/ui/modals/modalManager';
9
+ import { BaseComponent } from '@/ui/components/shared/BaseComponent';
10
10
  type MaplibreMap = unknown;
11
11
  export interface PanelRendererOptions {
12
12
  offlineManager: OfflineMapManager;
@@ -43,8 +43,8 @@
43
43
  *
44
44
  * @module downloadManager
45
45
  */
46
- import { OfflineMapManager } from '../../managers/offlineMapManager';
47
- import { RegionFormData } from '../modals/regionFormModal';
46
+ import { OfflineMapManager } from '@/managers/offlineMapManager';
47
+ import { RegionFormData } from '@/ui/modals/regionFormModal';
48
48
  /**
49
49
  * Progress information for an active download.
50
50
  *
@@ -3,7 +3,7 @@
3
3
  * Handles import/export operations for regions
4
4
  * Refactored to use modular Modal component for consistency
5
5
  */
6
- import type { StoredRegion, ImportExportOptions, ExportResult, ImportResult, RegionImportData } from '../../types';
6
+ import type { StoredRegion, ImportExportOptions, ExportResult, ImportResult, RegionImportData } from '@/types';
7
7
  export interface ImportExportModalOptions {
8
8
  region: StoredRegion;
9
9
  onClose: () => void;
@@ -3,7 +3,7 @@
3
3
  * Shows detailed information about a specific region
4
4
  * Refactored to use modular components
5
5
  */
6
- import { StoredRegion } from '../../types/region';
6
+ import { StoredRegion } from '@/types/region';
7
7
  export interface RegionDetailsOptions {
8
8
  region: StoredRegion;
9
9
  onClose: () => void;
@@ -11,6 +11,25 @@ export interface RegionFormData {
11
11
  bounds: [number, number, number, number];
12
12
  provider?: 'mapbox' | 'maplibre' | 'auto';
13
13
  accessToken?: string;
14
+ /** Additional tile sources to download alongside the style's own sources */
15
+ extraSources?: import('@/types/region').ExtraSource[];
16
+ }
17
+ /**
18
+ * A tile source discovered on the live map, presented to the user for selection.
19
+ */
20
+ export interface MapTileSource {
21
+ /** Source ID as it appears in the style */
22
+ id: string;
23
+ /** Source type */
24
+ type: 'vector' | 'raster' | 'raster-dem';
25
+ /** Tile URL templates */
26
+ tiles: string[];
27
+ /** Min zoom level */
28
+ minzoom?: number;
29
+ /** Max zoom level */
30
+ maxzoom?: number;
31
+ /** Attribution */
32
+ attribution?: string;
14
33
  }
15
34
  export interface RegionFormOptions {
16
35
  bounds: [number, number, number, number];
@@ -20,6 +39,8 @@ export interface RegionFormOptions {
20
39
  onThemeToggle?: () => void;
21
40
  styleUrl: string;
22
41
  accessToken?: string;
42
+ /** Tile sources discovered from the live map for user selection */
43
+ mapSources?: MapTileSource[];
23
44
  }
24
45
  export declare class RegionFormModal {
25
46
  private options;
@@ -31,6 +52,7 @@ export declare class RegionFormModal {
31
52
  private providerSelect?;
32
53
  private accessTokenInput?;
33
54
  private accessTokenGroup?;
55
+ private sourceCheckboxes;
34
56
  constructor(options: RegionFormOptions);
35
57
  /**
36
58
  * Show the region form modal
@@ -40,6 +62,14 @@ export declare class RegionFormModal {
40
62
  * Create the form content
41
63
  */
42
64
  private createForm;
65
+ /**
66
+ * Create the extra sources picker section
67
+ */
68
+ private createSourcesPicker;
69
+ /**
70
+ * Get the selected extra sources from the picker
71
+ */
72
+ private getSelectedExtraSources;
43
73
  /**
44
74
  * Handle style URL changes to auto-detect provider
45
75
  */
@@ -35,7 +35,7 @@
35
35
  * @module offlineManagerControl
36
36
  */
37
37
  import type { IControl, Map as MaplibreMap } from 'maplibre-gl';
38
- import { OfflineMapManager } from '../managers/offlineMapManager';
38
+ import { OfflineMapManager } from '@/managers/offlineMapManager';
39
39
  /**
40
40
  * Interface for map libraries that support custom protocol handlers.
41
41
  * MapLibre GL JS provides `addProtocol`/`removeProtocol`; Mapbox GL JS v3 does not.
@@ -50,6 +50,14 @@ export declare const ar: {
50
50
  readonly 'regionForm.downloadRegion': "تحميل المنطقة";
51
51
  readonly 'regionForm.area': "المساحة";
52
52
  readonly 'regionForm.bounds': "الحدود";
53
+ readonly 'regionForm.extraSources': "مصادر بلاطات إضافية";
54
+ readonly 'regionForm.extraSourcesInfo': "اختر طبقات إضافية من الخريطة لتضمينها في هذه المنطقة";
55
+ readonly 'regionForm.noExtraSources': "لم يتم العثور على مصادر بلاطات إضافية على الخريطة";
56
+ readonly 'regionForm.sourceType.vector': "متجه";
57
+ readonly 'regionForm.sourceType.raster': "نقطي";
58
+ readonly 'regionForm.sourceType.raster-dem': "تضاريس";
59
+ readonly 'regionForm.selectAll': "تحديد الكل";
60
+ readonly 'regionForm.deselectAll': "إلغاء تحديد الكل";
53
61
  readonly 'regionList.empty': "لم يتم العثور على أنماط أو مناطق غير متصلة. انقر على \"إضافة منطقة\" للبدء.";
54
62
  readonly 'regionList.emptyFallback': "لم يتم العثور على مناطق غير متصلة. انقر على \"إضافة منطقة\" للبدء.";
55
63
  readonly 'regionList.orphanedHeader': "مناطق بدون نمط";
@@ -49,6 +49,14 @@ export declare const en: {
49
49
  readonly 'regionForm.downloadRegion': "Download Region";
50
50
  readonly 'regionForm.area': "Area";
51
51
  readonly 'regionForm.bounds': "Bounds";
52
+ readonly 'regionForm.extraSources': "Additional Tile Sources";
53
+ readonly 'regionForm.extraSourcesInfo': "Select extra layers from the map to include in this offline region";
54
+ readonly 'regionForm.noExtraSources': "No additional tile sources found on the map";
55
+ readonly 'regionForm.sourceType.vector': "Vector";
56
+ readonly 'regionForm.sourceType.raster': "Raster";
57
+ readonly 'regionForm.sourceType.raster-dem': "Terrain";
58
+ readonly 'regionForm.selectAll': "Select All";
59
+ readonly 'regionForm.deselectAll': "Deselect All";
52
60
  readonly 'regionList.empty': "No offline styles or regions found. Click \"Add Region\" to get started.";
53
61
  readonly 'regionList.emptyFallback': "No offline regions found. Click \"Add Region\" to get started.";
54
62
  readonly 'regionList.orphanedHeader': "Regions without Style";
@@ -1,4 +1,4 @@
1
- import type { MapboxStyle } from '../types/style';
1
+ import type { MapboxStyle } from '@/types/style';
2
2
  /**
3
3
  * Convert a style with `idb://` URLs to use absolute `/__offline__/` HTTP URLs
4
4
  * so that a Service Worker can intercept the requests from web workers.
@@ -1,4 +1,4 @@
1
- import type { DownloadProgress } from '../types';
1
+ import type { DownloadProgress } from '@/types';
2
2
  import { type ProxyType } from './proxyConfig';
3
3
  export type FetchResourceResult = {
4
4
  type: 'json';
@@ -6,7 +6,7 @@
6
6
  * into the outer style. This allows the existing download pipeline to work
7
7
  * unchanged with import-based styles like Mapbox Standard.
8
8
  */
9
- import type { BaseStyle } from '../types/style';
9
+ import type { BaseStyle } from '@/types/style';
10
10
  /** A single import entry in a style's `imports` array */
11
11
  export interface StyleImport {
12
12
  id: string;
@@ -2,7 +2,7 @@
2
2
  * Style Provider Detection and Handling Utilities
3
3
  * Supports both Mapbox GL and MapLibre GL styles
4
4
  */
5
- import type { BaseStyle, StyleProvider } from '../types/style';
5
+ import type { BaseStyle, StyleProvider } from '@/types/style';
6
6
  /**
7
7
  * Check if a URL uses the mapbox:// protocol
8
8
  */
@@ -1,4 +1,4 @@
1
- import type { MapboxStyle } from '../types/style';
1
+ import type { MapboxStyle } from '@/types/style';
2
2
  /**
3
3
  * Patches a MapboxStyle for offline use by replacing URLs with IndexedDB references
4
4
  * @param style - The style to patch
@@ -2,7 +2,7 @@
2
2
  * Validation utilities for common patterns
3
3
  * Provides reusable validation functions to ensure data integrity
4
4
  */
5
- import type { OfflineRegionOptions } from '../types';
5
+ import type { OfflineRegionOptions } from '@/types';
6
6
  /**
7
7
  * Validate geographic bounds
8
8
  * @param bounds - Array of two [lng, lat] coordinate pairs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "map-gl-offline",
3
- "version": "0.5.2",
3
+ "version": "0.5.5",
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",
@@ -52,9 +52,9 @@
52
52
  "test:watch": "jest --watch",
53
53
  "test:coverage": "jest --coverage",
54
54
  "test:ci": "jest --ci --coverage --watchAll=false --testPathIgnorePatterns='tests/e2e'",
55
- "lint": "eslint src --ext .ts,.tsx --ignore-pattern 'src/main.ts'",
56
- "lint:fix": "eslint src --ext .ts,.tsx --ignore-pattern 'src/main.ts' --fix",
57
- "lint:warn": "eslint src --ext .ts,.tsx --ignore-pattern 'src/main.ts' --max-warnings 200",
55
+ "lint": "eslint src",
56
+ "lint:fix": "eslint src --fix",
57
+ "lint:warn": "eslint src --max-warnings 200",
58
58
  "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
59
59
  "format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
60
60
  "typecheck": "tsc --noEmit",
@@ -102,8 +102,10 @@
102
102
  "type": "module",
103
103
  "dependencies": {
104
104
  "@mapbox/tilebelt": "^2.0.3",
105
- "@tabler/icons": "^3.36.1",
106
- "@turf/turf": "^7.3.4",
105
+ "@turf/area": "^7.3.4",
106
+ "@turf/bbox-polygon": "^7.3.4",
107
+ "@turf/difference": "^7.3.4",
108
+ "@turf/helpers": "^7.3.4",
107
109
  "i18next": "^25.8.11",
108
110
  "idb": "^8.0.3"
109
111
  },
@@ -121,7 +123,7 @@
121
123
  },
122
124
  "devDependencies": {
123
125
  "@babel/preset-env": "^7.29.0",
124
- "@eslint/js": "^9.28.0",
126
+ "@eslint/js": "^10.0.1",
125
127
  "@rollup/plugin-commonjs": "^29.0.0",
126
128
  "@rollup/plugin-node-resolve": "^16.0.3",
127
129
  "@rollup/plugin-typescript": "^12.3.0",
@@ -132,12 +134,8 @@
132
134
  "@types/mapbox-gl": "^3.4.1",
133
135
  "@types/maplibre-gl": "^1.14.0",
134
136
  "@types/node": "^25.3.0",
135
- "@typescript-eslint/eslint-plugin": "^8.33.1",
136
- "@typescript-eslint/parser": "^8.33.1",
137
137
  "autoprefixer": "^10.4.24",
138
- "eslint": "^9.22.0",
139
- "eslint-config-prettier": "^10.1.8",
140
- "eslint-plugin-prettier": "^5.5.5",
138
+ "eslint": "^10.0.0",
141
139
  "fake-indexeddb": "^6.2.5",
142
140
  "husky": "^9.1.7",
143
141
  "jest": "^30.2.0",
@@ -148,7 +146,7 @@
148
146
  "prettier": "^3.8.1",
149
147
  "puppeteer": "^24.37.4",
150
148
  "rimraf": "^6.1.3",
151
- "rollup": "^4.57.1",
149
+ "rollup": "^4.60.0",
152
150
  "rollup-plugin-dts": "^6.3.0",
153
151
  "tailwindcss": "^4.2.0",
154
152
  "ts-jest": "^29.4.6",
@@ -157,8 +155,8 @@
157
155
  "tslib": "^2.8.1",
158
156
  "tsx": "^4.21.0",
159
157
  "typescript": "^5.9.3",
160
- "typescript-eslint": "^8.33.1",
161
- "vite": "^7.3.1",
158
+ "typescript-eslint": "^8.56.0",
159
+ "vite": "^7.3.2",
162
160
  "vite-tsconfig-paths": "^6.1.1"
163
161
  }
164
162
  }