map-gl-offline 0.5.1 → 0.5.3
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 +62 -12
- package/bin/cli.js +40 -0
- package/bin/vite-plugin.js +48 -0
- package/dist/idb-offline-sw.js +396 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +4274 -11248
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4278 -11252
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +4277 -11256
- package/dist/index.umd.js.map +1 -1
- package/dist/managers/offlineMapManager/analyticsManagement.d.ts +1 -1
- package/dist/managers/offlineMapManager/base.d.ts +5 -5
- package/dist/managers/offlineMapManager/cleanupManagement.d.ts +1 -1
- package/dist/managers/offlineMapManager/importExportManagement.d.ts +1 -1
- package/dist/managers/offlineMapManager/maintenanceManagement.d.ts +2 -2
- package/dist/managers/offlineMapManager/regionManagement.d.ts +1 -1
- package/dist/managers/offlineMapManager/resourceManagement.d.ts +1 -1
- package/dist/managers/offlineMapManager/styleManagement.d.ts +1 -1
- package/dist/services/analyticsService.d.ts +1 -1
- package/dist/services/cleanupService.d.ts +1 -1
- package/dist/services/fontService.d.ts +1 -1
- package/dist/services/glyphService.d.ts +1 -3
- package/dist/services/importExportService.d.ts +3 -3
- package/dist/services/maintenanceService.d.ts +2 -2
- package/dist/services/regionService.d.ts +1 -1
- package/dist/services/resourceService.d.ts +2 -2
- package/dist/services/spriteService.d.ts +1 -3
- package/dist/services/styleService.d.ts +2 -2
- package/dist/services/tileService.d.ts +1 -1
- package/dist/storage/indexedDbManager.d.ts +1 -1
- package/dist/types/maintenance.d.ts +1 -1
- package/dist/ui/components/PanelActions.d.ts +1 -1
- package/dist/ui/components/PanelHeader.d.ts +1 -1
- package/dist/ui/components/RegionList.d.ts +1 -1
- package/dist/ui/components/shared/LanguageSelector.d.ts +1 -1
- package/dist/ui/components/shared/MapControlButton.d.ts +1 -1
- package/dist/ui/components/shared/PanelContent.d.ts +3 -3
- package/dist/ui/components/shared/RegionDrawingTool.d.ts +2 -2
- package/dist/ui/controls/polygonControl.d.ts +1 -1
- package/dist/ui/controls/regionControl.d.ts +3 -3
- package/dist/ui/managers/ControlButtonManager.d.ts +1 -1
- package/dist/ui/managers/PanelManager.d.ts +3 -3
- package/dist/ui/managers/downloadManager.d.ts +2 -2
- package/dist/ui/modals/importExportModal.d.ts +1 -1
- package/dist/ui/modals/regionDetailsModal.d.ts +1 -1
- package/dist/ui/offlineManagerControl.d.ts +1 -1
- package/dist/utils/convertStyleForSW.d.ts +1 -1
- package/dist/utils/download.d.ts +1 -1
- package/dist/utils/importResolver.d.ts +1 -1
- package/dist/utils/styleProviderUtils.d.ts +1 -1
- package/dist/utils/styleUtils.d.ts +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/vite-plugin.js +48 -0
- package/package.json +19 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StorageAnalyticsReport } from '
|
|
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 '
|
|
2
|
-
import { RegionService } from '
|
|
3
|
-
import { ResourceService } from '
|
|
4
|
-
import { AnalyticsService } from '
|
|
5
|
-
import { ImportExportService } from '
|
|
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 '
|
|
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, PMTilesExportOptions, MBTilesExportOptions, RegionImportData } from '
|
|
1
|
+
import type { ExportResult, ImportExportOptions, ImportResult, PMTilesExportOptions, MBTilesExportOptions, RegionImportData } from '@/types';
|
|
2
2
|
import type { OfflineManagerServices } from './base';
|
|
3
3
|
export interface ImportExportManagement {
|
|
4
4
|
exportRegionAsJSON(regionId: string, options?: ImportExportOptions): Promise<ExportResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MaintenanceOptions, MaintenanceResults } from '
|
|
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';
|
|
@@ -8,6 +8,6 @@ export interface MaintenanceManagement {
|
|
|
8
8
|
}
|
|
9
9
|
export declare const createMaintenanceManagement: (services: OfflineManagerServices, deps: {
|
|
10
10
|
performSmartCleanup: CleanupManagement["performSmartCleanup"];
|
|
11
|
-
|
|
11
|
+
listStoredRegions: RegionManagement["listStoredRegions"];
|
|
12
12
|
getComprehensiveStorageAnalytics: AnalyticsManagement["getComprehensiveStorageAnalytics"];
|
|
13
13
|
}) => MaintenanceManagement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OfflineRegionOptions, StoredRegion } from '
|
|
1
|
+
import type { 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 '
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import type { EnhancedStyleStats, StyleDownloadOptions, StyleDownloadResult, StyleEntry, StyleProvider } from '
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnhancedGlyphStats } from './glyphService';
|
|
2
|
-
import type { RegionAnalytics, TileStats, StorageAnalyticsReport, EnhancedFontStats, EnhancedSpriteStats } from '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
1
|
+
import type { GlyphDownloadOptions, GlyphDownloadResult, GlyphEntry, GlyphRange } from '@/types';
|
|
2
2
|
export interface EnhancedGlyphStats {
|
|
3
3
|
count: number;
|
|
4
4
|
totalSize: number;
|
|
@@ -38,8 +38,6 @@ export declare class GlyphService {
|
|
|
38
38
|
removed: number;
|
|
39
39
|
}>;
|
|
40
40
|
private validateGlyphData;
|
|
41
|
-
private countGlyphsInData;
|
|
42
|
-
private calculateCompressionRatio;
|
|
43
41
|
private normalizeFontstack;
|
|
44
42
|
private buildGlyphPath;
|
|
45
43
|
private parseGlyphKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RegionImportData, ImportExportOptions, ImportResult, ExportResult, PMTilesExportOptions, MBTilesExportOptions } from '
|
|
1
|
+
import type { RegionImportData, ImportExportOptions, ImportResult, ExportResult, PMTilesExportOptions, MBTilesExportOptions } from '@/types';
|
|
2
2
|
export declare class ImportExportService {
|
|
3
3
|
private db;
|
|
4
4
|
constructor();
|
|
@@ -39,9 +39,9 @@ export declare class ImportExportService {
|
|
|
39
39
|
*/
|
|
40
40
|
private exportFonts;
|
|
41
41
|
/**
|
|
42
|
-
* Read file content
|
|
42
|
+
* Read file content as text (for JSON files)
|
|
43
43
|
*/
|
|
44
|
-
private
|
|
44
|
+
private readFileAsText;
|
|
45
45
|
/**
|
|
46
46
|
* Parse PMTiles file (simplified)
|
|
47
47
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StorageAnalyticsReport, MaintenanceOptions, MaintenanceResults, RegionCleanupOptions, CleanupResult } from '
|
|
2
|
-
export type { MaintenanceOptions, MaintenanceResults } from '
|
|
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,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 } from '
|
|
2
|
+
import type { OfflineRegionOptions, MapboxStyle, TileDownloadOptions, TileDownloadResult, TileStats, SpriteDownloadOptions, SpriteDownloadResult, EnhancedSpriteStats, FontDownloadOptions, FontDownloadResult, EnhancedFontStats, GlyphDownloadOptions, GlyphDownloadResult } from '@/types';
|
|
3
3
|
export declare class ResourceService {
|
|
4
4
|
downloadTilesWithOptions(region: OfflineRegionOptions, style: MapboxStyle, styleId: string, options?: TileDownloadOptions): Promise<TileDownloadResult>;
|
|
5
5
|
getTileStatistics(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
|
getGlyphStatistics(): Promise<EnhancedGlyphStats>;
|
|
32
32
|
getGlyphAnalytics(): Promise<Record<string, unknown>>;
|
|
33
|
-
loadGlyphsForStyle(fontstack: string, ranges: string[], styleId?: string): Promise<import("
|
|
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 '
|
|
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
|
|
@@ -48,8 +48,6 @@ export declare class SpriteService {
|
|
|
48
48
|
private extractSpriteName;
|
|
49
49
|
private detectSpriteType;
|
|
50
50
|
private validateSprite;
|
|
51
|
-
private extractSpriteMetadata;
|
|
52
|
-
private isProbablySpritesheet;
|
|
53
51
|
private rateLimitDelay;
|
|
54
52
|
}
|
|
55
53
|
export declare const spriteService: SpriteService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StyleProvider, StyleDownloadOptions, StyleDownloadResult, StyleStorageItem, EnhancedStyleStats } from '
|
|
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>;
|
|
@@ -7,7 +7,7 @@ export declare function deleteStyleById(styleId: string): Promise<void>;
|
|
|
7
7
|
/**
|
|
8
8
|
* Get enhanced style statistics
|
|
9
9
|
*/
|
|
10
|
-
export declare function getStyleStats(): Promise<EnhancedStyleStats>;
|
|
10
|
+
export declare function getStyleStats(styleId?: string): Promise<EnhancedStyleStats>;
|
|
11
11
|
/**
|
|
12
12
|
* Clean up old styles based on criteria
|
|
13
13
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TileDownloadOptions, TileDownloadResult, TileStats, OfflineRegionOptions, MapboxStyle } from '
|
|
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
|
|
@@ -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 '
|
|
5
|
+
import { Theme } from '@/ui/ThemeManager';
|
|
6
6
|
export interface ActionButtonsProps {
|
|
7
7
|
onAddRegion?: () => void;
|
|
8
8
|
onCleanup?: () => void;
|
|
@@ -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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
7
|
-
import { DownloadManager } from '
|
|
8
|
-
import { ModalManager } from '
|
|
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 '
|
|
8
|
-
import { ModalManager } from '
|
|
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 '
|
|
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 '
|
|
7
|
-
import { ModalManager } from '
|
|
8
|
-
import type { CssPrefix } from '
|
|
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;
|
|
@@ -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 '
|
|
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 '
|
|
6
|
+
import { OfflineMapManager } from '@/managers/offlineMapManager';
|
|
7
7
|
import { DownloadManager } from './downloadManager';
|
|
8
|
-
import { ModalManager } from '
|
|
9
|
-
import { BaseComponent } from '
|
|
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;
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
*
|
|
44
44
|
* @module downloadManager
|
|
45
45
|
*/
|
|
46
|
-
import { OfflineMapManager } from '
|
|
47
|
-
import { RegionFormData } from '
|
|
46
|
+
import { OfflineMapManager } from '@/managers/offlineMapManager';
|
|
47
|
+
import { RegionFormData } from '@/ui/modals/regionFormModal';
|
|
48
48
|
/**
|
|
49
49
|
* Progress information for an active download.
|
|
50
50
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Handles import/export operations for regions
|
|
4
4
|
* Refactored to use modular Modal component for consistency
|
|
5
5
|
*/
|
|
6
|
-
import type { StoredRegion, ImportExportOptions, ExportResult, ImportResult, RegionImportData } from '
|
|
6
|
+
import type { StoredRegion, ImportExportOptions, ExportResult, ImportResult, RegionImportData } from '@/types';
|
|
7
7
|
export interface ImportExportModalOptions {
|
|
8
8
|
region: StoredRegion;
|
|
9
9
|
onClose: () => void;
|
|
@@ -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 '
|
|
6
|
+
import { StoredRegion } from '@/types/region';
|
|
7
7
|
export interface RegionDetailsOptions {
|
|
8
8
|
region: StoredRegion;
|
|
9
9
|
onClose: () => void;
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* @module offlineManagerControl
|
|
36
36
|
*/
|
|
37
37
|
import type { IControl, Map as MaplibreMap } from 'maplibre-gl';
|
|
38
|
-
import { OfflineMapManager } from '
|
|
38
|
+
import { OfflineMapManager } from '@/managers/offlineMapManager';
|
|
39
39
|
/**
|
|
40
40
|
* Interface for map libraries that support custom protocol handlers.
|
|
41
41
|
* MapLibre GL JS provides `addProtocol`/`removeProtocol`; Mapbox GL JS v3 does not.
|
package/dist/utils/download.d.ts
CHANGED
|
@@ -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 '
|
|
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 '
|
|
5
|
+
import type { BaseStyle, StyleProvider } from '@/types/style';
|
|
6
6
|
/**
|
|
7
7
|
* Check if a URL uses the mapbox:// protocol
|
|
8
8
|
*/
|
|
@@ -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 '
|
|
5
|
+
import type { OfflineRegionOptions } from '@/types';
|
|
6
6
|
/**
|
|
7
7
|
* Validate geographic bounds
|
|
8
8
|
* @param bounds - Array of two [lng, lat] coordinate pairs
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync } from 'fs';
|
|
2
|
+
import { resolve, dirname, join } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const SW_FILENAME = 'idb-offline-sw.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Vite plugin that copies the offline Service Worker to the public directory.
|
|
10
|
+
* Required for Mapbox GL JS offline support.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```js
|
|
14
|
+
* import { offlineSwPlugin } from 'map-gl-offline/vite-plugin';
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* plugins: [offlineSwPlugin()],
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function offlineSwPlugin() {
|
|
22
|
+
let projectRoot = '';
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
name: 'map-gl-offline-sw',
|
|
26
|
+
|
|
27
|
+
configResolved(config) {
|
|
28
|
+
projectRoot = config.root;
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
buildStart() {
|
|
32
|
+
const src = resolve(__dirname, '..', 'dist', SW_FILENAME);
|
|
33
|
+
const destDir = join(projectRoot, 'public');
|
|
34
|
+
const dest = join(destDir, SW_FILENAME);
|
|
35
|
+
|
|
36
|
+
if (!existsSync(src)) {
|
|
37
|
+
this.warn(
|
|
38
|
+
`${SW_FILENAME} not found in map-gl-offline dist/. Skipping copy.`,
|
|
39
|
+
);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
mkdirSync(destDir, { recursive: true });
|
|
44
|
+
cpSync(src, dest);
|
|
45
|
+
console.log(`[map-gl-offline] Copied ${SW_FILENAME} to public/`);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "map-gl-offline",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
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",
|
|
7
7
|
"unpkg": "dist/index.umd.js",
|
|
8
8
|
"jsdelivr": "dist/index.umd.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
|
+
"bin": {
|
|
11
|
+
"map-gl-offline": "./bin/cli.js"
|
|
12
|
+
},
|
|
10
13
|
"exports": {
|
|
11
14
|
".": {
|
|
12
15
|
"types": "./dist/index.d.ts",
|
|
13
16
|
"import": "./dist/index.esm.js",
|
|
14
17
|
"require": "./dist/index.js"
|
|
15
18
|
},
|
|
16
|
-
"./style.css": "./dist/style.css"
|
|
19
|
+
"./style.css": "./dist/style.css",
|
|
20
|
+
"./vite-plugin": "./dist/vite-plugin.js"
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
19
23
|
"dist",
|
|
24
|
+
"bin",
|
|
20
25
|
"README.md",
|
|
21
26
|
"LICENSE"
|
|
22
27
|
],
|
|
@@ -31,11 +36,12 @@
|
|
|
31
36
|
},
|
|
32
37
|
"scripts": {
|
|
33
38
|
"dev": "vite",
|
|
34
|
-
"build": "npm run build:clean && npm run build:lib && npm run build:types && npm run build:css",
|
|
39
|
+
"build": "npm run build:clean && npm run build:lib && npm run build:types && npm run build:css && npm run build:sw",
|
|
35
40
|
"build:clean": "rimraf dist",
|
|
36
41
|
"build:lib": "rollup -c",
|
|
37
42
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
38
43
|
"build:css": "tailwindcss -i src/styles/style.css -o dist/style.css --minify",
|
|
44
|
+
"build:sw": "cp public/idb-offline-sw.js dist/idb-offline-sw.js && cp bin/vite-plugin.js dist/vite-plugin.js",
|
|
39
45
|
"build:watch": "rollup -c -w",
|
|
40
46
|
"build:dev": "npm run build:clean && npm run build:lib",
|
|
41
47
|
"build:demo": "vite build --outDir demo",
|
|
@@ -46,9 +52,9 @@
|
|
|
46
52
|
"test:watch": "jest --watch",
|
|
47
53
|
"test:coverage": "jest --coverage",
|
|
48
54
|
"test:ci": "jest --ci --coverage --watchAll=false --testPathIgnorePatterns='tests/e2e'",
|
|
49
|
-
"lint": "eslint src
|
|
50
|
-
"lint:fix": "eslint src --
|
|
51
|
-
"lint:warn": "eslint src --
|
|
55
|
+
"lint": "eslint src",
|
|
56
|
+
"lint:fix": "eslint src --fix",
|
|
57
|
+
"lint:warn": "eslint src --max-warnings 200",
|
|
52
58
|
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
|
|
53
59
|
"format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
|
|
54
60
|
"typecheck": "tsc --noEmit",
|
|
@@ -96,8 +102,10 @@
|
|
|
96
102
|
"type": "module",
|
|
97
103
|
"dependencies": {
|
|
98
104
|
"@mapbox/tilebelt": "^2.0.3",
|
|
99
|
-
"@
|
|
100
|
-
"@turf/
|
|
105
|
+
"@turf/area": "^7.3.4",
|
|
106
|
+
"@turf/bbox-polygon": "^7.3.4",
|
|
107
|
+
"@turf/difference": "^7.3.4",
|
|
108
|
+
"@turf/helpers": "^7.3.4",
|
|
101
109
|
"i18next": "^25.8.11",
|
|
102
110
|
"idb": "^8.0.3"
|
|
103
111
|
},
|
|
@@ -115,7 +123,7 @@
|
|
|
115
123
|
},
|
|
116
124
|
"devDependencies": {
|
|
117
125
|
"@babel/preset-env": "^7.29.0",
|
|
118
|
-
"@eslint/js": "^
|
|
126
|
+
"@eslint/js": "^10.0.1",
|
|
119
127
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
120
128
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
121
129
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
@@ -126,12 +134,8 @@
|
|
|
126
134
|
"@types/mapbox-gl": "^3.4.1",
|
|
127
135
|
"@types/maplibre-gl": "^1.14.0",
|
|
128
136
|
"@types/node": "^25.3.0",
|
|
129
|
-
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
130
|
-
"@typescript-eslint/parser": "^8.33.1",
|
|
131
137
|
"autoprefixer": "^10.4.24",
|
|
132
|
-
"eslint": "^
|
|
133
|
-
"eslint-config-prettier": "^10.1.8",
|
|
134
|
-
"eslint-plugin-prettier": "^5.5.5",
|
|
138
|
+
"eslint": "^10.0.0",
|
|
135
139
|
"fake-indexeddb": "^6.2.5",
|
|
136
140
|
"husky": "^9.1.7",
|
|
137
141
|
"jest": "^30.2.0",
|
|
@@ -151,7 +155,7 @@
|
|
|
151
155
|
"tslib": "^2.8.1",
|
|
152
156
|
"tsx": "^4.21.0",
|
|
153
157
|
"typescript": "^5.9.3",
|
|
154
|
-
"typescript-eslint": "^8.
|
|
158
|
+
"typescript-eslint": "^8.56.0",
|
|
155
159
|
"vite": "^7.3.1",
|
|
156
160
|
"vite-tsconfig-paths": "^6.1.1"
|
|
157
161
|
}
|