tauri-plugin-live-activity 0.1.0-alpha.4 → 0.2.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/README.ko.md +522 -52
- package/README.md +521 -74
- package/dist-js/index.d.ts +17 -1
- package/dist-js/index.js +26 -0
- package/dist-js/layout.d.ts +32 -0
- package/dist-js/layout.js +61 -0
- package/dist-js/types.d.ts +253 -0
- package/package.json +3 -3
package/dist-js/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type UnlistenFn } from '@tauri-apps/api/event';
|
|
2
|
+
import type { ActionEvent, ActivityRecord, Capabilities, EndInput, LayoutActivityRecord, LayoutStartInput, LayoutUpdateInput, PermissionKind, Permissions, StartInput, UpdateInput } from './types.js';
|
|
2
3
|
export type * from './types.js';
|
|
4
|
+
/** Builders for the nodes of a layout tree. */
|
|
5
|
+
export * as layout from './layout.js';
|
|
3
6
|
/** Read backend features; this does not request OS permissions. */
|
|
4
7
|
export declare function getCapabilities(): Promise<Capabilities>;
|
|
5
8
|
/** Read current OS permission states without showing a permission prompt. */
|
|
@@ -14,3 +17,16 @@ export declare function update(input: UpdateInput): Promise<ActivityRecord>;
|
|
|
14
17
|
export declare function end(input: EndInput): Promise<ActivityRecord>;
|
|
15
18
|
/** Reconcile plugin-owned records with the OS; unknown is a valid observed state. */
|
|
16
19
|
export declare function list(): Promise<readonly ActivityRecord[]>;
|
|
20
|
+
/** Start a layout activity (contract v2); repeated identical starts for an active key are idempotent. */
|
|
21
|
+
export declare function startLayout(input: LayoutStartInput): Promise<LayoutActivityRecord>;
|
|
22
|
+
/** Replace every value with a newer revision; the layout stays as started. */
|
|
23
|
+
export declare function updateLayout(input: LayoutUpdateInput): Promise<LayoutActivityRecord>;
|
|
24
|
+
/** End this layout generation. A late update cannot revive it. */
|
|
25
|
+
export declare function endLayout(input: EndInput): Promise<LayoutActivityRecord>;
|
|
26
|
+
/** Reconcile plugin-owned layout records with the OS; `list` reports contract v1 activities. */
|
|
27
|
+
export declare function listLayout(): Promise<readonly LayoutActivityRecord[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Receive button taps while this webview is alive; resolves to the function that stops listening.
|
|
30
|
+
* Listening uses Tauri's event permissions (`core:event:default`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function onAction(handler: (event: ActionEvent) => void): Promise<UnlistenFn>;
|
package/dist-js/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
import { listen } from '@tauri-apps/api/event';
|
|
3
|
+
/** Builders for the nodes of a layout tree. */
|
|
4
|
+
export * as layout from './layout.js';
|
|
2
5
|
/** Read backend features; this does not request OS permissions. */
|
|
3
6
|
export function getCapabilities() {
|
|
4
7
|
return invoke('plugin:live-activity|get_capabilities', {});
|
|
@@ -27,3 +30,26 @@ export function end(input) {
|
|
|
27
30
|
export function list() {
|
|
28
31
|
return invoke('plugin:live-activity|list', {});
|
|
29
32
|
}
|
|
33
|
+
/** Start a layout activity (contract v2); repeated identical starts for an active key are idempotent. */
|
|
34
|
+
export function startLayout(input) {
|
|
35
|
+
return invoke('plugin:live-activity|start_layout', { input });
|
|
36
|
+
}
|
|
37
|
+
/** Replace every value with a newer revision; the layout stays as started. */
|
|
38
|
+
export function updateLayout(input) {
|
|
39
|
+
return invoke('plugin:live-activity|update_layout', { input });
|
|
40
|
+
}
|
|
41
|
+
/** End this layout generation. A late update cannot revive it. */
|
|
42
|
+
export function endLayout(input) {
|
|
43
|
+
return invoke('plugin:live-activity|end_layout', { input });
|
|
44
|
+
}
|
|
45
|
+
/** Reconcile plugin-owned layout records with the OS; `list` reports contract v1 activities. */
|
|
46
|
+
export function listLayout() {
|
|
47
|
+
return invoke('plugin:live-activity|list_layout', {});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Receive button taps while this webview is alive; resolves to the function that stops listening.
|
|
51
|
+
* Listening uses Tauri's event permissions (`core:event:default`).
|
|
52
|
+
*/
|
|
53
|
+
export function onAction(handler) {
|
|
54
|
+
return listen('live-activity://action', event => handler(event.payload));
|
|
55
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LayoutButtonNode, LayoutDividerNode, LayoutGaugeNode, LayoutHStackNode, LayoutImageNode, LayoutNode, LayoutPathNode, LayoutProgressNode, LayoutSpacerNode, LayoutSymbolNode, LayoutTextNode, LayoutTimerTextNode, LayoutVStackNode, LayoutZStackNode } from './types.js';
|
|
2
|
+
/** The members of a node that its builder does not take as arguments. */
|
|
3
|
+
type Options<N extends LayoutNode, Argument extends keyof N = never> = N extends unknown ? Omit<N, 'type' | Argument> : never;
|
|
4
|
+
/** Children from top to bottom. */
|
|
5
|
+
export declare function vstack(children: readonly LayoutNode[], options?: Options<LayoutVStackNode, 'children'>): LayoutVStackNode;
|
|
6
|
+
/** Children side by side. */
|
|
7
|
+
export declare function hstack(children: readonly LayoutNode[], options?: Options<LayoutHStackNode, 'children'>): LayoutHStackNode;
|
|
8
|
+
/** Children on top of each other, the first at the back. */
|
|
9
|
+
export declare function zstack(children: readonly LayoutNode[], options?: Options<LayoutZStackNode, 'children'>): LayoutZStackNode;
|
|
10
|
+
/** Flexible space inside a stack. */
|
|
11
|
+
export declare function spacer(options?: Options<LayoutSpacerNode>): LayoutSpacerNode;
|
|
12
|
+
/** A separator line. */
|
|
13
|
+
export declare function divider(options?: Options<LayoutDividerNode>): LayoutDividerNode;
|
|
14
|
+
/** Literal text. */
|
|
15
|
+
export declare function text(value: string, options?: Options<LayoutTextNode, 'value' | 'bind'>): LayoutTextNode;
|
|
16
|
+
/** Text that shows the value of `key`. */
|
|
17
|
+
export declare function bound(key: string, options?: Options<LayoutTextNode, 'value' | 'bind'>): LayoutTextNode;
|
|
18
|
+
/** An SF Symbol. */
|
|
19
|
+
export declare function symbol(name: string, options?: Options<LayoutSymbolNode, 'name'>): LayoutSymbolNode;
|
|
20
|
+
/** An image of the widget extension's asset catalog. */
|
|
21
|
+
export declare function image(asset: string, options?: Options<LayoutImageNode, 'source'>): LayoutImageNode;
|
|
22
|
+
/** A shape from SVG path data `d`, drawn in a `box` of `[width, height]`. */
|
|
23
|
+
export declare function path(d: string, box: readonly [number, number], options?: Options<LayoutPathNode, 'd' | 'box'>): LayoutPathNode;
|
|
24
|
+
/** A progress bar or ring for the number value of `key`. */
|
|
25
|
+
export declare function progress(key: string, options?: Options<LayoutProgressNode, 'bind'>): LayoutProgressNode;
|
|
26
|
+
/** A gauge for the number value of `key`. */
|
|
27
|
+
export declare function gauge(key: string, options?: Options<LayoutGaugeNode, 'bind'>): LayoutGaugeNode;
|
|
28
|
+
/** A timer the system draws between the epoch-millisecond values of the `start` and `end` keys. */
|
|
29
|
+
export declare function timerText(start: string, end: string, options?: Options<LayoutTimerTextNode, 'start' | 'end'>): LayoutTimerTextNode;
|
|
30
|
+
/** A button around `child`; a tap reports `actionId` to `onAction`. */
|
|
31
|
+
export declare function button(actionId: string, child: LayoutNode, options?: Options<LayoutButtonNode, 'actionId' | 'child'>): LayoutButtonNode;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** Copies the options that were given, so that a node never carries an undefined member. */
|
|
2
|
+
function given(options) {
|
|
3
|
+
return Object.fromEntries(Object.entries(options ?? {}).filter(([, value]) => value !== undefined));
|
|
4
|
+
}
|
|
5
|
+
// The builders return plain node objects. They do not validate: the plugin checks the whole request.
|
|
6
|
+
/** Children from top to bottom. */
|
|
7
|
+
export function vstack(children, options) {
|
|
8
|
+
return { type: 'vstack', children, ...given(options) };
|
|
9
|
+
}
|
|
10
|
+
/** Children side by side. */
|
|
11
|
+
export function hstack(children, options) {
|
|
12
|
+
return { type: 'hstack', children, ...given(options) };
|
|
13
|
+
}
|
|
14
|
+
/** Children on top of each other, the first at the back. */
|
|
15
|
+
export function zstack(children, options) {
|
|
16
|
+
return { type: 'zstack', children, ...given(options) };
|
|
17
|
+
}
|
|
18
|
+
/** Flexible space inside a stack. */
|
|
19
|
+
export function spacer(options) {
|
|
20
|
+
return { type: 'spacer', ...given(options) };
|
|
21
|
+
}
|
|
22
|
+
/** A separator line. */
|
|
23
|
+
export function divider(options) {
|
|
24
|
+
return { type: 'divider', ...given(options) };
|
|
25
|
+
}
|
|
26
|
+
/** Literal text. */
|
|
27
|
+
export function text(value, options) {
|
|
28
|
+
return { type: 'text', value, ...given(options) };
|
|
29
|
+
}
|
|
30
|
+
/** Text that shows the value of `key`. */
|
|
31
|
+
export function bound(key, options) {
|
|
32
|
+
return { type: 'text', bind: key, ...given(options) };
|
|
33
|
+
}
|
|
34
|
+
/** An SF Symbol. */
|
|
35
|
+
export function symbol(name, options) {
|
|
36
|
+
return { type: 'symbol', name, ...given(options) };
|
|
37
|
+
}
|
|
38
|
+
/** An image of the widget extension's asset catalog. */
|
|
39
|
+
export function image(asset, options) {
|
|
40
|
+
return { type: 'image', source: { asset }, ...given(options) };
|
|
41
|
+
}
|
|
42
|
+
/** A shape from SVG path data `d`, drawn in a `box` of `[width, height]`. */
|
|
43
|
+
export function path(d, box, options) {
|
|
44
|
+
return { type: 'path', d, box, ...given(options) };
|
|
45
|
+
}
|
|
46
|
+
/** A progress bar or ring for the number value of `key`. */
|
|
47
|
+
export function progress(key, options) {
|
|
48
|
+
return { type: 'progress', bind: key, ...given(options) };
|
|
49
|
+
}
|
|
50
|
+
/** A gauge for the number value of `key`. */
|
|
51
|
+
export function gauge(key, options) {
|
|
52
|
+
return { type: 'gauge', bind: key, ...given(options) };
|
|
53
|
+
}
|
|
54
|
+
/** A timer the system draws between the epoch-millisecond values of the `start` and `end` keys. */
|
|
55
|
+
export function timerText(start, end, options) {
|
|
56
|
+
return { type: 'timerText', start, end, ...given(options) };
|
|
57
|
+
}
|
|
58
|
+
/** A button around `child`; a tap reports `actionId` to `onAction`. */
|
|
59
|
+
export function button(actionId, child, options) {
|
|
60
|
+
return { type: 'button', actionId, child, ...given(options) };
|
|
61
|
+
}
|
package/dist-js/types.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface Capabilities {
|
|
|
15
15
|
readonly stateObservation: FeatureSupport;
|
|
16
16
|
readonly silentUpdate: FeatureSupport;
|
|
17
17
|
readonly nativeLiveActivity: FeatureSupport;
|
|
18
|
+
/** Layout activities of request contract v2. */
|
|
19
|
+
readonly layout: FeatureSupport;
|
|
18
20
|
readonly maxPayloadBytes: number;
|
|
19
21
|
}
|
|
20
22
|
export interface Permissions {
|
|
@@ -103,4 +105,255 @@ export interface LiveActivityError {
|
|
|
103
105
|
readonly code: ErrorCode;
|
|
104
106
|
readonly message: string;
|
|
105
107
|
}
|
|
108
|
+
/** Text of at most 1000 Unicode code points, a number from -8640000000000000 to 8640000000000000, or a boolean. */
|
|
109
|
+
export type LayoutValue = string | number | boolean;
|
|
110
|
+
/** At most 32 entries. A key is an ASCII letter followed by up to 31 ASCII letters, digits or `_`. */
|
|
111
|
+
export interface LayoutValues {
|
|
112
|
+
readonly [key: string]: LayoutValue;
|
|
113
|
+
}
|
|
114
|
+
export interface LayoutSnapshot {
|
|
115
|
+
/** Nonnegative JavaScript safe integer; strictly increases when the values change. */
|
|
116
|
+
readonly revision: number;
|
|
117
|
+
/** The complete map. An update keeps the keys and the value types accepted at start. */
|
|
118
|
+
readonly values: LayoutValues;
|
|
119
|
+
/** UTC Unix epoch milliseconds. */
|
|
120
|
+
readonly staleAt?: number;
|
|
121
|
+
}
|
|
122
|
+
type ColorName = 'primary' | 'secondary' | 'accent' | 'red' | 'orange' | 'yellow' | 'green' | 'mint' | 'teal' | 'cyan' | 'blue' | 'indigo' | 'purple' | 'pink' | 'brown' | 'white' | 'black' | 'gray' | 'clear';
|
|
123
|
+
/** `#RRGGBB` or `#RRGGBBAA`. */
|
|
124
|
+
type HexColor = `#${string}`;
|
|
125
|
+
/** A semantic name, one hex color for both appearances, or a light and dark pair. */
|
|
126
|
+
export type LayoutColor = ColorName | HexColor | {
|
|
127
|
+
readonly light: HexColor;
|
|
128
|
+
readonly dark: HexColor;
|
|
129
|
+
};
|
|
130
|
+
type Anchor = 'center' | 'leading' | 'trailing' | 'top' | 'bottom' | 'topLeading' | 'topTrailing' | 'bottomLeading' | 'bottomTrailing';
|
|
131
|
+
/** At least one member. Sizes are points from 0 to 1024. */
|
|
132
|
+
export interface LayoutFrame {
|
|
133
|
+
readonly width?: number;
|
|
134
|
+
readonly height?: number;
|
|
135
|
+
readonly minWidth?: number;
|
|
136
|
+
readonly minHeight?: number;
|
|
137
|
+
readonly maxWidth?: number | 'infinity';
|
|
138
|
+
readonly maxHeight?: number | 'infinity';
|
|
139
|
+
readonly alignment?: Anchor;
|
|
140
|
+
}
|
|
141
|
+
interface StyleFields {
|
|
142
|
+
readonly weight?: 'ultraLight' | 'thin' | 'light' | 'regular' | 'medium' | 'semibold' | 'bold' | 'heavy' | 'black';
|
|
143
|
+
readonly design?: 'default' | 'rounded' | 'serif' | 'monospaced';
|
|
144
|
+
readonly monospacedDigit?: boolean;
|
|
145
|
+
/** Foreground color. */
|
|
146
|
+
readonly color?: LayoutColor;
|
|
147
|
+
/** Integer from 1 to 10. */
|
|
148
|
+
readonly lineLimit?: number;
|
|
149
|
+
/** From 0.1 to 1. */
|
|
150
|
+
readonly minimumScaleFactor?: number;
|
|
151
|
+
/** Alignment of text that spans several lines. */
|
|
152
|
+
readonly alignment?: 'leading' | 'center' | 'trailing';
|
|
153
|
+
/** Points from 0 to 64: one number for every edge, or `[top, leading, bottom, trailing]`. */
|
|
154
|
+
readonly padding?: number | readonly [number, number, number, number];
|
|
155
|
+
readonly frame?: LayoutFrame;
|
|
156
|
+
readonly background?: LayoutColor;
|
|
157
|
+
/** Points from 0 to 64. */
|
|
158
|
+
readonly cornerRadius?: number;
|
|
159
|
+
/** From 0 to 1. */
|
|
160
|
+
readonly opacity?: number;
|
|
161
|
+
/** Tint of buttons, progress views and gauges. */
|
|
162
|
+
readonly tint?: LayoutColor;
|
|
163
|
+
readonly buttonStyle?: 'automatic' | 'bordered' | 'borderedProminent' | 'plain';
|
|
164
|
+
}
|
|
165
|
+
/** At least one member. `font`, a system text style, and `size`, points from 6 to 96, exclude each other. */
|
|
166
|
+
export type LayoutStyle = StyleFields & ({
|
|
167
|
+
readonly font?: 'largeTitle' | 'title' | 'title2' | 'title3' | 'headline' | 'subheadline' | 'body' | 'callout' | 'footnote' | 'caption' | 'caption2';
|
|
168
|
+
readonly size?: never;
|
|
169
|
+
} | {
|
|
170
|
+
readonly size?: number;
|
|
171
|
+
readonly font?: never;
|
|
172
|
+
});
|
|
173
|
+
/** Members every node may carry. A condition names a value key; `if` and `unless` exclude each other. */
|
|
174
|
+
type NodeFields = {
|
|
175
|
+
/** A token of the request's `styles` table. */
|
|
176
|
+
readonly style?: string;
|
|
177
|
+
} & ({
|
|
178
|
+
readonly if?: string;
|
|
179
|
+
readonly unless?: never;
|
|
180
|
+
} | {
|
|
181
|
+
readonly unless?: string;
|
|
182
|
+
readonly if?: never;
|
|
183
|
+
});
|
|
184
|
+
export type LayoutVStackNode = NodeFields & {
|
|
185
|
+
readonly type: 'vstack';
|
|
186
|
+
/** Between 1 and 12 nodes. */
|
|
187
|
+
readonly children: readonly LayoutNode[];
|
|
188
|
+
/** Points from 0 to 64. */
|
|
189
|
+
readonly spacing?: number;
|
|
190
|
+
readonly alignment?: 'leading' | 'center' | 'trailing';
|
|
191
|
+
};
|
|
192
|
+
export type LayoutHStackNode = NodeFields & {
|
|
193
|
+
readonly type: 'hstack';
|
|
194
|
+
/** Between 1 and 12 nodes. */
|
|
195
|
+
readonly children: readonly LayoutNode[];
|
|
196
|
+
/** Points from 0 to 64. */
|
|
197
|
+
readonly spacing?: number;
|
|
198
|
+
readonly alignment?: 'top' | 'center' | 'bottom' | 'firstTextBaseline';
|
|
199
|
+
};
|
|
200
|
+
export type LayoutZStackNode = NodeFields & {
|
|
201
|
+
readonly type: 'zstack';
|
|
202
|
+
/** Between 1 and 12 nodes. */
|
|
203
|
+
readonly children: readonly LayoutNode[];
|
|
204
|
+
readonly alignment?: Anchor;
|
|
205
|
+
};
|
|
206
|
+
export type LayoutSpacerNode = NodeFields & {
|
|
207
|
+
readonly type: 'spacer';
|
|
208
|
+
/** Points from 0 to 256. */
|
|
209
|
+
readonly minLength?: number;
|
|
210
|
+
};
|
|
211
|
+
export type LayoutDividerNode = NodeFields & {
|
|
212
|
+
readonly type: 'divider';
|
|
213
|
+
};
|
|
214
|
+
/** Literal text of at most 200 Unicode code points, or the value of a key. */
|
|
215
|
+
export type LayoutTextNode = NodeFields & {
|
|
216
|
+
readonly type: 'text';
|
|
217
|
+
} & ({
|
|
218
|
+
readonly value: string;
|
|
219
|
+
readonly bind?: never;
|
|
220
|
+
} | {
|
|
221
|
+
readonly bind: string;
|
|
222
|
+
readonly value?: never;
|
|
223
|
+
});
|
|
224
|
+
export type LayoutSymbolNode = NodeFields & {
|
|
225
|
+
readonly type: 'symbol';
|
|
226
|
+
/** SF Symbol name: lowercase letters and digits in parts joined by dots, 64 characters at most. */
|
|
227
|
+
readonly name: string;
|
|
228
|
+
readonly rendering?: 'monochrome' | 'hierarchical' | 'palette' | 'multicolor';
|
|
229
|
+
/** Key of a number value: the symbol's variable value, from 0 to 1. */
|
|
230
|
+
readonly variableBind?: string;
|
|
231
|
+
};
|
|
232
|
+
export type LayoutImageNode = NodeFields & {
|
|
233
|
+
readonly type: 'image';
|
|
234
|
+
/** Name of an image in the widget extension's asset catalog. */
|
|
235
|
+
readonly source: {
|
|
236
|
+
readonly asset: string;
|
|
237
|
+
};
|
|
238
|
+
readonly resizable?: boolean;
|
|
239
|
+
readonly contentMode?: 'fit' | 'fill';
|
|
240
|
+
};
|
|
241
|
+
export type LayoutPathNode = NodeFields & {
|
|
242
|
+
readonly type: 'path';
|
|
243
|
+
/** SVG path data of at most 512 bytes; commands `M L H V C S Q T Z` in either case, no arcs. */
|
|
244
|
+
readonly d: string;
|
|
245
|
+
/** `[width, height]` of the coordinate space of `d`, each from 1 to 1024. */
|
|
246
|
+
readonly box: readonly [number, number];
|
|
247
|
+
/** Line width from 0.5 to 16; the path is filled when absent. */
|
|
248
|
+
readonly stroke?: number;
|
|
249
|
+
};
|
|
250
|
+
export type LayoutProgressNode = NodeFields & {
|
|
251
|
+
readonly type: 'progress';
|
|
252
|
+
/** Key of a number value, shown clamped to 0..1. */
|
|
253
|
+
readonly bind: string;
|
|
254
|
+
readonly kind?: 'linear' | 'circular';
|
|
255
|
+
};
|
|
256
|
+
export type LayoutGaugeNode = NodeFields & {
|
|
257
|
+
readonly type: 'gauge';
|
|
258
|
+
/** Key of a number value. */
|
|
259
|
+
readonly bind: string;
|
|
260
|
+
/** Defaults to 0; less than `max`. */
|
|
261
|
+
readonly min?: number;
|
|
262
|
+
/** Defaults to 1. */
|
|
263
|
+
readonly max?: number;
|
|
264
|
+
readonly kind?: 'linear' | 'circular';
|
|
265
|
+
};
|
|
266
|
+
export type LayoutTimerTextNode = NodeFields & {
|
|
267
|
+
readonly type: 'timerText';
|
|
268
|
+
/** Key of a number value: UTC Unix epoch milliseconds. */
|
|
269
|
+
readonly start: string;
|
|
270
|
+
/** Key of a number value: UTC Unix epoch milliseconds after `start`. */
|
|
271
|
+
readonly end: string;
|
|
272
|
+
/** Defaults to true. */
|
|
273
|
+
readonly countsDown?: boolean;
|
|
274
|
+
};
|
|
275
|
+
/** Allowed in the lock screen and the expanded regions, never inside another button. */
|
|
276
|
+
export type LayoutButtonNode = NodeFields & {
|
|
277
|
+
readonly type: 'button';
|
|
278
|
+
/** Reported by `onAction`: starts with a letter or digit, then letters, digits or `._:-`, 64 characters at most. */
|
|
279
|
+
readonly actionId: string;
|
|
280
|
+
readonly child: LayoutNode;
|
|
281
|
+
};
|
|
282
|
+
export type LayoutNode = LayoutVStackNode | LayoutHStackNode | LayoutZStackNode | LayoutSpacerNode | LayoutDividerNode | LayoutTextNode | LayoutSymbolNode | LayoutImageNode | LayoutPathNode | LayoutProgressNode | LayoutGaugeNode | LayoutTimerTextNode | LayoutButtonNode;
|
|
283
|
+
/** At least one region, each of at most 12 nodes. */
|
|
284
|
+
export interface LayoutIslandExpanded {
|
|
285
|
+
readonly leading?: LayoutNode;
|
|
286
|
+
readonly trailing?: LayoutNode;
|
|
287
|
+
readonly center?: LayoutNode;
|
|
288
|
+
readonly bottom?: LayoutNode;
|
|
289
|
+
}
|
|
290
|
+
/** At least one member; a missing part renders a default. */
|
|
291
|
+
export interface LayoutIsland {
|
|
292
|
+
readonly expanded?: LayoutIslandExpanded;
|
|
293
|
+
/** At most 3 nodes and no button. */
|
|
294
|
+
readonly compactLeading?: LayoutNode;
|
|
295
|
+
/** At most 3 nodes and no button. */
|
|
296
|
+
readonly compactTrailing?: LayoutNode;
|
|
297
|
+
/** At most 2 nodes and no button. */
|
|
298
|
+
readonly minimal?: LayoutNode;
|
|
299
|
+
}
|
|
300
|
+
/** Trees are at most 8 levels deep and hold at most 4 buttons per region. */
|
|
301
|
+
export interface Layout {
|
|
302
|
+
/** At most 40 nodes. */
|
|
303
|
+
readonly lockScreen: LayoutNode;
|
|
304
|
+
readonly island?: LayoutIsland;
|
|
305
|
+
/** Tint behind the lock screen presentation. */
|
|
306
|
+
readonly background?: LayoutColor;
|
|
307
|
+
/** Tint of the Dynamic Island keyline. */
|
|
308
|
+
readonly keyline?: LayoutColor;
|
|
309
|
+
}
|
|
310
|
+
export interface LayoutAndroidOptions {
|
|
311
|
+
/** Lock screen visibility of the notification. */
|
|
312
|
+
readonly visibility: 'public' | 'private' | 'secret';
|
|
313
|
+
}
|
|
314
|
+
export interface LayoutStartInput {
|
|
315
|
+
/** Stable app-owned key; do not put credentials or private data in this key. */
|
|
316
|
+
readonly activityKey: string;
|
|
317
|
+
readonly schemaVersion: 2;
|
|
318
|
+
/** Explicitly permits or forbids selection of the notification fallback. */
|
|
319
|
+
readonly fallback: Fallback;
|
|
320
|
+
/** Fixed for this generation; updates replace the values only. */
|
|
321
|
+
readonly layout: Layout;
|
|
322
|
+
/** Between 1 and 24 styles by token; a token follows the rule for value keys. */
|
|
323
|
+
readonly styles?: {
|
|
324
|
+
readonly [token: string]: LayoutStyle;
|
|
325
|
+
};
|
|
326
|
+
readonly snapshot: LayoutSnapshot;
|
|
327
|
+
/** Ignored on iOS. */
|
|
328
|
+
readonly android?: LayoutAndroidOptions;
|
|
329
|
+
}
|
|
330
|
+
export interface LayoutUpdateInput {
|
|
331
|
+
readonly id: string;
|
|
332
|
+
/** Complete replacement snapshot, not a partial update. */
|
|
333
|
+
readonly snapshot: LayoutSnapshot;
|
|
334
|
+
}
|
|
335
|
+
/** The record does not repeat the layout. */
|
|
336
|
+
export interface LayoutActivityRecord {
|
|
337
|
+
/** Opaque handle for this generation; contract v1 commands do not see it. */
|
|
338
|
+
readonly id: string;
|
|
339
|
+
readonly activityKey: string;
|
|
340
|
+
readonly schemaVersion: 2;
|
|
341
|
+
readonly snapshot: LayoutSnapshot;
|
|
342
|
+
readonly backend: Backend;
|
|
343
|
+
readonly state: ActivityState;
|
|
344
|
+
/** A successful OS call does not prove that the user can see the activity. */
|
|
345
|
+
readonly visibility: 'unknown';
|
|
346
|
+
/** What this backend left out, for example `layout.island` on Android. */
|
|
347
|
+
readonly degradedFeatures: readonly string[];
|
|
348
|
+
readonly promotionRequested: boolean;
|
|
349
|
+
readonly promotionState: PromotionState;
|
|
350
|
+
}
|
|
351
|
+
/** A tap on a button node. */
|
|
352
|
+
export interface ActionEvent {
|
|
353
|
+
readonly actionId: string;
|
|
354
|
+
/** Handle of the activity that showed the button. */
|
|
355
|
+
readonly activityId: string;
|
|
356
|
+
/** The key of that activity, when the plugin knows it. */
|
|
357
|
+
readonly activityKey?: string;
|
|
358
|
+
}
|
|
106
359
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-plugin-live-activity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"build": "tsc -p tsconfig.json",
|
|
29
29
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p examples/demo/tsconfig.json",
|
|
30
30
|
"test": "npm run build && npm run test:contracts && npm run test:api && npm run test:demo",
|
|
31
|
-
"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",
|
|
31
|
+
"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",
|
|
32
32
|
"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",
|
|
33
|
-
"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",
|
|
33
|
+
"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",
|
|
34
34
|
"build:demo": "npm run build && node examples/demo/build.mjs",
|
|
35
35
|
"prepack": "npm run build",
|
|
36
36
|
"pack:check": "npm pack --dry-run"
|