@versatiles/style 5.8.3 → 5.9.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.
Files changed (56) hide show
  1. package/README.md +38 -32
  2. package/dist/index.d.ts +21 -15
  3. package/dist/index.js +719 -419
  4. package/dist/index.js.map +1 -1
  5. package/package.json +22 -17
  6. package/src/color/abstract.ts +1 -1
  7. package/src/color/hsl.test.ts +11 -18
  8. package/src/color/hsl.ts +11 -23
  9. package/src/color/hsv.test.ts +4 -10
  10. package/src/color/hsv.ts +38 -22
  11. package/src/color/index.test.ts +91 -5
  12. package/src/color/index.ts +4 -2
  13. package/src/color/random.test.ts +55 -1
  14. package/src/color/random.ts +130 -26
  15. package/src/color/rgb.test.ts +60 -38
  16. package/src/color/rgb.ts +34 -56
  17. package/src/color/utils.test.ts +4 -6
  18. package/src/color/utils.ts +2 -4
  19. package/src/guess_style/guess_style.test.ts +49 -43
  20. package/src/guess_style/guess_style.ts +67 -22
  21. package/src/guess_style/index.ts +0 -1
  22. package/src/index.test.ts +35 -8
  23. package/src/index.ts +41 -21
  24. package/src/lib/utils.test.ts +86 -3
  25. package/src/lib/utils.ts +12 -20
  26. package/src/shortbread/index.ts +0 -1
  27. package/src/shortbread/layers.test.ts +15 -1
  28. package/src/shortbread/layers.ts +204 -199
  29. package/src/shortbread/properties.test.ts +3 -4
  30. package/src/shortbread/properties.ts +18 -4
  31. package/src/shortbread/template.test.ts +7 -2
  32. package/src/shortbread/template.ts +7 -14
  33. package/src/style_builder/decorator.test.ts +4 -4
  34. package/src/style_builder/decorator.ts +46 -31
  35. package/src/style_builder/recolor.test.ts +6 -31
  36. package/src/style_builder/recolor.ts +38 -31
  37. package/src/style_builder/style_builder.test.ts +50 -13
  38. package/src/style_builder/style_builder.ts +35 -34
  39. package/src/style_builder/types.ts +44 -2
  40. package/src/styles/LICENSE.md +15 -15
  41. package/src/styles/colorful.test.ts +91 -0
  42. package/src/styles/colorful.ts +229 -122
  43. package/src/styles/eclipse.ts +1 -1
  44. package/src/styles/empty.ts +1 -1
  45. package/src/styles/graybeard.ts +2 -2
  46. package/src/styles/index.ts +2 -3
  47. package/src/styles/neutrino.ts +14 -16
  48. package/src/styles/satellite.test.ts +146 -0
  49. package/src/styles/satellite.ts +106 -0
  50. package/src/styles/shadow.ts +2 -2
  51. package/src/types/index.ts +0 -1
  52. package/src/types/maplibre.ts +17 -3
  53. package/src/types/tilejson.test.ts +17 -14
  54. package/src/types/tilejson.ts +59 -37
  55. package/src/types/vector_layer.test.ts +5 -2
  56. package/src/types/vector_layer.ts +8 -10
package/README.md CHANGED
@@ -18,6 +18,7 @@
18
18
  | **eclipse** | <img width="384" src="https://versatiles.org/versatiles-style/eclipse.png" alt="eclipse style" /> |
19
19
  | **neutrino** | <img width="384" src="https://versatiles.org/versatiles-style/neutrino.png" alt="neutrino style" /> |
20
20
  | **shadow** | <img width="384" src="https://versatiles.org/versatiles-style/shadow.png" alt="shadow style" /> |
21
+ | **satellite** | <img width="384" src="https://versatiles.org/versatiles-style/satellite.png" alt="satellite style" /> |
21
22
 
22
23
  ---
23
24
 
@@ -51,16 +52,16 @@ Integrate it into your HTML application:
51
52
  <script src="maplibre-gl.js"></script>
52
53
  <script src="versatiles-style.js"></script>
53
54
  <script>
54
- const style = VersaTilesStyle.graybeard({
55
- language: "de",
56
- colors: { label: "#222" },
57
- recolor: { gamma: 0.5 },
58
- });
59
-
60
- const map = new maplibregl.Map({
61
- container: "map",
62
- style,
63
- });
55
+ const style = VersaTilesStyle.graybeard({
56
+ language: 'de',
57
+ colors: { label: '#222' },
58
+ recolor: { gamma: 0.5 },
59
+ });
60
+
61
+ const map = new maplibregl.Map({
62
+ container: 'map',
63
+ style,
64
+ });
64
65
  </script>
