tauri-plugin-live-activity 0.6.0 → 0.7.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.
@@ -20,6 +20,46 @@ export interface Capabilities {
20
20
  /** Pushes: tokens, channels and push-to-start (iOS). */
21
21
  readonly push: FeatureSupport;
22
22
  readonly maxPayloadBytes: number;
23
+ /**
24
+ * Which notification styles the device draws and what else it offers, for the `android` content of a snapshot and
25
+ * for what follows a device: another style in an update, an update that alerts, a last content that stays. Android
26
+ * only.
27
+ */
28
+ readonly androidPresentation?: AndroidPresentationSupport;
29
+ }
30
+ /**
31
+ * The notification styles an Android device draws, and what it offers beside them. A member that the Android side
32
+ * does not report is false.
33
+ */
34
+ export interface AndroidPresentationSupport {
35
+ readonly standard: boolean;
36
+ readonly bigText: boolean;
37
+ /** The timer style: a clock in the header and nothing else. */
38
+ readonly timer: boolean;
39
+ /** A progress with segments and points: Android 16. */
40
+ readonly progressStyle: boolean;
41
+ /** Up to three metrics: Android 17. */
42
+ readonly metricStyle: boolean;
43
+ readonly actions: boolean;
44
+ readonly images: boolean;
45
+ readonly events: boolean;
46
+ readonly samsungNowBar: boolean;
47
+ /** A clock in the header beside another style: the `chronometer` of a content, and a layout's timer beside its progress. */
48
+ readonly chronometer: boolean;
49
+ /** URLs that a tap on the notification or on an action opens in the app, and what `onOpened` reports. */
50
+ readonly links: boolean;
51
+ /** A snapshot of another notification style than the one the activity shows; `UNSUPPORTED_FEATURE` without it. */
52
+ readonly styleChange: boolean;
53
+ /** An end with the policy `after`, whose last content stays until its time; `UNSUPPORTED_FEATURE` without it. */
54
+ readonly delayedEnd: boolean;
55
+ /** The `foreground` placement of a start; `UNSUPPORTED_FEATURE` without it. */
56
+ readonly foregroundPlacement: boolean;
57
+ /** An update that alerts again. Without it the update is silent and the record names `alert`. */
58
+ readonly alert: boolean;
59
+ /** What a secure lock screen shows in place of the content of a private activity. */
60
+ readonly publicVersion: boolean;
61
+ /** A small icon, an accent color and a sub text. */
62
+ readonly branding: boolean;
23
63
  }
