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

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.
@@ -8809,6 +8809,13 @@ var layerTransformationSchema = strictNativeObject({
8809
8809
  "Expected unique, ordered properties"
8810
8810
  )
8811
8811
  });
8812
+ var symbolOverlapTransformationSchema = strictNativeObject({
8813
+ inputLayer: layerCountSchema,
8814
+ properties: z4.array(z4.enum(["icon-overlap", "text-overlap"])).min(1).max(2).refine(
8815
+ (properties2) => properties2.length === 1 || properties2[0] === "icon-overlap" && properties2[1] === "text-overlap",
8816
+ "Expected unique, ordered properties"
8817
+ )
8818
+ });
8812
8819
  var tileflowNativeStyleTransformationSchema = strictNativeObject({
8813
8820
  map: tileflowPortableIdSchema,
8814
8821
  theme: tileflowThemeNameSchema,
@@ -8817,7 +8824,8 @@ var tileflowNativeStyleTransformationSchema = strictNativeObject({
8817
8824
  inputLayers: layerCountSchema,
8818
8825
  outputLayers: layerCountSchema,
8819
8826
  projection: z4.enum(["none", "mercator-to-implicit", "globe-to-mercator"]),
8820
- layers: z4.array(layerTransformationSchema).max(tileflowNativeProfileLimits.maximumLayers)
8827
+ layers: z4.array(layerTransformationSchema).max(tileflowNativeProfileLimits.maximumLayers),
8828
+ symbolOverlap: z4.array(symbolOverlapTransformationSchema).max(tileflowNativeProfileLimits.maximumLayers)
8821
8829
  }).superRefine((style, context) => {
8822
8830
  let previous = -1;
8823
8831
  let added = 0;
@@ -8839,6 +8847,18 @@ var tileflowNativeStyleTransformationSchema = strictNativeObject({
8839
8847
  message: "Layer counts do not match transformation spans"
8840
8848
  });
8841
8849
  }
8850
+ const partitioned = new Set(style.layers.map(({ inputLayer }) => inputLayer));
8851
+ previous = -1;
8852
+ for (const [index, layer] of style.symbolOverlap.entries()) {
8853
+ if (layer.inputLayer <= previous || layer.inputLayer >= style.inputLayers || partitioned.has(layer.inputLayer)) {
8854
+ context.addIssue({
8855
+ code: "custom",
8856
+ path: ["symbolOverlap", index],
8857
+ message: "Invalid symbol overlap layer"
8858
+ });
8859
+ }
8860
+ previous = layer.inputLayer;
8861
+ }
8842
8862
  });
8843
8863
  var tileflowNativeBuildRecordSchema = strictNativeObject({
8844
8864
  schemaVersion: z4.literal(2),
package/dist/native.d.ts CHANGED
@@ -26,12 +26,39 @@ declare function resolveTileflowNativeManifestUrl(value: unknown, options?: Tile
26
26
  /** Resolve a resource against its owner without fetching it or authorizing requests. */
27
27
  declare function resolveTileflowNativeResourceUrl(value: unknown, options: TileflowNativeResourceUrlOptions): string;
28
28
 
29
+ type TileflowColor = `#${string}`;
29
30
  type TileflowViewConfig = {
30
31
  bearing?: number;
31
32
  center?: readonly [number, number];
32
33
  pitch?: number;
33
34
  zoom?: number;
34
35
  };
36
+ type MapLibreSprite = string | Array<{
37
+ id: string;
38
+ url: string;
39
+ }>;
40
+ type TileflowProjection = 'globe' | 'mercator';
41
+ type TileflowLight = {
42
+ anchor?: 'map' | 'viewport';
43
+ color?: TileflowColor;
44
+ intensity?: number;
45
+ position?: readonly [number, number, number];
46
+ };
47
+ type MapLibreStyle = {
48
+ sky?: Record<string, unknown>;
49
+ version: 8;
50
+ name: string;
51
+ glyphs?: string;
52
+ light?: TileflowLight;
53
+ projection?: {
54
+ type: TileflowProjection;
55
+ };
56
+ sprite?: MapLibreSprite;
57
+ sources: Record<string, Record<string, unknown>>;
58
+ layers: Array<Record<string, unknown>>;
59
+ terrain?: Record<string, unknown>;
60
+ metadata?: Record<string, unknown>;
61
+ };
35
62
 
36
63
  /** Runtime-ready logical map with all relative theme resources already resolved. */
37
64
  type TileflowRuntimeManifestMap = TileflowRuntimeManifestMapEntry & {
@@ -47,6 +74,24 @@ type TileflowStyleFontFace = {
47
74
  style?: 'italic' | 'normal' | 'oblique';
48
75
  weight?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
49
76
  };
77
+ /**
78
+ * A continuous blend of named themes of one Tileflow map. `position` places the map between
79
+ * neighbouring themes: 0 is the first, 1 the second, and 1.25 a quarter of the way from the second
80
+ * to the third.
81
+ */
82
+ type TileflowThemeBlendSelection = Readonly<{
83
+ /** From 0 to `themes.length - 1`. */
84
+ position: number;
85
+ /** Two to eight concrete theme names of the map, in blend order. */
86
+ themes: readonly string[];
87
+ }>;
88
+ declare const tileflowThemeBlendLimits: Readonly<{
89
+ maximumThemes: 8;
90
+ minimumThemes: 2;
91
+ }>;
92
+ declare function validateTileflowThemeBlendSelection(value: unknown): value is TileflowThemeBlendSelection;
93
+ /** The theme nearest to a blend position, which a blend shows when it cannot blend. */
94
+ declare function nearestTileflowBlendTheme(blend: TileflowThemeBlendSelection): string;
50
95
 
51
96
  /** The first and only public multi-theme runtime manifest contract. */
52
97
  declare const tileflowRuntimeManifestVersion: 1;
@@ -219,4 +264,92 @@ type TileflowNativeInitialViewOptions = {
219
264
  /** Resolve once or repeatedly without changing source generations, themes or acquisition. */
220
265
  declare function resolveTileflowNativeInitialView(options?: TileflowNativeInitialViewOptions): TileflowNativeInitialView;
221
266
 
222
- 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, createTileflowNativeSourceController, loadTileflowNativeManifest, resolveTileflowNativeInitialView, resolveTileflowNativeManifestUrl, resolveTileflowNativeResourceUrl, tileflowNativeManifestLimits, tileflowNativeUrlLimits };
267
+ /**
268
+ * Theme blending plans one MapLibre style that can show any point between the themes of one map.
269
+ *
270
+ * The themes of a Tileflow map compile to the same sources, layers, filters, and expressions; they
271
+ * differ only in token values: colours, numbers, and image names. A plan keeps the first theme's
272
+ * structure and records every value that differs as a template the browser fills in for a blend
273
+ * position: 0 is the first theme, 1 the second, and 1.25 a quarter of the way from the second to
274
+ * the third. Filling a template needs no expression parsing in the browser, so the renderer only
275
+ * receives plain values.
276
+ *
277
+ * Values that MapLibre evaluates per feature (data-driven values, such as a fill colour chosen by
278
+ * land-use class) are baked into tiles, and changing them re-lays the whole source out. A plan
279
+ * splits such a layer into one layer per branch that a feature can take through the value's
280
+ * decisions on feature data, each filtered to the features that take it, so each value depends
281
+ * only on zoom and the blend position. A value that reads feature data continuously is drawn once
282
+ * per theme instead, and the copies cross-fade by opacity. Images are mixed in their pixels.
283
+ * Values that read feature state cannot be split, because filters cannot read state; they switch
284
+ * when the dominant theme changes.
285
+ */
286
+ /** A paint value that the browser sets as the blend moves. */
287
+ type TileflowThemeBlendPaint = Readonly<{
288
+ layer: string;
289
+ property: string;
290
+ template: unknown;
291
+ /** Ground values follow the blend position; symbol values follow the label cross-fade. */
292
+ follows: TileflowThemeBlendClock;
293
+ }>;
294
+ /** Image names whose artwork differs between themes and is mixed in pixels. */
295
+ type TileflowThemeBlendImage = Readonly<{
296
+ names: readonly string[];
297
+ follows: TileflowThemeBlendClock;
298
+ }>;
299
+ /** A value that can only change all at once, when the dominant theme changes. */
300
+ type TileflowThemeBlendSwitch = Readonly<{
301
+ layer: string;
302
+ group: 'layout' | 'paint';
303
+ property: string;
304
+ values: readonly unknown[];
305
+ }>;
306
+ /**
307
+ * `position` values follow the blend; `dominant` values follow a short cross-fade that starts when
308
+ * the nearest theme changes. Labels use it because light lettering on a dark plate and dark
309
+ * lettering on a light plate meet in the same grey halfway.
310
+ */
311
+ type TileflowThemeBlendClock = 'dominant' | 'position';
312
+ type TileflowThemeBlendPlan = Readonly<{
313
+ /** Number of themes; blend positions run from 0 to `themes - 1`. */
314
+ themes: number;
315
+ paints: readonly TileflowThemeBlendPaint[];
316
+ images: readonly TileflowThemeBlendImage[];
317
+ switches: readonly TileflowThemeBlendSwitch[];
318
+ /** Root sky and light, when they differ between themes. */
319
+ sky?: unknown;
320
+ light?: unknown;
321
+ summary: Readonly<{
322
+ splitLayers: number;
323
+ copiedLayers: number;
324
+ /** Per-theme layers of which only the nearest theme's copy is shown. */
325
+ switchedLayers: number;
326
+ switchedValues: number;
327
+ }>;
328
+ /** The style at a blend position: every template filled, every switch at the nearest theme. */
329
+ styleAt(position: number): MapLibreStyle;
330
+ }>;
331
+ type TileflowThemeBlendOptions = Readonly<{
332
+ /**
333
+ * How icon images that differ between themes change. `mix` (the default) mixes their artwork in
334
+ * pixels under the first theme's image names. `switch` changes the image names when the nearest
335
+ * theme changes, for renderers that cannot replace an image's pixels while keeping its stretch
336
+ * and content metadata.
337
+ */
338
+ iconImages?: 'mix' | 'switch';
339
+ /**
340
+ * How values that read feature data change when they can be neither split nor cross-faded.
341
+ * `values` (the default) sets each value when the nearest theme changes. `layers` draws such a
342
+ * layer once per theme and shows only the nearest theme's copy, for renderers that cannot set
343
+ * data-driven values at run time reliably.
344
+ */
345
+ featureSwitches?: 'layers' | 'values';
346
+ }>;
347
+ declare class TileflowThemeBlendError extends Error {
348
+ name: string;
349
+ }
350
+ /** Plans a blend of two or more compiled themes of one map, in blend order. */
351
+ declare function planTileflowThemeBlend(styles: readonly MapLibreStyle[], options?: TileflowThemeBlendOptions): TileflowThemeBlendPlan;
352
+ /** Fills one blend template for a position. Plain values pass through unchanged. */
353
+ declare function fillTileflowThemeBlendTemplate(template: unknown, position: number): unknown;
354
+
355
+ 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, createTileflowNativeSourceController, fillTileflowThemeBlendTemplate, loadTileflowNativeManifest, nearestTileflowBlendTheme, planTileflowThemeBlend, resolveTileflowNativeInitialView, resolveTileflowNativeManifestUrl, resolveTileflowNativeResourceUrl, tileflowNativeManifestLimits, tileflowNativeUrlLimits, tileflowThemeBlendLimits, validateTileflowThemeBlendSelection };