@tileflow/core 0.1.0-alpha.29 → 0.1.0-alpha.30

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/README.md CHANGED
@@ -139,12 +139,18 @@ export default defineMap({
139
139
  `system` is a runtime selection policy, not a stored theme. Builds, captures, static scenes, and
140
140
  receipts must use a concrete theme such as `light` or `dark`.
141
141
 
142
+ Because every theme of a map shares one structure, a browser map can cross-fade between themes or
143
+ show a continuous blend of them on the same MapLibre instance, with no extra requests. See
144
+ [theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/theme-transitions-and-blends.md).
145
+
142
146
  The semantic domains are `land`, `water`, `nautical`, `roads`, `buildings`, `boundaries`, `labels`,
143
147
  `poi`, `aeroways`, `transit`, `vegetation`, `addresses`, and `landforms`. Style stable geographic
144
148
  targets rather than compiler-generated MapLibre layer IDs. Shared primitives cover fills, lines,
145
149
  text, icons, circles, and extrusions. `zoom.*` supplies zoom curves; `expr.*` and `field(...)` supply
146
150
  the closed data-expression language. `renderPass`, `refineRenderTarget`, and `withRenderStack` add
147
- owner-local rendering behavior without bypassing the compiler.
151
+ owner-local rendering behavior without bypassing the compiler. A pass, or a target its module moves,
152
+ is placed at a band edge such as `'above-relief'` or `'below-labels'`, or `{above}` / `{below}` one
153
+ semantic target.
148
154
 
149
155
  ## Compile and inspect
150
156
 
@@ -255,6 +261,7 @@ revision; prefer the installed copy when working with an older release.
255
261
  - [Shared visual primitives](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/shared-visual-primitives.md)
256
262
  - [Compiled-style performance](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/compiled-style-performance.md)
257
263
  - [Themes and module styles](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/themes-and-module-styles.md)
264
+ - [Theme transitions and blends](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/theme-transitions-and-blends.md)
258
265
  - [Data is separate from design](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/data-is-separate-from-design.md)
259
266
  - [Capture scenes](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/capture-scenes.md)
260
267
  - [Public API and browser subpath](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/docs/public-api-and-browser-subpath.md)
package/dist/browser.d.ts CHANGED
@@ -94,6 +94,27 @@ type TileflowStyleFontFace = {
94
94
  weight?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
95
95
  };
96
96
 
97
+ /**
98
+ * Browser helpers for theme transitions and blends. They use only methods that MapLibre GL JS maps
99
+ * provide and check each one at runtime, so a map without them falls back to an immediate change.
100
+ */
101
+ type TileflowThemeMotionMap = {
102
+ areTilesLoaded?: unknown;
103
+ getCanvas?: unknown;
104
+ getImage?: unknown;
105
+ isStyleLoaded?: unknown;
106
+ off(event: string, listener: (event?: unknown) => void): unknown;
107
+ on(event: string, listener: (event?: unknown) => void): unknown;
108
+ project?: unknown;
109
+ redraw?: unknown;
110
+ setLayoutProperty?: unknown;
111
+ setLight?: unknown;
112
+ setPaintProperty?: unknown;
113
+ setSky?: unknown;
114
+ unproject?: unknown;
115
+ updateImage?: unknown;
116
+ };
117
+
97
118
  /** Structural MapLibre capabilities; importing this module never loads a renderer. */
98
119
  type TileflowAtmosphereMap = {
99
120
  getBearing(): number;
@@ -178,15 +199,51 @@ type TileflowThemeTransitionResult = Readonly<{
178
199
  status: 'applied' | 'failed' | 'superseded';
179
200
  theme?: string;
180
201
  }>;
181
- type TileflowStyleSwitchMap = {
182
- off(event: 'error' | 'style.load', listener: (event?: unknown) => void): unknown;
183
- on(event: 'error' | 'style.load', listener: (event?: unknown) => void): unknown;
202
+ /**
203
+ * How a theme change appears. With a `duration`, the map cross-fades from the previous theme to
204
+ * the new one: a snapshot of the previous frame covers the map, follows the camera, and fades out
205
+ * once the new theme is drawn. A browser preference for reduced motion changes at once.
206
+ */
207
+ type TileflowThemeTransitionOptions = Readonly<{
208
+ /** Cross-fade length in milliseconds, from 0 (the default, an immediate change) to 5000. */
209
+ duration?: number;
210
+ }>;
211
+ type TileflowThemeChangeOptions = Readonly<{
212
+ transition?: TileflowThemeTransitionOptions;
213
+ }>;
214
+ /**
215
+ * A continuous mix of two or more themes of the same map. `position` places the map between
216
+ * neighbouring themes: 0 is the first, 1 the second, and 1.25 a quarter of the way from the second
217
+ * to the third. Ground colours, patterns, the sky, and light follow the position; labels and icons
218
+ * cross-fade when the nearest theme changes.
219
+ */
220
+ type TileflowThemeBlendRequest = Readonly<{
221
+ position: number;
222
+ /** Two to eight concrete themes of one map, in blend order. */
223
+ themes: readonly TileflowRuntimeStyle[];
224
+ }>;
225
+ type TileflowThemeBlendState = Readonly<{
226
+ position: number;
227
+ themes: readonly string[];
228
+ }>;
229
+ type TileflowStyleSwitchMap = TileflowThemeMotionMap & {
230
+ off(event: string, listener: (event?: unknown) => void): unknown;
231
+ on(event: string, listener: (event?: unknown) => void): unknown;
184
232
  setStyle: unknown;
185
233
  };
186
234
  type TileflowThemeController = {
187
235
  dispose(): void;
236
+ /** The active blend, or undefined when the map shows one theme. */
237
+ getBlend(): TileflowThemeBlendState | undefined;
238
+ /** The theme the map shows; during a blend, the nearest theme. */
188
239
  getCurrent(): TileflowRuntimeStyle;
189
- setTheme(style: TileflowRuntimeStyle): Promise<TileflowThemeTransitionResult>;
240
+ /**
241
+ * Shows a blend of themes. The first request for a set of themes loads their styles and
242
+ * prepares one style that holds all of them; later requests for the same themes only move the
243
+ * position and take effect at once, so they can follow an animation or a slider.
244
+ */
245
+ setBlend(request: TileflowThemeBlendRequest, options?: TileflowThemeChangeOptions): Promise<TileflowThemeTransitionResult>;
246
+ setTheme(style: TileflowRuntimeStyle, options?: TileflowThemeChangeOptions): Promise<TileflowThemeTransitionResult>;
190
247
  };
191
248
  /**
192
249
  * Transactionally changes a MapLibre style while preserving the map instance and camera.
@@ -195,9 +252,13 @@ type TileflowThemeController = {
195
252
  declare function createTileflowThemeController(options: {
196
253
  initial: TileflowRuntimeStyle;
197
254
  loadFonts?: (style: TileflowRuntimeStyle) => Promise<void>;
255
+ /** Loads a theme's style document for a blend; defaults to a same-origin-credentials fetch. */
256
+ loadStyle?: (url: string) => Promise<MapLibreStyle>;
198
257
  map: TileflowStyleSwitchMap;
199
258
  onTransition?: (transition: TileflowThemeTransition) => void;
200
259
  timeoutMs?: number;
260
+ /** The default for every change; each change may pass its own. */
261
+ transition?: TileflowThemeTransitionOptions;
201
262
  }): TileflowThemeController;
202
263
  type TileflowMapLifecycleEvent = 'dataloading' | 'error' | 'idle' | 'load' | 'styledataloading';
203
264
  type TileflowFrameScheduler<TFrame> = {
@@ -270,4 +331,4 @@ declare function createTileflowTransformRequest<TRequest extends TileflowTransfo
270
331
  worldRequestBridge?: TileflowWorldRequestBridge;
271
332
  }): TileflowTransformRequest<TRequest, TResourceType> | undefined;
272
333
 
273
- export { type TileflowAsyncAnalyticsTiming, type TileflowAtmosphereMap, type TileflowComposedRequest, type TileflowContourProtocolHandler, type TileflowContourProtocolRegistrationOptions, type TileflowContourProtocolRegistry, type TileflowContourProtocolRequest, type TileflowContourProtocolResponse, type TileflowFairUseNotice, type TileflowFairUseNoticeController, type TileflowFairUseNoticeState, type TileflowFrameScheduler, type TileflowMapLifecycleAttachment, type TileflowMapLifecycleEvent, type TileflowMapLifecycleSubscriber, type TileflowMapReadinessState, type TileflowPmtilesProtocolHandler, type TileflowPmtilesProtocolRegistrationOptions, type TileflowPmtilesProtocolRegistry, type TileflowSessionSender, type TileflowSessionStarter, type TileflowStyleFontLoadOptions, type TileflowStyleSwitchMap, type TileflowThemeController, type TileflowThemeTransition, type TileflowThemeTransitionPhase, type TileflowThemeTransitionResult, type TileflowTransformRequest, type TileflowTransformRequestParameters, type TileflowUserTransformRequest, type TileflowWorldProtocolHandler, type TileflowWorldProtocolRequest, type TileflowWorldProtocolResponse, type TileflowWorldRequestBridge, attachTileflowAtmosphere, attachTileflowFairUseNotice, attachTileflowMapLifecycle, createTileflowSessionStarter, createTileflowThemeController, createTileflowTransformRequest, getTileflowSystemColorScheme, loadTileflowStyleFonts, registerTileflowContourProtocol, registerTileflowPmtilesProtocol, registerTileflowWorldRequestBridge, subscribeTileflowSystemColorScheme, tileflowFairUseNoticeMessage, tileflowMaplibreContourVersion, tileflowPmtilesMaximumDirectoryDepth, tileflowPmtilesProtocol };
334
+ export { type TileflowAsyncAnalyticsTiming, type TileflowAtmosphereMap, type TileflowComposedRequest, type TileflowContourProtocolHandler, type TileflowContourProtocolRegistrationOptions, type TileflowContourProtocolRegistry, type TileflowContourProtocolRequest, type TileflowContourProtocolResponse, type TileflowFairUseNotice, type TileflowFairUseNoticeController, type TileflowFairUseNoticeState, type TileflowFrameScheduler, type TileflowMapLifecycleAttachment, type TileflowMapLifecycleEvent, type TileflowMapLifecycleSubscriber, type TileflowMapReadinessState, type TileflowPmtilesProtocolHandler, type TileflowPmtilesProtocolRegistrationOptions, type TileflowPmtilesProtocolRegistry, type TileflowSessionSender, type TileflowSessionStarter, type TileflowStyleFontLoadOptions, type TileflowStyleSwitchMap, type TileflowThemeBlendRequest, type TileflowThemeBlendState, type TileflowThemeChangeOptions, type TileflowThemeController, type TileflowThemeTransition, type TileflowThemeTransitionOptions, type TileflowThemeTransitionPhase, type TileflowThemeTransitionResult, type TileflowTransformRequest, type TileflowTransformRequestParameters, type TileflowUserTransformRequest, type TileflowWorldProtocolHandler, type TileflowWorldProtocolRequest, type TileflowWorldProtocolResponse, type TileflowWorldRequestBridge, attachTileflowAtmosphere, attachTileflowFairUseNotice, attachTileflowMapLifecycle, createTileflowSessionStarter, createTileflowThemeController, createTileflowTransformRequest, getTileflowSystemColorScheme, loadTileflowStyleFonts, registerTileflowContourProtocol, registerTileflowPmtilesProtocol, registerTileflowWorldRequestBridge, subscribeTileflowSystemColorScheme, tileflowFairUseNoticeMessage, tileflowMaplibreContourVersion, tileflowPmtilesMaximumDirectoryDepth, tileflowPmtilesProtocol };