@mapbox/mapbox-gl-style-spec 14.11.0 → 14.12.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/composite.ts +2 -0
- package/deref.ts +5 -5
- package/diff.ts +65 -31
- package/dist/index.cjs +816 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +224 -16
- package/dist/index.es.js +816 -16
- package/dist/index.es.js.map +1 -1
- package/error/validation_error.ts +1 -3
- package/expression/compound_expression.ts +1 -1
- package/expression/definitions/assertion.ts +2 -1
- package/expression/definitions/at.ts +1 -1
- package/expression/definitions/at_interpolated.ts +1 -1
- package/expression/definitions/case.ts +3 -1
- package/expression/definitions/coalesce.ts +3 -2
- package/expression/definitions/coercion.ts +3 -1
- package/expression/definitions/collator.ts +2 -1
- package/expression/definitions/comparison.ts +15 -1
- package/expression/definitions/config.ts +4 -1
- package/expression/definitions/distance.ts +6 -4
- package/expression/definitions/format.ts +1 -1
- package/expression/definitions/index.ts +24 -2
- package/expression/definitions/index_of.ts +1 -0
- package/expression/definitions/interpolate.ts +7 -3
- package/expression/definitions/let.ts +1 -0
- package/expression/definitions/literal.ts +2 -2
- package/expression/definitions/match.ts +4 -2
- package/expression/definitions/number_format.ts +3 -4
- package/expression/definitions/slice.ts +1 -0
- package/expression/definitions/step.ts +2 -1
- package/expression/definitions/var.ts +1 -0
- package/expression/definitions/within.ts +6 -2
- package/expression/evaluation_context.ts +3 -5
- package/expression/expression.ts +3 -0
- package/expression/index.ts +20 -10
- package/expression/parsing_context.ts +1 -1
- package/expression/types/image_variant.ts +2 -2
- package/expression/types.ts +1 -0
- package/expression/values.ts +1 -3
- package/feature_filter/convert.ts +13 -6
- package/feature_filter/index.ts +17 -1
- package/format.ts +1 -0
- package/function/convert.ts +5 -1
- package/function/index.ts +28 -0
- package/group_by_layout.ts +17 -8
- package/migrate/expressions.ts +3 -3
- package/migrate/v8.ts +10 -1
- package/migrate/v9.ts +2 -1
- package/migrate.ts +2 -1
- package/package.json +1 -1
- package/read_style.ts +1 -0
- package/reference/latest.ts +1 -0
- package/reference/v8.json +425 -8
- package/test.js +2 -4
- package/types.ts +207 -1
- package/union-to-intersection.ts +1 -0
- package/util/extend.ts +2 -1
- package/util/geometry_util.ts +25 -9
- package/util/interpolate.ts +1 -1
- package/validate/validate.ts +6 -0
- package/validate/validate_array.ts +2 -0
- package/validate/validate_enum.ts +1 -0
- package/validate/validate_expression.ts +4 -0
- package/validate/validate_filter.ts +4 -2
- package/validate/validate_fog.ts +4 -1
- package/validate/validate_function.ts +7 -2
- package/validate/validate_glyphs_url.ts +1 -1
- package/validate/validate_iconset.ts +1 -0
- package/validate/validate_layer.ts +3 -2
- package/validate/validate_light.ts +4 -1
- package/validate/validate_lights.ts +7 -1
- package/validate/validate_model.ts +4 -0
- package/validate/validate_object.ts +2 -2
- package/validate/validate_projection.ts +1 -0
- package/validate/validate_property.ts +5 -1
- package/validate/validate_rain.ts +3 -0
- package/validate/validate_snow.ts +3 -0
- package/validate/validate_source.ts +9 -9
- package/validate/validate_terrain.ts +5 -1
- package/validate_mapbox_api_supported.ts +31 -20
- package/validate_style.ts +1 -0
- package/visit.ts +4 -2
package/group_by_layout.ts
CHANGED
|
@@ -2,6 +2,7 @@ import refProperties from './util/ref_properties';
|
|
|
2
2
|
|
|
3
3
|
import type {LayerSpecification} from './types';
|
|
4
4
|
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
function stringify(obj: any) {
|
|
6
7
|
if (typeof obj === 'number' || typeof obj === 'boolean' || typeof obj === 'string' || obj === undefined || obj === null)
|
|
7
8
|
return JSON.stringify(obj);
|
|
@@ -31,12 +32,13 @@ function getKey(layer: LayerSpecification) {
|
|
|
31
32
|
if (layer.type === 'model' && (k === 'minzoom' || k === 'maxzoom')) {
|
|
32
33
|
continue;
|
|
33
34
|
} else {
|
|
34
|
-
key += `/${stringify(
|
|
35
|
+
key += `/${stringify(layer[k])}`;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
return key;
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
42
|
function containsKey(obj: any, key: string) {
|
|
41
43
|
function recursiveSearch(item) {
|
|
42
44
|
if (typeof item === 'string' && item === key) {
|
|
@@ -77,6 +79,7 @@ export default function groupByLayout(
|
|
|
77
79
|
[id: string]: string;
|
|
78
80
|
},
|
|
79
81
|
): Array<Array<LayerSpecification>> {
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
83
|
const groups: Record<string, any> = {};
|
|
81
84
|
|
|
82
85
|
for (let i = 0; i < layers.length; i++) {
|
|
@@ -84,13 +87,18 @@ export default function groupByLayout(
|
|
|
84
87
|
let k = cachedKeys && cachedKeys[layer.id];
|
|
85
88
|
|
|
86
89
|
if (!k) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
// Do not group symbol layers together, as their paint properties affect placement
|
|
91
|
+
if (layer.type === 'symbol') {
|
|
92
|
+
k = layer.id;
|
|
93
|
+
} else {
|
|
94
|
+
k = getKey(layer);
|
|
95
|
+
// The usage of "line-progress" inside "line-width" makes the property act like a layout property.
|
|
96
|
+
// We need to split it from the group to avoid conflicts in the bucket creation.
|
|
97
|
+
if (layer.type === 'line' && layer["paint"]) {
|
|
98
|
+
const lineWidth = layer["paint"]['line-width'];
|
|
99
|
+
if (containsKey(lineWidth, 'line-progress')) {
|
|
100
|
+
k += `/${stringify(layer["paint"]['line-width'])}`;
|
|
101
|
+
}
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
}
|
|
@@ -112,5 +120,6 @@ export default function groupByLayout(
|
|
|
112
120
|
result.push(groups[k]);
|
|
113
121
|
}
|
|
114
122
|
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
115
124
|
return result;
|
|
116
125
|
}
|
package/migrate/expressions.ts
CHANGED
|
@@ -3,19 +3,19 @@ import {isExpression} from '../expression/index';
|
|
|
3
3
|
import convertFunction, {convertTokenString} from '../function/convert';
|
|
4
4
|
import convertFilter from '../feature_filter/convert';
|
|
5
5
|
|
|
6
|
-
import type {StyleSpecification, FunctionSpecification} from '../types';
|
|
6
|
+
import type {StyleSpecification, FilterSpecification, FunctionSpecification} from '../types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Migrate the given style object in place to use expressions. Specifically,
|
|
10
10
|
* this will convert (a) "stop" functions, and (b) legacy filters to their
|
|
11
11
|
* expression equivalents.
|
|
12
12
|
*/
|
|
13
|
-
export default function(style: StyleSpecification): StyleSpecification {
|
|
13
|
+
export default function (style: StyleSpecification): StyleSpecification {
|
|
14
14
|
const converted = [];
|
|
15
15
|
|
|
16
16
|
eachLayer(style, (layer) => {
|
|
17
17
|
if (layer.filter) {
|
|
18
|
-
layer.filter =
|
|
18
|
+
layer.filter = convertFilter(layer.filter) as FilterSpecification;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
|
package/migrate/v8.ts
CHANGED
|
@@ -20,8 +20,10 @@ function eachPaint(layer, callback) {
|
|
|
20
20
|
|
|
21
21
|
function resolveConstant(style, value) {
|
|
22
22
|
if (typeof value === 'string' && value[0] === '@') {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
23
24
|
return resolveConstant(style, style.constants[value]);
|
|
24
25
|
} else {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
25
27
|
return value;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
@@ -34,7 +36,7 @@ function renameProperty(obj, from, to) {
|
|
|
34
36
|
obj[to] = obj[from]; delete obj[from];
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
export default function(style) {
|
|
39
|
+
export default function (style) {
|
|
38
40
|
style.version = 8;
|
|
39
41
|
|
|
40
42
|
// Rename properties, reverse coordinates in source and layers
|
|
@@ -113,6 +115,7 @@ export default function(style) {
|
|
|
113
115
|
const inputPathnameParts = inputParsed.pathname.split('/');
|
|
114
116
|
|
|
115
117
|
if (inputParsed.protocol !== 'mapbox:') {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
116
119
|
return input;
|
|
117
120
|
|
|
118
121
|
} else if (inputParsed.hostname === 'fontstack') {
|
|
@@ -142,22 +145,27 @@ export default function(style) {
|
|
|
142
145
|
|
|
143
146
|
function migrateFontStack(font) {
|
|
144
147
|
function splitAndTrim(string) {
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
145
149
|
return string.split(',').map((s) => {
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
146
151
|
return s.trim();
|
|
147
152
|
});
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
if (Array.isArray(font)) {
|
|
151
156
|
// Assume it's a previously migrated font-array.
|
|
157
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
152
158
|
return font;
|
|
153
159
|
|
|
154
160
|
} else if (typeof font === 'string') {
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
155
162
|
return splitAndTrim(font);
|
|
156
163
|
|
|
157
164
|
} else if (typeof font === 'object') {
|
|
158
165
|
font.stops.forEach((stop) => {
|
|
159
166
|
stop[1] = splitAndTrim(stop[1]);
|
|
160
167
|
});
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
161
169
|
return font;
|
|
162
170
|
|
|
163
171
|
} else {
|
|
@@ -199,5 +207,6 @@ export default function(style) {
|
|
|
199
207
|
symbolLayers.reverse();
|
|
200
208
|
style.layers = style.layers.concat(symbolLayers);
|
|
201
209
|
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
202
211
|
return style;
|
|
203
212
|
}
|
package/migrate/v9.ts
CHANGED
|
@@ -8,7 +8,7 @@ function eachLayer(style, callback) {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export default function(style) {
|
|
11
|
+
export default function (style) {
|
|
12
12
|
style.version = 9;
|
|
13
13
|
|
|
14
14
|
// remove user-specified refs
|
|
@@ -23,5 +23,6 @@ export default function(style) {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
26
27
|
return style;
|
|
27
28
|
}
|
package/migrate.ts
CHANGED
|
@@ -17,7 +17,7 @@ import migrateToExpressions from './migrate/expressions';
|
|
|
17
17
|
* var style = fs.readFileSync('./style.json', 'utf8');
|
|
18
18
|
* fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
|
|
19
19
|
*/
|
|
20
|
-
export default function(style) {
|
|
20
|
+
export default function (style) {
|
|
21
21
|
let migrated = false;
|
|
22
22
|
|
|
23
23
|
if (style.version === 7) {
|
|
@@ -34,5 +34,6 @@ export default function(style) {
|
|
|
34
34
|
throw new Error('cannot migrate from', style.version);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
37
38
|
return style;
|
|
38
39
|
}
|
package/package.json
CHANGED
package/read_style.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {StyleSpecification} from './types';
|
|
|
6
6
|
export default function readStyle(style: string | Buffer | StyleSpecification): StyleSpecification {
|
|
7
7
|
if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
|
|
8
8
|
try {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
9
10
|
return jsonlint.parse(style.toString());
|
|
10
11
|
} catch (e) {
|
|
11
12
|
throw new ParsingError(e);
|