@mapbox/mapbox-gl-style-spec 14.23.0 → 14.24.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composite.ts +5 -3
- package/diff.ts +37 -80
- package/dist/index.cjs +159 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +159 -113
- package/dist/index.es.js.map +1 -1
- package/error/parsing_error.ts +3 -1
- package/expression/compound_expression.ts +11 -4
- package/expression/definitions/assertion.ts +2 -3
- package/expression/definitions/case.ts +1 -1
- package/expression/definitions/coercion.ts +4 -4
- package/expression/definitions/format.ts +1 -1
- package/expression/definitions/image.ts +2 -2
- package/expression/definitions/in.ts +1 -1
- package/expression/definitions/index.ts +7 -8
- package/expression/definitions/interpolate.ts +1 -1
- package/expression/definitions/let.ts +4 -2
- package/expression/definitions/match.ts +1 -1
- package/expression/definitions/step.ts +1 -1
- package/expression/is_constant.ts +2 -2
- package/expression/parsing_context.ts +18 -4
- package/expression/stops.ts +2 -1
- package/expression/types/image_variant.ts +5 -3
- package/feature_filter/index.ts +7 -30
- package/function/index.ts +7 -6
- package/migrate/v9.ts +1 -1
- package/package.json +1 -1
- package/reference/v8.json +20 -0
- package/types.ts +5 -1
- package/util/color.ts +2 -7
- package/util/geometry_util.ts +3 -8
- package/util/interpolate.ts +2 -3
- package/util/lerp.ts +3 -0
- package/util/properties.ts +4 -1
- package/validate/validate_enum.ts +2 -2
- package/validate/validate_fog.ts +3 -2
- package/validate/validate_function.ts +2 -2
- package/validate/validate_glyphs_url.ts +2 -2
- package/validate/validate_layer.ts +6 -5
- package/validate/validate_light.ts +3 -2
- package/validate/validate_lights.ts +3 -2
- package/validate/validate_model.ts +1 -1
- package/validate/validate_object.ts +1 -3
- package/validate/validate_property.ts +7 -5
- package/validate/validate_rain.ts +2 -1
- package/validate/validate_snow.ts +2 -1
- package/validate/validate_style.ts +1 -0
- package/validate/validate_terrain.ts +3 -2
- package/validate_mapbox_api_supported.ts +9 -8
package/dist/index.es.js
CHANGED
|
@@ -8178,6 +8178,26 @@ var paint_line = {
|
|
|
8178
8178
|
]
|
|
8179
8179
|
},
|
|
8180
8180
|
"property-type": "data-constant"
|
|
8181
|
+
},
|
|
8182
|
+
"line-blend-additive-clamp": {
|
|
8183
|
+
type: "number",
|
|
8184
|
+
"default": 0,
|
|
8185
|
+
minimum: 0,
|
|
8186
|
+
doc: "Controls the brightness of lines in additive blend mode. When set to 0 (the default), brightness is adjusted automatically based on the density of lines visible on screen. Increase this value if the lines appear too bright, or decrease it if they appear too faint.",
|
|
8187
|
+
experimental: true,
|
|
8188
|
+
"private": true,
|
|
8189
|
+
"sdk-support": {
|
|
8190
|
+
"basic functionality": {
|
|
8191
|
+
js: "3.21.0"
|
|
8192
|
+
}
|
|
8193
|
+
},
|
|
8194
|
+
expression: {
|
|
8195
|
+
interpolated: true,
|
|
8196
|
+
parameters: [
|
|
8197
|
+
"zoom"
|
|
8198
|
+
]
|
|
8199
|
+
},
|
|
8200
|
+
"property-type": "data-constant"
|
|
8181
8201
|
}
|
|
8182
8202
|
};
|
|
8183
8203
|
var paint_circle = {
|
|
@@ -13547,21 +13567,6 @@ var csscolorparserExports = requireCsscolorparser();
|
|
|
13547
13567
|
function number(a, b, t) {
|
|
13548
13568
|
return a * (1 - t) + b * t;
|
|
13549
13569
|
}
|
|
13550
|
-
function color(from, to, t) {
|
|
13551
|
-
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));
|
|
13552
|
-
}
|
|
13553
|
-
function array(from, to, t) {
|
|
13554
|
-
return from.map((d, i) => {
|
|
13555
|
-
return number(d, to[i], t);
|
|
13556
|
-
});
|
|
13557
|
-
}
|
|
13558
|
-
|
|
13559
|
-
var interpolate$1 = /*#__PURE__*/Object.freeze({
|
|
13560
|
-
__proto__: null,
|
|
13561
|
-
array: array,
|
|
13562
|
-
color: color,
|
|
13563
|
-
number: number
|
|
13564
|
-
});
|
|
13565
13570
|
|
|
13566
13571
|
class Color {
|
|
13567
13572
|
constructor(r, g, b, a = 1) {
|
|
@@ -13601,12 +13606,7 @@ class Color {
|
|
|
13601
13606
|
* translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
|
|
13602
13607
|
*/
|
|
13603
13608
|
toString() {
|
|
13604
|
-
const
|
|
13605
|
-
this.r,
|
|
13606
|
-
this.g,
|
|
13607
|
-
this.b,
|
|
13608
|
-
this.a
|
|
13609
|
-
];
|
|
13609
|
+
const {r, g, b, a} = this;
|
|
13610
13610
|
return `rgba(${ Math.round(r * 255) },${ Math.round(g * 255) },${ Math.round(b * 255) },${ a })`;
|
|
13611
13611
|
}
|
|
13612
13612
|
toNonPremultipliedRenderColor(lut) {
|
|
@@ -13933,7 +13933,10 @@ class ImageVariant {
|
|
|
13933
13933
|
return JSON.stringify(this);
|
|
13934
13934
|
}
|
|
13935
13935
|
static parse(str) {
|
|
13936
|
-
let id
|
|
13936
|
+
let id;
|
|
13937
|
+
let params;
|
|
13938
|
+
let sx;
|
|
13939
|
+
let sy;
|
|
13937
13940
|
try {
|
|
13938
13941
|
({id, params, sx, sy} = JSON.parse(str) || {});
|
|
13939
13942
|
} catch (e) {
|
|
@@ -14315,7 +14318,7 @@ class FormatExpression {
|
|
|
14315
14318
|
if (!textColor)
|
|
14316
14319
|
return null;
|
|
14317
14320
|
}
|
|
14318
|
-
const lastExpression = sections
|
|
14321
|
+
const lastExpression = sections.at(-1);
|
|
14319
14322
|
lastExpression.scale = scale;
|
|
14320
14323
|
lastExpression.font = font;
|
|
14321
14324
|
lastExpression.textColor = textColor;
|
|
@@ -14457,7 +14460,7 @@ class ImageExpression {
|
|
|
14457
14460
|
}
|
|
14458
14461
|
parsedParams[key] = value;
|
|
14459
14462
|
}
|
|
14460
|
-
imageExpression
|
|
14463
|
+
imageExpression.at(-1).options.params = parsedParams;
|
|
14461
14464
|
}
|
|
14462
14465
|
if (iconset) {
|
|
14463
14466
|
if (typeof iconset !== 'object' || iconset.constructor !== Object) {
|
|
@@ -14468,7 +14471,7 @@ class ImageExpression {
|
|
|
14468
14471
|
optionsContext.error(`Image options "iconset" should have an "id" property`);
|
|
14469
14472
|
return false;
|
|
14470
14473
|
}
|
|
14471
|
-
imageExpression
|
|
14474
|
+
imageExpression.at(-1).options.iconset = iconset;
|
|
14472
14475
|
}
|
|
14473
14476
|
nextArgId++;
|
|
14474
14477
|
return true;
|
|
@@ -14874,7 +14877,11 @@ class CompoundExpression {
|
|
|
14874
14877
|
continue;
|
|
14875
14878
|
overloadParams.push(params);
|
|
14876
14879
|
overloadIndex++;
|
|
14877
|
-
|
|
14880
|
+
if (signatureContext === null) {
|
|
14881
|
+
signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, [], context._scope, context.options, context.iconImageUseTheme);
|
|
14882
|
+
} else {
|
|
14883
|
+
signatureContext.errors.length = 0;
|
|
14884
|
+
}
|
|
14878
14885
|
const parsedArgs = [];
|
|
14879
14886
|
let argParseFailed = false;
|
|
14880
14887
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -14899,7 +14906,7 @@ class CompoundExpression {
|
|
|
14899
14906
|
for (let i = 0; i < parsedArgs.length; i++) {
|
|
14900
14907
|
const expected = Array.isArray(params) ? params[i] : params.type;
|
|
14901
14908
|
const arg = parsedArgs[i];
|
|
14902
|
-
signatureContext.
|
|
14909
|
+
signatureContext.checkSubtype(expected, arg.type, i + 1);
|
|
14903
14910
|
}
|
|
14904
14911
|
if (signatureContext.errors.length === 0) {
|
|
14905
14912
|
return new CompoundExpression(op, type, evaluate, parsedArgs, overloadIndex);
|
|
@@ -15873,7 +15880,7 @@ class CheapRuler {
|
|
|
15873
15880
|
const d = this.distance(p0, p1);
|
|
15874
15881
|
sum += d;
|
|
15875
15882
|
if (sum > dist)
|
|
15876
|
-
return interpolate(p0, p1, (dist - (sum - d)) / d);
|
|
15883
|
+
return interpolate$1(p0, p1, (dist - (sum - d)) / d);
|
|
15877
15884
|
}
|
|
15878
15885
|
return line[line.length - 1];
|
|
15879
15886
|
}
|
|
@@ -16012,10 +16019,10 @@ class CheapRuler {
|
|
|
16012
16019
|
const d = this.distance(p0, p1);
|
|
16013
16020
|
sum += d;
|
|
16014
16021
|
if (sum > start && slice.length === 0) {
|
|
16015
|
-
slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
|
|
16022
|
+
slice.push(interpolate$1(p0, p1, (start - (sum - d)) / d));
|
|
16016
16023
|
}
|
|
16017
16024
|
if (sum >= stop) {
|
|
16018
|
-
slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
|
|
16025
|
+
slice.push(interpolate$1(p0, p1, (stop - (sum - d)) / d));
|
|
16019
16026
|
return slice;
|
|
16020
16027
|
}
|
|
16021
16028
|
if (sum > start)
|
|
@@ -16091,7 +16098,7 @@ function equals(a, b) {
|
|
|
16091
16098
|
* @param {number} t
|
|
16092
16099
|
* @returns {[number, number]}
|
|
16093
16100
|
*/
|
|
16094
|
-
function interpolate(a, b, t) {
|
|
16101
|
+
function interpolate$1(a, b, t) {
|
|
16095
16102
|
const dx = wrap(b[0] - a[0]);
|
|
16096
16103
|
const dy = b[1] - a[1];
|
|
16097
16104
|
return [
|
|
@@ -16785,7 +16792,7 @@ function isFeatureConstant(e) {
|
|
|
16785
16792
|
return false;
|
|
16786
16793
|
} else if (e.name === 'properties' || e.name === 'geometry-type' || e.name === 'id') {
|
|
16787
16794
|
return false;
|
|
16788
|
-
} else if (
|
|
16795
|
+
} else if (e.name.startsWith('filter-')) {
|
|
16789
16796
|
return false;
|
|
16790
16797
|
}
|
|
16791
16798
|
}
|
|
@@ -16821,7 +16828,7 @@ function isStateConstant(e) {
|
|
|
16821
16828
|
return result;
|
|
16822
16829
|
}
|
|
16823
16830
|
function isGlobalPropertyConstant(e, properties) {
|
|
16824
|
-
if (e instanceof CompoundExpression && properties.
|
|
16831
|
+
if (e instanceof CompoundExpression && properties.includes(e.name)) {
|
|
16825
16832
|
return false;
|
|
16826
16833
|
}
|
|
16827
16834
|
let result = true;
|
|
@@ -17001,12 +17008,6 @@ class ParsingContext {
|
|
|
17001
17008
|
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options, iconImageUseTheme) {
|
|
17002
17009
|
this.registry = registry;
|
|
17003
17010
|
this.path = path;
|
|
17004
|
-
this.key = path.map(part => {
|
|
17005
|
-
if (typeof part === 'string') {
|
|
17006
|
-
return `['${ part }']`;
|
|
17007
|
-
}
|
|
17008
|
-
return `[${ part }]`;
|
|
17009
|
-
}).join('');
|
|
17010
17011
|
this.scope = scope;
|
|
17011
17012
|
this.errors = errors;
|
|
17012
17013
|
this.expectedType = expectedType;
|
|
@@ -17014,6 +17015,18 @@ class ParsingContext {
|
|
|
17014
17015
|
this.options = options;
|
|
17015
17016
|
this.iconImageUseTheme = iconImageUseTheme;
|
|
17016
17017
|
}
|
|
17018
|
+
get key() {
|
|
17019
|
+
if (this._key === void 0) {
|
|
17020
|
+
const path = this.path;
|
|
17021
|
+
let key = '';
|
|
17022
|
+
for (let i = 0; i < path.length; i++) {
|
|
17023
|
+
const part = path[i];
|
|
17024
|
+
key += typeof part === 'string' ? `['${ part }']` : `[${ part }]`;
|
|
17025
|
+
}
|
|
17026
|
+
this._key = key;
|
|
17027
|
+
}
|
|
17028
|
+
return this._key;
|
|
17029
|
+
}
|
|
17017
17030
|
/**
|
|
17018
17031
|
* @param expr the JSON expression to parse
|
|
17019
17032
|
* @param index the optional argument index if this expression is an argument of a parent expression that's being parsed
|
|
@@ -17126,10 +17139,10 @@ class ParsingContext {
|
|
|
17126
17139
|
* Returns null if `t` is a subtype of `expected`; otherwise returns an
|
|
17127
17140
|
* error message and also pushes it to `this.errors`.
|
|
17128
17141
|
*/
|
|
17129
|
-
checkSubtype(expected, t) {
|
|
17142
|
+
checkSubtype(expected, t, index) {
|
|
17130
17143
|
const error = checkSubtype(expected, t);
|
|
17131
17144
|
if (error)
|
|
17132
|
-
this.error(error);
|
|
17145
|
+
this.error(error, ...typeof index === 'number' ? [index] : []);
|
|
17133
17146
|
return error;
|
|
17134
17147
|
}
|
|
17135
17148
|
}
|
|
@@ -17181,7 +17194,8 @@ function findStopLessThanOrEqualTo(stops, input) {
|
|
|
17181
17194
|
let lowerIndex = 0;
|
|
17182
17195
|
let upperIndex = lastIndex;
|
|
17183
17196
|
let currentIndex = 0;
|
|
17184
|
-
let currentValue
|
|
17197
|
+
let currentValue;
|
|
17198
|
+
let nextValue;
|
|
17185
17199
|
while (lowerIndex <= upperIndex) {
|
|
17186
17200
|
currentIndex = Math.floor((lowerIndex + upperIndex) / 2);
|
|
17187
17201
|
currentValue = stops[currentIndex];
|
|
@@ -17234,7 +17248,7 @@ class Step {
|
|
|
17234
17248
|
if (typeof label !== 'number') {
|
|
17235
17249
|
return context.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
|
|
17236
17250
|
}
|
|
17237
|
-
if (stops.length && stops
|
|
17251
|
+
if (stops.length && stops.at(-1)[0] >= label) {
|
|
17238
17252
|
return context.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', labelKey);
|
|
17239
17253
|
}
|
|
17240
17254
|
const parsed = context.parse(value, valueKey, outputType);
|
|
@@ -17366,6 +17380,22 @@ function requireUnitbezier () {
|
|
|
17366
17380
|
var unitbezierExports = requireUnitbezier();
|
|
17367
17381
|
var UnitBezier = /*@__PURE__*/getDefaultExportFromCjs(unitbezierExports);
|
|
17368
17382
|
|
|
17383
|
+
function color(from, to, t) {
|
|
17384
|
+
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));
|
|
17385
|
+
}
|
|
17386
|
+
function array(from, to, t) {
|
|
17387
|
+
return from.map((d, i) => {
|
|
17388
|
+
return number(d, to[i], t);
|
|
17389
|
+
});
|
|
17390
|
+
}
|
|
17391
|
+
|
|
17392
|
+
var interpolate = /*#__PURE__*/Object.freeze({
|
|
17393
|
+
__proto__: null,
|
|
17394
|
+
array: array,
|
|
17395
|
+
color: color,
|
|
17396
|
+
number: number
|
|
17397
|
+
});
|
|
17398
|
+
|
|
17369
17399
|
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;
|
|
17370
17400
|
function xyz2lab(t) {
|
|
17371
17401
|
return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
|
|
@@ -17530,7 +17560,7 @@ class Interpolate {
|
|
|
17530
17560
|
if (typeof label !== 'number') {
|
|
17531
17561
|
return context.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
|
|
17532
17562
|
}
|
|
17533
|
-
if (stops.length && stops
|
|
17563
|
+
if (stops.length && stops.at(-1)[0] >= label) {
|
|
17534
17564
|
return context.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', labelKey);
|
|
17535
17565
|
}
|
|
17536
17566
|
const parsed = context.parse(value, valueKey, outputType);
|
|
@@ -17568,7 +17598,7 @@ class Interpolate {
|
|
|
17568
17598
|
const outputLower = outputs[index].evaluate(ctx);
|
|
17569
17599
|
const outputUpper = outputs[index + 1].evaluate(ctx);
|
|
17570
17600
|
if (this.operator === 'interpolate') {
|
|
17571
|
-
return interpolate
|
|
17601
|
+
return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
|
|
17572
17602
|
} else if (this.operator === 'interpolate-hcl') {
|
|
17573
17603
|
return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
|
|
17574
17604
|
} else {
|
|
@@ -17689,6 +17719,7 @@ class Coalesce {
|
|
|
17689
17719
|
}
|
|
17690
17720
|
}
|
|
17691
17721
|
|
|
17722
|
+
const INVALID_VAR_CHAR_RE = /[^a-zA-Z0-9_]/;
|
|
17692
17723
|
class Let {
|
|
17693
17724
|
constructor(bindings, result) {
|
|
17694
17725
|
this.type = result.type;
|
|
@@ -17714,7 +17745,7 @@ class Let {
|
|
|
17714
17745
|
if (typeof name !== 'string') {
|
|
17715
17746
|
return context.error(`Expected string, but found ${ typeof name } instead.`, i);
|
|
17716
17747
|
}
|
|
17717
|
-
if (
|
|
17748
|
+
if (INVALID_VAR_CHAR_RE.test(name)) {
|
|
17718
17749
|
return context.error(`Variable names must contain only alphanumeric characters or '_'.`, i);
|
|
17719
17750
|
}
|
|
17720
17751
|
const value = context.parse(args[i + 1], i + 1);
|
|
@@ -17725,7 +17756,7 @@ class Let {
|
|
|
17725
17756
|
value
|
|
17726
17757
|
]);
|
|
17727
17758
|
}
|
|
17728
|
-
const result = context.parse(args
|
|
17759
|
+
const result = context.parse(args.at(-1), args.length - 1, context.expectedType, bindings);
|
|
17729
17760
|
if (!result)
|
|
17730
17761
|
return null;
|
|
17731
17762
|
return new Let(bindings, result);
|
|
@@ -17889,7 +17920,7 @@ class In {
|
|
|
17889
17920
|
])) {
|
|
17890
17921
|
throw new RuntimeError(`Expected second argument to be of type array or string, but found ${ toString$1(typeOf(haystack)) } instead.`);
|
|
17891
17922
|
}
|
|
17892
|
-
return haystack.
|
|
17923
|
+
return haystack.includes(needle);
|
|
17893
17924
|
}
|
|
17894
17925
|
eachChild(fn) {
|
|
17895
17926
|
fn(this.needle);
|
|
@@ -18051,7 +18082,7 @@ class Match {
|
|
|
18051
18082
|
const input = context.parse(args[1], 1, ValueType);
|
|
18052
18083
|
if (!input)
|
|
18053
18084
|
return null;
|
|
18054
|
-
const otherwise = context.parse(args
|
|
18085
|
+
const otherwise = context.parse(args.at(-1), args.length - 1, outputType);
|
|
18055
18086
|
if (!otherwise)
|
|
18056
18087
|
return null;
|
|
18057
18088
|
if (input.type.kind !== 'value' && context.concat(1).checkSubtype(inputType, input.type)) {
|
|
@@ -18140,7 +18171,7 @@ class Case {
|
|
|
18140
18171
|
]);
|
|
18141
18172
|
outputType = outputType || result.type;
|
|
18142
18173
|
}
|
|
18143
|
-
const otherwise = context.parse(args
|
|
18174
|
+
const otherwise = context.parse(args.at(-1), args.length - 1, outputType);
|
|
18144
18175
|
if (!otherwise)
|
|
18145
18176
|
return null;
|
|
18146
18177
|
return new Case(outputType, branches, otherwise);
|
|
@@ -19177,14 +19208,14 @@ CompoundExpression.register(expressions, {
|
|
|
19177
19208
|
'filter-type-in': [
|
|
19178
19209
|
BooleanType,
|
|
19179
19210
|
[array$1(StringType)],
|
|
19180
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
19181
|
-
(ctx, [v]) => v.value.
|
|
19211
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
19212
|
+
(ctx, [v]) => v.value.includes(ctx.geometryType())
|
|
19182
19213
|
],
|
|
19183
19214
|
'filter-id-in': [
|
|
19184
19215
|
BooleanType,
|
|
19185
19216
|
[array$1(ValueType)],
|
|
19186
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
19187
|
-
(ctx, [v]) => v.value.
|
|
19217
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
19218
|
+
(ctx, [v]) => v.value.includes(ctx.id())
|
|
19188
19219
|
],
|
|
19189
19220
|
'filter-in-small': [
|
|
19190
19221
|
BooleanType,
|
|
@@ -19193,8 +19224,8 @@ CompoundExpression.register(expressions, {
|
|
|
19193
19224
|
array$1(ValueType)
|
|
19194
19225
|
],
|
|
19195
19226
|
// assumes v is an array literal
|
|
19196
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
19197
|
-
(ctx, [k, v]) => v.value.
|
|
19227
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
19228
|
+
(ctx, [k, v]) => v.value.includes(ctx.properties()[k.value])
|
|
19198
19229
|
],
|
|
19199
19230
|
'filter-in-large': [
|
|
19200
19231
|
BooleanType,
|
|
@@ -19365,8 +19396,10 @@ function error(value) {
|
|
|
19365
19396
|
};
|
|
19366
19397
|
}
|
|
19367
19398
|
|
|
19399
|
+
const TRANSITION_KEY_RE = /^(.*)-transition$/;
|
|
19400
|
+
const USE_THEME_KEY_RE = /^(.*)-use-theme$/;
|
|
19368
19401
|
function expressionHasParameter(expression, parameter) {
|
|
19369
|
-
return !!expression && !!expression.parameters && expression.parameters.
|
|
19402
|
+
return !!expression && !!expression.parameters && expression.parameters.includes(parameter);
|
|
19370
19403
|
}
|
|
19371
19404
|
function supportsPropertyExpression(spec) {
|
|
19372
19405
|
return spec['property-type'] === 'data-driven';
|
|
@@ -19494,7 +19527,7 @@ function createFunction(parameters, propertySpec) {
|
|
|
19494
19527
|
interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
|
|
19495
19528
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
19496
19529
|
zoomStops: parameters.stops.map(s => s[0]),
|
|
19497
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
19530
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
19498
19531
|
evaluate: ({zoom}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
|
|
19499
19532
|
};
|
|
19500
19533
|
} else {
|
|
@@ -19552,7 +19585,7 @@ function evaluateExponentialFunction(parameters, propertySpec, input) {
|
|
|
19552
19585
|
parameters.stops[index + 1][0]);
|
|
19553
19586
|
const outputLower = parameters.stops[index][1];
|
|
19554
19587
|
const outputUpper = parameters.stops[index + 1][1];
|
|
19555
|
-
let interp = interpolate
|
|
19588
|
+
let interp = interpolate[propertySpec.type] || identityFunction;
|
|
19556
19589
|
if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
|
|
19557
19590
|
const colorspace = colorSpaces[parameters.colorSpace];
|
|
19558
19591
|
interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
|
|
@@ -20283,13 +20316,13 @@ function unionDynamicBranches(filter) {
|
|
|
20283
20316
|
isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[i]);
|
|
20284
20317
|
branches.push(filter[i + 1]);
|
|
20285
20318
|
}
|
|
20286
|
-
branches.push(filter
|
|
20319
|
+
branches.push(filter.at(-1));
|
|
20287
20320
|
} else if (filter[0] === 'match') {
|
|
20288
20321
|
isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[1]);
|
|
20289
20322
|
for (let i = 2; i < filter.length - 1; i += 2) {
|
|
20290
20323
|
branches.push(filter[i + 1]);
|
|
20291
20324
|
}
|
|
20292
|
-
branches.push(filter
|
|
20325
|
+
branches.push(filter.at(-1));
|
|
20293
20326
|
} else if (filter[0] === 'step') {
|
|
20294
20327
|
isBranchingDynamically = isBranchingDynamically || isDynamicFilter(filter[1]);
|
|
20295
20328
|
for (let i = 1; i < filter.length - 1; i += 2) {
|
|
@@ -20689,6 +20722,7 @@ function migrate (style) {
|
|
|
20689
20722
|
return style;
|
|
20690
20723
|
}
|
|
20691
20724
|
|
|
20725
|
+
const MAPBOX_URL_RE = /^mapbox:\/\/(.*)/;
|
|
20692
20726
|
function composite (style) {
|
|
20693
20727
|
const styleIDs = [];
|
|
20694
20728
|
const sourceIDs = [];
|
|
@@ -20697,7 +20731,7 @@ function composite (style) {
|
|
|
20697
20731
|
const source = style.sources[id];
|
|
20698
20732
|
if (source.type !== 'vector')
|
|
20699
20733
|
continue;
|
|
20700
|
-
const match =
|
|
20734
|
+
const match = MAPBOX_URL_RE.exec(source.url);
|
|
20701
20735
|
if (!match)
|
|
20702
20736
|
continue;
|
|
20703
20737
|
styleIDs.push(id);
|
|
@@ -20714,10 +20748,10 @@ function composite (style) {
|
|
|
20714
20748
|
'url': `mapbox://${ compositeID }`
|
|
20715
20749
|
};
|
|
20716
20750
|
style.layers.forEach(layer => {
|
|
20717
|
-
if (styleIDs.
|
|
20751
|
+
if (styleIDs.includes(layer.source)) {
|
|
20718
20752
|
layer.source = compositeID;
|
|
20719
20753
|
if ('source-layer' in layer) {
|
|
20720
|
-
if (compositedSourceLayers.
|
|
20754
|
+
if (compositedSourceLayers.includes(layer['source-layer'])) {
|
|
20721
20755
|
throw new Error('Conflicting source layer names');
|
|
20722
20756
|
} else {
|
|
20723
20757
|
compositedSourceLayers.push(layer['source-layer']);
|
|
@@ -20948,14 +20982,14 @@ function updateSource(sourceId, after, commands, sourcesRemoved) {
|
|
|
20948
20982
|
function canUpdateGeoJSON(before, after, sourceId) {
|
|
20949
20983
|
let prop;
|
|
20950
20984
|
for (prop in before[sourceId]) {
|
|
20951
|
-
if (!before[sourceId]
|
|
20985
|
+
if (!Object.hasOwn(before[sourceId], prop))
|
|
20952
20986
|
continue;
|
|
20953
20987
|
if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {
|
|
20954
20988
|
return false;
|
|
20955
20989
|
}
|
|
20956
20990
|
}
|
|
20957
20991
|
for (prop in after[sourceId]) {
|
|
20958
|
-
if (!after[sourceId]
|
|
20992
|
+
if (!Object.hasOwn(after[sourceId], prop))
|
|
20959
20993
|
continue;
|
|
20960
20994
|
if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {
|
|
20961
20995
|
return false;
|
|
@@ -20968,17 +21002,17 @@ function diffSources(before, after, commands, sourcesRemoved) {
|
|
|
20968
21002
|
after = after || {};
|
|
20969
21003
|
let sourceId;
|
|
20970
21004
|
for (sourceId in before) {
|
|
20971
|
-
if (!
|
|
21005
|
+
if (!Object.hasOwn(before, sourceId))
|
|
20972
21006
|
continue;
|
|
20973
|
-
if (!
|
|
21007
|
+
if (!Object.hasOwn(after, sourceId)) {
|
|
20974
21008
|
removeSource(sourceId, commands, sourcesRemoved);
|
|
20975
21009
|
}
|
|
20976
21010
|
}
|
|
20977
21011
|
for (sourceId in after) {
|
|
20978
|
-
if (!
|
|
21012
|
+
if (!Object.hasOwn(after, sourceId))
|
|
20979
21013
|
continue;
|
|
20980
21014
|
const source = after[sourceId];
|
|
20981
|
-
if (!
|
|
21015
|
+
if (!Object.hasOwn(before, sourceId)) {
|
|
20982
21016
|
addSource(sourceId, after, commands);
|
|
20983
21017
|
} else if (!deepEqual(before[sourceId], source)) {
|
|
20984
21018
|
if (before[sourceId].type === 'geojson' && source.type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {
|
|
@@ -21000,7 +21034,7 @@ function diffLayerPropertyChanges(before, after, commands, layerId, klass, comma
|
|
|
21000
21034
|
after = after || {};
|
|
21001
21035
|
let prop;
|
|
21002
21036
|
for (prop in before) {
|
|
21003
|
-
if (!
|
|
21037
|
+
if (!Object.hasOwn(before, prop))
|
|
21004
21038
|
continue;
|
|
21005
21039
|
if (!deepEqual(before[prop], after[prop])) {
|
|
21006
21040
|
commands.push({
|
|
@@ -21015,7 +21049,7 @@ function diffLayerPropertyChanges(before, after, commands, layerId, klass, comma
|
|
|
21015
21049
|
}
|
|
21016
21050
|
}
|
|
21017
21051
|
for (prop in after) {
|
|
21018
|
-
if (!
|
|
21052
|
+
if (!Object.hasOwn(after, prop) || Object.hasOwn(before, prop))
|
|
21019
21053
|
continue;
|
|
21020
21054
|
if (!deepEqual(before[prop], after[prop])) {
|
|
21021
21055
|
commands.push({
|
|
@@ -21047,10 +21081,16 @@ function diffLayers(before, after, commands) {
|
|
|
21047
21081
|
const tracker = beforeOrder.slice();
|
|
21048
21082
|
const clean = /* @__PURE__ */
|
|
21049
21083
|
Object.create(null);
|
|
21050
|
-
let i
|
|
21084
|
+
let i;
|
|
21085
|
+
let d;
|
|
21086
|
+
let layerId;
|
|
21087
|
+
let beforeLayer;
|
|
21088
|
+
let afterLayer;
|
|
21089
|
+
let insertBeforeLayerId;
|
|
21090
|
+
let prop;
|
|
21051
21091
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
21052
21092
|
layerId = beforeOrder[i];
|
|
21053
|
-
if (!
|
|
21093
|
+
if (!Object.hasOwn(afterIndex, layerId)) {
|
|
21054
21094
|
commands.push({
|
|
21055
21095
|
command: operations.removeLayer,
|
|
21056
21096
|
args: [layerId]
|
|
@@ -21064,7 +21104,7 @@ function diffLayers(before, after, commands) {
|
|
|
21064
21104
|
layerId = afterOrder[afterOrder.length - 1 - i];
|
|
21065
21105
|
if (tracker[tracker.length - 1 - i] === layerId)
|
|
21066
21106
|
continue;
|
|
21067
|
-
if (
|
|
21107
|
+
if (Object.hasOwn(beforeIndex, layerId)) {
|
|
21068
21108
|
commands.push({
|
|
21069
21109
|
command: operations.removeLayer,
|
|
21070
21110
|
args: [layerId]
|
|
@@ -21136,7 +21176,7 @@ function diffLayers(before, after, commands) {
|
|
|
21136
21176
|
});
|
|
21137
21177
|
}
|
|
21138
21178
|
for (prop in beforeLayer) {
|
|
21139
|
-
if (!
|
|
21179
|
+
if (!Object.hasOwn(beforeLayer, prop))
|
|
21140
21180
|
continue;
|
|
21141
21181
|
if (prop === 'layout' || prop === 'paint' || prop === 'filter' || prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot')
|
|
21142
21182
|
continue;
|
|
@@ -21154,7 +21194,7 @@ function diffLayers(before, after, commands) {
|
|
|
21154
21194
|
}
|
|
21155
21195
|
}
|
|
21156
21196
|
for (prop in afterLayer) {
|
|
21157
|
-
if (!
|
|
21197
|
+
if (!Object.hasOwn(afterLayer, prop) || Object.hasOwn(beforeLayer, prop))
|
|
21158
21198
|
continue;
|
|
21159
21199
|
if (prop === 'layout' || prop === 'paint' || prop === 'filter' || prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot')
|
|
21160
21200
|
continue;
|
|
@@ -21181,10 +21221,13 @@ function diffImports(before = [], after = [], commands) {
|
|
|
21181
21221
|
const beforeIndex = before.reduce(indexById, {});
|
|
21182
21222
|
const afterIndex = after.reduce(indexById, {});
|
|
21183
21223
|
const tracker = beforeOrder.slice();
|
|
21184
|
-
let i
|
|
21224
|
+
let i;
|
|
21225
|
+
let d;
|
|
21226
|
+
let importId;
|
|
21227
|
+
let insertBefore;
|
|
21185
21228
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
21186
21229
|
importId = beforeOrder[i];
|
|
21187
|
-
if (!
|
|
21230
|
+
if (!Object.hasOwn(afterIndex, importId)) {
|
|
21188
21231
|
commands.push({
|
|
21189
21232
|
command: operations.removeImport,
|
|
21190
21233
|
args: [importId]
|
|
@@ -21198,7 +21241,7 @@ function diffImports(before = [], after = [], commands) {
|
|
|
21198
21241
|
importId = afterOrder[afterOrder.length - 1 - i];
|
|
21199
21242
|
if (tracker[tracker.length - 1 - i] === importId)
|
|
21200
21243
|
continue;
|
|
21201
|
-
if (
|
|
21244
|
+
if (Object.hasOwn(beforeIndex, importId)) {
|
|
21202
21245
|
commands.push({
|
|
21203
21246
|
command: operations.removeImport,
|
|
21204
21247
|
args: [importId]
|
|
@@ -21238,9 +21281,9 @@ function diffIconsets(before, after, commands) {
|
|
|
21238
21281
|
after = after || {};
|
|
21239
21282
|
let iconsetId;
|
|
21240
21283
|
for (iconsetId in before) {
|
|
21241
|
-
if (!
|
|
21284
|
+
if (!Object.hasOwn(before, iconsetId))
|
|
21242
21285
|
continue;
|
|
21243
|
-
if (!
|
|
21286
|
+
if (!Object.hasOwn(after, iconsetId)) {
|
|
21244
21287
|
commands.push({
|
|
21245
21288
|
command: operations.removeIconset,
|
|
21246
21289
|
args: [iconsetId]
|
|
@@ -21248,10 +21291,10 @@ function diffIconsets(before, after, commands) {
|
|
|
21248
21291
|
}
|
|
21249
21292
|
}
|
|
21250
21293
|
for (iconsetId in after) {
|
|
21251
|
-
if (!
|
|
21294
|
+
if (!Object.hasOwn(after, iconsetId))
|
|
21252
21295
|
continue;
|
|
21253
21296
|
const iconset = after[iconsetId];
|
|
21254
|
-
if (!
|
|
21297
|
+
if (!Object.hasOwn(before, iconsetId)) {
|
|
21255
21298
|
commands.push({
|
|
21256
21299
|
command: operations.addIconset,
|
|
21257
21300
|
args: [
|
|
@@ -21441,11 +21484,12 @@ class ValidationError {
|
|
|
21441
21484
|
class ValidationWarning extends ValidationError {
|
|
21442
21485
|
}
|
|
21443
21486
|
|
|
21487
|
+
const LINE_NUMBER_RE = /line (\d+)/;
|
|
21444
21488
|
class ParsingError {
|
|
21445
21489
|
constructor(error) {
|
|
21446
21490
|
this.error = error;
|
|
21447
21491
|
this.message = error.message;
|
|
21448
|
-
const match = error.message.match(
|
|
21492
|
+
const match = error.message.match(LINE_NUMBER_RE);
|
|
21449
21493
|
this.line = match ? parseInt(match[1], 10) : 0;
|
|
21450
21494
|
}
|
|
21451
21495
|
}
|
|
@@ -21843,11 +21887,11 @@ function validateEnum(options) {
|
|
|
21843
21887
|
const valueSpec = options.valueSpec;
|
|
21844
21888
|
const errors = [];
|
|
21845
21889
|
if (Array.isArray(valueSpec.values)) {
|
|
21846
|
-
if (valueSpec.values.
|
|
21890
|
+
if (!valueSpec.values.includes(unbundle(value))) {
|
|
21847
21891
|
errors.push(new ValidationError(key, value, `expected one of [${ valueSpec.values.join(', ') }], ${ JSON.stringify(value) } found`));
|
|
21848
21892
|
}
|
|
21849
21893
|
} else {
|
|
21850
|
-
if (Object.keys(valueSpec.values).
|
|
21894
|
+
if (!Object.keys(valueSpec.values).includes(unbundle(value))) {
|
|
21851
21895
|
errors.push(new ValidationError(key, value, `expected one of [${ Object.keys(valueSpec.values).join(', ') }], ${ JSON.stringify(value) } found`));
|
|
21852
21896
|
}
|
|
21853
21897
|
}
|
|
@@ -21949,6 +21993,7 @@ function validateNonExpressionFilter(options) {
|
|
|
21949
21993
|
return errors;
|
|
21950
21994
|
}
|
|
21951
21995
|
|
|
21996
|
+
const TOKEN_PATTERN_RE = /^{([^}]+)}$/;
|
|
21952
21997
|
function validateProperty(options, propertyType) {
|
|
21953
21998
|
const key = options.key;
|
|
21954
21999
|
const style = options.style;
|
|
@@ -21959,7 +22004,7 @@ function validateProperty(options, propertyType) {
|
|
|
21959
22004
|
const layerSpec = styleSpec[`${ propertyType }_${ options.layerType }`];
|
|
21960
22005
|
if (!layerSpec)
|
|
21961
22006
|
return [];
|
|
21962
|
-
const useThemeMatch = propertyKey.match(
|
|
22007
|
+
const useThemeMatch = propertyKey.match(USE_THEME_KEY_RE);
|
|
21963
22008
|
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
21964
22009
|
if (isExpression(deepUnbundle(value))) {
|
|
21965
22010
|
const errors2 = [];
|
|
@@ -21992,7 +22037,7 @@ function validateProperty(options, propertyType) {
|
|
|
21992
22037
|
styleSpec
|
|
21993
22038
|
});
|
|
21994
22039
|
}
|
|
21995
|
-
const transitionMatch = propertyKey.match(
|
|
22040
|
+
const transitionMatch = propertyKey.match(TRANSITION_KEY_RE);
|
|
21996
22041
|
if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {
|
|
21997
22042
|
return validate({
|
|
21998
22043
|
key,
|
|
@@ -22008,7 +22053,7 @@ function validateProperty(options, propertyType) {
|
|
|
22008
22053
|
return [new ValidationWarning(key, value, `unknown property "${ propertyKey }"`)];
|
|
22009
22054
|
}
|
|
22010
22055
|
let tokenMatch;
|
|
22011
|
-
if (isString(value) && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch =
|
|
22056
|
+
if (isString(value) && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = TOKEN_PATTERN_RE.exec(value))) {
|
|
22012
22057
|
const example = `\`{ "type": "identity", "property": ${ tokenMatch ? JSON.stringify(tokenMatch[1]) : '"_"' } }\``;
|
|
22013
22058
|
return [new ValidationError(key, value, `"${ propertyKey }" does not support interpolation syntax
|
|
22014
22059
|
Use an identity property function instead: ${ example }.`)];
|
|
@@ -22021,7 +22066,7 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22021
22066
|
if (propertyKey === 'text-font' && isFunction(deepUnbundle(value)) && unbundle(value.type) === 'identity') {
|
|
22022
22067
|
errors.push(new ValidationError(key, value, '"text-font" does not support identity functions'));
|
|
22023
22068
|
}
|
|
22024
|
-
} else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout
|
|
22069
|
+
} else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && Object.hasOwn(layer.layout, 'model-id')) {
|
|
22025
22070
|
if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
|
|
22026
22071
|
const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
|
|
22027
22072
|
const expressionValue = expression.value;
|
|
@@ -22189,8 +22234,10 @@ function validateLayer(options) {
|
|
|
22189
22234
|
'raster-particle'
|
|
22190
22235
|
].includes(type)) {
|
|
22191
22236
|
errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type 'raster'.`));
|
|
22192
|
-
} else if (type === 'line' && layer.paint &&
|
|
22237
|
+
} else if (type === 'line' && layer.paint && layer.paint['line-gradient'] && (sourceType === 'geojson' && !source.lineMetrics)) {
|
|
22193
22238
|
errors.push(new ValidationError(key, layer, `layer "${ layer.id }" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`));
|
|
22239
|
+
} else if (type === 'line' && layer.paint && layer.paint['line-trim-offset'] && (sourceType === 'geojson' && !source.lineMetrics)) {
|
|
22240
|
+
errors.push(new ValidationError(key, layer, `layer "${ layer.id }" specifies a line-trim-offset, which requires the GeoJSON source to have \`lineMetrics\` enabled.`));
|
|
22194
22241
|
} else if (type === 'raster-particle' && sourceType !== 'raster-array') {
|
|
22195
22242
|
errors.push(new ValidationError(key, layer.source, `layer "${ layer.id }" requires a 'raster-array' source.`));
|
|
22196
22243
|
}
|
|
@@ -22465,7 +22512,7 @@ function validatePromoteId({key, value}) {
|
|
|
22465
22512
|
}
|
|
22466
22513
|
|
|
22467
22514
|
function isValidUrl(str, allowRelativeUrls) {
|
|
22468
|
-
const isRelative = str.
|
|
22515
|
+
const isRelative = !str.includes('://');
|
|
22469
22516
|
try {
|
|
22470
22517
|
new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' : void 0);
|
|
22471
22518
|
return true;
|
|
@@ -22500,8 +22547,8 @@ function validateLight(options) {
|
|
|
22500
22547
|
}
|
|
22501
22548
|
let errors = [];
|
|
22502
22549
|
for (const key in light) {
|
|
22503
|
-
const transitionMatch = key.match(
|
|
22504
|
-
const useThemeMatch = key.match(
|
|
22550
|
+
const transitionMatch = key.match(TRANSITION_KEY_RE);
|
|
22551
|
+
const useThemeMatch = key.match(USE_THEME_KEY_RE);
|
|
22505
22552
|
if (useThemeMatch && lightSpec[useThemeMatch[1]]) {
|
|
22506
22553
|
errors = errors.concat(validate({
|
|
22507
22554
|
key,
|
|
@@ -22585,8 +22632,8 @@ function validateLights(options) {
|
|
|
22585
22632
|
return errors;
|
|
22586
22633
|
}
|
|
22587
22634
|
for (const propertyKey in properties) {
|
|
22588
|
-
const transitionMatch = propertyKey.match(
|
|
22589
|
-
const useThemeMatch = propertyKey.match(
|
|
22635
|
+
const transitionMatch = propertyKey.match(TRANSITION_KEY_RE);
|
|
22636
|
+
const useThemeMatch = propertyKey.match(USE_THEME_KEY_RE);
|
|
22590
22637
|
if (useThemeMatch && lightPropertySpec[useThemeMatch[1]]) {
|
|
22591
22638
|
errors = errors.concat(validate({
|
|
22592
22639
|
key: key2,
|
|
@@ -22649,8 +22696,8 @@ function validateTerrain(options) {
|
|
|
22649
22696
|
}
|
|
22650
22697
|
let errors = [];
|
|
22651
22698
|
for (const key2 in terrain) {
|
|
22652
|
-
const transitionMatch = key2.match(
|
|
22653
|
-
const useThemeMatch = key2.match(
|
|
22699
|
+
const transitionMatch = key2.match(TRANSITION_KEY_RE);
|
|
22700
|
+
const useThemeMatch = key2.match(USE_THEME_KEY_RE);
|
|
22654
22701
|
if (useThemeMatch && terrainSpec[useThemeMatch[1]]) {
|
|
22655
22702
|
errors = errors.concat(validate({
|
|
22656
22703
|
key: key2,
|
|
@@ -22710,8 +22757,8 @@ function validateFog(options) {
|
|
|
22710
22757
|
}
|
|
22711
22758
|
let errors = [];
|
|
22712
22759
|
for (const key in fog) {
|
|
22713
|
-
const transitionMatch = key.match(
|
|
22714
|
-
const useThemeMatch = key.match(
|
|
22760
|
+
const transitionMatch = key.match(TRANSITION_KEY_RE);
|
|
22761
|
+
const useThemeMatch = key.match(USE_THEME_KEY_RE);
|
|
22715
22762
|
if (useThemeMatch && fogSpec[useThemeMatch[1]]) {
|
|
22716
22763
|
errors = errors.concat(validate({
|
|
22717
22764
|
key,
|
|
@@ -22900,7 +22947,6 @@ function validateObject(options) {
|
|
|
22900
22947
|
errors = errors.concat(validateElement({
|
|
22901
22948
|
key: (key ? `${ key }.` : key) + objectKey,
|
|
22902
22949
|
value: object[objectKey],
|
|
22903
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
22904
22950
|
valueSpec: elementSpec,
|
|
22905
22951
|
style,
|
|
22906
22952
|
styleSpec,
|
|
@@ -22928,10 +22974,10 @@ function validateGlyphsUrl({key, value}) {
|
|
|
22928
22974
|
if (errors.length)
|
|
22929
22975
|
return errors;
|
|
22930
22976
|
const str = value;
|
|
22931
|
-
if (str.
|
|
22977
|
+
if (!str.includes('{fontstack}')) {
|
|
22932
22978
|
errors.push(new ValidationError(key, value, '"glyphs" url must include a "{fontstack}" token'));
|
|
22933
22979
|
}
|
|
22934
|
-
if (str.
|
|
22980
|
+
if (!str.includes('{range}')) {
|
|
22935
22981
|
errors.push(new ValidationError(key, value, '"glyphs" url must include a "{range}" token'));
|
|
22936
22982
|
}
|
|
22937
22983
|
return errors;
|
|
@@ -22942,7 +22988,7 @@ function validateStyle$2(style, styleSpec = v8, options = {}) {
|
|
|
22942
22988
|
key: options.key || '',
|
|
22943
22989
|
value: style,
|
|
22944
22990
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
22945
|
-
valueSpec: Object.assign(styleSpec.$root, // Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
|
|
22991
|
+
valueSpec: Object.assign({}, styleSpec.$root, // Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
|
|
22946
22992
|
{ '*': { type: '*' } }),
|
|
22947
22993
|
styleSpec,
|
|
22948
22994
|
style,
|
|
@@ -23101,6 +23147,10 @@ function validateStyle(style, styleSpec = v8) {
|
|
|
23101
23147
|
return validateStyle$1(s, styleSpec);
|
|
23102
23148
|
}
|
|
23103
23149
|
|
|
23150
|
+
const MAPBOX_SOURCE_URL_RE = /^mapbox:\/\/([^/]*)$/;
|
|
23151
|
+
const MAPBOX_GLYPH_URL_RE = /^mapbox:\/\/fonts\/([^/]*)\/{fontstack}\/{range}.pbf$/;
|
|
23152
|
+
const MAPBOX_SPRITE_URL_RE = /^mapbox:\/\/sprites\/([^/]*)\/([^/]*)\/?([^/]*)?$/;
|
|
23153
|
+
const VISIBILITY_RE = /^(public|private)$/;
|
|
23104
23154
|
const SUPPORTED_SPEC_VERSION = 8;
|
|
23105
23155
|
const MAX_SOURCES_IN_STYLE = 15;
|
|
23106
23156
|
function isValid(value, regex) {
|
|
@@ -23140,8 +23190,7 @@ function getSourceErrors(source, i) {
|
|
|
23140
23190
|
if (!acceptedSourceTypes.has(String(source.type))) {
|
|
23141
23191
|
errors.push(new ValidationError(`sources[${ i }].type`, source.type, `Expected one of [${ Array.from(acceptedSourceTypes).join(', ') }]`));
|
|
23142
23192
|
}
|
|
23143
|
-
|
|
23144
|
-
if (!('url' in source) || !isValid(source.url, sourceUrlPattern)) {
|
|
23193
|
+
if (!('url' in source) || !isValid(source.url, MAPBOX_SOURCE_URL_RE)) {
|
|
23145
23194
|
errors.push(new ValidationError(`sources[${ i }].url`, source.url, 'Expected a valid Mapbox tileset url'));
|
|
23146
23195
|
}
|
|
23147
23196
|
return errors;
|
|
@@ -23213,16 +23262,13 @@ function getRootErrors(style, specKeys) {
|
|
|
23213
23262
|
if (style.version > SUPPORTED_SPEC_VERSION || style.version < SUPPORTED_SPEC_VERSION) {
|
|
23214
23263
|
errors.push(new ValidationError('version', style.version, `Style version must be ${ SUPPORTED_SPEC_VERSION }`));
|
|
23215
23264
|
}
|
|
23216
|
-
|
|
23217
|
-
if (!isValid(style.glyphs, glyphUrlPattern)) {
|
|
23265
|
+
if (!isValid(style.glyphs, MAPBOX_GLYPH_URL_RE)) {
|
|
23218
23266
|
errors.push(new ValidationError('glyphs', style.glyphs, 'Styles must reference glyphs hosted by Mapbox'));
|
|
23219
23267
|
}
|
|
23220
|
-
|
|
23221
|
-
if (!isValid(style.sprite, spriteUrlPattern)) {
|
|
23268
|
+
if (!isValid(style.sprite, MAPBOX_SPRITE_URL_RE)) {
|
|
23222
23269
|
errors.push(new ValidationError('sprite', style.sprite, 'Styles must reference sprites hosted by Mapbox'));
|
|
23223
23270
|
}
|
|
23224
|
-
|
|
23225
|
-
if (!isValid(style.visibility, visibilityPattern)) {
|
|
23271
|
+
if (!isValid(style.visibility, VISIBILITY_RE)) {
|
|
23226
23272
|
errors.push(new ValidationError('visibility', style.visibility, 'Style visibility must be public or private'));
|
|
23227
23273
|
}
|
|
23228
23274
|
if (style.protected !== void 0 && !isBoolean(style.protected)) {
|