@fxi/zartigl 0.4.1 → 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?;
@@ -1222,6 +1227,9 @@ export declare class Zartigl {
1222
1227
  private activeFieldSource;
1223
1228
  private switchGeneration;
1224
1229
  private destroyed;
1230
+ private initialized;
1231
+ private initStarted;
1232
+ private updateQueue;
1225
1233
  private suspended;
1226
1234
  private attachQueued;
1227
1235
  private querySources;
@@ -1230,24 +1238,26 @@ export declare class Zartigl {
1230
1238
  private readonly onStyleData;
1231
1239
  private readonly onMapIdle;
1232
1240
  constructor(options: ZartiglOptions);
1233
- setLayer(id: string, preference?: CatalogSourcePreference): Promise<void>;
1234
- setSource(preference: CatalogSourcePreference): Promise<void>;
1235
- show(): void;
1236
- hide(): void;
1241
+ init(): Promise<void>;
1242
+ update(change: ZartiglUpdate): Promise<void>;
1243
+ private applyUpdate;
1244
+ private loadLayer;
1245
+ private changeSource;
1246
+ private applyVisible;
1237
1247
  /** Pause rendering and abort field requests without discarding layer state. */
1238
1248
  suspend(): void;
1239
1249
  /** Resume rendering and load only the latest requested time/depth state. */
1240
1250
  resume(): void;
1241
1251
  destroy(): void;
1242
- setTime(time: Date | string | number): void;
1252
+ private applyTime;
1243
1253
  play(): Promise<void>;
1244
1254
  pause(): void;
1245
- setLoop(loop: boolean): void;
1246
- setPlaybackRate(rate: number): void;
1255
+ private applyLoop;
1256
+ private applyPlaybackRate;
1247
1257
  /** Apply or clear a time window without rebuilding source metadata or the map layer. */
1248
- setTimeRange(range?: TimeRange | null): TimeMeta;
1249
- setDepth(depth: number): void;
1250
- setTimeAndDepth(time: Date | string | number, depth: number): void;
1258
+ private applyTimeRange;
1259
+ private applyDepth;
1260
+ private applyTimeAndDepth;
1251
1261
  on<K extends keyof ZartiglEventMap>(event: K, handler: ZartiglEventMap[K]): this;
1252
1262
  off<K extends keyof ZartiglEventMap>(event: K, handler: ZartiglEventMap[K]): this;
1253
1263
  getTimeMeta(options?: {
@@ -1271,7 +1281,7 @@ export declare class Zartigl {
1271
1281
  /** Whether palette/domain styling is applied to values in the active renderer. */
1272
1282
  supportsDynamicStyle(): boolean;
1273
1283
  getDebugInfo(): ZartiglDebugInfo;
1274
- updateSettings(settings: Partial<ZartiglSettings>): void;
1284
+ private applySettings;
1275
1285
  queryTimeSeries(options: QueryPointOptions): Promise<ZarrPointSeriesResult>;
1276
1286
  queryDepthProfile(options: QueryDepthProfileOptions): Promise<ZarrPointSeriesResult>;
1277
1287
  private attachWhenReady;
@@ -1345,8 +1355,11 @@ export declare interface ZartiglOptions {
1345
1355
  id?: string;
1346
1356
  map: Map_2;
1347
1357
  catalog: Catalog;
1358
+ layer: string;
1348
1359
  source?: CatalogSourcePreference;
1349
1360
  timeRange?: TimeRange;
1361
+ time?: Date | string | number;
1362
+ depth?: number;
1350
1363
  geoVideo?: GeoVideoOptions;
1351
1364
  visible?: boolean;
1352
1365
  settings?: Partial<ZartiglSettings>;
@@ -1393,4 +1406,15 @@ export declare type ZartiglStatus = {
1393
1406
  error: Error;
1394
1407
  };
1395
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
+
1396
1420
  export { }