@mapwhit/tilerenderer 0.50.0 → 0.51.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 (187) hide show
  1. package/build/min/package.json +1 -1
  2. package/build/min/src/shaders/.dir +0 -0
  3. package/build/min/src/shaders/{_prelude.fragment.glsl.txt → _prelude.fragment.glsl.js} +2 -1
  4. package/build/min/src/shaders/{_prelude.vertex.glsl.txt → _prelude.vertex.glsl.js} +2 -2
  5. package/build/min/src/shaders/background.fragment.glsl.js +5 -0
  6. package/build/min/src/shaders/background.vertex.glsl.js +1 -0
  7. package/build/min/src/shaders/background_pattern.fragment.glsl.js +5 -0
  8. package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -0
  9. package/build/min/src/shaders/{circle.fragment.glsl.txt → circle.fragment.glsl.js} +2 -2
  10. package/build/min/src/shaders/{circle.vertex.glsl.txt → circle.vertex.glsl.js} +2 -2
  11. package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -0
  12. package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -0
  13. package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -0
  14. package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -0
  15. package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -0
  16. package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -0
  17. package/build/min/src/shaders/debug.fragment.glsl.js +1 -0
  18. package/build/min/src/shaders/debug.vertex.glsl.js +1 -0
  19. package/build/min/src/shaders/{fill.fragment.glsl.txt → fill.fragment.glsl.js} +2 -2
  20. package/build/min/src/shaders/{fill.vertex.glsl.txt → fill.vertex.glsl.js} +2 -2
  21. package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +5 -0
  22. package/build/min/src/shaders/{fill_extrusion.vertex.glsl.txt → fill_extrusion.vertex.glsl.js} +2 -2
  23. package/build/min/src/shaders/{fill_extrusion_pattern.fragment.glsl.txt → fill_extrusion_pattern.fragment.glsl.js} +2 -2
  24. package/build/min/src/shaders/{fill_extrusion_pattern.vertex.glsl.txt → fill_extrusion_pattern.vertex.glsl.js} +2 -2
  25. package/build/min/src/shaders/{fill_outline.fragment.glsl.txt → fill_outline.fragment.glsl.js} +2 -2
  26. package/build/min/src/shaders/{fill_outline.vertex.glsl.txt → fill_outline.vertex.glsl.js} +2 -2
  27. package/build/min/src/shaders/{fill_outline_pattern.fragment.glsl.txt → fill_outline_pattern.fragment.glsl.js} +2 -2
  28. package/build/min/src/shaders/{fill_outline_pattern.vertex.glsl.txt → fill_outline_pattern.vertex.glsl.js} +2 -2
  29. package/build/min/src/shaders/{fill_pattern.fragment.glsl.txt → fill_pattern.fragment.glsl.js} +2 -2
  30. package/build/min/src/shaders/{fill_pattern.vertex.glsl.txt → fill_pattern.vertex.glsl.js} +2 -2
  31. package/build/min/src/shaders/{heatmap.fragment.glsl.txt → heatmap.fragment.glsl.js} +2 -2
  32. package/build/min/src/shaders/{heatmap.vertex.glsl.txt → heatmap.vertex.glsl.js} +2 -2
  33. package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +5 -0
  34. package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -0
  35. package/build/min/src/shaders/{hillshade.fragment.glsl.txt → hillshade.fragment.glsl.js} +2 -2
  36. package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -0
  37. package/build/min/src/shaders/{hillshade_prepare.fragment.glsl.txt → hillshade_prepare.fragment.glsl.js} +2 -2
  38. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -0
  39. package/build/min/src/shaders/{line.fragment.glsl.txt → line.fragment.glsl.js} +2 -2
  40. package/build/min/src/shaders/{line.vertex.glsl.txt → line.vertex.glsl.js} +2 -2
  41. package/build/min/src/shaders/{line_gradient.fragment.glsl.txt → line_gradient.fragment.glsl.js} +2 -2
  42. package/build/min/src/shaders/{line_gradient.vertex.glsl.txt → line_gradient.vertex.glsl.js} +2 -2
  43. package/build/min/src/shaders/{line_pattern.fragment.glsl.txt → line_pattern.fragment.glsl.js} +2 -2
  44. package/build/min/src/shaders/{line_pattern.vertex.glsl.txt → line_pattern.vertex.glsl.js} +2 -2
  45. package/build/min/src/shaders/{line_sdf.fragment.glsl.txt → line_sdf.fragment.glsl.js} +2 -2
  46. package/build/min/src/shaders/{line_sdf.vertex.glsl.txt → line_sdf.vertex.glsl.js} +2 -2
  47. package/build/min/src/shaders/raster.fragment.glsl.js +5 -0
  48. package/build/min/src/shaders/raster.vertex.glsl.js +1 -0
  49. package/build/min/src/shaders/{symbol_icon.fragment.glsl.txt → symbol_icon.fragment.glsl.js} +2 -2
  50. package/build/min/src/shaders/{symbol_icon.vertex.glsl.txt → symbol_icon.vertex.glsl.js} +2 -2
  51. package/build/min/src/shaders/{symbol_sdf.fragment.glsl.txt → symbol_sdf.fragment.glsl.js} +2 -2
  52. package/build/min/src/shaders/{symbol_sdf.vertex.glsl.txt → symbol_sdf.vertex.glsl.js} +2 -2
  53. package/package.json +14 -10
  54. package/src/data/array_types.js +1 -1
  55. package/src/data/bucket/fill_bucket.js +1 -1
  56. package/src/data/bucket/fill_extrusion_bucket.js +2 -2
  57. package/src/data/bucket/line_bucket.js +1 -1
  58. package/src/data/bucket/symbol_bucket.js +3 -3
  59. package/src/data/feature_index.js +1 -1
  60. package/src/data/program_configuration.js +1 -1
  61. package/src/geo/transform.js +1 -1
  62. package/src/gl/color_mode.js +1 -1
  63. package/src/gl/value.js +1 -1
  64. package/src/index.js +2 -2
  65. package/src/render/draw_debug.js +1 -1
  66. package/src/render/draw_fill.js +1 -1
  67. package/src/render/draw_heatmap.js +1 -1
  68. package/src/render/glyph_manager.js +6 -130
  69. package/src/render/painter.js +1 -1
  70. package/src/render/uniform_binding.js +1 -1
  71. package/src/shaders/index.js +50 -50
  72. package/src/source/geojson_source.js +1 -1
  73. package/src/source/geojson_worker_source.js +4 -4
  74. package/src/source/geojson_wrapper.js +35 -27
  75. package/src/source/image_source.js +2 -2
  76. package/src/source/raster_tile_source.js +1 -1
  77. package/src/source/resources/glyphs.js +73 -0
  78. package/src/source/resources/images.js +68 -0
  79. package/src/source/resources/index.js +22 -0
  80. package/src/source/rtl_text_plugin.js +1 -1
  81. package/src/source/source_cache.js +2 -2
  82. package/src/source/tile.js +1 -1
  83. package/src/source/vector_tile_source.js +1 -1
  84. package/src/source/vector_tile_worker_source.js +5 -5
  85. package/src/source/worker.js +6 -5
  86. package/src/source/worker_tile.js +4 -4
  87. package/src/style/light.js +1 -1
  88. package/src/style/properties.js +1 -2
  89. package/src/style/query_utils.js +1 -1
  90. package/src/style/style.js +4 -4
  91. package/src/style/style_layer/circle_style_layer.js +1 -1
  92. package/src/style/style_layer/fill_extrusion_style_layer.js +1 -1
  93. package/src/style/style_layer/line_style_layer.js +1 -1
  94. package/src/style/style_layer/symbol_style_layer.js +1 -1
  95. package/src/style/style_layer.js +2 -2
  96. package/src/style-spec/feature_filter/index.js +43 -34
  97. package/src/style-spec/group_by_layout.js +10 -32
  98. package/src/symbol/anchor.js +1 -1
  99. package/src/symbol/clip_line.js +1 -1
  100. package/src/symbol/collision_feature.js +1 -1
  101. package/src/symbol/collision_index.js +1 -1
  102. package/src/symbol/mergelines.js +0 -2
  103. package/src/symbol/projection.js +1 -1
  104. package/src/symbol/quads.js +1 -1
  105. package/src/symbol/symbol_layout.js +0 -1
  106. package/src/symbol/symbol_size.js +1 -1
  107. package/src/symbol/transform_text.js +0 -1
  108. package/src/ui/camera.js +2 -2
  109. package/src/ui/map.js +11 -41
  110. package/src/util/browser.js +3 -18
  111. package/src/util/classify_rings.js +1 -1
  112. package/src/util/config.js +1 -1
  113. package/src/util/dom.js +0 -88
  114. package/src/util/find_pole_of_inaccessibility.js +3 -3
  115. package/src/util/intersection_tests.js +1 -1
  116. package/src/util/web_worker_transfer.js +4 -4
  117. package/src/worker.js +4 -0
  118. package/build/min/src/shaders/background.fragment.glsl.txt +0 -5
  119. package/build/min/src/shaders/background.vertex.glsl.txt +0 -1
  120. package/build/min/src/shaders/background_pattern.fragment.glsl.txt +0 -5
  121. package/build/min/src/shaders/background_pattern.vertex.glsl.txt +0 -1
  122. package/build/min/src/shaders/clipping_mask.fragment.glsl.txt +0 -1
  123. package/build/min/src/shaders/clipping_mask.vertex.glsl.txt +0 -1
  124. package/build/min/src/shaders/collision_box.fragment.glsl.txt +0 -1
  125. package/build/min/src/shaders/collision_box.vertex.glsl.txt +0 -1
  126. package/build/min/src/shaders/collision_circle.fragment.glsl.txt +0 -1
  127. package/build/min/src/shaders/collision_circle.vertex.glsl.txt +0 -1
  128. package/build/min/src/shaders/debug.fragment.glsl.txt +0 -1
  129. package/build/min/src/shaders/debug.vertex.glsl.txt +0 -1
  130. package/build/min/src/shaders/fill_extrusion.fragment.glsl.txt +0 -5
  131. package/build/min/src/shaders/heatmap_texture.fragment.glsl.txt +0 -5
  132. package/build/min/src/shaders/heatmap_texture.vertex.glsl.txt +0 -1
  133. package/build/min/src/shaders/hillshade.vertex.glsl.txt +0 -1
  134. package/build/min/src/shaders/hillshade_prepare.vertex.glsl.txt +0 -1
  135. package/build/min/src/shaders/raster.fragment.glsl.txt +0 -5
  136. package/build/min/src/shaders/raster.vertex.glsl.txt +0 -1
  137. package/src/style/load_glyph_range.js +0 -17
  138. package/src/style-spec/expression/compound_expression.js +0 -132
  139. package/src/style-spec/expression/definitions/assertion.js +0 -116
  140. package/src/style-spec/expression/definitions/at.js +0 -57
  141. package/src/style-spec/expression/definitions/case.js +0 -73
  142. package/src/style-spec/expression/definitions/coalesce.js +0 -66
  143. package/src/style-spec/expression/definitions/coercion.js +0 -120
  144. package/src/style-spec/expression/definitions/collator.js +0 -80
  145. package/src/style-spec/expression/definitions/comparison.js +0 -193
  146. package/src/style-spec/expression/definitions/format.js +0 -97
  147. package/src/style-spec/expression/definitions/index.js +0 -339
  148. package/src/style-spec/expression/definitions/interpolate.js +0 -245
  149. package/src/style-spec/expression/definitions/length.js +0 -54
  150. package/src/style-spec/expression/definitions/let.js +0 -60
  151. package/src/style-spec/expression/definitions/literal.js +0 -69
  152. package/src/style-spec/expression/definitions/match.js +0 -142
  153. package/src/style-spec/expression/definitions/step.js +0 -116
  154. package/src/style-spec/expression/definitions/var.js +0 -38
  155. package/src/style-spec/expression/evaluation_context.js +0 -38
  156. package/src/style-spec/expression/index.js +0 -330
  157. package/src/style-spec/expression/is_constant.js +0 -63
  158. package/src/style-spec/expression/parsing_context.js +0 -221
  159. package/src/style-spec/expression/parsing_error.js +0 -9
  160. package/src/style-spec/expression/runtime_error.js +0 -12
  161. package/src/style-spec/expression/scope.js +0 -34
  162. package/src/style-spec/expression/stops.js +0 -37
  163. package/src/style-spec/expression/types/collator.js +0 -24
  164. package/src/style-spec/expression/types/formatted.js +0 -39
  165. package/src/style-spec/expression/types.js +0 -88
  166. package/src/style-spec/expression/values.js +0 -149
  167. package/src/style-spec/function/convert.js +0 -240
  168. package/src/style-spec/function/index.js +0 -303
  169. package/src/style-spec/util/color.js +0 -73
  170. package/src/style-spec/util/color_spaces.js +0 -128
  171. package/src/style-spec/util/get_type.js +0 -18
  172. package/src/style-spec/util/interpolate.js +0 -21
  173. package/src/style-spec/util/properties.js +0 -17
  174. package/src/style-spec/util/result.js +0 -19
  175. package/src/ui/anchor.js +0 -24
  176. package/src/ui/bind_handlers.js +0 -199
  177. package/src/ui/events.js +0 -210
  178. package/src/ui/handler/box_zoom.js +0 -151
  179. package/src/ui/handler/dblclick_zoom.js +0 -91
  180. package/src/ui/handler/drag_pan.js +0 -285
  181. package/src/ui/handler/drag_rotate.js +0 -290
  182. package/src/ui/handler/frame.js +0 -28
  183. package/src/ui/handler/inertia.js +0 -45
  184. package/src/ui/handler/keyboard.js +0 -148
  185. package/src/ui/handler/scroll_zoom.js +0 -284
  186. package/src/ui/handler/touch_zoom_rotate.js +0 -263
  187. package/src/util/evented.js +0 -182