24
64
  export interface Permissions {
25
65
  readonly notifications: PermissionState;
@@ -128,6 +168,221 @@ export interface LayoutSnapshot {
128
168
  * shows; without it iOS takes the time the content is sent. Android keeps it in the record.
129
169
  */
130
170
  readonly timestamp?: number;
171
+ /**
172
+ * Which of the app's activities the Dynamic Island shows first: the highest score wins. Without it the activity
173
+ * keeps its score, 0 at first. Android ignores it, and an Android record does not repeat it.
174
+ */
175
+ readonly relevance?: number;
176
+ /**
177
+ * What Android shows for this snapshot instead of the projection of the layout. iOS ignores it, and an iOS record
178
+ * does not repeat it.
179
+ */
180
+ readonly android?: AndroidContent;
181
+ }
182
+ /**
183
+ * What the Android notification shows for a snapshot, in Android's own terms: a progress with segments and points,
184
+ * metrics, the text of the status chip, icons of actions, the URL a tap opens, a clock in the header. It is checked
185
+ * on every platform, so a wrong one is `INVALID_INPUT` on iOS too.
186
+ *
187
+ * A snapshot may have another notification style than the one the activity shows, a content of another style or the
188
+ * projection of the layout after a content, where the device offers `styleChange`; elsewhere it is
189
+ * `UNSUPPORTED_FEATURE` on Android, and the activity keeps what it shows. `getCapabilities().androidPresentation`
190
+ * says which styles the device draws and which members of a presentation it offers. A tap on one of its actions comes
191
+ * through `onAction`, unless the action opens a URL.
192
+ */
193
+ export interface AndroidContent {
194
+ /** The notification's title, 1 to 120 code points. */
195
+ readonly title: string;
196
+ /** The notification's text, 1 to 240 code points. */
197
+ readonly status: string;
198
+ readonly presentation: AndroidPresentation;
199
+ }
200
+ /**
201
+ * The liveupdate crate's presentation of a notification. The members from `chronometer` on each need a device that
202
+ * offers them, under the name their comment gives in `getCapabilities().androidPresentation`. A content is shown as
203
+ * given or not at all: one that uses a member the device does not offer is `UNSUPPORTED_FEATURE` on Android. The
204
+ * `alert` is the exception, since a revision can be shown without alerting.
205
+ */
206
+ export interface AndroidPresentation {
207
+ readonly style: AndroidStyle;
208
+ /** The text of the status chip, at most 7 code points. */
209
+ readonly shortCriticalText?: string;
210
+ readonly largeIcon?: AndroidIcon;
211
+ /** Up to three. */
212
+ readonly actions?: readonly AndroidAction[];
213
+ /** The texts of Samsung's Now Bar, where the title and the status are not what it should show. */
214
+ readonly samsungNowBar?: {
215
+ readonly primary?: string;
216
+ readonly secondary?: string;
217
+ };
218
+ /** A clock in the header, beside any style but `timer`, which is that clock alone (`chronometer`). */
219
+ readonly chronometer?: AndroidTimerStyle;
220
+ /**
221
+ * The URL a tap on the notification opens in the app (`links`); without it a tap opens the launch activity. 1 to
222
+ * 2048 printable ASCII characters with a lowercase scheme, which is none of `intent`, `content`, `file`,
223
+ * `javascript`, `data` and `android-app`. An activity of the app declares the scheme: a URL that nothing in the
224
+ * app opens is `INVALID_INPUT` on Android, and the content is not posted.
225
+ */
226
+ readonly openUrl?: string;
227
+ /**
228
+ * Whether this revision alerts again (`alert`); every other one updates silently. The `alert` of an update sets it
229
+ * for both platforms. On a device that does not offer it the revision is silent, and the record names `alert` in
230
+ * `degradedFeatures`.
231
+ */
232
+ readonly alert?: boolean;
233
+ /**
234
+ * What a secure lock screen shows in place of this content (`publicVersion`). Only for an activity that started as
235
+ * `private`, as one does without `android.visibility`: `INVALID_INPUT` for another.
236
+ */
237
+ readonly publicVersion?: AndroidPublicVersion;
238
+ /**
239
+ * The small icon, a drawable or mipmap resource of the app and never a file (`branding`); without it the plugin's
240
+ * own icon. A name that is no resource of the app is `INVALID_INPUT` on Android, and the content is not posted.
241
+ */
242
+ readonly smallIcon?: Extract<AndroidIcon, {
243
+ readonly kind: 'resource';
244
+ }>;
245
+ /** The color of the icon and the header, an unsigned ARGB number such as `0xff2196f3` (`branding`). */
246
+ readonly accentColor?: number;
247
+ /** The third text of the header, at most 64 code points (`branding`). */
248
+ readonly subText?: string;
249
+ }
250
+ export type AndroidStyle = {
251
+ readonly kind: 'standard';
252
+ } | {
253
+ readonly kind: 'bigText';
254
+ readonly value: {
255
+ readonly text: string;
256
+ readonly summary?: string;
257
+ };
258
+ } | {
259
+ readonly kind: 'progress';
260
+ readonly value: AndroidProgressStyle;
261
+ } | {
262
+ readonly kind: 'timer';
263
+ readonly value: AndroidTimerStyle;
264
+ } | {
265
+ readonly kind: 'metric';
266
+ readonly value: {
267
+ readonly metrics: readonly AndroidMetric[];
268
+ readonly criticalMetric?: number;
269
+ };
270
+ };
271
+ /** A clock in the header of the notification: down to the end of its timer, or up from its start. */
272
+ export interface AndroidTimerStyle {
273
+ readonly timer: Timer;
274
+ readonly countsDown: boolean;
275
+ }
276
+ /** What a secure lock screen shows in place of the content of a private activity. */
277
+ export interface AndroidPublicVersion {
278
+ /** 1 to 120 code points. */
279
+ readonly title: string;
280
+ /** 1 to 240 code points. */
281
+ readonly status: string;
282
+ }
283
+ export type AndroidSemanticStyle = 'unspecified' | 'info' | 'safe' | 'caution' | 'danger';
284
+ /** A drawable or mipmap resource of the app by name, or a file under the app's files, such as one `writeImage` wrote. */
285
+ export type AndroidIcon = {
286
+ readonly kind: 'resource';
287
+ readonly value: string;
288
+ } | {
289
+ readonly kind: 'appFile';
290
+ readonly value: string;
291
+ };
292
+ export interface AndroidAction {
293
+ /** Reported by `onAction`: starts with a letter or digit, then letters, digits or `._:-`, 64 characters at most. */
294
+ readonly id: string;
295
+ /** 1 to 64 code points. */
296
+ readonly title: string;
297
+ readonly icon?: AndroidIcon;
298
+ /** Whether Android asks the person to unlock before the tap is sent. */
299
+ readonly authenticationRequired?: boolean;
300
+ /**
301
+ * The URL the action opens in the app, by the rules of the presentation's `openUrl` (`links`). Such an action sends
302
+ * no tap: `onOpened` reports the opening with the action's `id`.
303
+ */
304
+ readonly openUrl?: string;
305
+ }
306
+ /**
307
+ * Android 16 draws the segments, the points and the icons; Android 17 also their semantic styles. Below Android 16
308
+ * it is a plain bar.
309
+ */
310
+ export interface AndroidProgressStyle {
311
+ /** In the units of the segments, at most their sum. */
312
+ readonly progress: number;
313
+ readonly indeterminate?: boolean;
314
+ /** Whether Android draws the part behind the progress differently from the part ahead. */
315
+ readonly styledByProgress?: boolean;
316
+ /** 1 to 32. */
317
+ readonly segments: readonly AndroidProgressElement<'length'>[];
318
+ /** Up to 32, each after the one before. */
319
+ readonly points?: readonly AndroidProgressElement<'position'>[];
320
+ readonly startIcon?: AndroidIcon;
321
+ readonly endIcon?: AndroidIcon;
322
+ readonly trackerIcon?: AndroidIcon;
323
+ }
324
+ /** A segment, with its `length`, or a point, with its `position`: a positive integer, and an optional ARGB color. */
325
+ export type AndroidProgressElement<Measure extends 'length' | 'position'> = {
326
+ readonly [M in Measure]: number;
327
+ } & {
328
+ readonly id?: number;
329
+ readonly color?: number;
330
+ readonly semanticStyle?: AndroidSemanticStyle;
331
+ };
332
+ export interface AndroidMetric {
333
+ /** At most 10 code points. */
334
+ readonly label: string;
335
+ readonly value: AndroidMetricValue;
336
+ readonly semanticStyle?: AndroidSemanticStyle;
337
+ }
338
+ /**
339
+ * A number with an optional unit of at most 8 code points, a text of at most 64, a stopwatch that runs from
340
+ * `startedAt` or a countdown that runs to `endsAt`, both UTC Unix epoch milliseconds.
341
+ */
342
+ export type AndroidMetricValue = {
343
+ readonly kind: 'integer';
344
+ readonly value: {
345
+ readonly value: number;
346
+ readonly unit?: string;
347
+ };
348
+ } | {
349
+ readonly kind: 'decimal';
350
+ readonly value: {
351
+ readonly value: number;
352
+ readonly unit?: string;
353
+ };
354
+ } | {
355
+ readonly kind: 'text';
356
+ readonly value: string;
357
+ } | {
358
+ readonly kind: 'stopwatch';
359
+ readonly value: {
360
+ readonly startedAt: number;
361
+ };
362
+ } | {
363
+ readonly kind: 'countdown';
364
+ readonly value: {
365
+ readonly endsAt: number;
366
+ };
367
+ };
368
+ /**
369
+ * An alert that comes with an update, or with a scheduled start. On iOS the device lights up, the Dynamic Island
370
+ * expands and an Apple Watch shows the title and the body. On Android the notification alerts again with that
371
+ * revision, with its own title and text, where the device offers `alert` (`getCapabilities().androidPresentation`);
372
+ * elsewhere the update is silent and the record names `alert` in `degradedFeatures`.
373
+ */
374
+ export interface LayoutAlert {
375
+ /** 1 to 120 code points. */
376
+ readonly title: string;
377
+ /** 1 to 240 code points. */
378
+ readonly body: string;
379
+ /**
380
+ * The sound of the alert on iOS: the file name of a sound in the app's bundle or in its `Library/Sounds`, such as
381
+ * `chime.aiff`, 1 to 64 ASCII letters, digits, `.`, `_` and `-`, starting with a letter or digit. Without it the
382
+ * system plays its default sound. Android alerts with the sound of its channel, which is the person's choice, and
383
+ * the record names `alert.sound` in `degradedFeatures`.
384
+ */
385
+ readonly sound?: string;
131
386
  }
132
387
  type ColorName = 'primary' | 'secondary' | 'accent' | 'red' | 'orange' | 'yellow' | 'green' | 'mint' | 'teal' | 'cyan' | 'blue' | 'indigo' | 'purple' | 'pink' | 'brown' | 'white' | 'black' | 'gray' | 'clear';
133
388
  /** `#RRGGBB` or `#RRGGBBAA`. */
@@ -140,7 +395,8 @@ export type LayoutColor = ColorName | HexColor | {
140
395
  /**
141
396
  * A value key in place of a literal, as `layout.bind(key)` writes it. The member reads the value on
142
397
  * every render, so an update can change it. The value must be what the member takes as a literal: a
143
- * color name or a hex color (not a light and dark pair), a weight name, or a number in the member's range.
398
+ * color name or a hex color (not a light and dark pair), a weight name, a number in the member's range, or
399
+ * a URL. A member of a node's `accessibility` reads a value of any type.
144
400
  */
145
401
  export interface LayoutBound {
146
402
  readonly bind: string;
@@ -159,6 +415,8 @@ export interface LayoutFrame {
159
415
  readonly maxHeight?: number | 'infinity';
160
416
  readonly alignment?: Anchor;
161
417
  }
418
+ /** Points from 0 to 64: one number for every edge, or `[top, leading, bottom, trailing]`. */
419
+ export type LayoutPadding = number | readonly [number, number, number, number];
162
420
  /**
163
421
  * `weight`, `color`, `background`, `cornerRadius`, `opacity`, `tint` and `size` may be bound to a value
164
422
  * with `layout.bind(key)`. The other members are fixed at start.
@@ -174,17 +432,21 @@ interface StyleFields {
174
432
  readonly minimumScaleFactor?: number;
175
433
  /** Alignment of text that spans several lines. */
176
434
  readonly alignment?: 'leading' | 'center' | 'trailing';
177
- /** Points from 0 to 64: one number for every edge, or `[top, leading, bottom, trailing]`. */
178
- readonly padding?: number | readonly [number, number, number, number];
435
+ readonly padding?: LayoutPadding;
179
436
  readonly frame?: LayoutFrame;
180
437
  readonly background?: LayoutBindable<LayoutColor>;
181
438
  /** Points from 0 to 64. */
182
439
  readonly cornerRadius?: LayoutBindable<number>;
183
440
  /** From 0 to 1. */
184
441
  readonly opacity?: LayoutBindable<number>;
185
- /** Tint of buttons, progress views and gauges. */
442
+ /** Tint of buttons, toggles, progress views and gauges. */
186
443
  readonly tint?: LayoutBindable<LayoutColor>;
187
444
  readonly buttonStyle?: 'automatic' | 'bordered' | 'borderedProminent' | 'plain';
445
+ /**
446
+ * How text and symbols with the style change when an update gives them another value. `numericText` rolls the
447
+ * digits upward, `numericTextDown` the other way.
448
+ */
449
+ readonly contentTransition?: 'numericText' | 'numericTextDown' | 'opacity' | 'interpolate' | 'identity';
188
450
  }
189
451
  /**
190
452
  * At least one member. `font`, a system text style, and `size`, points from 6 to 96, exclude each other.
@@ -206,10 +468,52 @@ export type LayoutStyle = StyleFields & ({
206
468
  readonly fontFamily?: string;
207
469
  readonly design?: never;
208
470
  });
471
+ /**
472
+ * What a node tells assistive technologies such as VoiceOver: at least one member. `label`, `value` and `hint` are
473
+ * text of 1 to 200 code points, or `layout.bind(key)` for a value of any type, which is read as a text node shows it;
474
+ * a value that is missing or empty leaves its member out. On a stack or a custom node, any of the three makes the
475
+ * node one element that stands for what is inside; a button or a link inside stays an action of it. Without a member
476
+ * the system reads its own: the text of a text node, the title of a button, the name of an SF Symbol. A path, an
477
+ * image and a custom view have none: label them or hide them. Android has no label per node.
478
+ */
479
+ export type LayoutAccessibility = {
480
+ /** What the node is, in a few words. */
481
+ readonly label?: LayoutBindable<string>;
482
+ /** What the node shows now, such as `40 percent`. */
483
+ readonly value?: LayoutBindable<string>;
484
+ /** What happens when the person acts on the node. */
485
+ readonly hint?: LayoutBindable<string>;
486
+ readonly hidden?: false;
487
+ }
488
+ /** `hidden: true` hides the node and its subtree, for what is decoration, and then stands alone. */
489
+ | {
490
+ readonly hidden: true;
491
+ readonly label?: never;
492
+ readonly value?: never;
493
+ readonly hint?: never;
494
+ };
495
+ /** How a node comes and goes when its `if` or `unless` shows or hides it. iOS runs these and no others. */
496
+ export type LayoutTransition = 'opacity' | 'slide' | 'moveTop' | 'moveBottom' | 'moveLeading' | 'moveTrailing' | 'pushTop' | 'pushBottom' | 'pushLeading' | 'pushTrailing';
209
497
  /** Members every node may carry. A condition names a value key; `if` and `unless` exclude each other. */
210
498
  type NodeFields = {
211
499
  /** A token of the request's `styles` table. */
212
500
  readonly style?: string;
501
+ /**
502
+ * `true`: the node and its subtree are drawn only while the content is stale; `false`: only while it is not.
503
+ * Content is stale once the snapshot's `staleAt` has passed and no newer content has come: iOS then draws the stale
504
+ * nodes without an update and without the app running. Beside `if` or `unless` the node is drawn while both hold.
505
+ * Android draws the layout as it is while fresh and names `layout.ifStale` in `degradedFeatures`.
506
+ */
507
+ readonly ifStale?: boolean;
508
+ /** What assistive technologies read of the node. */
509
+ readonly accessibility?: LayoutAccessibility;
510
+ /** How the node comes and goes when its `if` or `unless` shows or hides it. Without it the system chooses. */
511
+ readonly transition?: LayoutTransition;
512
+ /**
513
+ * `sensitive` marks what the node and its subtree show as private: iOS hides it on a locked device and in the
514
+ * always-on display when the person has asked for that.
515
+ */
516
+ readonly privacy?: 'sensitive';
213
517
  } & ({
214
518
  readonly if?: string;
215
519
  readonly unless?: never;
@@ -316,13 +620,45 @@ export type LayoutTimerTextNode = NodeFields & {
316
620
  /** Defaults to true. */
317
621
  readonly countsDown?: boolean;
318
622
  };
319
- /** Allowed in the lock screen and the expanded regions, never inside another button. */
623
+ /**
624
+ * Allowed in the lock screen and the expanded regions, never inside a button, a link or a toggle. A region holds at
625
+ * most 4 buttons, links and toggles together.
626
+ */
320
627
  export type LayoutButtonNode = NodeFields & {
321
628
  readonly type: 'button';
322
629
  /** Reported by `onAction`: starts with a letter or digit, then letters, digits or `._:-`, 64 characters at most. */
323
630
  readonly actionId: string;
324
631
  readonly child: LayoutNode;
325
632
  };
633
+ /**
634
+ * A tap on the child opens the app with the URL, which the app receives as any URL it is opened with; no event
635
+ * reports it on iOS. A link stands where a button may, and neither holds the other. On Android, where the device
636
+ * offers `links`, it is an action of the notification that opens its URL, and `onOpened` reports it.
637
+ */
638
+ export type LayoutLinkNode = NodeFields & {
639
+ readonly type: 'link';
640
+ /**
641
+ * 1 to 1024 ASCII characters: a scheme, a colon and at least one more character, such as `myapp://delivery/7`, in
642
+ * the characters of RFC 3986 with a `%` only before two hex digits. Or `layout.bind(key)` for a text value that is
643
+ * such a URL. Only the form is checked: the app decides what it follows.
644
+ */
645
+ readonly url: LayoutBindable<string>;
646
+ readonly child: LayoutNode;
647
+ };
648
+ /**
649
+ * A switch beside its label (iOS 17; before, the label alone). It shows the boolean value of `bind`. A tap comes
650
+ * through `onAction` with `on`, the state the person asked for, and does not move the switch: send an update with
651
+ * the new value, or none to refuse the change. A toggle stands where a button may.
652
+ */
653
+ export type LayoutToggleNode = NodeFields & {
654
+ readonly type: 'toggle';
655
+ /** Reported by `onAction`, as a button's. */
656
+ readonly actionId: string;
657
+ /** Key of a boolean value: the state the switch shows. */
658
+ readonly bind: string;
659
+ /** The label. */
660
+ readonly child: LayoutNode;
661
+ };
326
662
  /**
327
663
  * A SwiftUI view that the app registers under `name` in LiveActivityCustomViews.swift of its widget extension.
328
664
  * A name without a view draws nothing and is reported in `degradedFeatures` as `layout.custom.<name>`; Android
@@ -340,25 +676,51 @@ export type LayoutCustomNode = NodeFields & {
340
676
  readonly [name: string]: LayoutBindable<LayoutValue>;
341
677
  };
342
678
  };
343
- export type LayoutNode = LayoutVStackNode | LayoutHStackNode | LayoutZStackNode | LayoutSpacerNode | LayoutDividerNode | LayoutTextNode | LayoutSymbolNode | LayoutImageNode | LayoutPathNode | LayoutProgressNode | LayoutGaugeNode | LayoutTimerTextNode | LayoutButtonNode | LayoutCustomNode;
344
- /** At least one region, each of at most 12 nodes. */
679
+ export type LayoutNode = LayoutVStackNode | LayoutHStackNode | LayoutZStackNode | LayoutSpacerNode | LayoutDividerNode | LayoutTextNode | LayoutSymbolNode | LayoutImageNode | LayoutPathNode | LayoutProgressNode | LayoutGaugeNode | LayoutTimerTextNode | LayoutButtonNode | LayoutLinkNode | LayoutToggleNode | LayoutCustomNode;
680
+ /** At least one region, each of at most 12 nodes. `priority` and `belowIfTooWide` are options, and no region. */
345
681
  export interface LayoutIslandExpanded {
346
682
  readonly leading?: LayoutNode;
347
683
  readonly trailing?: LayoutNode;
348
684
  readonly center?: LayoutNode;
349
685
  readonly bottom?: LayoutNode;
686
+ /**
687
+ * At least one member, each a number from 0 to 100 for a region the layout has. The region with the higher one gets
688
+ * the width first; a region without one has 0.
689
+ */
690
+ readonly priority?: {
691
+ readonly leading?: number;
692
+ readonly trailing?: number;
693
+ readonly center?: number;
694
+ readonly bottom?: number;
695
+ };
696
+ /**
697
+ * The regions beside the camera that go below it when they are too wide to stand beside it: `leading`, `trailing`
698
+ * or both, each once and each a region the layout has.
699
+ */
700
+ readonly belowIfTooWide?: readonly ('leading' | 'trailing')[];
701
+ }
702
+ /**
703
+ * The margins between a presentation of the Dynamic Island and what it shows, as a style's `padding`. At least one
704
+ * member; a presentation without them keeps the system's.
705
+ */
706
+ export interface LayoutIslandMargins {
707
+ readonly expanded?: LayoutPadding;
708
+ readonly compactLeading?: LayoutPadding;
709
+ readonly compactTrailing?: LayoutPadding;
710
+ readonly minimal?: LayoutPadding;
350
711
  }
351
- /** At least one member; a missing part renders a default. */
712
+ /** At least one part; a missing part renders a default. `margins` are an option, and no part. */
352
713
  export interface LayoutIsland {
353
714
  readonly expanded?: LayoutIslandExpanded;
354
- /** At most 3 nodes and no button. */
715
+ /** At most 3 nodes and no button, link or toggle. */
355
716
  readonly compactLeading?: LayoutNode;
356
- /** At most 3 nodes and no button. */
717
+ /** At most 3 nodes and no button, link or toggle. */
357
718
  readonly compactTrailing?: LayoutNode;
358
- /** At most 2 nodes and no button. */
719
+ /** At most 3 nodes and no button, link or toggle. */
359
720
  readonly minimal?: LayoutNode;
721
+ readonly margins?: LayoutIslandMargins;
360
722
  }
361
- /** Trees are at most 8 levels deep and hold at most 4 buttons per region. */
723
+ /** Trees are at most 8 levels deep and hold at most 4 buttons, links and toggles per region. */
362
724
  export interface Layout {
363
725
  /** At most 40 nodes. */
364
726
  readonly lockScreen: LayoutNode;
@@ -367,10 +729,31 @@ export interface Layout {
367
729
  readonly background?: LayoutBindable<LayoutColor>;
368
730
  /** Tint of the Dynamic Island keyline. */
369
731
  readonly keyline?: LayoutBindable<LayoutColor>;
732
+ /**
733
+ * The URL a tap on the activity opens the app with, on the Lock Screen and in every presentation of the Dynamic
734
+ * Island: a URL as a link node's, or `layout.bind(key)` for a text value that is one. Without it a tap opens the
735
+ * app without a URL. On Android, where the device offers `links`, it is what a tap on the notification opens.
736
+ */
737
+ readonly url?: LayoutBindable<string>;
370
738
  }
739
+ /** What only Android reads of a start. */
371
740
  export interface LayoutAndroidOptions {
372
- /** Lock screen visibility of the notification. */
741
+ /** Lock screen visibility of the notification. A start without `android` is `private`. */
373
742
  readonly visibility: 'public' | 'private' | 'secret';
743
+ /**
744
+ * What a secure lock screen shows in place of the content. Only with the visibility `private`: `INVALID_INPUT`
745
+ * otherwise, on every platform. It goes with every snapshot that has no public version of its own. On a device that
746
+ * does not offer `publicVersion` the snapshot is shown without it, and the record names `publicVersion` in
747
+ * `degradedFeatures`.
748
+ */
749
+ readonly publicVersion?: AndroidPublicVersion;
750
+ /**
751
+ * How Android keys the notification. `tagged`, which it is when absent, is a notification of its own. `foreground`
752
+ * is the one that a foreground service of the app holds, so that the service shows no second one: one running
753
+ * activity has it at a time (`SYSTEM_LIMIT` for a second), and a device that does not offer `foregroundPlacement`
754
+ * answers `UNSUPPORTED_FEATURE`.
755
+ */
756
+ readonly placement?: 'tagged' | 'foreground';
374
757
  }
375
758
  /**
376
759
  * What a layout activity asks ActivityKit for on iOS: a push token of its own, which `onPushToken` reports, or a
@@ -379,6 +762,29 @@ export interface LayoutAndroidOptions {
379
762
  export type LayoutPush = 'token' | {
380
763
  readonly channel: string;
381
764
  };
765
+ /**
766
+ * What only iOS reads of a start. Android ignores it, and the options are no part of what makes two starts the same
767
+ * activity.
768
+ */
769
+ export interface LayoutIosOptions {
770
+ /**
771
+ * `true` asks for a transient activity (iOS 18; `UNSUPPORTED_FEATURE` before). By Apple's description it shows in
772
+ * the expanded Dynamic Island, and the system ends it when the person locks the device, collapses that presentation
773
+ * or leaves the app.
774
+ */
775
+ readonly transient: boolean;
776
+ }
777
+ /**
778
+ * A start at a later time instead of now (iOS 26; an older iOS and Android answer `UNSUPPORTED_FEATURE`, and nothing
779
+ * is kept). Until then the record is `pending`: the activity holds its key, it can be ended, and an update is
780
+ * `CONFLICT`, since it begins with the content of its start. `onState` reports `active` when it begins.
781
+ */
782
+ export interface LayoutScheduledStart {
783
+ /** UTC Unix epoch milliseconds. A time that has passed starts the activity at once. */
784
+ readonly at: number;
785
+ /** The alert the system shows when it starts the activity: it requires one. */
786
+ readonly alert: LayoutAlert;
787
+ }
382
788
  export interface LayoutStartInput {
383
789
  /** Stable app-owned key; do not put credentials or private data in this key. */
384
790
  readonly activityKey: string;
@@ -395,12 +801,18 @@ export interface LayoutStartInput {
395
801
  /** Ignored on iOS. */
396
802
  readonly android?: LayoutAndroidOptions;
397
803
  /** Ignored on Android. */
804
+ readonly ios?: LayoutIosOptions;
805
+ /** Starts the activity at a later time instead of now. */
806
+ readonly scheduled?: LayoutScheduledStart;
807
+ /** Ignored on Android. */
398
808
  readonly push?: LayoutPush;
399
809
  }
400
810
  export interface LayoutUpdateInput {
401
811
  readonly id: string;
402
812
  /** Complete replacement snapshot, not a partial update. */
403
813
  readonly snapshot: LayoutSnapshot;
814
+ /** An alert that comes with the update; without it the update is silent. */
815
+ readonly alert?: LayoutAlert;
404
816
  }
405
817
  /**
406
818
  * The end of a layout activity. With `snapshot` it ends with that final content, checked as an update; without one it
@@ -444,6 +856,24 @@ export interface PushToStartTokenEvent {
444
856
  export interface UpdatedEvent {
445
857
  readonly record: LayoutActivityRecord;
446
858
  }
859
+ /** A layout activity that began while the app ran: one the app started, or one a push started (iOS). */
860
+ export interface StartedEvent {
861
+ readonly record: LayoutActivityRecord;
862
+ }
863
+ /**
864
+ * A new lifecycle state of an activity, of a template or a layout. iOS reports the changes ActivityKit tells of
865
+ * while the app runs. Android reports the state an activity has when the plugin looks, if it is another than the
866
+ * one it reported last: `active` once Android shows the notification, `stale` after the snapshot's `staleAt`,
867
+ * `ended`, and `dismissed` when the person removed the notification. An activity is over at `ended` and at
868
+ * `dismissed`: take either as its end.
869
+ */
870
+ export interface StateEvent {
871
+ /** Handle of the activity. */
872
+ readonly activityId: string;
873
+ /** The key of that activity, when the plugin knows it. */
874
+ readonly activityKey?: string;
875
+ readonly state: ActivityState;
876
+ }
447
877
  /**
448
878
  * The push tokens the plugin holds since launch (iOS): the newest token of each of the last 32 activities that got
449
879
  * one, and the app's push-to-start token. Empty where there are no pushes.
@@ -453,12 +883,34 @@ export interface PushTokens {
453
883
  /** In the order the activities' first tokens came. */
454
884
  readonly activities: readonly PushTokenEvent[];
455
885
  }
456
- /** A tap on a button node. */
886
+ /** A tap on a button or a toggle node, or on an action of an Android content. */
457
887
  export interface ActionEvent {
458
888
  readonly actionId: string;
459
- /** Handle of the activity that showed the button. */
889
+ /** Handle of the activity that showed it. */
460
890
  readonly activityId: string;
461
891
  /** The key of that activity, when the plugin knows it. */
462
892
  readonly activityKey?: string;
893
+ /**
894
+ * For a toggle: the state the person asked for, the other one than the value the switch showed. The tap changes
895
+ * nothing: send an update with that value to move the switch. Absent for a button and for an action of an Android
896
+ * content.
897
+ */
898
+ readonly on?: boolean;
899
+ }
900
+ /**
901
+ * The person opened the app from the notification of an activity (Android): by the notification itself, or by one
902
+ * of its actions that opens a URL. The app receives the URL as any deep link; this says which activity it came
903
+ * from.
904
+ */
905
+ export interface OpenedEvent {
906
+ /** Handle of the activity. */
907
+ readonly activityId: string;
908
+ /** The key of that activity, when the plugin knows it. */
909
+ readonly activityKey?: string;
910
+ /**
911
+ * The action that opened the app, when the person tapped one and not the notification itself: `link:<n>` for the
912
+ * nth `link` node of the layout, or the id of an action of an Android content.
913
+ */
914
+ readonly actionId?: string;
463
915
  }
464
916
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Tauri 2 plugin for iOS Live Activities (ActivityKit and Dynamic Island) and Android Live Updates with ongoing notification fallback",
5
5
  "author": "1eedaegon",
6
6
  "type": "module",
@@ -33,8 +33,8 @@
33
33
  "build": "tsc -p tsconfig.json",
34
34
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p examples/demo/tsconfig.json",
35
35
  "test": "npm run build && npm run test:contracts && npm run test:api && npm run test:jsx && npm run test:react && npm run test:demo && npm run test:setup",
36
- "test:contracts": "node --test --experimental-test-coverage \"--test-coverage-include=tools/validate-request.mjs\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/requests.test.mjs tests/layout-requests.test.mjs tests/contract-sync.test.mjs tests/android-liveupdate.test.mjs tests/ci.test.mjs tests/ci-cache.test.mjs tests/spec-coverage.test.mjs",
37
- "test:api": "node --test --experimental-test-coverage \"--test-coverage-include=dist-js/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/api.test.mjs",
36
+ "test:contracts": "node --test --experimental-test-coverage \"--test-coverage-include=tools/validate-request.mjs\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/requests.test.mjs tests/layout-requests.test.mjs tests/contract-sync.test.mjs tests/android-liveupdate.test.mjs tests/android-contents.test.mjs tests/ci.test.mjs tests/ci-cache.test.mjs tests/spec-coverage.test.mjs",
37
+ "test:api": "node --test --experimental-test-coverage \"--test-coverage-include=dist-js/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/api.test.mjs tests/api-reload.test.mjs",
38
38
  "test:jsx": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=dist-js/jsx/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/jsx.test.mjs",
39
39
  "test:react": "node --test --experimental-test-coverage \"--test-coverage-include=dist-js/react/*.js\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/react.test.mjs",
40
40
  "test:demo": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=examples/demo/src/*.ts\" \"--test-coverage-exclude=examples/demo/tests/**\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 examples/demo/tests/self-test.test.mjs examples/demo/tests/ui-state.test.mjs examples/demo/tests/layouts.test.mjs examples/demo/tests/setup.test.mjs",