@versatiles/style 5.2.0 → 5.2.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.
Files changed (42) hide show
  1. package/dist/color/abstract.d.ts +3 -2
  2. package/dist/color/hsl.d.ts +2 -1
  3. package/dist/color/hsl.js +8 -6
  4. package/dist/color/hsv.d.ts +2 -1
  5. package/dist/color/hsv.js +7 -0
  6. package/dist/color/index.d.ts +4 -1
  7. package/dist/color/index.js +0 -1
  8. package/dist/color/random.js +18 -12
  9. package/dist/color/rgb.d.ts +2 -1
  10. package/dist/color/rgb.js +7 -0
  11. package/dist/guess_style/guess_style.d.ts +8 -5
  12. package/dist/guess_style/guess_style.js +39 -104
  13. package/dist/guess_style/index.d.ts +2 -2
  14. package/dist/guess_style/index.js +1 -1
  15. package/dist/index.d.ts +9 -4
  16. package/dist/index.js +3 -3
  17. package/dist/lib/utils.js +1 -1
  18. package/dist/shortbread/template.d.ts +4 -2
  19. package/dist/shortbread/template.js +308 -309
  20. package/dist/style_builder/decorator.js +1 -1
  21. package/dist/style_builder/recolor.d.ts +1 -1
  22. package/dist/style_builder/recolor.js +1 -1
  23. package/dist/style_builder/style_builder.d.ts +4 -4
  24. package/dist/style_builder/style_builder.js +2 -2
  25. package/dist/style_builder/types.d.ts +4 -6
  26. package/dist/styles/colorful.d.ts +1 -1
  27. package/dist/styles/colorful.js +1 -1
  28. package/dist/styles/empty.d.ts +1 -1
  29. package/dist/styles/empty.js +1 -1
  30. package/dist/styles/index.d.ts +3 -5
  31. package/dist/styles/neutrino.d.ts +1 -1
  32. package/dist/styles/neutrino.js +1 -1
  33. package/dist/types/index.d.ts +2 -2
  34. package/dist/types/maplibre.d.ts +2 -16
  35. package/dist/types/tilejson.d.ts +5 -10
  36. package/dist/types/tilejson.js +21 -38
  37. package/package.json +1 -2
  38. package/LICENSE +0 -21
  39. package/dist/browser.d.ts +0 -6
  40. package/dist/browser.js +0 -4
  41. package/dist/guess_style/types.d.ts +0 -23
  42. package/dist/guess_style/types.js +0 -1
