map-gl-offline 0.1.0-alpha.0

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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +590 -0
  3. package/dist/index.d.ts +17 -0
  4. package/dist/index.esm.js +15863 -0
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/index.js +16015 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/main.d.ts +2 -0
  9. package/dist/managers/offlineMapManager/analyticsManagement.d.ts +7 -0
  10. package/dist/managers/offlineMapManager/base.d.ts +14 -0
  11. package/dist/managers/offlineMapManager/cleanupManagement.d.ts +16 -0
  12. package/dist/managers/offlineMapManager/importExportManagement.d.ts +10 -0
  13. package/dist/managers/offlineMapManager/index.d.ts +72 -0
  14. package/dist/managers/offlineMapManager/maintenanceManagement.d.ts +13 -0
  15. package/dist/managers/offlineMapManager/modules.d.ts +10 -0
  16. package/dist/managers/offlineMapManager/regionManagement.d.ts +11 -0
  17. package/dist/managers/offlineMapManager/resourceManagement.d.ts +24 -0
  18. package/dist/managers/offlineMapManager/styleManagement.d.ts +17 -0
  19. package/dist/managers/offlineMapManager.d.ts +2 -0
  20. package/dist/services/analyticsService.d.ts +10 -0
  21. package/dist/services/baseDownloadService.d.ts +96 -0
  22. package/dist/services/cleanupService.d.ts +34 -0
  23. package/dist/services/fontService.d.ts +26 -0
  24. package/dist/services/glyphService.d.ts +58 -0
  25. package/dist/services/importExportService.d.ts +57 -0
  26. package/dist/services/maintenanceService.d.ts +15 -0
  27. package/dist/services/regionService.d.ts +31 -0
  28. package/dist/services/resourceService.d.ts +42 -0
  29. package/dist/services/spriteService.d.ts +30 -0
  30. package/dist/services/styleService.d.ts +73 -0
  31. package/dist/services/tileService.d.ts +24 -0
  32. package/dist/storage/indexedDbManager.d.ts +2 -0
  33. package/dist/style.css +213 -0
  34. package/dist/types/cleanup.d.ts +49 -0
  35. package/dist/types/database.d.ts +33 -0
  36. package/dist/types/font.d.ts +115 -0
  37. package/dist/types/glyph.d.ts +127 -0
  38. package/dist/types/import-export.d.ts +96 -0
  39. package/dist/types/index.d.ts +12 -0
  40. package/dist/types/maintenance.d.ts +49 -0
  41. package/dist/types/progress.d.ts +11 -0
  42. package/dist/types/region.d.ts +57 -0
  43. package/dist/types/sprite.d.ts +172 -0
  44. package/dist/types/style.d.ts +103 -0
  45. package/dist/types/tile.d.ts +112 -0
  46. package/dist/types/ui.d.ts +10 -0
  47. package/dist/ui/ThemeManager.d.ts +23 -0
  48. package/dist/ui/components/DownloadProgress.d.ts +14 -0
  49. package/dist/ui/components/PanelActions.d.ts +12 -0
  50. package/dist/ui/components/PanelHeader.d.ts +15 -0
  51. package/dist/ui/components/RegionList.d.ts +24 -0
  52. package/dist/ui/components/shared/BaseComponent.d.ts +86 -0
  53. package/dist/ui/components/shared/Button.d.ts +45 -0
  54. package/dist/ui/components/shared/List.d.ts +56 -0
  55. package/dist/ui/components/shared/MapControlButton.d.ts +37 -0
  56. package/dist/ui/components/shared/Modal.d.ts +49 -0
  57. package/dist/ui/components/shared/Panel.d.ts +53 -0
  58. package/dist/ui/components/shared/PanelContent.d.ts +39 -0
  59. package/dist/ui/components/shared/RegionDrawingTool.d.ts +54 -0
  60. package/dist/ui/components/shared/index.d.ts +12 -0
  61. package/dist/ui/controls/polygonControl.d.ts +83 -0
  62. package/dist/ui/controls/regionControl.d.ts +71 -0
  63. package/dist/ui/managers/ControlButtonManager.d.ts +42 -0
  64. package/dist/ui/managers/PanelManager.d.ts +160 -0
  65. package/dist/ui/managers/downloadManager.d.ts +63 -0
  66. package/dist/ui/modals/confirmationModal.d.ts +30 -0
  67. package/dist/ui/modals/importExportModal.d.ts +46 -0
  68. package/dist/ui/modals/importExportModal.old.d.ts +27 -0
  69. package/dist/ui/modals/modalManager.d.ts +23 -0
  70. package/dist/ui/modals/regionDetailsModal.d.ts +37 -0
  71. package/dist/ui/modals/regionFormModal.d.ts +86 -0
  72. package/dist/ui/offlineManagerControl.d.ts +120 -0
  73. package/dist/utils/asyncUtils.d.ts +24 -0
  74. package/dist/utils/cleanupCompressedTiles.d.ts +12 -0
  75. package/dist/utils/constants.d.ts +94 -0
  76. package/dist/utils/download.d.ts +52 -0
  77. package/dist/utils/errorHandling.d.ts +67 -0
  78. package/dist/utils/formatUtils.d.ts +24 -0
  79. package/dist/utils/formatting.d.ts +31 -0
  80. package/dist/utils/icons.d.ts +50 -0
  81. package/dist/utils/idbFetchHandler.d.ts +2 -0
  82. package/dist/utils/index.d.ts +13 -0
  83. package/dist/utils/logger.d.ts +52 -0
  84. package/dist/utils/performance.d.ts +164 -0
  85. package/dist/utils/styleProviderUtils.d.ts +42 -0
  86. package/dist/utils/styleUtils.d.ts +35 -0
  87. package/dist/utils/validation.d.ts +67 -0
  88. package/package.json +145 -0
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import 'maplibre-gl/dist/maplibre-gl.css';
2
+ import 'map-gl-style-switcher/dist/map-gl-style-switcher.css';
@@ -0,0 +1,7 @@
1
+ import type { StorageAnalyticsReport } from '../../types';
2
+ import type { OfflineManagerServices } from './base';
3
+ import type { CleanupManagement } from './cleanupManagement';
4
+ export interface AnalyticsManagement {
5
+ getComprehensiveStorageAnalytics(): Promise<StorageAnalyticsReport>;
6
+ }
7
+ export declare const createAnalyticsManagement: (services: OfflineManagerServices, deps: Pick<CleanupManagement, "getRegionAnalytics">) => AnalyticsManagement;
@@ -0,0 +1,14 @@
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
+ export interface OfflineManagerServices {
7
+ regionService: RegionService;
8
+ cleanupService: CleanupService;
9
+ resourceService: ResourceService;
10
+ analyticsService: AnalyticsService;
11
+ importExportService: ImportExportService;
12
+ }
13
+ export type OfflineManagerServiceOverrides = Partial<OfflineManagerServices>;
14
+ export declare const createManagerServices: (overrides?: OfflineManagerServiceOverrides) => OfflineManagerServices;
@@ -0,0 +1,16 @@
1
+ import type { CleanupResult, RegionAnalytics, RegionCleanupOptions } from '../../types';
2
+ import type { OfflineManagerServices } from './base';
3
+ export interface CleanupManagement {
4
+ getRegionSize(regionId: string): Promise<number>;
5
+ cleanupExpiredRegions(): Promise<number>;
6
+ forceCleanupExpiredRegions(): Promise<number>;
7
+ setupAutoCleanup(options?: RegionCleanupOptions & {
8
+ intervalHours?: number;
9
+ }): Promise<string>;
10
+ stopAutoCleanup(cleanupId?: string): Promise<void>;
11
+ getRegionAnalytics(): Promise<RegionAnalytics>;
12
+ performSmartCleanup(options?: RegionCleanupOptions): Promise<CleanupResult>;
13
+ startEnhancedAutoCleanup(intervalHours?: number, options?: RegionCleanupOptions): Promise<string>;
14
+ stopAllAutoCleanup(): Promise<void>;
15
+ }
16
+ export declare const createCleanupManagement: (services: OfflineManagerServices) => CleanupManagement;
@@ -0,0 +1,10 @@
1
+ import type { ExportResult, ImportExportOptions, ImportResult, PMTilesExportOptions, MBTilesExportOptions, RegionImportData } from '../../types';
2
+ import type { OfflineManagerServices } from './base';
3
+ export interface ImportExportManagement {
4
+ exportRegionAsJSON(regionId: string, options?: ImportExportOptions): Promise<ExportResult>;
5
+ exportRegionAsPMTiles(regionId: string, options?: ImportExportOptions & PMTilesExportOptions): Promise<ExportResult>;
6
+ exportRegionAsMBTiles(regionId: string, options?: ImportExportOptions & MBTilesExportOptions): Promise<ExportResult>;
7
+ importRegion(importData: RegionImportData): Promise<ImportResult>;
8
+ downloadExportedRegion(exportResult: ExportResult): void;
9
+ }
10
+ export declare const createImportExportManagement: (services: OfflineManagerServices) => ImportExportManagement;
@@ -0,0 +1,72 @@
1
+ import { type OfflineManagerServiceOverrides, type OfflineManagerServices } from './base';
2
+ import { type OfflineMapManagerModules } from './modules';
3
+ import type { RegionManagement } from './regionManagement';
4
+ import type { CleanupManagement } from './cleanupManagement';
5
+ import type { ResourceManagement } from './resourceManagement';
6
+ import type { AnalyticsManagement } from './analyticsManagement';
7
+ import type { MaintenanceManagement } from './maintenanceManagement';
8
+ import type { ImportExportManagement } from './importExportManagement';
9
+ import type { StyleManagement } from './styleManagement';
10
+ export declare class OfflineMapManager implements OfflineMapManagerModules {
11
+ private readonly services;
12
+ private readonly modules;
13
+ addRegion: RegionManagement['addRegion'];
14
+ loadRegion: RegionManagement['loadRegion'];
15
+ deleteRegion: RegionManagement['deleteRegion'];
16
+ listRegions: RegionManagement['listRegions'];
17
+ listStoredRegions: RegionManagement['listStoredRegions'];
18
+ getStoredRegion: RegionManagement['getStoredRegion'];
19
+ getRegionSize: CleanupManagement['getRegionSize'];
20
+ cleanupExpiredRegions: CleanupManagement['cleanupExpiredRegions'];
21
+ forceCleanupExpiredRegions: CleanupManagement['forceCleanupExpiredRegions'];
22
+ setupAutoCleanup: CleanupManagement['setupAutoCleanup'];
23
+ stopAutoCleanup: CleanupManagement['stopAutoCleanup'];
24
+ getRegionAnalytics: CleanupManagement['getRegionAnalytics'];
25
+ performSmartCleanup: CleanupManagement['performSmartCleanup'];
26
+ startEnhancedAutoCleanup: CleanupManagement['startEnhancedAutoCleanup'];
27
+ stopAllAutoCleanup: CleanupManagement['stopAllAutoCleanup'];
28
+ downloadTilesWithOptions: ResourceManagement['downloadTilesWithOptions'];
29
+ getTileStatistics: ResourceManagement['getTileStatistics'];
30
+ downloadFontsWithOptions: ResourceManagement['downloadFontsWithOptions'];
31
+ getFontStatistics: ResourceManagement['getFontStatistics'];
32
+ getFontAnalytics: ResourceManagement['getFontAnalytics'];
33
+ cleanupOldFonts: ResourceManagement['cleanupOldFonts'];
34
+ verifyAndRepairFonts: ResourceManagement['verifyAndRepairFonts'];
35
+ downloadSpritesWithOptions: ResourceManagement['downloadSpritesWithOptions'];
36
+ getSpriteStatistics: ResourceManagement['getSpriteStatistics'];
37
+ cleanupOldSprites: ResourceManagement['cleanupOldSprites'];
38
+ verifyAndRepairSprites: ResourceManagement['verifyAndRepairSprites'];
39
+ getSpriteAnalytics: ResourceManagement['getSpriteAnalytics'];
40
+ downloadGlyphsWithOptions: ResourceManagement['downloadGlyphsWithOptions'];
41
+ getGlyphStatistics: ResourceManagement['getGlyphStatistics'];
42
+ getGlyphAnalytics: ResourceManagement['getGlyphAnalytics'];
43
+ loadGlyphsForStyle: ResourceManagement['loadGlyphsForStyle'];
44
+ cleanupOldGlyphs: ResourceManagement['cleanupOldGlyphs'];
45
+ verifyAndRepairGlyphs: ResourceManagement['verifyAndRepairGlyphs'];
46
+ getComprehensiveStorageAnalytics: AnalyticsManagement['getComprehensiveStorageAnalytics'];
47
+ performCompleteMaintenance: MaintenanceManagement['performCompleteMaintenance'];
48
+ exportRegionAsJSON: ImportExportManagement['exportRegionAsJSON'];
49
+ exportRegionAsPMTiles: ImportExportManagement['exportRegionAsPMTiles'];
50
+ exportRegionAsMBTiles: ImportExportManagement['exportRegionAsMBTiles'];
51
+ importRegion: ImportExportManagement['importRegion'];
52
+ downloadExportedRegion: ImportExportManagement['downloadExportedRegion'];
53
+ downloadStyle: StyleManagement['downloadStyle'];
54
+ loadStyleById: StyleManagement['loadStyleById'];
55
+ listStyles: StyleManagement['listStyles'];
56
+ deleteStyle: StyleManagement['deleteStyle'];
57
+ getStyleStats: StyleManagement['getStyleStats'];
58
+ downloadMapboxStyle: StyleManagement['downloadMapboxStyle'];
59
+ downloadMapLibreStyle: StyleManagement['downloadMapLibreStyle'];
60
+ downloadStyleWithAutoDetection: StyleManagement['downloadStyleWithAutoDetection'];
61
+ cleanupOldStyles: StyleManagement['cleanupOldStyles'];
62
+ constructor(overrides?: OfflineManagerServiceOverrides);
63
+ getServices(): OfflineManagerServices;
64
+ getModules(): OfflineMapManagerModules;
65
+ }
66
+ export declare const createOfflineMapManager: (overrides?: OfflineManagerServiceOverrides) => {
67
+ services: OfflineManagerServices;
68
+ modules: OfflineMapManagerModules;
69
+ };
70
+ export type { OfflineManagerServices, OfflineManagerServiceOverrides } from './base';
71
+ export type { OfflineMapManagerModules } from './modules';
72
+ export { createOfflineMapManagerModules } from './modules';
@@ -0,0 +1,13 @@
1
+ import type { MaintenanceOptions, MaintenanceResults } from '../../types';
2
+ import type { OfflineManagerServices } from './base';
3
+ import type { CleanupManagement } from './cleanupManagement';
4
+ import type { RegionManagement } from './regionManagement';
5
+ import type { AnalyticsManagement } from './analyticsManagement';
6
+ export interface MaintenanceManagement {
7
+ performCompleteMaintenance(options?: MaintenanceOptions): Promise<MaintenanceResults>;
8
+ }
9
+ export declare const createMaintenanceManagement: (services: OfflineManagerServices, deps: {
10
+ performSmartCleanup: CleanupManagement["performSmartCleanup"];
11
+ listRegions: RegionManagement["listRegions"];
12
+ getComprehensiveStorageAnalytics: AnalyticsManagement["getComprehensiveStorageAnalytics"];
13
+ }) => MaintenanceManagement;
@@ -0,0 +1,10 @@
1
+ import type { OfflineManagerServices } from './base';
2
+ import { type RegionManagement } from './regionManagement';
3
+ import { type CleanupManagement } from './cleanupManagement';
4
+ import { type ResourceManagement } from './resourceManagement';
5
+ import { type AnalyticsManagement } from './analyticsManagement';
6
+ import { type MaintenanceManagement } from './maintenanceManagement';
7
+ import { type ImportExportManagement } from './importExportManagement';
8
+ import { type StyleManagement } from './styleManagement';
9
+ export type OfflineMapManagerModules = RegionManagement & CleanupManagement & ResourceManagement & AnalyticsManagement & MaintenanceManagement & ImportExportManagement & StyleManagement;
10
+ export declare const createOfflineMapManagerModules: (services: OfflineManagerServices) => OfflineMapManagerModules;
@@ -0,0 +1,11 @@
1
+ import type { OfflineRegionOptions, StoredRegion } from '../../types';
2
+ import type { OfflineManagerServices } from './base';
3
+ export interface RegionManagement {
4
+ addRegion(region: OfflineRegionOptions): Promise<void>;
5
+ loadRegion(region: OfflineRegionOptions): Promise<void>;
6
+ deleteRegion(regionId: string): Promise<void>;
7
+ listRegions(): Promise<OfflineRegionOptions[]>;
8
+ listStoredRegions(): Promise<StoredRegion[]>;
9
+ getStoredRegion(regionId: string): Promise<StoredRegion | null>;
10
+ }
11
+ export declare const createRegionManagement: (services: OfflineManagerServices) => RegionManagement;
@@ -0,0 +1,24 @@
1
+ import type { ResourceService } from '../../services/resourceService';
2
+ import type { OfflineManagerServices } from './base';
3
+ export type ResourceServiceMethod<TMethod extends keyof ResourceService> = ResourceService[TMethod];
4
+ export interface ResourceManagement {
5
+ downloadTilesWithOptions: ResourceService['downloadTilesWithOptions'];
6
+ getTileStatistics: ResourceService['getTileStatistics'];
7
+ downloadFontsWithOptions: ResourceService['downloadFontsWithOptions'];
8
+ getFontStatistics: ResourceService['getFontStatistics'];
9
+ getFontAnalytics: ResourceService['getFontAnalytics'];
10
+ cleanupOldFonts: ResourceService['cleanupOldFonts'];
11
+ verifyAndRepairFonts: ResourceService['verifyAndRepairFonts'];
12
+ downloadSpritesWithOptions: ResourceService['downloadSpritesWithOptions'];
13
+ getSpriteStatistics: ResourceService['getSpriteStatistics'];
14
+ cleanupOldSprites: ResourceService['cleanupOldSprites'];
15
+ verifyAndRepairSprites: ResourceService['verifyAndRepairSprites'];
16
+ getSpriteAnalytics: ResourceService['getSpriteAnalytics'];
17
+ downloadGlyphsWithOptions: ResourceService['downloadGlyphsWithOptions'];
18
+ getGlyphStatistics: ResourceService['getGlyphStatistics'];
19
+ getGlyphAnalytics: ResourceService['getGlyphAnalytics'];
20
+ loadGlyphsForStyle: ResourceService['loadGlyphsForStyle'];
21
+ cleanupOldGlyphs: ResourceService['cleanupOldGlyphs'];
22
+ verifyAndRepairGlyphs: ResourceService['verifyAndRepairGlyphs'];
23
+ }
24
+ export declare const createResourceManagement: (services: OfflineManagerServices) => ResourceManagement;
@@ -0,0 +1,17 @@
1
+ import type { EnhancedStyleStats, StyleDownloadOptions, StyleDownloadResult, StyleEntry, StyleProvider } from '../../types';
2
+ export interface StyleManagement {
3
+ downloadStyle(styleUrl: string, options?: StyleDownloadOptions & {
4
+ provider?: StyleProvider;
5
+ accessToken?: string;
6
+ forceProvider?: boolean;
7
+ }): Promise<StyleDownloadResult>;
8
+ loadStyleById(styleId: string): Promise<StyleEntry | null>;
9
+ listStyles(): Promise<StyleEntry[]>;
10
+ deleteStyle(styleId: string): Promise<void>;
11
+ getStyleStats(styleId: string): Promise<EnhancedStyleStats>;
12
+ downloadMapboxStyle(styleUrl: string, accessToken?: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
13
+ downloadMapLibreStyle(styleUrl: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
14
+ downloadStyleWithAutoDetection(styleUrl: string, options?: StyleDownloadOptions): Promise<StyleDownloadResult>;
15
+ cleanupOldStyles(maxAgeDays?: number): Promise<number>;
16
+ }
17
+ export declare const createStyleManagement: () => StyleManagement;
@@ -0,0 +1,2 @@
1
+ export { OfflineMapManager, createOfflineMapManager, createOfflineMapManagerModules, } from './offlineMapManager/index';
2
+ export type { OfflineManagerServices, OfflineManagerServiceOverrides, OfflineMapManagerModules, } from './offlineMapManager/index';
@@ -0,0 +1,10 @@
1
+ import { EnhancedGlyphStats } from './glyphService';
2
+ import type { RegionAnalytics, TileStats, StorageAnalyticsReport, EnhancedFontStats, EnhancedSpriteStats } from '../types/';
3
+ export declare class AnalyticsService {
4
+ getAllTileStats(): Promise<TileStats>;
5
+ getAllFontStats(): Promise<EnhancedFontStats>;
6
+ getAllSpriteStats(): Promise<EnhancedSpriteStats>;
7
+ getAllGlyphStats(): Promise<EnhancedGlyphStats>;
8
+ getComprehensiveStorageAnalytics(getRegionAnalytics: () => Promise<RegionAnalytics>): Promise<StorageAnalyticsReport>;
9
+ private generateStorageRecommendations;
10
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Base class for download services
3
+ * Provides common functionality for tile, glyph, sprite, and font downloads
4
+ */
5
+ import type { DownloadProgress } from '../types';
6
+ /**
7
+ * Base options for all download services
8
+ */
9
+ export interface BaseDownloadOptions {
10
+ /** Progress callback */
11
+ onProgress?: (progress: DownloadProgress) => void;
12
+ /** Number of items to process concurrently */
13
+ batchSize?: number;
14
+ /** Maximum retry attempts */
15
+ maxRetries?: number;
16
+ /** Skip items that already exist */
17
+ skipExisting?: boolean;
18
+ /** Request timeout in milliseconds */
19
+ timeout?: number;
20
+ /** Delay between retries in milliseconds */
21
+ retryDelay?: number;
22
+ /** Check storage quota before download */
23
+ storageQuotaCheck?: boolean;
24
+ }
25
+ /**
26
+ * Base result for all download operations
27
+ */
28
+ export interface BaseDownloadResult {
29
+ /** Total items in download plan */
30
+ total: number;
31
+ /** Successfully downloaded items */
32
+ downloaded: number;
33
+ /** Items skipped (already exist) */
34
+ skipped: number;
35
+ /** Failed downloads */
36
+ failed: number;
37
+ /** Total size in bytes */
38
+ totalSize: number;
39
+ /** Download duration in milliseconds */
40
+ downloadTime: number;
41
+ /** Average download speed in KB/s */
42
+ averageSpeed: number;
43
+ /** Error details */
44
+ errors: Array<{
45
+ url: string;
46
+ error: string;
47
+ }>;
48
+ }
49
+ /**
50
+ * Base download service with common functionality
51
+ */
52
+ export declare abstract class BaseDownloadService {
53
+ protected abstract serviceName: string;
54
+ /**
55
+ * Get a scoped logger for this service
56
+ */
57
+ protected getLogger(): import("..").ScopedLogger;
58
+ /**
59
+ * Check storage quota before download
60
+ * @param requiredSpace - Estimated space needed in bytes
61
+ * @throws Error if insufficient space
62
+ */
63
+ protected checkStorageQuota(requiredSpace?: number): Promise<void>;
64
+ /**
65
+ * Calculate average speed in KB/s
66
+ */
67
+ protected calculateSpeed(bytes: number, milliseconds: number): number;
68
+ /**
69
+ * Create a standardized error object
70
+ */
71
+ protected createError(url: string, error: unknown): {
72
+ url: string;
73
+ error: string;
74
+ };
75
+ /**
76
+ * Sleep for a specified duration
77
+ */
78
+ protected sleep(ms: number): Promise<void>;
79
+ /**
80
+ * Track download statistics
81
+ */
82
+ protected createStatsTracker(): {
83
+ trackItem(name: string, size: number, type?: string): void;
84
+ getStats(): {
85
+ largest: {
86
+ name: string;
87
+ size: number;
88
+ } | undefined;
89
+ smallest: {
90
+ name: string;
91
+ size: number;
92
+ } | undefined;
93
+ byType: Record<string, number>;
94
+ };
95
+ };
96
+ }
@@ -0,0 +1,34 @@
1
+ import type { StoredRegion, RegionCleanupOptions, CleanupResult, RegionAnalytics } from '../types';
2
+ export declare class CleanupService {
3
+ private db;
4
+ private deleteRegionCallback;
5
+ private autoCleanupIntervals;
6
+ constructor(deleteRegionCallback: (regionId: string, styleId?: string) => Promise<void>);
7
+ runCleanup(options?: RegionCleanupOptions): Promise<CleanupResult>;
8
+ performCleanup(options?: RegionCleanupOptions): Promise<CleanupResult>;
9
+ getRegionAnalytics(): Promise<RegionAnalytics>;
10
+ setupAutoCleanup(options?: RegionCleanupOptions & {
11
+ intervalHours?: number;
12
+ }): Promise<string>;
13
+ stopAutoCleanup(cleanupId?: string): Promise<void>;
14
+ optimizeStorage(): Promise<{
15
+ compactedSize: number;
16
+ freedSpace: number;
17
+ }>;
18
+ getAllRegions(): Promise<StoredRegion[]>;
19
+ getRegionSize(regionId: string): Promise<number>;
20
+ private calculateTotalStorageSize;
21
+ private selectRegionsForDeletion;
22
+ private generateRecommendations;
23
+ }
24
+ export declare const cleanupService: CleanupService;
25
+ export declare const performCleanup: (options?: RegionCleanupOptions) => Promise<CleanupResult>;
26
+ export declare const getRegionAnalytics: () => Promise<RegionAnalytics>;
27
+ export declare const setupAutoCleanup: (options?: RegionCleanupOptions & {
28
+ intervalHours?: number;
29
+ }) => Promise<string>;
30
+ export declare const stopAutoCleanup: (cleanupId?: string) => Promise<void>;
31
+ export declare const optimizeStorage: () => Promise<{
32
+ compactedSize: number;
33
+ freedSpace: number;
34
+ }>;
@@ -0,0 +1,26 @@
1
+ import type { EnhancedFontStats, FontDownloadOptions, FontDownloadResult } from '../types';
2
+ export declare class FontService {
3
+ private db;
4
+ downloadFonts(fontUrls: string[], styleName?: string, options?: FontDownloadOptions): Promise<FontDownloadResult>;
5
+ getFontStats(): Promise<EnhancedFontStats>;
6
+ getFontAnalytics(): Promise<Record<string, unknown>>;
7
+ cleanupOldFonts(maxAge?: number): Promise<number>;
8
+ verifyAndRepairFonts(): Promise<{
9
+ verified: number;
10
+ repaired: number;
11
+ removed: number;
12
+ }>;
13
+ private createFontKey;
14
+ private detectFontType;
15
+ private validateFont;
16
+ }
17
+ export declare const fontService: FontService;
18
+ export declare const downloadFonts: (fontUrls: string[], styleName?: string, options?: FontDownloadOptions) => Promise<FontDownloadResult>;
19
+ export declare const getFontStats: () => Promise<EnhancedFontStats>;
20
+ export declare const getFontAnalytics: () => Promise<Record<string, unknown>>;
21
+ export declare const cleanupOldFonts: (maxAge?: number) => Promise<number>;
22
+ export declare const verifyAndRepairFonts: () => Promise<{
23
+ verified: number;
24
+ repaired: number;
25
+ removed: number;
26
+ }>;
@@ -0,0 +1,58 @@
1
+ import type { GlyphDownloadOptions, GlyphDownloadResult, GlyphEntry, GlyphRange } from '../types';
2
+ export interface EnhancedGlyphStats {
3
+ count: number;
4
+ totalSize: number;
5
+ averageSize: number;
6
+ glyphs: Array<{
7
+ fontstack: string;
8
+ range: string;
9
+ size: number;
10
+ lastModified: number;
11
+ metadata?: Record<string, unknown>;
12
+ }>;
13
+ fontsByStack: Record<string, number>;
14
+ sizeByStack: Record<string, number>;
15
+ oldestGlyph?: {
16
+ fontstack: string;
17
+ range: string;
18
+ lastModified: number;
19
+ };
20
+ newestGlyph?: {
21
+ fontstack: string;
22
+ range: string;
23
+ lastModified: number;
24
+ };
25
+ corruptedGlyphs: string[];
26
+ }
27
+ export declare class GlyphService {
28
+ private db;
29
+ downloadGlyphs(glyphUrl: string, fontstacks: string[], styleName?: string, ranges?: string[], options?: GlyphDownloadOptions): Promise<GlyphDownloadResult>;
30
+ loadGlyphs(fontstack: string, ranges: string[], styleName?: string): Promise<GlyphRange[]>;
31
+ getGlyph(fontstack: string, range: string, styleName?: string): Promise<GlyphEntry | null>;
32
+ getGlyphStats(): Promise<EnhancedGlyphStats>;
33
+ getGlyphAnalytics(): Promise<Record<string, unknown>>;
34
+ cleanupOldGlyphs(maxAge?: number): Promise<number>;
35
+ verifyAndRepairGlyphs(): Promise<{
36
+ verified: number;
37
+ repaired: number;
38
+ removed: number;
39
+ }>;
40
+ private validateGlyphData;
41
+ private countGlyphsInData;
42
+ private calculateCompressionRatio;
43
+ private normalizeFontstack;
44
+ private buildGlyphPath;
45
+ private parseGlyphKey;
46
+ private createGlyphKey;
47
+ }
48
+ export declare const glyphService: GlyphService;
49
+ export declare const downloadGlyphs: (glyphUrl: string, fontstacks: string[], styleName?: string, ranges?: string[], options?: GlyphDownloadOptions) => Promise<GlyphDownloadResult>;
50
+ export declare const loadGlyphs: (fontstack: string, ranges: string[], styleName?: string) => Promise<GlyphRange[]>;
51
+ export declare const getGlyphStats: () => Promise<EnhancedGlyphStats>;
52
+ export declare const getGlyphAnalytics: () => Promise<Record<string, unknown>>;
53
+ export declare const cleanupOldGlyphs: (maxAge?: number) => Promise<number>;
54
+ export declare const verifyAndRepairGlyphs: () => Promise<{
55
+ verified: number;
56
+ repaired: number;
57
+ removed: number;
58
+ }>;
@@ -0,0 +1,57 @@
1
+ import type { RegionImportData, ImportExportOptions, ImportResult, ExportResult, PMTilesExportOptions, MBTilesExportOptions } from '../types';
2
+ export declare class ImportExportService {
3
+ private db;
4
+ constructor();
5
+ /**
6
+ * Export a region to JSON format
7
+ */
8
+ exportRegionAsJSON(regionId: string, options?: ImportExportOptions): Promise<ExportResult>;
9
+ /**
10
+ * Export region as PMTiles format
11
+ */
12
+ exportRegionAsPMTiles(regionId: string, options?: ImportExportOptions & PMTilesExportOptions): Promise<ExportResult>;
13
+ /**
14
+ * Export region as MBTiles format
15
+ */
16
+ exportRegionAsMBTiles(regionId: string, options?: ImportExportOptions & MBTilesExportOptions): Promise<ExportResult>;
17
+ /**
18
+ * Import region from file
19
+ */
20
+ importRegion(importData: RegionImportData): Promise<ImportResult>;
21
+ /**
22
+ * Get region metadata
23
+ */
24
+ private getRegionMetadata;
25
+ /**
26
+ * Export style data
27
+ */
28
+ private exportStyle;
29
+ /**
30
+ * Export tiles data
31
+ */
32
+ private exportTiles;
33
+ /**
34
+ * Export sprites data
35
+ */
36
+ private exportSprites;
37
+ /**
38
+ * Export fonts data
39
+ */
40
+ private exportFonts;
41
+ /**
42
+ * Read file content
43
+ */
44
+ private readFileContent;
45
+ /**
46
+ * Parse PMTiles file (simplified)
47
+ */
48
+ private parsePMTiles;
49
+ /**
50
+ * Parse MBTiles file (simplified)
51
+ */
52
+ private parseMBTiles;
53
+ /**
54
+ * Import region data to database
55
+ */
56
+ private importRegionData;
57
+ }
@@ -0,0 +1,15 @@
1
+ import type { StorageAnalyticsReport, MaintenanceOptions, MaintenanceResults, RegionCleanupOptions, CleanupResult } from '../types';
2
+ export type { MaintenanceOptions, MaintenanceResults } from '../types/maintenance';
3
+ export declare class MaintenanceService {
4
+ private performSmartCleanup;
5
+ private listRegions;
6
+ private verifyAndRepairFonts;
7
+ private verifyAndRepairSprites;
8
+ private verifyAndRepairGlyphs;
9
+ private cleanupOldFonts;
10
+ private cleanupOldSprites;
11
+ private cleanupOldGlyphs;
12
+ private getComprehensiveStorageAnalytics;
13
+ constructor(performSmartCleanup: (options?: RegionCleanupOptions) => Promise<CleanupResult>, listRegions: () => Promise<unknown[]>, verifyAndRepairFonts: (styleId: string, options?: Record<string, unknown>) => Promise<unknown>, verifyAndRepairSprites: (styleId: string, options?: Record<string, unknown>) => Promise<unknown>, verifyAndRepairGlyphs: (styleId: string, options?: Record<string, unknown>) => Promise<unknown>, cleanupOldFonts: (options?: Record<string, unknown>) => Promise<unknown>, cleanupOldSprites: (styleId: string, options?: Record<string, unknown>) => Promise<unknown>, cleanupOldGlyphs: (options?: Record<string, unknown>) => Promise<unknown>, getComprehensiveStorageAnalytics: () => Promise<StorageAnalyticsReport>);
14
+ performCompleteMaintenance(options?: MaintenanceOptions): Promise<MaintenanceResults>;
15
+ }
@@ -0,0 +1,31 @@
1
+ import type { OfflineRegionOptions, StoredRegion } from '../types/region';
2
+ export declare class RegionService {
3
+ /**
4
+ * Check if a tile overlaps with any region bounds
5
+ */
6
+ private tileOverlapsWithRegion;
7
+ /**
8
+ * Check if a tile overlaps with any of the given regions
9
+ */
10
+ private tileOverlapsWithAnyRegion;
11
+ /**
12
+ * Delete tiles that don't overlap with any remaining regions
13
+ */
14
+ private deleteNonOverlappingTiles;
15
+ /**
16
+ * Delete all resources for a style (fonts, glyphs, sprites)
17
+ */
18
+ private deleteStyleResources;
19
+ /**
20
+ * Delete all tiles for a style
21
+ */
22
+ private deleteAllStyleTiles;
23
+ addRegion(region: OfflineRegionOptions): Promise<void>;
24
+ loadRegion(region: OfflineRegionOptions): Promise<void>;
25
+ deleteRegion(regionId: string): Promise<void>;
26
+ listRegions(): Promise<OfflineRegionOptions[]>;
27
+ /**
28
+ * List all stored regions from styles (used for UI and fitBounds)
29
+ */
30
+ listStoredRegions(): Promise<StoredRegion[]>;
31
+ }
@@ -0,0 +1,42 @@
1
+ import { EnhancedGlyphStats } from './glyphService';
2
+ import type { OfflineRegionOptions, MapboxStyle, TileDownloadOptions, TileDownloadResult, TileStats, SpriteDownloadOptions, SpriteDownloadResult, EnhancedSpriteStats, FontDownloadOptions, FontDownloadResult, EnhancedFontStats, GlyphDownloadOptions, GlyphDownloadResult } from '../types';
3
+ export declare class ResourceService {
4
+ downloadTilesWithOptions(region: OfflineRegionOptions, style: MapboxStyle, styleId: string, options?: TileDownloadOptions): Promise<TileDownloadResult>;
5
+ getTileStatistics(styleId?: string): Promise<TileStats>;
6
+ getTileAnalytics(styleId?: string): Promise<Record<string, unknown>>;
7
+ cleanupOldTiles(maxAge?: number, styleId?: string): Promise<number>;
8
+ downloadFontsWithOptions(fontUrls: string[], downloadId?: string, options?: FontDownloadOptions): Promise<FontDownloadResult>;
9
+ getFontStatistics(): Promise<EnhancedFontStats>;
10
+ getFontAnalytics(): Promise<Record<string, unknown>>;
11
+ cleanupOldFonts(styleId?: string, options?: {
12
+ maxAge?: number;
13
+ }): Promise<number>;
14
+ verifyAndRepairFonts(): Promise<{
15
+ verified: number;
16
+ repaired: number;
17
+ removed: number;
18
+ }>;
19
+ downloadSpritesWithOptions(spriteUrls: string[], styleName: string, options?: SpriteDownloadOptions): Promise<SpriteDownloadResult>;
20
+ getSpriteStatistics(): Promise<EnhancedSpriteStats>;
21
+ getSpriteAnalytics(): Promise<Record<string, unknown>>;
22
+ cleanupOldSprites(styleId?: string, options?: {
23
+ maxAge?: number;
24
+ }): Promise<number>;
25
+ verifyAndRepairSprites(): Promise<{
26
+ verified: number;
27
+ repaired: number;
28
+ removed: number;
29
+ }>;
30
+ downloadGlyphsWithOptions(glyphUrl: string, fontstacks: string[], styleName: string, ranges?: string[], options?: GlyphDownloadOptions): Promise<GlyphDownloadResult>;
31
+ getGlyphStatistics(): Promise<EnhancedGlyphStats>;
32
+ getGlyphAnalytics(): Promise<Record<string, unknown>>;
33
+ loadGlyphsForStyle(fontstack: string, ranges: string[], styleId?: string): Promise<import("..").GlyphRange[]>;
34
+ cleanupOldGlyphs(styleId?: string, options?: {
35
+ maxAge?: number;
36
+ }): Promise<number>;
37
+ verifyAndRepairGlyphs(): Promise<{
38
+ verified: number;
39
+ repaired: number;
40
+ removed: number;
41
+ }>;
42
+ }
@@ -0,0 +1,30 @@
1
+ import type { EnhancedSpriteStats, SpriteDownloadOptions, SpriteDownloadResult } from '../types';
2
+ export declare class SpriteService {
3
+ private db;
4
+ downloadSprites(spriteUrls: string[], styleName: string, options?: SpriteDownloadOptions): Promise<SpriteDownloadResult>;
5
+ getSpriteStats(): Promise<EnhancedSpriteStats>;
6
+ getSpriteAnalytics(): Promise<Record<string, unknown>>;
7
+ cleanupOldSprites(maxAge?: number): Promise<number>;
8
+ verifyAndRepairSprites(): Promise<{
9
+ verified: number;
10
+ repaired: number;
11
+ removed: number;
12
+ }>;
13
+ private createSpriteKey;
14
+ private extractSpriteName;
15
+ private detectSpriteType;
16
+ private validateSprite;
17
+ private extractSpriteMetadata;
18
+ private isProbablySpritesheet;
19
+ private rateLimitDelay;
20
+ }
21
+ export declare const spriteService: SpriteService;
22
+ export declare const downloadSprites: (spriteUrls: string[], styleName: string, options?: SpriteDownloadOptions) => Promise<SpriteDownloadResult>;
23
+ export declare const getSpriteStats: () => Promise<EnhancedSpriteStats>;
24
+ export declare const getSpriteAnalytics: () => Promise<Record<string, unknown>>;
25
+ export declare const cleanupOldSprites: (maxAge?: number) => Promise<number>;
26
+ export declare const verifyAndRepairSprites: () => Promise<{
27
+ verified: number;
28
+ repaired: number;
29
+ removed: number;
30
+ }>;