@mapbox/mapbox-gl-style-spec 14.1.0 → 14.2.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/composite.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @noflow
1
2
 
2
3
  export default function (style) {
3
4
  const styleIDs = [];
package/dist/index.cjs CHANGED
@@ -587,12 +587,12 @@
587
587
  },
588
588
  url: {
589
589
  type: "string",
590
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
590
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
591
591
  },
592
592
  tiles: {
593
593
  type: "array",
594
594
  value: "string",
595
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
595
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
596
596
  },
597
597
  bounds: {
598
598
  type: "array",
@@ -666,12 +666,12 @@
666
666
  },
667
667
  url: {
668
668
  type: "string",
669
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
669
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
670
670
  },
671
671
  tiles: {
672
672
  type: "array",
673
673
  value: "string",
674
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
674
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
675
675
  },
676
676
  bounds: {
677
677
  type: "array",
@@ -747,12 +747,12 @@
747
747
  },
748
748
  url: {
749
749
  type: "string",
750
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
750
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
751
751
  },
752
752
  tiles: {
753
753
  type: "array",
754
754
  value: "string",
755
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
755
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
756
756
  },
757
757
  bounds: {
758
758
  type: "array",
@@ -828,12 +828,12 @@
828
828
  },
829
829
  url: {
830
830
  type: "string",
831
- doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`."
831
+ doc: "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://<Tileset ID>`. Required if `tiles` is not provided."
832
832
  },
833
833
  tiles: {
834
834
  type: "array",
835
835
  value: "string",
836
- doc: "An array of one or more tile source URLs, as in the TileJSON spec."
836
+ doc: "An array of one or more tile source URLs, as in the TileJSON spec. Required if `url` is not provided."
837
837
  },
838
838
  bounds: {
839
839
  type: "array",
@@ -1186,7 +1186,7 @@
1186
1186
  },
1187
1187
  "source-layer": {
1188
1188
  type: "string",
1189
- doc: "Layer to use from a vector tile source. Required for vector tile sources; prohibited for all other source types, including GeoJSON sources."
1189
+ doc: "Layer to use from a vector tile source. Required for vector and raster-array sources; prohibited for all other source types, including GeoJSON sources."
1190
1190
  },
