@mapbox/mapbox-gl-style-spec 14.15.0-beta.1 → 14.15.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/deref.ts +3 -0
- package/diff.ts +63 -0
- package/dist/index.cjs +743 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +85 -6
- package/dist/index.es.js +743 -65
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.ts +4 -0
- package/expression/definitions/assertion.ts +7 -0
- package/expression/definitions/case.ts +2 -1
- package/expression/definitions/coalesce.ts +4 -0
- package/expression/definitions/coercion.ts +12 -0
- package/expression/definitions/collator.ts +8 -5
- package/expression/definitions/comparison.ts +12 -5
- package/expression/definitions/config.ts +12 -0
- package/expression/definitions/distance.ts +13 -2
- package/expression/definitions/format.ts +10 -0
- package/expression/definitions/image.ts +3 -0
- package/expression/definitions/in.ts +5 -0
- package/expression/definitions/index.ts +62 -10
- package/expression/definitions/index_of.ts +6 -0
- package/expression/definitions/interpolate.ts +5 -1
- package/expression/definitions/length.ts +2 -0
- package/expression/definitions/let.ts +1 -0
- package/expression/definitions/match.ts +5 -0
- package/expression/definitions/number_format.ts +7 -0
- package/expression/definitions/slice.ts +4 -0
- package/expression/definitions/within.ts +1 -0
- package/expression/index.ts +28 -19
- package/expression/parsing_context.ts +2 -0
- package/expression/types/image_variant.ts +3 -0
- package/expression/types.ts +1 -2
- package/expression/values.ts +1 -0
- package/feature_filter/convert.ts +9 -1
- package/feature_filter/index.ts +41 -1
- package/format.ts +5 -0
- package/function/convert.ts +5 -0
- package/function/index.ts +79 -25
- package/group_by_layout.ts +4 -5
- package/migrate/v8.ts +42 -3
- package/migrate/v9.ts +5 -0
- package/migrate.ts +1 -0
- package/package.json +1 -1
- package/read_style.ts +2 -0
- package/reference/v8.json +457 -12
- package/rollup.config.js +1 -0
- package/test.js +4 -0
- package/types.ts +74 -5
- package/util/color.ts +21 -26
- package/util/geometry_util.ts +4 -0
- package/validate/validate.ts +1 -0
- package/validate/validate_appearance.ts +101 -0
- package/validate/validate_array.ts +1 -0
- package/validate/validate_expression.ts +48 -3
- package/validate/validate_filter.ts +5 -3
- package/validate/validate_fog.ts +6 -0
- package/validate/validate_function.ts +2 -0
- package/validate/validate_iconset.ts +1 -0
- package/validate/validate_import.ts +2 -2
- package/validate/validate_layer.ts +37 -4
- package/validate/validate_light.ts +6 -0
- package/validate/validate_lights.ts +9 -0
- package/validate/validate_model.ts +1 -2
- package/validate/validate_number.ts +2 -0
- package/validate/validate_object.ts +7 -0
- package/validate/validate_projection.ts +2 -0
- package/validate/validate_property.ts +15 -4
- package/validate/validate_rain.ts +5 -0
- package/validate/validate_snow.ts +5 -0
- package/validate/validate_source.ts +12 -0
- package/validate/validate_style.ts +1 -0
- package/validate/validate_terrain.ts +6 -0
- package/validate_mapbox_api_supported.ts +1 -0
- package/visit.ts +2 -0
- package/util/extend.ts +0 -9
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import ValidationError from '../error/validation_error';
|
|
2
2
|
import {unbundle} from '../util/unbundle_jsonlint';
|
|
3
|
+
import validateArray from './validate_array';
|
|
3
4
|
import validateObject from './validate_object';
|
|
4
5
|
import validateFilter from './validate_filter';
|
|
6
|
+
import validateAppearance, {type AppearanceValidatorOptions} from './validate_appearance';
|
|
5
7
|
import validatePaintProperty from './validate_paint_property';
|
|
6
8
|
import validateLayoutProperty from './validate_layout_property';
|
|
7
9
|
import validateSpec from './validate';
|
|
8
|
-
import extend from '../util/extend';
|
|
9
10
|
import {isObject, isString} from '../util/get_type';
|
|
10
11
|
|
|
11
12
|
import type {StyleReference} from '../reference/latest';
|
|
@@ -64,9 +65,11 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
64
65
|
if (!parent) {
|
|
65
66
|
if (typeof ref === 'string')
|
|
66
67
|
errors.push(new ValidationError(key, layer.ref, `ref layer "${ref}" not found`));
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
67
69
|
} else if (parent.ref) {
|
|
68
70
|
errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));
|
|
69
71
|
} else {
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
70
73
|
type = unbundle(parent.type) as string;
|
|
71
74
|
}
|
|
72
75
|
} else if (!(type === 'background' || type === 'sky' || type === 'slot')) {
|
|
@@ -101,6 +104,7 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
101
104
|
errors = errors.concat(validateObject({
|
|
102
105
|
key,
|
|
103
106
|
value: layer,
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
104
108
|
valueSpec: styleSpec.layer,
|
|
105
109
|
style: options.style,
|
|
106
110
|
styleSpec: options.styleSpec,
|
|
@@ -114,6 +118,7 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
114
118
|
return validateSpec({
|
|
115
119
|
key: `${key}.type`,
|
|
116
120
|
value: layer.type,
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
117
122
|
valueSpec: styleSpec.layer.type,
|
|
118
123
|
style: options.style,
|
|
119
124
|
styleSpec: options.styleSpec,
|
|
@@ -122,7 +127,7 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
122
127
|
});
|
|
123
128
|
},
|
|
124
129
|
filter(options) {
|
|
125
|
-
return validateFilter(
|
|
130
|
+
return validateFilter(Object.assign({layerType: type}, options));
|
|
126
131
|
},
|
|
127
132
|
layout(options) {
|
|
128
133
|
return validateObject({
|
|
@@ -134,7 +139,7 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
134
139
|
styleSpec: options.styleSpec,
|
|
135
140
|
objectElementValidators: {
|
|
136
141
|
'*'(options) {
|
|
137
|
-
return validateLayoutProperty(
|
|
142
|
+
return validateLayoutProperty(Object.assign({layerType: type}, options));
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
});
|
|
@@ -149,10 +154,38 @@ export default function validateLayer(options: LayerValidatorOptions): Validatio
|
|
|
149
154
|
styleSpec: options.styleSpec,
|
|
150
155
|
objectElementValidators: {
|
|
151
156
|
'*'(options) {
|
|
152
|
-
return validatePaintProperty(
|
|
157
|
+
return validatePaintProperty(Object.assign({layerType: type, layer}, options));
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
});
|
|
161
|
+
},
|
|
162
|
+
appearances(options) {
|
|
163
|
+
const validationErrors = validateArray({
|
|
164
|
+
key: options.key,
|
|
165
|
+
value: options.value,
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
167
|
+
valueSpec: options.valueSpec,
|
|
168
|
+
style: options.style,
|
|
169
|
+
styleSpec: options.styleSpec,
|
|
170
|
+
arrayElementValidator: (options) => validateAppearance(Object.assign({layerType: type, layer}, options) as AppearanceValidatorOptions)
|
|
171
|
+
});
|
|
172
|
+
// Check non-repeated names on a given layer
|
|
173
|
+
const appearances = Array.isArray(options.value) ? options.value : [];
|
|
174
|
+
const dedupedNames = new Set<string>();
|
|
175
|
+
appearances.forEach((a, index) => {
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
177
|
+
const name: string | undefined = unbundle(a.name) as string | undefined;
|
|
178
|
+
if (name) {
|
|
179
|
+
if (dedupedNames.has(name)) {
|
|
180
|
+
const layerId = unbundle((layer as LayerSpecification).id) as string;
|
|
181
|
+
validationErrors.push(new ValidationError(options.key, name, `Duplicated appearance name "${name}" for layer "${layerId}"`));
|
|
182
|
+
} else {
|
|
183
|
+
dedupedNames.add(name);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
return validationErrors;
|
|
156
189
|
}
|
|
157
190
|
}
|
|
158
191
|
}));
|
|
@@ -15,6 +15,7 @@ type LightValidatorOptions = {
|
|
|
15
15
|
export default function validateLight(options: LightValidatorOptions): ValidationError[] {
|
|
16
16
|
const light = options.value;
|
|
17
17
|
const styleSpec = options.styleSpec;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
18
19
|
const lightSpec = styleSpec.light;
|
|
19
20
|
const style = options.style;
|
|
20
21
|
|
|
@@ -31,6 +32,7 @@ export default function validateLight(options: LightValidatorOptions): Validatio
|
|
|
31
32
|
const transitionMatch = key.match(/^(.*)-transition$/);
|
|
32
33
|
const useThemeMatch = key.match(/^(.*)-use-theme$/);
|
|
33
34
|
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
34
36
|
if (useThemeMatch && lightSpec[useThemeMatch[1]]) {
|
|
35
37
|
errors = errors.concat(validate({
|
|
36
38
|
key,
|
|
@@ -39,18 +41,22 @@ export default function validateLight(options: LightValidatorOptions): Validatio
|
|
|
39
41
|
style,
|
|
40
42
|
styleSpec
|
|
41
43
|
}));
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
42
45
|
} else if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {
|
|
43
46
|
errors = errors.concat(validate({
|
|
44
47
|
key,
|
|
45
48
|
value: light[key],
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
46
50
|
valueSpec: styleSpec.transition,
|
|
47
51
|
style,
|
|
48
52
|
styleSpec
|
|
49
53
|
}));
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
50
55
|
} else if (lightSpec[key]) {
|
|
51
56
|
errors = errors.concat(validate({
|
|
52
57
|
key,
|
|
53
58
|
value: light[key],
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
54
60
|
valueSpec: lightSpec[key],
|
|
55
61
|
style,
|
|
56
62
|
styleSpec
|
|
@@ -28,6 +28,7 @@ export default function validateLights(options: LightsValidatorOptions): Validat
|
|
|
28
28
|
|
|
29
29
|
let errors: ValidationError[] = [];
|
|
30
30
|
const styleSpec = options.styleSpec;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
31
32
|
const lightSpec = styleSpec['light-3d'];
|
|
32
33
|
const style = options.style;
|
|
33
34
|
const lights = options.style.lights;
|
|
@@ -60,6 +61,7 @@ export default function validateLights(options: LightsValidatorOptions): Validat
|
|
|
60
61
|
return errors;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
63
65
|
const lightPropertySpec = styleSpec[lightType];
|
|
64
66
|
|
|
65
67
|
for (const key in light) {
|
|
@@ -73,6 +75,7 @@ export default function validateLights(options: LightsValidatorOptions): Validat
|
|
|
73
75
|
const transitionMatch = propertyKey.match(/^(.*)-transition$/);
|
|
74
76
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
75
77
|
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
76
79
|
if (useThemeMatch && lightPropertySpec[useThemeMatch[1]]) {
|
|
77
80
|
errors = errors.concat(validate({
|
|
78
81
|
key,
|
|
@@ -81,20 +84,24 @@ export default function validateLights(options: LightsValidatorOptions): Validat
|
|
|
81
84
|
style,
|
|
82
85
|
styleSpec
|
|
83
86
|
}));
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
84
88
|
} else if (transitionMatch && lightPropertySpec[transitionMatch[1]] && lightPropertySpec[transitionMatch[1]].transition) {
|
|
85
89
|
errors = errors.concat(validate({
|
|
86
90
|
key,
|
|
87
91
|
value: light[key],
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
88
93
|
valueSpec: styleSpec.transition,
|
|
89
94
|
style,
|
|
90
95
|
styleSpec
|
|
91
96
|
}));
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
92
98
|
} else if (!lightPropertySpec[propertyKey]) {
|
|
93
99
|
errors = errors.concat([new ValidationWarning(options.key, properties[propertyKey], `unknown property "${propertyKey}"`)]);
|
|
94
100
|
} else {
|
|
95
101
|
errors = errors.concat(validate({
|
|
96
102
|
key: propertyKey,
|
|
97
103
|
value: properties[propertyKey],
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
98
105
|
valueSpec: lightPropertySpec[propertyKey],
|
|
99
106
|
style,
|
|
100
107
|
styleSpec
|
|
@@ -102,10 +109,12 @@ export default function validateLights(options: LightsValidatorOptions): Validat
|
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
} else {
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
105
113
|
if (lightSpec[key]) {
|
|
106
114
|
errors = errors.concat(validate({
|
|
107
115
|
key,
|
|
108
116
|
value: light[key],
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
109
118
|
valueSpec: lightSpec[key],
|
|
110
119
|
style,
|
|
111
120
|
styleSpec
|
|
@@ -10,8 +10,7 @@ export function isValidUrl(str: string, allowRelativeUrls: boolean): boolean {
|
|
|
10
10
|
try {
|
|
11
11
|
new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' : undefined);
|
|
12
12
|
return true;
|
|
13
|
-
|
|
14
|
-
} catch (_: any) {
|
|
13
|
+
} catch (_: unknown) {
|
|
15
14
|
return false;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
@@ -34,6 +34,7 @@ export default function validateNumber(options: NumberValidatorOptions): Validat
|
|
|
34
34
|
let specMin = valueSpec.minimum;
|
|
35
35
|
if (Array.isArray(valueSpec.minimum)) {
|
|
36
36
|
const i = options.arrayIndex;
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
37
38
|
specMin = valueSpec.minimum[i];
|
|
38
39
|
}
|
|
39
40
|
if (value < specMin) {
|
|
@@ -45,6 +46,7 @@ export default function validateNumber(options: NumberValidatorOptions): Validat
|
|
|
45
46
|
let specMax = valueSpec.maximum;
|
|
46
47
|
if (Array.isArray(valueSpec.maximum)) {
|
|
47
48
|
const i = options.arrayIndex;
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
48
50
|
specMax = valueSpec.maximum[i];
|
|
49
51
|
}
|
|
50
52
|
if (value > specMax) {
|
|
@@ -8,8 +8,11 @@ import type {StyleSpecification, LayerSpecification} from '../types';
|
|
|
8
8
|
type ObjectElementValidatorOptions = {
|
|
9
9
|
key: string;
|
|
10
10
|
value: unknown;
|
|
11
|
+
valueSpec?: unknown;
|
|
11
12
|
style: Partial<StyleSpecification>;
|
|
12
13
|
styleSpec: StyleReference;
|
|
14
|
+
object?: object;
|
|
15
|
+
objectKey?: string;
|
|
13
16
|
};
|
|
14
17
|
|
|
15
18
|
type ObjectValidatorOptions = {
|
|
@@ -39,6 +42,7 @@ export default function validateObject(options: ObjectValidatorOptions): Validat
|
|
|
39
42
|
let errors: ValidationError[] = [];
|
|
40
43
|
for (const objectKey in object) {
|
|
41
44
|
const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
42
46
|
const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];
|
|
43
47
|
|
|
44
48
|
let validateElement;
|
|
@@ -57,9 +61,11 @@ export default function validateObject(options: ObjectValidatorOptions): Validat
|
|
|
57
61
|
continue;
|
|
58
62
|
}
|
|
59
63
|
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
|
60
65
|
errors = errors.concat(validateElement({
|
|
61
66
|
key: (key ? `${key}.` : key) + objectKey,
|
|
62
67
|
value: object[objectKey],
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
63
69
|
valueSpec: elementSpec,
|
|
64
70
|
style,
|
|
65
71
|
styleSpec,
|
|
@@ -74,6 +80,7 @@ export default function validateObject(options: ObjectValidatorOptions): Validat
|
|
|
74
80
|
continue;
|
|
75
81
|
}
|
|
76
82
|
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
77
84
|
if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {
|
|
78
85
|
errors.push(new ValidationError(key, object, `missing required property "${elementSpecKey}"`));
|
|
79
86
|
}
|
|
@@ -15,6 +15,7 @@ type ProjectionValidatorOptions = {
|
|
|
15
15
|
export default function validateProjection(options: ProjectionValidatorOptions): ValidationError[] {
|
|
16
16
|
const projection = options.value;
|
|
17
17
|
const styleSpec = options.styleSpec;
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
18
19
|
const projectionSpec = styleSpec.projection;
|
|
19
20
|
const style = options.style;
|
|
20
21
|
|
|
@@ -25,6 +26,7 @@ export default function validateProjection(options: ProjectionValidatorOptions):
|
|
|
25
26
|
errors = errors.concat(validate({
|
|
26
27
|
key,
|
|
27
28
|
value: projection[key],
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
28
30
|
valueSpec: projectionSpec[key],
|
|
29
31
|
style,
|
|
30
32
|
styleSpec
|
|
@@ -13,12 +13,12 @@ import type {StyleSpecification, LayerSpecification} from '../types';
|
|
|
13
13
|
export type PropertyValidatorOptions = {
|
|
14
14
|
key: string;
|
|
15
15
|
value: unknown;
|
|
16
|
-
valueSpec
|
|
16
|
+
valueSpec?: unknown;
|
|
17
17
|
style: Partial<StyleSpecification>;
|
|
18
18
|
styleSpec: StyleReference;
|
|
19
|
-
objectKey
|
|
19
|
+
objectKey?: string;
|
|
20
20
|
layerType: string;
|
|
21
|
-
layer
|
|
21
|
+
layer?: Partial<LayerSpecification>;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export default function validateProperty(options: PropertyValidatorOptions, propertyType: string): ValidationError[] {
|
|
@@ -28,11 +28,13 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
28
28
|
const styleSpec = options.styleSpec;
|
|
29
29
|
const value = options.value;
|
|
30
30
|
const propertyKey = options.objectKey;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
31
32
|
const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];
|
|
32
33
|
|
|
33
34
|
if (!layerSpec) return [];
|
|
34
35
|
|
|
35
36
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
36
38
|
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
37
39
|
if (isExpression(value)) {
|
|
38
40
|
const errors: ValidationError[] = [];
|
|
@@ -67,22 +69,26 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
const transitionMatch = propertyKey.match(/^(.*)-transition$/);
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
70
73
|
if (propertyType === 'paint' && transitionMatch && layerSpec[transitionMatch[1]] && layerSpec[transitionMatch[1]].transition) {
|
|
71
74
|
return validate({
|
|
72
75
|
key,
|
|
73
76
|
value,
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
74
78
|
valueSpec: styleSpec.transition,
|
|
75
79
|
style,
|
|
76
80
|
styleSpec
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
80
85
|
const valueSpec = options.valueSpec || layerSpec[propertyKey];
|
|
81
86
|
if (!valueSpec) {
|
|
82
87
|
return [new ValidationWarning(key, value, `unknown property "${propertyKey}"`)];
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
let tokenMatch: RegExpExecArray | undefined;
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
86
92
|
if (isString(value) && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {
|
|
87
93
|
const example = `\`{ "type": "identity", "property": ${tokenMatch ? JSON.stringify(tokenMatch[1]) : '"_"'} }\``;
|
|
88
94
|
return [new ValidationError(
|
|
@@ -101,13 +107,17 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
101
107
|
errors.push(new ValidationError(key, value, '"text-font" does not support identity functions'));
|
|
102
108
|
}
|
|
103
109
|
} 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
|
|
104
111
|
if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
|
|
105
112
|
// 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
|
|
106
114
|
const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
108
116
|
const expressionObj = (expression.value as any).expression || (expression.value as any)._styleExpression.expression;
|
|
109
117
|
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
110
119
|
if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
111
121
|
if (propertyKey !== 'model-emissive-strength' || (!isFeatureConstant(expressionObj) || !isStateConstant(expressionObj))) {
|
|
112
122
|
errors.push(new ValidationError(key, value, `${propertyKey} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`));
|
|
113
123
|
}
|
|
@@ -118,6 +128,7 @@ export default function validateProperty(options: PropertyValidatorOptions, prop
|
|
|
118
128
|
return errors.concat(validate({
|
|
119
129
|
key: options.key,
|
|
120
130
|
value,
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
121
132
|
valueSpec,
|
|
122
133
|
style,
|
|
123
134
|
styleSpec,
|
|
@@ -16,6 +16,7 @@ export default function validateRain(options: RainValidatorOptions): ValidationE
|
|
|
16
16
|
const rain = options.value;
|
|
17
17
|
const style = options.style;
|
|
18
18
|
const styleSpec = options.styleSpec;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
19
20
|
const rainSpec = styleSpec.rain;
|
|
20
21
|
|
|
21
22
|
if (rain === undefined) {
|
|
@@ -30,18 +31,22 @@ export default function validateRain(options: RainValidatorOptions): ValidationE
|
|
|
30
31
|
for (const key in rain) {
|
|
31
32
|
const transitionMatch = key.match(/^(.*)-transition$/);
|
|
32
33
|
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
33
35
|
if (transitionMatch && rainSpec[transitionMatch[1]] && rainSpec[transitionMatch[1]].transition) {
|
|
34
36
|
errors = errors.concat(validate({
|
|
35
37
|
key,
|
|
36
38
|
value: rain[key],
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
37
40
|
valueSpec: styleSpec.transition,
|
|
38
41
|
style,
|
|
39
42
|
styleSpec
|
|
40
43
|
}));
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
41
45
|
} else if (rainSpec[key]) {
|
|
42
46
|
errors = errors.concat(validate({
|
|
43
47
|
key,
|
|
44
48
|
value: rain[key],
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
45
50
|
valueSpec: rainSpec[key],
|
|
46
51
|
style,
|
|
47
52
|
styleSpec
|
|
@@ -16,6 +16,7 @@ export default function validateSnow(options: SnowValidatorOptions): ValidationE
|
|
|
16
16
|
const snow = options.value;
|
|
17
17
|
const style = options.style;
|
|
18
18
|
const styleSpec = options.styleSpec;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
19
20
|
const snowSpec = styleSpec.snow;
|
|
20
21
|
|
|
21
22
|
if (snow === undefined) {
|
|
@@ -30,18 +31,22 @@ export default function validateSnow(options: SnowValidatorOptions): ValidationE
|
|
|
30
31
|
for (const key in snow) {
|
|
31
32
|
const transitionMatch = key.match(/^(.*)-transition$/);
|
|
32
33
|
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
33
35
|
if (transitionMatch && snowSpec[transitionMatch[1]] && snowSpec[transitionMatch[1]].transition) {
|
|
34
36
|
errors = errors.concat(validate({
|
|
35
37
|
key,
|
|
36
38
|
value: snow[key],
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
37
40
|
valueSpec: styleSpec.transition,
|
|
38
41
|
style,
|
|
39
42
|
styleSpec
|
|
40
43
|
}));
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
41
45
|
} else if (snowSpec[key]) {
|
|
42
46
|
errors = errors.concat(validate({
|
|
43
47
|
key,
|
|
44
48
|
value: snow[key],
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
45
50
|
valueSpec: snowSpec[key],
|
|
46
51
|
style,
|
|
47
52
|
styleSpec
|
|
@@ -53,6 +53,7 @@ export default function validateSource(options: SourceValidatorOptions): Validat
|
|
|
53
53
|
errors = errors.concat(validateObject({
|
|
54
54
|
key,
|
|
55
55
|
value,
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
56
57
|
valueSpec: styleSpec[`source_${type.replace('-', '_')}`],
|
|
57
58
|
style: options.style,
|
|
58
59
|
styleSpec,
|
|
@@ -63,6 +64,7 @@ export default function validateSource(options: SourceValidatorOptions): Validat
|
|
|
63
64
|
errors = validateObject({
|
|
64
65
|
key,
|
|
65
66
|
value,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
66
68
|
valueSpec: styleSpec.source_geojson,
|
|
67
69
|
style,
|
|
68
70
|
styleSpec,
|
|
@@ -80,7 +82,9 @@ export default function validateSource(options: SourceValidatorOptions): Validat
|
|
|
80
82
|
return [new ValidationError(`${key}.clusterProperties.${prop}`, propValue, 'array expected')];
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
83
86
|
const [operator, mapExpr] = propValue;
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
84
88
|
const reduceExpr = typeof operator === 'string' ? [operator, ['accumulated'], ['get', prop]] : operator;
|
|
85
89
|
|
|
86
90
|
errors.push(...validateExpression({
|
|
@@ -102,6 +106,7 @@ export default function validateSource(options: SourceValidatorOptions): Validat
|
|
|
102
106
|
return validateObject({
|
|
103
107
|
key,
|
|
104
108
|
value,
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
105
110
|
valueSpec: styleSpec.source_video,
|
|
106
111
|
style,
|
|
107
112
|
styleSpec
|
|
@@ -111,6 +116,7 @@ export default function validateSource(options: SourceValidatorOptions): Validat
|
|
|
111
116
|
return validateObject({
|
|
112
117
|
key,
|
|
113
118
|
value,
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
114
120
|
valueSpec: styleSpec.source_image,
|
|
115
121
|
style,
|
|
116
122
|
styleSpec
|
|
@@ -131,9 +137,13 @@ export default function validateSource(options: SourceValidatorOptions): Validat
|
|
|
131
137
|
}
|
|
132
138
|
|
|
133
139
|
function getSourceTypeValues(styleSpec: StyleReference): string[] {
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
134
141
|
return styleSpec.source.reduce((memo: string[], source: string) => {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
135
143
|
const sourceType = styleSpec[source];
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
136
145
|
if (sourceType.type.type === 'enum') {
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
|
|
137
147
|
memo = memo.concat(Object.keys(sourceType.type.values));
|
|
138
148
|
}
|
|
139
149
|
return memo;
|
|
@@ -161,7 +171,9 @@ function validatePromoteId({key, value}: PromoteIdValidatorOptions) {
|
|
|
161
171
|
}
|
|
162
172
|
|
|
163
173
|
// @ts-expect-error - TS2339: Property 'expression' does not exist on type 'ParsingError[] | StyleExpression'.
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
164
175
|
const parsed = expression.value.expression;
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
165
177
|
const onlyFeatureDependent = isConstant.isGlobalPropertyConstant(parsed, ['zoom', 'heatmap-density', 'line-progress', 'raster-value', 'sky-radial-progress', 'accumulated', 'is-supported-script', 'pitch', 'distance-from-center', 'measure-light', 'raster-particle-speed']);
|
|
166
178
|
if (!onlyFeatureDependent) {
|
|
167
179
|
errors.push(new ValidationError(`${key}`, null, 'promoteId expression should be only feature dependent'));
|
|
@@ -13,6 +13,7 @@ export default function validateStyle(style: unknown, styleSpec: StyleReference
|
|
|
13
13
|
const errors = validateObject({
|
|
14
14
|
key: options.key || '',
|
|
15
15
|
value: style,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
16
17
|
valueSpec: Object.assign(
|
|
17
18
|
styleSpec.$root,
|
|
18
19
|
// Skip validation of the root properties that are not defined in the style spec (e.g. 'owner').
|
|
@@ -18,6 +18,7 @@ export default function validateTerrain(options: TerrainValidatorOptions): Valid
|
|
|
18
18
|
const key = options.key;
|
|
19
19
|
const style = options.style;
|
|
20
20
|
const styleSpec = options.styleSpec;
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
21
22
|
const terrainSpec = styleSpec.terrain;
|
|
22
23
|
|
|
23
24
|
if (terrain == null) {
|
|
@@ -33,6 +34,7 @@ export default function validateTerrain(options: TerrainValidatorOptions): Valid
|
|
|
33
34
|
const transitionMatch = key.match(/^(.*)-transition$/);
|
|
34
35
|
const useThemeMatch = key.match(/^(.*)-use-theme$/);
|
|
35
36
|
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
36
38
|
if (useThemeMatch && terrainSpec[useThemeMatch[1]]) {
|
|
37
39
|
errors = errors.concat(validate({
|
|
38
40
|
key,
|
|
@@ -41,18 +43,22 @@ export default function validateTerrain(options: TerrainValidatorOptions): Valid
|
|
|
41
43
|
style,
|
|
42
44
|
styleSpec
|
|
43
45
|
}));
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
44
47
|
} else if (transitionMatch && terrainSpec[transitionMatch[1]] && terrainSpec[transitionMatch[1]].transition) {
|
|
45
48
|
errors = errors.concat(validate({
|
|
46
49
|
key,
|
|
47
50
|
value: terrain[key],
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
48
52
|
valueSpec: styleSpec.transition,
|
|
49
53
|
style,
|
|
50
54
|
styleSpec
|
|
51
55
|
}));
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
52
57
|
} else if (terrainSpec[key]) {
|
|
53
58
|
errors = errors.concat(validate({
|
|
54
59
|
key,
|
|
55
60
|
value: terrain[key],
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
56
62
|
valueSpec: terrainSpec[key],
|
|
57
63
|
style,
|
|
58
64
|
styleSpec
|
package/visit.ts
CHANGED
|
@@ -11,11 +11,13 @@ import type {
|
|
|
11
11
|
function getPropertyReference(propertyName: string): StylePropertySpecification {
|
|
12
12
|
for (let i = 0; i < Reference.layout.length; i++) {
|
|
13
13
|
for (const key in Reference[Reference.layout[i]]) {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
14
15
|
if (key === propertyName) return Reference[Reference.layout[i]][key] as StylePropertySpecification;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
for (let i = 0; i < Reference.paint.length; i++) {
|
|
18
19
|
for (const key in Reference[Reference.paint[i]]) {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
19
21
|
if (key === propertyName) return Reference[Reference.paint[i]][key] as StylePropertySpecification;
|
|
20
22
|
}
|
|
21
23
|
}
|
package/util/extend.ts
DELETED