map-gl-offline 0.6.0 → 0.8.2

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 (39) hide show
  1. package/README.md +3 -1
  2. package/dist/idb-offline-sw.js +313 -360
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.esm.js +1359 -1021
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.js +1373 -1020
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.umd.js +1373 -1020
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/managers/offlineMapManager/importExportManagement.d.ts +5 -3
  11. package/dist/managers/offlineMapManager/resourceManagement.d.ts +4 -0
  12. package/dist/services/fontService.d.ts +12 -2
  13. package/dist/services/glyphService.d.ts +11 -2
  14. package/dist/services/importExportService.d.ts +11 -26
  15. package/dist/services/modelService.d.ts +57 -0
  16. package/dist/services/resourceService.d.ts +11 -1
  17. package/dist/services/spriteService.d.ts +10 -3
  18. package/dist/style.css +1 -1
  19. package/dist/sw/offline-sw.d.ts +17 -0
  20. package/dist/sw/shared.d.ts +108 -0
  21. package/dist/types/database.d.ts +9 -0
  22. package/dist/types/import-export.d.ts +7 -28
  23. package/dist/types/index.d.ts +1 -0
  24. package/dist/types/model.d.ts +62 -0
  25. package/dist/types/region.d.ts +11 -1
  26. package/dist/types/style.d.ts +11 -2
  27. package/dist/ui/components/shared/PanelContent.d.ts +0 -1
  28. package/dist/ui/managers/PanelManager.d.ts +1 -1
  29. package/dist/ui/managers/downloadManager.d.ts +1 -1
  30. package/dist/ui/modals/{importExportModal.d.ts → mbtilesModal.d.ts} +18 -17
  31. package/dist/ui/translations/ar.d.ts +23 -37
  32. package/dist/ui/translations/en.d.ts +23 -37
  33. package/dist/utils/constants.d.ts +2 -1
  34. package/dist/utils/importResolver.d.ts +10 -0
  35. package/dist/utils/index.d.ts +1 -0
  36. package/dist/utils/sqlJsLoader.d.ts +17 -0
  37. package/dist/utils/styleProviderUtils.d.ts +16 -0
  38. package/dist/utils/tileKey.d.ts +13 -0
  39. package/package.json +7 -4
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Pure helpers shared between the main-thread offline fetch handler
3
+ * (`src/utils/idbFetchHandler.ts`) and the offline Service Worker
4
+ * (`src/sw/offline-sw.ts`, compiled to `public/idb-offline-sw.js`).
5
+ *
6
+ * Keeping these in one place means the SW and the main-thread handler
7
+ * can't drift — adding a new `model` handler, changing the fallback
8
+ * order, or tweaking the tilejson-source matcher happens once.
9
+ *
10
+ * Nothing in here touches IndexedDB directly. Each helper takes already-
11
+ * resolved inputs and returns the list of candidate keys (or the
12
+ * resolved output) that the caller feeds into its own IDB lookup.
13
+ *
14
+ * The corresponding IDB access layer is:
15
+ * - main thread: `idb` library via `dbPromise`
16
+ * - service worker: raw `indexedDB.open` (see `offline-sw.ts`)
17
+ *
18
+ * They have different shapes so cannot be shared; the key computation
19
+ * can be and is.
20
+ */
21
+ export declare const OFFLINE_PREFIX = "/__offline__/";
22
+ export declare const DB_NAME = "offline-map-db";
23
+ /**
24
+ * Minimal stored-style shape used for region-by-style lookup and
25
+ * tilejson source resolution.
26
+ */
27
+ export interface StyleEntryLike {
28
+ key: string;
29
+ style?: {
30
+ sources?: Record<string, unknown>;
31
+ };
32
+ regions?: Array<{
33
+ id?: string;
34
+ regionId?: string;
35
+ }>;
36
+ }
37
+ /** Canonical tile key format used across stores. Keep in sync with `tileKey.ts`. */
38
+ export declare function makeTileKey(x: number, y: number, z: number, styleId: string, sourceId: string, ext: string): string;
39
+ /**
40
+ * Extensions to try in order when the requested extension misses. `glb` is
41
+ * last so batched-model sources (Mapbox Standard 3D buildings) resolve when
42
+ * their source URL template ended in `.vector` or similar and the actual
43
+ * tile body was stored as glb.
44
+ */
45
+ export declare const TILE_FALLBACK_EXTENSIONS: readonly ["pbf", "mvt", "png", "jpg", "webp", "glb"];
46
+ /** Extensions minus the one the caller already tried. */
47
+ export declare function tileFallbackExtensions(requested: string): string[];
48
+ /** Extract `.../{y}.ext` → `{ y, ext }`. Returns null if the path isn't a tile filename. */
49
+ export declare function parseTileYExt(yExt: string): {
50
+ y: number;
51
+ ext: string;
52
+ } | null;
53
+ /**
54
+ * Given an already-fetched list of style entries, find the first one whose
55
+ * `regions` array contains the given ID. Pure — the caller is responsible for
56
+ * loading the entries and for caching. Used by both `findStyleByRegionId`
57
+ * implementations to keep the match rule identical.
58
+ */
59
+ export declare function findStyleByRegionIdIn(styles: readonly StyleEntryLike[], regionId: string): StyleEntryLike | null;
60
+ /**
61
+ * Parse `FontA,FontB,FontC/0-255.pbf` into (fontstacks, rangePart). Mapbox
62
+ * requests a comma-joined font-family fallback chain; each glyph is stored
63
+ * individually, so the caller tries each fontstack in order.
64
+ */
65
+ export declare function parseGlyphPath(decodedPath: string): {
66
+ fontstacks: string[];
67
+ rangePart: string;
68
+ };
69
+ /**
70
+ * Build the list of keys to try for a single (fontstack, range) pair.
71
+ * Order: actualStyleId variants first (most common), then downloadId,
72
+ * then the bare path. Normalized and raw `.pbf`-less forms are both tried
73
+ * to cover stored-key variants from older versions.
74
+ */
75
+ export declare function glyphCandidateKeys(actualStyleId: string, downloadId: string, fontstack: string, rangePart: string): string[];
76
+ /**
77
+ * Sprite keys have historically used both `::` and `:` as the separator, and
78
+ * both the full filename (`sprite.json`) and the bare name (`sprite`). Return
79
+ * every variant in priority order; the caller stops at the first hit.
80
+ */
81
+ export declare function spriteCandidateKeys(actualStyleId: string, downloadId: string, decodedPath: string): string[];
82
+ /**
83
+ * Model keys are `{styleId}::model::{name}`. Try the resolved style id first,
84
+ * then the bare downloadId in case the request came through the region-scoped
85
+ * URL form (`idb://{regionId}/model/{name}`).
86
+ */
87
+ export declare function modelCandidateKeys(actualStyleId: string, downloadId: string, decodedPath: string): string[];
88
+ /**
89
+ * Mapbox GL requests tilejson via `idb://{downloadId}/tilesjson/{path}` where
90
+ * `{path}` may be the source id, the original TileJSON URL, or the URL we
91
+ * stashed under `__originalTilesetUrl` when patching for offline. Try all
92
+ * three; return the matching source id + its config, or null.
93
+ */
94
+ export declare function matchTileJsonSource(sources: Record<string, unknown>, decodedPath: string): {
95
+ sourceId: string;
96
+ config: Record<string, unknown>;
97
+ } | null;
98
+ /**
99
+ * Build the offline TileJSON payload that replaces the one Mapbox would
100
+ * have fetched from the network. `tiles` is rewritten to serve from the SW
101
+ * (the caller supplies the scheme via `tileUrlScheme`); copyable TileJSON
102
+ * fields are preserved.
103
+ */
104
+ export declare function buildOfflineTileJson(sourceConfig: Record<string, unknown>, downloadId: string, sourceId: string, extension: string, tileUrlScheme: 'idb' | 'offline', origin?: string): Record<string, unknown>;
105
+ /** First-match extension derivation, same rule as `tileKey.extractTileExtensionFromUrl`. */
106
+ export declare function deriveTileExtensionFromTiles(tiles: unknown): string;
107
+ /** RFC 1952 gzip magic bytes: 1f 8b. */
108
+ export declare function isGzipped(buffer: ArrayBuffer): boolean;
@@ -5,6 +5,7 @@ import type { FontEntry } from './font';
5
5
  import type { TileEntry } from './tile';
