@versatiles/style 5.2.5 → 5.2.7

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 (102) hide show
  1. package/dist/index.d.ts +274 -14
  2. package/dist/index.js +3650 -11
  3. package/dist/index.js.map +1 -0
  4. package/package.json +8 -7
  5. package/src/color/abstract.ts +83 -0
  6. package/src/color/hsl.test.ts +182 -0
  7. package/src/color/hsl.ts +122 -0
  8. package/src/color/hsv.test.ts +174 -0
  9. package/src/color/hsv.ts +100 -0
  10. package/src/color/index.test.ts +119 -0
  11. package/src/color/index.ts +38 -0
  12. package/src/color/random.test.ts +35 -0
  13. package/src/color/random.ts +165 -0
  14. package/src/color/rgb.test.ts +227 -0
  15. package/src/color/rgb.ts +248 -0
  16. package/src/color/utils.test.ts +86 -0
  17. package/src/color/utils.ts +13 -0
  18. package/src/guess_style/guess_style.test.ts +134 -0
  19. package/src/guess_style/guess_style.ts +166 -0
  20. package/{dist/guess_style/index.d.ts → src/guess_style/index.ts} +1 -0
  21. package/src/index.test.ts +77 -0
  22. package/src/index.ts +18 -0
  23. package/src/lib/utils.test.ts +197 -0
  24. package/src/lib/utils.ts +134 -0
  25. package/{dist/shortbread/index.d.ts → src/shortbread/index.ts} +1 -0
  26. package/src/shortbread/layers.test.ts +36 -0
  27. package/src/shortbread/layers.ts +564 -0
  28. package/src/shortbread/properties.test.ts +44 -0
  29. package/src/shortbread/properties.ts +142 -0
  30. package/src/shortbread/template.test.ts +43 -0
  31. package/src/shortbread/template.ts +343 -0
  32. package/src/style_builder/decorator.test.ts +67 -0
  33. package/src/style_builder/decorator.ts +135 -0
  34. package/src/style_builder/recolor.test.ts +306 -0
  35. package/src/style_builder/recolor.ts +110 -0
  36. package/src/style_builder/style_builder.test.ts +103 -0
  37. package/src/style_builder/style_builder.ts +134 -0
  38. package/src/style_builder/types.ts +141 -0
  39. package/src/styles/LICENSE.md +41 -0
  40. package/src/styles/colorful.ts +1041 -0
  41. package/src/styles/eclipse.ts +11 -0
  42. package/{dist/styles/empty.d.ts → src/styles/empty.ts} +7 -3
  43. package/src/styles/graybeard.ts +11 -0
  44. package/src/styles/index.ts +33 -0
  45. package/src/styles/neutrino.ts +429 -0
  46. package/{dist/types/index.d.ts → src/types/index.ts} +1 -0
  47. package/{dist/types/maplibre.d.ts → src/types/maplibre.ts} +3 -0
  48. package/src/types/tilejson.test.ts +94 -0
  49. package/src/types/tilejson.ts +125 -0
  50. package/src/types/vector_layer.test.ts +64 -0
  51. package/src/types/vector_layer.ts +69 -0
  52. package/dist/color/abstract.d.ts +0 -34
  53. package/dist/color/abstract.js +0 -53
  54. package/dist/color/hsl.d.ts +0 -23
  55. package/dist/color/hsl.js +0 -98
  56. package/dist/color/hsv.d.ts +0 -20
  57. package/dist/color/hsv.js +0 -100
  58. package/dist/color/index.d.ts +0 -6
  59. package/dist/color/index.js +0 -29
  60. package/dist/color/random.d.ts +0 -9
  61. package/dist/color/random.js +0 -134
  62. package/dist/color/rgb.d.ts +0 -28
  63. package/dist/color/rgb.js +0 -195
  64. package/dist/color/utils.d.ts +0 -3
  65. package/dist/color/utils.js +0 -10
  66. package/dist/guess_style/guess_style.d.ts +0 -8
  67. package/dist/guess_style/guess_style.js +0 -147
  68. package/dist/guess_style/index.js +0 -2
  69. package/dist/lib/utils.d.ts +0 -6
  70. package/dist/lib/utils.js +0 -126
  71. package/dist/shortbread/index.js +0 -3
  72. package/dist/shortbread/layers.d.ts +0 -5
  73. package/dist/shortbread/layers.js +0 -521
  74. package/dist/shortbread/properties.d.ts +0 -7
  75. package/dist/shortbread/properties.js +0 -125
  76. package/dist/shortbread/template.d.ts +0 -4
  77. package/dist/shortbread/template.js +0 -339
  78. package/dist/style_builder/decorator.d.ts +0 -4
  79. package/dist/style_builder/decorator.js +0 -127
  80. package/dist/style_builder/recolor.d.ts +0 -22
  81. package/dist/style_builder/recolor.js +0 -89
  82. package/dist/style_builder/style_builder.d.ts +0 -15
  83. package/dist/style_builder/style_builder.js +0 -106
  84. package/dist/style_builder/types.d.ts +0 -122
  85. package/dist/style_builder/types.js +0 -3
  86. package/dist/styles/colorful.d.ts +0 -11
  87. package/dist/styles/colorful.js +0 -956
  88. package/dist/styles/eclipse.d.ts +0 -5
  89. package/dist/styles/eclipse.js +0 -9
  90. package/dist/styles/empty.js +0 -8
  91. package/dist/styles/graybeard.d.ts +0 -5
  92. package/dist/styles/graybeard.js +0 -9
  93. package/dist/styles/index.d.ts +0 -11
  94. package/dist/styles/index.js +0 -20
  95. package/dist/styles/neutrino.d.ts +0 -11
  96. package/dist/styles/neutrino.js +0 -401
  97. package/dist/types/index.js +0 -3
  98. package/dist/types/maplibre.js +0 -2
  99. package/dist/types/tilejson.d.ts +0 -32
  100. package/dist/types/tilejson.js +0 -87
  101. package/dist/types/vector_layer.d.ts +0 -14
  102. package/dist/types/vector_layer.js +0 -51
