map-gl-offline 0.8.3 → 0.8.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.
@@ -22,7 +22,7 @@ export interface DownloadRegionProgress {
22
22
  * Options for the programmatic `downloadRegion` pipeline.
23
23
  */
24
24
  export interface DownloadRegionOptions {
25
- /** Called with per-phase progress during style → sprites → glyphs → tiles → metadata. */
25
+ /** Called with per-phase progress during style → sprites → glyphs → models → tiles → metadata. */
26
26
  onProgress?: (progress: DownloadRegionProgress) => void;
27
27
  /** Style provider hint when the style needs to be fetched. Defaults to 'auto'. */
28
28
  provider?: StyleProvider;
@@ -2,14 +2,15 @@
2
2
  * Download Manager for offline map regions.
3
3
  *
4
4
  * This module handles the complete download workflow for offline map regions,
5
- * including styles, sprites, glyphs (fonts), and map tiles. It provides
5
+ * including styles, sprites, glyphs (fonts), 3D models, and map tiles. It provides
6
6
  * progress tracking across all download phases.
7
7
  *
8
8
  * **Download Phases:**
9
9
  * 1. `style` - Downloads the map style JSON and processes sources
10
10
  * 2. `sprites` - Downloads sprite images and JSON for map icons
11
11
  * 3. `glyphs` - Downloads font glyphs for text rendering
12
- * 4. `tiles` - Downloads map tiles for the specified region bounds
12
+ * 4. `models` - Downloads 3D model assets (Mapbox Standard trees / turbines)
13
+ * 5. `tiles` - Downloads map tiles for the specified region bounds
13
14
  *
14
15
  * **Usage:**
15
16
  * The DownloadManager is typically instantiated by the OfflineManagerControl
@@ -12,7 +12,7 @@
12
12
  * - Integrates seamlessly as a MapLibre GL control
13
13
  * - Intercepts fetch requests to serve offline resources from IndexedDB
14
14
  * - Supports light and dark themes
15
- * - Shows download progress across all phases (style, sprites, glyphs, tiles)
15
+ * - Shows download progress across all phases (style, sprites, glyphs, models, tiles)
16
16
  * - Optional bounding box visualization for regions
17
17
  *
18
18
  * @example
@@ -34,7 +34,7 @@
34
34
  *
35
35
  * @module offlineManagerControl
36
36
  */
37
- import type { IControl, Map as MaplibreMap } from 'maplibre-gl';
37
+ import type { IControl } from 'maplibre-gl';
38
38
  import { OfflineMapManager } from '@/managers/offlineMapManager';
39
39
  /**
40
40
  * Request shape MapLibre passes to a protocol handler. `type` indicates how
@@ -63,6 +63,17 @@ export interface MapLibProtocol {
63
63
  addProtocol: (protocol: string, handler: (params: MapLibProtocolRequest) => Promise<MapLibProtocolResponse>) => void;
64
64
  removeProtocol: (protocol: string) => void;
65
65
  }
66
+ /**
67
+ * Minimal structural type for the host map `OfflineManagerControl` is added to.
68
+ *
69
+ * The control works with both MapLibre GL JS and Mapbox GL JS. Typing the
70
+ * `onAdd` parameter structurally — rather than as a specific renderer's `Map`
71
+ * — lets the control satisfy *either* library's `IControl`, so it can be added
72
+ * via `map.addControl()` on either renderer without a cast. See issue #39.
73
+ */
74
+ export interface ControlMap {
75
+ getContainer(): HTMLElement;
76
+ }
66
77
  /**
67
78
  * Configuration options for the OfflineManagerControl.
68
79
  *
@@ -94,7 +105,7 @@ export interface OfflineManagerControlOptions {
94
105
  /**
95
106
  * MapLibre GL JS control for managing offline map regions.
96
107
  *
97
- * Implements the IControl interface to integrate with MapLibre GL maps.
108
+ * Implements the IControl interface to integrate with MapLibre GL and Mapbox GL maps.
98
109
  * Provides a complete UI for downloading, managing, and loading offline map data.
99
110
  *
100
111
  * The control automatically intercepts fetch requests to serve offline resources
@@ -153,10 +164,10 @@ export declare class OfflineManagerControl implements IControl {
153
164
  * Called when the control is added to a map.
154
165
  * Implements the IControl.onAdd interface method.
155
166
  *
156
- * @param map - The MapLibre GL map instance
167
+ * @param map - The MapLibre GL or Mapbox GL map instance
157
168
  * @returns The control's container element
158
169
  */
159
- onAdd(map: MaplibreMap): HTMLElement;
170
+ onAdd(map: ControlMap): HTMLElement;
160
171
  /**
161
172
  * Called when the control is removed from a map.
162
173
  * Implements the IControl.onRemove interface method.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "map-gl-offline",
3
- "version": "0.8.3",
3
+ "version": "0.8.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",