@versatiles/style 5.2.6 → 5.2.8
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/dist/index.d.ts +274 -14
- package/dist/index.js +3650 -11
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/color/abstract.ts +83 -0
- package/src/color/hsl.test.ts +182 -0
- package/src/color/hsl.ts +122 -0
- package/src/color/hsv.test.ts +174 -0
- package/src/color/hsv.ts +100 -0
- package/src/color/index.test.ts +119 -0
- package/src/color/index.ts +38 -0
- package/src/color/random.test.ts +35 -0
- package/src/color/random.ts +165 -0
- package/src/color/rgb.test.ts +227 -0
- package/src/color/rgb.ts +248 -0
- package/src/color/utils.test.ts +86 -0
- package/src/color/utils.ts +13 -0
- package/src/guess_style/guess_style.test.ts +134 -0
- package/src/guess_style/guess_style.ts +166 -0
- package/{dist/guess_style/index.d.ts → src/guess_style/index.ts} +1 -0
- package/src/index.test.ts +77 -0
- package/src/index.ts +18 -0
- package/src/lib/utils.test.ts +197 -0
- package/src/lib/utils.ts +134 -0
- package/{dist/shortbread/index.d.ts → src/shortbread/index.ts} +1 -0
- package/src/shortbread/layers.test.ts +36 -0
- package/src/shortbread/layers.ts +564 -0
- package/src/shortbread/properties.test.ts +44 -0
- package/src/shortbread/properties.ts +142 -0
- package/src/shortbread/template.test.ts +43 -0
- package/src/shortbread/template.ts +343 -0
- package/src/style_builder/decorator.test.ts +67 -0
- package/src/style_builder/decorator.ts +135 -0
- package/src/style_builder/recolor.test.ts +306 -0
- package/src/style_builder/recolor.ts +110 -0
- package/src/style_builder/style_builder.test.ts +103 -0
- package/src/style_builder/style_builder.ts +134 -0
- package/src/style_builder/types.ts +141 -0
- package/src/styles/LICENSE.md +41 -0
- package/src/styles/colorful.ts +1041 -0
- package/src/styles/eclipse.ts +11 -0
- package/{dist/styles/empty.d.ts → src/styles/empty.ts} +7 -3
- package/src/styles/graybeard.ts +11 -0
- package/src/styles/index.ts +33 -0
- package/src/styles/neutrino.ts +429 -0
- package/{dist/types/index.d.ts → src/types/index.ts} +1 -0
- package/{dist/types/maplibre.d.ts → src/types/maplibre.ts} +3 -0
- package/src/types/tilejson.test.ts +94 -0
- package/src/types/tilejson.ts +125 -0
- package/src/types/vector_layer.test.ts +64 -0
- package/src/types/vector_layer.ts +69 -0
- package/dist/color/abstract.d.ts +0 -34
- package/dist/color/abstract.js +0 -53
- package/dist/color/abstract.js.map +0 -1
- package/dist/color/hsl.d.ts +0 -23
- package/dist/color/hsl.js +0 -98
- package/dist/color/hsl.js.map +0 -1
- package/dist/color/hsv.d.ts +0 -20
- package/dist/color/hsv.js +0 -100
- package/dist/color/hsv.js.map +0 -1
- package/dist/color/index.d.ts +0 -6
- package/dist/color/index.js +0 -29
- package/dist/color/index.js.map +0 -1
- package/dist/color/random.d.ts +0 -9
- package/dist/color/random.js +0 -134
- package/dist/color/random.js.map +0 -1
- package/dist/color/rgb.d.ts +0 -28
- package/dist/color/rgb.js +0 -195
- package/dist/color/rgb.js.map +0 -1
- package/dist/color/utils.d.ts +0 -3
- package/dist/color/utils.js +0 -10
- package/dist/color/utils.js.map +0 -1
- package/dist/guess_style/guess_style.d.ts +0 -8
- package/dist/guess_style/guess_style.js +0 -147
- package/dist/guess_style/guess_style.js.map +0 -1
- package/dist/guess_style/index.js +0 -2
- package/dist/guess_style/index.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -6
- package/dist/lib/utils.js +0 -126
- package/dist/lib/utils.js.map +0 -1
- package/dist/shortbread/index.js +0 -3
- package/dist/shortbread/index.js.map +0 -1
- package/dist/shortbread/layers.d.ts +0 -5
- package/dist/shortbread/layers.js +0 -521
- package/dist/shortbread/layers.js.map +0 -1
- package/dist/shortbread/properties.d.ts +0 -7
- package/dist/shortbread/properties.js +0 -125
- package/dist/shortbread/properties.js.map +0 -1
- package/dist/shortbread/template.d.ts +0 -4
- package/dist/shortbread/template.js +0 -339
- package/dist/shortbread/template.js.map +0 -1
- package/dist/style_builder/decorator.d.ts +0 -4
- package/dist/style_builder/decorator.js +0 -127
- package/dist/style_builder/decorator.js.map +0 -1
- package/dist/style_builder/recolor.d.ts +0 -22
- package/dist/style_builder/recolor.js +0 -89
- package/dist/style_builder/recolor.js.map +0 -1
- package/dist/style_builder/style_builder.d.ts +0 -15
- package/dist/style_builder/style_builder.js +0 -106
- package/dist/style_builder/style_builder.js.map +0 -1
- package/dist/style_builder/types.d.ts +0 -122
- package/dist/style_builder/types.js +0 -3
- package/dist/style_builder/types.js.map +0 -1
- package/dist/styles/colorful.d.ts +0 -11
- package/dist/styles/colorful.js +0 -956
- package/dist/styles/colorful.js.map +0 -1
- package/dist/styles/eclipse.d.ts +0 -5
- package/dist/styles/eclipse.js +0 -9
- package/dist/styles/eclipse.js.map +0 -1
- package/dist/styles/empty.js +0 -8
- package/dist/styles/empty.js.map +0 -1
- package/dist/styles/graybeard.d.ts +0 -5
- package/dist/styles/graybeard.js +0 -9
- package/dist/styles/graybeard.js.map +0 -1
- package/dist/styles/index.d.ts +0 -11
- package/dist/styles/index.js +0 -20
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/neutrino.d.ts +0 -11
- package/dist/styles/neutrino.js +0 -401
- package/dist/styles/neutrino.js.map +0 -1
- package/dist/types/index.js +0 -3
- package/dist/types/index.js.map +0 -1
- package/dist/types/maplibre.js +0 -2
- package/dist/types/maplibre.js.map +0 -1
- package/dist/types/tilejson.d.ts +0 -32
- package/dist/types/tilejson.js +0 -87
- package/dist/types/tilejson.js.map +0 -1
- package/dist/types/vector_layer.d.ts +0 -14
- package/dist/types/vector_layer.js +0 -51
- package/dist/types/vector_layer.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,275 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 };
|