@fxi/zartigl 0.4.0 → 0.4.2

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
@@ -37,30 +37,29 @@ const map = new maplibregl.Map({
37
37
  zoom: 2,
38
38
  });
39
39
 
40
+ const currents = searchCatalog("ocean-current-velocity")[0];
40
41
  const z = new Zartigl({
41
42
  id: "zarr-layer",
42
43
  map,
43
44
  catalog,
45
+ layer: currents.id,
44
46
  source: "auto",
45
47
  // Optional: expose only the month ending at the latest available timestamp.
46
48
  timeRange: { trailing: "P1M" },
49
+ time: new Date("2025-01-01T00:00:00Z"),
50
+ depth: 0,
51
+ settings: { palette: "rdylbu", opacity: 0.9 },
47
52
  geoVideo: { autoplay: false, loop: true, playbackRate: 1 },
48
53
  });
49
54
 
50
- const currents = searchCatalog("ocean-current-velocity")[0];
51
- await z.setLayer(currents.id);
52
- z.setTimeAndDepth(new Date("2025-01-01T00:00:00Z"), 0);
53
- z.updateSettings({
54
- palette: "rdylbu",
55
- opacity: 0.9,
56
- });
55
+ z.on("status", (status) => console.log(status.phase));
56
+ await z.init();
57
57
  ```
58
58
 
59
- Pass a source UUID (or source type) as the optional second argument when entry
60
- and source should switch atomically. `setSource()` changes the source of the
61
- active entry.
59
+ Use `await z.update({ ... })` to change any subset of the active configuration.
60
+ Pass `layer` and `source` together when both should switch atomically.
62
61
 
63
- `setLayer()` resolves after the field store's consolidated metadata and coordinate axes have loaded. Metadata getters are therefore authoritative after the awaited call, including exact values for irregular time axes.
62
+ `init()` and layer/source updates resolve after consolidated metadata and coordinate axes have loaded. Metadata getters are therefore authoritative afterward, including exact values for irregular time axes.
64
63
 
65
64
  The root import does not bundle the catalog presets. Import catalog data from `@fxi/zartigl/catalog` only when you want the built-in catalog.
66
65
 
@@ -115,13 +114,12 @@ z.on("status", (status) => {
115
114
  // GeoVideo uses native media playback and reports scientific time updates.
116
115
  z.on("timeChange", (time) => console.log(new Date(time)));
117
116
  z.on("playbackChange", (playing) => console.log({ playing }));
118
- z.setPlaybackRate(2);
119
- z.setLoop(false);
117
+ await z.update({ geoVideo: { playbackRate: 2, loop: false } });
120
118
 
121
119
  // Embedding applications can stop rendering and abort field requests while
122
120
  // retaining the latest requested time/depth for one reload on resume.
123
121
  z.suspend();
124
- z.setTime(new Date("2025-02-01T00:00:00Z"));
122
+ await z.update({ time: new Date("2025-02-01T00:00:00Z") });
125
123
  z.resume();
126
124
 
127
125
  const series = await z.queryTimeSeries({
@@ -227,10 +225,13 @@ const map = new maplibregl.Map({
227
225
 
228
226
  map.setProjection({ type: "globe" });
229
227
 
228
+ const ice = searchCatalog("sea-ice-thickness")[0];
229
+ const video = ice.sources.find((source) => source.type === "geovideo")!;
230
230
  const z = new Zartigl({
231
231
  map,
232
232
  catalog,
233
- source: "auto",
233
+ layer: ice.id,
234
+ source: video.id,
234
235
  geoVideo: {
235
236
  autoplay: true,
236
237
  loop: true,
@@ -238,13 +239,10 @@ const z = new Zartigl({
238
239
  },
239
240
  });
240
241
 
241
- const ice = searchCatalog("sea-ice-thickness")[0];
242
- await z.setLayer(ice.id);
243
- await z.setSource(ice.sources.find((source) => source.type === "geovideo")!.id);
242
+ await z.init();
244
243
  ```
245
244
 
246
- `setSource()` selects the entry's published GeoVideo manifest by its stable
247
- source UUID. Globe projection demonstrates its polar
245
+ The source UUID selects the entry's published GeoVideo manifest. Globe projection demonstrates its polar
248
246
  coverage. `loop` and `playbackRate` are optional playback settings. Browsers
249
247
  may restrict autoplay, so embedding applications should provide a user-gesture
250
248
  fallback when necessary.
package/dist/zartigl.d.ts CHANGED
@@ -4,6 +4,8 @@ import { Map as Map_2 } from 'maplibre-gl';
4
4
 
5
5
  export declare function buildMapxWidgetSnippet(options: MapxWidgetSnippetOptions): string;
6
6
 
7
+ export declare function buildStandaloneDemoHtml(options: StandaloneDemoSnippetOptions): string;
8
+
7
9
  export declare function buildStandaloneDemoSnippet(options: StandaloneDemoSnippetOptions): string;
8
10
 
