@react-x11/components 0.3.0 → 0.5.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 (314) hide show
  1. package/README.md +131 -4
  2. package/dist/charts/components.d.ts +3 -1
  3. package/dist/charts/components.d.ts.map +1 -1
  4. package/dist/charts/components.js +8 -4
  5. package/dist/charts/components.js.map +1 -1
  6. package/dist/charts/node.d.ts +13 -6
  7. package/dist/charts/node.d.ts.map +1 -1
  8. package/dist/charts/node.js +75 -24
  9. package/dist/charts/node.js.map +1 -1
  10. package/dist/charts/render.d.ts +4 -0
  11. package/dist/charts/render.d.ts.map +1 -1
  12. package/dist/charts/render.js +11 -6
  13. package/dist/charts/render.js.map +1 -1
  14. package/dist/code-editor/node.d.ts +47 -16
  15. package/dist/code-editor/node.d.ts.map +1 -1
  16. package/dist/code-editor/node.js +121 -51
  17. package/dist/code-editor/node.js.map +1 -1
  18. package/dist/flow/draw.d.ts +19 -1
  19. package/dist/flow/draw.d.ts.map +1 -1
  20. package/dist/flow/draw.js +64 -35
  21. package/dist/flow/draw.js.map +1 -1
  22. package/dist/flow/index.d.ts.map +1 -1
  23. package/dist/flow/index.js +24 -8
  24. package/dist/flow/index.js.map +1 -1
  25. package/dist/flow/model.d.ts +4 -2
  26. package/dist/flow/model.d.ts.map +1 -1
  27. package/dist/flow/model.js +4 -2
  28. package/dist/flow/model.js.map +1 -1
  29. package/dist/flow/node.d.ts +40 -9
  30. package/dist/flow/node.d.ts.map +1 -1
  31. package/dist/flow/node.js +142 -53
  32. package/dist/flow/node.js.map +1 -1
  33. package/dist/flow/types.d.ts +46 -21
  34. package/dist/flow/types.d.ts.map +1 -1
  35. package/dist/formula/index.d.ts +4 -2
  36. package/dist/formula/index.d.ts.map +1 -1
  37. package/dist/formula/index.js.map +1 -1
  38. package/dist/formula/node.d.ts +5 -1
  39. package/dist/formula/node.d.ts.map +1 -1
  40. package/dist/formula/node.js +19 -3
  41. package/dist/formula/node.js.map +1 -1
  42. package/dist/html/controls.d.ts +4 -1
  43. package/dist/html/controls.d.ts.map +1 -1
  44. package/dist/html/controls.js.map +1 -1
  45. package/dist/html/css/cascade.d.ts +11 -5
  46. package/dist/html/css/cascade.d.ts.map +1 -1
  47. package/dist/html/css/cascade.js +18 -8
  48. package/dist/html/css/cascade.js.map +1 -1
  49. package/dist/html/css/parse.d.ts +15 -10
  50. package/dist/html/css/parse.d.ts.map +1 -1
  51. package/dist/html/css/parse.js +41 -16
  52. package/dist/html/css/parse.js.map +1 -1
  53. package/dist/html/css/style.d.ts +3 -0
  54. package/dist/html/css/style.d.ts.map +1 -1
  55. package/dist/html/css/style.js +3 -1
  56. package/dist/html/css/style.js.map +1 -1
  57. package/dist/html/css/values.d.ts +14 -1
  58. package/dist/html/css/values.d.ts.map +1 -1
  59. package/dist/html/css/values.js +11 -8
  60. package/dist/html/css/values.js.map +1 -1
  61. package/dist/html/index.d.ts.map +1 -1
  62. package/dist/html/index.js +1 -0
  63. package/dist/html/index.js.map +1 -1
  64. package/dist/html/layout/boxes.d.ts +12 -5
  65. package/dist/html/layout/boxes.d.ts.map +1 -1
  66. package/dist/html/layout/boxes.js +7 -4
  67. package/dist/html/layout/boxes.js.map +1 -1
  68. package/dist/html/layout/inline.d.ts.map +1 -1
  69. package/dist/html/layout/inline.js +22 -1
  70. package/dist/html/layout/inline.js.map +1 -1
  71. package/dist/html/node.d.ts +22 -8
  72. package/dist/html/node.d.ts.map +1 -1
  73. package/dist/html/node.js +97 -15
  74. package/dist/html/node.js.map +1 -1
  75. package/dist/html/paint.d.ts +3 -0
  76. package/dist/html/paint.d.ts.map +1 -1
  77. package/dist/html/paint.js +2 -2
  78. package/dist/html/paint.js.map +1 -1
  79. package/dist/index.d.ts +11 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +26 -0
  82. package/dist/index.js.map +1 -1
  83. package/dist/maps/clip.d.ts +43 -0
  84. package/dist/maps/clip.d.ts.map +1 -0
  85. package/dist/maps/clip.js +171 -0
  86. package/dist/maps/clip.js.map +1 -0
  87. package/dist/maps/gzip.d.ts +15 -0
  88. package/dist/maps/gzip.d.ts.map +1 -0
  89. package/dist/maps/gzip.js +56 -0
  90. package/dist/maps/gzip.js.map +1 -0
  91. package/dist/maps/index.d.ts +55 -0
  92. package/dist/maps/index.d.ts.map +1 -0
  93. package/dist/maps/index.js +141 -0
  94. package/dist/maps/index.js.map +1 -0
  95. package/dist/maps/labels.d.ts +123 -0
  96. package/dist/maps/labels.d.ts.map +1 -0
  97. package/dist/maps/labels.js +323 -0
  98. package/dist/maps/labels.js.map +1 -0
  99. package/dist/maps/mvt.d.ts +244 -0
  100. package/dist/maps/mvt.d.ts.map +1 -0
  101. package/dist/maps/mvt.js +820 -0
  102. package/dist/maps/mvt.js.map +1 -0
  103. package/dist/maps/node.d.ts +278 -0
  104. package/dist/maps/node.d.ts.map +1 -0
  105. package/dist/maps/node.js +1459 -0
  106. package/dist/maps/node.js.map +1 -0
  107. package/dist/maps/overlay.d.ts +157 -0
  108. package/dist/maps/overlay.d.ts.map +1 -0
  109. package/dist/maps/overlay.js +472 -0
  110. package/dist/maps/overlay.js.map +1 -0
  111. package/dist/maps/paint.d.ts +226 -0
  112. package/dist/maps/paint.d.ts.map +1 -0
  113. package/dist/maps/paint.js +705 -0
  114. package/dist/maps/paint.js.map +1 -0
  115. package/dist/maps/proj.d.ts +281 -0
  116. package/dist/maps/proj.d.ts.map +1 -0
  117. package/dist/maps/proj.js +451 -0
  118. package/dist/maps/proj.js.map +1 -0
  119. package/dist/maps/sources.d.ts +256 -0
  120. package/dist/maps/sources.d.ts.map +1 -0
  121. package/dist/maps/sources.js +210 -0
  122. package/dist/maps/sources.js.map +1 -0
  123. package/dist/maps/style.d.ts +141 -0
  124. package/dist/maps/style.d.ts.map +1 -0
  125. package/dist/maps/style.js +147 -0
  126. package/dist/maps/style.js.map +1 -0
  127. package/dist/maps/styles.d.ts +82 -0
  128. package/dist/maps/styles.d.ts.map +1 -0
  129. package/dist/maps/styles.js +898 -0
  130. package/dist/maps/styles.js.map +1 -0
  131. package/dist/maps/tiles.d.ts +283 -0
  132. package/dist/maps/tiles.d.ts.map +1 -0
  133. package/dist/maps/tiles.js +469 -0
  134. package/dist/maps/tiles.js.map +1 -0
  135. package/dist/maps/types.d.ts +244 -0
  136. package/dist/maps/types.d.ts.map +1 -0
  137. package/dist/maps/types.js +2 -0
  138. package/dist/maps/types.js.map +1 -0
  139. package/dist/qml/containers.d.ts +3 -0
  140. package/dist/qml/containers.d.ts.map +1 -0
  141. package/dist/qml/containers.js +331 -0
  142. package/dist/qml/containers.js.map +1 -0
  143. package/dist/qml/controls.d.ts +12 -0
  144. package/dist/qml/controls.d.ts.map +1 -0
  145. package/dist/qml/controls.js +21 -0
  146. package/dist/qml/controls.js.map +1 -0
  147. package/dist/qml/globals.d.ts +6 -0
  148. package/dist/qml/globals.d.ts.map +1 -0
  149. package/dist/qml/globals.js +25 -0
  150. package/dist/qml/globals.js.map +1 -0
  151. package/dist/qml/index.d.ts +15 -0
  152. package/dist/qml/index.d.ts.map +1 -0
  153. package/dist/qml/index.js +25 -0
  154. package/dist/qml/index.js.map +1 -0
  155. package/dist/qml/interaction.d.ts +12 -0
  156. package/dist/qml/interaction.d.ts.map +1 -0
  157. package/dist/qml/interaction.js +246 -0
  158. package/dist/qml/interaction.js.map +1 -0
  159. package/dist/qml/ir.d.ts +106 -0
  160. package/dist/qml/ir.d.ts.map +1 -0
  161. package/dist/qml/ir.js +7 -0
  162. package/dist/qml/ir.js.map +1 -0
  163. package/dist/qml/layouts.d.ts +3 -0
  164. package/dist/qml/layouts.d.ts.map +1 -0
  165. package/dist/qml/layouts.js +122 -0
  166. package/dist/qml/layouts.js.map +1 -0
  167. package/dist/qml/models.d.ts +14 -0
  168. package/dist/qml/models.d.ts.map +1 -0
  169. package/dist/qml/models.js +80 -0
  170. package/dist/qml/models.js.map +1 -0
  171. package/dist/qml/objects.d.ts +228 -0
  172. package/dist/qml/objects.d.ts.map +1 -0
  173. package/dist/qml/objects.js +1103 -0
  174. package/dist/qml/objects.js.map +1 -0
  175. package/dist/qml/parse.d.ts +10 -0
  176. package/dist/qml/parse.d.ts.map +1 -0
  177. package/dist/qml/parse.js +607 -0
  178. package/dist/qml/parse.js.map +1 -0
  179. package/dist/qml/qtquick.d.ts +7 -0
  180. package/dist/qml/qtquick.d.ts.map +1 -0
  181. package/dist/qml/qtquick.js +347 -0
  182. package/dist/qml/qtquick.js.map +1 -0
  183. package/dist/qml/react.d.ts +83 -0
  184. package/dist/qml/react.d.ts.map +1 -0
  185. package/dist/qml/react.js +323 -0
  186. package/dist/qml/react.js.map +1 -0
  187. package/dist/qml/resolver.d.ts +38 -0
  188. package/dist/qml/resolver.d.ts.map +1 -0
  189. package/dist/qml/resolver.js +64 -0
  190. package/dist/qml/resolver.js.map +1 -0
  191. package/dist/qml/slots.d.ts +65 -0
  192. package/dist/qml/slots.d.ts.map +1 -0
  193. package/dist/qml/slots.js +230 -0
  194. package/dist/qml/slots.js.map +1 -0
  195. package/dist/qml/states.d.ts +5 -0
  196. package/dist/qml/states.d.ts.map +1 -0
  197. package/dist/qml/states.js +276 -0
  198. package/dist/qml/states.js.map +1 -0
  199. package/dist/qml/view-utils.d.ts +42 -0
  200. package/dist/qml/view-utils.d.ts.map +1 -0
  201. package/dist/qml/view-utils.js +121 -0
  202. package/dist/qml/view-utils.js.map +1 -0
  203. package/dist/reorder/hx.d.ts +18 -0
  204. package/dist/reorder/hx.d.ts.map +1 -0
  205. package/dist/reorder/hx.js +10 -0
  206. package/dist/reorder/hx.js.map +1 -0
  207. package/dist/reorder/index.d.ts +314 -0
  208. package/dist/reorder/index.d.ts.map +1 -0
  209. package/dist/reorder/index.js +1539 -0
  210. package/dist/reorder/index.js.map +1 -0
  211. package/dist/reorder/model.d.ts +107 -0
  212. package/dist/reorder/model.d.ts.map +1 -0
  213. package/dist/reorder/model.js +162 -0
  214. package/dist/reorder/model.js.map +1 -0
  215. package/dist/richtext/node.d.ts +15 -5
  216. package/dist/richtext/node.d.ts.map +1 -1
  217. package/dist/richtext/node.js +40 -11
  218. package/dist/richtext/node.js.map +1 -1
  219. package/dist/richtext/runs.d.ts +35 -13
  220. package/dist/richtext/runs.d.ts.map +1 -1
  221. package/dist/richtext/runs.js +83 -27
  222. package/dist/richtext/runs.js.map +1 -1
  223. package/dist/tabs/hx.d.ts +18 -0
  224. package/dist/tabs/hx.d.ts.map +1 -0
  225. package/dist/tabs/hx.js +10 -0
  226. package/dist/tabs/hx.js.map +1 -0
  227. package/dist/tabs/index.d.ts +160 -0
  228. package/dist/tabs/index.d.ts.map +1 -0
  229. package/dist/tabs/index.js +1265 -0
  230. package/dist/tabs/index.js.map +1 -0
  231. package/dist/terminal/vt/fonts.d.ts +45 -15
  232. package/dist/terminal/vt/fonts.d.ts.map +1 -1
  233. package/dist/terminal/vt/fonts.js +89 -19
  234. package/dist/terminal/vt/fonts.js.map +1 -1
  235. package/dist/terminal/vt/index.d.ts +1 -1
  236. package/dist/terminal/vt/index.d.ts.map +1 -1
  237. package/dist/terminal/vt/index.js +3 -3
  238. package/dist/terminal/vt/index.js.map +1 -1
  239. package/dist/terminal/vt/node.d.ts +42 -0
  240. package/dist/terminal/vt/node.d.ts.map +1 -1
  241. package/dist/terminal/vt/node.js +95 -11
  242. package/dist/terminal/vt/node.js.map +1 -1
  243. package/dist/terminal/vt/pty.d.ts +16 -0
  244. package/dist/terminal/vt/pty.d.ts.map +1 -1
  245. package/dist/terminal/vt/pty.js +186 -0
  246. package/dist/terminal/vt/pty.js.map +1 -1
  247. package/dist/terminal/vt/renderer.d.ts.map +1 -1
  248. package/dist/terminal/vt/renderer.js +13 -3
  249. package/dist/terminal/vt/renderer.js.map +1 -1
  250. package/package.json +23 -3
  251. package/src/charts/components.ts +14 -7
  252. package/src/charts/node.ts +81 -26
  253. package/src/charts/render.ts +16 -6
  254. package/src/code-editor/node.ts +147 -53
  255. package/src/flow/draw.ts +104 -35
  256. package/src/flow/index.ts +33 -13
  257. package/src/flow/model.ts +4 -2
  258. package/src/flow/node.ts +158 -59
  259. package/src/flow/types.ts +46 -21
  260. package/src/formula/index.ts +4 -2
  261. package/src/formula/node.ts +24 -5
  262. package/src/html/controls.ts +4 -1
  263. package/src/html/css/cascade.ts +18 -7
  264. package/src/html/css/parse.ts +46 -21
  265. package/src/html/css/style.ts +6 -1
  266. package/src/html/css/values.ts +25 -9
  267. package/src/html/index.ts +1 -0
  268. package/src/html/layout/boxes.ts +19 -9
  269. package/src/html/layout/inline.ts +23 -1
  270. package/src/html/node.ts +110 -17
  271. package/src/html/paint.ts +17 -2
  272. package/src/index.ts +142 -0
  273. package/src/maps/clip.ts +184 -0
  274. package/src/maps/gzip.ts +66 -0
  275. package/src/maps/index.ts +316 -0
  276. package/src/maps/labels.ts +442 -0
  277. package/src/maps/mvt.ts +857 -0
  278. package/src/maps/node.ts +1819 -0
  279. package/src/maps/overlay.ts +639 -0
  280. package/src/maps/paint.ts +978 -0
  281. package/src/maps/proj.ts +641 -0
  282. package/src/maps/sources.ts +425 -0
  283. package/src/maps/style.ts +309 -0
  284. package/src/maps/styles.ts +1040 -0
  285. package/src/maps/tiles.ts +676 -0
  286. package/src/maps/types.ts +260 -0
  287. package/src/qml/containers.tsx +380 -0
  288. package/src/qml/controls.tsx +47 -0
  289. package/src/qml/globals.ts +33 -0
  290. package/src/qml/index.ts +67 -0
  291. package/src/qml/interaction.tsx +317 -0
  292. package/src/qml/ir.ts +80 -0
  293. package/src/qml/layouts.tsx +141 -0
  294. package/src/qml/models.ts +101 -0
  295. package/src/qml/objects.ts +1431 -0
  296. package/src/qml/parse.ts +624 -0
  297. package/src/qml/qtquick.tsx +413 -0
  298. package/src/qml/react.tsx +454 -0
  299. package/src/qml/resolver.ts +99 -0
  300. package/src/qml/slots.ts +249 -0
  301. package/src/qml/states.ts +318 -0
  302. package/src/qml/view-utils.ts +140 -0
  303. package/src/reorder/hx.ts +31 -0
  304. package/src/reorder/index.ts +2223 -0
  305. package/src/reorder/model.ts +232 -0
  306. package/src/richtext/node.ts +49 -14
  307. package/src/richtext/runs.ts +115 -30
  308. package/src/tabs/hx.ts +31 -0
  309. package/src/tabs/index.ts +1686 -0
  310. package/src/terminal/vt/fonts.ts +128 -36
  311. package/src/terminal/vt/index.ts +4 -2
  312. package/src/terminal/vt/node.ts +105 -12
  313. package/src/terminal/vt/pty.ts +243 -0
  314. package/src/terminal/vt/renderer.ts +13 -3
