@tileflow/core 0.1.0-alpha.3 → 0.1.0-alpha.4
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 +11 -5
- package/dist/index.js +24 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ type TileflowTheme = 'standard' | 'light' | 'dark' | 'minimal' | 'osm-bright-2';
|
|
|
6
6
|
type TileflowBuildings = 'hidden' | 'flat' | '3d';
|
|
7
7
|
type TileflowTerrainMode = 'none' | 'hillshade' | '3d';
|
|
8
8
|
type TileflowTerrainEncoding = 'mapbox' | 'terrarium';
|
|
9
|
-
type
|
|
9
|
+
type TileflowThemeName = 'light' | 'dark';
|
|
10
|
+
type TileflowThemeMode = TileflowThemeName;
|
|
10
11
|
type TileflowColors = {
|
|
11
12
|
canvas: string;
|
|
12
13
|
land: string;
|
|
@@ -28,9 +29,13 @@ type TileflowTypography = {
|
|
|
28
29
|
font?: string;
|
|
29
30
|
weight?: TileflowFontWeight;
|
|
30
31
|
};
|
|
32
|
+
type TileflowFonts = {
|
|
33
|
+
body?: string;
|
|
34
|
+
labels?: string;
|
|
35
|
+
};
|
|
31
36
|
type TileflowThemeConfig = {
|
|
32
|
-
mode?: TileflowThemeMode;
|
|
33
37
|
colors?: TileflowColorConfig;
|
|
38
|
+
fonts?: TileflowFonts;
|
|
34
39
|
typography?: TileflowTypography;
|
|
35
40
|
};
|
|
36
41
|
type TileflowSourceLayers = {
|
|
@@ -118,13 +123,14 @@ type TileflowTilesetConfig = {
|
|
|
118
123
|
attribution?: string;
|
|
119
124
|
sourceLayers?: TileflowSourceLayers;
|
|
120
125
|
};
|
|
126
|
+
type TileflowProjectThemes = Partial<Record<TileflowThemeName, TileflowThemeConfig>>;
|
|
121
127
|
type TileflowProjectConfig = {
|
|
122
|
-
themes?:
|
|
128
|
+
themes?: TileflowProjectThemes;
|
|
123
129
|
tilesets?: Record<string, TileflowTilesetConfig>;
|
|
124
130
|
maps: Record<string, TileflowMapConfig>;
|
|
125
131
|
};
|
|
126
132
|
type TileflowStyleOptions = {
|
|
127
|
-
themes?:
|
|
133
|
+
themes?: TileflowProjectThemes;
|
|
128
134
|
tileBaseUrl?: string;
|
|
129
135
|
tileset?: string;
|
|
130
136
|
};
|
|
@@ -169,4 +175,4 @@ declare function osm(options?: TileflowOsmBasemapOptions): TileflowOsmBasemapCon
|
|
|
169
175
|
|
|
170
176
|
declare function roads(options?: TileflowRoadsModuleOptions): TileflowRoadsModuleConfig;
|
|
171
177
|
|
|
172
|
-
export { type MapLibreStyle, type TileflowBasemapConfig, type TileflowBuildings, type TileflowColorConfig, type TileflowColors, type TileflowConfig, type TileflowDensity, type TileflowFontWeight, type TileflowLabels, type TileflowManifest, type TileflowMapConfig, type TileflowModuleConfig, type TileflowOsmBasemapConfig, type TileflowOsmBasemapOptions, type TileflowPoi, type TileflowProjectConfig, type TileflowRoads, type TileflowRoadsModuleConfig, type TileflowRoadsModuleOptions, type TileflowRoadsModulePreset, type TileflowSourceLayers, type TileflowStyleOptions, type TileflowTerrain, type TileflowTerrainConfig, type TileflowTerrainEncoding, type TileflowTerrainMode, type TileflowTheme, type TileflowThemeConfig, type TileflowThemeMode, type TileflowTiles, type TileflowTilesetConfig, type TileflowTypography, type TileflowViewConfig, type ValidationMessage, type ValidationResult, createManifest, createStyle, createStyleFromProject, defineTileflow, getDefaultColors, osm, roads, validateConfig };
|
|
178
|
+
export { type MapLibreStyle, type TileflowBasemapConfig, type TileflowBuildings, type TileflowColorConfig, type TileflowColors, type TileflowConfig, type TileflowDensity, type TileflowFontWeight, type TileflowFonts, type TileflowLabels, type TileflowManifest, type TileflowMapConfig, type TileflowModuleConfig, type TileflowOsmBasemapConfig, type TileflowOsmBasemapOptions, type TileflowPoi, type TileflowProjectConfig, type TileflowProjectThemes, type TileflowRoads, type TileflowRoadsModuleConfig, type TileflowRoadsModuleOptions, type TileflowRoadsModulePreset, type TileflowSourceLayers, type TileflowStyleOptions, type TileflowTerrain, type TileflowTerrainConfig, type TileflowTerrainEncoding, type TileflowTerrainMode, type TileflowTheme, type TileflowThemeConfig, type TileflowThemeMode, type TileflowThemeName, type TileflowTiles, type TileflowTilesetConfig, type TileflowTypography, type TileflowViewConfig, type ValidationMessage, type ValidationResult, createManifest, createStyle, createStyleFromProject, defineTileflow, getDefaultColors, osm, roads, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -2591,11 +2591,15 @@ var typographySchema = z.object({
|
|
|
2591
2591
|
font: z.string().trim().min(1).optional(),
|
|
2592
2592
|
weight: z.enum(["regular", "medium", "semibold", "bold"]).optional()
|
|
2593
2593
|
});
|
|
2594
|
+
var fontsSchema = z.object({
|
|
2595
|
+
body: z.string().trim().min(1).optional(),
|
|
2596
|
+
labels: z.string().trim().min(1).optional()
|
|
2597
|
+
}).strict();
|
|
2594
2598
|
var themeConfigSchema = z.object({
|
|
2595
|
-
mode: z.enum(["light", "dark"]).optional(),
|
|
2596
2599
|
colors: colorConfigSchema.optional(),
|
|
2600
|
+
fonts: fontsSchema.optional(),
|
|
2597
2601
|
typography: typographySchema.optional()
|
|
2598
|
-
});
|
|
2602
|
+
}).strict();
|
|
2599
2603
|
var sourceLayersSchema = z.object({
|
|
2600
2604
|
landuse: z.string().optional(),
|
|
2601
2605
|
park: z.string().optional(),
|
|
@@ -2673,7 +2677,10 @@ var tilesetConfigSchema = z.object({
|
|
|
2673
2677
|
sourceLayers: sourceLayersSchema.optional()
|
|
2674
2678
|
});
|
|
2675
2679
|
var projectConfigSchema = z.object({
|
|
2676
|
-
themes: z.
|
|
2680
|
+
themes: z.object({
|
|
2681
|
+
light: themeConfigSchema.optional(),
|
|
2682
|
+
dark: themeConfigSchema.optional()
|
|
2683
|
+
}).strict().optional(),
|
|
2677
2684
|
tilesets: z.record(z.string(), tilesetConfigSchema).optional(),
|
|
2678
2685
|
maps: z.record(z.string(), configSchema).refine((maps) => {
|
|
2679
2686
|
return Object.keys(maps).length > 0;
|
|
@@ -3022,7 +3029,7 @@ function resolveTheme(theme, projectThemes) {
|
|
|
3022
3029
|
return resolveLegacyTheme("light");
|
|
3023
3030
|
}
|
|
3024
3031
|
if (typeof theme === "string") {
|
|
3025
|
-
const projectTheme = projectThemes?.[theme];
|
|
3032
|
+
const projectTheme = isProjectThemeName(theme) ? projectThemes?.[theme] : void 0;
|
|
3026
3033
|
if (projectTheme) {
|
|
3027
3034
|
return resolveThemeConfig(theme, projectTheme);
|
|
3028
3035
|
}
|
|
@@ -3046,22 +3053,32 @@ function resolveLegacyTheme(theme) {
|
|
|
3046
3053
|
}
|
|
3047
3054
|
function resolveThemeConfig(name, theme) {
|
|
3048
3055
|
const colors = normalizeColorAliases(theme.colors);
|
|
3049
|
-
const
|
|
3056
|
+
const themeName = isProjectThemeName(name) ? name : "light";
|
|
3057
|
+
const preset = themePresets[themeName];
|
|
3050
3058
|
return {
|
|
3051
3059
|
colors: {
|
|
3052
3060
|
...preset.colors,
|
|
3053
3061
|
...colors
|
|
3054
3062
|
},
|
|
3055
3063
|
custom: true,
|
|
3056
|
-
mode:
|
|
3064
|
+
mode: themeName,
|
|
3057
3065
|
name,
|
|
3058
3066
|
preset,
|
|
3059
|
-
typography: resolveTypography(theme
|
|
3067
|
+
typography: resolveTypography(resolveThemeTypography(theme), defaultTypography)
|
|
3060
3068
|
};
|
|
3061
3069
|
}
|
|
3062
3070
|
function isLegacyTheme(value) {
|
|
3063
3071
|
return value in themePresets;
|
|
3064
3072
|
}
|
|
3073
|
+
function isProjectThemeName(value) {
|
|
3074
|
+
return value === "light" || value === "dark";
|
|
3075
|
+
}
|
|
3076
|
+
function resolveThemeTypography(theme) {
|
|
3077
|
+
return {
|
|
3078
|
+
...theme.typography,
|
|
3079
|
+
font: theme.typography?.font ?? theme.fonts?.labels ?? theme.fonts?.body
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3065
3082
|
function normalizeColorAliases(colors) {
|
|
3066
3083
|
if (!colors) {
|
|
3067
3084
|
return {};
|