@tileflow/core 0.1.0-alpha.4 → 0.1.0-alpha.41

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 (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +318 -26
  3. package/THIRD_PARTY_NOTICES.md +444 -0
  4. package/dist/3d-CzLTD0RK.d.ts +1092 -0
  5. package/dist/3d.d.ts +1 -0
  6. package/dist/3d.js +12660 -0
  7. package/dist/browser.d.ts +2278 -0
  8. package/dist/browser.js +21826 -0
  9. package/dist/build.d.ts +595 -0
  10. package/dist/build.js +29737 -0
  11. package/dist/capture-shot-ChPQvPyi.d.ts +291 -0
  12. package/dist/capture.d.ts +9 -0
  13. package/dist/capture.js +510 -0
  14. package/dist/config-reference.json +40527 -0
  15. package/dist/icon-composition-HUh_Lj8Z.d.ts +2516 -0
  16. package/dist/index.d.ts +1805 -162
  17. package/dist/index.js +26400 -3488
  18. package/dist/manifest-types-DnhSJjCM.d.ts +902 -0
  19. package/dist/manifest.d.ts +9 -0
  20. package/dist/manifest.js +449 -0
  21. package/dist/native-profile.d.ts +206 -0
  22. package/dist/native-profile.js +9339 -0
  23. package/dist/native.d.ts +365 -0
  24. package/dist/native.js +5970 -0
  25. package/dist/runtime.d.ts +1 -0
  26. package/dist/runtime.js +1445 -0
  27. package/dist/worker/camera-tile-worker.global.js +20 -0
  28. package/docs/application-tile-reading.md +86 -0
  29. package/docs/authoring-model.md +269 -0
  30. package/docs/boundary-areas-and-choropleths.md +217 -0
  31. package/docs/buildings-3d.md +608 -0
  32. package/docs/camera-moves-and-tile-cache.md +112 -0
  33. package/docs/capture-scenes.md +40 -0
  34. package/docs/capture-shots.md +173 -0
  35. package/docs/cartographic-defaults.md +210 -0
  36. package/docs/compiled-style-performance.md +286 -0
  37. package/docs/data-is-separate-from-design.md +610 -0
  38. package/docs/depth-markers.md +65 -0
  39. package/docs/dynamic-style-images.md +100 -0
  40. package/docs/globe-atmosphere.md +113 -0
  41. package/docs/hosted-session-authorization.md +106 -0
  42. package/docs/map-and-terrain-examples.md +156 -0
  43. package/docs/map-emphasis.md +89 -0
  44. package/docs/native-artifact-profile.md +152 -0
  45. package/docs/native-resource-urls.md +369 -0
  46. package/docs/nautical-marks.md +308 -0
  47. package/docs/public-api-and-browser-subpath.md +101 -0
  48. package/docs/route-drawing.md +191 -0
  49. package/docs/shared-visual-primitives.md +101 -0
  50. package/docs/street-lights.md +127 -0
  51. package/docs/street-sky.md +156 -0
  52. package/docs/style-states.md +73 -0
  53. package/docs/sun-and-light.md +167 -0
  54. package/docs/theme-transitions-and-blends.md +317 -0
  55. package/docs/themes-and-module-styles.md +156 -0
  56. package/docs/trees-3d.md +295 -0
  57. package/package.json +67 -8
@@ -0,0 +1,365 @@
1
+ /** Artistic presets; selecting one never starts a clock or moves the real sun. */
2
+ declare const tileflowTimesOfDay: readonly ["day", "dawn", "dusk", "night"];
3
+ type TileflowTimeOfDay = (typeof tileflowTimesOfDay)[number];
4
+ /** A named theme family points to complete, already compiled themes. */
5
+ type TileflowTimeOfDayVariants = Readonly<Record<string, Readonly<Partial<Record<TileflowTimeOfDay, string>>>>>;
6
+
7
+ /** URL resolution for native clients, without a renderer or an ambient application origin. */
8
+ declare const tileflowNativeUrlLimits: Readonly<{
9
+ maximumLength: 2048;
10
+ }>;
11
+ type TileflowNativeNetworkOptions = {
12
+ /** An exact HTTP development origin; never inferred from the device or environment. */
13
+ developmentOrigin?: string;
14
+ };
15
+ type TileflowNativeResourceUrlOptions = TileflowNativeNetworkOptions & {
16
+ /** The absolute URL of the document declaring this resource, after any approved redirects. */
17
+ documentUrl: string;
18
+ /** Preserve supported placeholders in the path or query, without expanding them. */
19
+ template?: 'tile' | 'glyphs';
20
+ };
21
+ type TileflowNativeUrlErrorCode = 'NATIVE_URL_INVALID' | 'NATIVE_URL_ABSOLUTE_REQUIRED' | 'NATIVE_URL_HTTPS_REQUIRED' | 'NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID' | 'NATIVE_URL_TEMPLATE_INVALID';
22
+ type TileflowNativeUrlField = 'manifestUrl' | 'documentUrl' | 'resourceUrl' | 'developmentOrigin';
23
+ /** Safe to report without exposing URL credentials, query parameters or filesystem paths. */
24
+ declare class TileflowNativeUrlError extends TypeError {
25
+ readonly code: TileflowNativeUrlErrorCode;
26
+ readonly field: TileflowNativeUrlField;
27
+ constructor(code: TileflowNativeUrlErrorCode, field: TileflowNativeUrlField);
28
+ }
29
+
30
+ /** Resolve an explicit manifest URL with the private WHATWG parser, not the ambient URL. */
31
+ declare function resolveTileflowNativeManifestUrl(value: unknown, options?: TileflowNativeNetworkOptions): string;
32
+ /** Resolve a resource against its owner without fetching it or authorizing requests. */
33
+ declare function resolveTileflowNativeResourceUrl(value: unknown, options: TileflowNativeResourceUrlOptions): string;
34
+
35
+ type TileflowColor = `#${string}`;
36
+ type TileflowViewConfig = {
37
+ bearing?: number;
38
+ center?: readonly [number, number];
39
+ pitch?: number;
40
+ zoom?: number;
41
+ };
42
+ type MapLibreSprite = string | Array<{
43
+ id: string;
44
+ url: string;
45
+ }>;
46
+ type TileflowProjection = 'globe' | 'mercator';
47
+ type TileflowLight = {
48
+ anchor?: 'map' | 'viewport';
49
+ color?: TileflowColor;
50
+ intensity?: number;
51
+ position?: readonly [number, number, number];
52
+ };
53
+ type MapLibreStyle = {
54
+ sky?: Record<string, unknown>;
55
+ version: 8;
56
+ name: string;
57
+ glyphs?: string;
58
+ light?: TileflowLight;
59
+ projection?: {
60
+ type: TileflowProjection;
61
+ };
62
+ sprite?: MapLibreSprite;
63
+ sources: Record<string, Record<string, unknown>>;
64
+ layers: Array<Record<string, unknown>>;
65
+ terrain?: Record<string, unknown>;
66
+ metadata?: Record<string, unknown>;
67
+ };
68
+
69
+ /** Runtime-ready logical map with all relative theme resources already resolved. */
70
+ type TileflowRuntimeManifestMap = TileflowRuntimeManifestMapEntry & {
71
+ apiUrl?: string;
72
+ name: string;
73
+ };
74
+ type TileflowResolvedRuntimeTheme = TileflowRuntimeManifestTheme & {
75
+ name: string;
76
+ };
77
+ type TileflowStyleFontFace = {
78
+ family: string;
79
+ source: string;
80
+ style?: 'italic' | 'normal' | 'oblique';
81
+ weight?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
82
+ };
83
+ /**
84
+ * A continuous blend of named themes of one Tileflow map. `position` places the map between
85
+ * neighbouring themes: 0 is the first, 1 the second, and 1.25 a quarter of the way from the second
86
+ * to the third.
87
+ */
88
+ type TileflowThemeBlendSelection = Readonly<{
89
+ /** From 0 to `themes.length - 1`. */
90
+ position: number;
91
+ /** Two to eight concrete theme names of the map, in blend order. */
92
+ themes: readonly string[];
93
+ }>;
94
+ declare const tileflowThemeBlendLimits: Readonly<{
95
+ maximumThemes: 8;
96
+ minimumThemes: 2;
97
+ }>;
98
+ declare function validateTileflowThemeBlendSelection(value: unknown): value is TileflowThemeBlendSelection;
99
+ /** The theme nearest to a blend position, which a blend shows when it cannot blend. */
100
+ declare function nearestTileflowBlendTheme(blend: TileflowThemeBlendSelection): string;
101
+
102
+ /** The original public multi-theme runtime manifest contract. */
103
+ declare const tileflowRuntimeManifestVersion: 1;
104
+ /** V2 adds the optional time-of-day catalog; maps without it still publish V1. */
105
+ declare const tileflowTimeOfDayManifestVersion: 2;
106
+ type TileflowRuntimeColorScheme = 'dark' | 'light';
107
+ type TileflowRuntimeManifestTheme = {
108
+ colorScheme: TileflowRuntimeColorScheme;
109
+ /** Complete font closure for this compiled theme. */
110
+ fontFaces?: TileflowStyleFontFace[];
111
+ /** Content or deployment revision used for cache identity and receipts. */
112
+ revision?: string;
113
+ /** Hosted style identity, when different from the logical map identity. */
114
+ styleId?: string;
115
+ styleUrl: string;
116
+ };
117
+ type TileflowRuntimeSystemThemes = {
118
+ dark: string;
119
+ light: string;
120
+ };
121
+ type TileflowRuntimeManifestMapEntry = {
122
+ apiUrl?: string;
123
+ defaultTheme: string;
124
+ environment?: string;
125
+ mapId?: string;
126
+ systemThemes?: TileflowRuntimeSystemThemes;
127
+ themes: Record<string, TileflowRuntimeManifestTheme>;
128
+ timeOfDay?: TileflowTimeOfDayVariants;
129
+ usageMode?: 'session';
130
+ view?: TileflowViewConfig;
131
+ worldGeneration?: 'v1';
132
+ };
133
+ /**
134
+ * One logical map catalog for local and Hosted delivery.
135
+ *
136
+ * Delivery-specific fields are optional metadata on a map. The wire shape never forks into
137
+ * self-hosted and Hosted variants, so every runtime follows the same theme resolution path.
138
+ */
139
+ type TileflowRuntimeManifest = {
140
+ apiUrl?: string;
141
+ maps: Record<string, TileflowRuntimeManifestMapEntry>;
142
+ version: typeof tileflowRuntimeManifestVersion | typeof tileflowTimeOfDayManifestVersion;
143
+ };
144
+
145
+ /** The adapter must honor the requested read bound, without first buffering an unbounded body. */
146
+ type TileflowNativeManifestReader = {
147
+ read(maximumBytes: number): Promise<{
148
+ done: true;
149
+ value?: undefined;
150
+ } | {
151
+ done: false;
152
+ value: Uint8Array;
153
+ }>;
154
+ cancel(): void | Promise<void>;
155
+ };
156
+ type TileflowNativeManifestResponse = {
157
+ /** Absolute final URL after redirects approved by the acquisition adapter. */
158
+ url: string;
159
+ status: number;
160
+ reader: TileflowNativeManifestReader;
161
+ };
162
+ /** Cancellation must be available immediately, including before response headers arrive. */
163
+ type TileflowNativeManifestOperation = {
164
+ response: Promise<TileflowNativeManifestResponse>;
165
+ cancel(): void | Promise<void>;
166
+ };
167
+ type TileflowNativeManifestAcquire = (url: string, options: Readonly<{
168
+ maximumBytes: number;
169
+ }>) => TileflowNativeManifestOperation;
170
+ /** No AbortController/EventTarget construction or reason inspection is required by Core. */
171
+ type TileflowNativeAbortSignal = {
172
+ readonly aborted: boolean;
173
+ addEventListener(type: 'abort', listener: () => void, options?: {
174
+ once?: boolean;
175
+ }): void;
176
+ removeEventListener(type: 'abort', listener: () => void): void;
177
+ };
178
+ type TileflowNativeManifestLoadOptions = TileflowNativeNetworkOptions & {
179
+ acquire: TileflowNativeManifestAcquire;
180
+ signal?: TileflowNativeAbortSignal;
181
+ };
182
+ /** A published Tileflow map with an explicit manifest URL. Does not create a renderer. */
183
+ type TileflowNativeSource = {
184
+ map: string;
185
+ manifestUrl: string;
186
+ /** Exact HTTP origin permitted by this development source. HTTPS remains allowed. */
187
+ developmentOrigin?: string;
188
+ };
189
+ type TileflowNativeSourceOptions = {
190
+ theme?: string;
191
+ timeOfDay?: TileflowTimeOfDay;
192
+ /** Required only for theme="system"; no ambient appearance access. */
193
+ colorScheme?: TileflowRuntimeColorScheme;
194
+ signal?: TileflowNativeAbortSignal;
195
+ };
196
+ type Immutable<T> = T extends object ? {
197
+ readonly [K in keyof T]: Immutable<T[K]>;
198
+ } : T;
199
+ type TileflowNativeManifestResult = {
200
+ readonly manifestUrl: string;
201
+ readonly manifest: Immutable<TileflowRuntimeManifest>;
202
+ };
203
+ type TileflowNativeSourceState = {
204
+ readonly status: 'loading';
205
+ readonly generation: number;
206
+ } | ({
207
+ readonly status: 'ready';
208
+ readonly generation: number;
209
+ readonly source: Readonly<TileflowNativeSource>;
210
+ readonly map: Immutable<TileflowRuntimeManifestMap>;
211
+ readonly theme: Immutable<TileflowResolvedRuntimeTheme>;
212
+ } & TileflowNativeManifestResult) | {
213
+ readonly status: 'error';
214
+ readonly generation: number;
215
+ readonly error: TileflowNativeSourceError;
216
+ };
217
+ type TileflowNativeSourceController = {
218
+ /** Undefined until the first replacement. Disposed controllers retain their last snapshot. */
219
+ readonly state: TileflowNativeSourceState | undefined;
220
+ replace(source: TileflowNativeSource, options?: TileflowNativeSourceOptions): Promise<void>;
221
+ subscribe(listener: (state: TileflowNativeSourceState) => void): () => void;
222
+ dispose(): void;
223
+ };
224
+ declare const messages: {
225
+ readonly NATIVE_SOURCE_INVALID: "Expected a valid native source or renderer-neutral view.";
226
+ readonly NATIVE_SOURCE_ABORTED: "The source operation was cancelled.";
227
+ readonly NATIVE_SOURCE_DISPOSED: "The source controller has been disposed.";
228
+ readonly NATIVE_MANIFEST_URL_INVALID: "Expected a safe absolute manifest URL and an exact development origin.";
229
+ readonly NATIVE_MANIFEST_REQUEST_FAILED: "Manifest acquisition failed.";
230
+ readonly NATIVE_MANIFEST_RESPONSE_INVALID: "Expected a bounded byte reader and an explicit final response URL.";
231
+ readonly NATIVE_MANIFEST_ACCESS_DENIED: "Manifest access was denied.";
232
+ readonly NATIVE_MANIFEST_NOT_FOUND: "The manifest was not found.";
233
+ readonly NATIVE_MANIFEST_TOO_LARGE: "The manifest exceeds the 1 MiB limit.";
234
+ readonly NATIVE_MANIFEST_UTF8_INVALID: "The manifest body is not valid UTF-8.";
235
+ readonly NATIVE_MANIFEST_JSON_INVALID: "The manifest body is not valid JSON.";
236
+ readonly NATIVE_MANIFEST_INVALID: "The manifest does not satisfy the version-1 runtime contract.";
237
+ readonly NATIVE_MANIFEST_RESOURCE_INVALID: "A manifest resource URL is outside the native URL policy.";
238
+ readonly NATIVE_MAP_NOT_FOUND: "The requested map is not declared by the manifest.";
239
+ readonly NATIVE_THEME_INVALID: "Expected a declared concrete theme or an explicitly supplied system color scheme.";
240
+ };
241
+ type TileflowNativeSourceErrorCode = keyof typeof messages;
242
+ type TileflowNativeSourceErrorField = 'source' | 'signal' | 'manifestUrl' | 'response' | 'body' | 'map' | 'theme' | 'view';
243
+ /** Contains no body, URL, remote cause, parser details, or AbortSignal.reason. */
244
+ declare class TileflowNativeSourceError extends Error {
245
+ readonly code: TileflowNativeSourceErrorCode;
246
+ readonly field: TileflowNativeSourceErrorField;
247
+ readonly kind: 'terminal' | 'cancelled';
248
+ constructor(code: TileflowNativeSourceErrorCode, field: TileflowNativeSourceErrorField);
249
+ }
250
+
251
+ declare const tileflowNativeManifestLimits: Readonly<{
252
+ maximumBytes: number;
253
+ maximumChunkBytes: number;
254
+ maximumDepth: 64;
255
+ }>;
256
+ /** Acquire only the manifest. There is no default network client, cache, retry or session. */
257
+ declare function loadTileflowNativeManifest(manifestUrl: string, options: TileflowNativeManifestLoadOptions): Promise<TileflowNativeManifestResult>;
258
+
259
+ /** A renderer-neutral lifecycle for an explicitly located Tileflow manifest. */
260
+ declare function createTileflowNativeSourceController(options: {
261
+ acquire: TileflowNativeManifestAcquire;
262
+ }): TileflowNativeSourceController;
263
+
264
+ type TileflowNativeInitialView = Readonly<Required<TileflowViewConfig>>;
265
+ /** Inputs are views, not renderer props. Validate all supplied levels before applying precedence. */
266
+ type TileflowNativeInitialViewOptions = {
267
+ /** Highest precedence, supplied explicitly by the application. */
268
+ view?: TileflowViewConfig;
269
+ /** View values extracted by an adapter from its renderer options. */
270
+ mapOptionsView?: TileflowViewConfig;
271
+ /** The selected manifest map's view, when present. */
272
+ manifestView?: TileflowViewConfig;
273
+ };
274
+ /** Resolve once or repeatedly without changing source generations, themes or acquisition. */
275
+ declare function resolveTileflowNativeInitialView(options?: TileflowNativeInitialViewOptions): TileflowNativeInitialView;
276
+
277
+ /**
278
+ * Theme blending plans one MapLibre style that can show any point between the themes of one map.
279
+ *
280
+ * The themes of a Tileflow map compile to the same sources, layers, filters, and expressions; they
281
+ * differ only in token values: colours, numbers, and image names. A plan keeps the first theme's
282
+ * structure and records every value that differs as a template the browser fills in for a blend
283
+ * position: 0 is the first theme, 1 the second, and 1.25 a quarter of the way from the second to
284
+ * the third. Filling a template needs no expression parsing in the browser, so the renderer only
285
+ * receives plain values.
286
+ *
287
+ * Values that MapLibre evaluates per feature (data-driven values, such as a fill colour chosen by
288
+ * land-use class) are baked into tiles, and changing them re-lays the whole source out. A plan
289
+ * splits such a layer into one layer per branch that a feature can take through the value's
290
+ * decisions on feature data, each filtered to the features that take it, so each value depends
291
+ * only on zoom and the blend position. A value that reads feature data continuously is drawn once
292
+ * per theme instead, and the copies cross-fade by opacity. Images are mixed in their pixels.
293
+ * Values that read feature state cannot be split, because filters cannot read state; they switch
294
+ * when the dominant theme changes.
295
+ */
296
+ /** A paint value that the browser sets as the blend moves. */
297
+ type TileflowThemeBlendPaint = Readonly<{
298
+ layer: string;
299
+ property: string;
300
+ template: unknown;
301
+ /** Ground values follow the blend position; symbol values follow the label cross-fade. */
302
+ follows: TileflowThemeBlendClock;
303
+ }>;
304
+ /** Image names whose artwork differs between themes and is mixed in pixels. */
305
+ type TileflowThemeBlendImage = Readonly<{
306
+ names: readonly string[];
307
+ follows: TileflowThemeBlendClock;
308
+ }>;
309
+ /** A value that can only change all at once, when the dominant theme changes. */
310
+ type TileflowThemeBlendSwitch = Readonly<{
311
+ layer: string;
312
+ group: 'layout' | 'paint';
313
+ property: string;
314
+ values: readonly unknown[];
315
+ }>;
316
+ /**
317
+ * `position` values follow the blend; `dominant` values follow a short cross-fade that starts when
318
+ * the nearest theme changes. Labels use it because light lettering on a dark plate and dark
319
+ * lettering on a light plate meet in the same grey halfway.
320
+ */
321
+ type TileflowThemeBlendClock = 'dominant' | 'position';
322
+ type TileflowThemeBlendPlan = Readonly<{
323
+ /** Number of themes; blend positions run from 0 to `themes - 1`. */
324
+ themes: number;
325
+ paints: readonly TileflowThemeBlendPaint[];
326
+ images: readonly TileflowThemeBlendImage[];
327
+ switches: readonly TileflowThemeBlendSwitch[];
328
+ /** Root sky and light, when they differ between themes. */
329
+ sky?: unknown;
330
+ light?: unknown;
331
+ summary: Readonly<{
332
+ splitLayers: number;
333
+ copiedLayers: number;
334
+ /** Per-theme layers of which only the nearest theme's copy is shown. */
335
+ switchedLayers: number;
336
+ switchedValues: number;
337
+ }>;
338
+ /** The style at a blend position: every template filled, every switch at the nearest theme. */
339
+ styleAt(position: number): MapLibreStyle;
340
+ }>;
341
+ type TileflowThemeBlendOptions = Readonly<{
342
+ /**
343
+ * How icon images that differ between themes change. `mix` (the default) mixes their artwork in
344
+ * pixels under the first theme's image names. `switch` changes the image names when the nearest
345
+ * theme changes, for renderers that cannot replace an image's pixels while keeping its stretch
346
+ * and content metadata.
347
+ */
348
+ iconImages?: 'mix' | 'switch';
349
+ /**
350
+ * How values that read feature data change when they can be neither split nor cross-faded.
351
+ * `values` (the default) sets each value when the nearest theme changes. `layers` draws such a
352
+ * layer once per theme and shows only the nearest theme's copy, for renderers that cannot set
353
+ * data-driven values at run time reliably.
354
+ */
355
+ featureSwitches?: 'layers' | 'values';
356
+ }>;
357
+ declare class TileflowThemeBlendError extends Error {
358
+ name: string;
359
+ }
360
+ /** Plans a blend of two or more compiled themes of one map, in blend order. */
361
+ declare function planTileflowThemeBlend(styles: readonly MapLibreStyle[], options?: TileflowThemeBlendOptions): TileflowThemeBlendPlan;
362
+ /** Fills one blend template for a position. Plain values pass through unchanged. */
363
+ declare function fillTileflowThemeBlendTemplate(template: unknown, position: number): unknown;
364
+
365
+ export { type TileflowNativeAbortSignal, type TileflowNativeInitialView, type TileflowNativeInitialViewOptions, type TileflowNativeManifestAcquire, type TileflowNativeManifestLoadOptions, type TileflowNativeManifestOperation, type TileflowNativeManifestReader, type TileflowNativeManifestResponse, type TileflowNativeManifestResult, type TileflowNativeNetworkOptions, type TileflowNativeResourceUrlOptions, type TileflowNativeSource, type TileflowNativeSourceController, TileflowNativeSourceError, type TileflowNativeSourceErrorCode, type TileflowNativeSourceErrorField, type TileflowNativeSourceOptions, type TileflowNativeSourceState, TileflowNativeUrlError, type TileflowNativeUrlErrorCode, type TileflowNativeUrlField, type TileflowThemeBlendClock, TileflowThemeBlendError, type TileflowThemeBlendImage, type TileflowThemeBlendOptions, type TileflowThemeBlendPaint, type TileflowThemeBlendPlan, type TileflowThemeBlendSelection, type TileflowThemeBlendSwitch, type TileflowTimeOfDay, type TileflowTimeOfDayVariants, createTileflowNativeSourceController, fillTileflowThemeBlendTemplate, loadTileflowNativeManifest, nearestTileflowBlendTheme, planTileflowThemeBlend, resolveTileflowNativeInitialView, resolveTileflowNativeManifestUrl, resolveTileflowNativeResourceUrl, tileflowNativeManifestLimits, tileflowNativeUrlLimits, tileflowThemeBlendLimits, validateTileflowThemeBlendSelection };