maplibre-gl 3.1.0 → 3.2.0-pre.2
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/README.md +7 -7
- package/build/generate-doc-images.ts +73 -0
- package/build/generate-docs.ts +100 -0
- package/build/generate-struct-arrays.ts +9 -12
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +3303 -3398
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +3899 -3531
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +28 -25
- package/src/data/array_types.g.ts +14 -48
- package/src/data/bucket/circle_bucket.ts +11 -14
- package/src/data/bucket/fill_bucket.test.ts +6 -6
- package/src/data/bucket/fill_bucket.ts +10 -12
- package/src/data/bucket/fill_extrusion_bucket.ts +11 -13
- package/src/data/bucket/heatmap_bucket.ts +3 -6
- package/src/data/bucket/line_attributes.ts +1 -2
- package/src/data/bucket/line_attributes_ext.ts +1 -2
- package/src/data/bucket/line_bucket.test.ts +5 -5
- package/src/data/bucket/line_bucket.ts +18 -21
- package/src/data/bucket/pattern_attributes.ts +1 -3
- package/src/data/bucket/pattern_bucket_features.ts +3 -3
- package/src/data/bucket/symbol_bucket.test.ts +5 -5
- package/src/data/bucket/symbol_bucket.ts +12 -15
- package/src/data/bucket.ts +7 -11
- package/src/data/dem_data.test.ts +1 -1
- package/src/data/dem_data.ts +1 -1
- package/src/data/evaluation_feature.ts +4 -5
- package/src/data/extent.ts +1 -4
- package/src/data/feature_index.ts +14 -13
- package/src/data/feature_position_map.test.ts +4 -4
- package/src/data/feature_position_map.ts +1 -1
- package/src/data/index_array_type.ts +0 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/load_geometry.ts +3 -4
- package/src/data/program_configuration.ts +6 -11
- package/src/data/segment.ts +9 -6
- package/src/geo/edge_insets.test.ts +1 -1
- package/src/geo/edge_insets.ts +36 -26
- package/src/geo/lng_lat.test.ts +1 -1
- package/src/geo/lng_lat.ts +61 -44
- package/src/geo/lng_lat_bounds.test.ts +2 -2
- package/src/geo/lng_lat_bounds.ts +88 -68
- package/src/geo/mercator_coordinate.test.ts +2 -2
- package/src/geo/mercator_coordinate.ts +34 -27
- package/src/geo/transform.test.ts +3 -3
- package/src/geo/transform.ts +58 -79
- package/src/gl/color_mode.ts +1 -3
- package/src/gl/context.ts +12 -11
- package/src/gl/cull_face_mode.ts +1 -3
- package/src/gl/depth_mode.ts +1 -3
- package/src/gl/framebuffer.ts +5 -4
- package/src/gl/index_buffer.ts +5 -4
- package/src/gl/render_pool.test.ts +2 -2
- package/src/gl/render_pool.ts +5 -5
- package/src/gl/state.test.ts +1 -1
- package/src/gl/stencil_mode.ts +1 -3
- package/src/gl/value.ts +1 -1
- package/src/gl/vertex_buffer.test.ts +2 -2
- package/src/gl/vertex_buffer.ts +8 -14
- package/src/index.test.ts +2 -2
- package/src/index.ts +121 -113
- package/src/render/draw_background.ts +7 -9
- package/src/render/draw_circle.ts +13 -15
- package/src/render/draw_collision_debug.ts +11 -13
- package/src/render/draw_custom.ts +6 -8
- package/src/render/draw_debug.test.ts +4 -4
- package/src/render/draw_debug.ts +8 -10
- package/src/render/draw_fill.test.ts +13 -13
- package/src/render/draw_fill.ts +9 -11
- package/src/render/draw_fill_extrusion.ts +10 -12
- package/src/render/draw_heatmap.ts +12 -14
- package/src/render/draw_hillshade.ts +10 -12
- package/src/render/draw_line.ts +9 -9
- package/src/render/draw_raster.ts +9 -11
- package/src/render/draw_symbol.test.ts +16 -16
- package/src/render/draw_symbol.ts +15 -16
- package/src/render/draw_terrain.ts +11 -11
- package/src/render/glyph_atlas.ts +10 -1
- package/src/render/glyph_manager.test.ts +3 -3
- package/src/render/glyph_manager.ts +7 -7
- package/src/render/image_atlas.ts +6 -3
- package/src/render/image_manager.ts +3 -5
- package/src/render/line_atlas.test.ts +1 -1
- package/src/render/line_atlas.ts +19 -14
- package/src/render/painter.ts +85 -65
- package/src/render/program/background_program.ts +2 -2
- package/src/render/program/circle_program.ts +5 -5
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +4 -4
- package/src/render/program/debug_program.ts +1 -1
- package/src/render/program/fill_extrusion_program.ts +3 -3
- package/src/render/program/fill_program.ts +3 -3
- package/src/render/program/heatmap_program.ts +5 -5
- package/src/render/program/hillshade_program.ts +7 -7
- package/src/render/program/line_program.ts +6 -6
- package/src/render/program/pattern.ts +3 -3
- package/src/render/program/raster_program.ts +2 -2
- package/src/render/program/symbol_program.ts +2 -2
- package/src/render/program/terrain_program.ts +1 -1
- package/src/render/program.ts +18 -16
- package/src/render/render_to_texture.test.ts +15 -15
- package/src/render/render_to_texture.ts +10 -10
- package/src/render/terrain.test.ts +38 -7
- package/src/render/terrain.ts +103 -67
- package/src/render/texture.ts +5 -4
- package/src/render/uniform_binding.test.ts +1 -1
- package/src/render/uniform_binding.ts +7 -1
- package/src/render/update_pattern_positions_in_program.ts +5 -5
- package/src/render/vertex_array_object.ts +9 -8
- package/src/shaders/encode_attribute.ts +0 -2
- package/src/shaders/shaders.ts +1 -3
- package/src/source/canvas_source.test.ts +6 -6
- package/src/source/canvas_source.ts +46 -60
- package/src/source/geojson_source.test.ts +5 -5
- package/src/source/geojson_source.ts +75 -59
- package/src/source/geojson_source_diff.ts +39 -2
- package/src/source/geojson_worker_source.test.ts +3 -3
- package/src/source/geojson_worker_source.ts +20 -26
- package/src/source/geojson_wrapper.test.ts +3 -3
- package/src/source/geojson_wrapper.ts +2 -4
- package/src/source/image_source.test.ts +9 -8
- package/src/source/image_source.ts +49 -35
- package/src/source/load_tilejson.ts +2 -2
- package/src/source/pixels_to_tile_units.ts +2 -3
- package/src/source/query_features.test.ts +3 -3
- package/src/source/query_features.ts +50 -19
- package/src/source/raster_dem_tile_source.test.ts +3 -3
- package/src/source/raster_dem_tile_source.ts +23 -10
- package/src/source/raster_dem_tile_worker_source.test.ts +2 -2
- package/src/source/raster_dem_tile_worker_source.ts +3 -5
- package/src/source/raster_tile_source.test.ts +3 -3
- package/src/source/raster_tile_source.ts +38 -11
- package/src/source/rtl_text_plugin.ts +4 -1
- package/src/source/source.ts +67 -59
- package/src/source/source_cache.test.ts +7 -7
- package/src/source/source_cache.ts +17 -38
- package/src/source/source_state.ts +2 -5
- package/src/source/terrain_source_cache.test.ts +8 -8
- package/src/source/terrain_source_cache.ts +42 -27
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +32 -38
- package/src/source/tile_bounds.ts +2 -4
- package/src/source/tile_cache.test.ts +2 -2
- package/src/source/tile_cache.ts +20 -30
- package/src/source/tile_id.ts +11 -2
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +34 -24
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +11 -23
- package/src/source/video_source.test.ts +5 -5
- package/src/source/video_source.ts +21 -28
- package/src/source/worker.ts +6 -8
- package/src/source/worker_source.ts +6 -8
- package/src/source/worker_tile.test.ts +5 -5
- package/src/source/worker_tile.ts +13 -16
- package/src/style/create_style_layer.ts +31 -26
- package/src/style/evaluation_parameters.ts +5 -4
- package/src/style/format_section_override.test.ts +2 -2
- package/src/style/format_section_override.ts +1 -1
- package/src/style/light.test.ts +2 -2
- package/src/style/light.ts +3 -5
- package/src/style/load_glyph_range.test.ts +1 -1
- package/src/style/load_glyph_range.ts +3 -3
- package/src/style/load_sprite.test.ts +1 -1
- package/src/style/load_sprite.ts +3 -3
- package/src/style/parse_glyph_pbf.ts +1 -1
- package/src/style/pauseable_placement.ts +7 -9
- package/src/style/properties.ts +4 -53
- package/src/style/query_utils.ts +3 -3
- package/src/style/style.test.ts +22 -19
- package/src/style/style.ts +118 -84
- package/src/style/style_glyph.ts +6 -0
- package/src/style/style_image.ts +39 -33
- package/src/style/style_layer/background_style_layer.ts +2 -4
- package/src/style/style_layer/circle_style_layer.ts +7 -6
- package/src/style/style_layer/custom_style_layer.ts +23 -48
- package/src/style/style_layer/fill_extrusion_style_layer.ts +4 -6
- package/src/style/style_layer/fill_style_layer.ts +5 -7
- package/src/style/style_layer/heatmap_style_layer.ts +8 -7
- package/src/style/style_layer/hillshade_style_layer.ts +2 -4
- package/src/style/style_layer/line_style_layer.ts +6 -8
- package/src/style/style_layer/overlap_mode.test.ts +3 -3
- package/src/style/style_layer/overlap_mode.ts +3 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -4
- package/src/style/style_layer/symbol_style_layer.ts +6 -8
- package/src/style/style_layer/typed_style_layer.ts +7 -7
- package/src/style/style_layer.test.ts +5 -5
- package/src/style/style_layer.ts +7 -6
- package/src/style/style_layer_index.test.ts +1 -1
- package/src/style/style_layer_index.ts +3 -5
- package/src/style/zoom_history.ts +1 -3
- package/src/symbol/anchor.test.ts +1 -1
- package/src/symbol/anchor.ts +1 -3
- package/src/symbol/check_max_angle.test.ts +8 -2
- package/src/symbol/check_max_angle.ts +10 -13
- package/src/symbol/clip_line.test.ts +1 -1
- package/src/symbol/clip_line.ts +6 -9
- package/src/symbol/collision_feature.test.ts +2 -2
- package/src/symbol/collision_feature.ts +7 -12
- package/src/symbol/collision_index.test.ts +2 -2
- package/src/symbol/collision_index.ts +5 -11
- package/src/symbol/cross_tile_symbol_index.test.ts +2 -2
- package/src/symbol/cross_tile_symbol_index.ts +5 -7
- package/src/symbol/get_anchors.ts +2 -2
- package/src/symbol/grid_index.test.ts +1 -1
- package/src/symbol/grid_index.ts +4 -5
- package/src/symbol/merge_lines.test.ts +1 -1
- package/src/symbol/merge_lines.ts +1 -1
- package/src/symbol/opacity_state.ts +1 -3
- package/src/symbol/path_interpolator.test.ts +1 -1
- package/src/symbol/path_interpolator.ts +1 -3
- package/src/symbol/placement.ts +9 -9
- package/src/symbol/projection.ts +61 -34
- package/src/symbol/quads.ts +7 -11
- package/src/symbol/shaping.ts +1 -1
- package/src/symbol/symbol_layout.ts +9 -12
- package/src/symbol/symbol_size.ts +1 -1
- package/src/symbol/symbol_style_layer.test.ts +4 -4
- package/src/symbol/transform_text.ts +2 -2
- package/src/types/callback.ts +14 -14
- package/src/types/cancelable.ts +3 -0
- package/src/types/transferable.ts +3 -0
- package/src/ui/anchor.ts +4 -0
- package/src/ui/camera.test.ts +6 -6
- package/src/ui/camera.ts +392 -361
- package/src/ui/control/attribution_control.test.ts +1 -1
- package/src/ui/control/attribution_control.ts +34 -30
- package/src/ui/control/control.ts +14 -20
- package/src/ui/control/fullscreen_control.test.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +21 -26
- package/src/ui/control/geolocate_control.test.ts +5 -5
- package/src/ui/control/geolocate_control.ts +181 -194
- package/src/ui/control/logo_control.ts +20 -16
- package/src/ui/control/navigation_control.test.ts +1 -1
- package/src/ui/control/navigation_control.ts +46 -42
- package/src/ui/control/scale_control.test.ts +1 -1
- package/src/ui/control/scale_control.ts +30 -21
- package/src/ui/control/terrain_control.test.ts +1 -1
- package/src/ui/control/terrain_control.ts +14 -18
- package/src/ui/default_locale.ts +1 -3
- package/src/ui/events.ts +570 -1281
- package/src/ui/handler/box_zoom.test.ts +2 -2
- package/src/ui/handler/box_zoom.ts +16 -11
- package/src/ui/handler/click_zoom.ts +11 -3
- package/src/ui/handler/cooperative_gestures.test.ts +3 -3
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_handler.ts +30 -22
- package/src/ui/handler/drag_move_state_manager.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +2 -2
- package/src/ui/handler/drag_rotate.test.ts +3 -3
- package/src/ui/handler/keyboard.test.ts +2 -2
- package/src/ui/handler/keyboard.ts +22 -13
- package/src/ui/handler/map_event.test.ts +2 -2
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.test.ts +3 -3
- package/src/ui/handler/scroll_zoom.ts +45 -52
- package/src/ui/handler/shim/dblclick_zoom.ts +12 -6
- package/src/ui/handler/shim/drag_pan.ts +34 -14
- package/src/ui/handler/shim/drag_rotate.ts +20 -12
- package/src/ui/handler/shim/two_fingers_touch.ts +24 -18
- package/src/ui/handler/tap_drag_zoom.test.ts +113 -0
- package/src/ui/handler/tap_drag_zoom.ts +18 -10
- package/src/ui/handler/tap_recognizer.ts +1 -1
- package/src/ui/handler/tap_zoom.ts +4 -3
- package/src/ui/handler/touch_pan.ts +3 -2
- package/src/ui/handler/transform-provider.ts +4 -6
- package/src/ui/handler/two_fingers_touch.test.ts +3 -3
- package/src/ui/handler/two_fingers_touch.ts +64 -47
- package/src/ui/handler_inertia.ts +4 -4
- package/src/ui/handler_manager.ts +86 -52
- package/src/ui/hash.test.ts +1 -1
- package/src/ui/hash.ts +21 -28
- package/src/ui/map/isMoving.test.ts +3 -3
- package/src/ui/map/isRotating.test.ts +3 -3
- package/src/ui/map/isZooming.test.ts +3 -3
- package/src/ui/map.test.ts +97 -8
- package/src/ui/map.ts +856 -702
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +35 -15
- package/src/ui/marker.ts +220 -141
- package/src/ui/popup.test.ts +2 -2
- package/src/ui/popup.ts +179 -147
- package/src/util/actor.test.ts +7 -7
- package/src/util/actor.ts +25 -22
- package/src/util/ajax.ts +37 -17
- package/src/util/browser.test.ts +1 -1
- package/src/util/browser.ts +2 -6
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/classify_rings.ts +1 -1
- package/src/util/color_ramp.ts +0 -2
- package/src/util/config.ts +6 -3
- package/src/util/debug.ts +0 -2
- package/src/util/dictionary_coder.ts +1 -4
- package/src/util/dispatcher.test.ts +3 -3
- package/src/util/dispatcher.ts +4 -9
- package/src/util/dom.ts +1 -1
- package/src/util/evented.ts +23 -18
- package/src/util/find_pole_of_inaccessibility.test.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +4 -5
- package/src/util/global_worker_pool.ts +2 -3
- package/src/util/image.ts +10 -4
- package/src/util/image_request.test.ts +3 -3
- package/src/util/image_request.ts +15 -14
- package/src/util/is_char_in_unicode_block.ts +1 -3
- package/src/util/offscreen_canvas_supported.ts +1 -1
- package/src/util/performance.ts +1 -2
- package/src/util/request_manager.ts +4 -0
- package/src/util/resolve_tokens.test.ts +1 -1
- package/src/util/resolve_tokens.ts +3 -6
- package/src/util/script_detection.ts +1 -4
- package/src/util/smart_wrap.ts +3 -5
- package/src/util/struct_array.ts +18 -14
- package/src/util/style.ts +2 -2
- package/src/util/task_queue.test.ts +1 -1
- package/src/util/task_queue.ts +1 -3
- package/src/util/test/mock_webgl.ts +6 -0
- package/src/util/test/util.ts +2 -2
- package/src/util/throttle.test.ts +1 -1
- package/src/util/throttle.ts +1 -2
- package/src/util/throttled_invoker.ts +1 -5
- package/src/util/transferable_grid_index.test.ts +1 -1
- package/src/util/transferable_grid_index.ts +1 -3
- package/src/util/util.test.ts +1 -14
- package/src/util/util.ts +44 -107
- package/src/util/vectortile_to_geojson.ts +13 -3
- package/src/util/verticalize_punctuation.ts +1 -1
- package/src/util/web_worker.ts +2 -2
- package/src/util/web_worker_transfer.ts +11 -8
- package/src/util/webp_supported.ts +2 -4
- package/src/util/worker_pool.test.ts +1 -1
- package/src/util/worker_pool.ts +4 -5
package/src/util/performance.ts
CHANGED
|
@@ -77,8 +77,7 @@ export const PerformanceUtils = {
|
|
|
77
77
|
/**
|
|
78
78
|
* Safe wrapper for the performance resource timing API in web workers with graceful degradation
|
|
79
79
|
*
|
|
80
|
-
* @
|
|
81
|
-
* @private
|
|
80
|
+
* @hidden
|
|
82
81
|
*/
|
|
83
82
|
export class RequestPerformance {
|
|
84
83
|
_marks: {
|
|
@@ -14,6 +14,10 @@ export const enum ResourceType {
|
|
|
14
14
|
Unknown = 'Unknown',
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* This function is used to tranform a request.
|
|
19
|
+
* It is used just before executing the relevant request.
|
|
20
|
+
*/
|
|
17
21
|
export type RequestTransformFunction = (url: string, resourceType?: ResourceType) => RequestParameters | undefined;
|
|
18
22
|
|
|
19
23
|
type UrlObject = {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
export default resolveTokens;
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Replace tokens in a string template with values in an object
|
|
5
3
|
*
|
|
6
|
-
* @param properties a key/value relationship between tokens and replacements
|
|
7
|
-
* @param text the template string
|
|
4
|
+
* @param properties - a key/value relationship between tokens and replacements
|
|
5
|
+
* @param text - the template string
|
|
8
6
|
* @returns the template with tokens replaced
|
|
9
|
-
* @private
|
|
10
7
|
*/
|
|
11
|
-
function resolveTokens(
|
|
8
|
+
export function resolveTokens(
|
|
12
9
|
properties: {
|
|
13
10
|
readonly [x: string]: unknown;
|
|
14
11
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable new-cap */
|
|
2
2
|
|
|
3
|
-
import isChar from './is_char_in_unicode_block';
|
|
3
|
+
import {unicodeBlockLookup as isChar} from './is_char_in_unicode_block';
|
|
4
4
|
|
|
5
5
|
export function allowsIdeographicBreaking(chars: string) {
|
|
6
6
|
for (const char of chars) {
|
|
@@ -81,7 +81,6 @@ export function charAllowsIdeographicBreaking(char: number) {
|
|
|
81
81
|
* adjacent characters can be rotated. For example, a Chinese character is
|
|
82
82
|
* always drawn upright. An uprightly oriented character causes an adjacent
|
|
83
83
|
* “neutral” character to be drawn upright as well.
|
|
84
|
-
* @private
|
|
85
84
|
*/
|
|
86
85
|
export function charHasUprightVerticalOrientation(char: number) {
|
|
87
86
|
if (char === 0x02EA /* modifier letter yin departing tone mark */ ||
|
|
@@ -169,7 +168,6 @@ export function charHasUprightVerticalOrientation(char: number) {
|
|
|
169
168
|
* fraction ½ is drawn upright among Chinese characters but rotated among Latin
|
|
170
169
|
* letters. A neutrally oriented character does not influence whether an
|
|
171
170
|
* adjacent character is drawn upright or rotated.
|
|
172
|
-
* @private
|
|
173
171
|
*/
|
|
174
172
|
export function charHasNeutralVerticalOrientation(char: number) {
|
|
175
173
|
if (isChar['Latin-1 Supplement'](char)) {
|
|
@@ -260,7 +258,6 @@ export function charHasNeutralVerticalOrientation(char: number) {
|
|
|
260
258
|
* oriented vertically, even if both adjacent characters are upright. For
|
|
261
259
|
* example, a Latin letter is drawn rotated along a vertical line. A rotated
|
|
262
260
|
* character causes an adjacent “neutral” character to be drawn rotated as well.
|
|
263
|
-
* @private
|
|
264
261
|
*/
|
|
265
262
|
export function charHasRotatedVerticalOrientation(char: number) {
|
|
266
263
|
return !(charHasUprightVerticalOrientation(char) ||
|
package/src/util/smart_wrap.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import LngLat from '../geo/lng_lat';
|
|
1
|
+
import {LngLat} from '../geo/lng_lat';
|
|
2
2
|
|
|
3
3
|
import type Point from '@mapbox/point-geometry';
|
|
4
|
-
import type Transform from '../geo/transform';
|
|
4
|
+
import type {Transform} from '../geo/transform';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Given a LngLat, prior projected position, and a transform, return a new LngLat shifted
|
|
@@ -15,10 +15,8 @@ import type Transform from '../geo/transform';
|
|
|
15
15
|
* possible; they should avoid shifting large distances across the screen, even when the
|
|
16
16
|
* map center changes by ±360° due to automatic wrapping, and when about to go off screen,
|
|
17
17
|
* should wrap just enough to avoid doing so.
|
|
18
|
-
*
|
|
19
|
-
* @private
|
|
20
18
|
*/
|
|
21
|
-
export
|
|
19
|
+
export function smartWrap(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {
|
|
22
20
|
lngLat = new LngLat(lngLat.lng, lngLat.lat);
|
|
23
21
|
|
|
24
22
|
// First, try shifting one world in either direction, and see if either is closer to the
|
package/src/util/struct_array.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import type {Transferable} from '../types/transferable';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A view type size
|
|
7
|
+
*/
|
|
5
8
|
const viewTypes = {
|
|
6
9
|
'Int8': Int8Array,
|
|
7
10
|
'Uint8': Uint8Array,
|
|
@@ -12,11 +15,12 @@ const viewTypes = {
|
|
|
12
15
|
'Float32': Float32Array
|
|
13
16
|
};
|
|
14
17
|
|
|
15
|
-
export type ViewType = keyof typeof viewTypes;
|
|
16
|
-
|
|
17
18
|
/**
|
|
18
|
-
*
|
|
19
|
+
* A view type size
|
|
19
20
|
*/
|
|
21
|
+
export type ViewType = keyof typeof viewTypes;
|
|
22
|
+
|
|
23
|
+
/** */
|
|
20
24
|
class Struct {
|
|
21
25
|
_pos1: number;
|
|
22
26
|
_pos2: number;
|
|
@@ -28,9 +32,8 @@ class Struct {
|
|
|
28
32
|
size: number;
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @private
|
|
35
|
+
* @param structArray - The StructArray the struct is stored in
|
|
36
|
+
* @param index - The index of the struct in the StructArray.
|
|
34
37
|
*/
|
|
35
38
|
constructor(structArray: StructArray, index: number) {
|
|
36
39
|
(this as any)._structArray = structArray;
|
|
@@ -44,6 +47,9 @@ class Struct {
|
|
|
44
47
|
const DEFAULT_CAPACITY = 128;
|
|
45
48
|
const RESIZE_MULTIPLIER = 5;
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* A struct array memeber
|
|
52
|
+
*/
|
|
47
53
|
export type StructArrayMember = {
|
|
48
54
|
name: string;
|
|
49
55
|
type: ViewType;
|
|
@@ -57,6 +63,9 @@ export type StructArrayLayout = {
|
|
|
57
63
|
alignment: number;
|
|
58
64
|
};
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* An array that can be desialized
|
|
68
|
+
*/
|
|
60
69
|
export type SerializedStructArray = {
|
|
61
70
|
length: number;
|
|
62
71
|
arrayBuffer: ArrayBuffer;
|
|
@@ -80,8 +89,6 @@ export type SerializedStructArray = {
|
|
|
80
89
|
* i-th element. This affords the convience of working with (seemingly) plain
|
|
81
90
|
* Javascript objects without the overhead of serializing/deserializing them
|
|
82
91
|
* into ArrayBuffers for efficient web worker transfer.
|
|
83
|
-
*
|
|
84
|
-
* @private
|
|
85
92
|
*/
|
|
86
93
|
abstract class StructArray {
|
|
87
94
|
capacity: number;
|
|
@@ -106,7 +113,6 @@ abstract class StructArray {
|
|
|
106
113
|
* Serialize a StructArray instance. Serializes both the raw data and the
|
|
107
114
|
* metadata needed to reconstruct the StructArray base class during
|
|
108
115
|
* deserialization.
|
|
109
|
-
* @private
|
|
110
116
|
*/
|
|
111
117
|
static serialize(array: StructArray, transferables?: Array<Transferable>): SerializedStructArray {
|
|
112
118
|
|
|
@@ -144,7 +150,7 @@ abstract class StructArray {
|
|
|
144
150
|
}
|
|
145
151
|
|
|
146
152
|
/**
|
|
147
|
-
* Resets the
|
|
153
|
+
* Resets the length of the array to 0 without de-allocating capcacity.
|
|
148
154
|
*/
|
|
149
155
|
clear() {
|
|
150
156
|
this.length = 0;
|
|
@@ -154,7 +160,7 @@ abstract class StructArray {
|
|
|
154
160
|
* Resize the array.
|
|
155
161
|
* If `n` is greater than the current length then additional elements with undefined values are added.
|
|
156
162
|
* If `n` is less than the current length then the array will be reduced to the first `n` elements.
|
|
157
|
-
* @param
|
|
163
|
+
* @param n - The new size of the array.
|
|
158
164
|
*/
|
|
159
165
|
resize(n: number) {
|
|
160
166
|
this.reserve(n);
|
|
@@ -164,7 +170,7 @@ abstract class StructArray {
|
|
|
164
170
|
/**
|
|
165
171
|
* Indicate a planned increase in size, so that any necessary allocation may
|
|
166
172
|
* be done once, ahead of time.
|
|
167
|
-
* @param
|
|
173
|
+
* @param n - The expected size of the array.
|
|
168
174
|
*/
|
|
169
175
|
reserve(n: number) {
|
|
170
176
|
if (n > this.capacity) {
|
|
@@ -190,8 +196,6 @@ abstract class StructArray {
|
|
|
190
196
|
* particular calculating the correct byte offset for each field. This data
|
|
191
197
|
* is used at build time to generate StructArrayLayout_*#emplaceBack() and
|
|
192
198
|
* other accessors, and at runtime for binding vertex buffer attributes.
|
|
193
|
-
*
|
|
194
|
-
* @private
|
|
195
199
|
*/
|
|
196
200
|
function createLayout(
|
|
197
201
|
members: Array<{
|
package/src/util/style.ts
CHANGED
|
@@ -4,8 +4,8 @@ import {SpriteSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
4
4
|
* Takes a SpriteSpecification value and returns it in its array form. If `undefined` is passed as an input value, an
|
|
5
5
|
* empty array is returned.
|
|
6
6
|
* duplicated entries with identical id/url will be removed in returned array
|
|
7
|
-
* @param
|
|
8
|
-
* @returns
|
|
7
|
+
* @param sprite - optional sprite to coerce
|
|
8
|
+
* @returns an empty array in case `undefined` is passed; id-url pairs otherwise
|
|
9
9
|
*/
|
|
10
10
|
export function coerceSpriteToArray(sprite?: SpriteSpecification): {id: string; url: string}[] {
|
|
11
11
|
const resultArray: {id: string; url: string}[] = [];
|
package/src/util/task_queue.ts
CHANGED
|
@@ -30,6 +30,12 @@ export function setupMockWebGLContext(webglContext: any) {
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
// Update drawingBufferWidth and drawingBufferHeigth when viewport changes
|
|
34
|
+
webglContext.viewport = jest.fn((x, y, width, height) => {
|
|
35
|
+
webglContext.drawingBufferWidth = width;
|
|
36
|
+
webglContext.drawingBufferHeight = height;
|
|
37
|
+
});
|
|
38
|
+
|
|
33
39
|
// Define the properties on the WebGL context
|
|
34
40
|
Object.defineProperty(webglContext, 'bindVertexArray', {
|
|
35
41
|
get() {
|
package/src/util/test/util.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Map from '../../ui/map';
|
|
1
|
+
import {Map} from '../../ui/map';
|
|
2
2
|
import {extend} from '../../util/util';
|
|
3
|
-
import Dispatcher from '../../util/dispatcher';
|
|
3
|
+
import {Dispatcher} from '../../util/dispatcher';
|
|
4
4
|
import {setWebGlContext} from './mock_webgl';
|
|
5
5
|
|
|
6
6
|
export function createMap(options?, callback?) {
|
package/src/util/throttle.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Throttle the given function to run at most every `period` milliseconds.
|
|
3
|
-
* @private
|
|
4
3
|
*/
|
|
5
|
-
export
|
|
4
|
+
export function throttle(fn: () => void, time: number): () => ReturnType<typeof setTimeout> {
|
|
6
5
|
let pending = false;
|
|
7
6
|
let timerId: ReturnType<typeof setTimeout> = null;
|
|
8
7
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests
|
|
3
3
|
* are ignored until the function was actually invoked.
|
|
4
|
-
*
|
|
5
|
-
* @private
|
|
6
4
|
*/
|
|
7
|
-
class ThrottledInvoker {
|
|
5
|
+
export class ThrottledInvoker {
|
|
8
6
|
_channel: MessageChannel;
|
|
9
7
|
_triggered: boolean;
|
|
10
8
|
_callback: Function;
|
|
@@ -40,5 +38,3 @@ class ThrottledInvoker {
|
|
|
40
38
|
this._callback = () => {};
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
export default ThrottledInvoker;
|
|
@@ -23,7 +23,7 @@ export type SerializedGrid = {
|
|
|
23
23
|
buffer: ArrayBuffer;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
class TransferableGridIndex {
|
|
26
|
+
export class TransferableGridIndex {
|
|
27
27
|
cells: number[][];
|
|
28
28
|
arrayBuffer: ArrayBuffer;
|
|
29
29
|
d: number;
|
|
@@ -212,5 +212,3 @@ class TransferableGridIndex {
|
|
|
212
212
|
return new TransferableGridIndex(serialized.buffer);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
|
|
216
|
-
export default TransferableGridIndex;
|
package/src/util/util.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Point from '@mapbox/point-geometry';
|
|
2
|
-
import {arraysIntersect, asyncAll, bezier,
|
|
2
|
+
import {arraysIntersect, asyncAll, bezier, clamp, clone, deepEqual, easeCubicInOut, extend, filterObject, findLineIntersection, isClosedPolygon, isCounterClockwise, isPowerOfTwo, keysDifference, mapObject, nextPowerOfTwo, parseCacheControl, pick, uniqueId, wrap} from './util';
|
|
3
3
|
|
|
4
4
|
describe('util', () => {
|
|
5
5
|
expect(easeCubicInOut(0)).toBe(0);
|
|
@@ -13,19 +13,6 @@ describe('util', () => {
|
|
|
13
13
|
expect(pick({a: 1, b: 2, c: 3}, ['a', 'c', 'd'])).toEqual({a: 1, c: 3});
|
|
14
14
|
expect(typeof uniqueId() === 'number').toBeTruthy();
|
|
15
15
|
|
|
16
|
-
test('bindAll', done => {
|
|
17
|
-
function MyClass() {
|
|
18
|
-
bindAll(['ontimer'], this);
|
|
19
|
-
this.name = 'Tom';
|
|
20
|
-
}
|
|
21
|
-
MyClass.prototype.ontimer = function() {
|
|
22
|
-
expect(this.name).toBe('Tom');
|
|
23
|
-
done();
|
|
24
|
-
};
|
|
25
|
-
const my = new MyClass();
|
|
26
|
-
setTimeout(my.ontimer, 0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
16
|
test('asyncAll - sync', done => {
|
|
30
17
|
expect(asyncAll([0, 1, 2], (data, callback) => {
|
|
31
18
|
callback(null, data);
|