map-gl-offline 0.8.5 → 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.
Files changed (54) hide show
  1. package/README.md +61 -0
  2. package/dist/index.esm.js +12 -2
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +12 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.umd.js +12 -2
  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 +1 -1
  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 +3 -3
  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 -1
  20. package/dist/services/importExportService.d.ts +1 -1
  21. package/dist/services/maintenanceService.d.ts +2 -2
  22. package/dist/services/modelService.d.ts +1 -1
  23. package/dist/services/regionService.d.ts +1 -1
  24. package/dist/services/resourceService.d.ts +2 -2
  25. package/dist/services/spriteService.d.ts +1 -1
  26. package/dist/services/styleService.d.ts +2 -2
  27. package/dist/services/tileService.d.ts +1 -1
  28. package/dist/storage/indexedDbManager.d.ts +1 -1
  29. package/dist/types/maintenance.d.ts +1 -1
  30. package/dist/types/region.d.ts +21 -3
  31. package/dist/types/style.d.ts +6 -2
  32. package/dist/ui/components/PanelActions.d.ts +1 -1
  33. package/dist/ui/components/PanelHeader.d.ts +1 -1
  34. package/dist/ui/components/RegionList.d.ts +1 -1
  35. package/dist/ui/components/shared/LanguageSelector.d.ts +1 -1
  36. package/dist/ui/components/shared/MapControlButton.d.ts +1 -1
  37. package/dist/ui/components/shared/PanelContent.d.ts +3 -3
  38. package/dist/ui/components/shared/RegionDrawingTool.d.ts +2 -2
  39. package/dist/ui/controls/polygonControl.d.ts +1 -1
  40. package/dist/ui/controls/regionControl.d.ts +4 -4
  41. package/dist/ui/managers/ControlButtonManager.d.ts +1 -1
  42. package/dist/ui/managers/PanelManager.d.ts +3 -3
  43. package/dist/ui/managers/downloadManager.d.ts +2 -2
  44. package/dist/ui/modals/mbtilesModal.d.ts +1 -1
  45. package/dist/ui/modals/regionDetailsModal.d.ts +1 -1
  46. package/dist/ui/modals/regionFormModal.d.ts +3 -3
  47. package/dist/ui/offlineManagerControl.d.ts +6 -3
  48. package/dist/utils/convertStyleForSW.d.ts +1 -1
  49. package/dist/utils/download.d.ts +1 -1
  50. package/dist/utils/importResolver.d.ts +1 -1
  51. package/dist/utils/styleProviderUtils.d.ts +1 -1
  52. package/dist/utils/styleUtils.d.ts +1 -1
  53. package/dist/utils/validation.d.ts +1 -1
  54. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import type { StorageAnalyticsReport } from '@/types';
1
+ import type { StorageAnalyticsReport } from '../../types';
2
2
  import type { OfflineManagerServices } from './base';
3
3
  import type { CleanupManagement } from './cleanupManagement';