@@ -0,0 +1,898 @@
1
+ /** The tags Shortbread puts a road's class in, grouped as a style wants
2
+ * them rather than as the schema lists them. */
3
+ const MOTORWAY = ['motorway'];
4
+ const TRUNK = ['trunk'];
5
+ const PRIMARY = ['primary'];
6
+ const SECONDARY = ['secondary'];
7
+ const TERTIARY = ['tertiary'];
8
+ const MINOR = [
9
+ 'unclassified',
10
+ 'residential',
11
+ 'living_street',
12
+ 'pedestrian',
13
+ 'busway',
14
+ ];
15
+ const SERVICE = ['service', 'track', 'ford'];
16
+ const PATH = ['path', 'footway', 'cycleway', 'steps', 'bridleway'];
17
+ const RAIL = [
18
+ 'rail',
19
+ 'narrow_gauge',
20
+ 'light_rail',
21
+ 'subway',
22
+ 'tram',
23
+ 'monorail',
24
+ 'funicular',
25
+ ];
26
+ /** Landuse kinds that read as green space. */
27
+ const GREEN = [
28
+ 'park',
29
+ 'garden',
30
+ 'grass',
31
+ 'meadow',
32
+ 'forest',
33
+ 'wood',
34
+ 'scrub',
35
+ 'heath',
36
+ 'orchard',
37
+ 'vineyard',
38
+ 'village_green',
39
+ 'recreation_ground',
40
+ 'golf_course',
41
+ 'cemetery',
42
+ 'allotments',
43
+ 'farmland',
44
+ 'farmyard',
45
+ ];
46
+ /** …and the ones that read as built-up. */
47
+ const BUILT = [
48
+ 'residential',
49
+ 'commercial',
50
+ 'retail',
51
+ 'industrial',
52
+ 'brownfield',
53
+ 'greenfield',
54
+ 'railway',
55
+ 'garages',
56
+ 'quarry',
57
+ 'construction',
58
+ 'landfill',
59
+ ];
60
+ /** OSM Carto's hues, near enough that a user's eye reads the map as the one
61
+ * they already know. */
62
+ export const LIGHT_PALETTE = {
63
+ land: '#f2efe9',
64
+ ocean: '#aad3df',
65
+ water: '#aad3df',
66
+ green: '#cfe8b4',
67
+ built: '#e8e2dc',
68
+ site: '#f0e7db',
69
+ building: '#dfd7cd',
70
+ buildingEdge: '#cec4b8',
71
+ motorway: '#f9b29c',
72
+ motorwayCasing: '#d97f63',
73
+ trunk: '#fcd6a4',
74
+ primary: '#fcd6a4',
75
+ secondary: '#f7fabf',
76
+ minor: '#ffffff',
77
+ minorCasing: '#cfcdca',
78
+ path: '#d4b8a8',
79
+ rail: '#b0aeab',
80
+ boundary: '#a4a1ae',
81
+ pier: '#f2efe9',
82
+ text: '#33322e',
83
+ textMinor: '#6b6862',
84
+ halo: 'rgba(255,255,255,0.85)',
85
+ };
86
+ /** The dark counterpart. Desaturated rather than inverted: an inverted map
87
+ * puts white water under dark land, which reads as a negative. */
88
+ export const DARK_PALETTE = {
89
+ land: '#191b1f',
90
+ ocean: '#0f1c28',
91
+ water: '#12222f',
92
+ green: '#1a2620',
93
+ built: '#1f2126',
94
+ site: '#20232a',
95
+ building: '#23262c',
96
+ buildingEdge: '#2b2f36',
97
+ motorway: '#5d4b38',
98
+ motorwayCasing: '#7a6244',
99
+ trunk: '#4c4232',
100
+ primary: '#43403a',
101
+ secondary: '#3b3a35',
102
+ minor: '#33363c',
103
+ minorCasing: '#22242a',
104
+ path: '#3a352f',
105
+ rail: '#33363c',
106
+ boundary: '#4a4757',
107
+ pier: '#22252b',
108
+ text: '#d3d7de',
109
+ textMinor: '#9299a3',
110
+ halo: 'rgba(12,14,18,0.85)',
111
+ };
112
+ /** How wide a road class is, at each zoom. */
113
+ function width(stops) {
114
+ return { stops };
115
+ }
116
+ /**
117
+ * The default style for Shortbread tiles.
118
+ *
119
+ * Twenty-six layers, in paint order. The order is the cartography: sea,
120
+ * then landuse, then water, then sites and buildings, then road *casings*
121
+ * as one pass and road *fills* as another — which is what makes a junction
122
+ * look like a junction rather than two roads crossing — then rail,
123
+ * boundaries, and labels last.
124
+ */
125
+ export function shortbreadStyle(options = {}) {
126
+ const p = {
127
+ ...(options.dark ? DARK_PALETTE : LIGHT_PALETTE),
128
+ ...options.palette,
129
+ };
130
+ const name = options.nameField ?? 'name';
131
+ const layers = [
132
+ { id: 'ocean', type: 'fill', sourceLayer: 'ocean', color: p.ocean },
133
+ {
134
+ id: 'landuse-green',
135
+ type: 'fill',
136
+ sourceLayer: 'land',
137
+ filter: ['in', 'kind', ...GREEN],
138
+ color: p.green,
139
+ },
140
+ {
141
+ id: 'landuse-built',
142
+ type: 'fill',
143
+ sourceLayer: 'land',
144
+ filter: ['in', 'kind', ...BUILT],
145
+ color: p.built,
146
+ },
147
+ {
148
+ id: 'sites',
149
+ type: 'fill',
150
+ sourceLayer: 'sites',
151
+ color: p.site,
152
+ minZoom: 13,
153
+ },
154
+ {
155
+ id: 'water-polygons',
156
+ type: 'fill',
157
+ sourceLayer: 'water_polygons',
158
+ color: p.water,
159
+ },
160
+ {
161
+ id: 'water-lines',
162
+ type: 'line',
163
+ sourceLayer: 'water_lines',
164
+ color: p.water,
165
+ width: width([
166
+ [6, 0.5],
167
+ [10, 1.2],
168
+ [14, 3],
169
+ [18, 8],
170
+ ]),
171
+ },
172
+ {
173
+ id: 'dams',
174
+ type: 'fill',
175
+ sourceLayer: 'dam_polygons',
176
+ color: p.built,
177
+ minZoom: 13,
178
+ },
179
+ {
180
+ id: 'piers',
181
+ type: 'fill',
182
+ sourceLayer: 'pier_polygons',
183
+ color: p.pier,
184
+ minZoom: 13,
185
+ },
186
+ ];
187
+ if (options.buildings !== false) {
188
+ layers.push({
189
+ id: 'buildings',
190
+ type: 'fill',
191
+ sourceLayer: 'buildings',
192
+ minZoom: 14,
193
+ color: p.building,
194
+ // The edge only once a footprint is big enough for it to be an edge
195
+ // rather than a darkening of the whole polygon.
196
+ outlineColor: p.buildingEdge,
197
+ });
198
+ }
199
+ // Casings first, every class in one pass, so that the fills above them
200
+ // knit together at every junction. This is the one thing that separates a
201
+ // road network from a pile of coloured lines.
202
+ const roadClasses = [
203
+ {
204
+ id: 'motorway',
205
+ kinds: MOTORWAY,
206
+ fill: p.motorway,
207
+ casing: p.motorwayCasing,
208
+ fillWidth: width([
209
+ [5, 0.6],
210
+ [8, 1.4],
211
+ [10, 2.4],
212
+ [13, 5],
213
+ [16, 12],
214
+ [20, 40],
215
+ ]),
216
+ },
217
+ {
218
+ id: 'trunk',
219
+ kinds: TRUNK,
220
+ fill: p.trunk,
221
+ casing: p.motorwayCasing,
222
+ fillWidth: width([
223
+ [6, 0.5],
224
+ [9, 1.2],
225
+ [12, 2.6],
226
+ [16, 9],
227
+ [20, 30],
228
+ ]),
229
+ },
230
+ {
231
+ id: 'primary',
232
+ kinds: PRIMARY,
233
+ fill: p.primary,
234
+ casing: p.minorCasing,
235
+ fillWidth: width([
236
+ [7, 0.5],
237
+ [10, 1.3],
238
+ [13, 3],
239
+ [16, 8],
240
+ [20, 26],
241
+ ]),
242
+ minZoom: 7,
243
+ },
244
+ {
245
+ id: 'secondary',
246
+ kinds: SECONDARY,
247
+ fill: p.secondary,
248
+ casing: p.minorCasing,
249
+ fillWidth: width([
250
+ [9, 0.5],
251
+ [12, 1.6],
252
+ [15, 5],
253
+ [20, 20],
254
+ ]),
255
+ minZoom: 9,
256
+ },
257
+ {
258
+ id: 'tertiary',
259
+ kinds: TERTIARY,
260
+ fill: p.minor,
261
+ casing: p.minorCasing,
262
+ fillWidth: width([
263
+ [11, 0.6],
264
+ [14, 2.4],
265
+ [17, 7],
266
+ [20, 18],
267
+ ]),
268
+ minZoom: 11,
269
+ },
270
+ {
271
+ id: 'minor',
272
+ kinds: MINOR,
273
+ fill: p.minor,
274
+ casing: p.minorCasing,
275
+ fillWidth: width([
276
+ [12, 0.5],
277
+ [14, 1.8],
278
+ [17, 6],
279
+ [20, 16],
280
+ ]),
281
+ minZoom: 12,
282
+ },
283
+ {
284
+ id: 'service',
285
+ kinds: SERVICE,
286
+ fill: p.minor,
287
+ casing: p.minorCasing,
288
+ fillWidth: width([
289
+ [14, 0.8],
290
+ [17, 3],
291
+ [20, 9],
292
+ ]),
293
+ minZoom: 14,
294
+ },
295
+ ];
296
+ for (const road of roadClasses) {
297
+ layers.push({
298
+ id: `${road.id}-casing`,
299
+ type: 'line',
300
+ sourceLayer: 'streets',
301
+ minZoom: road.minZoom,
302
+ filter: ['all', ['in', 'kind', ...road.kinds], ['!=', 'rail', true]],
303
+ color: road.casing,
304
+ // A casing is the fill plus two logical pixels, which is what makes
305
+ // the outline a constant width at every zoom rather than a ratio that
306
+ // disappears when the road is thin.
307
+ width: scaleWidth(road.fillWidth, 2),
308
+ cap: 'round',
309
+ join: 'round',
310
+ });
311
+ }
312
+ for (const road of roadClasses) {
313
+ layers.push({
314
+ id: road.id,
315
+ type: 'line',
316
+ sourceLayer: 'streets',
317
+ minZoom: road.minZoom,
318
+ filter: ['all', ['in', 'kind', ...road.kinds], ['!=', 'rail', true]],
319
+ color: road.fill,
320
+ width: road.fillWidth,
321
+ cap: 'round',
322
+ join: 'round',
323
+ });
324
+ }
325
+ layers.push({
326
+ id: 'paths',
327
+ type: 'line',
328
+ sourceLayer: 'streets',
329
+ minZoom: 15,
330
+ filter: ['in', 'kind', ...PATH],
331
+ color: p.path,
332
+ width: width([
333
+ [15, 0.8],
334
+ [18, 1.6],
335
+ [20, 3],
336
+ ]),
337
+ dash: [3, 2],
338
+ }, {
339
+ id: 'rail',
340
+ type: 'line',
341
+ sourceLayer: 'streets',
342
+ minZoom: 9,
343
+ filter: ['in', 'kind', ...RAIL],
344
+ color: p.rail,
345
+ width: width([
346
+ [9, 0.5],
347
+ [13, 1],
348
+ [17, 2],
349
+ [20, 3],
350
+ ]),
351
+ }, {
352
+ id: 'ferries',
353
+ type: 'line',
354
+ sourceLayer: 'ferries',
355
+ minZoom: 9,
356
+ color: p.boundary,
357
+ width: 1,
358
+ dash: [4, 3],
359
+ }, {
360
+ id: 'boundaries-country',
361
+ type: 'line',
362
+ sourceLayer: 'boundaries',
363
+ color: p.boundary,
364
+ filter: ['<=', 'admin_level', 2],
365
+ width: width([
366
+ [2, 0.6],
367
+ [6, 1.1],
368
+ [12, 1.6],
369
+ ]),
370
+ dash: [5, 3],
371
+ }, {
372
+ // Regional borders only once there is room for them to mean
373
+ // something — at zoom 3 they are noise over the country outlines.
374
+ id: 'boundaries-region',
375
+ type: 'line',
376
+ sourceLayer: 'boundaries',
377
+ minZoom: 6,
378
+ color: p.boundary,
379
+ filter: ['>', 'admin_level', 2],
380
+ width: width([
381
+ [6, 0.5],
382
+ [12, 1],
383
+ ]),
384
+ dash: [3, 3],
385
+ });
386
+ if (options.labels !== false) {
387
+ layers.push(
388
+ // Places, split by kind rather than ranked by a field — see
389
+ // `SymbolLayer.rank` for why. The split is also what lets each class
390
+ // have its own size and its own zoom, which is most of what makes a
391
+ // label layer read as cartography.
392
+ {
393
+ id: 'place-labels-city',
394
+ type: 'symbol',
395
+ sourceLayer: 'place_labels',
396
+ filter: ['in', 'kind', 'capital', 'city'],
397
+ textField: name,
398
+ textColor: p.text,
399
+ textHaloColor: p.halo,
400
+ textHaloWidth: 1.5,
401
+ textSize: {
402
+ stops: [
403
+ [3, 12],
404
+ [8, 15],
405
+ [12, 18],
406
+ [16, 20],
407
+ ],
408
+ },
409
+ rank: 100,
410
+ }, {
411
+ id: 'place-labels-town',
412
+ type: 'symbol',
413
+ sourceLayer: 'place_labels',
414
+ minZoom: 7,
415
+ filter: ['in', 'kind', 'town', 'borough'],
416
+ textField: name,
417
+ textColor: p.text,
418
+ textHaloColor: p.halo,
419
+ textHaloWidth: 1.5,
420
+ textSize: {
421
+ stops: [
422
+ [7, 11],
423
+ [12, 14],
424
+ [16, 16],
425
+ ],
426
+ },
427
+ rank: 80,
428
+ }, {
429
+ id: 'place-labels-suburb',
430
+ type: 'symbol',
431
+ sourceLayer: 'place_labels',
432
+ minZoom: 11,
433
+ filter: ['in', 'kind', 'suburb', 'quarter', 'neighbourhood', 'village'],
434
+ textField: name,
435
+ textColor: p.textMinor,
436
+ textHaloColor: p.halo,
437
+ textHaloWidth: 1.2,
438
+ textSize: {
439
+ stops: [
440
+ [11, 10],
441
+ [15, 13],
442
+ ],
443
+ },
444
+ rank: 60,
445
+ }, {
446
+ id: 'place-labels-locality',
447
+ type: 'symbol',
448
+ sourceLayer: 'place_labels',
449
+ minZoom: 13,
450
+ filter: [
451
+ 'in',
452
+ 'kind',
453
+ 'hamlet',
454
+ 'locality',
455
+ 'isolated_dwelling',
456
+ 'farm',
457
+ 'island',
458
+ 'islet',
459
+ ],
460
+ textField: name,
461
+ textColor: p.textMinor,
462
+ textHaloColor: p.halo,
463
+ textHaloWidth: 1.2,
464
+ textSize: 10,
465
+ rank: 40,
466
+ }, {
467
+ id: 'water-labels',
468
+ type: 'symbol',
469
+ sourceLayer: 'water_polygons_labels',
470
+ minZoom: 9,
471
+ textField: name,
472
+ textColor: p.textMinor,
473
+ textHaloColor: p.halo,
474
+ textHaloWidth: 1,
475
+ textSize: 11,
476
+ rank: 30,
477
+ }, {
478
+ id: 'street-labels',
479
+ type: 'symbol',
480
+ sourceLayer: 'street_labels',
481
+ minZoom: 14,
482
+ filter: ['!in', 'kind', ...RAIL],
483
+ textField: name,
484
+ textColor: p.textMinor,
485
+ textHaloColor: p.halo,
486
+ textHaloWidth: 1,
487
+ textSize: 11,
488
+ // Under every place name: a suburb's name is what orients someone,
489
+ // a street's name is what they read once they are oriented.
490
+ rank: 20,
491
+ }, {
492
+ id: 'transport-labels',
493
+ type: 'symbol',
494
+ sourceLayer: 'public_transport',
495
+ minZoom: 15,
496
+ textField: name,
497
+ textColor: p.textMinor,
498
+ textHaloColor: p.halo,
499
+ textHaloWidth: 1,
500
+ textSize: 10,
501
+ rank: 10,
502
+ });
503
+ }
504
+ return { background: p.land, layers };
505
+ }
506
+ /** A width ramp plus a constant — how a casing is derived from its fill so
507
+ * the two cannot drift apart when one of them is retuned. */
508
+ function scaleWidth(base, add) {
509
+ if (typeof base === 'number')
510
+ return base + add;
511
+ return { stops: base.stops.map(([z, v]) => [z, v + add]) };
512
+ }
513
+ // --- OpenMapTiles -----------------------------------------------------------
514
+ /**
515
+ * Road classes as **OpenMapTiles** names them.
516
+ *
517
+ * Not the same words as Shortbread's, which is the whole reason this second
518
+ * style exists: `transportation.class` is `minor` where Shortbread says
519
+ * `residential`, `unclassified` and `living_street`, and rail lives in the
520
+ * same layer under `class: 'rail'` rather than beside the roads. Point
521
+ * {@link shortbreadStyle} at an OpenMapTiles source and it matches nothing
522
+ * and draws an empty map.
523
+ */
524
+ const OMT_RAIL = ['rail', 'transit'];
525
+ /** Landcover classes that read as green space. */
526
+ const OMT_GREEN = ['wood', 'grass', 'farmland', 'wetland'];
527
+ /** Landuse classes that read as built-up. */
528
+ const OMT_BUILT = [
529
+ 'residential',
530
+ 'commercial',
531
+ 'industrial',
532
+ 'retail',
533
+ 'railway',
534
+ 'cemetery',
535
+ 'quarry',
536
+ ];
537
+ /** Landuse classes for an institutional site. */
538
+ const OMT_SITES = [
539
+ 'hospital',
540
+ 'school',
541
+ 'university',
542
+ 'college',
543
+ 'kindergarten',
544
+ 'stadium',
545
+ 'pitch',
546
+ 'playground',
547
+ ];
548
+ /**
549
+ * The same cartography over the **OpenMapTiles** schema.
550
+ *
551
+ * OpenMapTiles is the other open schema, and between them the two cover
552
+ * nearly every provider worth pointing this at: Shortbread is what
553
+ * OpenStreetMap's own server and VersaTiles cut, OpenMapTiles is what
554
+ * MapTiler, Stadia, Geoapify, OpenFreeMap and most self-hosted planets cut.
555
+ *
556
+ * Deliberately the same palette, the same layer ids where they mean the
557
+ * same thing, and the same casing-then-fill ordering, so switching a source
558
+ * between the two schemas changes which style you pass and nothing else
559
+ * about how the map looks.
560
+ */
561
+ export function openMapTilesStyle(options = {}) {
562
+ const p = {
563
+ ...(options.dark ? DARK_PALETTE : LIGHT_PALETTE),
564
+ ...options.palette,
565
+ };
566
+ const name = options.nameField ?? 'name';
567
+ const layers = [
568
+ // One `water` layer for everything wet, with `class` telling the sea
569
+ // from a lake — where Shortbread has `ocean` and `water_polygons`.
570
+ { id: 'ocean', type: 'fill', sourceLayer: 'water', color: p.water },
571
+ {
572
+ id: 'landuse-green',
573
+ type: 'fill',
574
+ sourceLayer: 'landcover',
575
+ filter: ['in', 'class', ...OMT_GREEN],
576
+ color: p.green,
577
+ },
578
+ { id: 'park', type: 'fill', sourceLayer: 'park', color: p.green },
579
+ {
580
+ id: 'landuse-built',
581
+ type: 'fill',
582
+ sourceLayer: 'landuse',
583
+ filter: ['in', 'class', ...OMT_BUILT],
584
+ color: p.built,
585
+ },
586
+ {
587
+ id: 'sites',
588
+ type: 'fill',
589
+ sourceLayer: 'landuse',
590
+ minZoom: 13,
591
+ filter: ['in', 'class', ...OMT_SITES],
592
+ color: p.site,
593
+ },
594
+ {
595
+ id: 'water-lines',
596
+ type: 'line',
597
+ sourceLayer: 'waterway',
598
+ color: p.water,
599
+ width: width([
600
+ [6, 0.5],
601
+ [10, 1.2],
602
+ [14, 3],
603
+ [18, 8],
604
+ ]),
605
+ },
606
+ ];
607
+ if (options.buildings !== false) {
608
+ layers.push({
609
+ id: 'buildings',
610
+ type: 'fill',
611
+ sourceLayer: 'building',
612
+ minZoom: 14,
613
+ color: p.building,
614
+ outlineColor: p.buildingEdge,
615
+ });
616
+ }
617
+ const roads = [
618
+ {
619
+ id: 'motorway',
620
+ classes: ['motorway'],
621
+ fill: p.motorway,
622
+ casing: p.motorwayCasing,
623
+ fillWidth: width([
624
+ [5, 0.6],
625
+ [8, 1.4],
626
+ [10, 2.4],
627
+ [13, 5],
628
+ [16, 12],
629
+ [20, 40],
630
+ ]),
631
+ },
632
+ {
633
+ id: 'trunk',
634
+ classes: ['trunk'],
635
+ fill: p.trunk,
636
+ casing: p.motorwayCasing,
637
+ fillWidth: width([
638
+ [6, 0.5],
639
+ [9, 1.2],
640
+ [12, 2.6],
641
+ [16, 9],
642
+ [20, 30],
643
+ ]),
644
+ },
645
+ {
646
+ id: 'primary',
647
+ classes: ['primary'],
648
+ fill: p.primary,
649
+ casing: p.minorCasing,
650
+ minZoom: 7,
651
+ fillWidth: width([
652
+ [7, 0.5],
653
+ [10, 1.3],
654
+ [13, 3],
655
+ [16, 8],
656
+ [20, 26],
657
+ ]),
658
+ },
659
+ {
660
+ id: 'secondary',
661
+ classes: ['secondary'],
662
+ fill: p.secondary,
663
+ casing: p.minorCasing,
664
+ minZoom: 9,
665
+ fillWidth: width([
666
+ [9, 0.5],
667
+ [12, 1.6],
668
+ [15, 5],
669
+ [20, 20],
670
+ ]),
671
+ },
672
+ {
673
+ id: 'tertiary',
674
+ classes: ['tertiary'],
675
+ fill: p.minor,
676
+ casing: p.minorCasing,
677
+ minZoom: 11,
678
+ fillWidth: width([
679
+ [11, 0.6],
680
+ [14, 2.4],
681
+ [17, 7],
682
+ [20, 18],
683
+ ]),
684
+ },
685
+ {
686
+ // `minor` is OpenMapTiles' one word for residential, unclassified and
687
+ // living_street, which Shortbread keeps apart.
688
+ id: 'minor',
689
+ classes: ['minor'],
690
+ fill: p.minor,
691
+ casing: p.minorCasing,
692
+ minZoom: 12,
693
+ fillWidth: width([
694
+ [12, 0.5],
695
+ [14, 1.8],
696
+ [17, 6],
697
+ [20, 16],
698
+ ]),
699
+ },
700
+ {
701
+ id: 'service',
702
+ classes: ['service', 'track'],
703
+ fill: p.minor,
704
+ casing: p.minorCasing,
705
+ minZoom: 14,
706
+ fillWidth: width([
707
+ [14, 0.8],
708
+ [17, 3],
709
+ [20, 9],
710
+ ]),
711
+ },
712
+ ];
713
+ for (const road of roads) {
714
+ layers.push({
715
+ id: `${road.id}-casing`,
716
+ type: 'line',
717
+ sourceLayer: 'transportation',
718
+ minZoom: road.minZoom,
719
+ filter: ['in', 'class', ...road.classes],
720
+ color: road.casing,
721
+ width: scaleWidth(road.fillWidth, 2),
722
+ cap: 'round',
723
+ join: 'round',
724
+ });
725
+ }
726
+ for (const road of roads) {
727
+ layers.push({
728
+ id: road.id,
729
+ type: 'line',
730
+ sourceLayer: 'transportation',
731
+ minZoom: road.minZoom,
732
+ filter: ['in', 'class', ...road.classes],
733
+ color: road.fill,
734
+ width: road.fillWidth,
735
+ cap: 'round',
736
+ join: 'round',
737
+ });
738
+ }
739
+ layers.push({
740
+ id: 'paths',
741
+ type: 'line',
742
+ sourceLayer: 'transportation',
743
+ minZoom: 15,
744
+ filter: ['in', 'class', 'path', 'pedestrian'],
745
+ color: p.path,
746
+ width: width([
747
+ [15, 0.8],
748
+ [18, 1.6],
749
+ [20, 3],
750
+ ]),
751
+ dash: [3, 2],
752
+ }, {
753
+ id: 'rail',
754
+ type: 'line',
755
+ sourceLayer: 'transportation',
756
+ minZoom: 9,
757
+ filter: ['in', 'class', ...OMT_RAIL],
758
+ color: p.rail,
759
+ width: width([
760
+ [9, 0.5],
761
+ [13, 1],
762
+ [17, 2],
763
+ [20, 3],
764
+ ]),
765
+ }, {
766
+ id: 'ferries',
767
+ type: 'line',
768
+ sourceLayer: 'transportation',
769
+ minZoom: 9,
770
+ filter: ['==', 'class', 'ferry'],
771
+ color: p.boundary,
772
+ width: 1,
773
+ dash: [4, 3],
774
+ }, {
775
+ id: 'boundaries-country',
776
+ type: 'line',
777
+ sourceLayer: 'boundary',
778
+ filter: ['<=', 'admin_level', 2],
779
+ color: p.boundary,
780
+ width: width([
781
+ [2, 0.6],
782
+ [6, 1.1],
783
+ [12, 1.6],
784
+ ]),
785
+ dash: [5, 3],
786
+ }, {
787
+ id: 'boundaries-region',
788
+ type: 'line',
789
+ sourceLayer: 'boundary',
790
+ minZoom: 6,
791
+ filter: ['>', 'admin_level', 2],
792
+ color: p.boundary,
793
+ width: width([
794
+ [6, 0.5],
795
+ [12, 1],
796
+ ]),
797
+ dash: [3, 3],
798
+ });
799
+ if (options.labels !== false) {
800
+ layers.push({
801
+ id: 'place-labels-city',
802
+ type: 'symbol',
803
+ sourceLayer: 'place',
804
+ filter: ['in', 'class', 'city'],
805
+ textField: name,
806
+ textColor: p.text,
807
+ textHaloColor: p.halo,
808
+ textHaloWidth: 1.5,
809
+ textSize: {
810
+ stops: [
811
+ [3, 12],
812
+ [8, 15],
813
+ [12, 18],
814
+ [16, 20],
815
+ ],
816
+ },
817
+ rank: 100,
818
+ }, {
819
+ id: 'place-labels-town',
820
+ type: 'symbol',
821
+ sourceLayer: 'place',
822
+ minZoom: 7,
823
+ filter: ['in', 'class', 'town'],
824
+ textField: name,
825
+ textColor: p.text,
826
+ textHaloColor: p.halo,
827
+ textHaloWidth: 1.5,
828
+ textSize: {
829
+ stops: [
830
+ [7, 11],
831
+ [12, 14],
832
+ [16, 16],
833
+ ],
834
+ },
835
+ rank: 80,
836
+ }, {
837
+ id: 'place-labels-suburb',
838
+ type: 'symbol',
839
+ sourceLayer: 'place',
840
+ minZoom: 11,
841
+ filter: [
842
+ 'in',
843
+ 'class',
844
+ 'suburb',
845
+ 'quarter',
846
+ 'neighbourhood',
847
+ 'village',
848
+ ],
849
+ textField: name,
850
+ textColor: p.textMinor,
851
+ textHaloColor: p.halo,
852
+ textHaloWidth: 1.2,
853
+ textSize: {
854
+ stops: [
855
+ [11, 10],
856
+ [15, 13],
857
+ ],
858
+ },
859
+ rank: 60,
860
+ }, {
861
+ id: 'place-labels-locality',
862
+ type: 'symbol',
863
+ sourceLayer: 'place',
864
+ minZoom: 13,
865
+ filter: ['in', 'class', 'hamlet', 'isolated_dwelling', 'island'],
866
+ textField: name,
867
+ textColor: p.textMinor,
868
+ textHaloColor: p.halo,
869
+ textHaloWidth: 1.2,
870
+ textSize: 10,
871
+ rank: 40,
872
+ }, {
873
+ id: 'water-labels',
874
+ type: 'symbol',
875
+ sourceLayer: 'water_name',
876
+ minZoom: 9,
877
+ textField: name,
878
+ textColor: p.textMinor,
879
+ textHaloColor: p.halo,
880
+ textHaloWidth: 1,
881
+ textSize: 11,
882
+ rank: 30,
883
+ }, {
884
+ id: 'street-labels',
885
+ type: 'symbol',
886
+ sourceLayer: 'transportation_name',
887
+ minZoom: 14,
888
+ textField: name,
889
+ textColor: p.textMinor,
890
+ textHaloColor: p.halo,
891
+ textHaloWidth: 1,
892
+ textSize: 11,
893
+ rank: 20,
894
+ });
895
+ }
896
+ return { background: p.land, layers };
897
+ }
898
+ //# sourceMappingURL=styles.js.map