@fxi/zartigl 0.6.0 → 0.7.0

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/zartigl.d.ts CHANGED
@@ -2,6 +2,21 @@ import { CustomLayerInterface } from 'maplibre-gl';
2
2
  import { CustomRenderMethodInput } from 'maplibre-gl';
3
3
  import { Map as Map_2 } from 'maplibre-gl';
4
4
 
5
+ /** Particle backdrop off: see BackdropStyle. */
6
+ export declare const BACKDROP_OFF: Readonly<BackdropStyle>;
7
+
8
+ /**
9
+ * Solid color under the particle trails, drawn on valid data cells only: it
10
+ * keeps particles readable over a light basemap. Off by default; an object
11
+ * without `enabled` is on.
12
+ */
13
+ declare interface BackdropStyle {
14
+ enabled: boolean;
15
+ /** Hex color, `#rgb` or `#rrggbb`. */
16
+ color: string;
17
+ opacity: number;
18
+ }
19
+
5
20
  export declare function buildMapxWidgetSnippet(options: MapxWidgetSnippetOptions): string;
6
21
 
7
22
  export declare function buildStandaloneDemoHtml(options: StandaloneDemoSnippetOptions): string;
@@ -41,22 +56,10 @@ export declare interface CatalogEntry {
41
56
  tags?: string[];
42
57
  kind: "scalar" | "vector";
43
58
  sources: CatalogSource[];
44
- defaults: {
59
+ /** Default source, plus the layer's base style. */
60
+ defaults: LayerStyleInput & {
45
61
  sourceId: string;
46
62
  querySourceId?: string;
47
- palette?: string;
48
- renderMode?: "particles" | "raster" | "raster+particles";
49
- particles?: {
50
- density?: number;
51
- speed?: number;
52
- fade?: number;
53
- };
54
- raster?: {
55
- opacity?: number;
56
- logScale?: boolean;
57
- vibrance?: number;
58
- colorDomain?: [number, number];
59
- };
60
63
  };
61
64
  }
62
65
 
@@ -178,6 +181,9 @@ export declare interface ColorGrade {
178
181
  highlights: number;
179
182
  }
180
183
 
184
+ /** Style `particles.grade` of a color grade: a preset when it is one. */
185
+ export declare function colorGradeToGrade(input: Partial<ColorGrade>): ParticleGrade;
186
+
181
187
  export declare type ColorRampInput = string | string[] | Record<number, string>;
182
188
 
183
189
  declare interface CoordArrays {
@@ -557,6 +563,24 @@ export declare function getPalettes(): PaletteMeta[];
557
563
 
558
564
  export declare function getVectorDerivationVariables(derivation: VectorDerivation): [string, string];
559
565
 
566
+ /** Color grade of a style `particles.grade`; an object tunes the vibrant one. */
567
+ export declare function gradeToColorGrade(grade: ParticleGrade | undefined): ColorGrade;
568
+
569
+ /** Vibrant grade values; each one left out takes the vibrant preset's. */
570
+ declare interface GradeTuning {
571
+ /** Mid-tone lift [0, 4]. */
572
+ exposure?: number;
573
+ /** S-curve strength [0, 1]. */
574
+ contrast?: number;
575
+ /** Vibrance-weighted saturation [-1, 1]. */
576
+ saturation?: number;
577
+ /** Push of the bright half toward white [0, 1]. */
578
+ highlights?: number;
579
+ }
580
+
581
+ /** A `#rgb` or `#rrggbb` color. */
582
+ export declare const isHexColor: (value: unknown) => value is string;
583
+
560
584
  declare type LayerEventMap = {
561
585
  loading: () => void;
562
586
  loaded: (meta: FieldMeta) => void;
@@ -577,6 +601,25 @@ declare type LayerEventMap_2 = {
577
601
  cacheInvalidated: () => void;
578
602
  };
579
603
 
604
+ declare interface LayerStyle {
605
+ /** Palette id; undefined lets the engine pick its own. */
606
+ palette?: string;
607
+ renderMode: StyleRenderMode;
608
+ particles: ParticleStyle;
609
+ raster: RasterStyle;
610
+ }
611
+
612
+ /** A partial style: any key left out takes the value below it. */
613
+ declare interface LayerStyleInput {
614
+ palette?: string;
615
+ renderMode?: StyleRenderMode;
616
+ particles?: ParticleStyleInput;
617
+ raster?: Partial<RasterStyle>;
618
+ }
619
+
620
+ /** Where each deprecated flat style setting moved in the style. */
621
+ export declare const LEGACY_STYLE_SETTINGS: Readonly<Partial<Record<keyof ZartiglSettings, string>>>;
622
+
580
623
  export declare type Legend = {
581
624
  type: "gradient";
582
625
  palette: string;
@@ -598,12 +641,20 @@ declare type LocalizedText = Record<string, string>;
598
641
  export declare interface MapxWidgetSnippetOptions {
599
642
  layerId: string;
600
643
  layerKind: CatalogEntry["kind"];
644
+ /**
645
+ * The layer's own style, the catalog `defaults`: only override keys that
646
+ * differ from it are written. Unknown, the whole override is written.
647
+ */
648
+ layerDefaults?: LayerStyleInput;
601
649
  source?: string;
602
650
  sourceType?: SnippetSourceType;
603
651
  time?: string | number | Date;
604
652
  timeRange?: TimeRange;
605
653
  geoVideo?: GeoVideoOptions;
606
654
  depth?: number;
655
+ /** Style override; only keys that differ from the layer's own are written. */
656
+ style?: LayerStyleInput;
657
+ /** Engine tuning; flat style keys are ignored. */
607
658
  settings?: Partial<ZartiglSettings>;
608
659
  }
609
660
 
@@ -614,6 +665,9 @@ export declare interface PaletteMeta {
614
665
  colors: string[];
615
666
  }
616
667
 
668
+ /** Particle trail color grade: a preset, or the vibrant one tuned. */
669
+ declare type ParticleGrade = "off" | "vibrant" | GradeTuning;
670
+
617
671
  export declare class ParticleSimulation {
618
672
  private gl;
619
673
  private params;
@@ -686,13 +740,13 @@ export declare class ParticleSimulation {
686
740
  south: number;
687
741
  east: number;
688
742
  north: number;
689
- }, opacityScale?: number): void;
743
+ }, opacityScale?: number, solid?: Vec4): void;
690
744
  renderGridGlobe(velocityTexUnit: number, velocityMin: [number, number], velocityMax: [number, number], matrix: Iterable<number>, geoBounds: {
691
745
  west: number;
692
746
  south: number;
693
747
  east: number;
694
748
  north: number;
695
- }, clippingPlane: [number, number, number, number], opacityScale?: number): void;
749
+ }, clippingPlane: [number, number, number, number], opacityScale?: number, solid?: Vec4): void;
696
750
  private setGridFieldUniforms;
