@mapbox/mapbox-gl-style-spec 13.10.1 → 13.13.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +32 -4
  2. package/dist/index.es.js +2244 -2406
  3. package/dist/index.es.js.map +1 -1
  4. package/dist/index.js +2244 -2405
  5. package/dist/index.js.map +1 -1
  6. package/empty.js +29 -0
  7. package/error/parsing_error.js +5 -2
  8. package/error/validation_error.js +6 -3
  9. package/expression/compound_expression.js +5 -5
  10. package/expression/definitions/assertion.js +3 -4
  11. package/expression/definitions/at.js +3 -3
  12. package/expression/definitions/case.js +3 -6
  13. package/expression/definitions/coalesce.js +3 -4
  14. package/expression/definitions/coercion.js +3 -4
  15. package/expression/definitions/collator.js +5 -5
  16. package/expression/definitions/comparison.js +3 -3
  17. package/expression/definitions/format.js +3 -3
  18. package/expression/definitions/format_section_override.js +3 -4
  19. package/expression/definitions/image.js +6 -8
  20. package/expression/definitions/in.js +4 -4
  21. package/expression/definitions/index.js +4 -2
  22. package/expression/definitions/interpolate.js +3 -4
  23. package/expression/definitions/length.js +3 -3
  24. package/expression/definitions/let.js +3 -3
  25. package/expression/definitions/literal.js +2 -2
  26. package/expression/definitions/match.js +3 -6
  27. package/expression/definitions/number_format.js +3 -3
  28. package/expression/definitions/step.js +3 -4
  29. package/expression/definitions/var.js +2 -2
  30. package/expression/definitions/within.js +297 -0
  31. package/expression/evaluation_context.js +12 -1
  32. package/expression/expression.js +3 -5
  33. package/expression/index.js +24 -19
  34. package/expression/is_constant.js +5 -1
  35. package/expression/parsing_context.js +3 -0
  36. package/expression/scope.js +1 -1
  37. package/expression/types/resolved_image.js +2 -1
  38. package/feature_filter/convert.js +1 -1
  39. package/feature_filter/index.js +10 -5
  40. package/flow-typed/offscreen-canvas.js +9 -0
  41. package/flow-typed/vector-tile.js +2 -2
  42. package/function/convert.js +8 -2
  43. package/package.json +2 -1
  44. package/reference/v8.json +166 -168
  45. package/style-spec.js +3 -1
  46. package/types.js +7 -3
  47. package/validate/validate_expression.js +1 -1
  48. package/validate/validate_source.js +22 -2
  49. package/visit.js +2 -2
