@mapbox/mapbox-gl-style-spec 14.14.0 → 14.15.0-alpha.ffa987fef46
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 +22 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.es.js +22 -18
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.ts +1 -1
- package/expression/definitions/config.ts +1 -1
- package/expression/definitions/image.ts +1 -1
- package/expression/evaluation_context.ts +3 -1
- package/expression/index.ts +16 -7
- package/expression/parsing_context.ts +7 -3
- package/package.json +1 -1
- package/reference/v8.json +1 -0
- package/types.ts +1 -0
- package/validate/validate_property.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2872,6 +2872,7 @@
|
|
|
2872
2872
|
doc: "Name of image in sprite to use for drawing an image background.",
|
|
2873
2873
|
tokens: true,
|
|
2874
2874
|
appearance: true,
|
|
2875
|
+
"use-theme": true,
|
|
2875
2876
|
"sdk-support": {
|
|
2876
2877
|
"basic functionality": {
|
|
2877
2878
|
js: "0.10.0",
|
|
@@ -14044,7 +14045,7 @@
|
|
|
14044
14045
|
'Polygon'
|
|
14045
14046
|
];
|
|
14046
14047
|
class EvaluationContext {
|
|
14047
|
-
constructor(scope, options) {
|
|
14048
|
+
constructor(scope, options, iconImageUseTheme) {
|
|
14048
14049
|
this.globals = null;
|
|
14049
14050
|
this.feature = null;
|
|
14050
14051
|
this.featureState = null;
|
|
@@ -14056,6 +14057,7 @@
|
|
|
14056
14057
|
this.featureDistanceData = null;
|
|
14057
14058
|
this.scope = scope;
|
|
14058
14059
|
this.options = options;
|
|
14060
|
+
this.iconImageUseTheme = iconImageUseTheme;
|
|
14059
14061
|
}
|
|
14060
14062
|
id() {
|
|
14061
14063
|
return this.feature && this.feature.id !== void 0 ? this.feature.id : null;
|
|
@@ -14144,7 +14146,7 @@
|
|
|
14144
14146
|
continue;
|
|
14145
14147
|
overloadParams.push(params);
|
|
14146
14148
|
overloadIndex++;
|
|
14147
|
-
signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, void 0, context._scope, context.options);
|
|
14149
|
+
signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, void 0, context._scope, context.options, context.iconImageUseTheme);
|
|
14148
14150
|
const parsedArgs = [];
|
|
14149
14151
|
let argParseFailed = false;
|
|
14150
14152
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -16280,7 +16282,7 @@
|
|
|
16280
16282
|
}
|
|
16281
16283
|
|
|
16282
16284
|
class ParsingContext {
|
|
16283
|
-
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options) {
|
|
16285
|
+
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options, iconImageUseTheme) {
|
|
16284
16286
|
this.registry = registry;
|
|
16285
16287
|
this.path = path;
|
|
16286
16288
|
this.key = path.map(part => {
|
|
@@ -16294,6 +16296,7 @@
|
|
|
16294
16296
|
this.expectedType = expectedType;
|
|
16295
16297
|
this._scope = _scope;
|
|
16296
16298
|
this.options = options;
|
|
16299
|
+
this.iconImageUseTheme = iconImageUseTheme;
|
|
16297
16300
|
}
|
|
16298
16301
|
/**
|
|
16299
16302
|
* @param expr the JSON expression to parse
|
|
@@ -16356,7 +16359,7 @@
|
|
|
16356
16359
|
}
|
|
16357
16360
|
}
|
|
16358
16361
|
if (!(parsed instanceof Literal) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
|
|
16359
|
-
const ec = new EvaluationContext(this._scope, this.options);
|
|
16362
|
+
const ec = new EvaluationContext(this._scope, this.options, this.iconImageUseTheme);
|
|
16360
16363
|
try {
|
|
16361
16364
|
parsed = new Literal(parsed.type, parsed.evaluate(ec));
|
|
16362
16365
|
} catch (e) {
|
|
@@ -16390,7 +16393,7 @@
|
|
|
16390
16393
|
let path = typeof index === 'number' ? this.path.concat(index) : this.path;
|
|
16391
16394
|
path = typeof key === 'string' ? path.concat(key) : path;
|
|
16392
16395
|
const scope = bindings ? this.scope.concat(bindings) : this.scope;
|
|
16393
|
-
return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options);
|
|
16396
|
+
return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options, this.iconImageUseTheme);
|
|
16394
16397
|
}
|
|
16395
16398
|
/**
|
|
16396
16399
|
* Push a parsing (or type checking) error into the `this.errors`
|
|
@@ -18774,10 +18777,10 @@
|
|
|
18774
18777
|
}
|
|
18775
18778
|
|
|
18776
18779
|
class StyleExpression {
|
|
18777
|
-
constructor(expression, propertySpec, scope, options) {
|
|
18780
|
+
constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18778
18781
|
this.expression = expression;
|
|
18779
18782
|
this._warningHistory = {};
|
|
18780
|
-
this._evaluator = new EvaluationContext(scope, options);
|
|
18783
|
+
this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
|
|
18781
18784
|
this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
|
|
18782
18785
|
this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
|
|
18783
18786
|
this.configDependencies = getConfigDependencies(expression);
|
|
@@ -18793,7 +18796,7 @@
|
|
|
18793
18796
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
18794
18797
|
return this.expression.evaluate(this._evaluator);
|
|
18795
18798
|
}
|
|
18796
|
-
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData) {
|
|
18799
|
+
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData, iconImageUseTheme) {
|
|
18797
18800
|
this._evaluator.globals = globals;
|
|
18798
18801
|
this._evaluator.feature = feature || null;
|
|
18799
18802
|
this._evaluator.featureState = featureState || null;
|
|
@@ -18802,6 +18805,7 @@
|
|
|
18802
18805
|
this._evaluator.formattedSection = formattedSection || null;
|
|
18803
18806
|
this._evaluator.featureTileCoord = featureTileCoord || null;
|
|
18804
18807
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
18808
|
+
this._evaluator.iconImageUseTheme = iconImageUseTheme || null;
|
|
18805
18809
|
try {
|
|
18806
18810
|
const val = this.expression.evaluate(this._evaluator);
|
|
18807
18811
|
if (val === null || val === void 0 || typeof val === 'number' && val !== val) {
|
|
@@ -18825,13 +18829,13 @@
|
|
|
18825
18829
|
function isExpression(expression) {
|
|
18826
18830
|
return Array.isArray(expression) && expression.length > 0 && typeof expression[0] === 'string' && expression[0] in expressions;
|
|
18827
18831
|
}
|
|
18828
|
-
function createExpression(expression, propertySpec, scope, options) {
|
|
18829
|
-
const parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0, void 0, void 0, scope, options);
|
|
18832
|
+
function createExpression(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18833
|
+
const parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0, void 0, void 0, scope, options, iconImageUseTheme);
|
|
18830
18834
|
const parsed = parser.parse(expression, void 0, void 0, void 0, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : void 0);
|
|
18831
18835
|
if (!parsed) {
|
|
18832
18836
|
return error(parser.errors);
|
|
18833
18837
|
}
|
|
18834
|
-
return success(new StyleExpression(parsed, propertySpec, scope, options));
|
|
18838
|
+
return success(new StyleExpression(parsed, propertySpec, scope, options, iconImageUseTheme));
|
|
18835
18839
|
}
|
|
18836
18840
|
class ZoomConstantExpression {
|
|
18837
18841
|
constructor(kind, expression, isLightConstant, isLineProgressConstant) {
|
|
@@ -18845,8 +18849,8 @@
|
|
|
18845
18849
|
evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {
|
|
18846
18850
|
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
18847
18851
|
}
|
|
18848
|
-
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {
|
|
18849
|
-
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
18852
|
+
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, iconImageUseTheme) {
|
|
18853
|
+
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, void 0, void 0, iconImageUseTheme);
|
|
18850
18854
|
}
|
|
18851
18855
|
}
|
|
18852
18856
|
class ZoomDependentExpression {
|
|
@@ -18874,8 +18878,8 @@
|
|
|
18874
18878
|
}
|
|
18875
18879
|
}
|
|
18876
18880
|
}
|
|
18877
|
-
function createPropertyExpression(expression, propertySpec, scope, options) {
|
|
18878
|
-
expression = createExpression(expression, propertySpec, scope, options);
|
|
18881
|
+
function createPropertyExpression(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18882
|
+
expression = createExpression(expression, propertySpec, scope, options, iconImageUseTheme);
|
|
18879
18883
|
if (expression.result === 'error') {
|
|
18880
18884
|
return expression;
|
|
18881
18885
|
}
|
|
@@ -18931,11 +18935,11 @@
|
|
|
18931
18935
|
};
|
|
18932
18936
|
}
|
|
18933
18937
|
}
|
|
18934
|
-
function normalizePropertyExpression(value, specification, scope, options) {
|
|
18938
|
+
function normalizePropertyExpression(value, specification, scope, options, iconImageUseTheme) {
|
|
18935
18939
|
if (isFunction(value)) {
|
|
18936
18940
|
return new StylePropertyFunction(value, specification);
|
|
18937
18941
|
} else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
|
|
18938
|
-
const expression = createPropertyExpression(value, specification, scope, options);
|
|
18942
|
+
const expression = createPropertyExpression(value, specification, scope, options, iconImageUseTheme);
|
|
18939
18943
|
if (expression.result === 'error') {
|
|
18940
18944
|
throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
|
|
18941
18945
|
}
|
|
@@ -21122,7 +21126,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
21122
21126
|
if (!layerSpec)
|
|
21123
21127
|
return [];
|
|
21124
21128
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
21125
|
-
if (
|
|
21129
|
+
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
21126
21130
|
if (isExpression(value)) {
|
|
21127
21131
|
const errors2 = [];
|
|
21128
21132
|
return errors2.concat(validate({
|