@versatiles/style 4.4.0 → 5.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 CHANGED
@@ -1,9 +1,13 @@
1
1
  [![NPM Version](https://img.shields.io/npm/v/%40versatiles%2Fstyle)](https://www.npmjs.com/package/@versatiles/style)
2
2
  [![Code Coverage](https://codecov.io/gh/versatiles-org/versatiles-style/branch/main/graph/badge.svg?token=IDHAI13M0K)](https://codecov.io/gh/versatiles-org/versatiles-style)
3
3
  [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/versatiles-org/versatiles-style/ci.yml)](https://github.com/versatiles-org/versatiles-style/actions/workflows/ci.yml)
4
+ [![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/versatiles-org/versatiles-style/total)](https://github.com/versatiles-org/versatiles-style/releases/latest)
4
5
 
5
6
  # VersaTiles Style
6
7
 
8
+ > [!WARNING]
9
+ > We are currently migrating to the [VersaTiles Frontend Specification](https://github.com/versatiles-org/versatiles-documentation/blob/main/compendium/specification_frontend.md). While this is good for the long term, it does mean that there will be breaking changes in the short term. You can find the [old v4.4.1 release here](https://github.com/versatiles-org/versatiles-style/releases/tag/v4.4.1).
10
+
7
11
  Generates styles and sprites for MapLibre.
8
12
 
9
13
  ![Example: Colorful Style](docs/colorful.png)
@@ -12,6 +16,7 @@ Generates styles and sprites for MapLibre.
12
16
 
13
17
  * Colorful - colorful, full featured map
14
18
  * Graybeard - gray, full featured map
19
+ * Eclipse - dark, full featured map
15
20
  * Neutrino - light basemap
16
21
 
17
22
  # Use styles for versatiles.org
@@ -22,12 +27,14 @@ Be aware that these styles use `tiles.versatiles.org` as source for tiles, fonts
22
27
  - [`sprites.tar.gz`](https://github.com/versatiles-org/versatiles-style/releases/latest/download/sprites.tar.gz) containing sprites, used e.g. for map icons
23
28
  - [`versatiles-style.tar.gz`](https://github.com/versatiles-org/versatiles-style/releases/latest/download/versatiles-style.tar.gz) containing a JavaScript file to generate your own style in the browser.
24
29
 
25
- # Create styles in the frontend (web browser)
30
+ # Generating styles on-the-fly
31
+
32
+ ## Generating styles in the frontend (web browser)
26
33
 
27
34
  Download latest release:
28
35
 
29
36
  ```bash
30
- wget "https://github.com/versatiles-org/versatiles-style/releases/latest/download/versatiles-style.tar.gz"
37
+ curl -Ls "https://github.com/versatiles-org/versatiles-style/releases/latest/download/versatiles-style.tar.gz" | gzip -d | tar -xf -
31
38
  ```
32
39
 
33
40
  Use it in:
@@ -37,24 +44,20 @@ Use it in:
37
44
  <script src="maplibre-gl.js"></script>
38
45
  <script src="versatiles-style.js"></script>
39
46
  <script>
40
- const style = VersaTilesStyle.styles.graybeard({
41
- tiles: ['/tiles/osm/{z}/{x}/{y}'],
42
- sprite: '/assets/styles/swr-bright/sprite',
43
- glyphs: '/assets/fonts/{fontstack}/{range}.pbf',
44
- baseUrl: 'https://example.org/',
45
- languageSuffix: '_de',
47
+ const style = VersaTilesStyle.graybeard({
48
+ language: 'de',
46
49
  colors: { label: '#222' },
47
50
  recolor: { gamma: 0.5 }
48
51
  });
49
-
50
- const map = new maplibregl.Map({
51
- container: 'map',
52
- style
53
- });
54
- <script>
52
+
53
+ const map = new maplibregl.Map({
54
+ container: 'map',
55
+ style
56
+ });
57
+ </script>
55
58
  ```
56
59
 
57
- # Create styles in the backend (Node.js)
60
+ ## Generating styles in the backend (Node.js)
58
61
 
59
62
  Install `@versatiles/style` via NPM:
60
63
 
@@ -65,111 +68,101 @@ npm install @versatiles/style
65
68
  Use it in Node.js:
66
69
 
67
70
  ```javascript
68
- import { styles } from '@versatiles/style';
69
- let style = styles.colorful({
70
- languageSuffix: '_en',
71
+ import { colorful } from '@versatiles/style';
72
+ let style = colorful({
73
+ language: 'en',
71
74
  });
72
75
  writeFileSync('style.json', JSON.stringify(style));
73
76
  ```
74
77
 
75
- # API
76
-
77
- <!--- This chapter is generated automatically --->
78
-
79
- ## Interfaces
80
-
81
- ### Interface: `TileJSONSpecificationRaster`<a id="interface_tilejsonspecificationraster"></a>
82
-
83
- ```typescript
84
- interface {
85
- attribution?: string;
86
- bounds?: [number, number, number, number];
87
- center?: [number, number];
88
- description?: string;
89
- fillzoom?: number;
90
- format: "avif" | "jpg" | "png" | "webp";
91
- grids?: string[];
92
- legend?: string;
93
- maxzoom?: number;
94
- minzoom?: number;
95
- name?: string;
96
- scheme?: "xyz" | "tms";
97
- template?: string;
98
- tilejson?: "3.0.0";
99
- tiles: string[];
100
- type: "raster";
101
- }
102
- ```
78
+ ### Methods for generating styles
103
79
 
104
- ### Interface: `TileJSONSpecificationVector`<a id="interface_tilejsonspecificationvector"></a>
105
-
106
- ```typescript
107
- interface {
108
- attribution?: string;
109
- bounds?: [number, number, number, number];
110
- center?: [number, number];
111
- description?: string;
112
- fillzoom?: number;
113
- format: "pbf";
114
- grids?: string[];
115
- legend?: string;
116
- maxzoom?: number;
117
- minzoom?: number;
118
- name?: string;
119
- scheme?: "xyz" | "tms";
120
- template?: string;
121
- tilejson?: "3.0.0";
122
- tiles: string[];
123
- type: "vector";
124
- vector_layers: VectorLayer[];
125
- }
126
- ```
80
+ This library provides:
81
+ - `style = colorful(options);`
82
+ - `style = eclipse(options);`
83
+ - `style = graybeard(options);`
84
+ - `style = neutrino(options);`
127
85
 
128
- ## Type Aliases
86
+ Where `options` is an optional object:
129
87
 
130
- ### Type: `TileJSONSpecification`<a id="type_tilejsonspecification"></a>
88
+ ```javascript
89
+ const options: StyleBuilderOptions<Colorful> = {
90
+ // The base URL for loading external resources like tiles, sprites, and fonts.
91
+ // Default: document.location.origin (in the browser), or 'https://tiles.versatiles.org'
92
+ baseUrl?: string;
131
93
 
132
- **Type:** <code>[TileJSONSpecificationRaster](#interface_tilejsonspecificationraster) | [TileJSONSpecificationVector](#interface_tilejsonspecificationvector)</code>
94
+ // The URL template for loading font glyphs, formatted with '{fontstack}' and '{range}' placeholders.
95
+ // Default: '/assets/glyphs/{fontstack}/{range}.pbf'
96
+ glyphs?: string;
133
97
 
134
- ## Functions
98
+ // The URL for loading sprite images and metadata.
99
+ // Default: [{ id: 'basics', url: '/assets/sprites/basics/sprites' }]
100
+ sprite?: string | { id: string; url: string }[];
135
101
 
136
- ### Method: `colorful(options)`
102
+ // An array of URL templates for loading map tiles, using '{z}', '{x}', and '{y}' placeholders.
103
+ // Default: ['/tiles/osm/{z}/{x}/{y}']
104
+ tiles?: string[];
137
105
 
138
- <sup><a href="https://github.com/versatiles-org/versatiles-style/blob/be6dcfe/src/index.ts#L4">\[src]</a></sup>
106
+ // If set to true, hides all map labels.
107
+ // Default: false
108
+ hideLabels?: boolean;
139
109
 
140
- **Parameters:**
110
+ // Set the language ('en', 'de') of all map labels.
111
+ // A null value means that the language of the country in which the label is drawn will be used.
112
+ // Default: null
113
+ language?: Language;
141
114
 
142
- * <code>options: StylemakerOptions<default></code> (optional)
115
+ // An object specifying overrides for default color values, keyed by the color names.
116
+ colors?: Partial<StyleBuilderColorStrings<T>>;
143
117
 
144
- **Returns:** <code>MaplibreStyle</code>
118
+ // An object specifying overrides for default font names, keyed by the font names.
119
+ fonts?: Partial<StyleBuilderFontStrings<T>>;
145
120
 
146
- ### Method: `graybeard(options)`
121
+ // Options for color adjustments and transformations applied to the entire style.
122
+ recolor?: RecolorOptions;
123
+ }
147
124
 
148
- <sup><a href="https://github.com/versatiles-org/versatiles-style/blob/be6dcfe/src/index.ts#L9">\[src]</a></sup>
125
+ export interface RecolorOptions {
126
+ // If true, inverts all colors.
127
+ invertBrightness?: boolean;
149
128
 
150
- **Parameters:**
129
+ // Rotate the hue of all colors (in degrees).
130
+ rotate?: number;
151
131
 
152
- * <code>options: StylemakerOptions<default></code> (optional)
132
+ // Adjusts the saturation level of all colors. Positive values increase saturation, negative values decrease it.
133
+ saturate?: number;
153
134
 
154
- **Returns:** <code>MaplibreStyle</code>
135
+ // Adjusts the gamma of all colors. Affects the brightness in a non-linear manner.
136
+ gamma?: number;
155
137
 
156
- ### Method: `guessStyle(opt)`
138
+ // Adjusts the contrast of all colors. Higher values produce more contrast.
139
+ contrast?: number;
157
140
 
158
- <sup><a href="https://github.com/versatiles-org/versatiles-style/blob/be6dcfe/src/lib/style_guesser.ts#L13">\[src]</a></sup>
141
+ // Adjusts the brightness of all colors. Positive values make it brighter, negative values make it darker.
142
+ brightness?: number;
159
143
 
160
- **Parameters:**
144
+ // Specifies the intensity of the tinting effect. Ranges from 0 (no effect) to 1 (full effect).
145
+ tint?: number;
161
146
 
162
- * <code>opt: TileJSONOption</code>
147
+ // Specifies the color used for tinting, in a string format (e.g., '#FF0000').
148
+ tintColor?: string;
149
+ }
150
+ ```
163
151
 
164
- **Returns:** <code>MaplibreStyle</code>
152
+ ### Method: `guessStyle(options)`
153
+
154
+ ```javascript
155
+ const style = guessStyle(options);
156
+ ```
165
157
 
166
- ### Method: `neutrino(options)`
167
158
 
168
- <sup><a href="https://github.com/versatiles-org/versatiles-style/blob/be6dcfe/src/index.ts#L14">\[src]</a></sup>
159
+ GuessStyleOptions
160
+
161
+ <sup><a href="https://github.com/versatiles-org/versatiles-style/blob/be6dcfe/src/lib/style_guesser.ts#L13">\[src]</a></sup>
169
162
 
170
163
  **Parameters:**
171
164
 
172
- * <code>options: StylemakerOptions<default></code> (optional)
165
+ * <code>opt: TileJSONOption</code>
173
166
 
174
167
  **Returns:** <code>MaplibreStyle</code>
175
168
 
@@ -185,9 +178,7 @@ Please note that for building new sprites you need `optipng`.
185
178
 
186
179
  ## Configuration
187
180
 
188
- Iconsets can be defined in [`scripts/config-sprites.ts`](./scripts/config-sprites.ts);
189
- * `colors` are applied to each path in the order they appear in the source SVG.
190
- * `size` applies to the height
181
+ Iconsets can be defined in [`scripts/config-sprites.ts`](./scripts/config-sprites.ts)
191
182
 
192
183
  # Licenses
193
184
 
package/dist/browser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type * from './styles/index.js';
2
- export * as styles from './styles/index.js';
2
+ export * from './styles/index.js';
3
3
  export type { GuessStyleOptions } from './guess_style/index.js';
4
4
  export { guessStyle } from './guess_style/index.js';
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- export * as styles from './styles/index.js';
1
+ export * from './styles/index.js';
2
2
  export { guessStyle } from './guess_style/index.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  import { isTileJSONSpecification, isVectorLayers } from '../types/index.js';
3
2
  import { resolveUrl } from '../lib/utils.js';
4
3
  import randomColorGenerator from './random_color.js';
@@ -27,11 +26,11 @@ export function guessStyle(opt) {
27
26
  }
28
27
  let k;
29
28
  for (k in tilejsonBasic) {
30
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
31
29
  if (tilejsonBasic[k] === undefined)
32
30
  delete tilejsonBasic[k];
33
31
  }
34
32
  let tilejson;
33
+ let vectorLayers;
35
34
  switch (format) {
36
35
  case 'avif':
37
36
  case 'jpg':
@@ -40,7 +39,7 @@ export function guessStyle(opt) {
40
39
  tilejson = { ...tilejsonBasic, type: 'raster', format };
41
40
  break;
42
41
  case 'pbf':
43
- const { vectorLayers } = opt;
42
+ vectorLayers = opt.vectorLayers;
44
43
  if (!isVectorLayers(vectorLayers))
45
44
  throw Error('property vector_layers is invalid');
46
45
  tilejson = { ...tilejsonBasic, type: 'vector', format, vector_layers: vectorLayers };
@@ -90,9 +89,14 @@ export async function guessStyleFromContainer(container, options) {
90
89
  }
91
90
  let vectorLayers;
92
91
  if (typeof metadata === 'string') {
93
- const t = JSON.parse(metadata);
94
- if (('vector_layers' in t) && Array.isArray(t.vector_layers))
95
- vectorLayers = t.vector_layers;
92
+ try {
93
+ const t = JSON.parse(metadata);
94
+ if (('vector_layers' in t) && Array.isArray(t.vector_layers))
95
+ vectorLayers = t.vector_layers;
96
+ }
97
+ catch (error) {
98
+ console.log(error);
99
+ }
96
100
  }
97
101
  const guessStyleOptions = {
98
102
  ...options,
@@ -117,7 +121,6 @@ function isShortbread(spec) {
117
121
  }
118
122
  function getShortbreadStyle(spec, builderOption) {
119
123
  return colorful({
120
- hideLabels: true,
121
124
  tiles: spec.tiles,
122
125
  baseUrl: builderOption.baseUrl,
123
126
  glyphs: builderOption.glyphs,
@@ -84,7 +84,6 @@ export default function randomColorGenerator(startSeed) {
84
84
  }
85
85
  if (typeof hue === 'string') {
86
86
  const color = colorDictionary[hue];
87
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
88
87
  if (color?.hueRange)
89
88
  return color.hueRange;
90
89
  }
@@ -132,7 +131,6 @@ export default function randomColorGenerator(startSeed) {
132
131
  defineColor('pink', [282, 334], [[20, 100], [30, 90], [40, 86], [60, 84], [80, 80], [90, 75], [100, 73]]);
133
132
  return dic;
134
133
  }
135
- // eslint-disable-next-line @typescript-eslint/naming-convention
136
134
  function HSVtoHSL(hsv) {
137
135
  const s = hsv[1] / 100, v = hsv[2] / 100, k = (2 - s) * v;
138
136
  return [hsv[0], 100 * s * v / (k < 1 ? k : 2 - k), 100 * k / 2];
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type * from './styles/index.js';
2
- export * as styles from './styles/index.js';
2
+ export * from './styles/index.js';
3
3
  export { guessStyle, guessStyleFromContainer } from './guess_style/index.js';
4
4
  export type { GuessStyleOptions, GuessContainerOptions } from './guess_style/index.js';
5
5
  export type { VectorLayer } from './types/index.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * as styles from './styles/index.js';
1
+ export * from './styles/index.js';
2
2
  export { guessStyle, guessStyleFromContainer } from './guess_style/index.js';
@@ -1,5 +1,6 @@
1
1
  export declare function deepClone<T>(obj: T): T;
2
- export declare function isSimpleObject(item: unknown): boolean;
3
- export declare function isBasicType(item: unknown): boolean;
4
- export declare function deepMerge<T extends object>(source0: T, ...sources: T[]): T;
2
+ export declare function isSimpleObject(item: unknown): item is object;
3
+ export declare function isBasicType(item: unknown): item is boolean | number | string | undefined;
4
+ export declare function deepMerge<T extends object>(source0: T, ...sources: Partial<T>[]): T;
5
5
  export declare function resolveUrl(base: string, url: string): string;
6
+ export declare function basename(url: string): string;
package/dist/lib/utils.js CHANGED
@@ -63,7 +63,7 @@ export function deepMerge(source0, ...sources) {
63
63
  if (typeof source !== 'object')
64
64
  continue;
65
65
  for (const key in source) {
66
- if (!Object.hasOwn(source, key))
66
+ if (!(key in source))
67
67
  continue;
68
68
  const sourceValue = source[key];
69
69
  // *********
@@ -87,7 +87,6 @@ export function deepMerge(source0, ...sources) {
87
87
  continue;
88
88
  }
89
89
  if (isSimpleObject(target[key]) && isSimpleObject(sourceValue)) {
90
- // @ts-expect-error: Too complicated to handle
91
90
  target[key] = deepMerge(target[key], sourceValue);
92
91
  continue;
93
92
  }
@@ -95,7 +94,6 @@ export function deepMerge(source0, ...sources) {
95
94
  // merge
96
95
  // *********
97
96
  if (isSimpleObject(target[key]) && isSimpleObject(sourceValue)) {
98
- // @ts-expect-error: Too complicated to handle
99
97
  target[key] = deepMerge(target[key], sourceValue);
100
98
  continue;
101
99
  }
@@ -107,10 +105,22 @@ export function deepMerge(source0, ...sources) {
107
105
  return target;
108
106
  }
109
107
  export function resolveUrl(base, url) {
110
- if (!Boolean(base))
108
+ if (!base)
111
109
  return url;
112
110
  url = new URL(url, base).href;
113
111
  url = url.replace(/%7B/gi, '{');
114
112
  url = url.replace(/%7D/gi, '}');
115
113
  return url;
116
114
  }
115
+ export function basename(url) {
116
+ if (!url)
117
+ return '';
118
+ try {
119
+ url = new URL(url, 'http://example.org').pathname;
120
+ }
121
+ catch (_) {
122
+ // ignore
123
+ }
124
+ url = url.replace(/\/+$/, '');
125
+ return url.split('/').pop() ?? '';
126
+ }
@@ -1,5 +1,5 @@
1
- import type { LanguageSuffix } from '../style_builder/index.js';
1
+ import type { Language } from '../style_builder/index.js';
2
2
  import type { MaplibreLayerDefinition } from '../types/index.js';
3
3
  export declare function getShortbreadLayers(option: {
4
- readonly languageSuffix: LanguageSuffix;
4
+ readonly language: Language;
5
5
  }): MaplibreLayerDefinition[];
@@ -1,7 +1,6 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  export function getShortbreadLayers(option) {
3
- const { languageSuffix } = option;
4
- const nameField = languageSuffix ? '{name_' + languageSuffix + '}' : '{name}';
2
+ const { language } = option;
3
+ const nameField = language ? '{name_' + language + '}' : '{name}';
5
4
  return [
6
5
  // background
7
6
  { id: 'background', type: 'background' },
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  const maxzoom = 14;
3
2
  export function getShortbreadTemplate() {
4
3
  return {
@@ -8,8 +7,8 @@ export function getShortbreadTemplate() {
8
7
  'maputnik:renderer': 'mbgljs',
9
8
  license: 'https://creativecommons.org/publicdomain/zero/1.0/',
10
9
  },
11
- glyphs: 'https://tiles.versatiles.org/fonts/{fontstack}/{range}.pbf',
12
- sprite: 'https://tiles.versatiles.org/sprites/sprites',
10
+ glyphs: 'https://tiles.versatiles.org/assets/glyphs/{fontstack}/{range}.pbf',
11
+ sprite: [{ id: 'basics', url: 'https://tiles.versatiles.org/assets/sprites/basics/sprites' }],
13
12
  sources: {
14
13
  'versatiles-shortbread': {
15
14
  tilejson: '3.0.0',
@@ -87,7 +87,6 @@ export function decorate(layers, rules, recolor) {
87
87
  layer.paint[key] = value;
88
88
  break;
89
89
  default:
90
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
91
90
  throw new Error(`unknown parent "${propertyDef.parent}" for key "${key}"`);
92
91
  }
93
92
  });
@@ -1 +1 @@
1
- export type { LanguageSuffix } from './types.js';
1
+ export type { Language } from './types.js';
@@ -1,20 +1,12 @@
1
1
  import Color from 'color';
2
2
  export interface RecolorOptions {
3
- /** If true, inverts the colors. */
4
3
  invertBrightness?: boolean;
5
- /** The degree to rotate the hue of the color (in degrees). */
6
4
  rotate?: number;
7
- /** Adjusts the saturation level of the color. Positive values increase saturation, negative values decrease it. */
8
5
  saturate?: number;
9
- /** Adjusts the gamma of the color. Affects the brightness in a non-linear manner. */
10
6
  gamma?: number;
11
- /** Adjusts the contrast of the color. Higher values produce more contrast. */
12
7
  contrast?: number;
13
- /** Adjusts the brightness of the color. Positive values make it brighter, negative values make it darker. */
14
8
  brightness?: number;
15
- /** Specifies the intensity of the tinting effect. Ranges from 0 (no effect) to 1 (full effect). */
16
9
  tint?: number;
17
- /** Specifies the color used for tinting, in a string format (e.g., '#FF0000'). */
18
10
  tintColor?: string;
19
11
  }
20
12
  export declare function getDefaultRecolorFlags(): RecolorOptions;
@@ -2,19 +2,18 @@ import Color from 'color';
2
2
  import { getShortbreadTemplate, getShortbreadLayers } from '../shortbread/index.js';
3
3
  import { decorate } from './decorator.js';
4
4
  import { CachedRecolor, getDefaultRecolorFlags } from './recolor.js';
5
- import { deepClone, resolveUrl } from '../lib/utils.js';
5
+ import { basename, deepClone, resolveUrl } from '../lib/utils.js';
6
6
  // StyleBuilder class definition
7
7
  export default class StyleBuilder {
8
8
  #sourceName = 'versatiles-shortbread';
9
9
  build(options) {
10
10
  options ??= {};
11
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
12
- const baseUrl = options.baseUrl ?? globalThis?.document?.location?.href ?? 'https://tiles.versatiles.org';
13
- const glyphs = options.glyphs ?? '/assets/fonts/{fontstack}/{range}.pbf';
14
- const sprite = options.sprite ?? '/assets/sprites/sprites';
11
+ const baseUrl = options.baseUrl ?? globalThis?.document?.location?.origin ?? 'https://tiles.versatiles.org';
12
+ const glyphs = options.glyphs ?? '/assets/glyphs/{fontstack}/{range}.pbf';
13
+ const sprite = options.sprite ?? [{ id: 'basics', url: '/assets/sprites/basics/sprites' }];
15
14
  const tiles = options.tiles ?? ['/tiles/osm/{z}/{x}/{y}'];
16
15
  const hideLabels = options.hideLabels ?? false;
17
- const { languageSuffix } = options;
16
+ const language = options.language ?? null;
18
17
  const recolorOptions = options.recolor ?? getDefaultRecolorFlags();
19
18
  const colors = this.getColors(this.defaultColors);
20
19
  if (options.colors) {
@@ -34,12 +33,12 @@ export default class StyleBuilder {
34
33
  const styleRuleOptions = {
35
34
  colors,
36
35
  fonts,
37
- languageSuffix,
36
+ language,
38
37
  };
39
38
  // get layer style rules from child class
40
39
  const layerStyleRules = this.getStyleRules(styleRuleOptions);
41
40
  // get shortbread layers
42
- const layerDefinitions = getShortbreadLayers({ languageSuffix });
41
+ const layerDefinitions = getShortbreadLayers({ language });
43
42
  let layers = layerDefinitions.map(layer => {
44
43
  switch (layer.type) {
45
44
  case 'background':
@@ -48,8 +47,8 @@ export default class StyleBuilder {
48
47
  case 'line':
49
48
  case 'symbol':
50
49
  return {
51
- ...layer,
52
50
  source: this.#sourceName,
51
+ ...layer,
53
52
  };
54
53
  }
55
54
  throw Error('unknown layer type');
@@ -62,7 +61,12 @@ export default class StyleBuilder {
62
61
  style.layers = layers;
63
62
  style.name = 'versatiles-' + this.name.toLowerCase();
64
63
  style.glyphs = resolveUrl(baseUrl, glyphs);
65
- style.sprite = resolveUrl(baseUrl, sprite);
64
+ if (typeof sprite == 'string') {
65
+ style.sprite = [{ id: basename(sprite), url: resolveUrl(baseUrl, sprite) }];
66
+ }
67
+ else {
68
+ style.sprite = sprite.map(({ id, url }) => ({ id, url: resolveUrl(baseUrl, url) }));
69
+ }
66
70
  const source = style.sources[this.#sourceName];
67
71
  if ('tiles' in source)
68
72
  source.tiles = tiles.map(url => resolveUrl(baseUrl, url));
@@ -81,7 +85,7 @@ export default class StyleBuilder {
81
85
  sprite: '',
82
86
  tiles: [],
83
87
  hideLabels: false,
84
- languageSuffix: undefined,
88
+ language: undefined,
85
89
  colors: deepClone(this.defaultColors),
86
90
  fonts: deepClone(this.defaultFonts),
87
91
  recolor: getDefaultRecolorFlags(),
@@ -2,25 +2,19 @@ import type Color from 'color';
2
2
  import type StyleBuilder from './style_builder.js';
3
3
  import type { RecolorOptions } from './recolor.js';
4
4
  /** Represents language suffixes used in map styles. */
5
- export type LanguageSuffix = 'de' | 'en' | undefined;
5
+ export type Language = 'de' | 'en' | null;
6
6
  export interface StyleBuilderOptions<T extends StyleBuilder<T>> {
7
- /** The base URL for loading external resources like tiles, sprites, and fonts. */
8
7
  baseUrl?: string;
9
- /** The URL template for loading font glyphs, formatted with `{fontstack}` and `{range}` placeholders. */
10
8
  glyphs?: string;
11
- /** The URL for loading sprite images and metadata. */
12
- sprite?: string;
13
- /** An array of URL templates for loading map tiles, with `{z}`, `{x}`, and `{y}` placeholders. */
9
+ sprite?: string | {
10
+ id: string;
11
+ url: string;
12
+ }[];
14
13
  tiles?: string[];
15
- /** If true, hides all map labels. */
16
14
  hideLabels?: boolean;
17
- /** Suffix to append to language-specific resources, such as `"-en"` for English. */
18
- languageSuffix?: LanguageSuffix;
19
- /** An object specifying overrides for default color values, keyed by the color names. */
15
+ language?: Language;
20
16
  colors?: Partial<StyleBuilderColorStrings<T>>;
21
- /** An object specifying overrides for default font names, keyed by the font names. */
22
17
  fonts?: Partial<StyleBuilderFontStrings<T>>;
23
- /** Options for color adjustments and transformations applied to the entire style. */
24
18
  recolor?: RecolorOptions;
25
19
  }
26
20
  /** Defines the keys for color properties in a style builder. */
@@ -39,7 +33,7 @@ export type StyleBuilderFonts<T extends StyleBuilder<T>> = Record<StyleBuilderFo
39
33
  export interface StyleRulesOptions<T extends StyleBuilder<T>> {
40
34
  colors: StyleBuilderColors<T>;
41
35
  fonts: StyleBuilderFontStrings<T>;
42
- languageSuffix: LanguageSuffix;
36
+ language: Language;
43
37
  }
44
38
  /** Defines the value type for a style rule. */
45
39
  export type StyleRuleValue = boolean | number | object | string;
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  import StyleBuilder from '../style_builder/style_builder.js';
3
2
  export default class Colorful extends StyleBuilder {
4
3
  name = 'Colorful';
@@ -145,6 +144,9 @@ export default class Colorful extends StyleBuilder {
145
144
  color: colors.land,
146
145
  opacity: { 12: 0, 13: 1 },
147
146
  },
147
+ 'water-pier': {
148
+ color: colors.land,
149
+ },
148
150
  'water-river': {
149
151
  lineWidth: { 9: 0, 10: 3, 15: 5, 17: 9, 18: 20, 20: 60 },
150
152
  },
@@ -217,7 +219,7 @@ export default class Colorful extends StyleBuilder {
217
219
  color: colors.danger,
218
220
  fillOutlineColor: colors.danger,
219
221
  opacity: 0.3,
220
- image: 'pattern-warning',
222
+ image: 'basics:pattern-warning',
221
223
  },
222
224
  'site-hospital': {
223
225
  color: colors.hospital,
@@ -225,12 +227,12 @@ export default class Colorful extends StyleBuilder {
225
227
  },
226
228
  'site-prison': {
227
229
  color: colors.prison,
228
- image: 'pattern-striped',
230
+ image: 'basics:pattern-striped',
229
231
  opacity: 0.1,
230
232
  },
231
233
  'site-construction': {
232
234
  color: colors.construction,
233
- image: 'pattern-hatched_thin',
235
+ image: 'basics:pattern-hatched_thin',
234
236
  opacity: 0.1,
235
237
  },
236
238
  'site-{university,college,school}': {
@@ -650,7 +652,7 @@ export default class Colorful extends StyleBuilder {
650
652
  // markings
651
653
  'marking-oneway{-reverse,}': {
652
654
  minzoom: 16,
653
- image: 'marking-arrow',
655
+ image: 'basics:marking-arrow',
654
656
  opacity: { 16: 0, 17: 0.7 },
655
657
  font: fonts.regular,
656
658
  },
@@ -672,37 +674,37 @@ export default class Colorful extends StyleBuilder {
672
674
  },
673
675
  'symbol-transit-airport': {
674
676
  minzoom: 12,
675
- image: 'icon-airport',
677
+ image: 'basics:icon-airport',
676
678
  iconSize: { 12: 0.5, 14: 1 },
677
679
  },
678
680
  'symbol-transit-airfield': {
679
681
  minzoom: 13,
680
- image: 'icon-airfield',
682
+ image: 'basics:icon-airfield',
681
683
  iconSize: { 13: 0.5, 15: 1 },
682
684
  },
683
685
  'symbol-transit-station': {
684
686
  minzoom: 13,
685
- image: 'icon-rail',
687
+ image: 'basics:icon-rail',
686
688
  iconSize: { 13: 0.5, 15: 1 },
687
689
  },
688
690
  'symbol-transit-lightrail': {
689
691
  minzoom: 14,
690
- image: 'icon-rail_light',
692
+ image: 'basics:icon-rail_light',
691
693
  iconSize: { 14: 0.5, 16: 1 },
692
694
  },
693
695
  'symbol-transit-subway': {
694
696
  minzoom: 14,
695
- image: 'icon-rail_metro',
697
+ image: 'basics:icon-rail_metro',
696
698
  iconSize: { 14: 0.5, 16: 1 },
697
699
  },
698
700
  'symbol-transit-tram': {
699
701
  minzoom: 15,
700
- image: 'transport-tram',
702
+ image: 'basics:transport-tram',
701
703
  iconSize: { 15: 0.5, 17: 1 },
702
704
  },
703
705
  'symbol-transit-bus': {
704
706
  minzoom: 16,
705
- image: 'icon-bus',
707
+ image: 'basics:icon-bus',
706
708
  iconSize: { 16: 0.5, 18: 1 },
707
709
  },
708
710
  // TODO: localized symbols? depends on shortbread
@@ -719,191 +721,191 @@ export default class Colorful extends StyleBuilder {
719
721
  'poi-amenity': {
720
722
  image: ['match',
721
723
  ['get', 'amenity'],
722
- 'arts_centre', 'icon-art_gallery',
723
- 'atm', 'icon-atm',
724
- 'bank', 'icon-bank',
725
- 'bar', 'icon-bar',
726
- 'bench', 'icon-bench',
727
- 'bicycle_rental', 'icon-bicycle_share',
728
- 'biergarten', 'icon-beergarden',
729
- 'cafe', 'icon-cafe',
730
- 'car_rental', 'icon-car_rental',
731
- 'car_sharing', 'icon-car_rental',
732
- 'car_wash', 'icon-car_wash',
733
- 'cinema', 'icon-cinema',
734
- //'clinic', 'icon-clinic',
735
- 'college', 'icon-college',
736
- 'community_centre', 'icon-community',
737
- //'courthouse', 'icon-courthouse',
738
- 'dentist', 'icon-dentist',
739
- 'doctors', 'icon-doctor',
740
- 'dog_park', 'icon-dog_park',
741
- 'drinking_water', 'icon-drinking_water',
742
- 'embassy', 'icon-embassy',
743
- 'fast_food', 'icon-fast_food',
744
- 'fire_station', 'icon-fire_station',
745
- //'food_court', 'icon-food_court',
746
- 'fountain', 'icon-fountain',
747
- 'grave_yard', 'icon-cemetery',
748
- 'hospital', 'icon-hospital',
749
- 'hunting_stand', 'icon-huntingstand',
750
- 'library', 'icon-library',
751
- 'marketplace', 'icon-marketplace',
752
- 'nightclub', 'icon-nightclub',
753
- 'nursing_home', 'icon-nursinghome',
754
- 'pharmacy', 'icon-pharmacy',
755
- 'place_of_worship', 'icon-place_of_worship',
756
- 'playground', 'icon-playground',
757
- 'police', 'icon-police',
758
- 'post_box', 'icon-postbox',
759
- 'post_office', 'icon-post',
760
- 'prison', 'icon-prison',
761
- 'pub', 'icon-beer',
762
- //'public_building', 'icon-public_building',
763
- 'recycling', 'icon-recycling',
764
- 'restaurant', 'icon-restaurant',
765
- 'school', 'icon-school',
766
- 'shelter', 'icon-shelter',
767
- 'telephone', 'icon-telephone',
768
- 'theatre', 'icon-theatre',
769
- 'toilets', 'icon-toilet',
770
- 'townhall', 'icon-town_hall',
771
- //'university', 'icon-university',
772
- 'vending_machine', 'icon-vendingmachine',
773
- 'veterinary', 'icon-veterinary',
774
- 'waste_basket', 'icon-waste_basket',
775
- 'unknown',
724
+ 'arts_centre', 'basics:icon-art_gallery',
725
+ 'atm', 'basics:icon-atm',
726
+ 'bank', 'basics:icon-bank',
727
+ 'bar', 'basics:icon-bar',
728
+ 'bench', 'basics:icon-bench',
729
+ 'bicycle_rental', 'basics:icon-bicycle_share',
730
+ 'biergarten', 'basics:icon-beergarden',
731
+ 'cafe', 'basics:icon-cafe',
732
+ 'car_rental', 'basics:icon-car_rental',
733
+ 'car_sharing', 'basics:icon-car_rental',
734
+ 'car_wash', 'basics:icon-car_wash',
735
+ 'cinema', 'basics:icon-cinema',
736
+ //'clinic', 'basics:icon-clinic',
737
+ 'college', 'basics:icon-college',
738
+ 'community_centre', 'basics:icon-community',
739
+ //'courthouse', 'basics:icon-courthouse',
740
+ 'dentist', 'basics:icon-dentist',
741
+ 'doctors', 'basics:icon-doctor',
742
+ 'dog_park', 'basics:icon-dog_park',
743
+ 'drinking_water', 'basics:icon-drinking_water',
744
+ 'embassy', 'basics:icon-embassy',
745
+ 'fast_food', 'basics:icon-fast_food',
746
+ 'fire_station', 'basics:icon-fire_station',
747
+ //'food_court', 'basics:icon-food_court',
748
+ 'fountain', 'basics:icon-fountain',
749
+ 'grave_yard', 'basics:icon-cemetery',
750
+ 'hospital', 'basics:icon-hospital',
751
+ 'hunting_stand', 'basics:icon-huntingstand',
752
+ 'library', 'basics:icon-library',
753
+ 'marketplace', 'basics:icon-marketplace',
754
+ 'nightclub', 'basics:icon-nightclub',
755
+ 'nursing_home', 'basics:icon-nursinghome',
756
+ 'pharmacy', 'basics:icon-pharmacy',
757
+ 'place_of_worship', 'basics:icon-place_of_worship',
758
+ 'playground', 'basics:icon-playground',
759
+ 'police', 'basics:icon-police',
760
+ 'post_box', 'basics:icon-postbox',
761
+ 'post_office', 'basics:icon-post',
762
+ 'prison', 'basics:icon-prison',
763
+ 'pub', 'basics:icon-beer',
764
+ //'public_building', 'basics:icon-public_building',
765
+ 'recycling', 'basics:icon-recycling',
766
+ 'restaurant', 'basics:icon-restaurant',
767
+ 'school', 'basics:icon-school',
768
+ 'shelter', 'basics:icon-shelter',
769
+ 'telephone', 'basics:icon-telephone',
770
+ 'theatre', 'basics:icon-theatre',
771
+ 'toilets', 'basics:icon-toilet',
772
+ 'townhall', 'basics:icon-town_hall',
773
+ //'university', 'basics:icon-university',
774
+ 'vending_machine', 'basics:icon-vendingmachine',
775
+ 'veterinary', 'basics:icon-veterinary',
776
+ 'waste_basket', 'basics:icon-waste_basket',
777
+ '',
776
778
  ],
777
779
  },
778
780
  'poi-leisure': {
779
781
  image: ['match',
780
782
  ['get', 'leisure'],
781
- 'golf_course', 'icon-golf',
782
- 'ice_rink', 'icon-icerink',
783
- 'pitch', 'icon-pitch',
784
- //'sports_centre', 'icon-sports_centre',
785
- 'stadium', 'icon-stadium',
786
- 'swimming_pool', 'icon-swimming',
787
- 'water_park', 'icon-waterpark',
788
- 'icon-sports',
783
+ 'golf_course', 'basics:icon-golf',
784
+ 'ice_rink', 'basics:icon-icerink',
785
+ 'pitch', 'basics:icon-pitch',
786
+ //'sports_centre', 'basics:icon-sports_centre',
787
+ 'stadium', 'basics:icon-stadium',
788
+ 'swimming_pool', 'basics:icon-swimming',
789
+ 'water_park', 'basics:icon-waterpark',
790
+ 'basics:icon-sports',
789
791
  ],
790
792
  },
791
793
  'poi-tourism': {
792
794
  image: ['match',
793
795
  ['get', 'tourism'],
794
- //'alpine_hut', 'icon-alpine_hut',
795
- //'bed_and_breakfast', 'icon-bed_and_breakfast',
796
- //'camp_site', 'icon-camp_site',
797
- //'caravan_site', 'icon-caravan_site',
798
- 'chalet', 'icon-chalet',
799
- //'guest_house', 'icon-guest_house',
800
- //'hostel', 'icon-hostel',
801
- //'hotel', 'icon-hotel',
802
- 'information', 'transport-information',
803
- //'motel', 'icon-motel',
804
- 'picnic_site', 'icon-picnic_site',
805
- //'theme_park', 'icon-theme_park',
806
- 'viewpoint', 'icon-viewpoint',
807
- 'zoo', 'icon-zoo',
808
- 'unknown',
796
+ //'alpine_hut', 'basics:icon-alpine_hut',
797
+ //'bed_and_breakfast', 'basics:icon-bed_and_breakfast',
798
+ //'camp_site', 'basics:icon-camp_site',
799
+ //'caravan_site', 'basics:icon-caravan_site',
800
+ 'chalet', 'basics:icon-chalet',
801
+ //'guest_house', 'basics:icon-guest_house',
802
+ //'hostel', 'basics:icon-hostel',
803
+ //'hotel', 'basics:icon-hotel',
804
+ 'information', 'basics:transport-information',
805
+ //'motel', 'basics:icon-motel',
806
+ 'picnic_site', 'basics:icon-picnic_site',
807
+ //'theme_park', 'basics:icon-theme_park',
808
+ 'viewpoint', 'basics:icon-viewpoint',
809
+ 'zoo', 'basics:icon-zoo',
810
+ '',
809
811
  ],
810
812
  },
811
813
  'poi-shop': {
812
814
  image: ['match',
813
815
  ['get', 'shop'],
814
- 'alcohol', 'icon-alcohol_shop',
815
- 'bakery', 'icon-bakery',
816
- 'beauty', 'icon-beauty',
817
- 'beverages', 'icon-beverages',
818
- //'bicycle', 'icon-bicycle',
819
- 'books', 'icon-books',
820
- 'butcher', 'icon-butcher',
821
- //'car', 'icon-car',
822
- 'chemist', 'icon-chemist',
823
- 'clothes', 'icon-clothes',
824
- //'computer', 'icon-computer',
825
- //'convinience', 'icon-convinience',
826
- //'department_store', 'icon-department_store',
827
- 'doityourself', 'icon-doityourself',
828
- 'dry_cleaning', 'icon-drycleaning',
829
- 'florist', 'icon-florist',
830
- 'furniture', 'icon-furniture',
831
- 'garden_centre', 'icon-garden_centre',
832
- 'general', 'icon-shop',
833
- 'gift', 'icon-gift',
834
- 'greengrocer', 'icon-greengrocer',
835
- 'hairdresser', 'icon-hairdresser',
836
- 'hardware', 'icon-hardware',
837
- 'jewelry', 'icon-jewelry_store',
838
- 'kiosk', 'icon-kiosk',
839
- 'laundry', 'icon-laundry',
840
- //'mall', 'icon-mall',
841
- //'mobile_phone', 'icon-mobile_phone',
842
- 'newsagent', 'icon-newsagent',
843
- 'optican', 'icon-optician',
844
- 'outdoor', 'icon-outdoor',
845
- 'shoes', 'icon-shoes',
846
- 'sports', 'icon-sports',
847
- 'stationery', 'icon-stationery',
848
- //'supermarket', 'icon-supermarket',
849
- 'toys', 'icon-toys',
850
- 'travel_agency', 'icon-travel_agent',
851
- 'video', 'icon-video',
852
- 'icon-shop',
816
+ 'alcohol', 'basics:icon-alcohol_shop',
817
+ 'bakery', 'basics:icon-bakery',
818
+ 'beauty', 'basics:icon-beauty',
819
+ 'beverages', 'basics:icon-beverages',
820
+ //'bicycle', 'basics:icon-bicycle',
821
+ 'books', 'basics:icon-books',
822
+ 'butcher', 'basics:icon-butcher',
823
+ //'car', 'basics:icon-car',
824
+ 'chemist', 'basics:icon-chemist',
825
+ 'clothes', 'basics:icon-clothes',
826
+ //'computer', 'basics:icon-computer',
827
+ //'convinience', 'basics:icon-convinience',
828
+ //'department_store', 'basics:icon-department_store',
829
+ 'doityourself', 'basics:icon-doityourself',
830
+ 'dry_cleaning', 'basics:icon-drycleaning',
831
+ 'florist', 'basics:icon-florist',
832
+ 'furniture', 'basics:icon-furniture',
833
+ 'garden_centre', 'basics:icon-garden_centre',
834
+ 'general', 'basics:icon-shop',
835
+ 'gift', 'basics:icon-gift',
836
+ 'greengrocer', 'basics:icon-greengrocer',
837
+ 'hairdresser', 'basics:icon-hairdresser',
838
+ 'hardware', 'basics:icon-hardware',
839
+ 'jewelry', 'basics:icon-jewelry_store',
840
+ 'kiosk', 'basics:icon-kiosk',
841
+ 'laundry', 'basics:icon-laundry',
842
+ //'mall', 'basics:icon-mall',
843
+ //'mobile_phone', 'basics:icon-mobile_phone',
844
+ 'newsagent', 'basics:icon-newsagent',
845
+ 'optican', 'basics:icon-optician',
846
+ 'outdoor', 'basics:icon-outdoor',
847
+ 'shoes', 'basics:icon-shoes',
848
+ 'sports', 'basics:icon-sports',
849
+ 'stationery', 'basics:icon-stationery',
850
+ //'supermarket', 'basics:icon-supermarket',
851
+ 'toys', 'basics:icon-toys',
852
+ 'travel_agency', 'basics:icon-travel_agent',
853
+ 'video', 'basics:icon-video',
854
+ 'basics:icon-shop',
853
855
  ],
854
856
  },
855
857
  'poi-man_made': {
856
858
  image: ['match',
857
859
  ['get', 'man_made'],
858
- 'lighthouse', 'icon-lighthouse',
859
- 'surveillance', 'icon-surveillance',
860
- 'tower', 'icon-observation_tower',
861
- //'wastewater_plant', 'icon-wastewater_plant',
862
- //'water_well', 'icon-water_well',
863
- //'water_works', 'icon-water_works',
864
- 'watermill', 'icon-watermill',
865
- 'windmill', 'icon-windmill',
866
- 'unknown',
860
+ 'lighthouse', 'basics:icon-lighthouse',
861
+ 'surveillance', 'basics:icon-surveillance',
862
+ 'tower', 'basics:icon-observation_tower',
863
+ //'wastewater_plant', 'basics:icon-wastewater_plant',
864
+ //'water_well', 'basics:icon-water_well',
865
+ //'water_works', 'basics:icon-water_works',
866
+ 'watermill', 'basics:icon-watermill',
867
+ 'windmill', 'basics:icon-windmill',
868
+ '',
867
869
  ],
868
870
  },
869
871
  'poi-historic': {
870
872
  image: ['match',
871
873
  ['get', 'historic'],
872
- //'archaelogical_site', 'icon-archaelogical_site',
873
- 'artwork', 'icon-artwork',
874
- //'battlefield', 'icon-battlefield',
875
- 'castle', 'icon-castle',
876
- //'fort', 'icon-fort',
877
- //'memorial', 'icon-memorial',
878
- 'monument', 'icon-monument',
879
- //'ruins', 'icon-ruins',
880
- //'wayside_cross', 'icon-wayside_cross',
881
- 'wayside_shrine', 'icon-shrine',
882
- 'icon-historic',
874
+ //'archaelogical_site', 'basics:icon-archaelogical_site',
875
+ 'artwork', 'basics:icon-artwork',
876
+ //'battlefield', 'basics:icon-battlefield',
877
+ 'castle', 'basics:icon-castle',
878
+ //'fort', 'basics:icon-fort',
879
+ //'memorial', 'basics:icon-memorial',
880
+ 'monument', 'basics:icon-monument',
881
+ //'ruins', 'basics:icon-ruins',
882
+ //'wayside_cross', 'basics:icon-wayside_cross',
883
+ 'wayside_shrine', 'basics:icon-shrine',
884
+ 'basics:icon-historic',
883
885
  ],
884
886
  },
885
887
  'poi-emergency': {
886
888
  image: ['match',
887
889
  ['get', 'emergency'],
888
- 'defibrillator', 'icon-defibrillator',
889
- 'fire_hydrant', 'icon-hydrant',
890
- 'phone', 'icon-emergency_phone',
891
- 'unknown',
890
+ 'defibrillator', 'basics:icon-defibrillator',
891
+ 'fire_hydrant', 'basics:icon-hydrant',
892
+ 'phone', 'basics:icon-emergency_phone',
893
+ '',
892
894
  ],
893
895
  },
894
896
  /*
895
897
  'poi-highway': {
896
898
  image: ['match',
897
899
  ['get', 'highway'],
898
- //'emergency_access_point', 'icon-emergency_access_point',
899
- 'unknown'
900
+ //'emergency_access_point', 'basics:icon-emergency_access_point',
901
+ ''
900
902
  ]
901
903
  },
902
904
  'poi-office': {
903
905
  image: ['match',
904
906
  ['get', 'office'],
905
- //'diplomatic', 'icon-diplomatic',
906
- 'unknown'
907
+ //'diplomatic', 'basics:icon-diplomatic',
908
+ ''
907
909
  ]
908
910
  },
909
911
  */
@@ -0,0 +1,11 @@
1
+ import StyleBuilder from '../style_builder/style_builder.js';
2
+ import type { StyleRules, StyleRulesOptions } from '../style_builder/types.js';
3
+ export default class Empty extends StyleBuilder<Empty> {
4
+ readonly name: string;
5
+ defaultFonts: {
6
+ regular: string;
7
+ bold: string;
8
+ };
9
+ defaultColors: {};
10
+ protected getStyleRules(options: StyleRulesOptions<Empty>): StyleRules;
11
+ }
@@ -0,0 +1,13 @@
1
+ import StyleBuilder from '../style_builder/style_builder.js';
2
+ export default class Empty extends StyleBuilder {
3
+ name = 'Empty';
4
+ defaultFonts = {
5
+ regular: 'noto_sans_regular',
6
+ bold: 'noto_sans_bold',
7
+ };
8
+ defaultColors = {};
9
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
+ getStyleRules(options) {
11
+ return {};
12
+ }
13
+ }
@@ -7,11 +7,13 @@ import Colorful from './colorful.js';
7
7
  import Eclipse from './eclipse.js';
8
8
  import Graybeard from './graybeard.js';
9
9
  import Neutrino from './neutrino.js';
10
+ import Empty from './empty.js';
10
11
  export type ColorfulOptions = StyleBuilderOptions<Colorful>;
11
12
  export type EclipseOptions = StyleBuilderOptions<Eclipse>;
12
13
  export type GraybeardOptions = StyleBuilderOptions<Graybeard>;
13
14
  export type NeutrinoOptions = StyleBuilderOptions<Neutrino>;
14
- export type SomeOptions = ColorfulOptions | EclipseOptions | GraybeardOptions | NeutrinoOptions;
15
+ export type EmptyOptions = StyleBuilderOptions<Empty>;
16
+ export type SomeOptions = ColorfulOptions | EclipseOptions | EmptyOptions | GraybeardOptions | NeutrinoOptions;
15
17
  type MakeStyle<T extends StyleBuilder<T>, O extends StyleBuilderOptions<T>> = ((options?: O) => MaplibreStyle) & {
16
18
  getOptions: () => O;
17
19
  };
@@ -19,8 +21,10 @@ export type ColorfulBuilder = MakeStyle<Colorful, ColorfulOptions>;
19
21
  export type EclipseBuilder = MakeStyle<Eclipse, EclipseOptions>;
20
22
  export type GraybeardBuilder = MakeStyle<Graybeard, GraybeardOptions>;
21
23
  export type NeutrinoBuilder = MakeStyle<Neutrino, NeutrinoOptions>;
22
- export type SomeBuilder = ColorfulBuilder | GraybeardBuilder | NeutrinoBuilder;
24
+ export type EmptyBuilder = MakeStyle<Empty, EmptyOptions>;
25
+ export type SomeBuilder = ColorfulBuilder | EclipseBuilder | EmptyBuilder | GraybeardBuilder | NeutrinoBuilder;
23
26
  export declare const colorful: ColorfulBuilder;
24
27
  export declare const eclipse: EclipseBuilder;
25
28
  export declare const graybeard: GraybeardBuilder;
26
29
  export declare const neutrino: NeutrinoBuilder;
30
+ export declare const empty: EmptyBuilder;
@@ -3,6 +3,7 @@ import Colorful from './colorful.js';
3
3
  import Eclipse from './eclipse.js';
4
4
  import Graybeard from './graybeard.js';
5
5
  import Neutrino from './neutrino.js';
6
+ import Empty from './empty.js';
6
7
  function getStyleBuilder(styleBuilder) {
7
8
  const fn = function (options) {
8
9
  return new styleBuilder().build(options);
@@ -15,3 +16,4 @@ export const colorful = getStyleBuilder(Colorful);
15
16
  export const eclipse = getStyleBuilder(Eclipse);
16
17
  export const graybeard = getStyleBuilder(Graybeard);
17
18
  export const neutrino = getStyleBuilder(Neutrino);
19
+ export const empty = getStyleBuilder(Empty);
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
1
  import StyleBuilder from '../style_builder/style_builder.js';
3
2
  export default class Neutrino extends StyleBuilder {
4
3
  name = 'Neutrino';
@@ -77,6 +76,9 @@ export default class Neutrino extends StyleBuilder {
77
76
  color: colors.land,
78
77
  opacity: { 12: 0, 13: 1 },
79
78
  },
79
+ 'water-pier': {
80
+ color: colors.land,
81
+ },
80
82
  'land-*': {
81
83
  color: colors.land,
82
84
  },
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@versatiles/style",
3
- "version": "4.4.0",
3
+ "version": "5.0.0",
4
4
  "description": "Generate StyleJSON for MapLibre",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
- "check": "npm run lint && npm run build && npm run test",
8
+ "check": "npm run lint && npm run test && npm run build",
9
9
  "build": "rm -rf release; npm run build-browser && npm run build-node && npm run build-styles && npm run build-sprites",
10
- "build-browser": "rollup -c=rollup.config.js; $(cd release/versatiles-style; tar -cf - versatiles-style.* | gzip -9 > ../versatiles-style.tar.gz); rm -rf release/versatiles-style",
10
+ "build-browser": "rollup -c=rollup.config.js && $(cd release/versatiles-style; tar -cf - versatiles-style.* | gzip -9 > ../versatiles-style.tar.gz)",
11
11
  "build-node": "rm -rf dist && tsc -p tsconfig.node.json && chmod +x dist/index.js",
12
12
  "build-styles": "tsx scripts/build-styles.ts",
13
13
  "build-sprites": "tsx scripts/build-sprites.ts",
14
- "// dev": "????",
14
+ "dev": "tsx scripts/dev.ts",
15
15
  "// doc": "vrt ts2md src/index.ts tsconfig.node.json | vrt insertmd README.md '# API'",
16
16
  "lint": "eslint --color .",
17
+ "prepack": "npm run build",
17
18
  "release": "npx vrt release-npm",
18
19
  "test": "npm run test-typescript",
19
20
  "test-coverage": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
@@ -28,7 +29,7 @@
28
29
  "license": "MIT",
29
30
  "type": "module",
30
31
  "dependencies": {
31
- "@types/color": "^3.0.6",
32
+ "@types/color": "^4.2.0",
32
33
  "brace-expansion": "^4.0.0",
33
34
  "color": "^4.2.3"
34
35
  },
@@ -37,35 +38,36 @@
37
38
  "dist/**/*.d.ts"
38
39
  ],
39
40
  "devDependencies": {
40
- "@maplibre/maplibre-gl-style-spec": "^20.1.1",
41
- "@rollup/plugin-commonjs": "^25.0.7",
42
- "@rollup/plugin-node-resolve": "^15.2.3",
41
+ "@maplibre/maplibre-gl-style-spec": "^21.2.0",
42
+ "@rollup/plugin-commonjs": "^28.0.1",
43
+ "@rollup/plugin-node-resolve": "^15.3.0",
43
44
  "@rollup/plugin-terser": "^0.4.4",
44
- "@rollup/plugin-typescript": "^11.1.6",
45
+ "@rollup/plugin-typescript": "^12.1.1",
45
46
  "@types/bin-pack": "^1.0.3",
46
47
  "@types/brace-expansion": "^1.1.2",
47
48
  "@types/inquirer": "^9.0.7",
48
- "@types/jest": "^29.5.12",
49
- "@types/node": "^20.12.4",
49
+ "@types/jest": "^29.5.14",
50
+ "@types/node": "^22.9.0",
50
51
  "@types/tar-stream": "^3.1.3",
51
- "@typescript-eslint/eslint-plugin": "^7.5.0",
52
- "@typescript-eslint/parser": "^7.5.0",
53
- "@versatiles/container": "^1.2.1",
54
- "@versatiles/release-tool": "^1.2.2",
52
+ "@typescript-eslint/eslint-plugin": "^8.14.0",
53
+ "@typescript-eslint/parser": "^8.14.0",
54
+ "@versatiles/container": "^1.2.3",
55
+ "@versatiles/release-tool": "^1.2.6",
55
56
  "bin-pack": "^1.0.2",
56
- "eslint": "^8.57.0",
57
- "inquirer": "^9.2.17",
57
+ "eslint": "^9.14.0",
58
+ "inquirer": "^12.1.0",
58
59
  "jest": "^29.7.0",
59
60
  "jest-environment-jsdom": "^29.7.0",
60
61
  "jest-ts-webcompat-resolver": "^1.0.0",
61
- "npm-check-updates": "^16.14.18",
62
- "rollup": "^4.14.0",
63
- "rollup-plugin-dts": "^6.1.0",
64
- "sharp": "^0.33.3",
62
+ "npm-check-updates": "^17.1.11",
63
+ "rollup": "^4.26.0",
64
+ "rollup-plugin-dts": "^6.1.1",
65
+ "sharp": "^0.33.5",
65
66
  "tar-stream": "^3.1.7",
66
- "ts-jest": "^29.1.2",
67
+ "ts-jest": "^29.2.5",
67
68
  "ts-node": "^10.9.2",
68
- "tsx": "^4.7.2",
69
- "typescript": "^5.4.4"
69
+ "tsx": "^4.19.2",
70
+ "typescript": "^5.6.3",
71
+ "typescript-eslint": "^8.14.0"
70
72
  }
71
73
  }