package/dist/index.d.ts CHANGED
@@ -1,15 +1,275 @@
1
- export { colorful, eclipse, graybeard, neutrino, type StyleBuilderFunction } from './styles/index.js';
2
- export declare const styles: {
3
- colorful: import("./styles/index.js").StyleBuilderFunction;
4
- eclipse: import("./styles/index.js").StyleBuilderFunction;
5
- graybeard: import("./styles/index.js").StyleBuilderFunction;
6
- neutrino: import("./styles/index.js").StyleBuilderFunction;
1
+ import { SpriteSpecification, StyleSpecification } from '@maplibre/maplibre-gl-style-spec';
2
+
3
+ declare class RGB extends Color {
4
+ readonly r: number;
5
+ readonly g: number;
6
+ readonly b: number;
7
+ readonly a: number;
8
+ constructor(r: number, g: number, b: number, a?: number);
9
+ clone(): RGB;
10
+ asArray(): [number, number, number, number];
11
+ round(): RGB;
12
+ asString(): string;
13
+ asHex(): string;
14
+ asHSL(): HSL;
15
+ asHSV(): HSV;
16
+ asRGB(): RGB;
17
+ toRGB(): RGB;
18
+ static parse(input: string | Color): RGB;
19
+ gamma(value: number): RGB;
20
+ invert(): RGB;
21
+ contrast(value: number): RGB;
22
+ brightness(value: number): RGB;
23
+ tint(value: number, tintColor: Color): RGB;
24
+ lighten(ratio: number): RGB;
25
+ darken(ratio: number): RGB;
26
+ fade(value: number): RGB;
27
+ }
28
+
29
+ declare class HSV extends Color {
30
+ readonly h: number;
31
+ readonly s: number;
32
+ readonly v: number;
33
+ readonly a: number;
34
+ constructor(h: number, s: number, v: number, a?: number);
35
+ asArray(): [number, number, number, number];
36
+ round(): HSV;
37
+ asString(): string;
38
+ clone(): HSV;
39
+ asHSL(): HSL;
40
+ asHSV(): HSV;
41
+ toHSV(): HSV;
42
+ asRGB(): RGB;
43
+ fade(value: number): HSV;
44
+ setHue(value: number): HSV;
45
+ }
46
+
47
+ declare class HSL extends Color {
48
+ readonly h: number;
49
+ readonly s: number;
50
+ readonly l: number;
51
+ readonly a: number;
52
+ constructor(h: number, s: number, l: number, a?: number);
53
+ asArray(): [number, number, number, number];
54
+ round(): HSL;
55
+ clone(): HSL;
56
+ asString(): string;
57
+ asHSL(): HSL;
58
+ toHSL(): HSL;
59
+ asHSV(): HSV;
60
+ asRGB(): RGB;
61
+ static parse(input: string | Color): HSL;
62
+ invertLuminosity(): HSL;
63
+ rotateHue(offset: number): HSL;
64
+ saturate(ratio: number): HSL;
65
+ fade(value: number): HSL;
66
+ }
67
+
68
+ interface RandomColorOptions {
69
+ seed?: string;
70
+ hue?: number | string;
71
+ opacity?: number;
72
+ luminosity?: number | string;
73
+ saturation?: number | string;
74
+ }
75
+
76
+ declare abstract class Color {
77
+ static parse: (input: Color | string) => Color;
78
+ static HSL: typeof HSL;
79
+ static HSV: typeof HSV;
80
+ static RGB: typeof RGB;
81
+ static random: (options?: RandomColorOptions) => HSV;
82
+ abstract clone(): Color;
83
+ asHex(): string;
84
+ abstract asString(): string;
85
+ abstract round(): Color;
86
+ abstract asArray(): number[];
87
+ abstract asHSL(): HSL;
88
+ abstract asHSV(): HSV;
89
+ abstract asRGB(): RGB;
90
+ toHSL(): HSL;
91
+ toHSV(): HSV;
92
+ toRGB(): RGB;
93
+ invertLuminosity(): HSL;
94
+ rotateHue(offset: number): HSL;
95
+ saturate(ratio: number): HSL;
96
+ gamma(value: number): RGB;
97
+ invert(): RGB;
98
+ contrast(value: number): RGB;
99
+ brightness(value: number): RGB;
100
+ lighten(value: number): RGB;
101
+ darken(value: number): RGB;
102
+ tint(value: number, tintColor: Color): RGB;
103
+ setHue(value: number): HSV;
104
+ abstract fade(value: number): Color;
105
+ }
106
+
107
+ interface RecolorOptions {
108
+ invertBrightness?: boolean;
109
+ rotate?: number;
110
+ saturate?: number;
111
+ gamma?: number;
112
+ contrast?: number;
113
+ brightness?: number;
114
+ tint?: number;
115
+ tintColor?: string;
116
+ }
117
+
118
+ /** Represents language suffixes used in map styles. */
119
+ type Language = 'de' | 'en' | null;
120
+ /** Options for configuring a style builder. */
121
+ interface StyleBuilderOptions {
122
+ /**
123
+ * The base URL for loading external resources like tiles, sprites, and fonts.
124
+ * Default: document.location.origin (in the browser), or 'https://tiles.versatiles.org'
125
+ */
126
+ baseUrl?: string;
127
+ /**
128
+ * The URL template for loading font glyphs, formatted with '{fontstack}' and '{range}' placeholders.
129
+ * Default: '/assets/glyphs/{fontstack}/{range}.pbf'
130
+ */
131
+ glyphs?: string;
132
+ /**
133
+ * The URL for loading sprite images and metadata.
134
+ * Default: [{ id: 'basics', url: '/assets/sprites/basics/sprites' }]
135
+ */
136
+ sprite?: SpriteSpecification;
137
+ /**
138
+ * An array of URL templates for loading map tiles, using '{z}', '{x}', and '{y}' placeholders.
139
+ * Default: ['/tiles/osm/{z}/{x}/{y}']
140
+ */
141
+ tiles?: string[];
142
+ /**
143
+ * If set to true, hides all map labels.
144
+ * Default: false
145
+ */
146
+ hideLabels?: boolean;
147
+ /**
148
+ * Set the language ('en', 'de') of all map labels.
149
+ * A null value means that the language of the country in which the label is drawn will be used.
150
+ * Default: null
151
+ */
152
+ language?: Language;
153
+ /**
154
+ * An object specifying overrides for default color values, keyed by the color names.
155
+ */
156
+ colors?: Partial<StyleBuilderColors>;
157
+ /**
158
+ * An object specifying overrides for default font names, keyed by the font names.
159
+ */
160
+ fonts?: Partial<StyleBuilderFonts>;
161
+ /**
162
+ * Options for color adjustments and transformations applied to the entire style.
163
+ */
164
+ recolor?: RecolorOptions;
165
+ }
166
+ /** Records string values for color properties in a style builder. */
167
+ interface StyleBuilderColors {
168
+ agriculture: Color | string;
169
+ boundary: Color | string;
170
+ building: Color | string;
171
+ buildingbg: Color | string;
172
+ burial: Color | string;
173
+ commercial: Color | string;
174
+ construction: Color | string;
175
+ cycle: Color | string;
176
+ danger: Color | string;
177
+ disputed: Color | string;
178
+ education: Color | string;
179
+ foot: Color | string;
180
+ glacier: Color | string;
181
+ grass: Color | string;
182
+ hospital: Color | string;
183
+ industrial: Color | string;
184
+ label: Color | string;
185
+ labelHalo: Color | string;
186
+ land: Color | string;
187
+ leisure: Color | string;
188
+ motorway: Color | string;
189
+ motorwaybg: Color | string;
190
+ park: Color | string;
191
+ parking: Color | string;
192
+ poi: Color | string;
193
+ prison: Color | string;
194
+ rail: Color | string;
195
+ residential: Color | string;
196
+ rock: Color | string;
197
+ sand: Color | string;
198
+ shield: Color | string;
199
+ street: Color | string;
200
+ streetbg: Color | string;
201
+ subway: Color | string;
202
+ symbol: Color | string;
203
+ trunk: Color | string;
204
+ trunkbg: Color | string;
205
+ waste: Color | string;
206
+ water: Color | string;
207
+ wetland: Color | string;
208
+ wood: Color | string;
209
+ }
210
+ type StyleBuilderColorsEnsured = Record<keyof StyleBuilderColors, Color>;
211
+ /** Records string values for font properties in a style builder. */
212
+ type StyleBuilderFonts = {
213
+ regular: string;
214
+ bold: string;
7
215
  };
8
- export type { GuessStyleOptions } from './guess_style/index.js';
9
- export type { RGB, HSL, HSV, RandomColorOptions } from './color/index.js';
10
- export type { TileJSONSpecification, TileJSONSpecificationRaster, TileJSONSpecificationVector } from './types/tilejson.js';
11
- export type { VectorLayer } from './types/index.js';
12
- export type { StyleBuilderOptions, Language, StyleBuilderColors, StyleBuilderColorsEnsured, StyleBuilderFonts } from './style_builder/types.js';
13
- export type { RecolorOptions } from './style_builder/recolor.js';
14
- export { guessStyle } from './guess_style/index.js';
15
- export { Color } from './color/index.js';
216
+
217
+ interface StyleBuilderFunction {
218
+ (options?: StyleBuilderOptions): StyleSpecification;
219
+ getOptions(): StyleBuilderOptions;
220
+ }
221
+ declare const colorful: StyleBuilderFunction;
222
+ declare const eclipse: StyleBuilderFunction;
223
+ declare const graybeard: StyleBuilderFunction;
224
+ declare const neutrino: StyleBuilderFunction;
225
+
226
+ /** Represents the structure of a vector layer in a TileJSON specification. */
227
+ interface VectorLayer {
228
+ id: string;
229
+ fields: Record<string, 'Boolean' | 'Number' | 'String'>;
230
+ description?: string;
231
+ minzoom?: number;
232
+ maxzoom?: number;
233
+ }
234
+
235
+ /** Basic structure for TileJSON specification, applicable to both raster and vector types. */
236
+ interface TileJSONSpecificationRaster {
237
+ tilejson?: '3.0.0';
238
+ tiles: string[];
239
+ attribution?: string;
240
+ bounds?: [number, number, number, number];
241
+ center?: [number, number];
242
+ data?: string[];
243
+ description?: string;
244
+ fillzoom?: number;
245
+ grids?: string[];
246
+ legend?: string;
247
+ maxzoom?: number;
248
+ minzoom?: number;
249
+ name?: string;
250
+ scheme?: 'tms' | 'xyz';
251
+ template?: string;
252
+ version?: string;
253
+ }
254
+ /** Structure for TileJSON specification of vector type, specifying vector-specific properties. */
255
+ interface TileJSONSpecificationVector extends TileJSONSpecificationRaster {
256
+ vector_layers: VectorLayer[];
257
+ }
258
+ /** Represents a TileJSON specification, which can be either raster or vector. */
259
+ type TileJSONSpecification = TileJSONSpecificationRaster | TileJSONSpecificationVector;
260
+
261
+ interface GuessStyleOptions {
262
+ baseUrl?: string;
263
+ glyphs?: string;
264
+ sprite?: SpriteSpecification;
265
+ }
266
+ declare function guessStyle(tileJSON: TileJSONSpecification, options?: GuessStyleOptions): StyleSpecification;
267
+
268
+ declare const styles: {
269
+ colorful: StyleBuilderFunction;
270
+ eclipse: StyleBuilderFunction;
271
+ graybeard: StyleBuilderFunction;
272
+ neutrino: StyleBuilderFunction;
273
+ };
274
+
275
+ export { Color, type GuessStyleOptions, HSL, HSV, type Language, RGB, type RandomColorOptions, type RecolorOptions, type StyleBuilderColors, type StyleBuilderColorsEnsured, type StyleBuilderFonts, type StyleBuilderFunction, type StyleBuilderOptions, type TileJSONSpecification, type TileJSONSpecificationRaster, type TileJSONSpecificationVector, type VectorLayer, colorful, eclipse, graybeard, guessStyle, neutrino, styles };