@tileflow/core 0.1.0-alpha.0 → 0.1.0-alpha.10

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.
@@ -0,0 +1,62 @@
1
+ Copyright (c) 2024, MapTiler.com & OpenMapTiles contributors.
2
+ Copyright (c) 2014, Mapbox.
3
+ All rights reserved.
4
+
5
+ Modifications by MapTiler.com & OpenMapTiles contributors.
6
+ Derived from "Mapbox Open Styles" https://github.com/mapbox/mapbox-gl-styles
7
+
8
+ # Code license: BSD 3-Clause License
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions are met:
12
+
13
+ * Redistributions of source code must retain the above copyright notice, this
14
+ list of conditions and the following disclaimer.
15
+
16
+ * Redistributions in binary form must reproduce the above copyright notice,
17
+ this list of conditions and the following disclaimer in the documentation
18
+ and/or other materials provided with the distribution.
19
+
20
+ * Neither the name of the copyright holder nor the names of its
21
+ contributors may be used to endorse or promote products derived from
22
+ this software without specific prior written permission.
23
+
24
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+
35
+ # Design license: CC-BY 4.0
36
+
37
+ The visual design features of the style (also known as the "look and feel" of
38
+ the map) are licensed under the Creative Commons Attribution 4.0 license.
39
+
40
+ To view a copy of the license, visit https://creativecommons.org/licenses/by/4.0/.
41
+
42
+ Attribution for the design defined in this repository needs not to be provided
43
+ on map images, but should be reasonably accessible from maps based on this style
44
+ (for example, in a webpage linked from copyright notice on the map).
45
+
46
+ Products or services using maps derived from OpenMapTiles schema need to visibly
47
+ credit "OpenMapTiles.org" or reference "OpenMapTiles" with a link to
48
+ https://openmaptiles.org/.
49
+
50
+ For a browsable electronic map based on OpenMapTiles and OpenStreetMap data, the
51
+ credit should appear in the corner of the map. For example:
52
+
53
+ [© OpenMapTiles](https://openmaptiles.org/)
54
+ [© OpenStreetMap contributors](https://www.openstreetmap.org/copyright)
55
+
56
+ For printed and static maps a similar attribution should be made in a textual
57
+ description near the image, in the same fashion as if you cite a photograph.
58
+
59
+ Exceptions to OpenMapTiles attribution requirement can be in a written form granted
60
+ by MapTiler AG (info@maptiler.com).
61
+ The project contributors grant MapTiler AG the license to give such
62
+ exceptions on a commercial basis.
package/README.md CHANGED
@@ -3,23 +3,134 @@
3
3
  Typed Tileflow config helpers and the MapLibre style compiler.
4
4
 
5
5
  ```ts
6
- import { defineTileflow } from "@tileflow/core";
6
+ import {defineTileflow, labels, osm, poi} from '@tileflow/core';
7
7
 
8
8
  export default defineTileflow({
9
+ icons: {
10
+ brand: {
11
+ sprite: 'https://cdn.example.com/tileflow/brand/sprite',
12
+ },
13
+ },
14
+ themes: {
15
+ light: {
16
+ colors: {
17
+ background: '#F8F7F7',
18
+ land: '#F4F2ED',
19
+ water: '#8ED6E8',
20
+ park: '#C3F1D5',
21
+ building: '#EEF0F2',
22
+ road: '#FFFFFF',
23
+ roadMajor: '#F5D58A',
24
+ roadCasing: '#DDE0E3',
25
+ boundary: '#C9CED3',
26
+ text: '#566371',
27
+ textMuted: '#8A98A8',
28
+ textHalo: '#FFFFFF',
29
+ },
30
+ modules: {
31
+ labels: {
32
+ road: '#7A8794',
33
+ water: '#4B8FA8',
34
+ },
35
+ poi: {
36
+ food: '#D97706',
37
+ transit: '#2563EB',
38
+ },
39
+ roads: {
40
+ motorway: '#F7C56F',
41
+ },
42
+ },
43
+ typography: {
44
+ font: 'Inter',
45
+ },
46
+ },
47
+ },
9
48
  maps: {
10
49
  madrid: {
11
- colors: {
12
- canvas: "#F8F6F1",
13
- land: "#F2EEE6",
14
- water: "#B6CBD8",
15
- nature: "#AEBB9B",
16
- road: "#DED6C8",
17
- text: "#2E2E2E",
18
- accent: "#C6A15B",
50
+ basemap: osm(),
51
+ icons: 'brand',
52
+ theme: 'light',
53
+ modules: [
54
+ labels({roads: 'minimal'}),
55
+ poi({categories: ['food', 'coffee', 'culture', 'transit'], icons: 'essential'}),
56
+ ],
57
+ layers: {
58
+ 'highway-primary': {
59
+ paint: {
60
+ 'line-opacity': 0.9,
61
+ },
62
+ },
63
+ },
64
+ view: {
65
+ center: [-3.7038, 40.4168],
66
+ zoom: 12,
19
67
  },
20
68
  },
21
69
  },
22
70
  });
23
71
  ```
24
72
 
73
+ ## Style contract
74
+
75
+ Tileflow keeps these levels separate:
76
+
77
+ - `basemap: osm()` chooses the source defaults, glyphs, sprites, and OSM Bright layer template.
78
+ - `theme.colors` contains human-scale base tokens such as `water`, `park`, `road`, `roadMajor`, `roadCasing`, `text`, and `textHalo`.
79
+ - `theme.modules.<name>` contains advanced, module-specific tokens. These are granular: setting `theme.modules.roads.rail` does not recolor primary roads.
80
+ - `maps.<name>.icons` can point at a reusable root icon set, a hosted MapLibre sprite URL, or a local icon folder for Vite/build output.
81
+ - `maps.<name>.modules` enables semantic behavior such as `labels()`, `poi()`, and `roads()`. Road colors remain in `theme.modules.roads`; `roads()` controls detail, hierarchy, weight, casing, and optional transport extras.
82
+ - `maps.<name>.renderer` can be `auto`, `osm-bright`, or `generated`. `auto` preserves the default template when compatible; `generated` always uses Tileflow's generated layers; `osm-bright` throws if the map config cannot be rendered with the template.
83
+ - `layers` is the raw MapLibre escape hatch for exact layer patches.
84
+
85
+ Missing colors preserve the basemap default. Legacy aliases such as `accent`, `canvas`, `greenspace`, `fontFamily`, and `fonts` are accepted for compatibility but are not the recommended API.
86
+
87
+ ## Roads module
88
+
89
+ Use a preset for the overall road-network intent, then override only the behavior you need:
90
+
91
+ ```ts
92
+ roads({
93
+ preset: 'navigation',
94
+ detail: 'streets',
95
+ hierarchy: 'strong',
96
+ weight: 'regular',
97
+ casing: 'strong',
98
+ extras: {
99
+ paths: false,
100
+ rail: false,
101
+ ferry: false,
102
+ },
103
+ });
104
+ ```
105
+
106
+ | Preset | Detail | Hierarchy | Weight | Casing | Extras |
107
+ | ------------ | --------- | --------- | --------- | -------- | ------- |
108
+ | `minimal` | `streets` | `subtle` | `thin` | `subtle` | all off |
109
+ | `standard` | `streets` | `clear` | `regular` | `subtle` | all on |
110
+ | `navigation` | `streets` | `strong` | `regular` | `strong` | all off |
111
+ | `detailed` | `all` | `clear` | `regular` | `strong` | all on |
112
+
113
+ `detail` accepts `none`, `major`, `streets`, or `all`; `hierarchy` accepts `subtle`, `clear`, or `strong`; `weight` accepts `thin`, `regular`, or `bold`; and `casing` accepts `none`, `subtle`, or `strong`. Explicit options override their preset. `extras.paths`, `extras.rail`, and `extras.ferry` are independent.
114
+
115
+ Colors never belong in `roads()`. Put common colors in `theme.colors` and granular road colors in `theme.modules.roads`. Road-label density remains a `labels({roads: ...})` concern.
116
+
117
+ ## Public API
118
+
119
+ Use the package root only:
120
+
121
+ ```ts
122
+ import {
123
+ createStyle,
124
+ defineTileflow,
125
+ labels,
126
+ osm,
127
+ poi,
128
+ roads,
129
+ styleOverride,
130
+ validateConfig,
131
+ } from '@tileflow/core';
132
+ ```
133
+
134
+ Subpaths under `src/`, `themes/`, `templates/`, and `modules/` are internal implementation details and can change during alpha releases.
135
+
25
136
  Docs: https://tileflow.dev/docs