1191
1191
  slot: {
1192
1192
  type: "string",
@@ -6891,7 +6891,12 @@
6891
6891
  required: false,
6892
6892
  "property-type": "data-constant",
6893
6893
  transition: false,
6894
- doc: "Displayed band of raster array source layer",
6894
+ requires: [
6895
+ {
6896
+ source: "raster-array"
6897
+ }
6898
+ ],
6899
+ doc: "Displayed band of raster array source layer. Defaults to the first band if not set.",
6895
6900
  example: "band-name",
6896
6901
  "sdk-support": {
6897
6902
  "basic functionality": {
@@ -8305,12 +8310,6 @@
8305
8310
  },
8306
8311
  transition: true,
8307
8312
  doc: "Controls the intensity of shading near ground and concave angles between walls. Default value 0.0 disables ambient occlusion and values around 0.3 provide the most plausible results for buildings.",
8308
- requires: [
8309
- "lights",
8310
- {
8311
- "!": "fill-extrusion-flood-light-intensity"
8312
- }
8313
- ],
8314
8313
  "sdk-support": {
8315
8314
  "basic functionality": {
8316
8315
  js: "3.0.0",
@@ -8334,10 +8333,7 @@
8334
8333
  transition: true,
8335
8334
  doc: "Shades area near ground and concave angles between walls where the radius defines only vertical impact. Default value 3.0 corresponds to height of one floor and brings the most plausible results for buildings. This property works only with legacy light. When 3D lights are enabled `fill-extrusion-ambient-occlusion-wall-radius` and `fill-extrusion-ambient-occlusion-ground-radius` are used instead.",
8336
8335
  requires: [
8337
- "fill-extrusion-edge-radius",
8338
- {
8339
- "!": "fill-extrusion-flood-light-intensity"
8340
- }
8336
+ "fill-extrusion-edge-radius"
8341
8337
  ],
8342
8338
  "sdk-support": {
8343
8339
  "basic functionality": {
@@ -8362,10 +8358,7 @@
8362
8358
  doc: "Shades area near ground and concave angles between walls where the radius defines only vertical impact. Default value 3.0 corresponds to height of one floor and brings the most plausible results for buildings.",
8363
8359
  requires: [
8364
8360
  "lights",
8365
- "fill-extrusion-edge-radius",
8366
- {
8367
- "!": "fill-extrusion-flood-light-intensity"
8368
- }
8361
+ "fill-extrusion-edge-radius"
8369
8362
  ],
8370
8363
  "sdk-support": {
8371
8364
  "basic functionality": {
@@ -8389,10 +8382,7 @@
8389
8382
  transition: true,
8390
8383
  doc: "The extent of the ambient occlusion effect on the ground beneath the extruded buildings in meters.",
8391
8384
  requires: [
8392
- "lights",
8393
- {
8394
- "!": "fill-extrusion-flood-light-intensity"
8395
- }
8385
+ "lights"
8396
8386
  ],
8397
8387
  "sdk-support": {
8398
8388
  "basic functionality": {
@@ -8410,10 +8400,7 @@
8410
8400
  maximum: 1,
8411
8401
  doc: "Provides a control to futher fine-tune the look of the ambient occlusion on the ground beneath the extruded buildings. Lower values give the effect a more solid look while higher values make it smoother.",
8412
8402
  requires: [
8413
- "lights",
8414
- {
8415
- "!": "fill-extrusion-flood-light-intensity"
8416
- }
8403
+ "lights"
8417
8404
  ],
8418
8405
  transition: true,
8419
8406
  expression: {
@@ -8436,10 +8423,7 @@
8436
8423
  "default": "#ffffff",
8437
8424
  doc: "The color of the flood light effect on the walls of the extruded buildings.",
8438
8425
  requires: [
8439
- "lights",
8440
- {
8441
- "!": "fill-extrusion-ambient-occlusion-intensity"
8442
- }
8426
+ "lights"
8443
8427
  ],
8444
8428
  transition: true,
8445
8429
  expression: {
@@ -8465,10 +8449,7 @@
8465
8449
  maximum: 1,
8466
8450
  doc: "The intensity of the flood light color.",
8467
8451
  requires: [
8468
- "lights",
8469
- {
8470
- "!": "fill-extrusion-ambient-occlusion-intensity"
8471
- }
8452
+ "lights"
8472
8453
  ],
8473
8454
  transition: true,
8474
8455
  expression: {
@@ -8494,10 +8475,7 @@
8494
8475
  minimum: 0,
8495
8476
  doc: "The extent of the flood light effect on the walls of the extruded buildings in meters.",
8496
8477
  requires: [
8497
- "lights",
8498
- {
8499
- "!": "fill-extrusion-ambient-occlusion-intensity"
8500
- }
8478
+ "lights"
8501
8479
  ],
8502
8480
  transition: true,
8503
8481
  expression: {
@@ -8525,13 +8503,9 @@
8525
8503
  type: "number",
8526
8504
  units: "meters",
8527
8505
  "default": 0,
8528
- minimum: 0,
8529
8506
  doc: "The extent of the flood light effect on the ground beneath the extruded buildings in meters.",
8530
8507
  requires: [
8531
- "lights",
8532
- {
8533
- "!": "fill-extrusion-ambient-occlusion-intensity"
8534
- }
8508
+ "lights"
8535
8509
  ],
8536
8510
  transition: true,
8537
8511
  expression: {
@@ -8562,10 +8536,7 @@
8562
8536
  maximum: 1,
8563
8537
  doc: "Provides a control to futher fine-tune the look of the flood light on the ground beneath the extruded buildings. Lower values give the effect a more solid look while higher values make it smoother.",
8564
8538
  requires: [
8565
- "lights",
8566
- {
8567
- "!": "fill-extrusion-ambient-occlusion-intensity"
8568
- }
8539
+ "lights"
8569
8540
  ],
8570
8541
  transition: true,
8571
8542
  expression: {
@@ -8631,7 +8602,7 @@
8631
8602
  "default": 0,
8632
8603
  minimum: 0,
8633
8604
  maximum: 1,
8634
- doc: "This parameter defines the range for the fade-out effect before an automatic content cutoff on pitched map views. The automatic cutoff range is calculated according to the minimum required zoom level of the source and layer. The fade range is expressed in relation to the height of the map view. A value of 1.0 indicates that the content is faded to the same extent as the map's height in pixels, while a value close to zero represents a sharp cutoff. When the value is set to 0.0, the cutoff is completely disabled. Note: The property has no effect on the map if terrain is enabled.",
8605
+ doc: "This parameter defines the range for the fade-out effect before an automatic content cutoff on pitched map views. Fade out is implemented by scaling down and removing buildings in the fade range in a staggered fashion. Opacity is not changed. The fade range is expressed in relation to the height of the map view. A value of 1.0 indicates that the content is faded to the same extent as the map's height in pixels, while a value close to zero represents a sharp cutoff. When the value is set to 0.0, the cutoff is completely disabled. Note: The property has no effect on the map if terrain is enabled.",
8635
8606
  transition: false,
8636
8607
  expression: {
8637
8608
  interpolated: false
@@ -8772,6 +8743,7 @@
8772
8743
  }(passedObj, '', 0);
8773
8744
  }
8774
8745
 
8746
+ //
8775
8747
  function sortKeysBy(obj, reference) {
8776
8748
  const result = {};
8777
8749
  for (const key in reference) {
@@ -10045,6 +10017,7 @@
10045
10017
  });
10046
10018
  }
10047
10019
 
10020
+ //
10048
10021
  function eachLayout(layer, callback) {
10049
10022
  for (const k in layer) {
10050
10023
  if (k.indexOf('layout') === 0) {
@@ -11549,8 +11522,6 @@
11549
11522
  var Color$1 = Color;
11550
11523
 
11551
11524
  //
11552
- // Flow type declarations for Intl cribbed from
11553
- // https://github.com/facebook/flow/issues/1270
11554
11525
  class Collator {
11555
11526
  constructor(caseSensitive, diacriticSensitive, locale) {
11556
11527
  if (caseSensitive)
@@ -12315,7 +12286,7 @@
12315
12286
  'Polygon'
12316
12287
  ];
12317
12288
  class EvaluationContext {
12318
- constructor(options) {
12289
+ constructor(scope, options) {
12319
12290
  this.globals = null;
12320
12291
  this.feature = null;
12321
12292
  this.featureState = null;
@@ -12325,6 +12296,7 @@
12325
12296
  this.canonical = null;
12326
12297
  this.featureTileCoord = null;
12327
12298
  this.featureDistanceData = null;
12299
+ this.scope = scope;
12328
12300
  this.options = options;
12329
12301
  }
12330
12302
  id() {
@@ -12424,7 +12396,7 @@
12424
12396
  overloadIndex++;
12425
12397
  // Use a fresh context for each attempted signature so that, if
12426
12398
  // we eventually succeed, we haven't polluted `context.errors`.
12427
- signatureContext = new ParsingContext$1(context.registry, context.path, null, context.scope, undefined, context.options);
12399
+ signatureContext = new ParsingContext$1(context.registry, context.path, null, context.scope, undefined, context._scope, context.options);
12428
12400
  // First parse all the args, potentially coercing to the
12429
12401
  // types expected by this overload.
12430
12402
  const parsedArgs = [];
@@ -14553,13 +14525,14 @@
14553
14525
  // implementations to infer argument types: Expression#parse() need not
14554
14526
  // check that the output type of the parsed expression matches
14555
14527
  // `expectedType`.
14556
- constructor(registry, path = [], expectedType, scope = new Scope$1(), errors = [], options) {
14528
+ constructor(registry, path = [], expectedType, scope = new Scope$1(), errors = [], _scope, options) {
14557
14529
  this.registry = registry;
14558
14530
  this.path = path;
14559
14531
  this.key = path.map(part => `[${ part }]`).join('');
14560
14532
  this.scope = scope;
14561
14533
  this.errors = errors;
14562
14534
  this.expectedType = expectedType;
14535
+ this._scope = _scope;
14563
14536
  this.options = options;
14564
14537
  }
14565
14538
  /**
@@ -14624,7 +14597,7 @@
14624
14597
  // parsed/compiled result. Expressions that expect an image should
14625
14598
  // not be resolved here so we can later get the available images.
14626
14599
  if (!(parsed instanceof Literal$1) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
14627
- const ec = new EvaluationContext$1(this.options);
14600
+ const ec = new EvaluationContext$1(this._scope, this.options);
14628
14601
  try {
14629
14602
  parsed = new Literal$1(parsed.type, parsed.evaluate(ec));
14630
14603
  } catch (e) {
@@ -14658,7 +14631,7 @@
14658
14631
  concat(index, expectedType, bindings) {
14659
14632
  const path = typeof index === 'number' ? this.path.concat(index) : this.path;
14660
14633
  const scope = bindings ? this.scope.concat(bindings) : this.scope;
14661
- return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this.options);
14634
+ return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options);
14662
14635
  }
14663
14636
  /**
14664
14637
  * Push a parsing (or type checking) error into the `this.errors`
@@ -16270,16 +16243,28 @@
16270
16243
  }
16271
16244
  return value;
16272
16245
  }
16246
+ const FQIDSeparator = '\x1F';
16273
16247
  function getConfig(ctx, key, scope) {
16274
- if (scope.length) {
16275
- key += `\u{1f}${ scope }`;
16276
- }
16248
+ // Create a fully qualified key from the requested scope
16249
+ // and the scope from the current evaluation context
16250
+ key = [
16251
+ key,
16252
+ scope,
16253
+ ctx.scope
16254
+ ].filter(Boolean).join(FQIDSeparator);
16277
16255
  const config = ctx.getConfig(key);
16278
16256
  if (!config)
16279
16257
  return null;
16280
16258
  const {type, value, values, minValue, maxValue, stepValue} = config;
16281
16259
  const defaultValue = config.default.evaluate(ctx);
16282
- let result = value ? value.evaluate(ctx) : defaultValue;
16260
+ let result = defaultValue;
16261
+ if (value) {
16262
+ // temporarily override scope to parent to evaluate config expressions passed from the parent
16263
+ const originalScope = ctx.scope;
16264
+ ctx.scope = (originalScope || '').split(FQIDSeparator).slice(1).join(FQIDSeparator);
16265
+ result = value.evaluate(ctx);
16266
+ ctx.scope = originalScope;
16267
+ }
16283
16268
  if (type)
16284
16269
  result = coerceValue(type, result);
16285
16270
  if (value !== undefined && result !== undefined && values && !values.includes(result)) {
@@ -16418,7 +16403,7 @@
16418
16403
  overloads: [
16419
16404
  [
16420
16405
  [StringType],
16421
- (ctx, [key]) => getConfig(ctx, key.evaluate(ctx), '')
16406
+ (ctx, [key]) => getConfig(ctx, key.evaluate(ctx))
16422
16407
  ],
16423
16408
  [
16424
16409
  [
@@ -16945,6 +16930,7 @@
16945
16930
  return !!spec.expression && spec.expression.interpolated;
16946
16931
  }
16947
16932
 
16933
+ //
16948
16934
  function isFunction(value) {
16949
16935
  return typeof value === 'object' && value !== null && !Array.isArray(value);
16950
16936
  }
@@ -17192,10 +17178,10 @@
17192
17178
  }
17193
17179
 
17194
17180
  class StyleExpression {
17195
- constructor(expression, propertySpec, options) {
17181
+ constructor(expression, propertySpec, scope, options) {
17196
17182
  this.expression = expression;
17197
17183
  this._warningHistory = {};
17198
- this._evaluator = new EvaluationContext$1(options);
17184
+ this._evaluator = new EvaluationContext$1(scope, options);
17199
17185
  this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
17200
17186
  this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
17201
17187
  }
@@ -17252,14 +17238,14 @@
17252
17238
  *
17253
17239
  * @private
17254
17240
  */
17255
- function createExpression(expression, propertySpec, options) {
17256
- const parser = new ParsingContext$1(definitions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, options);
17241
+ function createExpression(expression, propertySpec, scope, options) {
17242
+ const parser = new ParsingContext$1(definitions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, scope, options);
17257
17243
  // For string-valued properties, coerce to string at the top level rather than asserting.
17258
17244
  const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);
17259
17245
  if (!parsed) {
17260
17246
  return error(parser.errors);
17261
17247
  }
17262
- return success(new StyleExpression(parsed, propertySpec, options));
17248
+ return success(new StyleExpression(parsed, propertySpec, scope, options));
17263
17249
  }
17264
17250
  class ZoomConstantExpression {
17265
17251
  constructor(kind, expression, isLightConstant) {
@@ -17300,8 +17286,8 @@
17300
17286
  }
17301
17287
  }
17302
17288
  }
17303
- function createPropertyExpression(expression, propertySpec, options) {
17304
- expression = createExpression(expression, propertySpec, options);
17289
+ function createPropertyExpression(expression, propertySpec, scope, options) {
17290
+ expression = createExpression(expression, propertySpec, scope, options);
17305
17291
  if (expression.result === 'error') {
17306
17292
  return expression;
17307
17293
  }
@@ -17355,11 +17341,11 @@
17355
17341
  };
17356
17342
  }
17357
17343
  }
17358
- function normalizePropertyExpression(value, specification, options) {
17344
+ function normalizePropertyExpression(value, specification, scope, options) {
17359
17345
  if (isFunction(value)) {
17360
17346
  return new StylePropertyFunction(value, specification);
17361
17347
  } else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
17362
- const expression = createPropertyExpression(value, specification, options);
17348
+ const expression = createPropertyExpression(value, specification, scope, options);
17363
17349
  if (expression.result === 'error') {
17364
17350
  // this should have been caught in validation
17365
17351
  throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
@@ -18376,6 +18362,7 @@ ${ JSON.stringify(filterExp, null, 2) }
18376
18362
  return style;
18377
18363
  }
18378
18364
 
18365
+ //
18379
18366
  /**
18380
18367
  * Migrate a Mapbox GL Style to the latest version.
18381
18368
  *
@@ -18405,6 +18392,7 @@ ${ JSON.stringify(filterExp, null, 2) }
18405
18392
  return style;
18406
18393
  }
18407
18394
 
18395
+ //
18408
18396
  function composite (style) {
18409
18397
  const styleIDs = [];
18410
18398
  const sourceIDs = [];
@@ -19963,7 +19951,7 @@ ${ JSON.stringify(filterExp, null, 2) }
19963
19951
  'raster-dem'
19964
19952
  ].includes(type)) {
19965
19953
  if (!value.url && !value.tiles) {
19966
- errors.push(new ValidationError(key, value, 'Either "url" or "tiles" is required.'));
19954
+ errors.push(new ValidationWarning(key, value, 'Either "url" or "tiles" is required.'));
19967
19955
  }
19968
19956
  }
19969
19957
  switch (type) {
@@ -21530,6 +21518,7 @@ ${ JSON.stringify(filterExp, null, 2) }
21530
21518
 
21531
21519
  var jsonlint = /*@__PURE__*/getDefaultExportFromCjs(jsonlint$1);
21532
21520
 
21521
+ //
21533
21522
  function readStyle(style) {
21534
21523
  if (style instanceof String || typeof style === 'string' || style instanceof Buffer) {
21535
21524
  try {