@@ -1,5 +1,4 @@
1
1
  const { plugin: rtlTextPlugin } = require('../source/rtl_text_plugin');
2
- const { Formatted } = require('../style-spec/expression/types/formatted');
3
2
 
4
3
  function transformText(text, layer, feature) {
5
4
  const transform = layer.layout.get('text-transform').evaluate(feature, {});
package/src/ui/camera.js CHANGED
@@ -5,8 +5,8 @@ const interpolate = require('../util/interpolate');
5
5
  const browser = require('../util/browser');
6
6
  const LngLat = require('../geo/lng_lat');
7
7
  const LngLatBounds = require('../geo/lng_lat_bounds');
8
- const Point = require('@mapbox/point-geometry');
9
- const { Event, Evented } = require('../util/evented');
8
+ const { default: Point } = require('@mapbox/point-geometry');
9
+ const { Event, Evented } = require('@mapwhit/events');
10
10
 
11
11
  /**
12
12
  * Options common to {@link Map#jumpTo}, {@link Map#easeTo}, and {@link Map#flyTo}, controlling the desired location,
package/src/ui/map.js CHANGED
@@ -9,13 +9,12 @@ const Style = require('../style/style');
9
9
  const EvaluationParameters = require('../style/evaluation_parameters');
10
10
  const Painter = require('../render/painter');
11
11
  const Transform = require('../geo/transform');
12
- const bindHandlers = require('./bind_handlers');
13
12
  const Camera = require('./camera');
14
13
  const LngLat = require('../geo/lng_lat');
15
14
  const LngLatBounds = require('../geo/lng_lat_bounds');
16
- const Point = require('@mapbox/point-geometry');
15
+ const { default: Point } = require('@mapbox/point-geometry');
17
16
  const { RGBAImage } = require('../util/image');
18
- const { Event, ErrorEvent } = require('../util/evented');
17
+ const { Event, ErrorEvent } = require('@mapwhit/events');
19
18
  const taskQueue = require('../util/task_queue');
20
19
 
21
20
  const defaultMinZoom = 0;
@@ -31,18 +30,8 @@ const defaultOptions = {
31
30
 
32
31
  interactive: true,
33
32
 
34
- scrollZoom: true,
35
- boxZoom: true,
36
- dragRotate: true,
37
- dragPan: true,
38
- keyboard: true,
39
- doubleClickZoom: true,
40
- touchZoomRotate: true,
41
-
42
33
  bearingSnap: 7,
43
34
 
44
- clickTolerance: 3,
45
-
46
35
  attributionControl: true,
47
36
 
48
37
  failIfMajorPerformanceCaveat: false,
@@ -98,19 +87,11 @@ const defaultOptions = {
98
87
  * bearing will snap to north. For example, with a `bearingSnap` of 7, if the user rotates
99
88
  * the map within 7 degrees of north, the map will automatically snap to exact north.
100
89
  * @param {boolean} [options.pitchWithRotate=true] If `false`, the map's pitch (tilt) control with "drag to rotate" interaction will be disabled.
101
- * @param {number} [options.clickTolerance=3] The max number of pixels a user can shift the mouse pointer during a click for it to be considered a valid click (as opposed to a mouse drag).
102
90
  * @param {string} [options.logoPosition='bottom-left'] A string representing the position of the Mapbox wordmark on the map. Valid options are `top-left`,`top-right`, `bottom-left`, `bottom-right`.
103
91
  * @param {boolean} [options.failIfMajorPerformanceCaveat=false] If `true`, map creation will fail if the performance of Mapbox
104
92
  * GL JS would be dramatically worse than expected (i.e. a software renderer would be used).
105
93
  * @param {boolean} [options.preserveDrawingBuffer=false] If `true`, the map's canvas can be exported to a PNG using `map.getCanvas().toDataURL()`. This is `false` by default as a performance optimization.
106
94
  * @param {LngLatBoundsLike} [options.maxBounds] If set, the map will be constrained to the given bounds.
107
- * @param {boolean|Object} [options.scrollZoom=true] If `true`, the "scroll to zoom" interaction is enabled. An `Object` value is passed as options to {@link ScrollZoomHandler#enable}.
108
- * @param {boolean} [options.boxZoom=true] If `true`, the "box zoom" interaction is enabled (see {@link BoxZoomHandler}).
109
- * @param {boolean} [options.dragRotate=true] If `true`, the "drag to rotate" interaction is enabled (see {@link DragRotateHandler}).
110
- * @param {boolean} [options.dragPan=true] If `true`, the "drag to pan" interaction is enabled (see {@link DragPanHandler}).
111
- * @param {boolean} [options.keyboard=true] If `true`, keyboard shortcuts are enabled (see {@link KeyboardHandler}).
112
- * @param {boolean} [options.doubleClickZoom=true] If `true`, the "double click to zoom" interaction is enabled (see {@link DoubleClickZoomHandler}).
113
- * @param {boolean|Object} [options.touchZoomRotate=true] If `true`, the "pinch to rotate and zoom" interaction is enabled. An `Object` value is passed as options to {@link TouchZoomRotateHandler#enable}.
114
95
  * @param {boolean} [options.trackResize=true] If `true`, the map will automatically resize when the browser window resizes.
115
96
  * @param {LngLatLike} [options.center=[0, 0]] The inital geographical centerpoint of the map. If `center` is not specified in the constructor options, Mapbox GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `[0, 0]` Note: Mapbox GL uses longitude, latitude coordinate order (as opposed to latitude, longitude) to match GeoJSON.
116
97
  * @param {number} [options.zoom=0] The initial zoom level of the map. If `zoom` is not specified in the constructor options, Mapbox GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.
@@ -118,10 +99,6 @@ const defaultOptions = {
118
99
  * @param {number} [options.pitch=0] The initial pitch (tilt) of the map, measured in degrees away from the plane of the screen (0-60). If `pitch` is not specified in the constructor options, Mapbox GL JS will look for it in the map's style object. If it is not specified in the style, either, it will default to `0`.
119
100
  * @param {boolean} [options.renderWorldCopies=true] If `true`, multiple copies of the world will be rendered, when zoomed out.
120
101
  * @param {number} [options.maxTileCacheSize=null] The maximum number of tiles stored in the tile cache for a given source. If omitted, the cache will be dynamically sized based on the current viewport.
121
- * @param {string} [options.localIdeographFontFamily=null] If specified, defines a CSS font-family
122
- * for locally overriding generation of glyphs in the 'CJK Unified Ideographs' and 'Hangul Syllables' ranges.
123
- * In these ranges, font settings from the map's style will be ignored, except for font-weight keywords (light/regular/medium/bold).
124
- * The purpose of this option is to avoid bandwidth-intensive glyph server requests. (see [Use locally generated ideographs](https://www.mapbox.com/mapbox-gl-js/example/local-ideographs))
125
102
  * @param {number} [options.fadeDuration=300] Controls the duration of the fade-in/fade-out animation for label collisions, in milliseconds. This setting affects all symbol layers. This setting does not affect the duration of runtime styling transitions or raster tile cross-fading.
126
103
  * @param {boolean} [options.crossSourceCollisions=true] If `true`, symbols from multiple sources can collide with each other during collision detection. If `false`, collision detection is run separately for the symbols in each source.
127
104
  * @example
@@ -203,8 +180,6 @@ class Map extends Camera {
203
180
  window.addEventListener('resize', this._onWindowResize, false);
204
181
  }
205
182
 
206
- bindHandlers(this, options);
207
-
208
183
  this.jumpTo({
209
184
  center: options.center,
210
185
  zoom: options.zoom,
@@ -214,7 +189,7 @@ class Map extends Camera {
214
189
 
215
190
  this.resize();
216
191
 
217
- if (options.style) this.setStyle(options.style, { localIdeographFontFamily: options.localIdeographFontFamily });
192
+ if (options.style) this.setStyle(options.style);
218
193
 
219
194
  this.on('style.load', function () {
220
195
  if (this.transform.unmodified) {
@@ -465,27 +440,21 @@ class Map extends Camera {
465
440
  * Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.
466
441
  */
467
442
  isMoving() {
468
- return (
469
- this._moving ||
470
- this.dragPan.isActive() ||
471
- this.dragRotate.isActive() ||
472
- this.touchZoomRotate.isActive() ||
473
- this.scrollZoom.isActive()
474
- );
443
+ return !!(this._moving || this._mapGestures?.isMoving());
475
444
  }
476
445
 
477
446
  /**
478
447
  * Returns true if the map is zooming due to a camera animation or user gesture.
479
448
  */
480
449
  isZooming() {
481
- return this._zooming || this.touchZoomRotate.isActive() || this.scrollZoom.isZooming();
450
+ return !!(this._zooming || this._mapGestures?.isZooming());
482
451
  }
483
452
 
484
453
  /**
485
454
  * Returns true if the map is rotating due to a camera animation or user gesture.
486
455
  */
487
456
  isRotating() {
488
- return this._rotating || this.touchZoomRotate.isActive() || this.dragRotate.isActive();
457
+ return !!(this._rotating || this._mapGestures?.isRotating());
489
458
  }
490
459
 
491
460
  /**
@@ -666,9 +635,6 @@ class Map extends Camera {
666
635
  * @param {Object} [options]
667
636
  * @param {boolean} [options.diff=true] If false, force a 'full' update, removing the current style
668
637
  * and adding building the given one instead of attempting a diff-based update.
669
- * @param {string} [options.localIdeographFontFamily=null] If non-null, defines a css font-family
670
- * for locally overriding generation of glyphs in the 'CJK Unified Ideographs' and 'Hangul Syllables'
671
- * ranges. Forces a full update.
672
638
  * @returns {Map} `this`
673
639
  * @see [Change a map's style](https://www.mapbox.com/mapbox-gl-js/example/setstyle/)
674
640
  */
@@ -823,7 +789,11 @@ class Map extends Camera {
823
789
  );
824
790
  } else {
825
791
  const { width, height, data } = image;
826
- this.style.addImage(id, { data: new RGBAImage({ width, height }, new Uint8Array(data)), pixelRatio, sdf });
792
+ this.style.addImage(id, {
793
+ data: new RGBAImage({ width, height }, new Uint8Array(data)),
794
+ pixelRatio,
795
+ sdf
796
+ });
827
797
  }