65
66
  ```
66
67
 
@@ -75,13 +76,13 @@ npm install @versatiles/style
75
76
  Generate styles programmatically:
76
77
 
77
78
  ```javascript
78
- import { colorful } from "@versatiles/style";
79
- import { writeFileSync } from "node:fs";
79
+ import { colorful } from '@versatiles/style';
80
+ import { writeFileSync } from 'node:fs';
80
81
 
81
82
  const style = colorful({
82
- language: "en",
83
+ language: 'en',
83
84
  });
84
- writeFileSync("style.json", JSON.stringify(style));
85
+ writeFileSync('style.json', JSON.stringify(style));
85
86
  ```
86
87
 
87
88
  ---
@@ -95,8 +96,10 @@ The library offers the following style generation methods:
95
96
  - `graybeard(options)` - [Documentation](https://versatiles.org/versatiles-style/functions/graybeard.html)
96
97
  - `neutrino(options)` - [Documentation](https://versatiles.org/versatiles-style/functions/neutrino.html)
97
98
  - `shadow(options)` - [Documentation](https://versatiles.org/versatiles-style/functions/shadow.html)
99
+ - `satellite(options)` - [Documentation](https://versatiles.org/versatiles-style/functions/satellite.html)
98
100
 
99
101
  **`options`**: An optional object to customize the styles. [Learn more](https://versatiles.org/versatiles-style/interfaces/StyleBuilderOptions.html)
102
+ `satellite` uses a different options type: [SatelliteStyleOptions](https://versatiles.org/versatiles-style/interfaces/SatelliteStyleOptions.html)
100
103
 
101
104
  ### Guess Style Method
102
105
 
@@ -159,7 +162,7 @@ subgraph 1["color"]
159
162
  end
160
163
  subgraph 9["guess_style"]
161
164
  A["guess_style.ts"]
162
- Z["index.ts"]
165
+ 10["index.ts"]
163
166
  end
164
167
  subgraph B["lib"]
165
168
  C["utils.ts"]
@@ -171,7 +174,8 @@ Q["eclipse.ts"]
171
174
  R["empty.ts"]
172
175
  S["graybeard.ts"]
173
176
  T["neutrino.ts"]
174
- U["shadow.ts"]
177
+ U["satellite.ts"]
178
+ V["shadow.ts"]
175
179
  end
176
180
  subgraph G["style_builder"]
177
181
  H["style_builder.ts"]
@@ -185,13 +189,13 @@ K["layers.ts"]
185
189
  L["template.ts"]
186
190
  N["properties.ts"]
187
191
  end
188
- subgraph V["types"]
189
- W["index.ts"]
190
- X["tilejson.ts"]
191
- Y["vector_layer.ts"]
192
- 11["maplibre.ts"]
192
+ subgraph W["types"]
193
+ X["index.ts"]
194
+ Y["tilejson.ts"]
195
+ Z["vector_layer.ts"]
196
+ 12["maplibre.ts"]
193
197
  end
194
- 10["index.ts"]
198
+ 11["index.ts"]
195
199
  end
196
200
  3-->2
197
201
  3-->4
@@ -215,8 +219,8 @@ end
215
219
  A-->5
216
220
  A-->C
217
221
  A-->E
218
- A-->W
219
222
  A-->X
223
+ A-->Y
220
224
  C-->8
221
225
  E-->F
222
226
  E-->Q
@@ -224,6 +228,7 @@ E-->R
224
228
  E-->S
225
229
  E-->T
226
230
  E-->U
231
+ E-->V
227
232
  F-->H
228
233
  H-->8
229
234
  H-->C
@@ -241,15 +246,16 @@ Q-->F
241
246
  R-->F
242
247
  S-->F
243
248
  T-->F
244
- U-->F
245
- W-->X
246
- W-->Y
247
- Z-->A
248
- 10-->8
249
- 10-->Z
250
- 10-->E
251
-
252
- class 0,1,9,B,D,G,I,V subgraphs;
249
+ U-->S
250
+ V-->F
251
+ X-->Y
252
+ X-->Z
253
+ 10-->A
254
+ 11-->8
255
+ 11-->10
256
+ 11-->E
257
+
258
+ class 0,1,9,B,D,G,I,W subgraphs;
253
259
  classDef subgraphs fill-opacity:0.1, fill:#888, color:#888, stroke:#888;
254
260
  ```
255
261
 
