tauri-plugin-live-activity 0.13.2 → 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 +49 -1
  2. package/README.md +49 -1
  3. package/package.json +1 -1
package/README.ko.md CHANGED
@@ -84,7 +84,8 @@ liveactivity liveactivity-rs 브리지: 하나의 요청 계약,
84
84
  진행 중 알림, Android 16부터 Live Update
85
85
  ```
86
86
 
87
- 플러그인 자체의 Swift 코드는 없고, Kotlin은 권한 명령과 liveupdate의 Android 어댑터 호출만 맡습니다.
87
+ 플러그인 자체의 Swift 코드는 없고, Kotlin은 권한 명령과 liveupdate의 Android 어댑터 호출만 맡습니다. 플러그인
88
+ 아래의 백엔드는 바꾸거나 층으로 감쌀 수 있습니다: [직접 만든 백엔드](#직접-만든-백엔드).
88
89
  [iOS 설정](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/ios-integration.md)과
89
90
  [Android 설정](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md)이
90
91
  `setup`이 각 프로젝트에서 바꾸는 것을 보여 줍니다.
@@ -345,6 +346,49 @@ Auto에는 이를 보여 줄 자리가 없습니다. Android는 `small`을 `degr
345
346
  덮어쓰지 않으며, `custom('ring', { props: { level: bind('done') } })`으로 놓습니다. 그린 PNG는 최대 1 MiB,
346
347
  1224 × 480 픽셀입니다. [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#beyond-the-built-in-parts)
347
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
+
348
392
  ## 제약
349
393
 
350
394
  - iOS: iOS 16.1의 iPhone 또는 iPadOS 17의 iPad, 버튼과 토글은 iOS 17.2부터. iOS 16.1에는 stale 날짜와 relevance 점수가
@@ -388,6 +432,10 @@ Live Update를 요청하고, 그 밖에는 Android 8.0 (API 26)부터 같은 요
388
432
  **liveactivity-rs가 뭔가요?** 이 플러그인이 올라선 Rust 브리지, `liveactivity` 크레이트입니다. 요청 계약과 수명
389
433
  주기를 맡고, iOS는 activitykit-rs, Android는 liveupdate-rs 위에서 돌립니다([동작 구조](#동작-구조)).
390
434
 
435
+ **백엔드를 바꾸거나 덧붙일 수 있나요?** 네. `Builder::layer`는 플랫폼 백엔드 위에 렌더러, 로그, 시험용 대역 같은
436
+ 층을 씌우고, `Builder::backend`는 그 자리에 직접 만든 백엔드를 넣습니다. 둘 다 liveactivity-rs 브리지의
437
+ `LiveActivityBackend` 인터페이스를 씁니다([직접 만든 백엔드](#직접-만든-백엔드)).
438
+
391
439
  **홈 화면 위젯 플러그인과 무엇이 다른가요?** tauri-plugin-widgets 같은 위젯 플러그인은 홈 화면에 계속 머무는
392
440
  WidgetKit, Android Glance 위젯을 그립니다. 이 플러그인은 작업 하나가 진행되는 동안 그 작업을 따라가는 Live
393
441
  Activity와 Android Live Update를 그립니다. 한 앱에서 둘 다 쓸 수 있습니다.
package/README.md CHANGED
@@ -85,7 +85,7 @@ liveactivity the liveactivity-rs bridge: one request contract,
85
85
  ```
86
86
 
87
87
  The plugin has no Swift of its own; its Kotlin answers the permission commands and carries liveupdate's Android
88
- 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
89
89
  [Android setup](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/android-integration.md) show
90
90
  what `setup` changes in each project.
91
91
 
@@ -355,6 +355,50 @@ A view of your own is SwiftUI in `gen/apple/LiveActivityWidget/LiveActivityCusto
355
355
  creates once and never overwrites, placed with `custom('ring', { props: { level: bind('done') } })`. A drawn PNG is
356
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)
357
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
+
358
402
  ## Limits
359
403
 
360
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
@@ -399,6 +443,10 @@ plugin and its crates. A view of your own can still be SwiftUI ([Beyond the buil
399
443
  **What is liveactivity-rs?** The Rust bridge this plugin is built on, the `liveactivity` crate. It owns the request
400
444
  contract and the lifecycle, and runs iOS on activitykit-rs and Android on liveupdate-rs ([How it works](#how-it-works)).
401
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
+
402
450
  **How is it different from a home-screen widget plugin?** Widget plugins such as tauri-plugin-widgets draw
403
451
  WidgetKit and Android Glance widgets that stay on the home screen. This plugin draws Live Activities and Android Live
404
452
  Updates, which follow one task while it runs. An app can use both.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "0.13.2",
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",