maplibre-gl 6.6.0 → 6.7.0

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 (69) hide show
  1. package/build/generate-unicode-data.ts +83 -0
  2. package/dist/maplibre-gl-dev.mjs +480 -80
  3. package/dist/maplibre-gl-dev.mjs.map +1 -1
  4. package/dist/maplibre-gl-shared-dev.mjs +1578 -983
  5. package/dist/maplibre-gl-shared-dev.mjs.map +1 -1
  6. package/dist/maplibre-gl-shared.mjs +2 -2
  7. package/dist/maplibre-gl-shared.mjs.map +1 -1
  8. package/dist/maplibre-gl-worker-dev.mjs +7 -6
  9. package/dist/maplibre-gl-worker-dev.mjs.map +1 -1
  10. package/dist/maplibre-gl-worker.mjs +2 -2
  11. package/dist/maplibre-gl-worker.mjs.map +1 -1
  12. package/dist/maplibre-gl.d.ts +306 -66
  13. package/dist/maplibre-gl.mjs +36 -36
  14. package/dist/maplibre-gl.mjs.map +1 -1
  15. package/package.json +23 -18
  16. package/src/data/bucket/symbol_bucket.test.ts +45 -12
  17. package/src/data/bucket/symbol_bucket.ts +39 -18
  18. package/src/data/bucket.ts +11 -3
  19. package/src/data/feature_index.ts +35 -6
  20. package/src/geo/projection/mercator_transform.test.ts +24 -4
  21. package/src/geo/projection/mercator_transform.ts +1 -1
  22. package/src/geo/projection/vertical_perspective_transform.ts +1 -1
  23. package/src/render/font_face_manager.test.ts +295 -0
  24. package/src/render/font_face_manager.ts +249 -0
  25. package/src/render/glyph_atlas.ts +3 -7
  26. package/src/render/glyph_manager.test.ts +251 -94
  27. package/src/render/glyph_manager.ts +195 -52
  28. package/src/render/terrain.test.ts +36 -0
  29. package/src/render/terrain.ts +17 -7
  30. package/src/source/geojson_worker_source.test.ts +4 -53
  31. package/src/source/image_source.test.ts +53 -0
  32. package/src/source/image_source.ts +24 -2
  33. package/src/source/vector_tile_worker_source.test.ts +46 -38
  34. package/src/source/vector_tile_worker_source.ts +6 -1
  35. package/src/source/worker_source.ts +1 -5
  36. package/src/source/worker_tile.test.ts +6 -22
  37. package/src/source/worker_tile.ts +8 -5
  38. package/src/style/style.test.ts +92 -0
  39. package/src/style/style.ts +67 -3
  40. package/src/style/style_image.ts +5 -1
  41. package/src/style/style_layer/symbol_style_layer.ts +7 -7
  42. package/src/style/style_layer/symbol_style_layer_properties.g.ts +3 -3
  43. package/src/symbol/shaping.test.ts +436 -2
  44. package/src/symbol/shaping.ts +298 -113
  45. package/src/symbol/symbol_layout.ts +1 -1
  46. package/src/symbol/tagged_string.test.ts +29 -6
  47. package/src/symbol/tagged_string.ts +151 -89
  48. package/src/tile/terrain_tile_manager.test.ts +23 -0
  49. package/src/tile/terrain_tile_manager.ts +6 -1
  50. package/src/ui/camera.test.ts +6 -5
  51. package/src/ui/camera.ts +3 -3
  52. package/src/ui/control/navigation_control.test.ts +32 -0
  53. package/src/ui/control/navigation_control.ts +3 -3
  54. package/src/ui/map.ts +87 -21
  55. package/src/ui/map_tests/map_render.test.ts +139 -1
  56. package/src/ui/map_tests/map_style.test.ts +17 -0
  57. package/src/ui/map_tests/map_terrain.test.ts +60 -1
  58. package/src/ui/map_tests/map_webgl.test.ts +41 -11
  59. package/src/ui/map_tests/map_zoom.test.ts +11 -0
  60. package/src/util/actor_messages.ts +3 -6
  61. package/src/util/gpu_initialization_error.ts +2 -1
  62. package/src/util/graphemes.test.ts +79 -0
  63. package/src/util/graphemes.ts +79 -0
  64. package/src/util/test/util.ts +46 -1
  65. package/src/util/unicode_properties.g.ts +28 -0
  66. package/src/util/util.ts +6 -2
  67. package/src/webgl/draw/draw_symbol.ts +1 -1
  68. package/src/style/load_glyph_range.test.ts +0 -74
  69. package/src/style/load_glyph_range.ts +0 -32
@@ -313,6 +313,61 @@ async function requiresComplexTextShaping(): Promise<string> {
313
313
  return set.toString();
314
314
  }
