@mapbox/mapbox-gl-style-spec 13.28.0 → 14.0.0-beta.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/LICENSE.txt +47 -0
- package/README.md +7 -0
- package/data/extent.js +18 -0
- package/deref.js +1 -1
- package/diff.js +36 -15
- package/dist/index.cjs +5839 -2015
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +5837 -2011
- 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 +6 -3
- package/reference/v8.json +1771 -114
- 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 +18 -4
- 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/LICENSE.txt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Copyright © 2021 - 2023 Mapbox, Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
The software and files in this repository (collectively, "Software") are
|
|
4
|
+
licensed under the Mapbox TOS for use only with the relevant Mapbox product(s)
|
|
5
|
+
listed at www.mapbox.com/pricing. This license allows developers with a
|
|
6
|
+
current active Mapbox account to use and modify the authorized portions of the
|
|
7
|
+
Software as needed for use only with the relevant Mapbox product(s) through
|
|
8
|
+
their Mapbox account in accordance with the Mapbox TOS. This license
|
|
9
|
+
terminates automatically if a developer no longer has a Mapbox account in good
|
|
10
|
+
standing or breaches the Mapbox TOS. For the license terms, please see the
|
|
11
|
+
Mapbox TOS at https://www.mapbox.com/legal/tos/ which incorporates the Mapbox
|
|
12
|
+
Product Terms at www.mapbox.com/legal/service-terms. If this Software is a
|
|
13
|
+
SDK, modifications that change or interfere with marked portions of the code
|
|
14
|
+
related to billing, accounting, or data collection are not authorized and the
|
|
15
|
+
SDK sends limited de-identified location and usage data which is used in
|
|
16
|
+
accordance with the Mapbox TOS. [Updated 2023-01]
|
|
17
|
+
|
|
18
|
+
-------------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
Contains code from mapbox-gl-js v1.13 and earlier
|
|
21
|
+
|
|
22
|
+
Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license
|
|
23
|
+
|
|
24
|
+
Copyright (c) 2020, Mapbox
|
|
25
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
26
|
+
are permitted provided that the following conditions are met:
|
|
27
|
+
|
|
28
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
29
|
+
this list of conditions and the following disclaimer.
|
|
30
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
31
|
+
this list of conditions and the following disclaimer in the documentation
|
|
32
|
+
and/or other materials provided with the distribution.
|
|
33
|
+
* Neither the name of Mapbox GL JS nor the names of its contributors
|
|
34
|
+
may be used to endorse or promote products derived from this software
|
|
35
|
+
without specific prior written permission.
|
|
36
|
+
|
|
37
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
38
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
39
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
40
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
41
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
42
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
43
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
44
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
45
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
46
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
47
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -57,3 +57,10 @@ Will validate the given style JSON and print errors to stdout. Provide a
|
|
|
57
57
|
`--json` flag to get JSON output.
|
|
58
58
|
|
|
59
59
|
To validate that a style can be uploaded to the Mapbox Styles API, use the `--mapbox-api-supported` flag.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
This project uses the standard Mapbox license, which is designed to provide flexibility for our customers and a sustained foundation for the development of our technology. Please consult LICENSE.txt for its specific details.
|
|
64
|
+
|
|
65
|
+
We understand that the Mapbox Style Specification embodied in this module may be useful in a wide variety of projects. If you are interested in using this module in a manner not expressly permitted by its license, please do not hesitate to contact legal@mapbox.com with details of what you have in mind.
|
|
66
|
+
```
|
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
|