@tileflow/core 0.1.0-alpha.2 → 0.1.0-alpha.21

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,223 @@
1
+ import { z } from 'zod';
2
+ import { T as TileflowViewConfig, M as MapLibreStyle } from './types-DlUGI6LC.js';
3
+
4
+ /** The first and only public multi-theme runtime manifest contract. */
5
+ declare const tileflowRuntimeManifestVersion: 1;
6
+ declare const tileflowRuntimeManifestLimits: Readonly<{
7
+ maximumBytes: number;
8
+ }>;
9
+ type TileflowRuntimeColorScheme = 'dark' | 'light';
10
+ type TileflowRuntimeManifestTheme = {
11
+ colorScheme: TileflowRuntimeColorScheme;
12
+ /** Complete font closure for this compiled theme. */
13
+ fontFaces?: TileflowStyleFontFace[];
14
+ /** Content or deployment revision used for cache identity and receipts. */
15
+ revision?: string;
16
+ /** Hosted style identity, when different from the logical map identity. */
17
+ styleId?: string;
18
+ styleUrl: string;
19
+ };
20
+ type TileflowRuntimeSystemThemes = {
21
+ dark: string;
22
+ light: string;
23
+ };
24
+ type TileflowRuntimeManifestMapEntry = {
25
+ apiUrl?: string;
26
+ defaultTheme: string;
27
+ environment?: string;
28
+ mapId?: string;
29
+ systemThemes?: TileflowRuntimeSystemThemes;
30
+ themes: Record<string, TileflowRuntimeManifestTheme>;
31
+ usageMode?: 'session';
32
+ view?: TileflowViewConfig;
33
+ worldGeneration?: 'v1';
34
+ };
35
+ /**
36
+ * One logical map catalog for local and Hosted delivery.
37
+ *
38
+ * Delivery-specific fields are optional metadata on a map. The wire shape never forks into
39
+ * self-hosted and Hosted variants, so every runtime follows the same theme resolution path.
40
+ */
41
+ type TileflowRuntimeManifest = {
42
+ apiUrl?: string;
43
+ maps: Record<string, TileflowRuntimeManifestMapEntry>;
44
+ version: typeof tileflowRuntimeManifestVersion;
45
+ };
46
+ declare const tileflowRuntimeManifestSchema: z.ZodType<TileflowRuntimeManifest>;
47
+ declare function parseTileflowRuntimeManifest(input: unknown): TileflowRuntimeManifest;
48
+ declare function safeParseTileflowRuntimeManifest(input: unknown): z.ZodSafeParseResult<TileflowRuntimeManifest>;
49
+
50
+ declare const defaultTileflowManifestUrl = "/tileflow/manifest.json";
51
+ declare const defaultTileflowRuntimeView: Readonly<{
52
+ bearing: 0;
53
+ center: readonly [number, number];
54
+ pitch: 0;
55
+ zoom: 2;
56
+ }>;
57
+ type TileflowAnalytics = {
58
+ apiUrl?: string;
59
+ endpoint?: string;
60
+ enabled?: boolean;
61
+ mapId?: string;
62
+ metadata?: Record<string, unknown>;
63
+ projectId?: string;
64
+ sdkVersion?: string;
65
+ source?: string;
66
+ styleId?: string;
67
+ };
68
+ type TileflowSessionGrantResponse = {
69
+ billingEnabled?: false;
70
+ disposition?: 'ordinary' | 'unbilled_fail_open';
71
+ expiresAt?: string;
72
+ grant?: string;
73
+ meterMode?: 'disabled' | 'shadow' | 'enforced';
74
+ ok: boolean;
75
+ resourceOrigins?: string[];
76
+ sessionId: string;
77
+ usageMode?: 'session';
78
+ code?: string;
79
+ retryWithNewSession?: boolean;
80
+ };
81
+ type TileflowSessionController = {
82
+ readonly sessionId: string;
83
+ resolveRequestUrl(url: string, analytics: TileflowAnalytics | undefined): Promise<string | undefined>;
84
+ };
85
+ type TileflowMapMarker = {
86
+ id: string;
87
+ coordinates: [number, number];
88
+ color?: string;
89
+ label?: string;
90
+ };
91
+ type TileflowMapMode = 'interactive' | 'image';
92
+ type TileflowMapModeOptions = {
93
+ mode?: TileflowMapMode;
94
+ };
95
+ /** Runtime-ready logical map with all relative theme resources already resolved. */
96
+ type TileflowRuntimeManifestMap = TileflowRuntimeManifestMapEntry & {
97
+ apiUrl?: string;
98
+ name: string;
99
+ };
100
+ /** `system` is a selector and therefore reserved as a published theme name. */
101
+ type TileflowThemeSelection = string | 'system';
102
+ type TileflowResolvedRuntimeTheme = TileflowRuntimeManifestTheme & {
103
+ name: string;
104
+ };
105
+ type TileflowRuntimeStyle = {
106
+ analytics?: TileflowAnalytics;
107
+ colorScheme?: TileflowRuntimeColorScheme;
108
+ /** An explicit empty array means the manifest declares that no web fonts are required. */
109
+ fontFaces?: TileflowStyleFontFace[];
110
+ revision?: string;
111
+ style: MapLibreStyle | string;
112
+ theme?: string;
113
+ };
114
+ declare const tileflowStyleFontFacesMetadataKey: "tileflow:fontFaces";
115
+ declare const tileflowStyleFontFaceLimits: Readonly<{
116
+ maximumCount: 16;
117
+ maximumSourceLength: 2048;
118
+ }>;
119
+ type TileflowStyleFontFace = {
120
+ family: string;
121
+ source: string;
122
+ style?: 'italic' | 'normal' | 'oblique';
123
+ weight?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
124
+ };
125
+ /** Browser input is either one published Tileflow map or one direct MapLibre style. */
126
+ type TileflowRuntimeSource = {
127
+ kind: 'tileflow';
128
+ manifestUrl?: string;
129
+ map: string;
130
+ } | {
131
+ kind: 'maplibre';
132
+ style: MapLibreStyle | string;
133
+ };
134
+ type TileflowRuntimeStyleOptions = {
135
+ colorScheme?: TileflowRuntimeColorScheme;
136
+ manifestMap?: TileflowRuntimeManifestMap | null;
137
+ source: TileflowRuntimeSource;
138
+ theme?: TileflowThemeSelection;
139
+ };
140
+ type TileflowRuntimeSourceValidation = {
141
+ ok: true;
142
+ } | {
143
+ code: 'invalid-source' | 'missing-source';
144
+ error: string;
145
+ ok: false;
146
+ };
147
+ type TileflowManifestLoadOptions = {
148
+ source: TileflowRuntimeSource;
149
+ };
150
+ type TileflowManifestFetchOptions = {
151
+ /** Successful manifests are shared for this duration. Set to 0 to bypass the cache. */
152
+ cacheTtlMs?: number;
153
+ fetch?: typeof globalThis.fetch;
154
+ signal?: AbortSignal;
155
+ /** Hard request timeout in milliseconds. Defaults to 10 seconds and is capped at 60 seconds. */
156
+ timeoutMs?: number;
157
+ };
158
+ type TileflowRuntimeViewOptions = TileflowViewConfig & {
159
+ fallback?: TileflowViewConfig;
160
+ manifestMap?: TileflowRuntimeManifestMap | null;
161
+ };
162
+ type TileflowRuntimeCenterLike = readonly [number, number] | {
163
+ lat: number;
164
+ lng: number;
165
+ } | {
166
+ lat: number;
167
+ lon: number;
168
+ };
169
+ declare function shouldLoadTileflowManifest(options: TileflowManifestLoadOptions): boolean;
170
+ declare function validateTileflowRuntimeSource(source: unknown): TileflowRuntimeSourceValidation;
171
+ /** Validate the only runtime selection grammar: one concrete portable name or `system`. */
172
+ declare function validateTileflowThemeSelection(value: unknown): value is TileflowThemeSelection;
173
+ declare function assertValidTileflowRuntimeSource(source: unknown): asserts source is TileflowRuntimeSource;
174
+ declare function resolveTileflowRuntimeStyle(options: TileflowRuntimeStyleOptions): TileflowRuntimeStyle | null;
175
+ /** Resolve one concrete published theme without consulting ambient browser state. */
176
+ declare function resolveTileflowRuntimeTheme(map: TileflowRuntimeManifestMap, selection: TileflowThemeSelection | undefined, colorScheme?: TileflowRuntimeColorScheme): TileflowResolvedRuntimeTheme;
177
+ /** Strictly reads Tileflow-owned web-font metadata from a compiled MapLibre style. */
178
+ declare function getTileflowStyleFontFaces(style: Pick<MapLibreStyle, 'metadata'>): TileflowStyleFontFace[];
179
+ declare function normalizeTileflowUrl(value: string): string;
180
+ declare function createTileflowSessionId(): string;
181
+ declare function createTileflowSessionController(input: {
182
+ fetch?: typeof fetch;
183
+ grantTimeoutMs?: number;
184
+ now?: () => Date;
185
+ sessionIdFactory?: () => string;
186
+ source: string;
187
+ }): TileflowSessionController;
188
+ declare function resolveTileflowAnalyticsRequestUrl(url: string, analytics: TileflowAnalytics | undefined, sessionId: string): string | undefined;
189
+ declare function startTileflowSession(analytics: TileflowAnalytics | undefined, input: {
190
+ mapId?: string;
191
+ sessionId: string;
192
+ source: string;
193
+ styleId?: string;
194
+ }): void;
195
+ declare function getTileflowAnalyticsApiUrl(analytics: TileflowAnalytics): string;
196
+ declare function mergeTileflowAnalytics(userAnalytics: TileflowAnalytics | undefined, runtimeAnalytics: TileflowAnalytics | undefined): TileflowAnalytics | undefined;
197
+ declare function resolveTileflowMapMode(options: TileflowMapModeOptions): TileflowMapMode;
198
+ declare function resolveTileflowRuntimeView(options: TileflowRuntimeViewOptions): TileflowViewConfig;
199
+ declare function normalizeTileflowRuntimeCenter(center: TileflowRuntimeCenterLike | undefined, fallback?: readonly [number, number]): [number, number];
200
+ declare function loadTileflowManifest(url: string, options?: TileflowManifestFetchOptions): Promise<TileflowRuntimeManifest | null>;
201
+ declare function clearTileflowManifestCache(url?: string): void;
202
+ declare function resolveTileflowManifestMap(manifest: TileflowRuntimeManifest, mapName: string): TileflowRuntimeManifestMap | null;
203
+ declare function resolveTileflowStaticImageUrl(input: {
204
+ center: [number, number];
205
+ colorScheme?: TileflowRuntimeColorScheme;
206
+ imageSize: {
207
+ height: number;
208
+ width: number;
209
+ } | null;
210
+ manifestMap: TileflowRuntimeManifestMap | null;
211
+ theme?: TileflowThemeSelection;
212
+ zoom: number;
213
+ }): string | undefined;
214
+ declare function normalizeTileflowStaticImageSize(input: {
215
+ height: number;
216
+ width: number;
217
+ }): {
218
+ height: number;
219
+ width: number;
220
+ };
221
+ declare function inferTileflowAnalyticsFromStyleUrl(styleUrl: string): TileflowAnalytics | undefined;
222
+
223
+ export { validateTileflowRuntimeSource as $, defaultTileflowManifestUrl as A, defaultTileflowRuntimeView as B, getTileflowAnalyticsApiUrl as C, getTileflowStyleFontFaces as D, inferTileflowAnalyticsFromStyleUrl as E, loadTileflowManifest as F, mergeTileflowAnalytics as G, normalizeTileflowRuntimeCenter as H, normalizeTileflowStaticImageSize as I, normalizeTileflowUrl as J, parseTileflowRuntimeManifest as K, resolveTileflowAnalyticsRequestUrl as L, resolveTileflowManifestMap as M, resolveTileflowMapMode as N, resolveTileflowRuntimeStyle as O, resolveTileflowRuntimeTheme as P, resolveTileflowRuntimeView as Q, resolveTileflowStaticImageUrl as R, safeParseTileflowRuntimeManifest as S, type TileflowAnalytics as T, shouldLoadTileflowManifest as U, startTileflowSession as V, tileflowRuntimeManifestLimits as W, tileflowRuntimeManifestSchema as X, tileflowRuntimeManifestVersion as Y, tileflowStyleFontFaceLimits as Z, tileflowStyleFontFacesMetadataKey as _, type TileflowStyleFontFace as a, validateTileflowThemeSelection as a0, type TileflowRuntimeStyle as b, type TileflowSessionController as c, type TileflowRuntimeColorScheme as d, type TileflowRuntimeManifest as e, type TileflowManifestFetchOptions as f, type TileflowManifestLoadOptions as g, type TileflowMapMarker as h, type TileflowMapMode as i, type TileflowMapModeOptions as j, type TileflowResolvedRuntimeTheme as k, type TileflowRuntimeCenterLike as l, type TileflowRuntimeManifestMap as m, type TileflowRuntimeManifestMapEntry as n, type TileflowRuntimeManifestTheme as o, type TileflowRuntimeSource as p, type TileflowRuntimeSourceValidation as q, type TileflowRuntimeStyleOptions as r, type TileflowRuntimeSystemThemes as s, type TileflowRuntimeViewOptions as t, type TileflowSessionGrantResponse as u, type TileflowThemeSelection as v, assertValidTileflowRuntimeSource as w, clearTileflowManifestCache as x, createTileflowSessionController as y, createTileflowSessionId as z };
@@ -0,0 +1,3 @@
1
+ export { T as TileflowAnalytics, f as TileflowManifestFetchOptions, g as TileflowManifestLoadOptions, h as TileflowMapMarker, i as TileflowMapMode, j as TileflowMapModeOptions, k as TileflowResolvedRuntimeTheme, l as TileflowRuntimeCenterLike, d as TileflowRuntimeColorScheme, e as TileflowRuntimeManifest, m as TileflowRuntimeManifestMap, n as TileflowRuntimeManifestMapEntry, o as TileflowRuntimeManifestTheme, p as TileflowRuntimeSource, q as TileflowRuntimeSourceValidation, b as TileflowRuntimeStyle, r as TileflowRuntimeStyleOptions, s as TileflowRuntimeSystemThemes, t as TileflowRuntimeViewOptions, c as TileflowSessionController, u as TileflowSessionGrantResponse, a as TileflowStyleFontFace, v as TileflowThemeSelection, w as assertValidTileflowRuntimeSource, x as clearTileflowManifestCache, y as createTileflowSessionController, z as createTileflowSessionId, A as defaultTileflowManifestUrl, B as defaultTileflowRuntimeView, C as getTileflowAnalyticsApiUrl, D as getTileflowStyleFontFaces, E as inferTileflowAnalyticsFromStyleUrl, F as loadTileflowManifest, G as mergeTileflowAnalytics, H as normalizeTileflowRuntimeCenter, I as normalizeTileflowStaticImageSize, J as normalizeTileflowUrl, L as resolveTileflowAnalyticsRequestUrl, M as resolveTileflowManifestMap, N as resolveTileflowMapMode, O as resolveTileflowRuntimeStyle, P as resolveTileflowRuntimeTheme, Q as resolveTileflowRuntimeView, R as resolveTileflowStaticImageUrl, U as shouldLoadTileflowManifest, V as startTileflowSession, Z as tileflowStyleFontFaceLimits, _ as tileflowStyleFontFacesMetadataKey, $ as validateTileflowRuntimeSource, a0 as validateTileflowThemeSelection } from './runtime-C4MtSzkB.js';
2
+ import './types-DlUGI6LC.js';
3
+ import 'zod';