@versatiles/style 3.8.1 → 3.8.2

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 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
- const styleBuilder = new VersaTilesStyle.Colorful();
39
- styleBuilder.tilesUrl = ['tiles/{z}/{x}/{y}'];
38
+ const style = VersaTilesStyle.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: styleBuilder.build()
49
+ style
44
50
  });
45
51
  <script>
46
52
  ```
@@ -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.hexa();
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', '#00ff0080');
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
  });
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versatiles/style",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
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": "tsx scripts/release.ts",
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": "^19.3.3",
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.5",
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.11",
48
- "@types/node": "^20.10.6",
49
- "@typescript-eslint/eslint-plugin": "^6.17.0",
50
- "@typescript-eslint/parser": "^6.17.0",
51
- "@versatiles/release-tool": "^1.0.3",
47
+ "@types/jest": "^29.5.12",
48
+ "@types/node": "^20.11.17",
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.12",
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.12",
58
- "rollup": "^4.9.3",
57
+ "npm-check-updates": "^16.14.15",
58
+ "rollup": "^4.10.0",
59
59
  "rollup-plugin-dts": "^6.1.0",
60
- "ts-jest": "^29.1.1",
60
+ "ts-jest": "^29.1.2",
61
61
  "ts-node": "^10.9.2",
62
- "tsx": "^4.7.0",
62
+ "tsx": "^4.7.1",
63
63
  "typescript": "^5.3.3"
64
64
  }
65
65
  }