@mapbox/mapbox-gl-style-spec 14.12.0-beta.1 → 14.13.0-beta.1
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 +21 -21
- package/dist/index.cjs +455 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +64 -30
- package/dist/index.es.js +455 -241
- package/dist/index.es.js.map +1 -1
- package/error/validation_error.ts +1 -3
- 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 +1 -0
- 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 +33 -10
- package/expression/definitions/distance.ts +6 -4
- package/expression/definitions/format.ts +3 -2
- package/expression/definitions/index.ts +29 -3
- package/expression/definitions/index_of.ts +1 -0
- package/expression/definitions/interpolate.ts +5 -1
- package/expression/definitions/let.ts +1 -0
- package/expression/definitions/literal.ts +3 -3
- package/expression/definitions/match.ts +5 -3
- package/expression/definitions/number_format.ts +3 -4
- package/expression/definitions/slice.ts +1 -0
- package/expression/definitions/step.ts +1 -0
- package/expression/definitions/var.ts +1 -0
- package/expression/definitions/within.ts +6 -2
- package/expression/expression.ts +3 -0
- package/expression/index.ts +18 -3
- package/expression/is_constant.ts +4 -0
- package/expression/parsing_context.ts +1 -1
- package/expression/types/formatted.ts +1 -1
- package/expression/types/image_variant.ts +2 -2
- package/expression/types.ts +9 -0
- package/expression/values.ts +1 -3
- package/feature_filter/convert.ts +13 -6
- package/feature_filter/index.ts +16 -0
- 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 +2 -2
- package/migrate/v8.ts +9 -0
- package/migrate/v9.ts +1 -0
- package/migrate.ts +1 -0
- package/package.json +1 -1
- package/read_style.ts +1 -0
- package/reference/latest.ts +1 -0
- package/reference/v8.json +209 -21
- package/types.ts +21 -2
- package/union-to-intersection.ts +1 -1
- package/util/color.ts +85 -69
- package/util/extend.ts +1 -0
- package/util/geometry_util.ts +7 -8
- package/util/interpolate.ts +0 -4
- 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 +3 -0
- package/validate/validate_function.ts +7 -2
- package/validate/validate_iconset.ts +1 -0
- package/validate/validate_layer.ts +1 -0
- package/validate/validate_light.ts +3 -0
- package/validate/validate_lights.ts +27 -21
- 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 +4 -0
- package/validate/validate_rain.ts +3 -0
- package/validate/validate_snow.ts +3 -0
- package/validate/validate_source.ts +8 -6
- package/validate/validate_terrain.ts +4 -0
- package/validate_mapbox_api_supported.ts +30 -19
- package/validate_style.ts +1 -0
- package/visit.ts +3 -1
package/composite.ts
CHANGED
|
@@ -21,6 +21,7 @@ export default function (style) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (styleIDs.length < 2)
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
24
25
|
return style;
|
|
25
26
|
|
|
26
27
|
styleIDs.forEach((id) => {
|
|
@@ -48,5 +49,6 @@ export default function (style) {
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
51
53
|
return style;
|
|
52
54
|
}
|
package/deref.ts
CHANGED
|
@@ -3,7 +3,7 @@ import refProperties from './util/ref_properties';
|
|
|
3
3
|
import type {LayerSpecification} from './types';
|
|
4
4
|
|
|
5
5
|
function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpecification {
|
|
6
|
-
const result
|
|
6
|
+
const result = {} as LayerSpecification;
|
|
7
7
|
|
|
8
8
|
for (const k in layer) {
|
|
9
9
|
if (k !== 'ref') {
|
|
@@ -13,11 +13,11 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
|
|
|
13
13
|
|
|
14
14
|
refProperties.forEach((k) => {
|
|
15
15
|
if (k in parent) {
|
|
16
|
-
result[k] =
|
|
16
|
+
result[k] = parent[k];
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
return result
|
|
20
|
+
return result;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -36,14 +36,14 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
|
|
|
36
36
|
export default function derefLayers(layers: Array<LayerSpecification>): Array<LayerSpecification> {
|
|
37
37
|
layers = layers.slice();
|
|
38
38
|
|
|
39
|
-
const map:
|
|
39
|
+
const map: Record<string, LayerSpecification> = Object.create(null);
|
|
40
40
|
for (let i = 0; i < layers.length; i++) {
|
|
41
41
|
map[layers[i].id] = layers[i];
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
for (let i = 0; i < layers.length; i++) {
|
|
45
45
|
if ('ref' in layers[i]) {
|
|
46
|
-
layers[i] = deref(layers[i], map[(layers[i] as
|
|
46
|
+
layers[i] = deref(layers[i], map[(layers[i] as LayerSpecification & {ref: string}).ref]);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
package/diff.ts
CHANGED
|
@@ -8,7 +8,7 @@ type Sources = {
|
|
|
8
8
|
|
|
9
9
|
type Command = {
|
|
10
10
|
command: string;
|
|
11
|
-
args:
|
|
11
|
+
args: unknown[];
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const operations = {
|
|
@@ -240,7 +240,16 @@ function diffSources(before: Sources, after: Sources, commands: Array<Command>,
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
function diffLayerPropertyChanges(before:
|
|
243
|
+
function diffLayerPropertyChanges(before: LayerSpecification['layout'], after: LayerSpecification['layout'], commands: Array<Command>, layerId: string, klass: string | null | undefined, command: string): void;
|
|
244
|
+
function diffLayerPropertyChanges(before: LayerSpecification['paint'], after: LayerSpecification['paint'], commands: Array<Command>, layerId: string, klass: string | null | undefined, command: string): void;
|
|
245
|
+
function diffLayerPropertyChanges(
|
|
246
|
+
before: LayerSpecification['paint'] | LayerSpecification['layout'],
|
|
247
|
+
after: LayerSpecification['paint'] | LayerSpecification['layout'],
|
|
248
|
+
commands: Command[],
|
|
249
|
+
layerId: string,
|
|
250
|
+
klass: string | null | undefined,
|
|
251
|
+
command: string
|
|
252
|
+
) {
|
|
244
253
|
before = before || {};
|
|
245
254
|
after = after || {};
|
|
246
255
|
|
|
@@ -260,22 +269,11 @@ function diffLayerPropertyChanges(before: any, after: any, commands: Array<Comma
|
|
|
260
269
|
}
|
|
261
270
|
}
|
|
262
271
|
|
|
263
|
-
function pluckId<T extends {
|
|
264
|
-
id: string;
|
|
265
|
-
}>(item: T): string {
|
|
272
|
+
function pluckId<T extends {id: string}>(item: T): string {
|
|
266
273
|
return item.id;
|
|
267
274
|
}
|
|
268
275
|
|
|
269
|
-
function indexById<T extends {
|
|
270
|
-
id: string;
|
|
271
|
-
}>(
|
|
272
|
-
group: {
|
|
273
|
-
[key: string]: T;
|
|
274
|
-
},
|
|
275
|
-
item: T,
|
|
276
|
-
): {
|
|
277
|
-
[id: string]: T;
|
|
278
|
-
} {
|
|
276
|
+
function indexById<T extends {id: string}>(group: {[key: string]: T}, item: T): {[id: string]: T} {
|
|
279
277
|
group[item.id] = item;
|
|
280
278
|
return group;
|
|
281
279
|
}
|
|
@@ -289,14 +287,14 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
289
287
|
const afterOrder = after.map(pluckId);
|
|
290
288
|
|
|
291
289
|
// index of layer by id
|
|
292
|
-
const beforeIndex = before.reduce
|
|
293
|
-
const afterIndex = after.reduce
|
|
290
|
+
const beforeIndex = before.reduce(indexById, {});
|
|
291
|
+
const afterIndex = after.reduce(indexById, {});
|
|
294
292
|
|
|
295
293
|
// track order of layers as if they have been mutated
|
|
296
294
|
const tracker = beforeOrder.slice();
|
|
297
295
|
|
|
298
296
|
// layers that have been added do not need to be diffed
|
|
299
|
-
const clean
|
|
297
|
+
const clean = Object.create(null);
|
|
300
298
|
|
|
301
299
|
let i, d, layerId, beforeLayer: LayerSpecification, afterLayer: LayerSpecification, insertBeforeLayerId, prop;
|
|
302
300
|
|
|
@@ -401,8 +399,8 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
|
|
|
401
399
|
const afterOrder = after.map(pluckId);
|
|
402
400
|
|
|
403
401
|
// index imports by id
|
|
404
|
-
const beforeIndex = before.reduce
|
|
405
|
-
const afterIndex = after.reduce
|
|
402
|
+
const beforeIndex = before.reduce(indexById, {});
|
|
403
|
+
const afterIndex = after.reduce(indexById, {});
|
|
406
404
|
|
|
407
405
|
// track order of imports as if they have been mutated
|
|
408
406
|
const tracker = beforeOrder.slice();
|
|
@@ -446,7 +444,9 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
|
|
|
446
444
|
// update imports
|
|
447
445
|
for (const afterImport of after) {
|
|
448
446
|
const beforeImport = beforeIndex[afterImport.id];
|
|
449
|
-
if (!beforeImport
|
|
447
|
+
if (!beforeImport) continue;
|
|
448
|
+
delete beforeImport.data;
|
|
449
|
+
if (isEqual(beforeImport, afterImport)) continue;
|
|
450
450
|
|
|
451
451
|
commands.push({command: operations.updateImport, args: [afterImport.id, afterImport]});
|
|
452
452
|
}
|