@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.d.ts
CHANGED
|
@@ -896,6 +896,7 @@ type SymbolLayerSpecification = {
|
|
|
896
896
|
number
|
|
897
897
|
]>;
|
|
898
898
|
"icon-image"?: DataDrivenPropertyValueSpecification<ResolvedImageSpecification>;
|
|
899
|
+
"icon-image-use-theme"?: PropertyValueSpecification<string>;
|
|
899
900
|
"icon-rotate"?: DataDrivenPropertyValueSpecification<number>;
|
|
900
901
|
"icon-padding"?: PropertyValueSpecification<number>;
|
|
901
902
|
"icon-keep-upright"?: PropertyValueSpecification<boolean>;
|
|
@@ -1923,10 +1924,11 @@ declare class EvaluationContext {
|
|
|
1923
1924
|
featureDistanceData: FeatureDistanceData | null | undefined;
|
|
1924
1925
|
scope: string | null | undefined;
|
|
1925
1926
|
options: ConfigOptions | null | undefined;
|
|
1927
|
+
iconImageUseTheme: string | null | undefined;
|
|
1926
1928
|
_parseColorCache: {
|
|
1927
1929
|
[_: string]: Color | null | undefined;
|
|
1928
1930
|
};
|
|
1929
|
-
constructor(scope?: string | null, options?: ConfigOptions | null);
|
|
1931
|
+
constructor(scope?: string | null, options?: ConfigOptions | null, iconImageUseTheme?: string);
|
|
1930
1932
|
id(): string | number | null;
|
|
1931
1933
|
geometryType(): null | string;
|
|
1932
1934
|
geometry(): Array<Array<Point>> | null | undefined;
|
|
@@ -1994,12 +1996,12 @@ declare class StyleExpression {
|
|
|
1994
1996
|
[_: string]: unknown;
|
|
1995
1997
|
};
|
|
1996
1998
|
configDependencies: Set<string>;
|
|
1997
|
-
constructor(expression: Expression, propertySpec?: StylePropertySpecification, scope?: string, options?: ConfigOptions);
|
|
1999
|
+
constructor(expression: Expression, propertySpec?: StylePropertySpecification, scope?: string, options?: ConfigOptions, iconImageUseTheme?: string);
|
|
1998
2000
|
evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
|
|
1999
|
-
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
|
|
2001
|
+
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData, iconImageUseTheme?: string): any;
|
|
2000
2002
|
}
|
|
2001
2003
|
declare function isExpression(expression: unknown): boolean;
|
|
2002
|
-
declare function createExpression(expression: unknown, propertySpec?: StylePropertySpecification | null, scope?: string | null, options?: ConfigOptions | null): Result<StyleExpression, Array<ParsingError$1>>;
|
|
2004
|
+
declare function createExpression(expression: unknown, propertySpec?: StylePropertySpecification | null, scope?: string | null, options?: ConfigOptions | null, iconImageUseTheme?: string | null): Result<StyleExpression, Array<ParsingError$1>>;
|
|
2003
2005
|
declare class ZoomConstantExpression<Kind extends EvaluationKind> {
|
|
2004
2006
|
kind: Kind;
|
|
2005
2007
|
isStateDependent: boolean;
|
|
@@ -2009,7 +2011,7 @@ declare class ZoomConstantExpression<Kind extends EvaluationKind> {
|
|
|
2009
2011
|
isLineProgressConstant: boolean | null | undefined;
|
|
2010
2012
|
constructor(kind: Kind, expression: StyleExpression, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null);
|
|
2011
2013
|
evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
|
|
2012
|
-
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
|
|
2014
|
+
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, iconImageUseTheme?: string): any;
|
|
2013
2015
|
}
|
|
2014
2016
|
declare class ZoomDependentExpression<Kind extends EvaluationKind> {
|
|
2015
2017
|
kind: Kind;
|
|
@@ -2028,7 +2030,7 @@ declare class ZoomDependentExpression<Kind extends EvaluationKind> {
|
|
|
2028
2030
|
type ConstantExpression = {
|
|
2029
2031
|
kind: "constant";
|
|
2030
2032
|
configDependencies: Set<string>;
|
|
2031
|
-
readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[]) => any;
|
|
2033
|
+
readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, iconImageUseTheme?: string) => any;
|
|
2032
2034
|
};
|
|
2033
2035
|
type SourceExpression = {
|
|
2034
2036
|
kind: "source";
|
|
@@ -2053,13 +2055,13 @@ interface CompositeExpression {
|
|
|
2053
2055
|
isLightConstant: boolean | null | undefined;
|
|
2054
2056
|
isLineProgressConstant: boolean | null | undefined;
|
|
2055
2057
|
configDependencies: Set<string>;
|
|
2056
|
-
readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection) => any;
|
|
2058
|
+
readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, iconImageUseTheme?: string) => any;
|
|
2057
2059
|
readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
|
|
2058
2060
|
zoomStops: Array<number>;
|
|
2059
2061
|
interpolationType: InterpolationType | null | undefined;
|
|
2060
2062
|
}
|
|
2061
2063
|
type StylePropertyExpression = ConstantExpression | SourceExpression | CameraExpression | CompositeExpression;
|
|
2062
|
-
declare function createPropertyExpression(expression: any, propertySpec: StylePropertySpecification, scope?: string | null, options?: ConfigOptions | null): Result<StylePropertyExpression, Array<ParsingError$1>>;
|
|
2064
|
+
declare function createPropertyExpression(expression: any, propertySpec: StylePropertySpecification, scope?: string | null, options?: ConfigOptions | null, iconImageUseTheme?: string | null): Result<StylePropertyExpression, Array<ParsingError$1>>;
|
|
2063
2065
|
declare class StylePropertyFunction<T> {
|
|
2064
2066
|
_parameters: PropertyValueSpecification<T>;
|
|
2065
2067
|
_specification: StylePropertySpecification;
|
|
@@ -2077,7 +2079,7 @@ declare class StylePropertyFunction<T> {
|
|
|
2077
2079
|
_specification: StylePropertySpecification;
|
|
2078
2080
|
};
|
|
2079
2081
|
}
|
|
2080
|
-
declare function normalizePropertyExpression<T>(value: PropertyValueSpecification<T>, specification: StylePropertySpecification, scope?: string | null, options?: ConfigOptions | null): StylePropertyExpression;
|
|
2082
|
+
declare function normalizePropertyExpression<T>(value: PropertyValueSpecification<T>, specification: StylePropertySpecification, scope?: string | null, options?: ConfigOptions | null, iconImageUseTheme?: string | null): StylePropertyExpression;
|
|
2081
2083
|
/**
|
|
2082
2084
|
* Convert the given legacy filter to (the JSON representation of) an
|
|
2083
2085
|
* equivalent expression
|
package/dist/index.es.js
CHANGED
|
@@ -2866,6 +2866,7 @@ var layout_symbol = {
|
|
|
2866
2866
|
doc: "Name of image in sprite to use for drawing an image background.",
|
|
2867
2867
|
tokens: true,
|
|
2868
2868
|
appearance: true,
|
|
2869
|
+
"use-theme": true,
|
|
2869
2870
|
"sdk-support": {
|
|
2870
2871
|
"basic functionality": {
|
|
2871
2872
|
js: "0.10.0",
|
|
@@ -14038,7 +14039,7 @@ const geometryTypes = [
|
|
|
14038
14039
|
'Polygon'
|
|
14039
14040
|
];
|
|
14040
14041
|
class EvaluationContext {
|
|
14041
|
-
constructor(scope, options) {
|
|
14042
|
+
constructor(scope, options, iconImageUseTheme) {
|
|
14042
14043
|
this.globals = null;
|
|
14043
14044
|
this.feature = null;
|
|
14044
14045
|
this.featureState = null;
|
|
@@ -14050,6 +14051,7 @@ class EvaluationContext {
|
|
|
14050
14051
|
this.featureDistanceData = null;
|
|
14051
14052
|
this.scope = scope;
|
|
14052
14053
|
this.options = options;
|
|
14054
|
+
this.iconImageUseTheme = iconImageUseTheme;
|
|
14053
14055
|
}
|
|
14054
14056
|
id() {
|
|
14055
14057
|
return this.feature && this.feature.id !== void 0 ? this.feature.id : null;
|
|
@@ -14138,7 +14140,7 @@ class CompoundExpression {
|
|
|
14138
14140
|
continue;
|
|
14139
14141
|
overloadParams.push(params);
|
|
14140
14142
|
overloadIndex++;
|
|
14141
|
-
signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, void 0, context._scope, context.options);
|
|
14143
|
+
signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, void 0, context._scope, context.options, context.iconImageUseTheme);
|
|
14142
14144
|
const parsedArgs = [];
|
|
14143
14145
|
let argParseFailed = false;
|
|
14144
14146
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -16274,7 +16276,7 @@ class Var {
|
|
|
16274
16276
|
}
|
|
16275
16277
|
|
|
16276
16278
|
class ParsingContext {
|
|
16277
|
-
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options) {
|
|
16279
|
+
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options, iconImageUseTheme) {
|
|
16278
16280
|
this.registry = registry;
|
|
16279
16281
|
this.path = path;
|
|
16280
16282
|
this.key = path.map(part => {
|
|
@@ -16288,6 +16290,7 @@ class ParsingContext {
|
|
|
16288
16290
|
this.expectedType = expectedType;
|
|
16289
16291
|
this._scope = _scope;
|
|
16290
16292
|
this.options = options;
|
|
16293
|
+
this.iconImageUseTheme = iconImageUseTheme;
|
|
16291
16294
|
}
|
|
16292
16295
|
/**
|
|
16293
16296
|
* @param expr the JSON expression to parse
|
|
@@ -16350,7 +16353,7 @@ class ParsingContext {
|
|
|
16350
16353
|
}
|
|
16351
16354
|
}
|
|
16352
16355
|
if (!(parsed instanceof Literal) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
|
|
16353
|
-
const ec = new EvaluationContext(this._scope, this.options);
|
|
16356
|
+
const ec = new EvaluationContext(this._scope, this.options, this.iconImageUseTheme);
|
|
16354
16357
|
try {
|
|
16355
16358
|
parsed = new Literal(parsed.type, parsed.evaluate(ec));
|
|
16356
16359
|
} catch (e) {
|
|
@@ -16384,7 +16387,7 @@ class ParsingContext {
|
|
|
16384
16387
|
let path = typeof index === 'number' ? this.path.concat(index) : this.path;
|
|
16385
16388
|
path = typeof key === 'string' ? path.concat(key) : path;
|
|
16386
16389
|
const scope = bindings ? this.scope.concat(bindings) : this.scope;
|
|
16387
|
-
return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options);
|
|
16390
|
+
return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options, this.iconImageUseTheme);
|
|
16388
16391
|
}
|
|
16389
16392
|
/**
|
|
16390
16393
|
* Push a parsing (or type checking) error into the `this.errors`
|
|
@@ -18768,10 +18771,10 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
|
|
|
18768
18771
|
}
|
|
18769
18772
|
|
|
18770
18773
|
class StyleExpression {
|
|
18771
|
-
constructor(expression, propertySpec, scope, options) {
|
|
18774
|
+
constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18772
18775
|
this.expression = expression;
|
|
18773
18776
|
this._warningHistory = {};
|
|
18774
|
-
this._evaluator = new EvaluationContext(scope, options);
|
|
18777
|
+
this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
|
|
18775
18778
|
this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
|
|
18776
18779
|
this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
|
|
18777
18780
|
this.configDependencies = getConfigDependencies(expression);
|
|
@@ -18787,7 +18790,7 @@ class StyleExpression {
|
|
|
18787
18790
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
18788
18791
|
return this.expression.evaluate(this._evaluator);
|
|
18789
18792
|
}
|
|
18790
|
-
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData) {
|
|
18793
|
+
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData, iconImageUseTheme) {
|
|
18791
18794
|
this._evaluator.globals = globals;
|
|
18792
18795
|
this._evaluator.feature = feature || null;
|
|
18793
18796
|
this._evaluator.featureState = featureState || null;
|
|
@@ -18796,6 +18799,7 @@ class StyleExpression {
|
|
|
18796
18799
|
this._evaluator.formattedSection = formattedSection || null;
|
|
18797
18800
|
this._evaluator.featureTileCoord = featureTileCoord || null;
|
|
18798
18801
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
18802
|
+
this._evaluator.iconImageUseTheme = iconImageUseTheme || null;
|
|
18799
18803
|
try {
|
|
18800
18804
|
const val = this.expression.evaluate(this._evaluator);
|
|
18801
18805
|
if (val === null || val === void 0 || typeof val === 'number' && val !== val) {
|
|
@@ -18819,13 +18823,13 @@ class StyleExpression {
|
|
|
18819
18823
|
function isExpression(expression) {
|
|
18820
18824
|
return Array.isArray(expression) && expression.length > 0 && typeof expression[0] === 'string' && expression[0] in expressions;
|
|
18821
18825
|
}
|
|
18822
|
-
function createExpression(expression, propertySpec, scope, options) {
|
|
18823
|
-
const parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0, void 0, void 0, scope, options);
|
|
18826
|
+
function createExpression(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18827
|
+
const parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0, void 0, void 0, scope, options, iconImageUseTheme);
|
|
18824
18828
|
const parsed = parser.parse(expression, void 0, void 0, void 0, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : void 0);
|
|
18825
18829
|
if (!parsed) {
|
|
18826
18830
|
return error(parser.errors);
|
|
18827
18831
|
}
|
|
18828
|
-
return success(new StyleExpression(parsed, propertySpec, scope, options));
|
|
18832
|
+
return success(new StyleExpression(parsed, propertySpec, scope, options, iconImageUseTheme));
|
|
18829
18833
|
}
|
|
18830
18834
|
class ZoomConstantExpression {
|
|
18831
18835
|
constructor(kind, expression, isLightConstant, isLineProgressConstant) {
|
|
@@ -18839,8 +18843,8 @@ class ZoomConstantExpression {
|
|
|
18839
18843
|
evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {
|
|
18840
18844
|
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
18841
18845
|
}
|
|
18842
|
-
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {
|
|
18843
|
-
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
18846
|
+
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, iconImageUseTheme) {
|
|
18847
|
+
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, void 0, void 0, iconImageUseTheme);
|
|
18844
18848
|
}
|
|
18845
18849
|
}
|
|
18846
18850
|
class ZoomDependentExpression {
|
|
@@ -18868,8 +18872,8 @@ class ZoomDependentExpression {
|
|
|
18868
18872
|
}
|
|
18869
18873
|
}
|
|
18870
18874
|
}
|
|
18871
|
-
function createPropertyExpression(expression, propertySpec, scope, options) {
|
|
18872
|
-
expression = createExpression(expression, propertySpec, scope, options);
|
|
18875
|
+
function createPropertyExpression(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18876
|
+
expression = createExpression(expression, propertySpec, scope, options, iconImageUseTheme);
|
|
18873
18877
|
if (expression.result === 'error') {
|
|
18874
18878
|
return expression;
|
|
18875
18879
|
}
|
|
@@ -18925,11 +18929,11 @@ class StylePropertyFunction {
|
|
|
18925
18929
|
};
|
|
18926
18930
|
}
|
|
18927
18931
|
}
|
|
18928
|
-
function normalizePropertyExpression(value, specification, scope, options) {
|
|
18932
|
+
function normalizePropertyExpression(value, specification, scope, options, iconImageUseTheme) {
|
|
18929
18933
|
if (isFunction(value)) {
|
|
18930
18934
|
return new StylePropertyFunction(value, specification);
|
|
18931
18935
|
} else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
|
|
18932
|
-
const expression = createPropertyExpression(value, specification, scope, options);
|
|
18936
|
+
const expression = createPropertyExpression(value, specification, scope, options, iconImageUseTheme);
|
|
18933
18937
|
if (expression.result === 'error') {
|
|
18934
18938
|
throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
|
|
18935
18939
|
}
|
|
@@ -21116,7 +21120,7 @@ function validateProperty(options, propertyType) {
|
|
|
21116
21120
|
if (!layerSpec)
|
|
21117
21121
|
return [];
|
|
21118
21122
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
21119
|
-
if (
|
|
21123
|
+
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
21120
21124
|
if (isExpression(value)) {
|
|
21121
21125
|
const errors2 = [];
|
|
21122
21126
|
return errors2.concat(validate({
|