@mapbox/mapbox-gl-style-spec 14.36.0 → 14.37.0-rc.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/dist/index.d.ts CHANGED
@@ -6300,6 +6300,8 @@ declare const _exports: {
6300
6300
  "sdk-support": {
6301
6301
  "basic functionality": {
6302
6302
  js: string;
6303
+ android: string;
6304
+ ios: string;
6303
6305
  };
6304
6306
  };
6305
6307
  };
@@ -6319,6 +6321,8 @@ declare const _exports: {
6319
6321
  "sdk-support": {
6320
6322
  "basic functionality": {
6321
6323
  js: string;
6324
+ android: string;
6325
+ ios: string;
6322
6326
  };
6323
6327
  };
6324
6328
  };
@@ -12620,6 +12624,11 @@ interface Expression {
12620
12624
  * (e.g. `within`, `distance`, `config`); `isFeatureConstant` returns it without recursing.
12621
12625
  */
12622
12626
  readonly featureConstant?: boolean;
12627
+ /**
12628
+ * Set by expressions whose global dependencies can't be derived from their children (e.g. `config`);
12629
+ * a `GlobalDependency` bitmask that `getGlobalDependencies` uses in place of the expression's own flags.
12630
+ */
12631
+ readonly globalDependencies?: number;
12623
12632
  evaluate: (ctx: EvaluationContext) => any;
12624
12633
  eachChild: (fn: (arg1: Expression) => void) => void;
12625
12634
  /**
@@ -12780,7 +12789,8 @@ declare class ZoomConstantExpression<Kind extends EvaluationKind> {
12780
12789
  _styleExpression: StyleExpression;
12781
12790
  isLightConstant: boolean | null | undefined;
12782
12791
  isLineProgressConstant: boolean | null | undefined;
12783
- constructor(kind: Kind, expression: StyleExpression, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null);
12792
+ isConfigZoomDependent: boolean;
12793
+ constructor(kind: Kind, expression: StyleExpression, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null, isConfigZoomDependent?: boolean);
12784
12794
  evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
12785
12795
  evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, iconImageUseTheme?: string): any;
12786
12796
  }
@@ -12801,6 +12811,7 @@ declare class ZoomDependentExpression<Kind extends EvaluationKind> {
12801
12811
  }
12802
12812
  type ConstantExpression = {
12803
12813
  kind: 'constant';
12814
+ isConfigZoomDependent?: boolean;
12804
12815
  configDependencies: Set<string>;
12805
12816
  isIndoorDependent: boolean;
12806
12817
  readonly evaluate: <T = unknown>(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, iconImageUseTheme?: string) => T;
package/dist/index.es.js CHANGED
@@ -6809,7 +6809,9 @@ var projection = {
6809
6809
  ],
6810
6810
  "sdk-support": {
6811
6811
  "basic functionality": {
6812
- js: "2.6.0"
6812
+ js: "2.6.0",
6813
+ android: "11.37.0",
6814
+ ios: "11.37.0"
6813
6815
  }
6814
6816
  }
6815
6817
  },
@@ -6842,7 +6844,9 @@ var projection = {
6842
6844
  ],
6843
6845
  "sdk-support": {
6844
6846
  "basic functionality": {
6845
- js: "2.6.0"
6847
+ js: "2.6.0",
6848
+ android: "11.37.0",
6849
+ ios: "11.37.0"
6846
6850
  }
6847
6851
  }
6848
6852
  }
@@ -15147,7 +15151,7 @@ function isGlobalPropertyConstantSet(e, properties) {
15147
15151
  function isGlobalPropertyConstant(e, properties) {
15148
15152
  return isGlobalPropertyConstantSet(e, new Set(properties));
15149
15153
  }
15150
- const GlobalDependency = { Zoom: 1, Light: 2, LineProgress: 4 };
15154
+ const GlobalDependency = { Zoom: 1, Light: 2, LineProgress: 4, ConfigLight: 8, ConfigZoom: 16 };
15151
15155
  const globalDependencyFlags = {
15152
15156
  "zoom": GlobalDependency.Zoom,
15153
15157
  "pitch": GlobalDependency.Zoom,
@@ -15156,7 +15160,7 @@ const globalDependencyFlags = {
15156
15160
  "line-progress": GlobalDependency.LineProgress
15157
15161
  };
15158
15162
  function getGlobalDependencies(e) {
15159
- let flags = e instanceof CompoundExpression ? globalDependencyFlags[e.name] || 0 : 0;
15163
+ let flags = e.globalDependencies !== void 0 ? e.globalDependencies : e instanceof CompoundExpression ? globalDependencyFlags[e.name] || 0 : 0;
15160
15164
  e.eachChild((arg) => {
15161
15165
  flags |= getGlobalDependencies(arg);
15162
15166
  });
@@ -15797,6 +15801,25 @@ function makeConfigFQID(id, ownScope, contextScope) {
15797
15801
  if (contextScope) fqid = fqid ? fqid + FQIDSeparator + contextScope : contextScope;
15798
15802
  return fqid;
15799
15803
  }
15804
+ function getConfigParentScope(scope) {
15805
+ const separator = scope.indexOf(FQIDSeparator);
15806
+ return separator >= 0 ? scope.slice(separator + 1) : "";
15807
+ }
15808
+ function getConfigGlobalDependencies(options, fqid, scope, visited = /* @__PURE__ */ new Set()) {
15809
+ const config = options.get(fqid);
15810
+ if (!config || visited.has(fqid)) return 0;
15811
+ visited.add(fqid);
15812
+ const getDeps = (e, s) => {
15813
+ let flags = getGlobalDependencies(e);
15814
+ const visit = (node) => {
15815
+ if (node instanceof Config) flags |= getConfigGlobalDependencies(options, makeConfigFQID(node.key, node.scope, s), s, visited);
15816
+ node.eachChild(visit);
15817
+ };
15818
+ visit(e);
15819
+ return flags;
15820
+ };
15821
+ return getDeps(config.default, scope) | (config.value ? getDeps(config.value, getConfigParentScope(scope)) : 0);
15822
+ }
15800
15823
  function coerceValue(type, value) {
15801
15824
  switch (type) {
15802
15825
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -15831,11 +15854,12 @@ function clampToAllowedNumber(value, min, max, step) {
15831
15854
  return value;
15832
15855
  }
15833
15856
  class Config {
15834
- constructor(type, key, scope, featureConstant = false) {
15857
+ constructor(type, key, scope, featureConstant = false, globalDependencies = 0) {
15835
15858
  this.type = type;
15836
15859
  this.key = key;
15837
15860
  this.scope = scope;
15838
15861
  this.featureConstant = featureConstant;
15862
+ this.globalDependencies = globalDependencies;
15839
15863
  }
15840
15864
  static parse(args, context) {
15841
15865
  let type = context.expectedType;
@@ -15848,6 +15872,7 @@ class Config {
15848
15872
  return context.error(`Key name of 'config' expression must be a string literal.`);
15849
15873
  }
15850
15874
  let featureConstant = true;
15875
+ let globalDependencies = 0;
15851
15876
  let configScopeValue;
15852
15877
  const configKeyValue = toString(configKey.value);
15853
15878
  if (args.length >= 3) {
@@ -15862,9 +15887,13 @@ class Config {
15862
15887
  const config = context.options.get(fqid);
15863
15888
  if (config) {
15864
15889
  featureConstant = isFeatureConstant(config.value || config.default);
15890
+ const { Light, Zoom, ConfigLight, ConfigZoom } = GlobalDependency;
15891
+ const deps = getConfigGlobalDependencies(context.options, fqid, context._scope || "");
15892
+ if (deps & (Light | ConfigLight)) globalDependencies |= ConfigLight;
15893
+ if (deps & (Zoom | ConfigZoom)) globalDependencies |= ConfigZoom;
15865
15894
  }
15866
15895
  }
15867
- return new Config(type, configKeyValue, configScopeValue, featureConstant);
15896
+ return new Config(type, configKeyValue, configScopeValue, featureConstant, globalDependencies);
15868
15897
  }
15869
15898
  evaluate(ctx) {
15870
15899
  const fqid = makeConfigFQID(this.key, this.scope, ctx.scope);
@@ -15875,9 +15904,7 @@ class Config {
15875
15904
  let result = defaultValue;
15876
15905
  if (value) {
15877
15906
  const originalScope = ctx.scope;
15878
- const scope = originalScope || "";
15879
- const sep = scope.indexOf(FQIDSeparator);
15880
- ctx.scope = sep >= 0 ? scope.slice(sep + 1) : "";
15907
+ ctx.scope = getConfigParentScope(originalScope || "");
15881
15908
  result = value.evaluate(ctx);
15882
15909
  ctx.scope = originalScope;
15883
15910
  }
@@ -18329,11 +18356,12 @@ function createExpression(expression, propertySpec, scope, options, iconImageUse
18329
18356
  return success(new StyleExpression(parsed, propertySpec, scope, options, iconImageUseTheme));
18330
18357
  }
18331
18358
  class ZoomConstantExpression {
18332
- constructor(kind, expression, isLightConstant, isLineProgressConstant) {
18359
+ constructor(kind, expression, isLightConstant, isLineProgressConstant, isConfigZoomDependent = false) {
18333
18360
  this.kind = kind;
18334
18361
  this._styleExpression = expression;
18335
18362
  this.isLightConstant = isLightConstant;
18336
18363
  this.isLineProgressConstant = isLineProgressConstant;
18364
+ this.isConfigZoomDependent = isConfigZoomDependent;
18337
18365
  this.isStateDependent = kind !== "constant" && !isStateConstant(expression.expression);
18338
18366
  this.configDependencies = expression.configDependencies;
18339
18367
  this.isIndoorDependent = expression.isIndoorDependent;
@@ -18386,10 +18414,10 @@ function createPropertyExpression(expression, propertySpec, scope, options, icon
18386
18414
  if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {
18387
18415
  return error([new ParsingError$1("", "zoom expressions not supported")]);
18388
18416
  }
18389
- const isLightConstant = (globalDependencies & GlobalDependency.Light) === 0;
18390
- if (!isLightConstant && !supportsLightExpression(propertySpec)) {
18417
+ if (globalDependencies & GlobalDependency.Light && !supportsLightExpression(propertySpec)) {
18391
18418
  return error([new ParsingError$1("", "measure-light expression not supported")]);
18392
18419
  }
18420
+ const isLightConstant = (globalDependencies & (GlobalDependency.Light | GlobalDependency.ConfigLight)) === 0;
18393
18421
  const isLineProgressConstant = (globalDependencies & GlobalDependency.LineProgress) === 0;
18394
18422
  if (!isLineProgressConstant && !supportsLineProgressExpression(propertySpec)) {
18395
18423
  return error([new ParsingError$1("", "line-progress expression not supported")]);
@@ -18404,7 +18432,8 @@ function createPropertyExpression(expression, propertySpec, scope, options, icon
18404
18432
  return error([new ParsingError$1("", '"interpolate" expressions cannot be used with this property')]);
18405
18433
  }
18406
18434
  if (!zoomCurve) {
18407
- return success(isFeatureConstant$1 && isLineProgressConstant ? new ZoomConstantExpression("constant", styleExpression.value, isLightConstant, isLineProgressConstant) : new ZoomConstantExpression("source", styleExpression.value, isLightConstant, isLineProgressConstant));
18435
+ const isConfigZoomDependent = (globalDependencies & GlobalDependency.ConfigZoom) !== 0;
18436
+ return success(isFeatureConstant$1 && isLineProgressConstant ? new ZoomConstantExpression("constant", styleExpression.value, isLightConstant, isLineProgressConstant, isConfigZoomDependent) : new ZoomConstantExpression("source", styleExpression.value, isLightConstant, isLineProgressConstant));
18408
18437
  }
18409
18438
  const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : void 0;
18410
18439
  return success(isFeatureConstant$1 && isLineProgressConstant ? new ZoomDependentExpression("camera", styleExpression.value, zoomCurve.labels, interpolationType, isLightConstant, isLineProgressConstant) : new ZoomDependentExpression("composite", styleExpression.value, zoomCurve.labels, interpolationType, isLightConstant, isLineProgressConstant));
@@ -19737,13 +19766,14 @@ function validateImport(options) {
19737
19766
  }
19738
19767
  if (data) {
19739
19768
  const key2 = `${options.key}.data`;
19740
- errors = errors.concat(validateStyle$2(data, styleSpec, { key: key2 }));
19769
+ errors = errors.concat(validateStyle$2(data, styleSpec, { key: key2, fragment: true }));
19741
19770
  }
19742
19771
  return errors;
19743
19772
  }
19744
19773
 
19745
19774
  function validateOption(options) {
19746
19775
  const styleSpec = options.styleSpec;
19776
+ const optionSpec = styleSpec.option;
19747
19777
  const optionValue = options.value;
19748
19778
  const isArrayOption = isObject(optionValue) && unbundle(optionValue.array) === true;
19749
19779
  const declaredType = !isArrayOption && isObject(optionValue) ? unbundle(optionValue.type) : void 0;
@@ -19759,8 +19789,7 @@ function validateOption(options) {
19759
19789
  };
19760
19790
  return validateObject({
19761
19791
  ...options,
19762
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
19763
- valueSpec: styleSpec.option,
19792
+ valueSpec: optionSpec,
19764
19793
  objectElementValidators: {
19765
19794
  default: validateDefault
19766
19795
  }
@@ -20311,7 +20340,7 @@ Use an identity property function instead: ${example}.`
20311
20340
  }
20312
20341
  const errors = [];
20313
20342
  if (options.layerType === "symbol") {
20314
- if (propertyKey === "text-field" && style && !style.glyphs && !style.imports) {
20343
+ if (propertyKey === "text-field" && style && !style.glyphs && !style.imports && !style.fragment) {
20315
20344
  errors.push(new ValidationError(key, value, 'use of "text-field" requires a style "glyphs" property'));
20316
20345
  }
20317
20346
  if (propertyKey === "text-font" && isFunction(deepUnbundle(value)) && unbundle(value.type) === "identity") {
@@ -21200,6 +21229,7 @@ function validateGlyphsUrl({ key, value }) {
21200
21229
  }
21201
21230
 
21202
21231
  function validateStyle$2(style, styleSpec = v8, options = {}) {
21232
+ const root = style;
21203
21233
  const errors = validateObject({
21204
21234
  key: options.key || "",
21205
21235
  value: style,
@@ -21210,7 +21240,7 @@ function validateStyle$2(style, styleSpec = v8, options = {}) {
21210
21240
  "*": { type: "*" }
21211
21241
  },
21212
21242
  styleSpec,
21213
- style,
21243
+ style: options.fragment ? { ...root, fragment: true } : root,
21214
21244
  objectElementValidators: {
21215
21245
  glyphs: validateGlyphsUrl
21216
21246
  }