828
798
  }
829
799
 
@@ -1,25 +1,10 @@
1
1
  // TODO move code that assumes that `window` may not be set to relevant tests
2
2
 
3
- const now =
4
- typeof window === 'object' && window.performance?.now
5
- ? window.performance.now.bind(window.performance)
6
- : Date.now.bind(Date);
3
+ const now = () => performance.now();
7
4
 
8
- const raf =
9
- typeof window === 'object'
10
- ? window.requestAnimationFrame ||
11
- window.mozRequestAnimationFrame ||
12
- window.webkitRequestAnimationFrame ||
13
- window.msRequestAnimationFrame
14
- : fn => setTimeout(fn, 0);
5
+ const raf = typeof window === 'object' ? window.requestAnimationFrame : fn => setTimeout(fn, 0);
15
6
 
16
- const cancel =
17
- typeof window === 'object'
18
- ? window.cancelAnimationFrame ||
19
- window.mozCancelAnimationFrame ||
20
- window.webkitCancelAnimationFrame ||
21
- window.msCancelAnimationFrame
22
- : id => clearTimeout(id);
7
+ const cancel = typeof window === 'object' ? window.cancelAnimationFrame : id => clearTimeout(id);
23
8
 
24
9
  /**
25
10
  * @private
@@ -1,4 +1,4 @@
1
- const quickselect = require('quickselect');
1
+ const { default: quickselect } = require('quickselect');
2
2
 
3
3
  const { calculateSignedArea } = require('./util');
4
4
 
@@ -1,4 +1,4 @@
1
- const { Evented } = require('./evented');
1
+ const { Evented } = require('@mapwhit/events');
2
2
 
3
3
  function getDefaultWorkerCount() {
4
4
  const browser = require('./browser');
package/src/util/dom.js CHANGED
@@ -1,7 +1,3 @@
1
- const Point = require('@mapbox/point-geometry');
2
-
3
- const assert = require('assert');
4
-
5
1
  const DOM = {};
6
2
  module.exports = DOM;
7
3
 
@@ -16,87 +12,3 @@ DOM.createNS = function (namespaceURI, tagName) {
16
12
  const el = window.document.createElementNS(namespaceURI, tagName);
17
13
  return el;
18
14
  };
19
-
20
- let docStyle;
21
- let selectProp;
22
-
23
- DOM.initEnableDisableDrag = function () {
24
- docStyle = window.document ? window.document.documentElement.style : null;
25
-
26
- function testProp(props) {
27
- if (!docStyle) return null;
28
- for (let i = 0; i < props.length; i++) {
29
- if (props[i] in docStyle) {
30
- return props[i];
31
- }
32
- }
33
- return props[0];
34
- }
35
-
36
- selectProp = testProp(['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'msUserSelect']);
37
- };
38
-
39
- let userSelect;
40
-
41
- DOM.disableDrag = function () {
42
- if (docStyle && selectProp) {
43
- userSelect = docStyle[selectProp];
44
- docStyle[selectProp] = 'none';
45
- }
46
- };
47
-
48
- DOM.enableDrag = function () {
49
- if (docStyle && selectProp) {
50
- docStyle[selectProp] = userSelect;
51
- }
52
- };
53
-
54
- // Suppress the next click, but only if it's immediate.
55
- const suppressClick = function (e) {
56
- e.preventDefault();
57
- e.stopPropagation();
58
- window.removeEventListener('click', suppressClick, true);
59
- };
60
-
61
- DOM.suppressClick = function () {
62
- window.addEventListener('click', suppressClick, true);
63
- window.setTimeout(() => {
64
- if (typeof window === 'object' && window) {
65
- window.removeEventListener('click', suppressClick, true);
66
- }
67
- }, 0);
68
- };
69
-
70
- DOM.mousePos = function (el, e) {
71
- const rect = el.getBoundingClientRect();
72
- e = e.touches ? e.touches[0] : e;
73
- return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
74
- };
75
-
76
- DOM.touchPos = function (el, e) {
77
- const rect = el.getBoundingClientRect();
78
- const points = [];
79
- const touches = e.type === 'touchend' ? e.changedTouches : e.touches;
80
- for (let i = 0; i < touches.length; i++) {
81
- points.push(
82
- new Point(touches[i].clientX - rect.left - el.clientLeft, touches[i].clientY - rect.top - el.clientTop)
83
- );
84
- }
85
- return points;
86
- };
87
-
88
- DOM.mouseButton = function (e) {
89
- assert(e.type === 'mousedown' || e.type === 'mouseup');
90
- if (
91
- typeof window.InstallTrigger !== 'undefined' &&
92
- e.button === 2 &&
93
- e.ctrlKey &&
94
- window.navigator.platform.toUpperCase().indexOf('MAC') >= 0
95
- ) {
96
- // Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:
97
- // Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when
98
- // using Control + left click
99
- return 0;
100
- }
101
- return e.button;
102
- };
@@ -1,6 +1,6 @@
1
- const Queue = require('tinyqueue');
1
+ const { default: Queue } = require('tinyqueue');
2
2
 
3
- const Point = require('@mapbox/point-geometry');
3
+ const { default: Point } = require('@mapbox/point-geometry');
4
4
  const { distToSegmentSquared } = require('./intersection_tests');
5
5
 
6
6
  /**
@@ -34,7 +34,7 @@ module.exports = function (polygonRings, precision = 1, debug = false) {
34
34
  let h = cellSize / 2;
35
35
 
36
36
  // a priority queue of cells in order of their "potential" (max distance to polygon)
37
- const cellQueue = new Queue(null, compareMax);
37
+ const cellQueue = new Queue(undefined, compareMax);
38
38
 
39
39
  if (cellSize === 0) return new Point(minX, minY);
40
40
 
@@ -1,5 +1,5 @@
1
1
  const { isCounterClockwise } = require('./util');
2
- const Point = require('@mapbox/point-geometry');
2
+ const { default: Point } = require('@mapbox/point-geometry');
3
3
 
4
4
  module.exports = {
5
5
  polygonIntersectsBufferedPoint,
@@ -1,13 +1,13 @@
1
1
  const Grid = require('grid-index');
2
- const Color = require('../style-spec/util/color');
2
+ const { Color } = require('@mapwhit/style-expressions');
3
3
  const {
4
+ CompoundExpression,
5
+ definitions: expressions,
4
6
  StylePropertyFunction,
5
7
  StyleExpression,
6
8
  ZoomDependentExpression,
7
9
  ZoomConstantExpression
8
- } = require('../style-spec/expression');
9
- const CompoundExpression = require('../style-spec/expression/compound_expression');
10
- const expressions = require('../style-spec/expression/definitions');
10
+ } = require('@mapwhit/style-expressions');
11
11
 
12
12
  const { register, serialize, deserialize } = require('./transfer_registry');
13
13
  module.exports = {
package/src/worker.js ADDED
@@ -0,0 +1,4 @@
1
+ const worker = require('./source/worker');
2
+
3
+ /* global self */
4
+ worker(self);
@@ -1,5 +0,0 @@
1
- uniform vec4 u_color;uniform float u_opacity;void main(){gl_FragColor=u_color*u_opacity;
2
- #ifdef OVERDRAW_INSPECTOR
3
- gl_FragColor=vec4(1.);
4
- #endif
5
- }
@@ -1 +0,0 @@
1
- attribute vec2 a_pos;uniform mat4 u_matrix;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);}
@@ -1,5 +0,0 @@
1
- uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main(){vec2 imagecoord=mod(v_pos_a,1.);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;
2
- #ifdef OVERDRAW_INSPECTOR
3
- gl_FragColor=vec4(1.);
4
- #endif
5
- }
@@ -1 +0,0 @@
1
- uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}
@@ -1 +0,0 @@
1
- void main(){gl_FragColor=vec4(1.);}
@@ -1 +0,0 @@
1
- attribute vec2 a_pos;uniform mat4 u_matrix;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);}
@@ -1 +0,0 @@
1
- varying float v_placed;varying float v_notUsed;void main(){float alpha=0.5;gl_FragColor=vec4(1.,0.,0.,1.)*alpha;if(v_placed>0.5){gl_FragColor=vec4(0.,0.,1.,0.5)*alpha;}if(v_notUsed>0.5){gl_FragColor*=.1;}}
@@ -1 +0,0 @@
1
- attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main(){vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.,4.);gl_Position=u_matrix*vec4(a_pos,0.,1.);gl_Position.xy+=a_extrude*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}
@@ -1 +0,0 @@
1
- uniform float u_overscale_factor;varying float v_placed;varying float v_notUsed;varying float v_radius;varying vec2 v_extrude;varying vec2 v_extrude_scale;void main(){float alpha=0.5;vec4 color=vec4(1.,0.,0.,1.)*alpha;if(v_placed>0.5){color=vec4(0.,0.,1.,0.5)*alpha;}if(v_notUsed>0.5){color*=.2;}float extrude_scale_length=length(v_extrude_scale);float extrude_length=length(v_extrude)*extrude_scale_length;float stroke_width=15.*extrude_scale_length/u_overscale_factor;float radius=v_radius*extrude_scale_length;float distance_to_edge=abs(extrude_length-radius);float opacity_t=smoothstep(-stroke_width,0.,-distance_to_edge);gl_FragColor=opacity_t*color;}
@@ -1 +0,0 @@
1
- attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;varying float v_radius;varying vec2 v_extrude;varying vec2 v_extrude_scale;void main(){vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.,4.);gl_Position=u_matrix*vec4(a_pos,0.,1.);highp float padding_factor=1.2;gl_Position.xy+=a_extrude*u_extrude_scale*padding_factor*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;v_radius=abs(a_extrude.y);v_extrude=a_extrude*padding_factor;v_extrude_scale=u_extrude_scale*u_camera_to_center_distance*collision_perspective_ratio;}
@@ -1 +0,0 @@
1
- uniform highp vec4 u_color;void main(){gl_FragColor=u_color;}
@@ -1 +0,0 @@
1
- attribute vec2 a_pos;uniform mat4 u_matrix;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);}
@@ -1,5 +0,0 @@
1
- varying vec4 v_color;void main(){gl_FragColor=v_color;
2
- #ifdef OVERDRAW_INSPECTOR
3
- gl_FragColor=vec4(1.);
4
- #endif
5
- }
@@ -1,5 +0,0 @@
1
- uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main(){float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
2
- #ifdef OVERDRAW_INSPECTOR
3
- gl_FragColor=vec4(0.);
4
- #endif
5
- }
@@ -1 +0,0 @@
1
- uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main(){gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.-a_pos.y;}
@@ -1 +0,0 @@
1
- uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.;}
@@ -1 +0,0 @@
1
- uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);vec2 epsilon=1./u_dimension;float scale=(u_dimension.x-2.)/u_dimension.x;v_pos=(a_texture_pos/8192.)*scale+epsilon;}
@@ -1,5 +0,0 @@
1
- uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main(){vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if(color0.a>0.){color0.rgb=color0.rgb/color0.a;}if(color1.a>0.){color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
2
- #ifdef OVERDRAW_INSPECTOR
3
- gl_FragColor=vec4(1.);
4
- #endif
5
- }
@@ -1 +0,0 @@
1
- uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main(){gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.)-0.5)/u_buffer_scale)+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}
@@ -1,17 +0,0 @@
1
- const parseGlyphPBF = require('./parse_glyph_pbf');
2
- const { callback } = require('../util/callback');
3
-
4
- module.exports = loadGlyphRange;
5
-
6
- function loadGlyphRange(fontstack, range, load, fn) {
7
- return callback(fn, perform());
8
-
9
- async function perform() {
10
- const data = await load(fontstack, range);
11
- const glyphs = {};
12
- for (const glyph of parseGlyphPBF(data)) {
13
- glyphs[glyph.id] = glyph;
14
- }
15
- return glyphs;
16
- }
17
- }
@@ -1,132 +0,0 @@
1
- const { toString } = require('./types');
2
-
3
- const assert = require('assert');
4
-
5
- class CompoundExpression {
6
- constructor(name, type, evaluate, args) {
7
- this.name = name;
8
- this.type = type;
9
- this._evaluate = evaluate;
10
- this.args = args;
11
- }
12
-
13
- evaluate(ctx) {
14
- return this._evaluate(ctx, this.args);
15
- }
16
-
17
- eachChild(fn) {
18
- this.args.forEach(fn);
19
- }
20
-
21
- possibleOutputs() {
22
- return [undefined];
23
- }
24
-
25
- serialize() {
26
- return [this.name].concat(this.args.map(arg => arg.serialize()));
27
- }
28
-
29
- static parse(args, context) {
30
- const ParsingContext = require('./parsing_context');
31
-
32
- const op = args[0];
33
- const definition = CompoundExpression.definitions[op];
34
- if (!definition) {
35
- return context.error(`Unknown expression "${op}". If you wanted a literal array, use ["literal", [...]].`, 0);
36
- }
37
-
38
- // Now check argument types against each signature
39
- const type = Array.isArray(definition) ? definition[0] : definition.type;
40
-
41
- const availableOverloads = Array.isArray(definition) ? [[definition[1], definition[2]]] : definition.overloads;
42
-
43
- const overloads = availableOverloads.filter(
44
- ([signature]) =>
45
- !Array.isArray(signature) || // varags
46
- signature.length === args.length - 1 // correct param count
47
- );
48
-
49
- let signatureContext = null;
50
-
51
- for (const [params, evaluate] of overloads) {
52
- // Use a fresh context for each attempted signature so that, if
53
- // we eventually succeed, we haven't polluted `context.errors`.
54
- signatureContext = new ParsingContext(context.registry, context.path, null, context.scope);
55
-
56
- // First parse all the args, potentially coercing to the
57
- // types expected by this overload.
58
- const parsedArgs = [];
59
- let argParseFailed = false;
60
- for (let i = 1; i < args.length; i++) {
61
- const arg = args[i];
62
- const expectedType = Array.isArray(params) ? params[i - 1] : params.type;
63
-
64
- const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);
65
- if (!parsed) {
66
- argParseFailed = true;
67
- break;
68
- }
69
- parsedArgs.push(parsed);
70
- }
71
- if (argParseFailed) {
72
- // Couldn't coerce args of this overload to expected type, move
73
- // on to next one.
74
- continue;
75
- }
76
-
77
- if (Array.isArray(params)) {
78
- if (params.length !== parsedArgs.length) {
79
- signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);
80
- continue;
81
- }
82
- }
83
-
84
- for (let i = 0; i < parsedArgs.length; i++) {
85
- const expected = Array.isArray(params) ? params[i] : params.type;
86
- const arg = parsedArgs[i];
87
- signatureContext.concat(i + 1).checkSubtype(expected, arg.type);
88
- }
89
-
90
- if (signatureContext.errors.length === 0) {
91
- return new CompoundExpression(op, type, evaluate, parsedArgs);
92
- }
93
- }
94
-
95
- assert(!signatureContext || signatureContext.errors.length > 0);
96
-
97
- if (overloads.length === 1) {
98
- context.errors.push.apply(context.errors, signatureContext.errors);
99
- } else {
100
- const expected = overloads.length ? overloads : availableOverloads;
101
- const signatures = expected.map(([params]) => stringifySignature(params)).join(' | ');
102
- const actualTypes = [];
103
- // For error message, re-parse arguments without trying to
104
- // apply any coercions
105
- for (let i = 1; i < args.length; i++) {
106
- const parsed = context.parse(args[i], 1 + actualTypes.length);
107
- if (!parsed) return null;
108
- actualTypes.push(toString(parsed.type));
109
- }
110
- context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);
111
- }
112
-
113
- return null;
114
- }
115
-
116
- static register(registry, definitions) {
117
- assert(!CompoundExpression.definitions);
118
- CompoundExpression.definitions = definitions;
119
- for (const name in definitions) {
120
- registry[name] = CompoundExpression;
121
- }
122
- }
123
- }
124
-
125
- function stringifySignature(signature) {
126
- if (Array.isArray(signature)) {
127
- return `(${signature.map(toString).join(', ')})`;
128
- }
129
- return `(${toString(signature.type)}...)`;
130
- }
131
-
132
- module.exports = CompoundExpression;