package/style-spec.js CHANGED
@@ -31,7 +31,7 @@ export type StylePropertySpecification = {
31
31
  type: 'enum',
32
32
  'property-type': ExpressionType,
33
33
  expression?: ExpressionSpecification,
34
- values: {[string]: {}},
34
+ values: {[_: string]: {}},
35
35
  transition: boolean,
36
36
  default?: string
37
37
  } | {
@@ -64,6 +64,7 @@ import latest from './reference/latest';
64
64
  import format from './format';
65
65
  import migrate from './migrate';
66
66
  import composite from './composite';
67
+ import derefLayers from './deref';
67
68
  import diff from './diff';
68
69
  import ValidationError from './error/validation_error';
69
70
  import ParsingError from './error/parsing_error';
@@ -103,6 +104,7 @@ export {
103
104
  format,
104
105
  migrate,
105
106
  composite,
107
+ derefLayers,
106
108
  diff,
107
109
  ValidationError,
108
110
  ParsingError,
package/types.js CHANGED
@@ -8,6 +8,8 @@ export type FormattedSpecification = string;
8
8
 
9
9
  export type ResolvedImageSpecification = string;
10
10
 
11
+ export type PromoteIdSpecification = {[_: string]: string} | string;
12
+
11
13
  export type FilterSpecification =
12
14
  | ['has', string]
13
15
  | ['!has', string]
@@ -64,7 +66,7 @@ export type StyleSpecification = {|
64
66
  "bearing"?: number,
65
67
  "pitch"?: number,
66
68
  "light"?: LightSpecification,
67
- "sources": {[string]: SourceSpecification},
69
+ "sources": {[_: string]: SourceSpecification},
68
70
  "sprite"?: string,
69
71
  "glyphs"?: string,
70
72
  "transition"?: TransitionSpecification,
@@ -86,7 +88,8 @@ export type VectorSourceSpecification = {
86
88
  "scheme"?: "xyz" | "tms",
87
89
  "minzoom"?: number,
88
90
  "maxzoom"?: number,
89
- "attribution"?: string
91
+ "attribution"?: string,
92
+ "promoteId"?: PromoteIdSpecification
90
93
  }
91
94
 
92
95
  export type RasterSourceSpecification = {
@@ -125,7 +128,8 @@ export type GeoJSONSourceSpecification = {|
125
128
  "clusterMaxZoom"?: number,
126
129
  "clusterProperties"?: mixed,
127
130
  "lineMetrics"?: boolean,
128
- "generateId"?: boolean
131
+ "generateId"?: boolean,
132
+ "promoteId"?: PromoteIdSpecification
129
133
  |}
130
134
 
131
135
  export type VideoSourceSpecification = {|
@@ -17,7 +17,7 @@ export default function validateExpression(options: any): Array<ValidationError>
17
17
  const expressionObj = (expression.value: any).expression || (expression.value: any)._styleExpression.expression;
18
18
 
19
19
  if (options.expressionContext === 'property' && (options.propertyKey === 'text-font') &&
20
- expressionObj.possibleOutputs().indexOf(undefined) !== -1) {
20
+ !expressionObj.outputDefined()) {
21
21
  return [new ValidationError(options.key, options.value, `Invalid data expression for "${options.propertyKey}". Output values must be contained as literals within the expression.`)];
22
22
  }
23
23
 
@@ -4,6 +4,12 @@ import {unbundle} from '../util/unbundle_jsonlint';
4
4
  import validateObject from './validate_object';
5
5
  import validateEnum from './validate_enum';
6
6
  import validateExpression from './validate_expression';
7
+ import validateString from './validate_string';
8
+ import getType from '../util/get_type';
9
+
10
+ const objectElementValidators = {
11
+ promoteId: validatePromoteId
12
+ };
7
13
 
8
14
  export default function validateSource(options) {
9
15
  const value = options.value;
@@ -27,7 +33,8 @@ export default function validateSource(options) {
27
33
  value,
28
34
  valueSpec: styleSpec[`source_${type.replace('-', '_')}`],
29
35
  style: options.style,
30
- styleSpec
36
+ styleSpec,
37
+ objectElementValidators
31
38
  });
32
39
  return errors;
33
40
 
@@ -37,7 +44,8 @@ export default function validateSource(options) {
37
44
  value,
38
45
  valueSpec: styleSpec.source_geojson,
39
46
  style,
40
- styleSpec
47
+ styleSpec,
48
+ objectElementValidators
41
49
  });
42
50
  if (value.cluster) {
43
51
  for (const prop in value.clusterProperties) {
@@ -89,3 +97,15 @@ export default function validateSource(options) {
89
97
  });
90
98
  }
91
99
  }
100
+
101
+ function validatePromoteId({key, value}) {
102
+ if (getType(value) === 'string') {
103
+ return validateString({key, value});
104
+ } else {
105
+ const errors = [];
106
+ for (const prop in value) {
107
+ errors.push(...validateString({key: `${key}.${prop}`, value: value[prop]}));
108
+ }
109
+ return errors;
110
+ }
111
+ }
package/visit.js CHANGED
@@ -25,13 +25,13 @@ function getPropertyReference(propertyName): StylePropertySpecification {
25
25
  return (null: any);
26
26
  }
27
27
 
28
- export function eachSource(style: StyleSpecification, callback: (SourceSpecification) => void) {
28
+ export function eachSource(style: StyleSpecification, callback: (_: SourceSpecification) => void) {
29
29
  for (const k in style.sources) {
30
30
  callback(style.sources[k]);
31
31
  }
32
32
  }
33
33
 
34
- export function eachLayer(style: StyleSpecification, callback: (LayerSpecification) => void) {
34
+ export function eachLayer(style: StyleSpecification, callback: (_: LayerSpecification) => void) {
35
35
  for (const layer of style.layers) {
36
36
  callback(layer);
37
37
  }