map-gl-offline 0.8.6 → 0.8.7

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.
@@ -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>;
@@ -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
- /** Mapbox access token; required when the style or sources use mapbox:// URLs. */
30
- accessToken?: string;
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: [[number, number], [number, number]];
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 */
@@ -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
- accessToken?: string;
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;
@@ -13,7 +13,7 @@ export interface RegionControlOptions {
13
13
  container: HTMLDivElement;
14
14
  onRegionSaved?: () => void;
15
15
  styleUrl: string;
16
- accessToken?: string;
16
+ accessToken?: string | null;
17
17
  cssPrefix?: CssPrefix;
18
18
  }
19
19
  export declare class RegionControl {
@@ -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
- /** Mapbox access token, pre-filled in the region download form for mapbox:// style URLs */
97
- accessToken?: string;
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "map-gl-offline",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
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",