tauri-plugin-live-activity 0.8.0 → 0.9.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 +6 -1
- package/README.md +6 -1
- package/cli/ios.mjs +15 -6
- package/cli/main.mjs +4 -2
- package/cli/setup.mjs +4 -3
- package/cli/xcodegen.mjs +11 -1
- package/dist-js/types.d.ts +13 -2
- package/package.json +3 -3
package/README.ko.md
CHANGED
|
@@ -149,7 +149,7 @@ fn deliver<R: Runtime>(app: &AppHandle<R>) -> Result<()> {
|
|
|
149
149
|
fallback: Fallback::Notification,
|
|
150
150
|
layout: Layout {
|
|
151
151
|
lock_screen: Element::Text { value: None, bind: Some("status".into()) }.into(),
|
|
152
|
-
island: None, background: None, keyline: None, url: None,
|
|
152
|
+
island: None, background: None, keyline: None, url: None, small: None,
|
|
153
153
|
},
|
|
154
154
|
styles: None,
|
|
155
155
|
snapshot: snapshot(0, "On time"),
|
|
@@ -242,6 +242,11 @@ island: {
|
|
|
242
242
|
keyline: '#A3D9C2', // 아일랜드 테두리 색
|
|
243
243
|
```
|
|
244
244
|
|
|
245
|
+
페어링된 Apple Watch(iOS 18)와 CarPlay(iOS 26)는 아일랜드의 compact 부분을 보여 줍니다. 위젯 익스텐션이 그
|
|
246
|
+
패밀리를 그리도록 해 두면(`setup --small-family`) `small`이 거기에 자기 트리를 줍니다. 노드는 12개까지이고
|
|
247
|
+
버튼·링크·토글은 넣을 수 없습니다: `small: hstack([symbol('pawprint.fill'), bound('eta')])`. Android는 이를
|
|
248
|
+
`degradedFeatures`에 적습니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#apple-watch-and-carplay)
|
|
249
|
+
|
|
245
250
|
## 푸시 (iOS)
|
|
246
251
|
|
|
247
252
|
서버가 APNs로 액티비티를 갱신하고 끝내고 시작합니다. `push: 'token'`(iOS 18에서는 `{ channel }`도)으로
|
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ fn deliver<R: Runtime>(app: &AppHandle<R>) -> Result<()> {
|
|
|
150
150
|
fallback: Fallback::Notification,
|
|
151
151
|
layout: Layout {
|
|
152
152
|
lock_screen: Element::Text { value: None, bind: Some("status".into()) }.into(),
|
|
153
|
-
island: None, background: None, keyline: None, url: None,
|
|
153
|
+
island: None, background: None, keyline: None, url: None, small: None,
|
|
154
154
|
},
|
|
155
155
|
styles: None,
|
|
156
156
|
snapshot: snapshot(0, "On time"),
|
|
@@ -246,6 +246,11 @@ island: {
|
|
|
246
246
|
keyline: '#A3D9C2', // the island's edge color
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
+
A paired Apple Watch (iOS 18) and CarPlay (iOS 26) show the island's compact parts. `small` gives them a tree of
|
|
250
|
+
their own, at most 12 nodes without buttons, links or toggles, once the widget extension draws that family
|
|
251
|
+
(`setup --small-family`): `small: hstack([symbol('pawprint.fill'), bound('eta')])`. Android names it in
|
|
252
|
+
`degradedFeatures`. [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#apple-watch-and-carplay)
|
|
253
|
+
|
|
249
254
|
## Pushes (iOS)
|
|
250
255
|
|
|
251
256
|
A server updates, ends or starts activities through APNs. Start with `push: 'token'` (or `{ channel }` on iOS 18)
|
package/cli/ios.mjs
CHANGED
|
@@ -8,7 +8,9 @@ import { OLD_MODULES, RETIRED, released, renameCustomViews } from './migration.m
|
|
|
8
8
|
import { newPlist, setTrueKey } from './plist.mjs';
|
|
9
9
|
import { SetupError, parseJson, readText, step, tail, which, writeFile } from './steps.mjs';
|
|
10
10
|
import { assetSteps, bundledFonts, fontSteps } from './widget-files.mjs';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
SMALL_FAMILY_KEY, SPEC_FILE, WIDGET, addInclude, appGroupOf, drawsSmallFamily, readProject, widgetSpec, writtenBySetup,
|
|
13
|
+
} from './xcodegen.mjs';
|
|
12
14
|
|
|
13
15
|
/** The widget bundle: activitykit's template, under the name 0.2 and 0.3 gave the plugin's. */
|
|
14
16
|
const WIDGET_FILE = 'LiveActivityWidget.swift';
|
|
@@ -32,9 +34,9 @@ export function iosSteps(context) {
|
|
|
32
34
|
const plist = infoPlistStep(context);
|
|
33
35
|
if (project.widget) {
|
|
34
36
|
const detail = `already has a widget extension, ${project.widget}; add the plugin's widget to it by hand (docs/ios-integration.md)`;
|
|
35
|
-
const { files, appGroup } = context;
|
|
36
|
-
const given = [files.fonts.length && '--font', files.assets.length && '--asset', appGroup && '--app-group'].filter(Boolean);
|
|
37
|
-
const left = given.length === 0 ? [] : [step('todo', show(specPath), `${given.join(', ')} not applied: that widget is yours to give fonts, images
|
|
37
|
+
const { files, appGroup, smallFamily } = context;
|
|
38
|
+
const given = [files.fonts.length && '--font', files.assets.length && '--asset', appGroup && '--app-group', smallFamily && '--small-family'].filter(Boolean);
|
|
39
|
+
const left = given.length === 0 ? [] : [step('todo', show(specPath), `${given.join(', ')} not applied: that widget is yours to give fonts, images, an App Group and the small family (docs/ios-integration.md)`)];
|
|
38
40
|
return [plist, step('skipped', show(specPath), detail), ...left];
|
|
39
41
|
}
|
|
40
42
|
if (!project.appTarget) {
|
|
@@ -43,12 +45,14 @@ export function iosSteps(context) {
|
|
|
43
45
|
}
|
|
44
46
|
const widget = join(apple, WIDGET);
|
|
45
47
|
const appGroup = appGroupFor(context, apple, project);
|
|
48
|
+
// A spec that setup wrote with the small family keeps it on later runs, as it keeps its App Group.
|
|
49
|
+
const smallFamily = context.smallFamily || drawsSmallFamily(readText(join(apple, SPEC_FILE)));
|
|
46
50
|
const include = includeStep(context, specPath, yaml);
|
|
47
51
|
// XcodeGen lists the files of a folder when it generates, so a new or removed widget file also needs a run.
|
|
48
52
|
const projectSteps = [
|
|
49
53
|
widgetStep(context, widget), ...retiredSteps(context, widget, readText(join(apple, SPEC_FILE))), customViewsStep(context, widget),
|
|
50
54
|
...fontSteps(context, widget), ...assetSteps(context, widget),
|
|
51
|
-
specStep(context, apple, project, { fonts: bundledFonts(context, widget), appGroup }), include,
|
|
55
|
+
specStep(context, apple, project, { fonts: bundledFonts(context, widget), appGroup, smallFamily }), include,
|
|
52
56
|
];
|
|
53
57
|
return [plist, ...projectSteps, xcodegenStep(context, apple, specPath, projectSteps, include)];
|
|
54
58
|
}
|
|
@@ -133,11 +137,12 @@ function retiredSteps({ show }, widget, spec) {
|
|
|
133
137
|
});
|
|
134
138
|
}
|
|
135
139
|
|
|
136
|
-
function specStep({ plugin, activitykit, config, srcTauri, show }, apple, project, { fonts, appGroup }) {
|
|
140
|
+
function specStep({ plugin, activitykit, config, srcTauri, show }, apple, project, { fonts, appGroup, smallFamily }) {
|
|
137
141
|
const path = join(apple, SPEC_FILE);
|
|
138
142
|
const wanted = widgetSpec({
|
|
139
143
|
fonts,
|
|
140
144
|
appGroup,
|
|
145
|
+
smallFamily,
|
|
141
146
|
// XcodeGen writes the entitlements file from the spec, so the App Group goes into the spec, at the app's path.
|
|
142
147
|
appEntitlements: project.entitlements ?? `${project.appTarget}/${project.appTarget}.entitlements`,
|
|
143
148
|
pluginVersion: plugin.version,
|
|
@@ -153,6 +158,10 @@ function specStep({ plugin, activitykit, config, srcTauri, show }, apple, projec
|
|
|
153
158
|
}
|
|
154
159
|
if (current === wanted) return step('unchanged', show(path));
|
|
155
160
|
if (!writtenBySetup(current)) {
|
|
161
|
+
// The spec is the app's now: the key that --small-family asks for goes in by hand, as the rest of it did.
|
|
162
|
+
if (smallFamily && !drawsSmallFamily(current)) {
|
|
163
|
+
return step('todo', show(path), `it was changed by hand, so --small-family was not applied: add \`${SMALL_FAMILY_KEY}: true\` to the info properties of ${WIDGET}, or delete the file and run setup again`);
|
|
164
|
+
}
|
|
156
165
|
return step('kept', show(path), 'it was changed by hand; delete it and run setup again to have it written anew');
|
|
157
166
|
}
|
|
158
167
|
return step('updated', show(path), 'for the current plugin, activitykit and app version', writeFile(path, wanted));
|
package/cli/main.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { formatReport } from './report.mjs';
|
|
3
3
|
import { SetupError, setup } from './setup.mjs';
|
|
4
4
|
|
|
5
|
-
const USAGE = `Usage: npx tauri-plugin-live-activity setup [--dry-run] [--ios-only] [--font <file>]... [--asset <file>]... [--app-group[=<id>]]
|
|
5
|
+
const USAGE = `Usage: npx tauri-plugin-live-activity setup [--dry-run] [--ios-only] [--font <file>]... [--asset <file>]... [--app-group[=<id>]] [--small-family]
|
|
6
6
|
|
|
7
7
|
Run it in the folder of a Tauri 2 app after \`cargo add\` and \`npm i\`. It grants the plugin's
|
|
8
8
|
permissions, sets the Android minimum to API 26 and, on a Mac, adds the Live Activity widget
|
|
@@ -16,9 +16,11 @@ ever made from scratch.
|
|
|
16
16
|
name@2x.png and name@3x.png are scales of the asset name
|
|
17
17
|
--app-group[=<id>] give the app and the widget extension an App Group, group.<app identifier> unless
|
|
18
18
|
named, so writeImage can share images; later runs keep it
|
|
19
|
+
--small-family draw a layout's small region on a paired Apple Watch and in CarPlay, and there the
|
|
20
|
+
compact parts of a layout without one; later runs keep it
|
|
19
21
|
`;
|
|
20
22
|
|
|
21
|
-
const FLAGS = { '--dry-run': 'dryRun', '--ios-only': 'iosOnly' };
|
|
23
|
+
const FLAGS = { '--dry-run': 'dryRun', '--ios-only': 'iosOnly', '--small-family': 'smallFamily' };
|
|
22
24
|
const FILES = { '--font': 'fonts', '--asset': 'assets' };
|
|
23
25
|
const HELP = new Set(['help', '--help', '-h']);
|
|
24
26
|
|
package/cli/setup.mjs
CHANGED
|
@@ -25,16 +25,17 @@ const NPM_VERSION = JSON.parse(readFileSync(new URL('../package.json', import.me
|
|
|
25
25
|
/**
|
|
26
26
|
* Sets up the app in `cwd` (its folder or its src-tauri folder) and returns the steps with their
|
|
27
27
|
* status, and notes for the person who runs it. `fonts` and `assets` are files for the widget
|
|
28
|
-
* extension; `appGroup` is true or the name of an App Group
|
|
28
|
+
* extension; `appGroup` is true or the name of an App Group; with `smallFamily` the widget draws a layout's small
|
|
29
|
+
* region. Throws SetupError when it cannot start.
|
|
29
30
|
*/
|
|
30
31
|
export function setup({
|
|
31
32
|
cwd = process.cwd(), env = process.env, dryRun = false, iosOnly = false, platform = process.platform,
|
|
32
|
-
fonts = [], assets = [], appGroup = undefined,
|
|
33
|
+
fonts = [], assets = [], appGroup = undefined, smallFamily = false,
|
|
33
34
|
} = {}) {
|
|
34
35
|
const files = widgetFiles(cwd, { fonts, assets });
|
|
35
36
|
const app = findApp(cwd);
|
|
36
37
|
const { plugin, activitykit } = findCrates(app, env);
|
|
37
|
-
const context = { ...app, plugin, activitykit, env, platform, files, appGroup, show: path => display(cwd, path) };
|
|
38
|
+
const context = { ...app, plugin, activitykit, env, platform, files, appGroup, smallFamily, show: path => display(cwd, path) };
|
|
38
39
|
const planned = [...(iosOnly ? [] : [capabilitiesStep(context), ...androidSteps(context)]), ...iosSteps(context)];
|
|
39
40
|
const steps = dryRun ? planned : planned.map(apply);
|
|
40
41
|
return { dryRun, version: plugin.version, steps: steps.map(({ effect, ...rest }) => rest), notes: notes(context) };
|
package/cli/xcodegen.mjs
CHANGED
|
@@ -10,6 +10,8 @@ export const WIDGET_ENTITLEMENTS = `${WIDGET}.entitlements`;
|
|
|
10
10
|
export const APP_GROUP_KEY = 'ActivityKitAppGroup';
|
|
11
11
|
/** The key of 0.2 and 0.3, which a spec they wrote may hold. */
|
|
12
12
|
const OLD_APP_GROUP_KEY = 'TauriLiveActivityAppGroup';
|
|
13
|
+
/** The Info.plist key of the extension with which activitykit's widget draws the small family. */
|
|
14
|
+
export const SMALL_FAMILY_KEY = 'ActivityKitSmallFamily';
|
|
13
15
|
/**
|
|
14
16
|
* The files of the widget folder that the app target compiles too. The custom views file is Swift, so the app target
|
|
15
17
|
* compiles Swift, which Xcode needs to take the App Intents metadata of the linked ActivityKitIntent product.
|
|
@@ -87,6 +89,11 @@ export function appGroupOf(spec = '') {
|
|
|
87
89
|
return value && JSON.parse(value);
|
|
88
90
|
}
|
|
89
91
|
|
|
92
|
+
/** Whether a spec that setup wrote has the widget draw the small family, so that a later run keeps that. */
|
|
93
|
+
export function drawsSmallFamily(spec = '') {
|
|
94
|
+
return new RegExp(`^\\s+${SMALL_FAMILY_KEY}: true$`, 'm').test(spec);
|
|
95
|
+
}
|
|
96
|
+
|
|
90
97
|
/**
|
|
91
98
|
* Adds `file` to the spec's `include` list. Status: `added` (with the new `text`), `present`, or
|
|
92
99
|
* `unsupported` when the list has a form this does not edit.
|
|
@@ -122,10 +129,12 @@ const quoted = value => JSON.stringify(String(value));
|
|
|
122
129
|
* The included spec: activitykit's Swift package, the widget extension target, and in the app target the extension,
|
|
123
130
|
* the button intent and the custom views. `fonts` go to the extension's UIAppFonts. An `appGroup` goes to the
|
|
124
131
|
* entitlements of both targets, the app's at `appEntitlements`, and to the extension's Info.plist, where activitykit
|
|
125
|
-
* and the widget read it.
|
|
132
|
+
* and the widget read it. With `smallFamily` the extension's Info.plist says that the widget draws the small family,
|
|
133
|
+
* for a paired Apple Watch and CarPlay. XcodeGen merges the app target's part into the target of project.yml.
|
|
126
134
|
*/
|
|
127
135
|
export function widgetSpec({
|
|
128
136
|
pluginVersion, packagePath, appTarget, bundleId, appVersion, buildVersion, teamGroup, fonts = [], appGroup, appEntitlements,
|
|
137
|
+
smallFamily = false,
|
|
129
138
|
}) {
|
|
130
139
|
const versions = appVersion === undefined ? [] : [
|
|
131
140
|
` CFBundleShortVersionString: ${quoted(appVersion)}`,
|
|
@@ -172,6 +181,7 @@ export function widgetSpec({
|
|
|
172
181
|
' NSExtensionPointIdentifier: com.apple.widgetkit-extension',
|
|
173
182
|
' # A start answers CONFIGURATION_REQUIRED without an extension that declares this.',
|
|
174
183
|
' ActivityKitLayout: 2',
|
|
184
|
+
...(smallFamily ? [` ${SMALL_FAMILY_KEY}: true`] : []),
|
|
175
185
|
...fontList,
|
|
176
186
|
...group,
|
|
177
187
|
...entitlements(WIDGET_ENTITLEMENTS),
|
package/dist-js/types.d.ts
CHANGED
|
@@ -62,7 +62,10 @@ export interface AndroidPresentationSupport {
|
|
|
62
62
|
readonly branding: boolean;
|
|
63
63
|
/** A start with `scheduled`, which Android begins at its time, also while the app does not run; `UNSUPPORTED_FEATURE` without it. */
|
|
64
64
|
readonly scheduledStart: boolean;
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Whether a scheduled start begins at its time: the app may set exact alarms. Without it Android chooses the
|
|
67
|
+
* moment: up to ten minutes late while the device is awake, an hour while it dozes.
|
|
68
|
+
*/
|
|
66
69
|
readonly exactStart: boolean;
|
|
67
70
|
}
|
|
68
71
|
export interface Permissions {
|
|
@@ -739,6 +742,14 @@ export interface Layout {
|
|
|
739
742
|
* app without a URL. On Android, where the device offers `links`, it is what a tap on the notification opens.
|
|
740
743
|
*/
|
|
741
744
|
readonly url?: LayoutBindable<string>;
|
|
745
|
+
/**
|
|
746
|
+
* What the activity shows in the Smart Stack of a paired Apple Watch (iOS 18) and in CarPlay (iOS 26): at most 12
|
|
747
|
+
* nodes and no button, link or toggle. iOS draws it when the widget extension's Info.plist sets
|
|
748
|
+
* `ActivityKitSmallFamily` to true (`setup --small-family`); without the key the system shows the compact parts of
|
|
749
|
+
* the island there, and the record names `layout.small` in `degradedFeatures`. So does Android, where a watch and a
|
|
750
|
+
* car show the notification.
|
|
751
|
+
*/
|
|
752
|
+
readonly small?: LayoutNode;
|
|
742
753
|
}
|
|
743
754
|
/** What only Android reads of a start. */
|
|
744
755
|
export interface LayoutAndroidOptions {
|
|
@@ -782,7 +793,7 @@ export interface LayoutIosOptions {
|
|
|
782
793
|
* A start at a later time instead of now: iOS 26, and Android where `getCapabilities().androidPresentation.scheduledStart`
|
|
783
794
|
* is true. Until then the record is `pending`: the activity holds its key, it can be ended, and an update is
|
|
784
795
|
* `CONFLICT`, since it begins with the content of its start. `onState` reports `active` when it begins. On Android
|
|
785
|
-
* it begins at its time with the permission for exact alarms (`exactStart`) and
|
|
796
|
+
* it begins at its time with the permission for exact alarms (`exactStart`) and late without, by minutes. It is
|
|
786
797
|
* `UNSUPPORTED_FEATURE`, and nothing is kept, before iOS 26, with the foreground placement on Android, and where
|
|
787
798
|
* `scheduledStart` is false.
|
|
788
799
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tauri-plugin-live-activity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -33,12 +33,13 @@
|
|
|
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/
|
|
36
|
+
"test:contracts": "node --test --experimental-test-coverage \"--test-coverage-include=tools/activitykit.mjs\" \"--test-coverage-include=tools/sync-liveupdate.mjs\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/contract-files.test.mjs tests/typescript-requests.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
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",
|
|
41
41
|
"test:setup": "node --test --experimental-test-coverage \"--test-coverage-include=cli/*.mjs\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/setup.test.mjs",
|
|
42
|
+
"write:requests": "npm run build && node --experimental-strip-types --test --test-update-snapshots tests/jsx.test.mjs tests/react.test.mjs examples/demo/tests/layouts.test.mjs examples/demo/tests/self-test.test.mjs examples/demo/tests/ui-state.test.mjs",
|
|
42
43
|
"build:demo": "npm run build && node examples/demo/build.mjs",
|
|
43
44
|
"prepack": "npm run build",
|
|
44
45
|
"pack:check": "npm pack --dry-run"
|
|
@@ -54,7 +55,6 @@
|
|
|
54
55
|
"@tauri-apps/cli": "2.12.4",
|
|
55
56
|
"@tauri-apps/api": "2.12.4",
|
|
56
57
|
"@types/react": "19.3.0",
|
|
57
|
-
"ajv": "8.20.0",
|
|
58
58
|
"esbuild": "0.28.2",
|
|
59
59
|
"react": "19.3.1",
|
|
60
60
|
"react-test-renderer": "19.3.1",
|