@fxi/zartigl 0.9.3 → 0.10.1

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
@@ -24,7 +24,7 @@ ARCO layers of [MapX](https://app.mapx.org).
24
24
  | Runtime library | `src/lib/` | `@fxi/zartigl`: the `Zartigl` facade, Zarr/WMTS/GeoVideo layers, shaders, particle simulation, point queries |
25
25
  | Catalog | `src/catalog/`, `scripts/catalog_builder/` | `@fxi/zartigl/catalog` presets and the tools that discover, describe, and validate entries |
26
26
  | GeoVideo pipeline | `scripts/geovideo/`, `.github/workflows/geovideo.yml` | Single renders and incremental archives published to S3, rendered daily on a self-hosted runner |
27
- | Demos | `src/demo-prod/`, `src/demo-story/` | Technical demo and narrative story, deployed to GitHub Pages |
27
+ | Demos | `src/explorer/`, `src/demo-story/` | Catalog explorer and narrative story, deployed to GitHub Pages |
28
28
  | MapX integration | `src/mapx/` | Widget and standalone snippet generation for reproducible MapX views |
29
29
 
30
30
  ## Features
@@ -103,6 +103,7 @@ the MapX `ArcoMapLegend` and the snippets the demo exports.
103
103
  ```jsonc
104
104
  {
105
105
  "palette": "thermal",
106
+ "reversePalette": false,
106
107
  "renderMode": "particles", // or "raster", "raster+particles"
107
108
  "particles": {
108
109
  "density": 0.03,
@@ -111,10 +112,36 @@ the MapX `ArcoMapLegend` and the snippets the demo exports.
111
112
  "grade": "vibrant",
112
113
  "backdrop": { "enabled": true, "color": "#000000", "opacity": 0.3 }
113
114
  },
114
- "raster": { "opacity": 0.9, "logScale": false, "vibrance": 0.2, "colorDomain": null }
115
+ "raster": {
116
+ "opacity": 0.9, "logScale": false, "vibrance": 0.2, "colorDomain": null,
117
+ "alphaFadeLow": 0, "alphaFadeHigh": 0, "alphaFadeCurve": "linear"
118
+ }
115
119
  }
116
120
  ```
117
121
 
122
+ `reversePalette` runs the palette from its last color to its first, for the
123
+ raster and the particles.
124
+
125
+ `raster.alphaFadeLow` and `alphaFadeHigh` make the ends of the color range
126
+ transparent, with any palette. Each is a fraction of the range as displayed
127
+ (the color domain, after log scale): `alphaFadeLow: 0.25` fades the lowest
128
+ quarter in from transparent, `alphaFadeHigh: 0.5` fades the upper half out,
129
+ and values beyond the domain take its transparent ends. A field that is
130
+ mostly zero, such as fire radiative power or coral heat stress, then shows
131
+ only where something happens. `alphaFadeCurve` shapes both fades, with the
132
+ curves of `logScale`: `"linear"`, `"log"` (`log10(1 + 9x)`, rises fast) or
133
+ `"exp"` (its inverse, stays faint longer, which also hides codec noise at the
134
+ ends of a GeoVideo). The fade is part of the color ramp
135
+ (`resolveColorRamp(palette, { reverse, alphaFade })`), so Zarr, GeoVideo,
136
+ projversor and legends show the same transparency. Neither key changes how
137
+ GeoVideo archives are encoded, so restyling never re-renders them.
138
+
139
+ `heat-alert`, which faded low values in through transparent palette stops, is
140
+ deprecated: `migrateLegacyStyle` reads it as `heat` with `alphaFadeLow: 0.25`
141
+ (the closest fit of its alpha), wherever a style enters, so old catalogs,
142
+ share links and story views keep working. `getPalettes()` leaves deprecated
143
+ palettes out of pickers.
144
+
118
145
  `particles.grade` is `"off"`, `"vibrant"`, or a tuned vibrant grade
119
146
  `{ exposure, contrast, saturation, highlights }`; it is replaced as a whole.
120
147
 
package/dist/catalog.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ /** Shape of an alpha fade inside its zone; the same curves as `logScale`. */
2
+ export declare type AlphaFadeCurve = "linear" | "log" | "exp";
3
+
1
4
  /**
2
5
  * Solid color under the particle trails, drawn on valid data cells only: it
3
6
  * keeps particles readable over a light basemap. Off by default; an object
@@ -18,6 +21,9 @@ export declare interface Catalog {
18
21
 
19
22
  export declare const catalog: Catalog;
20
23
 
24
+ /** Live catalog of schema 2; a schema 3 would publish under `v3/`. */
25
+ export declare const CATALOG_URL = "https://sos-ch-gva-2.exo.io/mapx-zartigl/catalog/v2/catalog.json";
26
+
21
27
  export declare interface CatalogEntry {
22
28
  id: string;
23
29
  aliases?: string[];
@@ -126,6 +132,9 @@ export declare interface CatalogZarrSource extends CatalogSourceBase {
126
132
  variables: CatalogVariables;
127
133
  }
128
134
 
135
+ /** -1, 0 or 1 as `a` is older than, equal to or newer than `b` (x.y.z). */
136
+ export declare function compareVersions(a: string, b: string): number;
137
+
129
138
  /** The keys of `style` whose value differs from `base`'s. */
130
139
  export declare function diffStyle(style: LayerStyleInput, base: LayerStyle): LayerStyleInput;
131
140
 
@@ -155,6 +164,8 @@ export declare const LAYER_STYLE_DEFAULTS: Readonly<LayerStyle>;
155
164
  export declare interface LayerStyle {
156
165
  /** Palette id; undefined lets the engine pick its own. */
157
166
  palette?: string;
167
+ /** Run the palette from its last color to its first, for raster and particles. */
168
+ reversePalette: boolean;
158
169
  renderMode: StyleRenderMode;
159
170
  particles: ParticleStyle;
160
171
  raster: RasterStyle;
@@ -163,11 +174,35 @@ export declare interface LayerStyle {
163
174
  /** A partial style: any key left out takes the value below it. */
164
175
  export declare interface LayerStyleInput {
165
176
  palette?: string;
177
+ reversePalette?: boolean;
166
178
  renderMode?: StyleRenderMode;
167
179
  particles?: ParticleStyleInput;
168
180
  raster?: Partial<RasterStyle>;
169
181
  }
170
182
 
183
+ /**
184
+ * The live catalog, or `fallback` (the bundled catalog) when it cannot be
185
+ * fetched or is not a schema 2 catalog. A catalog that needs a newer engine
186
+ * still loads, with a warning: its new style keys degrade, they do not fail.
187
+ */
188
+ export declare function loadCatalog(url?: string, options?: LoadCatalogOptions): Promise<LoadedCatalog>;
189
+
190
+ export declare interface LoadCatalogOptions {
191
+ /** Give up on the live catalog after this delay. */
192
+ timeoutMs?: number;
193
+ /** Used when the live catalog cannot be read; the bundled one by default. */
194
+ fallback?: Catalog;
195
+ /** Where warnings go; console.warn by default. */
196
+ warn?: (message: string) => void;
197
+ /** For tests: the fetch to use. */
198
+ fetch?: typeof fetch;
199
+ }
200
+
201
+ export declare interface LoadedCatalog {
202
+ catalog: Catalog;
203
+ source: "remote" | "bundled";
204
+ }
205
+
171
206
  export declare type LocalizedText = Record<string, string>;
172
207
 
173
208
  /**
@@ -176,6 +211,14 @@ export declare type LocalizedText = Record<string, string>;
176
211
  */
177
212
  export declare function mergeStyles(...inputs: (LayerStyleInput | undefined)[]): LayerStyleInput;
178
213
 
214
+ /**
215
+ * `input` with legacy palettes rewritten, so old catalogs, share links and
216
+ * story views keep their look. Keys the input sets itself win.
217
+ */
218
+ export declare function migrateLegacyStyle(input: LayerStyleInput): LayerStyleInput;
219
+
220
+ export declare function migrateLegacyStyle(input: LayerStyleInput | undefined): LayerStyleInput | undefined;
221
+
179
222
  /**
180
223
  * Validate a style, throwing an error that names the offending path, e.g.
181
224
  * `views.swell.config.style.particles.density must be a number in (0, 0.2]`.
@@ -192,6 +235,14 @@ export declare interface ParseLayerStyleOptions {
192
235
  particles?: readonly (keyof ParticleStyle)[];
193
236
  raster?: readonly (keyof RasterStyle)[];
194
237
  };
238
+ /**
239
+ * Keys that are not style keys at all: "throw" (default), or "drop" them
240
+ * with a warning, so a style written for a newer engine still renders with
241
+ * an older one. Invalid values of known keys always throw.
242
+ */
243
+ unknownKeys?: "throw" | "drop";
244
+ /** Where dropped keys are reported; console.warn by default. */
245
+ warn?: (message: string) => void;
195
246
  }
196
247
 
197
248
  /** Style keys, for checks against other definitions of the same shape. */
@@ -232,6 +283,11 @@ export declare function pickPreferredSource(entry: CatalogEntry, request?: Sourc
232
283
  */
233
284
  export declare function pickSourceByPriority(entry: CatalogEntry, priority: readonly CatalogSource["type"][], request?: SourceTimeRequest): CatalogSource | undefined;
234
285
 
286
+ /** A published catalog: the catalog plus the oldest engine that renders it all. */
287
+ export declare type PublishedCatalog = Catalog & {
288
+ minEngine?: string;
289
+ };
290
+
235
291
  export declare const RASTER_STYLE_KEYS: (keyof RasterStyle)[];
236
292
 
237
293
  export declare interface RasterStyle {
@@ -241,6 +297,17 @@ export declare interface RasterStyle {
241
297
  vibrance: number;
242
298
  /** Fixed physical-value domain; null follows the data. */
243
299
  colorDomain: [number, number] | null;
300
+ /**
301
+ * Fraction of the color range, from its low end, over which colors fade in
302
+ * from transparent, [0, 1]: a field that is mostly zero (fires, heat
303
+ * stress) shows only where something happens. Values below the domain are
304
+ * transparent too.
305
+ */
306
+ alphaFadeLow: number;
307
+ /** Fraction of the color range, from its high end, fading out, [0, 1]. */
308
+ alphaFadeHigh: number;
309
+ /** Shape of both fades: "log" rises fast, "exp" stays faint longer. */
310
+ alphaFadeCurve: AlphaFadeCurve;
244
311
  }
245
312
 
246
313
  export declare function requireCatalogEntry(id: string, data?: Catalog): CatalogEntry;
@@ -284,11 +351,6 @@ export declare interface StyledEntry {
284
351
  /** `style` without the keys a layer of `kind` cannot draw. */
285
352
  export declare function styleForKind(style: LayerStyleInput, kind: StyledEntry["kind"] | undefined): LayerStyleInput;
286
353
 
287
- /**
288
- * Layer style: how a layer looks, with the same keys in the catalog
289
- * `defaults`, the engines and story views. Playback (how time moves) is not
290
- * part of it, so `particles.speed` is always the particle speed.
291
- */
292
354
  export declare type StyleRenderMode = "particles" | "raster" | "raster+particles";
293
355
 
294
356
  export { }