@mapwhit/tilerenderer 1.0.0 → 1.1.1

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 (236) hide show
  1. package/build/min/package.json +2 -1
  2. package/build/min/src/shaders/_prelude.fragment.glsl.js +1 -1
  3. package/build/min/src/shaders/_prelude.vertex.glsl.js +1 -1
  4. package/build/min/src/shaders/background.fragment.glsl.js +1 -1
  5. package/build/min/src/shaders/background.vertex.glsl.js +1 -1
  6. package/build/min/src/shaders/background_pattern.fragment.glsl.js +1 -1
  7. package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
  8. package/build/min/src/shaders/circle.fragment.glsl.js +1 -1
  9. package/build/min/src/shaders/circle.vertex.glsl.js +1 -1
  10. package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
  11. package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
  12. package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
  13. package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
  14. package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
  15. package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
  16. package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
  17. package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
  18. package/build/min/src/shaders/fill.fragment.glsl.js +1 -1
  19. package/build/min/src/shaders/fill.vertex.glsl.js +1 -1
  20. package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +1 -1
  21. package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +1 -1
  22. package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +1 -1
  23. package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +1 -1
  24. package/build/min/src/shaders/fill_outline.fragment.glsl.js +1 -1
  25. package/build/min/src/shaders/fill_outline.vertex.glsl.js +1 -1
  26. package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +1 -1
  27. package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +1 -1
  28. package/build/min/src/shaders/fill_pattern.fragment.glsl.js +1 -1
  29. package/build/min/src/shaders/fill_pattern.vertex.glsl.js +1 -1
  30. package/build/min/src/shaders/heatmap.fragment.glsl.js +1 -1
  31. package/build/min/src/shaders/heatmap.vertex.glsl.js +1 -1
  32. package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +1 -1
  33. package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
  34. package/build/min/src/shaders/hillshade.fragment.glsl.js +1 -1
  35. package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
  36. package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +1 -1
  37. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
  38. package/build/min/src/shaders/line.fragment.glsl.js +1 -1
  39. package/build/min/src/shaders/line.vertex.glsl.js +1 -1
  40. package/build/min/src/shaders/line_gradient.fragment.glsl.js +1 -1
  41. package/build/min/src/shaders/line_gradient.vertex.glsl.js +1 -1
  42. package/build/min/src/shaders/line_pattern.fragment.glsl.js +1 -1
  43. package/build/min/src/shaders/line_pattern.vertex.glsl.js +1 -1
  44. package/build/min/src/shaders/line_sdf.fragment.glsl.js +1 -1
  45. package/build/min/src/shaders/line_sdf.vertex.glsl.js +1 -1
  46. package/build/min/src/shaders/raster.fragment.glsl.js +1 -1
  47. package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
  48. package/build/min/src/shaders/symbol_icon.fragment.glsl.js +1 -1
  49. package/build/min/src/shaders/symbol_icon.vertex.glsl.js +1 -1
  50. package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +1 -1
  51. package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +1 -1
  52. package/package.json +3 -2
  53. package/src/data/array_types.js +54 -81
  54. package/src/data/bucket/circle_attributes.js +2 -4
  55. package/src/data/bucket/circle_bucket.js +19 -13
  56. package/src/data/bucket/fill_attributes.js +2 -4
  57. package/src/data/bucket/fill_bucket.js +38 -24
  58. package/src/data/bucket/fill_extrusion_attributes.js +2 -4
  59. package/src/data/bucket/fill_extrusion_bucket.js +56 -34
  60. package/src/data/bucket/heatmap_bucket.js +2 -7
  61. package/src/data/bucket/line_attributes.js +2 -4
  62. package/src/data/bucket/line_bucket.js +207 -159
  63. package/src/data/bucket/pattern_attributes.js +2 -4
  64. package/src/data/bucket/pattern_bucket_features.js +5 -7
  65. package/src/data/bucket/symbol_attributes.js +12 -26
  66. package/src/data/bucket/symbol_bucket.js +111 -221
  67. package/src/data/bucket/symbol_buffers.js +62 -0
  68. package/src/data/bucket/symbol_collision_buffers.js +33 -0
  69. package/src/data/bucket.js +2 -6
  70. package/src/data/dem_data.js +11 -7
  71. package/src/data/extent.js +1 -1
  72. package/src/data/feature_index.js +35 -20
  73. package/src/data/index_array_type.js +1 -6
  74. package/src/data/load_geometry.js +6 -9
  75. package/src/data/pos_attributes.js +2 -3
  76. package/src/data/program_configuration.js +44 -26
  77. package/src/data/raster_bounds_attributes.js +2 -2
  78. package/src/data/segment.js +4 -3
  79. package/src/geo/coordinate.js +1 -1
  80. package/src/geo/lng_lat.js +3 -3
  81. package/src/geo/lng_lat_bounds.js +8 -4
  82. package/src/geo/transform.js +69 -30
  83. package/src/gl/color_mode.js +2 -2
  84. package/src/gl/context.js +28 -29
  85. package/src/gl/cull_face_mode.js +1 -1
  86. package/src/gl/depth_mode.js +1 -1
  87. package/src/gl/framebuffer.js +8 -4
  88. package/src/gl/index_buffer.js +2 -2
  89. package/src/gl/stencil_mode.js +1 -1
  90. package/src/gl/value.js +33 -68
  91. package/src/gl/vertex_buffer.js +2 -2
  92. package/src/index.js +49 -25
  93. package/src/render/draw_background.js +14 -9
  94. package/src/render/draw_circle.js +11 -8
  95. package/src/render/draw_collision_debug.js +11 -8
  96. package/src/render/draw_debug.js +16 -14
  97. package/src/render/draw_fill.js +19 -12
  98. package/src/render/draw_fill_extrusion.js +12 -9
  99. package/src/render/draw_heatmap.js +17 -12
  100. package/src/render/draw_hillshade.js +12 -9
  101. package/src/render/draw_line.js +30 -16
  102. package/src/render/draw_raster.js +17 -13
  103. package/src/render/draw_symbol.js +22 -17
  104. package/src/render/glyph_atlas.js +9 -5
  105. package/src/render/glyph_manager.js +1 -1
  106. package/src/render/image_atlas.js +4 -7
  107. package/src/render/image_manager.js +6 -9
  108. package/src/render/line_atlas.js +2 -2
  109. package/src/render/painter.js +65 -47
  110. package/src/render/program/background_program.js +6 -13
  111. package/src/render/program/circle_program.js +4 -6
  112. package/src/render/program/clipping_mask_program.js +3 -5
  113. package/src/render/program/collision_program.js +4 -6
  114. package/src/render/program/debug_program.js +3 -5
  115. package/src/render/program/fill_extrusion_program.js +8 -14
  116. package/src/render/program/fill_program.js +10 -21
  117. package/src/render/program/heatmap_program.js +8 -14
  118. package/src/render/program/hillshade_program.js +10 -16
  119. package/src/render/program/line_program.js +11 -22
  120. package/src/render/program/pattern.js +5 -7
  121. package/src/render/program/program_uniforms.js +13 -20
  122. package/src/render/program/raster_program.js +3 -5
  123. package/src/render/program/symbol_program.js +5 -7
  124. package/src/render/program.js +5 -6
  125. package/src/render/texture.js +1 -1
  126. package/src/render/tile_mask.js +6 -4
  127. package/src/render/uniform_binding.js +9 -20
  128. package/src/render/vertex_array_object.js +5 -3
  129. package/src/shaders/encode_attribute.js +2 -6
  130. package/src/shaders/index.js +103 -51
  131. package/src/source/geojson_source.js +11 -7
  132. package/src/source/geojson_worker_source.js +7 -7
  133. package/src/source/geojson_wrapper.js +4 -4
  134. package/src/source/image_source.js +11 -12
  135. package/src/source/load_tilejson.js +3 -3
  136. package/src/source/pixels_to_tile_units.js +3 -3
  137. package/src/source/query_features.js +13 -10
  138. package/src/source/raster_dem_tile_source.js +12 -10
  139. package/src/source/raster_tile_source.js +13 -9
  140. package/src/source/resources/glyphs.js +2 -3
  141. package/src/source/resources/index.js +2 -4
  142. package/src/source/rtl_text_plugin.js +8 -8
  143. package/src/source/source.js +9 -15
  144. package/src/source/source_cache.js +114 -49
  145. package/src/source/source_state.js +37 -14
  146. package/src/source/tile.js +38 -23
  147. package/src/source/tile_bounds.js +15 -8
  148. package/src/source/tile_cache.js +2 -2
  149. package/src/source/tile_id.js +30 -23
  150. package/src/source/vector_tile_source.js +10 -8
  151. package/src/source/vector_tile_worker_source.js +4 -4
  152. package/src/source/worker_tile.js +24 -22
  153. package/src/style/create_style_layer.js +11 -11
  154. package/src/style/evaluation_parameters.js +4 -6
  155. package/src/style/light.js +5 -5
  156. package/src/style/load_sprite.js +6 -6
  157. package/src/style/parse_glyph_pbf.js +21 -17
  158. package/src/style/pauseable_placement.js +3 -4
  159. package/src/style/properties.js +21 -44
  160. package/src/style/query_utils.js +4 -10
  161. package/src/style/style.js +64 -34
  162. package/src/style/style_layer/background_style_layer.js +3 -4
  163. package/src/style/style_layer/background_style_layer_properties.js +2 -2
  164. package/src/style/style_layer/circle_style_layer.js +12 -9
  165. package/src/style/style_layer/circle_style_layer_properties.js +2 -2
  166. package/src/style/style_layer/fill_extrusion_style_layer.js +16 -13
  167. package/src/style/style_layer/fill_extrusion_style_layer_properties.js +2 -2
  168. package/src/style/style_layer/fill_style_layer.js +6 -7
  169. package/src/style/style_layer/fill_style_layer_properties.js +2 -2
  170. package/src/style/style_layer/heatmap_style_layer.js +5 -6
  171. package/src/style/style_layer/heatmap_style_layer_properties.js +2 -2
  172. package/src/style/style_layer/hillshade_style_layer.js +3 -4
  173. package/src/style/style_layer/hillshade_style_layer_properties.js +2 -2
  174. package/src/style/style_layer/line_style_layer.js +10 -11
  175. package/src/style/style_layer/line_style_layer_properties.js +5 -5
  176. package/src/style/style_layer/raster_style_layer.js +3 -4
  177. package/src/style/style_layer/raster_style_layer_properties.js +2 -2
  178. package/src/style/style_layer/symbol_style_layer.js +7 -8
  179. package/src/style/style_layer/symbol_style_layer_properties.js +2 -2
  180. package/src/style/style_layer.js +21 -20
  181. package/src/style/style_layer_index.js +2 -2
  182. package/src/style/zoom_history.js +1 -1
  183. package/src/style-spec/error/parsing_error.js +1 -1
  184. package/src/style-spec/error/validation_error.js +5 -3
  185. package/src/style-spec/feature_filter/convert.js +17 -9
  186. package/src/style-spec/feature_filter/index.js +13 -9
  187. package/src/style-spec/util/eval_support.js +2 -2
  188. package/src/style-spec/util/ref_properties.js +1 -1
  189. package/src/symbol/anchor.js +2 -2
  190. package/src/symbol/check_max_angle.js +13 -5
  191. package/src/symbol/clip_line.js +2 -3
  192. package/src/symbol/collision_feature.js +8 -4
  193. package/src/symbol/collision_index.js +5 -7
  194. package/src/symbol/cross_tile_symbol_index.js +5 -5
  195. package/src/symbol/get_anchors.js +15 -8
  196. package/src/symbol/grid_index.js +5 -3
  197. package/src/symbol/mergelines.js +2 -2
  198. package/src/symbol/opacity_state.js +1 -1
  199. package/src/symbol/placement.js +25 -20
  200. package/src/symbol/projection.js +29 -28
  201. package/src/symbol/quads.js +10 -12
  202. package/src/symbol/shaping.js +27 -19
  203. package/src/symbol/symbol_layout.js +17 -21
  204. package/src/symbol/symbol_size.js +13 -12
  205. package/src/symbol/transform_text.js +3 -3
  206. package/src/ui/camera.js +34 -18
  207. package/src/ui/map.js +54 -34
  208. package/src/util/async.js +11 -5
  209. package/src/util/browser.js +1 -1
  210. package/src/util/callback.js +3 -9
  211. package/src/util/classify_rings.js +13 -8
  212. package/src/util/color_ramp.js +3 -3
  213. package/src/util/config.js +4 -4
  214. package/src/util/dictionary_coder.js +2 -3
  215. package/src/util/dom.js +7 -3
  216. package/src/util/find_pole_of_inaccessibility.js +29 -14
  217. package/src/util/group_layers.js +1 -1
  218. package/src/util/image.js +3 -8
  219. package/src/util/interpolate.js +1 -1
  220. package/src/util/intersection_tests.js +80 -42
  221. package/src/util/is_char_in_unicode_block.js +1 -1
  222. package/src/util/key.js +7 -3
  223. package/src/util/loader/image.js +1 -1
  224. package/src/util/object.js +25 -23
  225. package/src/util/script_detection.js +212 -91
  226. package/src/util/struct_array.js +8 -40
  227. package/src/util/task_queue.js +11 -7
  228. package/src/util/throttle.js +2 -2
  229. package/src/util/tile_cover.js +8 -5
  230. package/src/util/token.js +1 -1
  231. package/src/util/unique_id.js +2 -2
  232. package/src/util/util.js +21 -29
  233. package/src/util/vectortile_to_geojson.js +4 -2
  234. package/src/util/verticalize_punctuation.js +3 -7
  235. package/src/util/warn.js +4 -4
  236. package/src/util/web_worker.js +3 -3