@@ -4,21 +4,18 @@ export function getShortbreadTemplate() {
4
4
  version: 8,
5
5
  name: 'versatiles',
6
6
  metadata: {
7
- 'maputnik:renderer': 'mbgljs',
8
7
  license: 'https://creativecommons.org/publicdomain/zero/1.0/',
9
8
  },
10
9
  glyphs: 'https://tiles.versatiles.org/assets/glyphs/{fontstack}/{range}.pbf',
11
10
  sprite: [{ id: 'basics', url: 'https://tiles.versatiles.org/assets/sprites/basics/sprites' }],
12
11
  sources: {
13
12
  'versatiles-shortbread': {
14
- tilejson: '3.0.0',
15
13
  attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
16
14
  tiles: [
17
15
  'https://tiles.versatiles.org/tiles/osm/{z}/{x}/{y}',
18
16
  ],
19
17
  type: 'vector',
20
18
  scheme: 'xyz',
21
- format: 'pbf',
22
19
  bounds: [
23
20
  -180,
24
21
  -85.0511287798066,
@@ -26,314 +23,316 @@ export function getShortbreadTemplate() {
26
23
  85.0511287798066,
27
24
  ],
28
25
  minzoom: 0,
29
- maxzoom,
30
- vector_layers: [
31
- {
32
- id: 'place_labels',
33
- fields: {
34
- kind: 'String',
35
- name: 'String',
36
- name_de: 'String',
37
- name_en: 'String',
38
- population: 'Number',
39
- },
40
- minzoom: 3,
41
- maxzoom,
42
- },
43
- {
44
- id: 'boundaries',
45
- fields: {
46
- admin_level: 'Number',
47
- coastline: 'Boolean',
48
- disputed: 'Boolean',
49
- maritime: 'Boolean',
50
- },
51
- minzoom: 0,
52
- maxzoom,
53
- },
54
- {
55
- id: 'boundary_labels',
56
- fields: {
57
- admin_level: 'Number',
58
- land_area: 'Number',
59
- name: 'String',
60
- name_de: 'String',
61
- name_en: 'String',
62
- name_single: 'String',
63
- way_area: 'Number',
64
- },
65
- minzoom: 2,
66
- maxzoom,
67
- },
68
- {
69
- id: 'addresses',
70
- fields: {
71
- housename: 'String',
72
- housenumber: 'String',
73
- },
74
- minzoom: 14,
75
- maxzoom,
76
- },
77
- {
78
- id: 'water_lines',
79
- fields: {
80
- bridge: 'Boolean',
81
- kind: 'String',
82
- tunnel: 'Boolean',
83
- },
84
- minzoom: 4,
85
- maxzoom,
86
- },
87
- {
88
- id: 'water_lines_labels',
89
- fields: {
90
- bridge: 'Boolean',
91
- kind: 'String',
92
- name: 'String',
93
- name_de: 'String',
94
- name_en: 'String',
95
- tunnel: 'Boolean',
96
- },
97
- minzoom: 4,
98
- maxzoom,
99
- },
100
- {
101
- id: 'dam_lines',
102
- fields: {
103
- kind: 'String',
104
- },
105
- minzoom: 12,
106
- maxzoom,
107
- },
108
- {
109
- id: 'dam_polygons',
110
- fields: {
111
- kind: 'String',
112
- },
113
- minzoom: 12,
114
- maxzoom,
115
- },
116
- {
117
- id: 'pier_lines',
118
- fields: {
119
- kind: 'String',
120
- },
121
- minzoom: 12,
122
- maxzoom,
123
- },
124
- {
125
- id: 'pier_polygons',
126
- fields: {
127
- kind: 'String',
128
- },
129
- minzoom: 12,
130
- maxzoom,
131
- },
132
- {
133
- id: 'bridges',
134
- fields: {
135
- kind: 'String',
136
- },
137
- minzoom: 12,
138
- maxzoom,
139
- },
140
- {
141
- id: 'street_polygons',
142
- fields: {
143
- bridge: 'Boolean',
144
- kind: 'String',
145
- rail: 'Boolean',
146
- service: 'String',
147
- surface: 'String',
148
- tunnel: 'Boolean',
149
- },
150
- minzoom: 11,
151
- maxzoom,
152
- },
153
- {
154
- id: 'streets_polygons_labels',
155
- fields: {
156
- kind: 'String',
157
- name: 'String',
158
- name_de: 'String',
159
- name_en: 'String',
160
- },
161
- minzoom: 14,
162
- maxzoom,
163
- },
164
- {
165
- id: 'ferries',
166
- fields: {
167
- kind: 'String',
168
- name: 'String',
169
- name_de: 'String',
170
- name_en: 'String',
171
- },
172
- minzoom: 8,
173
- maxzoom,
174
- },
175
- {
176
- id: 'streets',
177
- fields: {
178
- bicycle: 'String',
179
- bridge: 'Boolean',
180
- horse: 'String',
181
- kind: 'String',
182
- link: 'Boolean',
183
- oneway: 'Boolean',
184
- oneway_reverse: 'Boolean',
185
- rail: 'Boolean',
186
- service: 'String',
187
- surface: 'String',
188
- tracktype: 'String',
189
- tunnel: 'Boolean',
190
- },
191
- minzoom: 5,
192
- maxzoom,
193
- },
194
- {
195
- id: 'street_labels',
196
- fields: {
197
- kind: 'String',
198
- name: 'String',
199
- name_de: 'String',
200
- name_en: 'String',
201
- ref: 'String',
202
- ref_cols: 'Number',
203
- ref_rows: 'Number',
204
- tunnel: 'Boolean',
205
- },
206
- minzoom: 10,
207
- maxzoom,
208
- },
209
- {
210
- id: 'street_labels_points',
211
- fields: {
212
- kind: 'String',
213
- name: 'String',
214
- name_de: 'String',
215
- name_en: 'String',
216
- ref: 'String',
217
- },
218
- minzoom: 12,
219
- maxzoom,
220
- },
221
- {
222
- id: 'aerialways',
223
- fields: {
224
- kind: 'String',
225
- },
226
- minzoom: 12,
227
- maxzoom,
228
- },
229
- {
230
- id: 'public_transport',
231
- fields: {
232
- iata: 'String',
233
- kind: 'String',
234
- name: 'String',
235
- name_de: 'String',
236
- name_en: 'String',
237
- station: 'String',
238
- },
239
- minzoom: 11,
240
- maxzoom,
241
- },
242
- {
243
- id: 'buildings',
244
- fields: {
245
- amenity: 'String',
246
- dummy: 'Number',
247
- name: 'String',
248
- name_de: 'String',
249
- name_en: 'String',
250
- },
251
- minzoom: 14,
252
- maxzoom,
253
- },
254
- {
255
- id: 'water_polygons',
256
- fields: {
257
- kind: 'String',
258
- way_area: 'Number',
259
- },
260
- minzoom: 4,
261
- maxzoom,
262
- },
263
- {
264
- id: 'ocean',
265
- fields: {
266
- x: 'Number',
267
- y: 'Number',
268
- },
269
- minzoom: 0,
270
- maxzoom,
271
- },
272
- {
273
- id: 'water_polygons_labels',
274
- fields: {
275
- kind: 'String',
276
- name: 'String',
277
- name_de: 'String',
278
- name_en: 'String',
279
- way_area: 'Number',
280
- },
281
- minzoom: 14,
282
- maxzoom,
283
- },
284
- {
285
- id: 'land',
286
- fields: {
287
- kind: 'String',
288
- },
289
- minzoom: 7,
290
- maxzoom,
291
- },
292
- {
293
- id: 'sites',
294
- fields: {
295
- amenity: 'String',
296
- kind: 'String',
297
- name: 'String',
298
- name_de: 'String',
299
- name_en: 'String',
300
- },
301
- minzoom: 14,
302
- maxzoom,
303
- },
304
- {
305
- id: 'pois',
306
- fields: {
307
- amenity: 'String',
308
- atm: 'Boolean',
309
- cuisine: 'String',
310
- denomination: 'String',
311
- emergency: 'String',
312
- highway: 'String',
313
- historic: 'String',
314
- information: 'String',
315
- leisure: 'String',
316
- man_made: 'String',
317
- name: 'String',
318
- name_de: 'String',
319
- name_en: 'String',
320
- 'recycling:clothes': 'Boolean',
321
- 'recycling:glass_bottles': 'Boolean',
322
- 'recycling:paper': 'Boolean',
323
- 'recycling:scrap_metal': 'Boolean',
324
- religion: 'String',
325
- shop: 'String',
326
- sport: 'String',
327
- tourism: 'String',
328
- 'tower:type': 'String',
329
- vending: 'String',
330
- },
331
- minzoom: 14,
332
- maxzoom,
333
- },
334
- ],
26
+ maxzoom
335
27
  },
336
28
  },
337
29
  layers: [],
338
30
  };
339
31
  }