package/dist/index.d.ts CHANGED
@@ -88,12 +88,6 @@ declare class RGB extends Color {
88
88
  * @returns The current RGB instance.
89
89
  */
90
90
  asRGB(): RGB;
91
- /**
92
- * Returns the RGB color.
93
- *
94
- * @returns The current RGB instance.
95
- */
96
- toRGB(): RGB;
97
91
  /**
98
92
  * Parses a string or Color instance into an RGB color.
99
93
  *
@@ -306,11 +300,6 @@ declare class HSL extends Color {
306
300
  * @returns The current HSL color.
307
301
  */
308
302
  asHSL(): HSL;
309
- /**
310
- * Returns the current HSL color.
311
- * @returns The current HSL color.
312
- */
313
- toHSL(): HSL;
314
303
  /**
315
304
  * Converts the HSL color to an HSV color.
316
305
  * @returns A new HSV color representing the same color.
@@ -548,7 +537,7 @@ interface RecolorOptions {
548
537
  /**
549
538
  * If true, inverts all colors' brightness.
550
539
  * See also {@link HSL.invertLuminosity}
551
- */
540
+ */
552
541
  invertBrightness?: boolean;
553
542
  /**
554
543
  * Rotate the hue of all colors in degrees (0-360).
@@ -667,7 +656,8 @@ interface StyleBuilderOptions {
667
656
  */
668
657
  recolor?: RecolorOptions;
669
658
  }
670
- type StyleBuilderColorKey = 'agriculture' | 'boundary' | 'building' | 'buildingbg' | 'burial' | 'commercial' | 'construction' | 'cycle' | 'danger' | 'disputed' | 'education' | 'foot' | 'glacier' | 'grass' | 'hospital' | 'industrial' | 'label' | 'labelHalo' | 'land' | 'leisure' | 'motorway' | 'motorwaybg' | 'park' | 'parking' | 'poi' | 'prison' | 'rail' | 'residential' | 'rock' | 'sand' | 'shield' | 'street' | 'streetbg' | 'subway' | 'symbol' | 'trunk' | 'trunkbg' | 'waste' | 'water' | 'wetland' | 'wood';
659
+ declare const styleBuilderColorKeys: readonly ["agriculture", "boundary", "building", "buildingbg", "burial", "commercial", "construction", "cycle", "danger", "disputed", "education", "foot", "glacier", "grass", "hospital", "industrial", "label", "labelHalo", "land", "leisure", "motorway", "motorwaybg", "park", "parking", "poi", "prison", "rail", "residential", "rock", "sand", "shield", "street", "streetbg", "subway", "symbol", "trunk", "trunkbg", "waste", "water", "wetland", "wood"];
660
+ type StyleBuilderColorKey = (typeof styleBuilderColorKeys)[number];
671
661
  /** Records string values for color properties in a style builder. */
672
662
  type StyleBuilderColors<T = Color | string> = Record<StyleBuilderColorKey, T>;
673
663
  /** Records string values for font properties in a style builder. */
@@ -676,6 +666,21 @@ type StyleBuilderFonts = {
676
666
  bold: string;
677
667
  };
678
668
 
669
+ interface SatelliteStyleOptions {
670
+ baseUrl?: string;
671
+ rasterTiles?: string[];
672
+ overlayTiles?: string[];
673
+ overlay?: boolean;
674
+ language?: Language;
675
+ rasterOpacity?: number;
676
+ rasterHueRotate?: number;
677
+ rasterBrightnessMin?: number;
678
+ rasterBrightnessMax?: number;
679
+ rasterSaturation?: number;
680
+ rasterContrast?: number;
681
+ }
682
+ declare function buildSatelliteStyle(options?: SatelliteStyleOptions): StyleSpecification;
683
+
679
684
  interface StyleBuilderFunction {
680
685
  (options?: StyleBuilderOptions): StyleSpecification;
681
686
  getOptions(): StyleBuilderOptions;
@@ -757,7 +762,8 @@ declare const styles: {
757
762
  graybeard: StyleBuilderFunction;
758
763
  shadow: StyleBuilderFunction;
759
764
  neutrino: StyleBuilderFunction;
765
+ satellite: typeof buildSatelliteStyle;
760
766
  };
761
767
 
762
- export { Color, HSL, HSV, RGB, colorful, eclipse, graybeard, guessStyle, neutrino, shadow, styles };
763
- export type { GuessStyleOptions, Language, RandomColorOptions, RecolorOptions, StyleBuilderColorKey, StyleBuilderColors, StyleBuilderFonts, StyleBuilderFunction, StyleBuilderOptions, TileJSONSpecification, TileJSONSpecificationRaster, TileJSONSpecificationVector, VectorLayer };
768
+ export { Color, HSL, HSV, RGB, colorful, eclipse, graybeard, guessStyle, neutrino, buildSatelliteStyle as satellite, shadow, styles };
769
+ export type { GuessStyleOptions, Language, RandomColorOptions, RecolorOptions, SatelliteStyleOptions, StyleBuilderColorKey, StyleBuilderColors, StyleBuilderFonts, StyleBuilderFunction, StyleBuilderOptions, TileJSONSpecification, TileJSONSpecificationRaster, TileJSONSpecificationVector, VectorLayer };