@fxi/zartigl 0.7.1 → 0.9.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/engine.d.ts CHANGED
@@ -174,6 +174,21 @@ export declare function fadeToFrames(fade: number): number;
174
174
  /** Per-frame trail opacity multiplier for a 0–1 `fade`. */
175
175
  export declare function fadeToOpacity(fade: number): number;
176
176
 
177
+ /**
178
+ * Short display label of a CF / UDUNITS `units` attribute, for legends and
179
+ * query values: "mmol m-3" → "mmol/m³", "degree_Celsius_weeks" → "°C-weeks".
180
+ * Unknown labels pass through with underscores turned into spaces.
181
+ */
182
+ export declare function formatUnit(unit: string | undefined): string;
183
+
184
+ /**
185
+ * `float geoVideoScalarValue(float r)`: a scalar-luma frame's red channel to
186
+ * its value, with the `u_code_range` / `u_value_range` uniforms it declares
187
+ * (geoVideoScalarUniforms); GLSL ES 1.0 and 3.0. The one scalar GeoVideo
188
+ * decoder: frames go to the GPU as images, never read back.
189
+ */
190
+ export declare const GEOVIDEO_SCALAR_GLSL: string;
191
+
177
192
  /**
178
193
  * One immutable chunk of a GeoVideo archive, independent of the catalog: a
179
194
  * manifest and the range of its encoded samples.
@@ -308,8 +323,8 @@ export declare interface GeoVideoChunkSpan {
308
323
  end: number;
309
324
  }
310
325
 
311
- /** Scalar values (NaN invalid) or u/v components (NaN invalid). */
312
- export declare type GeoVideoFrameData = Float32Array | GeoVideoVectorFrame;
326
+ /** A scalar frame image (decoded on the GPU) or u/v components (NaN invalid). */
327
+ export declare type GeoVideoFrameData = GeoVideoScalarFrame | GeoVideoVectorFrame;
313
328
 
314
329
  /** The part of a frame source an archive reads. */