32
+ export function getShortbreadVectorLayers() {
33
+ return [
34
+ {
35
+ id: 'place_labels',
36
+ fields: {
37
+ kind: 'String',
38
+ name: 'String',
39
+ name_de: 'String',
40
+ name_en: 'String',
41
+ population: 'Number',
42
+ },
43
+ minzoom: 3,
44
+ maxzoom,
45
+ },
46
+ {
47
+ id: 'boundaries',
48
+ fields: {
49
+ admin_level: 'Number',
50
+ coastline: 'Boolean',
51
+ disputed: 'Boolean',
52
+ maritime: 'Boolean',
53
+ },
54
+ minzoom: 0,
55
+ maxzoom,
56
+ },
57
+ {
58
+ id: 'boundary_labels',
59
+ fields: {
60
+ admin_level: 'Number',
61
+ land_area: 'Number',
62
+ name: 'String',
63
+ name_de: 'String',
64
+ name_en: 'String',
65
+ name_single: 'String',
66
+ way_area: 'Number',
67
+ },
68
+ minzoom: 2,
69
+ maxzoom,
70
+ },
71
+ {
72
+ id: 'addresses',
73
+ fields: {
74
+ housename: 'String',
75
+ housenumber: 'String',
76
+ },
77
+ minzoom: 14,
78
+ maxzoom,
79
+ },
80
+ {
81
+ id: 'water_lines',
82
+ fields: {
83
+ bridge: 'Boolean',
84
+ kind: 'String',
85
+ tunnel: 'Boolean',
86
+ },
87
+ minzoom: 4,
88
+ maxzoom,
89
+ },
90
+ {
91
+ id: 'water_lines_labels',
92
+ fields: {
93
+ bridge: 'Boolean',
94
+ kind: 'String',
95
+ name: 'String',
96
+ name_de: 'String',
97
+ name_en: 'String',
98
+ tunnel: 'Boolean',
99
+ },
100
+ minzoom: 4,
101
+ maxzoom,
102
+ },
103
+ {
104
+ id: 'dam_lines',
105
+ fields: {
106
+ kind: 'String',
107
+ },
108
+ minzoom: 12,
109
+ maxzoom,
110
+ },
111
+ {
112
+ id: 'dam_polygons',
113
+ fields: {
114
+ kind: 'String',
115
+ },
116
+ minzoom: 12,
117
+ maxzoom,
118
+ },
119
+ {
120
+ id: 'pier_lines',
121
+ fields: {
122
+ kind: 'String',
123
+ },
124
+ minzoom: 12,
125
+ maxzoom,
126
+ },
127
+ {
128
+ id: 'pier_polygons',
129
+ fields: {
130
+ kind: 'String',
131
+ },
132
+ minzoom: 12,
133
+ maxzoom,
134
+ },
135
+ {
136
+ id: 'bridges',
137
+ fields: {
138
+ kind: 'String',
139
+ },
140
+ minzoom: 12,
141
+ maxzoom,
142
+ },
143
+ {
144
+ id: 'street_polygons',
145
+ fields: {
146
+ bridge: 'Boolean',
147
+ kind: 'String',
148
+ rail: 'Boolean',
149
+ service: 'String',
150
+ surface: 'String',
151
+ tunnel: 'Boolean',
152
+ },
153
+ minzoom: 11,
154
+ maxzoom,
155
+ },
156
+ {
157
+ id: 'streets_polygons_labels',
158
+ fields: {
159
+ kind: 'String',
160
+ name: 'String',
161
+ name_de: 'String',
162
+ name_en: 'String',
163
+ },
164
+ minzoom: 14,
165
+ maxzoom,
166
+ },
167
+ {
168
+ id: 'ferries',
169
+ fields: {
170
+ kind: 'String',
171
+ name: 'String',
172
+ name_de: 'String',
173
+ name_en: 'String',
174
+ },
175
+ minzoom: 8,
176
+ maxzoom,
177
+ },
178
+ {
179
+ id: 'streets',
180
+ fields: {
181
+ bicycle: 'String',
182
+ bridge: 'Boolean',
183
+ horse: 'String',
184
+ kind: 'String',
185
+ link: 'Boolean',
186
+ oneway: 'Boolean',
187
+ oneway_reverse: 'Boolean',
188
+ rail: 'Boolean',
189
+ service: 'String',
190
+ surface: 'String',
191
+ tracktype: 'String',
192
+ tunnel: 'Boolean',
193
+ },
194
+ minzoom: 5,
195
+ maxzoom,
196
+ },
197
+ {
198
+ id: 'street_labels',
199
+ fields: {
200
+ kind: 'String',
201
+ name: 'String',
202
+ name_de: 'String',
203
+ name_en: 'String',
204
+ ref: 'String',
205
+ ref_cols: 'Number',
206
+ ref_rows: 'Number',
207
+ tunnel: 'Boolean',
208
+ },
209
+ minzoom: 10,
210
+ maxzoom,
211
+ },
212
+ {
213
+ id: 'street_labels_points',
214
+ fields: {
215
+ kind: 'String',
216
+ name: 'String',
217
+ name_de: 'String',
218
+ name_en: 'String',
219
+ ref: 'String',
220
+ },
221
+ minzoom: 12,
222
+ maxzoom,
223
+ },
224
+ {
225
+ id: 'aerialways',
226
+ fields: {
227
+ kind: 'String',
228
+ },
229
+ minzoom: 12,
230
+ maxzoom,
231
+ },
232
+ {
233
+ id: 'public_transport',
234
+ fields: {
235
+ iata: 'String',
236
+ kind: 'String',
237
+ name: 'String',
238
+ name_de: 'String',
239
+ name_en: 'String',
240
+ station: 'String',
241
+ },
242
+ minzoom: 11,
243
+ maxzoom,
244
+ },
245
+ {
246
+ id: 'buildings',
247
+ fields: {
248
+ amenity: 'String',
249
+ dummy: 'Number',
250
+ name: 'String',
251
+ name_de: 'String',
252
+ name_en: 'String',
253
+ },
254
+ minzoom: 14,
255
+ maxzoom,
256
+ },
257
+ {
258
+ id: 'water_polygons',
259
+ fields: {
260
+ kind: 'String',
261
+ way_area: 'Number',
262
+ },
263
+ minzoom: 4,
264
+ maxzoom,
265
+ },
266
+ {
267
+ id: 'ocean',
268
+ fields: {
269
+ x: 'Number',
270
+ y: 'Number',
271
+ },
272
+ minzoom: 0,
273
+ maxzoom,
274
+ },
275
+ {
276
+ id: 'water_polygons_labels',
277
+ fields: {
278
+ kind: 'String',
279
+ name: 'String',
280
+ name_de: 'String',
281
+ name_en: 'String',
282
+ way_area: 'Number',
283
+ },
284
+ minzoom: 14,
285
+ maxzoom,
286
+ },
287
+ {
288
+ id: 'land',
289
+ fields: {
290
+ kind: 'String',
291
+ },
292
+ minzoom: 7,
293
+ maxzoom,
294
+ },
295
+ {
296
+ id: 'sites',
297
+ fields: {
298
+ amenity: 'String',
299
+ kind: 'String',
300
+ name: 'String',
301
+ name_de: 'String',
302
+ name_en: 'String',
303
+ },
304
+ minzoom: 14,
305
+ maxzoom,
306
+ },
307
+ {
308
+ id: 'pois',
309
+ fields: {
310
+ amenity: 'String',
311
+ atm: 'Boolean',
312
+ cuisine: 'String',
313
+ denomination: 'String',
314
+ emergency: 'String',
315
+ highway: 'String',
316
+ historic: 'String',
317
+ information: 'String',
318
+ leisure: 'String',
319
+ man_made: 'String',
320
+ name: 'String',
321
+ name_de: 'String',
322
+ name_en: 'String',
323
+ 'recycling:clothes': 'Boolean',
324
+ 'recycling:glass_bottles': 'Boolean',
325
+ 'recycling:paper': 'Boolean',
326
+ 'recycling:scrap_metal': 'Boolean',
327
+ religion: 'String',
328
+ shop: 'String',
329
+ sport: 'String',
330
+ tourism: 'String',
331
+ 'tower:type': 'String',
332
+ vending: 'String',
333
+ },
334
+ minzoom: 14,
335
+ maxzoom,
336
+ },
337
+ ];
338
+ }
@@ -1,4 +1,4 @@
1
- import Color from '../color/index.js';
1
+ import { Color } from '../color/index.js';
2
2
  import expandBraces from 'brace-expansion';