697
751
  private bindRasterGrid;
698
752
  private unbindRasterGrid;
@@ -713,6 +767,8 @@ export declare class ParticleSimulation {
713
767
  setVibrance(v: number): void;
714
768
  /** Partial values take the vibrant preset; see resolveColorGrade. */
715
769
  setColorGrade(grade: Partial<ColorGrade>): void;
770
+ /** Missing values take the defaults; see resolveBackdrop. */
771
+ setBackdrop(backdrop: Partial<BackdropStyle>): void;
716
772
  setScalarMode(v: boolean): void;
717
773
  setRgba8MaxParticleZoom(v: number): void;
718
774
  /**
@@ -749,6 +805,7 @@ export declare interface ParticleSimulationDebugInfo {
749
805
  logScale: boolean;
750
806
  vibrance: number;
751
807
  colorGrade: ColorGrade;
808
+ backdrop: BackdropStyle;
752
809
  scalarMode: boolean;
753
810
  devicePixelRatio?: number;
754
811
  webgl: WebGLRendererInfo | null;
@@ -758,6 +815,24 @@ export declare type ParticleStateKind = StateTextureFormat["kind"];
758
815
 
759
816
  export declare type ParticleStateMode = "auto" | "rgba8";
760
817
 
818
+ declare interface ParticleStyle {
819
+ /** Particles per device pixel, (0, 0.2]. */
820
+ density: number;
821
+ /** Css px per frame for the fastest value of the field, (0, 10]. */
822
+ speed: number;
823
+ /** Trail length, [0, 1] (longer when higher). */
824
+ fade: number;
825
+ /** Trail color grade; replaced as a whole, not merged. */
826
+ grade: ParticleGrade;
827
+ /** Solid color under the trails; replaced as a whole, not merged. */
828
+ backdrop: BackdropStyle;
829
+ }
830
+
831
+ /** Partial particle style; a partial backdrop takes the defaults' keys. */
832
+ declare type ParticleStyleInput = Partial<Omit<ParticleStyle, "backdrop">> & {
833
+ backdrop?: Partial<BackdropStyle>;
834
+ };
835
+
761
836
  export declare interface PlaybackState {
762
837
  /** Whether the active source plays automatically: GeoVideo only. */
763
838
  available: boolean;
@@ -783,8 +858,24 @@ export declare interface QueryPointOptions {
783
858
  maxPoints?: number;
784
859
  }
785
860
 
861
+ declare interface RasterStyle {
862
+ opacity: number;
863
+ logScale: boolean;
864
+ /** Vibrance adjustment, [-1, 1]. */
865
+ vibrance: number;
866
+ /** Fixed physical-value domain; null follows the data. */
867
+ colorDomain: [number, number] | null;
868
+ }
869
+
786
870
  export declare type RenderMode = "raster" | "particles" | "raster+particles";
787
871
 
872
+ /**
873
+ * Complete backdrop from partial input. Missing or invalid values take the
874
+ * defaults, opacity is clamped; `enabled` defaults to true when any input is
875
+ * given, so `{ opacity: 0.2 }` means "on".
876
+ */
877
+ export declare function resolveBackdrop(input?: Partial<BackdropStyle>): BackdropStyle;
878
+
788
879
  /**
789
880
  * Complete grade from partial input. Missing or non-finite values take the
790
881
  * vibrant preset, others are clamped to their range; `enabled` defaults to
@@ -914,6 +1005,8 @@ declare interface SimulationParams {
914
1005
  vibrance: number;
915
1006
  /** Grade of the trail composite; off by default. */
916
1007
  colorGrade: ColorGrade;
1008
+ /** Solid color under the trails, on valid cells; off by default. */
1009
+ backdrop: BackdropStyle;
917
1010
  scalarMode: boolean;
918
1011
  particleState: ParticleStateMode;
919
1012
  rgba8MaxParticleZoom: number;
@@ -921,6 +1014,17 @@ declare interface SimulationParams {
921
1014
 
922
1015
  declare type SnippetSourceType = "zarr" | "geovideo" | "wmts";
923
1016
 
1017
+ /**
1018
+ * Split flat settings into the style their style keys make and the engine
1019
+ * tuning left. A custom palette ramp, not a palette id, stays in
1020
+ * `settings`. `legacyKeys` lists the style keys found.
1021
+ */
1022
+ export declare function splitLegacySettings(settings?: Partial<ZartiglSettings>): {
1023
+ style: LayerStyleInput;
1024
+ settings: Partial<ZartiglSettings>;
1025
+ legacyKeys: (keyof ZartiglSettings)[];
1026
+ };
1027
+
924
1028
  export declare interface StandaloneDemoSnippetOptions extends MapxWidgetSnippetOptions {
925
1029
  moduleBaseUrl?: string;
926
1030
  center?: [number, number];
@@ -928,7 +1032,8 @@ export declare interface StandaloneDemoSnippetOptions extends MapxWidgetSnippetO
928
1032
  bearing?: number;
929
1033
  pitch?: number;
930
1034
  projection?: "mercator" | "globe";
931
- style?: string;
1035
+ /** MapLibre map style URL; a cloudless imagery style when omitted. */
1036
+ mapStyle?: string;
932
1037
  }
933
1038
 
934
1039
  /**
@@ -968,6 +1073,13 @@ export declare function stitchVelocityChunks(uChunks: Array<{
968
1073
  north: number;
969
1074
  }, latDescending?: boolean, scalarMode?: boolean): VelocityData;
970
1075
 
1076
+ /**
1077
+ * Layer style: how a layer looks, with the same keys in the catalog
1078
+ * `defaults`, the engines and story views. Playback (how time moves) is not
1079
+ * part of it, so `particles.speed` is always the particle speed.
1080
+ */
1081
+ declare type StyleRenderMode = "particles" | "raster" | "raster+particles";
1082
+
971
1083
  export declare type TimeGranularity = "year" | "month" | "day" | "hour" | "minute" | "second";
972
1084
 
973
1085
  export declare interface TimeMeta {
@@ -999,6 +1111,8 @@ export declare interface VariableMeta {
999
1111
  units?: string;
1000
1112
  }
1001
1113
 
1114
+ declare type Vec4 = [number, number, number, number];
1115
+
1002
1116
  /**
1003
1117
  * Vector GeoVideo speeds: each step re-seeds the particles, so trails need
1004
1118
  * time to settle (the projection demo plays 0.2 to 2 steps per second).
@@ -1092,6 +1206,7 @@ export declare class VectorLayer implements CustomLayerInterface {
1092
1206
  setLogScale(v: boolean): void;
1093
1207
  setVibrance(v: number): void;
1094
1208
  setColorGrade(grade: Partial<ColorGrade>): void;
1209
+ setBackdrop(backdrop: Partial<BackdropStyle>): void;
1095
1210
  getDebugInfo(): VectorLayerDebugInfo;
1096
1211
  on<K extends keyof LayerEventMap_2>(event: K, handler: LayerEventMap_2[K]): this;
1097
1212
  off<K extends keyof LayerEventMap_2>(event: K, handler: LayerEventMap_2[K]): this;
@@ -1145,6 +1260,8 @@ export declare interface VectorLayerOptions {
1145
1260
  * vibrant preset (see resolveColorGrade).
1146
1261
  */
1147
1262
  colorGrade?: Partial<ColorGrade>;
1263
+ /** Solid color under the trails, on valid cells. Omitted: off. */
1264
+ backdrop?: Partial<BackdropStyle>;
1148
1265
  unit?: string;
1149
1266
  }
1150
1267
 
@@ -1424,6 +1541,8 @@ export declare class Zartigl {
1424
1541
  /** GeoVideo manifests that failed to load; "auto" falls back to Zarr. */
1425
1542
  private failedGeoVideo;
1426
1543
  private settings;
1544
+ /** Style override over the layer's own, kept across layers. */
1545
+ private style;
1427
1546
  private colorDomainOverridden;
1428
1547
  private paletteOverridden;
1429
1548
  private lastMeta;
@@ -1453,7 +1572,7 @@ export declare class Zartigl {
1453
1572
  private readonly onMapIdle;
1454
1573
  constructor(options: ZartiglOptions);
1455
1574
  init(): Promise<void>;
1456
- update(change: ZartiglUpdate): Promise<void>;
1575
+ update(input: ZartiglUpdate): Promise<void>;
1457
1576
  /**
1458
1577
  * Queue a change after earlier ones. Internal seeks, such as an archive
1459
1578
  * chunk handoff, come here directly and keep playback going.
@@ -1534,7 +1653,19 @@ export declare class Zartigl {
1534
1653
  private hasPlayback;
1535
1654
  /** Whether palette/domain styling is applied to values in the active renderer. */
1536
1655
  supportsDynamicStyle(): boolean;
1656
+ /**
1657
+ * The style drawn: the layer's own, then the override, with what the
1658
+ * source chose, such as a GeoVideo archive's palette.
1659
+ */
1660
+ getStyle(): LayerStyle;
1661
+ /** The style override over the layer's own. */
1662
+ getStyleOverride(): LayerStyleInput;
1537
1663
  getDebugInfo(): ZartiglDebugInfo;
1664
+ /**
1665
+ * Every style key of the shown layer with the override, the palette and
1666
+ * color domain of a GeoVideo archive included, as a load sets them.
1667
+ */
1668
+ private styledSettings;
1538
1669
  private applySettings;
1539
1670
  queryTimeSeries(options: QueryPointOptions): Promise<ZarrPointSeriesResult>;
1540
1671
  queryDepthProfile(options: QueryDepthProfileOptions): Promise<ZarrPointSeriesResult>;
@@ -1679,6 +1810,12 @@ export declare interface ZartiglOptions {
1679
1810
  depth?: number;
1680
1811
  geoVideo?: GeoVideoOptions;
1681
1812
  visible?: boolean;
1813
+ /** Style override over the layer's own. */
1814
+ style?: LayerStyleInput;
1815
+ /**
1816
+ * Engine tuning (`particleState`, `rgba8MaxParticleZoom`). Flat style
1817
+ * keys are deprecated: they move to `style`, with a warning.
1818
+ */
1682
1819
  settings?: Partial<ZartiglSettings>;
1683
1820
  metadata?: Record<string, unknown>;
1684
1821
  before?: string;
@@ -1698,6 +1835,8 @@ export declare interface ZartiglSettings {
1698
1835
  * vibrant preset (see resolveColorGrade).
1699
1836
  */
1700
1837
  colorGrade: Partial<ColorGrade>;
1838
+ /** Solid color under particle trails, on valid cells; off by default. */
1839
+ backdrop: Partial<BackdropStyle>;
1701
1840
  /** Fixed physical-value domain for scalar colors. Null uses frame extrema. */
1702
1841
  colorDomain: [number, number] | null;
1703
1842
  particleState: ParticleStateMode;
@@ -1734,6 +1873,17 @@ export declare interface ZartiglUpdate {
1734
1873
  timeRange?: TimeRange | null;
1735
1874
  time?: Date | string | number;
1736
1875
  depth?: number;
1876
+ /**
1877
+ * Replaces the style override: every style key returns to the layer's own,
1878
+ * then this one applies (`{}` clears it). Omitted, the override stays,
1879
+ * across layers too, without the keys a new layer kind cannot draw. Kept
1880
+ * once a layer switch loads.
1881
+ */
1882
+ style?: LayerStyleInput;
1883
+ /**
1884
+ * Engine tuning. Flat style keys are deprecated: they patch the style
1885
+ * override, with a warning.
1886
+ */
1737
1887
  settings?: Partial<ZartiglSettings>;
1738
1888
  geoVideo?: GeoVideoOptions;
1739
1889
  visible?: boolean;