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/dist/index.js CHANGED
@@ -61,45 +61,61 @@ const TILE_CONFIG = {
61
61
  SUPPORTED_EXTENSIONS: ['pbf', 'mvt', 'png', 'jpg', 'jpeg', 'webp', 'glb'],
62
62
  };
63
63
  // Glyph Configuration
64
+ //
65
+ // Glyph servers (MapTiler, Mapbox, OpenFreeMap, ...) serve glyphs in fixed
66
+ // 256-codepoint blocks aligned to a multiple of 256: every request must be
67
+ // `${k * 256}-${k * 256 + 255}`. Strict servers (e.g. MapTiler) reject any
68
+ // other range with HTTP 400 "Invalid glyph range"; lenient ones silently
69
+ // accept them, which is how malformed ranges went unnoticed. See issue #37.
70
+ const GLYPH_BLOCK_SIZE = 256;
71
+ const MAX_GLYPH_CODEPOINT = 65535;
72
+ /**
73
+ * Expand an inclusive Unicode codepoint span into the aligned 256-codepoint
74
+ * glyph blocks that cover it, formatted as `"start-end"` request ranges.
75
+ * The span need not be block-aligned — it is snapped out to whole blocks.
76
+ */
77
+ function glyphBlocksForSpan(start, end) {
78
+ const firstBlock = Math.floor(start / GLYPH_BLOCK_SIZE);
79
+ const lastBlock = Math.floor(Math.min(end, MAX_GLYPH_CODEPOINT) / GLYPH_BLOCK_SIZE);
80
+ const blocks = [];
81
+ for (let block = firstBlock; block <= lastBlock; block++) {
82
+ const blockStart = block * GLYPH_BLOCK_SIZE;
83
+ blocks.push(`${blockStart}-${blockStart + GLYPH_BLOCK_SIZE - 1}`);
84
+ }
85
+ return blocks;
86
+ }
87
+ /**
88
+ * Unicode codepoint spans the comprehensive glyph download aims to cover.
89
+ * Each span is snapped to whole 256-codepoint glyph blocks below, so the
90
+ * resulting request ranges are always server-valid regardless of where the
91
+ * underlying Unicode blocks happen to start or end. To extend coverage, add
92
+ * a span here — never hand-write raw `"start-end"` ranges.
93
+ */
94
+ const GLYPH_COVERAGE_SPANS = [
95
+ [0x0000, 0x12ff], // Latin, Greek, Cyrillic, Hebrew, Arabic, Indic, SE Asian, Georgian, Ethiopic, Cherokee
96
+ [0x1e00, 0x21ff], // Latin Extended Additional, punctuation, symbols, arrows
97
+ [0x2e00, 0x31ff], // CJK radicals, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo
98
+ [0x4e00, 0x4fff], // CJK Unified Ideographs (common subset)
99
+ [0xa000, 0xa4ff], // Yi Syllables and Radicals
100
+ [0xac00, 0xd7ff], // Hangul Syllables (Korean)
101
+ [0xf900, 0xfbff], // CJK Compatibility Ideographs, Alphabetic Presentation Forms
102
+ [0xfe00, 0xfeff], // Variation Selectors
103
+ [0xff00, 0xffff], // Halfwidth and Fullwidth Forms
104
+ ];
105
+ /** Build the deduped, codepoint-ascending list of comprehensive glyph ranges. */
106
+ function buildComprehensiveRanges() {
107
+ const ranges = new Set();
108
+ for (const [start, end] of GLYPH_COVERAGE_SPANS) {
109
+ for (const range of glyphBlocksForSpan(start, end)) {
110
+ ranges.add(range);
111
+ }
112
+ }
113
+ return Array.from(ranges).sort((a, b) => Number(a.split('-')[0]) - Number(b.split('-')[0]));
114
+ }
64
115
  const GLYPH_CONFIG = {
65
116
  DEFAULT_URL: 'https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf',
66
117
  DEFAULT_RANGES: ['0-255'],
67
- COMPREHENSIVE_RANGES: [
68
- '0-255', // Basic Latin + Latin-1 Supplement
69
- '256-511', // Latin Extended-A + Latin Extended-B
70
- '512-767', // IPA Extensions + Spacing Modifier Letters
71
- '768-1023', // Combining Diacritical Marks + Greek and Coptic
72
- '1024-1279', // Cyrillic + Cyrillic Supplement
73
- '1280-1535', // Armenian + Hebrew
74
- '1536-1791', // Arabic
75
- '1792-2047', // Syriac + Arabic Supplement + Thaana
76
- '2048-2303', // NKo + Samaritan + Mandaic
77
- '2304-2559', // Devanagari + Bengali
78
- '2560-2815', // Gurmukhi + Gujarati
79
- '2816-3071', // Oriya + Tamil
80
- '3072-3327', // Telugu + Kannada
81
- '3328-3583', // Malayalam + Sinhala
82
- '3584-3839', // Thai + Lao
83
- '3840-4095', // Tibetan + Myanmar
84
- '4096-4351', // Georgian + Hangul Jamo
85
- '4352-4607', // Ethiopic
86
- '4608-4863', // Cherokee + Canadian Aboriginal
87
- '7680-7935', // Latin Extended Additional
88
- '8192-8447', // General Punctuation, Superscripts/Subscripts, Currency Symbols
89
- '8448-8703', // Letterlike Symbols, Number Forms, Arrows
90
- '11904-12031', // CJK Radicals Supplement
91
- '12032-12255', // Kangxi Radicals + CJK Symbols
92
- '12288-12543', // Hiragana + Katakana
93
- '12544-12799', // Bopomofo + Hangul Compatibility Jamo
94
- '19968-20223', // CJK Unified Ideographs (first block)
95
- '20224-20479', // CJK Unified Ideographs
96
- '40960-42127', // Yi Syllables + Yi Radicals
97
- '44032-55203', // Hangul Syllables (Korean)
98
- '63744-64255', // CJK Compatibility Ideographs
99
- '64256-64511', // Alphabetic Presentation Forms
100
- '65024-65279', // Variation Selectors
101
- '65280-65535', // Halfwidth and Fullwidth Forms
102
- ],
118
+ COMPREHENSIVE_RANGES: buildComprehensiveRanges(),
103
119
  };
