map-gl-offline 0.8.6 → 0.8.8
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.
- package/README.md +61 -0
- package/dist/index.esm.js +52 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -3
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +53 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/managers/offlineMapManager/styleManagement.d.ts +2 -2
- package/dist/services/styleService.d.ts +1 -1
- package/dist/services/tileService.d.ts +9 -0
- package/dist/types/region.d.ts +21 -3
- package/dist/types/style.d.ts +6 -2
- package/dist/types/tile.d.ts +14 -0
- package/dist/ui/controls/regionControl.d.ts +1 -1
- package/dist/ui/modals/regionFormModal.d.ts +2 -2
- package/dist/ui/offlineManagerControl.d.ts +5 -2
- package/dist/utils/constants.d.ts +13 -0
- package/package.json +1 -1
|
@@ -2,14 +2,14 @@ import type { EnhancedStyleStats, StyleDownloadOptions, StyleDownloadResult, Sty
|
|
|
2
2
|
export interface StyleManagement {
|
|
3
3
|
downloadStyle(styleUrl: string, options?: StyleDownloadOptions & {
|
|
4
4
|
provider?: StyleProvider;
|
|
5
|
-
accessToken?: string;
|
|
5
|
+
accessToken?: string | null;
|
|
6
6
|
forceProvider?: boolean;
|
|
7
7
|
}): Promise<StyleDownloadResult>;
|
|
8
8
|
loadStyleById(styleId: string): Promise<StyleEntry | null>;
|
|
9
9
|
listStyles(): Promise<StyleEntry[]>;
|
|
10
10
|
deleteStyle(styleId: string): Promise<void>;
|
|
11
11
|
getStyleStats(styleId: string): Promise<EnhancedStyleStats>;
|
|
12
|
-
downloadMapboxStyle(styleUrl: string, accessToken?: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
|
|
12
|
+
downloadMapboxStyle(styleUrl: string, accessToken?: string | null, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
|
|
13
13
|
downloadMapLibreStyle(styleUrl: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
|
|
14
14
|
downloadStyleWithAutoDetection(styleUrl: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
|
|
15
15
|
cleanupOldStyles(maxAgeDays?: number): Promise<number>;
|
|
@@ -32,6 +32,6 @@ export declare function isStyleDownloaded(styleId?: string, styleUrl?: string):
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function downloadStyleWithProvider(styleUrl: string, options?: StyleDownloadOptions & {
|
|
34
34
|
provider?: StyleProvider;
|
|
35
|
-
accessToken?: string;
|
|
35
|
+
accessToken?: string | null;
|
|
36
36
|
forceProvider?: boolean;
|
|
37
37
|
}): Promise<StyleDownloadResult>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { TileDownloadOptions, TileDownloadResult, TileStats, OfflineRegionOptions, MapboxStyle } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Match a tile-URL template against the known-sparse Mapbox Standard
|
|
4
|
+
* sub-tilesets. Catches:
|
|
5
|
+
* - `mapbox://<tileset>` — original style source URL.
|
|
6
|
+
* - `.../v4/<tileset>.json...` — resolved TileJSON URL produced when the
|
|
7
|
+
* library resolves a `mapbox://` source URL into an HTTPS one.
|
|
8
|
+
* - `.../v4/<tileset>/{z}/{x}/{y}...` — resolved tile-template URL.
|
|
9
|
+
*/
|
|
10
|
+
export declare function urlReferencesKnownSparseTileset(template: string): boolean;
|
|
2
11
|
/**
|
|
3
12
|
* Service for managing offline map tiles
|
|
4
13
|
* Handles downloading, storing, and retrieving map tiles from IndexedDB
|
package/dist/types/region.d.ts
CHANGED
|
@@ -26,8 +26,12 @@ export interface DownloadRegionOptions {
|
|
|
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;
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Mapbox access token; required when the style or sources use mapbox:// URLs.
|
|
31
|
+
* Accepts `null` to match Mapbox GL's `accessToken` type so callers can pass
|
|
32
|
+
* `mapboxgl.accessToken` directly without a cast; treated the same as omitted.
|
|
33
|
+
*/
|
|
34
|
+
accessToken?: string | null;
|
|
31
35
|
/** Skip glyph download entirely. Default: false. */
|
|
32
36
|
skipGlyphs?: boolean;
|
|
33
37
|
/** Skip sprite download entirely. Default: false. */
|
|
@@ -98,6 +102,20 @@ export interface ExtraSource {
|
|
|
98
102
|
/** Attribution string for this source */
|
|
99
103
|
attribution?: string;
|
|
100
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Geographic bounding box as `[[west, south], [east, north]]`.
|
|
107
|
+
*
|
|
108
|
+
* Exposed as a public tuple alias so callers can annotate `bounds` literals
|
|
109
|
+
* (or arrays of them) without TypeScript widening them to `number[][]`. Use
|
|
110
|
+
* this in your own types for cities/regions lists, e.g.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* const cities: Array<{ id: string; bounds: BoundingBox }> = [
|
|
114
|
+
* { id: 'nyc', bounds: [[-74.05, 40.68], [-73.90, 40.82]] },
|
|
115
|
+
* ];
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export type BoundingBox = [[number, number], [number, number]];
|
|
101
119
|
/**
|
|
102
120
|
* Configuration options for an offline region
|
|
103
121
|
*/
|
|
@@ -109,7 +127,7 @@ export interface OfflineRegionOptions {
|
|
|
109
127
|
/** Human-readable region name */
|
|
110
128
|
name: string;
|
|
111
129
|
/** Geographic bounds: [[west, south], [east, north]] */
|
|
112
|
-
bounds:
|
|
130
|
+
bounds: BoundingBox;
|
|
113
131
|
/** Whether this region is part of a multi-region download */
|
|
114
132
|
multipleRegions?: boolean;
|
|
115
133
|
/** URL to the map style JSON */
|
package/dist/types/style.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type StyleEntry = {
|
|
|
54
54
|
fonts: string[];
|
|
55
55
|
glyphs: string[];
|
|
56
56
|
sprites: string[];
|
|
57
|
-
accessToken?: string;
|
|
57
|
+
accessToken?: string | null;
|
|
58
58
|
originalUrl?: string;
|
|
59
59
|
originalSpriteUrl?: BaseStyle['sprite'];
|
|
60
60
|
originalGlyphsUrl?: string;
|
|
@@ -71,7 +71,11 @@ export interface StyleDownloadOptions {
|
|
|
71
71
|
enableSourceEmbedding?: boolean;
|
|
72
72
|
storageQuotaCheck?: boolean;
|
|
73
73
|
includeMetadata?: boolean;
|
|
74
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Mapbox access token. Accepts `null` to match `mapboxgl.accessToken`'s
|
|
76
|
+
* type so callers can pass it through without a cast; treated as omitted.
|
|
77
|
+
*/
|
|
78
|
+
accessToken?: string | null;
|
|
75
79
|
}
|
|
76
80
|
export interface StyleDownloadResult {
|
|
77
81
|
styleId: string;
|
package/dist/types/tile.d.ts
CHANGED
|
@@ -80,6 +80,20 @@ export interface TileDownloadOptions {
|
|
|
80
80
|
* (old behavior — noisier, but guaranteed-complete).
|
|
81
81
|
*/
|
|
82
82
|
probeSourcesBeforeDownload?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Pre-skip a small allowlist of Mapbox Standard sub-tilesets that are
|
|
85
|
+
* sparse-by-design across the whole planet — `mapbox.indoor-v3`,
|
|
86
|
+
* `mapbox.landmark-pois-v1`, `mapbox.procedural-buildings-v1`. These
|
|
87
|
+
* have tiles only where indoor venues / landmark POIs / 3D buildings
|
|
88
|
+
* actually exist; for typical regions they return 404 for nearly every
|
|
89
|
+
* coordinate. Pre-skipping means we never issue probe or download
|
|
90
|
+
* requests for them, eliminating the 404 noise in devtools.
|
|
91
|
+
*
|
|
92
|
+
* Default: `true`. Set `false` to attempt these sources anyway — the
|
|
93
|
+
* downstream `probeSourcesBeforeDownload` pass will still skip them
|
|
94
|
+
* for most regions, but you'll see the probe 404s in the network log.
|
|
95
|
+
*/
|
|
96
|
+
skipKnownSparseSources?: boolean;
|
|
83
97
|
}
|
|
84
98
|
/**
|
|
85
99
|
* Result of a tile download operation
|
|
@@ -10,7 +10,7 @@ export interface RegionFormData {
|
|
|
10
10
|
styleUrl: string;
|
|
11
11
|
bounds: [number, number, number, number];
|
|
12
12
|
provider?: 'mapbox' | 'maplibre' | 'auto';
|
|
13
|
-
accessToken?: string;
|
|
13
|
+
accessToken?: string | null;
|
|
14
14
|
/** Additional tile sources to download alongside the style's own sources */
|
|
15
15
|
extraSources?: import('../../types/region').ExtraSource[];
|
|
16
16
|
}
|
|
@@ -38,7 +38,7 @@ export interface RegionFormOptions {
|
|
|
38
38
|
onCancel: () => void;
|
|
39
39
|
onThemeToggle?: () => void;
|
|
40
40
|
styleUrl: string;
|
|
41
|
-
accessToken?: string;
|
|
41
|
+
accessToken?: string | null;
|
|
42
42
|
/** Tile sources discovered from the live map for user selection */
|
|
43
43
|
mapSources?: MapTileSource[];
|
|
44
44
|
}
|
|
@@ -93,8 +93,11 @@ export interface OfflineManagerControlOptions {
|
|
|
93
93
|
theme?: 'light' | 'dark';
|
|
94
94
|
/** Whether to show bounding boxes when focusing on regions */
|
|
95
95
|
showBbox?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Mapbox access token, pre-filled in the region download form for mapbox:// style URLs.
|
|
98
|
+
* Accepts `null` so callers can pass `mapboxgl.accessToken` directly; treated as omitted.
|
|
99
|
+
*/
|
|
100
|
+
accessToken?: string | null;
|
|
98
101
|
/**
|
|
99
102
|
* Map library module that supports `addProtocol`/`removeProtocol`.
|
|
100
103
|
* Pass `maplibregl` here so the `idb://` protocol is registered in web workers.
|
|
@@ -81,6 +81,19 @@ export declare const MAPBOX_API: {
|
|
|
81
81
|
readonly MODELS_PATH: "/models/v1";
|
|
82
82
|
readonly PROTOCOL: "mapbox://";
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* Mapbox Standard sub-tilesets that are sparse-by-design across the planet.
|
|
86
|
+
* These only have tiles where the underlying feature (indoor venues, landmark
|
|
87
|
+
* POIs, 3D procedural buildings) actually exists, and return 404 for nearly
|
|
88
|
+
* every other coordinate. The tile downloader pre-skips any source whose tile
|
|
89
|
+
* URL templates reference one of these tileset IDs, so we never issue probe
|
|
90
|
+
* or download requests for them — eliminating the 404 noise in devtools.
|
|
91
|
+
*
|
|
92
|
+
* Matching is done against the tileset segment of the tile URL template
|
|
93
|
+
* (e.g. `https://api.mapbox.com/v4/mapbox.indoor-v3/{z}/{x}/{y}.vector.pbf`
|
|
94
|
+
* or `mapbox://mapbox.indoor-v3`).
|
|
95
|
+
*/
|
|
96
|
+
export declare const MAPBOX_STANDARD_SPARSE_TILESETS: readonly ["mapbox.indoor-v3", "mapbox.landmark-pois-v1", "mapbox.procedural-buildings-v1"];
|
|
84
97
|
export declare const MAP_PROVIDERS: {
|
|
85
98
|
readonly AUTO: "auto";
|
|
86
99
|
readonly MAPBOX: "mapbox";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "map-gl-offline",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
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",
|