@mapbox/mapbox-gl-style-spec 14.23.0 → 14.24.0-rc.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 +5 -3
- package/diff.ts +37 -80
- package/dist/index.cjs +159 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +159 -113
- package/dist/index.es.js.map +1 -1
- package/error/parsing_error.ts +3 -1
- package/expression/compound_expression.ts +11 -4
- package/expression/definitions/assertion.ts +2 -3
- package/expression/definitions/case.ts +1 -1
- package/expression/definitions/coercion.ts +4 -4
- package/expression/definitions/format.ts +1 -1
- package/expression/definitions/image.ts +2 -2
- package/expression/definitions/in.ts +1 -1
- package/expression/definitions/index.ts +7 -8
- package/expression/definitions/interpolate.ts +1 -1
- package/expression/definitions/let.ts +4 -2
- package/expression/definitions/match.ts +1 -1
- package/expression/definitions/step.ts +1 -1
- package/expression/is_constant.ts +2 -2
- package/expression/parsing_context.ts +18 -4
- package/expression/stops.ts +2 -1
- package/expression/types/image_variant.ts +5 -3
- package/feature_filter/index.ts +7 -30
- package/function/index.ts +7 -6
- package/migrate/v9.ts +1 -1
- package/package.json +1 -1
- package/reference/v8.json +20 -0
- package/types.ts +5 -1
- package/util/color.ts +2 -7
- package/util/geometry_util.ts +3 -8
- package/util/interpolate.ts +2 -3
- package/util/lerp.ts +3 -0
- package/util/properties.ts +4 -1
- package/validate/validate_enum.ts +2 -2
- package/validate/validate_fog.ts +3 -2
- package/validate/validate_function.ts +2 -2
- package/validate/validate_glyphs_url.ts +2 -2
- package/validate/validate_layer.ts +6 -5
- package/validate/validate_light.ts +3 -2
- package/validate/validate_lights.ts +3 -2
- package/validate/validate_model.ts +1 -1
- package/validate/validate_object.ts +1 -3
- package/validate/validate_property.ts +7 -5
- package/validate/validate_rain.ts +2 -1
- package/validate/validate_snow.ts +2 -1
- package/validate/validate_style.ts +1 -0
- package/validate/validate_terrain.ts +3 -2
- package/validate_mapbox_api_supported.ts +9 -8
package/composite.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type {StyleSpecification} from './types';
|
|
2
2
|
|
|
3
|
+
const MAPBOX_URL_RE = /^mapbox:\/\/(.*)/;
|
|
4
|
+
|
|
3
5
|
export default function (style: StyleSpecification): StyleSpecification {
|
|
4
6
|
const styleIDs: string[] = [];
|
|
5
7
|
const sourceIDs: string[] = [];
|
|
@@ -11,7 +13,7 @@ export default function (style: StyleSpecification): StyleSpecification {
|
|
|
11
13
|
if (source.type !== "vector")
|
|
12
14
|
continue;
|
|
13
15
|
|
|
14
|
-
const match =
|
|
16
|
+
const match = MAPBOX_URL_RE.exec(source.url);
|
|
15
17
|
if (!match)
|
|
16
18
|
continue;
|
|
17
19
|
|
|
@@ -34,11 +36,11 @@ export default function (style: StyleSpecification): StyleSpecification {
|
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
style.layers.forEach((layer) => {
|
|
37
|
-
if (styleIDs.
|
|
39
|
+
if (styleIDs.includes(layer.source)) {
|
|
38
40
|
layer.source = compositeID;
|
|
39
41
|
|
|
40
42
|
if ('source-layer' in layer) {
|
|
41
|
-
if (compositedSourceLayers.
|
|
43
|
+
if (compositedSourceLayers.includes(layer['source-layer'])) {
|
|
42
44
|
throw new Error('Conflicting source layer names');
|
|
43
45
|
} else {
|
|
44
46
|
compositedSourceLayers.push(layer['source-layer']);
|
package/diff.ts
CHANGED
|
@@ -193,19 +193,15 @@ function updateSource(sourceId: string, after: Sources, commands: Array<Command>
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
function canUpdateGeoJSON(before: Sources, after: Sources, sourceId: string) {
|
|
196
|
-
let prop;
|
|
196
|
+
let prop: string;
|
|
197
197
|
for (prop in before[sourceId]) {
|
|
198
|
-
|
|
199
|
-
if (!before[sourceId].hasOwnProperty(prop)) continue;
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
198
|
+
if (!Object.hasOwn(before[sourceId], prop)) continue;
|
|
201
199
|
if (prop !== 'data' && !isEqual(before[sourceId][prop], after[sourceId][prop])) {
|
|
202
200
|
return false;
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
203
|
for (prop in after[sourceId]) {
|
|
206
|
-
|
|
207
|
-
if (!after[sourceId].hasOwnProperty(prop)) continue;
|
|
208
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
204
|
+
if (!Object.hasOwn(after[sourceId], prop)) continue;
|
|
209
205
|
if (prop !== 'data' && !isEqual(before[sourceId][prop], after[sourceId][prop])) {
|
|
210
206
|
return false;
|
|
211
207
|
}
|
|
@@ -217,37 +213,27 @@ function diffSources(before: Sources, after: Sources, commands: Array<Command>,
|
|
|
217
213
|
before = before || {};
|
|
218
214
|
after = after || {};
|
|
219
215
|
|
|
220
|
-
let sourceId;
|
|
216
|
+
let sourceId: string;
|
|
221
217
|
|
|
222
218
|
// look for sources to remove
|
|
223
219
|
for (sourceId in before) {
|
|
224
|
-
|
|
225
|
-
if (!
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
227
|
-
if (!after.hasOwnProperty(sourceId)) {
|
|
228
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
220
|
+
if (!Object.hasOwn(before, sourceId)) continue;
|
|
221
|
+
if (!Object.hasOwn(after, sourceId)) {
|
|
229
222
|
removeSource(sourceId, commands, sourcesRemoved);
|
|
230
223
|
}
|
|
231
224
|
}
|
|
232
225
|
|
|
233
226
|
// look for sources to add/update
|
|
234
227
|
for (sourceId in after) {
|
|
235
|
-
|
|
236
|
-
if (!after.hasOwnProperty(sourceId)) continue;
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
228
|
+
if (!Object.hasOwn(after, sourceId)) continue;
|
|
238
229
|
const source = after[sourceId];
|
|
239
|
-
|
|
240
|
-
if (!before.hasOwnProperty(sourceId)) {
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
230
|
+
if (!Object.hasOwn(before, sourceId)) {
|
|
242
231
|
addSource(sourceId, after, commands);
|
|
243
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
244
232
|
} else if (!isEqual(before[sourceId], source)) {
|
|
245
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
|
|
246
233
|
if (before[sourceId].type === 'geojson' && source.type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {
|
|
247
234
|
commands.push({command: operations.setGeoJSONSourceData, args: [sourceId, source.data]});
|
|
248
235
|
} else {
|
|
249
236
|
// no update command, must remove then add
|
|
250
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
251
237
|
updateSource(sourceId, after, commands, sourcesRemoved);
|
|
252
238
|
}
|
|
253
239
|
}
|
|
@@ -267,23 +253,17 @@ function diffLayerPropertyChanges(
|
|
|
267
253
|
before = before || {};
|
|
268
254
|
after = after || {};
|
|
269
255
|
|
|
270
|
-
let prop;
|
|
256
|
+
let prop: string;
|
|
271
257
|
|
|
272
258
|
for (prop in before) {
|
|
273
|
-
|
|
274
|
-
if (!before.hasOwnProperty(prop)) continue;
|
|
275
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
259
|
+
if (!Object.hasOwn(before, prop)) continue;
|
|
276
260
|
if (!isEqual(before[prop], after[prop])) {
|
|
277
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
278
261
|
commands.push({command, args: [layerId, prop, after[prop], klass]});
|
|
279
262
|
}
|
|
280
263
|
}
|
|
281
264
|
for (prop in after) {
|
|
282
|
-
|
|
283
|
-
if (!after.hasOwnProperty(prop) || before.hasOwnProperty(prop)) continue;
|
|
284
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
265
|
+
if (!Object.hasOwn(after, prop) || Object.hasOwn(before, prop)) continue;
|
|
285
266
|
if (!isEqual(before[prop], after[prop])) {
|
|
286
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
287
267
|
commands.push({command, args: [layerId, prop, after[prop], klass]});
|
|
288
268
|
}
|
|
289
269
|
}
|
|
@@ -317,16 +297,19 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
317
297
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
318
298
|
const clean = Object.create(null);
|
|
319
299
|
|
|
320
|
-
let i
|
|
300
|
+
let i: number;
|
|
301
|
+
let d: number;
|
|
302
|
+
let layerId: string;
|
|
303
|
+
let beforeLayer: LayerSpecification;
|
|
304
|
+
let afterLayer: LayerSpecification;
|
|
305
|
+
let insertBeforeLayerId: string;
|
|
306
|
+
let prop: string;
|
|
321
307
|
|
|
322
308
|
// remove layers
|
|
323
309
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
325
310
|
layerId = beforeOrder[i];
|
|
326
|
-
|
|
327
|
-
if (!afterIndex.hasOwnProperty(layerId)) {
|
|
311
|
+
if (!Object.hasOwn(afterIndex, layerId)) {
|
|
328
312
|
commands.push({command: operations.removeLayer, args: [layerId]});
|
|
329
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
330
313
|
tracker.splice(tracker.indexOf(layerId, d), 1);
|
|
331
314
|
} else {
|
|
332
315
|
// limit where in tracker we need to look for a match
|
|
@@ -341,11 +324,9 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
341
324
|
|
|
342
325
|
if (tracker[tracker.length - 1 - i] === layerId) continue;
|
|
343
326
|
|
|
344
|
-
|
|
345
|
-
if (beforeIndex.hasOwnProperty(layerId)) {
|
|
327
|
+
if (Object.hasOwn(beforeIndex, layerId)) {
|
|
346
328
|
// remove the layer before we insert at the correct position
|
|
347
329
|
commands.push({command: operations.removeLayer, args: [layerId]});
|
|
348
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
349
330
|
tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);
|
|
350
331
|
} else {
|
|
351
332
|
// limit where in tracker we need to look for a match
|
|
@@ -354,9 +335,7 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
354
335
|
|
|
355
336
|
// add layer at correct position
|
|
356
337
|
insertBeforeLayerId = tracker[tracker.length - i];
|
|
357
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
358
338
|
commands.push({command: operations.addLayer, args: [afterIndex[layerId], insertBeforeLayerId]});
|
|
359
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
360
339
|
tracker.splice(tracker.length - i, 0, layerId);
|
|
361
340
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
362
341
|
clean[layerId] = true;
|
|
@@ -364,11 +343,10 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
364
343
|
|
|
365
344
|
// update layers
|
|
366
345
|
for (i = 0; i < afterOrder.length; i++) {
|
|
367
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
368
346
|
layerId = afterOrder[i];
|
|
369
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
347
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
370
348
|
beforeLayer = beforeIndex[layerId];
|
|
371
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
349
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
372
350
|
afterLayer = afterIndex[layerId];
|
|
373
351
|
|
|
374
352
|
// no need to update if previously added (new or moved)
|
|
@@ -381,16 +359,13 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
381
359
|
commands.push({command: operations.removeLayer, args: [layerId]});
|
|
382
360
|
// we add the layer back at the same position it was already in, so
|
|
383
361
|
// there's no need to update the `tracker`
|
|
384
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
385
362
|
insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];
|
|
386
363
|
commands.push({command: operations.addLayer, args: [afterLayer, insertBeforeLayerId]});
|
|
387
364
|
continue;
|
|
388
365
|
}
|
|
389
366
|
|
|
390
367
|
// layout, paint, filter, minzoom, maxzoom
|
|
391
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
392
368
|
diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
394
369
|
diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);
|
|
395
370
|
if (!isEqual(beforeLayer.slot, afterLayer.slot)) {
|
|
396
371
|
commands.push({command: operations.setSlot, args: [layerId, afterLayer.slot]});
|
|
@@ -404,32 +379,24 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
404
379
|
|
|
405
380
|
// handle all other layer props, including paint.*
|
|
406
381
|
for (prop in beforeLayer) {
|
|
407
|
-
|
|
408
|
-
if (!beforeLayer.hasOwnProperty(prop)) continue;
|
|
382
|
+
if (!Object.hasOwn(beforeLayer, prop)) continue;
|
|
409
383
|
if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||
|
|
410
384
|
prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot') continue;
|
|
411
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
412
385
|
if (prop.indexOf('paint.') === 0) {
|
|
413
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
386
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
414
387
|
diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);
|
|
415
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
416
388
|
} else if (!isEqual(beforeLayer[prop], afterLayer[prop])) {
|
|
417
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
418
389
|
commands.push({command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]]});
|
|
419
390
|
}
|
|
420
391
|
}
|
|
421
392
|
for (prop in afterLayer) {
|
|
422
|
-
|
|
423
|
-
if (!afterLayer.hasOwnProperty(prop) || beforeLayer.hasOwnProperty(prop)) continue;
|
|
393
|
+
if (!Object.hasOwn(afterLayer, prop) || Object.hasOwn(beforeLayer, prop)) continue;
|
|
424
394
|
if (prop === 'layout' || prop === 'paint' || prop === 'filter' ||
|
|
425
395
|
prop === 'metadata' || prop === 'minzoom' || prop === 'maxzoom' || prop === 'slot') continue;
|
|
426
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
427
396
|
if (prop.indexOf('paint.') === 0) {
|
|
428
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
397
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
429
398
|
diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), operations.setPaintProperty);
|
|
430
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
431
399
|
} else if (!isEqual(beforeLayer[prop], afterLayer[prop])) {
|
|
432
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
433
400
|
commands.push({command: operations.setLayerProperty, args: [layerId, prop, afterLayer[prop]]});
|
|
434
401
|
}
|
|
435
402
|
}
|
|
@@ -451,16 +418,16 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
|
|
|
451
418
|
// track order of imports as if they have been mutated
|
|
452
419
|
const tracker = beforeOrder.slice();
|
|
453
420
|
|
|
454
|
-
let i
|
|
421
|
+
let i: number;
|
|
422
|
+
let d: number;
|
|
423
|
+
let importId: string;
|
|
424
|
+
let insertBefore: string;
|
|
455
425
|
|
|
456
426
|
// remove imports
|
|
457
427
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
458
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
459
428
|
importId = beforeOrder[i];
|
|
460
|
-
|
|
461
|
-
if (!afterIndex.hasOwnProperty(importId)) {
|
|
429
|
+
if (!Object.hasOwn(afterIndex, importId)) {
|
|
462
430
|
commands.push({command: operations.removeImport, args: [importId]});
|
|
463
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
464
431
|
tracker.splice(tracker.indexOf(importId, d), 1);
|
|
465
432
|
} else {
|
|
466
433
|
// limit where in tracker we need to look for a match
|
|
@@ -475,11 +442,9 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
|
|
|
475
442
|
|
|
476
443
|
if (tracker[tracker.length - 1 - i] === importId) continue;
|
|
477
444
|
|
|
478
|
-
|
|
479
|
-
if (beforeIndex.hasOwnProperty(importId)) {
|
|
445
|
+
if (Object.hasOwn(beforeIndex, importId)) {
|
|
480
446
|
// remove the import before we insert at the correct position
|
|
481
447
|
commands.push({command: operations.removeImport, args: [importId]});
|
|
482
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
483
448
|
tracker.splice(tracker.lastIndexOf(importId, tracker.length - d), 1);
|
|
484
449
|
} else {
|
|
485
450
|
// limit where in tracker we need to look for a match
|
|
@@ -488,9 +453,7 @@ export function diffImports(before: Array<ImportSpecification> | null | undefine
|
|
|
488
453
|
|
|
489
454
|
// add import at correct position
|
|
490
455
|
insertBefore = tracker[tracker.length - i];
|
|
491
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
492
456
|
commands.push({command: operations.addImport, args: [afterIndex[importId], insertBefore]});
|
|
493
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
494
457
|
tracker.splice(tracker.length - i, 0, importId);
|
|
495
458
|
}
|
|
496
459
|
|
|
@@ -511,28 +474,22 @@ function diffIconsets(before: IconsetsSpecification, after: IconsetsSpecificatio
|
|
|
511
474
|
before = before || {};
|
|
512
475
|
after = after || {};
|
|
513
476
|
|
|
514
|
-
let iconsetId;
|
|
477
|
+
let iconsetId: string;
|
|
515
478
|
|
|
516
479
|
// look for iconsets to remove
|
|
517
480
|
for (iconsetId in before) {
|
|
518
|
-
|
|
519
|
-
if (!
|
|
520
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
521
|
-
if (!after.hasOwnProperty(iconsetId)) {
|
|
481
|
+
if (!Object.hasOwn(before, iconsetId)) continue;
|
|
482
|
+
if (!Object.hasOwn(after, iconsetId)) {
|
|
522
483
|
commands.push({command: operations.removeIconset, args: [iconsetId]});
|
|
523
484
|
}
|
|
524
485
|
}
|
|
525
486
|
|
|
526
487
|
// look for iconsets to add/update
|
|
527
488
|
for (iconsetId in after) {
|
|
528
|
-
|
|
529
|
-
if (!after.hasOwnProperty(iconsetId)) continue;
|
|
530
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
489
|
+
if (!Object.hasOwn(after, iconsetId)) continue;
|
|
531
490
|
const iconset = after[iconsetId];
|
|
532
|
-
|
|
533
|
-
if (!before.hasOwnProperty(iconsetId)) {
|
|
491
|
+
if (!Object.hasOwn(before, iconsetId)) {
|
|
534
492
|
commands.push({command: operations.addIconset, args: [iconsetId, iconset]});
|
|
535
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
536
493
|
} else if (!isEqual(before[iconsetId], iconset)) {
|
|
537
494
|
commands.push({command: operations.removeIconset, args: [iconsetId]});
|
|
538
495
|
commands.push({command: operations.addIconset, args: [iconsetId, iconset]});
|