@mapgis/mapbox-gl 16.0.1 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mapbox-gl.js +3 -3
- package/dist/mapbox-gl.js.map +1 -1
- package/package.json +1 -1
- package/.flowconfig +0 -61
- package/LICENSE.txt +0 -84
- package/README.md +0 -34
- package/build/banner.js +0 -4
- package/build/check-bundle-size.js +0 -140
- package/build/generate-access-token-script.js +0 -11
- package/build/generate-flow-typed-style-spec.js +0 -188
- package/build/generate-release-list.js +0 -21
- package/build/generate-struct-arrays.js +0 -237
- package/build/generate-style-code.js +0 -159
- package/build/mapbox-gl.js.flow +0 -3
- package/build/print-release-url.js +0 -6
- package/build/rollup_plugin_minify_style_spec.js +0 -20
- package/build/rollup_plugins.js +0 -80
- package/build/run-node +0 -3
- package/build/run-tap +0 -8
- package/build/test/build-tape.js +0 -19
- package/flow-typed/gl.js +0 -5
- package/flow-typed/jsdom.js +0 -18
- package/flow-typed/mapbox-gl-supported.js +0 -9
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -25
- package/flow-typed/point-geometry.js +0 -44
- package/flow-typed/potpack.js +0 -12
- package/flow-typed/sinon.js +0 -28
- package/flow-typed/vector-tile.js +0 -41
- package/src/css/mapbox-gl.css +0 -798
- package/src/css/svg/mapboxgl-ctrl-attrib.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-compass.svg +0 -4
- package/src/css/svg/mapboxgl-ctrl-fullscreen.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-geolocate.svg +0 -5
- package/src/css/svg/mapboxgl-ctrl-logo.svg +0 -20
- package/src/css/svg/mapboxgl-ctrl-shrink.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-in.svg +0 -3
- package/src/css/svg/mapboxgl-ctrl-zoom-out.svg +0 -3
- package/src/data/array_types.js +0 -1095
- package/src/data/bucket/circle_attributes.js +0 -9
- package/src/data/bucket/circle_bucket.js +0 -204
- package/src/data/bucket/fill_attributes.js +0 -9
- package/src/data/bucket/fill_bucket.js +0 -233
- package/src/data/bucket/fill_extrusion_attributes.js +0 -10
- package/src/data/bucket/fill_extrusion_bucket.js +0 -289
- package/src/data/bucket/heatmap_bucket.js +0 -17
- package/src/data/bucket/line_attributes.js +0 -10
- package/src/data/bucket/line_bucket.js +0 -556
- package/src/data/bucket/pattern_attributes.js +0 -10
- package/src/data/bucket/pattern_bucket_features.js +0 -60
- package/src/data/bucket/symbol_attributes.js +0 -117
- package/src/data/bucket/symbol_bucket.js +0 -972
- package/src/data/bucket.js +0 -123
- package/src/data/dem_data.js +0 -125
- package/src/data/extent.js +0 -18
- package/src/data/feature_index.js +0 -321
- package/src/data/feature_position_map.js +0 -125
- package/src/data/index_array_type.js +0 -16
- package/src/data/load_geometry.js +0 -48
- package/src/data/pos_attributes.js +0 -6
- package/src/data/program_configuration.js +0 -687
- package/src/data/raster_bounds_attributes.js +0 -7
- package/src/data/segment.js +0 -76
- package/src/geo/edge_insets.js +0 -102
- package/src/geo/lng_lat.js +0 -165
- package/src/geo/lng_lat_bounds.js +0 -267
- package/src/geo/mercator_coordinate.js +0 -153
- package/src/geo/transform.js +0 -864
- package/src/gl/color_mode.js +0 -34
- package/src/gl/context.js +0 -298
- package/src/gl/cull_face_mode.js +0 -26
- package/src/gl/depth_mode.js +0 -29
- package/src/gl/framebuffer.js +0 -44
- package/src/gl/index_buffer.js +0 -55
- package/src/gl/stencil_mode.js +0 -30
- package/src/gl/types.js +0 -84
- package/src/gl/value.js +0 -520
- package/src/gl/vertex_buffer.js +0 -119
- package/src/index.js +0 -201
- package/src/render/draw_background.js +0 -57
- package/src/render/draw_circle.js +0 -113
- package/src/render/draw_collision_debug.js +0 -49
- package/src/render/draw_custom.js +0 -49
- package/src/render/draw_debug.js +0 -127
- package/src/render/draw_fill.js +0 -126
- package/src/render/draw_fill_extrusion.js +0 -96
- package/src/render/draw_heatmap.js +0 -140
- package/src/render/draw_hillshade.js +0 -108
- package/src/render/draw_line.js +0 -98
- package/src/render/draw_raster.js +0 -125
- package/src/render/draw_symbol.js +0 -394
- package/src/render/glyph_atlas.js +0 -71
- package/src/render/glyph_manager.js +0 -182
- package/src/render/image_atlas.js +0 -149
- package/src/render/image_manager.js +0 -306
- package/src/render/line_atlas.js +0 -210
- package/src/render/painter.js +0 -653
- package/src/render/program/background_program.js +0 -103
- package/src/render/program/circle_program.js +0 -69
- package/src/render/program/clipping_mask_program.js +0 -20
- package/src/render/program/collision_program.js +0 -49
- package/src/render/program/debug_program.js +0 -35
- package/src/render/program/fill_extrusion_program.js +0 -122
- package/src/render/program/fill_program.js +0 -126
- package/src/render/program/heatmap_program.js +0 -83
- package/src/render/program/hillshade_program.js +0 -122
- package/src/render/program/line_program.js +0 -207
- package/src/render/program/pattern.js +0 -102
- package/src/render/program/program_uniforms.js +0 -42
- package/src/render/program/raster_program.js +0 -92
- package/src/render/program/symbol_program.js +0 -224
- package/src/render/program.js +0 -168
- package/src/render/texture.js +0 -122
- package/src/render/uniform_binding.js +0 -147
- package/src/render/vertex_array_object.js +0 -163
- package/src/shaders/README.md +0 -42
- package/src/shaders/_prelude.fragment.glsl +0 -17
- package/src/shaders/_prelude.vertex.glsl +0 -73
- package/src/shaders/background.fragment.glsl +0 -10
- package/src/shaders/background.vertex.glsl +0 -7
- package/src/shaders/background_pattern.fragment.glsl +0 -28
- package/src/shaders/background_pattern.vertex.glsl +0 -20
- package/src/shaders/circle.fragment.glsl +0 -39
- package/src/shaders/circle.vertex.glsl +0 -64
- package/src/shaders/clipping_mask.fragment.glsl +0 -3
- package/src/shaders/clipping_mask.vertex.glsl +0 -7
- package/src/shaders/collision_box.fragment.glsl +0 -21
- package/src/shaders/collision_box.vertex.glsl +0 -27
- package/src/shaders/collision_circle.fragment.glsl +0 -34
- package/src/shaders/collision_circle.vertex.glsl +0 -36
- package/src/shaders/debug.fragment.glsl +0 -9
- package/src/shaders/debug.vertex.glsl +0 -12
- package/src/shaders/encode_attribute.js +0 -17
- package/src/shaders/fill.fragment.glsl +0 -13
- package/src/shaders/fill.vertex.glsl +0 -13
- package/src/shaders/fill_extrusion.fragment.glsl +0 -9
- package/src/shaders/fill_extrusion.vertex.glsl +0 -66
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +0 -45
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +0 -79
- package/src/shaders/fill_outline.fragment.glsl +0 -17
- package/src/shaders/fill_outline.vertex.glsl +0 -17
- package/src/shaders/fill_outline_pattern.fragment.glsl +0 -43
- package/src/shaders/fill_outline_pattern.vertex.glsl +0 -44
- package/src/shaders/fill_pattern.fragment.glsl +0 -36
- package/src/shaders/fill_pattern.vertex.glsl +0 -39
- package/src/shaders/heatmap.fragment.glsl +0 -22
- package/src/shaders/heatmap.vertex.glsl +0 -54
- package/src/shaders/heatmap_texture.fragment.glsl +0 -14
- package/src/shaders/heatmap_texture.vertex.glsl +0 -11
- package/src/shaders/hillshade.fragment.glsl +0 -52
- package/src/shaders/hillshade.vertex.glsl +0 -11
- package/src/shaders/hillshade_prepare.fragment.glsl +0 -74
- package/src/shaders/hillshade_prepare.vertex.glsl +0 -15
- package/src/shaders/index.js +0 -20
- package/src/shaders/line.fragment.glsl +0 -30
- package/src/shaders/line.vertex.glsl +0 -85
- package/src/shaders/line_gradient.fragment.glsl +0 -34
- package/src/shaders/line_gradient.vertex.glsl +0 -87
- package/src/shaders/line_pattern.fragment.glsl +0 -74
- package/src/shaders/line_pattern.vertex.glsl +0 -99
- package/src/shaders/line_sdf.fragment.glsl +0 -45
- package/src/shaders/line_sdf.vertex.glsl +0 -98
- package/src/shaders/raster.fragment.glsl +0 -52
- package/src/shaders/raster.vertex.glsl +0 -21
- package/src/shaders/shaders.js +0 -180
- package/src/shaders/symbol_icon.fragment.glsl +0 -17
- package/src/shaders/symbol_icon.vertex.glsl +0 -94
- package/src/shaders/symbol_sdf.fragment.glsl +0 -52
- package/src/shaders/symbol_sdf.vertex.glsl +0 -115
- package/src/shaders/symbol_text_and_icon.fragment.glsl +0 -68
- package/src/shaders/symbol_text_and_icon.vertex.glsl +0 -116
- package/src/source/canvas_source.js +0 -238
- package/src/source/geojson_helper.js +0 -92
- package/src/source/geojson_source.js +0 -374
- package/src/source/geojson_worker_source.js +0 -357
- package/src/source/geojson_wrapper.js +0 -94
- package/src/source/image_source.js +0 -307
- package/src/source/load_tilejson.js +0 -39
- package/src/source/mbtiles_source.js +0 -115
- package/src/source/offline_database.js +0 -61
- package/src/source/offline_database_root.js +0 -62
- package/src/source/pixels_to_tile_units.js +0 -21
- package/src/source/query_features.js +0 -208
- package/src/source/raster_dem_tile_source.js +0 -138
- package/src/source/raster_dem_tile_worker_source.js +0 -62
- package/src/source/raster_tile_offline_source.js +0 -136
- package/src/source/raster_tile_source.js +0 -177
- package/src/source/rtl_text_plugin.js +0 -138
- package/src/source/source.js +0 -137
- package/src/source/source_cache.js +0 -957
- package/src/source/source_state.js +0 -159
- package/src/source/tile.js +0 -465
- package/src/source/tile_bounds.js +0 -38
- package/src/source/tile_cache.js +0 -212
- package/src/source/tile_id.js +0 -402
- package/src/source/vector_tile_source.js +0 -192
- package/src/source/vector_tile_worker_source.js +0 -216
- package/src/source/video_source.js +0 -203
- package/src/source/worker.js +0 -237
- package/src/source/worker_source.js +0 -106
- package/src/source/worker_tile.js +0 -224
- package/src/style/create_style_layer.js +0 -36
- package/src/style/evaluation_parameters.js +0 -62
- package/src/style/light.js +0 -130
- package/src/style/load_glyph_range.js +0 -38
- package/src/style/load_sprite.js +0 -67
- package/src/style/parse_glyph_pbf.js +0 -44
- package/src/style/pauseable_placement.js +0 -132
- package/src/style/properties.js +0 -753
- package/src/style/query_utils.js +0 -43
- package/src/style/style.js +0 -1361
- package/src/style/style_glyph.js +0 -17
- package/src/style/style_image.js +0 -137
- package/src/style/style_layer/background_style_layer.js +0 -21
- package/src/style/style_layer/background_style_layer_properties.js +0 -40
- package/src/style/style_layer/circle_style_layer.js +0 -98
- package/src/style/style_layer/circle_style_layer_properties.js +0 -63
- package/src/style/style_layer/custom_style_layer.js +0 -223
- package/src/style/style_layer/fill_extrusion_style_layer.js +0 -224
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +0 -50
- package/src/style/style_layer/fill_style_layer.js +0 -67
- package/src/style/style_layer/fill_style_layer_properties.js +0 -55
- package/src/style/style_layer/heatmap_style_layer.js +0 -69
- package/src/style/style_layer/heatmap_style_layer_properties.js +0 -44
- package/src/style/style_layer/hillshade_style_layer.js +0 -25
- package/src/style/style_layer/hillshade_style_layer_properties.js +0 -46
- package/src/style/style_layer/layer_properties.js.ejs +0 -69
- package/src/style/style_layer/line_style_layer.js +0 -151
- package/src/style/style_layer/line_style_layer_properties.js +0 -71
- package/src/style/style_layer/raster_style_layer.js +0 -21
- package/src/style/style_layer/raster_style_layer_properties.js +0 -50
- package/src/style/style_layer/symbol_style_layer.js +0 -190
- package/src/style/style_layer/symbol_style_layer_properties.js +0 -153
- package/src/style/style_layer/typed_style_layer.js +0 -17
- package/src/style/style_layer.js +0 -281
- package/src/style/style_layer_index.js +0 -80
- package/src/style/validate_style.js +0 -42
- package/src/style/zoom_history.js +0 -44
- package/src/style-spec/.eslintrc +0 -5
- package/src/style-spec/CHANGELOG.md +0 -438
- package/src/style-spec/README.md +0 -59
- package/src/style-spec/bin/gl-style-composite +0 -9
- package/src/style-spec/bin/gl-style-format +0 -22
- package/src/style-spec/bin/gl-style-migrate +0 -9
- package/src/style-spec/bin/gl-style-validate +0 -50
- package/src/style-spec/composite.js +0 -50
- package/src/style-spec/declass.js +0 -42
- package/src/style-spec/deref.js +0 -52
- package/src/style-spec/diff.js +0 -393
- package/src/style-spec/dist/.gitkeep +0 -0
- package/src/style-spec/empty.js +0 -29
- package/src/style-spec/error/parsing_error.js +0 -16
- package/src/style-spec/error/validation_error.js +0 -18
- package/src/style-spec/expression/compound_expression.js +0 -162
- package/src/style-spec/expression/definitions/assertion.js +0 -130
- package/src/style-spec/expression/definitions/at.js +0 -70
- package/src/style-spec/expression/definitions/case.js +0 -85
- package/src/style-spec/expression/definitions/coalesce.js +0 -93
- package/src/style-spec/expression/definitions/coercion.js +0 -133
- package/src/style-spec/expression/definitions/collator.js +0 -78
- package/src/style-spec/expression/definitions/comparison.js +0 -184
- package/src/style-spec/expression/definitions/format.js +0 -144
- package/src/style-spec/expression/definitions/format_section_override.js +0 -54
- package/src/style-spec/expression/definitions/image.js +0 -52
- package/src/style-spec/expression/definitions/in.js +0 -92
- package/src/style-spec/expression/definitions/index.js +0 -561
- package/src/style-spec/expression/definitions/interpolate.js +0 -267
- package/src/style-spec/expression/definitions/length.js +0 -61
- package/src/style-spec/expression/definitions/let.js +0 -72
- package/src/style-spec/expression/definitions/literal.js +0 -77
- package/src/style-spec/expression/definitions/match.js +0 -158
- package/src/style-spec/expression/definitions/number_format.js +0 -142
- package/src/style-spec/expression/definitions/step.js +0 -120
- package/src/style-spec/expression/definitions/var.js +0 -46
- package/src/style-spec/expression/definitions/within.js +0 -333
- package/src/style-spec/expression/evaluation_context.js +0 -59
- package/src/style-spec/expression/expression.js +0 -27
- package/src/style-spec/expression/index.js +0 -392
- package/src/style-spec/expression/is_constant.js +0 -59
- package/src/style-spec/expression/parsing_context.js +0 -233
- package/src/style-spec/expression/parsing_error.js +0 -13
- package/src/style-spec/expression/runtime_error.js +0 -17
- package/src/style-spec/expression/scope.js +0 -36
- package/src/style-spec/expression/stops.js +0 -39
- package/src/style-spec/expression/types/collator.js +0 -61
- package/src/style-spec/expression/types/formatted.js +0 -73
- package/src/style-spec/expression/types/resolved_image.js +0 -29
- package/src/style-spec/expression/types.js +0 -106
- package/src/style-spec/expression/values.js +0 -123
- package/src/style-spec/feature_filter/README.md +0 -55
- package/src/style-spec/feature_filter/convert.js +0 -208
- package/src/style-spec/feature_filter/index.js +0 -165
- package/src/style-spec/format.js +0 -51
- package/src/style-spec/function/convert.js +0 -254
- package/src/style-spec/function/index.js +0 -262
- package/src/style-spec/group_by_layout.js +0 -75
- package/src/style-spec/migrate/expressions.js +0 -39
- package/src/style-spec/migrate/v8.js +0 -203
- package/src/style-spec/migrate/v9.js +0 -26
- package/src/style-spec/migrate.js +0 -36
- package/src/style-spec/package.json +0 -41
- package/src/style-spec/read_style.js +0 -14
- package/src/style-spec/reference/latest.js +0 -3
- package/src/style-spec/reference/v8.json +0 -5808
- package/src/style-spec/rollup.config.js +0 -45
- package/src/style-spec/style-spec.js +0 -122
- package/src/style-spec/types.js +0 -438
- package/src/style-spec/util/color.js +0 -95
- package/src/style-spec/util/color_spaces.js +0 -139
- package/src/style-spec/util/deep_equal.js +0 -28
- package/src/style-spec/util/extend.js +0 -10
- package/src/style-spec/util/get_type.js +0 -17
- package/src/style-spec/util/interpolate.js +0 -22
- package/src/style-spec/util/properties.js +0 -15
- package/src/style-spec/util/ref_properties.js +0 -2
- package/src/style-spec/util/result.js +0 -19
- package/src/style-spec/util/unbundle_jsonlint.js +0 -24
- package/src/style-spec/validate/latest.js +0 -11
- package/src/style-spec/validate/validate.js +0 -75
- package/src/style-spec/validate/validate_array.js +0 -52
- package/src/style-spec/validate/validate_boolean.js +0 -15
- package/src/style-spec/validate/validate_color.js +0 -20
- package/src/style-spec/validate/validate_constants.js +0 -13
- package/src/style-spec/validate/validate_enum.js +0 -21
- package/src/style-spec/validate/validate_expression.js +0 -43
- package/src/style-spec/validate/validate_filter.js +0 -111
- package/src/style-spec/validate/validate_formatted.js +0 -11
- package/src/style-spec/validate/validate_function.js +0 -207
- package/src/style-spec/validate/validate_glyphs_url.js +0 -21
- package/src/style-spec/validate/validate_image.js +0 -11
- package/src/style-spec/validate/validate_layer.js +0 -134
- package/src/style-spec/validate/validate_layout_property.js +0 -6
- package/src/style-spec/validate/validate_light.js +0 -47
- package/src/style-spec/validate/validate_number.js +0 -29
- package/src/style-spec/validate/validate_object.js +0 -61
- package/src/style-spec/validate/validate_paint_property.js +0 -6
- package/src/style-spec/validate/validate_property.js +0 -64
- package/src/style-spec/validate/validate_source.js +0 -111
- package/src/style-spec/validate/validate_string.js +0 -15
- package/src/style-spec/validate_mapbox_api_supported.js +0 -171
- package/src/style-spec/validate_style.js +0 -39
- package/src/style-spec/validate_style.min.js +0 -78
- package/src/style-spec/visit.js +0 -77
- package/src/symbol/anchor.js +0 -26
- package/src/symbol/check_max_angle.js +0 -81
- package/src/symbol/clip_line.js +0 -71
- package/src/symbol/collision_feature.js +0 -217
- package/src/symbol/collision_index.js +0 -372
- package/src/symbol/cross_tile_symbol_index.js +0 -301
- package/src/symbol/get_anchors.js +0 -167
- package/src/symbol/grid_index.js +0 -335
- package/src/symbol/mergelines.js +0 -82
- package/src/symbol/one_em.js +0 -4
- package/src/symbol/opacity_state.js +0 -27
- package/src/symbol/placement.js +0 -1062
- package/src/symbol/projection.js +0 -450
- package/src/symbol/quads.js +0 -334
- package/src/symbol/shaping.js +0 -816
- package/src/symbol/symbol_layout.js +0 -772
- package/src/symbol/symbol_size.js +0 -113
- package/src/symbol/transform_text.js +0 -29
- package/src/types/callback.js +0 -17
- package/src/types/cancelable.js +0 -3
- package/src/types/tilejson.js +0 -17
- package/src/types/transferable.js +0 -3
- package/src/types/window.js +0 -172
- package/src/ui/anchor.js +0 -32
- package/src/ui/bind_handlers.js +0 -202
- package/src/ui/camera.js +0 -1152
- package/src/ui/control/attribution_control.js +0 -189
- package/src/ui/control/fps_control.js +0 -185
- package/src/ui/control/fullscreen_control.js +0 -147
- package/src/ui/control/geolocate_control.js +0 -594
- package/src/ui/control/logo_control.js +0 -92
- package/src/ui/control/navigation_control.js +0 -148
- package/src/ui/control/scale_control.js +0 -142
- package/src/ui/crs.js +0 -64
- package/src/ui/default_locale.js +0 -20
- package/src/ui/events.js +0 -806
- package/src/ui/handler/box_zoom.js +0 -175
- package/src/ui/handler/dblclick_zoom.js +0 -139
- package/src/ui/handler/drag_pan.js +0 -416
- package/src/ui/handler/drag_rotate.js +0 -378
- package/src/ui/handler/keyboard.js +0 -161
- package/src/ui/handler/scroll_zoom.js +0 -333
- package/src/ui/handler/touch_zoom_rotate.js +0 -293
- package/src/ui/hash.js +0 -147
- package/src/ui/map.js +0 -2883
- package/src/ui/marker.js +0 -607
- package/src/ui/offline_map.js +0 -91
- package/src/ui/popup.js +0 -530
- package/src/util/actor.js +0 -212
- package/src/util/ajax.js +0 -371
- package/src/util/browser/web_worker.js +0 -10
- package/src/util/browser/window.js +0 -5
- package/src/util/browser.js +0 -70
- package/src/util/classify_rings.js +0 -52
- package/src/util/color_ramp.js +0 -28
- package/src/util/config.js +0 -30
- package/src/util/debug.js +0 -12
- package/src/util/dictionary_coder.js +0 -30
- package/src/util/dispatcher.js +0 -70
- package/src/util/dom.js +0 -144
- package/src/util/evented.js +0 -174
- package/src/util/find_pole_of_inaccessibility.js +0 -129
- package/src/util/global_worker_pool.js +0 -17
- package/src/util/image.js +0 -142
- package/src/util/intersection_tests.js +0 -208
- package/src/util/is_char_in_unicode_block.js +0 -311
- package/src/util/mapbox.js +0 -486
- package/src/util/offscreen_canvas_supported.js +0 -14
- package/src/util/performance.js +0 -112
- package/src/util/primitives.js +0 -145
- package/src/util/resolve_tokens.js +0 -16
- package/src/util/script_detection.js +0 -328
- package/src/util/sku_token.js +0 -42
- package/src/util/smart_wrap.js +0 -55
- package/src/util/struct_array.js +0 -243
- package/src/util/struct_array.js.ejs +0 -112
- package/src/util/struct_array_layout.js.ejs +0 -98
- package/src/util/task_queue.js +0 -68
- package/src/util/throttle.js +0 -28
- package/src/util/throttled_invoker.js +0 -46
- package/src/util/tile_cover.js +0 -101
- package/src/util/tile_request_cache.js +0 -172
- package/src/util/util.js +0 -504
- package/src/util/vectortile_to_geojson.js +0 -54
- package/src/util/verticalize_punctuation.js +0 -114
- package/src/util/web_worker.js +0 -91
- package/src/util/web_worker_transfer.js +0 -266
- package/src/util/webp_supported.js +0 -69
- package/src/util/window.js +0 -102
- package/src/util/worker_pool.js +0 -47
package/src/util/struct_array.js
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
// Note: all "sizes" are measured in bytes
|
|
4
|
-
|
|
5
|
-
import assert from 'assert';
|
|
6
|
-
|
|
7
|
-
import type {Transferable} from '../types/transferable';
|
|
8
|
-
|
|
9
|
-
const viewTypes = {
|
|
10
|
-
'Int8': Int8Array,
|
|
11
|
-
'Uint8': Uint8Array,
|
|
12
|
-
'Int16': Int16Array,
|
|
13
|
-
'Uint16': Uint16Array,
|
|
14
|
-
'Int32': Int32Array,
|
|
15
|
-
'Uint32': Uint32Array,
|
|
16
|
-
'Float32': Float32Array
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type ViewType = $Keys<typeof viewTypes>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
|
-
class Struct {
|
|
25
|
-
_pos1: number;
|
|
26
|
-
_pos2: number;
|
|
27
|
-
_pos4: number;
|
|
28
|
-
_pos8: number;
|
|
29
|
-
+_structArray: StructArray;
|
|
30
|
-
|
|
31
|
-
// The following properties are defined on the prototype of sub classes.
|
|
32
|
-
size: number;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {StructArray} structArray The StructArray the struct is stored in
|
|
36
|
-
* @param {number} index The index of the struct in the StructArray.
|
|
37
|
-
* @private
|
|
38
|
-
*/
|
|
39
|
-
constructor(structArray: StructArray, index: number) {
|
|
40
|
-
(this: any)._structArray = structArray;
|
|
41
|
-
this._pos1 = index * this.size;
|
|
42
|
-
this._pos2 = this._pos1 / 2;
|
|
43
|
-
this._pos4 = this._pos1 / 4;
|
|
44
|
-
this._pos8 = this._pos1 / 8;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const DEFAULT_CAPACITY = 128;
|
|
49
|
-
const RESIZE_MULTIPLIER = 5;
|
|
50
|
-
|
|
51
|
-
export type StructArrayMember = {
|
|
52
|
-
name: string,
|
|
53
|
-
type: ViewType,
|
|
54
|
-
components: number,
|
|
55
|
-
offset: number
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export type StructArrayLayout = {
|
|
59
|
-
members: Array<StructArrayMember>,
|
|
60
|
-
size: number,
|
|
61
|
-
alignment: ?number
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type SerializedStructArray = {
|
|
65
|
-
length: number,
|
|
66
|
-
arrayBuffer: ArrayBuffer
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* `StructArray` provides an abstraction over `ArrayBuffer` and `TypedArray`
|
|
71
|
-
* making it behave like an array of typed structs.
|
|
72
|
-
*
|
|
73
|
-
* Conceptually, a StructArray is comprised of elements, i.e., instances of its
|
|
74
|
-
* associated struct type. Each particular struct type, together with an
|
|
75
|
-
* alignment size, determines the memory layout of a StructArray whose elements
|
|
76
|
-
* are of that type. Thus, for each such layout that we need, we have
|
|
77
|
-
* a corrseponding StructArrayLayout class, inheriting from StructArray and
|
|
78
|
-
* implementing `emplaceBack()` and `_refreshViews()`.
|
|
79
|
-
*
|
|
80
|
-
* In some cases, where we need to access particular elements of a StructArray,
|
|
81
|
-
* we implement a more specific subclass that inherits from one of the
|
|
82
|
-
* StructArrayLayouts and adds a `get(i): T` accessor that returns a structured
|
|
83
|
-
* object whose properties are proxies into the underlying memory space for the
|
|
84
|
-
* i-th element. This affords the convience of working with (seemingly) plain
|
|
85
|
-
* Javascript objects without the overhead of serializing/deserializing them
|
|
86
|
-
* into ArrayBuffers for efficient web worker transfer.
|
|
87
|
-
*
|
|
88
|
-
* @private
|
|
89
|
-
*/
|
|
90
|
-
class StructArray {
|
|
91
|
-
capacity: number;
|
|
92
|
-
length: number;
|
|
93
|
-
isTransferred: boolean;
|
|
94
|
-
arrayBuffer: ArrayBuffer;
|
|
95
|
-
uint8: Uint8Array;
|
|
96
|
-
|
|
97
|
-
// The following properties are defined on the prototype.
|
|
98
|
-
members: Array<StructArrayMember>;
|
|
99
|
-
bytesPerElement: number;
|
|
100
|
-
+emplaceBack: Function;
|
|
101
|
-
+emplace: Function;
|
|
102
|
-
|
|
103
|
-
constructor() {
|
|
104
|
-
this.isTransferred = false;
|
|
105
|
-
this.capacity = -1;
|
|
106
|
-
this.resize(0);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Serialize a StructArray instance. Serializes both the raw data and the
|
|
111
|
-
* metadata needed to reconstruct the StructArray base class during
|
|
112
|
-
* deserialization.
|
|
113
|
-
* @private
|
|
114
|
-
*/
|
|
115
|
-
static serialize(array: StructArray, transferables?: Array<Transferable>): SerializedStructArray {
|
|
116
|
-
assert(!array.isTransferred);
|
|
117
|
-
|
|
118
|
-
array._trim();
|
|
119
|
-
|
|
120
|
-
if (transferables) {
|
|
121
|
-
array.isTransferred = true;
|
|
122
|
-
transferables.push(array.arrayBuffer);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
length: array.length,
|
|
127
|
-
arrayBuffer: array.arrayBuffer,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
static deserialize(input: SerializedStructArray) {
|
|
132
|
-
const structArray = Object.create(this.prototype);
|
|
133
|
-
structArray.arrayBuffer = input.arrayBuffer;
|
|
134
|
-
structArray.length = input.length;
|
|
135
|
-
structArray.capacity = input.arrayBuffer.byteLength / structArray.bytesPerElement;
|
|
136
|
-
structArray._refreshViews();
|
|
137
|
-
return structArray;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Resize the array to discard unused capacity.
|
|
142
|
-
*/
|
|
143
|
-
_trim() {
|
|
144
|
-
if (this.length !== this.capacity) {
|
|
145
|
-
this.capacity = this.length;
|
|
146
|
-
this.arrayBuffer = this.arrayBuffer.slice(0, this.length * this.bytesPerElement);
|
|
147
|
-
this._refreshViews();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Resets the the length of the array to 0 without de-allocating capcacity.
|
|
153
|
-
*/
|
|
154
|
-
clear() {
|
|
155
|
-
this.length = 0;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Resize the array.
|
|
160
|
-
* If `n` is greater than the current length then additional elements with undefined values are added.
|
|
161
|
-
* If `n` is less than the current length then the array will be reduced to the first `n` elements.
|
|
162
|
-
* @param {number} n The new size of the array.
|
|
163
|
-
*/
|
|
164
|
-
resize(n: number) {
|
|
165
|
-
assert(!this.isTransferred);
|
|
166
|
-
this.reserve(n);
|
|
167
|
-
this.length = n;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Indicate a planned increase in size, so that any necessary allocation may
|
|
172
|
-
* be done once, ahead of time.
|
|
173
|
-
* @param {number} n The expected size of the array.
|
|
174
|
-
*/
|
|
175
|
-
reserve(n: number) {
|
|
176
|
-
if (n > this.capacity) {
|
|
177
|
-
this.capacity = Math.max(n, Math.floor(this.capacity * RESIZE_MULTIPLIER), DEFAULT_CAPACITY);
|
|
178
|
-
this.arrayBuffer = new ArrayBuffer(this.capacity * this.bytesPerElement);
|
|
179
|
-
|
|
180
|
-
const oldUint8Array = this.uint8;
|
|
181
|
-
this._refreshViews();
|
|
182
|
-
if (oldUint8Array) this.uint8.set(oldUint8Array);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Create TypedArray views for the current ArrayBuffer.
|
|
188
|
-
*/
|
|
189
|
-
_refreshViews() {
|
|
190
|
-
throw new Error('_refreshViews() must be implemented by each concrete StructArray layout');
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Given a list of member fields, create a full StructArrayLayout, in
|
|
196
|
-
* particular calculating the correct byte offset for each field. This data
|
|
197
|
-
* is used at build time to generate StructArrayLayout_*#emplaceBack() and
|
|
198
|
-
* other accessors, and at runtime for binding vertex buffer attributes.
|
|
199
|
-
*
|
|
200
|
-
* @private
|
|
201
|
-
*/
|
|
202
|
-
function createLayout(
|
|
203
|
-
members: Array<{ name: string, type: ViewType, +components?: number, }>,
|
|
204
|
-
alignment: number = 1
|
|
205
|
-
): StructArrayLayout {
|
|
206
|
-
|
|
207
|
-
let offset = 0;
|
|
208
|
-
let maxSize = 0;
|
|
209
|
-
const layoutMembers = members.map((member) => {
|
|
210
|
-
assert(member.name.length);
|
|
211
|
-
const typeSize = sizeOf(member.type);
|
|
212
|
-
const memberOffset = offset = align(offset, Math.max(alignment, typeSize));
|
|
213
|
-
const components = member.components || 1;
|
|
214
|
-
|
|
215
|
-
maxSize = Math.max(maxSize, typeSize);
|
|
216
|
-
offset += typeSize * components;
|
|
217
|
-
|
|
218
|
-
return {
|
|
219
|
-
name: member.name,
|
|
220
|
-
type: member.type,
|
|
221
|
-
components,
|
|
222
|
-
offset: memberOffset,
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
const size = align(offset, Math.max(maxSize, alignment));
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
members: layoutMembers,
|
|
230
|
-
size,
|
|
231
|
-
alignment
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function sizeOf(type: ViewType): number {
|
|
236
|
-
return viewTypes[type].BYTES_PER_ELEMENT;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function align(offset: number, size: number): number {
|
|
240
|
-
return Math.ceil(offset / size) * size;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export {StructArray, Struct, viewTypes, createLayout};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const {
|
|
3
|
-
arrayClass,
|
|
4
|
-
members,
|
|
5
|
-
size,
|
|
6
|
-
usedTypes,
|
|
7
|
-
hasAnchorPoint,
|
|
8
|
-
layoutClass,
|
|
9
|
-
includeStructAccessors
|
|
10
|
-
} = locals
|
|
11
|
-
|
|
12
|
-
const StructTypeClass = arrayClass.replace('Array', 'Struct');
|
|
13
|
-
const StructArrayClass = arrayClass;
|
|
14
|
-
const StructArrayLayoutClass = layoutClass;
|
|
15
|
-
-%>
|
|
16
|
-
<%
|
|
17
|
-
// collect components
|
|
18
|
-
const components = [];
|
|
19
|
-
for (const member of members) {
|
|
20
|
-
for (let c = 0; c < member.components; c++) {
|
|
21
|
-
let name = member.name;
|
|
22
|
-
if (member.components > 1) {
|
|
23
|
-
name += c;
|
|
24
|
-
}
|
|
25
|
-
components.push({name, member, component: c});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// exceptions for which we generate accessors on the array rather than a separate struct for performance
|
|
30
|
-
const useComponentGetters = StructArrayClass === 'GlyphOffsetArray' || StructArrayClass === 'SymbolLineVertexArray';
|
|
31
|
-
|
|
32
|
-
if (includeStructAccessors && !useComponentGetters) {
|
|
33
|
-
-%>
|
|
34
|
-
class <%=StructTypeClass%> extends Struct {
|
|
35
|
-
_structArray: <%=StructArrayClass%>;
|
|
36
|
-
<%
|
|
37
|
-
// property declarations
|
|
38
|
-
for (const {name} of components) {-%>
|
|
39
|
-
<%=name%>: number;
|
|
40
|
-
<% }
|
|
41
|
-
if (hasAnchorPoint) { -%>
|
|
42
|
-
anchorPoint: Point;
|
|
43
|
-
<% } -%>
|
|
44
|
-
<%
|
|
45
|
-
for (const {name, member, component} of components) {
|
|
46
|
-
const elementOffset = `this._pos${member.size.toFixed(0)}`;
|
|
47
|
-
const componentOffset = (member.offset / member.size + component).toFixed(0);
|
|
48
|
-
const index = `${elementOffset} + ${componentOffset}`;
|
|
49
|
-
const componentAccess = `this._structArray.${member.view}[${index}]`;
|
|
50
|
-
-%>
|
|
51
|
-
get <%=name%>() { return <%=componentAccess%>; }
|
|
52
|
-
<%
|
|
53
|
-
// generate setters for properties that are updated during runtime symbol placement; others are read-only
|
|
54
|
-
if (name === 'crossTileID' || name === 'placedOrientation' || name === 'hidden') {
|
|
55
|
-
-%>
|
|
56
|
-
set <%=name%>(x: number) { <%=componentAccess%> = x; }
|
|
57
|
-
<%
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Special case used for the CollisionBoxArray type
|
|
61
|
-
if (hasAnchorPoint) {
|
|
62
|
-
-%>
|
|
63
|
-
get anchorPoint() { return new Point(this.anchorPointX, this.anchorPointY); }
|
|
64
|
-
<%
|
|
65
|
-
}
|
|
66
|
-
-%>
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
<%=StructTypeClass%>.prototype.size = <%=size%>;
|
|
70
|
-
|
|
71
|
-
export type <%=StructTypeClass.replace('Struct', '')%> = <%=StructTypeClass%>;
|
|
72
|
-
|
|
73
|
-
<%
|
|
74
|
-
} // end 'if (includeStructAccessors)'
|
|
75
|
-
-%>
|
|
76
|
-
/**
|
|
77
|
-
* @private
|
|
78
|
-
*/
|
|
79
|
-
export class <%=StructArrayClass%> extends <%=StructArrayLayoutClass%> {
|
|
80
|
-
<%
|
|
81
|
-
if (useComponentGetters) {
|
|
82
|
-
for (const member of members) {
|
|
83
|
-
for (let c = 0; c < member.components; c++) {
|
|
84
|
-
if (!includeStructAccessors) continue;
|
|
85
|
-
let name = `get${member.name}`;
|
|
86
|
-
if (member.components > 1) {
|
|
87
|
-
name += c;
|
|
88
|
-
}
|
|
89
|
-
const componentOffset = (member.offset / member.size + c).toFixed(0);
|
|
90
|
-
const componentStride = size / member.size;
|
|
91
|
-
-%>
|
|
92
|
-
<%=name%>(index: number) { return this.<%=member.view%>[index * <%=componentStride%> + <%=componentOffset%>]; }
|
|
93
|
-
<%
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
} else if (includeStructAccessors) { // get(i)
|
|
97
|
-
-%>
|
|
98
|
-
/**
|
|
99
|
-
* Return the <%=StructTypeClass%> at the given location in the array.
|
|
100
|
-
* @param {number} index The index of the element.
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
get(index: number): <%=StructTypeClass%> {
|
|
104
|
-
assert(!this.isTransferred);
|
|
105
|
-
return new <%=StructTypeClass%>(this, index);
|
|
106
|
-
}
|
|
107
|
-
<%
|
|
108
|
-
}
|
|
109
|
-
-%>
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
register('<%=StructArrayClass%>', <%=StructArrayClass%>);
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
const {
|
|
3
|
-
className,
|
|
4
|
-
members,
|
|
5
|
-
size,
|
|
6
|
-
usedTypes
|
|
7
|
-
} = locals
|
|
8
|
-
|
|
9
|
-
const StructArrayLayoutClass = className;
|
|
10
|
-
-%>
|
|
11
|
-
/**
|
|
12
|
-
* Implementation of the StructArray layout:
|
|
13
|
-
<%
|
|
14
|
-
for (const member of members) {
|
|
15
|
-
-%>
|
|
16
|
-
* [<%=member.offset%>]: <%=member.type%>[<%=member.components%>]
|
|
17
|
-
<%
|
|
18
|
-
}
|
|
19
|
-
-%>
|
|
20
|
-
*
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
class <%=StructArrayLayoutClass%> extends StructArray {
|
|
24
|
-
<%
|
|
25
|
-
for (const type of usedTypes) {
|
|
26
|
-
-%>
|
|
27
|
-
<%=type.toLowerCase()%>: <%=type%>Array;
|
|
28
|
-
<%
|
|
29
|
-
}
|
|
30
|
-
-%>
|
|
31
|
-
|
|
32
|
-
_refreshViews() {
|
|
33
|
-
<%
|
|
34
|
-
for (const type of usedTypes) {
|
|
35
|
-
-%>
|
|
36
|
-
this.<%=type.toLowerCase()%> = new <%=type%>Array(this.arrayBuffer);
|
|
37
|
-
<%
|
|
38
|
-
}
|
|
39
|
-
-%>
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
<%
|
|
43
|
-
// prep for emplaceBack: collect type sizes and count the number of arguments
|
|
44
|
-
// we'll need
|
|
45
|
-
const bytesPerElement = size;
|
|
46
|
-
const usedTypeSizes = [];
|
|
47
|
-
const argNames = [];
|
|
48
|
-
const argNamesTyped = [];
|
|
49
|
-
for (const member of members) {
|
|
50
|
-
if (usedTypeSizes.indexOf(member.size) < 0) {
|
|
51
|
-
usedTypeSizes.push(member.size);
|
|
52
|
-
}
|
|
53
|
-
for (let c = 0; c < member.components; c++) {
|
|
54
|
-
// arguments v0, v1, v2, ... are, in order, the components of
|
|
55
|
-
// member 0, then the components of member 1, etc.
|
|
56
|
-
const name = `v${argNames.length}`;
|
|
57
|
-
argNames.push(name);
|
|
58
|
-
argNamesTyped.push(`${name}: number`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
-%>
|
|
62
|
-
emplaceBack(<%=argNamesTyped.join(', ')%>) {
|
|
63
|
-
const i = this.length;
|
|
64
|
-
this.resize(i + 1);
|
|
65
|
-
return this.emplace(i, <%=argNames.join(', ')%>);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
emplace(i: number, <%=argNamesTyped.join(', ')%>) {
|
|
69
|
-
<%
|
|
70
|
-
{
|
|
71
|
-
for (const size of usedTypeSizes) {
|
|
72
|
-
-%>
|
|
73
|
-
const o<%=size.toFixed(0)%> = i * <%=(bytesPerElement / size).toFixed(0)%>;
|
|
74
|
-
<%
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let argIndex = 0;
|
|
78
|
-
for (const member of members) {
|
|
79
|
-
for (let c = 0; c < member.components; c++) {
|
|
80
|
-
// The index for `member` component `c` into the appropriate type array is:
|
|
81
|
-
// this.{TYPE}[o{SIZE} + MEMBER_OFFSET + {c}] = v{X}
|
|
82
|
-
// where MEMBER_OFFSET = ROUND(member.offset / size) is the per-element
|
|
83
|
-
// offset of this member into the array
|
|
84
|
-
const index = `o${member.size.toFixed(0)} + ${(member.offset / member.size + c).toFixed(0)}`;
|
|
85
|
-
-%>
|
|
86
|
-
this.<%=member.view%>[<%=index%>] = v<%=argIndex++%>;
|
|
87
|
-
<%
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
-%>
|
|
92
|
-
return i;
|
|
93
|
-
}
|
|
94
|
-
-%>
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
<%=StructArrayLayoutClass%>.prototype.bytesPerElement = <%= size %>;
|
|
98
|
-
register('<%=StructArrayLayoutClass%>', <%=StructArrayLayoutClass%>);
|
package/src/util/task_queue.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// @flow strict
|
|
2
|
-
import assert from 'assert';
|
|
3
|
-
|
|
4
|
-
export type TaskID = number; // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61
|
|
5
|
-
type Task = {
|
|
6
|
-
callback: () => void;
|
|
7
|
-
id: TaskID;
|
|
8
|
-
cancelled: boolean;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
class TaskQueue {
|
|
12
|
-
_queue: Array<Task>;
|
|
13
|
-
_id: TaskID;
|
|
14
|
-
_cleared: boolean;
|
|
15
|
-
_currentlyRunning: Array<Task> | false;
|
|
16
|
-
|
|
17
|
-
constructor() {
|
|
18
|
-
this._queue = [];
|
|
19
|
-
this._id = 0;
|
|
20
|
-
this._cleared = false;
|
|
21
|
-
this._currentlyRunning = false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
add(callback: () => void): TaskID {
|
|
25
|
-
const id = ++this._id;
|
|
26
|
-
const queue = this._queue;
|
|
27
|
-
queue.push({callback, id, cancelled: false});
|
|
28
|
-
return id;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
remove(id: TaskID) {
|
|
32
|
-
const running = this._currentlyRunning;
|
|
33
|
-
const queue = running ? this._queue.concat(running) : this._queue;
|
|
34
|
-
for (const task of queue) {
|
|
35
|
-
if (task.id === id) {
|
|
36
|
-
task.cancelled = true;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
run() {
|
|
43
|
-
assert(!this._currentlyRunning);
|
|
44
|
-
const queue = this._currentlyRunning = this._queue;
|
|
45
|
-
|
|
46
|
-
// Tasks queued by callbacks in the current queue should be executed
|
|
47
|
-
// on the next run, not the current run.
|
|
48
|
-
this._queue = [];
|
|
49
|
-
|
|
50
|
-
for (const task of queue) {
|
|
51
|
-
if (task.cancelled) continue;
|
|
52
|
-
task.callback();
|
|
53
|
-
if (this._cleared) break;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this._cleared = false;
|
|
57
|
-
this._currentlyRunning = false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
clear() {
|
|
61
|
-
if (this._currentlyRunning) {
|
|
62
|
-
this._cleared = true;
|
|
63
|
-
}
|
|
64
|
-
this._queue = [];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default TaskQueue;
|
package/src/util/throttle.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @flow strict
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Throttle the given function to run at most every `period` milliseconds.
|
|
5
|
-
Throttle the given function to run at most every period milliseconds.
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
export default function throttle(fn: () => void, time: number): () => ?TimeoutID {
|
|
9
|
-
let pending = false;
|
|
10
|
-
let timerId: ?TimeoutID = null;
|
|
11
|
-
|
|
12
|
-
const later = () => {
|
|
13
|
-
timerId = null;
|
|
14
|
-
if (pending) {
|
|
15
|
-
fn();
|
|
16
|
-
timerId = setTimeout(later, time);
|
|
17
|
-
pending = false;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
return () => {
|
|
22
|
-
pending = true;
|
|
23
|
-
if (!timerId) {
|
|
24
|
-
later();
|
|
25
|
-
}
|
|
26
|
-
return timerId;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Invokes the wrapped function in a non-blocking way when trigger() is called. Invocation requests
|
|
5
|
-
* are ignored until the function was actually invoked.
|
|
6
|
-
*
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
|
-
class ThrottledInvoker {
|
|
10
|
-
_channel: MessageChannel;
|
|
11
|
-
_triggered: boolean;
|
|
12
|
-
_callback: Function
|
|
13
|
-
|
|
14
|
-
constructor(callback: Function) {
|
|
15
|
-
this._callback = callback;
|
|
16
|
-
this._triggered = false;
|
|
17
|
-
if (typeof MessageChannel !== 'undefined') {
|
|
18
|
-
this._channel = new MessageChannel();
|
|
19
|
-
this._channel.port2.onmessage = () => {
|
|
20
|
-
this._triggered = false;
|
|
21
|
-
this._callback();
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
trigger() {
|
|
27
|
-
if (!this._triggered) {
|
|
28
|
-
this._triggered = true;
|
|
29
|
-
if (this._channel) {
|
|
30
|
-
this._channel.port1.postMessage(true);
|
|
31
|
-
} else {
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
this._triggered = false;
|
|
34
|
-
this._callback();
|
|
35
|
-
}, 0);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
remove() {
|
|
41
|
-
delete this._channel;
|
|
42
|
-
this._callback = () => {};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default ThrottledInvoker;
|
package/src/util/tile_cover.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import MercatorCoordinate from '../geo/mercator_coordinate';
|
|
4
|
-
import Point from '@mapbox/point-geometry';
|
|
5
|
-
|
|
6
|
-
import { OverscaledTileID } from '../source/tile_id';
|
|
7
|
-
|
|
8
|
-
export default tileCover;
|
|
9
|
-
|
|
10
|
-
function tileCover(z: number, bounds: [MercatorCoordinate, MercatorCoordinate, MercatorCoordinate, MercatorCoordinate],
|
|
11
|
-
actualZ: number, renderWorldCopies: boolean | void): Array<OverscaledTileID> {
|
|
12
|
-
if (renderWorldCopies === undefined) {
|
|
13
|
-
renderWorldCopies = true;
|
|
14
|
-
}
|
|
15
|
-
const tiles = 1 << z;
|
|
16
|
-
const t = {};
|
|
17
|
-
|
|
18
|
-
function scanLine(x0, x1, y) {
|
|
19
|
-
let x, w, wx, coord;
|
|
20
|
-
if (y >= 0 && y <= tiles) {
|
|
21
|
-
for (x = x0; x < x1; x++) {
|
|
22
|
-
w = Math.floor(x / tiles);
|
|
23
|
-
wx = (x % tiles + tiles) % tiles;
|
|
24
|
-
if (w === 0 || renderWorldCopies === true) {
|
|
25
|
-
coord = new OverscaledTileID(actualZ, w, z, wx, y);
|
|
26
|
-
t[coord.key] = coord;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const zoomedBounds = bounds.map((coord) => new Point(coord.x, coord.y)._mult(tiles));
|
|
33
|
-
|
|
34
|
-
// Divide the screen up in two triangles and scan each of them:
|
|
35
|
-
// +---/
|
|
36
|
-
// | / |
|
|
37
|
-
// /---+
|
|
38
|
-
scanTriangle(zoomedBounds[0], zoomedBounds[1], zoomedBounds[2], 0, tiles, scanLine);
|
|
39
|
-
scanTriangle(zoomedBounds[2], zoomedBounds[3], zoomedBounds[0], 0, tiles, scanLine);
|
|
40
|
-
|
|
41
|
-
return Object.keys(t).map((id) => {
|
|
42
|
-
return t[id];
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Taken from polymaps src/Layer.js
|
|
48
|
-
// https://github.com/simplegeo/polymaps/blob/master/src/Layer.js#L333-L383
|
|
49
|
-
|
|
50
|
-
function edge(a: Point, b: Point) {
|
|
51
|
-
if (a.y > b.y) { const t = a; a = b; b = t; }
|
|
52
|
-
return {
|
|
53
|
-
x0: a.x,
|
|
54
|
-
y0: a.y,
|
|
55
|
-
x1: b.x,
|
|
56
|
-
y1: b.y,
|
|
57
|
-
dx: b.x - a.x,
|
|
58
|
-
dy: b.y - a.y
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function scanSpans(e0, e1, ymin, ymax, scanLine) {
|
|
63
|
-
const y0 = Math.max(ymin, Math.floor(e1.y0));
|
|
64
|
-
const y1 = Math.min(ymax, Math.ceil(e1.y1));
|
|
65
|
-
|
|
66
|
-
// sort edges by x-coordinate
|
|
67
|
-
if ((e0.x0 === e1.x0 && e0.y0 === e1.y0) ?
|
|
68
|
-
(e0.x0 + e1.dy / e0.dy * e0.dx < e1.x1) :
|
|
69
|
-
(e0.x1 - e1.dy / e0.dy * e0.dx < e1.x0)) {
|
|
70
|
-
const t = e0; e0 = e1; e1 = t;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// scan lines!
|
|
74
|
-
const m0 = e0.dx / e0.dy;
|
|
75
|
-
const m1 = e1.dx / e1.dy;
|
|
76
|
-
const d0 = e0.dx > 0; // use y + 1 to compute x0
|
|
77
|
-
const d1 = e1.dx < 0; // use y + 1 to compute x1
|
|
78
|
-
for (let y = y0; y < y1; y++) {
|
|
79
|
-
const x0 = m0 * Math.max(0, Math.min(e0.dy, y + d0 - e0.y0)) + e0.x0;
|
|
80
|
-
const x1 = m1 * Math.max(0, Math.min(e1.dy, y + d1 - e1.y0)) + e1.x0;
|
|
81
|
-
scanLine(Math.floor(x1), Math.ceil(x0), y);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function scanTriangle(a: Point, b: Point, c: Point, ymin, ymax, scanLine) {
|
|
86
|
-
let ab = edge(a, b),
|
|
87
|
-
bc = edge(b, c),
|
|
88
|
-
ca = edge(c, a);
|
|
89
|
-
|
|
90
|
-
let t;
|
|
91
|
-
|
|
92
|
-
// sort edges by y-length
|
|
93
|
-
if (ab.dy > bc.dy) { t = ab; ab = bc; bc = t; }
|
|
94
|
-
if (ab.dy > ca.dy) { t = ab; ab = ca; ca = t; }
|
|
95
|
-
if (bc.dy > ca.dy) { t = bc; bc = ca; ca = t; }
|
|
96
|
-
|
|
97
|
-
// scan span! scan span!
|
|
98
|
-
if (ab.dy) scanSpans(ca, ab, ymin, ymax, scanLine);
|
|
99
|
-
if (bc.dy) scanSpans(ca, bc, ymin, ymax, scanLine);
|
|
100
|
-
}
|
|
101
|
-
|