@versatiles/style 5.2.6 → 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 (130) hide show
  1. package/dist/index.d.ts +274 -14
  2. package/dist/index.js +3650 -11
  3. package/dist/index.js.map +1 -1
  4. package/package.json +8 -8
  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/abstract.js.map +0 -1
  55. package/dist/color/hsl.d.ts +0 -23
  56. package/dist/color/hsl.js +0 -98
  57. package/dist/color/hsl.js.map +0 -1
  58. package/dist/color/hsv.d.ts +0 -20
  59. package/dist/color/hsv.js +0 -100
  60. package/dist/color/hsv.js.map +0 -1
  61. package/dist/color/index.d.ts +0 -6
  62. package/dist/color/index.js +0 -29
  63. package/dist/color/index.js.map +0 -1
  64. package/dist/color/random.d.ts +0 -9
  65. package/dist/color/random.js +0 -134
  66. package/dist/color/random.js.map +0 -1
  67. package/dist/color/rgb.d.ts +0 -28
  68. package/dist/color/rgb.js +0 -195
  69. package/dist/color/rgb.js.map +0 -1
  70. package/dist/color/utils.d.ts +0 -3
  71. package/dist/color/utils.js +0 -10
  72. package/dist/color/utils.js.map +0 -1
  73. package/dist/guess_style/guess_style.d.ts +0 -8
  74. package/dist/guess_style/guess_style.js +0 -147
  75. package/dist/guess_style/guess_style.js.map +0 -1
  76. package/dist/guess_style/index.js +0 -2
  77. package/dist/guess_style/index.js.map +0 -1
  78. package/dist/lib/utils.d.ts +0 -6
  79. package/dist/lib/utils.js +0 -126
  80. package/dist/lib/utils.js.map +0 -1
  81. package/dist/shortbread/index.js +0 -3
  82. package/dist/shortbread/index.js.map +0 -1
  83. package/dist/shortbread/layers.d.ts +0 -5
  84. package/dist/shortbread/layers.js +0 -521
  85. package/dist/shortbread/layers.js.map +0 -1
  86. package/dist/shortbread/properties.d.ts +0 -7
  87. package/dist/shortbread/properties.js +0 -125
  88. package/dist/shortbread/properties.js.map +0 -1
  89. package/dist/shortbread/template.d.ts +0 -4
  90. package/dist/shortbread/template.js +0 -339
  91. package/dist/shortbread/template.js.map +0 -1
  92. package/dist/style_builder/decorator.d.ts +0 -4
  93. package/dist/style_builder/decorator.js +0 -127
  94. package/dist/style_builder/decorator.js.map +0 -1
  95. package/dist/style_builder/recolor.d.ts +0 -22
  96. package/dist/style_builder/recolor.js +0 -89
  97. package/dist/style_builder/recolor.js.map +0 -1
  98. package/dist/style_builder/style_builder.d.ts +0 -15
  99. package/dist/style_builder/style_builder.js +0 -106
  100. package/dist/style_builder/style_builder.js.map +0 -1
  101. package/dist/style_builder/types.d.ts +0 -122
  102. package/dist/style_builder/types.js +0 -3
  103. package/dist/style_builder/types.js.map +0 -1
  104. package/dist/styles/colorful.d.ts +0 -11
  105. package/dist/styles/colorful.js +0 -956
  106. package/dist/styles/colorful.js.map +0 -1
  107. package/dist/styles/eclipse.d.ts +0 -5
  108. package/dist/styles/eclipse.js +0 -9
  109. package/dist/styles/eclipse.js.map +0 -1
  110. package/dist/styles/empty.js +0 -8
  111. package/dist/styles/empty.js.map +0 -1
  112. package/dist/styles/graybeard.d.ts +0 -5
  113. package/dist/styles/graybeard.js +0 -9
  114. package/dist/styles/graybeard.js.map +0 -1
  115. package/dist/styles/index.d.ts +0 -11
  116. package/dist/styles/index.js +0 -20
  117. package/dist/styles/index.js.map +0 -1
  118. package/dist/styles/neutrino.d.ts +0 -11
  119. package/dist/styles/neutrino.js +0 -401
  120. package/dist/styles/neutrino.js.map +0 -1
  121. package/dist/types/index.js +0 -3
  122. package/dist/types/index.js.map +0 -1
  123. package/dist/types/maplibre.js +0 -2
  124. package/dist/types/maplibre.js.map +0 -1
  125. package/dist/types/tilejson.d.ts +0 -32
  126. package/dist/types/tilejson.js +0 -87
  127. package/dist/types/tilejson.js.map +0 -1
  128. package/dist/types/vector_layer.d.ts +0 -14
  129. package/dist/types/vector_layer.js +0 -51
  130. package/dist/types/vector_layer.js.map +0 -1
