@fxi/zartigl 0.3.1 → 0.4.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/dist/zartigl.d.ts CHANGED
@@ -2,108 +2,6 @@ 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
- export declare class ArcoLayer implements CustomLayerInterface {
6
- readonly id: string;
7
- readonly type: "custom";
8
- readonly renderingMode: "3d";
9
- readonly metadata?: Record<string, unknown>;
10
- private readonly options;
11
- private readonly backend;
12
- private delegate;
13
- private map;
14
- private rasterSourceId;
15
- private rasterLayerId;
16
- private time;
17
- private depth;
18
- private opacity;
19
- private suspended;
20
- private listeners;
21
- constructor(options: ArcoLayerOptions);
22
- getBackend(): ArcoLayerBackend;
23
- getDebugInfo(): ArcoLayerDebugInfo;
24
- onAdd(map: Map_2, gl: WebGLRenderingContext): void | Promise<void>;
25
- render(gl: WebGLRenderingContext, options: CustomRenderMethodInput): void;
26
- onRemove(): void;
27
- setTime(time: string | number): void;
28
- setTimeAndDepth(time: string | number, depth: number): void;
29
- setDepth(depth: number): void;
30
- prefetchTime(ms: number): Promise<void>;
31
- isFrameCached(ms: number): boolean;
32
- cancelPrefetches(): void;
33
- suspend(): void;
34
- resume(): void;
35
- setSpeed(v: number): void;
36
- setFade(v: number): void;
37
- setParticleDensity(density: number): void;
38
- setRenderMode(mode: RenderMode): void;
39
- setRgba8MaxParticleZoom(v: number): void;
40
- setColorRamp(ramp: ColorRampInput): void;
41
- setOpacity(v: number): void;
42
- setLogScale(v: boolean): void;
43
- setVibrance(v: number): void;
44
- setColorDomain(domain: [number, number] | null): void;
45
- play(): Promise<void>;
46
- pause(): void;
47
- setLoop(loop: boolean): void;
48
- setPlaybackRate(rate: number): void;
49
- setTimeRange(range: [number, number]): void;
50
- samplePoint(options: {
51
- longitude: number;
52
- latitude: number;
53
- time?: string | number;
54
- depth?: number;
55
- }): Promise<{
56
- longitude: number;
57
- latitude: number;
58
- value: number;
59
- unit: string;
60
- time: number;
61
- depth?: number;
62
- } | undefined>;
63
- on<K extends keyof LayerEventMap_3>(event: K, handler: LayerEventMap_3[K]): this;
64
- off<K extends keyof LayerEventMap_3>(event: K, handler: LayerEventMap_3[K]): this;
65
- private addOrUpdateWmts;
66
- private removeWmts;
67
- private emitLoaded;
68
- private emit;
69
- private getBeforeLayerId;
70
- }
71
-
72
- export declare type ArcoLayerBackend = "vector" | "scalar-zarr" | "scalar-geovideo" | "scalar-wmts";
73
-
74
- export declare type ArcoLayerBackendPreference = "auto" | "wmts" | "geovideo" | "zarr";
75
-
76
- export declare type ArcoLayerCatalogLayer = CatalogLayer;
77
-
78
- export declare type ArcoLayerDebugInfo = {
79
- id: string;
80
- backend: ArcoLayerBackend;
81
- catalogLayer: {
82
- id: string;
83
- label: string;
84
- kind: CatalogLayer["kind"];
85
- };
86
- time: string | number;
87
- depth: number;
88
- opacity: number;
89
- delegate: VectorLayerDebugInfo | ScalarLayerDebugInfo | GeoVideoLayerDebugInfo | null;
90
- };
91
-
92
- export declare interface ArcoLayerOptions extends Omit<VectorLayerOptions, "source" | "variableU" | "variableV"> {
93
- layer: ArcoLayerCatalogLayer;
94
- backend?: ArcoLayerBackendPreference;
95
- /** Fixed physical-value domain for scalar colors. Null/omitted uses frame extrema. */
96
- colorDomain?: [number, number] | null;
97
- geoVideoManifest?: GeoVideoManifest;
98
- geoVideoAutoplay?: boolean;
99
- geoVideoLoop?: boolean;
100
- geoVideoPlaybackRate?: number;
101
- geoVideoTimeRange?: [number, number];
102
- verticalLabel?: string;
103
- metadata?: Record<string, unknown>;
104
- before?: string;
105
- }
106
-
107
5
  export declare function buildMapxWidgetSnippet(options: MapxWidgetSnippetOptions): string;
