tauri-plugin-live-activity 1.1.0 → 1.2.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.
package/README.ko.md CHANGED
@@ -52,7 +52,7 @@ TypeScript 또는 Rust로 적고, 그리는 일은 플러그인이 [liveactivity
52
52
  | --- | --- | --- |
53
53
  | iPhone | iOS 16.1 | 잠금 화면의 Live Activity, Dynamic Island가 있는 iPhone에서는 Dynamic Island에도. 오래된 표시(stale)와 relevance는 iOS 16.2부터, 버튼·토글·push-to-start는 iOS 17.2부터 |
54
54
  | iPad | iPadOS 17 | 잠금 화면의 같은 Live Activity |
55
- | StandBy | iOS 17 | 옆으로 눕혀 충전하는 iPhone에서 크게 보이는 잠금 화면 카드, `ifFullscreen` 노드가 여기에만 보임 |
55
+ | StandBy | iOS 17 | 옆으로 눕혀 충전하는 iPhone에서 크게 보이는 잠금 화면 카드, iOS 18부터 `ifFullscreen` 노드가 여기에만 보임 |
56
56
  | Apple Watch | iOS 18과 watchOS 11 | 레이아웃의 `small` 영역이 워치의 Smart Stack에 |
57
57
  | Android | Android 8.0 (API 26) | 진행률 막대나 타이머, 동작 최대 세 개가 있는 진행 중 알림. 알림 권한은 Android 13 (API 33)부터 묻습니다 |
58
58
  | Android Live Updates | Android 16 (API 36) | 시스템과 사용자 설정이 허락하면 승격된 Live Update, 아니면 진행 중 알림; `openPromotionSettings()`가 그 설정을 엶 |
@@ -114,8 +114,10 @@ npx tauri-plugin-live-activity setup
114
114
  ```
115
115
 
116
116
  `setup`은 플러그인 권한을 허용하고, Android 최소 버전을 API 26으로 올리고, Mac에서는 액티비티를 그리는
117
- 위젯 확장을 Xcode 프로젝트에 추가합니다. `tauri ios init` 뒤에 실행하고, `src-tauri/gen/apple`을 새로
118
- 만들 때마다 다시 실행합니다. `--dry-run`은 바꿀 내용만 보여 줍니다.
117
+ 위젯 확장을 Xcode 프로젝트에 추가합니다. `src-tauri/gen/apple`이 없으면 앱의 `tauri ios init`으로 먼저
118
+ 만듭니다. 언제 다시 실행해도 됩니다: 이미 된 것은 그대로 두고 빠진 것만 합니다. `--dry-run`은 바꿀 내용만 보여
119
+ 주고, 모든 옵션은 [setup이 하는 일](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#what-setup-does)에
120
+ 있습니다.
119
121
 
120
122
  ## React와 TSX
121
123
 
@@ -435,8 +437,8 @@ tauri-plugin-live-activity는 커뮤니티 플러그인이고, Tauri 공식 플
435
437
  iOS 16.1 이상에서 ActivityKit Live Activity를 시작, 갱신, 종료하고, 잠금 화면과 Dynamic Island에 그립니다.
436
438
 
437
439
  **Xcode에서 Widget Extension을 손으로 넣어야 하나요?** 아니요. `npx tauri-plugin-live-activity setup`이 활동을
438
- 그리는 위젯 확장을 `src-tauri/gen/apple`의 Xcode 프로젝트에 넣습니다. `gen/apple`을 새로 만들 때마다 다시
439
- 실행하세요.
440
+ 그리는 위젯 확장을 `src-tauri/gen/apple`의 Xcode 프로젝트에 넣고, 그 프로젝트가 없으면 앱의 `tauri ios init`으로
441
+ 먼저 만듭니다. 언제 다시 실행해도 빠진 것만 합니다.
440
442
 
441
443
  **Android Live Updates를 지원하나요?** 네. Android 16 (API 36) 이상에서는 시스템과 사용자 설정이 허락하면 승격된
442
444
  Live Update를 요청하고, 그 밖에는 Android 8.0 (API 26)부터 같은 요청이 진행 중 알림으로 보입니다.
package/README.md CHANGED
@@ -52,7 +52,7 @@ In short: iOS 16.1+ and Android 8+, and no activities on desktop.
52
52
  | --- | --- | --- |
53
53
  | iPhone | iOS 16.1 | Live Activities on the Lock Screen and, on iPhones that have one, in the Dynamic Island. Stale dates and relevance from iOS 16.2; buttons, toggles and push-to-start from iOS 17.2 |
54
54
  | iPad | iPadOS 17 | The same Live Activities on the Lock Screen |
55
- | StandBy | iOS 17 | The Lock Screen card scaled up on an iPhone that charges on its side, where nodes with `ifFullscreen` show |
55
+ | StandBy | iOS 17 | The Lock Screen card scaled up on an iPhone that charges on its side; from iOS 18 nodes with `ifFullscreen` show there |
56
56
  | Apple Watch | iOS 18 with watchOS 11 | A layout's `small` region in the watch's Smart Stack |
57
57
  | Android | Android 8.0 (API 26) | An ongoing notification with a progress bar or a timer and up to three actions; the notification permission is asked from Android 13 (API 33) |
58
58
  | Android Live Updates | Android 16 (API 36) | A promoted Live Update where the system and the person's settings allow one, the ongoing notification otherwise; `openPromotionSettings()` opens that setting |
@@ -114,8 +114,11 @@ Then register the plugin in `src-tauri/src/lib.rs`:
114
114
  ```
115
115
 
116
116
  `setup` grants the plugin's permissions, raises the Android minimum to API 26 and, on a Mac, adds the
117
- widget extension that draws the activity to the Xcode project. Run it after `tauri ios init`, and again
118
- whenever `src-tauri/gen/apple` is made from scratch. `--dry-run` shows what it would change.
117
+ widget extension that draws the activity to the Xcode project, which it first makes with the app's
118
+ `tauri ios init` when `src-tauri/gen/apple` is not there. Run it again at any time: it leaves what is set up as it
119
+ is and does what is missing. `--dry-run` shows what it would change, and
120
+ [What setup does](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#what-setup-does)
121
+ has all its options.
119
122
 
120
123
  ## React and TSX
121
124
 
@@ -446,8 +449,8 @@ is a community plugin; Tauri has no official one. With it a Tauri 2 app starts,
446
449
  Activities on iOS 16.1 and later, drawn on the Lock Screen and in the Dynamic Island.
447
450
 
448
451
  **Do I have to add a Widget Extension in Xcode by hand?** No. `npx tauri-plugin-live-activity setup` adds the widget
449
- extension that draws the activity to the Xcode project in `src-tauri/gen/apple`. Run it again whenever `gen/apple` is
450
- made from scratch.
452
+ extension that draws the activity to the Xcode project in `src-tauri/gen/apple`, and first makes that project with the
453
+ app's `tauri ios init` when it is not there. Run it again at any time: it does only what is missing.
451
454
 
452
455
  **Does it support Android Live Updates?** Yes. On Android 16 (API 36) and later the plugin asks for a promoted Live
453
456
  Update where the system and the person's settings allow one; elsewhere, from Android 8.0 (API 26), the same request
package/cli/ios.d.mts CHANGED
@@ -1,3 +1,12 @@
1
1
  import type { SetupContext } from './setup.mjs';
2
2
  import type { PlannedStep } from './steps.mjs';
3
- export declare function iosSteps(context: SetupContext): PlannedStep[];
3
+ /**
4
+ * On a Mac, the step that makes src-tauri/gen/apple with the app's Tauri CLI when the app has no Xcode project yet,
5
+ * so that the iOS steps can follow in the same run. Undefined when the project is there, elsewhere than on a Mac, or
6
+ * without a Tauri CLI, where the iOS steps report what is left.
7
+ */
8
+ export declare function iosInitStep({ srcTauri, env, platform }: Pick<SetupContext, 'srcTauri' | 'env' | 'platform'>): PlannedStep | undefined;
9
+ /** The iOS steps. `initPlanned`: a dry run plans `tauri ios init`, so the project is not there yet. */
10
+ export declare function iosSteps(context: SetupContext, { initPlanned }?: {
11
+ initPlanned?: boolean | undefined;
12
+ }): PlannedStep[];
package/cli/ios.mjs CHANGED
@@ -3,10 +3,10 @@
3
3
  // Xcode project. An app that 0.2 or 0.3 set up loses the plugin's old Swift files on the way (migration.mts).
4
4
  import { spawnSync } from 'node:child_process';
5
5
  import { readdirSync, rmSync } from 'node:fs';
6
- import { join, resolve } from 'node:path';
6
+ import { dirname, join, resolve } from 'node:path';
7
7
  import { OLD_MODULES, RETIRED, released, renameCustomViews } from './migration.mjs';
8
8
  import { newPlist, setTrueKey } from './plist.mjs';
9
- import { SetupError, member, parseJson, readText, step, tail, which, writeFile } from './steps.mjs';
9
+ import { SetupError, isExecutable, member, parseJson, readText, step, tail, which, writeFile } from './steps.mjs';
10
10
  import { assetSteps, bundledFonts, fontSteps } from './widget-files.mjs';
11
11
  import { SMALL_FAMILY_KEY, SPEC_FILE, WIDGET, addInclude, appGroupOf, drawsSmallFamily, readProject, widgetSpec, writtenBySetup, } from './xcodegen.mjs';
12
12
  /** The widget bundle: activitykit's template, under the name 0.2 and 0.3 gave the plugin's. */
@@ -25,7 +25,42 @@ function bundleIdOf(project, config) {
25
25
  }
26
26
  return id;
27
27
  }
28
- export function iosSteps(context) {
28
+ const IOS_INIT = 'tauri ios init --ci';
29
+ /** The app's own Tauri CLI: its @tauri-apps/cli, else cargo's `cargo tauri`, as a program and its first arguments. */
30
+ function tauriCli(srcTauri, env) {
31
+ const local = join(dirname(srcTauri), 'node_modules', '.bin', 'tauri');
32
+ if (isExecutable(local))
33
+ return [local];
34
+ const cargoTauri = which('cargo-tauri', env);
35
+ return cargoTauri ? [cargoTauri, 'tauri'] : undefined;
36
+ }
37
+ /**
38
+ * On a Mac, the step that makes src-tauri/gen/apple with the app's Tauri CLI when the app has no Xcode project yet,
39
+ * so that the iOS steps can follow in the same run. Undefined when the project is there, elsewhere than on a Mac, or
40
+ * without a Tauri CLI, where the iOS steps report what is left.
41
+ */
42
+ export function iosInitStep({ srcTauri, env, platform }) {
43
+ if (platform !== 'darwin')
44
+ return undefined;
45
+ const specPath = join(srcTauri, 'gen', 'apple', 'project.yml');
46
+ if (readText(specPath) !== undefined)
47
+ return undefined;
48
+ const cli = tauriCli(srcTauri, env);
49
+ if (!cli)
50
+ return undefined;
51
+ const [program, ...first] = cli;
52
+ return step('ran', IOS_INIT, 'makes src-tauri/gen/apple', () => {
53
+ // Its own output goes to the terminal as it runs: it may install what iOS builds need, which takes a while.
54
+ const result = spawnSync(program, [...first, 'ios', 'init', '--ci'], { cwd: dirname(srcTauri), env, stdio: ['ignore', 'inherit', 'inherit'] });
55
+ if (result.status === 0 && readText(specPath) !== undefined)
56
+ return undefined;
57
+ const why = result.error ? result.error.message
58
+ : result.status === 0 ? 'it made no src-tauri/gen/apple/project.yml' : `it exited with ${result.status ?? result.signal}; its output is above`;
59
+ return step('todo', IOS_INIT, `${why}. Fix it, then run setup again`);
60
+ });
61
+ }
62
+ /** The iOS steps. `initPlanned`: a dry run plans `tauri ios init`, so the project is not there yet. */
63
+ export function iosSteps(context, { initPlanned = false } = {}) {
29
64
  const { srcTauri, platform, show } = context;
30
65
  if (platform !== 'darwin')
31
66
  return [step('skipped', 'iOS', 'needs a Mac with Xcode')];
@@ -33,6 +68,8 @@ export function iosSteps(context) {
33
68
  const specPath = join(apple, 'project.yml');
34
69
  const yaml = readText(specPath);
35
70
  if (yaml === undefined) {
71
+ if (initPlanned)
72
+ return [step('skipped', 'iOS', 'the widget extension follows `tauri ios init`')];
36
73
  return [step('skipped', 'iOS', 'no src-tauri/gen/apple yet: run `tauri ios init`, then run setup again')];
37
74
  }
38
75
  const project = readProject(yaml);
package/cli/main.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  // The command line of `npx tauri-plugin-live-activity`.
2
2
  import { formatReport } from './report.mjs';
3
3
  import { SetupError, setup } from './setup.mjs';
4
- const USAGE = `Usage: npx tauri-plugin-live-activity setup [--dry-run] [--ios-only] [--font <file>]... [--asset <file>]... [--app-group[=<id>]] [--small-family]
4
+ const USAGE = `Usage: npx tauri-plugin-live-activity setup [--dry-run] [--ios-only] [--font <file>]... [--asset <file>]... [--app-group[=<id>]] [--small-family] [--no-ios-init]
5
5
 
6
6
  Run it in the folder of a Tauri 2 app after \`cargo add\` and \`npm i\`. It grants the plugin's
7
7
  permissions, sets the Android minimum to API 26 and, on a Mac, adds the Live Activity widget
8
- extension to src-tauri/gen/apple. Run it after \`tauri ios init\`, and again if that folder is
9
- ever made from scratch.
8
+ extension to src-tauri/gen/apple, which it makes first with the app's \`tauri ios init\` when it
9
+ is not there. A later run leaves what is set up as it is and does what is missing.
10
10
 
11
11
  --dry-run show what would change, and write nothing
12
12
  --ios-only do only the iOS part: leave the capabilities and tauri.conf.json alone
@@ -17,8 +17,9 @@ ever made from scratch.
17
17
  named, so writeImage can share images; later runs keep it
18
18
  --small-family draw a layout's small region on a paired Apple Watch and in CarPlay, and there the
19
19
  compact parts of a layout without one; later runs keep it
20
+ --no-ios-init leave an app without src-tauri/gen/apple as it is instead of running \`tauri ios init\`
20
21
  `;
21
- const FLAGS = { '--dry-run': 'dryRun', '--ios-only': 'iosOnly', '--small-family': 'smallFamily' };
22
+ const FLAGS = { '--dry-run': 'dryRun', '--ios-only': 'iosOnly', '--small-family': 'smallFamily', '--no-ios-init': 'noIosInit' };
22
23
  const FILES = { '--font': 'fonts', '--asset': 'assets' };
23
24
  const HELP = new Set(['help', '--help', '-h']);
24
25
  const isFlag = (name) => Object.hasOwn(FLAGS, name);
package/cli/setup.d.mts CHANGED
@@ -59,6 +59,8 @@ export interface SetupOptions {
59
59
  readonly appGroup?: boolean | string | undefined;
60
60
  /** Has the widget draw a layout's small region. */
61
61
  readonly smallFamily?: boolean | undefined;
62
+ /** Leaves an app without src-tauri/gen/apple as it is, where setup would run `tauri ios init`. */
63
+ readonly noIosInit?: boolean | undefined;
62
64
  }
63
65
  /** What every step is given: the app, the crates, and what the person asked for. */
64
66
  export interface SetupContext extends App, Crates {
@@ -89,7 +91,7 @@ export interface SetupResult {
89
91
  * extension; `appGroup` is true or the name of an App Group; with `smallFamily` the widget draws a layout's small
90
92
  * region. Throws SetupError when it cannot start.
91
93
  */
92
- export declare function setup({ cwd, env, dryRun, iosOnly, platform, fonts, assets, appGroup, smallFamily, }?: SetupOptions): SetupResult;
94
+ export declare function setup({ cwd, env, dryRun, iosOnly, platform, fonts, assets, appGroup, smallFamily, noIosInit, }?: SetupOptions): SetupResult;
93
95
  /**
94
96
  * The plugin crate's version and the folder of the activitykit crate it depends on, from `cargo metadata`: the widget
95
97
  * extension and the app target link activitykit's Swift package, which lies in that folder.
package/cli/setup.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  import { spawnSync } from 'node:child_process';
4
4
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
5
5
  import { dirname, join } from 'node:path';
6
- import { iosSteps } from './ios.mjs';
6
+ import { iosInitStep, iosSteps } from './ios.mjs';
7
7
  import { SetupError, display, errorCode, isList, isRecord, jsonLike, member, parseJson, readText, step, tail, writeFile, } from './steps.mjs';
8
8
  import { widgetFiles } from './widget-files.mjs';
9
9
  export { SetupError } from './steps.mjs';
@@ -31,15 +31,24 @@ export const NPM_VERSION = String(member(NPM_MANIFEST, 'version'));
31
31
  * extension; `appGroup` is true or the name of an App Group; with `smallFamily` the widget draws a layout's small
32
32
  * region. Throws SetupError when it cannot start.
33
33
  */
34
- export function setup({ cwd = process.cwd(), env = process.env, dryRun = false, iosOnly = false, platform = process.platform, fonts = [], assets = [], appGroup = undefined, smallFamily = false, } = {}) {
34
+ export function setup({ cwd = process.cwd(), env = process.env, dryRun = false, iosOnly = false, platform = process.platform, fonts = [], assets = [], appGroup = undefined, smallFamily = false, noIosInit = false, } = {}) {
35
35
  const files = widgetFiles(cwd, { fonts, assets });
36
36
  const app = findApp(cwd);
37
37
  const { plugin, activitykit } = findCrates(app, env);
38
38
  const context = { ...app, plugin, activitykit, env, platform, files, appGroup, smallFamily, show: path => display(cwd, path) };
39
- const planned = [...(iosOnly ? [] : [capabilitiesStep(context), ...androidSteps(context)]), ...iosSteps(context)];
39
+ // Without an Xcode project the iOS steps have nothing to read: `tauri ios init` runs first, before they are planned.
40
+ const init = noIosInit ? undefined : iosInitStep(context);
41
+ const initialized = init && !dryRun ? withoutEffect(apply(init)) : init;
42
+ const planned = [
43
+ ...(iosOnly ? [] : [capabilitiesStep(context), ...androidSteps(context)]),
44
+ ...(initialized ? [initialized] : []),
45
+ ...iosSteps(context, { initPlanned: dryRun && init !== undefined }),
46
+ ];
40
47
  const steps = dryRun ? planned : planned.map(apply);
41
48
  return { dryRun, version: plugin.version, steps: steps.map(({ effect, ...rest }) => rest), notes: notes(context) };
42
49
  }
50
+ /** A step whose effect has run, as it is reported. */
51
+ const withoutEffect = ({ effect, ...report }) => report;
43
52
  function apply(planned) {
44
53
  if (!planned.effect)
45
54
  return planned;
package/cli/steps.d.mts CHANGED
@@ -40,3 +40,5 @@ export declare function tail(text?: string): string;
40
40
  export declare function display(cwd: string, path: string): string;
41
41
  /** The executable `name` on the PATH of `env`, or undefined. */
42
42
  export declare function which(name: string, env: NodeJS.ProcessEnv): string | undefined;
43
+ /** Whether `path` is a file this process may run. */
44
+ export declare function isExecutable(path: string): boolean;
package/cli/steps.mjs CHANGED
@@ -87,7 +87,8 @@ export function which(name, env) {
87
87
  }
88
88
  return undefined;
89
89
  }
90
- function isExecutable(path) {
90
+ /** Whether `path` is a file this process may run. */
91
+ export function isExecutable(path) {
91
92
  try {
92
93
  accessSync(path, constants.X_OK);
93
94
  return statSync(path).isFile();
@@ -610,11 +610,11 @@ type NodeFields = {
610
610
  readonly ifStale?: boolean;
611
611
  /**
612
612
  * `true`: the node and its subtree are drawn only while the Lock Screen presentation fills the screen, in StandBy
613
- * on an iPhone that charges on its side (iOS 17); `false`: only while it does not. Beside the other conditions the
614
- * node is drawn while all hold. The island's parts and the small family are never full screen, and neither is an
615
- * Android notification: Android leaves out a node of `true` and draws one of `false`, and names nothing. The widget
616
- * extension needs activitykit 0.9.0, which `setup` points it at: one built with an earlier activitykit draws such a
617
- * node always.
613
+ * on an iPhone that charges on its side (iOS 18; on iOS 17 the card there is drawn as on the Lock Screen); `false`:
614
+ * only while it does not. Beside the other conditions the node is drawn while all hold. The island's parts and the
615
+ * small family are never full screen, and neither is an Android notification: Android leaves out a node of `true`
616
+ * and draws one of `false`, and names nothing. The widget extension needs activitykit 0.9.0, and 1.0.4 on iOS 17,
617
+ * which `setup` points it at: one built with an activitykit before 0.9.0 draws such a node always.
618
618
  */
619
619
  readonly ifFullscreen?: boolean;
620
620
  /** What assistive technologies read of the node. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "1.1.0",
3
+ "version": "1.2.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",