@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.cjs +48 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.es.js +48 -18
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/config.ts +41 -6
- package/expression/expression.ts +5 -0
- package/expression/index.ts +11 -4
- package/expression/is_constant.ts +6 -2
- package/package.json +1 -1
- package/reference/v8.json +6 -2
- package/types/csscolorparser.d.ts +8 -0
- package/util/color.ts +2 -0
- package/validate/validate_import.ts +1 -1
- package/validate/validate_option.ts +4 -3
- package/validate/validate_property.ts +1 -1
- package/validate/validate_style.ts +4 -1
package/dist/index.cjs
CHANGED
|
@@ -6815,7 +6815,9 @@
|
|
|
6815
6815
|
],
|
|
6816
6816
|
"sdk-support": {
|
|
6817
6817
|
"basic functionality": {
|
|
6818
|
-
js: "2.6.0"
|
|
6818
|
+
js: "2.6.0",
|
|
6819
|
+
android: "11.37.0",
|
|
6820
|
+
ios: "11.37.0"
|
|
6819
6821
|
}
|
|
6820
6822
|
}
|
|
6821
6823
|
},
|
|
@@ -6848,7 +6850,9 @@
|
|
|
6848
6850
|
],
|
|
6849
6851
|
"sdk-support": {
|
|
6850
6852
|
"basic functionality": {
|
|
6851
|
-
js: "2.6.0"
|
|
6853
|
+
js: "2.6.0",
|
|
6854
|
+
android: "11.37.0",
|
|
6855
|
+
ios: "11.37.0"
|
|
6852
6856
|
}
|
|
6853
6857
|
}
|
|
6854
6858
|
}
|
|
@@ -15153,7 +15157,7 @@
|
|
|
15153
15157
|
function isGlobalPropertyConstant(e, properties) {
|
|
15154
15158
|
return isGlobalPropertyConstantSet(e, new Set(properties));
|
|
15155
15159
|
}
|
|
15156
|
-
const GlobalDependency = { Zoom: 1, Light: 2, LineProgress: 4 };
|
|
15160
|
+
const GlobalDependency = { Zoom: 1, Light: 2, LineProgress: 4, ConfigLight: 8, ConfigZoom: 16 };
|
|
15157
15161
|
const globalDependencyFlags = {
|
|
15158
15162
|
"zoom": GlobalDependency.Zoom,
|
|
15159
15163
|
"pitch": GlobalDependency.Zoom,
|
|
@@ -15162,7 +15166,7 @@
|
|
|
15162
15166
|
"line-progress": GlobalDependency.LineProgress
|
|
15163
15167
|
};
|
|
15164
15168
|
function getGlobalDependencies(e) {
|
|
15165
|
-
let flags = e instanceof CompoundExpression ? globalDependencyFlags[e.name] || 0 : 0;
|
|
15169
|
+
let flags = e.globalDependencies !== void 0 ? e.globalDependencies : e instanceof CompoundExpression ? globalDependencyFlags[e.name] || 0 : 0;
|
|
15166
15170
|
e.eachChild((arg) => {
|
|
15167
15171
|
flags |= getGlobalDependencies(arg);
|
|
15168
15172
|
});
|
|
@@ -15803,6 +15807,25 @@
|
|
|
15803
15807
|
if (contextScope) fqid = fqid ? fqid + FQIDSeparator + contextScope : contextScope;
|
|
15804
15808
|
return fqid;
|
|
15805
15809
|
}
|
|
15810
|
+
function getConfigParentScope(scope) {
|
|
15811
|
+
const separator = scope.indexOf(FQIDSeparator);
|
|
15812
|
+
return separator >= 0 ? scope.slice(separator + 1) : "";
|
|
15813
|
+
}
|
|
15814
|
+
function getConfigGlobalDependencies(options, fqid, scope, visited = /* @__PURE__ */ new Set()) {
|
|
15815
|
+
const config = options.get(fqid);
|
|
15816
|
+
if (!config || visited.has(fqid)) return 0;
|
|
15817
|
+
visited.add(fqid);
|
|
15818
|
+
const getDeps = (e, s) => {
|
|
15819
|
+
let flags = getGlobalDependencies(e);
|
|
15820
|
+
const visit = (node) => {
|
|
15821
|
+
if (node instanceof Config) flags |= getConfigGlobalDependencies(options, makeConfigFQID(node.key, node.scope, s), s, visited);
|
|
15822
|
+
node.eachChild(visit);
|
|
15823
|
+
};
|
|
15824
|
+
visit(e);
|
|
15825
|
+
return flags;
|
|
15826
|
+
};
|
|
15827
|
+
return getDeps(config.default, scope) | (config.value ? getDeps(config.value, getConfigParentScope(scope)) : 0);
|
|
15828
|
+
}
|
|
15806
15829
|
function coerceValue(type, value) {
|
|
15807
15830
|
switch (type) {
|
|
15808
15831
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -15837,11 +15860,12 @@
|
|
|
15837
15860
|
return value;
|
|
15838
15861
|
}
|
|
15839
15862
|
class Config {
|
|
15840
|
-
constructor(type, key, scope, featureConstant = false) {
|
|
15863
|
+
constructor(type, key, scope, featureConstant = false, globalDependencies = 0) {
|
|
15841
15864
|
this.type = type;
|
|
15842
15865
|
this.key = key;
|
|
15843
15866
|
this.scope = scope;
|
|
15844
15867
|
this.featureConstant = featureConstant;
|
|
15868
|
+
this.globalDependencies = globalDependencies;
|
|
15845
15869
|
}
|
|
15846
15870
|
static parse(args, context) {
|
|
15847
15871
|
let type = context.expectedType;
|
|
@@ -15854,6 +15878,7 @@
|
|
|
15854
15878
|
return context.error(`Key name of 'config' expression must be a string literal.`);
|
|
15855
15879
|
}
|
|
15856
15880
|
let featureConstant = true;
|
|
15881
|
+
let globalDependencies = 0;
|
|
15857
15882
|
let configScopeValue;
|
|
15858
15883
|
const configKeyValue = toString(configKey.value);
|
|
15859
15884
|
if (args.length >= 3) {
|
|
@@ -15868,9 +15893,13 @@
|
|
|
15868
15893
|
const config = context.options.get(fqid);
|
|
15869
15894
|
if (config) {
|
|
15870
15895
|
featureConstant = isFeatureConstant(config.value || config.default);
|
|
15896
|
+
const { Light, Zoom, ConfigLight, ConfigZoom } = GlobalDependency;
|
|
15897
|
+
const deps = getConfigGlobalDependencies(context.options, fqid, context._scope || "");
|
|
15898
|
+
if (deps & (Light | ConfigLight)) globalDependencies |= ConfigLight;
|
|
15899
|
+
if (deps & (Zoom | ConfigZoom)) globalDependencies |= ConfigZoom;
|
|
15871
15900
|
}
|
|
15872
15901
|
}
|
|
15873
|
-
return new Config(type, configKeyValue, configScopeValue, featureConstant);
|
|
15902
|
+
return new Config(type, configKeyValue, configScopeValue, featureConstant, globalDependencies);
|
|
15874
15903
|
}
|
|
15875
15904
|
evaluate(ctx) {
|
|
15876
15905
|
const fqid = makeConfigFQID(this.key, this.scope, ctx.scope);
|
|
@@ -15881,9 +15910,7 @@
|
|
|
15881
15910
|
let result = defaultValue;
|
|
15882
15911
|
if (value) {
|
|
15883
15912
|
const originalScope = ctx.scope;
|
|
15884
|
-
|
|
15885
|
-
const sep = scope.indexOf(FQIDSeparator);
|
|
15886
|
-
ctx.scope = sep >= 0 ? scope.slice(sep + 1) : "";
|
|
15913
|
+
ctx.scope = getConfigParentScope(originalScope || "");
|
|
15887
15914
|
result = value.evaluate(ctx);
|
|
15888
15915
|
ctx.scope = originalScope;
|
|
15889
15916
|
}
|
|
@@ -18335,11 +18362,12 @@
|
|
|
18335
18362
|
return success(new StyleExpression(parsed, propertySpec, scope, options, iconImageUseTheme));
|
|
18336
18363
|
}
|
|
18337
18364
|
class ZoomConstantExpression {
|
|
18338
|
-
constructor(kind, expression, isLightConstant, isLineProgressConstant) {
|
|
18365
|
+
constructor(kind, expression, isLightConstant, isLineProgressConstant, isConfigZoomDependent = false) {
|
|
18339
18366
|
this.kind = kind;
|
|
18340
18367
|
this._styleExpression = expression;
|
|
18341
18368
|
this.isLightConstant = isLightConstant;
|
|
18342
18369
|
this.isLineProgressConstant = isLineProgressConstant;
|
|
18370
|
+
this.isConfigZoomDependent = isConfigZoomDependent;
|
|
18343
18371
|
this.isStateDependent = kind !== "constant" && !isStateConstant(expression.expression);
|
|
18344
18372
|
this.configDependencies = expression.configDependencies;
|
|
18345
18373
|
this.isIndoorDependent = expression.isIndoorDependent;
|
|
@@ -18392,10 +18420,10 @@
|
|
|
18392
18420
|
if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {
|
|
18393
18421
|
return error([new ParsingError$1("", "zoom expressions not supported")]);
|
|
18394
18422
|
}
|
|
18395
|
-
|
|
18396
|
-
if (!isLightConstant && !supportsLightExpression(propertySpec)) {
|
|
18423
|
+
if (globalDependencies & GlobalDependency.Light && !supportsLightExpression(propertySpec)) {
|
|
18397
18424
|
return error([new ParsingError$1("", "measure-light expression not supported")]);
|
|
18398
18425
|
}
|
|
18426
|
+
const isLightConstant = (globalDependencies & (GlobalDependency.Light | GlobalDependency.ConfigLight)) === 0;
|
|
18399
18427
|
const isLineProgressConstant = (globalDependencies & GlobalDependency.LineProgress) === 0;
|
|
18400
18428
|
if (!isLineProgressConstant && !supportsLineProgressExpression(propertySpec)) {
|
|
18401
18429
|
return error([new ParsingError$1("", "line-progress expression not supported")]);
|
|
@@ -18410,7 +18438,8 @@
|
|
|
18410
18438
|
return error([new ParsingError$1("", '"interpolate" expressions cannot be used with this property')]);
|
|
18411
18439
|
}
|
|
18412
18440
|
if (!zoomCurve) {
|
|
18413
|
-
|
|
18441
|
+
const isConfigZoomDependent = (globalDependencies & GlobalDependency.ConfigZoom) !== 0;
|
|
18442
|
+
return success(isFeatureConstant$1 && isLineProgressConstant ? new ZoomConstantExpression("constant", styleExpression.value, isLightConstant, isLineProgressConstant, isConfigZoomDependent) : new ZoomConstantExpression("source", styleExpression.value, isLightConstant, isLineProgressConstant));
|
|
18414
18443
|
}
|
|
18415
18444
|
const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : void 0;
|
|
18416
18445
|
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));
|
|
@@ -19743,13 +19772,14 @@ ${JSON.stringify(filterExp, null, 2)}
|
|
|
19743
19772
|
}
|
|
19744
19773
|
if (data) {
|
|
19745
19774
|
const key2 = `${options.key}.data`;
|
|
19746
|
-
errors = errors.concat(validateStyle$2(data, styleSpec, { key: key2 }));
|
|
19775
|
+
errors = errors.concat(validateStyle$2(data, styleSpec, { key: key2, fragment: true }));
|
|
19747
19776
|
}
|
|
19748
19777
|
return errors;
|
|
19749
19778
|
}
|
|
19750
19779
|
|
|
19751
19780
|
function validateOption(options) {
|
|
19752
19781
|
const styleSpec = options.styleSpec;
|
|
19782
|
+
const optionSpec = styleSpec.option;
|
|
19753
19783
|
const optionValue = options.value;
|
|
19754
19784
|
const isArrayOption = isObject(optionValue) && unbundle(optionValue.array) === true;
|
|
19755
19785
|
const declaredType = !isArrayOption && isObject(optionValue) ? unbundle(optionValue.type) : void 0;
|
|
@@ -19765,8 +19795,7 @@ ${JSON.stringify(filterExp, null, 2)}
|
|
|
19765
19795
|
};
|
|
19766
19796
|
return validateObject({
|
|
19767
19797
|
...options,
|
|
19768
|
-
|
|
19769
|
-
valueSpec: styleSpec.option,
|
|
19798
|
+
valueSpec: optionSpec,
|
|
19770
19799
|
objectElementValidators: {
|
|
19771
19800
|
default: validateDefault
|
|
19772
19801
|
}
|
|
@@ -20317,7 +20346,7 @@ Use an identity property function instead: ${example}.`
|
|
|
20317
20346
|
}
|
|
20318
20347
|
const errors = [];
|
|
20319
20348
|
if (options.layerType === "symbol") {
|
|
20320
|
-
if (propertyKey === "text-field" && style && !style.glyphs && !style.imports) {
|
|
20349
|
+
if (propertyKey === "text-field" && style && !style.glyphs && !style.imports && !style.fragment) {
|
|
20321
20350
|
errors.push(new ValidationError(key, value, 'use of "text-field" requires a style "glyphs" property'));
|
|
20322
20351
|
}
|
|
20323
20352
|
if (propertyKey === "text-font" && isFunction(deepUnbundle(value)) && unbundle(value.type) === "identity") {
|
|
@@ -21206,6 +21235,7 @@ Use an identity property function instead: ${example}.`
|
|
|
21206
21235
|
}
|
|
21207
21236
|
|
|
21208
21237
|
function validateStyle$2(style, styleSpec = v8, options = {}) {
|
|
21238
|
+
const root = style;
|
|
21209
21239
|
const errors = validateObject({
|
|
21210
21240
|
key: options.key || "",
|
|
21211
21241
|
value: style,
|
|
@@ -21216,7 +21246,7 @@ Use an identity property function instead: ${example}.`
|
|
|
21216
21246
|
"*": { type: "*" }
|
|
21217
21247
|
},
|
|
21218
21248
|
styleSpec,
|
|
21219
|
-
style,
|
|
21249
|
+
style: options.fragment ? { ...root, fragment: true } : root,
|
|
21220
21250
|
objectElementValidators: {
|
|
21221
21251
|
glyphs: validateGlyphsUrl
|
|
21222
21252
|
}
|