104
120
  // Style Configuration
105
121
  const STYLE_CONFIG = {
@@ -12943,14 +12959,15 @@ class RegionControl {
12943
12959
  * Download Manager for offline map regions.
12944
12960
  *
12945
12961
  * This module handles the complete download workflow for offline map regions,
12946
- * including styles, sprites, glyphs (fonts), and map tiles. It provides
12962
+ * including styles, sprites, glyphs (fonts), 3D models, and map tiles. It provides
12947
12963
  * progress tracking across all download phases.
12948
12964
  *
12949
12965
  * **Download Phases:**
12950
12966
  * 1. `style` - Downloads the map style JSON and processes sources
12951
12967
  * 2. `sprites` - Downloads sprite images and JSON for map icons
12952
12968
  * 3. `glyphs` - Downloads font glyphs for text rendering
12953
- * 4. `tiles` - Downloads map tiles for the specified region bounds
12969
+ * 4. `models` - Downloads 3D model assets (Mapbox Standard trees / turbines)
12970
+ * 5. `tiles` - Downloads map tiles for the specified region bounds
12954
12971
  *
12955
12972
  * **Usage:**
12956
12973
  * The DownloadManager is typically instantiated by the OfflineManagerControl
@@ -13210,7 +13227,7 @@ class ModalManager {
13210
13227
  * - Integrates seamlessly as a MapLibre GL control
13211
13228
  * - Intercepts fetch requests to serve offline resources from IndexedDB
13212
13229
  * - Supports light and dark themes
13213
- * - Shows download progress across all phases (style, sprites, glyphs, tiles)
13230
+ * - Shows download progress across all phases (style, sprites, glyphs, models, tiles)
13214
13231
  * - Optional bounding box visualization for regions
13215
13232
  *
13216
13233
  * @example
@@ -13979,6 +13996,7 @@ exports.DB_VERSION = DB_VERSION;
13979
13996
  exports.DOWNLOAD_DEFAULTS = DOWNLOAD_DEFAULTS;
13980
13997
  exports.ERROR_MESSAGES = ERROR_MESSAGES;
13981
13998
  exports.FontService = FontService;
13999
+ exports.GLYPH_BLOCK_SIZE = GLYPH_BLOCK_SIZE;
13982
14000
  exports.GLYPH_CONFIG = GLYPH_CONFIG;
13983
14001
  exports.GZIP_MAGIC_BYTES = GZIP_MAGIC_BYTES;
13984
14002
  exports.GlyphService = GlyphService;
@@ -13987,6 +14005,7 @@ exports.MAPBOX_API = MAPBOX_API;
13987
14005
  exports.MAPBOX_CACHE_TTL = MAPBOX_CACHE_TTL;
13988
14006
  exports.MAPBOX_CLASSIC_STYLES = MAPBOX_CLASSIC_STYLES;
13989
14007
  exports.MAP_PROVIDERS = MAP_PROVIDERS;
14008
+ exports.MAX_GLYPH_CODEPOINT = MAX_GLYPH_CODEPOINT;
13990
14009
  exports.MaintenanceService = MaintenanceService;
13991
14010
  exports.ModelService = ModelService;
13992
14011
  exports.OfflineManagerControl = OfflineManagerControl;