@mapbox/mapbox-gl-style-spec 13.28.0-beta.1 → 14.0.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/CHANGELOG.md +0 -11
- package/bin/gl-style-composite.js +2 -2
- package/bin/gl-style-format.js +2 -2
- package/bin/gl-style-migrate.js +2 -2
- package/bin/gl-style-validate.js +2 -2
- package/data/extent.js +18 -0
- package/deref.js +1 -1
- package/diff.js +36 -15
- package/dist/index.cjs +5810 -1995
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +5808 -1991
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.js +2 -1
- package/expression/definitions/assertion.js +2 -2
- package/expression/definitions/coercion.js +54 -15
- package/expression/definitions/comparison.js +2 -0
- package/expression/definitions/distance.js +597 -0
- package/expression/definitions/format.js +2 -2
- package/expression/definitions/image.js +34 -14
- package/expression/definitions/index.js +122 -8
- package/expression/definitions/interpolate.js +1 -1
- package/expression/definitions/match.js +2 -2
- package/expression/definitions/within.js +21 -92
- package/expression/evaluation_context.js +12 -1
- package/expression/index.js +74 -43
- package/expression/is_constant.js +19 -1
- package/expression/parsing_context.js +20 -16
- package/expression/types/formatted.js +2 -2
- package/expression/types/resolved_image.js +19 -8
- package/expression/types.js +2 -1
- package/expression/values.js +25 -0
- package/feature_filter/convert.js +1 -1
- package/feature_filter/index.js +4 -4
- package/flow-typed/cheap-ruler.js +25 -0
- package/flow-typed/geojson.js +8 -7
- package/flow-typed/gl-matrix.js +4 -2
- package/flow-typed/kdbush.js +9 -0
- package/function/convert.js +23 -12
- package/group_by_layout.js +2 -2
- package/migrate/expressions.js +3 -0
- package/package.json +5 -2
- package/reference/v8.json +1772 -112
- package/style-spec.js +4 -3
- package/types.js +190 -24
- package/util/color.js +31 -0
- package/util/geometry_util.js +145 -0
- package/util/properties.js +10 -2
- package/util/random.js +12 -0
- package/validate/validate.js +17 -7
- package/validate/validate_array.js +1 -1
- package/validate/validate_filter.js +4 -12
- package/validate/validate_function.js +2 -2
- package/validate/validate_import.js +31 -0
- package/validate/validate_layer.js +3 -2
- package/validate/validate_lights.js +84 -0
- package/validate/validate_model.js +38 -0
- package/validate/validate_property.js +17 -3
- package/validate/validate_source.js +3 -2
- package/validate/validate_style.js +29 -0
- package/validate_mapbox_api_supported.js +55 -11
- package/validate_style.js +4 -0
- package/validate_style.min.js +11 -19
- package/visit.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
## 13.28.0-beta.1
|
|
2
|
-
|
|
3
|
-
### Features ✨
|
|
4
|
-
|
|
5
|
-
* Add optional spec parameter to `validateMapboxApiSupported` ([#12448](https://github.com/mapbox/mapbox-gl-js/pull/12448))
|
|
6
|
-
* Derive source type values from spec ([#12449](https://github.com/mapbox/mapbox-gl-js/pull/12449))
|
|
7
|
-
|
|
8
|
-
### Bug fixes 🐞
|
|
9
|
-
|
|
10
|
-
* Fix incorrect transition flag in *-pattern and line-dasharray properties ([#12372](https://github.com/mapbox/mapbox-gl-js/pull/12372))
|
|
11
|
-
|
|
12
1
|
## 13.27.0
|
|
13
2
|
|
|
14
3
|
### Bug fixes 🐞
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import minimist from 'minimist';
|
|
8
8
|
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
9
|
+
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec-private$'] }] */
|
|
10
10
|
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
|
-
import {format, composite} from '@mapbox/mapbox-gl-style-spec';
|
|
11
|
+
import {format, composite} from '@mapbox/mapbox-gl-style-spec-private';
|
|
12
12
|
|
|
13
13
|
const argv = minimist(process.argv.slice(2));
|
|
14
14
|
|
package/bin/gl-style-format.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import minimist from 'minimist';
|
|
8
8
|
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
9
|
+
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec-private$'] }] */
|
|
10
10
|
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
|
-
import {format} from '@mapbox/mapbox-gl-style-spec';
|
|
11
|
+
import {format} from '@mapbox/mapbox-gl-style-spec-private';
|
|
12
12
|
|
|
13
13
|
const argv = minimist(process.argv.slice(2));
|
|
14
14
|
|
package/bin/gl-style-migrate.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import fs from 'fs';
|
|
7
7
|
import minimist from 'minimist';
|
|
8
8
|
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
9
|
+
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec-private$'] }] */
|
|
10
10
|
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
|
-
import {format, migrate} from '@mapbox/mapbox-gl-style-spec';
|
|
11
|
+
import {format, migrate} from '@mapbox/mapbox-gl-style-spec-private';
|
|
12
12
|
|
|
13
13
|
const argv = minimist(process.argv.slice(2));
|
|
14
14
|
|
package/bin/gl-style-validate.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
import rw from 'rw';
|
|
7
7
|
import minimist from 'minimist';
|
|
8
8
|
|
|
9
|
-
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
|
|
9
|
+
/* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec-private$'] }] */
|
|
10
10
|
/* $FlowFixMe[cannot-resolve-module] */
|
|
11
|
-
import {validate, validateMapboxApiSupported} from '@mapbox/mapbox-gl-style-spec';
|
|
11
|
+
import {validate, validateMapboxApiSupported} from '@mapbox/mapbox-gl-style-spec-private';
|
|
12
12
|
|
|
13
13
|
const argv = minimist(process.argv.slice(2), {
|
|
14
14
|
boolean: ['json', 'mapbox-api-supported'],
|
package/data/extent.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The maximum value of a coordinate in the internal tile coordinate system. Coordinates of
|
|
5
|
+
* all source features normalized to this extent upon load.
|
|
6
|
+
*
|
|
7
|
+
* The value is a consequence of the following:
|
|
8
|
+
*
|
|
9
|
+
* * Vertex buffer store positions as signed 16 bit integers.
|
|
10
|
+
* * One bit is lost for signedness to support tile buffers.
|
|
11
|
+
* * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.
|
|
12
|
+
* * One bit is lost to support features extending past the extent on the right edge of the tile.
|
|
13
|
+
* * This leaves us with 2^13 = 8192
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @readonly
|
|
17
|
+
*/
|
|
18
|
+
export default 8192;
|
package/deref.js
CHANGED
|
@@ -38,7 +38,7 @@ function deref(layer: LayerSpecification, parent: LayerSpecification): LayerSpec
|
|
|
38
38
|
export default function derefLayers(layers: Array<LayerSpecification>): Array<LayerSpecification> {
|
|
39
39
|
layers = layers.slice();
|
|
40
40
|
|
|
41
|
-
const map = Object.create(null);
|
|
41
|
+
const map: Object = Object.create(null);
|
|
42
42
|
for (let i = 0; i < layers.length; i++) {
|
|
43
43
|
map[layers[i].id] = layers[i];
|
|
44
44
|
}
|
package/diff.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import isEqual from './util/deep_equal.js';
|
|
4
4
|
|
|
5
|
-
import type {StyleSpecification} from './types.js';
|
|
5
|
+
import type {StyleSpecification, SourceSpecification, LayerSpecification} from './types.js';
|
|
6
|
+
|
|
7
|
+
type Sources = { [string]: SourceSpecification };
|
|
6
8
|
|
|
7
9
|
type Command = {
|
|
8
10
|
command: string;
|
|
@@ -116,27 +118,37 @@ export const operations: {[_: string]: string} = {
|
|
|
116
118
|
*/
|
|
117
119
|
setFog: 'setFog',
|
|
118
120
|
|
|
121
|
+
/*
|
|
122
|
+
* { command: 'setCamera', args: [cameraProperties] }
|
|
123
|
+
*/
|
|
124
|
+
setCamera: 'setCamera',
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* { command: 'setLights', args: [{light-3d},...] }
|
|
128
|
+
*/
|
|
129
|
+
setLights: 'setLights',
|
|
130
|
+
|
|
119
131
|
/*
|
|
120
132
|
* { command: 'setProjection', args: [projectionProperties] }
|
|
121
133
|
*/
|
|
122
134
|
setProjection: 'setProjection'
|
|
123
135
|
};
|
|
124
136
|
|
|
125
|
-
function addSource(sourceId, after, commands) {
|
|
137
|
+
function addSource(sourceId: string, after: Sources, commands: Array<Command>) {
|
|
126
138
|
commands.push({command: operations.addSource, args: [sourceId, after[sourceId]]});
|
|
127
139
|
}
|
|
128
140
|
|
|
129
|
-
function removeSource(sourceId, commands
|
|
141
|
+
function removeSource(sourceId: string, commands: Array<Command>, sourcesRemoved: {[string]: true}) {
|
|
130
142
|
commands.push({command: operations.removeSource, args: [sourceId]});
|
|
131
143
|
sourcesRemoved[sourceId] = true;
|
|
132
144
|
}
|
|
133
145
|
|
|
134
|
-
function updateSource(sourceId, after, commands
|
|
146
|
+
function updateSource(sourceId: string, after: Sources, commands: Array<Command>, sourcesRemoved: {[string]: true}) {
|
|
135
147
|
removeSource(sourceId, commands, sourcesRemoved);
|
|
136
148
|
addSource(sourceId, after, commands);
|
|
137
149
|
}
|
|
138
150
|
|
|
139
|
-
function canUpdateGeoJSON(before, after, sourceId) {
|
|
151
|
+
function canUpdateGeoJSON(before: Sources, after: Sources, sourceId: string) {
|
|
140
152
|
let prop;
|
|
141
153
|
for (prop in before[sourceId]) {
|
|
142
154
|
if (!before[sourceId].hasOwnProperty(prop)) continue;
|
|
@@ -153,7 +165,7 @@ function canUpdateGeoJSON(before, after, sourceId) {
|
|
|
153
165
|
return true;
|
|
154
166
|
}
|
|
155
167
|
|
|
156
|
-
function diffSources(before, after, commands
|
|
168
|
+
function diffSources(before: Sources, after: Sources, commands: Array<Command>, sourcesRemoved: {[string]: true}) {
|
|
157
169
|
before = before || {};
|
|
158
170
|
after = after || {};
|
|
159
171
|
|
|
@@ -170,11 +182,12 @@ function diffSources(before, after, commands, sourcesRemoved) {
|
|
|
170
182
|
// look for sources to add/update
|
|
171
183
|
for (sourceId in after) {
|
|
172
184
|
if (!after.hasOwnProperty(sourceId)) continue;
|
|
185
|
+
const source = after[sourceId];
|
|
173
186
|
if (!before.hasOwnProperty(sourceId)) {
|
|
174
187
|
addSource(sourceId, after, commands);
|
|
175
|
-
} else if (!isEqual(before[sourceId],
|
|
176
|
-
if (before[sourceId].type === 'geojson' &&
|
|
177
|
-
commands.push({command: operations.setGeoJSONSourceData, args: [sourceId,
|
|
188
|
+
} else if (!isEqual(before[sourceId], source)) {
|
|
189
|
+
if (before[sourceId].type === 'geojson' && source.type === 'geojson' && canUpdateGeoJSON(before, after, sourceId)) {
|
|
190
|
+
commands.push({command: operations.setGeoJSONSourceData, args: [sourceId, source.data]});
|
|
178
191
|
} else {
|
|
179
192
|
// no update command, must remove then add
|
|
180
193
|
updateSource(sourceId, after, commands, sourcesRemoved);
|
|
@@ -183,7 +196,7 @@ function diffSources(before, after, commands, sourcesRemoved) {
|
|
|
183
196
|
}
|
|
184
197
|
}
|
|
185
198
|
|
|
186
|
-
function diffLayerPropertyChanges(before, after, commands
|
|
199
|
+
function diffLayerPropertyChanges(before: any, after: any, commands: Array<Command>, layerId: string, klass: ?string, command: string) {
|
|
187
200
|
before = before || {};
|
|
188
201
|
after = after || {};
|
|
189
202
|
|
|
@@ -203,15 +216,16 @@ function diffLayerPropertyChanges(before, after, commands, layerId, klass, comma
|
|
|
203
216
|
}
|
|
204
217
|
}
|
|
205
218
|
|
|
206
|
-
function pluckId(layer) {
|
|
219
|
+
function pluckId(layer: LayerSpecification) {
|
|
207
220
|
return layer.id;
|
|
208
221
|
}
|
|
209
|
-
|
|
222
|
+
|
|
223
|
+
function indexById(group: {[string]: LayerSpecification}, layer: LayerSpecification) {
|
|
210
224
|
group[layer.id] = layer;
|
|
211
225
|
return group;
|
|
212
226
|
}
|
|
213
227
|
|
|
214
|
-
function diffLayers(before
|
|
228
|
+
function diffLayers(before: Array<LayerSpecification>, after: Array<LayerSpecification>, commands: Array<Command>) {
|
|
215
229
|
before = before || [];
|
|
216
230
|
after = after || [];
|
|
217
231
|
|
|
@@ -227,9 +241,9 @@ function diffLayers(before, after, commands) {
|
|
|
227
241
|
const tracker = beforeOrder.slice();
|
|
228
242
|
|
|
229
243
|
// layers that have been added do not need to be diffed
|
|
230
|
-
const clean = Object.create(null);
|
|
244
|
+
const clean: Object = Object.create(null);
|
|
231
245
|
|
|
232
|
-
let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;
|
|
246
|
+
let i, d, layerId, beforeLayer: LayerSpecification, afterLayer: LayerSpecification, insertBeforeLayerId, prop;
|
|
233
247
|
|
|
234
248
|
// remove layers
|
|
235
249
|
for (i = 0, d = 0; i < beforeOrder.length; i++) {
|
|
@@ -277,6 +291,7 @@ function diffLayers(before, after, commands) {
|
|
|
277
291
|
|
|
278
292
|
// If source, source-layer, or type have changes, then remove the layer
|
|
279
293
|
// and add it back 'from scratch'.
|
|
294
|
+
// $FlowFixMe[prop-missing] - there is no `source-layer` in background and sky layers
|
|
280
295
|
if (!isEqual(beforeLayer.source, afterLayer.source) || !isEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !isEqual(beforeLayer.type, afterLayer.type)) {
|
|
281
296
|
commands.push({command: operations.removeLayer, args: [layerId]});
|
|
282
297
|
// we add the layer back at the same position it was already in, so
|
|
@@ -378,6 +393,12 @@ export default function diffStyles(before: StyleSpecification, after: StyleSpeci
|
|
|
378
393
|
if (!isEqual(before.projection, after.projection)) {
|
|
379
394
|
commands.push({command: operations.setProjection, args: [after.projection]});
|
|
380
395
|
}
|
|
396
|
+
if (!isEqual(before.lights, after.lights)) {
|
|
397
|
+
commands.push({command: operations.setLights, args: [after.lights]});
|
|
398
|
+
}
|
|
399
|
+
if (!isEqual(before.camera, after.camera)) {
|
|
400
|
+
commands.push({command: operations.setCamera, args: [after.camera]});
|
|
401
|
+
}
|
|
381
402
|
|
|
382
403
|
// Handle changes to `sources`
|
|
383
404
|
// If a source is to be removed, we also--before the removeSource
|