Skip to content

Commit

Permalink
Merge branch 'maplibre:main' into cloer/d50
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLoer authored Apr 27, 2023
2 parents 8490e3b + 4f849af commit ac48493
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-style-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
with:
tag: ${{ steps.prepare_release.outputs.version_tag }}
name: ${{steps.prepare_release.outputs.version_tag }}
body: ${{ steps.release_notes.outputs.release_notes }}
bodyFile: ${{ steps.release_notes.outputs.release_notes }}
draft: false
prerelease: false

Expand All @@ -82,4 +82,4 @@ jobs:
run: |
npm publish --access=public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
## main

## 19.0.1

### 🐛 Bug fixes

* Restore support for `Color` instances in `Color.parse` [#128](https://github.com/maplibre/maplibre-style-spec/pull/128)


## 19.0.0

### ✨ Features and improvements

* Add support for defining colors using CSS Color 4 syntax [#94](https://github.com/maplibre/maplibre-style-spec/pull/94)
* [Breaking] Interpretation of interpolation of colors with alpha channel equal to 0 has changed. When interpolating colors with alpha channel equal to 0, the values of the other color channels in the specified color space are included in the calculation. Previously they were ignored and only the alpha value of the other, not fully transparent, color was interpolated. [#94](https://github.com/maplibre/maplibre-style-spec/pull/94)

### 🐛 Bug fixes

* Fix incorrect color interpolation in HCL and LAB color spaces when interpolation results are outside the sRGB gamut. [#94](https://github.com/maplibre/maplibre-style-spec/pull/94)

### Breaking changes

Interpretation of interpolation of colors with alpha channel equal to 0 has changed. When interpolating colors with alpha channel equal to 0, the values of the other color channels in the specified color space are included in the calculation. Previously they were ignored and only the alpha value of the other, not fully transparent, color was interpolated. [#94](https://github.com/maplibre/maplibre-style-spec/pull/94)


## 18.0.0
* The maplibre style specification and utilities now has it's own repository. The major bump is mainly a precautionary measure, in case the restructuring causes friction.

## 17.1.0
* Add support for multiple sprites in one style (#1805)
* Add support for multiple sprites in one style [#1805](https://github.com/maplibre/maplibre-style-spec/pull/1805)

## 17.0.2

* Fix errors when running style-spec bin scripts and added missing help. Removed unnecessary script 'gl-style-composite'. ([#1971](https://github.com/maplibre/maplibre-gl-js/pull/1971))
* Fix errors when running style-spec bin scripts and added missing help. Removed unnecessary script 'gl-style-composite'. [#1971](https://github.com/maplibre/maplibre-gl-js/pull/1971)

## 17.0.1

Expand Down
12 changes: 12 additions & 0 deletions docs/public/maplibre-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/src/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {useNavigate} from 'solid-start';
import style from './header.module.scss';
import {setShowNavOverlay} from '../app/app';

const logo = `${import.meta.env.BASE_URL}maplibre-logo-big.svg`;
const logo = `${import.meta.env.BASE_URL}maplibre-logo-dark.svg`;

export function Header() {
const navigate = useNavigate();
Expand Down
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@maplibre/maplibre-gl-style-spec",
"description": "a specification for maplibre gl styles",
"version": "18.0.1",
"version": "19.0.1",
"author": "MapLibre",
"keywords": [
"mapbox",
Expand Down Expand Up @@ -52,7 +52,7 @@
},
"sideEffects": false,
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
Expand All @@ -65,7 +65,7 @@
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"dts-bundle-generator": "^7.2.0",
"dts-bundle-generator": "^8.0.1",
"eslint": "^8.38.0",
"eslint-config-mourner": "^3.0.0",
"eslint-plugin-html": "^7.1.0",
Expand All @@ -76,10 +76,10 @@
"jest": "^29.5.0",
"jest-canvas-mock": "^2.5.0",
"jest-environment-jsdom": "^29.5.0",
"rollup": "^3.20.2",
"rollup": "^3.20.4",
"rollup-plugin-preserve-shebang": "^1.0.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"semver": "^7.3.8",
"semver": "^7.4.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
Expand Down
34 changes: 34 additions & 0 deletions src/function/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,40 @@ describe('exponential function', () => {

});

test('zoom-and-property function, color', () => {
const f = createFunction({
type: 'exponential',
property: 'prop',
stops: [
[{zoom: 0, value: 0}, 'red'], [{zoom: 1, value: 0}, 'blue'],
[{zoom: 0, value: 1}, 'lime'], [{zoom: 1, value: 1}, 'magenta'],
],
}, {
type: 'color',
}).evaluate;

expect(f({zoom: 0.0}, {properties: {prop: 0}})).toEqual(new Color(1, 0, 0, 1));
expect(f({zoom: 1.0}, {properties: {prop: 0}})).toEqual(new Color(0, 0, 1, 1));
expect(f({zoom: 0.5}, {properties: {prop: 1}})).toEqual(new Color(0.5, 0.5, 0.5, 1));
});

test('zoom-and-property function, padding', () => {
const f = createFunction({
type: 'exponential',
property: 'prop',
stops: [
[{zoom: 0, value: 0}, [2]], [{zoom: 1, value: 0}, [4]],
[{zoom: 0, value: 1}, [6]], [{zoom: 1, value: 1}, [8]],
],
}, {
type: 'padding',
}).evaluate;

expect(f({zoom: 0.0}, {properties: {prop: 0}})).toEqual(new Padding([2, 2, 2, 2]));
expect(f({zoom: 1.0}, {properties: {prop: 0}})).toEqual(new Padding([4, 4, 4, 4]));
expect(f({zoom: 0.5}, {properties: {prop: 1}})).toEqual(new Padding([7, 7, 7, 7]));
});

});

describe('interval function', () => {
Expand Down
30 changes: 30 additions & 0 deletions src/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,34 @@ describe('migrate', () => {
]);
expect(validate(migrated, v8)).toEqual([]);
});

test('converts colors to supported format', () => {
const migrated = migrate({
version: 8,
sources: {},
layers: [{
id: '1',
type: 'fill',
source: 'vector',
paint: {
'fill-color': 'hsl(100,0.3,.2)',
'fill-outline-color': [
'interpolate', ['linear'], ['zoom'],
0, 'hsl(110, 0.7, 0.055)',
10, 'hsla(330,0.85,50%)',
],
},
}],
});

expect(migrated.layers[0].paint).toEqual({
'fill-color': 'hsl(100,30%,20%)',
'fill-outline-color': [
'interpolate', ['linear'], ['zoom'],
0, 'hsl(110,70%,5.5%)',
10, 'hsl(330,85%,50%)',
],
});
});

});
8 changes: 8 additions & 0 deletions src/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import migrateToV8 from './migrate/v8';
import migrateToExpressions from './migrate/expressions';
import migrateColors from './migrate/migrate_colors';
import {eachProperty} from './visit';
import type {StyleSpecification} from './types.g';

/**
Expand Down Expand Up @@ -29,6 +31,12 @@ export default function migrate(style: StyleSpecification): StyleSpecification {
migrated = true;
}

eachProperty(style, {paint: true, layout: true}, ({value, reference, set}) => {
if (reference.type === 'color') {
set(migrateColors(value));
}
});

if (!migrated) {
throw new Error(`Cannot migrate from ${style.version}`);
}
Expand Down
24 changes: 24 additions & 0 deletions src/migrate/migrate_colors.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import migrateColors from './migrate_colors';

describe('migrate colors', () => {

test('should convert hsl to a format compliant with CSS Color specification', () => {
expect(migrateColors('hsla(0, 0, 0, 0)')).toBe('hsla(0,0%,0%,0)');
expect(migrateColors('hsl(900, 0.15, 90%)')).toBe('hsl(900,15%,90%)');
expect(migrateColors('hsla(900, .15, .9)')).toBe('hsl(900,15%,90%)');
expect(migrateColors('hsl(900, 15%, 90%)')).toBe('hsl(900,15%,90%)');
expect(migrateColors('hsla(900, 15%, 90%)')).toBe('hsl(900,15%,90%)');
expect(migrateColors('hsla(900, 15%, 90%, 1)')).toBe('hsla(900,15%,90%,1)');
expect(migrateColors([
'interpolate', ['linear'], ['zoom'],
0, 'hsla(900,0.85,0.05,0)',
10, 'hsla(900, .20, .0155, 1)',
])).toEqual([
'interpolate', ['linear'], ['zoom'],
0, 'hsla(900,85%,5%,0)',
10, 'hsla(900,20%,1.55%,1)',
]);
expect(migrateColors('hsl(9001590)')).toBe('hsl(9001590)'); // invalid - no changes
});

});
Loading

0 comments on commit ac48493

Please sign in to comment.