@mapbox/mapbox-gl-style-spec 14.0.0-beta.4 → 14.0.0-rc.2
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.js +79 -11
- package/dist/index.cjs +294 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +294 -72
- package/dist/index.es.js.map +1 -1
- package/error/validation_error.js +2 -0
- package/flow-typed/webgl2.js +10 -0
- package/package.json +1 -1
- package/reference/v8.json +163 -44
- package/validate/validate_fog.js +2 -2
- package/validate/validate_import.js +7 -0
- package/validate/validate_lights.js +32 -10
- package/validate/validate_object.js +2 -2
- package/validate/validate_property.js +4 -4
- package/validate/validate_terrain.js +2 -2
- package/validate_mapbox_api_supported.js +3 -0
package/diff.js
CHANGED
|
@@ -134,14 +134,24 @@ export const operations: {[_: string]: string} = {
|
|
|
134
134
|
setProjection: 'setProjection',
|
|
135
135
|
|
|
136
136
|
/*
|
|
137
|
-
* { command: 'addImport', args: [
|
|
137
|
+
* { command: 'addImport', args: [import] }
|
|
138
138
|
*/
|
|
139
139
|
addImport: 'addImport',
|
|
140
140
|
|
|
141
141
|
/*
|
|
142
142
|
* { command: 'removeImport', args: [importId] }
|
|
143
143
|
*/
|
|
144
|
-
removeImport: 'removeImport'
|
|
144
|
+
removeImport: 'removeImport',
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* { command: 'setImportUrl', args: [importId, styleUrl] }
|
|
148
|
+
*/
|
|
149
|
+
setImportUrl: 'setImportUrl',
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* { command: 'setImportData', args: [importId, stylesheet] }
|
|
153
|
+
*/
|
|
154
|
+
setImportData: 'setImportData'
|
|
145
155
|
};
|
|
146
156
|
|
|
147
157
|
function addSource(sourceId: string, after: Sources, commands: Array<Command>) {
|
|
@@ -226,12 +236,12 @@ function diffLayerPropertyChanges(before: any, after: any, commands: Array<Comma
|
|
|
226
236
|
}
|
|
227
237
|
}
|
|
228
238
|
|
|
229
|
-
function pluckId(
|
|
230
|
-
return
|
|
239
|
+
function pluckId<T: {id: string}>(item: T): string {
|
|
240
|
+
return item.id;
|
|
231
241
|
}
|
|
232
242
|
|
|
233
|
-
function indexById(group: {[string]:
|
|
234
|
-
group[
|
|
243
|
+
function indexById<T: {id: string}>(group: {[string]: T}, item: T): {[id: string]: T} {
|
|
244
|
+
group[item.id] = item;
|
|
235
245
|
return group;
|
|
236
246
|
}
|
|
237
247
|
|
|
@@ -345,14 +355,72 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
345
355
|
}
|
|
346
356
|
}
|
|
347
357
|
|
|
348
|
-
function diffImports(before: Array<ImportSpecification> = [], after: Array<ImportSpecification> = [], commands: Array<Command>) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
358
|
+
export function diffImports(before: Array<ImportSpecification> = [], after: Array<ImportSpecification> = [], commands: Array<Command>) {
|
|
359
|
+
before = before || [];
|
|
360
|
+
after = after || [];
|
|
361
|
+
|
|
362
|
+
// order imports by id
|
|
363
|
+
const beforeOrder = before.map(pluckId);
|
|
364
|
+
const afterOrder = after.map(pluckId);
|
|
365
|
+
|
|
366
|
+
// index imports by id
|
|
367
|
+
const beforeIndex = before.reduce(indexById, {});
|
|
368
|
+
const afterIndex = after.reduce(indexById, {});
|
|
369
|
+
|
|
370
|
+
// track order of imports as if they have been mutated
|
|
371
|
+
const tracker = beforeOrder.slice();
|
|
372
|
+
|
|
373
|
+
let i, d, importId, insertBefore;
|
|
374
|
+
|
|
375
|
+
// remove imports
|
|
376
|
+
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
377
|
+
importId = beforeOrder[i];
|
|
378
|
+
if (!afterIndex.hasOwnProperty(importId)) {
|
|
379
|
+
commands.push({command: operations.removeImport, args: [importId]});
|
|
380
|
+
tracker.splice(tracker.indexOf(importId, d), 1);
|
|
381
|
+
} else {
|
|
382
|
+
// limit where in tracker we need to look for a match
|
|
383
|
+
d++;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// add/reorder imports
|
|
388
|
+
for (i = 0, d = 0; i < afterOrder.length; i++) {
|
|
389
|
+
// work backwards as insert is before an existing import
|
|
390
|
+
importId = afterOrder[afterOrder.length - 1 - i];
|
|
391
|
+
|
|
392
|
+
if (tracker[tracker.length - 1 - i] === importId) continue;
|
|
393
|
+
|
|
394
|
+
if (beforeIndex.hasOwnProperty(importId)) {
|
|
395
|
+
// remove the import before we insert at the correct position
|
|
396
|
+
commands.push({command: operations.removeImport, args: [importId]});
|
|
397
|
+
tracker.splice(tracker.lastIndexOf(importId, tracker.length - d), 1);
|
|
398
|
+
} else {
|
|
399
|
+
// limit where in tracker we need to look for a match
|
|
400
|
+
d++;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// add import at correct position
|
|
404
|
+
insertBefore = tracker[tracker.length - i];
|
|
405
|
+
commands.push({command: operations.addImport, args: [afterIndex[importId], insertBefore]});
|
|
406
|
+
tracker.splice(tracker.length - i, 0, importId);
|
|
352
407
|
}
|
|
353
408
|
|
|
409
|
+
// update imports
|
|
354
410
|
for (const afterImport of after) {
|
|
355
|
-
|
|
411
|
+
const beforeImport = beforeIndex[afterImport.id];
|
|
412
|
+
if (!beforeImport || isEqual(beforeImport, afterImport)) continue;
|
|
413
|
+
|
|
414
|
+
if (!isEqual(beforeImport.url, afterImport.url)) {
|
|
415
|
+
commands.push({command: operations.setImportUrl, args: [afterImport.id, afterImport.url]});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const beforeData = beforeImport && beforeImport.data;
|
|
419
|
+
const afterData = afterImport.data;
|
|
420
|
+
|
|
421
|
+
if (!isEqual(beforeData, afterData)) {
|
|
422
|
+
commands.push({command: operations.setImportData, args: [afterImport.id, afterData]});
|
|
423
|
+
}
|
|
356
424
|
}
|
|
357
425
|
}
|
|
358
426
|
|