@@ -1,73 +1,118 @@
1
- const isChar = require('./is_char_in_unicode_block');
1
+ import isChar from './is_char_in_unicode_block.js';
2
2
 
3
- module.exports = {
4
- allowsIdeographicBreaking,
5
- allowsVerticalWritingMode,
6
- allowsLetterSpacing,
7
- charAllowsLetterSpacing,
8
- charAllowsIdeographicBreaking,
9
- charHasUprightVerticalOrientation,
10
- charHasNeutralVerticalOrientation,
11
- charHasRotatedVerticalOrientation,
12
- charInSupportedScript,
13
- isStringInSupportedScript
14
- };
15
-
16
- function allowsIdeographicBreaking(chars) {
3
+ export function allowsIdeographicBreaking(chars) {
17
4
  for (const char of chars) {
18
- if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) return false;
5
+ if (!charAllowsIdeographicBreaking(char.charCodeAt(0))) {
6
+ return false;
7
+ }
19
8
  }
20
9
  return true;
21
10
  }
22
11
 
23
- function allowsVerticalWritingMode(chars) {
12
+ export function allowsVerticalWritingMode(chars) {
24
13
  for (const char of chars) {
25
- if (charHasUprightVerticalOrientation(char.charCodeAt(0))) return true;
14
+ if (charHasUprightVerticalOrientation(char.charCodeAt(0))) {
15
+ return true;
16
+ }
26
17
  }
27
18
  return false;
28
19
  }
29
20
 
30
- function allowsLetterSpacing(chars) {
21
+ export function allowsLetterSpacing(chars) {
31
22
  for (const char of chars) {
32
- if (!charAllowsLetterSpacing(char.charCodeAt(0))) return false;
23
+ if (!charAllowsLetterSpacing(char.charCodeAt(0))) {
24
+ return false;
25
+ }
33
26
  }
34
27
  return true;
35
28
  }
36
29
 
37
- function charAllowsLetterSpacing(char) {
38
- if (isChar['Arabic'](char)) return false;
39
- if (isChar['Arabic Supplement'](char)) return false;
40
- if (isChar['Arabic Extended-A'](char)) return false;
41
- if (isChar['Arabic Presentation Forms-A'](char)) return false;
42
- if (isChar['Arabic Presentation Forms-B'](char)) return false;
30
+ export function charAllowsLetterSpacing(char) {
31
+ if (isChar['Arabic'](char)) {
32
+ return false;
33
+ }
34
+ if (isChar['Arabic Supplement'](char)) {
35
+ return false;
36
+ }
37
+ if (isChar['Arabic Extended-A'](char)) {
38
+ return false;
39
+ }
40
+ if (isChar['Arabic Presentation Forms-A'](char)) {
41
+ return false;
42
+ }
43
+ if (isChar['Arabic Presentation Forms-B'](char)) {
44
+ return false;
45
+ }
43
46
 
44
47
  return true;
45
48
  }
46
49
 
47
- function charAllowsIdeographicBreaking(char) {
50
+ export function charAllowsIdeographicBreaking(char) {
48
51
  // Return early for characters outside all ideographic ranges.
49
- if (char < 0x2e80) return false;
52
+ if (char < 0x2e80) {
53
+ return false;
54
+ }
50
55
 
51
- if (isChar['Bopomofo Extended'](char)) return true;
52
- if (isChar['Bopomofo'](char)) return true;
53
- if (isChar['CJK Compatibility Forms'](char)) return true;
54
- if (isChar['CJK Compatibility Ideographs'](char)) return true;
55
- if (isChar['CJK Compatibility'](char)) return true;
56
- if (isChar['CJK Radicals Supplement'](char)) return true;
57
- if (isChar['CJK Strokes'](char)) return true;
58
- if (isChar['CJK Symbols and Punctuation'](char)) return true;
59
- if (isChar['CJK Unified Ideographs Extension A'](char)) return true;
60
- if (isChar['CJK Unified Ideographs'](char)) return true;
61
- if (isChar['Enclosed CJK Letters and Months'](char)) return true;
62
- if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;
63
- if (isChar['Hiragana'](char)) return true;
64
- if (isChar['Ideographic Description Characters'](char)) return true;
65
- if (isChar['Kangxi Radicals'](char)) return true;
66
- if (isChar['Katakana Phonetic Extensions'](char)) return true;
67
- if (isChar['Katakana'](char)) return true;
68
- if (isChar['Vertical Forms'](char)) return true;
69
- if (isChar['Yi Radicals'](char)) return true;
70
- if (isChar['Yi Syllables'](char)) return true;
56
+ if (isChar['Bopomofo Extended'](char)) {
57
+ return true;
58
+ }
59
+ if (isChar['Bopomofo'](char)) {
60
+ return true;
61
+ }
62
+ if (isChar['CJK Compatibility Forms'](char)) {
63
+ return true;
64
+ }
65
+ if (isChar['CJK Compatibility Ideographs'](char)) {
66
+ return true;
67
+ }
68
+ if (isChar['CJK Compatibility'](char)) {
69
+ return true;
70
+ }
71
+ if (isChar['CJK Radicals Supplement'](char)) {
72
+ return true;
73
+ }
74
+ if (isChar['CJK Strokes'](char)) {
75
+ return true;
76
+ }
77
+ if (isChar['CJK Symbols and Punctuation'](char)) {
78
+ return true;
79
+ }
80
+ if (isChar['CJK Unified Ideographs Extension A'](char)) {
81
+ return true;
82
+ }
83
+ if (isChar['CJK Unified Ideographs'](char)) {
84
+ return true;
85
+ }
86
+ if (isChar['Enclosed CJK Letters and Months'](char)) {
87
+ return true;
88
+ }
89
+ if (isChar['Halfwidth and Fullwidth Forms'](char)) {
90
+ return true;
91
+ }
92
+ if (isChar['Hiragana'](char)) {
93
+ return true;
94
+ }
95
+ if (isChar['Ideographic Description Characters'](char)) {
96
+ return true;
97
+ }
98
+ if (isChar['Kangxi Radicals'](char)) {
99
+ return true;
100
+ }
101
+ if (isChar['Katakana Phonetic Extensions'](char)) {
102
+ return true;
103
+ }
104
+ if (isChar['Katakana'](char)) {
105
+ return true;
106
+ }
107
+ if (isChar['Vertical Forms'](char)) {
108
+ return true;
109
+ }
110
+ if (isChar['Yi Radicals'](char)) {
111
+ return true;
112
+ }
113
+ if (isChar['Yi Syllables'](char)) {
114
+ return true;
115
+ }
71
116
 
72
117
  return false;
73
118
  }
@@ -92,7 +137,7 @@ function charAllowsIdeographicBreaking(char) {
92
137
  * “neutral” character to be drawn upright as well.
93
138
  * @private
94
139
  */
95
- function charHasUprightVerticalOrientation(char) {
140
+ export function charHasUprightVerticalOrientation(char) {
96
141
  if (
97
142
  char === 0x02ea /* modifier letter yin departing tone mark */ ||
98
143
  char === 0x02eb /* modifier letter yang departing tone mark */
@@ -102,19 +147,33 @@ function charHasUprightVerticalOrientation(char) {
102
147
 
103
148
  // Return early for characters outside all ranges whose characters remain
104
149
  // upright in vertical writing mode.
105
- if (char < 0x1100) return false;
150
+ if (char < 0x1100) {
151
+ return false;
152
+ }
106
153
 
107
- if (isChar['Bopomofo Extended'](char)) return true;
108
- if (isChar['Bopomofo'](char)) return true;
154
+ if (isChar['Bopomofo Extended'](char)) {
155
+ return true;
156
+ }
157
+ if (isChar['Bopomofo'](char)) {
158
+ return true;
159
+ }
109
160
  if (isChar['CJK Compatibility Forms'](char)) {
110
161
  if (!((char >= 0xfe49 /* dashed overline */ && char <= 0xfe4f) /* wavy low line */)) {
111
162
  return true;
112
163
  }
113
164
  }
114
- if (isChar['CJK Compatibility Ideographs'](char)) return true;
115
- if (isChar['CJK Compatibility'](char)) return true;
116
- if (isChar['CJK Radicals Supplement'](char)) return true;
117
- if (isChar['CJK Strokes'](char)) return true;
165
+ if (isChar['CJK Compatibility Ideographs'](char)) {
166
+ return true;
167
+ }
168
+ if (isChar['CJK Compatibility'](char)) {
169
+ return true;
170
+ }
171
+ if (isChar['CJK Radicals Supplement'](char)) {
172
+ return true;
173
+ }
174
+ if (isChar['CJK Strokes'](char)) {
175
+ return true;
176
+ }
118
177
  if (isChar['CJK Symbols and Punctuation'](char)) {
119
178
  if (
120
179
  !((char >= 0x3008 /* left angle bracket */ && char <= 0x3011) /* right black lenticular bracket */) &&
@@ -124,19 +183,45 @@ function charHasUprightVerticalOrientation(char) {
124
183
  return true;
125
184
  }
126
185
  }
127
- if (isChar['CJK Unified Ideographs Extension A'](char)) return true;
128
- if (isChar['CJK Unified Ideographs'](char)) return true;
129
- if (isChar['Enclosed CJK Letters and Months'](char)) return true;
130
- if (isChar['Hangul Compatibility Jamo'](char)) return true;
131
- if (isChar['Hangul Jamo Extended-A'](char)) return true;
132
- if (isChar['Hangul Jamo Extended-B'](char)) return true;
133
- if (isChar['Hangul Jamo'](char)) return true;
134
- if (isChar['Hangul Syllables'](char)) return true;
135
- if (isChar['Hiragana'](char)) return true;
136
- if (isChar['Ideographic Description Characters'](char)) return true;
137
- if (isChar['Kanbun'](char)) return true;
138
- if (isChar['Kangxi Radicals'](char)) return true;
139
- if (isChar['Katakana Phonetic Extensions'](char)) return true;
186
+ if (isChar['CJK Unified Ideographs Extension A'](char)) {
187
+ return true;
188
+ }
189
+ if (isChar['CJK Unified Ideographs'](char)) {
190
+ return true;
191
+ }
192
+ if (isChar['Enclosed CJK Letters and Months'](char)) {
193
+ return true;
194
+ }
195
+ if (isChar['Hangul Compatibility Jamo'](char)) {
196
+ return true;
197
+ }
198
+ if (isChar['Hangul Jamo Extended-A'](char)) {
199
+ return true;
200
+ }
201
+ if (isChar['Hangul Jamo Extended-B'](char)) {
202
+ return true;
203
+ }
204
+ if (isChar['Hangul Jamo'](char)) {
205
+ return true;
206
+ }
207
+ if (isChar['Hangul Syllables'](char)) {
208
+ return true;
209
+ }
210
+ if (isChar['Hiragana'](char)) {
211
+ return true;
212
+ }
213
+ if (isChar['Ideographic Description Characters'](char)) {
214
+ return true;
215
+ }
216
+ if (isChar['Kanbun'](char)) {
217
+ return true;
218
+ }
219
+ if (isChar['Kangxi Radicals'](char)) {
220
+ return true;
221
+ }
222
+ if (isChar['Katakana Phonetic Extensions'](char)) {
223
+ return true;
224
+ }
140
225
  if (isChar['Katakana'](char)) {
141
226
  if (char !== 0x30fc /* katakana-hiragana prolonged sound mark */) {
142
227
  return true;
@@ -166,12 +251,24 @@ function charHasUprightVerticalOrientation(char) {
166
251
  return true;
167
252
  }
168
253
  }
169
- if (isChar['Unified Canadian Aboriginal Syllabics'](char)) return true;
170
- if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) return true;
171
- if (isChar['Vertical Forms'](char)) return true;
172
- if (isChar['Yijing Hexagram Symbols'](char)) return true;
173
- if (isChar['Yi Syllables'](char)) return true;
174
- if (isChar['Yi Radicals'](char)) return true;
254
+ if (isChar['Unified Canadian Aboriginal Syllabics'](char)) {
255
+ return true;
256
+ }
257
+ if (isChar['Unified Canadian Aboriginal Syllabics Extended'](char)) {
258
+ return true;
259
+ }
260
+ if (isChar['Vertical Forms'](char)) {
261
+ return true;
262
+ }
263
+ if (isChar['Yijing Hexagram Symbols'](char)) {
264
+ return true;
265
+ }
266
+ if (isChar['Yi Syllables'](char)) {
267
+ return true;
268
+ }
269
+ if (isChar['Yi Radicals'](char)) {
270
+ return true;
271
+ }
175
272
 
176
273
  return false;
177
274
  }
@@ -188,7 +285,7 @@ function charHasUprightVerticalOrientation(char) {
188
285
  * adjacent character is drawn upright or rotated.
189
286
  * @private
190
287
  */
191
- function charHasNeutralVerticalOrientation(char) {
288
+ export function charHasNeutralVerticalOrientation(char) {
192
289
  if (isChar['Latin-1 Supplement'](char)) {
193
290
  if (
194
291
  char === 0x00a7 /* section sign */ ||
@@ -222,8 +319,12 @@ function charHasNeutralVerticalOrientation(char) {
222
319
  return true;
223
320
  }
224
321
  }
225
- if (isChar['Letterlike Symbols'](char)) return true;
226
- if (isChar['Number Forms'](char)) return true;
322
+ if (isChar['Letterlike Symbols'](char)) {
323
+ return true;
324
+ }
325
+ if (isChar['Number Forms'](char)) {
326
+ return true;
327
+ }
227
328
  if (isChar['Miscellaneous Technical'](char)) {
228
329
  if (
229
330
  (char >= 0x2300 /* diameter sign */ && char <= 0x2307) /* wavy line */ ||
@@ -239,10 +340,18 @@ function charHasNeutralVerticalOrientation(char) {
239
340
  return true;
240
341
  }
241
342
  }
242
- if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) return true;
243
- if (isChar['Optical Character Recognition'](char)) return true;
244
- if (isChar['Enclosed Alphanumerics'](char)) return true;
245
- if (isChar['Geometric Shapes'](char)) return true;
343
+ if (isChar['Control Pictures'](char) && char !== 0x2423 /* open box */) {
344
+ return true;
345
+ }
346
+ if (isChar['Optical Character Recognition'](char)) {
347
+ return true;
348
+ }
349
+ if (isChar['Enclosed Alphanumerics'](char)) {
350
+ return true;
351
+ }
352
+ if (isChar['Geometric Shapes'](char)) {
353
+ return true;
354
+ }
246
355
  if (isChar['Miscellaneous Symbols'](char)) {
247
356
  if (!((char >= 0x261a /* black left pointing index */ && char <= 0x261f) /* white down pointing index */)) {
248
357
  return true;
@@ -257,12 +366,24 @@ function charHasNeutralVerticalOrientation(char) {
257
366
  return true;
258
367
  }
259
368
  }
260
- if (isChar['CJK Symbols and Punctuation'](char)) return true;
261
- if (isChar['Katakana'](char)) return true;
262
- if (isChar['Private Use Area'](char)) return true;
263
- if (isChar['CJK Compatibility Forms'](char)) return true;
264
- if (isChar['Small Form Variants'](char)) return true;
265
- if (isChar['Halfwidth and Fullwidth Forms'](char)) return true;
369
+ if (isChar['CJK Symbols and Punctuation'](char)) {
370
+ return true;
371
+ }
372
+ if (isChar['Katakana'](char)) {
373
+ return true;
374
+ }
375
+ if (isChar['Private Use Area'](char)) {
376
+ return true;
377
+ }
378
+ if (isChar['CJK Compatibility Forms'](char)) {
379
+ return true;
380
+ }
381
+ if (isChar['Small Form Variants'](char)) {
382
+ return true;
383
+ }
384
+ if (isChar['Halfwidth and Fullwidth Forms'](char)) {
385
+ return true;
386
+ }
266
387
 
267
388
  if (
268
389
  char === 0x221e /* infinity */ ||
@@ -290,11 +411,11 @@ function charHasNeutralVerticalOrientation(char) {
290
411
  * character causes an adjacent “neutral” character to be drawn rotated as well.
291
412
  * @private
292
413
  */
293
- function charHasRotatedVerticalOrientation(char) {
414
+ export function charHasRotatedVerticalOrientation(char) {
294
415
  return !(charHasUprightVerticalOrientation(char) || charHasNeutralVerticalOrientation(char));
295
416
  }
296
417
 
297
- function charInSupportedScript(char, canRenderRTL) {
418
+ export function charInSupportedScript(char, canRenderRTL) {
298
419
  // This is a rough heuristic: whether we "can render" a script
299
420
  // actually depends on the properties of the font being used
300
421
  // and whether differences from the ideal rendering are considered
@@ -327,7 +448,7 @@ function charInSupportedScript(char, canRenderRTL) {
327
448
  return true;
328
449
  }
329
450
 
330
- function isStringInSupportedScript(chars, canRenderRTL) {
451
+ export function isStringInSupportedScript(chars, canRenderRTL) {
331
452
  for (const char of chars) {
332
453
  if (!charInSupportedScript(char.charCodeAt(0), canRenderRTL)) {
333
454
  return false;
@@ -1,8 +1,8 @@
1
1
  // Note: all "sizes" are measured in bytes
2
2
 
3
- const assert = require('assert');
3
+ import assert from 'assert';
4
4
 
5
- const viewTypes = {
5
+ export const viewTypes = {
6
6
  Int8: Int8Array,
7
7
  Uint8: Uint8Array,
8
8
  Int16: Int16Array,
@@ -15,7 +15,7 @@ const viewTypes = {
15
15
  /**
16
16
  * @private
17
17
  */
18
- class Struct {
18
+ export class Struct {
19
19
  // The following properties are defined on the prototype of sub classes.
20
20
 
21
21
  /**
@@ -56,45 +56,14 @@ const RESIZE_MULTIPLIER = 5;
56
56
  *
57
57
  * @private
58
58
  */
59
- class StructArray {
59
+ export class StructArray {
60
60
  // The following properties are defined on the prototype.
61
61
 
62
62
  constructor() {
63
- this.isTransferred = false;
64
63
  this.capacity = -1;
65
64
  this.resize(0);
66
65
  }
67
66
 
68
- /**
69
- * Serialize a StructArray instance. Serializes both the raw data and the
70
- * metadata needed to reconstruct the StructArray base class during
71
- * deserialization.
72
- */
73
- static serialize(array, transferables) {
74
- assert(!array.isTransferred);
75
-
76
- array._trim();
77
-
78
- if (transferables) {
79
- array.isTransferred = true;
80
- transferables.push(array.arrayBuffer);
81
- }
82
-
83
- return {
84
- length: array.length,
85
- arrayBuffer: array.arrayBuffer
86
- };
87
- }
88
-
89
- static deserialize(input) {
90
- const structArray = Object.create(this.prototype);
91
- structArray.arrayBuffer = input.arrayBuffer;
92
- structArray.length = input.length;
93
- structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;
94
- structArray._refreshViews();
95
- return structArray;
96
- }
97
-
98
67
  /**
99
68
  * Resize the array to discard unused capacity.
100
69
  */
@@ -120,7 +89,6 @@ class StructArray {
120
89
  * @param {number} n The new size of the array.
121
90
  */
122
91
  resize(n) {
123
- assert(!this.isTransferred);
124
92
  this.reserve(n);
125
93
  this.length = n;
126
94
  }
@@ -137,7 +105,9 @@ class StructArray {
137
105
 
138
106
  const oldUint8Array = this.uint8;
139
107
  this._refreshViews();
140
- if (oldUint8Array) this.uint8.set(oldUint8Array);
108
+ if (oldUint8Array) {
109
+ this.uint8.set(oldUint8Array);
110
+ }
141
111
  }
142
112
  }
143
113
 
@@ -157,7 +127,7 @@ class StructArray {
157
127
  *
158
128
  * @private
159
129
  */
160
- function createLayout(members, alignment = 1) {
130
+ export function createLayout(members, alignment = 1) {
161
131
  let offset = 0;
162
132
  let maxSize = 0;
163
133
  const layoutMembers = members.map(member => {
@@ -193,5 +163,3 @@ function sizeOf(type) {
193
163
  function align(offset, size) {
194
164
  return Math.ceil(offset / size) * size;
195
165
  }
196
-
197
- module.exports = { StructArray, Struct, viewTypes, createLayout };
@@ -1,8 +1,6 @@
1
- const assert = require('assert');
1
+ import assert from 'assert';
2
2
 
3
- module.exports = taskQueue;
4
-
5
- function taskQueue(thisArg) {
3
+ export default function taskQueue(thisArg) {
6
4
  const queues = {
7
5
  running: [],
8
6
  later: []
@@ -18,7 +16,9 @@ function taskQueue(thisArg) {
18
16
  };
19
17
 
20
18
  function add(fn) {
21
- if (id === Number.MAX_SAFE_INTEGER) id = Number.MIN_SAFE_INTEGER;
19
+ if (id === Number.MAX_SAFE_INTEGER) {
20
+ id = Number.MIN_SAFE_INTEGER;
21
+ }
22
22
  id += 1;
23
23
  queues.later.push({ fn, id, cancelled: false });
24
24
  return id;
@@ -36,9 +36,13 @@ function taskQueue(thisArg) {
36
36
  queues.running = queues.later;
37
37
  queues.later = [];
38
38
  for (const { fn, cancelled } of queues.running) {
39
- if (cancelled) continue;
39
+ if (cancelled) {
40
+ continue;
41
+ }
40
42
  fn.call(thisArg);
41
- if (cleared) break;
43
+ if (cleared) {
44
+ break;
45
+ }
42
46
  }
43
47
  queues.running.length = 0;
44
48
  cleared = false;
@@ -3,7 +3,7 @@
3
3
  Throttle the given function to run at most every period milliseconds.
4
4
  * @private
5
5
  */
6
- module.exports = function throttle(fn, time) {
6
+ export default function throttle(fn, time) {
7
7
  let pending = false;
8
8
  let timerId = 0;
9
9
 
@@ -23,4 +23,4 @@ module.exports = function throttle(fn, time) {
23
23
  }
24
24
  return timerId;
25
25
  };
26
- };
26
+ }
@@ -1,6 +1,5 @@
1
- const { OverscaledTileID } = require('../source/tile_id');
2
-
3
- module.exports = tileCover;
1
+ import { OverscaledTileID } from '../source/tile_id.js';
2
+ export default tileCover;
4
3
 
5
4
  function tileCover(z, bounds, actualZ, renderWorldCopies) {
6
5
  if (renderWorldCopies === undefined) {
@@ -109,6 +108,10 @@ function scanTriangle(a, b, c, ymin, ymax, scanLine) {
109
108
  }
110
109
 
111
110
  // scan span! scan span!
112
- if (ab.dy) scanSpans(ca, ab, ymin, ymax, scanLine);
113
- if (bc.dy) scanSpans(ca, bc, ymin, ymax, scanLine);
111
+ if (ab.dy) {
112
+ scanSpans(ca, ab, ymin, ymax, scanLine);
113
+ }
114
+ if (bc.dy) {
115
+ scanSpans(ca, bc, ymin, ymax, scanLine);
116
+ }
114
117
  }
package/src/util/token.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = resolveTokens;
1
+ export default resolveTokens;
2
2
 
3
3
  /**
4
4
  * Replace tokens in a string template with values in an object
@@ -7,6 +7,6 @@ let id = 1;
7
7
  * @returns unique numeric id.
8
8
  * @private
9
9
  */
10
- module.exports = function uniqueId() {
10
+ export default function uniqueId() {
11
11
  return id++;
12
- };
12
+ }