315
315
 
316
+ /**
317
+ * Returns a character class matching every character that can take part in a grapheme cluster of
318
+ * more than one codepoint.
319
+ *
320
+ * These are the characters the grapheme break rules of UAX #29 join to their neighbours: combining
321
+ * marks, the joiners, the Hangul jamo that build a syllable, the regional indicators that pair into
322
+ * a flag, and the carriage return that pairs with a line feed. Text with none of them has one
323
+ * cluster per codepoint, and does not need segmenting at all.
324
+ */
325
+ async function canFormGraphemeCluster(): Promise<string> {
326
+ const set = regenerate.default();
327
+ for (const category of ['CR', 'Extend', 'L', 'LV', 'LVT', 'Prepend', 'Regional_Indicator', 'SpacingMark', 'T', 'V', 'ZWJ']) {
328
+ set.add((await import(`@unicode/unicode-${unicodeVersion}/Grapheme_Cluster_Break/${category}/code-points.js`)).default);
329
+ }
330
+
331
+ return set.toString();
332
+ }
333
+
334
+ /**
335
+ * Returns a character class matching the scripts that do not put spaces between words.
336
+ *
337
+ * Text in these has no punctuation to break a line at, so the only way to wrap it is to ask the
338
+ * browser's word segmenter where the words are. Elsewhere the segmenter is the wrong tool: it
339
+ * isolates a comma as a word of its own, and a line must not begin with one.
340
+ */
341
+ async function isWrittenWithoutSpaces(): Promise<string> {
342
+ const set = await createSet([], [
343
+ 'Balinese',
344
+ 'Javanese',
345
+ 'Khmer',
346
+ 'Lao',
347
+ 'Myanmar',
348
+ 'Thai',
349
+ 'Tibetan',
350
+ ]);
351
+
352
+ return set.toString();
353
+ }
354
+
355
+ /**
356
+ * Returns a character class matching the characters that join the grapheme cluster they end to the
357
+ * one after it.
358
+ *
359
+ * An invisible stacker -- a virama and its equivalents in other scripts -- joins the consonant
360
+ * before it to the one after it, and a zero-width joiner does the same for emoji. `Intl.Segmenter`
361
+ * puts a cluster boundary after both, so the two halves have to be put back together.
362
+ */
363
+ async function joinsToTheFollowingGrapheme(): Promise<string> {
364
+ const set = regenerate.default();
365
+ set.add((await import(`@unicode/unicode-${unicodeVersion}/Indic_Syllabic_Category/Invisible_Stacker/code-points.js`)).default);
366
+ set.add(0x200d);
367
+
368
+ return set.toString();
369
+ }
370
+
316
371
  fs.writeFileSync('src/util/unicode_properties.g.ts',
317
372
  `// This file is generated. Edit build/generate-unicode-data.ts, then run \`npm run generate-unicode-data\`.
318
373
 
@@ -367,4 +422,32 @@ export function codePointHasNeutralVerticalOrientation(codePoint: number): boole
367
422
  export function codePointRequiresComplexTextShaping(codePoint: number): boolean {
368
423
  return /${await requiresComplexTextShaping()}/gim.test(String.fromCodePoint(codePoint));
369
424
  }
425
+
426
+ /**
427
+ * Returns whether the text could hold a grapheme cluster of more than one codepoint, and so is worth
428
+ * segmenting. A negative answer means every codepoint of it stands alone.
429
+ */
430
+ export function textCanContainGraphemeClusters(text: string): boolean {
431
+ return /${await canFormGraphemeCluster()}/.test(text);
432
+ }
433
+
434
+ /**
435
+ * Returns whether the given codepoint belongs to a script that does not put spaces between words,
436
+ * and so can only be wrapped by asking the word segmenter where its words are.
437
+ */
438
+ export function codePointIsWrittenWithoutSpaces(codePoint: number): boolean {
439
+ return /${await isWrittenWithoutSpaces()}/gim.test(String.fromCodePoint(codePoint));
440
+ }
441
+
442
+ /**
443
+ * Returns whether two grapheme clusters found by \`Intl.Segmenter\` are really one unit of writing,
444
+ * and so have to be measured and drawn as a whole.
445
+ *
446
+ * The segmenter follows the tailored rules CLDR uses for stepping a cursor through text, which put a
447
+ * boundary after an invisible stacker and before a spacing mark. Laying text out wants the untailored
448
+ * rules of UAX #29 instead: \`လ\`, \`ာ\` and \`း\` are one Burmese syllable, not three.
449
+ */
450
+ export function canCombineGraphemes(former: string, latter: string): boolean {
451
+ return /(?:${await joinsToTheFollowingGrapheme()})$/.test(former) || /^\\p{gc=Mc}/u.test(latter);
452
+ }
370
453
  `);