315
330
  export declare interface GeoVideoFrameReader<TFrame> {
@@ -325,11 +340,12 @@ export declare interface GeoVideoFrameRequest {
325
340
 
326
341
  /**
327
342
  * GeoVideo frames read one time step at a time (seek, no playback): video
328
- * and static mask loading, luma readback, a serial decode queue, and a small
329
- * LRU cache of decoded frames. Requests for the same step share one decode;
330
- * each can be abandoned with its own signal, and the decode is dropped once
331
- * no request waits for it. cancelAll() aborts every pending decode.
332
- * Subclasses turn the luma codes of a frame into values.
343
+ * and static mask loading, a serial decode queue, and a small LRU cache of
344
+ * decoded frames. Requests for the same step share one decode; each can be
345
+ * abandoned with its own signal, and the decode is dropped once no request
346
+ * waits for it. cancelAll() aborts every pending decode. Subclasses capture
347
+ * the presented frame: read back as luma codes (readCodes) or kept as an
348
+ * image for the GPU.
333
349
  */
334
350
  export declare abstract class GeoVideoFrameSource<TFrame> {
335
351
  /** Grid size; the video stacks `planes` grids vertically. */
@@ -341,7 +357,7 @@ export declare abstract class GeoVideoFrameSource<TFrame> {
341
357
  private readonly cacheSize;
342
358
  private readonly reader;
343
359
  private video;
344
- private mask;
360
+ private maskCodes;
345
361
  private initPromise;
346
362
  private presented;
347
363
  private primed;
@@ -354,8 +370,17 @@ export declare abstract class GeoVideoFrameSource<TFrame> {
354
370
  constructor(manifest: GeoVideoManifest, planes: number, options?: {
355
371
  cacheSize?: number;
356
372
  });
357
- /** Codes of the stacked planes and the per-cell mask to frame values. */
358
- protected abstract decodeCodes(codes: Uint8Array, mask: Uint8Array, threshold: number): TFrame;
373
+ /**
374
+ * The presented frame (`rows` = stacked planes) and the per-cell mask to
375
+ * frame data; null when the decoder exposed no pixels yet.
376
+ */
377
+ protected abstract capture(video: HTMLVideoElement, rows: number, mask: Uint8Array): Promise<TFrame | null>;
378
+ /** Static validity, one 8-bit value per grid cell; null before init(). */
379
+ get mask(): Uint8Array | null;
380
+ /** Luma codes of the presented frame, or null when it is blank. */
381
+ protected readCodes(video: HTMLVideoElement, rows: number): Uint8Array | null;
382
+ /** True when the decoder exposed no pixels; reads back one row only. */
383
+ protected isBlank(video: HTMLVideoElement): boolean;
359
384
  init(): Promise<void>;
360
385
  /** Abort every pending frame decode; frames already decoded stay cached. */
361
386
  cancelAll(): void;
@@ -383,8 +408,8 @@ export declare abstract class GeoVideoFrameSource<TFrame> {
383
408
  */
384
409
  private primeDecoder;
385
410
  /**
386
- * Seek, read back and decode one step. `signal` aborts it between steps;
387
- * a seek already started completes first, keeping the queue serial.
411
+ * Seek and capture one step. `signal` aborts it between steps; a seek
412
+ * already started completes first, keeping the queue serial.
388
413
  */
389
414
  protected decode(index: number, signal: AbortSignal): Promise<TFrame>;
390
415
  }
@@ -507,18 +532,28 @@ export declare interface GeoVideoScalarEncoding {
507
532
  colorRange: "limited" | "full";
508
533
  }
509
534
 
535
+ /** One scalar-luma frame, as decoded by the browser; GPU input only. */
536
+ export declare type GeoVideoScalarFrame = ImageBitmap;
537
+
510
538
  /**
511
- * Scalar-luma GeoVideo read frame by frame (seek, no playback), for values
512
- * sampled on the GPU rather than the styled playback of GeoVideoLayer.
539
+ * Scalar-luma GeoVideo read frame by frame (seek, no playback). Frames stay
540
+ * images, uploaded as textures and decoded by GEOVIDEO_SCALAR_GLSL, the
541
+ * decoder GeoVideoLayer uses: never read back, so both renderers turn the
542
+ * same pixels into the same values.
513
543
  */
514
- export declare class GeoVideoScalarSource extends GeoVideoFrameSource<Float32Array> {
515
- private readonly encoding;
544
+ export declare class GeoVideoScalarSource extends GeoVideoFrameSource<GeoVideoScalarFrame> {
516
545
  constructor(manifest: GeoVideoManifest, options?: {
517
546
  cacheSize?: number;
518
547
  });
519
- protected decodeCodes(codes: Uint8Array, mask: Uint8Array, threshold: number): Float32Array;
548
+ protected capture(video: HTMLVideoElement): Promise<GeoVideoScalarFrame | null>;
520
549
  }
521
550
 
551
+ /** Uniforms of GEOVIDEO_SCALAR_GLSL for a scalar-luma encoding. */
552
+ export declare function geoVideoScalarUniforms(encoding: Pick<GeoVideoScalarEncoding, "codeMin" | "codeMax" | "valueMin" | "valueMax">): {
553
+ codeRange: [number, number];
554
+ valueRange: [number, number];
555
+ };
556
+
522
557
  declare interface GeoVideoSnapshotLoopTimeline {
523
558
  kind: "snapshot-loop";
524
559
  date: string;
@@ -585,7 +620,8 @@ export declare class GeoVideoVectorSource extends GeoVideoFrameSource<GeoVideoVe
585
620
  fetchSpatialChunkResult(variable: string, selection: {
586
621
  timeIndex: number;
587
622
  }): Promise<ZarrChunkFetchResult>;
588
- protected decodeCodes(codes: Uint8Array, mask: Uint8Array, threshold: number): GeoVideoVectorFrame;
623
+ /** u/v codes are written into luma: read back, then decoded on the CPU. */
624
+ protected capture(video: HTMLVideoElement, rows: number, mask: Uint8Array): Promise<GeoVideoVectorFrame | null>;
589
625
  }
590
626
 
591
627
  export declare function getPalettes(): PaletteMeta[];
package/dist/engine.js CHANGED
@@ -1,5 +1,5 @@
1
- import { D as d, E as i, F as l, G as m, T as u, H as v, b as x, I as g, c as p, J as f, K as G, l as V, B as C, L as b, M as S, q as _, x as O, y as R, A as h, m as A, z as L, N as F, O as T, P as k, o as y, Q as I, C as D, v as B } from "./geovideo-index-CMGVia5M.js";
2
- import { B as w, C as M, e as N, b as P, d as z, c as H, g as K, i as q, a as J, r as Q } from "./backdrop-DctkJ45Q.js";
1
+ import { F as i, H as u, I as m, G as v, T as g, J as x, b as f, K as _, c as p, L as V, M as G, l as C, y as S, D as b, N as O, O as R, n as L, t as A, z as h, A as y, C as F, m as I, B as T, P as k, Q as D, R as E, p as B, S as w, E as M, v as N } from "./geovideo-index-CzQo6UIG.js";
2
+ import { B as z, C as H, e as K, b as U, d as J, c as Q, g as j, i as q, a as W, r as X } from "./backdrop-DctkJ45Q.js";
3
3
  var e = `vec3 applyVibrance(vec3 c, float v) {
4
4
  float mx = max(c.r, max(c.g, c.b));
5
5
  float mn = min(c.r, min(c.g, c.b));
@@ -21,7 +21,13 @@ vec3 gradeColor(vec3 c, vec4 g) {
21
21
 
22
22
  c = mix(c, c * c * (3.0 - 2.0 * c), g.y);
23
23
  return clamp(applyVibrance(c, g.z), 0.0, 1.0);
24
- }`, a = `uint pcg(uint v) {
24
+ }`, a = `uniform vec2 u_code_range;
25
+ uniform vec2 u_value_range;
26
+
27
+ float geoVideoScalarValue(float r) {
28
+ float code = clamp((r - u_code_range.x) / (u_code_range.y - u_code_range.x), 0.0, 1.0);
29
+ return mix(u_value_range.x, u_value_range.y, code);
30
+ }`, o = `uint pcg(uint v) {
25
31
  uint state = v * 747796405u + 2891336453u;
26
32
  uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
27
33
  return (word >> 22u) ^ word;
@@ -29,54 +35,57 @@ vec3 gradeColor(vec3 c, vec4 g) {
29
35
 
30
36
  float random(uvec3 v) {
31
37
  return float(pcg(v.x ^ pcg(v.y ^ pcg(v.z))) >> 8u) * (1.0 / 16777216.0);
32
- }`, o = `vec3 applyVibrance(vec3 c, float v) {
38
+ }`, r = `vec3 applyVibrance(vec3 c, float v) {
33
39
  float mx = max(c.r, max(c.g, c.b));
34
40
  float mn = min(c.r, min(c.g, c.b));
35
41
  float boost = v * (1.0 - (mx - mn));
36
42
  float luma = dot(c, vec3(0.299, 0.587, 0.114));
37
43
  return mix(vec3(luma), c, 1.0 + boost);
38
44
  }`;
39
- const r = o, n = e, c = a;
45
+ const n = r, c = e, t = o, s = a;
40
46
  export {
41
- w as BACKDROP_OFF,
42
- n as COLOR_GRADE_GLSL,
43
- M as COLOR_GRADE_OFF,
44
- N as COLOR_GRADE_VIBRANT,
45
- d as GeoVideoArchiveSource,
46
- i as GeoVideoFrameSource,
47
- l as GeoVideoScalarSource,
48
- m as GeoVideoVectorSource,
49
- c as RANDOM_GLSL,
50
- u as TrailFade,
51
- r as VIBRANCE_GLSL,
52
- v as assertGeoVideoIndexIdentity,
53
- P as backdropVec4,
54
- z as colorGradeToGrade,
55
- H as colorGradeVec4,
56
- x as createColorRampTexture,
57
- g as createGeoVideoFrameSource,
47
+ z as BACKDROP_OFF,
48
+ c as COLOR_GRADE_GLSL,
49
+ H as COLOR_GRADE_OFF,
50
+ K as COLOR_GRADE_VIBRANT,
51
+ s as GEOVIDEO_SCALAR_GLSL,
52
+ i as GeoVideoArchiveSource,
53
+ u as GeoVideoFrameSource,
54
+ m as GeoVideoScalarSource,
55
+ v as GeoVideoVectorSource,
56
+ t as RANDOM_GLSL,
57
+ g as TrailFade,
58
+ n as VIBRANCE_GLSL,
59
+ x as assertGeoVideoIndexIdentity,
60
+ U as backdropVec4,
61
+ J as colorGradeToGrade,
62
+ Q as colorGradeVec4,
63
+ f as createColorRampTexture,
64
+ _ as createGeoVideoFrameSource,
58
65
  p as createProgram,
59
- f as createShader,
66
+ V as createShader,
60
67
  G as fadeToFrames,
61
- V as fadeToOpacity,
62
- C as geoVideoChunkSources,
63
- b as geoVideoGrid,
64
- S as geoVideoIndexChunks,
65
- _ as geoVideoTimelineValues,
66
- O as getPalettes,
67
- K as gradeToColorGrade,
68
- R as isGeoVideoArchiveSource,
68
+ C as fadeToOpacity,
69
+ S as formatUnit,
70
+ b as geoVideoChunkSources,
71
+ O as geoVideoGrid,
72
+ R as geoVideoIndexChunks,
73
+ L as geoVideoScalarUniforms,
74
+ A as geoVideoTimelineValues,
75
+ h as getPalettes,
76
+ j as gradeToColorGrade,
77
+ y as isGeoVideoArchiveSource,
69
78
  q as isHexColor,
70
- h as loadGeoVideoIndex,
71
- A as loadGeoVideoManifest,
72
- L as nextChunk,
73
- F as nextChunkSpan,
74
- T as pairChunk,
75
- k as pairChunkSpan,
76
- J as resolveBackdrop,
77
- Q as resolveColorGrade,
78
- y as resolveColorRamp,
79
- I as validateGeoVideoIndex,
80
- D as validateGeoVideoManifest,
81
- B as validateScalarColorDomain
79
+ F as loadGeoVideoIndex,
80
+ I as loadGeoVideoManifest,
81
+ T as nextChunk,
82
+ k as nextChunkSpan,
83
+ D as pairChunk,
84
+ E as pairChunkSpan,
85
+ W as resolveBackdrop,
86
+ X as resolveColorGrade,
87
+ B as resolveColorRamp,
88
+ w as validateGeoVideoIndex,
89
+ M as validateGeoVideoManifest,
90
+ N as validateScalarColorDomain
82
91
  };