@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
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {parseCSSColor} from 'csscolorparser';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* An RGBA color value. Create instances from color strings using the static
|
|
7
|
-
* method `Color.parse`. The constructor accepts RGB channel values in the range
|
|
8
|
-
* `[0, 1]`, premultiplied by A.
|
|
9
|
-
*
|
|
10
|
-
* @param {number} r The red channel.
|
|
11
|
-
* @param {number} g The green channel.
|
|
12
|
-
* @param {number} b The blue channel.
|
|
13
|
-
* @param {number} a The alpha channel.
|
|
14
|
-
* @private
|
|
15
|
-
*/
|
|
16
|
-
class Color {
|
|
17
|
-
r: number;
|
|
18
|
-
g: number;
|
|
19
|
-
b: number;
|
|
20
|
-
a: number;
|
|
21
|
-
|
|
22
|
-
constructor(r: number, g: number, b: number, a: number = 1) {
|
|
23
|
-
this.r = r;
|
|
24
|
-
this.g = g;
|
|
25
|
-
this.b = b;
|
|
26
|
-
this.a = a;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static black: Color;
|
|
30
|
-
static white: Color;
|
|
31
|
-
static transparent: Color;
|
|
32
|
-
static red: Color;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Parses valid CSS color strings and returns a `Color` instance.
|
|
36
|
-
* @returns A `Color` instance, or `undefined` if the input is not a valid color string.
|
|
37
|
-
*/
|
|
38
|
-
static parse(input?: string | Color | null): Color | void {
|
|
39
|
-
if (!input) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (input instanceof Color) {
|
|
44
|
-
return input;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (typeof input !== 'string') {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const rgba = parseCSSColor(input);
|
|
52
|
-
if (!rgba) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return new Color(
|
|
57
|
-
rgba[0] / 255 * rgba[3],
|
|
58
|
-
rgba[1] / 255 * rgba[3],
|
|
59
|
-
rgba[2] / 255 * rgba[3],
|
|
60
|
-
rgba[3]
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Returns an RGBA string representing the color value.
|
|
66
|
-
*
|
|
67
|
-
* @returns An RGBA string.
|
|
68
|
-
* @example
|
|
69
|
-
* var purple = new Color.parse('purple');
|
|
70
|
-
* purple.toString; // = "rgba(128,0,128,1)"
|
|
71
|
-
* var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');
|
|
72
|
-
* translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
|
|
73
|
-
*/
|
|
74
|
-
toString(): string {
|
|
75
|
-
const [r, g, b, a] = this.toArray();
|
|
76
|
-
return `rgba(${Math.round(r)},${Math.round(g)},${Math.round(b)},${a})`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
toArray(): [number, number, number, number] {
|
|
80
|
-
const {r, g, b, a} = this;
|
|
81
|
-
return a === 0 ? [0, 0, 0, 0] : [
|
|
82
|
-
r * 255 / a,
|
|
83
|
-
g * 255 / a,
|
|
84
|
-
b * 255 / a,
|
|
85
|
-
a
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
Color.black = new Color(0, 0, 0, 1);
|
|
91
|
-
Color.white = new Color(1, 1, 1, 1);
|
|
92
|
-
Color.transparent = new Color(0, 0, 0, 0);
|
|
93
|
-
Color.red = new Color(1, 0, 0, 1);
|
|
94
|
-
|
|
95
|
-
export default Color;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import Color from './color';
|
|
4
|
-
|
|
5
|
-
import {number as interpolateNumber} from './interpolate';
|
|
6
|
-
|
|
7
|
-
type LABColor = {
|
|
8
|
-
l: number,
|
|
9
|
-
a: number,
|
|
10
|
-
b: number,
|
|
11
|
-
alpha: number
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type HCLColor = {
|
|
15
|
-
h: number,
|
|
16
|
-
c: number,
|
|
17
|
-
l: number,
|
|
18
|
-
alpha: number
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Constants
|
|
22
|
-
const Xn = 0.950470, // D65 standard referent
|
|
23
|
-
Yn = 1,
|
|
24
|
-
Zn = 1.088830,
|
|
25
|
-
t0 = 4 / 29,
|
|
26
|
-
t1 = 6 / 29,
|
|
27
|
-
t2 = 3 * t1 * t1,
|
|
28
|
-
t3 = t1 * t1 * t1,
|
|
29
|
-
deg2rad = Math.PI / 180,
|
|
30
|
-
rad2deg = 180 / Math.PI;
|
|
31
|
-
|
|
32
|
-
// Utilities
|
|
33
|
-
function xyz2lab(t: number) {
|
|
34
|
-
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function lab2xyz(t: number) {
|
|
38
|
-
return t > t1 ? t * t * t : t2 * (t - t0);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function xyz2rgb(x: number) {
|
|
42
|
-
return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function rgb2xyz(x: number) {
|
|
46
|
-
x /= 255;
|
|
47
|
-
return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// LAB
|
|
51
|
-
function rgbToLab(rgbColor: Color): LABColor {
|
|
52
|
-
const b = rgb2xyz(rgbColor.r),
|
|
53
|
-
a = rgb2xyz(rgbColor.g),
|
|
54
|
-
l = rgb2xyz(rgbColor.b),
|
|
55
|
-
x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn),
|
|
56
|
-
y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn),
|
|
57
|
-
z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
l: 116 * y - 16,
|
|
61
|
-
a: 500 * (x - y),
|
|
62
|
-
b: 200 * (y - z),
|
|
63
|
-
alpha: rgbColor.a
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function labToRgb(labColor: LABColor): Color {
|
|
68
|
-
let y = (labColor.l + 16) / 116,
|
|
69
|
-
x = isNaN(labColor.a) ? y : y + labColor.a / 500,
|
|
70
|
-
z = isNaN(labColor.b) ? y : y - labColor.b / 200;
|
|
71
|
-
y = Yn * lab2xyz(y);
|
|
72
|
-
x = Xn * lab2xyz(x);
|
|
73
|
-
z = Zn * lab2xyz(z);
|
|
74
|
-
return new Color(
|
|
75
|
-
xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
|
|
76
|
-
xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z),
|
|
77
|
-
xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z),
|
|
78
|
-
labColor.alpha
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function interpolateLab(from: LABColor, to: LABColor, t: number) {
|
|
83
|
-
return {
|
|
84
|
-
l: interpolateNumber(from.l, to.l, t),
|
|
85
|
-
a: interpolateNumber(from.a, to.a, t),
|
|
86
|
-
b: interpolateNumber(from.b, to.b, t),
|
|
87
|
-
alpha: interpolateNumber(from.alpha, to.alpha, t)
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// HCL
|
|
92
|
-
function rgbToHcl(rgbColor: Color): HCLColor {
|
|
93
|
-
const {l, a, b} = rgbToLab(rgbColor);
|
|
94
|
-
const h = Math.atan2(b, a) * rad2deg;
|
|
95
|
-
return {
|
|
96
|
-
h: h < 0 ? h + 360 : h,
|
|
97
|
-
c: Math.sqrt(a * a + b * b),
|
|
98
|
-
l,
|
|
99
|
-
alpha: rgbColor.a
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function hclToRgb(hclColor: HCLColor): Color {
|
|
104
|
-
const h = hclColor.h * deg2rad,
|
|
105
|
-
c = hclColor.c,
|
|
106
|
-
l = hclColor.l;
|
|
107
|
-
return labToRgb({
|
|
108
|
-
l,
|
|
109
|
-
a: Math.cos(h) * c,
|
|
110
|
-
b: Math.sin(h) * c,
|
|
111
|
-
alpha: hclColor.alpha
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function interpolateHue(a: number, b: number, t: number) {
|
|
116
|
-
const d = b - a;
|
|
117
|
-
return a + t * (d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function interpolateHcl(from: HCLColor, to: HCLColor, t: number) {
|
|
121
|
-
return {
|
|
122
|
-
h: interpolateHue(from.h, to.h, t),
|
|
123
|
-
c: interpolateNumber(from.c, to.c, t),
|
|
124
|
-
l: interpolateNumber(from.l, to.l, t),
|
|
125
|
-
alpha: interpolateNumber(from.alpha, to.alpha, t)
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export const lab = {
|
|
130
|
-
forward: rgbToLab,
|
|
131
|
-
reverse: labToRgb,
|
|
132
|
-
interpolate: interpolateLab
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export const hcl = {
|
|
136
|
-
forward: rgbToHcl,
|
|
137
|
-
reverse: hclToRgb,
|
|
138
|
-
interpolate: interpolateHcl
|
|
139
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Deeply compares two object literals.
|
|
5
|
-
*
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
|
-
function deepEqual(a: ?mixed, b: ?mixed): boolean {
|
|
9
|
-
if (Array.isArray(a)) {
|
|
10
|
-
if (!Array.isArray(b) || a.length !== b.length) return false;
|
|
11
|
-
for (let i = 0; i < a.length; i++) {
|
|
12
|
-
if (!deepEqual(a[i], b[i])) return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
if (typeof a === 'object' && a !== null && b !== null) {
|
|
17
|
-
if (!(typeof b === 'object')) return false;
|
|
18
|
-
const keys = Object.keys(a);
|
|
19
|
-
if (keys.length !== Object.keys(b).length) return false;
|
|
20
|
-
for (const key in a) {
|
|
21
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return a === b;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default deepEqual;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
export default function getType(val: mixed): string {
|
|
4
|
-
if (val instanceof Number) {
|
|
5
|
-
return 'number';
|
|
6
|
-
} else if (val instanceof String) {
|
|
7
|
-
return 'string';
|
|
8
|
-
} else if (val instanceof Boolean) {
|
|
9
|
-
return 'boolean';
|
|
10
|
-
} else if (Array.isArray(val)) {
|
|
11
|
-
return 'array';
|
|
12
|
-
} else if (val === null) {
|
|
13
|
-
return 'null';
|
|
14
|
-
} else {
|
|
15
|
-
return typeof val;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import Color from './color';
|
|
4
|
-
|
|
5
|
-
export function number(a: number, b: number, t: number) {
|
|
6
|
-
return (a * (1 - t)) + (b * t);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function color(from: Color, to: Color, t: number) {
|
|
10
|
-
return new Color(
|
|
11
|
-
number(from.r, to.r, t),
|
|
12
|
-
number(from.g, to.g, t),
|
|
13
|
-
number(from.b, to.b, t),
|
|
14
|
-
number(from.a, to.a, t)
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function array(from: Array<number>, to: Array<number>, t: number): Array<number> {
|
|
19
|
-
return from.map((d, i) => {
|
|
20
|
-
return number(d, to[i], t);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import type {StylePropertySpecification} from '../style-spec';
|
|
4
|
-
|
|
5
|
-
export function supportsPropertyExpression(spec: StylePropertySpecification): boolean {
|
|
6
|
-
return spec['property-type'] === 'data-driven' || spec['property-type'] === 'cross-faded-data-driven';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function supportsZoomExpression(spec: StylePropertySpecification): boolean {
|
|
10
|
-
return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function supportsInterpolation(spec: StylePropertySpecification): boolean {
|
|
14
|
-
return !!spec.expression && spec.expression.interpolated;
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A type used for returning and propagating errors. The first element of the union
|
|
5
|
-
* represents success and contains a value, and the second represents an error and
|
|
6
|
-
* contains an error value.
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
|
-
export type Result<T, E> =
|
|
10
|
-
| {| result: 'success', value: T |}
|
|
11
|
-
| {| result: 'error', value: E |};
|
|
12
|
-
|
|
13
|
-
export function success<T, E>(value: T): Result<T, E> {
|
|
14
|
-
return {result: 'success', value};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function error<T, E>(value: E): Result<T, E> {
|
|
18
|
-
return {result: 'error', value};
|
|
19
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
// Turn jsonlint-lines-primitives objects into primitive objects
|
|
4
|
-
export function unbundle(value: mixed) {
|
|
5
|
-
if (value instanceof Number || value instanceof String || value instanceof Boolean) {
|
|
6
|
-
return value.valueOf();
|
|
7
|
-
} else {
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function deepUnbundle(value: mixed): mixed {
|
|
13
|
-
if (Array.isArray(value)) {
|
|
14
|
-
return value.map(deepUnbundle);
|
|
15
|
-
} else if (value instanceof Object && !(value instanceof Number || value instanceof String || value instanceof Boolean)) {
|
|
16
|
-
const unbundledValue: { [key: string]: mixed } = {};
|
|
17
|
-
for (const key in value) {
|
|
18
|
-
unbundledValue[key] = deepUnbundle(value[key]);
|
|
19
|
-
}
|
|
20
|
-
return unbundledValue;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return unbundle(value);
|
|
24
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import validateStyle from '../validate_style.min';
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* Validate a style against the latest specification. This method is optimized
|
|
6
|
-
* to keep its bundle size small by refraining from requiring jslint or old
|
|
7
|
-
* style spec versions.
|
|
8
|
-
* @see validateStyleMin
|
|
9
|
-
* @deprecated This file exists for backwards compatibility and will be dropped in the next minor release.
|
|
10
|
-
*/
|
|
11
|
-
export default validateStyle;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import extend from '../util/extend';
|
|
3
|
-
import {unbundle, deepUnbundle} from '../util/unbundle_jsonlint';
|
|
4
|
-
import {isExpression} from '../expression';
|
|
5
|
-
import {isFunction} from '../function';
|
|
6
|
-
|
|
7
|
-
import validateFunction from './validate_function';
|
|
8
|
-
import validateExpression from './validate_expression';
|
|
9
|
-
import validateObject from './validate_object';
|
|
10
|
-
import validateArray from './validate_array';
|
|
11
|
-
import validateBoolean from './validate_boolean';
|
|
12
|
-
import validateNumber from './validate_number';
|
|
13
|
-
import validateColor from './validate_color';
|
|
14
|
-
import validateConstants from './validate_constants';
|
|
15
|
-
import validateEnum from './validate_enum';
|
|
16
|
-
import validateFilter from './validate_filter';
|
|
17
|
-
import validateLayer from './validate_layer';
|
|
18
|
-
import validateSource from './validate_source';
|
|
19
|
-
import validateLight from './validate_light';
|
|
20
|
-
import validateString from './validate_string';
|
|
21
|
-
import validateFormatted from './validate_formatted';
|
|
22
|
-
import validateImage from './validate_image';
|
|
23
|
-
|
|
24
|
-
const VALIDATORS = {
|
|
25
|
-
'*'() {
|
|
26
|
-
return [];
|
|
27
|
-
},
|
|
28
|
-
'array': validateArray,
|
|
29
|
-
'boolean': validateBoolean,
|
|
30
|
-
'number': validateNumber,
|
|
31
|
-
'color': validateColor,
|
|
32
|
-
'constants': validateConstants,
|
|
33
|
-
'enum': validateEnum,
|
|
34
|
-
'filter': validateFilter,
|
|
35
|
-
'function': validateFunction,
|
|
36
|
-
'layer': validateLayer,
|
|
37
|
-
'object': validateObject,
|
|
38
|
-
'source': validateSource,
|
|
39
|
-
'light': validateLight,
|
|
40
|
-
'string': validateString,
|
|
41
|
-
'formatted': validateFormatted,
|
|
42
|
-
'resolvedImage': validateImage
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Main recursive validation function. Tracks:
|
|
46
|
-
//
|
|
47
|
-
// - key: string representing location of validation in style tree. Used only
|
|
48
|
-
// for more informative error reporting.
|
|
49
|
-
// - value: current value from style being evaluated. May be anything from a
|
|
50
|
-
// high level object that needs to be descended into deeper or a simple
|
|
51
|
-
// scalar value.
|
|
52
|
-
// - valueSpec: current spec being evaluated. Tracks value.
|
|
53
|
-
// - styleSpec: current full spec being evaluated.
|
|
54
|
-
|
|
55
|
-
export default function validate(options) {
|
|
56
|
-
const value = options.value;
|
|
57
|
-
const valueSpec = options.valueSpec;
|
|
58
|
-
const styleSpec = options.styleSpec;
|
|
59
|
-
|
|
60
|
-
if (valueSpec.expression && isFunction(unbundle(value))) {
|
|
61
|
-
return validateFunction(options);
|
|
62
|
-
|
|
63
|
-
} else if (valueSpec.expression && isExpression(deepUnbundle(value))) {
|
|
64
|
-
return validateExpression(options);
|
|
65
|
-
|
|
66
|
-
} else if (valueSpec.type && VALIDATORS[valueSpec.type]) {
|
|
67
|
-
return VALIDATORS[valueSpec.type](options);
|
|
68
|
-
|
|
69
|
-
} else {
|
|
70
|
-
const valid = validateObject(extend({}, options, {
|
|
71
|
-
valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec
|
|
72
|
-
}));
|
|
73
|
-
return valid;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import getType from '../util/get_type';
|
|
3
|
-
import validate from './validate';
|
|
4
|
-
import ValidationError from '../error/validation_error';
|
|
5
|
-
|
|
6
|
-
export default function validateArray(options) {
|
|
7
|
-
const array = options.value;
|
|
8
|
-
const arraySpec = options.valueSpec;
|
|
9
|
-
const style = options.style;
|
|
10
|
-
const styleSpec = options.styleSpec;
|
|
11
|
-
const key = options.key;
|
|
12
|
-
const validateArrayElement = options.arrayElementValidator || validate;
|
|
13
|
-
|
|
14
|
-
if (getType(array) !== 'array') {
|
|
15
|
-
return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (arraySpec.length && array.length !== arraySpec.length) {
|
|
19
|
-
return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (arraySpec['min-length'] && array.length < arraySpec['min-length']) {
|
|
23
|
-
return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let arrayElementSpec = {
|
|
27
|
-
"type": arraySpec.value,
|
|
28
|
-
"values": arraySpec.values
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
if (styleSpec.$version < 7) {
|
|
32
|
-
arrayElementSpec.function = arraySpec.function;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (getType(arraySpec.value) === 'object') {
|
|
36
|
-
arrayElementSpec = arraySpec.value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let errors = [];
|
|
40
|
-
for (let i = 0; i < array.length; i++) {
|
|
41
|
-
errors = errors.concat(validateArrayElement({
|
|
42
|
-
array,
|
|
43
|
-
arrayIndex: i,
|
|
44
|
-
value: array[i],
|
|
45
|
-
valueSpec: arrayElementSpec,
|
|
46
|
-
style,
|
|
47
|
-
styleSpec,
|
|
48
|
-
key: `${key}[${i}]`
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
return errors;
|
|
52
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import getType from '../util/get_type';
|
|
3
|
-
import ValidationError from '../error/validation_error';
|
|
4
|
-
|
|
5
|
-
export default function validateBoolean(options) {
|
|
6
|
-
const value = options.value;
|
|
7
|
-
const key = options.key;
|
|
8
|
-
const type = getType(value);
|
|
9
|
-
|
|
10
|
-
if (type !== 'boolean') {
|
|
11
|
-
return [new ValidationError(key, value, `boolean expected, ${type} found`)];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import ValidationError from '../error/validation_error';
|
|
3
|
-
import getType from '../util/get_type';
|
|
4
|
-
import {parseCSSColor} from 'csscolorparser';
|
|
5
|
-
|
|
6
|
-
export default function validateColor(options) {
|
|
7
|
-
const key = options.key;
|
|
8
|
-
const value = options.value;
|
|
9
|
-
const type = getType(value);
|
|
10
|
-
|
|
11
|
-
if (type !== 'string') {
|
|
12
|
-
return [new ValidationError(key, value, `color expected, ${type} found`)];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (parseCSSColor(value) === null) {
|
|
16
|
-
return [new ValidationError(key, value, `color expected, "${value}" found`)];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import ValidationError from '../error/validation_error';
|
|
3
|
-
|
|
4
|
-
export default function validateConstants(options) {
|
|
5
|
-
const key = options.key;
|
|
6
|
-
const constants = options.value;
|
|
7
|
-
|
|
8
|
-
if (constants) {
|
|
9
|
-
return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];
|
|
10
|
-
} else {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import ValidationError from '../error/validation_error';
|
|
3
|
-
import {unbundle} from '../util/unbundle_jsonlint';
|
|
4
|
-
|
|
5
|
-
export default function validateEnum(options) {
|
|
6
|
-
const key = options.key;
|
|
7
|
-
const value = options.value;
|
|
8
|
-
const valueSpec = options.valueSpec;
|
|
9
|
-
const errors = [];
|
|
10
|
-
|
|
11
|
-
if (Array.isArray(valueSpec.values)) { // <=v7
|
|
12
|
-
if (valueSpec.values.indexOf(unbundle(value)) === -1) {
|
|
13
|
-
errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));
|
|
14
|
-
}
|
|
15
|
-
} else { // >=v8
|
|
16
|
-
if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {
|
|
17
|
-
errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return errors;
|
|
21
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import ValidationError from '../error/validation_error';
|
|
4
|
-
|
|
5
|
-
import {createExpression, createPropertyExpression} from '../expression';
|
|
6
|
-
import {deepUnbundle} from '../util/unbundle_jsonlint';
|
|
7
|
-
import {isStateConstant, isGlobalPropertyConstant, isFeatureConstant} from '../expression/is_constant';
|
|
8
|
-
|
|
9
|
-
export default function validateExpression(options: any): Array<ValidationError> {
|
|
10
|
-
const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);
|
|
11
|
-
if (expression.result === 'error') {
|
|
12
|
-
return expression.value.map((error) => {
|
|
13
|
-
return new ValidationError(`${options.key}${error.key}`, options.value, error.message);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const expressionObj = (expression.value: any).expression || (expression.value: any)._styleExpression.expression;
|
|
18
|
-
|
|
19
|
-
if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&
|
|
20
|
-
!expressionObj.outputDefined()) {
|
|
21
|
-
return [new ValidationError(options.key, options.value, `Invalid data expression for "${options.propertyKey}". Output values must be contained as literals within the expression.`)];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (options.expressionContext === 'property' && options.propertyType === 'layout' &&
|
|
25
|
-
(!isStateConstant(expressionObj))) {
|
|
26
|
-
return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with layout properties.')];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {
|
|
30
|
-
return [new ValidationError(options.key, options.value, '"feature-state" data expressions are not supported with filters.')];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {
|
|
34
|
-
if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {
|
|
35
|
-
return [new ValidationError(options.key, options.value, '"zoom" and "feature-state" expressions are not supported with cluster properties.')];
|
|
36
|
-
}
|
|
37
|
-
if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {
|
|
38
|
-
return [new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return [];
|
|
43
|
-
}
|