@mapbox/mapbox-gl-style-spec 14.16.0-beta.3 → 14.16.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/diff.ts +3 -4
- package/dist/index.cjs +23 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.es.js +23 -23
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/case.ts +1 -2
- package/expression/definitions/coalesce.ts +2 -5
- package/expression/definitions/distance.ts +8 -20
- package/expression/definitions/format.ts +1 -2
- package/expression/definitions/in.ts +2 -2
- package/expression/definitions/index_of.ts +3 -4
- package/expression/definitions/match.ts +2 -6
- package/expression/index.ts +12 -1
- package/expression/parsing_context.ts +1 -2
- package/feature_filter/convert.ts +8 -11
- package/function/convert.ts +3 -6
- package/package.json +1 -1
- package/read_style.ts +1 -2
- package/reference/v8.json +4 -4
- package/validate/validate_appearance.ts +1 -2
- package/validate/validate_object.ts +2 -2
- package/validate/validate_projection.ts +3 -3
- package/validate/validate_property.ts +5 -4
- package/validate/validate_rain.ts +3 -5
- package/validate/validate_snow.ts +3 -5
- package/validate/validate_source.ts +6 -8
package/diff.ts
CHANGED
|
@@ -629,8 +629,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
|
|
|
629
629
|
const sourcesRemoved: Record<string, true> = {};
|
|
630
630
|
|
|
631
631
|
// First collect the {add,remove}Source commands
|
|
632
|
-
const removeOrAddSourceCommands = [];
|
|
633
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
632
|
+
const removeOrAddSourceCommands: Command[] = [];
|
|
634
633
|
diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);
|
|
635
634
|
|
|
636
635
|
// Push a removeLayer command for each style layer that depends on a
|
|
@@ -638,7 +637,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
|
|
|
638
637
|
// Also, exclude any such layers them from the input to `diffLayers`
|
|
639
638
|
// below, so that diffLayers produces the appropriate `addLayers`
|
|
640
639
|
// command
|
|
641
|
-
const beforeLayers = [];
|
|
640
|
+
const beforeLayers: LayerSpecification[] = [];
|
|
642
641
|
if (before.layers) {
|
|
643
642
|
before.layers.forEach((layer) => {
|
|
644
643
|
if (layer.source && sourcesRemoved[layer.source]) {
|
|
@@ -667,7 +666,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
|
|
|
667
666
|
}
|
|
668
667
|
|
|
669
668
|
// Handle changes to `layers`
|
|
670
|
-
|
|
669
|
+
|
|
671
670
|
diffLayers(beforeLayers, after.layers, commands);
|
|
672
671
|
} catch (e) {
|
|
673
672
|
// fall back to setStyle
|
package/dist/index.cjs
CHANGED
|
@@ -838,7 +838,7 @@
|
|
|
838
838
|
},
|
|
839
839
|
promoteId: {
|
|
840
840
|
type: "promoteId",
|
|
841
|
-
doc: "A property to use as a feature id (for feature state).
|
|
841
|
+
doc: "A property to use as a feature id (for feature state). It can be a property name, or an expression to evaluate as the ID, or an object of the form `{<sourceLayer>: <propertyName/expression>}`. The expression can only be feature dependent if it is used. If specified as a string for a vector tile source, the same property is used across all its source layers. If specified as an object only specified source layers will have id overriden, others will fallback to original feature id"
|
|
842
842
|
},
|
|
843
843
|
volatile: {
|
|
844
844
|
type: "boolean",
|
|
@@ -1204,7 +1204,7 @@
|
|
|
1204
1204
|
},
|
|
1205
1205
|
promoteId: {
|
|
1206
1206
|
type: "promoteId",
|
|
1207
|
-
doc: "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{<sourceLayer>: <propertyName>}`."
|
|
1207
|
+
doc: "A property to use as a feature id (for feature state). Either a property name, an expression to evaluate as the ID, or an object of the form `{<sourceLayer>: <propertyName/expression>}`. The expression can only be feature dependent if it is used."
|
|
1208
1208
|
},
|
|
1209
1209
|
dynamic: {
|
|
1210
1210
|
type: "boolean",
|
|
@@ -1648,7 +1648,7 @@
|
|
|
1648
1648
|
"symbol"
|
|
1649
1649
|
],
|
|
1650
1650
|
"private": true,
|
|
1651
|
-
doc: "Conditional styling applied to layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with '
|
|
1651
|
+
doc: "Conditional styling applied to symbol layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Works with appearances' are supported."
|
|
1652
1652
|
}
|
|
1653
1653
|
};
|
|
1654
1654
|
var appearance = {
|
|
@@ -10576,7 +10576,7 @@
|
|
|
10576
10576
|
var promoteId = {
|
|
10577
10577
|
"*": {
|
|
10578
10578
|
type: "*",
|
|
10579
|
-
doc: "A feature property name to use as the ID, or an expression to evaluate as the ID for feature state."
|
|
10579
|
+
doc: "A feature property name to use as the ID, or an expression to evaluate as the ID for feature state. The expression can only be feature dependent if it is used."
|
|
10580
10580
|
}
|
|
10581
10581
|
};
|
|
10582
10582
|
var $doc = {
|
|
@@ -14129,8 +14129,7 @@
|
|
|
14129
14129
|
}
|
|
14130
14130
|
return new FormattedSection(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14131
14131
|
toString(evaluatedContent), null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14132
|
-
section.scale ? section.scale.evaluate(ctx) : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14133
|
-
section.font ? section.font.evaluate(ctx).join(',') : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14132
|
+
section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14134
14133
|
section.textColor ? section.textColor.evaluate(ctx) : null);
|
|
14135
14134
|
};
|
|
14136
14135
|
return new Formatted(this.sections.map(evaluateSection));
|
|
@@ -16439,8 +16438,7 @@
|
|
|
16439
16438
|
}
|
|
16440
16439
|
const ruler = new CheapRuler(lngLatLines[0][0][1], 'meters');
|
|
16441
16440
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
16442
|
-
return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates,
|
|
16443
|
-
geometry.type === 'LineString', lngLatLines, ruler);
|
|
16441
|
+
return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatLines, ruler);
|
|
16444
16442
|
}
|
|
16445
16443
|
if (geometry.type === 'MultiLineString') {
|
|
16446
16444
|
let dist = Infinity;
|
|
@@ -16477,8 +16475,7 @@
|
|
|
16477
16475
|
}
|
|
16478
16476
|
const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], 'meters');
|
|
16479
16477
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
16480
|
-
return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates,
|
|
16481
|
-
geometry.type === 'LineString', lngLatPolygons, ruler);
|
|
16478
|
+
return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatPolygons, ruler);
|
|
16482
16479
|
}
|
|
16483
16480
|
if (geometry.type === 'MultiLineString') {
|
|
16484
16481
|
let dist = Infinity;
|
|
@@ -16492,8 +16489,7 @@
|
|
|
16492
16489
|
return dist;
|
|
16493
16490
|
}
|
|
16494
16491
|
if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
|
|
16495
|
-
return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates,
|
|
16496
|
-
lngLatPolygons, ruler);
|
|
16492
|
+
return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, lngLatPolygons, ruler);
|
|
16497
16493
|
}
|
|
16498
16494
|
return null;
|
|
16499
16495
|
}
|
|
@@ -17432,11 +17428,8 @@
|
|
|
17432
17428
|
outputType = outputType || parsed.type;
|
|
17433
17429
|
parsedArgs.push(parsed);
|
|
17434
17430
|
}
|
|
17435
|
-
const needsAnnotation = expectedType &&
|
|
17436
|
-
|
|
17437
|
-
return needsAnnotation ? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
17438
|
-
new Coalesce(ValueType, parsedArgs) : // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
17439
|
-
new Coalesce(outputType, parsedArgs);
|
|
17431
|
+
const needsAnnotation = expectedType && parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
|
|
17432
|
+
return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
|
|
17440
17433
|
}
|
|
17441
17434
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17442
17435
|
evaluate(ctx) {
|
|
@@ -19370,6 +19363,9 @@
|
|
|
19370
19363
|
constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
19371
19364
|
this.expression = expression;
|
|
19372
19365
|
this._warningHistory = {};
|
|
19366
|
+
this._scope = scope;
|
|
19367
|
+
this._options = options;
|
|
19368
|
+
this._iconImageUseTheme = iconImageUseTheme;
|
|
19373
19369
|
this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
|
|
19374
19370
|
this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
|
|
19375
19371
|
this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
|
|
@@ -19388,6 +19384,9 @@
|
|
|
19388
19384
|
return this.expression.evaluate(this._evaluator);
|
|
19389
19385
|
}
|
|
19390
19386
|
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData, iconImageUseTheme) {
|
|
19387
|
+
if (!this._evaluator) {
|
|
19388
|
+
this._evaluator = new EvaluationContext(this._scope, this._options, this._iconImageUseTheme);
|
|
19389
|
+
}
|
|
19391
19390
|
this._evaluator.globals = globals;
|
|
19392
19391
|
this._evaluator.feature = feature || null;
|
|
19393
19392
|
this._evaluator.featureState = featureState || null;
|
|
@@ -21779,7 +21778,8 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21779
21778
|
} else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
|
|
21780
21779
|
if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
|
|
21781
21780
|
const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
|
|
21782
|
-
const
|
|
21781
|
+
const expressionValue = expression.value;
|
|
21782
|
+
const expressionObj = 'expression' in expressionValue && expressionValue.expression || '_styleExpression' in expressionValue && expressionValue._styleExpression && expressionValue._styleExpression.expression;
|
|
21783
21783
|
if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
|
|
21784
21784
|
if (propertyKey !== 'model-emissive-strength' || (!isFeatureConstant(expressionObj) || !isStateConstant(expressionObj))) {
|
|
21785
21785
|
errors.push(new ValidationError(key, value, `${ propertyKey } does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`));
|
|
@@ -21858,7 +21858,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21858
21858
|
errors.push(...validateExpression({
|
|
21859
21859
|
key: options.key,
|
|
21860
21860
|
value: condition,
|
|
21861
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
21862
21861
|
valueSpec: v8['appearance']['condition'],
|
|
21863
21862
|
expressionContext: 'appearance'
|
|
21864
21863
|
}));
|
|
@@ -22161,10 +22160,11 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22161
22160
|
}
|
|
22162
22161
|
}
|
|
22163
22162
|
function getSourceTypeValues(styleSpec) {
|
|
22164
|
-
|
|
22163
|
+
const sourceArray = styleSpec.source;
|
|
22164
|
+
return sourceArray.reduce((memo, source) => {
|
|
22165
22165
|
const sourceType = styleSpec[source];
|
|
22166
22166
|
if (sourceType.type.type === 'enum') {
|
|
22167
|
-
memo = memo.concat(Object.keys(sourceType.type.values));
|
|
22167
|
+
memo = memo.concat(Object.keys(sourceType.type.values || {}));
|
|
22168
22168
|
}
|
|
22169
22169
|
return memo;
|
|
22170
22170
|
}, []);
|
|
@@ -22525,7 +22525,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22525
22525
|
errors = errors.concat(validate({
|
|
22526
22526
|
key,
|
|
22527
22527
|
value: projection[key],
|
|
22528
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
22529
22528
|
valueSpec: projectionSpec[key],
|
|
22530
22529
|
style,
|
|
22531
22530
|
styleSpec
|
|
@@ -22666,7 +22665,8 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22666
22665
|
if (elementValidators[elementSpecKey]) {
|
|
22667
22666
|
continue;
|
|
22668
22667
|
}
|
|
22669
|
-
|
|
22668
|
+
const elementSpec = elementSpecs[elementSpecKey];
|
|
22669
|
+
if (elementSpec.required && elementSpec['default'] === void 0 && object[elementSpecKey] === void 0) {
|
|
22670
22670
|
errors.push(new ValidationError(key, object, `missing required property "${ elementSpecKey }"`));
|
|
22671
22671
|
}
|
|
22672
22672
|
}
|