@mapbox/mapbox-gl-style-spec 14.4.0 → 14.5.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/bin/gl-style-composite.js +0 -5
- package/bin/gl-style-format.js +0 -5
- package/bin/gl-style-migrate.js +0 -5
- package/bin/gl-style-validate.js +0 -5
- package/{composite.js → composite.ts} +1 -1
- package/data/{extent.js → extent.ts} +0 -2
- package/{deref.js → deref.ts} +7 -9
- package/{diff.js → diff.ts} +44 -21
- package/dist/index.cjs +794 -1226
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1746 -0
- package/dist/index.es.js +794 -1226
- package/dist/index.es.js.map +1 -1
- package/{empty.js → empty.ts} +1 -2
- package/error/{parsing_error.js → parsing_error.ts} +0 -2
- package/error/{validation_error.js → validation_error.ts} +5 -5
- package/expression/{compound_expression.js → compound_expression.ts} +29 -19
- package/expression/definitions/{assertion.js → assertion.ts} +16 -13
- package/expression/definitions/{at.js → at.ts} +12 -13
- package/expression/definitions/{case.js → case.ts} +12 -11
- package/expression/definitions/{coalesce.js → coalesce.ts} +11 -11
- package/expression/definitions/{coercion.js → coercion.ts} +21 -20
- package/expression/definitions/{collator.js → collator.ts} +11 -11
- package/expression/definitions/{comparison.js → comparison.ts} +30 -24
- package/expression/definitions/{config.js → config.ts} +16 -16
- package/expression/definitions/{distance.js → distance.ts} +60 -52
- package/expression/definitions/{format.js → format.ts} +26 -15
- package/expression/definitions/{image.js → image.ts} +12 -12
- package/expression/definitions/{in.js → in.ts} +22 -13
- package/expression/definitions/{index.js → index.ts} +70 -83
- package/expression/definitions/{index_of.js → index_of.ts} +24 -15
- package/expression/definitions/{interpolate.js → interpolate.ts} +44 -25
- package/expression/definitions/{length.js → length.ts} +11 -10
- package/expression/definitions/{let.js → let.ts} +10 -7
- package/expression/definitions/{literal.js → literal.ts} +11 -12
- package/expression/definitions/{match.js → match.ts} +25 -15
- package/expression/definitions/{number_format.js → number_format.ts} +10 -10
- package/expression/definitions/{slice.js → slice.ts} +23 -15
- package/expression/definitions/{step.js → step.ts} +14 -12
- package/expression/definitions/{var.js → var.ts} +5 -7
- package/expression/definitions/{within.js → within.ts} +41 -29
- package/expression/{evaluation_context.js → evaluation_context.ts} +26 -23
- package/expression/expression.ts +29 -0
- package/expression/{index.js → index.ts} +208 -110
- package/expression/{is_constant.js → is_constant.ts} +5 -7
- package/expression/{parsing_context.js → parsing_context.ts} +47 -34
- package/expression/{parsing_error.js → parsing_error.ts} +0 -2
- package/expression/{runtime_error.js → runtime_error.ts} +0 -2
- package/expression/{scope.js → scope.ts} +5 -5
- package/expression/{stops.js → stops.ts} +2 -4
- package/expression/types/{collator.js → collator.ts} +1 -3
- package/expression/types/{formatted.js → formatted.ts} +8 -7
- package/expression/types/{resolved_image.js → resolved_image.ts} +5 -7
- package/expression/{types.js → types.ts} +53 -45
- package/expression/{values.js → values.ts} +12 -12
- package/feature_filter/{convert.js → convert.ts} +19 -18
- package/feature_filter/{index.js → index.ts} +39 -21
- package/{format.js → format.ts} +3 -3
- package/function/{convert.js → convert.ts} +44 -44
- package/function/{index.js → index.ts} +12 -12
- package/{group_by_layout.js → group_by_layout.ts} +11 -8
- package/migrate/{expressions.js → expressions.ts} +7 -16
- package/migrate/{v8.js → v8.ts} +2 -2
- package/migrate/{v9.js → v9.ts} +2 -2
- package/{migrate.js → migrate.ts} +3 -3
- package/package.json +19 -18
- package/{read_style.js → read_style.ts} +5 -4
- package/reference/latest.ts +5 -0
- package/reference/v8.json +264 -7
- package/rollup.config.js +6 -24
- package/{style-spec.js → style-spec.ts} +41 -36
- package/test.js +3 -2
- package/types/config_options.ts +13 -0
- package/types/lut.ts +7 -0
- package/types/tile_id.ts +5 -0
- package/{types.js → types.ts} +527 -165
- package/util/{color.js → color.ts} +89 -3
- package/util/{color_spaces.js → color_spaces.ts} +12 -14
- package/util/{deep_equal.js → deep_equal.ts} +1 -3
- package/util/{extend.js → extend.ts} +1 -3
- package/util/{geometry_util.js → geometry_util.ts} +23 -11
- package/util/{get_type.js → get_type.ts} +1 -3
- package/util/{interpolate.js → interpolate.ts} +1 -3
- package/util/{properties.js → properties.ts} +5 -4
- package/util/{random.js → random.ts} +0 -2
- package/util/{ref_properties.js → ref_properties.ts} +0 -1
- package/util/{result.js → result.ts} +7 -5
- package/util/{unbundle_jsonlint.js → unbundle_jsonlint.ts} +5 -5
- package/validate/{validate.js → validate.ts} +33 -35
- package/validate/{validate_array.js → validate_array.ts} +5 -7
- package/validate/{validate_boolean.js → validate_boolean.ts} +3 -5
- package/validate/{validate_color.js → validate_color.ts} +3 -5
- package/validate/{validate_enum.js → validate_enum.ts} +4 -5
- package/validate/{validate_expression.js → validate_expression.ts} +7 -9
- package/validate/{validate_filter.js → validate_filter.ts} +16 -12
- package/validate/{validate_fog.js → validate_fog.ts} +4 -6
- package/validate/validate_formatted.ts +13 -0
- package/validate/{validate_function.js → validate_function.ts} +14 -16
- package/validate/{validate_glyphs_url.js → validate_glyphs_url.ts} +3 -5
- package/validate/validate_image.ts +13 -0
- package/validate/{validate_import.js → validate_import.ts} +6 -8
- package/validate/{validate_layer.js → validate_layer.ts} +17 -15
- package/validate/{validate_layout_property.js → validate_layout_property.ts} +3 -5
- package/validate/{validate_light.js → validate_light.ts} +4 -6
- package/validate/{validate_lights.js → validate_lights.ts} +7 -9
- package/validate/{validate_model.js → validate_model.ts} +4 -6
- package/validate/{validate_number.js → validate_number.ts} +4 -6
- package/validate/{validate_object.js → validate_object.ts} +5 -8
- package/validate/{validate_paint_property.js → validate_paint_property.ts} +3 -5
- package/validate/{validate_projection.js → validate_projection.ts} +4 -6
- package/validate/{validate_property.js → validate_property.ts} +15 -15
- package/validate/{validate_source.js → validate_source.ts} +16 -13
- package/validate/validate_string.ts +16 -0
- package/validate/validate_style.ts +33 -0
- package/validate/{validate_terrain.js → validate_terrain.ts} +5 -7
- package/{validate_mapbox_api_supported.js → validate_mapbox_api_supported.ts} +22 -18
- package/{validate_style.min.js → validate_style.min.ts} +20 -21
- package/{validate_style.js → validate_style.ts} +9 -9
- package/{visit.js → visit.ts} +22 -17
- package/.eslintrc +0 -10
- package/expression/expression.js +0 -28
- package/flow-typed/cheap-ruler.js +0 -25
- package/flow-typed/geojson.js +0 -44
- package/flow-typed/gl-matrix.js +0 -119
- package/flow-typed/gl.js +0 -5
- package/flow-typed/intl.js +0 -58
- package/flow-typed/kdbush.js +0 -9
- package/flow-typed/mapbox-gl-supported.js +0 -16
- package/flow-typed/mapbox-unitbezier.js +0 -14
- package/flow-typed/offscreen-canvas.js +0 -9
- package/flow-typed/pbf.js +0 -26
- package/flow-typed/point-geometry.js +0 -46
- package/flow-typed/potpack.js +0 -13
- package/flow-typed/tiny-sdf.js +0 -31
- package/flow-typed/tracked_parameters_proxy.js +0 -82
- package/flow-typed/vector-tile.js +0 -49
- package/flow-typed/webgl2.js +0 -41
- package/reference/latest.js +0 -7
- package/validate/validate_formatted.js +0 -15
- package/validate/validate_image.js +0 -15
- package/validate/validate_string.js +0 -18
- package/validate/validate_style.js +0 -29
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @flow
|
|
4
2
|
/* eslint-disable no-process-exit */
|
|
5
3
|
|
|
6
4
|
import fs from 'fs';
|
|
7
5
|
import minimist from 'minimist';
|
|
8
|
-
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
10
|
-
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
6
|
import {format, composite} from '@mapbox/mapbox-gl-style-spec';
|
|
12
7
|
|
|
13
8
|
const argv = minimist(process.argv.slice(2));
|
package/bin/gl-style-format.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @flow
|
|
4
2
|
/* eslint-disable no-process-exit */
|
|
5
3
|
|
|
6
4
|
import fs from 'fs';
|
|
7
5
|
import minimist from 'minimist';
|
|
8
|
-
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
10
|
-
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
6
|
import {format} from '@mapbox/mapbox-gl-style-spec';
|
|
12
7
|
|
|
13
8
|
const argv = minimist(process.argv.slice(2));
|
package/bin/gl-style-migrate.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @flow
|
|
4
2
|
/* eslint-disable no-process-exit */
|
|
5
3
|
|
|
6
4
|
import fs from 'fs';
|
|
7
5
|
import minimist from 'minimist';
|
|
8
|
-
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
10
|
-
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
6
|
import {format, migrate} from '@mapbox/mapbox-gl-style-spec';
|
|
12
7
|
|
|
13
8
|
const argv = minimist(process.argv.slice(2));
|
package/bin/gl-style-validate.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @flow
|
|
4
2
|
/* eslint-disable no-process-exit */
|
|
5
3
|
|
|
6
4
|
import rw from 'rw';
|
|
7
5
|
import minimist from 'minimist';
|
|
8
|
-
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
10
|
-
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
6
|
import {validate, validateMapboxApiSupported} from '@mapbox/mapbox-gl-style-spec';
|
|
12
7
|
|
|
13
8
|
const argv = minimist(process.argv.slice(2), {
|
package/{deref.js → deref.ts}
RENAMED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import refProperties from './util/ref_properties';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import type {LayerSpecification} from './types.js';
|
|
3
|
+
import type {LayerSpecification} from './types';
|
|
6
4
|
|
|
7
5
|
function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpecification {
|
|
8
|
-
const result = {};
|
|
6
|
+
const result: Record<string, any> = {};
|
|
9
7
|
|
|
10
8
|
for (const k in layer) {
|
|
11
9
|
if (k !== 'ref') {
|
|
@@ -15,11 +13,11 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
|
|
|
15
13
|
|
|
16
14
|
refProperties.forEach((k) => {
|
|
17
15
|
if (k in parent) {
|
|
18
|
-
result[k] = (parent
|
|
16
|
+
result[k] = (parent as any)[k];
|
|
19
17
|
}
|
|
20
18
|
});
|
|
21
19
|
|
|
22
|
-
return
|
|
20
|
+
return result as LayerSpecification;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -38,14 +36,14 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
|
|
|
38
36
|
export default function derefLayers(layers: Array<LayerSpecification>): Array<LayerSpecification> {
|
|
39
37
|
layers = layers.slice();
|
|
40
38
|
|
|
41
|
-
const map:
|
|
39
|
+
const map: any = Object.create(null);
|
|
42
40
|
for (let i = 0; i < layers.length; i++) {
|
|
43
41
|
map[layers[i].id] = layers[i];
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
for (let i = 0; i < layers.length; i++) {
|
|
47
45
|
if ('ref' in layers[i]) {
|
|
48
|
-
layers[i] = deref(layers[i], map[(layers[i]
|
|
46
|
+
layers[i] = deref(layers[i], map[(layers[i] as any).ref]);
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
|
package/{diff.js → diff.ts}
RENAMED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import isEqual from './util/deep_equal';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import type {StyleSpecification, ImportSpecification, SourceSpecification, LayerSpecification} from './types';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type Sources = {
|
|
6
|
+
[key: string]: SourceSpecification;
|
|
7
|
+
};
|
|
8
8
|
|
|
9
9
|
type Command = {
|
|
10
10
|
command: string;
|
|
11
11
|
args: Array<any>;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const operations: {
|
|
14
|
+
export const operations: {
|
|
15
|
+
[_: string]: string;
|
|
16
|
+
} = {
|
|
15
17
|
|
|
16
18
|
/*
|
|
17
19
|
* { command: 'setStyle', args: [stylesheet] }
|
|
@@ -158,12 +160,16 @@ function addSource(sourceId: string, after: Sources, commands: Array<Command>) {
|
|
|
158
160
|
commands.push({command: operations.addSource, args: [sourceId, after[sourceId]]});
|
|
159
161
|
}
|
|
160
162
|
|
|
161
|
-
function removeSource(sourceId: string, commands: Array<Command>, sourcesRemoved: {
|
|
163
|
+
function removeSource(sourceId: string, commands: Array<Command>, sourcesRemoved: {
|
|
164
|
+
[key: string]: true;
|
|
165
|
+
}) {
|
|
162
166
|
commands.push({command: operations.removeSource, args: [sourceId]});
|
|
163
167
|
sourcesRemoved[sourceId] = true;
|
|
164
168
|
}
|
|
165
169
|
|
|
166
|
-
function updateSource(sourceId: string, after: Sources, commands: Array<Command>, sourcesRemoved: {
|
|
170
|
+
function updateSource(sourceId: string, after: Sources, commands: Array<Command>, sourcesRemoved: {
|
|
171
|
+
[key: string]: true;
|
|
172
|
+
}) {
|
|
167
173
|
removeSource(sourceId, commands, sourcesRemoved);
|
|
168
174
|
addSource(sourceId, after, commands);
|
|
169
175
|
}
|
|
@@ -185,7 +191,9 @@ function canUpdateGeoJSON(before: Sources, after: Sources, sourceId: string) {
|
|
|
185
191
|
return true;
|
|
186
192
|
}
|
|
187
193
|
|
|
188
|
-
function diffSources(before: Sources, after: Sources, commands: Array<Command>, sourcesRemoved: {
|
|
194
|
+
function diffSources(before: Sources, after: Sources, commands: Array<Command>, sourcesRemoved: {
|
|
195
|
+
[key: string]: true;
|
|
196
|
+
}) {
|
|
189
197
|
before = before || {};
|
|
190
198
|
after = after || {};
|
|
191
199
|
|
|
@@ -216,7 +224,7 @@ function diffSources(before: Sources, after: Sources, commands: Array<Command>,
|
|
|
216
224
|
}
|
|
217
225
|
}
|
|
218
226
|
|
|
219
|
-
function diffLayerPropertyChanges(before: any, after: any, commands: Array<Command>, layerId: string, klass:
|
|
227
|
+
function diffLayerPropertyChanges(before: any, after: any, commands: Array<Command>, layerId: string, klass: string | null | undefined, command: string) {
|
|
220
228
|
before = before || {};
|
|
221
229
|
after = after || {};
|
|
222
230
|
|
|
@@ -236,11 +244,22 @@ function diffLayerPropertyChanges(before: any, after: any, commands: Array<Comma
|
|
|
236
244
|
}
|
|
237
245
|
}
|
|
238
246
|
|
|
239
|
-
function pluckId<T
|
|
247
|
+
function pluckId<T extends {
|
|
248
|
+
id: string;
|
|
249
|
+
}>(item: T): string {
|
|
240
250
|
return item.id;
|
|
241
251
|
}
|
|
242
252
|
|
|
243
|
-
function indexById<T
|
|
253
|
+
function indexById<T extends {
|
|
254
|
+
id: string;
|
|
255
|
+
}>(
|
|
256
|
+
group: {
|
|
257
|
+
[key: string]: T;
|
|
258
|
+
},
|
|
259
|
+
item: T,
|
|
260
|
+
): {
|
|
261
|
+
[id: string]: T;
|
|
262
|
+
} {
|
|
244
263
|
group[item.id] = item;
|
|
245
264
|
return group;
|
|
246
265
|
}
|
|
@@ -254,14 +273,14 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
254
273
|
const afterOrder = after.map(pluckId);
|
|
255
274
|
|
|
256
275
|
// index of layer by id
|
|
257
|
-
const beforeIndex = before.reduce(indexById, {});
|
|
258
|
-
const afterIndex = after.reduce(indexById, {});
|
|
276
|
+
const beforeIndex = before.reduce<Record<string, any>>(indexById, {});
|
|
277
|
+
const afterIndex = after.reduce<Record<string, any>>(indexById, {});
|
|
259
278
|
|
|
260
279
|
// track order of layers as if they have been mutated
|
|
261
280
|
const tracker = beforeOrder.slice();
|
|
262
281
|
|
|
263
282
|
// layers that have been added do not need to be diffed
|
|
264
|
-
const clean:
|
|
283
|
+
const clean: any = Object.create(null);
|
|
265
284
|
|
|
266
285
|
let i, d, layerId, beforeLayer: LayerSpecification, afterLayer: LayerSpecification, insertBeforeLayerId, prop;
|
|
267
286
|
|
|
@@ -311,7 +330,6 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
311
330
|
|
|
312
331
|
// If source, source-layer, or type have changes, then remove the layer
|
|
313
332
|
// and add it back 'from scratch'.
|
|
314
|
-
// $FlowFixMe[prop-missing] - there is no `source-layer` in background and sky layers
|
|
315
333
|
if (!isEqual(beforeLayer.source, afterLayer.source) || !isEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !isEqual(beforeLayer.type, afterLayer.type)) {
|
|
316
334
|
commands.push({command: operations.removeLayer, args: [layerId]});
|
|
317
335
|
// we add the layer back at the same position it was already in, so
|
|
@@ -358,7 +376,7 @@ function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecifi
|
|
|
358
376
|
}
|
|
359
377
|
}
|
|
360
378
|
|
|
361
|
-
export function diffImports(before: Array<ImportSpecification> = [], after: Array<ImportSpecification> = [], commands: Array<Command>) {
|
|
379
|
+
export function diffImports(before: Array<ImportSpecification> | null | undefined = [], after: Array<ImportSpecification> | null | undefined = [], commands: Array<Command>) {
|
|
362
380
|
before = before || [];
|
|
363
381
|
after = after || [];
|
|
364
382
|
|
|
@@ -367,8 +385,8 @@ export function diffImports(before: Array<ImportSpecification> = [], after: Arra
|
|
|
367
385
|
const afterOrder = after.map(pluckId);
|
|
368
386
|
|
|
369
387
|
// index imports by id
|
|
370
|
-
const beforeIndex = before.reduce(indexById, {});
|
|
371
|
-
const afterIndex = after.reduce(indexById, {});
|
|
388
|
+
const beforeIndex = before.reduce<Record<string, any>>(indexById, {});
|
|
389
|
+
const afterIndex = after.reduce<Record<string, any>>(indexById, {});
|
|
372
390
|
|
|
373
391
|
// track order of imports as if they have been mutated
|
|
374
392
|
const tracker = beforeOrder.slice();
|
|
@@ -486,11 +504,16 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
|
|
|
486
504
|
if (!isEqual(before.camera, after.camera)) {
|
|
487
505
|
commands.push({command: operations.setCamera, args: [after.camera]});
|
|
488
506
|
}
|
|
507
|
+
if (!isEqual(before["color-theme"], after["color-theme"])) {
|
|
508
|
+
// Update this to setColorTheme after
|
|
509
|
+
// https://mapbox.atlassian.net/browse/GLJS-842 is implemented
|
|
510
|
+
return [{command: operations.setStyle, args: [after]}];
|
|
511
|
+
}
|
|
489
512
|
|
|
490
513
|
// Handle changes to `sources`
|
|
491
514
|
// If a source is to be removed, we also--before the removeSource
|
|
492
515
|
// command--need to remove all the style layers that depend on it.
|
|
493
|
-
const sourcesRemoved = {};
|
|
516
|
+
const sourcesRemoved: Record<string, any> = {};
|
|
494
517
|
|
|
495
518
|
// First collect the {add,remove}Source commands
|
|
496
519
|
const removeOrAddSourceCommands = [];
|
|
@@ -531,7 +554,7 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
|
|
|
531
554
|
|
|
532
555
|
// Handle changes to `layers`
|
|
533
556
|
diffLayers(beforeLayers, after.layers, commands);
|
|
534
|
-
} catch (e) {
|
|
557
|
+
} catch (e: any) {
|
|
535
558
|
// fall back to setStyle
|
|
536
559
|
console.warn('Unable to compute style diff:', e);
|
|
537
560
|
commands = [{command: operations.setStyle, args: [after]}];
|