Skip to content

Commit e32cf89

Browse files
authored
Merge branch 'main' into mlt
2 parents eb80632 + a38f503 commit e32cf89

File tree

11 files changed

+333
-265
lines changed

11 files changed

+333
-265
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
### 🐞 Bug fixes
88
- _...Add new stuff here..._
99

10+
## 24.2.0
11+
12+
### ✨ Features and improvements
13+
14+
- Add note regarding visual artifacts that can appear with large width/size/offset values on vector tile layers, highlight remediation options ([#4160](https://github.com/maplibre/maplibre-gl-js/issues/4160))
15+
- Implement data-driven styling support for `line-dasharray` ([#5812](https://github.com/mapbox/mapbox-gl-js/pull/5812))
16+
17+
### 🐞 Bug fixes
18+
19+
- Replace additional spread operator (`...`) due to esbuild limitations ([#1297](https://github.com/maplibre/maplibre-style-spec/pull/1297))
20+
21+
## 24.1.1
22+
23+
### 🐞 Bug fixes
24+
25+
- Replace spread operator (`...`) due to esbuild limitations ([#1286](https://github.com/maplibre/maplibre-style-spec/pull/1286))
26+
1027
## 24.1.0
1128

1229
### ✨ Features and improvements

build/generate-docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function createLayersContent() {
355355
function createSourcesContent() {
356356
const sourcesExtraData = {
357357
vector: {
358-
doc: 'A vector tile source. Tiles must be in [Mapbox Vector Tile format](https://github.com/mapbox/vector-tile-spec). All geometric coordinates in vector tiles must be between \`-1 * extent\` and \`(extent * 2) - 1\` inclusive. All layers that use a vector source must specify a [`source-layer`](layers.md#source-layer) value.',
358+
doc: 'A vector tile source. Tiles must be in [Mapbox Vector Tile format](https://github.com/mapbox/vector-tile-spec). All geometric coordinates in vector tiles must be between \`-1 * extent\` and \`(extent * 2) - 1\` inclusive. All layers that use a vector source must specify a [`source-layer`](layers.md#source-layer) value. Note that features are only rendered within their originating tile, which may lead to visual artifacts when large values for width, radius, size or offset are specified. To mitigate rendering issues, either reduce the value of the property causing the artifact or, if you have control over the tile generation process, increase the buffer size to ensure that features are fully rendered within the tile.',
359359
example: {
360360
'maplibre-streets': {
361361
'type': 'vector',

eslint.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ export default [{
7171
"no-lonely-if": "off",
7272
"no-new": "off",
7373

74-
"no-restricted-properties": [2, {
75-
object: "Object",
76-
property: "assign",
77-
}],
78-
7974
"no-unused-vars": "off",
8075
"no-warning-comments": "error",
8176
"object-curly-spacing": ["error", "never"],

package-lock.json

Lines changed: 222 additions & 203 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@maplibre/maplibre-gl-style-spec",
33
"description": "a specification for maplibre styles",
4-
"version": "24.1.0",
4+
"version": "24.2.0",
55
"author": "MapLibre",
66
"keywords": [
77
"mapbox",
@@ -69,21 +69,21 @@
6969
"@rollup/plugin-strip": "^3.0.4",
7070
"@rollup/plugin-terser": "^0.4.4",
7171
"@rollup/plugin-typescript": "^12.1.4",
72-
"@stylistic/eslint-plugin": "^5.3.1",
72+
"@stylistic/eslint-plugin": "^5.4.0",
7373
"@types/eslint": "^9.6.1",
7474
"@types/geojson": "^7946.0.16",
75-
"@types/node": "^24.4.0",
76-
"@typescript-eslint/eslint-plugin": "^8.43.0",
77-
"@typescript-eslint/parser": "^8.42.0",
75+
"@types/node": "^24.5.2",
76+
"@typescript-eslint/eslint-plugin": "^8.44.1",
77+
"@typescript-eslint/parser": "^8.44.1",
7878
"@vitest/coverage-v8": "3.2.4",
79-
"@vitest/eslint-plugin": "^1.3.9",
79+
"@vitest/eslint-plugin": "^1.3.13",
8080
"@vitest/ui": "3.2.4",
8181
"dts-bundle-generator": "^9.5.1",
82-
"eslint": "^9.35.0",
83-
"eslint-plugin-jsdoc": "^57.0.8",
82+
"eslint": "^9.36.0",
83+
"eslint-plugin-jsdoc": "^60.5.0",
8484
"glob": "^11.0.3",
8585
"globals": "^16.4.0",
86-
"rollup": "^4.50.1",
86+
"rollup": "^4.52.3",
8787
"rollup-plugin-preserve-shebang": "^1.0.1",
8888
"semver": "^7.7.2",
8989
"ts-node": "^10.9.2",

src/expression/index.test.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

2-
import {normalizePropertyExpression} from '.'
2+
import {normalizePropertyExpression, StyleExpression} from '.'
33
import {StylePropertySpecification} from '..';
44
import {Color} from './types/color';
55
import {ColorArray} from './types/color_array';
66
import {NumberArray} from './types/number_array';
77
import {Padding} from './types/padding';
8-
import {describe, test, expect} from 'vitest';
8+
import type {Expression} from './expression';
9+
import {describe, test, expect, vi} from 'vitest';
910

1011
function stylePropertySpecification(type): StylePropertySpecification {
1112
return {
@@ -119,4 +120,28 @@ describe('normalizePropertyExpression raw values', () => {
119120
expect(expression.evaluate({zoom: 0}).values).toEqual([1,2,1,2]);
120121
})
121122

123+
});
124+
125+
describe('StyleExpressions', () => {
126+
127+
test('ignore random fields when adding global state ', () => {
128+
const expression = {
129+
evaluate: vi.fn()
130+
} as any as Expression;
131+
const styleExpression = new StyleExpression(expression, {
132+
type: null,
133+
default: 42,
134+
'property-type': 'data-driven',
135+
transition: false
136+
} as StylePropertySpecification, {x: 5} as Record<string, any>);
137+
138+
styleExpression.evaluate({zoom: 10, a: 20, b: 30} as any);
139+
expect(expression.evaluate).toHaveBeenCalled();
140+
const params = (expression.evaluate as any).mock.calls[0][0].globals;
141+
expect(params).toHaveProperty('zoom', 10);
142+
expect(params).toHaveProperty('globalState', {x: 5});
143+
expect(params).not.toHaveProperty('a');
144+
expect(params).not.toHaveProperty('b');
145+
});
146+
122147
});

src/expression/index.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ export type Feature = {
5151
'max': string;
5252
};
5353
};
54+
readonly dashes?: {
55+
[_: string]: {
56+
'min': string;
57+
'mid': string;
58+
'max': string;
59+
};
60+
};
5461
readonly geometry?: Array<Array<Point2D>>;
5562
};
5663

@@ -93,7 +100,7 @@ export class StyleExpression {
93100
formattedSection?: FormattedSection
94101
): any {
95102
if (this._globalState) {
96-
globals = {...globals, globalState: this._globalState};
103+
globals = addGlobalState(globals, this._globalState);
97104
}
98105
this._evaluator.globals = globals;
99106
this._evaluator.feature = feature;
@@ -114,7 +121,7 @@ export class StyleExpression {
114121
formattedSection?: FormattedSection
115122
): any {
116123
if (this._globalState) {
117-
globals = {...globals, globalState: this._globalState};
124+
globals = addGlobalState(globals, this._globalState);
118125
}
119126
this._evaluator.globals = globals;
120127
this._evaluator.feature = feature || null;
@@ -196,7 +203,7 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
196203
formattedSection?: FormattedSection
197204
): any {
198205
if (this._globalState) {
199-
globals = {...globals, globalState: this._globalState};
206+
globals = addGlobalState(globals, this._globalState);
200207
}
201208
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
202209
}
@@ -210,7 +217,7 @@ export class ZoomConstantExpression<Kind extends EvaluationKind> {
210217
formattedSection?: FormattedSection
211218
): any {
212219
if (this._globalState) {
213-
globals = {...globals, globalState: this._globalState};
220+
globals = addGlobalState(globals, this._globalState);
214221
}
215222
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
216223
}
@@ -244,7 +251,7 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
244251
formattedSection?: FormattedSection
245252
): any {
246253
if (this._globalState) {
247-
globals = {...globals, globalState: this._globalState};
254+
globals = addGlobalState(globals, this._globalState);
248255
}
249256
return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);
250257
}
@@ -258,7 +265,7 @@ export class ZoomDependentExpression<Kind extends EvaluationKind> {
258265
formattedSection?: FormattedSection
259266
): any {
260267
if (this._globalState) {
261-
globals = {...globals, globalState: this._globalState};
268+
globals = addGlobalState(globals, this._globalState);
262269
}
263270
return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);
264271
}
@@ -551,3 +558,23 @@ function getDefaultValue(spec: StylePropertySpecification): Value {
551558
return (spec.default === undefined ? null : spec.default);
552559
}
553560
}
561+
562+
function addGlobalState(globals: GlobalProperties, globalState: Record<string, any>): GlobalProperties {
563+
const {
564+
zoom,
565+
heatmapDensity,
566+
elevation,
567+
lineProgress,
568+
isSupportedScript,
569+
accumulated
570+
} = globals ?? {};
571+
return {
572+
zoom,
573+
heatmapDensity,
574+
elevation,
575+
lineProgress,
576+
isSupportedScript,
577+
accumulated,
578+
globalState
579+
};
580+
}

src/reference/v8.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@
591591
"android": "https://github.com/maplibre/maplibre-native/issues/2783"
592592
}
593593
}
594-
},
594+
},
595595
"baseShift": {
596596
"type": "number",
597597
"default": 0.0,
@@ -603,7 +603,7 @@
603603
"android": "https://github.com/maplibre/maplibre-native/issues/2783"
604604
}
605605
}
606-
},
606+
},
607607
"volatile": {
608608
"type": "boolean",
609609
"default": false,
@@ -5697,7 +5697,7 @@
56975697
"type": {
56985698
"type": "projectionDefinition",
56995699
"doc": "The projection definition type. Can be specified as a string, a transition state, or an expression.",
5700-
"default": "mercator",
5700+
"default": "mercator",
57015701
"property-type": "data-constant",
57025702
"transition": false,
57035703
"expression": {
@@ -6371,7 +6371,7 @@
63716371
"line-dasharray": {
63726372
"type": "array",
63736373
"value": "number",
6374-
"doc": "Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels.",
6374+
"doc": "Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Zoom-dependent expressions will be evaluated only at integer zoom levels. The only way to create an array value is using `[\"literal\", [...]]`; arrays cannot be read from or derived from feature properties.",
63756375
"minimum": 0,
63766376
"transition": true,
63776377
"units": "line widths",
@@ -6395,10 +6395,11 @@
63956395
"expression": {
63966396
"interpolated": false,
63976397
"parameters": [
6398-
"zoom"
6398+
"zoom",
6399+
"feature"
63996400
]
64006401
},
6401-
"property-type": "cross-faded"
6402+
"property-type": "cross-faded-data-driven"
64026403
},
64036404
"line-pattern": {
64046405
"type": "resolvedImage",

src/validate_style.min.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ validateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLay
7575

7676
function injectValidateSpec(validator: (options: object) => any) {
7777
return function(options) {
78-
return validator({
79-
...options,
80-
validateSpec: validate,
81-
});
78+
return validator(Object.assign({}, options, {validateSpec: validate}));
8279
};
8380
}
8481

test/integration/style-spec/tests/functions.input.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -934,15 +934,6 @@
934934
"fill-extrusion-opacity": ["get", "opacity"]
935935
}
936936
},
937-
{
938-
"id": "invalid expression - line-dasharray must use step interpolation",
939-
"type": "line",
940-
"source": "source",
941-
"source-layer": "layer",
942-
"paint": {
943-
"line-dasharray": ["interpolate", ["linear"], ["zoom"], 0, ["literal", [1, 2]], 1, ["literal", [3, 4]]]
944-
}
945-
},
946937
{
947938
"id": "invalid expression - heatmap-color must be zoom constant",
948939
"type": "heatmap",

0 commit comments

Comments
 (0)