@mapbox/mapbox-gl-style-spec 14.4.0 → 14.5.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/bin/gl-style-composite.js +0 -5
- package/bin/gl-style-format.js +0 -5
- package/bin/gl-style-migrate.js +0 -5
- package/bin/gl-style-validate.js +0 -5
- package/{composite.js → composite.ts} +1 -1
- package/data/{extent.js → extent.ts} +0 -2
- package/{deref.js → deref.ts} +7 -9
- package/{diff.js → diff.ts} +44 -21
- package/dist/index.cjs +794 -1226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1746 -0
- package/dist/index.es.js +794 -1226
- package/dist/index.es.js.map +1 -1
- package/{empty.js → empty.ts} +1 -2
- package/error/{parsing_error.js → parsing_error.ts} +0 -2
- package/error/{validation_error.js → validation_error.ts} +5 -5
- package/expression/{compound_expression.js → compound_expression.ts} +29 -19
- package/expression/definitions/{assertion.js → assertion.ts} +16 -13
- package/expression/definitions/{at.js → at.ts} +12 -13
- package/expression/definitions/{case.js → case.ts} +12 -11
- package/expression/definitions/{coalesce.js → coalesce.ts} +11 -11
- package/expression/definitions/{coercion.js → coercion.ts} +21 -20
- package/expression/definitions/{collator.js → collator.ts} +11 -11
- package/expression/definitions/{comparison.js → comparison.ts} +30 -24
- package/expression/definitions/{config.js → config.ts} +16 -16
- package/expression/definitions/{distance.js → distance.ts} +60 -52
- package/expression/definitions/{format.js → format.ts} +26 -15
- package/expression/definitions/{image.js → image.ts} +12 -12
- package/expression/definitions/{in.js → in.ts} +22 -13
- package/expression/definitions/{index.js → index.ts} +70 -83
- package/expression/definitions/{index_of.js → index_of.ts} +24 -15
- package/expression/definitions/{interpolate.js → interpolate.ts} +44 -25
- package/expression/definitions/{length.js → length.ts} +11 -10
- package/expression/definitions/{let.js → let.ts} +10 -7
- package/expression/definitions/{literal.js → literal.ts} +11 -12
- package/expression/definitions/{match.js → match.ts} +25 -15
- package/expression/definitions/{number_format.js → number_format.ts} +10 -10
- package/expression/definitions/{slice.js → slice.ts} +23 -15
- package/expression/definitions/{step.js → step.ts} +14 -12
- package/expression/definitions/{var.js → var.ts} +5 -7
- package/expression/definitions/{within.js → within.ts} +41 -29
- package/expression/{evaluation_context.js → evaluation_context.ts} +26 -23
- package/expression/expression.ts +29 -0
- package/expression/{index.js → index.ts} +208 -110
- package/expression/{is_constant.js → is_constant.ts} +5 -7
- package/expression/{parsing_context.js → parsing_context.ts} +47 -34
- package/expression/{parsing_error.js → parsing_error.ts} +0 -2
- package/expression/{runtime_error.js → runtime_error.ts} +0 -2
- package/expression/{scope.js → scope.ts} +5 -5
- package/expression/{stops.js → stops.ts} +2 -4
- package/expression/types/{collator.js → collator.ts} +1 -3
- package/expression/types/{formatted.js → formatted.ts} +8 -7
- package/expression/types/{resolved_image.js → resolved_image.ts} +5 -7
- package/expression/{types.js → types.ts} +53 -45
- package/expression/{values.js → values.ts} +12 -12
- package/feature_filter/{convert.js → convert.ts} +19 -18
- package/feature_filter/{index.js → index.ts} +39 -21
- package/{format.js → format.ts} +3 -3
- package/function/{convert.js → convert.ts} +44 -44
- package/function/{index.js → index.ts} +12 -12
- package/{group_by_layout.js → group_by_layout.ts} +11 -8
- package/migrate/{expressions.js → expressions.ts} +7 -16
- package/migrate/{v8.js → v8.ts} +2 -2
- package/migrate/{v9.js → v9.ts} +2 -2
- package/{migrate.js → migrate.ts} +3 -3
- package/package.json +19 -18
- package/{read_style.js → read_style.ts} +5 -4
- package/reference/latest.ts +5 -0
- package/reference/v8.json +264 -7
- package/rollup.config.js +6 -24
- package/{style-spec.js → style-spec.ts} +41 -36
- package/test.js +3 -2
- package/types/config_options.ts +13 -0
- package/types/lut.ts +7 -0
- package/types/tile_id.ts +5 -0
- package/{types.js → types.ts} +527 -165
- package/util/{color.js → color.ts} +89 -3
- package/util/{color_spaces.js → color_spaces.ts} +12 -14
- package/util/{deep_equal.js → deep_equal.ts} +1 -3
- package/util/{extend.js → extend.ts} +1 -3
- package/util/{geometry_util.js → geometry_util.ts} +23 -11
- package/util/{get_type.js → get_type.ts} +1 -3
- package/util/{interpolate.js → interpolate.ts} +1 -3
- package/util/{properties.js → properties.ts} +5 -4
- package/util/{random.js → random.ts} +0 -2
- package/util/{ref_properties.js → ref_properties.ts} +0 -1
- package/util/{result.js → result.ts} +7 -5
- package/util/{unbundle_jsonlint.js → unbundle_jsonlint.ts} +5 -5
- package/validate/{validate.js → validate.ts} +33 -35
- package/validate/{validate_array.js → validate_array.ts} +5 -7
- package/validate/{validate_boolean.js → validate_boolean.ts} +3 -5
- package/validate/{validate_color.js → validate_color.ts} +3 -5
- package/validate/{validate_enum.js → validate_enum.ts} +4 -5
- package/validate/{validate_expression.js → validate_expression.ts} +7 -9
- package/validate/{validate_filter.js → validate_filter.ts} +16 -12
- package/validate/{validate_fog.js → validate_fog.ts} +4 -6
- package/validate/validate_formatted.ts +13 -0
- package/validate/{validate_function.js → validate_function.ts} +14 -16
- package/validate/{validate_glyphs_url.js → validate_glyphs_url.ts} +3 -5
- package/validate/validate_image.ts +13 -0
- package/validate/{validate_import.js → validate_import.ts} +6 -8
- package/validate/{validate_layer.js → validate_layer.ts} +17 -15
- package/validate/{validate_layout_property.js → validate_layout_property.ts} +3 -5
- package/validate/{validate_light.js → validate_light.ts} +4 -6
- package/validate/{validate_lights.js → validate_lights.ts} +7 -9
- package/validate/{validate_model.js → validate_model.ts} +4 -6
- package/validate/{validate_number.js → validate_number.ts} +4 -6
- package/validate/{validate_object.js → validate_object.ts} +5 -8
- package/validate/{validate_paint_property.js → validate_paint_property.ts} +3 -5
- package/validate/{validate_projection.js → validate_projection.ts} +4 -6
- package/validate/{validate_property.js → validate_property.ts} +15 -15
- package/validate/{validate_source.js → validate_source.ts} +16 -13
- package/validate/validate_string.ts +16 -0
- package/validate/validate_style.ts +33 -0
- package/validate/{validate_terrain.js → validate_terrain.ts} +5 -7
- package/{validate_mapbox_api_supported.js → validate_mapbox_api_supported.ts} +22 -18
- package/{validate_style.min.js → validate_style.min.ts} +20 -21
- package/{validate_style.js → validate_style.ts} +9 -9
- package/{visit.js → visit.ts} +22 -17
- package/.eslintrc +0 -10
- package/expression/expression.js +0 -28
- package/flow-typed/cheap-ruler.js +0 -25
- package/flow-typed/geojson.js +0 -44
- package/flow-typed/gl-matrix.js +0 -119
- package/flow-typed/gl.js +0 -5
- package/flow-typed/intl.js +0 -58
- package/flow-typed/kdbush.js +0 -9
- package/flow-typed/mapbox-gl-supported.js +0 -16
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -26
- package/flow-typed/point-geometry.js +0 -46
- package/flow-typed/potpack.js +0 -13
- package/flow-typed/tiny-sdf.js +0 -31
- package/flow-typed/tracked_parameters_proxy.js +0 -82
- package/flow-typed/vector-tile.js +0 -49
- package/flow-typed/webgl2.js +0 -41
- package/reference/latest.js +0 -7
- package/validate/validate_formatted.js +0 -15
- package/validate/validate_image.js +0 -15
- package/validate/validate_string.js +0 -18
- package/validate/validate_style.js +0 -29
package/dist/index.cjs
CHANGED
|
@@ -117,6 +117,10 @@
|
|
|
117
117
|
type: "camera",
|
|
118
118
|
doc: "Global setting to control additional camera intrinsics parameters, e.g. projection type (perspective / orthographic)."
|
|
119
119
|
},
|
|
120
|
+
"color-theme": {
|
|
121
|
+
type: "colorTheme",
|
|
122
|
+
doc: "A global modifier for the colors of the style."
|
|
123
|
+
},
|
|
120
124
|
imports: {
|
|
121
125
|
type: "array",
|
|
122
126
|
value: "import",
|
|
@@ -233,6 +237,10 @@
|
|
|
233
237
|
"default": {
|
|
234
238
|
type: "*",
|
|
235
239
|
doc: "Default configuration value for this option.",
|
|
240
|
+
"property-type": "data-constant",
|
|
241
|
+
expression: {
|
|
242
|
+
interpolated: false
|
|
243
|
+
},
|
|
236
244
|
required: true
|
|
237
245
|
},
|
|
238
246
|
type: {
|
|
@@ -816,6 +824,7 @@
|
|
|
816
824
|
}
|
|
817
825
|
};
|
|
818
826
|
var source_raster_array = {
|
|
827
|
+
experimental: true,
|
|
819
828
|
type: {
|
|
820
829
|
required: true,
|
|
821
830
|
type: "enum",
|
|
@@ -1149,6 +1158,7 @@
|
|
|
1149
1158
|
}
|
|
1150
1159
|
},
|
|
1151
1160
|
"raster-particle": {
|
|
1161
|
+
experimental: true,
|
|
1152
1162
|
doc: "Particle animation driven by textures such as wind maps.",
|
|
1153
1163
|
"sdk-support": {
|
|
1154
1164
|
"basic functionality": {
|
|
@@ -1170,6 +1180,7 @@
|
|
|
1170
1180
|
},
|
|
1171
1181
|
model: {
|
|
1172
1182
|
doc: "A 3D model",
|
|
1183
|
+
experimental: true,
|
|
1173
1184
|
"sdk-support": {
|
|
1174
1185
|
"basic functionality": {
|
|
1175
1186
|
js: "3.0.0",
|
|
@@ -1207,6 +1218,17 @@
|
|
|
1207
1218
|
ios: "11.0.0"
|
|
1208
1219
|
}
|
|
1209
1220
|
}
|
|
1221
|
+
},
|
|
1222
|
+
clip: {
|
|
1223
|
+
doc: "Layer that removes 3D content from map.",
|
|
1224
|
+
"sdk-support": {
|
|
1225
|
+
"basic functionality": {
|
|
1226
|
+
js: "3.5.0",
|
|
1227
|
+
android: "11.5.0",
|
|
1228
|
+
ios: "11.5.0"
|
|
1229
|
+
},
|
|
1230
|
+
experimental: true
|
|
1231
|
+
}
|
|
1210
1232
|
}
|
|
1211
1233
|
},
|
|
1212
1234
|
doc: "Rendering type of this layer.",
|
|
@@ -1261,6 +1283,7 @@
|
|
|
1261
1283
|
}
|
|
1262
1284
|
};
|
|
1263
1285
|
var layout = [
|
|
1286
|
+
"layout_clip",
|
|
1264
1287
|
"layout_fill",
|
|
1265
1288
|
"layout_line",
|
|
1266
1289
|
"layout_circle",
|
|
@@ -1396,6 +1419,35 @@
|
|
|
1396
1419
|
]
|
|
1397
1420
|
}
|
|
1398
1421
|
};
|
|
1422
|
+
var layout_clip = {
|
|
1423
|
+
"clip-layer-types": {
|
|
1424
|
+
type: "array",
|
|
1425
|
+
value: "enum",
|
|
1426
|
+
values: {
|
|
1427
|
+
model: {
|
|
1428
|
+
doc: "If present the clip layer would remove all 3d model layers below it. Currently only instanced models (e.g. trees) are removed."
|
|
1429
|
+
},
|
|
1430
|
+
symbol: {
|
|
1431
|
+
doc: "If present the clip layer would remove all symbol layers below it."
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
"default": [
|
|
1435
|
+
],
|
|
1436
|
+
doc: "Layer types that will also be removed if fallen below this clip layer.",
|
|
1437
|
+
"sdk-support": {
|
|
1438
|
+
"basic functionality": {
|
|
1439
|
+
js: "3.5.0",
|
|
1440
|
+
android: "11.5.0",
|
|
1441
|
+
ios: "11.5.0"
|
|
1442
|
+
}
|
|
1443
|
+
},
|
|
1444
|
+
expression: {
|
|
1445
|
+
interpolated: false
|
|
1446
|
+
},
|
|
1447
|
+
"property-type": "data-constant",
|
|
1448
|
+
experimental: true
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1399
1451
|
var layout_fill = {
|
|
1400
1452
|
"fill-sort-key": {
|
|
1401
1453
|
type: "number",
|
|
@@ -1688,6 +1740,32 @@
|
|
|
1688
1740
|
},
|
|
1689
1741
|
"property-type": "data-driven"
|
|
1690
1742
|
},
|
|
1743
|
+
"line-z-offset": {
|
|
1744
|
+
type: "number",
|
|
1745
|
+
experimental: true,
|
|
1746
|
+
doc: "Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment.",
|
|
1747
|
+
"sdk-support": {
|
|
1748
|
+
"basic functionality": {
|
|
1749
|
+
js: "3.5.0",
|
|
1750
|
+
android: "11.5.0",
|
|
1751
|
+
ios: "11.5.0"
|
|
1752
|
+
},
|
|
1753
|
+
"data-driven styling": {
|
|
1754
|
+
js: "3.5.0",
|
|
1755
|
+
android: "11.5.0",
|
|
1756
|
+
ios: "11.5.0"
|
|
1757
|
+
}
|
|
1758
|
+
},
|
|
1759
|
+
expression: {
|
|
1760
|
+
interpolated: false,
|
|
1761
|
+
parameters: [
|
|
1762
|
+
"zoom",
|
|
1763
|
+
"feature",
|
|
1764
|
+
"line-progress"
|
|
1765
|
+
]
|
|
1766
|
+
},
|
|
1767
|
+
"property-type": "data-driven"
|
|
1768
|
+
},
|
|
1691
1769
|
visibility: {
|
|
1692
1770
|
type: "enum",
|
|
1693
1771
|
values: {
|
|
@@ -4644,6 +4722,17 @@
|
|
|
4644
4722
|
"property-type": "data-constant"
|
|
4645
4723
|
}
|
|
4646
4724
|
};
|
|
4725
|
+
var colorTheme = {
|
|
4726
|
+
data: {
|
|
4727
|
+
type: "string",
|
|
4728
|
+
doc: "Expects a base64 encoded PNG image which represents a cube strip LUT. The height of the image cannot exceed 32 pixels and the width must be equal to the height squared.",
|
|
4729
|
+
transition: false,
|
|
4730
|
+
"property-type": "data-constant",
|
|
4731
|
+
expression: {
|
|
4732
|
+
interpolated: false
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4735
|
+
};
|
|
4647
4736
|
var light = {
|
|
4648
4737
|
anchor: {
|
|
4649
4738
|
type: "enum",
|
|
@@ -4902,6 +4991,7 @@
|
|
|
4902
4991
|
"paint_fill-extrusion",
|
|
4903
4992
|
"paint_symbol",
|
|
4904
4993
|
"paint_raster",
|
|
4994
|
+
"paint_raster-particle",
|
|
4905
4995
|
"paint_hillshade",
|
|
4906
4996
|
"paint_background",
|
|
4907
4997
|
"paint_sky",
|
|
@@ -5484,7 +5574,7 @@
|
|
|
5484
5574
|
"line-trim-offset": {
|
|
5485
5575
|
type: "array",
|
|
5486
5576
|
value: "number",
|
|
5487
|
-
doc: "The line part between [trim-start, trim-end] will be
|
|
5577
|
+
doc: "The line part between [trim-start, trim-end] will be painted using `line-trim-color,` which is transparent by default to produce a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0].",
|
|
5488
5578
|
length: 2,
|
|
5489
5579
|
"default": [
|
|
5490
5580
|
0,
|
|
@@ -5516,6 +5606,81 @@
|
|
|
5516
5606
|
},
|
|
5517
5607
|
"property-type": "constant"
|
|
5518
5608
|
},
|
|
5609
|
+
"line-trim-fade-range": {
|
|
5610
|
+
type: "array",
|
|
5611
|
+
value: "number",
|
|
5612
|
+
doc: "The fade range for the trim-start and trim-end points is defined by the `line-trim-offset` property. The first element of the array represents the fade range from the trim-start point toward the end of the line, while the second element defines the fade range from the trim-end point toward the beginning of the line. The fade result is achieved by interpolating between `line-trim-color` and the color specified by the `line-color` or the `line-gradient` property.",
|
|
5613
|
+
experimental: true,
|
|
5614
|
+
length: 2,
|
|
5615
|
+
"default": [
|
|
5616
|
+
0,
|
|
5617
|
+
0
|
|
5618
|
+
],
|
|
5619
|
+
minimum: [
|
|
5620
|
+
0,
|
|
5621
|
+
0
|
|
5622
|
+
],
|
|
5623
|
+
maximum: [
|
|
5624
|
+
1,
|
|
5625
|
+
1
|
|
5626
|
+
],
|
|
5627
|
+
transition: false,
|
|
5628
|
+
requires: [
|
|
5629
|
+
"line-trim-offset",
|
|
5630
|
+
{
|
|
5631
|
+
source: "geojson",
|
|
5632
|
+
has: {
|
|
5633
|
+
lineMetrics: true
|
|
5634
|
+
}
|
|
5635
|
+
}
|
|
5636
|
+
],
|
|
5637
|
+
expression: {
|
|
5638
|
+
interpolated: true,
|
|
5639
|
+
parameters: [
|
|
5640
|
+
"zoom",
|
|
5641
|
+
"measure-light"
|
|
5642
|
+
]
|
|
5643
|
+
},
|
|
5644
|
+
"sdk-support": {
|
|
5645
|
+
"basic functionality": {
|
|
5646
|
+
js: "3.6.0",
|
|
5647
|
+
android: "11.6.0",
|
|
5648
|
+
ios: "11.6.0"
|
|
5649
|
+
}
|
|
5650
|
+
},
|
|
5651
|
+
"property-type": "data-constant"
|
|
5652
|
+
},
|
|
5653
|
+
"line-trim-color": {
|
|
5654
|
+
type: "color",
|
|
5655
|
+
doc: "The color to be used for rendering the trimmed line section that is defined by the `line-trim-offset` property.",
|
|
5656
|
+
experimental: true,
|
|
5657
|
+
"default": "transparent",
|
|
5658
|
+
transition: true,
|
|
5659
|
+
requires: [
|
|
5660
|
+
"line-trim-offset",
|
|
5661
|
+
{
|
|
5662
|
+
source: "geojson",
|
|
5663
|
+
has: {
|
|
5664
|
+
lineMetrics: true
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5667
|
+
],
|
|
5668
|
+
"sdk-support": {
|
|
5669
|
+
"basic functionality": {
|
|
5670
|
+
js: "3.6.0",
|
|
5671
|
+
android: "11.6.0",
|
|
5672
|
+
ios: "11.6.0"
|
|
5673
|
+
}
|
|
5674
|
+
},
|
|
5675
|
+
expression: {
|
|
5676
|
+
interpolated: true,
|
|
5677
|
+
parameters: [
|
|
5678
|
+
"zoom",
|
|
5679
|
+
"measure-light"
|
|
5680
|
+
]
|
|
5681
|
+
},
|
|
5682
|
+
"property-type": "data-constant"
|
|
5683
|
+
},
|
|
5519
5684
|
"line-emissive-strength": {
|
|
5520
5685
|
type: "number",
|
|
5521
5686
|
"default": 0,
|
|
@@ -5598,6 +5763,29 @@
|
|
|
5598
5763
|
]
|
|
5599
5764
|
},
|
|
5600
5765
|
"property-type": "data-driven"
|
|
5766
|
+
},
|
|
5767
|
+
"line-occlusion-opacity": {
|
|
5768
|
+
type: "number",
|
|
5769
|
+
"default": 0,
|
|
5770
|
+
minimum: 0,
|
|
5771
|
+
maximum: 1,
|
|
5772
|
+
experimental: true,
|
|
5773
|
+
doc: "Opacity multiplier (multiplies line-opacity value) of the line part that is occluded by 3D objects. Value 0 hides occluded part, value 1 means the same opacity as non-occluded part. The property is not supported when `line-opacity` has data-driven styling.",
|
|
5774
|
+
"sdk-support": {
|
|
5775
|
+
"basic functionality": {
|
|
5776
|
+
js: "3.5.0",
|
|
5777
|
+
android: "11.5.0",
|
|
5778
|
+
ios: "11.5.0"
|
|
5779
|
+
}
|
|
5780
|
+
},
|
|
5781
|
+
expression: {
|
|
5782
|
+
interpolated: true,
|
|
5783
|
+
parameters: [
|
|
5784
|
+
"zoom"
|
|
5785
|
+
]
|
|
5786
|
+
},
|
|
5787
|
+
transition: true,
|
|
5788
|
+
"property-type": "data-constant"
|
|
5601
5789
|
}
|
|
5602
5790
|
};
|
|
5603
5791
|
var paint_circle = {
|
|
@@ -6122,6 +6310,39 @@
|
|
|
6122
6310
|
},
|
|
6123
6311
|
"property-type": "data-driven"
|
|
6124
6312
|
},
|
|
6313
|
+
"icon-occlusion-opacity": {
|
|
6314
|
+
doc: "The opacity at which the icon will be drawn in case of being depth occluded. Not supported on globe zoom levels.",
|
|
6315
|
+
type: "number",
|
|
6316
|
+
"default": 1,
|
|
6317
|
+
minimum: 0,
|
|
6318
|
+
maximum: 1,
|
|
6319
|
+
transition: true,
|
|
6320
|
+
requires: [
|
|
6321
|
+
"icon-image"
|
|
6322
|
+
],
|
|
6323
|
+
"sdk-support": {
|
|
6324
|
+
"basic functionality": {
|
|
6325
|
+
js: "3.5.0",
|
|
6326
|
+
android: "11.5.0",
|
|
6327
|
+
ios: "11.6.0"
|
|
6328
|
+
},
|
|
6329
|
+
"data-driven styling": {
|
|
6330
|
+
js: "3.5.0",
|
|
6331
|
+
android: "11.5.0",
|
|
6332
|
+
ios: "11.6.0"
|
|
6333
|
+
}
|
|
6334
|
+
},
|
|
6335
|
+
expression: {
|
|
6336
|
+
interpolated: true,
|
|
6337
|
+
parameters: [
|
|
6338
|
+
"zoom",
|
|
6339
|
+
"feature",
|
|
6340
|
+
"feature-state",
|
|
6341
|
+
"measure-light"
|
|
6342
|
+
]
|
|
6343
|
+
},
|
|
6344
|
+
"property-type": "data-driven"
|
|
6345
|
+
},
|
|
6125
6346
|
"icon-emissive-strength": {
|
|
6126
6347
|
type: "number",
|
|
6127
6348
|
"default": 1,
|
|
@@ -6438,6 +6659,39 @@
|
|
|
6438
6659
|
},
|
|
6439
6660
|
"property-type": "data-driven"
|
|
6440
6661
|
},
|
|
6662
|
+
"text-occlusion-opacity": {
|
|
6663
|
+
type: "number",
|
|
6664
|
+
doc: "The opacity at which the text will be drawn in case of being depth occluded. Not supported on globe zoom levels.",
|
|
6665
|
+
"default": 1,
|
|
6666
|
+
minimum: 0,
|
|
6667
|
+
maximum: 1,
|
|
6668
|
+
transition: true,
|
|
6669
|
+
requires: [
|
|
6670
|
+
"text-field"
|
|
6671
|
+
],
|
|
6672
|
+
"sdk-support": {
|
|
6673
|
+
"basic functionality": {
|
|
6674
|
+
js: "3.5.0",
|
|
6675
|
+
android: "11.5.0",
|
|
6676
|
+
ios: "11.6.0"
|
|
6677
|
+
},
|
|
6678
|
+
"data-driven styling": {
|
|
6679
|
+
js: "3.5.0",
|
|
6680
|
+
android: "11.5.0",
|
|
6681
|
+
ios: "11.6.0"
|
|
6682
|
+
}
|
|
6683
|
+
},
|
|
6684
|
+
expression: {
|
|
6685
|
+
interpolated: true,
|
|
6686
|
+
parameters: [
|
|
6687
|
+
"zoom",
|
|
6688
|
+
"feature",
|
|
6689
|
+
"feature-state",
|
|
6690
|
+
"measure-light"
|
|
6691
|
+
]
|
|
6692
|
+
},
|
|
6693
|
+
"property-type": "data-driven"
|
|
6694
|
+
},
|
|
6441
6695
|
"text-color": {
|
|
6442
6696
|
type: "color",
|
|
6443
6697
|
doc: "The color with which the text will be drawn.",
|
|
@@ -7000,6 +7254,7 @@
|
|
|
7000
7254
|
"raster-array-band": {
|
|
7001
7255
|
type: "string",
|
|
7002
7256
|
required: false,
|
|
7257
|
+
experimental: true,
|
|
7003
7258
|
"property-type": "data-constant",
|
|
7004
7259
|
transition: false,
|
|
7005
7260
|
requires: [
|
|
@@ -7023,6 +7278,7 @@
|
|
|
7023
7278
|
"default": 0,
|
|
7024
7279
|
minimum: 0,
|
|
7025
7280
|
transition: true,
|
|
7281
|
+
experimental: true,
|
|
7026
7282
|
"sdk-support": {
|
|
7027
7283
|
"basic functionality": {
|
|
7028
7284
|
js: "3.1.0",
|
|
@@ -8069,6 +8325,7 @@
|
|
|
8069
8325
|
layout_background: layout_background,
|
|
8070
8326
|
layout_sky: layout_sky,
|
|
8071
8327
|
layout_model: layout_model,
|
|
8328
|
+
layout_clip: layout_clip,
|
|
8072
8329
|
layout_fill: layout_fill,
|
|
8073
8330
|
layout_circle: layout_circle,
|
|
8074
8331
|
layout_heatmap: layout_heatmap,
|
|
@@ -8104,6 +8361,7 @@
|
|
|
8104
8361
|
},
|
|
8105
8362
|
"fill-extrusion-edge-radius": {
|
|
8106
8363
|
type: "number",
|
|
8364
|
+
experimental: true,
|
|
8107
8365
|
"private": true,
|
|
8108
8366
|
"default": 0,
|
|
8109
8367
|
minimum: 0,
|
|
@@ -8251,6 +8509,7 @@
|
|
|
8251
8509
|
expression_name: expression_name,
|
|
8252
8510
|
fog: fog,
|
|
8253
8511
|
camera: camera,
|
|
8512
|
+
colorTheme: colorTheme,
|
|
8254
8513
|
light: light,
|
|
8255
8514
|
projection: projection,
|
|
8256
8515
|
terrain: terrain,
|
|
@@ -8525,6 +8784,7 @@
|
|
|
8525
8784
|
"fill-extrusion-ambient-occlusion-wall-radius": {
|
|
8526
8785
|
"property-type": "data-constant",
|
|
8527
8786
|
type: "number",
|
|
8787
|
+
experimental: true,
|
|
8528
8788
|
"default": 3,
|
|
8529
8789
|
minimum: 0,
|
|
8530
8790
|
expression: {
|
|
@@ -8550,6 +8810,7 @@
|
|
|
8550
8810
|
"fill-extrusion-ambient-occlusion-ground-radius": {
|
|
8551
8811
|
"property-type": "data-constant",
|
|
8552
8812
|
type: "number",
|
|
8813
|
+
experimental: true,
|
|
8553
8814
|
"default": 3,
|
|
8554
8815
|
minimum: 0,
|
|
8555
8816
|
expression: {
|
|
@@ -8574,6 +8835,7 @@
|
|
|
8574
8835
|
"fill-extrusion-ambient-occlusion-ground-attenuation": {
|
|
8575
8836
|
"property-type": "data-constant",
|
|
8576
8837
|
type: "number",
|
|
8838
|
+
experimental: true,
|
|
8577
8839
|
"default": 0.69,
|
|
8578
8840
|
minimum: 0,
|
|
8579
8841
|
maximum: 1,
|
|
@@ -8599,6 +8861,7 @@
|
|
|
8599
8861
|
"fill-extrusion-flood-light-color": {
|
|
8600
8862
|
"property-type": "data-constant",
|
|
8601
8863
|
type: "color",
|
|
8864
|
+
experimental: true,
|
|
8602
8865
|
"default": "#ffffff",
|
|
8603
8866
|
doc: "The color of the flood light effect on the walls of the extruded buildings.",
|
|
8604
8867
|
requires: [
|
|
@@ -8623,6 +8886,7 @@
|
|
|
8623
8886
|
"fill-extrusion-flood-light-intensity": {
|
|
8624
8887
|
"property-type": "data-constant",
|
|
8625
8888
|
type: "number",
|
|
8889
|
+
experimental: true,
|
|
8626
8890
|
"default": 0,
|
|
8627
8891
|
minimum: 0,
|
|
8628
8892
|
maximum: 1,
|
|
@@ -8649,6 +8913,7 @@
|
|
|
8649
8913
|
"fill-extrusion-flood-light-wall-radius": {
|
|
8650
8914
|
"property-type": "data-driven",
|
|
8651
8915
|
type: "number",
|
|
8916
|
+
experimental: true,
|
|
8652
8917
|
units: "meters",
|
|
8653
8918
|
"default": 0,
|
|
8654
8919
|
minimum: 0,
|
|
@@ -8680,6 +8945,7 @@
|
|
|
8680
8945
|
"fill-extrusion-flood-light-ground-radius": {
|
|
8681
8946
|
"property-type": "data-driven",
|
|
8682
8947
|
type: "number",
|
|
8948
|
+
experimental: true,
|
|
8683
8949
|
units: "meters",
|
|
8684
8950
|
"default": 0,
|
|
8685
8951
|
doc: "The extent of the flood light effect on the ground beneath the extruded buildings in meters.",
|
|
@@ -8710,6 +8976,7 @@
|
|
|
8710
8976
|
"fill-extrusion-flood-light-ground-attenuation": {
|
|
8711
8977
|
"property-type": "data-constant",
|
|
8712
8978
|
type: "number",
|
|
8979
|
+
experimental: true,
|
|
8713
8980
|
"default": 0.69,
|
|
8714
8981
|
minimum: 0,
|
|
8715
8982
|
maximum: 1,
|
|
@@ -8735,6 +9002,7 @@
|
|
|
8735
9002
|
"fill-extrusion-vertical-scale": {
|
|
8736
9003
|
"property-type": "data-constant",
|
|
8737
9004
|
type: "number",
|
|
9005
|
+
experimental: true,
|
|
8738
9006
|
"default": 1,
|
|
8739
9007
|
minimum: 0,
|
|
8740
9008
|
doc: "A global multiplier that can be used to scale base, height, AO, and flood light of the fill extrusions.",
|
|
@@ -8757,6 +9025,7 @@
|
|
|
8757
9025
|
"property-type": "data-constant",
|
|
8758
9026
|
type: "boolean",
|
|
8759
9027
|
"default": true,
|
|
9028
|
+
experimental: true,
|
|
8760
9029
|
doc: "Indicates whether top edges should be rounded when fill-extrusion-edge-radius has a value greater than 0. If false, rounded edges are only applied to the sides. Default is true.",
|
|
8761
9030
|
requires: [
|
|
8762
9031
|
"fill-extrusion-edge-radius"
|
|
@@ -9050,42 +9319,20 @@
|
|
|
9050
9319
|
}(passedObj, '', 0);
|
|
9051
9320
|
}
|
|
9052
9321
|
|
|
9053
|
-
|
|
9054
|
-
function sortKeysBy(obj, reference) {
|
|
9322
|
+
function sortKeysBy(obj, reference2) {
|
|
9055
9323
|
const result = {};
|
|
9056
|
-
for (const key in
|
|
9057
|
-
if (obj[key] !==
|
|
9324
|
+
for (const key in reference2) {
|
|
9325
|
+
if (obj[key] !== void 0) {
|
|
9058
9326
|
result[key] = obj[key];
|
|
9059
9327
|
}
|
|
9060
9328
|
}
|
|
9061
9329
|
for (const key in obj) {
|
|
9062
|
-
if (result[key] ===
|
|
9330
|
+
if (result[key] === void 0) {
|
|
9063
9331
|
result[key] = obj[key];
|
|
9064
9332
|
}
|
|
9065
9333
|
}
|
|
9066
9334
|
return result;
|
|
9067
9335
|
}
|
|
9068
|
-
/**
|
|
9069
|
-
* Format a Mapbox GL Style. Returns a stringified style with its keys
|
|
9070
|
-
* sorted in the same order as the reference style.
|
|
9071
|
-
*
|
|
9072
|
-
* The optional `space` argument is passed to
|
|
9073
|
-
* [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
|
|
9074
|
-
* to generate formatted output.
|
|
9075
|
-
*
|
|
9076
|
-
* If `space` is unspecified, a default of `2` spaces will be used.
|
|
9077
|
-
*
|
|
9078
|
-
* @private
|
|
9079
|
-
* @param {Object} style a Mapbox GL Style
|
|
9080
|
-
* @param {number} [space] space argument to pass to `JSON.stringify`
|
|
9081
|
-
* @returns {string} stringified formatted JSON
|
|
9082
|
-
* @example
|
|
9083
|
-
* var fs = require('fs');
|
|
9084
|
-
* var format = require('mapbox-gl-style-spec').format;
|
|
9085
|
-
* var style = fs.readFileSync('./source.json', 'utf8');
|
|
9086
|
-
* fs.writeFileSync('./dest.json', format(style));
|
|
9087
|
-
* fs.writeFileSync('./dest.min.json', format(style, 0));
|
|
9088
|
-
*/
|
|
9089
9336
|
function format(style, space = 2) {
|
|
9090
9337
|
style = sortKeysBy(style, v8.$root);
|
|
9091
9338
|
if (style.layers) {
|
|
@@ -9094,7 +9341,6 @@
|
|
|
9094
9341
|
return stringify(style, { indent: space });
|
|
9095
9342
|
}
|
|
9096
9343
|
|
|
9097
|
-
//
|
|
9098
9344
|
function getPropertyReference(propertyName) {
|
|
9099
9345
|
for (let i = 0; i < v8.layout.length; i++) {
|
|
9100
9346
|
for (const key in v8[v8.layout[i]]) {
|
|
@@ -9122,7 +9368,7 @@
|
|
|
9122
9368
|
}
|
|
9123
9369
|
function eachProperty(style, options, callback) {
|
|
9124
9370
|
function inner(layer, propertyType) {
|
|
9125
|
-
if (layer.type === 'slot')
|
|
9371
|
+
if (layer.type === 'slot' || layer.type === 'clip')
|
|
9126
9372
|
return;
|
|
9127
9373
|
const properties = layer[propertyType];
|
|
9128
9374
|
if (!properties)
|
|
@@ -9153,7 +9399,6 @@
|
|
|
9153
9399
|
});
|
|
9154
9400
|
}
|
|
9155
9401
|
|
|
9156
|
-
//
|
|
9157
9402
|
function eachLayout(layer, callback) {
|
|
9158
9403
|
for (const k in layer) {
|
|
9159
9404
|
if (k.indexOf('layout') === 0) {
|
|
@@ -9184,9 +9429,8 @@
|
|
|
9184
9429
|
}
|
|
9185
9430
|
function migrateToV8 (style) {
|
|
9186
9431
|
style.version = 8;
|
|
9187
|
-
// Rename properties, reverse coordinates in source and layers
|
|
9188
9432
|
eachSource(style, source => {
|
|
9189
|
-
if (source.type === 'video' && source.url !==
|
|
9433
|
+
if (source.type === 'video' && source.url !== void 0) {
|
|
9190
9434
|
renameProperty(source, 'url', 'urls');
|
|
9191
9435
|
}
|
|
9192
9436
|
if (source.type === 'video') {
|
|
@@ -9197,23 +9441,22 @@
|
|
|
9197
9441
|
});
|
|
9198
9442
|
eachLayer(style, layer => {
|
|
9199
9443
|
eachLayout(layer, layout => {
|
|
9200
|
-
if (layout['symbol-min-distance'] !==
|
|
9444
|
+
if (layout['symbol-min-distance'] !== void 0) {
|
|
9201
9445
|
renameProperty(layout, 'symbol-min-distance', 'symbol-spacing');
|
|
9202
9446
|
}
|
|
9203
9447
|
});
|
|
9204
9448
|
eachPaint(layer, paint => {
|
|
9205
|
-
if (paint['background-image'] !==
|
|
9449
|
+
if (paint['background-image'] !== void 0) {
|
|
9206
9450
|
renameProperty(paint, 'background-image', 'background-pattern');
|
|
9207
9451
|
}
|
|
9208
|
-
if (paint['line-image'] !==
|
|
9452
|
+
if (paint['line-image'] !== void 0) {
|
|
9209
9453
|
renameProperty(paint, 'line-image', 'line-pattern');
|
|
9210
9454
|
}
|
|
9211
|
-
if (paint['fill-image'] !==
|
|
9455
|
+
if (paint['fill-image'] !== void 0) {
|
|
9212
9456
|
renameProperty(paint, 'fill-image', 'fill-pattern');
|
|
9213
9457
|
}
|
|
9214
9458
|
});
|
|
9215
9459
|
});
|
|
9216
|
-
// Inline Constants
|
|
9217
9460
|
eachProperty(style, {
|
|
9218
9461
|
paint: true,
|
|
9219
9462
|
layout: true
|
|
@@ -9228,9 +9471,6 @@
|
|
|
9228
9471
|
});
|
|
9229
9472
|
delete style.constants;
|
|
9230
9473
|
eachLayer(style, layer => {
|
|
9231
|
-
// get rid of text-max-size, icon-max-size
|
|
9232
|
-
// turn text-size, icon-size into layout properties
|
|
9233
|
-
// https://github.com/mapbox/mapbox-gl-style-spec/issues/255
|
|
9234
9474
|
eachLayout(layer, layout => {
|
|
9235
9475
|
delete layout['text-max-size'];
|
|
9236
9476
|
delete layout['icon-max-size'];
|
|
@@ -9282,7 +9522,6 @@
|
|
|
9282
9522
|
});
|
|
9283
9523
|
}
|
|
9284
9524
|
if (Array.isArray(font)) {
|
|
9285
|
-
// Assume it's a previously migrated font-array.
|
|
9286
9525
|
return font;
|
|
9287
9526
|
} else if (typeof font === 'string') {
|
|
9288
9527
|
return splitAndTrim(font);
|
|
@@ -9302,18 +9541,6 @@
|
|
|
9302
9541
|
}
|
|
9303
9542
|
});
|
|
9304
9543
|
});
|
|
9305
|
-
// Reverse order of symbol layers. This is an imperfect migration.
|
|
9306
|
-
//
|
|
9307
|
-
// The order of a symbol layer in the layers list affects two things:
|
|
9308
|
-
// - how it is drawn relative to other layers (like oneway arrows below bridges)
|
|
9309
|
-
// - the placement priority compared to other layers
|
|
9310
|
-
//
|
|
9311
|
-
// It's impossible to reverse the placement priority without breaking the draw order
|
|
9312
|
-
// in some cases. This migration only reverses the order of symbol layers that
|
|
9313
|
-
// are above all other types of layers.
|
|
9314
|
-
//
|
|
9315
|
-
// Symbol layers that are at the top of the map preserve their priority.
|
|
9316
|
-
// Symbol layers that are below another type (line, fill) of layer preserve their draw order.
|
|
9317
9544
|
let firstSymbolLayer = 0;
|
|
9318
9545
|
for (let i = style.layers.length - 1; i >= 0; i--) {
|
|
9319
9546
|
const layer = style.layers[i];
|
|
@@ -9328,7 +9555,6 @@
|
|
|
9328
9555
|
return style;
|
|
9329
9556
|
}
|
|
9330
9557
|
|
|
9331
|
-
//
|
|
9332
9558
|
function extend (output, ...inputs) {
|
|
9333
9559
|
for (const input of inputs) {
|
|
9334
9560
|
for (const k in input) {
|
|
@@ -9338,7 +9564,6 @@
|
|
|
9338
9564
|
return output;
|
|
9339
9565
|
}
|
|
9340
9566
|
|
|
9341
|
-
//
|
|
9342
9567
|
let ParsingError$1 = class ParsingError extends Error {
|
|
9343
9568
|
constructor(key, message) {
|
|
9344
9569
|
super(message);
|
|
@@ -9347,11 +9572,6 @@
|
|
|
9347
9572
|
}
|
|
9348
9573
|
};
|
|
9349
9574
|
|
|
9350
|
-
//
|
|
9351
|
-
/**
|
|
9352
|
-
* Tracks `let` bindings during expression parsing.
|
|
9353
|
-
* @private
|
|
9354
|
-
*/
|
|
9355
9575
|
class Scope {
|
|
9356
9576
|
constructor(parent, bindings = []) {
|
|
9357
9577
|
this.parent = parent;
|
|
@@ -9379,7 +9599,6 @@
|
|
|
9379
9599
|
}
|
|
9380
9600
|
}
|
|
9381
9601
|
|
|
9382
|
-
//
|
|
9383
9602
|
const NullType = { kind: 'null' };
|
|
9384
9603
|
const NumberType = { kind: 'number' };
|
|
9385
9604
|
const StringType = { kind: 'string' };
|
|
@@ -9417,14 +9636,8 @@
|
|
|
9417
9636
|
array$1(ValueType),
|
|
9418
9637
|
ResolvedImageType
|
|
9419
9638
|
];
|
|
9420
|
-
/**
|
|
9421
|
-
* Returns null if `t` is a subtype of `expected`; otherwise returns an
|
|
9422
|
-
* error message.
|
|
9423
|
-
* @private
|
|
9424
|
-
*/
|
|
9425
9639
|
function checkSubtype(expected, t) {
|
|
9426
9640
|
if (t.kind === 'error') {
|
|
9427
|
-
// Error is a subtype of every type
|
|
9428
9641
|
return null;
|
|
9429
9642
|
} else if (expected.kind === 'array') {
|
|
9430
9643
|
if (t.kind === 'array' && (t.N === 0 && t.itemType.kind === 'value' || !checkSubtype(expected.itemType, t.itemType)) && (typeof expected.N !== 'number' || expected.N === t.N)) {
|
|
@@ -10508,18 +10721,25 @@
|
|
|
10508
10721
|
} catch (e) {
|
|
10509
10722
|
}
|
|
10510
10723
|
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10724
|
+
function number(a, b, t) {
|
|
10725
|
+
return a * (1 - t) + b * t;
|
|
10726
|
+
}
|
|
10727
|
+
function color(from, to, t) {
|
|
10728
|
+
return new Color(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
|
|
10729
|
+
}
|
|
10730
|
+
function array(from, to, t) {
|
|
10731
|
+
return from.map((d, i) => {
|
|
10732
|
+
return number(d, to[i], t);
|
|
10733
|
+
});
|
|
10734
|
+
}
|
|
10735
|
+
|
|
10736
|
+
var interpolate$1 = /*#__PURE__*/Object.freeze({
|
|
10737
|
+
__proto__: null,
|
|
10738
|
+
array: array,
|
|
10739
|
+
color: color,
|
|
10740
|
+
number: number
|
|
10741
|
+
});
|
|
10742
|
+
|
|
10523
10743
|
class Color {
|
|
10524
10744
|
constructor(r, g, b, a = 1) {
|
|
10525
10745
|
this.r = r;
|
|
@@ -10528,44 +10748,99 @@
|
|
|
10528
10748
|
this.a = a;
|
|
10529
10749
|
}
|
|
10530
10750
|
/**
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10751
|
+
* Parses valid CSS color strings and returns a `Color` instance.
|
|
10752
|
+
* @returns A `Color` instance, or `undefined` if the input is not a valid color string.
|
|
10753
|
+
*/
|
|
10534
10754
|
static parse(input) {
|
|
10535
10755
|
if (!input) {
|
|
10536
|
-
return
|
|
10756
|
+
return void 0;
|
|
10537
10757
|
}
|
|
10538
10758
|
if (input instanceof Color) {
|
|
10539
10759
|
return input;
|
|
10540
10760
|
}
|
|
10541
10761
|
if (typeof input !== 'string') {
|
|
10542
|
-
return
|
|
10762
|
+
return void 0;
|
|
10543
10763
|
}
|
|
10544
10764
|
const rgba = parseCSSColor_1(input);
|
|
10545
10765
|
if (!rgba) {
|
|
10546
|
-
return
|
|
10766
|
+
return void 0;
|
|
10547
10767
|
}
|
|
10548
10768
|
return new Color(rgba[0] / 255 * rgba[3], rgba[1] / 255 * rgba[3], rgba[2] / 255 * rgba[3], rgba[3]);
|
|
10549
10769
|
}
|
|
10550
10770
|
/**
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10556
|
-
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10771
|
+
* Returns an RGBA string representing the color value.
|
|
10772
|
+
*
|
|
10773
|
+
* @returns An RGBA string.
|
|
10774
|
+
* @example
|
|
10775
|
+
* var purple = new Color.parse('purple');
|
|
10776
|
+
* purple.toString; // = "rgba(128,0,128,1)"
|
|
10777
|
+
* var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');
|
|
10778
|
+
* translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
|
|
10779
|
+
*/
|
|
10560
10780
|
toString() {
|
|
10561
|
-
const [r, g, b, a] = this.
|
|
10781
|
+
const [r, g, b, a] = this.a === 0 ? [
|
|
10782
|
+
0,
|
|
10783
|
+
0,
|
|
10784
|
+
0,
|
|
10785
|
+
0
|
|
10786
|
+
] : [
|
|
10787
|
+
this.r * 255 / this.a,
|
|
10788
|
+
this.g * 255 / this.a,
|
|
10789
|
+
this.b * 255 / this.a,
|
|
10790
|
+
this.a
|
|
10791
|
+
];
|
|
10562
10792
|
return `rgba(${ Math.round(r) },${ Math.round(g) },${ Math.round(b) },${ a })`;
|
|
10563
10793
|
}
|
|
10794
|
+
toRenderColor(lut) {
|
|
10795
|
+
const {r, g, b, a} = this;
|
|
10796
|
+
return new RenderColor(lut, r, g, b, a);
|
|
10797
|
+
}
|
|
10798
|
+
}
|
|
10799
|
+
class RenderColor {
|
|
10800
|
+
constructor(lut, r, g, b, a) {
|
|
10801
|
+
if (!lut) {
|
|
10802
|
+
this.r = r;
|
|
10803
|
+
this.g = g;
|
|
10804
|
+
this.b = b;
|
|
10805
|
+
this.a = a;
|
|
10806
|
+
} else {
|
|
10807
|
+
const N = lut.image.height;
|
|
10808
|
+
const N2 = N * N;
|
|
10809
|
+
r = a === 0 ? 0 : r / a * (N - 1);
|
|
10810
|
+
g = a === 0 ? 0 : g / a * (N - 1);
|
|
10811
|
+
b = a === 0 ? 0 : b / a * (N - 1);
|
|
10812
|
+
const r0 = Math.floor(r);
|
|
10813
|
+
const g0 = Math.floor(g);
|
|
10814
|
+
const b0 = Math.floor(b);
|
|
10815
|
+
const r1 = Math.ceil(r);
|
|
10816
|
+
const g1 = Math.ceil(g);
|
|
10817
|
+
const b1 = Math.ceil(b);
|
|
10818
|
+
const rw = r - r0;
|
|
10819
|
+
const gw = g - g0;
|
|
10820
|
+
const bw = b - b0;
|
|
10821
|
+
const data = lut.image.data;
|
|
10822
|
+
const i0 = (r0 + g0 * N2 + b0 * N) * 4;
|
|
10823
|
+
const i1 = (r0 + g0 * N2 + b1 * N) * 4;
|
|
10824
|
+
const i2 = (r0 + g1 * N2 + b0 * N) * 4;
|
|
10825
|
+
const i3 = (r0 + g1 * N2 + b1 * N) * 4;
|
|
10826
|
+
const i4 = (r1 + g0 * N2 + b0 * N) * 4;
|
|
10827
|
+
const i5 = (r1 + g0 * N2 + b1 * N) * 4;
|
|
10828
|
+
const i6 = (r1 + g1 * N2 + b0 * N) * 4;
|
|
10829
|
+
const i7 = (r1 + g1 * N2 + b1 * N) * 4;
|
|
10830
|
+
if (i0 < 0 || i7 >= data.length) {
|
|
10831
|
+
throw new Error('out of range');
|
|
10832
|
+
}
|
|
10833
|
+
this.r = number(number(number(data[i0], data[i1], bw), number(data[i2], data[i3], bw), gw), number(number(data[i4], data[i5], bw), number(data[i6], data[i7], bw), gw), rw) / 255 * a;
|
|
10834
|
+
this.g = number(number(number(data[i0 + 1], data[i1 + 1], bw), number(data[i2 + 1], data[i3 + 1], bw), gw), number(number(data[i4 + 1], data[i5 + 1], bw), number(data[i6 + 1], data[i7 + 1], bw), gw), rw) / 255 * a;
|
|
10835
|
+
this.b = number(number(number(data[i0 + 2], data[i1 + 2], bw), number(data[i2 + 2], data[i3 + 2], bw), gw), number(number(data[i4 + 2], data[i5 + 2], bw), number(data[i6 + 2], data[i7 + 2], bw), gw), rw) / 255 * a;
|
|
10836
|
+
this.a = a;
|
|
10837
|
+
}
|
|
10838
|
+
}
|
|
10564
10839
|
/**
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10840
|
+
* Returns an RGBA array of values representing the color, unpremultiplied by A.
|
|
10841
|
+
*
|
|
10842
|
+
* @returns An array of RGBA color values in the range [0, 255].
|
|
10843
|
+
*/
|
|
10569
10844
|
toArray() {
|
|
10570
10845
|
const {r, g, b, a} = this;
|
|
10571
10846
|
return a === 0 ? [
|
|
@@ -10581,10 +10856,10 @@
|
|
|
10581
10856
|
];
|
|
10582
10857
|
}
|
|
10583
10858
|
/**
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10859
|
+
* Returns a RGBA array of float values representing the color, unpremultiplied by A.
|
|
10860
|
+
*
|
|
10861
|
+
* @returns An array of RGBA color values in the range [0, 1].
|
|
10862
|
+
*/
|
|
10588
10863
|
toArray01() {
|
|
10589
10864
|
const {r, g, b, a} = this;
|
|
10590
10865
|
return a === 0 ? [
|
|
@@ -10600,11 +10875,11 @@
|
|
|
10600
10875
|
];
|
|
10601
10876
|
}
|
|
10602
10877
|
/**
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10878
|
+
* Returns an RGB array of values representing the color, unpremultiplied by A and multiplied by a scalar.
|
|
10879
|
+
*
|
|
10880
|
+
* @param {number} scale A scale to apply to the unpremultiplied-alpha values.
|
|
10881
|
+
* @returns An array of RGB color values in the range [0, 1].
|
|
10882
|
+
*/
|
|
10608
10883
|
toArray01Scaled(scale) {
|
|
10609
10884
|
const {r, g, b, a} = this;
|
|
10610
10885
|
return a === 0 ? [
|
|
@@ -10618,10 +10893,10 @@
|
|
|
10618
10893
|
];
|
|
10619
10894
|
}
|
|
10620
10895
|
/**
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10896
|
+
* Returns an RGBA array of values representing the color, premultiplied by A.
|
|
10897
|
+
*
|
|
10898
|
+
* @returns An array of RGBA color values in the range [0, 1].
|
|
10899
|
+
*/
|
|
10625
10900
|
toArray01PremultipliedAlpha() {
|
|
10626
10901
|
const {r, g, b, a} = this;
|
|
10627
10902
|
return [
|
|
@@ -10632,11 +10907,11 @@
|
|
|
10632
10907
|
];
|
|
10633
10908
|
}
|
|
10634
10909
|
/**
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10910
|
+
* Returns an RGBA array of values representing the color, unpremultiplied by A, and converted to linear color space.
|
|
10911
|
+
* The color is defined by sRGB primaries, but the sRGB transfer function is reversed to obtain linear energy.
|
|
10912
|
+
*
|
|
10913
|
+
* @returns An array of RGBA color values in the range [0, 1].
|
|
10914
|
+
*/
|
|
10640
10915
|
toArray01Linear() {
|
|
10641
10916
|
const {r, g, b, a} = this;
|
|
10642
10917
|
return a === 0 ? [
|
|
@@ -10657,9 +10932,7 @@
|
|
|
10657
10932
|
Color.transparent = new Color(0, 0, 0, 0);
|
|
10658
10933
|
Color.red = new Color(1, 0, 0, 1);
|
|
10659
10934
|
Color.blue = new Color(0, 0, 1, 1);
|
|
10660
|
-
var Color$1 = Color;
|
|
10661
10935
|
|
|
10662
|
-
//
|
|
10663
10936
|
class Collator {
|
|
10664
10937
|
constructor(caseSensitive, diacriticSensitive, locale) {
|
|
10665
10938
|
if (caseSensitive)
|
|
@@ -10676,16 +10949,12 @@
|
|
|
10676
10949
|
return this.collator.compare(lhs, rhs);
|
|
10677
10950
|
}
|
|
10678
10951
|
resolvedLocale() {
|
|
10679
|
-
// We create a Collator without "usage: search" because we don't want
|
|
10680
|
-
// the search options encoded in our result (e.g. "en-u-co-search")
|
|
10681
10952
|
return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;
|
|
10682
10953
|
}
|
|
10683
10954
|
}
|
|
10684
10955
|
|
|
10685
|
-
//
|
|
10686
10956
|
class FormattedSection {
|
|
10687
10957
|
constructor(text, image, scale, fontStack, textColor) {
|
|
10688
|
-
// combine characters so that diacritic marks are not separate code points
|
|
10689
10958
|
this.text = text.normalize ? text.normalize() : text;
|
|
10690
10959
|
this.image = image;
|
|
10691
10960
|
this.scale = scale;
|
|
@@ -10739,7 +11008,7 @@
|
|
|
10739
11008
|
options['font-scale'] = section.scale;
|
|
10740
11009
|
}
|
|
10741
11010
|
if (section.textColor) {
|
|
10742
|
-
options['text-color'] = ['rgba'].concat(section.textColor.toArray());
|
|
11011
|
+
options['text-color'] = ['rgba'].concat(section.textColor.toRenderColor(null).toArray());
|
|
10743
11012
|
}
|
|
10744
11013
|
serialized.push(options);
|
|
10745
11014
|
}
|
|
@@ -10747,7 +11016,6 @@
|
|
|
10747
11016
|
}
|
|
10748
11017
|
}
|
|
10749
11018
|
|
|
10750
|
-
//
|
|
10751
11019
|
class ResolvedImage {
|
|
10752
11020
|
constructor(options) {
|
|
10753
11021
|
this.namePrimary = options.namePrimary;
|
|
@@ -10765,7 +11033,6 @@
|
|
|
10765
11033
|
static fromString(namePrimary, nameSecondary) {
|
|
10766
11034
|
if (!namePrimary)
|
|
10767
11035
|
return null;
|
|
10768
|
-
// treat empty values as no image
|
|
10769
11036
|
return new ResolvedImage({
|
|
10770
11037
|
namePrimary,
|
|
10771
11038
|
nameSecondary,
|
|
@@ -10857,7 +11124,7 @@
|
|
|
10857
11124
|
return true;
|
|
10858
11125
|
} else if (typeof mixed === 'number') {
|
|
10859
11126
|
return true;
|
|
10860
|
-
} else if (mixed instanceof Color
|
|
11127
|
+
} else if (mixed instanceof Color) {
|
|
10861
11128
|
return true;
|
|
10862
11129
|
} else if (mixed instanceof Collator) {
|
|
10863
11130
|
return true;
|
|
@@ -10892,7 +11159,7 @@
|
|
|
10892
11159
|
return BooleanType;
|
|
10893
11160
|
} else if (typeof value === 'number') {
|
|
10894
11161
|
return NumberType;
|
|
10895
|
-
} else if (value instanceof Color
|
|
11162
|
+
} else if (value instanceof Color) {
|
|
10896
11163
|
return ColorType;
|
|
10897
11164
|
} else if (value instanceof Collator) {
|
|
10898
11165
|
return CollatorType;
|
|
@@ -10925,7 +11192,7 @@
|
|
|
10925
11192
|
return '';
|
|
10926
11193
|
} else if (type === 'string' || type === 'number' || type === 'boolean') {
|
|
10927
11194
|
return String(value);
|
|
10928
|
-
} else if (value instanceof Color
|
|
11195
|
+
} else if (value instanceof Color || value instanceof Formatted || value instanceof ResolvedImage) {
|
|
10929
11196
|
return value.toString();
|
|
10930
11197
|
} else {
|
|
10931
11198
|
return JSON.stringify(value);
|
|
@@ -10944,7 +11211,6 @@
|
|
|
10944
11211
|
return context.error(`invalid value`);
|
|
10945
11212
|
const value = args[1];
|
|
10946
11213
|
let type = typeOf(value);
|
|
10947
|
-
// special case: infer the item type if possible for zero-length arrays
|
|
10948
11214
|
const expected = context.expectedType;
|
|
10949
11215
|
if (type.kind === 'array' && type.N === 0 && expected && expected.kind === 'array' && (typeof expected.N !== 'number' || expected.N === 0)) {
|
|
10950
11216
|
type = expected;
|
|
@@ -10965,13 +11231,9 @@
|
|
|
10965
11231
|
'literal',
|
|
10966
11232
|
this.value
|
|
10967
11233
|
];
|
|
10968
|
-
} else if (this.value instanceof Color
|
|
10969
|
-
|
|
10970
|
-
// couldn't actually generate with a "literal" expression,
|
|
10971
|
-
// so we have to implement an equivalent serialization here
|
|
10972
|
-
return ['rgba'].concat(this.value.toArray());
|
|
11234
|
+
} else if (this.value instanceof Color) {
|
|
11235
|
+
return ['rgba'].concat(this.value.toRenderColor(null).toArray());
|
|
10973
11236
|
} else if (this.value instanceof Formatted) {
|
|
10974
|
-
// Same as Color
|
|
10975
11237
|
return this.value.serialize();
|
|
10976
11238
|
} else {
|
|
10977
11239
|
return this.value;
|
|
@@ -10979,7 +11241,6 @@
|
|
|
10979
11241
|
}
|
|
10980
11242
|
}
|
|
10981
11243
|
|
|
10982
|
-
//
|
|
10983
11244
|
class RuntimeError {
|
|
10984
11245
|
constructor(message) {
|
|
10985
11246
|
this.name = 'ExpressionEvaluationError';
|
|
@@ -11010,10 +11271,10 @@
|
|
|
11010
11271
|
if (name === 'array') {
|
|
11011
11272
|
let itemType;
|
|
11012
11273
|
if (args.length > 2) {
|
|
11013
|
-
const
|
|
11014
|
-
if (typeof
|
|
11274
|
+
const type2 = args[1];
|
|
11275
|
+
if (typeof type2 !== 'string' || !(type2 in types$1) || type2 === 'object')
|
|
11015
11276
|
return context.error('The item type argument of "array" must be one of string, number, boolean', 1);
|
|
11016
|
-
itemType = types$1[
|
|
11277
|
+
itemType = types$1[type2];
|
|
11017
11278
|
i++;
|
|
11018
11279
|
} else {
|
|
11019
11280
|
itemType = ValueType;
|
|
@@ -11074,7 +11335,6 @@
|
|
|
11074
11335
|
}
|
|
11075
11336
|
}
|
|
11076
11337
|
|
|
11077
|
-
//
|
|
11078
11338
|
class FormatExpression {
|
|
11079
11339
|
constructor(sections) {
|
|
11080
11340
|
this.type = FormattedType;
|
|
@@ -11159,8 +11419,6 @@
|
|
|
11159
11419
|
}
|
|
11160
11420
|
}
|
|
11161
11421
|
outputDefined() {
|
|
11162
|
-
// Technically the combinatoric set of all children
|
|
11163
|
-
// Usually, this.text will be undefined anyway
|
|
11164
11422
|
return false;
|
|
11165
11423
|
}
|
|
11166
11424
|
serialize() {
|
|
@@ -11183,7 +11441,6 @@
|
|
|
11183
11441
|
}
|
|
11184
11442
|
}
|
|
11185
11443
|
|
|
11186
|
-
//
|
|
11187
11444
|
class ImageExpression {
|
|
11188
11445
|
constructor(inputPrimary, inputSecondary) {
|
|
11189
11446
|
this.type = ResolvedImageType;
|
|
@@ -11206,10 +11463,9 @@
|
|
|
11206
11463
|
return new ImageExpression(namePrimary, nameSecondary);
|
|
11207
11464
|
}
|
|
11208
11465
|
evaluate(ctx) {
|
|
11209
|
-
const value = ResolvedImage.fromString(this.inputPrimary.evaluate(ctx), this.inputSecondary ? this.inputSecondary.evaluate(ctx) :
|
|
11466
|
+
const value = ResolvedImage.fromString(this.inputPrimary.evaluate(ctx), this.inputSecondary ? this.inputSecondary.evaluate(ctx) : void 0);
|
|
11210
11467
|
if (value && ctx.availableImages) {
|
|
11211
11468
|
value.available = ctx.availableImages.indexOf(value.namePrimary) > -1;
|
|
11212
|
-
// If there's a secondary variant, only mark it available if both are present
|
|
11213
11469
|
if (value.nameSecondary && value.available && ctx.availableImages) {
|
|
11214
11470
|
value.available = ctx.availableImages.indexOf(value.nameSecondary) > -1;
|
|
11215
11471
|
}
|
|
@@ -11223,12 +11479,10 @@
|
|
|
11223
11479
|
}
|
|
11224
11480
|
}
|
|
11225
11481
|
outputDefined() {
|
|
11226
|
-
// The output of image is determined by the list of available images in the evaluation context
|
|
11227
11482
|
return false;
|
|
11228
11483
|
}
|
|
11229
11484
|
serialize() {
|
|
11230
11485
|
if (this.inputSecondary) {
|
|
11231
|
-
// $FlowIgnore
|
|
11232
11486
|
return [
|
|
11233
11487
|
'image',
|
|
11234
11488
|
this.inputPrimary.serialize(),
|
|
@@ -11242,7 +11496,6 @@
|
|
|
11242
11496
|
}
|
|
11243
11497
|
}
|
|
11244
11498
|
|
|
11245
|
-
//
|
|
11246
11499
|
function getType(val) {
|
|
11247
11500
|
if (val instanceof Number) {
|
|
11248
11501
|
return 'number';
|
|
@@ -11265,13 +11518,6 @@
|
|
|
11265
11518
|
'to-number': NumberType,
|
|
11266
11519
|
'to-string': StringType
|
|
11267
11520
|
};
|
|
11268
|
-
/**
|
|
11269
|
-
* Special form for error-coalescing coercion expressions "to-number",
|
|
11270
|
-
* "to-color". Since these coercions can fail at runtime, they accept multiple
|
|
11271
|
-
* arguments, only evaluating one at a time until one succeeds.
|
|
11272
|
-
*
|
|
11273
|
-
* @private
|
|
11274
|
-
*/
|
|
11275
11521
|
class Coercion {
|
|
11276
11522
|
constructor(type, args) {
|
|
11277
11523
|
this.type = type;
|
|
@@ -11301,11 +11547,10 @@
|
|
|
11301
11547
|
return null;
|
|
11302
11548
|
}
|
|
11303
11549
|
for (let i = 0; i < arrayLength; i++) {
|
|
11304
|
-
// $FlowIgnore
|
|
11305
11550
|
const member = args[1][i];
|
|
11306
11551
|
let parsedMember;
|
|
11307
11552
|
if (getType(member) === 'array') {
|
|
11308
|
-
parsedMember = context.parse(member,
|
|
11553
|
+
parsedMember = context.parse(member, void 0, type.itemType);
|
|
11309
11554
|
} else {
|
|
11310
11555
|
const memberType = getType(member);
|
|
11311
11556
|
if (memberType !== type.itemType.kind) {
|
|
@@ -11313,7 +11558,7 @@
|
|
|
11313
11558
|
}
|
|
11314
11559
|
parsedMember = context.registry['literal'].parse([
|
|
11315
11560
|
'literal',
|
|
11316
|
-
member ===
|
|
11561
|
+
member === void 0 ? null : member
|
|
11317
11562
|
], context);
|
|
11318
11563
|
}
|
|
11319
11564
|
if (!parsedMember)
|
|
@@ -11342,7 +11587,7 @@
|
|
|
11342
11587
|
for (const arg of this.args) {
|
|
11343
11588
|
input = arg.evaluate(ctx);
|
|
11344
11589
|
error = null;
|
|
11345
|
-
if (input instanceof Color
|
|
11590
|
+
if (input instanceof Color) {
|
|
11346
11591
|
return input;
|
|
11347
11592
|
} else if (typeof input === 'string') {
|
|
11348
11593
|
const c = ctx.parseColor(input);
|
|
@@ -11355,7 +11600,7 @@
|
|
|
11355
11600
|
error = validateRGBA(input[0], input[1], input[2], input[3]);
|
|
11356
11601
|
}
|
|
11357
11602
|
if (!error) {
|
|
11358
|
-
return new Color
|
|
11603
|
+
return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);
|
|
11359
11604
|
}
|
|
11360
11605
|
}
|
|
11361
11606
|
}
|
|
@@ -11373,8 +11618,6 @@
|
|
|
11373
11618
|
}
|
|
11374
11619
|
throw new RuntimeError(`Could not convert ${ JSON.stringify(value) } to number.`);
|
|
11375
11620
|
} else if (this.type.kind === 'formatted') {
|
|
11376
|
-
// There is no explicit 'to-formatted' but this coercion can be implicitly
|
|
11377
|
-
// created by properties that expect the 'formatted' type.
|
|
11378
11621
|
return Formatted.fromString(toString(this.args[0].evaluate(ctx)));
|
|
11379
11622
|
} else if (this.type.kind === 'resolvedImage') {
|
|
11380
11623
|
return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx)));
|
|
@@ -11412,7 +11655,6 @@
|
|
|
11412
11655
|
}
|
|
11413
11656
|
}
|
|
11414
11657
|
|
|
11415
|
-
//
|
|
11416
11658
|
const geometryTypes = [
|
|
11417
11659
|
'Unknown',
|
|
11418
11660
|
'Point',
|
|
@@ -11434,7 +11676,7 @@
|
|
|
11434
11676
|
this.options = options;
|
|
11435
11677
|
}
|
|
11436
11678
|
id() {
|
|
11437
|
-
return this.feature && this.feature.id !==
|
|
11679
|
+
return this.feature && this.feature.id !== void 0 ? this.feature.id : null;
|
|
11438
11680
|
}
|
|
11439
11681
|
geometryType() {
|
|
11440
11682
|
return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;
|
|
@@ -11456,13 +11698,10 @@
|
|
|
11456
11698
|
const c = this.featureDistanceData.center;
|
|
11457
11699
|
const scale = this.featureDistanceData.scale;
|
|
11458
11700
|
const {x, y} = this.featureTileCoord;
|
|
11459
|
-
// Calculate the distance vector `d` (left handed)
|
|
11460
11701
|
const dX = x * scale - c[0];
|
|
11461
11702
|
const dY = y * scale - c[1];
|
|
11462
|
-
// The bearing vector `b` (left handed)
|
|
11463
11703
|
const bX = this.featureDistanceData.bearing[0];
|
|
11464
11704
|
const bY = this.featureDistanceData.bearing[1];
|
|
11465
|
-
// Distance is calculated as `dot(d, v)`
|
|
11466
11705
|
const dist = bX * dX + bY * dY;
|
|
11467
11706
|
return dist;
|
|
11468
11707
|
}
|
|
@@ -11471,7 +11710,7 @@
|
|
|
11471
11710
|
parseColor(input) {
|
|
11472
11711
|
let cached = this._parseColorCache[input];
|
|
11473
11712
|
if (!cached) {
|
|
11474
|
-
cached = this._parseColorCache[input] = Color
|
|
11713
|
+
cached = this._parseColorCache[input] = Color.parse(input);
|
|
11475
11714
|
}
|
|
11476
11715
|
return cached;
|
|
11477
11716
|
}
|
|
@@ -11480,7 +11719,6 @@
|
|
|
11480
11719
|
}
|
|
11481
11720
|
}
|
|
11482
11721
|
|
|
11483
|
-
//
|
|
11484
11722
|
class CompoundExpression {
|
|
11485
11723
|
constructor(name, type, evaluate, args, overloadIndex) {
|
|
11486
11724
|
this.name = name;
|
|
@@ -11491,7 +11729,6 @@
|
|
|
11491
11729
|
}
|
|
11492
11730
|
evaluate(ctx) {
|
|
11493
11731
|
if (!this._evaluate) {
|
|
11494
|
-
// restore evaluate function after transfer between threads
|
|
11495
11732
|
const definition = CompoundExpression.definitions[this.name];
|
|
11496
11733
|
this._evaluate = Array.isArray(definition) ? definition[2] : definition.overloads[this._overloadIndex][1];
|
|
11497
11734
|
}
|
|
@@ -11512,7 +11749,6 @@
|
|
|
11512
11749
|
if (!definition) {
|
|
11513
11750
|
return context.error(`Unknown expression "${ op }". If you wanted a literal array, use ["literal", [...]].`, 0);
|
|
11514
11751
|
}
|
|
11515
|
-
// Now check argument types against each signature
|
|
11516
11752
|
const type = Array.isArray(definition) ? definition[0] : definition.type;
|
|
11517
11753
|
const availableOverloads = Array.isArray(definition) ? [[
|
|
11518
11754
|
definition[1],
|
|
@@ -11524,19 +11760,15 @@
|
|
|
11524
11760
|
for (const [params, evaluate] of availableOverloads) {
|
|
11525
11761
|
if (Array.isArray(params) && params.length !== args.length - 1)
|
|
11526
11762
|
continue;
|
|
11527
|
-
// param count doesn't match
|
|
11528
11763
|
overloadParams.push(params);
|
|
11529
11764
|
overloadIndex++;
|
|
11530
|
-
|
|
11531
|
-
// we eventually succeed, we haven't polluted `context.errors`.
|
|
11532
|
-
signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, undefined, context._scope, context.options);
|
|
11533
|
-
// First parse all the args, potentially coercing to the
|
|
11534
|
-
// types expected by this overload.
|
|
11765
|
+
signatureContext = new ParsingContext$1(context.registry, context.path, null, context.scope, void 0, context._scope, context.options);
|
|
11535
11766
|
const parsedArgs = [];
|
|
11536
11767
|
let argParseFailed = false;
|
|
11537
11768
|
for (let i = 1; i < args.length; i++) {
|
|
11538
11769
|
const arg = args[i];
|
|
11539
|
-
const expectedType = Array.isArray(params) ? params[i - 1] :
|
|
11770
|
+
const expectedType = Array.isArray(params) ? params[i - 1] : // @ts-expect-error - TS2339 - Property 'type' does not exist on type 'Varargs | Evaluate'.
|
|
11771
|
+
params.type;
|
|
11540
11772
|
const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);
|
|
11541
11773
|
if (!parsed) {
|
|
11542
11774
|
argParseFailed = true;
|
|
@@ -11545,8 +11777,6 @@
|
|
|
11545
11777
|
parsedArgs.push(parsed);
|
|
11546
11778
|
}
|
|
11547
11779
|
if (argParseFailed) {
|
|
11548
|
-
// Couldn't coerce args of this overload to expected type, move
|
|
11549
|
-
// on to next one.
|
|
11550
11780
|
continue;
|
|
11551
11781
|
}
|
|
11552
11782
|
if (Array.isArray(params)) {
|
|
@@ -11570,8 +11800,6 @@
|
|
|
11570
11800
|
const expected = overloadParams.length ? overloadParams : availableOverloads.map(([params]) => params);
|
|
11571
11801
|
const signatures = expected.map(stringifySignature).join(' | ');
|
|
11572
11802
|
const actualTypes = [];
|
|
11573
|
-
// For error message, re-parse arguments without trying to
|
|
11574
|
-
// apply any coercions
|
|
11575
11803
|
for (let i = 1; i < args.length; i++) {
|
|
11576
11804
|
const parsed = context.parse(args[i], 1 + actualTypes.length);
|
|
11577
11805
|
if (!parsed)
|
|
@@ -11585,7 +11813,6 @@
|
|
|
11585
11813
|
static register(registry, definitions) {
|
|
11586
11814
|
CompoundExpression.definitions = definitions;
|
|
11587
11815
|
for (const name in definitions) {
|
|
11588
|
-
// $FlowFixMe[method-unbinding]
|
|
11589
11816
|
registry[name] = CompoundExpression;
|
|
11590
11817
|
}
|
|
11591
11818
|
}
|
|
@@ -11598,7 +11825,6 @@
|
|
|
11598
11825
|
}
|
|
11599
11826
|
}
|
|
11600
11827
|
|
|
11601
|
-
//
|
|
11602
11828
|
class CollatorExpression {
|
|
11603
11829
|
constructor(caseSensitive, diacriticSensitive, locale) {
|
|
11604
11830
|
this.type = CollatorType;
|
|
@@ -11612,10 +11838,10 @@
|
|
|
11612
11838
|
const options = args[1];
|
|
11613
11839
|
if (typeof options !== 'object' || Array.isArray(options))
|
|
11614
11840
|
return context.error(`Collator options argument must be an object.`);
|
|
11615
|
-
const caseSensitive = context.parse(options['case-sensitive'] ===
|
|
11841
|
+
const caseSensitive = context.parse(options['case-sensitive'] === void 0 ? false : options['case-sensitive'], 1, BooleanType);
|
|
11616
11842
|
if (!caseSensitive)
|
|
11617
11843
|
return null;
|
|
11618
|
-
const diacriticSensitive = context.parse(options['diacritic-sensitive'] ===
|
|
11844
|
+
const diacriticSensitive = context.parse(options['diacritic-sensitive'] === void 0 ? false : options['diacritic-sensitive'], 1, BooleanType);
|
|
11619
11845
|
if (!diacriticSensitive)
|
|
11620
11846
|
return null;
|
|
11621
11847
|
let locale = null;
|
|
@@ -11637,10 +11863,6 @@
|
|
|
11637
11863
|
}
|
|
11638
11864
|
}
|
|
11639
11865
|
outputDefined() {
|
|
11640
|
-
// Technically the set of possible outputs is the combinatoric set of Collators produced
|
|
11641
|
-
// by all possible outputs of locale/caseSensitive/diacriticSensitive
|
|
11642
|
-
// But for the primary use of Collators in comparison operators, we ignore the Collator's
|
|
11643
|
-
// possible outputs anyway, so we can get away with leaving this false for now.
|
|
11644
11866
|
return false;
|
|
11645
11867
|
}
|
|
11646
11868
|
serialize() {
|
|
@@ -11657,13 +11879,6 @@
|
|
|
11657
11879
|
}
|
|
11658
11880
|
}
|
|
11659
11881
|
|
|
11660
|
-
//
|
|
11661
|
-
// minX, minY, maxX, maxY
|
|
11662
|
-
/**
|
|
11663
|
-
* Returns the signed area for the polygon ring. Postive areas are exterior rings and
|
|
11664
|
-
* have a clockwise winding. Negative areas are interior rings and have a counter clockwise
|
|
11665
|
-
* ordering.
|
|
11666
|
-
*/
|
|
11667
11882
|
function calculateSignedArea(ring) {
|
|
11668
11883
|
let sum = 0;
|
|
11669
11884
|
for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
|
|
@@ -11673,7 +11888,6 @@
|
|
|
11673
11888
|
}
|
|
11674
11889
|
return sum;
|
|
11675
11890
|
}
|
|
11676
|
-
// classifies an array of rings into polygons with outer rings and holes
|
|
11677
11891
|
function classifyRings(rings, maxRings) {
|
|
11678
11892
|
const len = rings.length;
|
|
11679
11893
|
if (len <= 1)
|
|
@@ -11685,7 +11899,7 @@
|
|
|
11685
11899
|
if (area === 0)
|
|
11686
11900
|
continue;
|
|
11687
11901
|
rings[i].area = Math.abs(area);
|
|
11688
|
-
if (ccw ===
|
|
11902
|
+
if (ccw === void 0)
|
|
11689
11903
|
ccw = area < 0;
|
|
11690
11904
|
if (ccw === area < 0) {
|
|
11691
11905
|
if (polygon)
|
|
@@ -11726,7 +11940,6 @@
|
|
|
11726
11940
|
function rayIntersect(p, p1, p2) {
|
|
11727
11941
|
return p1[1] > p[1] !== p2[1] > p[1] && p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0];
|
|
11728
11942
|
}
|
|
11729
|
-
// ray casting algorithm for detecting if point is in polygon
|
|
11730
11943
|
function pointWithinPolygon(point, rings, trueOnBoundary = false) {
|
|
11731
11944
|
let inside = false;
|
|
11732
11945
|
for (let i = 0, len = rings.length; i < len; i++) {
|
|
@@ -11745,9 +11958,7 @@
|
|
|
11745
11958
|
function perp(v1, v2) {
|
|
11746
11959
|
return v1[0] * v2[1] - v1[1] * v2[0];
|
|
11747
11960
|
}
|
|
11748
|
-
// check if p1 and p2 are in different sides of line segment q1->q2
|
|
11749
11961
|
function twoSided(p1, p2, q1, q2) {
|
|
11750
|
-
// q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)
|
|
11751
11962
|
const x1 = p1[0] - q1[0];
|
|
11752
11963
|
const y1 = p1[1] - q1[1];
|
|
11753
11964
|
const x2 = p2[0] - q1[0];
|
|
@@ -11760,11 +11971,7 @@
|
|
|
11760
11971
|
return true;
|
|
11761
11972
|
return false;
|
|
11762
11973
|
}
|
|
11763
|
-
// a, b are end points for line segment1, c and d are end points for line segment2
|
|
11764
11974
|
function segmentIntersectSegment(a, b, c, d) {
|
|
11765
|
-
// check if two segments are parallel or not
|
|
11766
|
-
// precondition is end point a, b is inside polygon, if line a->b is
|
|
11767
|
-
// parallel to polygon edge c->d, then a->b won't intersect with c->d
|
|
11768
11975
|
const vectorP = [
|
|
11769
11976
|
b[0] - a[0],
|
|
11770
11977
|
b[1] - a[1]
|
|
@@ -11775,15 +11982,11 @@
|
|
|
11775
11982
|
];
|
|
11776
11983
|
if (perp(vectorQ, vectorP) === 0)
|
|
11777
11984
|
return false;
|
|
11778
|
-
// If lines are intersecting with each other, the relative location should be:
|
|
11779
|
-
// a and b lie in different sides of segment c->d
|
|
11780
|
-
// c and d lie in different sides of segment a->b
|
|
11781
11985
|
if (twoSided(a, b, c, d) && twoSided(c, d, a, b))
|
|
11782
11986
|
return true;
|
|
11783
11987
|
return false;
|
|
11784
11988
|
}
|
|
11785
11989
|
|
|
11786
|
-
//
|
|
11787
11990
|
const EXTENT$1 = 8192;
|
|
11788
11991
|
function mercatorXfromLng(lng) {
|
|
11789
11992
|
return (180 + lng) / 360;
|
|
@@ -11809,7 +12012,6 @@
|
|
|
11809
12012
|
}
|
|
11810
12013
|
function lineIntersectPolygon(p1, p2, polygon) {
|
|
11811
12014
|
for (const ring of polygon) {
|
|
11812
|
-
// loop through every edge of the ring
|
|
11813
12015
|
for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
|
|
11814
12016
|
const q1 = ring[k];
|
|
11815
12017
|
const q2 = ring[j];
|
|
@@ -11821,13 +12023,11 @@
|
|
|
11821
12023
|
return false;
|
|
11822
12024
|
}
|
|
11823
12025
|
function lineStringWithinPolygon(line, polygon) {
|
|
11824
|
-
// First, check if geometry points of line segments are all inside polygon
|
|
11825
12026
|
for (let i = 0; i < line.length; ++i) {
|
|
11826
12027
|
if (!pointWithinPolygon(line[i], polygon)) {
|
|
11827
12028
|
return false;
|
|
11828
12029
|
}
|
|
11829
12030
|
}
|
|
11830
|
-
// Second, check if there is line segment intersecting polygon edge
|
|
11831
12031
|
for (let i = 0; i < line.length - 1; ++i) {
|
|
11832
12032
|
if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {
|
|
11833
12033
|
return false;
|
|
@@ -12060,7 +12260,6 @@
|
|
|
12060
12260
|
}
|
|
12061
12261
|
}
|
|
12062
12262
|
|
|
12063
|
-
/* */
|
|
12064
12263
|
const factors = {
|
|
12065
12264
|
kilometers: 1,
|
|
12066
12265
|
miles: 1000 / 1609.344,
|
|
@@ -12080,13 +12279,6 @@
|
|
|
12080
12279
|
const RAD = Math.PI / 180;
|
|
12081
12280
|
/**
|
|
12082
12281
|
* A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.
|
|
12083
|
-
*
|
|
12084
|
-
* @param {number} lat latitude
|
|
12085
|
-
* @param {string} [units='kilometers']
|
|
12086
|
-
* @returns {CheapRuler}
|
|
12087
|
-
* @example
|
|
12088
|
-
* const ruler = cheapRuler(35.05, 'miles');
|
|
12089
|
-
* //=ruler
|
|
12090
12282
|
*/
|
|
12091
12283
|
class CheapRuler {
|
|
12092
12284
|
/**
|
|
@@ -12094,7 +12286,7 @@
|
|
|
12094
12286
|
*
|
|
12095
12287
|
* @param {number} y
|
|
12096
12288
|
* @param {number} z
|
|
12097
|
-
* @param {
|
|
12289
|
+
* @param {keyof typeof factors} [units='kilometers']
|
|
12098
12290
|
* @returns {CheapRuler}
|
|
12099
12291
|
* @example
|
|
12100
12292
|
* const ruler = cheapRuler.fromTile(1567, 12);
|
|
@@ -12119,8 +12311,7 @@
|
|
|
12119
12311
|
* Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
|
|
12120
12312
|
*
|
|
12121
12313
|
* @param {number} lat latitude
|
|
12122
|
-
* @param {
|
|
12123
|
-
* @returns {CheapRuler}
|
|
12314
|
+
* @param {keyof typeof factors} [units='kilometers']
|
|
12124
12315
|
* @example
|
|
12125
12316
|
* const ruler = cheapRuler(35.05, 'miles');
|
|
12126
12317
|
* //=ruler
|
|
@@ -12143,8 +12334,8 @@
|
|
|
12143
12334
|
/**
|
|
12144
12335
|
* Given two points of the form [longitude, latitude], returns the distance.
|
|
12145
12336
|
*
|
|
12146
|
-
* @param {
|
|
12147
|
-
* @param {
|
|
12337
|
+
* @param {[number, number]} a point [longitude, latitude]
|
|
12338
|
+
* @param {[number, number]} b point [longitude, latitude]
|
|
12148
12339
|
* @returns {number} distance
|
|
12149
12340
|
* @example
|
|
12150
12341
|
* const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
|
|
@@ -12158,8 +12349,8 @@
|
|
|
12158
12349
|
/**
|
|
12159
12350
|
* Returns the bearing between two points in angles.
|
|
12160
12351
|
*
|
|
12161
|
-
* @param {
|
|
12162
|
-
* @param {
|
|
12352
|
+
* @param {[number, number]} a point [longitude, latitude]
|
|
12353
|
+
* @param {[number, number]} b point [longitude, latitude]
|
|
12163
12354
|
* @returns {number} bearing
|
|
12164
12355
|
* @example
|
|
12165
12356
|
* const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
|
|
@@ -12173,10 +12364,10 @@
|
|
|
12173
12364
|
/**
|
|
12174
12365
|
* Returns a new point given distance and bearing from the starting point.
|
|
12175
12366
|
*
|
|
12176
|
-
* @param {
|
|
12367
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
12177
12368
|
* @param {number} dist distance
|
|
12178
12369
|
* @param {number} bearing
|
|
12179
|
-
* @returns {
|
|
12370
|
+
* @returns {[number, number]} point [longitude, latitude]
|
|
12180
12371
|
* @example
|
|
12181
12372
|
* const point = ruler.destination([30.5, 50.5], 0.1, 90);
|
|
12182
12373
|
* //=point
|
|
@@ -12188,10 +12379,10 @@
|
|
|
12188
12379
|
/**
|
|
12189
12380
|
* Returns a new point given easting and northing offsets (in ruler units) from the starting point.
|
|
12190
12381
|
*
|
|
12191
|
-
* @param {
|
|
12382
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
12192
12383
|
* @param {number} dx easting
|
|
12193
12384
|
* @param {number} dy northing
|
|
12194
|
-
* @returns {
|
|
12385
|
+
* @returns {[number, number]} point [longitude, latitude]
|
|
12195
12386
|
* @example
|
|
12196
12387
|
* const point = ruler.offset([30.5, 50.5], 10, 10);
|
|
12197
12388
|
* //=point
|
|
@@ -12205,7 +12396,7 @@
|
|
|
12205
12396
|
/**
|
|
12206
12397
|
* Given a line (an array of points), returns the total line distance.
|
|
12207
12398
|
*
|
|
12208
|
-
* @param {
|
|
12399
|
+
* @param {[number, number][]} points [longitude, latitude]
|
|
12209
12400
|
* @returns {number} total line distance
|
|
12210
12401
|
* @example
|
|
12211
12402
|
* const length = ruler.lineDistance([
|
|
@@ -12224,7 +12415,7 @@
|
|
|
12224
12415
|
/**
|
|
12225
12416
|
* Given a polygon (an array of rings, where each ring is an array of points), returns the area.
|
|
12226
12417
|
*
|
|
12227
|
-
* @param {
|
|
12418
|
+
* @param {[number, number][][]} polygon
|
|
12228
12419
|
* @returns {number} area value in the specified units (square kilometers by default)
|
|
12229
12420
|
* @example
|
|
12230
12421
|
* const area = ruler.area([[
|
|
@@ -12246,9 +12437,9 @@
|
|
|
12246
12437
|
/**
|
|
12247
12438
|
* Returns the point at a specified distance along the line.
|
|
12248
12439
|
*
|
|
12249
|
-
* @param {
|
|
12440
|
+
* @param {[number, number][]} line
|
|
12250
12441
|
* @param {number} dist distance
|
|
12251
|
-
* @returns {
|
|
12442
|
+
* @returns {[number, number]} point [longitude, latitude]
|
|
12252
12443
|
* @example
|
|
12253
12444
|
* const point = ruler.along(line, 2.5);
|
|
12254
12445
|
* //=point
|
|
@@ -12263,7 +12454,7 @@
|
|
|
12263
12454
|
const d = this.distance(p0, p1);
|
|
12264
12455
|
sum += d;
|
|
12265
12456
|
if (sum > dist)
|
|
12266
|
-
return interpolate
|
|
12457
|
+
return interpolate(p0, p1, (dist - (sum - d)) / d);
|
|
12267
12458
|
}
|
|
12268
12459
|
return line[line.length - 1];
|
|
12269
12460
|
}
|
|
@@ -12271,9 +12462,9 @@
|
|
|
12271
12462
|
* Returns the distance from a point `p` to a line segment `a` to `b`.
|
|
12272
12463
|
*
|
|
12273
12464
|
* @pointToSegmentDistance
|
|
12274
|
-
* @param {
|
|
12275
|
-
* @param {
|
|
12276
|
-
* @param {
|
|
12465
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
12466
|
+
* @param {[number, number]} a segment point 1 [longitude, latitude]
|
|
12467
|
+
* @param {[number, number]} b segment point 2 [longitude, latitude]
|
|
12277
12468
|
* @returns {number} distance
|
|
12278
12469
|
* @example
|
|
12279
12470
|
* const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
|
|
@@ -12283,9 +12474,8 @@
|
|
|
12283
12474
|
let [x, y] = a;
|
|
12284
12475
|
let dx = wrap(b[0] - x) * this.kx;
|
|
12285
12476
|
let dy = (b[1] - y) * this.ky;
|
|
12286
|
-
let t = 0;
|
|
12287
12477
|
if (dx !== 0 || dy !== 0) {
|
|
12288
|
-
t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
12478
|
+
const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
|
|
12289
12479
|
if (t > 1) {
|
|
12290
12480
|
x = b[0];
|
|
12291
12481
|
y = b[1];
|
|
@@ -12303,16 +12493,19 @@
|
|
|
12303
12493
|
* from the given point, index is the start index of the segment with the closest point,
|
|
12304
12494
|
* and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
|
|
12305
12495
|
*
|
|
12306
|
-
* @param {
|
|
12307
|
-
* @param {
|
|
12308
|
-
* @returns {
|
|
12496
|
+
* @param {[number, number][]} line
|
|
12497
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
12498
|
+
* @returns {{point: [number, number], index: number, t: number}} {point, index, t}
|
|
12309
12499
|
* @example
|
|
12310
12500
|
* const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
|
|
12311
12501
|
* //=point
|
|
12312
12502
|
*/
|
|
12313
12503
|
pointOnLine(line, p) {
|
|
12314
12504
|
let minDist = Infinity;
|
|
12315
|
-
let minX
|
|
12505
|
+
let minX = line[0][0];
|
|
12506
|
+
let minY = line[0][1];
|
|
12507
|
+
let minI = 0;
|
|
12508
|
+
let minT = 0;
|
|
12316
12509
|
for (let i = 0; i < line.length - 1; i++) {
|
|
12317
12510
|
let x = line[i][0];
|
|
12318
12511
|
let y = line[i][1];
|
|
@@ -12352,10 +12545,10 @@
|
|
|
12352
12545
|
/**
|
|
12353
12546
|
* Returns a part of the given line between the start and the stop points (or their closest points on the line).
|
|
12354
12547
|
*
|
|
12355
|
-
* @param {
|
|
12356
|
-
* @param {
|
|
12357
|
-
* @param {
|
|
12358
|
-
* @returns {
|
|
12548
|
+
* @param {[number, number]} start point [longitude, latitude]
|
|
12549
|
+
* @param {[number, number]} stop point [longitude, latitude]
|
|
12550
|
+
* @param {[number, number][]} line
|
|
12551
|
+
* @returns {[number, number][]} line part of a line
|
|
12359
12552
|
* @example
|
|
12360
12553
|
* const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
|
|
12361
12554
|
* //=line2
|
|
@@ -12383,10 +12576,10 @@
|
|
|
12383
12576
|
/**
|
|
12384
12577
|
* Returns a part of the given line between the start and the stop points indicated by distance along the line.
|
|
12385
12578
|
*
|
|
12386
|
-
* @param {number} start distance
|
|
12387
|
-
* @param {number} stop distance
|
|
12388
|
-
* @param {
|
|
12389
|
-
* @returns {
|
|
12579
|
+
* @param {number} start start distance
|
|
12580
|
+
* @param {number} stop stop distance
|
|
12581
|
+
* @param {[number, number][]} line
|
|
12582
|
+
* @returns {[number, number][]} part of a line
|
|
12390
12583
|
* @example
|
|
12391
12584
|
* const line2 = ruler.lineSliceAlong(10, 20, line1);
|
|
12392
12585
|
* //=line2
|
|
@@ -12400,10 +12593,10 @@
|
|
|
12400
12593
|
const d = this.distance(p0, p1);
|
|
12401
12594
|
sum += d;
|
|
12402
12595
|
if (sum > start && slice.length === 0) {
|
|
12403
|
-
slice.push(interpolate
|
|
12596
|
+
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
|
|
12404
12597
|
}
|
|
12405
12598
|
if (sum >= stop) {
|
|
12406
|
-
slice.push(interpolate
|
|
12599
|
+
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
|
|
12407
12600
|
return slice;
|
|
12408
12601
|
}
|
|
12409
12602
|
if (sum > start)
|
|
@@ -12414,9 +12607,9 @@
|
|
|
12414
12607
|
/**
|
|
12415
12608
|
* Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
|
|
12416
12609
|
*
|
|
12417
|
-
* @param {
|
|
12610
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
12418
12611
|
* @param {number} buffer
|
|
12419
|
-
* @returns {
|
|
12612
|
+
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
12420
12613
|
* @example
|
|
12421
12614
|
* const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
|
|
12422
12615
|
* //=bbox
|
|
@@ -12434,9 +12627,9 @@
|
|
|
12434
12627
|
/**
|
|
12435
12628
|
* Given a bounding box, returns the box buffered by a given distance.
|
|
12436
12629
|
*
|
|
12437
|
-
* @param {
|
|
12630
|
+
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
12438
12631
|
* @param {number} buffer
|
|
12439
|
-
* @returns {
|
|
12632
|
+
* @returns {[number, number, number, number]} bbox ([w, s, e, n])
|
|
12440
12633
|
* @example
|
|
12441
12634
|
* const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
|
|
12442
12635
|
* //=bbox
|
|
@@ -12454,21 +12647,32 @@
|
|
|
12454
12647
|
/**
|
|
12455
12648
|
* Returns true if the given point is inside in the given bounding box, otherwise false.
|
|
12456
12649
|
*
|
|
12457
|
-
* @param {
|
|
12458
|
-
* @param {
|
|
12650
|
+
* @param {[number, number]} p point [longitude, latitude]
|
|
12651
|
+
* @param {[number, number, number, number]} bbox ([w, s, e, n])
|
|
12459
12652
|
* @returns {boolean}
|
|
12460
12653
|
* @example
|
|
12461
12654
|
* const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
|
|
12462
12655
|
* //=inside
|
|
12463
12656
|
*/
|
|
12464
12657
|
insideBBox(p, bbox) {
|
|
12658
|
+
// eslint-disable-line
|
|
12465
12659
|
return wrap(p[0] - bbox[0]) >= 0 && wrap(p[0] - bbox[2]) <= 0 && p[1] >= bbox[1] && p[1] <= bbox[3];
|
|
12466
12660
|
}
|
|
12467
12661
|
}
|
|
12662
|
+
/**
|
|
12663
|
+
* @param {[number, number]} a
|
|
12664
|
+
* @param {[number, number]} b
|
|
12665
|
+
*/
|
|
12468
12666
|
function equals(a, b) {
|
|
12469
12667
|
return a[0] === b[0] && a[1] === b[1];
|
|
12470
12668
|
}
|
|
12471
|
-
|
|
12669
|
+
/**
|
|
12670
|
+
* @param {[number, number]} a
|
|
12671
|
+
* @param {[number, number]} b
|
|
12672
|
+
* @param {number} t
|
|
12673
|
+
* @returns {[number, number]}
|
|
12674
|
+
*/
|
|
12675
|
+
function interpolate(a, b, t) {
|
|
12472
12676
|
const dx = wrap(b[0] - a[0]);
|
|
12473
12677
|
const dy = b[1] - a[1];
|
|
12474
12678
|
return [
|
|
@@ -12476,7 +12680,10 @@
|
|
|
12476
12680
|
a[1] + dy * t
|
|
12477
12681
|
];
|
|
12478
12682
|
}
|
|
12479
|
-
|
|
12683
|
+
/**
|
|
12684
|
+
* normalize a degree value into [-180..180] range
|
|
12685
|
+
* @param {number} deg
|
|
12686
|
+
*/
|
|
12480
12687
|
function wrap(deg) {
|
|
12481
12688
|
while (deg < -180)
|
|
12482
12689
|
deg += 360;
|
|
@@ -12841,26 +13048,8 @@
|
|
|
12841
13048
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
12842
13049
|
}
|
|
12843
13050
|
|
|
12844
|
-
//
|
|
12845
|
-
/**
|
|
12846
|
-
* The maximum value of a coordinate in the internal tile coordinate system. Coordinates of
|
|
12847
|
-
* all source features normalized to this extent upon load.
|
|
12848
|
-
*
|
|
12849
|
-
* The value is a consequence of the following:
|
|
12850
|
-
*
|
|
12851
|
-
* * Vertex buffer store positions as signed 16 bit integers.
|
|
12852
|
-
* * One bit is lost for signedness to support tile buffers.
|
|
12853
|
-
* * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.
|
|
12854
|
-
* * One bit is lost to support features extending past the extent on the right edge of the tile.
|
|
12855
|
-
* * This leaves us with 2^13 = 8192
|
|
12856
|
-
*
|
|
12857
|
-
* @private
|
|
12858
|
-
* @readonly
|
|
12859
|
-
*/
|
|
12860
13051
|
var EXTENT = 8192;
|
|
12861
13052
|
|
|
12862
|
-
//
|
|
12863
|
-
// Inclusive index range for multipoint or linestring container
|
|
12864
13053
|
function compareMax(a, b) {
|
|
12865
13054
|
return b.dist - a.dist;
|
|
12866
13055
|
}
|
|
@@ -12893,9 +13082,6 @@
|
|
|
12893
13082
|
}
|
|
12894
13083
|
return ret;
|
|
12895
13084
|
}
|
|
12896
|
-
// Split the point set(points or linestring) into two halves, using IndexRange to do in-place splitting.
|
|
12897
|
-
// If geometry is a line, the last point(here is the second index) of range1 needs to be included as the first point(here is the first index) of range2.
|
|
12898
|
-
// If geometry are points, just split the points equally(if possible) into two new point sets(here are two index ranges).
|
|
12899
13085
|
function splitRange(range, isLine) {
|
|
12900
13086
|
if (range[0] > range[1])
|
|
12901
13087
|
return [
|
|
@@ -12973,28 +13159,21 @@
|
|
|
12973
13159
|
}
|
|
12974
13160
|
return bbox;
|
|
12975
13161
|
}
|
|
12976
|
-
// Calculate the distance between two bounding boxes.
|
|
12977
|
-
// Calculate the delta in x and y direction, and use two fake points {0.0, 0.0} and {dx, dy} to calculate the distance.
|
|
12978
|
-
// Distance will be 0.0 if bounding box are overlapping.
|
|
12979
13162
|
function bboxToBBoxDistance(bbox1, bbox2, ruler) {
|
|
12980
13163
|
if (isDefaultBBOX(bbox1) || isDefaultBBOX(bbox2)) {
|
|
12981
13164
|
return NaN;
|
|
12982
13165
|
}
|
|
12983
13166
|
let dx = 0;
|
|
12984
13167
|
let dy = 0;
|
|
12985
|
-
// bbox1 in left side
|
|
12986
13168
|
if (bbox1[2] < bbox2[0]) {
|
|
12987
13169
|
dx = bbox2[0] - bbox1[2];
|
|
12988
13170
|
}
|
|
12989
|
-
// bbox1 in right side
|
|
12990
13171
|
if (bbox1[0] > bbox2[2]) {
|
|
12991
13172
|
dx = bbox1[0] - bbox2[2];
|
|
12992
13173
|
}
|
|
12993
|
-
// bbox1 in above side
|
|
12994
13174
|
if (bbox1[1] > bbox2[3]) {
|
|
12995
13175
|
dy = bbox1[1] - bbox2[3];
|
|
12996
13176
|
}
|
|
12997
|
-
// bbox1 in down side
|
|
12998
13177
|
if (bbox1[3] < bbox2[1]) {
|
|
12999
13178
|
dy = bbox2[1] - bbox1[3];
|
|
13000
13179
|
}
|
|
@@ -13042,10 +13221,13 @@
|
|
|
13042
13221
|
}
|
|
13043
13222
|
return dist;
|
|
13044
13223
|
}
|
|
13045
|
-
// precondition is two segments are not intersecting with each other
|
|
13046
13224
|
function segmentToSegmentDistance(p1, p2, q1, q2, ruler) {
|
|
13047
|
-
const dist1 = Math.min(
|
|
13048
|
-
|
|
13225
|
+
const dist1 = Math.min(// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
13226
|
+
ruler.pointToSegmentDistance(p1, q1, q2), // @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
13227
|
+
ruler.pointToSegmentDistance(p2, q1, q2));
|
|
13228
|
+
const dist2 = Math.min(// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
13229
|
+
ruler.pointToSegmentDistance(q1, p1, p2), // @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
|
|
13230
|
+
ruler.pointToSegmentDistance(q2, p1, p2));
|
|
13049
13231
|
return Math.min(dist1, dist2);
|
|
13050
13232
|
}
|
|
13051
13233
|
function lineToLineDistance(line1, range1, line2, range2, ruler) {
|
|
@@ -13153,7 +13335,6 @@
|
|
|
13153
13335
|
if (r1 === null || r2 === null)
|
|
13154
13336
|
return;
|
|
13155
13337
|
const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), ruler);
|
|
13156
|
-
// Insert new pair to the queue if the bbox distance is less than miniDist, the pair with biggest distance will be at the top
|
|
13157
13338
|
if (tempDist < miniDist)
|
|
13158
13339
|
distQueue.push({
|
|
13159
13340
|
dist: tempDist,
|
|
@@ -13161,8 +13342,6 @@
|
|
|
13161
13342
|
range2: r2
|
|
13162
13343
|
});
|
|
13163
13344
|
}
|
|
13164
|
-
// Divide and conquer, the time complexity is O(n*lgn), faster than Brute force O(n*n)
|
|
13165
|
-
// Most of the time, use index for in-place processing.
|
|
13166
13345
|
function pointSetToPolygonDistance(pointSets, isLine, polygon, ruler, currentMiniDist = Infinity) {
|
|
13167
13346
|
let miniDist = Math.min(ruler.distance(pointSets[0], polygon[0][0]), currentMiniDist);
|
|
13168
13347
|
if (miniDist === 0)
|
|
@@ -13186,7 +13365,6 @@
|
|
|
13186
13365
|
if (distPair.dist >= miniDist)
|
|
13187
13366
|
continue;
|
|
13188
13367
|
const range = distPair.range1;
|
|
13189
|
-
// In case the set size are relatively small, we could use brute-force directly
|
|
13190
13368
|
if (getRangeSize(range) <= setThreshold) {
|
|
13191
13369
|
if (!isRangeSafe(range, pointSets.length))
|
|
13192
13370
|
return NaN;
|
|
@@ -13255,7 +13433,6 @@
|
|
|
13255
13433
|
continue;
|
|
13256
13434
|
const rangeA = distPair.range1;
|
|
13257
13435
|
const rangeB = distPair.range2;
|
|
13258
|
-
// In case the set size are relatively small, we could use brute-force directly
|
|
13259
13436
|
if (getRangeSize(rangeA) <= set1Threshold && getRangeSize(rangeB) <= set2Threshold) {
|
|
13260
13437
|
if (!isRangeSafe(rangeA, pointSet1.length) || !isRangeSafe(rangeB, pointSet2.length)) {
|
|
13261
13438
|
return NaN;
|
|
@@ -13294,7 +13471,7 @@
|
|
|
13294
13471
|
line.length - 1
|
|
13295
13472
|
]), ruler) >= dist)
|
|
13296
13473
|
continue;
|
|
13297
|
-
dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true
|
|
13474
|
+
dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true, ruler, dist));
|
|
13298
13475
|
if (dist === 0)
|
|
13299
13476
|
return dist;
|
|
13300
13477
|
}
|
|
@@ -13339,13 +13516,13 @@
|
|
|
13339
13516
|
}
|
|
13340
13517
|
const ruler = new CheapRuler(lngLatPoints[0][1], 'meters');
|
|
13341
13518
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
13342
|
-
return pointSetsDistance(lngLatPoints, false
|
|
13519
|
+
return pointSetsDistance(lngLatPoints, false, geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', ruler);
|
|
13343
13520
|
}
|
|
13344
13521
|
if (geometry.type === 'MultiLineString') {
|
|
13345
|
-
return pointSetToLinesDistance(lngLatPoints, false
|
|
13522
|
+
return pointSetToLinesDistance(lngLatPoints, false, geometry.coordinates, ruler);
|
|
13346
13523
|
}
|
|
13347
13524
|
if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
|
|
13348
|
-
return pointSetToPolygonsDistance(lngLatPoints, false
|
|
13525
|
+
return pointSetToPolygonsDistance(lngLatPoints, false, geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, ruler);
|
|
13349
13526
|
}
|
|
13350
13527
|
return null;
|
|
13351
13528
|
}
|
|
@@ -13360,12 +13537,12 @@
|
|
|
13360
13537
|
}
|
|
13361
13538
|
const ruler = new CheapRuler(lngLatLines[0][0][1], 'meters');
|
|
13362
13539
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
13363
|
-
return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString'
|
|
13540
|
+
return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatLines, ruler);
|
|
13364
13541
|
}
|
|
13365
13542
|
if (geometry.type === 'MultiLineString') {
|
|
13366
13543
|
let dist = Infinity;
|
|
13367
13544
|
for (let i = 0; i < geometry.coordinates.length; i++) {
|
|
13368
|
-
const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true
|
|
13545
|
+
const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true, lngLatLines, ruler, dist);
|
|
13369
13546
|
if (isNaN(tempDist))
|
|
13370
13547
|
return tempDist;
|
|
13371
13548
|
if ((dist = Math.min(dist, tempDist)) === 0)
|
|
@@ -13376,7 +13553,7 @@
|
|
|
13376
13553
|
if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
|
|
13377
13554
|
let dist = Infinity;
|
|
13378
13555
|
for (let i = 0; i < lngLatLines.length; i++) {
|
|
13379
|
-
const tempDist = pointSetToPolygonsDistance(lngLatLines[i], true
|
|
13556
|
+
const tempDist = pointSetToPolygonsDistance(lngLatLines[i], true, geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, ruler, dist);
|
|
13380
13557
|
if (isNaN(tempDist))
|
|
13381
13558
|
return tempDist;
|
|
13382
13559
|
if ((dist = Math.min(dist, tempDist)) === 0)
|
|
@@ -13397,12 +13574,12 @@
|
|
|
13397
13574
|
}
|
|
13398
13575
|
const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], 'meters');
|
|
13399
13576
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
13400
|
-
return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString'
|
|
13577
|
+
return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatPolygons, ruler);
|
|
13401
13578
|
}
|
|
13402
13579
|
if (geometry.type === 'MultiLineString') {
|
|
13403
13580
|
let dist = Infinity;
|
|
13404
13581
|
for (let i = 0; i < geometry.coordinates.length; i++) {
|
|
13405
|
-
const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true
|
|
13582
|
+
const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true, lngLatPolygons, ruler, dist);
|
|
13406
13583
|
if (isNaN(tempDist))
|
|
13407
13584
|
return tempDist;
|
|
13408
13585
|
if ((dist = Math.min(dist, tempDist)) === 0)
|
|
@@ -13478,7 +13655,6 @@
|
|
|
13478
13655
|
}
|
|
13479
13656
|
}
|
|
13480
13657
|
|
|
13481
|
-
//
|
|
13482
13658
|
function coerceValue(type, value) {
|
|
13483
13659
|
switch (type) {
|
|
13484
13660
|
case 'string':
|
|
@@ -13488,7 +13664,7 @@
|
|
|
13488
13664
|
case 'boolean':
|
|
13489
13665
|
return !!value;
|
|
13490
13666
|
case 'color':
|
|
13491
|
-
return Color
|
|
13667
|
+
return Color.parse(value);
|
|
13492
13668
|
case 'formatted': {
|
|
13493
13669
|
return Formatted.fromString(toString(value));
|
|
13494
13670
|
}
|
|
@@ -13499,13 +13675,13 @@
|
|
|
13499
13675
|
return value;
|
|
13500
13676
|
}
|
|
13501
13677
|
function clampToAllowedNumber(value, min, max, step) {
|
|
13502
|
-
if (step !==
|
|
13678
|
+
if (step !== void 0) {
|
|
13503
13679
|
value = step * Math.round(value / step);
|
|
13504
13680
|
}
|
|
13505
|
-
if (min !==
|
|
13681
|
+
if (min !== void 0 && value < min) {
|
|
13506
13682
|
value = min;
|
|
13507
13683
|
}
|
|
13508
|
-
if (max !==
|
|
13684
|
+
if (max !== void 0 && value > max) {
|
|
13509
13685
|
value = max;
|
|
13510
13686
|
}
|
|
13511
13687
|
return value;
|
|
@@ -13518,7 +13694,7 @@
|
|
|
13518
13694
|
}
|
|
13519
13695
|
static parse(args, context) {
|
|
13520
13696
|
let type = context.expectedType;
|
|
13521
|
-
if (type === null || type ===
|
|
13697
|
+
if (type === null || type === void 0) {
|
|
13522
13698
|
type = ValueType;
|
|
13523
13699
|
}
|
|
13524
13700
|
if (args.length < 2 || args.length > 3) {
|
|
@@ -13551,7 +13727,6 @@
|
|
|
13551
13727
|
const defaultValue = config.default.evaluate(ctx);
|
|
13552
13728
|
let result = defaultValue;
|
|
13553
13729
|
if (value) {
|
|
13554
|
-
// temporarily override scope to parent to evaluate config expressions passed from the parent
|
|
13555
13730
|
const originalScope = ctx.scope;
|
|
13556
13731
|
ctx.scope = (originalScope || '').split(FQIDSeparator).slice(1).join(FQIDSeparator);
|
|
13557
13732
|
result = value.evaluate(ctx);
|
|
@@ -13560,21 +13735,20 @@
|
|
|
13560
13735
|
if (type) {
|
|
13561
13736
|
result = coerceValue(type, result);
|
|
13562
13737
|
}
|
|
13563
|
-
if (result !==
|
|
13738
|
+
if (result !== void 0 && (minValue !== void 0 || maxValue !== void 0 || stepValue !== void 0)) {
|
|
13564
13739
|
if (typeof result === 'number') {
|
|
13565
13740
|
result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
|
|
13566
13741
|
} else if (Array.isArray(result)) {
|
|
13567
13742
|
result = result.map(item => typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
|
|
13568
13743
|
}
|
|
13569
13744
|
}
|
|
13570
|
-
if (value !==
|
|
13571
|
-
// The result is not among the allowed values. Instead, use the default value from the option.
|
|
13745
|
+
if (value !== void 0 && result !== void 0 && values && !values.includes(result)) {
|
|
13572
13746
|
result = defaultValue;
|
|
13573
13747
|
if (type) {
|
|
13574
13748
|
result = coerceValue(type, result);
|
|
13575
13749
|
}
|
|
13576
13750
|
}
|
|
13577
|
-
if (type && type !== this.type || result !==
|
|
13751
|
+
if (type && type !== this.type || result !== void 0 && typeOf(result) !== this.type) {
|
|
13578
13752
|
result = coerceValue(this.type.kind, result);
|
|
13579
13753
|
}
|
|
13580
13754
|
return result;
|
|
@@ -13596,7 +13770,6 @@
|
|
|
13596
13770
|
}
|
|
13597
13771
|
}
|
|
13598
13772
|
|
|
13599
|
-
//
|
|
13600
13773
|
function isFeatureConstant(e) {
|
|
13601
13774
|
if (e instanceof CompoundExpression) {
|
|
13602
13775
|
if (e.name === 'get' && e.args.length === 1) {
|
|
@@ -13664,7 +13837,6 @@
|
|
|
13664
13837
|
return result;
|
|
13665
13838
|
}
|
|
13666
13839
|
|
|
13667
|
-
//
|
|
13668
13840
|
class Var {
|
|
13669
13841
|
constructor(name, boundExpression) {
|
|
13670
13842
|
this.type = boundExpression.type;
|
|
@@ -13696,16 +13868,7 @@
|
|
|
13696
13868
|
}
|
|
13697
13869
|
}
|
|
13698
13870
|
|
|
13699
|
-
//
|
|
13700
|
-
/**
|
|
13701
|
-
* State associated parsing at a given point in an expression tree.
|
|
13702
|
-
* @private
|
|
13703
|
-
*/
|
|
13704
13871
|
class ParsingContext {
|
|
13705
|
-
// The expected type of this expression. Provided only to allow Expression
|
|
13706
|
-
// implementations to infer argument types: Expression#parse() need not
|
|
13707
|
-
// check that the output type of the parsed expression matches
|
|
13708
|
-
// `expectedType`.
|
|
13709
13872
|
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options) {
|
|
13710
13873
|
this.registry = registry;
|
|
13711
13874
|
this.path = path;
|
|
@@ -13717,12 +13880,12 @@
|
|
|
13717
13880
|
this.options = options;
|
|
13718
13881
|
}
|
|
13719
13882
|
/**
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13883
|
+
* @param expr the JSON expression to parse
|
|
13884
|
+
* @param index the optional argument index if this expression is an argument of a parent expression that's being parsed
|
|
13885
|
+
* @param options
|
|
13886
|
+
* @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.
|
|
13887
|
+
* @private
|
|
13888
|
+
*/
|
|
13726
13889
|
parse(expr, index, expectedType, bindings, options = {}) {
|
|
13727
13890
|
if (index || expectedType) {
|
|
13728
13891
|
return this.concat(index, expectedType, bindings)._parse(expr, options);
|
|
@@ -13749,7 +13912,7 @@
|
|
|
13749
13912
|
if (expr.length === 0) {
|
|
13750
13913
|
return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);
|
|
13751
13914
|
}
|
|
13752
|
-
const Expr = typeof expr[0] === 'string' ? this.registry[expr[0]] :
|
|
13915
|
+
const Expr = typeof expr[0] === 'string' ? this.registry[expr[0]] : void 0;
|
|
13753
13916
|
if (Expr) {
|
|
13754
13917
|
let parsed = Expr.parse(expr, this);
|
|
13755
13918
|
if (!parsed)
|
|
@@ -13757,14 +13920,6 @@
|
|
|
13757
13920
|
if (this.expectedType) {
|
|
13758
13921
|
const expected = this.expectedType;
|
|
13759
13922
|
const actual = parsed.type;
|
|
13760
|
-
// When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.
|
|
13761
|
-
// When we expect a color or formatted string, but have a string or value, wrap it in a coercion.
|
|
13762
|
-
// Otherwise, we do static type-checking.
|
|
13763
|
-
//
|
|
13764
|
-
// These behaviors are overridable for:
|
|
13765
|
-
// * The "coalesce" operator, which needs to omit type annotations.
|
|
13766
|
-
// * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.
|
|
13767
|
-
//
|
|
13768
13923
|
if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {
|
|
13769
13924
|
parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');
|
|
13770
13925
|
} else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {
|
|
@@ -13773,10 +13928,6 @@
|
|
|
13773
13928
|
return null;
|
|
13774
13929
|
}
|
|
13775
13930
|
}
|
|
13776
|
-
// If an expression's arguments are all literals, we can evaluate
|
|
13777
|
-
// it immediately and replace it with a literal value in the
|
|
13778
|
-
// parsed/compiled result. Expressions that expect an image should
|
|
13779
|
-
// not be resolved here so we can later get the available images.
|
|
13780
13931
|
if (!(parsed instanceof Literal) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
|
|
13781
13932
|
const ec = new EvaluationContext(this._scope, this.options);
|
|
13782
13933
|
try {
|
|
@@ -13788,7 +13939,6 @@
|
|
|
13788
13939
|
}
|
|
13789
13940
|
return parsed;
|
|
13790
13941
|
}
|
|
13791
|
-
// Try to parse as array
|
|
13792
13942
|
return Coercion.parse([
|
|
13793
13943
|
'to-array',
|
|
13794
13944
|
expr
|
|
@@ -13802,33 +13952,33 @@
|
|
|
13802
13952
|
}
|
|
13803
13953
|
}
|
|
13804
13954
|
/**
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13955
|
+
* Returns a copy of this context suitable for parsing the subexpression at
|
|
13956
|
+
* index `index`, optionally appending to 'let' binding map.
|
|
13957
|
+
*
|
|
13958
|
+
* Note that `errors` property, intended for collecting errors while
|
|
13959
|
+
* parsing, is copied by reference rather than cloned.
|
|
13960
|
+
* @private
|
|
13961
|
+
*/
|
|
13812
13962
|
concat(index, expectedType, bindings) {
|
|
13813
13963
|
const path = typeof index === 'number' ? this.path.concat(index) : this.path;
|
|
13814
13964
|
const scope = bindings ? this.scope.concat(bindings) : this.scope;
|
|
13815
13965
|
return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options);
|
|
13816
13966
|
}
|
|
13817
13967
|
/**
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13968
|
+
* Push a parsing (or type checking) error into the `this.errors`
|
|
13969
|
+
* @param error The message
|
|
13970
|
+
* @param keys Optionally specify the source of the error at a child
|
|
13971
|
+
* of the current expression at `this.key`.
|
|
13972
|
+
* @private
|
|
13973
|
+
*/
|
|
13824
13974
|
error(error, ...keys) {
|
|
13825
13975
|
const key = `${ this.key }${ keys.map(k => `[${ k }]`).join('') }`;
|
|
13826
13976
|
this.errors.push(new ParsingError$1(key, error));
|
|
13827
13977
|
}
|
|
13828
13978
|
/**
|
|
13829
|
-
|
|
13830
|
-
|
|
13831
|
-
|
|
13979
|
+
* Returns null if `t` is a subtype of `expected`; otherwise returns an
|
|
13980
|
+
* error message and also pushes it to `this.errors`.
|
|
13981
|
+
*/
|
|
13832
13982
|
checkSubtype(expected, t) {
|
|
13833
13983
|
const error = checkSubtype(expected, t);
|
|
13834
13984
|
if (error)
|
|
@@ -13836,15 +13986,13 @@
|
|
|
13836
13986
|
return error;
|
|
13837
13987
|
}
|
|
13838
13988
|
}
|
|
13989
|
+
var ParsingContext$1 = ParsingContext;
|
|
13839
13990
|
function isConstant(expression) {
|
|
13840
13991
|
if (expression instanceof Var) {
|
|
13841
13992
|
return isConstant(expression.boundExpression);
|
|
13842
13993
|
} else if (expression instanceof CompoundExpression && expression.name === 'error') {
|
|
13843
13994
|
return false;
|
|
13844
13995
|
} else if (expression instanceof CollatorExpression) {
|
|
13845
|
-
// Although the results of a Collator expression with fixed arguments
|
|
13846
|
-
// generally shouldn't change between executions, we can't serialize them
|
|
13847
|
-
// as constant expressions because results change based on environment.
|
|
13848
13996
|
return false;
|
|
13849
13997
|
} else if (expression instanceof Within) {
|
|
13850
13998
|
return false;
|
|
@@ -13856,12 +14004,6 @@
|
|
|
13856
14004
|
const isTypeAnnotation = expression instanceof Coercion || expression instanceof Assertion;
|
|
13857
14005
|
let childrenConstant = true;
|
|
13858
14006
|
expression.eachChild(child => {
|
|
13859
|
-
// We can _almost_ assume that if `expressions` children are constant,
|
|
13860
|
-
// they would already have been evaluated to Literal values when they
|
|
13861
|
-
// were parsed. Type annotations are the exception, because they might
|
|
13862
|
-
// have been inferred and added after a child was parsed.
|
|
13863
|
-
// So we recurse into isConstant() for the children of type annotations,
|
|
13864
|
-
// but otherwise simply check whether they are Literals.
|
|
13865
14007
|
if (isTypeAnnotation) {
|
|
13866
14008
|
childrenConstant = childrenConstant && isConstant(child);
|
|
13867
14009
|
} else {
|
|
@@ -13886,11 +14028,6 @@
|
|
|
13886
14028
|
]);
|
|
13887
14029
|
}
|
|
13888
14030
|
|
|
13889
|
-
//
|
|
13890
|
-
/**
|
|
13891
|
-
* Returns the index of the last stop <= input, or 0 if it doesn't exist.
|
|
13892
|
-
* @private
|
|
13893
|
-
*/
|
|
13894
14031
|
function findStopLessThanOrEqualTo(stops, input) {
|
|
13895
14032
|
const lastIndex = stops.length - 1;
|
|
13896
14033
|
let lowerIndex = 0;
|
|
@@ -13903,7 +14040,6 @@
|
|
|
13903
14040
|
nextValue = stops[currentIndex + 1];
|
|
13904
14041
|
if (currentValue <= input) {
|
|
13905
14042
|
if (currentIndex === lastIndex || input < nextValue) {
|
|
13906
|
-
// Search complete
|
|
13907
14043
|
return currentIndex;
|
|
13908
14044
|
}
|
|
13909
14045
|
lowerIndex = currentIndex + 1;
|
|
@@ -13916,7 +14052,6 @@
|
|
|
13916
14052
|
return 0;
|
|
13917
14053
|
}
|
|
13918
14054
|
|
|
13919
|
-
//
|
|
13920
14055
|
class Step {
|
|
13921
14056
|
constructor(type, input, stops) {
|
|
13922
14057
|
this.type = type;
|
|
@@ -14073,32 +14208,7 @@
|
|
|
14073
14208
|
|
|
14074
14209
|
var UnitBezier$1 = /*@__PURE__*/getDefaultExportFromCjs(unitbezier);
|
|
14075
14210
|
|
|
14076
|
-
|
|
14077
|
-
function number(a, b, t) {
|
|
14078
|
-
return a * (1 - t) + b * t;
|
|
14079
|
-
}
|
|
14080
|
-
function color(from, to, t) {
|
|
14081
|
-
return new Color$1(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
|
|
14082
|
-
}
|
|
14083
|
-
function array(from, to, t) {
|
|
14084
|
-
return from.map((d, i) => {
|
|
14085
|
-
return number(d, to[i], t);
|
|
14086
|
-
});
|
|
14087
|
-
}
|
|
14088
|
-
|
|
14089
|
-
var interpolate = /*#__PURE__*/Object.freeze({
|
|
14090
|
-
__proto__: null,
|
|
14091
|
-
array: array,
|
|
14092
|
-
color: color,
|
|
14093
|
-
number: number
|
|
14094
|
-
});
|
|
14095
|
-
|
|
14096
|
-
//
|
|
14097
|
-
// Constants
|
|
14098
|
-
const Xn = 0.95047,
|
|
14099
|
-
// D65 standard referent
|
|
14100
|
-
Yn = 1, Zn = 1.08883, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;
|
|
14101
|
-
// Utilities
|
|
14211
|
+
const Xn = 0.95047, Yn = 1, Zn = 1.08883, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;
|
|
14102
14212
|
function xyz2lab(t) {
|
|
14103
14213
|
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
|
|
14104
14214
|
}
|
|
@@ -14112,7 +14222,6 @@
|
|
|
14112
14222
|
x /= 255;
|
|
14113
14223
|
return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
|
|
14114
14224
|
}
|
|
14115
|
-
// LAB
|
|
14116
14225
|
function rgbToLab(rgbColor) {
|
|
14117
14226
|
const b = rgb2xyz(rgbColor.r), a = rgb2xyz(rgbColor.g), l = rgb2xyz(rgbColor.b), x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn), y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.072175 * l) / Yn), z = xyz2lab((0.0193339 * b + 0.119192 * a + 0.9503041 * l) / Zn);
|
|
14118
14227
|
return {
|
|
@@ -14127,7 +14236,7 @@
|
|
|
14127
14236
|
y = Yn * lab2xyz(y);
|
|
14128
14237
|
x = Xn * lab2xyz(x);
|
|
14129
14238
|
z = Zn * lab2xyz(z);
|
|
14130
|
-
return new Color
|
|
14239
|
+
return new Color(xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
|
|
14131
14240
|
xyz2rgb(-0.969266 * x + 1.8760108 * y + 0.041556 * z), xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z), labColor.alpha);
|
|
14132
14241
|
}
|
|
14133
14242
|
function interpolateLab(from, to, t) {
|
|
@@ -14138,7 +14247,6 @@
|
|
|
14138
14247
|
alpha: number(from.alpha, to.alpha, t)
|
|
14139
14248
|
};
|
|
14140
14249
|
}
|
|
14141
|
-
// HCL
|
|
14142
14250
|
function rgbToHcl(rgbColor) {
|
|
14143
14251
|
const {l, a, b} = rgbToLab(rgbColor);
|
|
14144
14252
|
const h = Math.atan2(b, a) * rad2deg;
|
|
@@ -14187,7 +14295,6 @@
|
|
|
14187
14295
|
lab: lab
|
|
14188
14296
|
});
|
|
14189
14297
|
|
|
14190
|
-
//
|
|
14191
14298
|
class Interpolate {
|
|
14192
14299
|
constructor(type, operator, interpolation, input, stops) {
|
|
14193
14300
|
this.type = type;
|
|
@@ -14236,7 +14343,7 @@
|
|
|
14236
14343
|
}
|
|
14237
14344
|
interpolation = {
|
|
14238
14345
|
name: 'cubic-bezier',
|
|
14239
|
-
controlPoints
|
|
14346
|
+
controlPoints
|
|
14240
14347
|
};
|
|
14241
14348
|
} else {
|
|
14242
14349
|
return context.error(`Unknown interpolation type ${ String(interpolation[0]) }`, 1, 0);
|
|
@@ -14303,7 +14410,7 @@
|
|
|
14303
14410
|
const outputLower = outputs[index].evaluate(ctx);
|
|
14304
14411
|
const outputUpper = outputs[index + 1].evaluate(ctx);
|
|
14305
14412
|
if (this.operator === 'interpolate') {
|
|
14306
|
-
return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
|
|
14413
|
+
return interpolate$1[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
|
|
14307
14414
|
} else if (this.operator === 'interpolate-hcl') {
|
|
14308
14415
|
return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
|
|
14309
14416
|
} else {
|
|
@@ -14346,41 +14453,6 @@
|
|
|
14346
14453
|
return serialized;
|
|
14347
14454
|
}
|
|
14348
14455
|
}
|
|
14349
|
-
/**
|
|
14350
|
-
* Returns a ratio that can be used to interpolate between exponential function
|
|
14351
|
-
* stops.
|
|
14352
|
-
* How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,
|
|
14353
|
-
* and `a` and `b` are constants affording sufficient degrees of freedom to fit
|
|
14354
|
-
* the function to the given stops.
|
|
14355
|
-
*
|
|
14356
|
-
* Here's a bit of algebra that lets us compute `f(x)` directly from the stop
|
|
14357
|
-
* values without explicitly solving for `a` and `b`:
|
|
14358
|
-
*
|
|
14359
|
-
* First stop value: `f(x0) = y0 = a * base^x0 + b`
|
|
14360
|
-
* Second stop value: `f(x1) = y1 = a * base^x1 + b`
|
|
14361
|
-
* => `y1 - y0 = a(base^x1 - base^x0)`
|
|
14362
|
-
* => `a = (y1 - y0)/(base^x1 - base^x0)`
|
|
14363
|
-
*
|
|
14364
|
-
* Desired value: `f(x) = y = a * base^x + b`
|
|
14365
|
-
* => `f(x) = y0 + a * (base^x - base^x0)`
|
|
14366
|
-
*
|
|
14367
|
-
* From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a
|
|
14368
|
-
* little algebra:
|
|
14369
|
-
* ```
|
|
14370
|
-
* a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)
|
|
14371
|
-
* = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)
|
|
14372
|
-
* ```
|
|
14373
|
-
*
|
|
14374
|
-
* If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have
|
|
14375
|
-
* `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as
|
|
14376
|
-
* an interpolation factor between the two stops' output values.
|
|
14377
|
-
*
|
|
14378
|
-
* (Note: a slightly different form for `ratio`,
|
|
14379
|
-
* `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer
|
|
14380
|
-
* expensive `Math.pow()` operations.)
|
|
14381
|
-
*
|
|
14382
|
-
* @private
|
|
14383
|
-
*/
|
|
14384
14456
|
function exponentialInterpolation(input, base, lowerValue, upperValue) {
|
|
14385
14457
|
const difference = upperValue - lowerValue;
|
|
14386
14458
|
const progress = input - lowerValue;
|
|
@@ -14409,17 +14481,12 @@
|
|
|
14409
14481
|
}
|
|
14410
14482
|
const parsedArgs = [];
|
|
14411
14483
|
for (const arg of args.slice(1)) {
|
|
14412
|
-
const parsed = context.parse(arg, 1 + parsedArgs.length, outputType,
|
|
14484
|
+
const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, void 0, { typeAnnotation: 'omit' });
|
|
14413
14485
|
if (!parsed)
|
|
14414
14486
|
return null;
|
|
14415
14487
|
outputType = outputType || parsed.type;
|
|
14416
14488
|
parsedArgs.push(parsed);
|
|
14417
14489
|
}
|
|
14418
|
-
// Above, we parse arguments without inferred type annotation so that
|
|
14419
|
-
// they don't produce a runtime error for `null` input, which would
|
|
14420
|
-
// preempt the desired null-coalescing behavior.
|
|
14421
|
-
// Thus, if any of our arguments would have needed an annotation, we
|
|
14422
|
-
// need to wrap the enclosing coalesce expression with it instead.
|
|
14423
14490
|
const needsAnnotation = expectedType && parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
|
|
14424
14491
|
return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
|
|
14425
14492
|
}
|
|
@@ -14430,15 +14497,11 @@
|
|
|
14430
14497
|
for (const arg of this.args) {
|
|
14431
14498
|
argCount++;
|
|
14432
14499
|
result = arg.evaluate(ctx);
|
|
14433
|
-
// we need to keep track of the first requested image in a coalesce statement
|
|
14434
|
-
// if coalesce can't find a valid image, we return the first image so styleimagemissing can fire
|
|
14435
14500
|
if (result && result instanceof ResolvedImage && !result.available) {
|
|
14436
|
-
// set to first image
|
|
14437
14501
|
if (!firstImage) {
|
|
14438
14502
|
firstImage = result;
|
|
14439
14503
|
}
|
|
14440
14504
|
result = null;
|
|
14441
|
-
// if we reach the end, return the first image
|
|
14442
14505
|
if (argCount === this.args.length) {
|
|
14443
14506
|
return firstImage;
|
|
14444
14507
|
}
|
|
@@ -14463,7 +14526,6 @@
|
|
|
14463
14526
|
}
|
|
14464
14527
|
}
|
|
14465
14528
|
|
|
14466
|
-
//
|
|
14467
14529
|
class Let {
|
|
14468
14530
|
constructor(bindings, result) {
|
|
14469
14531
|
this.type = result.type;
|
|
@@ -14517,7 +14579,6 @@
|
|
|
14517
14579
|
}
|
|
14518
14580
|
}
|
|
14519
14581
|
|
|
14520
|
-
//
|
|
14521
14582
|
class At {
|
|
14522
14583
|
constructor(type, index, input) {
|
|
14523
14584
|
this.type = type;
|
|
@@ -14536,17 +14597,17 @@
|
|
|
14536
14597
|
}
|
|
14537
14598
|
evaluate(ctx) {
|
|
14538
14599
|
const index = this.index.evaluate(ctx);
|
|
14539
|
-
const
|
|
14600
|
+
const array2 = this.input.evaluate(ctx);
|
|
14540
14601
|
if (index < 0) {
|
|
14541
14602
|
throw new RuntimeError(`Array index out of bounds: ${ index } < 0.`);
|
|
14542
14603
|
}
|
|
14543
|
-
if (index >=
|
|
14544
|
-
throw new RuntimeError(`Array index out of bounds: ${ index } > ${
|
|
14604
|
+
if (index >= array2.length) {
|
|
14605
|
+
throw new RuntimeError(`Array index out of bounds: ${ index } > ${ array2.length - 1 }.`);
|
|
14545
14606
|
}
|
|
14546
14607
|
if (index !== Math.floor(index)) {
|
|
14547
14608
|
throw new RuntimeError(`Array index must be an integer, but found ${ index } instead.`);
|
|
14548
14609
|
}
|
|
14549
|
-
return
|
|
14610
|
+
return array2[index];
|
|
14550
14611
|
}
|
|
14551
14612
|
eachChild(fn) {
|
|
14552
14613
|
fn(this.index);
|
|
@@ -14564,7 +14625,6 @@
|
|
|
14564
14625
|
}
|
|
14565
14626
|
}
|
|
14566
14627
|
|
|
14567
|
-
//
|
|
14568
14628
|
class In {
|
|
14569
14629
|
constructor(needle, haystack) {
|
|
14570
14630
|
this.type = BooleanType;
|
|
@@ -14627,7 +14687,6 @@
|
|
|
14627
14687
|
}
|
|
14628
14688
|
}
|
|
14629
14689
|
|
|
14630
|
-
//
|
|
14631
14690
|
class IndexOf {
|
|
14632
14691
|
constructor(needle, haystack, fromIndex) {
|
|
14633
14692
|
this.type = NumberType;
|
|
@@ -14695,7 +14754,7 @@
|
|
|
14695
14754
|
return false;
|
|
14696
14755
|
}
|
|
14697
14756
|
serialize() {
|
|
14698
|
-
if (this.fromIndex != null && this.fromIndex !==
|
|
14757
|
+
if (this.fromIndex != null && this.fromIndex !== void 0) {
|
|
14699
14758
|
const fromIndex = this.fromIndex.serialize();
|
|
14700
14759
|
return [
|
|
14701
14760
|
'index-of',
|
|
@@ -14712,7 +14771,6 @@
|
|
|
14712
14771
|
}
|
|
14713
14772
|
}
|
|
14714
14773
|
|
|
14715
|
-
// Map input label values to output expression index
|
|
14716
14774
|
class Match {
|
|
14717
14775
|
constructor(inputType, outputType, input, cases, outputs, otherwise) {
|
|
14718
14776
|
this.inputType = inputType;
|
|
@@ -14796,35 +14854,26 @@
|
|
|
14796
14854
|
'match',
|
|
14797
14855
|
this.input.serialize()
|
|
14798
14856
|
];
|
|
14799
|
-
// Sort so serialization has an arbitrary defined order, even though
|
|
14800
|
-
// branch order doesn't affect evaluation
|
|
14801
14857
|
const sortedLabels = Object.keys(this.cases).sort();
|
|
14802
|
-
// Group branches by unique match expression to support condensed
|
|
14803
|
-
// serializations of the form [case1, case2, ...] -> matchExpression
|
|
14804
14858
|
const groupedByOutput = [];
|
|
14805
14859
|
const outputLookup = {};
|
|
14806
|
-
// lookup index into groupedByOutput for a given output expression
|
|
14807
14860
|
for (const label of sortedLabels) {
|
|
14808
14861
|
const outputIndex = outputLookup[this.cases[label]];
|
|
14809
|
-
if (outputIndex ===
|
|
14810
|
-
// First time seeing this output, add it to the end of the grouped list
|
|
14862
|
+
if (outputIndex === void 0) {
|
|
14811
14863
|
outputLookup[this.cases[label]] = groupedByOutput.length;
|
|
14812
14864
|
groupedByOutput.push([
|
|
14813
14865
|
this.cases[label],
|
|
14814
14866
|
[label]
|
|
14815
14867
|
]);
|
|
14816
14868
|
} else {
|
|
14817
|
-
// We've seen this expression before, add the label to that output's group
|
|
14818
14869
|
groupedByOutput[outputIndex][1].push(label);
|
|
14819
14870
|
}
|
|
14820
14871
|
}
|
|
14821
14872
|
const coerceLabel = label => this.inputType.kind === 'number' ? Number(label) : label;
|
|
14822
14873
|
for (const [outputIndex, labels] of groupedByOutput) {
|
|
14823
14874
|
if (labels.length === 1) {
|
|
14824
|
-
// Only a single label matches this output expression
|
|
14825
14875
|
serialized.push(coerceLabel(labels[0]));
|
|
14826
14876
|
} else {
|
|
14827
|
-
// Array of literal labels pointing to this output expression
|
|
14828
14877
|
serialized.push(labels.map(coerceLabel));
|
|
14829
14878
|
}
|
|
14830
14879
|
serialized.push(this.outputs[outputIndex].serialize());
|
|
@@ -14895,7 +14944,6 @@
|
|
|
14895
14944
|
}
|
|
14896
14945
|
}
|
|
14897
14946
|
|
|
14898
|
-
//
|
|
14899
14947
|
class Slice {
|
|
14900
14948
|
constructor(type, input, beginIndex, endIndex) {
|
|
14901
14949
|
this.type = type;
|
|
@@ -14953,7 +15001,7 @@
|
|
|
14953
15001
|
return false;
|
|
14954
15002
|
}
|
|
14955
15003
|
serialize() {
|
|
14956
|
-
if (this.endIndex != null && this.endIndex !==
|
|
15004
|
+
if (this.endIndex != null && this.endIndex !== void 0) {
|
|
14957
15005
|
const endIndex = this.endIndex.serialize();
|
|
14958
15006
|
return [
|
|
14959
15007
|
'slice',
|
|
@@ -14970,13 +15018,10 @@
|
|
|
14970
15018
|
}
|
|
14971
15019
|
}
|
|
14972
15020
|
|
|
14973
|
-
//
|
|
14974
15021
|
function isComparableType(op, type) {
|
|
14975
15022
|
if (op === '==' || op === '!=') {
|
|
14976
|
-
// equality operator
|
|
14977
15023
|
return type.kind === 'boolean' || type.kind === 'string' || type.kind === 'number' || type.kind === 'null' || type.kind === 'value';
|
|
14978
15024
|
} else {
|
|
14979
|
-
// ordering operator
|
|
14980
15025
|
return type.kind === 'string' || type.kind === 'number' || type.kind === 'value';
|
|
14981
15026
|
}
|
|
14982
15027
|
}
|
|
@@ -15016,26 +15061,8 @@
|
|
|
15016
15061
|
function gteqCollate(ctx, a, b, c) {
|
|
15017
15062
|
return c.compare(a, b) >= 0;
|
|
15018
15063
|
}
|
|
15019
|
-
/**
|
|
15020
|
-
* Special form for comparison operators, implementing the signatures:
|
|
15021
|
-
* - (T, T, ?Collator) => boolean
|
|
15022
|
-
* - (T, value, ?Collator) => boolean
|
|
15023
|
-
* - (value, T, ?Collator) => boolean
|
|
15024
|
-
*
|
|
15025
|
-
* For inequalities, T must be either value, string, or number. For ==/!=, it
|
|
15026
|
-
* can also be boolean or null.
|
|
15027
|
-
*
|
|
15028
|
-
* Equality semantics are equivalent to Javascript's strict equality (===/!==)
|
|
15029
|
-
* -- i.e., when the arguments' types don't match, == evaluates to false, != to
|
|
15030
|
-
* true.
|
|
15031
|
-
*
|
|
15032
|
-
* When types don't match in an ordering comparison, a runtime error is thrown.
|
|
15033
|
-
*
|
|
15034
|
-
* @private
|
|
15035
|
-
*/
|
|
15036
15064
|
function makeComparison(op, compareBasic, compareWithCollator) {
|
|
15037
15065
|
const isOrderComparison = op !== '==' && op !== '!=';
|
|
15038
|
-
// $FlowFixMe[method-unbinding]
|
|
15039
15066
|
return class Comparison {
|
|
15040
15067
|
constructor(lhs, rhs, collator) {
|
|
15041
15068
|
this.type = BooleanType;
|
|
@@ -15044,33 +15071,29 @@
|
|
|
15044
15071
|
this.collator = collator;
|
|
15045
15072
|
this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';
|
|
15046
15073
|
}
|
|
15047
|
-
// $FlowFixMe[method-unbinding]
|
|
15048
15074
|
static parse(args, context) {
|
|
15049
15075
|
if (args.length !== 3 && args.length !== 4)
|
|
15050
15076
|
return context.error(`Expected two or three arguments.`);
|
|
15051
|
-
const
|
|
15077
|
+
const op2 = args[0];
|
|
15052
15078
|
let lhs = context.parse(args[1], 1, ValueType);
|
|
15053
15079
|
if (!lhs)
|
|
15054
15080
|
return null;
|
|
15055
|
-
if (!isComparableType(
|
|
15056
|
-
return context.concat(1).error(`"${
|
|
15081
|
+
if (!isComparableType(op2, lhs.type)) {
|
|
15082
|
+
return context.concat(1).error(`"${ op2 }" comparisons are not supported for type '${ toString$1(lhs.type) }'.`);
|
|
15057
15083
|
}
|
|
15058
15084
|
let rhs = context.parse(args[2], 2, ValueType);
|
|
15059
15085
|
if (!rhs)
|
|
15060
15086
|
return null;
|
|
15061
|
-
if (!isComparableType(
|
|
15062
|
-
return context.concat(2).error(`"${
|
|
15087
|
+
if (!isComparableType(op2, rhs.type)) {
|
|
15088
|
+
return context.concat(2).error(`"${ op2 }" comparisons are not supported for type '${ toString$1(rhs.type) }'.`);
|
|
15063
15089
|
}
|
|
15064
15090
|
if (lhs.type.kind !== rhs.type.kind && lhs.type.kind !== 'value' && rhs.type.kind !== 'value') {
|
|
15065
15091
|
return context.error(`Cannot compare types '${ toString$1(lhs.type) }' and '${ toString$1(rhs.type) }'.`);
|
|
15066
15092
|
}
|
|
15067
15093
|
if (isOrderComparison) {
|
|
15068
|
-
// typing rules specific to less/greater than operators
|
|
15069
15094
|
if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {
|
|
15070
|
-
// (value, T)
|
|
15071
15095
|
lhs = new Assertion(rhs.type, [lhs]);
|
|
15072
15096
|
} else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {
|
|
15073
|
-
// (T, value)
|
|
15074
15097
|
rhs = new Assertion(lhs.type, [rhs]);
|
|
15075
15098
|
}
|
|
15076
15099
|
}
|
|
@@ -15089,17 +15112,16 @@
|
|
|
15089
15112
|
const lhs = this.lhs.evaluate(ctx);
|
|
15090
15113
|
const rhs = this.rhs.evaluate(ctx);
|
|
15091
15114
|
if (isOrderComparison && this.hasUntypedArgument) {
|
|
15092
|
-
const
|
|
15115
|
+
const lt2 = typeOf(lhs);
|
|
15093
15116
|
const rt = typeOf(rhs);
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
throw new RuntimeError(`Expected arguments for "${ op }" to be (string, string) or (number, number), but found (${ lt.kind }, ${ rt.kind }) instead.`);
|
|
15117
|
+
if (lt2.kind !== rt.kind || !(lt2.kind === 'string' || lt2.kind === 'number')) {
|
|
15118
|
+
throw new RuntimeError(`Expected arguments for "${ op }" to be (string, string) or (number, number), but found (${ lt2.kind }, ${ rt.kind }) instead.`);
|
|
15097
15119
|
}
|
|
15098
15120
|
}
|
|
15099
15121
|
if (this.collator && !isOrderComparison && this.hasUntypedArgument) {
|
|
15100
|
-
const
|
|
15122
|
+
const lt2 = typeOf(lhs);
|
|
15101
15123
|
const rt = typeOf(rhs);
|
|
15102
|
-
if (
|
|
15124
|
+
if (lt2.kind !== 'string' || rt.kind !== 'string') {
|
|
15103
15125
|
return compareBasic(ctx, lhs, rhs);
|
|
15104
15126
|
}
|
|
15105
15127
|
}
|
|
@@ -15131,12 +15153,7 @@
|
|
|
15131
15153
|
const LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);
|
|
15132
15154
|
const GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);
|
|
15133
15155
|
|
|
15134
|
-
//
|
|
15135
15156
|
class NumberFormat {
|
|
15136
|
-
// BCP 47 language tag
|
|
15137
|
-
// ISO 4217 currency code, required if style=currency
|
|
15138
|
-
// Simple units sanctioned for use in ECMAScript, required if style=unit. https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier
|
|
15139
|
-
// Default 0
|
|
15140
15157
|
// Default 3
|
|
15141
15158
|
constructor(number, locale, currency, unit, minFractionDigits, maxFractionDigits) {
|
|
15142
15159
|
this.type = StringType;
|
|
@@ -15191,10 +15208,10 @@
|
|
|
15191
15208
|
evaluate(ctx) {
|
|
15192
15209
|
return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {
|
|
15193
15210
|
style: this.currency && 'currency' || this.unit && 'unit' || 'decimal',
|
|
15194
|
-
currency: this.currency ? this.currency.evaluate(ctx) :
|
|
15195
|
-
unit: this.unit ? this.unit.evaluate(ctx) :
|
|
15196
|
-
minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) :
|
|
15197
|
-
maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) :
|
|
15211
|
+
currency: this.currency ? this.currency.evaluate(ctx) : void 0,
|
|
15212
|
+
unit: this.unit ? this.unit.evaluate(ctx) : void 0,
|
|
15213
|
+
minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : void 0,
|
|
15214
|
+
maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : void 0
|
|
15198
15215
|
}).format(this.number.evaluate(ctx));
|
|
15199
15216
|
}
|
|
15200
15217
|
eachChild(fn) {
|
|
@@ -15243,7 +15260,6 @@
|
|
|
15243
15260
|
}
|
|
15244
15261
|
}
|
|
15245
15262
|
|
|
15246
|
-
//
|
|
15247
15263
|
class Length {
|
|
15248
15264
|
constructor(input) {
|
|
15249
15265
|
this.type = NumberType;
|
|
@@ -15284,8 +15300,6 @@
|
|
|
15284
15300
|
}
|
|
15285
15301
|
}
|
|
15286
15302
|
|
|
15287
|
-
//
|
|
15288
|
-
// Seeded pseudo random generator function
|
|
15289
15303
|
function mulberry32(a) {
|
|
15290
15304
|
return function () {
|
|
15291
15305
|
a |= 0;
|
|
@@ -15296,7 +15310,6 @@
|
|
|
15296
15310
|
};
|
|
15297
15311
|
}
|
|
15298
15312
|
|
|
15299
|
-
//
|
|
15300
15313
|
const expressions = {
|
|
15301
15314
|
// special forms
|
|
15302
15315
|
'==': Equals,
|
|
@@ -15305,58 +15318,36 @@
|
|
|
15305
15318
|
'<': LessThan,
|
|
15306
15319
|
'>=': GreaterThanOrEqual,
|
|
15307
15320
|
'<=': LessThanOrEqual,
|
|
15308
|
-
// $FlowFixMe[method-unbinding]
|
|
15309
15321
|
'array': Assertion,
|
|
15310
|
-
// $FlowFixMe[method-unbinding]
|
|
15311
15322
|
'at': At,
|
|
15312
15323
|
'boolean': Assertion,
|
|
15313
|
-
// $FlowFixMe[method-unbinding]
|
|
15314
15324
|
'case': Case,
|
|
15315
|
-
// $FlowFixMe[method-unbinding]
|
|
15316
15325
|
'coalesce': Coalesce,
|
|
15317
|
-
// $FlowFixMe[method-unbinding]
|
|
15318
15326
|
'collator': CollatorExpression,
|
|
15319
|
-
// $FlowFixMe[method-unbinding]
|
|
15320
15327
|
'format': FormatExpression,
|
|
15321
|
-
// $FlowFixMe[method-unbinding]
|
|
15322
15328
|
'image': ImageExpression,
|
|
15323
|
-
// $FlowFixMe[method-unbinding]
|
|
15324
15329
|
'in': In,
|
|
15325
|
-
// $FlowFixMe[method-unbinding]
|
|
15326
15330
|
'index-of': IndexOf,
|
|
15327
|
-
// $FlowFixMe[method-unbinding]
|
|
15328
15331
|
'interpolate': Interpolate,
|
|
15329
15332
|
'interpolate-hcl': Interpolate,
|
|
15330
15333
|
'interpolate-lab': Interpolate,
|
|
15331
|
-
// $FlowFixMe[method-unbinding]
|
|
15332
15334
|
'length': Length,
|
|
15333
|
-
// $FlowFixMe[method-unbinding]
|
|
15334
15335
|
'let': Let,
|
|
15335
|
-
// $FlowFixMe[method-unbinding]
|
|
15336
15336
|
'literal': Literal,
|
|
15337
|
-
// $FlowFixMe[method-unbinding]
|
|
15338
15337
|
'match': Match,
|
|
15339
15338
|
'number': Assertion,
|
|
15340
|
-
// $FlowFixMe[method-unbinding]
|
|
15341
15339
|
'number-format': NumberFormat,
|
|
15342
15340
|
'object': Assertion,
|
|
15343
|
-
// $FlowFixMe[method-unbinding]
|
|
15344
15341
|
'slice': Slice,
|
|
15345
|
-
// $FlowFixMe[method-unbinding]
|
|
15346
15342
|
'step': Step,
|
|
15347
15343
|
'string': Assertion,
|
|
15348
|
-
// $FlowFixMe[method-unbinding]
|
|
15349
15344
|
'to-boolean': Coercion,
|
|
15350
15345
|
'to-color': Coercion,
|
|
15351
15346
|
'to-number': Coercion,
|
|
15352
15347
|
'to-string': Coercion,
|
|
15353
|
-
// $FlowFixMe[method-unbinding]
|
|
15354
15348
|
'var': Var,
|
|
15355
|
-
// $FlowFixMe[method-unbinding]
|
|
15356
15349
|
'within': Within,
|
|
15357
|
-
// $FlowFixMe[method-unbinding]
|
|
15358
15350
|
'distance': Distance,
|
|
15359
|
-
// $FlowFixMe[method-unbinding]
|
|
15360
15351
|
'config': Config
|
|
15361
15352
|
};
|
|
15362
15353
|
function rgba(ctx, [r, g, b, a]) {
|
|
@@ -15367,7 +15358,7 @@
|
|
|
15367
15358
|
const error = validateRGBA(r, g, b, alpha);
|
|
15368
15359
|
if (error)
|
|
15369
15360
|
throw new RuntimeError(error);
|
|
15370
|
-
return new Color
|
|
15361
|
+
return new Color(r / 255 * alpha, g / 255 * alpha, b / 255 * alpha, alpha);
|
|
15371
15362
|
}
|
|
15372
15363
|
function hsla(ctx, [h, s, l, a]) {
|
|
15373
15364
|
h = h.evaluate(ctx);
|
|
@@ -15378,7 +15369,7 @@
|
|
|
15378
15369
|
if (error)
|
|
15379
15370
|
throw new RuntimeError(error);
|
|
15380
15371
|
const colorFunction = `hsla(${ h }, ${ s }%, ${ l }%, ${ alpha })`;
|
|
15381
|
-
const color = Color
|
|
15372
|
+
const color = Color.parse(colorFunction);
|
|
15382
15373
|
if (!color)
|
|
15383
15374
|
throw new RuntimeError(`Failed to parse HSLA color: ${ colorFunction }`);
|
|
15384
15375
|
return color;
|
|
@@ -15434,7 +15425,7 @@
|
|
|
15434
15425
|
array$1(NumberType, 4),
|
|
15435
15426
|
[ColorType],
|
|
15436
15427
|
(ctx, [v]) => {
|
|
15437
|
-
return v.evaluate(ctx).toArray();
|
|
15428
|
+
return v.evaluate(ctx).toRenderColor(null).toArray();
|
|
15438
15429
|
}
|
|
15439
15430
|
],
|
|
15440
15431
|
'rgb': [
|
|
@@ -15575,7 +15566,7 @@
|
|
|
15575
15566
|
'accumulated': [
|
|
15576
15567
|
ValueType,
|
|
15577
15568
|
[],
|
|
15578
|
-
ctx => ctx.globals.accumulated ===
|
|
15569
|
+
ctx => ctx.globals.accumulated === void 0 ? null : ctx.globals.accumulated
|
|
15579
15570
|
],
|
|
15580
15571
|
'+': [
|
|
15581
15572
|
NumberType,
|
|
@@ -15724,9 +15715,6 @@
|
|
|
15724
15715
|
[NumberType],
|
|
15725
15716
|
(ctx, [n]) => {
|
|
15726
15717
|
const v = n.evaluate(ctx);
|
|
15727
|
-
// Javascript's Math.round() rounds towards +Infinity for halfway
|
|
15728
|
-
// values, even when they're negative. It's more common to round
|
|
15729
|
-
// away from 0 (e.g., this is what python and C++ do)
|
|
15730
15718
|
return v < 0 ? -Math.round(-v) : Math.round(v);
|
|
15731
15719
|
}
|
|
15732
15720
|
],
|
|
@@ -15850,7 +15838,7 @@
|
|
|
15850
15838
|
'filter-has-id': [
|
|
15851
15839
|
BooleanType,
|
|
15852
15840
|
[],
|
|
15853
|
-
ctx => ctx.id() !== null && ctx.id() !==
|
|
15841
|
+
ctx => ctx.id() !== null && ctx.id() !== void 0
|
|
15854
15842
|
],
|
|
15855
15843
|
'filter-type-in': [
|
|
15856
15844
|
BooleanType,
|
|
@@ -15990,13 +15978,6 @@
|
|
|
15990
15978
|
]
|
|
15991
15979
|
});
|
|
15992
15980
|
|
|
15993
|
-
//
|
|
15994
|
-
/**
|
|
15995
|
-
* A type used for returning and propagating errors. The first element of the union
|
|
15996
|
-
* represents success and contains a value, and the second represents an error and
|
|
15997
|
-
* contains an error value.
|
|
15998
|
-
* @private
|
|
15999
|
-
*/
|
|
16000
15981
|
function success(value) {
|
|
16001
15982
|
return {
|
|
16002
15983
|
result: 'success',
|
|
@@ -16010,7 +15991,6 @@
|
|
|
16010
15991
|
};
|
|
16011
15992
|
}
|
|
16012
15993
|
|
|
16013
|
-
//
|
|
16014
15994
|
function expressionHasParameter(expression, parameter) {
|
|
16015
15995
|
return !!expression && !!expression.parameters && expression.parameters.indexOf(parameter) > -1;
|
|
16016
15996
|
}
|
|
@@ -16027,7 +16007,6 @@
|
|
|
16027
16007
|
return !!spec.expression && spec.expression.interpolated;
|
|
16028
16008
|
}
|
|
16029
16009
|
|
|
16030
|
-
//
|
|
16031
16010
|
function isFunction(value) {
|
|
16032
16011
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16033
16012
|
}
|
|
@@ -16037,7 +16016,7 @@
|
|
|
16037
16016
|
function createFunction(parameters, propertySpec) {
|
|
16038
16017
|
const isColor = propertySpec.type === 'color';
|
|
16039
16018
|
const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';
|
|
16040
|
-
const featureDependent = zoomAndFeatureDependent || parameters.property !==
|
|
16019
|
+
const featureDependent = zoomAndFeatureDependent || parameters.property !== void 0;
|
|
16041
16020
|
const zoomDependent = zoomAndFeatureDependent || !featureDependent;
|
|
16042
16021
|
const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');
|
|
16043
16022
|
if (isColor) {
|
|
@@ -16046,18 +16025,17 @@
|
|
|
16046
16025
|
parameters.stops = parameters.stops.map(stop => {
|
|
16047
16026
|
return [
|
|
16048
16027
|
stop[0],
|
|
16049
|
-
Color
|
|
16028
|
+
Color.parse(stop[1])
|
|
16050
16029
|
];
|
|
16051
16030
|
});
|
|
16052
16031
|
}
|
|
16053
16032
|
if (parameters.default) {
|
|
16054
|
-
parameters.default = Color
|
|
16033
|
+
parameters.default = Color.parse(parameters.default);
|
|
16055
16034
|
} else {
|
|
16056
|
-
parameters.default = Color
|
|
16035
|
+
parameters.default = Color.parse(propertySpec.default);
|
|
16057
16036
|
}
|
|
16058
16037
|
}
|
|
16059
16038
|
if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace]) {
|
|
16060
|
-
// eslint-disable-line import/namespace
|
|
16061
16039
|
throw new Error(`Unknown color space: ${ parameters.colorSpace }`);
|
|
16062
16040
|
}
|
|
16063
16041
|
let innerFun;
|
|
@@ -16069,12 +16047,11 @@
|
|
|
16069
16047
|
innerFun = evaluateIntervalFunction;
|
|
16070
16048
|
} else if (type === 'categorical') {
|
|
16071
16049
|
innerFun = evaluateCategoricalFunction;
|
|
16072
|
-
|
|
16073
|
-
|
|
16050
|
+
hashedStops = /* @__PURE__ */
|
|
16051
|
+
Object.create(null);
|
|
16074
16052
|
for (const stop of parameters.stops) {
|
|
16075
16053
|
hashedStops[stop[0]] = stop[1];
|
|
16076
16054
|
}
|
|
16077
|
-
// Infer key type based on first stop key-- used to encforce strict type checking later
|
|
16078
16055
|
categoricalKeyType = typeof parameters.stops[0][0];
|
|
16079
16056
|
} else if (type === 'identity') {
|
|
16080
16057
|
innerFun = evaluateIdentityFunction;
|
|
@@ -16087,7 +16064,7 @@
|
|
|
16087
16064
|
for (let s = 0; s < parameters.stops.length; s++) {
|
|
16088
16065
|
const stop = parameters.stops[s];
|
|
16089
16066
|
const zoom = stop[0].zoom;
|
|
16090
|
-
if (featureFunctions[zoom] ===
|
|
16067
|
+
if (featureFunctions[zoom] === void 0) {
|
|
16091
16068
|
featureFunctions[zoom] = {
|
|
16092
16069
|
zoom,
|
|
16093
16070
|
type: parameters.type,
|
|
@@ -16113,7 +16090,7 @@
|
|
|
16113
16090
|
return {
|
|
16114
16091
|
kind: 'composite',
|
|
16115
16092
|
interpolationType,
|
|
16116
|
-
interpolationFactor: Interpolate.interpolationFactor.bind(
|
|
16093
|
+
interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
|
|
16117
16094
|
zoomStops: featureFunctionStops.map(s => s[0]),
|
|
16118
16095
|
evaluate({zoom}, properties) {
|
|
16119
16096
|
return evaluateExponentialFunction({
|
|
@@ -16125,12 +16102,12 @@
|
|
|
16125
16102
|
} else if (zoomDependent) {
|
|
16126
16103
|
const interpolationType = type === 'exponential' ? {
|
|
16127
16104
|
name: 'exponential',
|
|
16128
|
-
base: parameters.base !==
|
|
16105
|
+
base: parameters.base !== void 0 ? parameters.base : 1
|
|
16129
16106
|
} : null;
|
|
16130
16107
|
return {
|
|
16131
16108
|
kind: 'camera',
|
|
16132
16109
|
interpolationType,
|
|
16133
|
-
interpolationFactor: Interpolate.interpolationFactor.bind(
|
|
16110
|
+
interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
|
|
16134
16111
|
zoomStops: parameters.stops.map(s => s[0]),
|
|
16135
16112
|
evaluate: ({zoom}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
|
|
16136
16113
|
};
|
|
@@ -16138,8 +16115,8 @@
|
|
|
16138
16115
|
return {
|
|
16139
16116
|
kind: 'source',
|
|
16140
16117
|
evaluate(_, feature) {
|
|
16141
|
-
const value = feature && feature.properties ? feature.properties[parameters.property] :
|
|
16142
|
-
if (value ===
|
|
16118
|
+
const value = feature && feature.properties ? feature.properties[parameters.property] : void 0;
|
|
16119
|
+
if (value === void 0) {
|
|
16143
16120
|
return coalesce$1(parameters.default, propertySpec.default);
|
|
16144
16121
|
}
|
|
16145
16122
|
return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);
|
|
@@ -16148,20 +16125,18 @@
|
|
|
16148
16125
|
}
|
|
16149
16126
|
}
|
|
16150
16127
|
function coalesce$1(a, b, c) {
|
|
16151
|
-
if (a !==
|
|
16128
|
+
if (a !== void 0)
|
|
16152
16129
|
return a;
|
|
16153
|
-
if (b !==
|
|
16130
|
+
if (b !== void 0)
|
|
16154
16131
|
return b;
|
|
16155
|
-
if (c !==
|
|
16132
|
+
if (c !== void 0)
|
|
16156
16133
|
return c;
|
|
16157
16134
|
}
|
|
16158
16135
|
function evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {
|
|
16159
|
-
const evaluated = typeof input === keyType ? hashedStops[input] :
|
|
16160
|
-
// Enforce strict typing on input
|
|
16136
|
+
const evaluated = typeof input === keyType ? hashedStops[input] : void 0;
|
|
16161
16137
|
return coalesce$1(evaluated, parameters.default, propertySpec.default);
|
|
16162
16138
|
}
|
|
16163
16139
|
function evaluateIntervalFunction(parameters, propertySpec, input) {
|
|
16164
|
-
// Edge cases
|
|
16165
16140
|
if (getType(input) !== 'number')
|
|
16166
16141
|
return coalesce$1(parameters.default, propertySpec.default);
|
|
16167
16142
|
const n = parameters.stops.length;
|
|
@@ -16175,8 +16150,7 @@
|
|
|
16175
16150
|
return parameters.stops[index][1];
|
|
16176
16151
|
}
|
|
16177
16152
|
function evaluateExponentialFunction(parameters, propertySpec, input) {
|
|
16178
|
-
const base = parameters.base !==
|
|
16179
|
-
// Edge cases
|
|
16153
|
+
const base = parameters.base !== void 0 ? parameters.base : 1;
|
|
16180
16154
|
if (getType(input) !== 'number')
|
|
16181
16155
|
return coalesce$1(parameters.default, propertySpec.default);
|
|
16182
16156
|
const n = parameters.stops.length;
|
|
@@ -16190,21 +16164,18 @@
|
|
|
16190
16164
|
const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);
|
|
16191
16165
|
const outputLower = parameters.stops[index][1];
|
|
16192
16166
|
const outputUpper = parameters.stops[index + 1][1];
|
|
16193
|
-
let interp = interpolate[propertySpec.type] || identityFunction;
|
|
16194
|
-
// eslint-disable-line import/namespace
|
|
16167
|
+
let interp = interpolate$1[propertySpec.type] || identityFunction;
|
|
16195
16168
|
if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
|
|
16196
16169
|
const colorspace = colorSpaces[parameters.colorSpace];
|
|
16197
|
-
// eslint-disable-line import/namespace
|
|
16198
16170
|
interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
|
|
16199
16171
|
}
|
|
16200
16172
|
if (typeof outputLower.evaluate === 'function') {
|
|
16201
16173
|
return {
|
|
16202
16174
|
evaluate(...args) {
|
|
16203
|
-
const evaluatedLower = outputLower.evaluate.apply(
|
|
16204
|
-
const evaluatedUpper = outputUpper.evaluate.apply(
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
return undefined;
|
|
16175
|
+
const evaluatedLower = outputLower.evaluate.apply(void 0, args);
|
|
16176
|
+
const evaluatedUpper = outputUpper.evaluate.apply(void 0, args);
|
|
16177
|
+
if (evaluatedLower === void 0 || evaluatedUpper === void 0) {
|
|
16178
|
+
return void 0;
|
|
16208
16179
|
}
|
|
16209
16180
|
return interp(evaluatedLower, evaluatedUpper, t);
|
|
16210
16181
|
}
|
|
@@ -16214,54 +16185,16 @@
|
|
|
16214
16185
|
}
|
|
16215
16186
|
function evaluateIdentityFunction(parameters, propertySpec, input) {
|
|
16216
16187
|
if (propertySpec.type === 'color') {
|
|
16217
|
-
input = Color
|
|
16188
|
+
input = Color.parse(input);
|
|
16218
16189
|
} else if (propertySpec.type === 'formatted') {
|
|
16219
16190
|
input = Formatted.fromString(input.toString());
|
|
16220
16191
|
} else if (propertySpec.type === 'resolvedImage') {
|
|
16221
16192
|
input = ResolvedImage.fromString(input.toString());
|
|
16222
16193
|
} else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {
|
|
16223
|
-
input =
|
|
16194
|
+
input = void 0;
|
|
16224
16195
|
}
|
|
16225
16196
|
return coalesce$1(input, parameters.default, propertySpec.default);
|
|
16226
16197
|
}
|
|
16227
|
-
/**
|
|
16228
|
-
* Returns a ratio that can be used to interpolate between exponential function
|
|
16229
|
-
* stops.
|
|
16230
|
-
*
|
|
16231
|
-
* How it works:
|
|
16232
|
-
* Two consecutive stop values define a (scaled and shifted) exponential
|
|
16233
|
-
* function `f(x) = a * base^x + b`, where `base` is the user-specified base,
|
|
16234
|
-
* and `a` and `b` are constants affording sufficient degrees of freedom to fit
|
|
16235
|
-
* the function to the given stops.
|
|
16236
|
-
*
|
|
16237
|
-
* Here's a bit of algebra that lets us compute `f(x)` directly from the stop
|
|
16238
|
-
* values without explicitly solving for `a` and `b`:
|
|
16239
|
-
*
|
|
16240
|
-
* First stop value: `f(x0) = y0 = a * base^x0 + b`
|
|
16241
|
-
* Second stop value: `f(x1) = y1 = a * base^x1 + b`
|
|
16242
|
-
* => `y1 - y0 = a(base^x1 - base^x0)`
|
|
16243
|
-
* => `a = (y1 - y0)/(base^x1 - base^x0)`
|
|
16244
|
-
*
|
|
16245
|
-
* Desired value: `f(x) = y = a * base^x + b`
|
|
16246
|
-
* => `f(x) = y0 + a * (base^x - base^x0)`
|
|
16247
|
-
*
|
|
16248
|
-
* From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a
|
|
16249
|
-
* little algebra:
|
|
16250
|
-
* ```
|
|
16251
|
-
* a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)
|
|
16252
|
-
* = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)
|
|
16253
|
-
* ```
|
|
16254
|
-
*
|
|
16255
|
-
* If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have
|
|
16256
|
-
* `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as
|
|
16257
|
-
* an interpolation factor between the two stops' output values.
|
|
16258
|
-
*
|
|
16259
|
-
* (Note: a slightly different form for `ratio`,
|
|
16260
|
-
* `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer
|
|
16261
|
-
* expensive `Math.pow()` operations.)
|
|
16262
|
-
*
|
|
16263
|
-
* @private
|
|
16264
|
-
*/
|
|
16265
16198
|
function interpolationFactor(input, base, lowerValue, upperValue) {
|
|
16266
16199
|
const difference = upperValue - lowerValue;
|
|
16267
16200
|
const progress = input - lowerValue;
|
|
@@ -16304,8 +16237,7 @@
|
|
|
16304
16237
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
16305
16238
|
try {
|
|
16306
16239
|
const val = this.expression.evaluate(this._evaluator);
|
|
16307
|
-
|
|
16308
|
-
if (val === null || val === undefined || typeof val === 'number' && val !== val) {
|
|
16240
|
+
if (val === null || val === void 0 || typeof val === 'number' && val !== val) {
|
|
16309
16241
|
return this._defaultValue;
|
|
16310
16242
|
}
|
|
16311
16243
|
if (this._enumValues && !(val in this._enumValues)) {
|
|
@@ -16326,19 +16258,9 @@
|
|
|
16326
16258
|
function isExpression(expression) {
|
|
16327
16259
|
return Array.isArray(expression) && expression.length > 0 && typeof expression[0] === 'string' && expression[0] in expressions;
|
|
16328
16260
|
}
|
|
16329
|
-
/**
|
|
16330
|
-
* Parse and typecheck the given style spec JSON expression. If
|
|
16331
|
-
* options.defaultValue is provided, then the resulting StyleExpression's
|
|
16332
|
-
* `evaluate()` method will handle errors by logging a warning (once per
|
|
16333
|
-
* message) and returning the default value. Otherwise, it will throw
|
|
16334
|
-
* evaluation errors.
|
|
16335
|
-
*
|
|
16336
|
-
* @private
|
|
16337
|
-
*/
|
|
16338
16261
|
function createExpression(expression, propertySpec, scope, options) {
|
|
16339
|
-
const parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) :
|
|
16340
|
-
|
|
16341
|
-
const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);
|
|
16262
|
+
const parser = new ParsingContext$1(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0, void 0, void 0, scope, options);
|
|
16263
|
+
const parsed = parser.parse(expression, void 0, void 0, void 0, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : void 0);
|
|
16342
16264
|
if (!parsed) {
|
|
16343
16265
|
return error(parser.errors);
|
|
16344
16266
|
}
|
|
@@ -16415,13 +16337,15 @@
|
|
|
16415
16337
|
return error([new ParsingError$1('', '"interpolate" expressions cannot be used with this property')]);
|
|
16416
16338
|
}
|
|
16417
16339
|
if (!zoomCurve) {
|
|
16418
|
-
return success(isFeatureConstant$1 ?
|
|
16340
|
+
return success(isFeatureConstant$1 ? // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
16341
|
+
new ZoomConstantExpression('constant', expression.value, isLightConstant) : // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
16342
|
+
new ZoomConstantExpression('source', expression.value, isLightConstant));
|
|
16419
16343
|
}
|
|
16420
|
-
const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation :
|
|
16421
|
-
return success(isFeatureConstant$1 ?
|
|
16344
|
+
const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : void 0;
|
|
16345
|
+
return success(isFeatureConstant$1 ? // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
16346
|
+
new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType, isLightConstant) : // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
16347
|
+
new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType, isLightConstant));
|
|
16422
16348
|
}
|
|
16423
|
-
// serialization wrapper for old-style stop functions normalized to the
|
|
16424
|
-
// expression interface
|
|
16425
16349
|
class StylePropertyFunction {
|
|
16426
16350
|
constructor(parameters, specification) {
|
|
16427
16351
|
this._parameters = parameters;
|
|
@@ -16444,14 +16368,13 @@
|
|
|
16444
16368
|
} else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
|
|
16445
16369
|
const expression = createPropertyExpression(value, specification, scope, options);
|
|
16446
16370
|
if (expression.result === 'error') {
|
|
16447
|
-
// this should have been caught in validation
|
|
16448
16371
|
throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
|
|
16449
16372
|
}
|
|
16450
16373
|
return expression.value;
|
|
16451
16374
|
} else {
|
|
16452
16375
|
let constant = value;
|
|
16453
16376
|
if (typeof value === 'string' && specification.type === 'color') {
|
|
16454
|
-
constant = Color
|
|
16377
|
+
constant = Color.parse(value);
|
|
16455
16378
|
}
|
|
16456
16379
|
return {
|
|
16457
16380
|
kind: 'constant',
|
|
@@ -16460,9 +16383,6 @@
|
|
|
16460
16383
|
};
|
|
16461
16384
|
}
|
|
16462
16385
|
}
|
|
16463
|
-
// Zoom-dependent expressions may only use ["zoom"] as the input to a top-level "step" or "interpolate"
|
|
16464
|
-
// expression (collectively referred to as a "curve"). The curve may be wrapped in one or more "let" or
|
|
16465
|
-
// "coalesce" expressions.
|
|
16466
16386
|
function findZoomCurve(expression) {
|
|
16467
16387
|
let result = null;
|
|
16468
16388
|
if (expression instanceof Let) {
|
|
@@ -16507,13 +16427,10 @@
|
|
|
16507
16427
|
}
|
|
16508
16428
|
function getDefaultValue(spec) {
|
|
16509
16429
|
if (spec.type === 'color' && (isFunction(spec.default) || Array.isArray(spec.default))) {
|
|
16510
|
-
|
|
16511
|
-
// default color ramp, but createExpression expects a simple value to fall
|
|
16512
|
-
// back to in case of runtime errors
|
|
16513
|
-
return new Color$1(0, 0, 0, 0);
|
|
16430
|
+
return new Color(0, 0, 0, 0);
|
|
16514
16431
|
} else if (spec.type === 'color') {
|
|
16515
|
-
return Color
|
|
16516
|
-
} else if (spec.default ===
|
|
16432
|
+
return Color.parse(spec.default) || null;
|
|
16433
|
+
} else if (spec.default === void 0) {
|
|
16517
16434
|
return null;
|
|
16518
16435
|
} else {
|
|
16519
16436
|
return spec.default;
|
|
@@ -16529,11 +16446,10 @@
|
|
|
16529
16446
|
function convertFunction(parameters, propertySpec) {
|
|
16530
16447
|
let stops = parameters.stops;
|
|
16531
16448
|
if (!stops) {
|
|
16532
|
-
// identity function
|
|
16533
16449
|
return convertIdentityFunction(parameters, propertySpec);
|
|
16534
16450
|
}
|
|
16535
16451
|
const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';
|
|
16536
|
-
const featureDependent = zoomAndFeatureDependent || parameters.property !==
|
|
16452
|
+
const featureDependent = zoomAndFeatureDependent || parameters.property !== void 0;
|
|
16537
16453
|
const zoomDependent = zoomAndFeatureDependent || !featureDependent;
|
|
16538
16454
|
stops = stops.map(stop => {
|
|
16539
16455
|
if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {
|
|
@@ -16560,9 +16476,7 @@
|
|
|
16560
16476
|
'get',
|
|
16561
16477
|
parameters.property
|
|
16562
16478
|
];
|
|
16563
|
-
if (parameters.default ===
|
|
16564
|
-
// By default, expressions for string-valued properties get coerced. To preserve
|
|
16565
|
-
// legacy function semantics, insert an explicit assertion instead.
|
|
16479
|
+
if (parameters.default === void 0) {
|
|
16566
16480
|
return propertySpec.type === 'string' ? [
|
|
16567
16481
|
'string',
|
|
16568
16482
|
get
|
|
@@ -16604,7 +16518,7 @@
|
|
|
16604
16518
|
for (let s = 0; s < stops.length; s++) {
|
|
16605
16519
|
const stop = stops[s];
|
|
16606
16520
|
const zoom = stop[0].zoom;
|
|
16607
|
-
if (featureFunctionParameters[zoom] ===
|
|
16521
|
+
if (featureFunctionParameters[zoom] === void 0) {
|
|
16608
16522
|
featureFunctionParameters[zoom] = {
|
|
16609
16523
|
zoom,
|
|
16610
16524
|
type: parameters.type,
|
|
@@ -16619,10 +16533,6 @@
|
|
|
16619
16533
|
stop[1]
|
|
16620
16534
|
]);
|
|
16621
16535
|
}
|
|
16622
|
-
// the interpolation type for the zoom dimension of a zoom-and-property
|
|
16623
|
-
// function is determined directly from the style property specification
|
|
16624
|
-
// for which it's being used: linear for interpolatable properties, step
|
|
16625
|
-
// otherwise.
|
|
16626
16536
|
const functionType = getFunctionType({}, propertySpec);
|
|
16627
16537
|
if (functionType === 'exponential') {
|
|
16628
16538
|
const expression = [
|
|
@@ -16649,20 +16559,14 @@
|
|
|
16649
16559
|
}
|
|
16650
16560
|
}
|
|
16651
16561
|
function coalesce(a, b) {
|
|
16652
|
-
if (a !==
|
|
16562
|
+
if (a !== void 0)
|
|
16653
16563
|
return a;
|
|
16654
|
-
if (b !==
|
|
16564
|
+
if (b !== void 0)
|
|
16655
16565
|
return b;
|
|
16656
16566
|
}
|
|
16657
16567
|
function getFallback(parameters, propertySpec) {
|
|
16658
16568
|
const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));
|
|
16659
|
-
|
|
16660
|
-
* Some fields with type: resolvedImage have an undefined default.
|
|
16661
|
-
* Because undefined is an invalid value for resolvedImage, set fallback to
|
|
16662
|
-
* an empty string instead of undefined to ensure output
|
|
16663
|
-
* passes validation.
|
|
16664
|
-
*/
|
|
16665
|
-
if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {
|
|
16569
|
+
if (defaultValue === void 0 && propertySpec.type === 'resolvedImage') {
|
|
16666
16570
|
return '';
|
|
16667
16571
|
}
|
|
16668
16572
|
return defaultValue;
|
|
@@ -16706,7 +16610,7 @@
|
|
|
16706
16610
|
appendStopPair(expression, stop[0], stop[1], true);
|
|
16707
16611
|
}
|
|
16708
16612
|
fixupDegenerateStepCurve(expression);
|
|
16709
|
-
return parameters.default ===
|
|
16613
|
+
return parameters.default === void 0 ? expression : [
|
|
16710
16614
|
'case',
|
|
16711
16615
|
[
|
|
16712
16616
|
'==',
|
|
@@ -16720,7 +16624,7 @@
|
|
|
16720
16624
|
convertLiteral(parameters.default)
|
|
16721
16625
|
];
|
|
16722
16626
|
} else if (type === 'exponential') {
|
|
16723
|
-
const base = parameters.base !==
|
|
16627
|
+
const base = parameters.base !== void 0 ? parameters.base : 1;
|
|
16724
16628
|
const expression = [
|
|
16725
16629
|
getInterpolateOperator(parameters),
|
|
16726
16630
|
base === 1 ? ['linear'] : [
|
|
@@ -16735,7 +16639,7 @@
|
|
|
16735
16639
|
for (const stop of stops) {
|
|
16736
16640
|
appendStopPair(expression, stop[0], stop[1], false);
|
|
16737
16641
|
}
|
|
16738
|
-
return parameters.default ===
|
|
16642
|
+
return parameters.default === void 0 ? expression : [
|
|
16739
16643
|
'case',
|
|
16740
16644
|
[
|
|
16741
16645
|
'==',
|
|
@@ -16763,7 +16667,7 @@
|
|
|
16763
16667
|
];
|
|
16764
16668
|
isStep = true;
|
|
16765
16669
|
} else if (type === 'exponential') {
|
|
16766
|
-
const base = parameters.base !==
|
|
16670
|
+
const base = parameters.base !== void 0 ? parameters.base : 1;
|
|
16767
16671
|
expression = [
|
|
16768
16672
|
getInterpolateOperator(parameters),
|
|
16769
16673
|
base === 1 ? ['linear'] : [
|
|
@@ -16782,19 +16686,15 @@
|
|
|
16782
16686
|
return expression;
|
|
16783
16687
|
}
|
|
16784
16688
|
function fixupDegenerateStepCurve(expression) {
|
|
16785
|
-
// degenerate step curve (i.e. a constant function): add a noop stop
|
|
16786
16689
|
if (expression[0] === 'step' && expression.length === 3) {
|
|
16787
16690
|
expression.push(0);
|
|
16788
16691
|
expression.push(expression[3]);
|
|
16789
16692
|
}
|
|
16790
16693
|
}
|
|
16791
16694
|
function appendStopPair(curve, input, output, isStep) {
|
|
16792
|
-
// Skip duplicate stop values. They were not validated for functions, but they are for expressions.
|
|
16793
|
-
// https://github.com/mapbox/mapbox-gl-js/issues/4107
|
|
16794
16695
|
if (curve.length > 3 && input === curve[curve.length - 2]) {
|
|
16795
16696
|
return;
|
|
16796
16697
|
}
|
|
16797
|
-
// step curves don't get the first input value, as it is redundant.
|
|
16798
16698
|
if (!(isStep && curve.length === 2)) {
|
|
16799
16699
|
curve.push(input);
|
|
16800
16700
|
}
|
|
@@ -16807,7 +16707,6 @@
|
|
|
16807
16707
|
return propertySpec.expression.interpolated ? 'exponential' : 'interval';
|
|
16808
16708
|
}
|
|
16809
16709
|
}
|
|
16810
|
-
// "String with {name} token" => ["concat", "String with ", ["get", "name"], " token"]
|
|
16811
16710
|
function convertTokenString(s) {
|
|
16812
16711
|
const result = ['concat'];
|
|
16813
16712
|
const re = /{([^{}]+)}/g;
|
|
@@ -16836,8 +16735,6 @@
|
|
|
16836
16735
|
return result;
|
|
16837
16736
|
}
|
|
16838
16737
|
|
|
16839
|
-
//
|
|
16840
|
-
// Turn jsonlint-lines-primitives objects into primitive objects
|
|
16841
16738
|
function unbundle(value) {
|
|
16842
16739
|
if (value instanceof Number || value instanceof String || value instanceof Boolean) {
|
|
16843
16740
|
return value.valueOf();
|
|
@@ -16858,7 +16755,6 @@
|
|
|
16858
16755
|
return unbundle(value);
|
|
16859
16756
|
}
|
|
16860
16757
|
|
|
16861
|
-
//
|
|
16862
16758
|
function isExpressionFilter(filter) {
|
|
16863
16759
|
if (filter === true || filter === false) {
|
|
16864
16760
|
return true;
|
|
@@ -16894,18 +16790,8 @@
|
|
|
16894
16790
|
return true;
|
|
16895
16791
|
}
|
|
16896
16792
|
}
|
|
16897
|
-
/**
|
|
16898
|
-
* Given a filter expressed as nested arrays, return a new function
|
|
16899
|
-
* that evaluates whether a given feature (with a .properties or .tags property)
|
|
16900
|
-
* passes its test.
|
|
16901
|
-
*
|
|
16902
|
-
* @private
|
|
16903
|
-
* @param {Array} filter mapbox gl filter
|
|
16904
|
-
* @param {string} layerType the type of the layer this filter will be applied to.
|
|
16905
|
-
* @returns {Function} filter-evaluating function
|
|
16906
|
-
*/
|
|
16907
16793
|
function createFilter(filter, layerType = 'fill') {
|
|
16908
|
-
if (filter === null || filter ===
|
|
16794
|
+
if (filter === null || filter === void 0) {
|
|
16909
16795
|
return {
|
|
16910
16796
|
filter: () => true,
|
|
16911
16797
|
needGeometry: false,
|
|
@@ -16913,7 +16799,6 @@
|
|
|
16913
16799
|
};
|
|
16914
16800
|
}
|
|
16915
16801
|
if (!isExpressionFilter(filter)) {
|
|
16916
|
-
// $FlowFixMe[incompatible-call]
|
|
16917
16802
|
filter = convertFilter$1(filter);
|
|
16918
16803
|
}
|
|
16919
16804
|
const filterExp = filter;
|
|
@@ -16929,7 +16814,6 @@ Filter Expression:
|
|
|
16929
16814
|
${ JSON.stringify(filterExp, null, 2) }
|
|
16930
16815
|
`);
|
|
16931
16816
|
}
|
|
16932
|
-
// Compile the static component of the filter
|
|
16933
16817
|
const filterSpec = v8[`filter_${ layerType }`];
|
|
16934
16818
|
const compiledStaticFilter = createExpression(staticFilter, filterSpec);
|
|
16935
16819
|
let filterFunc = null;
|
|
@@ -16938,8 +16822,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
16938
16822
|
} else {
|
|
16939
16823
|
filterFunc = (globalProperties, feature, canonical) => compiledStaticFilter.value.evaluate(globalProperties, feature, {}, canonical);
|
|
16940
16824
|
}
|
|
16941
|
-
// If the static component is not equal to the entire filter then we have a dynamic component
|
|
16942
|
-
// Compile the dynamic component separately
|
|
16943
16825
|
let dynamicFilterFunc = null;
|
|
16944
16826
|
let needFeature = null;
|
|
16945
16827
|
if (staticFilter !== filterExp) {
|
|
@@ -16947,7 +16829,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
16947
16829
|
if (compiledDynamicFilter.result === 'error') {
|
|
16948
16830
|
throw new Error(compiledDynamicFilter.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
|
|
16949
16831
|
} else {
|
|
16950
|
-
dynamicFilterFunc = (globalProperties, feature, canonical, featureTileCoord, featureDistanceData) => compiledDynamicFilter.value.evaluate(globalProperties, feature, {}, canonical,
|
|
16832
|
+
dynamicFilterFunc = (globalProperties, feature, canonical, featureTileCoord, featureDistanceData) => compiledDynamicFilter.value.evaluate(globalProperties, feature, {}, canonical, void 0, void 0, featureTileCoord, featureDistanceData);
|
|
16951
16833
|
needFeature = !isFeatureConstant(compiledDynamicFilter.value.expression);
|
|
16952
16834
|
}
|
|
16953
16835
|
}
|
|
@@ -16955,7 +16837,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
16955
16837
|
const needGeometry = geometryNeeded(staticFilter);
|
|
16956
16838
|
return {
|
|
16957
16839
|
filter: filterFunc,
|
|
16958
|
-
dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc :
|
|
16840
|
+
dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc : void 0,
|
|
16959
16841
|
needGeometry,
|
|
16960
16842
|
needFeature: !!needFeature
|
|
16961
16843
|
};
|
|
@@ -16964,11 +16846,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
16964
16846
|
if (!isDynamicFilter(filter)) {
|
|
16965
16847
|
return filter;
|
|
16966
16848
|
}
|
|
16967
|
-
// Shallow copy so we can replace expressions in-place
|
|
16968
16849
|
let result = deepUnbundle(filter);
|
|
16969
|
-
// 1. Union branches
|
|
16970
16850
|
unionDynamicBranches(result);
|
|
16971
|
-
// 2. Collapse dynamic conditions to `true`
|
|
16972
16851
|
result = collapseDynamicBooleanExpressions(result);
|
|
16973
16852
|
return result;
|
|
16974
16853
|
}
|
|
@@ -16983,15 +16862,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
16983
16862
|
return collapsed.map(subExpression => collapseDynamicBooleanExpressions(subExpression));
|
|
16984
16863
|
}
|
|
16985
16864
|
}
|
|
16986
|
-
/**
|
|
16987
|
-
* Traverses the expression and replaces all instances of branching on a
|
|
16988
|
-
* `dynamic` conditional (such as `['pitch']` or `['distance-from-center']`)
|
|
16989
|
-
* into an `any` expression.
|
|
16990
|
-
* This ensures that all possible outcomes of a `dynamic` branch are considered
|
|
16991
|
-
* when evaluating the expression upfront during filtering.
|
|
16992
|
-
*
|
|
16993
|
-
* @param {Array<any>} filter the filter expression mutated in-place.
|
|
16994
|
-
*/
|
|
16995
16865
|
function unionDynamicBranches(filter) {
|
|
16996
16866
|
let isBranchingDynamically = false;
|
|
16997
16867
|
const branches = [];
|
|
@@ -17017,13 +16887,11 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17017
16887
|
filter.length = 0;
|
|
17018
16888
|
filter.push('any', ...branches);
|
|
17019
16889
|
}
|
|
17020
|
-
// traverse and recurse into children
|
|
17021
16890
|
for (let i = 1; i < filter.length; i++) {
|
|
17022
16891
|
unionDynamicBranches(filter[i]);
|
|
17023
16892
|
}
|
|
17024
16893
|
}
|
|
17025
16894
|
function isDynamicFilter(filter) {
|
|
17026
|
-
// Base Cases
|
|
17027
16895
|
if (!Array.isArray(filter)) {
|
|
17028
16896
|
return false;
|
|
17029
16897
|
}
|
|
@@ -17041,7 +16909,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17041
16909
|
function isRootExpressionDynamic(expression) {
|
|
17042
16910
|
return expression === 'pitch' || expression === 'distance-from-center';
|
|
17043
16911
|
}
|
|
17044
|
-
const dynamicConditionExpressions =
|
|
16912
|
+
const dynamicConditionExpressions = /* @__PURE__ */
|
|
16913
|
+
new Set([
|
|
17045
16914
|
'in',
|
|
17046
16915
|
'==',
|
|
17047
16916
|
'!=',
|
|
@@ -17062,7 +16931,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17062
16931
|
}
|
|
17063
16932
|
return expression;
|
|
17064
16933
|
}
|
|
17065
|
-
// Comparison function to sort numbers and strings
|
|
17066
16934
|
function compare(a, b) {
|
|
17067
16935
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
17068
16936
|
}
|
|
@@ -17083,7 +16951,9 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17083
16951
|
const op = filter[0];
|
|
17084
16952
|
if (filter.length <= 1)
|
|
17085
16953
|
return op !== 'any';
|
|
17086
|
-
const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') : op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) : op === '<' || op === '>' || op === '<=' || op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) : op === 'any' ? convertDisjunctionOp(filter.slice(1)) :
|
|
16954
|
+
const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') : op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) : op === '<' || op === '>' || op === '<=' || op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) : op === 'any' ? convertDisjunctionOp(filter.slice(1)) : // @ts-expect-error - TS2769 - No overload matches this call.
|
|
16955
|
+
op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) : // @ts-expect-error - TS2769 - No overload matches this call.
|
|
16956
|
+
op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) : op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) : op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) : op === 'has' ? convertHasOp$1(filter[1]) : op === '!has' ? convertNegation(convertHasOp$1(filter[1])) : true;
|
|
17087
16957
|
return converted;
|
|
17088
16958
|
}
|
|
17089
16959
|
function convertComparisonOp$1(property, value, op) {
|
|
@@ -17172,63 +17042,9 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17172
17042
|
];
|
|
17173
17043
|
}
|
|
17174
17044
|
|
|
17175
|
-
//
|
|
17176
|
-
/**
|
|
17177
|
-
* Convert the given legacy filter to (the JSON representation of) an
|
|
17178
|
-
* equivalent expression
|
|
17179
|
-
* @private
|
|
17180
|
-
*/
|
|
17181
17045
|
function convertFilter(filter) {
|
|
17182
17046
|
return _convertFilter(filter, {});
|
|
17183
17047
|
}
|
|
17184
|
-
/*
|
|
17185
|
-
* Convert the given filter to an expression, storing the expected types for
|
|
17186
|
-
* any feature properties referenced in expectedTypes.
|
|
17187
|
-
*
|
|
17188
|
-
* These expected types are needed in order to construct preflight type checks
|
|
17189
|
-
* needed for handling 'any' filters. A preflight type check is necessary in
|
|
17190
|
-
* order to mimic legacy filters' semantics around expected type mismatches.
|
|
17191
|
-
* For example, consider the legacy filter:
|
|
17192
|
-
*
|
|
17193
|
-
* ["any", ["all", [">", "y", 0], [">", "y", 0]], [">", "x", 0]]
|
|
17194
|
-
*
|
|
17195
|
-
* Naively, we might convert this to the expression:
|
|
17196
|
-
*
|
|
17197
|
-
* ["any", ["all", [">", ["get", "y"], 0], [">", ["get", "z"], 0]], [">", ["get", "x"], 0]]
|
|
17198
|
-
*
|
|
17199
|
-
* But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the
|
|
17200
|
-
* [">", ["get", "y"], 0] would cause an evaluation error, leading to the
|
|
17201
|
-
* entire filter returning false. Legacy filter semantics, though, ask for
|
|
17202
|
-
* [">", "y", 0] to simply return `false` when `y` is of the wrong type,
|
|
17203
|
-
* allowing the subsequent terms of the outer "any" expression to be evaluated
|
|
17204
|
-
* (resulting, in this case, in a `true` value, because x > 0).
|
|
17205
|
-
*
|
|
17206
|
-
* We account for this by inserting a preflight type-checking expression before
|
|
17207
|
-
* each "any" term, allowing us to avoid evaluating the actual converted filter
|
|
17208
|
-
* if any type mismatches would cause it to produce an evalaution error:
|
|
17209
|
-
*
|
|
17210
|
-
* ["any",
|
|
17211
|
-
* ["case",
|
|
17212
|
-
* ["all", ["==", ["typeof", ["get", "y"]], "number"], ["==", ["typeof", ["get", "z"], "number]],
|
|
17213
|
-
* ["all", [">", ["get", "y"], 0], [">", ["get", "z"], 0]],
|
|
17214
|
-
* false
|
|
17215
|
-
* ],
|
|
17216
|
-
* ["case",
|
|
17217
|
-
* ["==", ["typeof", ["get", "x"], "number"]],
|
|
17218
|
-
* [">", ["get", "x"], 0],
|
|
17219
|
-
* false
|
|
17220
|
-
* ]
|
|
17221
|
-
* ]
|
|
17222
|
-
*
|
|
17223
|
-
* An alternative, possibly more direct approach would be to use type checks
|
|
17224
|
-
* in the conversion of each comparison operator, so that the converted version
|
|
17225
|
-
* of each individual ==, >=, etc. would mimic the legacy filter semantics. The
|
|
17226
|
-
* downside of this approach is that it can lead to many more type checks than
|
|
17227
|
-
* would otherwise be necessary: outside the context of an "any" expression,
|
|
17228
|
-
* bailing out due to a runtime type error (expression semantics) and returning
|
|
17229
|
-
* false (legacy filter semantics) are equivalent: they cause the filter to
|
|
17230
|
-
* produce a `false` result.
|
|
17231
|
-
*/
|
|
17232
17048
|
function _convertFilter(filter, expectedTypes) {
|
|
17233
17049
|
if (isExpressionFilter(filter)) {
|
|
17234
17050
|
return filter;
|
|
@@ -17279,14 +17095,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17279
17095
|
}
|
|
17280
17096
|
return converted;
|
|
17281
17097
|
}
|
|
17282
|
-
// Given a set of feature properties and an expected type for each one,
|
|
17283
|
-
// construct an boolean expression that tests whether each property has the
|
|
17284
|
-
// right type.
|
|
17285
|
-
// E.g.: for {name: 'string', population: 'number'}, return
|
|
17286
|
-
// [ 'all',
|
|
17287
|
-
// ['==', ['typeof', ['get', 'name'], 'string']],
|
|
17288
|
-
// ['==', ['typeof', ['get', 'population'], 'number]]
|
|
17289
|
-
// ]
|
|
17290
17098
|
function runtimeTypeChecks(expectedTypes) {
|
|
17291
17099
|
const conditions = [];
|
|
17292
17100
|
for (const property in expectedTypes) {
|
|
@@ -17381,10 +17189,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17381
17189
|
property
|
|
17382
17190
|
];
|
|
17383
17191
|
}
|
|
17384
|
-
// Determine if the list of values to be searched is homogenously typed.
|
|
17385
|
-
// If so (and if the type is string or number), then we can use a
|
|
17386
|
-
// [match, input, [...values], true, false] construction rather than a
|
|
17387
|
-
// bunch of `==` tests.
|
|
17388
17192
|
let uniformTypes = true;
|
|
17389
17193
|
const type = typeof values[0];
|
|
17390
17194
|
for (const value of values) {
|
|
@@ -17394,7 +17198,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17394
17198
|
}
|
|
17395
17199
|
}
|
|
17396
17200
|
if (uniformTypes && (type === 'string' || type === 'number')) {
|
|
17397
|
-
// Match expressions must have unique values.
|
|
17398
17201
|
const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);
|
|
17399
17202
|
return [
|
|
17400
17203
|
'match',
|
|
@@ -17404,7 +17207,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17404
17207
|
negate
|
|
17405
17208
|
];
|
|
17406
17209
|
}
|
|
17407
|
-
return [negate ? 'all' : 'any'].concat(
|
|
17210
|
+
return [negate ? 'all' : 'any'].concat(// @ts-expect-error - TS2769 - No overload matches this call.
|
|
17211
|
+
values.map(v => [
|
|
17408
17212
|
negate ? '!=' : '==',
|
|
17409
17213
|
get,
|
|
17410
17214
|
v
|
|
@@ -17427,12 +17231,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17427
17231
|
}
|
|
17428
17232
|
}
|
|
17429
17233
|
|
|
17430
|
-
//
|
|
17431
|
-
/**
|
|
17432
|
-
* Migrate the given style object in place to use expressions. Specifically,
|
|
17433
|
-
* this will convert (a) "stop" functions, and (b) legacy filters to their
|
|
17434
|
-
* expression equivalents.
|
|
17435
|
-
*/
|
|
17436
17234
|
function migrateToExpressions (style) {
|
|
17437
17235
|
const converted = [];
|
|
17438
17236
|
eachLayer(style, layer => {
|
|
@@ -17447,9 +17245,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17447
17245
|
if (isExpression(value))
|
|
17448
17246
|
return;
|
|
17449
17247
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
17450
|
-
// $FlowFixMe[prop-missing]
|
|
17451
|
-
// $FlowFixMe[incompatible-call]
|
|
17452
|
-
// $FlowFixMe[incompatible-variance]
|
|
17453
17248
|
set(convertFunction(value, reference));
|
|
17454
17249
|
converted.push(path.join('.'));
|
|
17455
17250
|
} else if (reference.tokens && typeof value === 'string') {
|
|
@@ -17459,20 +17254,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17459
17254
|
return style;
|
|
17460
17255
|
}
|
|
17461
17256
|
|
|
17462
|
-
//
|
|
17463
|
-
/**
|
|
17464
|
-
* Migrate a Mapbox GL Style to the latest version.
|
|
17465
|
-
*
|
|
17466
|
-
* @private
|
|
17467
|
-
* @alias migrate
|
|
17468
|
-
* @param {object} style a Mapbox GL Style
|
|
17469
|
-
* @returns {Object} a migrated style
|
|
17470
|
-
* @example
|
|
17471
|
-
* var fs = require('fs');
|
|
17472
|
-
* var migrate = require('mapbox-gl-style-spec').migrate;
|
|
17473
|
-
* var style = fs.readFileSync('./style.json', 'utf8');
|
|
17474
|
-
* fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
|
|
17475
|
-
*/
|
|
17476
17257
|
function migrate (style) {
|
|
17477
17258
|
let migrated = false;
|
|
17478
17259
|
if (style.version === 7) {
|
|
@@ -17489,7 +17270,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17489
17270
|
return style;
|
|
17490
17271
|
}
|
|
17491
17272
|
|
|
17492
|
-
//
|
|
17493
17273
|
function composite (style) {
|
|
17494
17274
|
const styleIDs = [];
|
|
17495
17275
|
const sourceIDs = [];
|
|
@@ -17529,7 +17309,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17529
17309
|
return style;
|
|
17530
17310
|
}
|
|
17531
17311
|
|
|
17532
|
-
//
|
|
17533
17312
|
var refProperties = [
|
|
17534
17313
|
'type',
|
|
17535
17314
|
'source',
|
|
@@ -17540,7 +17319,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17540
17319
|
'layout'
|
|
17541
17320
|
];
|
|
17542
17321
|
|
|
17543
|
-
//
|
|
17544
17322
|
function deref(layer, parent) {
|
|
17545
17323
|
const result = {};
|
|
17546
17324
|
for (const k in layer) {
|
|
@@ -17555,22 +17333,10 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17555
17333
|
});
|
|
17556
17334
|
return result;
|
|
17557
17335
|
}
|
|
17558
|
-
/**
|
|
17559
|
-
* Given an array of layers, some of which may contain `ref` properties
|
|
17560
|
-
* whose value is the `id` of another property, return a new array where
|
|
17561
|
-
* such layers have been augmented with the 'type', 'source', etc. properties
|
|
17562
|
-
* from the parent layer, and the `ref` property has been removed.
|
|
17563
|
-
*
|
|
17564
|
-
* The input is not modified. The output may contain references to portions
|
|
17565
|
-
* of the input.
|
|
17566
|
-
*
|
|
17567
|
-
* @private
|
|
17568
|
-
* @param {Array<Layer>} layers
|
|
17569
|
-
* @returns {Array<Layer>}
|
|
17570
|
-
*/
|
|
17571
17336
|
function derefLayers(layers) {
|
|
17572
17337
|
layers = layers.slice();
|
|
17573
|
-
const map =
|
|
17338
|
+
const map = /* @__PURE__ */
|
|
17339
|
+
Object.create(null);
|
|
17574
17340
|
for (let i = 0; i < layers.length; i++) {
|
|
17575
17341
|
map[layers[i].id] = layers[i];
|
|
17576
17342
|
}
|
|
@@ -17582,12 +17348,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17582
17348
|
return layers;
|
|
17583
17349
|
}
|
|
17584
17350
|
|
|
17585
|
-
//
|
|
17586
|
-
/**
|
|
17587
|
-
* Deeply compares two object literals.
|
|
17588
|
-
*
|
|
17589
|
-
* @private
|
|
17590
|
-
*/
|
|
17591
17351
|
function deepEqual(a, b) {
|
|
17592
17352
|
if (Array.isArray(a)) {
|
|
17593
17353
|
if (!Array.isArray(b) || a.length !== b.length)
|
|
@@ -17613,119 +17373,118 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17613
17373
|
return a === b;
|
|
17614
17374
|
}
|
|
17615
17375
|
|
|
17616
|
-
//
|
|
17617
17376
|
const operations = {
|
|
17618
17377
|
/*
|
|
17619
|
-
|
|
17620
|
-
|
|
17378
|
+
* { command: 'setStyle', args: [stylesheet] }
|
|
17379
|
+
*/
|
|
17621
17380
|
setStyle: 'setStyle',
|
|
17622
17381
|
/*
|
|
17623
|
-
|
|
17624
|
-
|
|
17382
|
+
* { command: 'addLayer', args: [layer, 'beforeLayerId'] }
|
|
17383
|
+
*/
|
|
17625
17384
|
addLayer: 'addLayer',
|
|
17626
17385
|
/*
|
|
17627
|
-
|
|
17628
|
-
|
|
17386
|
+
* { command: 'removeLayer', args: ['layerId'] }
|
|
17387
|
+
*/
|
|
17629
17388
|
removeLayer: 'removeLayer',
|
|
17630
17389
|
/*
|
|
17631
|
-
|
|
17632
|
-
|
|
17390
|
+
* { command: 'setPaintProperty', args: ['layerId', 'prop', value] }
|
|
17391
|
+
*/
|
|
17633
17392
|
setPaintProperty: 'setPaintProperty',
|
|
17634
17393
|
/*
|
|
17635
|
-
|
|
17636
|
-
|
|
17394
|
+
* { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }
|
|
17395
|
+
*/
|
|
17637
17396
|
setLayoutProperty: 'setLayoutProperty',
|
|
17638
17397
|
/*
|
|
17639
|
-
|
|
17640
|
-
|
|
17398
|
+
* { command: 'setSlot', args: ['layerId', slot] }
|
|
17399
|
+
*/
|
|
17641
17400
|
setSlot: 'setSlot',
|
|
17642
17401
|
/*
|
|
17643
|
-
|
|
17644
|
-
|
|
17402
|
+
* { command: 'setFilter', args: ['layerId', filter] }
|
|
17403
|
+
*/
|
|
17645
17404
|
setFilter: 'setFilter',
|
|
17646
17405
|
/*
|
|
17647
|
-
|
|
17648
|
-
|
|
17406
|
+
* { command: 'addSource', args: ['sourceId', source] }
|
|
17407
|
+
*/
|
|
17649
17408
|
addSource: 'addSource',
|
|
17650
17409
|
/*
|
|
17651
|
-
|
|
17652
|
-
|
|
17410
|
+
* { command: 'removeSource', args: ['sourceId'] }
|
|
17411
|
+
*/
|
|
17653
17412
|
removeSource: 'removeSource',
|
|
17654
17413
|
/*
|
|
17655
|
-
|
|
17656
|
-
|
|
17414
|
+
* { command: 'setGeoJSONSourceData', args: ['sourceId', data] }
|
|
17415
|
+
*/
|
|
17657
17416
|
setGeoJSONSourceData: 'setGeoJSONSourceData',
|
|
17658
17417
|
/*
|
|
17659
|
-
|
|
17660
|
-
|
|
17418
|
+
* { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }
|
|
17419
|
+
*/
|
|
17661
17420
|
setLayerZoomRange: 'setLayerZoomRange',
|
|
17662
17421
|
/*
|
|
17663
|
-
|
|
17664
|
-
|
|
17422
|
+
* { command: 'setLayerProperty', args: ['layerId', 'prop', value] }
|
|
17423
|
+
*/
|
|
17665
17424
|
setLayerProperty: 'setLayerProperty',
|
|
17666
17425
|
/*
|
|
17667
|
-
|
|
17668
|
-
|
|
17426
|
+
* { command: 'setCenter', args: [[lon, lat]] }
|
|
17427
|
+
*/
|
|
17669
17428
|
setCenter: 'setCenter',
|
|
17670
17429
|
/*
|
|
17671
|
-
|
|
17672
|
-
|
|
17430
|
+
* { command: 'setZoom', args: [zoom] }
|
|
17431
|
+
*/
|
|
17673
17432
|
setZoom: 'setZoom',
|
|
17674
17433
|
/*
|
|
17675
|
-
|
|
17676
|
-
|
|
17434
|
+
* { command: 'setBearing', args: [bearing] }
|
|
17435
|
+
*/
|
|
17677
17436
|
setBearing: 'setBearing',
|
|
17678
17437
|
/*
|
|
17679
|
-
|
|
17680
|
-
|
|
17438
|
+
* { command: 'setPitch', args: [pitch] }
|
|
17439
|
+
*/
|
|
17681
17440
|
setPitch: 'setPitch',
|
|
17682
17441
|
/*
|
|
17683
|
-
|
|
17684
|
-
|
|
17442
|
+
* { command: 'setSprite', args: ['spriteUrl'] }
|
|
17443
|
+
*/
|
|
17685
17444
|
setSprite: 'setSprite',
|
|
17686
17445
|
/*
|
|
17687
|
-
|
|
17688
|
-
|
|
17446
|
+
* { command: 'setGlyphs', args: ['glyphsUrl'] }
|
|
17447
|
+
*/
|
|
17689
17448
|
setGlyphs: 'setGlyphs',
|
|
17690
17449
|
/*
|
|
17691
|
-
|
|
17692
|
-
|
|
17450
|
+
* { command: 'setTransition', args: [transition] }
|
|
17451
|
+
*/
|
|
17693
17452
|
setTransition: 'setTransition',
|
|
17694
17453
|
/*
|
|
17695
|
-
|
|
17696
|
-
|
|
17454
|
+
* { command: 'setLighting', args: [lightProperties] }
|
|
17455
|
+
*/
|
|
17697
17456
|
setLight: 'setLight',
|
|
17698
17457
|
/*
|
|
17699
|
-
|
|
17700
|
-
|
|
17458
|
+
* { command: 'setTerrain', args: [terrainProperties] }
|
|
17459
|
+
*/
|
|
17701
17460
|
setTerrain: 'setTerrain',
|
|
17702
17461
|
/*
|
|
17703
|
-
|
|
17704
|
-
|
|
17462
|
+
* { command: 'setFog', args: [fogProperties] }
|
|
17463
|
+
*/
|
|
17705
17464
|
setFog: 'setFog',
|
|
17706
17465
|
/*
|
|
17707
|
-
|
|
17708
|
-
|
|
17466
|
+
* { command: 'setCamera', args: [cameraProperties] }
|
|
17467
|
+
*/
|
|
17709
17468
|
setCamera: 'setCamera',
|
|
17710
17469
|
/*
|
|
17711
|
-
|
|
17712
|
-
|
|
17470
|
+
* { command: 'setLights', args: [{light-3d},...] }
|
|
17471
|
+
*/
|
|
17713
17472
|
setLights: 'setLights',
|
|
17714
17473
|
/*
|
|
17715
|
-
|
|
17716
|
-
|
|
17474
|
+
* { command: 'setProjection', args: [projectionProperties] }
|
|
17475
|
+
*/
|
|
17717
17476
|
setProjection: 'setProjection',
|
|
17718
17477
|
/*
|
|
17719
|
-
|
|
17720
|
-
|
|
17478
|
+
* { command: 'addImport', args: [import] }
|
|
17479
|
+
*/
|
|
17721
17480
|
addImport: 'addImport',
|
|
17722
17481
|
/*
|
|
17723
|
-
|
|
17724
|
-
|
|
17482
|
+
* { command: 'removeImport', args: [importId] }
|
|
17483
|
+
*/
|
|
17725
17484
|
removeImport: 'removeImport',
|
|
17726
17485
|
/**
|
|
17727
|
-
|
|
17728
|
-
|
|
17486
|
+
* { command: 'updateImport', args: [importId, importSpecification | styleUrl] }
|
|
17487
|
+
*/
|
|
17729
17488
|
updateImport: 'updateImport'
|
|
17730
17489
|
};
|
|
17731
17490
|
function addSource(sourceId, after, commands) {
|
|
@@ -17770,7 +17529,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17770
17529
|
before = before || {};
|
|
17771
17530
|
after = after || {};
|
|
17772
17531
|
let sourceId;
|
|
17773
|
-
// look for sources to remove
|
|
17774
17532
|
for (sourceId in before) {
|
|
17775
17533
|
if (!before.hasOwnProperty(sourceId))
|
|
17776
17534
|
continue;
|
|
@@ -17778,7 +17536,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17778
17536
|
removeSource(sourceId, commands, sourcesRemoved);
|
|
17779
17537
|
}
|
|
17780
17538
|
}
|
|
17781
|
-
// look for sources to add/update
|
|
17782
17539
|
for (sourceId in after) {
|
|
17783
17540
|
if (!after.hasOwnProperty(sourceId))
|
|
17784
17541
|
continue;
|
|
@@ -17795,7 +17552,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17795
17552
|
]
|
|
17796
17553
|
});
|
|
17797
17554
|
} else {
|
|
17798
|
-
// no update command, must remove then add
|
|
17799
17555
|
updateSource(sourceId, after, commands, sourcesRemoved);
|
|
17800
17556
|
}
|
|
17801
17557
|
}
|
|
@@ -17846,18 +17602,14 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17846
17602
|
function diffLayers(before, after, commands) {
|
|
17847
17603
|
before = before || [];
|
|
17848
17604
|
after = after || [];
|
|
17849
|
-
// order of layers by id
|
|
17850
17605
|
const beforeOrder = before.map(pluckId);
|
|
17851
17606
|
const afterOrder = after.map(pluckId);
|
|
17852
|
-
// index of layer by id
|
|
17853
17607
|
const beforeIndex = before.reduce(indexById, {});
|
|
17854
17608
|
const afterIndex = after.reduce(indexById, {});
|
|
17855
|
-
// track order of layers as if they have been mutated
|
|
17856
17609
|
const tracker = beforeOrder.slice();
|
|
17857
|
-
|
|
17858
|
-
|
|
17610
|
+
const clean = /* @__PURE__ */
|
|
17611
|
+
Object.create(null);
|
|
17859
17612
|
let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;
|
|
17860
|
-
// remove layers
|
|
17861
17613
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
17862
17614
|
layerId = beforeOrder[i];
|
|
17863
17615
|
if (!afterIndex.hasOwnProperty(layerId)) {
|
|
@@ -17867,28 +17619,22 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17867
17619
|
});
|
|
17868
17620
|
tracker.splice(tracker.indexOf(layerId, d), 1);
|
|
17869
17621
|
} else {
|
|
17870
|
-
// limit where in tracker we need to look for a match
|
|
17871
17622
|
d++;
|
|
17872
17623
|
}
|
|
17873
17624
|
}
|
|
17874
|
-
// add/reorder layers
|
|
17875
17625
|
for (i = 0, d = 0; i < afterOrder.length; i++) {
|
|
17876
|
-
// work backwards as insert is before an existing layer
|
|
17877
17626
|
layerId = afterOrder[afterOrder.length - 1 - i];
|
|
17878
17627
|
if (tracker[tracker.length - 1 - i] === layerId)
|
|
17879
17628
|
continue;
|
|
17880
17629
|
if (beforeIndex.hasOwnProperty(layerId)) {
|
|
17881
|
-
// remove the layer before we insert at the correct position
|
|
17882
17630
|
commands.push({
|
|
17883
17631
|
command: operations.removeLayer,
|
|
17884
17632
|
args: [layerId]
|
|
17885
17633
|
});
|
|
17886
17634
|
tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);
|
|
17887
17635
|
} else {
|
|
17888
|
-
// limit where in tracker we need to look for a match
|
|
17889
17636
|
d++;
|
|
17890
17637
|
}
|
|
17891
|
-
// add layer at correct position
|
|
17892
17638
|
insertBeforeLayerId = tracker[tracker.length - i];
|
|
17893
17639
|
commands.push({
|
|
17894
17640
|
command: operations.addLayer,
|
|
@@ -17900,24 +17646,17 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17900
17646
|
tracker.splice(tracker.length - i, 0, layerId);
|
|
17901
17647
|
clean[layerId] = true;
|
|
17902
17648
|
}
|
|
17903
|
-
// update layers
|
|
17904
17649
|
for (i = 0; i < afterOrder.length; i++) {
|
|
17905
17650
|
layerId = afterOrder[i];
|
|
17906
17651
|
beforeLayer = beforeIndex[layerId];
|
|
17907
17652
|
afterLayer = afterIndex[layerId];
|
|
17908
|
-
// no need to update if previously added (new or moved)
|
|
17909
17653
|
if (clean[layerId] || deepEqual(beforeLayer, afterLayer))
|
|
17910
17654
|
continue;
|
|
17911
|
-
// If source, source-layer, or type have changes, then remove the layer
|
|
17912
|
-
// and add it back 'from scratch'.
|
|
17913
|
-
// $FlowFixMe[prop-missing] - there is no `source-layer` in background and sky layers
|
|
17914
17655
|
if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {
|
|
17915
17656
|
commands.push({
|
|
17916
17657
|
command: operations.removeLayer,
|
|
17917
17658
|
args: [layerId]
|
|
17918
17659
|
});
|
|
17919
|
-
// we add the layer back at the same position it was already in, so
|
|
17920
|
-
// there's no need to update the `tracker`
|
|
17921
17660
|
insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];
|
|
17922
17661
|
commands.push({
|
|
17923
17662
|
command: operations.addLayer,
|
|
@@ -17928,7 +17667,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17928
17667
|
});
|
|
17929
17668
|
continue;
|
|
17930
17669
|
}
|
|
17931
|
-
// layout, paint, filter, minzoom, maxzoom
|
|
17932
17670
|
diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);
|
|
17933
17671
|
diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);
|
|
17934
17672
|
if (!deepEqual(beforeLayer.slot, afterLayer.slot)) {
|
|
@@ -17959,7 +17697,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
17959
17697
|
]
|
|
17960
17698
|
});
|
|
17961
17699
|
}
|
|
17962
|
-
// handle all other layer props, including paint.*
|
|
17963
17700
|
for (prop in beforeLayer) {
|
|
17964
17701
|
if (!beforeLayer.hasOwnProperty(prop))
|
|
17965
17702
|
continue;
|
|
@@ -18001,16 +17738,12 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18001
17738
|
function diffImports(before = [], after = [], commands) {
|
|
18002
17739
|
before = before || [];
|
|
18003
17740
|
after = after || [];
|
|
18004
|
-
// order imports by id
|
|
18005
17741
|
const beforeOrder = before.map(pluckId);
|
|
18006
17742
|
const afterOrder = after.map(pluckId);
|
|
18007
|
-
// index imports by id
|
|
18008
17743
|
const beforeIndex = before.reduce(indexById, {});
|
|
18009
17744
|
const afterIndex = after.reduce(indexById, {});
|
|
18010
|
-
// track order of imports as if they have been mutated
|
|
18011
17745
|
const tracker = beforeOrder.slice();
|
|
18012
17746
|
let i, d, importId, insertBefore;
|
|
18013
|
-
// remove imports
|
|
18014
17747
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
18015
17748
|
importId = beforeOrder[i];
|
|
18016
17749
|
if (!afterIndex.hasOwnProperty(importId)) {
|
|
@@ -18020,28 +17753,22 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18020
17753
|
});
|
|
18021
17754
|
tracker.splice(tracker.indexOf(importId, d), 1);
|
|
18022
17755
|
} else {
|
|
18023
|
-
// limit where in tracker we need to look for a match
|
|
18024
17756
|
d++;
|
|
18025
17757
|
}
|
|
18026
17758
|
}
|
|
18027
|
-
// add/reorder imports
|
|
18028
17759
|
for (i = 0, d = 0; i < afterOrder.length; i++) {
|
|
18029
|
-
// work backwards as insert is before an existing import
|
|
18030
17760
|
importId = afterOrder[afterOrder.length - 1 - i];
|
|
18031
17761
|
if (tracker[tracker.length - 1 - i] === importId)
|
|
18032
17762
|
continue;
|
|
18033
17763
|
if (beforeIndex.hasOwnProperty(importId)) {
|
|
18034
|
-
// remove the import before we insert at the correct position
|
|
18035
17764
|
commands.push({
|
|
18036
17765
|
command: operations.removeImport,
|
|
18037
17766
|
args: [importId]
|
|
18038
17767
|
});
|
|
18039
17768
|
tracker.splice(tracker.lastIndexOf(importId, tracker.length - d), 1);
|
|
18040
17769
|
} else {
|
|
18041
|
-
// limit where in tracker we need to look for a match
|
|
18042
17770
|
d++;
|
|
18043
17771
|
}
|
|
18044
|
-
// add import at correct position
|
|
18045
17772
|
insertBefore = tracker[tracker.length - i];
|
|
18046
17773
|
commands.push({
|
|
18047
17774
|
command: operations.addImport,
|
|
@@ -18052,7 +17779,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18052
17779
|
});
|
|
18053
17780
|
tracker.splice(tracker.length - i, 0, importId);
|
|
18054
17781
|
}
|
|
18055
|
-
// update imports
|
|
18056
17782
|
for (const afterImport of after) {
|
|
18057
17783
|
const beforeImport = beforeIndex[afterImport.id];
|
|
18058
17784
|
if (!beforeImport || deepEqual(beforeImport, afterImport))
|
|
@@ -18066,24 +17792,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18066
17792
|
});
|
|
18067
17793
|
}
|
|
18068
17794
|
}
|
|
18069
|
-
/**
|
|
18070
|
-
* Diff two stylesheet
|
|
18071
|
-
*
|
|
18072
|
-
* Creates semanticly aware diffs that can easily be applied at runtime.
|
|
18073
|
-
* Operations produced by the diff closely resemble the mapbox-gl-js API. Any
|
|
18074
|
-
* error creating the diff will fall back to the 'setStyle' operation.
|
|
18075
|
-
*
|
|
18076
|
-
* Example diff:
|
|
18077
|
-
* [
|
|
18078
|
-
* { command: 'setConstant', args: ['@water', '#0000FF'] },
|
|
18079
|
-
* { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }
|
|
18080
|
-
* ]
|
|
18081
|
-
*
|
|
18082
|
-
* @private
|
|
18083
|
-
* @param {*} [before] stylesheet to compare from
|
|
18084
|
-
* @param {*} after stylesheet to compare to
|
|
18085
|
-
* @returns Array list of changes
|
|
18086
|
-
*/
|
|
18087
17795
|
function diffStyles(before, after) {
|
|
18088
17796
|
if (!before)
|
|
18089
17797
|
return [{
|
|
@@ -18092,7 +17800,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18092
17800
|
}];
|
|
18093
17801
|
let commands = [];
|
|
18094
17802
|
try {
|
|
18095
|
-
// Handle changes to top-level properties
|
|
18096
17803
|
if (!deepEqual(before.version, after.version)) {
|
|
18097
17804
|
return [{
|
|
18098
17805
|
command: operations.setStyle,
|
|
@@ -18135,7 +17842,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18135
17842
|
args: [after.glyphs]
|
|
18136
17843
|
});
|
|
18137
17844
|
}
|
|
18138
|
-
// Handle changes to `imports` before other mergable top-level properties
|
|
18139
17845
|
if (!deepEqual(before.imports, after.imports)) {
|
|
18140
17846
|
diffImports(before.imports, after.imports, commands);
|
|
18141
17847
|
}
|
|
@@ -18175,18 +17881,15 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18175
17881
|
args: [after.camera]
|
|
18176
17882
|
});
|
|
18177
17883
|
}
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
|
|
17884
|
+
if (!deepEqual(before['color-theme'], after['color-theme'])) {
|
|
17885
|
+
return [{
|
|
17886
|
+
command: operations.setStyle,
|
|
17887
|
+
args: [after]
|
|
17888
|
+
}];
|
|
17889
|
+
}
|
|
18181
17890
|
const sourcesRemoved = {};
|
|
18182
|
-
// First collect the {add,remove}Source commands
|
|
18183
17891
|
const removeOrAddSourceCommands = [];
|
|
18184
17892
|
diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);
|
|
18185
|
-
// Push a removeLayer command for each style layer that depends on a
|
|
18186
|
-
// source that's being removed.
|
|
18187
|
-
// Also, exclude any such layers them from the input to `diffLayers`
|
|
18188
|
-
// below, so that diffLayers produces the appropriate `addLayers`
|
|
18189
|
-
// command
|
|
18190
17893
|
const beforeLayers = [];
|
|
18191
17894
|
if (before.layers) {
|
|
18192
17895
|
before.layers.forEach(layer => {
|
|
@@ -18200,30 +17903,25 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18200
17903
|
}
|
|
18201
17904
|
});
|
|
18202
17905
|
}
|
|
18203
|
-
// Remove the terrain if the source for that terrain is being removed
|
|
18204
17906
|
let beforeTerrain = before.terrain;
|
|
18205
17907
|
if (beforeTerrain) {
|
|
18206
17908
|
if (sourcesRemoved[beforeTerrain.source]) {
|
|
18207
17909
|
commands.push({
|
|
18208
17910
|
command: operations.setTerrain,
|
|
18209
|
-
args: [
|
|
17911
|
+
args: [void 0]
|
|
18210
17912
|
});
|
|
18211
|
-
beforeTerrain =
|
|
17913
|
+
beforeTerrain = void 0;
|
|
18212
17914
|
}
|
|
18213
17915
|
}
|
|
18214
17916
|
commands = commands.concat(removeOrAddSourceCommands);
|
|
18215
|
-
// Even though terrain is a top-level property
|
|
18216
|
-
// Its like a layer in the sense that it depends on a source being present.
|
|
18217
17917
|
if (!deepEqual(beforeTerrain, after.terrain)) {
|
|
18218
17918
|
commands.push({
|
|
18219
17919
|
command: operations.setTerrain,
|
|
18220
17920
|
args: [after.terrain]
|
|
18221
17921
|
});
|
|
18222
17922
|
}
|
|
18223
|
-
// Handle changes to `layers`
|
|
18224
17923
|
diffLayers(beforeLayers, after.layers, commands);
|
|
18225
17924
|
} catch (e) {
|
|
18226
|
-
// fall back to setStyle
|
|
18227
17925
|
console.warn('Unable to compute style diff:', e);
|
|
18228
17926
|
commands = [{
|
|
18229
17927
|
command: operations.setStyle,
|
|
@@ -18233,14 +17931,12 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18233
17931
|
return commands;
|
|
18234
17932
|
}
|
|
18235
17933
|
|
|
18236
|
-
//
|
|
18237
|
-
// Note: Do not inherit from Error. It breaks when transpiling to ES5.
|
|
18238
17934
|
class ValidationError {
|
|
18239
17935
|
constructor(key, value, message, identifier) {
|
|
18240
17936
|
this.message = (key ? `${ key }: ` : '') + message;
|
|
18241
17937
|
if (identifier)
|
|
18242
17938
|
this.identifier = identifier;
|
|
18243
|
-
if (value !== null && value !==
|
|
17939
|
+
if (value !== null && value !== void 0 && value.__line__) {
|
|
18244
17940
|
this.line = value.__line__;
|
|
18245
17941
|
}
|
|
18246
17942
|
}
|
|
@@ -18248,8 +17944,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18248
17944
|
class ValidationWarning extends ValidationError {
|
|
18249
17945
|
}
|
|
18250
17946
|
|
|
18251
|
-
//
|
|
18252
|
-
// Note: Do not inherit from Error. It breaks when transpiling to ES5.
|
|
18253
17947
|
class ParsingError {
|
|
18254
17948
|
constructor(error) {
|
|
18255
17949
|
this.error = error;
|
|
@@ -18259,7 +17953,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18259
17953
|
}
|
|
18260
17954
|
}
|
|
18261
17955
|
|
|
18262
|
-
//
|
|
18263
17956
|
function validateObject(options) {
|
|
18264
17957
|
const key = options.key;
|
|
18265
17958
|
const object = options.value;
|
|
@@ -18274,7 +17967,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18274
17967
|
}
|
|
18275
17968
|
for (const objectKey in object) {
|
|
18276
17969
|
const elementSpecKey = objectKey.split('.')[0];
|
|
18277
|
-
// treat 'paint.*' as 'paint'
|
|
18278
17970
|
const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];
|
|
18279
17971
|
let validateElement;
|
|
18280
17972
|
if (elementValidators[elementSpecKey]) {
|
|
@@ -18297,26 +17989,23 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18297
17989
|
style,
|
|
18298
17990
|
styleSpec,
|
|
18299
17991
|
object,
|
|
18300
|
-
objectKey
|
|
17992
|
+
objectKey
|
|
18301
17993
|
}, object));
|
|
18302
17994
|
}
|
|
18303
17995
|
for (const elementSpecKey in elementSpecs) {
|
|
18304
|
-
// Don't check `required` when there's a custom validator for that property.
|
|
18305
17996
|
if (elementValidators[elementSpecKey]) {
|
|
18306
17997
|
continue;
|
|
18307
17998
|
}
|
|
18308
|
-
if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] ===
|
|
17999
|
+
if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === void 0 && object[elementSpecKey] === void 0) {
|
|
18309
18000
|
errors.push(new ValidationError(key, object, `missing required property "${ elementSpecKey }"`));
|
|
18310
18001
|
}
|
|
18311
18002
|
}
|
|
18312
18003
|
return errors;
|
|
18313
18004
|
}
|
|
18314
18005
|
|
|
18315
|
-
//
|
|
18316
18006
|
function validateImport(options) {
|
|
18317
18007
|
const {value, styleSpec} = options;
|
|
18318
18008
|
const {data, ...importSpec} = value;
|
|
18319
|
-
// Preserve __line__ from the value
|
|
18320
18009
|
Object.defineProperty(importSpec, '__line__', {
|
|
18321
18010
|
value: value.__line__,
|
|
18322
18011
|
enumerable: false
|
|
@@ -18325,7 +18014,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18325
18014
|
value: importSpec,
|
|
18326
18015
|
valueSpec: styleSpec.import
|
|
18327
18016
|
}));
|
|
18328
|
-
// Empty string is reserved for the root style id
|
|
18329
18017
|
if (unbundle(importSpec.id) === '') {
|
|
18330
18018
|
const key = `${ options.key }.id`;
|
|
18331
18019
|
errors.push(new ValidationError(key, importSpec, `import id can't be an empty string`));
|
|
@@ -18337,7 +18025,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18337
18025
|
return errors;
|
|
18338
18026
|
}
|
|
18339
18027
|
|
|
18340
|
-
//
|
|
18341
18028
|
function validateArray(options) {
|
|
18342
18029
|
const array = options.value;
|
|
18343
18030
|
const arraySpec = options.valueSpec;
|
|
@@ -18359,7 +18046,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18359
18046
|
'values': arraySpec.values,
|
|
18360
18047
|
'minimum': arraySpec.minimum,
|
|
18361
18048
|
'maximum': arraySpec.maximum,
|
|
18362
|
-
function:
|
|
18049
|
+
function: void 0
|
|
18363
18050
|
};
|
|
18364
18051
|
if (styleSpec.$version < 7) {
|
|
18365
18052
|
arrayElementSpec.function = arraySpec.function;
|
|
@@ -18382,13 +18069,11 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18382
18069
|
return errors;
|
|
18383
18070
|
}
|
|
18384
18071
|
|
|
18385
|
-
//
|
|
18386
18072
|
function validateNumber(options) {
|
|
18387
18073
|
const key = options.key;
|
|
18388
18074
|
const value = options.value;
|
|
18389
18075
|
const valueSpec = options.valueSpec;
|
|
18390
18076
|
let type = getType(value);
|
|
18391
|
-
// eslint-disable-next-line no-self-compare
|
|
18392
18077
|
if (type === 'number' && value !== value) {
|
|
18393
18078
|
type = 'NaN';
|
|
18394
18079
|
}
|
|
@@ -18418,7 +18103,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18418
18103
|
return [];
|
|
18419
18104
|
}
|
|
18420
18105
|
|
|
18421
|
-
//
|
|
18422
18106
|
function validateFunction(options) {
|
|
18423
18107
|
const functionValueSpec = options.valueSpec;
|
|
18424
18108
|
const functionType = unbundle(options.value.type);
|
|
@@ -18426,7 +18110,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18426
18110
|
let stopDomainValues = {};
|
|
18427
18111
|
let previousStopDomainValue;
|
|
18428
18112
|
let previousStopDomainZoom;
|
|
18429
|
-
const isZoomFunction = functionType !== 'categorical' && options.value.property ===
|
|
18113
|
+
const isZoomFunction = functionType !== 'categorical' && options.value.property === void 0;
|
|
18430
18114
|
const isPropertyFunction = !isZoomFunction;
|
|
18431
18115
|
const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' && getType(options.value.stops[0]) === 'array' && getType(options.value.stops[0][0]) === 'object';
|
|
18432
18116
|
const errors = validateObject({
|
|
@@ -18456,33 +18140,33 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18456
18140
|
errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));
|
|
18457
18141
|
}
|
|
18458
18142
|
}
|
|
18459
|
-
if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property ===
|
|
18143
|
+
if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === void 0) {
|
|
18460
18144
|
errors.push(new ValidationError(options.key, options.value, '"property" property is required'));
|
|
18461
18145
|
}
|
|
18462
18146
|
return errors;
|
|
18463
|
-
function validateFunctionStops(
|
|
18147
|
+
function validateFunctionStops(options2) {
|
|
18464
18148
|
if (functionType === 'identity') {
|
|
18465
|
-
return [new ValidationError(
|
|
18149
|
+
return [new ValidationError(options2.key, options2.value, 'identity function may not have a "stops" property')];
|
|
18466
18150
|
}
|
|
18467
|
-
let
|
|
18468
|
-
const value =
|
|
18469
|
-
|
|
18470
|
-
key:
|
|
18151
|
+
let errors2 = [];
|
|
18152
|
+
const value = options2.value;
|
|
18153
|
+
errors2 = errors2.concat(validateArray({
|
|
18154
|
+
key: options2.key,
|
|
18471
18155
|
value,
|
|
18472
|
-
valueSpec:
|
|
18473
|
-
style:
|
|
18474
|
-
styleSpec:
|
|
18156
|
+
valueSpec: options2.valueSpec,
|
|
18157
|
+
style: options2.style,
|
|
18158
|
+
styleSpec: options2.styleSpec,
|
|
18475
18159
|
arrayElementValidator: validateFunctionStop
|
|
18476
18160
|
}));
|
|
18477
18161
|
if (getType(value) === 'array' && value.length === 0) {
|
|
18478
|
-
|
|
18162
|
+
errors2.push(new ValidationError(options2.key, value, 'array must have at least one stop'));
|
|
18479
18163
|
}
|
|
18480
|
-
return
|
|
18164
|
+
return errors2;
|
|
18481
18165
|
}
|
|
18482
|
-
function validateFunctionStop(
|
|
18483
|
-
let
|
|
18484
|
-
const value =
|
|
18485
|
-
const key =
|
|
18166
|
+
function validateFunctionStop(options2) {
|
|
18167
|
+
let errors2 = [];
|
|
18168
|
+
const value = options2.value;
|
|
18169
|
+
const key = options2.key;
|
|
18486
18170
|
if (getType(value) !== 'array') {
|
|
18487
18171
|
return [new ValidationError(key, value, `array expected, ${ getType(value) } found`)];
|
|
18488
18172
|
}
|
|
@@ -18493,10 +18177,10 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18493
18177
|
if (getType(value[0]) !== 'object') {
|
|
18494
18178
|
return [new ValidationError(key, value, `object expected, ${ getType(value[0]) } found`)];
|
|
18495
18179
|
}
|
|
18496
|
-
if (value[0].zoom ===
|
|
18180
|
+
if (value[0].zoom === void 0) {
|
|
18497
18181
|
return [new ValidationError(key, value, 'object stop key must have zoom')];
|
|
18498
18182
|
}
|
|
18499
|
-
if (value[0].value ===
|
|
18183
|
+
if (value[0].value === void 0) {
|
|
18500
18184
|
return [new ValidationError(key, value, 'object stop key must have value')];
|
|
18501
18185
|
}
|
|
18502
18186
|
const nextStopDomainZoom = unbundle(value[0].zoom);
|
|
@@ -18508,86 +18192,85 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18508
18192
|
}
|
|
18509
18193
|
if (nextStopDomainZoom !== previousStopDomainZoom) {
|
|
18510
18194
|
previousStopDomainZoom = nextStopDomainZoom;
|
|
18511
|
-
previousStopDomainValue =
|
|
18195
|
+
previousStopDomainValue = void 0;
|
|
18512
18196
|
stopDomainValues = {};
|
|
18513
18197
|
}
|
|
18514
|
-
|
|
18198
|
+
errors2 = errors2.concat(validateObject({
|
|
18515
18199
|
key: `${ key }[0]`,
|
|
18516
18200
|
value: value[0],
|
|
18517
18201
|
valueSpec: { zoom: {} },
|
|
18518
|
-
style:
|
|
18519
|
-
styleSpec:
|
|
18202
|
+
style: options2.style,
|
|
18203
|
+
styleSpec: options2.styleSpec,
|
|
18520
18204
|
objectElementValidators: {
|
|
18521
18205
|
zoom: validateNumber,
|
|
18522
18206
|
value: validateStopDomainValue
|
|
18523
18207
|
}
|
|
18524
18208
|
}));
|
|
18525
18209
|
} else {
|
|
18526
|
-
|
|
18210
|
+
errors2 = errors2.concat(validateStopDomainValue({
|
|
18527
18211
|
key: `${ key }[0]`,
|
|
18528
18212
|
value: value[0],
|
|
18529
18213
|
valueSpec: {},
|
|
18530
|
-
style:
|
|
18531
|
-
styleSpec:
|
|
18214
|
+
style: options2.style,
|
|
18215
|
+
styleSpec: options2.styleSpec
|
|
18532
18216
|
}, value));
|
|
18533
18217
|
}
|
|
18534
18218
|
if (isExpression(deepUnbundle(value[1]))) {
|
|
18535
|
-
return
|
|
18219
|
+
return errors2.concat([new ValidationError(`${ key }[1]`, value[1], 'expressions are not allowed in function stops.')]);
|
|
18536
18220
|
}
|
|
18537
|
-
return
|
|
18221
|
+
return errors2.concat(validate({
|
|
18538
18222
|
key: `${ key }[1]`,
|
|
18539
18223
|
value: value[1],
|
|
18540
18224
|
valueSpec: functionValueSpec,
|
|
18541
|
-
style:
|
|
18542
|
-
styleSpec:
|
|
18225
|
+
style: options2.style,
|
|
18226
|
+
styleSpec: options2.styleSpec
|
|
18543
18227
|
}));
|
|
18544
18228
|
}
|
|
18545
|
-
function validateStopDomainValue(
|
|
18546
|
-
const type = getType(
|
|
18547
|
-
const value = unbundle(
|
|
18548
|
-
const reportValue =
|
|
18229
|
+
function validateStopDomainValue(options2, stop) {
|
|
18230
|
+
const type = getType(options2.value);
|
|
18231
|
+
const value = unbundle(options2.value);
|
|
18232
|
+
const reportValue = options2.value !== null ? options2.value : stop;
|
|
18549
18233
|
if (!stopKeyType) {
|
|
18550
18234
|
stopKeyType = type;
|
|
18551
18235
|
} else if (type !== stopKeyType) {
|
|
18552
|
-
return [new ValidationError(
|
|
18236
|
+
return [new ValidationError(options2.key, reportValue, `${ type } stop domain type must match previous stop domain type ${ stopKeyType }`)];
|
|
18553
18237
|
}
|
|
18554
18238
|
if (type !== 'number' && type !== 'string' && type !== 'boolean' && typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
|
|
18555
|
-
return [new ValidationError(
|
|
18239
|
+
return [new ValidationError(options2.key, reportValue, 'stop domain value must be a number, string, or boolean')];
|
|
18556
18240
|
}
|
|
18557
18241
|
if (type !== 'number' && functionType !== 'categorical') {
|
|
18558
18242
|
let message = `number expected, ${ type } found`;
|
|
18559
|
-
if (supportsPropertyExpression(functionValueSpec) && functionType ===
|
|
18243
|
+
if (supportsPropertyExpression(functionValueSpec) && functionType === void 0) {
|
|
18560
18244
|
message += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.';
|
|
18561
18245
|
}
|
|
18562
|
-
return [new ValidationError(
|
|
18246
|
+
return [new ValidationError(options2.key, reportValue, message)];
|
|
18563
18247
|
}
|
|
18564
18248
|
if (functionType === 'categorical' && type === 'number' && (typeof value !== 'number' || !isFinite(value) || Math.floor(value) !== value)) {
|
|
18565
|
-
return [new ValidationError(
|
|
18249
|
+
return [new ValidationError(options2.key, reportValue, `integer expected, found ${ String(value) }`)];
|
|
18566
18250
|
}
|
|
18567
|
-
if (functionType !== 'categorical' && type === 'number' && typeof value === 'number' && typeof previousStopDomainValue === 'number' && previousStopDomainValue !==
|
|
18568
|
-
return [new ValidationError(
|
|
18251
|
+
if (functionType !== 'categorical' && type === 'number' && typeof value === 'number' && typeof previousStopDomainValue === 'number' && previousStopDomainValue !== void 0 && value < previousStopDomainValue) {
|
|
18252
|
+
return [new ValidationError(options2.key, reportValue, 'stop domain values must appear in ascending order')];
|
|
18569
18253
|
} else {
|
|
18570
18254
|
previousStopDomainValue = value;
|
|
18571
18255
|
}
|
|
18572
18256
|
if (functionType === 'categorical' && value in stopDomainValues) {
|
|
18573
|
-
return [new ValidationError(
|
|
18257
|
+
return [new ValidationError(options2.key, reportValue, 'stop domain values must be unique')];
|
|
18574
18258
|
} else {
|
|
18575
18259
|
stopDomainValues[value] = true;
|
|
18576
18260
|
}
|
|
18577
18261
|
return [];
|
|
18578
18262
|
}
|
|
18579
|
-
function validateFunctionDefault(
|
|
18263
|
+
function validateFunctionDefault(options2) {
|
|
18580
18264
|
return validate({
|
|
18581
|
-
key:
|
|
18582
|
-
value:
|
|
18265
|
+
key: options2.key,
|
|
18266
|
+
value: options2.value,
|
|
18583
18267
|
valueSpec: functionValueSpec,
|
|
18584
|
-
style:
|
|
18585
|
-
styleSpec:
|
|
18268
|
+
style: options2.style,
|
|
18269
|
+
styleSpec: options2.styleSpec
|
|
18586
18270
|
});
|
|
18587
18271
|
}
|
|
18588
18272
|
}
|
|
18589
18273
|
|
|
18590
|
-
//
|
|
18591
18274
|
function validateExpression(options) {
|
|
18592
18275
|
const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);
|
|
18593
18276
|
if (expression.result === 'error') {
|
|
@@ -18619,7 +18302,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18619
18302
|
return [];
|
|
18620
18303
|
}
|
|
18621
18304
|
function disallowedFilterParameters(e, options) {
|
|
18622
|
-
const disallowedParameters =
|
|
18305
|
+
const disallowedParameters = /* @__PURE__ */
|
|
18306
|
+
new Set([
|
|
18623
18307
|
'zoom',
|
|
18624
18308
|
'feature-state',
|
|
18625
18309
|
'pitch',
|
|
@@ -18645,7 +18329,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18645
18329
|
return errors;
|
|
18646
18330
|
}
|
|
18647
18331
|
|
|
18648
|
-
//
|
|
18649
18332
|
function validateBoolean(options) {
|
|
18650
18333
|
const value = options.value;
|
|
18651
18334
|
const key = options.key;
|
|
@@ -18656,7 +18339,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18656
18339
|
return [];
|
|
18657
18340
|
}
|
|
18658
18341
|
|
|
18659
|
-
//
|
|
18660
18342
|
function validateColor(options) {
|
|
18661
18343
|
const key = options.key;
|
|
18662
18344
|
const value = options.value;
|
|
@@ -18670,19 +18352,16 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18670
18352
|
return [];
|
|
18671
18353
|
}
|
|
18672
18354
|
|
|
18673
|
-
//
|
|
18674
18355
|
function validateEnum(options) {
|
|
18675
18356
|
const key = options.key;
|
|
18676
18357
|
const value = options.value;
|
|
18677
18358
|
const valueSpec = options.valueSpec;
|
|
18678
18359
|
const errors = [];
|
|
18679
18360
|
if (Array.isArray(valueSpec.values)) {
|
|
18680
|
-
// <=v7
|
|
18681
18361
|
if (valueSpec.values.indexOf(unbundle(value)) === -1) {
|
|
18682
18362
|
errors.push(new ValidationError(key, value, `expected one of [${ valueSpec.values.join(', ') }], ${ JSON.stringify(value) } found`));
|
|
18683
18363
|
}
|
|
18684
18364
|
} else {
|
|
18685
|
-
// >=v8
|
|
18686
18365
|
if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {
|
|
18687
18366
|
errors.push(new ValidationError(key, value, `expected one of [${ Object.keys(valueSpec.values).join(', ') }], ${ JSON.stringify(value) } found`));
|
|
18688
18367
|
}
|
|
@@ -18690,10 +18369,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18690
18369
|
return errors;
|
|
18691
18370
|
}
|
|
18692
18371
|
|
|
18693
|
-
//
|
|
18694
18372
|
function validateFilter(options) {
|
|
18695
18373
|
if (isExpressionFilter(deepUnbundle(options.value))) {
|
|
18696
|
-
// We default to a layerType of `fill` because that points to a non-dynamic filter definition within the style-spec.
|
|
18697
18374
|
const layerType = options.layerType || 'fill';
|
|
18698
18375
|
return validateExpression(extend({}, options, {
|
|
18699
18376
|
expressionContext: 'filter',
|
|
@@ -18730,13 +18407,11 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18730
18407
|
if (value.length >= 2 && unbundle(value[1]) === '$type') {
|
|
18731
18408
|
errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${ value[0] }"`));
|
|
18732
18409
|
}
|
|
18733
|
-
/* falls through */
|
|
18734
18410
|
case '==':
|
|
18735
18411
|
case '!=':
|
|
18736
18412
|
if (value.length !== 3) {
|
|
18737
18413
|
errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
|
|
18738
18414
|
}
|
|
18739
|
-
/* falls through */
|
|
18740
18415
|
case 'in':
|
|
18741
18416
|
case '!in':
|
|
18742
18417
|
if (value.length >= 2) {
|
|
@@ -18785,7 +18460,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18785
18460
|
return errors;
|
|
18786
18461
|
}
|
|
18787
18462
|
|
|
18788
|
-
//
|
|
18789
18463
|
function validateProperty(options, propertyType) {
|
|
18790
18464
|
const key = options.key;
|
|
18791
18465
|
const style = options.style;
|
|
@@ -18813,7 +18487,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18813
18487
|
let tokenMatch;
|
|
18814
18488
|
if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {
|
|
18815
18489
|
const example = `\`{ "type": "identity", "property": ${ tokenMatch ? JSON.stringify(tokenMatch[1]) : '"_"' } }\``;
|
|
18816
|
-
return [new ValidationError(key, value, `"${ propertyKey }" does not support interpolation syntax
|
|
18490
|
+
return [new ValidationError(key, value, `"${ propertyKey }" does not support interpolation syntax
|
|
18491
|
+
Use an identity property function instead: ${ example }.`)];
|
|
18817
18492
|
}
|
|
18818
18493
|
const errors = [];
|
|
18819
18494
|
if (options.layerType === 'symbol') {
|
|
@@ -18825,7 +18500,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18825
18500
|
}
|
|
18826
18501
|
} else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
|
|
18827
18502
|
if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
|
|
18828
|
-
// Performance related style spec limitation: zoom and light expressions are not allowed for e.g. trees.
|
|
18829
18503
|
const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
|
|
18830
18504
|
const expressionObj = expression.value.expression || expression.value._styleExpression.expression;
|
|
18831
18505
|
if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
|
|
@@ -18841,23 +18515,21 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18841
18515
|
valueSpec,
|
|
18842
18516
|
style,
|
|
18843
18517
|
styleSpec,
|
|
18518
|
+
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'expressionContext' does not exist in type 'ValidationOptions'.
|
|
18844
18519
|
expressionContext: 'property',
|
|
18845
18520
|
propertyType,
|
|
18846
18521
|
propertyKey
|
|
18847
18522
|
}));
|
|
18848
18523
|
}
|
|
18849
18524
|
|
|
18850
|
-
//
|
|
18851
18525
|
function validatePaintProperty(options) {
|
|
18852
18526
|
return validateProperty(options, 'paint');
|
|
18853
18527
|
}
|
|
18854
18528
|
|
|
18855
|
-
//
|
|
18856
18529
|
function validateLayoutProperty(options) {
|
|
18857
18530
|
return validateProperty(options, 'layout');
|
|
18858
18531
|
}
|
|
18859
18532
|
|
|
18860
|
-
//
|
|
18861
18533
|
function validateLayer(options) {
|
|
18862
18534
|
let errors = [];
|
|
18863
18535
|
const layer = options.value;
|
|
@@ -18874,7 +18546,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18874
18546
|
for (let i = 0; i < options.arrayIndex; i++) {
|
|
18875
18547
|
const otherLayer = style.layers[i];
|
|
18876
18548
|
if (unbundle(otherLayer.id) === layerId) {
|
|
18877
|
-
// $FlowFixMe[prop-missing] - id.__line__ is added dynamically during the readStyle step
|
|
18878
18549
|
errors.push(new ValidationError(key, layer.id, `duplicate layer id "${ layer.id }", previously used at line ${ otherLayer.id.__line__ }`));
|
|
18879
18550
|
}
|
|
18880
18551
|
}
|
|
@@ -18892,13 +18563,13 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18892
18563
|
}
|
|
18893
18564
|
});
|
|
18894
18565
|
let parent;
|
|
18895
|
-
style.layers.forEach(
|
|
18896
|
-
if (unbundle(
|
|
18897
|
-
parent =
|
|
18566
|
+
style.layers.forEach(layer2 => {
|
|
18567
|
+
if (unbundle(layer2.id) === ref)
|
|
18568
|
+
parent = layer2;
|
|
18898
18569
|
});
|
|
18899
18570
|
if (!parent) {
|
|
18900
18571
|
if (typeof ref === 'string')
|
|
18901
|
-
errors.push(new ValidationError(key, layer.ref, `ref layer "${ ref }" not found`));
|
|
18572
|
+
errors.push(new ValidationError(key, layer.ref, `ref layer "${ ref }" not found`));
|
|
18902
18573
|
} else if (parent.ref) {
|
|
18903
18574
|
errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));
|
|
18904
18575
|
} else {
|
|
@@ -18924,11 +18595,11 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18924
18595
|
'raster',
|
|
18925
18596
|
'raster-particle'
|
|
18926
18597
|
].includes(type)) {
|
|
18927
|
-
errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type
|
|
18598
|
+
errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type 'raster'.`));
|
|
18928
18599
|
} else if (type === 'line' && layer.paint && (layer.paint['line-gradient'] || layer.paint['line-trim-offset']) && (sourceType !== 'geojson' || !source.lineMetrics)) {
|
|
18929
18600
|
errors.push(new ValidationError(key, layer, `layer "${ layer.id }" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`));
|
|
18930
18601
|
} else if (type === 'raster-particle' && sourceType !== 'raster-array') {
|
|
18931
|
-
errors.push(new ValidationError(key, layer.source, `layer "${ layer.id }" requires a
|
|
18602
|
+
errors.push(new ValidationError(key, layer.source, `layer "${ layer.id }" requires a 'raster-array' source.`));
|
|
18932
18603
|
}
|
|
18933
18604
|
}
|
|
18934
18605
|
}
|
|
@@ -18951,42 +18622,45 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18951
18622
|
valueSpec: styleSpec.layer.type,
|
|
18952
18623
|
style: options.style,
|
|
18953
18624
|
styleSpec: options.styleSpec,
|
|
18625
|
+
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'object' does not exist in type 'ValidationOptions'.
|
|
18954
18626
|
object: layer,
|
|
18955
18627
|
objectKey: 'type'
|
|
18956
18628
|
});
|
|
18957
18629
|
},
|
|
18958
|
-
filter(
|
|
18959
|
-
return validateFilter(extend({ layerType: type },
|
|
18630
|
+
filter(options2) {
|
|
18631
|
+
return validateFilter(extend({ layerType: type }, options2));
|
|
18960
18632
|
},
|
|
18961
|
-
layout(
|
|
18633
|
+
layout(options2) {
|
|
18962
18634
|
return validateObject({
|
|
18635
|
+
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'layer' does not exist in type 'Options'.
|
|
18963
18636
|
layer,
|
|
18964
|
-
key:
|
|
18965
|
-
value:
|
|
18637
|
+
key: options2.key,
|
|
18638
|
+
value: options2.value,
|
|
18966
18639
|
valueSpec: {},
|
|
18967
|
-
style:
|
|
18968
|
-
styleSpec:
|
|
18640
|
+
style: options2.style,
|
|
18641
|
+
styleSpec: options2.styleSpec,
|
|
18969
18642
|
objectElementValidators: {
|
|
18970
|
-
'*'(
|
|
18971
|
-
return validateLayoutProperty(extend({ layerType: type },
|
|
18643
|
+
'*'(options3) {
|
|
18644
|
+
return validateLayoutProperty(extend({ layerType: type }, options3));
|
|
18972
18645
|
}
|
|
18973
18646
|
}
|
|
18974
18647
|
});
|
|
18975
18648
|
},
|
|
18976
|
-
paint(
|
|
18649
|
+
paint(options2) {
|
|
18977
18650
|
return validateObject({
|
|
18651
|
+
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'layer' does not exist in type 'Options'.
|
|
18978
18652
|
layer,
|
|
18979
|
-
key:
|
|
18980
|
-
value:
|
|
18653
|
+
key: options2.key,
|
|
18654
|
+
value: options2.value,
|
|
18981
18655
|
valueSpec: {},
|
|
18982
|
-
style:
|
|
18983
|
-
styleSpec:
|
|
18656
|
+
style: options2.style,
|
|
18657
|
+
styleSpec: options2.styleSpec,
|
|
18984
18658
|
objectElementValidators: {
|
|
18985
|
-
'*'(
|
|
18659
|
+
'*'(options3) {
|
|
18986
18660
|
return validatePaintProperty(extend({
|
|
18987
18661
|
layerType: type,
|
|
18988
18662
|
layer
|
|
18989
|
-
},
|
|
18663
|
+
}, options3));
|
|
18990
18664
|
}
|
|
18991
18665
|
}
|
|
18992
18666
|
});
|
|
@@ -18996,7 +18670,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
18996
18670
|
return errors;
|
|
18997
18671
|
}
|
|
18998
18672
|
|
|
18999
|
-
//
|
|
19000
18673
|
function validateString(options) {
|
|
19001
18674
|
const value = options.value;
|
|
19002
18675
|
const key = options.key;
|
|
@@ -19007,7 +18680,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19007
18680
|
return [];
|
|
19008
18681
|
}
|
|
19009
18682
|
|
|
19010
|
-
//
|
|
19011
18683
|
const objectElementValidators = { promoteId: validatePromoteId };
|
|
19012
18684
|
function validateSource(options) {
|
|
19013
18685
|
const value = options.value;
|
|
@@ -19131,12 +18803,10 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19131
18803
|
}
|
|
19132
18804
|
}
|
|
19133
18805
|
|
|
19134
|
-
//
|
|
19135
|
-
// Allow any URL, use dummy base, if it's a relative URL
|
|
19136
18806
|
function isValidUrl(str, allowRelativeUrls) {
|
|
19137
18807
|
const isRelative = str.indexOf('://') === -1;
|
|
19138
18808
|
try {
|
|
19139
|
-
new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' :
|
|
18809
|
+
new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' : void 0);
|
|
19140
18810
|
return true;
|
|
19141
18811
|
} catch (_) {
|
|
19142
18812
|
return false;
|
|
@@ -19159,7 +18829,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19159
18829
|
return errors;
|
|
19160
18830
|
}
|
|
19161
18831
|
|
|
19162
|
-
//
|
|
19163
18832
|
function validateLight(options) {
|
|
19164
18833
|
const light = options.value;
|
|
19165
18834
|
const styleSpec = options.styleSpec;
|
|
@@ -19167,7 +18836,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19167
18836
|
const style = options.style;
|
|
19168
18837
|
let errors = [];
|
|
19169
18838
|
const rootType = getType(light);
|
|
19170
|
-
if (light ===
|
|
18839
|
+
if (light === void 0) {
|
|
19171
18840
|
return errors;
|
|
19172
18841
|
} else if (rootType !== 'object') {
|
|
19173
18842
|
errors = errors.concat([new ValidationError('light', light, `object expected, ${ rootType } found`)]);
|
|
@@ -19198,7 +18867,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19198
18867
|
return errors;
|
|
19199
18868
|
}
|
|
19200
18869
|
|
|
19201
|
-
//
|
|
19202
18870
|
function validateLights(options) {
|
|
19203
18871
|
const light = options.value;
|
|
19204
18872
|
let errors = [];
|
|
@@ -19215,21 +18883,20 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19215
18883
|
const key = options.key;
|
|
19216
18884
|
const style = options.style;
|
|
19217
18885
|
const lights = options.style.lights;
|
|
19218
|
-
for (const
|
|
18886
|
+
for (const key2 of [
|
|
19219
18887
|
'type',
|
|
19220
18888
|
'id'
|
|
19221
18889
|
]) {
|
|
19222
|
-
if (!(
|
|
19223
|
-
errors = errors.concat([new ValidationError('light-3d', light, `missing property ${
|
|
18890
|
+
if (!(key2 in light)) {
|
|
18891
|
+
errors = errors.concat([new ValidationError('light-3d', light, `missing property ${ key2 } on light`)]);
|
|
19224
18892
|
return errors;
|
|
19225
18893
|
}
|
|
19226
18894
|
}
|
|
19227
18895
|
if (light.type && lights) {
|
|
19228
18896
|
for (let i = 0; i < options.arrayIndex; i++) {
|
|
19229
|
-
const
|
|
18897
|
+
const lightType2 = unbundle(light.type);
|
|
19230
18898
|
const otherLight = lights[i];
|
|
19231
|
-
if (unbundle(otherLight.type) ===
|
|
19232
|
-
// $FlowFixMe[prop-missing] - id.__line__ is added dynamically during the readStyle step
|
|
18899
|
+
if (unbundle(otherLight.type) === lightType2) {
|
|
19233
18900
|
errors.push(new ValidationError(key, light.id, `duplicate light type "${ light.type }", previously defined at line ${ otherLight.id.__line__ }`));
|
|
19234
18901
|
}
|
|
19235
18902
|
}
|
|
@@ -19240,9 +18907,9 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19240
18907
|
return errors;
|
|
19241
18908
|
}
|
|
19242
18909
|
const lightPropertySpec = styleSpec[lightType];
|
|
19243
|
-
for (const
|
|
19244
|
-
if (
|
|
19245
|
-
const properties = light[
|
|
18910
|
+
for (const key2 in light) {
|
|
18911
|
+
if (key2 === 'properties') {
|
|
18912
|
+
const properties = light[key2];
|
|
19246
18913
|
const propertiesType = getType(properties);
|
|
19247
18914
|
if (propertiesType !== 'object') {
|
|
19248
18915
|
errors = errors.concat([new ValidationError('properties', properties, `object expected, ${ propertiesType } found`)]);
|
|
@@ -19262,32 +18929,31 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19262
18929
|
}
|
|
19263
18930
|
}
|
|
19264
18931
|
} else {
|
|
19265
|
-
const transitionMatch =
|
|
18932
|
+
const transitionMatch = key2.match(/^(.*)-transition$/);
|
|
19266
18933
|
if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {
|
|
19267
18934
|
errors = errors.concat(validate({
|
|
19268
|
-
key,
|
|
19269
|
-
value: light[
|
|
18935
|
+
key: key2,
|
|
18936
|
+
value: light[key2],
|
|
19270
18937
|
valueSpec: styleSpec.transition,
|
|
19271
18938
|
style,
|
|
19272
18939
|
styleSpec
|
|
19273
18940
|
}));
|
|
19274
|
-
} else if (lightSpec[
|
|
18941
|
+
} else if (lightSpec[key2]) {
|
|
19275
18942
|
errors = errors.concat(validate({
|
|
19276
|
-
key,
|
|
19277
|
-
value: light[
|
|
19278
|
-
valueSpec: lightSpec[
|
|
18943
|
+
key: key2,
|
|
18944
|
+
value: light[key2],
|
|
18945
|
+
valueSpec: lightSpec[key2],
|
|
19279
18946
|
style,
|
|
19280
18947
|
styleSpec
|
|
19281
18948
|
}));
|
|
19282
18949
|
} else {
|
|
19283
|
-
errors = errors.concat([new ValidationWarning(
|
|
18950
|
+
errors = errors.concat([new ValidationWarning(key2, light[key2], `unknown property "${ key2 }"`)]);
|
|
19284
18951
|
}
|
|
19285
18952
|
}
|
|
19286
18953
|
}
|
|
19287
18954
|
return errors;
|
|
19288
18955
|
}
|
|
19289
18956
|
|
|
19290
|
-
//
|
|
19291
18957
|
function validateTerrain(options) {
|
|
19292
18958
|
const terrain = options.value;
|
|
19293
18959
|
const key = options.key;
|
|
@@ -19296,7 +18962,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19296
18962
|
const terrainSpec = styleSpec.terrain;
|
|
19297
18963
|
let errors = [];
|
|
19298
18964
|
const rootType = getType(terrain);
|
|
19299
|
-
if (terrain ===
|
|
18965
|
+
if (terrain === void 0) {
|
|
19300
18966
|
return errors;
|
|
19301
18967
|
} else if (rootType === 'null') {
|
|
19302
18968
|
return errors;
|
|
@@ -19304,26 +18970,26 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19304
18970
|
errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${ rootType } found`)]);
|
|
19305
18971
|
return errors;
|
|
19306
18972
|
}
|
|
19307
|
-
for (const
|
|
19308
|
-
const transitionMatch =
|
|
18973
|
+
for (const key2 in terrain) {
|
|
18974
|
+
const transitionMatch = key2.match(/^(.*)-transition$/);
|
|
19309
18975
|
if (transitionMatch && terrainSpec[transitionMatch[1]] && terrainSpec[transitionMatch[1]].transition) {
|
|
19310
18976
|
errors = errors.concat(validate({
|
|
19311
|
-
key,
|
|
19312
|
-
value: terrain[
|
|
18977
|
+
key: key2,
|
|
18978
|
+
value: terrain[key2],
|
|
19313
18979
|
valueSpec: styleSpec.transition,
|
|
19314
18980
|
style,
|
|
19315
18981
|
styleSpec
|
|
19316
18982
|
}));
|
|
19317
|
-
} else if (terrainSpec[
|
|
18983
|
+
} else if (terrainSpec[key2]) {
|
|
19318
18984
|
errors = errors.concat(validate({
|
|
19319
|
-
key,
|
|
19320
|
-
value: terrain[
|
|
19321
|
-
valueSpec: terrainSpec[
|
|
18985
|
+
key: key2,
|
|
18986
|
+
value: terrain[key2],
|
|
18987
|
+
valueSpec: terrainSpec[key2],
|
|
19322
18988
|
style,
|
|
19323
18989
|
styleSpec
|
|
19324
18990
|
}));
|
|
19325
18991
|
} else {
|
|
19326
|
-
errors = errors.concat([new ValidationWarning(
|
|
18992
|
+
errors = errors.concat([new ValidationWarning(key2, terrain[key2], `unknown property "${ key2 }"`)]);
|
|
19327
18993
|
}
|
|
19328
18994
|
}
|
|
19329
18995
|
if (!terrain.source) {
|
|
@@ -19340,7 +19006,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19340
19006
|
return errors;
|
|
19341
19007
|
}
|
|
19342
19008
|
|
|
19343
|
-
//
|
|
19344
19009
|
function validateFog(options) {
|
|
19345
19010
|
const fog = options.value;
|
|
19346
19011
|
const style = options.style;
|
|
@@ -19348,7 +19013,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19348
19013
|
const fogSpec = styleSpec.fog;
|
|
19349
19014
|
let errors = [];
|
|
19350
19015
|
const rootType = getType(fog);
|
|
19351
|
-
if (fog ===
|
|
19016
|
+
if (fog === void 0) {
|
|
19352
19017
|
return errors;
|
|
19353
19018
|
} else if (rootType !== 'object') {
|
|
19354
19019
|
errors = errors.concat([new ValidationError('fog', fog, `object expected, ${ rootType } found`)]);
|
|
@@ -19379,7 +19044,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19379
19044
|
return errors;
|
|
19380
19045
|
}
|
|
19381
19046
|
|
|
19382
|
-
//
|
|
19383
19047
|
function validateFormatted(options) {
|
|
19384
19048
|
if (validateString(options).length === 0) {
|
|
19385
19049
|
return [];
|
|
@@ -19387,7 +19051,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19387
19051
|
return validateExpression(options);
|
|
19388
19052
|
}
|
|
19389
19053
|
|
|
19390
|
-
//
|
|
19391
19054
|
function validateImage(options) {
|
|
19392
19055
|
if (validateString(options).length === 0) {
|
|
19393
19056
|
return [];
|
|
@@ -19395,7 +19058,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19395
19058
|
return validateExpression(options);
|
|
19396
19059
|
}
|
|
19397
19060
|
|
|
19398
|
-
//
|
|
19399
19061
|
function validateProjection(options) {
|
|
19400
19062
|
const projection = options.value;
|
|
19401
19063
|
const styleSpec = options.styleSpec;
|
|
@@ -19419,7 +19081,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19419
19081
|
return errors;
|
|
19420
19082
|
}
|
|
19421
19083
|
|
|
19422
|
-
//
|
|
19423
19084
|
const VALIDATORS = {
|
|
19424
19085
|
'*'() {
|
|
19425
19086
|
return [];
|
|
@@ -19445,15 +19106,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19445
19106
|
'projection': validateProjection,
|
|
19446
19107
|
'import': validateImport
|
|
19447
19108
|
};
|
|
19448
|
-
// Main recursive validation function. Tracks:
|
|
19449
|
-
//
|
|
19450
|
-
// - key: string representing location of validation in style tree. Used only
|
|
19451
|
-
// for more informative error reporting.
|
|
19452
|
-
// - value: current value from style being evaluated. May be anything from a
|
|
19453
|
-
// high level object that needs to be descended into deeper or a simple
|
|
19454
|
-
// scalar value.
|
|
19455
|
-
// - valueSpec: current spec being evaluated. Tracks value.
|
|
19456
|
-
// - styleSpec: current full spec being evaluated.
|
|
19457
19109
|
function validate(options, arrayAsExpression = false) {
|
|
19458
19110
|
const value = options.value;
|
|
19459
19111
|
const valueSpec = options.valueSpec;
|
|
@@ -19465,7 +19117,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19465
19117
|
} else if (valueSpec.type && VALIDATORS[valueSpec.type]) {
|
|
19466
19118
|
const valid = VALIDATORS[valueSpec.type](options);
|
|
19467
19119
|
if (arrayAsExpression === true && valid.length > 0 && getType(options.value) === 'array') {
|
|
19468
|
-
// Try to validate as an expression
|
|
19469
19120
|
return validateExpression(options);
|
|
19470
19121
|
} else {
|
|
19471
19122
|
return valid;
|
|
@@ -19476,7 +19127,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19476
19127
|
}
|
|
19477
19128
|
}
|
|
19478
19129
|
|
|
19479
|
-
//
|
|
19480
19130
|
function validateGlyphsURL (options) {
|
|
19481
19131
|
const value = options.value;
|
|
19482
19132
|
const key = options.key;
|
|
@@ -19492,7 +19142,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19492
19142
|
return errors;
|
|
19493
19143
|
}
|
|
19494
19144
|
|
|
19495
|
-
//
|
|
19496
19145
|
function validateStyle$2(style, styleSpec = v8, options = {}) {
|
|
19497
19146
|
const errors = validate({
|
|
19498
19147
|
key: options.key || '',
|
|
@@ -19500,6 +19149,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19500
19149
|
valueSpec: styleSpec.$root,
|
|
19501
19150
|
styleSpec,
|
|
19502
19151
|
style,
|
|
19152
|
+
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'objectElementValidators' does not exist in type 'ValidationOptions'.
|
|
19503
19153
|
objectElementValidators: {
|
|
19504
19154
|
glyphs: validateGlyphsURL,
|
|
19505
19155
|
'*': () => []
|
|
@@ -19508,22 +19158,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19508
19158
|
return errors;
|
|
19509
19159
|
}
|
|
19510
19160
|
|
|
19511
|
-
//
|
|
19512
|
-
/**
|
|
19513
|
-
* Validate a Mapbox GL style against the style specification. This entrypoint,
|
|
19514
|
-
* `mapbox-gl-style-spec/lib/validate_style.min`, is designed to produce as
|
|
19515
|
-
* small a browserify bundle as possible by omitting unnecessary functionality
|
|
19516
|
-
* and legacy style specifications.
|
|
19517
|
-
*
|
|
19518
|
-
* @private
|
|
19519
|
-
* @param {Object} style The style to be validated.
|
|
19520
|
-
* @param {Object} [styleSpec] The style specification to validate against.
|
|
19521
|
-
* If omitted, the latest style spec is used.
|
|
19522
|
-
* @returns {Array<ValidationError>}
|
|
19523
|
-
* @example
|
|
19524
|
-
* var validate = require('mapbox-gl-style-spec/lib/validate_style.min');
|
|
19525
|
-
* var errors = validate(style);
|
|
19526
|
-
*/
|
|
19527
19161
|
function validateStyle$1(style, styleSpec = v8) {
|
|
19528
19162
|
const errors = validateStyle$2(style, styleSpec);
|
|
19529
19163
|
return sortErrors(errors);
|
|
@@ -20594,9 +20228,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20594
20228
|
|
|
20595
20229
|
var jsonlint = /*@__PURE__*/getDefaultExportFromCjs(jsonlint$1);
|
|
20596
20230
|
|
|
20597
|
-
//
|
|
20598
20231
|
function readStyle(style) {
|
|
20599
|
-
if (style instanceof String || typeof style === 'string' || style
|
|
20232
|
+
if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
|
|
20600
20233
|
try {
|
|
20601
20234
|
return jsonlint.parse(style.toString());
|
|
20602
20235
|
} catch (e) {
|
|
@@ -20606,22 +20239,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20606
20239
|
return style;
|
|
20607
20240
|
}
|
|
20608
20241
|
|
|
20609
|
-
//
|
|
20610
|
-
/**
|
|
20611
|
-
* Validate a Mapbox GL style against the style specification.
|
|
20612
|
-
*
|
|
20613
|
-
* @private
|
|
20614
|
-
* @alias validate
|
|
20615
|
-
* @param {Object|String|Buffer} style The style to be validated. If a `String`
|
|
20616
|
-
* or `Buffer` is provided, the returned errors will contain line numbers.
|
|
20617
|
-
* @param {Object} [styleSpec] The style specification to validate against.
|
|
20618
|
-
* If omitted, the spec version is inferred from the stylesheet.
|
|
20619
|
-
* @returns {Array<ValidationError|ParsingError>}
|
|
20620
|
-
* @example
|
|
20621
|
-
* var validate = require('mapbox-gl-style-spec').validate;
|
|
20622
|
-
* var style = fs.readFileSync('./style.json', 'utf8');
|
|
20623
|
-
* var errors = validate(style);
|
|
20624
|
-
*/
|
|
20625
20242
|
function validateStyle(style, styleSpec = v8) {
|
|
20626
20243
|
let s = style;
|
|
20627
20244
|
try {
|
|
@@ -20632,7 +20249,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20632
20249
|
return validateStyle$1(s, styleSpec);
|
|
20633
20250
|
}
|
|
20634
20251
|
|
|
20635
|
-
//
|
|
20636
20252
|
const SUPPORTED_SPEC_VERSION = 8;
|
|
20637
20253
|
const MAX_SOURCES_IN_STYLE = 15;
|
|
20638
20254
|
function isValid(value, regex) {
|
|
@@ -20658,7 +20274,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20658
20274
|
});
|
|
20659
20275
|
return errors;
|
|
20660
20276
|
}
|
|
20661
|
-
const acceptedSourceTypes =
|
|
20277
|
+
const acceptedSourceTypes = /* @__PURE__ */
|
|
20278
|
+
new Set([
|
|
20662
20279
|
'vector',
|
|
20663
20280
|
'raster',
|
|
20664
20281
|
'raster-dem',
|
|
@@ -20668,28 +20285,15 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20668
20285
|
]);
|
|
20669
20286
|
function getSourceErrors(source, i) {
|
|
20670
20287
|
const errors = [];
|
|
20671
|
-
/*
|
|
20672
|
-
* Inlined sources are not supported by the Mapbox Styles API, so only
|
|
20673
|
-
* "type", "url", and "tileSize" properties are valid
|
|
20674
|
-
*/
|
|
20675
20288
|
const sourceKeys = [
|
|
20676
20289
|
'type',
|
|
20677
20290
|
'url',
|
|
20678
20291
|
'tileSize'
|
|
20679
20292
|
];
|
|
20680
20293
|
errors.push(...getAllowedKeyErrors(source, sourceKeys, 'source'));
|
|
20681
|
-
/*
|
|
20682
|
-
* "type" is required and must be one of "vector", "raster", "raster-dem", "raster-array"
|
|
20683
|
-
*/
|
|
20684
20294
|
if (!acceptedSourceTypes.has(String(source.type))) {
|
|
20685
20295
|
errors.push(new ValidationError(`sources[${ i }].type`, source.type, `Expected one of [${ Array.from(acceptedSourceTypes).join(', ') }]`));
|
|
20686
20296
|
}
|
|
20687
|
-
/*
|
|
20688
|
-
* "source" is required. Valid examples:
|
|
20689
|
-
* mapbox://mapbox.abcd1234
|
|
20690
|
-
* mapbox://penny.abcd1234
|
|
20691
|
-
* mapbox://mapbox.abcd1234,penny.abcd1234
|
|
20692
|
-
*/
|
|
20693
20297
|
const sourceUrlPattern = /^mapbox:\/\/([^/]*)$/;
|
|
20694
20298
|
if (!source.url || !isValid(source.url, sourceUrlPattern)) {
|
|
20695
20299
|
errors.push(new ValidationError(`sources[${ i }].url`, source.url, 'Expected a valid Mapbox tileset url'));
|
|
@@ -20708,7 +20312,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20708
20312
|
let sourcesCount = 0;
|
|
20709
20313
|
Object.keys(sources).forEach((s, i) => {
|
|
20710
20314
|
const sourceErrors = getSourceErrors(sources[s], i);
|
|
20711
|
-
// If source has errors, skip counting
|
|
20712
20315
|
if (!sourceErrors.length) {
|
|
20713
20316
|
sourcesCount = sourcesCount + getSourceCount(sources[s]);
|
|
20714
20317
|
}
|
|
@@ -20722,8 +20325,8 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20722
20325
|
function getImportErrors(imports = []) {
|
|
20723
20326
|
let errors = [];
|
|
20724
20327
|
let sourcesCount = 0;
|
|
20725
|
-
const validateImports = (
|
|
20726
|
-
for (const importSpec of
|
|
20328
|
+
const validateImports = (imports2 = []) => {
|
|
20329
|
+
for (const importSpec of imports2) {
|
|
20727
20330
|
const style = importSpec.data;
|
|
20728
20331
|
if (!style)
|
|
20729
20332
|
continue;
|
|
@@ -20749,14 +20352,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20749
20352
|
}
|
|
20750
20353
|
function getRootErrors(style, specKeys) {
|
|
20751
20354
|
const errors = [];
|
|
20752
|
-
/*
|
|
20753
|
-
* The following keys are optional but fully managed by the Mapbox Styles
|
|
20754
|
-
* API. Values on stylesheet on POST or PATCH will be ignored: "owner",
|
|
20755
|
-
* "id", "cacheControl", "draft", "created", "modified", "protected"
|
|
20756
|
-
*
|
|
20757
|
-
* The following keys are optional. The Mapbox Styles API respects value on
|
|
20758
|
-
* stylesheet on PATCH, but ignores the value on POST: "visibility"
|
|
20759
|
-
*/
|
|
20760
20355
|
const optionalRootProperties = [
|
|
20761
20356
|
'owner',
|
|
20762
20357
|
'id',
|
|
@@ -20777,49 +20372,23 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20777
20372
|
if (style.version > SUPPORTED_SPEC_VERSION || style.version < SUPPORTED_SPEC_VERSION) {
|
|
20778
20373
|
errors.push(new ValidationError('version', style.version, `Style version must be ${ SUPPORTED_SPEC_VERSION }`));
|
|
20779
20374
|
}
|
|
20780
|
-
/*
|
|
20781
|
-
* "glyphs" is optional. If present, valid examples:
|
|
20782
|
-
* mapbox://fonts/penny/{fontstack}/{range}.pbf
|
|
20783
|
-
* mapbox://fonts/mapbox/{fontstack}/{range}.pbf
|
|
20784
|
-
*/
|
|
20785
20375
|
const glyphUrlPattern = /^mapbox:\/\/fonts\/([^/]*)\/{fontstack}\/{range}.pbf$/;
|
|
20786
20376
|
if (!isValid(style.glyphs, glyphUrlPattern)) {
|
|
20787
20377
|
errors.push(new ValidationError('glyphs', style.glyphs, 'Styles must reference glyphs hosted by Mapbox'));
|
|
20788
20378
|
}
|
|
20789
|
-
/*
|
|
20790
|
-
* "sprite" is optional. If present, valid examples:
|
|
20791
|
-
* mapbox://sprites/penny/abcd1234
|
|
20792
|
-
* mapbox://sprites/mapbox/abcd1234/draft
|
|
20793
|
-
* mapbox://sprites/cyrus/abcd1234/abcd1234
|
|
20794
|
-
*/
|
|
20795
20379
|
const spriteUrlPattern = /^mapbox:\/\/sprites\/([^/]*)\/([^/]*)\/?([^/]*)?$/;
|
|
20796
20380
|
if (!isValid(style.sprite, spriteUrlPattern)) {
|
|
20797
20381
|
errors.push(new ValidationError('sprite', style.sprite, 'Styles must reference sprites hosted by Mapbox'));
|
|
20798
20382
|
}
|
|
20799
|
-
/*
|
|
20800
|
-
* "visibility" is optional. If present, valid examples:
|
|
20801
|
-
* "private"
|
|
20802
|
-
* "public"
|
|
20803
|
-
*/
|
|
20804
20383
|
const visibilityPattern = /^(public|private)$/;
|
|
20805
20384
|
if (!isValid(style.visibility, visibilityPattern)) {
|
|
20806
20385
|
errors.push(new ValidationError('visibility', style.visibility, 'Style visibility must be public or private'));
|
|
20807
20386
|
}
|
|
20808
|
-
if (style.protected !==
|
|
20387
|
+
if (style.protected !== void 0 && getType(style.protected) !== 'boolean') {
|
|
20809
20388
|
errors.push(new ValidationError('protected', style.protected, 'Style protection must be true or false'));
|
|
20810
20389
|
}
|
|
20811
20390
|
return errors;
|
|
20812
20391
|
}
|
|
20813
|
-
/**
|
|
20814
|
-
* Validate a Mapbox GL style against the style specification and check for
|
|
20815
|
-
* compatibility with the Mapbox Styles API.
|
|
20816
|
-
*
|
|
20817
|
-
* @param {Object} style The style to be validated.
|
|
20818
|
-
* @returns {Array<ValidationError>}
|
|
20819
|
-
* @example
|
|
20820
|
-
* var validateMapboxApiSupported = require('mapbox-gl-style-spec/lib/validate_style_mapbox_api_supported.js');
|
|
20821
|
-
* var errors = validateMapboxApiSupported(style);
|
|
20822
|
-
*/
|
|
20823
20392
|
function validateMapboxApiSupported(style, styleSpec = v8) {
|
|
20824
20393
|
let s = style;
|
|
20825
20394
|
try {
|
|
@@ -20843,7 +20412,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20843
20412
|
return errors;
|
|
20844
20413
|
}
|
|
20845
20414
|
|
|
20846
|
-
//
|
|
20847
20415
|
const expression = {
|
|
20848
20416
|
StyleExpression,
|
|
20849
20417
|
isExpression,
|
|
@@ -20866,7 +20434,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
20866
20434
|
eachProperty
|
|
20867
20435
|
};
|
|
20868
20436
|
|
|
20869
|
-
exports.Color = Color
|
|
20437
|
+
exports.Color = Color;
|
|
20870
20438
|
exports.ParsingError = ParsingError;
|
|
20871
20439
|
exports.ValidationError = ValidationError;
|
|
20872
20440
|
exports.composite = composite;
|