@@ -1,127 +0,0 @@
1
- import { Color } from '../color/index.js';
2
- import expandBraces from 'brace-expansion';
3
- import maplibreProperties from '../shortbread/properties.js';
4
- import { deepMerge } from '../lib/utils.js';
5
- export function decorate(layers, rules, recolor) {
6
- const layerIds = layers.map(l => l.id);
7
- const layerIdSet = new Set(layerIds);
8
- // Initialize a new map to hold final styles for layers
9
- const layerStyles = new Map();
10
- // Iterate through the generated layer style rules
11
- Object.entries(rules).forEach(([idDef, layerStyle]) => {
12
- if (layerStyle == null)
13
- return;
14
- // Expand any braces in IDs and filter them through a RegExp if necessary
15
- const ids = expandBraces(idDef).flatMap(id => {
16
- if (!id.includes('*'))
17
- return id;
18
- const regExpString = id.replace(/[^a-z_:-]/g, c => {
19
- if (c === '*')
20
- return '[a-z_-]*';
21
- throw new Error('unknown char to process. Do not know how to make a RegExp from: ' + JSON.stringify(c));
22
- });
23
- const regExp = new RegExp(`^${regExpString}$`, 'i');
24
- return layerIds.filter(layerId => regExp.test(layerId));
25
- });
26
- ids.forEach(id => {
27
- if (!layerIdSet.has(id))
28
- return;
29
- layerStyles.set(id, deepMerge(layerStyles.get(id) ?? {}, layerStyle));
30
- });
31
- });
32
- // Deep clone the original layers and apply styles
33
- return layers.flatMap(layer => {
34
- // Get the id and style of the layer
35
- const layerStyle = layerStyles.get(layer.id);
36
- // Don't export layers that have no style
37
- if (!layerStyle)
38
- return [];
39
- processStyling(layer, layerStyle);
40
- return [layer];
41
- });
42
- // Function to process each style attribute for the layer
43
- function processStyling(layer, styleRule) {
44
- for (const [ruleKeyCamelCase, ruleValue] of Object.entries(styleRule)) {
45
- if (ruleValue == null)
46
- continue;
47
- // CamelCase to not-camel-case
48
- const ruleKey = ruleKeyCamelCase.replace(/[A-Z]/g, c => '-' + c.toLowerCase());
49
- const propertyDefs = maplibreProperties.get(layer.type + '/' + ruleKey);
50
- if (!propertyDefs)
51
- continue;
52
- propertyDefs.forEach(propertyDef => {
53
- const { key } = propertyDef;
54
- let value = ruleValue;
55
- switch (propertyDef.valueType) {
56
- case 'color':
57
- value = processExpression(value, processColor);
58
- break;
59
- case 'fonts':
60
- value = processExpression(value, processFont);
61
- break;
62
- case 'resolvedImage':
63
- case 'formatted':
64
- case 'array':
65
- case 'boolean':
66
- case 'enum':
67
- case 'number':
68
- value = processExpression(value);
69
- break;
70
- default: throw new Error(`unknown propertyDef.valueType "${propertyDef.valueType}" for key "${key}"`);
71
- }
72
- switch (propertyDef.parent) {
73
- case 'layer':
74
- // @ts-expect-error: too complex to handle
75
- layer[key] = value;
76
- break;
77
- case 'layout':
78
- if (!layer.layout)
79
- layer.layout = {};
80
- // @ts-expect-error: too complex to handle
81
- layer.layout[key] = value;
82
- break;
83
- case 'paint':
84
- if (!layer.paint)
85
- layer.paint = {};
86
- // @ts-expect-error: too complex to handle
87
- layer.paint[key] = value;
88
- break;
89
- default:
90
- throw new Error(`unknown parent "${propertyDef.parent}" for key "${key}"`);
91
- }
92
- });
93
- }
94
- function processColor(value) {
95
- if (typeof value === 'string')
96
- value = Color.parse(value);
97
- if (value instanceof Color) {
98
- const color = recolor.do(value);
99
- return color.asString();
100
- }
101
- throw new Error(`unknown color type "${typeof value}"`);
102
- }
103
- function processFont(value) {
104
- if (typeof value === 'string')
105
- return [value];
106
- throw new Error(`unknown font type "${typeof value}"`);
107
- }
108
- function processExpression(value, cbValue) {
109
- if (typeof value === 'object') {
110
- if (value instanceof Color)
111
- return processColor(value);
112
- if (!Array.isArray(value)) {
113
- return processZoomStops(value, cbValue);
114
- }
115
- }
116
- return cbValue ? cbValue(value) : value;
117
- }
118
- function processZoomStops(obj, cbValue) {
119
- return {
120
- stops: Object.entries(obj)
121
- .map(([z, v]) => [parseInt(z, 10), cbValue ? cbValue(v) : v])
122
- .sort((a, b) => a[0] - b[0]),
123
- };
124
- }
125
-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gBAAgB,CAAC,GAAmC,EAAE,OAAmD;YACjH,OAAO;gBACN,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;qBACxB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA6B,CAAC;qBACxF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aAC7B,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -1,22 +0,0 @@
1
- import { Color } from '../color/index.js';
2
- export interface RecolorOptions {
3
- invertBrightness?: boolean;
4
- rotate?: number;
5
- saturate?: number;
6
- gamma?: number;
7
- contrast?: number;
8
- brightness?: number;
9
- tint?: number;
10
- tintColor?: string;
11
- }
12
- export declare function getDefaultRecolorFlags(): RecolorOptions;
13
- export declare function recolorObject(colors: Record<string, Color>, opt?: RecolorOptions): void;
14
- export declare function recolorArray(colors: Color[], opt?: RecolorOptions): void;
15
- export declare class CachedRecolor {
16
- private readonly skip;
17
- private readonly opt?;
18
- private readonly cache;
19
- constructor(opt?: RecolorOptions);
20
- do(color: Color): Color;
21
- }
22
- export declare function recolor(color: Color, opt?: RecolorOptions): Color;
@@ -1,89 +0,0 @@
1
- import { Color } from '../color/index.js';
2
- export function getDefaultRecolorFlags() {
3
- return {
4
- invertBrightness: false,
5
- rotate: 0,
6
- saturate: 0,
7
- gamma: 1,
8
- contrast: 1,
9
- brightness: 0,
10
- tint: 0,
11
- tintColor: '#FF0000',
12
- };
13
- }
14
- function isValidRecolorOptions(opt) {
15
- if (!opt)
16
- return false;
17
- if ((opt.invertBrightness != null) && opt.invertBrightness)
18
- return true;
19
- if ((opt.rotate != null) && (opt.rotate !== 0))
20
- return true;
21
- if ((opt.saturate != null) && (opt.saturate !== 0))
22
- return true;
23
- if ((opt.gamma != null) && (opt.gamma !== 1))
24
- return true;
25
- if ((opt.contrast != null) && (opt.contrast !== 1))
26
- return true;
27
- if ((opt.brightness != null) && (opt.brightness !== 0))
28
- return true;
29
- if ((opt.tint != null) && (opt.tint !== 0))
30
- return true;
31
- if ((opt.tintColor != null) && (opt.tintColor !== '#FF0000'))
32
- return true;
33
- return false;
34
- }
35
- export function recolorObject(colors, opt) {
36
- if (!isValidRecolorOptions(opt))
37
- return;
38
- for (const [k, c] of Object.entries(colors)) {
39
- colors[k] = recolor(c, opt);
40
- }
41
- }
42
- export function recolorArray(colors, opt) {
43
- if (!isValidRecolorOptions(opt))
44
- return;
45
- for (let i = 0; i < colors.length; i++) {
46
- colors[i] = recolor(colors[i], opt);
47
- }
48
- }
49
- export class CachedRecolor {
50
- skip;
51
- opt;
52
- cache;
53
- constructor(opt) {
54
- this.skip = !isValidRecolorOptions(opt);
55
- this.cache = new Map();
56
- this.opt = opt;
57
- }
58
- do(color) {
59
- if (this.skip)
60
- return color;
61
- const key = color.asHex();
62
- const result = this.cache.get(key);
63
- if (result)
64
- return result;
65
- color = recolor(color, this.opt);
66
- this.cache.set(key, color);
67
- return color;
68
- }
69
- }
70
- export function recolor(color, opt) {
71
- if (!isValidRecolorOptions(opt))
72
- return color;
73
- if (opt.invertBrightness ?? false)
74
- color = color.invertLuminosity();
75
- if ((opt.rotate !== undefined) && (opt.rotate !== 0))
76
- color = color.rotateHue(opt.rotate);
77
- if ((opt.saturate !== undefined) && (opt.saturate !== 0))
78
- color = color.saturate(opt.saturate);
79
- if ((opt.gamma !== undefined) && (opt.gamma !== 1))
80
- color = color.gamma(opt.gamma);
81
- if ((opt.contrast !== undefined) && (opt.contrast !== 1))
82
- color = color.contrast(opt.contrast);
83
- if ((opt.brightness !== undefined) && (opt.brightness !== 0))
84
- color = color.brightness(opt.brightness);
85
- if ((opt.tint !== undefined) && (opt.tintColor !== undefined) && (opt.tint !== 0))
86
- color = color.tint(opt.tint, Color.parse(opt.tintColor));
87
- return color;
88
- }
89
- //# sourceMappingURL=recolor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recolor.js","sourceRoot":"","sources":["../../src/style_builder/recolor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AA4B1C,MAAM,UAAU,sBAAsB;IACrC,OAAO;QACN,gBAAgB,EAAE,KAAK;QACvB,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,CAAC;QACR,QAAQ,EAAE,CAAC;QACX,UAAU,EAAE,CAAC;QACb,IAAI,EAAE,CAAC;QACP,SAAS,EAAE,SAAS;KACpB,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAoB;IAClD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,gBAAgB;QAAE,OAAO,IAAI,CAAC;IACxE,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5D,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChE,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1D,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChE,IAAI,CAAC,GAA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AAG,CAAC,KAAK,CAAC,CAAC;IACnF,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC;QAAE,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/F,IAAI,CAAC,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,CAAC;QAAE,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvG,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC;QAAE,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5I,OAAO,KAAK,CAAC;AACd,CAAC"}
@@ -1,15 +0,0 @@
1
- import { Color } from '../color/index.js';
2
- import type { StyleSpecification } from '../types/maplibre.js';
3
- import type { StyleBuilderColors, StyleBuilderColorsEnsured, StyleBuilderFonts, StyleBuilderOptions } from './types.js';
4
- import type { StyleRules, StyleRulesOptions } from './types.js';
5
- export declare abstract class StyleBuilder {
6
- #private;
7
- abstract readonly name: string;
8
- abstract readonly defaultColors: StyleBuilderColors;
9
- abstract readonly defaultFonts: StyleBuilderFonts;
10
- build(options?: StyleBuilderOptions): StyleSpecification;
11
- getColors(colors: StyleBuilderColors): StyleBuilderColorsEnsured;
12
- getDefaultOptions(): StyleBuilderOptions;
13
- protected transformDefaultColors(callback: (color: Color) => Color): void;
14
- protected abstract getStyleRules(options: StyleRulesOptions): StyleRules;
15
- }
@@ -1,106 +0,0 @@
1
- import { Color } from '../color/index.js';
2
- import { getShortbreadTemplate, getShortbreadLayers } from '../shortbread/index.js';
3
- import { decorate } from './decorator.js';
4
- import { CachedRecolor, getDefaultRecolorFlags } from './recolor.js';
5
- import { basename, deepClone, resolveUrl } from '../lib/utils.js';
6
- // StyleBuilder class definition
7
- export class StyleBuilder {
8
- #sourceName = 'versatiles-shortbread';
9
- build(options) {
10
- options ??= {};
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' }];
14
- const tiles = options.tiles ?? ['/tiles/osm/{z}/{x}/{y}'];
15
- const hideLabels = options.hideLabels ?? false;
16
- const language = options.language ?? null;
17
- const recolorOptions = options.recolor ?? getDefaultRecolorFlags();
18
- const colors = this.getColors(this.defaultColors);
19
- if (options.colors) {
20
- let key;
21
- for (key in options.colors) {
22
- const value = options.colors[key];
23
- if (value != null)
24
- colors[key] = Color.parse(value);
25
- }
26
- }
27
- const fonts = deepClone(this.defaultFonts);
28
- if (options.fonts) {
29
- let key;
30
- for (key in options.fonts) {
31
- const fontName = options.fonts[key];
32
- if (fontName != null)
33
- fonts[key] = fontName;
34
- }
35
- }
36
- // get empty shortbread style
37
- const style = getShortbreadTemplate();
38
- const styleRuleOptions = {
39
- colors,
40
- fonts,
41
- language,
42
- };
43
- // get layer style rules from child class
44
- const layerStyleRules = this.getStyleRules(styleRuleOptions);
45
- // get shortbread layers
46
- const layerDefinitions = getShortbreadLayers({ language });
47
- let layers = layerDefinitions.map(layer => {
48
- switch (layer.type) {
49
- case 'background':
50
- return layer;
51
- case 'fill':
52
- case 'line':
53
- case 'symbol':
54
- return {
55
- source: this.#sourceName,
56
- ...layer,
57
- };
58
- }
59
- throw Error('unknown layer type');
60
- });
61
- // apply layer rules
62
- layers = decorate(layers, layerStyleRules, new CachedRecolor(recolorOptions));
63
- // hide labels, if wanted
64
- if (hideLabels)
65
- layers = layers.filter(l => l.type !== 'symbol');
66
- style.layers = layers;
67
- style.name = 'versatiles-' + this.name.toLowerCase();
68
- style.glyphs = resolveUrl(baseUrl, glyphs);
69
- if (typeof sprite == 'string') {
70
- style.sprite = [{ id: basename(sprite), url: resolveUrl(baseUrl, sprite) }];
71
- }
72
- else {
73
- style.sprite = sprite.map(({ id, url }) => ({ id, url: resolveUrl(baseUrl, url) }));
74
- }
75
- const source = style.sources[this.#sourceName];
76
- if ('tiles' in source)
77
- source.tiles = tiles.map(url => resolveUrl(baseUrl, url));
78
- return style;
79
- }
80
- getColors(colors) {
81
- const entriesString = Object.entries(colors);
82
- const result = Object.fromEntries(entriesString.map(([key, value]) => [key, Color.parse(value)]));
83
- return result;
84
- }
85
- getDefaultOptions() {
86
- return {
87
- baseUrl: '',
88
- glyphs: '',
89
- sprite: '',
90
- tiles: [],
91
- hideLabels: false,
92
- language: undefined,
93
- colors: deepClone(this.defaultColors),
94
- fonts: deepClone(this.defaultFonts),
95
- recolor: getDefaultRecolorFlags(),
96
- };
97
- }
98
- transformDefaultColors(callback) {
99
- const colors = this.getColors(this.defaultColors);
100
- let key;
101
- for (key in colors) {
102
- this.defaultColors[key] = callback(colors[key]);
103
- }
104
- }
105
- }
106
- //# sourceMappingURL=style_builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style_builder.js","sourceRoot":"","sources":["../../src/style_builder/style_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQlE,gCAAgC;AAChC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AAE;YACX,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;YACV,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,SAAS;YACnB,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;YACrC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;YACnC,OAAO,EAAE,sBAAsB,EAAE;SACjC,CAAC;IACH,CAAC;IAES,sBAAsB,CAAC,QAAiC;QACjE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClD,IAAI,GAAoC,CAAC;QACzC,KAAK,GAAG,IAAI,MAAM,EAAE,CAAC;YACpB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,CAAC;IACF,CAAC;CAGD"}
@@ -1,122 +0,0 @@
1
- import type { Color } from '../color/index.js';
2
- import type { RecolorOptions } from './recolor.js';
3
- import { SpriteSpecification } from '@maplibre/maplibre-gl-style-spec';
4
- /** Represents language suffixes used in map styles. */
5
- export type Language = 'de' | 'en' | null;
6
- /** Options for configuring a style builder. */
7
- export interface StyleBuilderOptions {
8
- /**
9
- * The base URL for loading external resources like tiles, sprites, and fonts.
10
- * Default: document.location.origin (in the browser), or 'https://tiles.versatiles.org'
11
- */
12
- baseUrl?: string;
13
- /**
14
- * The URL template for loading font glyphs, formatted with '{fontstack}' and '{range}' placeholders.
15
- * Default: '/assets/glyphs/{fontstack}/{range}.pbf'
16
- */
17
- glyphs?: string;
18
- /**
19
- * The URL for loading sprite images and metadata.
20
- * Default: [{ id: 'basics', url: '/assets/sprites/basics/sprites' }]
21
- */
22
- sprite?: SpriteSpecification;
23
- /**
24
- * An array of URL templates for loading map tiles, using '{z}', '{x}', and '{y}' placeholders.
25
- * Default: ['/tiles/osm/{z}/{x}/{y}']
26
- */
27
- tiles?: string[];
28
- /**
29
- * If set to true, hides all map labels.
30
- * Default: false
31
- */
32
- hideLabels?: boolean;
33
- /**
34
- * Set the language ('en', 'de') of all map labels.
35
- * A null value means that the language of the country in which the label is drawn will be used.
36
- * Default: null
37
- */
38
- language?: Language;
39
- /**
40
- * An object specifying overrides for default color values, keyed by the color names.
41
- */
42
- colors?: Partial<StyleBuilderColors>;
43
- /**
44
- * An object specifying overrides for default font names, keyed by the font names.
45
- */
46
- fonts?: Partial<StyleBuilderFonts>;
47
- /**
48
- * Options for color adjustments and transformations applied to the entire style.
49
- */
50
- recolor?: RecolorOptions;
51
- }
52
- /** Records string values for color properties in a style builder. */
53
- export interface StyleBuilderColors {
54
- agriculture: Color | string;
55
- boundary: Color | string;
56
- building: Color | string;
57
- buildingbg: Color | string;
58
- burial: Color | string;
59
- commercial: Color | string;
60
- construction: Color | string;
61
- cycle: Color | string;
62
- danger: Color | string;
63
- disputed: Color | string;
64
- education: Color | string;
65
- foot: Color | string;
66
- glacier: Color | string;
67
- grass: Color | string;
68
- hospital: Color | string;
69
- industrial: Color | string;
70
- label: Color | string;
71
- labelHalo: Color | string;
72
- land: Color | string;
73
- leisure: Color | string;
74
- motorway: Color | string;
75
- motorwaybg: Color | string;
76
- park: Color | string;
77
- parking: Color | string;
78
- poi: Color | string;
79
- prison: Color | string;
80
- rail: Color | string;
81
- residential: Color | string;
82
- rock: Color | string;
83
- sand: Color | string;
84
- shield: Color | string;
85
- street: Color | string;
86
- streetbg: Color | string;
87
- subway: Color | string;
88
- symbol: Color | string;
89
- trunk: Color | string;
90
- trunkbg: Color | string;
91
- waste: Color | string;
92
- water: Color | string;
93
- wetland: Color | string;
94
- wood: Color | string;
95
- }
96
- export type StyleBuilderColorsEnsured = Record<keyof StyleBuilderColors, Color>;
97
- /** Records string values for font properties in a style builder. */
98
- export type StyleBuilderFonts = {
99
- regular: string;
100
- bold: string;
101
- };
102
- /** Defines options for style rules in a style builder. */
103
- export interface StyleRulesOptions {
104
- /**
105
- * The set of colors used in the style builder.
106
- */
107
- colors: StyleBuilderColorsEnsured;
108
- /**
109
- * The set of fonts used in the style builder.
110
- */
111
- fonts: StyleBuilderFonts;
112
- /**
113
- * The language used for map labels.
114
- */
115
- language: Language;
116
- }
117
- /** Defines the value type for a style rule. */
118
- export type StyleRuleValue = boolean | number | object | string;
119
- /** Defines the structure of a style rule, which is a record of properties to style values. */
120
- export type StyleRule = Record<string, StyleRuleValue | undefined>;
121
- /** Defines the structure of style rules, which is a record of selectors to style rules. */
122
- export type StyleRules = Record<string, StyleRule | undefined>;
@@ -1,3 +0,0 @@
1
- ;
2
- export {};
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/style_builder/types.ts"],"names":[],"mappings":"AAyGC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { StyleBuilder } from '../style_builder/style_builder.js';
2
- import type { StyleBuilderColors, StyleRules, StyleRulesOptions } from '../style_builder/types.js';
3
- export default class Colorful extends StyleBuilder {
4
- readonly name: string;
5
- defaultFonts: {
6
- regular: string;
7
- bold: string;
8
- };
9
- defaultColors: StyleBuilderColors;
10
- protected getStyleRules(options: StyleRulesOptions): StyleRules;
11
- }