@mapbox/mapbox-gl-style-spec 14.14.0-beta.2 → 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/composite.ts +5 -8
- package/dist/index.cjs +53 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +48 -24
- package/dist/index.es.js +53 -27
- 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/distance.ts +2 -3
- package/expression/definitions/image.ts +1 -1
- package/expression/definitions/index.ts +4 -20
- package/expression/definitions/interpolate.ts +6 -9
- package/expression/definitions/within.ts +14 -15
- package/expression/evaluation_context.ts +3 -1
- package/expression/index.ts +18 -11
- package/expression/parsing_context.ts +7 -3
- package/group_by_layout.ts +3 -6
- package/migrate.ts +6 -8
- package/package.json +1 -1
- package/read_style.ts +1 -2
- package/reference/v8.json +26 -0
- package/types.ts +35 -13
- package/util/geometry_util.ts +1 -2
- package/validate/validate.ts +5 -6
- package/validate/validate_array.ts +2 -2
- package/validate/validate_enum.ts +2 -2
- package/validate/validate_expression.ts +1 -2
- package/validate/validate_filter.ts +3 -4
- package/validate/validate_fog.ts +2 -5
- package/validate/validate_function.ts +6 -10
- package/validate/validate_iconset.ts +1 -2
- package/validate/validate_layer.ts +1 -2
- package/validate/validate_light.ts +1 -4
- package/validate/validate_lights.ts +1 -7
- package/validate/validate_model.ts +1 -4
- package/validate/validate_projection.ts +1 -2
- package/validate/validate_property.ts +3 -7
- package/validate/validate_rain.ts +1 -4
- package/validate/validate_snow.ts +1 -4
- package/validate/validate_source.ts +2 -3
- package/validate/validate_terrain.ts +1 -5
- package/validate_mapbox_api_supported.ts +2 -4
- package/validate_style.ts +1 -2
- package/visit.ts +2 -4
package/composite.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
// @ts-nocheck
|
|
1
|
+
import type {StyleSpecification} from './types';
|
|
3
2
|
|
|
4
|
-
export default function (style) {
|
|
5
|
-
const styleIDs = [];
|
|
6
|
-
const sourceIDs = [];
|
|
7
|
-
const compositedSourceLayers = [];
|
|
3
|
+
export default function (style: StyleSpecification): StyleSpecification {
|
|
4
|
+
const styleIDs: string[] = [];
|
|
5
|
+
const sourceIDs: string[] = [];
|
|
6
|
+
const compositedSourceLayers: string[] = [];
|
|
8
7
|
|
|
9
8
|
for (const id in style.sources) {
|
|
10
9
|
const source = style.sources[id];
|
|
@@ -21,7 +20,6 @@ export default function (style) {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
if (styleIDs.length < 2)
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
25
23
|
return style;
|
|
26
24
|
|
|
27
25
|
styleIDs.forEach((id) => {
|
|
@@ -49,6 +47,5 @@ export default function (style) {
|
|
|
49
47
|
}
|
|
50
48
|
});
|
|
51
49
|
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
53
50
|
return style;
|
|
54
51
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1513,6 +1513,29 @@
|
|
|
1513
1513
|
paint: {
|
|
1514
1514
|
type: "paint",
|
|
1515
1515
|
doc: "Default paint properties for this layer."
|
|
1516
|
+
},
|
|
1517
|
+
appearances: {
|
|
1518
|
+
type: "array",
|
|
1519
|
+
value: "appearance",
|
|
1520
|
+
"supported-layer-types": [
|
|
1521
|
+
"symbol"
|
|
1522
|
+
],
|
|
1523
|
+
"private": true,
|
|
1524
|
+
doc: "Conditional styling applied to layer features based on dynamic conditions. If multiple conditions are true, only the first matching appearance will be applied. Only properties marked with 'Can be used in appearances' are supported."
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
var appearance = {
|
|
1528
|
+
condition: {
|
|
1529
|
+
type: "expression",
|
|
1530
|
+
doc: "A boolean expression that determines when this appearance should be applied."
|
|
1531
|
+
},
|
|
1532
|
+
name: {
|
|
1533
|
+
type: "string",
|
|
1534
|
+
doc: "Optional name for this appearance. Non-empty names should be unique within a layer."
|
|
1535
|
+
},
|
|
1536
|
+
properties: {
|
|
1537
|
+
type: "*",
|
|
1538
|
+
doc: "Style properties to apply when the condition is met."
|
|
1516
1539
|
}
|
|
1517
1540
|
};
|
|
1518
1541
|
var layout = [
|
|
@@ -2704,6 +2727,7 @@
|
|
|
2704
2727
|
minimum: 0,
|
|
2705
2728
|
units: "factor of the original icon size",
|
|
2706
2729
|
doc: "Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image.",
|
|
2730
|
+
appearance: true,
|
|
2707
2731
|
requires: [
|
|
2708
2732
|
"icon-image"
|
|
2709
2733
|
],
|
|
@@ -2847,6 +2871,8 @@
|
|
|
2847
2871
|
type: "resolvedImage",
|
|
2848
2872
|
doc: "Name of image in sprite to use for drawing an image background.",
|
|
2849
2873
|
tokens: true,
|
|
2874
|
+
appearance: true,
|
|
2875
|
+
"use-theme": true,
|
|
2850
2876
|
"sdk-support": {
|
|
2851
2877
|
"basic functionality": {
|
|
2852
2878
|
js: "0.10.0",
|
|
@@ -2874,6 +2900,7 @@
|
|
|
2874
2900
|
period: 360,
|
|
2875
2901
|
units: "degrees",
|
|
2876
2902
|
doc: "Rotates the icon clockwise.",
|
|
2903
|
+
appearance: true,
|
|
2877
2904
|
requires: [
|
|
2878
2905
|
"icon-image"
|
|
2879
2906
|
],
|
|
@@ -2962,6 +2989,7 @@
|
|
|
2962
2989
|
0
|
|
2963
2990
|
],
|
|
2964
2991
|
doc: "Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up.",
|
|
2992
|
+
appearance: true,
|
|
2965
2993
|
requires: [
|
|
2966
2994
|
"icon-image"
|
|
2967
2995
|
],
|
|
@@ -10188,6 +10216,7 @@
|
|
|
10188
10216
|
source_image: source_image,
|
|
10189
10217
|
source_model: source_model,
|
|
10190
10218
|
layer: layer,
|
|
10219
|
+
appearance: appearance,
|
|
10191
10220
|
layout: layout,
|
|
10192
10221
|
layout_background: layout_background,
|
|
10193
10222
|
layout_sky: layout_sky,
|
|
@@ -14016,7 +14045,7 @@
|
|
|
14016
14045
|
'Polygon'
|
|
14017
14046
|
];
|
|
14018
14047
|
class EvaluationContext {
|
|
14019
|
-
constructor(scope, options) {
|
|
14048
|
+
constructor(scope, options, iconImageUseTheme) {
|
|
14020
14049
|
this.globals = null;
|
|
14021
14050
|
this.feature = null;
|
|
14022
14051
|
this.featureState = null;
|
|
@@ -14028,6 +14057,7 @@
|
|
|
14028
14057
|
this.featureDistanceData = null;
|
|
14029
14058
|
this.scope = scope;
|
|
14030
14059
|
this.options = options;
|
|
14060
|
+
this.iconImageUseTheme = iconImageUseTheme;
|
|
14031
14061
|
}
|
|
14032
14062
|
id() {
|
|
14033
14063
|
return this.feature && this.feature.id !== void 0 ? this.feature.id : null;
|
|
@@ -14116,7 +14146,7 @@
|
|
|
14116
14146
|
continue;
|
|
14117
14147
|
overloadParams.push(params);
|
|
14118
14148
|
overloadIndex++;
|
|
14119
|
-
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);
|
|
14120
14150
|
const parsedArgs = [];
|
|
14121
14151
|
let argParseFailed = false;
|
|
14122
14152
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -16252,7 +16282,7 @@
|
|
|
16252
16282
|
}
|
|
16253
16283
|
|
|
16254
16284
|
class ParsingContext {
|
|
16255
|
-
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options) {
|
|
16285
|
+
constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options, iconImageUseTheme) {
|
|
16256
16286
|
this.registry = registry;
|
|
16257
16287
|
this.path = path;
|
|
16258
16288
|
this.key = path.map(part => {
|
|
@@ -16266,6 +16296,7 @@
|
|
|
16266
16296
|
this.expectedType = expectedType;
|
|
16267
16297
|
this._scope = _scope;
|
|
16268
16298
|
this.options = options;
|
|
16299
|
+
this.iconImageUseTheme = iconImageUseTheme;
|
|
16269
16300
|
}
|
|
16270
16301
|
/**
|
|
16271
16302
|
* @param expr the JSON expression to parse
|
|
@@ -16328,7 +16359,7 @@
|
|
|
16328
16359
|
}
|
|
16329
16360
|
}
|
|
16330
16361
|
if (!(parsed instanceof Literal) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
|
|
16331
|
-
const ec = new EvaluationContext(this._scope, this.options);
|
|
16362
|
+
const ec = new EvaluationContext(this._scope, this.options, this.iconImageUseTheme);
|
|
16332
16363
|
try {
|
|
16333
16364
|
parsed = new Literal(parsed.type, parsed.evaluate(ec));
|
|
16334
16365
|
} catch (e) {
|
|
@@ -16362,7 +16393,7 @@
|
|
|
16362
16393
|
let path = typeof index === 'number' ? this.path.concat(index) : this.path;
|
|
16363
16394
|
path = typeof key === 'string' ? path.concat(key) : path;
|
|
16364
16395
|
const scope = bindings ? this.scope.concat(bindings) : this.scope;
|
|
16365
|
-
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);
|
|
16366
16397
|
}
|
|
16367
16398
|
/**
|
|
16368
16399
|
* Push a parsing (or type checking) error into the `this.errors`
|
|
@@ -18006,7 +18037,6 @@
|
|
|
18006
18037
|
overloads: [
|
|
18007
18038
|
[
|
|
18008
18039
|
[StringType],
|
|
18009
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
18010
18040
|
(ctx, [key]) => get(key.evaluate(ctx), ctx.properties())
|
|
18011
18041
|
],
|
|
18012
18042
|
[
|
|
@@ -18022,7 +18052,6 @@
|
|
|
18022
18052
|
'feature-state': [
|
|
18023
18053
|
ValueType,
|
|
18024
18054
|
[StringType],
|
|
18025
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
18026
18055
|
(ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})
|
|
18027
18056
|
],
|
|
18028
18057
|
'properties': [
|
|
@@ -18748,10 +18777,10 @@
|
|
|
18748
18777
|
}
|
|
18749
18778
|
|
|
18750
18779
|
class StyleExpression {
|
|
18751
|
-
constructor(expression, propertySpec, scope, options) {
|
|
18780
|
+
constructor(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18752
18781
|
this.expression = expression;
|
|
18753
18782
|
this._warningHistory = {};
|
|
18754
|
-
this._evaluator = new EvaluationContext(scope, options);
|
|
18783
|
+
this._evaluator = new EvaluationContext(scope, options, iconImageUseTheme);
|
|
18755
18784
|
this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;
|
|
18756
18785
|
this._enumValues = propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;
|
|
18757
18786
|
this.configDependencies = getConfigDependencies(expression);
|
|
@@ -18767,7 +18796,7 @@
|
|
|
18767
18796
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
18768
18797
|
return this.expression.evaluate(this._evaluator);
|
|
18769
18798
|
}
|
|
18770
|
-
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData) {
|
|
18799
|
+
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection, featureTileCoord, featureDistanceData, iconImageUseTheme) {
|
|
18771
18800
|
this._evaluator.globals = globals;
|
|
18772
18801
|
this._evaluator.feature = feature || null;
|
|
18773
18802
|
this._evaluator.featureState = featureState || null;
|
|
@@ -18776,6 +18805,7 @@
|
|
|
18776
18805
|
this._evaluator.formattedSection = formattedSection || null;
|
|
18777
18806
|
this._evaluator.featureTileCoord = featureTileCoord || null;
|
|
18778
18807
|
this._evaluator.featureDistanceData = featureDistanceData || null;
|
|
18808
|
+
this._evaluator.iconImageUseTheme = iconImageUseTheme || null;
|
|
18779
18809
|
try {
|
|
18780
18810
|
const val = this.expression.evaluate(this._evaluator);
|
|
18781
18811
|
if (val === null || val === void 0 || typeof val === 'number' && val !== val) {
|
|
@@ -18799,13 +18829,13 @@
|
|
|
18799
18829
|
function isExpression(expression) {
|
|
18800
18830
|
return Array.isArray(expression) && expression.length > 0 && typeof expression[0] === 'string' && expression[0] in expressions;
|
|
18801
18831
|
}
|
|
18802
|
-
function createExpression(expression, propertySpec, scope, options) {
|
|
18803
|
-
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);
|
|
18804
18834
|
const parsed = parser.parse(expression, void 0, void 0, void 0, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : void 0);
|
|
18805
18835
|
if (!parsed) {
|
|
18806
18836
|
return error(parser.errors);
|
|
18807
18837
|
}
|
|
18808
|
-
return success(new StyleExpression(parsed, propertySpec, scope, options));
|
|
18838
|
+
return success(new StyleExpression(parsed, propertySpec, scope, options, iconImageUseTheme));
|
|
18809
18839
|
}
|
|
18810
18840
|
class ZoomConstantExpression {
|
|
18811
18841
|
constructor(kind, expression, isLightConstant, isLineProgressConstant) {
|
|
@@ -18819,8 +18849,8 @@
|
|
|
18819
18849
|
evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {
|
|
18820
18850
|
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
|
|
18821
18851
|
}
|
|
18822
|
-
evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {
|
|
18823
|
-
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);
|
|
18824
18854
|
}
|
|
18825
18855
|
}
|
|
18826
18856
|
class ZoomDependentExpression {
|
|
@@ -18848,8 +18878,8 @@
|
|
|
18848
18878
|
}
|
|
18849
18879
|
}
|
|
18850
18880
|
}
|
|
18851
|
-
function createPropertyExpression(expression, propertySpec, scope, options) {
|
|
18852
|
-
expression = createExpression(expression, propertySpec, scope, options);
|
|
18881
|
+
function createPropertyExpression(expression, propertySpec, scope, options, iconImageUseTheme) {
|
|
18882
|
+
expression = createExpression(expression, propertySpec, scope, options, iconImageUseTheme);
|
|
18853
18883
|
if (expression.result === 'error') {
|
|
18854
18884
|
return expression;
|
|
18855
18885
|
}
|
|
@@ -18905,11 +18935,11 @@
|
|
|
18905
18935
|
};
|
|
18906
18936
|
}
|
|
18907
18937
|
}
|
|
18908
|
-
function normalizePropertyExpression(value, specification, scope, options) {
|
|
18938
|
+
function normalizePropertyExpression(value, specification, scope, options, iconImageUseTheme) {
|
|
18909
18939
|
if (isFunction(value)) {
|
|
18910
18940
|
return new StylePropertyFunction(value, specification);
|
|
18911
18941
|
} else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
|
|
18912
|
-
const expression = createPropertyExpression(value, specification, scope, options);
|
|
18942
|
+
const expression = createPropertyExpression(value, specification, scope, options, iconImageUseTheme);
|
|
18913
18943
|
if (expression.result === 'error') {
|
|
18914
18944
|
throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
|
|
18915
18945
|
}
|
|
@@ -19808,11 +19838,11 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
19808
19838
|
migrated = true;
|
|
19809
19839
|
}
|
|
19810
19840
|
if (style.version === 8) {
|
|
19811
|
-
|
|
19841
|
+
style = migrateToExpressions(style);
|
|
19812
19842
|
migrated = true;
|
|
19813
19843
|
}
|
|
19814
19844
|
if (!migrated) {
|
|
19815
|
-
throw new Error(
|
|
19845
|
+
throw new Error(`Cannot migrate from ${ style.version }`);
|
|
19816
19846
|
}
|
|
19817
19847
|
return style;
|
|
19818
19848
|
}
|
|
@@ -21096,7 +21126,7 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
21096
21126
|
if (!layerSpec)
|
|
21097
21127
|
return [];
|
|
21098
21128
|
const useThemeMatch = propertyKey.match(/^(.*)-use-theme$/);
|
|
21099
|
-
if (
|
|
21129
|
+
if (useThemeMatch && layerSpec[useThemeMatch[1]]) {
|
|
21100
21130
|
if (isExpression(value)) {
|
|
21101
21131
|
const errors2 = [];
|
|
21102
21132
|
return errors2.concat(validate({
|
|
@@ -21115,7 +21145,6 @@ ${ JSON.stringify(filterExp, null, 2) }
|
|
|
21115
21145
|
},
|
|
21116
21146
|
style,
|
|
21117
21147
|
styleSpec,
|
|
21118
|
-
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'expressionContext' does not exist in type 'ValidationOptions'.
|
|
21119
21148
|
expressionContext: 'property',
|
|
21120
21149
|
propertyType,
|
|
21121
21150
|
propertyKey
|
|
@@ -21174,7 +21203,6 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21174
21203
|
valueSpec,
|
|
21175
21204
|
style,
|
|
21176
21205
|
styleSpec,
|
|
21177
|
-
// @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'expressionContext' does not exist in type 'ValidationOptions'.
|
|
21178
21206
|
expressionContext: 'property',
|
|
21179
21207
|
propertyType,
|
|
21180
21208
|
propertyKey
|
|
@@ -21827,9 +21855,7 @@ Use an identity property function instead: ${ example }.`)];
|
|
|
21827
21855
|
}
|
|
21828
21856
|
|
|
21829
21857
|
const VALIDATORS = {
|
|
21830
|
-
'*'()
|
|
21831
|
-
return [];
|
|
21832
|
-
},
|
|
21858
|
+
'*': () => [],
|
|
21833
21859
|
'array': validateArray,
|
|
21834
21860
|
'boolean': validateBoolean,
|
|
21835
21861
|
'number': validateNumber,
|