map-gl-offline 0.8.2 → 0.8.3

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.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 = {
@@ -13947,5 +13963,5 @@ class OfflineManagerControl {
13947
13963
  }
13948
13964
  }
13949
13965
 
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 };
13966
+ 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
13967
  //# sourceMappingURL=index.esm.js.map