@mapbox/mapbox-gl-style-spec 13.24.0-alpha.6 → 13.24.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.
Files changed (72) hide show
  1. package/.eslintrc +10 -0
  2. package/CHANGELOG.md +10 -4
  3. package/bin/gl-style-composite.js +6 -2
  4. package/bin/gl-style-format.js +6 -2
  5. package/bin/gl-style-migrate.js +6 -2
  6. package/bin/gl-style-validate.js +5 -1
  7. package/dist/index.cjs +41 -23
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.es.js +41 -23
  10. package/dist/index.es.js.map +1 -1
  11. package/expression/compound_expression.js +2 -2
  12. package/expression/definitions/assertion.js +3 -3
  13. package/expression/definitions/at.js +5 -5
  14. package/expression/definitions/case.js +4 -4
  15. package/expression/definitions/coalesce.js +4 -4
  16. package/expression/definitions/coercion.js +3 -3
  17. package/expression/definitions/collator.js +4 -4
  18. package/expression/definitions/comparison.js +22 -22
  19. package/expression/definitions/format.js +4 -4
  20. package/expression/definitions/image.js +4 -4
  21. package/expression/definitions/in.js +5 -5
  22. package/expression/definitions/index_of.js +5 -5
  23. package/expression/definitions/interpolate.js +6 -5
  24. package/expression/definitions/length.js +5 -5
  25. package/expression/definitions/let.js +5 -5
  26. package/expression/definitions/literal.js +5 -5
  27. package/expression/definitions/match.js +4 -4
  28. package/expression/definitions/number_format.js +4 -4
  29. package/expression/definitions/slice.js +5 -5
  30. package/expression/definitions/step.js +4 -4
  31. package/expression/definitions/var.js +4 -4
  32. package/expression/definitions/within.js +16 -8
  33. package/expression/evaluation_context.js +8 -8
  34. package/expression/expression.js +1 -1
  35. package/expression/index.js +4 -4
  36. package/expression/is_constant.js +3 -3
  37. package/expression/parsing_context.js +1 -1
  38. package/expression/runtime_error.js +1 -1
  39. package/expression/scope.js +1 -1
  40. package/expression/stops.js +1 -1
  41. package/expression/values.js +1 -1
  42. package/feature_filter/index.js +1 -1
  43. package/function/convert.js +4 -4
  44. package/migrate/expressions.js +1 -1
  45. package/package.json +1 -1
  46. package/reference/latest.js +4 -0
  47. package/reference/v8.json +1 -4
  48. package/types.js +1 -1
  49. package/validate/validate.js +13 -1
  50. package/validate/validate_array.js +10 -2
  51. package/validate/validate_boolean.js +4 -1
  52. package/validate/validate_color.js +4 -1
  53. package/validate/validate_enum.js +4 -1
  54. package/validate/validate_expression.js +5 -2
  55. package/validate/validate_filter.js +12 -4
  56. package/validate/validate_fog.js +4 -1
  57. package/validate/validate_formatted.js +5 -1
  58. package/validate/validate_function.js +24 -15
  59. package/validate/validate_glyphs_url.js +4 -1
  60. package/validate/validate_image.js +5 -1
  61. package/validate/validate_layer.js +15 -2
  62. package/validate/validate_layout_property.js +5 -1
  63. package/validate/validate_light.js +4 -1
  64. package/validate/validate_number.js +8 -1
  65. package/validate/validate_object.js +12 -2
  66. package/validate/validate_paint_property.js +5 -1
  67. package/validate/validate_projection.js +5 -1
  68. package/validate/validate_property.js +9 -1
  69. package/validate/validate_source.js +4 -1
  70. package/validate/validate_string.js +4 -1
  71. package/validate/validate_terrain.js +5 -2
  72. package/validate_style.min.js +1 -1
