map-gl-offline 0.8.2 → 0.8.4

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
@@ -36,6 +36,23 @@
36
36
  */
37
37
  import type { IControl, Map as MaplibreMap } from 'maplibre-gl';
38
38
  import { OfflineMapManager } from '@/managers/offlineMapManager';
39
+ /**
40
+ * Request shape MapLibre passes to a protocol handler. `type` indicates how
41
+ * the response will be consumed — `"json"` for sprite atlases / TileJSON,
42
+ * everything else binary (`"arrayBuffer"`, `"image"`, …).
43
+ */
44
+ export interface MapLibProtocolRequest {
45
+ url: string;
46
+ type?: string;
47
+ }
48
+ /**
49
+ * Response shape MapLibre expects from a promise-based protocol handler.
50
+ * `data` is binary (`ArrayBuffer`) for tiles/glyphs/sprites and a parsed
51
+ * JSON object for sprite atlas / TileJSON requests.
52
+ */
53
+ export interface MapLibProtocolResponse {
54
+ data: ArrayBuffer | Record<string, unknown>;
55
+ }
39
56
  /**
40
57
  * Interface for map libraries that support custom protocol handlers.
41
58
  * MapLibre GL JS provides `addProtocol`/`removeProtocol`; Mapbox GL JS v3 does not.
@@ -43,9 +60,7 @@ import { OfflineMapManager } from '@/managers/offlineMapManager';
43
60
  * `idb://` protocol for web-worker tile fetches.
44
61
  */
45
62
  export interface MapLibProtocol {
46
- addProtocol: (protocol: string, handler: (...args: any[]) => Promise<{
47
- data: ArrayBuffer;
48
- }>) => void;
63
+ addProtocol: (protocol: string, handler: (params: MapLibProtocolRequest) => Promise<MapLibProtocolResponse>) => void;
49
64
  removeProtocol: (protocol: string) => void;
50
65
  }
51
66
  /**
@@ -25,10 +25,12 @@ export declare const TILE_CONFIG: {
25
25
  readonly DEFAULT_EXTENSION: "pbf";
26
26
  readonly SUPPORTED_EXTENSIONS: readonly ["pbf", "mvt", "png", "jpg", "jpeg", "webp", "glb"];
27
27
  };
28
+ export declare const GLYPH_BLOCK_SIZE = 256;
29
+ export declare const MAX_GLYPH_CODEPOINT = 65535;
28
30
  export declare const GLYPH_CONFIG: {
29
31
  readonly DEFAULT_URL: "https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf";
30
32
  readonly DEFAULT_RANGES: readonly ["0-255"];
31
- readonly COMPREHENSIVE_RANGES: readonly ["0-255", "256-511", "512-767", "768-1023", "1024-1279", "1280-1535", "1536-1791", "1792-2047", "2048-2303", "2304-2559", "2560-2815", "2816-3071", "3072-3327", "3328-3583", "3584-3839", "3840-4095", "4096-4351", "4352-4607", "4608-4863", "7680-7935", "8192-8447", "8448-8703", "11904-12031", "12032-12255", "12288-12543", "12544-12799", "19968-20223", "20224-20479", "40960-42127", "44032-55203", "63744-64255", "64256-64511", "65024-65279", "65280-65535"];
33
+ readonly COMPREHENSIVE_RANGES: string[];
32
34
  };
33
35
  export declare const STYLE_CONFIG: {
34
36
  readonly OPENFREEMAP_BASE: "https://tiles.openfreemap.org/styles";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "map-gl-offline",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
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",
@@ -145,7 +145,7 @@
145
145
  "jest-environment-jsdom": "^30.2.0",
146
146
  "map-gl-style-switcher": "^0.9.2",
147
147
  "mapbox-gl": "^3.18.1",
148
- "postcss": "^8.5.6",
148
+ "postcss": "^8.5.10",
149
149
  "prettier": "^3.8.1",
150
150
  "puppeteer": "^24.37.4",
151
151
  "rimraf": "^6.1.3",