@maplibre/maplibre-gl-style-spec
Advanced tools
Comparing version 19.1.0 to 19.2.0
## main | ||
## 19.2.0 | ||
### ✨ Features and improvements | ||
* Remove mapbox reference from docs and test cases [#111](https://github.com/maplibre/maplibre-style-spec/issues/111) | ||
* Custom CSS Color 4 compliant css color parser [#175](https://github.com/maplibre/maplibre-style-spec/issues/175) | ||
## 19.1.0 | ||
@@ -4,0 +12,0 @@ |
{ | ||
"name": "@maplibre/maplibre-gl-style-spec", | ||
"description": "a specification for maplibre gl styles", | ||
"version": "19.1.0", | ||
"version": "19.2.0", | ||
"author": "MapLibre", | ||
@@ -47,3 +47,2 @@ "keywords": [ | ||
"@types/mapbox__point-geometry": "^0.1.2", | ||
"color-string": "^1.9.1", | ||
"json-stringify-pretty-compact": "^3.0.0", | ||
@@ -50,0 +49,0 @@ "minimist": "^1.2.8", |
https://github.com/maplibre/maplibre-gl-style-spec | ||
[Changes](https://github.com/maplibre/maplibre-gl-style-spec/compare/v19.0.1...v19.1.0) since [MapLibre GL Style Spec v19.0.1](https://github.com/maplibre/maplibre-gl-style-spec/releases/tag/v19.0.1): | ||
[Changes](https://github.com/maplibre/maplibre-gl-style-spec/compare/v19.1.0...v19.2.0) since [MapLibre GL Style Spec v19.1.0](https://github.com/maplibre/maplibre-gl-style-spec/releases/tag/v19.1.0): | ||
### ✨ Features and improvements | ||
* Use D50 white point instead of D65 in HCL/LAB color spaces [#146](https://github.com/maplibre/maplibre-style-spec/pull/146) | ||
* Automated migration of not-CSS-Color-specification-compliant hsl color values [#135](https://github.com/maplibre/maplibre-style-spec/pull/135) | ||
* Remove mapbox reference from docs and test cases [#111](https://github.com/maplibre/maplibre-style-spec/issues/111) | ||
* Custom CSS Color 4 compliant css color parser [#175](https://github.com/maplibre/maplibre-style-spec/issues/175) |
@@ -83,4 +83,4 @@ import migrate from './migrate'; | ||
sources: { | ||
streets: { | ||
url: 'mapbox://mapbox.streets', | ||
maplibre: { | ||
url: 'https://demotiles.maplibre.org/tiles/tiles.json', | ||
type: 'vector' | ||
@@ -91,3 +91,3 @@ } | ||
id: '1', | ||
source: 'streets', | ||
source: 'maplibre', | ||
'source-layer': 'labels', | ||
@@ -94,0 +94,0 @@ type: 'symbol', |
@@ -475,34 +475,2 @@ import migrate from './v8'; | ||
test('migrate UNversioned fontstack urls', () => { | ||
const input = { | ||
'version': 7, | ||
'glyphs': 'mapbox://fontstack/{fontstack}/{range}.pbf', | ||
'layers': [] | ||
} as any; | ||
const output = { | ||
'version': 8, | ||
'glyphs': 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf', | ||
'layers': [] | ||
}; | ||
expect(migrate(input)).toEqual(output); | ||
}); | ||
test('migrate versioned fontstack urls', () => { | ||
const input = { | ||
'version': 7, | ||
'glyphs': 'mapbox://fonts/v1/boxmap/{fontstack}/{range}.pbf', | ||
'layers': [] | ||
} as any; | ||
const output = { | ||
'version': 8, | ||
'glyphs': 'mapbox://fonts/boxmap/{fontstack}/{range}.pbf', | ||
'layers': [] | ||
}; | ||
expect(migrate(input)).toEqual(output); | ||
}); | ||
}); |
@@ -111,34 +111,2 @@ | ||
function migrateFontstackURL(input) { | ||
const inputParsed = new URL(input); | ||
const inputPathnameParts = inputParsed.pathname.split('/'); | ||
if (inputParsed.protocol !== 'mapbox:') { | ||
return input; | ||
} else if (inputParsed.hostname === 'fontstack') { | ||
assert(decodeURI(inputParsed.pathname) === '/{fontstack}/{range}.pbf'); | ||
return 'mapbox://fonts/mapbox/{fontstack}/{range}.pbf'; | ||
} else if (inputParsed.hostname === 'fonts') { | ||
assert(inputPathnameParts[1] === 'v1'); | ||
assert(decodeURI(inputPathnameParts[3]) === '{fontstack}'); | ||
assert(decodeURI(inputPathnameParts[4]) === '{range}.pbf'); | ||
return `mapbox://fonts/${inputPathnameParts[2]}/{fontstack}/{range}.pbf`; | ||
} else { | ||
assert(false); | ||
} | ||
function assert(predicate) { | ||
if (!predicate) { | ||
throw new Error(`Invalid font url: "${input}"`); | ||
} | ||
} | ||
} | ||
if (style.glyphs) { | ||
style.glyphs = migrateFontstackURL(style.glyphs); | ||
} | ||
function migrateFontStack(font) { | ||
@@ -145,0 +113,0 @@ function splitAndTrim(string) { |
@@ -8,39 +8,7 @@ import {expectCloseToArray, expectToMatchColor} from '../../test/unit/test_utils'; | ||
test('should parse color keyword', () => { | ||
expectToMatchColor(Color.parse('white'), 'rgb(100% 100% 100% / 1)'); | ||
expectToMatchColor(Color.parse('black'), 'rgb(0% 0% 0% / 1)'); | ||
test('should parse valid css color strings', () => { | ||
expectToMatchColor(Color.parse('RED'), 'rgb(100% 0% 0% / 1)'); | ||
expectToMatchColor(Color.parse('aquamarine'), 'rgb(49.804% 100% 83.137% / 1)'); | ||
expectToMatchColor(Color.parse('steelblue'), 'rgb(27.451% 50.98% 70.588% / 1)'); | ||
}); | ||
test('should parse hex color notation', () => { | ||
expectToMatchColor(Color.parse('#fff'), 'rgb(100% 100% 100% / 1)'); | ||
expectToMatchColor(Color.parse('#000'), 'rgb(0% 0% 0% / 1)'); | ||
expectToMatchColor(Color.parse('#f00C'), 'rgb(100% 0% 0% / .8)'); | ||
expectToMatchColor(Color.parse('#ff00ff'), 'rgb(100% 0% 100% / 1)'); | ||
expectToMatchColor(Color.parse('#4682B466'), 'rgb(27.451% 50.98% 70.588% / .4)'); | ||
}); | ||
test('should parse rgb function syntax', () => { | ||
expectToMatchColor(Color.parse('rgb(0,0,128)'), 'rgb(0% 0% 50.196% / 1)'); | ||
expectToMatchColor(Color.parse('rgb(0 0 128)'), 'rgb(0% 0% 50.196% / 1)'); | ||
expectToMatchColor(Color.parse('rgb(0 0 128 / 0.2)'), 'rgb(0% 0% 50.196% / .2)'); | ||
expectToMatchColor(Color.parse('rgb(0 0 128 / .2)'), 'rgb(0% 0% 50.196% / .2)'); | ||
expectToMatchColor(Color.parse('rgb(0 0 128 / 20%)'), 'rgb(0% 0% 50.196% / .2)'); | ||
expectToMatchColor(Color.parse('rgb(26,207,26,0.5)'), 'rgb(10.196% 81.176% 10.196% / .5)'); | ||
expectToMatchColor(Color.parse('rgba(26,207,26,.73)'), 'rgb(10.196% 81.176% 10.196% / .73)'); | ||
expectToMatchColor(Color.parse('rgba(0,0,128,.2)'), 'rgb(0% 0% 50.196% / .2)'); | ||
}); | ||
test('should parse hsl function syntax', () => { | ||
expectToMatchColor(Color.parse('hsl(300,100%,25.1%)'), 'rgb(50.2% 0% 50.2% / 1)'); | ||
expectToMatchColor(Color.parse('hsl(300 100% 25.1%)'), 'rgb(50.2% 0% 50.2% / 1)'); | ||
expectToMatchColor(Color.parse('hsl(300 100% 25.1% / 0.2)'), 'rgb(50.2% 0% 50.2% / .2)'); | ||
expectToMatchColor(Color.parse('hsl(300 100% 25.1% / .2)'), 'rgb(50.2% 0% 50.2% / .2)'); | ||
// expectToMatchColor(Color.parse('hsl(300 100% 25.1% / 20%)'), 'rgb(50.2% 0% 50.2% / .2)'); | ||
expectToMatchColor(Color.parse('hsl(300,100%,25.1%,0.7)'), 'rgb(50.2% 0% 50.2% / .7)'); | ||
expectToMatchColor(Color.parse('rgb(0 0 127.5 / 20%)'), 'rgb(0% 0% 50% / .2)'); | ||
expectToMatchColor(Color.parse('hsl(300deg 100% 25.1% / 0.7)'), 'rgb(50.2% 0% 50.2% / .7)'); | ||
expectToMatchColor(Color.parse('hsla(300,100%,25.1%,0.9)'), 'rgb(50.2% 0% 50.2% / .9)'); | ||
expectToMatchColor(Color.parse('hsla(300,100%,25.1%,.0)'), 'rgb(0% 0% 0% / 0)'); | ||
}); | ||
@@ -47,0 +15,0 @@ |
@@ -1,3 +0,3 @@ | ||
import colorString from 'color-string'; | ||
import {HCLColor, hslToRgb, LABColor, RGBColor, rgbToHcl, rgbToLab} from './color_spaces'; | ||
import {HCLColor, LABColor, RGBColor, rgbToHcl, rgbToLab} from './color_spaces'; | ||
import {parseCssColor} from './parse_css_color'; | ||
@@ -71,3 +71,3 @@ /** | ||
const rgba = parseCssColor(input.toLowerCase()); | ||
const rgba = parseCssColor(input); | ||
if (rgba) { | ||
@@ -150,15 +150,2 @@ return new Color(...rgba, false); | ||
function parseCssColor(colorToParse: string): RGBColor | undefined { | ||
const parsingResult = colorString.get(colorToParse); | ||
switch (parsingResult?.model) { | ||
case 'rgb': { | ||
const [r, g, b, alpha] = parsingResult.value; | ||
return [r / 255, g / 255, b / 255, alpha]; | ||
} | ||
case 'hsl': { | ||
return hslToRgb(parsingResult.value); | ||
} | ||
} | ||
} | ||
Color.black = new Color(0, 0, 0, 1); | ||
@@ -165,0 +152,0 @@ Color.white = new Color(1, 1, 1, 1); |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -6,7 +6,7 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
}, | ||
"raster": { | ||
"type": "raster", | ||
"url": "mapbox://mapbox.mapbox-satellite" | ||
"url": "https://demotiles.maplibre.org/terrain-tiles/tiles.json" | ||
}, | ||
@@ -13,0 +13,0 @@ "geojson": { |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -7,3 +7,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -10,0 +10,0 @@ }, |
@@ -7,3 +7,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -10,0 +10,0 @@ }, |
@@ -10,3 +10,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -13,0 +13,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -9,0 +9,0 @@ }, |
@@ -7,3 +7,3 @@ { | ||
"type": "vector", | ||
"url": "mapbox://mapbox.mapbox-streets-v5" | ||
"url": "https://demotiles.maplibre.org/tiles/tiles.json" | ||
} | ||
@@ -10,0 +10,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
18501584
8
89047
319
- Removedcolor-string@^1.9.1
- Removedcolor-name@1.1.4(transitive)
- Removedcolor-string@1.9.1(transitive)
- Removedis-arrayish@0.3.2(transitive)
- Removedsimple-swizzle@0.2.2(transitive)