108
6
 
109
7
  export declare function buildStandaloneDemoSnippet(options: StandaloneDemoSnippetOptions): string;
@@ -127,53 +25,23 @@ export declare function buildWmtsTileUrl(options: {
127
25
  }): string;
128
26
 
129
27
  export declare interface Catalog {
130
- schemaVersion: 1;
131
- layers: CatalogLayer[];
132
- }
133
-
134
- export declare interface CatalogGeoVideo {
135
- id: string;
136
- label?: string;
137
- manifestUrl: string;
28
+ schemaVersion: 2;
29
+ defaultLocale: string;
30
+ layers: CatalogEntry[];
138
31
  }
139
32
 
140
- export declare type CatalogLayer = (CatalogLayerBase & {
141
- kind: "scalar";
142
- variables: Extract<CatalogVariables, {
143
- kind: "scalar";
144
- }>;
145
- }) | (CatalogLayerBase & {
146
- kind: "vector";
147
- variables: Extract<CatalogVariables, {
148
- kind: "vector";
149
- }>;
150
- });
151
-
152
- declare interface CatalogLayerBase {
33
+ export declare interface CatalogEntry {
153
34
  id: string;
154
- label: string;
155
- description?: string;
156
- category?: string;
35
+ aliases?: string[];
36
+ title: LocalizedText;
37
+ description?: LocalizedText;
38
+ category: string;
157
39
  tags?: string[];
158
- dataset: {
159
- id: string;
160
- provider?: "copernicus" | string;
161
- productId?: string;
162
- };
163
- stores: {
164
- field: {
165
- url: string;
166
- };
167
- pointSeries?: {
168
- url: string;
169
- };
170
- wmts?: CatalogWmts;
171
- };
172
- derived?: {
173
- geoVideos?: CatalogGeoVideo[];
174
- };
175
- defaults?: {
176
- backend?: "zarr" | "geovideo" | "wmts";
40
+ kind: "scalar" | "vector";
41
+ sources: CatalogSource[];
42
+ defaults: {
43
+ sourceId: string;
44
+ querySourceId?: string;
177
45
  palette?: string;
178
46
  renderMode?: "particles" | "raster" | "raster+particles";
179
47
  particles?: {
@@ -185,12 +53,57 @@ declare interface CatalogLayerBase {
185
53
  opacity?: number;
186
54
  logScale?: boolean;
187
55
  vibrance?: number;
188
- /** Fixed physical-value domain for scalar color normalization. */
189
56
  colorDomain?: [number, number];
190
57
  };
191
58
  };
192
59
  }
193
60
 
61
+ declare interface CatalogGeoVideoSource extends CatalogSourceBase {
62
+ type: "geovideo";
63
+ manifestUrl: string;
64
+ }
65
+
66
+ declare type CatalogRenderLayerBackend = "vector-zarr" | "scalar-zarr" | "scalar-geovideo" | "scalar-wmts";
67
+
68
+ declare type CatalogRenderLayerDebugInfo = {
69
+ id: string;
70
+ backend: CatalogRenderLayerBackend;
71
+ catalogLayer: {
72
+ id: string;
73
+ title: string;
74
+ kind: CatalogEntry["kind"];
75
+ };
76
+ time: string | number;
77
+ depth: number;
78
+ opacity: number;
79
+ delegate: VectorLayerDebugInfo | ScalarLayerDebugInfo | GeoVideoLayerDebugInfo | null;
80
+ };
81
+
82
+ export declare type CatalogSource = CatalogZarrSource | CatalogWmtsSource | CatalogGeoVideoSource;
83
+
84
+ declare interface CatalogSourceBase {
85
+ id: string;
86
+ title: LocalizedText;
87
+ provenance?: CatalogSourceProvenance;
88
+ temporal?: CatalogTemporalSummary;
89
+ }
90
+
91
+ export declare type CatalogSourcePreference = "auto" | CatalogSourceType | string;
92
+
93
+ declare interface CatalogSourceProvenance {
94
+ provider: string;
95
+ identifiers?: Record<string, string>;
96
+ }
97
+
98
+ export declare type CatalogSourceType = CatalogSource["type"];
99
+
100
+ declare interface CatalogTemporalSummary {
101
+ cadence?: string;
102
+ mode: "historical" | "near-real-time" | "analysis-forecast" | "fixed";
103
+ start?: string;
104
+ end?: string;
105
+ }
106
+
194
107
  export declare type CatalogVariables = {
195
108
  kind: "scalar";
196
109
  value: string;
@@ -209,13 +122,24 @@ export declare interface CatalogVectorDerivation {
209
122
  output_direction: "from" | "toward";
210
123
  }
211
124
 
212
- export declare interface CatalogWmts {
213
- capabilities_url: string;
214
- base_url: string;
125
+ declare interface CatalogWmtsSource extends CatalogSourceBase {
126
+ type: "wmts";
127
+ capabilitiesUrl: string;
128
+ baseUrl?: string;
215
129
  layer: string;
216
- tileMatrixSet: string;
217
- format: string;
130
+ tileMatrixSet?: string;
131
+ format?: string;
218
132
  style?: string;
133
+ tileUrlTemplate?: string;
134
+ }
135
+
136
+ declare interface CatalogZarrSource extends CatalogSourceBase {
137
+ type: "zarr";
138
+ endpoints: {
139
+ field: string;
140
+ pointSeries?: string;
141
+ };
142
+ variables: CatalogVariables;
219
143
  }
220
144
 
221
145
  export declare type ColorRampInput = string | string[] | Record<number, string>;
@@ -399,7 +323,7 @@ export declare interface GeoVideoLayerOptions {
399
323
  }
400
324
 
401
325
  export declare interface GeoVideoManifest {
402
- schemaVersion: 2;
326
+ schemaVersion: 3;
403
327
  id: string;
404
328
  type: "geovideo";
405
329
  projection: "equirectangular";
@@ -432,11 +356,13 @@ export declare interface GeoVideoManifest {
432
356
  height: number;
433
357
  threshold: number;
434
358
  };
435
- timeline: GeoVideoRangeTimeline | GeoVideoSnapshotLoopTimeline;
359
+ timeline: GeoVideoRangeTimeline | GeoVideoSnapshotLoopTimeline | GeoVideoSampleSequenceTimeline;
436
360
  provenance: {
437
- layerId: string;
438
- datasetId: string;
439
- variable: string;
361
+ catalogEntryId: string;
362
+ inputSourceId: string;
363
+ provider?: string;
364
+ identifiers?: Record<string, string>;
365
+ variables: string[];
440
366
  generatedAt: string;
441
367
  };
442
368
  style: {
@@ -461,6 +387,11 @@ export declare interface GeoVideoRangeTimeline {
461
387
  interpolation: "linear" | "nearest";
462
388
  }
463
389
 
390
+ export declare interface GeoVideoSampleSequenceTimeline {
391
+ kind: "sample-sequence";
392
+ values: string[];
393
+ }
394
+
464
395
  export declare function geoVideoSecondsForTime(manifest: GeoVideoManifest, timeMs: number): number;
465
396
 
466
397
  export declare interface GeoVideoSnapshotLoopTimeline {
@@ -496,17 +427,6 @@ declare type LayerEventMap_2 = {
496
427
  cacheInvalidated: () => void;
497
428
  };
498
429
 
499
- declare type LayerEventMap_3 = {
500
- loading: () => void;
501
- loaded: (meta: FieldMeta) => void;
502
- error: (err: Error) => void;
503
- status: (status: ZartiglStatus) => void;
504
- frameBuffered: (ms: number) => void;
505
- cacheInvalidated: () => void;
506
- timeChange: (time: number) => void;
507
- playbackChange: (playing: boolean) => void;
508
- };
509
-
510
430
  export declare type Legend = {
511
431
  type: "gradient";
512
432
  palette: string;
@@ -523,9 +443,13 @@ export declare type Legend = {
523
443
 
524
444
  export declare function loadGeoVideoManifest(source: string | GeoVideoManifest, signal?: AbortSignal): Promise<GeoVideoManifest>;
525
445
 
446
+ declare type LocalizedText = Record<string, string>;
447
+
526
448
  export declare interface MapxWidgetSnippetOptions {
527
449
  layerId: string;
528
- backend?: "auto" | "zarr" | "geovideo" | "wmts";
450
+ layerKind: CatalogEntry["kind"];
451
+ source?: string;
452
+ sourceType?: SnippetSourceType;
529
453
  time?: string | number | Date;
530
454
  timeRange?: TimeRange;
531
455
  geoVideo?: GeoVideoOptions;
@@ -806,8 +730,6 @@ export declare interface ScalarLayerOptions {
806
730
  rgba8MaxParticleZoom?: number;
807
731
  }
808
732
 
809
- export declare function selectArcoLayerBackend(options: ArcoLayerOptions): ArcoLayerBackend;
810
-
811
733
  declare interface SimulationParams {
812
734
  /** Particles per screen pixel. Active count = clamp(w * h * density, 1, MAX). */
813
735
  particleDensity: number;
@@ -825,6 +747,8 @@ declare interface SimulationParams {
825
747
  rgba8MaxParticleZoom: number;
826
748
  }
827
749
 
750
+ declare type SnippetSourceType = "zarr" | "geovideo" | "wmts";
751
+
828
752
  export declare interface StandaloneDemoSnippetOptions extends MapxWidgetSnippetOptions {
829
753
  moduleBaseUrl?: string;
830
754
  center?: [number, number];
@@ -1171,7 +1095,7 @@ export declare class ZarrSource {
1171
1095
  getChunkShape(variable: string): number[];
1172
1096
  getCoords(): CoordArrays;
1173
1097
  getTimeDimension(): ZarrTimeDimension;
1174
- getVerticalDimension(): ZarrVerticalDimension | undefined;
1098
+ getVerticalDimension(variable?: string): ZarrVerticalDimension | undefined;
1175
1099
  hasVariable(variable: string): boolean;
1176
1100
  getVariableAttrs(variable: string): ZarrAttrs;
1177
1101
  getDimensions(variable: string): string[];
@@ -1229,6 +1153,17 @@ export declare class ZarrSource {
1229
1153
  lonSize: number;
1230
1154
  }>;
1231
1155
  fetchChunk(variable: string, indices: number[]): Promise<Float32Array>;
1156
+ /**
1157
+ * Fetch one latitude/longitude chunk and extract the requested time/vertical
1158
+ * plane from it. Logical coordinate indices are converted to physical Zarr
1159
+ * chunk indices before fetching.
1160
+ */
1161
+ fetchSpatialChunkResult(variable: string, selection: {
1162
+ timeIndex: number;
1163
+ verticalIndex: number;
1164
+ latitudeChunkIndex: number;
1165
+ longitudeChunkIndex: number;
1166
+ }): Promise<ZarrChunkFetchResult>;
1232
1167
  fetchChunkResult(variable: string, indices: number[]): Promise<ZarrChunkFetchResult>;
1233
1168
  cancelAll(): void;
1234
1169
  private cacheChunk;
@@ -1257,7 +1192,7 @@ export declare class Zartigl {
1257
1192
  private readonly id;
1258
1193
  private readonly map;
1259
1194
  private readonly catalog;
1260
- private readonly backendPreference;
1195
+ private sourcePreference;
1261
1196
  private timeRange?;
1262
1197
  private fullTimeMeta;
1263
1198
  private readonly autoplay;
@@ -1267,12 +1202,14 @@ export declare class Zartigl {
1267
1202
  private readonly before?;
1268
1203
  private visible;
1269
1204
  private catalogLayer;
1205
+ private catalogSource;
1270
1206
  private layer;
1271
1207
  private time;
1272
1208
  private pendingTime;
1273
1209
  private depth;
1274
1210
  private settings;
1275
1211
  private colorDomainOverridden;
1212
+ private paletteOverridden;
1276
1213
  private lastMeta;
1277
1214
  private timeMeta;
1278
1215
  private resolvedTimeRange;
@@ -1280,6 +1217,7 @@ export declare class Zartigl {
1280
1217
  private variableUnit;
1281
1218
  private variableStandardName;
1282
1219
  private geoVideoManifest;
1220
+ private wmtsMetadata;
1283
1221
  private fieldSources;
1284
1222
  private activeFieldSource;
1285
1223
  private switchGeneration;
@@ -1292,7 +1230,8 @@ export declare class Zartigl {
1292
1230
  private readonly onStyleData;
1293
1231
  private readonly onMapIdle;
1294
1232
  constructor(options: ZartiglOptions);
1295
- setLayer(id: string): Promise<void>;
1233
+ setLayer(id: string, preference?: CatalogSourcePreference): Promise<void>;
1234
+ setSource(preference: CatalogSourcePreference): Promise<void>;
1296
1235
  show(): void;
1297
1236
  hide(): void;
1298
1237
  /** Pause rendering and abort field requests without discarding layer state. */
@@ -1318,20 +1257,30 @@ export declare class Zartigl {
1318
1257
  getVariableMeta(): VariableMeta;
1319
1258
  getLegend(): Legend;
1320
1259
  getPalettes(): PaletteMeta[];
1321
- getBackend(): "zarr" | "geovideo" | "wmts" | undefined;
1260
+ getSource(): {
1261
+ id: string;
1262
+ type: CatalogSource["type"];
1263
+ } | undefined;
1264
+ getCapabilities(): {
1265
+ render: true;
1266
+ time: boolean;
1267
+ depth: boolean;
1268
+ pointQuery: boolean;
1269
+ sourceTypes: CatalogSource["type"][];
1270
+ };
1322
1271
  /** Whether palette/domain styling is applied to values in the active renderer. */
1323
1272
  supportsDynamicStyle(): boolean;
1324
1273
  getDebugInfo(): ZartiglDebugInfo;
1325
1274
  updateSettings(settings: Partial<ZartiglSettings>): void;
1326
1275
  queryTimeSeries(options: QueryPointOptions): Promise<ZarrPointSeriesResult>;
1327
1276
  queryDepthProfile(options: QueryDepthProfileOptions): Promise<ZarrPointSeriesResult>;
1328
- private activeBackendPreference;
1329
- private backendForLayer;
1330
1277
  private attachWhenReady;
1331
1278
  private detach;
1332
1279
  private applyMutableSettings;
1333
1280
  private getQuerySource;
1334
1281
  private getFieldSource;
1282
+ private resolveSource;
1283
+ private querySource;
1335
1284
  private isMapReady;
1336
1285
  private getBeforeLayerId;
1337
1286
  private requireLayer;
@@ -1346,8 +1295,11 @@ export declare interface ZartiglDebugInfo {
1346
1295
  destroyed: boolean;
1347
1296
  visible: boolean;
1348
1297
  suspended: boolean;
1349
- backendPreference: "auto" | "zarr" | "geovideo" | "wmts";
1350
- activeBackend?: "zarr" | "geovideo" | "wmts";
1298
+ sourcePreference: CatalogSourcePreference;
1299
+ activeSource?: {
1300
+ id: string;
1301
+ type: CatalogSource["type"];
1302
+ };
1351
1303
  projection?: string;
1352
1304
  canvasSize?: {
1353
1305
  width: number;
@@ -1358,17 +1310,17 @@ export declare interface ZartiglDebugInfo {
1358
1310
  height: number;
1359
1311
  };
1360
1312
  devicePixelRatio?: number;
1361
- catalogLayer: {
1313
+ catalogEntry: {
1362
1314
  id: string;
1363
- label: string;
1364
- kind: CatalogLayer["kind"];
1315
+ title: string;
1316
+ kind: CatalogEntry["kind"];
1365
1317
  } | null;
1366
1318
  time: number;
1367
1319
  depth: number;
1368
1320
  settings: Partial<ZartiglSettings>;
1369
1321
  timeRange?: TimeRange;
1370
1322
  geoVideo: Required<GeoVideoOptions>;
1371
- layer: ArcoLayerDebugInfo | null;
1323
+ layer: CatalogRenderLayerDebugInfo | null;
1372
1324
  }
1373
1325
 
1374
1326
  declare type ZartiglEventMap = {
@@ -1393,7 +1345,7 @@ export declare interface ZartiglOptions {
1393
1345
  id?: string;
1394
1346
  map: Map_2;
1395
1347
  catalog: Catalog;
1396
- backend?: "auto" | "zarr" | "geovideo" | "wmts";
1348
+ source?: CatalogSourcePreference;
1397
1349
  timeRange?: TimeRange;
1398
1350
  geoVideo?: GeoVideoOptions;
1399
1351
  visible?: boolean;