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