tauri-plugin-live-activity 0.5.0 → 0.5.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.
Files changed (3) hide show
  1. package/README.ko.md +45 -2
  2. package/README.md +45 -1
  3. package/package.json +1 -1
package/README.ko.md CHANGED
@@ -103,8 +103,7 @@ app.live_activity().update_layout(LayoutUpdateInput { id, snapshot: LayoutSnapsh
103
103
  레이아웃은 `text`/`bound`, `path`(SVG path 데이터), `vstack`·`hstack`·`zstack`·`spacer`·`divider`와
104
104
  아래 여섯 가지로 만듭니다. 그림은 모두 iOS 잠금화면입니다. 예시의 빌더는 `layout`에서 꺼내 씁니다
105
105
  (`const { vstack, hstack, text, bound, symbol, image, gauge, progress, timerText, button } = layout;`).
106
- 같은 레이아웃을 TSX로 쓸 수 있고, React 훅으로 컴포넌트와 액티비티를 함께 움직일 수도 있습니다
107
- ([TSX and React](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#tsx-and-react)).
106
+ 같은 레이아웃을 TSX로 쓸 수 있고, React 훅으로 컴포넌트와 액티비티를 함께 움직일 수도 있습니다([TSX와 React](#tsx와-react)).
108
107
 
109
108
  ### 심볼
110
109
 
@@ -205,6 +204,50 @@ keyline: '#A3D9C2', // 아일랜드 테두리 색
205
204
 
206
205
  Android는 레이아웃을 알림으로 보여 줍니다. 첫 두 텍스트가 제목과 본문이 되고, 첫 진행률 막대와 타이머, 버튼 최대 세 개가 들어갑니다. 빠진 것은 `degradedFeatures`에 이름이 남습니다.
207
206
 
207
+ ## TSX와 React
208
+
209
+ 같은 레이아웃을 TSX로 쓸 수 있습니다. `tauri-plugin-live-activity/jsx`는 자체 JSX 소스라 `.tsx` 파일에 React가
210
+ 필요 없습니다. `tsconfig.json`에 `"jsx": "react-jsx"`와 `"jsxImportSource": "tauri-plugin-live-activity/jsx"`를
211
+ 두거나, 파일 맨 위에 `/** @jsxImportSource tauri-plugin-live-activity/jsx */`를 적습니다.
212
+
213
+ ```tsx
214
+ import { Button, HStack, SFSymbol, Text, VStack } from 'tauri-plugin-live-activity/jsx';
215
+
216
+ const lockScreen = (
217
+ <VStack alignment="leading" spacing={8}>
218
+ <HStack spacing={8}><SFSymbol name="cat.fill" /><Text bind="title" /></HStack>
219
+ <Text bind="status" />
220
+ <Button actionId="pet"><Text>Pet Mochi</Text></Button>
221
+ </VStack>
222
+ );
223
+ ```
224
+
225
+ 노드마다 컴포넌트가 하나씩 있고(`VStack`, `HStack`, `ZStack`, `Spacer`, `Divider`, `Text`, `SFSymbol`, `Image`,
226
+ `Path`, `Progress`, `Gauge`, `TimerText`, `Button`, `Custom`), 노드의 멤버가 그대로 prop입니다. `Text`는 자식을
227
+ 글자로 보여 주고 `bind`를 주면 값을 보여 줍니다. 스택은 노드, 배열, `{late && <Text>Late</Text>}`를 받고, `Button`은
228
+ 노드 하나를 감쌉니다. HTML 요소와 프래그먼트는 없습니다. 이 엔트리는 Tauri도 React도 불러오지 않아서, 서버에서 푸시
229
+ 페이로드용으로 같은 레이아웃을 만들 수 있습니다.
230
+
231
+ `tauri-plugin-live-activity/react`는 액티비티 하나를 컴포넌트와 함께 움직입니다(React 18 이상, 선택적 peer
232
+ 의존성).
233
+
234
+ ```tsx
235
+ import { useLiveActivity } from 'tauri-plugin-live-activity/react';
236
+
237
+ const { status, record, error } = useLiveActivity({
238
+ activityKey: `delivery:${order.id}`,
239
+ layout: { lockScreen },
240
+ values: { title: order.title, status: order.status },
241
+ enabled: order.open,
242
+ onAction: ({ actionId }) => { if (actionId === 'done') closeOrder(order.id); },
243
+ });
244
+ ```
245
+
246
+ 마운트되면 시작하고, `values`가 바뀐 렌더마다 다음 revision으로 갱신 하나를 보내며(한 번에 요청 하나, 겹치면 마지막
247
+ 값만), 언마운트나 `enabled: false`에 끝납니다. `layout`과 `styles`는 시작할 때만 읽으니 바꾸려면 `activityKey`를
248
+ 바꿔 새 액티비티를 시작합니다. 거부된 요청은 `error`에 남고, `onAction`은 이 액티비티의 탭만 받습니다.
249
+ [더 보기](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#tsx-and-react)
250
+
208
251
  ## 기본 부품 너머
209
252
 
210
253
  대부분은 Swift 없이 바꿀 수 있습니다. 글꼴과 그림을 위젯 확장에 넣고 이름으로 부르면 됩니다.
package/README.md CHANGED
@@ -103,7 +103,7 @@ Layouts are built from `text`/`bound`, `path` (SVG path data) and `vstack`, `hst
103
103
  `spacer`, `divider`, plus the six below. Each picture is the iOS Lock Screen. The snippets take
104
104
  the builders from `layout` (`const { vstack, hstack, text, bound, symbol, image, gauge, progress, timerText, button } = layout;`).
105
105
  The same layouts can be written in TSX, and a React hook keeps an activity in step with a component
106
- ([TSX and React](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#tsx-and-react)).
106
+ ([TSX and React](#tsx-and-react)).
107
107
 
108
108
  ### Symbols
109
109
 
@@ -204,6 +204,50 @@ Put `island` next to `lockScreen` in the layout. A part you leave out shows the
204
204
 
205
205
  Android shows a layout as a notification: the first two texts as title and body, the first progress bar and timer, and up to three buttons. `degradedFeatures` names what it left out.
206
206
 
207
+ ## TSX and React
208
+
209
+ The same layouts can be written in TSX. `tauri-plugin-live-activity/jsx` is a JSX import source of its own, so a
210
+ `.tsx` file needs no React: set `"jsx": "react-jsx"` and `"jsxImportSource": "tauri-plugin-live-activity/jsx"` in
211
+ `tsconfig.json`, or `/** @jsxImportSource tauri-plugin-live-activity/jsx */` at the top of the file.
212
+
213
+ ```tsx
214
+ import { Button, HStack, SFSymbol, Text, VStack } from 'tauri-plugin-live-activity/jsx';
215
+
216
+ const lockScreen = (
217
+ <VStack alignment="leading" spacing={8}>
218
+ <HStack spacing={8}><SFSymbol name="cat.fill" /><Text bind="title" /></HStack>
219
+ <Text bind="status" />
220
+ <Button actionId="pet"><Text>Pet Mochi</Text></Button>
221
+ </VStack>
222
+ );
223
+ ```
224
+
225
+ One component per node (`VStack`, `HStack`, `ZStack`, `Spacer`, `Divider`, `Text`, `SFSymbol`, `Image`, `Path`,
226
+ `Progress`, `Gauge`, `TimerText`, `Button`, `Custom`), with the node's members as props. `Text` shows its
227
+ children or, with `bind`, a value; a stack takes nodes, arrays and `{late && <Text>Late</Text>}`; a `Button`
228
+ holds one node. There are no HTML elements and no fragments. The entry imports neither Tauri nor React, so a
229
+ server can build the same layout for a push payload.
230
+
231
+ `tauri-plugin-live-activity/react` keeps one activity in step with a component (React 18+, an optional peer
232
+ dependency):
233
+
234
+ ```tsx
235
+ import { useLiveActivity } from 'tauri-plugin-live-activity/react';
236
+
237
+ const { status, record, error } = useLiveActivity({
238
+ activityKey: `delivery:${order.id}`,
239
+ layout: { lockScreen },
240
+ values: { title: order.title, status: order.status },
241
+ enabled: order.open,
242
+ onAction: ({ actionId }) => { if (actionId === 'done') closeOrder(order.id); },
243
+ });
244
+ ```
245
+
246
+ The activity starts on mount, each render with other `values` sends one update at the next revision (one request
247
+ in flight at a time, the newest values last), and it ends on unmount or `enabled: false`. `layout` and `styles` are
248
+ read at start; change the `activityKey` to start a new activity. A refused request lands in `error`, and `onAction`
249
+ gets this activity's taps. [More](https://github.com/1eedaegon/tauri-plugin-live-activity/blob/main/docs/usage.md#tsx-and-react)
250
+
207
251
  ## Beyond the built-in parts
208
252
 
209
253
  Most customizing needs no Swift. Bundle your fonts and pictures in the widget extension, and name them:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-live-activity",
3
- "version": "0.5.0",
3
+ "version": "0.5.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",