map-gl-offline 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -52,13 +52,11 @@ const map = new maplibregl.Map({
52
52
  const offlineManager = new OfflineMapManager();
53
53
 
54
54
  map.on('load', () => {
55
- map.addControl(
56
- new OfflineManagerControl(offlineManager, {
57
- styleUrl: map.getStyle().sprite,
58
- mapLib: maplibregl, // enables idb:// protocol
59
- }),
60
- 'top-right',
61
- );
55
+ const control = new OfflineManagerControl(offlineManager, {
56
+ styleUrl: 'https://api.maptiler.com/maps/streets/style.json?key=YOUR_KEY',
57
+ mapLib: maplibregl, // enables idb:// protocol in web workers
58
+ });
59
+ map.addControl(control, 'top-right');
62
60
  });
63
61
  ```
64
62
 
@@ -103,7 +101,7 @@ map.on('load', () =>
103
101
 
104
102
  ## Programmatic Usage
105
103
 
106
- `downloadRegion` runs the full pipeline (**style → sprites → glyphs → tiles → metadata**) with per-phase progress. `addRegion` alone only stores metadata — use `downloadRegion` to actually fetch assets.
104
+ `downloadRegion` runs the full pipeline (**style → sprites → glyphs → models → tiles → metadata**) with per-phase progress. `addRegion` alone only stores metadata — use `downloadRegion` to actually fetch assets.
107
105
 
108
106
  ```typescript
109
107
  import { OfflineMapManager } from 'map-gl-offline';
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@
34
34
  * ```typescript
35
35
  * const offlineManager = new OfflineMapManager();
36
36
  *
37
- * // downloadRegion runs the full pipeline: style (if missing) → sprites → glyphs → tiles → metadata.
37
+ * // downloadRegion runs the full pipeline: style (if missing) → sprites → glyphs → models → tiles → metadata.
38
38
  * // addRegion on its own only stores metadata; use downloadRegion to actually fetch assets.
39
39
  * await offlineManager.downloadRegion(
40
40
  * {
package/dist/index.esm.js CHANGED
@@ -38,45 +38,61 @@ const TILE_CONFIG = {
38
38
  SUPPORTED_EXTENSIONS: ['pbf', 'mvt', 'png', 'jpg', 'jpeg', 'webp', 'glb'],
39
39
  };
40
40
  // Glyph Configuration
41
+ //
42
+ // Glyph servers (MapTiler, Mapbox, OpenFreeMap, ...) serve glyphs in fixed
43
+ // 256-codepoint blocks aligned to a multiple of 256: every request must be
44
+ // `${k * 256}-${k * 256 + 255}`. Strict servers (e.g. MapTiler) reject any
45
+ // other range with HTTP 400 "Invalid glyph range"; lenient ones silently
46
+ // accept them, which is how malformed ranges went unnoticed. See issue #37.
47
+ const GLYPH_BLOCK_SIZE = 256;
48
+ const MAX_GLYPH_CODEPOINT = 65535;
49
+ /**
50
+ * Expand an inclusive Unicode codepoint span into the aligned 256-codepoint
51
+ * glyph blocks that cover it, formatted as `"start-end"` request ranges.
52
+ * The span need not be block-aligned — it is snapped out to whole blocks.
53
+ */
54
+ function glyphBlocksForSpan(start, end) {
55
+ const firstBlock = Math.floor(start / GLYPH_BLOCK_SIZE);
56
+ const lastBlock = Math.floor(Math.min(end, MAX_GLYPH_CODEPOINT) / GLYPH_BLOCK_SIZE);
57
+ const blocks = [];
58
+ for (let block = firstBlock; block <= lastBlock; block++) {
59
+ const blockStart = block * GLYPH_BLOCK_SIZE;
60
+ blocks.push(`${blockStart}-${blockStart + GLYPH_BLOCK_SIZE - 1}`);
61
+ }
62
+ return blocks;
63
+ }
64
+ /**
65
+ * Unicode codepoint spans the comprehensive glyph download aims to cover.
66
+ * Each span is snapped to whole 256-codepoint glyph blocks below, so the
67
+ * resulting request ranges are always server-valid regardless of where the
68
+ * underlying Unicode blocks happen to start or end. To extend coverage, add
69
+ * a span here — never hand-write raw `"start-end"` ranges.
70
+ */
71
+ const GLYPH_COVERAGE_SPANS = [
72
+ [0x0000, 0x12ff], // Latin, Greek, Cyrillic, Hebrew, Arabic, Indic, SE Asian, Georgian, Ethiopic, Cherokee
73
+ [0x1e00, 0x21ff], // Latin Extended Additional, punctuation, symbols, arrows
74
+ [0x2e00, 0x31ff], // CJK radicals, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo
75
+ [0x4e00, 0x4fff], // CJK Unified Ideographs (common subset)
76
+ [0xa000, 0xa4ff], // Yi Syllables and Radicals
77
+ [0xac00, 0xd7ff], // Hangul Syllables (Korean)
78
+ [0xf900, 0xfbff], // CJK Compatibility Ideographs, Alphabetic Presentation Forms
79
+ [0xfe00, 0xfeff], // Variation Selectors
80
+ [0xff00, 0xffff], // Halfwidth and Fullwidth Forms
81
+ ];
82
+ /** Build the deduped, codepoint-ascending list of comprehensive glyph ranges. */
83
+ function buildComprehensiveRanges() {
84
+ const ranges = new Set();
85
+ for (const [start, end] of GLYPH_COVERAGE_SPANS) {
86
+ for (const range of glyphBlocksForSpan(start, end)) {
87
+ ranges.add(range);
88
+ }
89
+ }
90
+ return Array.from(ranges).sort((a, b) => Number(a.split('-')[0]) - Number(b.split('-')[0]));
91
+ }
41
92
  const GLYPH_CONFIG = {
42
93
  DEFAULT_URL: 'https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf',
43
94
  DEFAULT_RANGES: ['0-255'],
44
- COMPREHENSIVE_RANGES: [
45
- '0-255', // Basic Latin + Latin-1 Supplement
46
- '256-511', // Latin Extended-A + Latin Extended-B
47
- '512-767', // IPA Extensions + Spacing Modifier Letters
48
- '768-1023', // Combining Diacritical Marks + Greek and Coptic
49
- '1024-1279', // Cyrillic + Cyrillic Supplement
50
- '1280-1535', // Armenian + Hebrew
51
- '1536-1791', // Arabic
52
- '1792-2047', // Syriac + Arabic Supplement + Thaana
53
- '2048-2303', // NKo + Samaritan + Mandaic
54
- '2304-2559', // Devanagari + Bengali
55
- '2560-2815', // Gurmukhi + Gujarati
56
- '2816-3071', // Oriya + Tamil
57
- '3072-3327', // Telugu + Kannada
58
- '3328-3583', // Malayalam + Sinhala
59
- '3584-3839', // Thai + Lao
60
- '3840-4095', // Tibetan + Myanmar
61
- '4096-4351', // Georgian + Hangul Jamo
62
- '4352-4607', // Ethiopic
63
- '4608-4863', // Cherokee + Canadian Aboriginal
64
- '7680-7935', // Latin Extended Additional
65
- '8192-8447', // General Punctuation, Superscripts/Subscripts, Currency Symbols
66
- '8448-8703', // Letterlike Symbols, Number Forms, Arrows
67
- '11904-12031', // CJK Radicals Supplement
68
- '12032-12255', // Kangxi Radicals + CJK Symbols
69
- '12288-12543', // Hiragana + Katakana
70
- '12544-12799', // Bopomofo + Hangul Compatibility Jamo
71
- '19968-20223', // CJK Unified Ideographs (first block)
72
- '20224-20479', // CJK Unified Ideographs
73
- '40960-42127', // Yi Syllables + Yi Radicals
74
- '44032-55203', // Hangul Syllables (Korean)
75
- '63744-64255', // CJK Compatibility Ideographs
76
- '64256-64511', // Alphabetic Presentation Forms
77
- '65024-65279', // Variation Selectors
78
- '65280-65535', // Halfwidth and Fullwidth Forms
79
- ],
95
+ COMPREHENSIVE_RANGES: buildComprehensiveRanges(),
80
96
  };
81
97
  // Style Configuration
82
98
  const STYLE_CONFIG = {
@@ -12920,14 +12936,15 @@ class RegionControl {
12920
12936
  * Download Manager for offline map regions.
12921
12937
  *
12922
12938
  * This module handles the complete download workflow for offline map regions,
12923
- * including styles, sprites, glyphs (fonts), and map tiles. It provides
12939
+ * including styles, sprites, glyphs (fonts), 3D models, and map tiles. It provides
12924
12940
  * progress tracking across all download phases.
12925
12941
  *
12926
12942
  * **Download Phases:**
12927
12943
  * 1. `style` - Downloads the map style JSON and processes sources
12928
12944
  * 2. `sprites` - Downloads sprite images and JSON for map icons
12929
12945
  * 3. `glyphs` - Downloads font glyphs for text rendering
12930
- * 4. `tiles` - Downloads map tiles for the specified region bounds
12946
+ * 4. `models` - Downloads 3D model assets (Mapbox Standard trees / turbines)
12947
+ * 5. `tiles` - Downloads map tiles for the specified region bounds
12931
12948
  *
12932
12949
  * **Usage:**
12933
12950
  * The DownloadManager is typically instantiated by the OfflineManagerControl
@@ -13187,7 +13204,7 @@ class ModalManager {
13187
13204
  * - Integrates seamlessly as a MapLibre GL control
13188
13205
  * - Intercepts fetch requests to serve offline resources from IndexedDB
13189
13206
  * - Supports light and dark themes
13190
- * - Shows download progress across all phases (style, sprites, glyphs, tiles)
13207
+ * - Shows download progress across all phases (style, sprites, glyphs, models, tiles)
13191
13208
  * - Optional bounding box visualization for regions
13192
13209
  *
13193
13210
  * @example
@@ -13947,5 +13964,5 @@ class OfflineManagerControl {
13947
13964
  }
13948
13965
  }
13949
13966
 
13950
- export { AnalyticsService, CONTENT_TYPES, CategorizedError, CleanupService, DB_NAME, DB_VERSION, DOWNLOAD_DEFAULTS, ERROR_MESSAGES, ErrorType, FontService, GLYPH_CONFIG, GZIP_MAGIC_BYTES, GlyphService, ImportExportService, LogLevel, MAPBOX_API, MAPBOX_CACHE_TTL, MAPBOX_CLASSIC_STYLES, MAP_PROVIDERS, MaintenanceService, ModelService, OfflineManagerControl, OfflineMapDBVersionError, OfflineMapManager, RESOURCE_TYPES, RegionService, ResourceService, STORAGE_CONFIG, STORE_NAMES, STYLE_CONFIG, SUCCESS_MESSAGES, ScopedLogger, SpriteService, TILE_CONFIG, TileService, URL_SCHEMES, VALIDATION_PATTERNS, applyProxy, categorizeError, cleanupCompressedTiles, cleanupExpiredTiles, cleanupOldFonts, cleanupOldGlyphs, cleanupOldModels, cleanupOldSprites, cleanupOldStyles, cleanupOldTiles, cleanupService, clearAllCaches, configureLogger, configureProxy, configureSqlJs, convertStyleForServiceWorker, countCompressedTiles, createProgressTracker, createTileKey, dbPromise, OfflineMapManager as default, deleteStyleById, deleteStyles, deriveTileExtension, detectCssPrefix, detectStyleProvider, downloadFonts, downloadGlyphs, downloadModels, downloadSprites, downloadStyleWithProvider, downloadStyles, downloadTiles, escapeHtml$1 as escapeHtml, extractAccessToken, extractAllFontNames, extractFontNamesFromTextField, extractTileExtensionFromUrl, fetchResourceWithRetry, fetchWithRetry, fontService, formatBytes, formatDate, generateGlyphUrlsFromStyle, getExpiredResourceCount, getFontAnalytics, getFontStats, getGlyphAnalytics, getGlyphStats, getIcon, getModel, getModelStats, getRegionAnalytics, getSpriteAnalytics, getSpriteStats, getSqlJs, getStyleStats, getTileAnalytics, getTileStats, getUrlHostname, getUserErrorMessage, glyphService, hasImports, hostMatches, i18n, icons, idbFetchHandler, isMapboxHost, isMapboxProtocol, isStyleDownloaded, loadAllStoredRegions, loadGlyphs, loadStyleById, loadStyles, logger, modelKeyBelongsToStyle, modelService, normalizeSpriteProperty, normalizeStyleUrl, optimizeStorage, parseCacheExpiry, parseTileKey, patchStyleForOffline, performCleanup, processBatch, processStyleSources, registerOfflineServiceWorker, resetOfflineMapDB, resolveImports, resolveMapboxUrl, resourceKeyBelongsToStyle, rewriteMapboxCdnTileUrl, safeExecute, sanitizeIndoorExpressions, setupAutoCleanup, spriteService, stopAutoCleanup, t, tileService, unregisterOfflineServiceWorker, validateBounds, validateRegionOptions, validateResource, validateStyleForProvider, validateZoomLevels, verifyAndRepairFonts, verifyAndRepairGlyphs, verifyAndRepairModels, verifyAndRepairSprites };
13967
+ export { AnalyticsService, CONTENT_TYPES, CategorizedError, CleanupService, DB_NAME, DB_VERSION, DOWNLOAD_DEFAULTS, ERROR_MESSAGES, ErrorType, FontService, GLYPH_BLOCK_SIZE, GLYPH_CONFIG, GZIP_MAGIC_BYTES, GlyphService, ImportExportService, LogLevel, MAPBOX_API, MAPBOX_CACHE_TTL, MAPBOX_CLASSIC_STYLES, MAP_PROVIDERS, MAX_GLYPH_CODEPOINT, MaintenanceService, ModelService, OfflineManagerControl, OfflineMapDBVersionError, OfflineMapManager, RESOURCE_TYPES, RegionService, ResourceService, STORAGE_CONFIG, STORE_NAMES, STYLE_CONFIG, SUCCESS_MESSAGES, ScopedLogger, SpriteService, TILE_CONFIG, TileService, URL_SCHEMES, VALIDATION_PATTERNS, applyProxy, categorizeError, cleanupCompressedTiles, cleanupExpiredTiles, cleanupOldFonts, cleanupOldGlyphs, cleanupOldModels, cleanupOldSprites, cleanupOldStyles, cleanupOldTiles, cleanupService, clearAllCaches, configureLogger, configureProxy, configureSqlJs, convertStyleForServiceWorker, countCompressedTiles, createProgressTracker, createTileKey, dbPromise, OfflineMapManager as default, deleteStyleById, deleteStyles, deriveTileExtension, detectCssPrefix, detectStyleProvider, downloadFonts, downloadGlyphs, downloadModels, downloadSprites, downloadStyleWithProvider, downloadStyles, downloadTiles, escapeHtml$1 as escapeHtml, extractAccessToken, extractAllFontNames, extractFontNamesFromTextField, extractTileExtensionFromUrl, fetchResourceWithRetry, fetchWithRetry, fontService, formatBytes, formatDate, generateGlyphUrlsFromStyle, getExpiredResourceCount, getFontAnalytics, getFontStats, getGlyphAnalytics, getGlyphStats, getIcon, getModel, getModelStats, getRegionAnalytics, getSpriteAnalytics, getSpriteStats, getSqlJs, getStyleStats, getTileAnalytics, getTileStats, getUrlHostname, getUserErrorMessage, glyphService, hasImports, hostMatches, i18n, icons, idbFetchHandler, isMapboxHost, isMapboxProtocol, isStyleDownloaded, loadAllStoredRegions, loadGlyphs, loadStyleById, loadStyles, logger, modelKeyBelongsToStyle, modelService, normalizeSpriteProperty, normalizeStyleUrl, optimizeStorage, parseCacheExpiry, parseTileKey, patchStyleForOffline, performCleanup, processBatch, processStyleSources, registerOfflineServiceWorker, resetOfflineMapDB, resolveImports, resolveMapboxUrl, resourceKeyBelongsToStyle, rewriteMapboxCdnTileUrl, safeExecute, sanitizeIndoorExpressions, setupAutoCleanup, spriteService, stopAutoCleanup, t, tileService, unregisterOfflineServiceWorker, validateBounds, validateRegionOptions, validateResource, validateStyleForProvider, validateZoomLevels, verifyAndRepairFonts, verifyAndRepairGlyphs, verifyAndRepairModels, verifyAndRepairSprites };
13951
13968
  //# sourceMappingURL=index.esm.js.map