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
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Application-wide constants
3
+ * Centralizes magic numbers and configuration values
4
+ */
5
+ export declare const DB_NAME = "offline-map-db";
6
+ export declare const DB_VERSION = 2;
7
+ export declare const STORE_NAMES: {
8
+ readonly REGIONS: "regions";
9
+ readonly TILES: "tiles";
10
+ readonly STYLES: "styles";
11
+ readonly SPRITES: "sprites";
12
+ readonly GLYPHS: "glyphs";
13
+ readonly FONTS: "fonts";
14
+ };
15
+ export declare const DOWNLOAD_DEFAULTS: {
16
+ readonly BATCH_SIZE: 10;
17
+ readonly MAX_CONCURRENCY: 5;
18
+ readonly MAX_RETRIES: 3;
19
+ readonly TIMEOUT: 10000;
20
+ readonly RETRY_DELAY: 1000;
21
+ };
22
+ export declare const TILE_CONFIG: {
23
+ readonly MIN_ZOOM: 0;
24
+ readonly MAX_ZOOM: 24;
25
+ readonly DEFAULT_EXTENSION: "pbf";
26
+ readonly SUPPORTED_EXTENSIONS: readonly ["pbf", "mvt", "png", "jpg", "jpeg", "webp"];
27
+ };
28
+ export declare const GLYPH_CONFIG: {
29
+ readonly DEFAULT_RANGES: readonly ["0-255"];
30
+ readonly COMPREHENSIVE_RANGES: readonly ["0-255", "256-511", "512-767", "768-1023", "1024-1279", "1280-1535", "1536-1791", "1792-2047", "2048-2303", "2304-2559", "2560-2815", "2816-3071", "3072-3327", "3328-3583", "3584-3839", "3840-4095", "4096-4351", "4352-4607", "4608-4863", "11904-12031", "12032-12255", "12288-12543", "12544-12799", "19968-20223", "20224-20479", "40960-42127", "44032-55203", "63744-64255", "65280-65535"];
31
+ };
32
+ export declare const STORAGE_CONFIG: {
33
+ readonly DEFAULT_EXPIRY: number;
34
+ readonly MIN_AVAILABLE_SPACE: number;
35
+ readonly WARNING_THRESHOLD: 0.9;
36
+ };
37
+ export declare const CONTENT_TYPES: {
38
+ readonly VECTOR_TILE: "application/vnd.mapbox-vector-tile";
39
+ readonly PROTOBUF: "application/x-protobuf";
40
+ readonly JSON: "application/json";
41
+ readonly PNG: "image/png";
42
+ readonly JPEG: "image/jpeg";
43
+ readonly WEBP: "image/webp";
44
+ };
45
+ export declare const URL_SCHEMES: {
46
+ readonly IDB: "idb://";
47
+ readonly HTTP: "http://";
48
+ readonly HTTPS: "https://";
49
+ };
50
+ export declare const GZIP_MAGIC_BYTES: {
51
+ readonly FIRST: 31;
52
+ readonly SECOND: 139;
53
+ };
54
+ export declare const RESOURCE_TYPES: {
55
+ readonly TILE: "tile";
56
+ readonly GLYPH: "glyph";
57
+ readonly SPRITE: "sprite";
58
+ readonly FONT: "font";
59
+ readonly STYLE: "style";
60
+ readonly TILEJSON: "tilesjson";
61
+ };
62
+ export declare const MAP_PROVIDERS: {
63
+ readonly AUTO: "auto";
64
+ readonly MAPBOX: "mapbox";
65
+ readonly MAPLIBRE: "maplibre";
66
+ readonly CARTO: "carto";
67
+ readonly MAPTILER: "maptiler";
68
+ };
69
+ export declare const VALIDATION_PATTERNS: {
70
+ readonly TILE_URL: RegExp;
71
+ readonly STYLE_ID: RegExp;
72
+ readonly REGION_ID: RegExp;
73
+ };
74
+ export declare const ERROR_MESSAGES: {
75
+ readonly NO_STYLE: "Style must be downloaded before adding a region";
76
+ readonly NO_STYLE_ID: "No style ID found for region";
77
+ readonly NO_STYLE_URL: "Region must have a styleUrl";
78
+ readonly INVALID_BOUNDS: "Invalid bounds specified";
79
+ readonly INVALID_ZOOM: "Invalid zoom levels specified";
80
+ readonly INSUFFICIENT_STORAGE: "Insufficient storage space for download";
81
+ readonly TILE_VALIDATION_FAILED: "Tile validation failed";
82
+ readonly NETWORK_ERROR: "Network error occurred during download";
83
+ };
84
+ export declare const SUCCESS_MESSAGES: {
85
+ readonly TILES_DOWNLOADED: "Tiles downloaded successfully";
86
+ readonly STYLE_DOWNLOADED: "Style downloaded successfully";
87
+ readonly REGION_ADDED: "Region added successfully";
88
+ readonly REGION_DELETED: "Region deleted successfully";
89
+ readonly CLEANUP_COMPLETE: "Cleanup completed successfully";
90
+ };
91
+ export type StoreName = (typeof STORE_NAMES)[keyof typeof STORE_NAMES];
92
+ export type TileExtension = (typeof TILE_CONFIG.SUPPORTED_EXTENSIONS)[number];
93
+ export type ResourceType = (typeof RESOURCE_TYPES)[keyof typeof RESOURCE_TYPES];
94
+ export type MapProvider = (typeof MAP_PROVIDERS)[keyof typeof MAP_PROVIDERS];
@@ -0,0 +1,52 @@
1
+ import type { DownloadProgress } from '@/types';
2
+ export type FetchResourceResult = {
3
+ type: 'json';
4
+ data: unknown;
5
+ contentType: string;
6
+ contentEncoding?: string;
7
+ } | {
8
+ type: 'image' | 'pbf' | 'other';
9
+ data: ArrayBuffer;
10
+ contentType: string;
11
+ contentEncoding?: string;
12
+ };
13
+ export declare function fetchResource(url: string): Promise<{
14
+ type: 'image' | 'pbf';
15
+ data: ArrayBuffer;
16
+ }>;
17
+ /**
18
+ * Enhanced fetch with retry logic and timeout
19
+ */
20
+ export declare function fetchResourceWithRetry(url: string, options?: {
21
+ retries?: number;
22
+ retryDelay?: number;
23
+ timeout?: number;
24
+ }): Promise<FetchResourceResult>;
25
+ /**
26
+ * Enhanced fetch with retry logic and timeout that returns Response object
27
+ */
28
+ export declare function fetchWithRetry(url: string, options?: {
29
+ retries?: number;
30
+ retryDelay?: number;
31
+ timeout?: number;
32
+ }): Promise<Response>;
33
+ /**
34
+ * Process items in batches with concurrency control
35
+ */
36
+ export declare function processBatch<T, R>(items: T[], processor: (item: T) => Promise<R>, options?: {
37
+ batchSize?: number;
38
+ onProgress?: (completed: number, total: number) => void;
39
+ onError?: (error: Error, item: T) => void;
40
+ }): Promise<R[]>;
41
+ /**
42
+ * Create a progress tracker
43
+ */
44
+ export declare function createProgressTracker(total: number): {
45
+ progress: DownloadProgress;
46
+ update: (increment?: number, currentItem?: string, error?: string) => void;
47
+ getProgress: () => DownloadProgress;
48
+ };
49
+ /**
50
+ * Validate resource data
51
+ */
52
+ export declare function validateResource(data: ArrayBuffer, type: string): boolean;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Error handling utilities
3
+ * Provides consistent error handling patterns across the application
4
+ */
5
+ /**
6
+ * Error types for categorization
7
+ */
8
+ export declare enum ErrorType {
9
+ /** Network-related errors */
10
+ NETWORK = "NETWORK",
11
+ /** Storage/IndexedDB errors */
12
+ STORAGE = "STORAGE",
13
+ /** Validation errors */
14
+ VALIDATION = "VALIDATION",
15
+ /** Parsing/Format errors */
16
+ PARSE = "PARSE",
17
+ /** Quota exceeded errors */
18
+ QUOTA = "QUOTA",
19
+ /** Unknown errors */
20
+ UNKNOWN = "UNKNOWN"
21
+ }
22
+ /**
23
+ * Categorized error with additional context
24
+ */
25
+ export declare class CategorizedError extends Error {
26
+ readonly type: ErrorType;
27
+ readonly originalError?: unknown | undefined;
28
+ readonly context?: Record<string, unknown> | undefined;
29
+ constructor(message: string, type: ErrorType, originalError?: unknown | undefined, context?: Record<string, unknown> | undefined);
30
+ }
31
+ /**
32
+ * Categorize an error based on its properties
33
+ */
34
+ export declare function categorizeError(error: unknown): ErrorType;
35
+ /**
36
+ * Get user-friendly error message based on error type
37
+ */
38
+ export declare function getUserErrorMessage(error: unknown): string;
39
+ /**
40
+ * Safely execute a function and return a result or error
41
+ */
42
+ export declare function safeExecute<T>(fn: () => Promise<T>, context?: string): Promise<{
43
+ success: true;
44
+ data: T;
45
+ } | {
46
+ success: false;
47
+ error: CategorizedError;
48
+ }>;
49
+ /**
50
+ * Log error with appropriate level based on error type
51
+ */
52
+ export declare function logError(error: unknown, context?: string): void;
53
+ /**
54
+ * Check if error is retryable
55
+ */
56
+ export declare function isRetryableError(error: unknown): boolean;
57
+ /**
58
+ * Aggregate multiple errors into a summary
59
+ */
60
+ export declare function aggregateErrors(errors: Array<{
61
+ url: string;
62
+ error: string;
63
+ }>): {
64
+ total: number;
65
+ byType: Record<ErrorType, number>;
66
+ summary: string;
67
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Formats bytes to human readable format
3
+ */
4
+ export declare function formatBytes(bytes: number, decimals?: number): string;
5
+ /**
6
+ * Formats a timestamp to a readable date string
7
+ */
8
+ export declare function formatDate(timestamp: number): string;
9
+ /**
10
+ * Formats a duration in milliseconds to human readable format
11
+ */
12
+ export declare function formatDuration(ms: number): string;
13
+ /**
14
+ * Calculates percentage with proper formatting
15
+ */
16
+ export declare function formatPercentage(value: number, total: number, decimals?: number): string;
17
+ /**
18
+ * Formats a number with commas for thousands separator
19
+ */
20
+ export declare function formatNumber(num: number): string;
21
+ /**
22
+ * Truncates text to specified length with ellipsis
23
+ */
24
+ export declare function truncateText(text: string, maxLength: number): string;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Formatting utilities for the offline manager
3
+ */
4
+ /**
5
+ * Format bytes to human readable string
6
+ */
7
+ export declare function formatBytes(bytes: number): string;
8
+ /**
9
+ * Format date to human readable string
10
+ */
11
+ export declare function formatDate(date: number | Date): string;
12
+ /**
13
+ * Format date and time to human readable string
14
+ */
15
+ export declare function formatDateTime(timestamp: number): string;
16
+ /**
17
+ * Format duration in milliseconds to human readable string
18
+ */
19
+ export declare function formatDuration(milliseconds: number): string;
20
+ /**
21
+ * Format number with thousands separator
22
+ */
23
+ export declare function formatNumber(num: number): string;
24
+ /**
25
+ * Format percentage
26
+ */
27
+ export declare function formatPercentage(value: number, total: number): string;
28
+ /**
29
+ * Format coordinates to a readable string
30
+ */
31
+ export declare function formatCoordinates(bounds: [[number, number], [number, number]]): string;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Tabler Icons utility for the offline map manager
3
+ * Provides consistent icon usage throughout the application using inline SVG strings
4
+ */
5
+ /**
6
+ * Configuration for icon rendering
7
+ */
8
+ interface IconConfig {
9
+ size?: number;
10
+ color?: string;
11
+ className?: string;
12
+ style?: string;
13
+ }
14
+ /**
15
+ * Available icons in the application
16
+ */
17
+ export declare const icons: {
18
+ mapPin: (config?: IconConfig) => string;
19
+ focus: (config?: IconConfig) => string;
20
+ download: (config?: IconConfig) => string;
21
+ trash: (config?: IconConfig) => string;
22
+ eye: (config?: IconConfig) => string;
23
+ refresh: (config?: IconConfig) => string;
24
+ cleaning: (config?: IconConfig) => string;
25
+ plus: (config?: IconConfig) => string;
26
+ x: (config?: IconConfig) => string;
27
+ check: (config?: IconConfig) => string;
28
+ checkCircle: (config?: IconConfig) => string;
29
+ alertTriangle: (config?: IconConfig) => string;
30
+ fileText: (config?: IconConfig) => string;
31
+ clock: (config?: IconConfig) => string;
32
+ cloud: (config?: IconConfig) => string;
33
+ deviceMobile: (config?: IconConfig) => string;
34
+ deviceFloppy: (config?: IconConfig) => string;
35
+ settings: (config?: IconConfig) => string;
36
+ map: (config?: IconConfig) => string;
37
+ moon: (config?: IconConfig) => string;
38
+ sun: (config?: IconConfig) => string;
39
+ upload: (config?: IconConfig) => string;
40
+ infoCircle: (config?: IconConfig) => string;
41
+ };
42
+ /**
43
+ * Utility type for icon names
44
+ */
45
+ export type IconName = keyof typeof icons;
46
+ /**
47
+ * Helper function to get an icon by name
48
+ */
49
+ export declare function getIcon(name: IconName, config?: IconConfig): string;
50
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function idbFetchHandler(url: string, init?: RequestInit): Promise<Response>;
2
+ export declare function listTileKeysInIDB(styleId: string, sourceId: string, zoom: number): Promise<string[]>;
@@ -0,0 +1,13 @@
1
+ export * from './asyncUtils';
2
+ export * from './download';
3
+ export * from './formatting';
4
+ export * from './icons';
5
+ export * from './idbFetchHandler';
6
+ export * from './styleProviderUtils';
7
+ export * from './styleUtils';
8
+ export * from './cleanupCompressedTiles';
9
+ export * from './logger';
10
+ export * from './constants';
11
+ export * from './errorHandling';
12
+ export * from './validation';
13
+ export * from './performance';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Centralized logging utility with configurable log levels
3
+ * Following the project guidelines: only console.warn and console.error in production
4
+ */
5
+ export declare enum LogLevel {
6
+ ERROR = 0,
7
+ WARN = 1,
8
+ INFO = 2,
9
+ DEBUG = 3
10
+ }
11
+ declare class Logger {
12
+ private level;
13
+ private isDevelopment;
14
+ setLevel(level: LogLevel): void;
15
+ getLevel(): LogLevel;
16
+ /**
17
+ * Log error messages (always shown)
18
+ */
19
+ error(message: string, ...args: unknown[]): void;
20
+ /**
21
+ * Log warning messages (shown in production)
22
+ */
23
+ warn(message: string, ...args: unknown[]): void;
24
+ /**
25
+ * Log info messages (development only)
26
+ */
27
+ info(message: string, ...args: unknown[]): void;
28
+ /**
29
+ * Log debug messages (development only, verbose)
30
+ */
31
+ debug(message: string, ...args: unknown[]): void;
32
+ /**
33
+ * Log success messages
34
+ */
35
+ success(message: string, ...args: unknown[]): void;
36
+ /**
37
+ * Create a scoped logger with a prefix
38
+ */
39
+ scope(prefix: string): ScopedLogger;
40
+ }
41
+ declare class ScopedLogger {
42
+ private prefix;
43
+ private logger;
44
+ constructor(prefix: string, logger: Logger);
45
+ error(message: string, ...args: unknown[]): void;
46
+ warn(message: string, ...args: unknown[]): void;
47
+ info(message: string, ...args: unknown[]): void;
48
+ debug(message: string, ...args: unknown[]): void;
49
+ success(message: string, ...args: unknown[]): void;
50
+ }
51
+ export declare const logger: Logger;
52
+ export { ScopedLogger };
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Performance monitoring utilities
3
+ * Track and measure application performance
4
+ */
5
+ import { formatBytes, formatDuration } from './formatting';
6
+ export { formatBytes, formatDuration };
7
+ /**
8
+ * Performance metric data
9
+ */
10
+ export interface PerformanceMetric {
11
+ /** Operation name */
12
+ name: string;
13
+ /** Start timestamp in milliseconds */
14
+ startTime: number;
15
+ /** End timestamp in milliseconds */
16
+ endTime?: number;
17
+ /** Duration in milliseconds */
18
+ duration?: number;
19
+ /** Additional metadata */
20
+ metadata?: Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Download performance statistics
24
+ */
25
+ export interface DownloadPerformance {
26
+ /** Total items downloaded */
27
+ totalItems: number;
28
+ /** Total bytes downloaded */
29
+ totalBytes: number;
30
+ /** Total time in milliseconds */
31
+ totalTime: number;
32
+ /** Average download speed in bytes/second */
33
+ averageSpeed: number;
34
+ /** Average time per item in milliseconds */
35
+ averageTimePerItem: number;
36
+ /** Fastest download time in milliseconds */
37
+ fastestItem?: number;
38
+ /** Slowest download time in milliseconds */
39
+ slowestItem?: number;
40
+ /** Success rate percentage */
41
+ successRate: number;
42
+ }
43
+ /**
44
+ * Storage performance monitor
45
+ */
46
+ export interface StorageMetrics {
47
+ /** Current usage in bytes */
48
+ used: number;
49
+ /** Total quota in bytes */
50
+ quota: number;
51
+ /** Usage percentage */
52
+ usagePercentage: number;
53
+ /** Available space in bytes */
54
+ available: number;
55
+ /** Estimated items that can be stored */
56
+ estimatedCapacity?: number;
57
+ }
58
+ /**
59
+ * Performance timer for measuring operation duration
60
+ */
61
+ export declare class PerformanceTimer {
62
+ private metrics;
63
+ /**
64
+ * Start timing an operation
65
+ * @param name - Operation name
66
+ * @param metadata - Optional metadata to store with the metric
67
+ */
68
+ start(name: string, metadata?: Record<string, unknown>): void;
69
+ /**
70
+ * Stop timing an operation and return the duration
71
+ * @param name - Operation name
72
+ * @returns Duration in milliseconds, or undefined if not started
73
+ */
74
+ stop(name: string): number | undefined;
75
+ /**
76
+ * Get a metric by name
77
+ * @param name - Operation name
78
+ * @returns Metric data or undefined
79
+ */
80
+ getMetric(name: string): PerformanceMetric | undefined;
81
+ /**
82
+ * Get all completed metrics
83
+ * @returns Array of completed metrics
84
+ */
85
+ getAllMetrics(): PerformanceMetric[];
86
+ /**
87
+ * Clear all metrics
88
+ */
89
+ clear(): void;
90
+ /**
91
+ * Get summary statistics
92
+ */
93
+ getSummary(): {
94
+ total: number;
95
+ totalDuration: number;
96
+ averageDuration: number;
97
+ fastest: PerformanceMetric | null;
98
+ slowest: PerformanceMetric | null;
99
+ };
100
+ }
101
+ /**
102
+ * Download performance tracker
103
+ */
104
+ export declare class DownloadPerformanceTracker {
105
+ private items;
106
+ /**
107
+ * Record a download
108
+ * @param size - Size in bytes
109
+ * @param time - Time taken in milliseconds
110
+ * @param success - Whether the download succeeded
111
+ */
112
+ recordDownload(size: number, time: number, success?: boolean): void;
113
+ /**
114
+ * Get performance statistics
115
+ */
116
+ getStats(): DownloadPerformance;
117
+ /**
118
+ * Get human-readable speed
119
+ */
120
+ getFormattedSpeed(): string;
121
+ /**
122
+ * Clear all recorded downloads
123
+ */
124
+ clear(): void;
125
+ }
126
+ /**
127
+ * Get current storage metrics
128
+ */
129
+ export declare function getStorageMetrics(): Promise<StorageMetrics>;
130
+ /**
131
+ * Monitor operation performance with automatic timing
132
+ * @param name - Operation name
133
+ * @param operation - Async operation to monitor
134
+ * @param metadata - Optional metadata
135
+ * @returns Operation result and performance metric
136
+ */
137
+ export declare function monitorPerformance<T>(name: string, operation: () => Promise<T>, metadata?: Record<string, unknown>): Promise<{
138
+ result: T;
139
+ metric: PerformanceMetric;
140
+ }>;
141
+ /**
142
+ * Create a rate limiter for controlling request frequency
143
+ */
144
+ export declare class RateLimiter {
145
+ private maxConcurrent;
146
+ private delayMs;
147
+ private queue;
148
+ private activeRequests;
149
+ constructor(maxConcurrent?: number, delayMs?: number);
150
+ /**
151
+ * Execute an operation with rate limiting
152
+ * @param operation - Async operation to execute
153
+ * @returns Operation result
154
+ */
155
+ execute<T>(operation: () => Promise<T>): Promise<T>;
156
+ /**
157
+ * Get current queue length
158
+ */
159
+ getQueueLength(): number;
160
+ /**
161
+ * Get number of active requests
162
+ */
163
+ getActiveCount(): number;
164
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Style Provider Detection and Handling Utilities
3
+ * Supports both Mapbox GL and MapLibre GL styles
4
+ */
5
+ import type { BaseStyle, StyleProvider } from '../types/style';
6
+ /**
7
+ * Detect the style provider based on the style URL or content
8
+ */
9
+ export declare function detectStyleProvider(styleUrl: string, style?: BaseStyle): StyleProvider;
10
+ /**
11
+ * Extract access token from Mapbox style URL
12
+ */
13
+ export declare function extractAccessToken(styleUrl: string): string | null;
14
+ /**
15
+ * Validate if a style URL requires authentication
16
+ */
17
+ export declare function requiresAuthentication(styleUrl: string, provider: StyleProvider): boolean;
18
+ /**
19
+ * Normalize style URL for consistent processing
20
+ */
21
+ export declare function normalizeStyleUrl(styleUrl: string, accessToken?: string): string;
22
+ /**
23
+ * Process style sources for offline compatibility
24
+ */
25
+ export declare function processStyleSources(style: BaseStyle, provider: StyleProvider, accessToken?: string): BaseStyle;
26
+ /**
27
+ * Enhanced style validation for different providers
28
+ */
29
+ export declare function validateStyleForProvider(style: BaseStyle, provider: StyleProvider): {
30
+ isValid: boolean;
31
+ errors: string[];
32
+ warnings: string[];
33
+ };
34
+ /**
35
+ * Get default style configuration for a provider
36
+ */
37
+ export declare function getDefaultStyleConfig(provider: StyleProvider): {
38
+ requiresAuth: boolean;
39
+ defaultSources: string[];
40
+ supportedFormats: string[];
41
+ maxZoom: number;
42
+ };
@@ -0,0 +1,35 @@
1
+ import type { MapboxStyle } from '../types/style';
2
+ /**
3
+ * Patches a MapboxStyle for offline use by replacing URLs with IndexedDB references
4
+ */
5
+ export declare function patchStyleForOffline(style: MapboxStyle, downloadId: string, maxZoom?: number, tileExtension?: string): MapboxStyle;
6
+ /**
7
+ * Validates if a region configuration is valid
8
+ */
9
+ export declare function validateRegion(region: unknown): boolean;
10
+ /**
11
+ * Calculates the bounding box area in square degrees
12
+ */
13
+ export declare function calculateBBoxArea(bounds: [[number, number], [number, number]]): number;
14
+ /**
15
+ * Estimates the number of tiles for a given region and zoom range
16
+ */
17
+ export declare function estimateTileCount(bounds: [[number, number], [number, number]], minZoom: number, maxZoom: number): number;
18
+ /**
19
+ * Extracts all fontstacks from a style object and generates all glyph URLs for a set of Unicode ranges.
20
+ * @param style The style JSON object
21
+ * @param glyphsUrlTemplate The glyphs URL template from the style (e.g. .../fonts/{fontstack}/{range}.pbf)
22
+ * @param ranges Optional array of ranges (default: [0-255, 256-511, ..., 61440-61695])
23
+ */
24
+ export declare function generateGlyphUrlsFromStyle(style: {
25
+ layers?: Array<{
26
+ layout?: {
27
+ [key: string]: unknown;
28
+ };
29
+ }>;
30
+ }, glyphsUrlTemplate: string, ranges?: Array<[number, number]>): string[];
31
+ /**
32
+ * Extract tile coordinates from a tile URL
33
+ * e.g., "https://tiles-a.basemaps.cartocdn.com/vectortiles/carto.streets/v1/0/0/0.mvt" -> "0/0/0.mvt"
34
+ */
35
+ export declare function extractTileKey(url: string): string;