@versatiles/style 3.8.1 → 4.0.0
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/README.MD +13 -6
- package/dist/index.d.ts +7 -5
- package/dist/index.js +12 -10
- package/dist/index.test.js +11 -12
- package/dist/lib/{style_builder.test.js → build_style.test.js} +1 -1
- package/dist/lib/decorator.js +1 -1
- package/dist/lib/decorator.test.js +1 -1
- package/dist/lib/{style_guesser.test.js → guess_style.test.js} +19 -1
- package/dist/lib/recolor.d.ts +1 -1
- package/dist/lib/recolor.test.d.ts +1 -1
- package/dist/lib/recolor.test.js +1 -1
- package/dist/lib/types.d.ts +1 -1
- package/dist/style/colorful.d.ts +1 -1
- package/dist/style/colorful.js +1 -1
- package/dist/style/neutrino.d.ts +1 -1
- package/dist/style/neutrino.js +1 -1
- package/package.json +14 -14
- /package/dist/lib/{style_builder.d.ts → build_style.d.ts} +0 -0
- /package/dist/lib/{style_builder.js → build_style.js} +0 -0
- /package/dist/lib/{style_builder.test.d.ts → build_style.test.d.ts} +0 -0
- /package/dist/lib/{style_guesser.d.ts → guess_style.d.ts} +0 -0
- /package/dist/lib/{style_guesser.js → guess_style.js} +0 -0
- /package/dist/lib/{style_guesser.test.d.ts → guess_style.test.d.ts} +0 -0
package/README.MD
CHANGED
|
@@ -35,12 +35,18 @@ Use it in:
|
|
|
35
35
|
<script src="maplibre-gl.js"></script>
|
|
36
36
|
<script src="versatiles-style.js"></script>
|
|
37
37
|
<script>
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const style = VersaTilesStyle.styles.graybeard({
|
|
39
|
+
tiles: ['https://???.org/tiles/osm/{z}/{x}/{y}'],
|
|
40
|
+
sprite: 'https://???.org/assets/styles/swr-bright/sprite',
|
|
41
|
+
glyphs: 'https://???.org/assets/fonts/{fontstack}/{range}.pbf',
|
|
42
|
+
languageSuffix: '_de',
|
|
43
|
+
colors: { label: '#222' },
|
|
44
|
+
recolor: { gamma: 0.5 }
|
|
45
|
+
});
|
|
40
46
|
|
|
41
47
|
const map = new maplibregl.Map({
|
|
42
48
|
container: 'map',
|
|
43
|
-
style
|
|
49
|
+
style
|
|
44
50
|
});
|
|
45
51
|
<script>
|
|
46
52
|
```
|
|
@@ -56,9 +62,10 @@ npm install versatiles-style
|
|
|
56
62
|
Use it in Node.js:
|
|
57
63
|
|
|
58
64
|
```javascript
|
|
59
|
-
import {
|
|
60
|
-
let style =
|
|
61
|
-
|
|
65
|
+
import { styles } from 'versatiles-style';
|
|
66
|
+
let style = styles.colorful({
|
|
67
|
+
languageSuffix: '_en',
|
|
68
|
+
});
|
|
62
69
|
writeFileSync('style.json', JSON.stringify(style.build()));
|
|
63
70
|
```
|
|
64
71
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { MaplibreStyle, StylemakerOptions } from './lib/types.js';
|
|
2
|
+
export type { TileJSONSpecification, TileJSONSpecificationRaster, TileJSONSpecificationVector } from './lib/types.js';
|
|
2
3
|
import Colorful from './style/colorful.js';
|
|
3
|
-
export declare function colorful(options?: StylemakerOptions<Colorful>): MaplibreStyle;
|
|
4
4
|
import Graybeard from './style/graybeard.js';
|
|
5
|
-
export declare function graybeard(options?: StylemakerOptions<Graybeard>): MaplibreStyle;
|
|
6
5
|
import Neutrino from './style/neutrino.js';
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export declare const styles: {
|
|
7
|
+
colorful: (options?: StylemakerOptions<Colorful>) => MaplibreStyle;
|
|
8
|
+
graybeard: (options?: StylemakerOptions<Graybeard>) => MaplibreStyle;
|
|
9
|
+
neutrino: (options?: StylemakerOptions<Neutrino>) => MaplibreStyle;
|
|
10
|
+
};
|
|
11
|
+
export { default as guessStyle } from './lib/guess_style.js';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import Colorful from './style/colorful.js';
|
|
2
|
-
export function colorful(options) {
|
|
3
|
-
return new Colorful().build(options);
|
|
4
|
-
}
|
|
5
2
|
import Graybeard from './style/graybeard.js';
|
|
6
|
-
export function graybeard(options) {
|
|
7
|
-
return new Graybeard().build(options);
|
|
8
|
-
}
|
|
9
3
|
import Neutrino from './style/neutrino.js';
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export const styles = {
|
|
5
|
+
colorful: function colorful(options) {
|
|
6
|
+
return new Colorful().build(options);
|
|
7
|
+
},
|
|
8
|
+
graybeard: function graybeard(options) {
|
|
9
|
+
return new Graybeard().build(options);
|
|
10
|
+
},
|
|
11
|
+
neutrino: function neutrino(options) {
|
|
12
|
+
return new Neutrino().build(options);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export { default as guessStyle } from './lib/guess_style.js';
|
package/dist/index.test.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
-
import
|
|
3
|
-
describe('
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
]
|
|
9
|
-
styles.forEach(({ name, builder }) => {
|
|
2
|
+
import { guessStyle, styles } from './index.js';
|
|
3
|
+
describe('styles', () => {
|
|
4
|
+
it('should be all styles', () => {
|
|
5
|
+
expect(Array.from(Object.keys(styles)).sort())
|
|
6
|
+
.toStrictEqual(['colorful', 'graybeard', 'neutrino']);
|
|
7
|
+
});
|
|
8
|
+
Object.entries(styles).forEach(([name, builder]) => {
|
|
10
9
|
it(`should create and test an instance of ${name}`, () => {
|
|
11
10
|
expect(typeof builder).toBe('function');
|
|
12
11
|
const style = builder({ baseUrl: 'https://example.org' });
|
|
13
12
|
expect(JSON.stringify(style).length).toBeGreaterThan(50000);
|
|
14
|
-
expect(style.name).toBe('versatiles-' + name
|
|
13
|
+
expect(style.name).toBe('versatiles-' + name);
|
|
15
14
|
expect(style.glyphs).toBe('https://example.org/assets/fonts/{fontstack}/{range}.pbf');
|
|
16
15
|
expect(style.sprite).toBe('https://example.org/assets/sprites/sprites');
|
|
17
16
|
expect(Object.keys(style.sources).join(',')).toBe('versatiles-shortbread');
|
|
@@ -20,7 +19,7 @@ describe('Style Builders', () => {
|
|
|
20
19
|
});
|
|
21
20
|
});
|
|
22
21
|
describe('Colorful', () => {
|
|
23
|
-
const style =
|
|
22
|
+
const style = styles.colorful({
|
|
24
23
|
baseUrl: 'https://dev.null',
|
|
25
24
|
colors: { commercial: '#f00' },
|
|
26
25
|
});
|
|
@@ -38,7 +37,7 @@ describe('guessStyle', () => {
|
|
|
38
37
|
const tiles = ['https://fancy.map/tiles/{z}/{x}/{y}'];
|
|
39
38
|
const vectorLayers = [{ id: 'hallo', fields: { label: 'String' } }];
|
|
40
39
|
it('should build raster styles', () => {
|
|
41
|
-
const style =
|
|
40
|
+
const style = guessStyle({
|
|
42
41
|
tiles,
|
|
43
42
|
format: 'png',
|
|
44
43
|
});
|
|
@@ -49,7 +48,7 @@ describe('guessStyle', () => {
|
|
|
49
48
|
});
|
|
50
49
|
});
|
|
51
50
|
it('should build vector styles', () => {
|
|
52
|
-
const style =
|
|
51
|
+
const style = guessStyle({
|
|
53
52
|
tiles,
|
|
54
53
|
format: 'pbf',
|
|
55
54
|
vectorLayers,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import Color from 'color';
|
|
3
|
-
import StyleBuilder from './
|
|
3
|
+
import StyleBuilder from './build_style.js';
|
|
4
4
|
// Mock class for abstract class StyleBuilder
|
|
5
5
|
class MockStyleBuilder extends StyleBuilder {
|
|
6
6
|
name = 'mock';
|
package/dist/lib/decorator.js
CHANGED
|
@@ -98,7 +98,7 @@ function processColor(value) {
|
|
|
98
98
|
if (typeof value === 'string')
|
|
99
99
|
value = Color(value);
|
|
100
100
|
if (value instanceof Color) {
|
|
101
|
-
value = (value.alpha() === 1) ? value.hex() : value.
|
|
101
|
+
value = (value.alpha() === 1) ? value.hex() : value.string();
|
|
102
102
|
return value.toLowerCase();
|
|
103
103
|
}
|
|
104
104
|
throw new Error(`unknown color type "${typeof value}"`);
|
|
@@ -27,7 +27,7 @@ describe('decorate function', () => {
|
|
|
27
27
|
expect(layer.layout).toHaveProperty('visibility', 'none');
|
|
28
28
|
}
|
|
29
29
|
if (layer.id === 'layer2') {
|
|
30
|
-
expect(layer.paint).toHaveProperty('line-color', '
|
|
30
|
+
expect(layer.paint).toHaveProperty('line-color', 'rgba(0, 255, 0, 0.5)');
|
|
31
31
|
expect(layer.layout).toHaveProperty('visibility', 'visible');
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
2
|
import getTemplate from './shortbread/template.js';
|
|
3
|
-
import guessStyle from './
|
|
3
|
+
import guessStyle from './guess_style.js';
|
|
4
4
|
describe('guessStyle', () => {
|
|
5
5
|
const tiles = ['https://example.com/tiles/{z}/{x}/{y}'];
|
|
6
6
|
const vectorLayersSomething = [{ id: 'geometry', fields: { label: 'String', height: 'Number' } }];
|
|
@@ -121,4 +121,22 @@ describe('guessStyle', () => {
|
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
+
describe('absolute tile urls override baseUrl', () => {
|
|
125
|
+
cases.forEach(({ type, options }) => {
|
|
126
|
+
it(type, () => {
|
|
127
|
+
const style = guessStyle({ ...options, tiles: ['https://example1.org/tiles/{z}/{x}/{y}'], baseUrl: 'https://example2.org/' });
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
129
|
+
expect(Object.values(style.sources)[0].tiles).toEqual(['https://example1.org/tiles/{z}/{x}/{y}']);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
describe('relative tile urls are resolved with baseUrl', () => {
|
|
134
|
+
cases.forEach(({ type, options }) => {
|
|
135
|
+
it(type, () => {
|
|
136
|
+
const style = guessStyle({ ...options, tiles: ['./{z}/{x}/{y}'], baseUrl: 'https://example2.org/tiles/' });
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
138
|
+
expect(Object.values(style.sources)[0].tiles).toEqual(['https://example2.org/tiles/{z}/{x}/{y}']);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
124
142
|
});
|
package/dist/lib/recolor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RecolorOptions, StylemakerColors } from './types.js';
|
|
2
|
-
import type StyleBuilder from './
|
|
2
|
+
import type StyleBuilder from './build_style.ts';
|
|
3
3
|
export declare function getDefaultRecolorFlags(): RecolorOptions;
|
|
4
4
|
export declare function recolor<Subclass extends StyleBuilder<Subclass>>(colors: StylemakerColors<Subclass>, opt?: RecolorOptions): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StyleRules, StyleRulesOptions } from './types.js';
|
|
2
|
-
import StyleBuilder from './
|
|
2
|
+
import StyleBuilder from './build_style.js';
|
|
3
3
|
export default class TestStyle extends StyleBuilder<TestStyle> {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
defaultFonts: {};
|
package/dist/lib/recolor.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getDefaultRecolorFlags, recolor } from './recolor.js';
|
|
2
|
-
import StyleBuilder from './
|
|
2
|
+
import StyleBuilder from './build_style.js';
|
|
3
3
|
describe('colorTransformer', () => {
|
|
4
4
|
describe('getDefaultRecolorFlags', () => {
|
|
5
5
|
it('should return the default color transformer flags', () => {
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BackgroundLayerSpecification, FillLayerSpecification, FilterSpecification, LineLayerSpecification, StyleSpecification, SymbolLayerSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
2
|
import type Color from 'color';
|
|
3
|
-
import type StyleBuilder from './
|
|
3
|
+
import type StyleBuilder from './build_style.ts';
|
|
4
4
|
/** Represents the available tile formats. */
|
|
5
5
|
export type TileFormat = 'avif' | 'bin' | 'geojson' | 'jpg' | 'json' | 'pbf' | 'png' | 'svg' | 'topojson' | 'webp';
|
|
6
6
|
/** Type for Maplibre layers, including background, fill, line, and symbol specifications. */
|
package/dist/style/colorful.d.ts
CHANGED
package/dist/style/colorful.js
CHANGED
package/dist/style/neutrino.d.ts
CHANGED
package/dist/style/neutrino.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versatiles/style",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Generate StyleJSON for MapLibre",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build-styles": "tsx scripts/build-styles.ts",
|
|
13
13
|
"doc": "vrt ts2md src/index.ts tsconfig.node.json | vrt insertmd README.md '# API'",
|
|
14
14
|
"lint": "npm run build-browser && eslint --color .",
|
|
15
|
-
"release": "
|
|
15
|
+
"release": "npx vrt release-npm",
|
|
16
16
|
"test": "npm run test-typescript && npm run test-node && npm run test-browser",
|
|
17
17
|
"test-browser": "npm run build-browser && jest -c=jest.config.browser.ts",
|
|
18
18
|
"test-coverage": "NODE_OPTIONS=--experimental-vm-modules jest -c=jest.config.coverage.ts",
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
"dist/**/*.d.ts"
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@maplibre/maplibre-gl-style-spec": "^
|
|
40
|
+
"@maplibre/maplibre-gl-style-spec": "^20.1.1",
|
|
41
41
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
43
43
|
"@rollup/plugin-terser": "^0.4.4",
|
|
44
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
44
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
45
45
|
"@types/brace-expansion": "^1.1.2",
|
|
46
46
|
"@types/inquirer": "^9.0.7",
|
|
47
|
-
"@types/jest": "^29.5.
|
|
48
|
-
"@types/node": "^20.
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
50
|
-
"@typescript-eslint/parser": "^
|
|
51
|
-
"@versatiles/release-tool": "^1.
|
|
47
|
+
"@types/jest": "^29.5.12",
|
|
48
|
+
"@types/node": "^20.11.19",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
|
50
|
+
"@typescript-eslint/parser": "^7.0.1",
|
|
51
|
+
"@versatiles/release-tool": "^1.2.1",
|
|
52
52
|
"eslint": "^8.56.0",
|
|
53
|
-
"inquirer": "^9.2.
|
|
53
|
+
"inquirer": "^9.2.14",
|
|
54
54
|
"jest": "^29.7.0",
|
|
55
55
|
"jest-environment-jsdom": "^29.7.0",
|
|
56
56
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
57
|
-
"npm-check-updates": "^16.14.
|
|
58
|
-
"rollup": "^4.
|
|
57
|
+
"npm-check-updates": "^16.14.15",
|
|
58
|
+
"rollup": "^4.11.0",
|
|
59
59
|
"rollup-plugin-dts": "^6.1.0",
|
|
60
|
-
"ts-jest": "^29.1.
|
|
60
|
+
"ts-jest": "^29.1.2",
|
|
61
61
|
"ts-node": "^10.9.2",
|
|
62
|
-
"tsx": "^4.7.
|
|
62
|
+
"tsx": "^4.7.1",
|
|
63
63
|
"typescript": "^5.3.3"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|