@mapbox/mapbox-gl-style-spec 14.16.0-beta.2 → 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 +50 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.es.js +50 -48
- 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 +3 -2
- package/read_style.ts +1 -2
- package/reference/v8.json +23 -18
- package/types.ts +6 -2
- package/validate/validate_appearance.ts +6 -9
- package/validate/validate_filter.ts +0 -2
- package/validate/validate_layer.ts +3 -2
- package/validate/validate_object.ts +2 -2
- package/validate/validate_projection.ts +3 -3
- package/validate/validate_property.ts +16 -24
- 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
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
},
|
|
134
134
|
indoor: {
|
|
135
135
|
type: "indoor",
|
|
136
|
+
"private": true,
|
|
136
137
|
experimental: true,
|
|
137
138
|
doc: "Controls the behaviour of indoor features."
|
|
138
139
|
},
|
|
@@ -837,7 +838,7 @@
|
|
|
837
838
|
},
|
|
838
839
|
promoteId: {
|
|
839
840
|
type: "promoteId",
|
|
840
|
-
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"
|
|
841
842
|
},
|
|
842
843
|
volatile: {
|
|
843
844
|
type: "boolean",
|
|
@@ -1203,7 +1204,7 @@
|
|
|
1203
1204
|
},
|
|
1204
1205
|
promoteId: {
|
|
1205
1206
|
type: "promoteId",
|
|
1206
|
-
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."
|
|
1207
1208
|
},
|
|
1208
1209
|
dynamic: {
|
|
1209
1210
|
type: "boolean",
|
|
@@ -1647,7 +1648,7 @@
|
|
|
1647
1648
|
"symbol"
|
|
1648
1649
|
],
|
|
1649
1650
|
"private": true,
|
|
1650
|
-
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."
|
|
1651
1652
|
}
|
|
1652
1653
|
};
|
|
1653
1654
|
var appearance = {
|
|
@@ -5609,6 +5610,7 @@
|
|
|
5609
5610
|
doc: "Experimental. Returns `true` if the input floor id belongs to one of the active indoor floors, `false` otherwise. In case of array of strings, returns `true` if any of the input floor ids belongs to one of the active indoor floors, `false` otherwise. Only supported in filters.",
|
|
5610
5611
|
group: "Indoor",
|
|
5611
5612
|
experimental: true,
|
|
5613
|
+
"private": true,
|
|
5612
5614
|
"sdk-support": {
|
|
5613
5615
|
"basic functionality": {
|
|
5614
5616
|
js: "3.16.0",
|
|
@@ -6476,26 +6478,29 @@
|
|
|
6476
6478
|
}
|
|
6477
6479
|
}
|
|
6478
6480
|
};
|
|
6479
|
-
var
|
|
6480
|
-
|
|
6481
|
+
var indoor_source = {
|
|
6482
|
+
sourceId: {
|
|
6481
6483
|
type: "string",
|
|
6482
|
-
doc: "
|
|
6484
|
+
doc: "Source ID of a source to be used to retrieve indoor data.",
|
|
6483
6485
|
experimental: true,
|
|
6486
|
+
"private": true,
|
|
6484
6487
|
transition: false,
|
|
6485
|
-
"property-type": "data-constant"
|
|
6486
|
-
expression: {
|
|
6487
|
-
interpolated: false
|
|
6488
|
-
}
|
|
6488
|
+
"property-type": "data-constant"
|
|
6489
6489
|
},
|
|
6490
|
-
|
|
6491
|
-
type: "
|
|
6492
|
-
|
|
6490
|
+
sourceLayers: {
|
|
6491
|
+
type: "array",
|
|
6492
|
+
value: "string",
|
|
6493
|
+
doc: "An array of source layers to be used to retrieve indoor data.",
|
|
6493
6494
|
experimental: true,
|
|
6495
|
+
"private": true,
|
|
6494
6496
|
transition: false,
|
|
6495
|
-
"property-type": "data-constant"
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6497
|
+
"property-type": "data-constant"
|
|
6498
|
+
}
|
|
6499
|
+
};
|
|
6500
|
+
var indoor = {
|
|
6501
|
+
"*": {
|
|
6502
|
+
type: "indoor_source",
|
|
6503
|
+
doc: "Specification of an indoor source - sourceId and sourceLayer required for vector source, for GeoJSON sourceLayers should be omitted."
|
|
6499
6504
|
}
|
|
6500
6505
|
};
|
|
6501
6506
|
var light = {
|
|
@@ -10571,7 +10576,7 @@
|
|
|
10571
10576
|
var promoteId = {
|
|
10572
10577
|
"*": {
|
|
10573
10578
|
type: "*",
|
|
10574
|
-
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."
|
|
10575
10580
|
}
|
|
10576
10581
|
};
|
|
10577
10582
|
var $doc = {
|
|
@@ -10913,6 +10918,7 @@
|
|
|
10913
10918
|
rain: rain,
|
|
10914
10919
|
camera: camera,
|
|
10915
10920
|
colorTheme: colorTheme,
|
|
10921
|
+
indoor_source: indoor_source,
|
|
10916
10922
|
indoor: indoor,
|
|
10917
10923
|
light: light,
|
|
10918
10924
|
projection: projection,
|
|
@@ -14123,8 +14129,7 @@
|
|
|
14123
14129
|
}
|
|
14124
14130
|
return new FormattedSection(// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14125
14131
|
toString(evaluatedContent), null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14126
|
-
section.scale ? section.scale.evaluate(ctx) : null, // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
14127
|
-
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
|
|
14128
14133
|
section.textColor ? section.textColor.evaluate(ctx) : null);
|
|
14129
14134
|
};
|
|
14130
14135
|
return new Formatted(this.sections.map(evaluateSection));
|
|
@@ -16433,8 +16438,7 @@
|
|
|
16433
16438
|
}
|
|
16434
16439
|
const ruler = new CheapRuler(lngLatLines[0][0][1], 'meters');
|
|
16435
16440
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
16436
|
-
return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates,
|
|
16437
|
-
geometry.type === 'LineString', lngLatLines, ruler);
|
|
16441
|
+
return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatLines, ruler);
|
|
16438
16442
|
}
|
|
16439
16443
|
if (geometry.type === 'MultiLineString') {
|
|
16440
16444
|
let dist = Infinity;
|
|
@@ -16471,8 +16475,7 @@
|
|
|
16471
16475
|
}
|
|
16472
16476
|
const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], 'meters');
|
|
16473
16477
|
if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
|
|
16474
|
-
return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates,
|
|
16475
|
-
geometry.type === 'LineString', lngLatPolygons, ruler);
|
|
16478
|
+
return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatPolygons, ruler);
|
|
16476
16479
|
}
|
|
16477
16480
|
if (geometry.type === 'MultiLineString') {
|
|
16478
16481
|
let dist = Infinity;
|
|
@@ -16486,8 +16489,7 @@
|
|
|
16486
16489
|
return dist;
|
|
16487
16490
|
}
|
|
16488
16491
|
if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
|
|
16489
|
-
return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates,
|
|
16490
|
-
lngLatPolygons, ruler);
|
|
16492
|
+
return polygonsToPolygonsDistance(geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, lngLatPolygons, ruler);
|
|
16491
16493
|
}
|
|
16492
16494
|
return null;
|
|
16493
16495
|
}
|
|
@@ -17426,11 +17428,8 @@
|
|
|
17426
17428
|
outputType = outputType || parsed.type;
|
|
17427
17429
|
parsedArgs.push(parsed);
|
|
17428
17430
|
}
|
|
17429
|
-
const needsAnnotation = expectedType &&
|
|
17430
|
-
|
|
17431
|
-
return needsAnnotation ? // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
17432
|
-
new Coalesce(ValueType, parsedArgs) : // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
17433
|
-
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);
|
|
17434
17433
|
}
|
|
17435
17434
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17436
17435
|
evaluate(ctx) {
|
|
@@ -19364,6 +19363,9 @@
|
|
|
19364
19363
|
constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
19365
19364
|
this.expression = expression;
|
|
19366
19365
|
this._warningHistory = {};
|
|
19366
|
+
this._scope = scope;
|
|
19367
|
+
this._options = options;
|
|
19368
|
+
this._iconImageUseTheme = iconImageUseTheme;
|
|
19367
19369
|
this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
|
|
19368
19370
|
this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
|
|
19369
19371
|
this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
|
|
@@ -19382,6 +19384,9 @@
|
|
|
19382
19384
|
return this.expression.evaluate(this._evaluator);
|
|
19383
19385
|
}
|
|
19384
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
|
+
}
|
|
19385
19390
|
this._evaluator.globals = globals;
|
|
19386
19391
|
this._evaluator.feature = feature || null;
|
|
19387
19392
|
this._evaluator.featureState = featureState || null;
|
|
@@ -21643,14 +21648,12 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
21643
21648
|
case '<':
|
|
21644
21649
|
case '<=':
|
|
21645
21650
|
case '>':
|
|
21646
|
-
// @ts-expect-error - falls through
|
|
21647
21651
|
case '>=':
|
|
21648
21652
|
if (value.length >= 2 && unbundle(value[1]) === '$type') {
|
|
21649
21653
|
errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${ value[0] }"`));
|
|
21650
21654
|
}
|
|
21651
21655
|
/* falls through */
|
|
21652
21656
|
case '==':
|
|
21653
|
-
// @ts-expect-error - falls through
|
|
21654
21657
|
case '!=':
|
|
21655
21658
|
if (value.length !== 3) {
|
|
21656
21659
|
errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
|
|
@@ -21712,16 +21715,16 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
21712
21715
|
return [];
|
|
21713
21716
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
21714
21717
|
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
21715
|
-
if (isExpression(value)) {
|
|
21718
|
+
if (isExpression(deepUnbundle(value))) {
|
|
21716
21719
|
const errors2 = [];
|
|
21717
21720
|
return errors2.concat(validate({
|
|
21718
|
-
key
|
|
21721
|
+
key,
|
|
21719
21722
|
value,
|
|
21720
21723
|
valueSpec: {
|
|
21721
|
-
|
|
21722
|
-
|
|
21723
|
-
|
|
21724
|
-
|
|
21724
|
+
type: 'string',
|
|
21725
|
+
expression: {
|
|
21726
|
+
interpolated: false,
|
|
21727
|
+
parameters: [
|
|
21725
21728
|
'zoom',
|
|
21726
21729
|
'feature'
|
|
21727
21730
|
]
|
|
@@ -21775,7 +21778,8 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21775
21778
|
} else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
|
|
21776
21779
|
if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
|
|
21777
21780
|
const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
|
|
21778
|
-
const
|
|
21781
|
+
const expressionValue = expression.value;
|
|
21782
|
+
const expressionObj = 'expression' in expressionValue && expressionValue.expression || '_styleExpression' in expressionValue && expressionValue._styleExpression && expressionValue._styleExpression.expression;
|
|
21779
21783
|
if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
|
|
21780
21784
|
if (propertyKey !== 'model-emissive-strength' || (!isFeatureConstant(expressionObj) || !isStateConstant(expressionObj))) {
|
|
21781
21785
|
errors.push(new ValidationError(key, value, `${ propertyKey } does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`));
|
|
@@ -21786,7 +21790,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21786
21790
|
return errors.concat(validate({
|
|
21787
21791
|
key: options.key,
|
|
21788
21792
|
value,
|
|
21789
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
21790
21793
|
valueSpec,
|
|
21791
21794
|
style,
|
|
21792
21795
|
styleSpec,
|
|
@@ -21818,7 +21821,7 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21818
21821
|
}, options2))
|
|
21819
21822
|
}
|
|
21820
21823
|
});
|
|
21821
|
-
if (name !== 'hidden' &&
|
|
21824
|
+
if (name !== 'hidden' && condition === void 0) {
|
|
21822
21825
|
errors.push(new ValidationError(options.key, 'name', `Appearance with name different than "hidden" must have a condition`));
|
|
21823
21826
|
}
|
|
21824
21827
|
return errors;
|
|
@@ -21842,7 +21845,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21842
21845
|
layer,
|
|
21843
21846
|
layerType,
|
|
21844
21847
|
value: properties[propertyKey],
|
|
21845
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
21846
21848
|
valueSpec: propertyType === 'paint' ? paintProperties[propertyKey] : layoutProperties[propertyKey]
|
|
21847
21849
|
});
|
|
21848
21850
|
errors.push(...validateProperty(propertyValidationOptions, propertyType));
|
|
@@ -21856,7 +21858,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21856
21858
|
errors.push(...validateExpression({
|
|
21857
21859
|
key: options.key,
|
|
21858
21860
|
value: condition,
|
|
21859
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
21860
21861
|
valueSpec: v8['appearance']['condition'],
|
|
21861
21862
|
expressionContext: 'appearance'
|
|
21862
21863
|
}));
|
|
@@ -22159,10 +22160,11 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22159
22160
|
}
|
|
22160
22161
|
}
|
|
22161
22162
|
function getSourceTypeValues(styleSpec) {
|
|
22162
|
-
|
|
22163
|
+
const sourceArray = styleSpec.source;
|
|
22164
|
+
return sourceArray.reduce((memo, source) => {
|
|
22163
22165
|
const sourceType = styleSpec[source];
|
|
22164
22166
|
if (sourceType.type.type === 'enum') {
|
|
22165
|
-
memo = memo.concat(Object.keys(sourceType.type.values));
|
|
22167
|
+
memo = memo.concat(Object.keys(sourceType.type.values || {}));
|
|
22166
22168
|
}
|
|
22167
22169
|
return memo;
|
|
22168
22170
|
}, []);
|
|
@@ -22523,7 +22525,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22523
22525
|
errors = errors.concat(validate({
|
|
22524
22526
|
key,
|
|
22525
22527
|
value: projection[key],
|
|
22526
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
22527
22528
|
valueSpec: projectionSpec[key],
|
|
22528
22529
|
style,
|
|
22529
22530
|
styleSpec
|
|
@@ -22664,7 +22665,8 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
22664
22665
|
if (elementValidators[elementSpecKey]) {
|
|
22665
22666
|
continue;
|
|
22666
22667
|
}
|
|
22667
|
-
|
|
22668
|
+
const elementSpec = elementSpecs[elementSpecKey];
|
|
22669
|
+
if (elementSpec.required && elementSpec['default'] === void 0 && object[elementSpecKey] === void 0) {
|
|
22668
22670
|
errors.push(new ValidationError(key, object, `missing required property "${ elementSpecKey }"`));
|
|
22669
22671
|
}
|
|
22670
22672
|
}
|