4
4
  export interface AnalyticsManagement {
@@ -1,8 +1,8 @@
1
- import { CleanupService } from '@/services/cleanupService';
2
- import { RegionService } from '@/services/regionService';
3
- import { ResourceService } from '@/services/resourceService';
4
- import { AnalyticsService } from '@/services/analyticsService';
5
- import { ImportExportService } from '@/services/importExportService';
1
+ import { CleanupService } from '../../services/cleanupService';
2
+ import { RegionService } from '../../services/regionService';
3
+ import { ResourceService } from '../../services/resourceService';
4
+ import { AnalyticsService } from '../../services/analyticsService';
5
+ import { ImportExportService } from '../../services/importExportService';
6
6
  export interface OfflineManagerServices {
7
7
  regionService: RegionService;
8
8
  cleanupService: CleanupService;
@@ -1,4 +1,4 @@
1
- import type { CleanupResult, RegionAnalytics, RegionCleanupOptions } from '@/types';
1
+ import type { CleanupResult, RegionAnalytics, RegionCleanupOptions } from '../../types';
2
2
  import type { OfflineManagerServices } from './base';
3
3
  export interface CleanupManagement {
4
4
  getRegionSize(regionId: string, styleId?: string): Promise<number>;
@@ -1,4 +1,4 @@
1
- import type { ExportResult, ImportExportOptions, ImportResult, MBTilesExportOptions, RegionImportData } from '@/types';
1
+ import type { ExportResult, ImportExportOptions, ImportResult, MBTilesExportOptions, RegionImportData } from '../../types';
2
2
  import type { OfflineManagerServices } from './base';
3
3
  /**
4
4
  * MBTiles-only import/export surface. Regions are exchanged as real
@@ -1,4 +1,4 @@
1
- import type { MaintenanceOptions, MaintenanceResults } from '@/types';
1
+ import type { MaintenanceOptions, MaintenanceResults } from '../../types';
2
2
  import type { OfflineManagerServices } from './base';
3
3
  import type { CleanupManagement } from './cleanupManagement';
4
4
  import type { RegionManagement } from './regionManagement';
@@ -1,4 +1,4 @@
1
- import type { DownloadRegionOptions, DownloadRegionResult, OfflineRegionOptions, StoredRegion } from '@/types';
1
+ import type { DownloadRegionOptions, DownloadRegionResult, OfflineRegionOptions, StoredRegion } from '../../types';
2
2
  import type { OfflineManagerServices } from './base';
3
3
  export interface RegionManagement {
4
4
  addRegion(region: OfflineRegionOptions): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { ResourceService } from '@/services/resourceService';
1
+ import type { ResourceService } from '../../services/resourceService';
2
2
  import type { OfflineManagerServices } from './base';
3
3
  export type ResourceServiceMethod<TMethod extends keyof ResourceService> = ResourceService[TMethod];
4
4
  export interface ResourceManagement {
@@ -1,15 +1,15 @@
1
- import type { EnhancedStyleStats, StyleDownloadOptions, StyleDownloadResult, StyleEntry, StyleProvider } from '@/types';
1
+ import type { EnhancedStyleStats, StyleDownloadOptions, StyleDownloadResult, StyleEntry, StyleProvider } from '../../types';
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>;
@@ -1,5 +1,5 @@
1
1
  import { EnhancedGlyphStats } from './glyphService';
2
- import type { RegionAnalytics, TileStats, StorageAnalyticsReport, EnhancedFontStats, EnhancedSpriteStats } from '@/types';
2
+ import type { RegionAnalytics, TileStats, StorageAnalyticsReport, EnhancedFontStats, EnhancedSpriteStats } from '../types';
3
3
  export declare class AnalyticsService {
4
4
  getAllTileStats(): Promise<TileStats>;
5
5
  getAllFontStats(): Promise<EnhancedFontStats>;
@@ -1,4 +1,4 @@
1
- import type { StoredRegion, RegionCleanupOptions, CleanupResult, RegionAnalytics } from '@/types';
1
+ import type { StoredRegion, RegionCleanupOptions, CleanupResult, RegionAnalytics } from '../types';
2
2
  export declare class CleanupService {
3
3
  private db;
4
4
  private deleteRegionCallback;
@@ -1,4 +1,4 @@
1
- import type { EnhancedFontStats, FontDownloadOptions, FontDownloadResult } from '@/types';
1
+ import type { EnhancedFontStats, FontDownloadOptions, FontDownloadResult } from '../types';
2
2
  export declare class FontService {
3
3
  private db;
4
4
  downloadFonts(fontUrls: string[], styleName?: string, options?: FontDownloadOptions): Promise<FontDownloadResult>;
@@ -1,4 +1,4 @@
1
- import type { GlyphDownloadOptions, GlyphDownloadResult, GlyphEntry, GlyphRange } from '@/types';
1
+ import type { GlyphDownloadOptions, GlyphDownloadResult, GlyphEntry, GlyphRange } from '../types';
2
2
  export interface EnhancedGlyphStats {
3
3
  count: number;
4
4
  totalSize: number;
@@ -1,4 +1,4 @@
1
- import type { RegionImportData, ImportExportOptions, ImportResult, ExportResult, MBTilesExportOptions } from '@/types';
1
+ import type { RegionImportData, ImportExportOptions, ImportResult, ExportResult, MBTilesExportOptions } from '../types';
2
2
  export declare class ImportExportService {
3
3
  private db;
4
4
  constructor();
@@ -1,5 +1,5 @@
1
- import type { StorageAnalyticsReport, MaintenanceOptions, MaintenanceResults, RegionCleanupOptions, CleanupResult } from '@/types';
2
- export type { MaintenanceOptions, MaintenanceResults } from '@/types/maintenance';
1
+ import type { StorageAnalyticsReport, MaintenanceOptions, MaintenanceResults, RegionCleanupOptions, CleanupResult } from '../types';
2
+ export type { MaintenanceOptions, MaintenanceResults } from '../types/maintenance';
3
3
  export declare class MaintenanceService {
4
4
  private performSmartCleanup;
5
5
  private listRegions;
@@ -1,4 +1,4 @@
1
- import type { ModelEntry, ModelDownloadOptions, ModelDownloadResult, EnhancedModelStats } from '@/types';
1
+ import type { ModelEntry, ModelDownloadOptions, ModelDownloadResult, EnhancedModelStats } from '../types';
2
2
  /** True when the given key belongs to the given styleId's model store prefix. */
3
3
  export declare function modelKeyBelongsToStyle(key: string, styleId: string): boolean;
4
4
  /**
@@ -1,4 +1,4 @@
1
- import type { DownloadRegionOptions, DownloadRegionResult, OfflineRegionOptions, StoredRegion } from '@/types/region';
1
+ import type { DownloadRegionOptions, DownloadRegionResult, OfflineRegionOptions, StoredRegion } from '../types/region';
2
2
  /**
3
3
  * True when `key` belongs to the given styleId.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { EnhancedGlyphStats } from './glyphService';
2
- import type { OfflineRegionOptions, MapboxStyle, TileDownloadOptions, TileDownloadResult, TileStats, SpriteDownloadOptions, SpriteDownloadResult, EnhancedSpriteStats, FontDownloadOptions, FontDownloadResult, EnhancedFontStats, GlyphDownloadOptions, GlyphDownloadResult, ModelDownloadOptions, ModelDownloadResult, EnhancedModelStats } from '@/types';
2
+ import type { OfflineRegionOptions, MapboxStyle, TileDownloadOptions, TileDownloadResult, TileStats, SpriteDownloadOptions, SpriteDownloadResult, EnhancedSpriteStats, FontDownloadOptions, FontDownloadResult, EnhancedFontStats, GlyphDownloadOptions, GlyphDownloadResult, ModelDownloadOptions, ModelDownloadResult, EnhancedModelStats } from '../types';
3
3
  export declare class ResourceService {
4
4
  downloadTilesWithOptions(region: OfflineRegionOptions, style: MapboxStyle, styleId: string, options?: TileDownloadOptions): Promise<TileDownloadResult>;
5
5
  getTileStats(styleId?: string): Promise<TileStats>;
@@ -30,7 +30,7 @@ export declare class ResourceService {
30
30
  downloadGlyphsWithOptions(glyphUrl: string, fontstacks: string[], styleName: string, ranges?: string[], options?: GlyphDownloadOptions): Promise<GlyphDownloadResult>;
31
31
  getGlyphStats(): Promise<EnhancedGlyphStats>;
32
32
  getGlyphAnalytics(): Promise<Record<string, unknown>>;
33
- loadGlyphsForStyle(fontstack: string, ranges: string[], styleId?: string): Promise<import("@/types").GlyphRange[]>;
33
+ loadGlyphsForStyle(fontstack: string, ranges: string[], styleId?: string): Promise<import("../types").GlyphRange[]>;
34
34
  cleanupOldGlyphs(styleId?: string, options?: {
35
35
  maxAge?: number;
36
36
  }): Promise<number>;
@@ -1,4 +1,4 @@
1
- import type { EnhancedSpriteStats, SpriteDownloadOptions, SpriteDownloadResult } from '@/types';
1
+ import type { EnhancedSpriteStats, SpriteDownloadOptions, SpriteDownloadResult } from '../types';
2
2
  /**
3
3
  * Service for managing map sprite assets
4
4
  * Handles downloading, storing, and retrieving sprite images and JSON metadata
@@ -1,4 +1,4 @@
1
- import type { StyleProvider, StyleDownloadOptions, StyleDownloadResult, StyleStorageItem, EnhancedStyleStats } from '@/types';
1
+ import type { StyleProvider, StyleDownloadOptions, StyleDownloadResult, StyleStorageItem, EnhancedStyleStats } from '../types';
2
2
  export declare function downloadStyles(stylesUrl: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
3
3
  export declare function loadStyles(): Promise<StyleStorageItem[]>;
4
4
  export declare function loadStyleById(styleId: string): Promise<StyleStorageItem | null>;
@@ -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,4 @@
1
- import type { TileDownloadOptions, TileDownloadResult, TileStats, OfflineRegionOptions, MapboxStyle } from '@/types';
1
+ import type { TileDownloadOptions, TileDownloadResult, TileStats, OfflineRegionOptions, MapboxStyle } from '../types';
2
2
  /**
3
3
  * Service for managing offline map tiles
4
4
  * Handles downloading, storing, and retrieving map tiles from IndexedDB
@@ -1,5 +1,5 @@
1
1
  import { IDBPDatabase } from 'idb';
2
- import { OfflineMapDB } from '@/types';
2
+ import { OfflineMapDB } from '../types';
3
3
  /**
4
4
  * Thrown when the on-disk IndexedDB is at a higher schema version than the
5
5
  * library was built against — i.e. after a downgrade, or when another app
@@ -1,4 +1,4 @@
1
- import { EnhancedGlyphStats } from '@/services/glyphService';
1
+ import { EnhancedGlyphStats } from '../services/glyphService';
2
2
  import { TileStats } from './tile';
3
3
  import { EnhancedFontStats } from './font';
4
4
  import { EnhancedSpriteStats } from './sprite';
@@ -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;
@@ -2,7 +2,7 @@
2
2
  * Action buttons section for the offline manager
3
3
  * Refactored to use modular components
4
4
  */
5
- import { Theme } from '@/ui/ThemeManager';
5
+ import { Theme } from '../../ui/ThemeManager';
6
6
  export interface ActionButtonsProps {
7
7
  onAddRegion?: () => void;
8
8
  onCleanup?: () => void;
@@ -2,7 +2,7 @@
2
2
  * Header component for the offline manager
3
3
  * Refactored to use modular components
4
4
  */
5
- import { Theme } from '@/ui/ThemeManager';
5
+ import { Theme } from '../../ui/ThemeManager';
6
6
  export interface HeaderProps {
7
7
  title: string;
8
8
  subtitle: string;
@@ -3,7 +3,7 @@
3
3
  * Refactored to use modular Button components
4
4
  */
5
5
  import { BaseComponent } from './shared/BaseComponent';
6
- import type { StoredRegion } from '@/types';
6
+ import type { StoredRegion } from '../../types';
7
7
  export interface RegionsListProps {
8
8
  regions: StoredRegion[];
9
9
  onDeleteRegion?: (regionId: string) => void;
@@ -3,7 +3,7 @@
3
3
  * Provides a dropdown to switch between available languages
4
4
  */
5
5
  import { BaseComponent } from './BaseComponent';
6
- import { SupportedLanguage } from '@/ui/translations';
6
+ import { SupportedLanguage } from '../../../ui/translations';
7
7
  export interface LanguageSelectorOptions {
8
8
  onChange?: (language: SupportedLanguage) => void;
9
9
  }
@@ -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 '@/ui/managers/downloadManager';
8
- import { ModalManager } from '@/ui/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 '@/ui/managers/downloadManager';
8
- import { ModalManager } from '@/ui/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 '@/ui/managers/downloadManager';
7
- import { ModalManager } from '@/ui/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;
@@ -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 {
@@ -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 '@/ui/modals/modalManager';
9
- import { BaseComponent } from '@/ui/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;
@@ -44,8 +44,8 @@
44
44
  *
45
45
  * @module downloadManager
46
46
  */
47
- import { OfflineMapManager } from '@/managers/offlineMapManager';
48
- import { RegionFormData } from '@/ui/modals/regionFormModal';
47
+ import { OfflineMapManager } from '../../managers/offlineMapManager';
48
+ import { RegionFormData } from '../../ui/modals/regionFormModal';
49
49
  /**
50
50
  * Progress information for an active download.
51
51
  *
@@ -4,7 +4,7 @@
4
4
  * Focused modal for exchanging regions as binary SQLite MBTiles archives.
5
5
  * Replaces the previous multi-format import/export modal.
6
6
  */
7
- import type { StoredRegion, ImportExportOptions, MBTilesExportOptions, ExportResult, ImportResult, RegionImportData } from '@/types';
7
+ import type { StoredRegion, ImportExportOptions, MBTilesExportOptions, ExportResult, ImportResult, RegionImportData } from '../../types';
8
8
  type MBTilesExportRequestOptions = ImportExportOptions & MBTilesExportOptions;
9
9
  export interface MBTilesModalOptions {
10
10
  region: StoredRegion;
@@ -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;
@@ -10,9 +10,9 @@ 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
- extraSources?: import('@/types/region').ExtraSource[];
15
+ extraSources?: import('../../types/region').ExtraSource[];
16
16
  }
17
17
  /**
18
18
  * A tile source discovered on the live map, presented to the user for selection.
@@ -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
  }
@@ -35,7 +35,7 @@
35
35
  * @module offlineManagerControl
36
36
  */
37
37
  import type { IControl } from 'maplibre-gl';
38
- import { OfflineMapManager } from '@/managers/offlineMapManager';
38
+ import { OfflineMapManager } from '../managers/offlineMapManager';
39
39
  /**
40
40
  * Request shape MapLibre passes to a protocol handler. `type` indicates how
41
41
  * the response will be consumed — `"json"` for sprite atlases / TileJSON,
@@ -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.
@@ -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.8.5",
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",
@@ -39,7 +39,7 @@
39
39
  "build": "npm run build:clean && npm run build:sw-src && npm run build:lib && npm run build:types && npm run build:css && npm run build:sw",
40
40
  "build:clean": "rimraf dist",
41
41
  "build:lib": "rollup -c",
42
- "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
42
+ "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist && tsc-alias -p tsconfig.json --outDir dist",
43
43
  "build:css": "tailwindcss -i src/styles/style.css -o dist/style.css --minify",
44
44
  "build:sw-src": "node scripts/build-sw.mjs",
45
45
  "build:sw": "cp public/idb-offline-sw.js dist/idb-offline-sw.js && cp bin/vite-plugin.js dist/vite-plugin.js",
@@ -154,6 +154,7 @@
154
154
  "tailwindcss": "^4.2.0",
155
155
  "ts-jest": "^29.4.6",
156
156
  "ts-node": "^10.9.2",
157
+ "tsc-alias": "^1.8.17",
157
158
  "tsconfig-paths": "^4.2.0",
158
159
  "tslib": "^2.8.1",
159
160
  "tsx": "^4.21.0",