9
11
  export declare function buildWmtsLegendUrl(options: {
@@ -1192,10 +1194,13 @@ export declare class Zartigl {
1192
1194
  private readonly id;
1193
1195
  private readonly map;
1194
1196
  private readonly catalog;
1197
+ private readonly initialLayer;
1198
+ private readonly initialTime?;
1199
+ private readonly initialDepth?;
1195
1200
  private sourcePreference;
1196
1201
  private timeRange?;
1197
1202
  private fullTimeMeta;
1198
- private readonly autoplay;
1203
+ private autoplay;
1199
1204
  private loop;
1200
1205
  private playbackRate;
1201
1206
  private readonly metadata?;
@@ -1209,6 +1214,7 @@ export declare class Zartigl {
1209
1214
  private depth;
1210
1215
  private settings;
1211
1216
  private colorDomainOverridden;
1217
+ private paletteOverridden;
1212
1218
  private lastMeta;
1213
1219
  private timeMeta;
1214
1220
  private resolvedTimeRange;
@@ -1221,6 +1227,9 @@ export declare class Zartigl {
1221
1227
  private activeFieldSource;
1222
1228
  private switchGeneration;
1223
1229
  private destroyed;
1230
+ private initialized;
1231
+ private initStarted;
1232
+ private updateQueue;
1224
1233
  private suspended;
1225
1234
  private attachQueued;
1226
1235
  private querySources;
@@ -1229,24 +1238,26 @@ export declare class Zartigl {
1229
1238
  private readonly onStyleData;
1230
1239
  private readonly onMapIdle;
1231
1240
  constructor(options: ZartiglOptions);
1232
- setLayer(id: string, preference?: CatalogSourcePreference): Promise<void>;
1233
- setSource(preference: CatalogSourcePreference): Promise<void>;
1234
- show(): void;
1235
- hide(): void;
1241
+ init(): Promise<void>;
1242
+ update(change: ZartiglUpdate): Promise<void>;
1243
+ private applyUpdate;
1244
+ private loadLayer;
1245
+ private changeSource;
1246
+ private applyVisible;
1236
1247
  /** Pause rendering and abort field requests without discarding layer state. */
1237
1248
  suspend(): void;
1238
1249
  /** Resume rendering and load only the latest requested time/depth state. */
1239
1250
  resume(): void;
1240
1251
  destroy(): void;
1241
- setTime(time: Date | string | number): void;
1252
+ private applyTime;
1242
1253
  play(): Promise<void>;
1243
1254
  pause(): void;
1244
- setLoop(loop: boolean): void;
1245
- setPlaybackRate(rate: number): void;
1255
+ private applyLoop;
1256
+ private applyPlaybackRate;
1246
1257
  /** Apply or clear a time window without rebuilding source metadata or the map layer. */
1247
- setTimeRange(range?: TimeRange | null): TimeMeta;
1248
- setDepth(depth: number): void;
1249
- setTimeAndDepth(time: Date | string | number, depth: number): void;
1258
+ private applyTimeRange;
1259
+ private applyDepth;
1260
+ private applyTimeAndDepth;
1250
1261
  on<K extends keyof ZartiglEventMap>(event: K, handler: ZartiglEventMap[K]): this;
1251
1262
  off<K extends keyof ZartiglEventMap>(event: K, handler: ZartiglEventMap[K]): this;
1252
1263
  getTimeMeta(options?: {
@@ -1270,7 +1281,7 @@ export declare class Zartigl {
1270
1281
  /** Whether palette/domain styling is applied to values in the active renderer. */
1271
1282
  supportsDynamicStyle(): boolean;
1272
1283
  getDebugInfo(): ZartiglDebugInfo;
1273
- updateSettings(settings: Partial<ZartiglSettings>): void;
1284
+ private applySettings;
1274
1285
  queryTimeSeries(options: QueryPointOptions): Promise<ZarrPointSeriesResult>;
1275
1286
  queryDepthProfile(options: QueryDepthProfileOptions): Promise<ZarrPointSeriesResult>;
1276
1287
  private attachWhenReady;
@@ -1344,8 +1355,11 @@ export declare interface ZartiglOptions {
1344
1355
  id?: string;
1345
1356
  map: Map_2;
1346
1357
  catalog: Catalog;
1358
+ layer: string;
1347
1359
  source?: CatalogSourcePreference;
1348
1360
  timeRange?: TimeRange;
1361
+ time?: Date | string | number;
1362
+ depth?: number;
1349
1363
  geoVideo?: GeoVideoOptions;
1350
1364
  visible?: boolean;
1351
1365
  settings?: Partial<ZartiglSettings>;
@@ -1392,4 +1406,15 @@ export declare type ZartiglStatus = {
1392
1406
  error: Error;
1393
1407
  };
1394
1408
 
1409
+ export declare interface ZartiglUpdate {
1410
+ layer?: string;
1411
+ source?: CatalogSourcePreference;
1412
+ timeRange?: TimeRange | null;
1413
+ time?: Date | string | number;
1414
+ depth?: number;
1415
+ settings?: Partial<ZartiglSettings>;
1416
+ geoVideo?: GeoVideoOptions;
1417
+ visible?: boolean;
1418
+ }
1419
+
1395
1420
  export { }