package/.eslintrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "overrides": [
3
+ {
4
+ "files": ["rollup.config.js", "test.js"],
5
+ "rules": {
6
+ "flowtype/require-valid-file-annotation": "off"
7
+ }
8
+ }
9
+ ]
10
+ }
package/CHANGELOG.md CHANGED
@@ -1,23 +1,29 @@
1
- # 13.23.1
1
+ ## 13.24.0-beta.1
2
+ ### 🐞 Bug fixes
3
+
4
+ * Fix error on `gl-style-validate` script. ([#11538](https://github.com/mapbox/mapbox-gl-js/pull/11538))
5
+ * Allow the second argument to the `in` expression operator to be an empty string. ([#11547](https://github.com/mapbox/mapbox-gl-js/pull/11547))
6
+ * Fix error on some valid `filter` expressions. ([#11475](https://github.com/mapbox/mapbox-gl-js/pull/11475))
2
7
 
8
+ ## 13.23.1
3
9
  ### ✨ Features and improvements
4
10
 
5
11
  * Improve `coalesce` expressions to return a `ResolvedImage` when images are missing. ([#11371](https://github.com/mapbox/mapbox-gl-js/pull/11371))
6
12
 
7
- # 13.23.0
13
+ ## 13.23.0
8
14
 
9
15
  ### ✨ Features and improvements
10
16
 
11
17
  * Add a `projection` root property that allows a non-mercator projection to be set as a style's default projection. ([#11124](https://github.com/mapbox/mapbox-gl-js/pull/11124))
12
18
  * Add support for using `["pitch"]` and `["distance-from-camera"]` expressions within the `filter` of a symbol layer. ([#10795](https://github.com/mapbox/mapbox-gl-js/pull/10795))
13
19
 
14
- # 13.22.0
20
+ ## 13.22.0
15
21
 
16
22
  ### ✨ Features and improvements
17
23
 
18
24
  * Added `protected` field to mapbox-api-supported validation. ([#10968](https://github.com/mapbox/mapbox-gl-js/pull/10968))
19
25
 
20
- # 13.21.0
26
+ ## 13.21.0
21
27
 
22
28
  ### ✨ Features and improvements
23
29
  * Add support for `text-writing-mode` property when using `symbol-placement: line` text labels. ([#10647](https://github.com/mapbox/mapbox-gl-js/pull/10647))
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // @flow
2
4
  /* eslint-disable no-process-exit */
3
- /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
4
5
 
5
6
  import fs from 'fs';
6
7
  import minimist from 'minimist';
8
+
9
+ /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
10
+ /* $FlowFixMe[cannot-resolve-module] */
7
11
  import {format, composite} from '@mapbox/mapbox-gl-style-spec';
8
12
 
9
13
  const argv = minimist(process.argv.slice(2));
@@ -13,7 +17,7 @@ if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
13
17
  process.exit(0);
14
18
  }
15
19
 
16
- console.log(format(composite(JSON.parse(fs.readFileSync(argv._[0])))));
20
+ console.log(format(composite(JSON.parse(fs.readFileSync(argv._[0]).toString()))));
17
21
 
18
22
  function help() {
19
23
  console.log('usage:');
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // @flow
2
4
  /* eslint-disable no-process-exit */
3
- /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
4
5
 
5
6
  import fs from 'fs';
6
7
  import minimist from 'minimist';
8
+
9
+ /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
10
+ /* $FlowFixMe[cannot-resolve-module] */
7
11
  import {format} from '@mapbox/mapbox-gl-style-spec';
8
12
 
9
13
  const argv = minimist(process.argv.slice(2));
@@ -13,7 +17,7 @@ if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
13
17
  process.exit(0);
14
18
  }
15
19
 
16
- console.log(format(JSON.parse(fs.readFileSync(argv._[0])), argv.space));
20
+ console.log(format(JSON.parse(fs.readFileSync(argv._[0]).toString()), argv.space));
17
21
 
18
22
  function help() {
19
23
  console.log('usage:');
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // @flow
2
4
  /* eslint-disable no-process-exit */
3
- /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
4
5
 
5
6
  import fs from 'fs';
6
7
  import minimist from 'minimist';
8
+
9
+ /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
10
+ /* $FlowFixMe[cannot-resolve-module] */
7
11
  import {format, migrate} from '@mapbox/mapbox-gl-style-spec';
8
12
 
9
13
  const argv = minimist(process.argv.slice(2));
@@ -13,7 +17,7 @@ if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
13
17
  process.exit(0);
14
18
  }
15
19
 
16
- console.log(format(migrate(JSON.parse(fs.readFileSync(argv._[0])))));
20
+ console.log(format(migrate(JSON.parse(fs.readFileSync(argv._[0]).toString()))));
17
21
 
18
22
  function help() {
19
23
  console.log('usage:');
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env node
2
+
3
+ // @flow
2
4
  /* eslint-disable no-process-exit */
3
- /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
4
5
 
5
6
  import rw from 'rw';
6
7
  import minimist from 'minimist';
8
+
9
+ /* eslint import/no-unresolved: [error, { ignore: ['^@mapbox/mapbox-gl-style-spec$'] }] */
10
+ /* $FlowFixMe[cannot-resolve-module] */
7
11
  import {validate, validateMapboxApiSupported} from '@mapbox/mapbox-gl-style-spec';
8
12
 
9
13
  const argv = minimist(process.argv.slice(2), {
package/dist/index.cjs CHANGED
@@ -101,7 +101,7 @@
101
101
  },
102
102
  projection: {
103
103
  type: "projection",
104
- doc: "The projection the map should be rendered in. Supported projections are Albers, Equal Earth, Equirectangular (WGS84), Lambert conformal conic, Mercator, Natural Earth, Globe, and Winkel Tripel. Terrain, fog, sky and CustomLayerInterface are not supported for projections other than mercator.",
104
+ doc: "The projection the map should be rendered in. Supported projections are Albers, Equal Earth, Equirectangular (WGS84), Lambert conformal conic, Mercator, Natural Earth, and Winkel Tripel. Terrain, fog, sky and CustomLayerInterface are not supported for projections other than mercator.",
105
105
  example: {
106
106
  name: "albers",
107
107
  center: [
@@ -3922,9 +3922,6 @@
3922
3922
  },
3923
3923
  winkelTripel: {
3924
3924
  doc: "A Winkel Tripel projection."
3925
- },
3926
- globe: {
3927
- doc: "A globe projection."
3928
3925
  }
3929
3926
  },
3930
3927
  "default": "mercator",
@@ -9278,7 +9275,7 @@
9278
9275
  this.featureDistanceData = null;
9279
9276
  }
9280
9277
  id() {
9281
- return this.feature && 'id' in this.feature ? this.feature.id : null;
9278
+ return this.feature && 'id' in this.feature && this.feature.id ? this.feature.id : null;
9282
9279
  }
9283
9280
  geometryType() {
9284
9281
  return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;
@@ -9631,6 +9628,8 @@
9631
9628
  canonical.y * EXTENT
9632
9629
  ];
9633
9630
  const tilePoints = [];
9631
+ if (!geometry)
9632
+ return tilePoints;
9634
9633
  for (const points of geometry) {
9635
9634
  for (const point of points) {
9636
9635
  const p = [
@@ -9650,6 +9649,8 @@
9650
9649
  canonical.y * EXTENT
9651
9650
  ];
9652
9651
  const tileLines = [];
9652
+ if (!geometry)
9653
+ return tileLines;
9653
9654
  for (const line of geometry) {
9654
9655
  const tileLine = [];
9655
9656
  for (const point of line) {
@@ -9686,6 +9687,9 @@
9686
9687
  -Infinity
9687
9688
  ];
9688
9689
  const canonical = ctx.canonicalID();
9690
+ if (!canonical) {
9691
+ return false;
9692
+ }
9689
9693
  if (polygonGeometry.type === 'Polygon') {
9690
9694
  const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);
9691
9695
  const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);
@@ -9722,6 +9726,9 @@
9722
9726
  -Infinity
9723
9727
  ];
9724
9728
  const canonical = ctx.canonicalID();
9729
+ if (!canonical) {
9730
+ return false;
9731
+ }
9725
9732
  if (polygonGeometry.type === 'Polygon') {
9726
9733
  const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);
9727
9734
  const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);
@@ -12143,7 +12150,7 @@
12143
12150
  this._evaluator.globals = globals;
12144
12151
  this._evaluator.feature = feature;
12145
12152
  this._evaluator.featureState = featureState;
12146
- this._evaluator.canonical = canonical;
12153
+ this._evaluator.canonical = canonical || null;
12147
12154
  this._evaluator.availableImages = availableImages || null;
12148
12155
  this._evaluator.formattedSection = formattedSection;
12149
12156
  this._evaluator.featureTileCoord = featureTileCoord || null;
@@ -12154,7 +12161,7 @@
12154
12161
  this._evaluator.globals = globals;
12155
12162
  this._evaluator.feature = feature || null;
12156
12163
  this._evaluator.featureState = featureState || null;
12157
- this._evaluator.canonical = canonical;
12164
+ this._evaluator.canonical = canonical || null;
12158
12165
  this._evaluator.availableImages = availableImages || null;
12159
12166
  this._evaluator.formattedSection = formattedSection || null;
12160
12167
  this._evaluator.featureTileCoord = featureTileCoord || null;
@@ -13701,7 +13708,8 @@ ${ JSON.stringify(filterExp, null, 2) }
13701
13708
  validateElement = elementValidators['*'];
13702
13709
  } else if (elementSpecs['*']) {
13703
13710
  validateElement = validate;
13704
- } else {
13711
+ }
13712
+ if (!validateElement) {
13705
13713
  errors.push(new ValidationError(key, object[objectKey], `unknown property "${ objectKey }"`));
13706
13714
  continue;
13707
13715
  }
@@ -13746,7 +13754,8 @@ ${ JSON.stringify(filterExp, null, 2) }
13746
13754
  'type': arraySpec.value,
13747
13755
  'values': arraySpec.values,
13748
13756
  'minimum': arraySpec.minimum,
13749
- 'maximum': arraySpec.maximum
13757
+ 'maximum': arraySpec.maximum,
13758
+ function: undefined
13750
13759
  };
13751
13760
  if (styleSpec.$version < 7) {
13752
13761
  arrayElementSpec.function = arraySpec.function;
@@ -13883,11 +13892,15 @@ ${ JSON.stringify(filterExp, null, 2) }
13883
13892
  if (value[0].value === undefined) {
13884
13893
  return [new ValidationError(key, value, 'object stop key must have value')];
13885
13894
  }
13886
- if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {
13895
+ const nextStopDomainZoom = unbundle(value[0].zoom);
13896
+ if (typeof nextStopDomainZoom !== 'number') {
13897
+ return [new ValidationError(key, value[0].zoom, 'stop zoom values must be numbers')];
13898
+ }
13899
+ if (previousStopDomainZoom && previousStopDomainZoom > nextStopDomainZoom) {
13887
13900
  return [new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')];
13888
13901
  }
13889
- if (unbundle(value[0].zoom) !== previousStopDomainZoom) {
13890
- previousStopDomainZoom = unbundle(value[0].zoom);
13902
+ if (nextStopDomainZoom !== previousStopDomainZoom) {
13903
+ previousStopDomainZoom = nextStopDomainZoom;
13891
13904
  previousStopDomainValue = undefined;
13892
13905
  stopDomainValues = {};
13893
13906
  }
@@ -13931,7 +13944,7 @@ ${ JSON.stringify(filterExp, null, 2) }
13931
13944
  } else if (type !== stopKeyType) {
13932
13945
  return [new ValidationError(options.key, reportValue, `${ type } stop domain type must match previous stop domain type ${ stopKeyType }`)];
13933
13946
  }
13934
- if (type !== 'number' && type !== 'string' && type !== 'boolean') {
13947
+ if (type !== 'number' && type !== 'string' && type !== 'boolean' && typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
13935
13948
  return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];
13936
13949
  }
13937
13950
  if (type !== 'number' && functionType !== 'categorical') {
@@ -13941,10 +13954,10 @@ ${ JSON.stringify(filterExp, null, 2) }
13941
13954
  }
13942
13955
  return [new ValidationError(options.key, reportValue, message)];
13943
13956
  }
13944
- if (functionType === 'categorical' && type === 'number' && (!isFinite(value) || Math.floor(value) !== value)) {
13945
- return [new ValidationError(options.key, reportValue, `integer expected, found ${ value }`)];
13957
+ if (functionType === 'categorical' && type === 'number' && (typeof value !== 'number' || !isFinite(value) || Math.floor(value) !== value)) {
13958
+ return [new ValidationError(options.key, reportValue, `integer expected, found ${ String(value) }`)];
13946
13959
  }
13947
- if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {
13960
+ if (functionType !== 'categorical' && type === 'number' && typeof value === 'number' && typeof previousStopDomainValue === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {
13948
13961
  return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];
13949
13962
  } else {
13950
13963
  previousStopDomainValue = value;
@@ -14004,8 +14017,10 @@ ${ JSON.stringify(filterExp, null, 2) }
14004
14017
  'pitch',
14005
14018
  'distance-from-center'
14006
14019
  ]);
14007
- for (const param of options.valueSpec.expression.parameters) {
14008
- disallowedParameters.delete(param);
14020
+ if (options.valueSpec && options.valueSpec.expression) {
14021
+ for (const param of options.valueSpec.expression.parameters) {
14022
+ disallowedParameters.delete(param);
14023
+ }
14009
14024
  }
14010
14025
  if (disallowedParameters.size === 0) {
14011
14026
  return [];
@@ -14064,10 +14079,10 @@ ${ JSON.stringify(filterExp, null, 2) }
14064
14079
 
14065
14080
  function validateFilter(options) {
14066
14081
  if (isExpressionFilter(deepUnbundle(options.value))) {
14067
- const layerType = deepUnbundle(options.layerType);
14082
+ const layerType = options.layerType || 'fill';
14068
14083
  return validateExpression(extend({}, options, {
14069
14084
  expressionContext: 'filter',
14070
- valueSpec: options.styleSpec[`filter_${ layerType || 'fill' }`]
14085
+ valueSpec: options.styleSpec[`filter_${ layerType }`]
14071
14086
  }));
14072
14087
  } else {
14073
14088
  return validateNonExpressionFilter(options);
@@ -14255,7 +14270,8 @@ ${ JSON.stringify(filterExp, null, 2) }
14255
14270
  parent = layer;
14256
14271
  });
14257
14272
  if (!parent) {
14258
- errors.push(new ValidationError(key, layer.ref, `ref layer "${ ref }" not found`));
14273
+ if (typeof ref === 'string')
14274
+ errors.push(new ValidationError(key, layer.ref, `ref layer "${ ref }" not found`));
14259
14275
  } else if (parent.ref) {
14260
14276
  errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));
14261
14277
  } else {
@@ -14311,6 +14327,7 @@ ${ JSON.stringify(filterExp, null, 2) }
14311
14327
  layer,
14312
14328
  key: options.key,
14313
14329
  value: options.value,
14330
+ valueSpec: {},
14314
14331
  style: options.style,
14315
14332
  styleSpec: options.styleSpec,
14316
14333
  objectElementValidators: {
@@ -14325,6 +14342,7 @@ ${ JSON.stringify(filterExp, null, 2) }
14325
14342
  layer,
14326
14343
  key: options.key,
14327
14344
  value: options.value,
14345
+ valueSpec: {},
14328
14346
  style: options.style,
14329
14347
  styleSpec: options.styleSpec,
14330
14348
  objectElementValidators: {
@@ -14543,7 +14561,7 @@ ${ JSON.stringify(filterExp, null, 2) }
14543
14561
  if (!source) {
14544
14562
  errors.push(new ValidationError(key, terrain.source, `source "${ terrain.source }" not found`));
14545
14563
  } else if (sourceType !== 'raster-dem') {
14546
- errors.push(new ValidationError(key, terrain.source, `terrain cannot be used with a source of type ${ sourceType }, it only be used with a "raster-dem" source type`));
14564
+ errors.push(new ValidationError(key, terrain.source, `terrain cannot be used with a source of type ${ String(sourceType) }, it only be used with a "raster-dem" source type`));
14547
14565
  }
14548
14566
  }
14549
14567
  return errors;
@@ -14692,7 +14710,7 @@ ${ JSON.stringify(filterExp, null, 2) }
14692
14710
  return sortErrors(errors);
14693
14711
  }
14694
14712
  function sortErrors(errors) {
14695
- return errors.slice().sort((a, b) => a.line - b.line);
14713
+ return errors.slice().sort((a, b) => a.line && b.line ? a.line - b.line : 0);
14696
14714
  }
14697
14715
 
14698
14716
  /* parser generated by jison 0.4.15 */