@mapbox/mapbox-gl-style-spec 14.16.0-beta.2 → 14.16.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +27 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.es.js +27 -25
- package/dist/index.es.js.map +1 -1
- package/package.json +3 -2
- package/reference/v8.json +19 -14
- package/types.ts +6 -2
- package/validate/validate_appearance.ts +5 -7
- package/validate/validate_filter.ts +0 -2
- package/validate/validate_layer.ts +3 -2
- package/validate/validate_property.ts +11 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapbox/mapbox-gl-style-spec",
|
|
3
|
-
"version": "14.16.0-beta.
|
|
3
|
+
"version": "14.16.0-beta.3",
|
|
4
4
|
"description": "a specification for mapbox gl styles",
|
|
5
5
|
"author": "Mapbox",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"require": "./dist/index.cjs",
|
|
24
|
-
"import": "./dist/index.es.js"
|
|
24
|
+
"import": "./dist/index.es.js",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
25
26
|
},
|
|
26
27
|
"./": {
|
|
27
28
|
"import": "./"
|
package/reference/v8.json
CHANGED
|
@@ -125,6 +125,7 @@
|
|
|
125
125
|
},
|
|
126
126
|
"indoor": {
|
|
127
127
|
"type": "indoor",
|
|
128
|
+
"private": true,
|
|
128
129
|
"experimental": true,
|
|
129
130
|
"doc": "Controls the behaviour of indoor features."
|
|
130
131
|
},
|
|
@@ -5750,6 +5751,7 @@
|
|
|
5750
5751
|
"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.",
|
|
5751
5752
|
"group": "Indoor",
|
|
5752
5753
|
"experimental": true,
|
|
5754
|
+
"private": true,
|
|
5753
5755
|
"sdk-support": {
|
|
5754
5756
|
"basic functionality": {
|
|
5755
5757
|
"js": "3.16.0",
|
|
@@ -6586,26 +6588,29 @@
|
|
|
6586
6588
|
}
|
|
6587
6589
|
}
|
|
6588
6590
|
},
|
|
6589
|
-
"
|
|
6590
|
-
"
|
|
6591
|
+
"indoor_source": {
|
|
6592
|
+
"sourceId": {
|
|
6591
6593
|
"type": "string",
|
|
6592
|
-
"doc": "
|
|
6594
|
+
"doc": "Source ID of a source to be used to retrieve indoor data.",
|
|
6593
6595
|
"experimental": true,
|
|
6596
|
+
"private": true,
|
|
6594
6597
|
"transition": false,
|
|
6595
|
-
"property-type": "data-constant"
|
|
6596
|
-
"expression": {
|
|
6597
|
-
"interpolated": false
|
|
6598
|
-
}
|
|
6598
|
+
"property-type": "data-constant"
|
|
6599
6599
|
},
|
|
6600
|
-
"
|
|
6601
|
-
"type": "
|
|
6602
|
-
"
|
|
6600
|
+
"sourceLayers": {
|
|
6601
|
+
"type": "array",
|
|
6602
|
+
"value": "string",
|
|
6603
|
+
"doc": "An array of source layers to be used to retrieve indoor data.",
|
|
6603
6604
|
"experimental": true,
|
|
6605
|
+
"private": true,
|
|
6604
6606
|
"transition": false,
|
|
6605
|
-
"property-type": "data-constant"
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6607
|
+
"property-type": "data-constant"
|
|
6608
|
+
}
|
|
6609
|
+
},
|
|
6610
|
+
"indoor": {
|
|
6611
|
+
"*": {
|
|
6612
|
+
"type": "indoor_source",
|
|
6613
|
+
"doc": "Specification of an indoor source - sourceId and sourceLayer required for vector source, for GeoJSON sourceLayers should be omitted."
|
|
6609
6614
|
}
|
|
6610
6615
|
},
|
|
6611
6616
|
"light": {
|
package/types.ts
CHANGED
|
@@ -329,14 +329,18 @@ export type ImportSpecification = {
|
|
|
329
329
|
};
|
|
330
330
|
|
|
331
331
|
export type IndoorSpecification = {
|
|
332
|
+
[_: string]: IndoorSourceSpecification
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export type IndoorSourceSpecification = {
|
|
332
336
|
/**
|
|
333
337
|
* @experimental This property is experimental and subject to change in future versions.
|
|
334
338
|
*/
|
|
335
|
-
"
|
|
339
|
+
"sourceId"?: string,
|
|
336
340
|
/**
|
|
337
341
|
* @experimental This property is experimental and subject to change in future versions.
|
|
338
342
|
*/
|
|
339
|
-
"
|
|
343
|
+
"sourceLayers"?: Array<string>
|
|
340
344
|
};
|
|
341
345
|
|
|
342
346
|
export type ConfigSpecification = {
|
|
@@ -7,6 +7,7 @@ import latest from '../reference/latest';
|
|
|
7
7
|
|
|
8
8
|
import type {StyleSpecification, LayerSpecification, AppearanceSpecification} from '../types';
|
|
9
9
|
import type {StyleReference} from '../reference/latest';
|
|
10
|
+
import type {StylePropertySpecification} from '../style-spec';
|
|
10
11
|
|
|
11
12
|
export type AppearanceValidatorOptions = {
|
|
12
13
|
key: string;
|
|
@@ -37,7 +38,7 @@ export default function validateAppearance(options: AppearanceValidatorOptions):
|
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
|
|
40
|
-
if (name !== 'hidden' &&
|
|
41
|
+
if (name !== 'hidden' && condition === undefined) {
|
|
41
42
|
errors.push(new ValidationError(options.key, 'name', `Appearance with name different than "hidden" must have a condition`));
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -49,10 +50,8 @@ function validateProperties(options: AppearanceValidatorOptions): Array<Validati
|
|
|
49
50
|
|
|
50
51
|
const {styleSpec, layer, layerType} = options;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
55
|
-
const layoutProperties = styleSpec[`layout_${layerType}`];
|
|
53
|
+
const paintProperties = styleSpec[`paint_${layerType}`] as Record<string, StylePropertySpecification> | undefined;
|
|
54
|
+
const layoutProperties = styleSpec[`layout_${layerType}`] as Record<string, StylePropertySpecification> | undefined;
|
|
56
55
|
const properties = options.object[options.objectKey] as object;
|
|
57
56
|
|
|
58
57
|
for (const propertyKey in properties) {
|
|
@@ -73,8 +72,7 @@ function validateProperties(options: AppearanceValidatorOptions): Array<Validati
|
|
|
73
72
|
layer,
|
|
74
73
|
layerType,
|
|
75
74
|
value: properties[propertyKey] as unknown,
|
|
76
|
-
|
|
77
|
-
valueSpec: (propertyType === 'paint' ? paintProperties[propertyKey] : layoutProperties[propertyKey]) as object,
|
|
75
|
+
valueSpec: (propertyType === 'paint' ? paintProperties[propertyKey] : layoutProperties[propertyKey]),
|
|
78
76
|
});
|
|
79
77
|
|
|
80
78
|
errors.push(...validateProperty(propertyValidationOptions, propertyType));
|
|
@@ -59,14 +59,12 @@ function validateNonExpressionFilter(options: FilterValidatorOptions): Validatio
|
|
|
59
59
|
case '<':
|
|
60
60
|
case '<=':
|
|
61
61
|
case '>':
|
|
62
|
-
// @ts-expect-error - falls through
|
|
63
62
|
case '>=':
|
|
64
63
|
if (value.length >= 2 && unbundle(value[1]) === '$type') {
|
|
65
64
|
errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${value[0]}"`));
|
|
66
65
|
}
|
|
67
66
|
/* falls through */
|
|
68
67
|
case '==':
|
|
69
|
-
// @ts-expect-error - falls through
|
|
70
68
|
case '!=':
|
|
71
69
|
if (value.length !== 3) {
|
|
72
70
|
errors.push(new ValidationError(key, value, `filter array for operator "${value[0]}" must have 3 elements`));
|
|
@@ -10,6 +10,7 @@ import validateSpec from './validate';
|
|
|
10
10
|
import {isObject, isString} from '../util/get_type';
|
|
11
11
|
|
|
12
12
|
import type {StyleReference} from '../reference/latest';
|
|
13
|
+
import type {PropertyValidatorOptions} from './validate_property';
|
|
13
14
|
import type {StyleSpecification, LayerSpecification, GeoJSONSourceSpecification} from '../types';
|
|
14
15
|
|
|
15
16
|
type LayerValidatorOptions = {
|
|
@@ -138,7 +139,7 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
138
139
|
style: options.style,
|
|
139
140
|
styleSpec: options.styleSpec,
|
|
140
141
|
objectElementValidators: {
|
|
141
|
-
'*'(options) {
|
|
142
|
+
'*'(options: PropertyValidatorOptions) {
|
|
142
143
|
return validateLayoutProperty(Object.assign({layerType: type}, options));
|
|
143
144
|
}
|
|
144
145
|
}
|
|
@@ -153,7 +154,7 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
153
154
|
style: options.style,
|
|
154
155
|
styleSpec: options.styleSpec,
|
|
155
156
|
objectElementValidators: {
|
|
156
|
-
'*'(options) {
|
|
157
|
+
'*'(options: PropertyValidatorOptions) {
|
|
157
158
|
return validatePaintProperty(Object.assign({layerType: type, layer}, options));
|
|
158
159
|
}
|
|
159
160
|
}
|
|
@@ -8,12 +8,13 @@ import {isGlobalPropertyConstant, isFeatureConstant, isStateConstant} from '../e
|
|
|
8
8
|
import {createPropertyExpression, isExpression} from '../expression/index';
|
|
9
9
|
|
|
10
10
|
import type {StyleReference} from '../reference/latest';
|
|
11
|
+
import type {StylePropertySpecification} from '../style-spec';
|
|
11
12
|
import type {StyleSpecification, LayerSpecification} from '../types';
|
|
12
13
|
|
|
13
14
|
export type PropertyValidatorOptions = {
|
|
14
15
|
key: string;
|
|
15
16
|
value: unknown;
|
|
16
|
-
valueSpec?:
|
|
17
|
+
valueSpec?: StylePropertySpecification;
|
|
17
18
|
style: Partial<StyleSpecification>;
|
|
18
19
|
styleSpec: StyleReference;
|
|
19
20
|
objectKey?: string;
|
|
@@ -28,29 +29,24 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
28
29
|
const styleSpec = options.styleSpec;
|
|
29
30
|
const value = options.value;
|
|
30
31
|
const propertyKey = options.objectKey;
|
|
31
|
-
|
|
32
|
-
const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];
|
|
32
|
+
const layerSpec = styleSpec[`${propertyType}_${options.layerType}`] as Record<string, StylePropertySpecification> | undefined;
|
|
33
33
|
|
|
34
34
|
if (!layerSpec) return [];
|
|
35
35
|
|
|
36
36
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
38
37
|
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
39
|
-
if (isExpression(value)) {
|
|
38
|
+
if (isExpression(deepUnbundle(value))) {
|
|
40
39
|
const errors: ValidationError[] = [];
|
|
41
40
|
return errors.concat(validate({
|
|
42
|
-
key
|
|
41
|
+
key,
|
|
43
42
|
value,
|
|
44
43
|
valueSpec: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"zoom",
|
|
50
|
-
"feature"
|
|
51
|
-
]
|
|
44
|
+
type: 'string',
|
|
45
|
+
expression: {
|
|
46
|
+
interpolated: false,
|
|
47
|
+
parameters: ['zoom', 'feature']
|
|
52
48
|
},
|
|
53
|
-
|
|
49
|
+
'property-type': 'data-driven'
|
|
54
50
|
},
|
|
55
51
|
style,
|
|
56
52
|
styleSpec,
|
|
@@ -59,6 +55,7 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
59
55
|
propertyKey
|
|
60
56
|
}));
|
|
61
57
|
}
|
|
58
|
+
|
|
62
59
|
return validate({
|
|
63
60
|
key,
|
|
64
61
|
value,
|
|
@@ -69,7 +66,6 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
const transitionMatch = propertyKey.match(/^(.*)-transition$/);
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
73
69
|
if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {
|
|
74
70
|
return validate({
|
|
75
71
|
key,
|
|
@@ -81,14 +77,12 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
85
80
|
const valueSpec = options.valueSpec || layerSpec[propertyKey];
|
|
86
81
|
if (!valueSpec) {
|
|
87
82
|
return [new ValidationWarning(key, value, `unknown property "${propertyKey}"`)];
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
let tokenMatch: RegExpExecArray | undefined;
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
92
86
|
if (isString(value) && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {
|
|
93
87
|
const example = `\`{ "type": "identity", "property": ${tokenMatch ? JSON.stringify(tokenMatch[1]) : '"_"'} }\``;
|
|
94
88
|
return [new ValidationError(
|
|
@@ -107,10 +101,8 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
107
101
|
errors.push(new ValidationError(key, value, '"text-font" does not support identity functions'));
|
|
108
102
|
}
|
|
109
103
|
} else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
111
104
|
if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
|
|
112
105
|
// Performance related style spec limitation: zoom and light expressions are not allowed for e.g. trees.
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
114
106
|
const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
|
|
115
107
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
116
108
|
const expressionObj = (expression.value as any).expression || (expression.value as any)._styleExpression.expression;
|
|
@@ -128,7 +120,6 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
128
120
|
return errors.concat(validate({
|
|
129
121
|
key: options.key,
|
|
130
122
|
value,
|
|
131
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
132
123
|
valueSpec,
|
|
133
124
|
style,
|
|
134
125
|
styleSpec,
|