tauri-plugin-live-activity 0.13.1 → 0.14.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.
Files changed (3) hide show
  1. package/README.ko.md +62 -5
  2. package/README.md +62 -5
  3. package/package.json +3 -3
package/README.ko.md CHANGED
@@ -9,7 +9,8 @@
9
9
  Dynamic Island(ActivityKit)에, Android에서는 Live Update나 진행 중 알림으로 보여 줍니다. 레이아웃은 TSX,
10
10
  TypeScript 또는 Rust로 적고, 그리는 일은 플러그인이 [liveactivity-rs](https://github.com/1eedaegon/liveactivity-rs)
11
11
  브리지를 통해 맡습니다.
12
- [English](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/README.md)
12
+ [English](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/README.md) ·
13
+ [사이트](https://1eedaegon.github.io/tauri-plugin-live-activity/ko/)
13
14
 
14
15
  <table>
15
16
  <tr><th>iOS 잠금 화면</th><th>Dynamic Island</th></tr>
@@ -83,7 +84,8 @@ liveactivity liveactivity-rs 브리지: 하나의 요청 계약,
83
84
  진행 중 알림, Android 16부터 Live Update
84
85
  ```
85
86
 
86
- 플러그인 자체의 Swift 코드는 없고, Kotlin은 권한 명령과 liveupdate의 Android 어댑터 호출만 맡습니다.
87
+ 플러그인 자체의 Swift 코드는 없고, Kotlin은 권한 명령과 liveupdate의 Android 어댑터 호출만 맡습니다. 플러그인
88
+ 아래의 백엔드는 바꾸거나 층으로 감쌀 수 있습니다: [직접 만든 백엔드](#직접-만든-백엔드).
87
89
  [iOS 설정](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/ios-integration.md)과
88
90
  [Android 설정](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md)이
89
91
  `setup`이 각 프로젝트에서 바꾸는 것을 보여 줍니다.
@@ -344,6 +346,49 @@ Auto에는 이를 보여 줄 자리가 없습니다. Android는 `small`을 `degr
344
346
  덮어쓰지 않으며, `custom('ring', { props: { level: bind('done') } })`으로 놓습니다. 그린 PNG는 최대 1 MiB,
345
347
  1224 × 480 픽셀입니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#beyond-the-built-in-parts)
346
348
 
349
+ ## 직접 만든 백엔드
350
+
351
+ `init()`은 `Builder::new().build()`이고, 플랫폼 백엔드 위에서 돕니다: iOS는 ActivityKit, Android는 liveupdate.
352
+ `Builder::layer`는 그 위에 층을 씌웁니다. Android가 레이아웃에서 빼는 것을 그리는 렌더러, 로그, 시험용 대역 같은
353
+ 것입니다. `BackendLayer`는 바꾸는 호출만 덮어쓰고, 나머지 호출은 그대로 아래 백엔드로 갑니다. 그래서 메서드를
354
+ 빠뜨려도 기능이 꺼지지 않습니다. 탭을 지켜보는 층은 `attach`가 넘기는 `BackendContext`를 감쌉니다.
355
+
356
+ `Builder::backend`는 플랫폼 백엔드 자리에 직접 만든 백엔드를 넣습니다(예를 들어 데스크톱). 층은 그 위에 씌워집니다.
357
+ 이때 플랫폼 백엔드는 만들어지지 않습니다. 다만 Android에서는 정확한 알람 설정을 열기 위해 계속 만들어집니다. iOS에서는
358
+ 플러그인이 kit을 만들지 않으므로, 설정의 `receipts`와 `pushToStart`는 직접 만든 백엔드가 지켜야 합니다. 직접 만든
359
+ 백엔드는 liveactivity-rs 브리지의 인터페이스인 `LiveActivityBackend`를 구현하고, 탭을 비롯한 이벤트를 `attach`에서
360
+ 받은 컨텍스트로 보냅니다. 플러그인은 `sync_events`를 부르지 않습니다. liveactivity의 `testkit` 기능(`conformance`)으로
361
+ 백엔드가 계약을 지키는지 확인할 수 있습니다. 어느 쪽이든 Tauri 쪽인 명령, 이벤트, `live-activity:` 권한은 플러그인이
362
+ 계속 맡습니다.
363
+
364
+ ```rust
365
+ use std::sync::Arc;
366
+ use std::sync::atomic::{AtomicUsize, Ordering};
367
+ use tauri_plugin_live_activity::{
368
+ BackendFuture, BackendLayer, Builder, LayoutActivityRecord, LayoutStartInput, LiveActivityBackend,
369
+ };
370
+
371
+ /// 시작하는 레이아웃 활동을 셉니다. 나머지 호출은 그대로 넘어갑니다.
372
+ #[derive(Default)]
373
+ struct Starts(AtomicUsize);
374
+
375
+ impl BackendLayer for Starts {
376
+ fn start_layout<'a>(
377
+ &'a self,
378
+ input: LayoutStartInput,
379
+ next: &'a dyn LiveActivityBackend,
380
+ ) -> BackendFuture<'a, LayoutActivityRecord> {
381
+ self.0.fetch_add(1, Ordering::Relaxed);
382
+ next.start_layout(input)
383
+ }
384
+ }
385
+
386
+ // 앱의 빌더에서 `.plugin(tauri_plugin_live_activity::init())` 대신 씁니다. 수는 핸들로 읽습니다:
387
+ // `starts.0.load(Ordering::Relaxed)`.
388
+ let starts = Arc::new(Starts::default());
389
+ // .plugin(Builder::new().layer(starts.clone()).build())
390
+ ```
391
+
347
392
  ## 제약
348
393
 
349
394
  - iOS: iOS 16.1의 iPhone 또는 iPadOS 17의 iPad, 버튼과 토글은 iOS 17.2부터. iOS 16.1에는 stale 날짜와 relevance 점수가
@@ -367,9 +412,13 @@ Now Bar가 보여 줄 제목과 본문을 보냅니다. One UI는 Samsung의 허
367
412
 
368
413
  ## 자주 묻는 질문
369
414
 
370
- **Tauri 앱이 Live Activity를 띄우거나 Dynamic Island를 쓸 수 있나요?** 네. 이 플러그인으로 Tauri 2 앱은 iOS 16.1
371
- 이상에서 ActivityKit Live Activity를 시작, 갱신, 종료하고, 잠금 화면과 Dynamic Island에 그립니다. 그리는 위젯
372
- 확장은 `npx tauri-plugin-live-activity setup`이 앱의 Xcode 프로젝트에 넣습니다.
415
+ **iOS Live Activity와 Dynamic Island를 위한 Tauri 플러그인이 있나요?** 네, 이 플러그인입니다.
416
+ tauri-plugin-live-activity는 커뮤니티 플러그인이고, Tauri 공식 플러그인은 없습니다. 이 플러그인으로 Tauri 2 앱은
417
+ iOS 16.1 이상에서 ActivityKit Live Activity를 시작, 갱신, 종료하고, 잠금 화면과 Dynamic Island에 그립니다.
418
+
419
+ **Xcode에서 Widget Extension을 손으로 넣어야 하나요?** 아니요. `npx tauri-plugin-live-activity setup`이 활동을
420
+ 그리는 위젯 확장을 `src-tauri/gen/apple`의 Xcode 프로젝트에 넣습니다. `gen/apple`을 새로 만들 때마다 다시
421
+ 실행하세요.
373
422
 
374
423
  **Android Live Updates를 지원하나요?** 네. Android 16 (API 36) 이상에서는 시스템과 사용자 설정이 허락하면 승격된
375
424
  Live Update를 요청하고, 그 밖에는 Android 8.0 (API 26)부터 같은 요청이 진행 중 알림으로 보입니다.
@@ -383,6 +432,14 @@ Live Update를 요청하고, 그 밖에는 Android 8.0 (API 26)부터 같은 요
383
432
  **liveactivity-rs가 뭔가요?** 이 플러그인이 올라선 Rust 브리지, `liveactivity` 크레이트입니다. 요청 계약과 수명
384
433
  주기를 맡고, iOS는 activitykit-rs, Android는 liveupdate-rs 위에서 돌립니다([동작 구조](#동작-구조)).
385
434
 
435
+ **백엔드를 바꾸거나 덧붙일 수 있나요?** 네. `Builder::layer`는 플랫폼 백엔드 위에 렌더러, 로그, 시험용 대역 같은
436
+ 층을 씌우고, `Builder::backend`는 그 자리에 직접 만든 백엔드를 넣습니다. 둘 다 liveactivity-rs 브리지의
437
+ `LiveActivityBackend` 인터페이스를 씁니다([직접 만든 백엔드](#직접-만든-백엔드)).
438
+
439
+ **홈 화면 위젯 플러그인과 무엇이 다른가요?** tauri-plugin-widgets 같은 위젯 플러그인은 홈 화면에 계속 머무는
440
+ WidgetKit, Android Glance 위젯을 그립니다. 이 플러그인은 작업 하나가 진행되는 동안 그 작업을 따라가는 Live
441
+ Activity와 Android Live Update를 그립니다. 한 앱에서 둘 다 쓸 수 있습니다.
442
+
386
443
  **서버가 활동을 갱신할 수 있나요?** iOS에서는 APNs로 됩니다: 푸시 토큰, iOS 17.2부터 push-to-start, iOS 18부터
387
444
  broadcast 채널([푸시 (iOS)](#푸시-ios)). Android에는 푸시 경로가 없고, 앱이 알림을 갱신합니다.
388
445
 
package/README.md CHANGED
@@ -9,7 +9,8 @@
9
9
  Lock Screen and in the Dynamic Island (ActivityKit), and as a Live Update or an ongoing notification on Android.
10
10
  You describe the layout in TSX, TypeScript or Rust; the plugin draws it, through the
11
11
  [liveactivity-rs](https://github.com/1eedaegon/liveactivity-rs) bridge.
12
- [한국어](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/README.ko.md)
12
+ [한국어](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/README.ko.md) ·
13
+ [Site](https://1eedaegon.github.io/tauri-plugin-live-activity/)
13
14
 
14
15
  <table>
15
16
  <tr><th>iOS Lock Screen</th><th>Dynamic Island</th></tr>
@@ -84,7 +85,7 @@ liveactivity the liveactivity-rs bridge: one request contract,
84
85
  ```
85
86
 
86
87
  The plugin has no Swift of its own; its Kotlin answers the permission commands and carries liveupdate's Android
87
- adapter. [iOS setup](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/ios-integration.md) and
88
+ adapter. The backend under the plugin can be replaced, or wrapped in layers: see [Your own backend](#your-own-backend). [iOS setup](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/ios-integration.md) and
88
89
  [Android setup](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md) show
89
90
  what `setup` changes in each project.
90
91
 
@@ -354,6 +355,50 @@ A view of your own is SwiftUI in `gen/apple/LiveActivityWidget/LiveActivityCusto
354
355
  creates once and never overwrites, placed with `custom('ring', { props: { level: bind('done') } })`. A drawn PNG is
355
356
  at most 1 MiB and 1224 × 480 pixels. [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#beyond-the-built-in-parts)
356
357
 
358
+ ## Your own backend
359
+
360
+ `init()` is `Builder::new().build()`, on the platform's backend: ActivityKit on iOS and liveupdate on Android.
361
+ `Builder::layer` puts a layer over it, such as a renderer of what Android leaves out of a layout, a log or a stand-in
362
+ for tests. A `BackendLayer` overrides the calls it changes, and every other call goes to the backend under it, so a
363
+ layer never turns a feature off by leaving a method out; one that watches the taps wraps the `BackendContext` that
364
+ `attach` passes on.
365
+
366
+ `Builder::backend` puts a backend of your own in the platform's place, for example on desktop, and the layers go over
367
+ it. The platform's backend is then not built, except on Android, where it still opens the setting for exact alarms;
368
+ on iOS the plugin then builds no kit, so the configuration's `receipts` and `pushToStart` are your backend's to keep.
369
+ Your backend implements `LiveActivityBackend`, the interface of the liveactivity-rs bridge, and sends its events,
370
+ taps among them, through the context it gets in `attach`; the plugin calls no `sync_events`. liveactivity's `testkit`
371
+ feature checks a backend against the contract (`conformance`). The plugin keeps its Tauri side around either: the
372
+ commands, the events and the `live-activity:` permissions.
373
+
374
+ ```rust
375
+ use std::sync::Arc;
376
+ use std::sync::atomic::{AtomicUsize, Ordering};
377
+ use tauri_plugin_live_activity::{
378
+ BackendFuture, BackendLayer, Builder, LayoutActivityRecord, LayoutStartInput, LiveActivityBackend,
379
+ };
380
+
381
+ /// Counts the layout activities that start; every other call goes on unchanged.
382
+ #[derive(Default)]
383
+ struct Starts(AtomicUsize);
384
+
385
+ impl BackendLayer for Starts {
386
+ fn start_layout<'a>(
387
+ &'a self,
388
+ input: LayoutStartInput,
389
+ next: &'a dyn LiveActivityBackend,
390
+ ) -> BackendFuture<'a, LayoutActivityRecord> {
391
+ self.0.fetch_add(1, Ordering::Relaxed);
392
+ next.start_layout(input)
393
+ }
394
+ }
395
+
396
+ // In the builder of the app, in place of `.plugin(tauri_plugin_live_activity::init())`, with a handle to read the
397
+ // count by, `starts.0.load(Ordering::Relaxed)`:
398
+ let starts = Arc::new(Starts::default());
399
+ // .plugin(Builder::new().layer(starts.clone()).build())
400
+ ```
401
+
357
402
  ## Limits
358
403
 
359
404
  - iOS: an iPhone with iOS 16.1 or an iPad with iPadOS 17; buttons and toggles need iOS 17.2. iOS 16.1 has no stale date and no
@@ -377,9 +422,13 @@ app while the developer option "Live notifications for all apps" is on.
377
422
 
378
423
  ## Questions
379
424
 
380
- **Can a Tauri app show a Live Activity or use the Dynamic Island?** Yes. With this plugin a Tauri 2 app starts,
381
- updates and ends ActivityKit Live Activities on iOS 16.1 and later, drawn on the Lock Screen and in the Dynamic
382
- Island. `npx tauri-plugin-live-activity setup` adds the widget extension that draws them to the app's Xcode project.
425
+ **Is there a Tauri plugin for iOS Live Activities and the Dynamic Island?** Yes: this one. tauri-plugin-live-activity
426
+ is a community plugin; Tauri has no official one. With it a Tauri 2 app starts, updates and ends ActivityKit Live
427
+ Activities on iOS 16.1 and later, drawn on the Lock Screen and in the Dynamic Island.
428
+
429
+ **Do I have to add a Widget Extension in Xcode by hand?** No. `npx tauri-plugin-live-activity setup` adds the widget
430
+ extension that draws the activity to the Xcode project in `src-tauri/gen/apple`. Run it again whenever `gen/apple` is
431
+ made from scratch.
383
432
 
384
433
  **Does it support Android Live Updates?** Yes. On Android 16 (API 36) and later the plugin asks for a promoted Live
385
434
  Update where the system and the person's settings allow one; elsewhere, from Android 8.0 (API 26), the same request
@@ -394,6 +443,14 @@ plugin and its crates. A view of your own can still be SwiftUI ([Beyond the buil
394
443
  **What is liveactivity-rs?** The Rust bridge this plugin is built on, the `liveactivity` crate. It owns the request
395
444
  contract and the lifecycle, and runs iOS on activitykit-rs and Android on liveupdate-rs ([How it works](#how-it-works)).
396
445
 
446
+ **Can I replace the backend, or add to it?** Yes. `Builder::layer` puts a layer over the platform's backend, such as
447
+ a renderer, a log or a stand-in for tests, and `Builder::backend` puts a backend of your own in its place. Both use
448
+ the liveactivity-rs bridge's `LiveActivityBackend` interface ([Your own backend](#your-own-backend)).
449
+
450
+ **How is it different from a home-screen widget plugin?** Widget plugins such as tauri-plugin-widgets draw
451
+ WidgetKit and Android Glance widgets that stay on the home screen. This plugin draws Live Activities and Android Live
452
+ Updates, which follow one task while it runs. An app can use both.
453
+
397
454
  **Can a server update an activity?** On iOS, through APNs: push tokens, push-to-start from iOS 17.2 and broadcast
398
455
  channels from iOS 18 ([Pushes (iOS)](#pushes-ios)). Android has no push path; the app updates its notification.
399
456
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "0.13.1",
3
+ "version": "0.14.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",
@@ -9,7 +9,7 @@
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/1eedaegon/tauri-plugin-live-activity.git"
11
11
  },
12
- "homepage": "https://github.com/1eedaegon/tauri-plugin-live-activity#readme",
12
+ "homepage": "https://1eedaegon.github.io/tauri-plugin-live-activity/",
13
13
  "bugs": "https://github.com/1eedaegon/tauri-plugin-live-activity/issues",
14
14
  "keywords": ["tauri", "tauri-plugin", "tauri-v2", "ios", "ipados", "android", "live-activity", "live-activities", "activitykit", "dynamic-island", "live-updates", "live-update", "android-live-updates", "notifications", "ongoing-notification", "lock-screen", "widgetkit", "now-bar", "liveactivity-rs", "react", "tsx", "rust"],
15
15
  "sideEffects": false,
@@ -33,7 +33,7 @@
33
33
  "build": "tsc -p tsconfig.json && tsc -p cli && node -e \"require('node:fs').chmodSync('cli/bin.mjs', 0o755)\"",
34
34
  "typecheck": "npm run build && tsc -p tools && tsc -p tests && tsc -p examples/demo/tsconfig.json && tsc -p examples/demo/tsconfig.node.json && tsc -p examples/demo/tsconfig.live.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 --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=tools/activitykit.ts\" \"--test-coverage-include=tools/sync-liveupdate.ts\" \"--test-coverage-include=tools/cargo.ts\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/contract-files.test.ts tests/typescript-requests.test.ts tests/android-liveupdate.test.ts tests/android-contents.test.ts tests/ci.test.ts tests/ci-cache.test.ts tests/ios-run.test.ts tests/spec-coverage.test.ts tests/docs.test.ts",
36
+ "test:contracts": "node --experimental-strip-types --test --experimental-test-coverage \"--test-coverage-include=tools/activitykit.ts\" \"--test-coverage-include=tools/sync-liveupdate.ts\" \"--test-coverage-include=tools/cargo.ts\" --test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=80 tests/contract-files.test.ts tests/typescript-requests.test.ts tests/android-liveupdate.test.ts tests/android-contents.test.ts tests/ci.test.ts tests/ci-cache.test.ts tests/ios-run.test.ts tests/spec-coverage.test.ts tests/docs.test.ts tests/site.test.ts",
37
37
  "test:api": "node --experimental-strip-types --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.ts tests/api-reload.test.ts",
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.ts",
39
39
  "test:react": "node --experimental-strip-types --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.ts",