6
6
  import type { SpriteEntry } from './sprite';
7
7
  import type { GlyphEntry } from './glyph';
8
+ import type { ModelEntry } from './model';
8
9
  export interface OfflineMapDB extends DBSchema {
9
10
  /**
10
11
  * @deprecated Regions are now stored inside styles.regions[] array.
@@ -35,4 +36,12 @@ export interface OfflineMapDB extends DBSchema {
35
36
  key: string;
36
37
  value: FontEntry;
37
38
  };
39
+ /**
40
+ * 3D model files (.glb) referenced by `style.models` entries. Used by
41
+ * Mapbox Standard for tree / wind-turbine model layers.
42
+ */
43
+ models: {
44
+ key: string;
45
+ value: ModelEntry;
46
+ };
38
47
  }
@@ -10,12 +10,10 @@ export interface RegionExportData {
10
10
  createdAt: number;
11
11
  exportedAt: number;
12
12
  version: string;
13
- format: 'json' | 'pmtiles' | 'mbtiles';
13
+ format: 'mbtiles';
14
14
  };
15
15
  style: unknown;
16
16
  tiles: TileExportData[];
17
- sprites: SpriteExportData[];
18
- fonts: FontExportData[];
19
17
  }
20
18
  export interface TileExportData {
21
19
  z: number;
@@ -25,34 +23,13 @@ export interface TileExportData {
25
23
  format: 'pbf' | 'png' | 'jpg' | 'webp';
26
24
  sourceId: string;
27
25
  }
28
- export interface SpriteExportData {
29
- url: string;
30
- data: ArrayBuffer;
31
- type: 'json' | 'png';
32
- resolution: '1x' | '2x';
33
- }
34
- export interface FontExportData {
35
- fontStack: string;
36
- range: string;
37
- data: ArrayBuffer;
38
- }
39
- export interface PMTilesExportOptions {
40
- compression?: 'gzip' | 'brotli' | 'none';
41
- clustered?: boolean;
42
- metadata?: Record<string, unknown>;
43
- }
44
26
  export interface MBTilesExportOptions {
27
+ /** Tile format written into the MBTiles metadata table. */
45
28
  format?: 'pbf' | 'png' | 'jpg';
46
- compression?: 'gzip' | 'none';
29
+ /** Additional metadata rows. Values are JSON-stringified if non-string. */
47
30
  metadata?: Record<string, unknown>;
48
31
  }
49
32
  export interface ImportExportOptions {
50
- includeStyle?: boolean;
51
- includeTiles?: boolean;
52
- includeSprites?: boolean;
53
- includeFonts?: boolean;
54
- format?: 'json' | 'pmtiles' | 'mbtiles';
55
- compression?: boolean;
56
33
  onProgress?: (progress: ImportExportProgress) => void;
57
34
  }
58
35
  export interface ImportExportProgress {
@@ -65,10 +42,12 @@ export interface ImportExportProgress {
65
42
  }
66
43
  export interface RegionImportData {
67
44
  file: File;
68
- format: 'json' | 'pmtiles' | 'mbtiles';
45
+ /** Format is fixed to mbtiles; kept as a literal field for forward-compat. */
46
+ format: 'mbtiles';
69
47
  overwrite?: boolean;
70
48
  newRegionId?: string;
71
49
  newRegionName?: string;
50
+ onProgress?: (progress: ImportExportProgress) => void;
72
51
  }
73
52
  export interface ImportResult {
74
53
  success: boolean;
@@ -84,7 +63,7 @@ export interface ImportResult {
84
63
  }
85
64
  export interface ExportResult {
86
65
  success: boolean;
87
- format: 'json' | 'pmtiles' | 'mbtiles';
66
+ format: 'mbtiles';
88
67
  filename: string;
89
68
  blob: Blob;
90
69
  size: number;
@@ -4,6 +4,7 @@ export * from './font';
4
4
  export * from './tile';
5
5
  export * from './sprite';
6
6
  export * from './glyph';
7
+ export * from './model';
7
8
  export * from './database';
8
9
  export * from './maintenance';
9
10
  export * from './progress';
@@ -0,0 +1,62 @@
1
+ import { DownloadProgress } from './progress';
2
+ /**
3
+ * 3D model asset (e.g. a tree or turbine .glb) stored in IndexedDB.
4
+ *
5
+ * Mapbox Standard references 32 models via the top-level `style.models`
6
+ * dictionary (`{ "maple1-lod1": "mapbox://models/mapbox/maple1-v4-lod1.glb" }`).
7
+ * Layers of type `model` then pick one by name at render time.
8
+ */
9
+ export interface ModelEntry {
10
+ /** Storage key: `{styleId}::model::{modelName}`. */
11
+ key: string;
12
+ /** Model binary (.glb / .gltf) as ArrayBuffer. */
13
+ data: ArrayBuffer;
14
+ /** HTTP Content-Type (usually `model/gltf-binary`). */
15
+ contentType: string;
16
+ /** Byte length. */
17
+ size: number;
18
+ /** URL the model was downloaded from. */
19
+ url: string;
20
+ /** Style this model belongs to. */
21
+ styleId: string;
22
+ /** Model name (the key in `style.models`). */
23
+ modelName: string;
24
+ /** Last-Modified or download timestamp (ms since epoch). */
25
+ lastModified: number;
26
+ /** ISO 8601 download timestamp. */
27
+ downloadedAt: string;
28
+ /** Optional expiry from HTTP Cache-Control. */
29
+ expires?: number;
30
+ }
31
+ /** Options for `downloadModels`. */
32
+ export interface ModelDownloadOptions {
33
+ onProgress?: (progress: DownloadProgress) => void;
34
+ batchSize?: number;
35
+ maxRetries?: number;
36
+ skipExisting?: boolean;
37
+ timeoutMs?: number;
38
+ }
39
+ /** Result of a model download batch. */
40
+ export interface ModelDownloadResult {
41
+ totalModels: number;
42
+ downloadedModels: number;
43
+ skippedModels: number;
44
+ failedModels: number;
45
+ totalSize: number;
46
+ errors: Array<{
47
+ url: string;
48
+ error: string;
49
+ }>;
50
+ }
51
+ /** Aggregate stats across stored models. */
52
+ export interface EnhancedModelStats {
53
+ count: number;
54
+ totalSize: number;
55
+ averageSize: number;
56
+ models: Array<{
57
+ name: string;
58
+ size: number;
59
+ lastModified?: number;
60
+ }>;
61
+ modelsByStyle: Record<string, number>;
62
+ }
@@ -2,11 +2,12 @@ import type { StyleProvider } from './style';
2
2
  import type { TileDownloadOptions, TileDownloadResult } from './tile';
3
3
  import type { SpriteDownloadResult } from './sprite';
4
4
  import type { GlyphDownloadResult } from './glyph';
5
+ import type { ModelDownloadResult } from './model';
5
6
  import type { StyleDownloadResult } from './style';
6
7
  /**
7
8
  * Phase of a region download pipeline, reported via `DownloadRegionOptions.onProgress`.
8
9
  */
9
- export type DownloadRegionPhase = 'style' | 'sprites' | 'glyphs' | 'tiles' | 'metadata';
10
+ export type DownloadRegionPhase = 'style' | 'sprites' | 'glyphs' | 'models' | 'tiles' | 'metadata';
10
11
  /**
11
12
  * Progress update emitted by `OfflineMapManager.downloadRegion`.
12
13
  */
@@ -31,6 +32,14 @@ export interface DownloadRegionOptions {
31
32
  skipGlyphs?: boolean;
32
33
  /** Skip sprite download entirely. Default: false. */
33
34
  skipSprites?: boolean;
35
+ /**
36
+ * Skip 3D model download. Default: false. Models (e.g. Mapbox Standard
37
+ * trees / wind turbines) are declared via `style.models` and live at
38
+ * `mapbox://models/…` URLs that only Mapbox serves. Skip for styles that
39
+ * don't use model layers, or to reduce storage footprint at the cost of
40
+ * missing tree/turbine rendering.
41
+ */
42
+ skipModels?: boolean;
34
43
  /** Override Unicode glyph ranges fetched per font. Defaults to `GLYPH_CONFIG.COMPREHENSIVE_RANGES`. */
35
44
  glyphRanges?: string[];
36
45
  /** Extra options forwarded to the tile download step. */
@@ -45,6 +54,7 @@ export interface DownloadRegionResult {
45
54
  styleResult?: StyleDownloadResult;
46
55
  spriteResults: SpriteDownloadResult[];
47
56
  glyphResult?: GlyphDownloadResult;
57
+ modelResult?: ModelDownloadResult;
48
58
  tileResult: TileDownloadResult;
49
59
  }
50
60
  /**
@@ -19,8 +19,17 @@ export interface BaseStyle {
19
19
  data?: BaseStyle;
20
20
  config?: Record<string, unknown>;
21
21
  }>;
22
- models?: Record<string, {
23
- uri: string;
22
+ /**
23
+ * 3D model declarations used by `model` layers (Mapbox Standard trees /
24
+ * wind turbines). Two shapes are accepted in the wild:
25
+ *
26
+ * - Mapbox Standard format — values are plain URI strings:
27
+ * `{ "maple1-lod1": "mapbox://models/mapbox/maple1-v4-lod1.glb" }`
28
+ * - Older / generic format — values wrap the URI in an object:
29
+ * `{ "name": { "uri": "mapbox://..." } }`
30
+ */
31
+ models?: Record<string, string | {
32
+ uri?: string;
24
33
  [key: string]: unknown;
25
34
  }>;
26
35
  [key: string]: unknown;
@@ -31,7 +31,6 @@ export declare class PanelContentRenderer extends BaseComponent {
31
31
  private showRegionDetails;
32
32
  private deleteRegion;
33
33
  private downloadRegion;
34
- private showImportExportModal;
35
34
  /**
36
35
  * Refresh content
37
36
  */
@@ -100,7 +100,7 @@ export declare class PanelRenderer extends BaseComponent {
100
100
  */
101
101
  private handleRedownloadRegion;
102
102
  /**
103
- * Handle import/export functionality
103
+ * Show the MBTiles import/export modal for a region.
104
104
  */
105
105
  private handleImportExport;
106
106
  /**
@@ -74,7 +74,7 @@ export interface DownloadProgress {
74
74
  /** Human-readable description of current activity */
75
75
  currentResource: string;
76
76
  /** Current download phase */
77
- phase?: 'style' | 'sprites' | 'glyphs' | 'tiles';
77
+ phase?: 'style' | 'sprites' | 'glyphs' | 'models' | 'tiles';
78
78
  }
79
79
  /**
80
80
  * Configuration options for the DownloadManager.
@@ -1,47 +1,48 @@
1
1
  /**
2
- * Import/Export Modal Component
3
- * Handles import/export operations for regions
4
- * Refactored to use modular Modal component for consistency
2
+ * MBTiles Import/Export Modal
3
+ *
4
+ * Focused modal for exchanging regions as binary SQLite MBTiles archives.
5
+ * Replaces the previous multi-format import/export modal.
5
6
  */
6
- import type { StoredRegion, ImportExportOptions, ExportResult, ImportResult, RegionImportData } from '@/types';
7
- export interface ImportExportModalOptions {
7
+ import type { StoredRegion, ImportExportOptions, MBTilesExportOptions, ExportResult, ImportResult, RegionImportData } from '@/types';
8
+ type MBTilesExportRequestOptions = ImportExportOptions & MBTilesExportOptions;
9
+ export interface MBTilesModalOptions {
8
10
  region: StoredRegion;
9
11
  onClose: () => void;
10
12
  onExport?: (result: ExportResult) => void;
11
13
  onImport?: (result: ImportResult) => void;
12
- exportRegion?: (regionId: string, format: 'json' | 'pmtiles' | 'mbtiles', options?: ImportExportOptions) => Promise<ExportResult>;
14
+ exportRegion?: (regionId: string, options?: MBTilesExportRequestOptions) => Promise<ExportResult>;
13
15
  importRegion?: (data: RegionImportData) => Promise<ImportResult>;
14
16
  }
15
- export declare class ImportExportModal {
17
+ export declare class MBTilesModal {
16
18
  private modal?;
17
19
  private options;
18
20
  private isExporting;
19
21
  private isImporting;
20
- private exportFormatSelect?;
21
- private includeStyleCheckbox?;
22
- private includeTilesCheckbox?;
23
- private includeSpritesCheckbox?;
24
- private includeFontsCheckbox?;
25
22
  private exportProgressBar?;
26
23
  private exportProgressText?;
24
+ private exportProgressContainer?;
27
25
  private exportButton?;
28
26
  private importFileInput?;
29
27
  private importNameInput?;
30
28
  private importOverwriteCheckbox?;
31
29
  private importProgressBar?;
32
30
  private importProgressText?;
31
+ private importProgressContainer?;
33
32
  private importButton?;
34
- constructor(options: ImportExportModalOptions);
33
+ constructor(options: MBTilesModalOptions);
35
34
  show(): HTMLDivElement;
36
35
  hide(): void;
36
+ destroy(): void;
37
37
  private createContent;
38
- private createRegionInfoCard;
38
+ private createRegionInfoLine;
39
39
  private createExportSection;
40
40
  private createImportSection;
41
- private createFormatGuide;
41
+ private createSection;
42
+ private createProgressBlock;
43
+ private createFooter;
42
44
  private attachEventListeners;
43
45
  private handleExport;
44
46
  private handleImport;
45
- private createFooter;
46
- destroy(): void;
47
47
  }
48
+ export {};
@@ -95,9 +95,6 @@ export declare const ar: {
95
95
  readonly 'styleSelection.title': "اختر نمط غير متصل";
96
96
  readonly 'styleSelection.message': "اختر النمط غير المتصل الذي تريد تحميله:";
97
97
  readonly 'styleSelection.sources': "مصادر";
98
- readonly 'importExport.title': "استيراد/تصدير";
99
- readonly 'importExport.export': "تصدير";
100
- readonly 'importExport.import': "استيراد";
101
98
  readonly 'error.loadingContent': "خطأ في تحميل المحتوى";
102
99
  readonly 'error.tryAgain': "يرجى المحاولة مرة أخرى";
103
100
  readonly 'error.mapNotInitialized': "الخريطة غير مهيأة. يرجى التأكد من تحميل الخريطة قبل تحميل النمط.";
@@ -117,40 +114,29 @@ export declare const ar: {
117
114
  readonly 'regionDetails.bounds': "الحدود";
118
115
  readonly 'regionDetails.zoomRange': "نطاق التكبير";
119
116
  readonly 'regionDetails.created': "تاريخ الإنشاء";
120
- readonly 'importExport.regionTitle': "استيراد/تصدير المنطقة";
121
- readonly 'importExport.regionInfo': "معلومات المنطقة";
122
- readonly 'importExport.id': "المعرف";
123
- readonly 'importExport.name': "الاسم";
124
- readonly 'importExport.unnamed': "بدون اسم";
125
- readonly 'importExport.zoom': "التكبير";
126
- readonly 'importExport.created': "تاريخ الإنشاء";
127
- readonly 'importExport.exportRegion': "تصدير المنطقة";
128
- readonly 'importExport.exportFormat': "تنسيق التصدير";
129
- readonly 'importExport.formatJson': "JSON - بيانات كاملة (موصى به)";
130
- readonly 'importExport.formatPmtiles': "PMTiles - بلاطات محسنة للويب";
131
- readonly 'importExport.formatMbtiles': "MBTiles - معيار الصناعة";
132
- readonly 'importExport.formatHint': "اختر التنسيق بناءً على حالة استخدامك";
133
- readonly 'importExport.includeComponents': "تضمين المكونات";
134
- readonly 'importExport.styleConfig': "إعدادات النمط";
135
- readonly 'importExport.mapTiles': "بلاطات الخريطة";
136
- readonly 'importExport.spritesIcons': "الرموز والأيقونات";
137
- readonly 'importExport.fontsGlyphs': "الخطوط والحروف";
138
- readonly 'importExport.preparingExport': "جاري تجهيز التصدير...";
139
- readonly 'importExport.exportComplete': "اكتمل التصدير!";
140
- readonly 'importExport.exportFailed': "فشل التصدير. يرجى المحاولة مرة أخرى.";
141
- readonly 'importExport.importRegion': "استيراد المنطقة";
142
- readonly 'importExport.selectFile': "اختر ملف";
143
- readonly 'importExport.fileFormatsHint': "يدعم تنسيقات JSON و PMTiles و MBTiles";
144
- readonly 'importExport.newRegionName': "اسم المنطقة الجديد (اختياري)";
145
- readonly 'importExport.newRegionNamePlaceholder': "اتركه فارغاً لاستخدام الاسم الأصلي";
146
- readonly 'importExport.overwriteIfExists': "الكتابة فوق المنطقة الموجودة";
147
- readonly 'importExport.preparingImport': "جاري تجهيز الاستيراد...";
148
- readonly 'importExport.importComplete': "اكتمل الاستيراد!";
149
- readonly 'importExport.importFailed': "فشل الاستيراد. يرجى المحاولة مرة أخرى.";
150
- readonly 'importExport.formatGuide': "دليل التنسيقات";
151
- readonly 'importExport.jsonDesc': "بيانات كاملة، قابلة للقراءة، الأفضل للتطوير";
152
- readonly 'importExport.pmtilesDesc': "محسن للويب، خدمة فعالة، متوافق مع السحابة";
153
- readonly 'importExport.mbtilesDesc': "معيار الصناعة، قائم على SQLite، متعدد المنصات";
117
+ readonly 'mbtiles.title': "استيراد / تصدير MBTiles";
118
+ readonly 'mbtiles.regionInfo': "معلومات المنطقة";
119
+ readonly 'mbtiles.id': "المعرف";
120
+ readonly 'mbtiles.name': "الاسم";
121
+ readonly 'mbtiles.unnamed': "بدون اسم";
122
+ readonly 'mbtiles.zoom': "التكبير";
123
+ readonly 'mbtiles.created': "تاريخ الإنشاء";
124
+ readonly 'mbtiles.exportTitle': "التصدير كـ MBTiles";
125
+ readonly 'mbtiles.exportHint': "احزم بلاطات هذه المنطقة داخل أرشيف MBTiles (SQLite) يمكن فتحه في QGIS و tippecanoe وأدوات أخرى.";
126
+ readonly 'mbtiles.exportButton': "تنزيل ملف mbtiles.";
127
+ readonly 'mbtiles.preparingExport': "جاري تجهيز التصدير...";
128
+ readonly 'mbtiles.exportComplete': "اكتمل التصدير!";
129
+ readonly 'mbtiles.exportFailed': "فشل التصدير. يرجى المحاولة مرة أخرى.";
130
+ readonly 'mbtiles.importTitle': "الاستيراد من MBTiles";
131
+ readonly 'mbtiles.selectFile': "اختر ملف mbtiles.";
132
+ readonly 'mbtiles.fileHint': "تُدعم ملفات mbtiles. بتنسيق SQLite فقط.";
133
+ readonly 'mbtiles.newRegionName': "اسم المنطقة الجديد (اختياري)";
134
+ readonly 'mbtiles.newRegionNamePlaceholder': "اتركه فارغًا لاستخدام الاسم من الملف";
135
+ readonly 'mbtiles.overwriteIfExists': "الكتابة فوق المنطقة إذا كان المعرف موجودًا";
136
+ readonly 'mbtiles.importButton': "استيراد ملف mbtiles.";
137
+ readonly 'mbtiles.preparingImport': "جاري تجهيز الاستيراد...";
138
+ readonly 'mbtiles.importComplete': "اكتمل الاستيراد!";
139
+ readonly 'mbtiles.importFailed': "فشل الاستيراد. يرجى المحاولة مرة أخرى.";
154
140
  readonly 'download.activeCount': "التحميلات النشطة ({{count}})";
155
141
  readonly 'panel.downloadedRegions': "المناطق المحملة";
156
142
  readonly 'panel.noExpiry': "بدون انتهاء";
@@ -94,9 +94,6 @@ export declare const en: {
94
94
  readonly 'styleSelection.title': "Select Offline Style";
95
95
  readonly 'styleSelection.message': "Choose which offline style to load:";
96
96
  readonly 'styleSelection.sources': "sources";
97
- readonly 'importExport.title': "Import/Export";
98
- readonly 'importExport.export': "Export";
99
- readonly 'importExport.import': "Import";
100
97
  readonly 'error.loadingContent': "Error loading content";
101
98
  readonly 'error.tryAgain': "Please try again";
102
99
  readonly 'error.mapNotInitialized': "Map is not initialized. Please ensure the map is loaded before loading a style.";
@@ -116,40 +113,29 @@ export declare const en: {
116
113
  readonly 'regionDetails.bounds': "Bounds";
117
114
  readonly 'regionDetails.zoomRange': "Zoom Range";
118
115
  readonly 'regionDetails.created': "Created";
119
- readonly 'importExport.regionTitle': "Import/Export Region";
120
- readonly 'importExport.regionInfo': "Region Information";
121
- readonly 'importExport.id': "ID";
122
- readonly 'importExport.name': "Name";
123
- readonly 'importExport.unnamed': "Unnamed";
124
- readonly 'importExport.zoom': "Zoom";
125
- readonly 'importExport.created': "Created";
126
- readonly 'importExport.exportRegion': "Export Region";
127
- readonly 'importExport.exportFormat': "Export Format";
128
- readonly 'importExport.formatJson': "JSON - Complete data (recommended)";
129
- readonly 'importExport.formatPmtiles': "PMTiles - Web optimized tiles";
130
- readonly 'importExport.formatMbtiles': "MBTiles - Industry standard";
131
- readonly 'importExport.formatHint': "Choose format based on your use case";
132
- readonly 'importExport.includeComponents': "Include Components";
133
- readonly 'importExport.styleConfig': "Style Configuration";
134
- readonly 'importExport.mapTiles': "Map Tiles";
135
- readonly 'importExport.spritesIcons': "Sprites & Icons";
136
- readonly 'importExport.fontsGlyphs': "Fonts & Glyphs";
137
- readonly 'importExport.preparingExport': "Preparing export...";
138
- readonly 'importExport.exportComplete': "Export complete!";
139
- readonly 'importExport.exportFailed': "Export failed. Please try again.";
140
- readonly 'importExport.importRegion': "Import Region";
141
- readonly 'importExport.selectFile': "Select File";
142
- readonly 'importExport.fileFormatsHint': "Supports JSON, PMTiles, and MBTiles formats";
143
- readonly 'importExport.newRegionName': "New Region Name (Optional)";
144
- readonly 'importExport.newRegionNamePlaceholder': "Leave empty to use original name";
145
- readonly 'importExport.overwriteIfExists': "Overwrite if region exists";
146
- readonly 'importExport.preparingImport': "Preparing import...";
147
- readonly 'importExport.importComplete': "Import complete!";
148
- readonly 'importExport.importFailed': "Import failed. Please try again.";
149
- readonly 'importExport.formatGuide': "Format Guide";
150
- readonly 'importExport.jsonDesc': "Complete data, human-readable, best for development";
151
- readonly 'importExport.pmtilesDesc': "Web-optimized, efficient serving, cloud-friendly";
152
- readonly 'importExport.mbtilesDesc': "Industry standard, SQLite-based, cross-platform";
116
+ readonly 'mbtiles.title': "MBTiles Import / Export";
117
+ readonly 'mbtiles.regionInfo': "Region Information";
118
+ readonly 'mbtiles.id': "ID";
119
+ readonly 'mbtiles.name': "Name";
120
+ readonly 'mbtiles.unnamed': "Unnamed";
121
+ readonly 'mbtiles.zoom': "Zoom";
122
+ readonly 'mbtiles.created': "Created";
123
+ readonly 'mbtiles.exportTitle': "Export as MBTiles";
124
+ readonly 'mbtiles.exportHint': "Package the tiles in this region into a standard SQLite MBTiles archive that opens in QGIS, tippecanoe, and other tools.";
125
+ readonly 'mbtiles.exportButton': "Download .mbtiles";
126
+ readonly 'mbtiles.preparingExport': "Preparing export...";
127
+ readonly 'mbtiles.exportComplete': "Export complete!";
128
+ readonly 'mbtiles.exportFailed': "Export failed. Please try again.";
129
+ readonly 'mbtiles.importTitle': "Import from MBTiles";
130
+ readonly 'mbtiles.selectFile': "Select an .mbtiles file";
131
+ readonly 'mbtiles.fileHint': "Only SQLite-format .mbtiles files are supported.";
132
+ readonly 'mbtiles.newRegionName': "New Region Name (optional)";
133
+ readonly 'mbtiles.newRegionNamePlaceholder': "Leave empty to use the name from the file";
134
+ readonly 'mbtiles.overwriteIfExists': "Overwrite if a region with the same id exists";
135
+ readonly 'mbtiles.importButton': "Import .mbtiles";
136
+ readonly 'mbtiles.preparingImport': "Preparing import...";
137
+ readonly 'mbtiles.importComplete': "Import complete!";
138
+ readonly 'mbtiles.importFailed': "Import failed. Please try again.";
153
139
  readonly 'download.activeCount': "Active Downloads ({{count}})";
154
140
  readonly 'panel.downloadedRegions': "Downloaded Regions";
155
141
  readonly 'panel.noExpiry': "No expiry";
@@ -3,13 +3,14 @@
3
3
  * Centralizes magic numbers and configuration values
4
4
  */
5
5
  export declare const DB_NAME = "offline-map-db";
6
- export declare const DB_VERSION = 3;
6
+ export declare const DB_VERSION = 4;
7
7
  export declare const STORE_NAMES: {
8
8
  readonly TILES: "tiles";
9
9
  readonly STYLES: "styles";
10
10
  readonly SPRITES: "sprites";
11
11
  readonly GLYPHS: "glyphs";
12
12
  readonly FONTS: "fonts";
13
+ readonly MODELS: "models";
13
14
  };
14
15
  export declare const DOWNLOAD_DEFAULTS: {
15
16
  readonly BATCH_SIZE: 10;
@@ -31,3 +31,13 @@ export declare function hasImports(style: unknown): boolean;
31
31
  * Returns the mutated style.
32
32
  */
33
33
  export declare function resolveImports(style: BaseStyle, accessToken: string, options?: ResolveImportsOptions): Promise<BaseStyle>;
34
+ /**
35
+ * Rewrite indoor-only expressions in a style's layers to their outdoor no-op
36
+ * constants. See the in-line comment in `resolveValue` for why this is needed
37
+ * for Mapbox Standard when the `imports` wrapper is stripped.
38
+ *
39
+ * Safe to call multiple times and on already-downloaded stored styles — the
40
+ * rewrites are idempotent (after the first pass there are no more
41
+ * `is-active-floor` / `floor-level` expressions to rewrite).
42
+ */
43
+ export declare function sanitizeIndoorExpressions(style: BaseStyle): void;
@@ -15,3 +15,4 @@ export * from './convertStyleForSW';
15
15
  export * from './swRegistration';
16
16
  export * from './cssPrefix';
17
17
  export * from './importResolver';
18
+ export * from './sqlJsLoader';
@@ -0,0 +1,17 @@
1
+ import type { SqlJsStatic } from 'sql.js';
2
+ export interface SqlJsConfig {
3
+ /** URL where `sql-wasm.wasm` (and any Emscripten runtime files) can be fetched from. */
4
+ wasmUrl?: string;
5
+ /** Pre-fetched WASM binary. Takes precedence over `wasmUrl`. Useful in Node / tests. */
6
+ wasmBinary?: ArrayBuffer | Uint8Array;
7
+ }
8
+ /**
9
+ * Override how `sql.js` loads its WebAssembly. Call once before any MBTiles
10
+ * import/export is invoked. Resets any cached init.
11
+ */
12
+ export declare function configureSqlJs(config: SqlJsConfig): void;
13
+ /**
14
+ * Lazily initialise `sql.js`. The underlying module is loaded via dynamic
15
+ * `import()` so it only ships with bundles that actually call MBTiles code.
16
+ */
17
+ export declare function getSqlJs(): Promise<SqlJsStatic>;