3
3
  import maplibreProperties from '../shortbread/properties.js';
4
4
  import { deepMerge } from '../lib/utils.js';
@@ -1,4 +1,4 @@
1
- import Color from '../color/index.js';
1
+ import { Color } from '../color/index.js';
2
2
  export interface RecolorOptions {
3
3
  invertBrightness?: boolean;
4
4
  rotate?: number;
@@ -1,4 +1,4 @@
1
- import Color from '../color/index.js';
1
+ import { Color } from '../color/index.js';
2
2
  export function getDefaultRecolorFlags() {
3
3
  return {
4
4
  invertBrightness: false,
@@ -1,13 +1,13 @@
1
- import Color from '../color/index.js';
2
- import type { MaplibreStyle } from '../types/maplibre.js';
1
+ import { Color } from '../color/index.js';
2
+ import type { StyleSpecification } from '../types/maplibre.js';
3
3
  import type { StyleBuilderColorStrings, StyleBuilderColors, StyleBuilderFontStrings, StyleBuilderOptions } from './types.js';
4
4
  import type { StyleRules, StyleRulesOptions } from './types.js';
5
- export default abstract class StyleBuilder<Subclass extends StyleBuilder<Subclass>> {
5
+ export declare abstract class StyleBuilder<Subclass extends StyleBuilder<Subclass>> {
6
6
  #private;
7
7
  abstract readonly name: string;
8
8
  abstract readonly defaultColors: StyleBuilderColorStrings<Subclass>;
9
9
  abstract readonly defaultFonts: StyleBuilderFontStrings<Subclass>;
10
- build(options?: StyleBuilderOptions<Subclass>): MaplibreStyle;
10
+ build(options?: StyleBuilderOptions<Subclass>): StyleSpecification;
11
11
  getColors(colors: StyleBuilderColorStrings<Subclass>): StyleBuilderColors<Subclass>;
12
12
  getDefaultOptions(): StyleBuilderOptions<Subclass>;
13
13
  protected transformDefaultColors(callback: (color: Color) => Color): void;
@@ -1,10 +1,10 @@
1
- import Color from '../color/index.js';
1
+ import { Color } from '../color/index.js';
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
5
  import { basename, deepClone, resolveUrl } from '../lib/utils.js';
6
6
  // StyleBuilder class definition
7
- export default class StyleBuilder {
7
+ export class StyleBuilder {
8
8
  #sourceName = 'versatiles-shortbread';
9
9
  build(options) {
10
10
  options ??= {};