@mapbox/mapbox-gl-style-spec 14.8.0 → 14.9.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 +16 -0
- package/dist/index.cjs +807 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +162 -11
- package/dist/index.es.js +807 -130
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/coercion.ts +1 -1
- package/expression/definitions/config.ts +1 -1
- package/expression/definitions/image.ts +184 -14
- package/expression/definitions/index.ts +7 -0
- package/expression/definitions/interpolate.ts +54 -13
- package/expression/expression.ts +1 -0
- package/expression/index.ts +12 -6
- package/expression/types/formatted.ts +1 -1
- package/expression/types/image_id_with_options.ts +54 -0
- package/expression/types/resolved_image.ts +49 -7
- package/expression/values.ts +9 -7
- package/feature_filter/index.ts +1 -0
- package/function/index.ts +1 -1
- package/group_by_layout.ts +35 -3
- package/package.json +1 -1
- package/reference/v8.json +357 -70
- package/types.ts +118 -9
- package/util/color.ts +62 -1
- package/validate/validate_fog.ts +10 -1
- package/validate/validate_function.ts +1 -1
- package/validate/validate_light.ts +10 -1
- package/validate/validate_lights.ts +11 -1
- package/validate/validate_property.ts +11 -0
- package/validate/validate_rain.ts +47 -0
- package/validate/validate_snow.ts +47 -0
- package/validate/validate_terrain.ts +11 -2
- package/validate_style.min.ts +4 -0
package/expression/values.ts
CHANGED
|
@@ -13,14 +13,14 @@ export function validateRGBA(r: unknown, g: unknown, b: unknown, a?: unknown): s
|
|
|
13
13
|
typeof g === 'number' && g >= 0 && g <= 255 &&
|
|
14
14
|
typeof b === 'number' && b >= 0 && b <= 255
|
|
15
15
|
)) {
|
|
16
|
-
const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];
|
|
16
|
+
const value = (typeof a === 'number' ? [r, g, b, a] : [r, g, b]) as number[];
|
|
17
17
|
return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (!(
|
|
21
21
|
typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1)
|
|
22
22
|
)) {
|
|
23
|
-
return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;
|
|
23
|
+
return `Invalid rgba value [${([r, g, b, a] as number[]).join(', ')}]: 'a' must be between 0 and 1.`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
return null;
|
|
@@ -30,7 +30,7 @@ export function validateHSLA(h: unknown, s: unknown, l: unknown, a?: unknown): s
|
|
|
30
30
|
if (!(
|
|
31
31
|
typeof h === 'number' && h >= 0 && h <= 360
|
|
32
32
|
)) {
|
|
33
|
-
const value = typeof a === 'number' ? [h, s, l, a] : [h, s, l];
|
|
33
|
+
const value = (typeof a === 'number' ? [h, s, l, a] : [h, s, l]) as number[];
|
|
34
34
|
return `Invalid hsla value [${value.join(', ')}]: 'h' must be between 0 and 360.`;
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -38,14 +38,14 @@ export function validateHSLA(h: unknown, s: unknown, l: unknown, a?: unknown): s
|
|
|
38
38
|
typeof s === 'number' && s >= 0 && s <= 100 &&
|
|
39
39
|
typeof l === 'number' && l >= 0 && l <= 100
|
|
40
40
|
)) {
|
|
41
|
-
const value = typeof a === 'number' ? [h, s, l, a] : [h, s, l];
|
|
41
|
+
const value = (typeof a === 'number' ? [h, s, l, a] : [h, s, l]) as number[];
|
|
42
42
|
return `Invalid hsla value [${value.join(', ')}]: 's', and 'l' must be between 0 and 100.`;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
if (!(
|
|
46
46
|
typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1)
|
|
47
47
|
)) {
|
|
48
|
-
return `Invalid hsla value [${[h, s, l, a].join(', ')}]: 'a' must be between 0 and 1.`;
|
|
48
|
+
return `Invalid hsla value [${([h, s, l, a] as number[]).join(', ')}]: 'a' must be between 0 and 1.`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
return null;
|
|
@@ -136,8 +136,10 @@ export function toString(value: Value): string {
|
|
|
136
136
|
if (value === null) {
|
|
137
137
|
return '';
|
|
138
138
|
} else if (type === 'string' || type === 'number' || type === 'boolean') {
|
|
139
|
-
return String(value);
|
|
140
|
-
} else if (value instanceof Color
|
|
139
|
+
return String(value as string | number | boolean);
|
|
140
|
+
} else if (value instanceof Color) {
|
|
141
|
+
return value.toStringPremultipliedAlpha();
|
|
142
|
+
} else if (value instanceof Formatted || value instanceof ResolvedImage) {
|
|
141
143
|
return value.toString();
|
|
142
144
|
} else {
|
|
143
145
|
return JSON.stringify(value);
|
package/feature_filter/index.ts
CHANGED
package/function/index.ts
CHANGED
|
@@ -204,7 +204,7 @@ function evaluateIdentityFunction(parameters, propertySpec, input) {
|
|
|
204
204
|
} else if (propertySpec.type === 'formatted') {
|
|
205
205
|
input = Formatted.fromString(input.toString());
|
|
206
206
|
} else if (propertySpec.type === 'resolvedImage') {
|
|
207
|
-
input = ResolvedImage.
|
|
207
|
+
input = ResolvedImage.build(input.toString());
|
|
208
208
|
} else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {
|
|
209
209
|
input = undefined;
|
|
210
210
|
}
|
package/group_by_layout.ts
CHANGED
|
@@ -29,6 +29,25 @@ function getKey(layer: LayerSpecification) {
|
|
|
29
29
|
return key;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function containsKey(obj: any, key: string) {
|
|
33
|
+
function recursiveSearch(item) {
|
|
34
|
+
if (typeof item === 'string' && item === key) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (Array.isArray(item)) {
|
|
39
|
+
return item.some(recursiveSearch);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (item && typeof item === 'object') {
|
|
43
|
+
return Object.values(item).some(recursiveSearch);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return recursiveSearch(obj);
|
|
49
|
+
}
|
|
50
|
+
|
|
32
51
|
/**
|
|
33
52
|
* Given an array of layers, return an array of arrays of layers where all
|
|
34
53
|
* layers in each group have identical layout-affecting properties. These
|
|
@@ -53,17 +72,30 @@ export default function groupByLayout(
|
|
|
53
72
|
const groups: Record<string, any> = {};
|
|
54
73
|
|
|
55
74
|
for (let i = 0; i < layers.length; i++) {
|
|
75
|
+
const layer = layers[i];
|
|
76
|
+
let k = cachedKeys && cachedKeys[layer.id];
|
|
77
|
+
|
|
78
|
+
if (!k) {
|
|
79
|
+
k = getKey(layer);
|
|
80
|
+
// The usage of "line-progress" inside "line-width" makes the property act like a layout property.
|
|
81
|
+
// We need to split it from the group to avoid conflicts in the bucket creation.
|
|
82
|
+
if (layer.type === 'line' && layer["paint"]) {
|
|
83
|
+
const lineWidth = layer["paint"]['line-width'];
|
|
84
|
+
if (containsKey(lineWidth, 'line-progress')) {
|
|
85
|
+
k += `/${stringify(layer["paint"]['line-width'])}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
56
89
|
|
|
57
|
-
const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);
|
|
58
90
|
// update the cache if there is one
|
|
59
91
|
if (cachedKeys)
|
|
60
|
-
cachedKeys[
|
|
92
|
+
cachedKeys[layer.id] = k;
|
|
61
93
|
|
|
62
94
|
let group = groups[k];
|
|
63
95
|
if (!group) {
|
|
64
96
|
group = groups[k] = [];
|
|
65
97
|
}
|
|
66
|
-
group.push(
|
|
98
|
+
group.push(layer);
|
|
67
99
|
}
|
|
68
100
|
|
|
69
101
|
const result = [];
|