@capgo/capacitor-widget-kit 8.1.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 (54) hide show
  1. package/CapgoCapacitorWidgetKit.podspec +17 -0
  2. package/LICENSE +373 -0
  3. package/Package.swift +28 -0
  4. package/README.md +1119 -0
  5. package/android/build.gradle +59 -0
  6. package/android/src/main/AndroidManifest.xml +8 -0
  7. package/android/src/main/java/app/capgo/widgetkit/CapgoNativeWidgetBridge.java +311 -0
  8. package/android/src/main/java/app/capgo/widgetkit/CapgoTemplateActionReceiver.java +36 -0
  9. package/android/src/main/java/app/capgo/widgetkit/CapgoTemplateSvgBitmapRenderer.java +25 -0
  10. package/android/src/main/java/app/capgo/widgetkit/CapgoTemplateWidgetBridge.java +31 -0
  11. package/android/src/main/java/app/capgo/widgetkit/CapgoWidgetKit.java +218 -0
  12. package/android/src/main/java/app/capgo/widgetkit/CapgoWidgetKitConstants.java +18 -0
  13. package/android/src/main/java/app/capgo/widgetkit/CapgoWidgetKitPlugin.java +370 -0
  14. package/android/src/main/java/app/capgo/widgetkit/TemplateActivityStore.java +167 -0
  15. package/android/src/main/java/app/capgo/widgetkit/TemplateJsonUtils.java +369 -0
  16. package/android/src/main/java/app/capgo/widgetkit/TemplateRuntime.java +676 -0
  17. package/android/src/main/res/.gitkeep +0 -0
  18. package/dist/docs.json +2223 -0
  19. package/dist/esm/definitions.d.ts +1117 -0
  20. package/dist/esm/definitions.js +2 -0
  21. package/dist/esm/definitions.js.map +1 -0
  22. package/dist/esm/helpers/workout.d.ts +32 -0
  23. package/dist/esm/helpers/workout.js +129 -0
  24. package/dist/esm/helpers/workout.js.map +1 -0
  25. package/dist/esm/index.d.ts +6 -0
  26. package/dist/esm/index.js +9 -0
  27. package/dist/esm/index.js.map +1 -0
  28. package/dist/esm/runtime.d.ts +25 -0
  29. package/dist/esm/runtime.js +653 -0
  30. package/dist/esm/runtime.js.map +1 -0
  31. package/dist/esm/web.d.ts +23 -0
  32. package/dist/esm/web.js +292 -0
  33. package/dist/esm/web.js.map +1 -0
  34. package/dist/plugin.cjs.js +1096 -0
  35. package/dist/plugin.cjs.js.map +1 -0
  36. package/dist/plugin.js +1099 -0
  37. package/dist/plugin.js.map +1 -0
  38. package/ios/Sources/CapgoWidgetKitPlugin/CapgoNativeWidgetBridge.swift +372 -0
  39. package/ios/Sources/CapgoWidgetKitPlugin/CapgoTemplateWidgetBridge.swift +199 -0
  40. package/ios/Sources/CapgoWidgetKitPlugin/CapgoWidgetKit.swift +218 -0
  41. package/ios/Sources/CapgoWidgetKitPlugin/CapgoWidgetKitPlugin.swift +322 -0
  42. package/ios/Sources/CapgoWidgetKitPlugin/CapgoWidgetKitSharedStore.swift +47 -0
  43. package/ios/Sources/CapgoWidgetKitPlugin/CapgoWorkoutLiveActivityComponents.swift +246 -0
  44. package/ios/Sources/CapgoWidgetKitPlugin/CapgoWorkoutLiveActivityWidget.swift +257 -0
  45. package/ios/Sources/CapgoWidgetKitPlugin/CompleteSetIntent.swift +24 -0
  46. package/ios/Sources/CapgoWidgetKitPlugin/TemplateActionIntent.swift +56 -0
  47. package/ios/Sources/CapgoWidgetKitPlugin/TemplateActivityStore.swift +239 -0
  48. package/ios/Sources/CapgoWidgetKitPlugin/TemplateLiveActivityManager.swift +251 -0
  49. package/ios/Sources/CapgoWidgetKitPlugin/TemplateRuntime.swift +1067 -0
  50. package/ios/Sources/CapgoWidgetKitPlugin/WorkoutActivityStore.swift +111 -0
  51. package/ios/Sources/CapgoWidgetKitPlugin/WorkoutLiveActivityManager.swift +263 -0
  52. package/ios/Sources/CapgoWidgetKitPlugin/WorkoutSession.swift +271 -0
  53. package/ios/Tests/CapgoWidgetKitPluginTests/CapgoWidgetKitPluginTests.swift +130 -0
  54. package/package.json +93 -0
package/README.md ADDED
@@ -0,0 +1,1119 @@
1
+ # @capgo/capacitor-widget-kit
2
+ <a href="https://capgo.app/"><img src="https://capgo.app/readme-banner.svg?repo=Cap-go/capacitor-widget-kit" alt="Capgo - Instant updates for Capacitor" /></a>
3
+
4
+ <div align="center">
5
+ <h2><a href="https://capgo.app/?ref=plugin_widget_kit"> ➡️ Get Instant updates for your App with Capgo</a></h2>
6
+ <h2><a href="https://capgo.app/consulting/?ref=plugin_widget_kit"> Missing a feature? We’ll build the plugin for you 💪</a></h2>
7
+ </div>
8
+
9
+ Create WidgetKit, ActivityKit, and Android widget experiences from Capacitor without forcing one rendering model.
10
+
11
+ The plugin has two implementation paths:
12
+
13
+ - SVG template activities: store SVG layouts, optional named frames, hotspots, declarative state patches, pause/resume timers, and interaction events. Use this when your widget can be driven by resolved SVG output.
14
+ - Full-native widget sessions: store shared JSON state for native widget code and queue app-to-widget or widget-to-app messages. Use this when you want to render the widget fully in Swift/Kotlin/Java but still need Capacitor to start, stop, sync, or process async work.
15
+
16
+ The included workout flow is only an example helper built on top of the generic SVG abstraction.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ bun add file:../capacitor-widget-kit
22
+ bunx cap sync ios
23
+ bunx cap sync android
24
+ ```
25
+
26
+ ## iOS Requirements
27
+
28
+ - iOS 17+ is recommended for interactive Live Activity buttons.
29
+ - Add `NSSupportsLiveActivities` to the app `Info.plist` when using ActivityKit.
30
+ - Add the same App Group to the app target and the widget extension target.
31
+ - Set `CapgoWidgetKitAppGroup` in both `Info.plist` files to the shared App Group identifier.
32
+
33
+ Example App Group:
34
+
35
+ ```xml
36
+ <key>CapgoWidgetKitAppGroup</key>
37
+ <string>group.app.capgo.widgetkit.exampleapp.widgetkit</string>
38
+ ```
39
+
40
+ ## Native Widget Code
41
+
42
+ The plugin ships the native pieces a widget extension or Android widget can use:
43
+
44
+ - `CapgoTemplateActivityAttributes` for the iOS Live Activity bridge
45
+ - `CapgoTemplateActionIntent` for interactive iOS template buttons
46
+ - `CapgoTemplateWidgetBridge` to load a stored SVG activity and resolve one surface into `svg + width/height + frameId + hotspots + metadata`
47
+ - `CapgoNativeWidgetBridge` to load full-native widget sessions and exchange async messages without using SVG templates
48
+ - `CapgoTemplateActionReceiver` and `CapgoTemplateWidgetBridge` for Android template widgets
49
+
50
+ In your iOS widget extension bundle:
51
+
52
+ ```swift
53
+ import ActivityKit
54
+ import SwiftUI
55
+ import WidgetKit
56
+ import CapgoWidgetKitPlugin
57
+
58
+ @main
59
+ struct ExampleWidgetBundle: WidgetBundle {
60
+ var body: some Widget {
61
+ if #available(iOS 16.2, *) {
62
+ ExampleTemplateLiveActivityWidget()
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ See `example-app/widget-extension/ExampleWidgetBundle.swift` for a complete scaffold. The sample intentionally uses a placeholder card so you can plug in your own SVG renderer while keeping the same bridge and action intent wiring.
69
+
70
+ ## SVG Template Usage
71
+
72
+ This mode is for widgets that can render resolved SVG. Hotspot actions can switch frames, mutate state, pause/play timers, and emit events for the app to process later.
73
+
74
+ ```ts
75
+ import { CapgoWidgetKit } from '@capgo/capacitor-widget-kit';
76
+
77
+ const { activity } = await CapgoWidgetKit.startTemplateActivity({
78
+ activityId: 'session-1',
79
+ openUrl: 'widgetkitdemo://session/session-1',
80
+ state: {
81
+ title: 'Chest Day',
82
+ frame: 'summary',
83
+ restDurationMs: 90000,
84
+ },
85
+ definition: {
86
+ id: 'generic-session-card',
87
+ timers: [{ id: 'rest', durationPath: 'state.restDurationMs' }],
88
+ actions: [
89
+ {
90
+ id: 'next-frame',
91
+ eventName: 'widget.frame.changed',
92
+ frameMutations: [{ op: 'next', path: 'frame', surface: 'lockScreen' }],
93
+ },
94
+ {
95
+ id: 'toggle-rest',
96
+ eventName: 'widget.timer.toggled',
97
+ timerMutations: [{ op: 'toggle', timerId: 'rest' }],
98
+ },
99
+ ],
100
+ layouts: {
101
+ lockScreen: {
102
+ width: 100,
103
+ height: 40,
104
+ frameIdPath: 'state.frame',
105
+ frames: [
106
+ {
107
+ id: 'summary',
108
+ hotspots: [{ id: 'switch', actionId: 'next-frame', x: 0, y: 0, width: 100, height: 40 }],
109
+ svg: `<svg viewBox="0 0 100 40"><text x="6" y="20">{{state.title}}</text></svg>`,
110
+ },
111
+ {
112
+ id: 'timer',
113
+ hotspots: [{ id: 'pause-play', actionId: 'toggle-rest', x: 0, y: 0, width: 100, height: 40 }],
114
+ svg: `<svg viewBox="0 0 100 40"><text x="6" y="20">{{timers.rest.remainingText}}</text></svg>`,
115
+ },
116
+ ],
117
+ },
118
+ },
119
+ },
120
+ });
121
+
122
+ await CapgoWidgetKit.performTemplateAction({
123
+ activityId: activity.activityId,
124
+ actionId: 'toggle-rest',
125
+ sourceId: 'app-pause-play-button',
126
+ });
127
+
128
+ const pendingEvents = await CapgoWidgetKit.listTemplateEvents({
129
+ activityId: activity.activityId,
130
+ unacknowledgedOnly: true,
131
+ });
132
+ ```
133
+
134
+ ## Full-Native Widget Usage
135
+
136
+ This mode is for widgets rendered in native code. The app keeps a shared session state for sync reads/writes, and messages cover async jobs that need a later response.
137
+
138
+ ```ts
139
+ const { session } = await CapgoWidgetKit.startWidgetSession({
140
+ widgetId: 'native-session-1',
141
+ kind: 'workout-controls',
142
+ state: { isRunning: true, selectedSetId: 'set-1' },
143
+ metadata: { accent: '#00d69c' },
144
+ });
145
+
146
+ await CapgoWidgetKit.updateWidgetSession({
147
+ widgetId: session.widgetId,
148
+ merge: true,
149
+ state: { isRunning: false },
150
+ });
151
+
152
+ const { message } = await CapgoWidgetKit.sendWidgetMessage({
153
+ widgetId: session.widgetId,
154
+ direction: 'widgetToApp',
155
+ name: 'syncWorkoutSet',
156
+ payload: { setId: 'set-1' },
157
+ expectsResponse: true,
158
+ });
159
+
160
+ await CapgoWidgetKit.completeWidgetMessage({
161
+ messageId: message.messageId,
162
+ response: { synced: true },
163
+ });
164
+
165
+ await CapgoWidgetKit.stopWidgetSession({ widgetId: session.widgetId });
166
+ ```
167
+
168
+ ## Example App
169
+
170
+ The `example-app/` folder is a lightweight Vite demo for the generic template flow. It runs in the browser using the preview store and demonstrates:
171
+
172
+ - starting one SVG template activity
173
+ - resolving the lock-screen surface
174
+ - running an action from the app and from a hotspot overlay
175
+ - reading the stored activity back
176
+ - reading and acknowledging the event log
177
+ - ending the activity
178
+
179
+ The workout helper is only used there as an example template factory.
180
+
181
+ ## API
182
+
183
+ <docgen-index>
184
+
185
+ * [`areActivitiesSupported()`](#areactivitiessupported)
186
+ * [`startTemplateActivity(...)`](#starttemplateactivity)
187
+ * [`updateTemplateActivity(...)`](#updatetemplateactivity)
188
+ * [`endTemplateActivity(...)`](#endtemplateactivity)
189
+ * [`performTemplateAction(...)`](#performtemplateaction)
190
+ * [`getTemplateActivity(...)`](#gettemplateactivity)
191
+ * [`listTemplateActivities()`](#listtemplateactivities)
192
+ * [`listTemplateEvents(...)`](#listtemplateevents)
193
+ * [`acknowledgeTemplateEvents(...)`](#acknowledgetemplateevents)
194
+ * [`startWidgetSession(...)`](#startwidgetsession)
195
+ * [`updateWidgetSession(...)`](#updatewidgetsession)
196
+ * [`stopWidgetSession(...)`](#stopwidgetsession)
197
+ * [`getWidgetSession(...)`](#getwidgetsession)
198
+ * [`listWidgetSessions()`](#listwidgetsessions)
199
+ * [`sendWidgetMessage(...)`](#sendwidgetmessage)
200
+ * [`listWidgetMessages(...)`](#listwidgetmessages)
201
+ * [`acknowledgeWidgetMessages(...)`](#acknowledgewidgetmessages)
202
+ * [`completeWidgetMessage(...)`](#completewidgetmessage)
203
+ * [`getPluginVersion()`](#getpluginversion)
204
+ * [Interfaces](#interfaces)
205
+ * [Type Aliases](#type-aliases)
206
+
207
+ </docgen-index>
208
+
209
+ <docgen-api>
210
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
211
+
212
+ Capacitor bridge for an iOS-first WidgetKit / Live Activities plugin.
213
+
214
+ The core abstraction is a generic SVG template activity:
215
+ - raw SVG templates with binding placeholders
216
+ - declarative action patches
217
+ - timer bindings exposed to the template scope
218
+ - event logging so the host app can process button results later
219
+
220
+ The plugin owns shared persistence, declarative action execution, and event retrieval.
221
+ The host widget extension keeps full freedom over actual WidgetKit rendering.
222
+
223
+ Full-native widgets can use widget sessions for synchronous shared state and widget messages
224
+ for asynchronous app/widget jobs without adopting the SVG template renderer.
225
+
226
+ ### areActivitiesSupported()
227
+
228
+ ```typescript
229
+ areActivitiesSupported() => Promise<ActivitiesSupportedResult>
230
+ ```
231
+
232
+ Check whether the native template activity bridge can run on the current device.
233
+
234
+ **Returns:** <code>Promise&lt;<a href="#activitiessupportedresult">ActivitiesSupportedResult</a>&gt;</code>
235
+
236
+ --------------------
237
+
238
+
239
+ ### startTemplateActivity(...)
240
+
241
+ ```typescript
242
+ startTemplateActivity(options: StartTemplateActivityOptions) => Promise<StartTemplateActivityResult>
243
+ ```
244
+
245
+ Persist a generic SVG template activity and start the matching native Live Activity bridge.
246
+
247
+ | Param | Type |
248
+ | ------------- | ------------------------------------------------------------------------------------- |
249
+ | **`options`** | <code><a href="#starttemplateactivityoptions">StartTemplateActivityOptions</a></code> |
250
+
251
+ **Returns:** <code>Promise&lt;<a href="#starttemplateactivityresult">StartTemplateActivityResult</a>&gt;</code>
252
+
253
+ --------------------
254
+
255
+
256
+ ### updateTemplateActivity(...)
257
+
258
+ ```typescript
259
+ updateTemplateActivity(options: UpdateTemplateActivityOptions) => Promise<TemplateActivityResult>
260
+ ```
261
+
262
+ Replace part or all of the stored activity definition/state.
263
+
264
+ | Param | Type |
265
+ | ------------- | --------------------------------------------------------------------------------------- |
266
+ | **`options`** | <code><a href="#updatetemplateactivityoptions">UpdateTemplateActivityOptions</a></code> |
267
+
268
+ **Returns:** <code>Promise&lt;<a href="#templateactivityresult">TemplateActivityResult</a>&gt;</code>
269
+
270
+ --------------------
271
+
272
+
273
+ ### endTemplateActivity(...)
274
+
275
+ ```typescript
276
+ endTemplateActivity(options: EndTemplateActivityOptions) => Promise<void>
277
+ ```
278
+
279
+ End a running activity while optionally persisting one last state snapshot.
280
+
281
+ | Param | Type |
282
+ | ------------- | --------------------------------------------------------------------------------- |
283
+ | **`options`** | <code><a href="#endtemplateactivityoptions">EndTemplateActivityOptions</a></code> |
284
+
285
+ --------------------
286
+
287
+
288
+ ### performTemplateAction(...)
289
+
290
+ ```typescript
291
+ performTemplateAction(options: PerformTemplateActionOptions) => Promise<PerformTemplateActionResult>
292
+ ```
293
+
294
+ Execute one declarative action and record the resulting event.
295
+
296
+ | Param | Type |
297
+ | ------------- | ------------------------------------------------------------------------------------- |
298
+ | **`options`** | <code><a href="#performtemplateactionoptions">PerformTemplateActionOptions</a></code> |
299
+
300
+ **Returns:** <code>Promise&lt;<a href="#performtemplateactionresult">PerformTemplateActionResult</a>&gt;</code>
301
+
302
+ --------------------
303
+
304
+
305
+ ### getTemplateActivity(...)
306
+
307
+ ```typescript
308
+ getTemplateActivity(options: GetTemplateActivityOptions) => Promise<TemplateActivityResult>
309
+ ```
310
+
311
+ Read one activity back from the shared store.
312
+
313
+ | Param | Type |
314
+ | ------------- | --------------------------------------------------------------------------------- |
315
+ | **`options`** | <code><a href="#gettemplateactivityoptions">GetTemplateActivityOptions</a></code> |
316
+
317
+ **Returns:** <code>Promise&lt;<a href="#templateactivityresult">TemplateActivityResult</a>&gt;</code>
318
+
319
+ --------------------
320
+
321
+
322
+ ### listTemplateActivities()
323
+
324
+ ```typescript
325
+ listTemplateActivities() => Promise<ListTemplateActivitiesResult>
326
+ ```
327
+
328
+ List every activity currently known by the plugin.
329
+
330
+ **Returns:** <code>Promise&lt;<a href="#listtemplateactivitiesresult">ListTemplateActivitiesResult</a>&gt;</code>
331
+
332
+ --------------------
333
+
334
+
335
+ ### listTemplateEvents(...)
336
+
337
+ ```typescript
338
+ listTemplateEvents(options?: ListTemplateEventsOptions | undefined) => Promise<ListTemplateEventsResult>
339
+ ```
340
+
341
+ List stored action events so the app can react to widget interactions later.
342
+
343
+ | Param | Type |
344
+ | ------------- | ------------------------------------------------------------------------------- |
345
+ | **`options`** | <code><a href="#listtemplateeventsoptions">ListTemplateEventsOptions</a></code> |
346
+
347
+ **Returns:** <code>Promise&lt;<a href="#listtemplateeventsresult">ListTemplateEventsResult</a>&gt;</code>
348
+
349
+ --------------------
350
+
351
+
352
+ ### acknowledgeTemplateEvents(...)
353
+
354
+ ```typescript
355
+ acknowledgeTemplateEvents(options: AcknowledgeTemplateEventsOptions) => Promise<void>
356
+ ```
357
+
358
+ Mark previously processed events as acknowledged.
359
+
360
+ | Param | Type |
361
+ | ------------- | --------------------------------------------------------------------------------------------- |
362
+ | **`options`** | <code><a href="#acknowledgetemplateeventsoptions">AcknowledgeTemplateEventsOptions</a></code> |
363
+
364
+ --------------------
365
+
366
+
367
+ ### startWidgetSession(...)
368
+
369
+ ```typescript
370
+ startWidgetSession(options: StartWidgetSessionOptions) => Promise<StartWidgetSessionResult>
371
+ ```
372
+
373
+ Start a full-native widget session backed by shared JSON state.
374
+
375
+ | Param | Type |
376
+ | ------------- | ------------------------------------------------------------------------------- |
377
+ | **`options`** | <code><a href="#startwidgetsessionoptions">StartWidgetSessionOptions</a></code> |
378
+
379
+ **Returns:** <code>Promise&lt;<a href="#startwidgetsessionresult">StartWidgetSessionResult</a>&gt;</code>
380
+
381
+ --------------------
382
+
383
+
384
+ ### updateWidgetSession(...)
385
+
386
+ ```typescript
387
+ updateWidgetSession(options: UpdateWidgetSessionOptions) => Promise<WidgetSessionResult>
388
+ ```
389
+
390
+ Update a full-native widget session.
391
+
392
+ | Param | Type |
393
+ | ------------- | --------------------------------------------------------------------------------- |
394
+ | **`options`** | <code><a href="#updatewidgetsessionoptions">UpdateWidgetSessionOptions</a></code> |
395
+
396
+ **Returns:** <code>Promise&lt;<a href="#widgetsessionresult">WidgetSessionResult</a>&gt;</code>
397
+
398
+ --------------------
399
+
400
+
401
+ ### stopWidgetSession(...)
402
+
403
+ ```typescript
404
+ stopWidgetSession(options: StopWidgetSessionOptions) => Promise<void>
405
+ ```
406
+
407
+ Stop a full-native widget session.
408
+
409
+ | Param | Type |
410
+ | ------------- | ----------------------------------------------------------------------------- |
411
+ | **`options`** | <code><a href="#stopwidgetsessionoptions">StopWidgetSessionOptions</a></code> |
412
+
413
+ --------------------
414
+
415
+
416
+ ### getWidgetSession(...)
417
+
418
+ ```typescript
419
+ getWidgetSession(options: GetWidgetSessionOptions) => Promise<WidgetSessionResult>
420
+ ```
421
+
422
+ Read one full-native widget session.
423
+
424
+ | Param | Type |
425
+ | ------------- | --------------------------------------------------------------------------- |
426
+ | **`options`** | <code><a href="#getwidgetsessionoptions">GetWidgetSessionOptions</a></code> |
427
+
428
+ **Returns:** <code>Promise&lt;<a href="#widgetsessionresult">WidgetSessionResult</a>&gt;</code>
429
+
430
+ --------------------
431
+
432
+
433
+ ### listWidgetSessions()
434
+
435
+ ```typescript
436
+ listWidgetSessions() => Promise<ListWidgetSessionsResult>
437
+ ```
438
+
439
+ List every full-native widget session currently known by the plugin.
440
+
441
+ **Returns:** <code>Promise&lt;<a href="#listwidgetsessionsresult">ListWidgetSessionsResult</a>&gt;</code>
442
+
443
+ --------------------
444
+
445
+
446
+ ### sendWidgetMessage(...)
447
+
448
+ ```typescript
449
+ sendWidgetMessage(options: SendWidgetMessageOptions) => Promise<SendWidgetMessageResult>
450
+ ```
451
+
452
+ Queue a message between the app and native widget code.
453
+
454
+ | Param | Type |
455
+ | ------------- | ----------------------------------------------------------------------------- |
456
+ | **`options`** | <code><a href="#sendwidgetmessageoptions">SendWidgetMessageOptions</a></code> |
457
+
458
+ **Returns:** <code>Promise&lt;<a href="#sendwidgetmessageresult">SendWidgetMessageResult</a>&gt;</code>
459
+
460
+ --------------------
461
+
462
+
463
+ ### listWidgetMessages(...)
464
+
465
+ ```typescript
466
+ listWidgetMessages(options?: ListWidgetMessagesOptions | undefined) => Promise<ListWidgetMessagesResult>
467
+ ```
468
+
469
+ List queued full-native widget bridge messages.
470
+
471
+ | Param | Type |
472
+ | ------------- | ------------------------------------------------------------------------------- |
473
+ | **`options`** | <code><a href="#listwidgetmessagesoptions">ListWidgetMessagesOptions</a></code> |
474
+
475
+ **Returns:** <code>Promise&lt;<a href="#listwidgetmessagesresult">ListWidgetMessagesResult</a>&gt;</code>
476
+
477
+ --------------------
478
+
479
+
480
+ ### acknowledgeWidgetMessages(...)
481
+
482
+ ```typescript
483
+ acknowledgeWidgetMessages(options: AcknowledgeWidgetMessagesOptions) => Promise<void>
484
+ ```
485
+
486
+ Mark widget bridge messages as acknowledged after processing.
487
+
488
+ | Param | Type |
489
+ | ------------- | --------------------------------------------------------------------------------------------- |
490
+ | **`options`** | <code><a href="#acknowledgewidgetmessagesoptions">AcknowledgeWidgetMessagesOptions</a></code> |
491
+
492
+ --------------------
493
+
494
+
495
+ ### completeWidgetMessage(...)
496
+
497
+ ```typescript
498
+ completeWidgetMessage(options: CompleteWidgetMessageOptions) => Promise<WidgetMessageResult>
499
+ ```
500
+
501
+ Complete or fail an async widget bridge message.
502
+
503
+ | Param | Type |
504
+ | ------------- | ------------------------------------------------------------------------------------- |
505
+ | **`options`** | <code><a href="#completewidgetmessageoptions">CompleteWidgetMessageOptions</a></code> |
506
+
507
+ **Returns:** <code>Promise&lt;<a href="#widgetmessageresult">WidgetMessageResult</a>&gt;</code>
508
+
509
+ --------------------
510
+
511
+
512
+ ### getPluginVersion()
513
+
514
+ ```typescript
515
+ getPluginVersion() => Promise<PluginVersionResult>
516
+ ```
517
+
518
+ Return the platform implementation version marker.
519
+
520
+ **Returns:** <code>Promise&lt;<a href="#pluginversionresult">PluginVersionResult</a>&gt;</code>
521
+
522
+ --------------------
523
+
524
+
525
+ ### Interfaces
526
+
527
+
528
+ #### ActivitiesSupportedResult
529
+
530
+ Result of a Live Activities capability check.
531
+
532
+ | Prop | Type | Description |
533
+ | --------------- | -------------------- | ----------------------------------------------------------------------------------- |
534
+ | **`supported`** | <code>boolean</code> | Whether the current device and runtime can run the native template activity bridge. |
535
+ | **`reason`** | <code>string</code> | Human-readable reason when support is unavailable. |
536
+
537
+
538
+ #### StartTemplateActivityResult
539
+
540
+ Result when starting a generic template activity.
541
+
542
+ | Prop | Type | Description |
543
+ | -------------- | ------------------------------------------------------------------------------- | ------------------------- |
544
+ | **`activity`** | <code><a href="#svgtemplateactivityrecord">SvgTemplateActivityRecord</a></code> | Stored activity snapshot. |
545
+
546
+
547
+ #### SvgTemplateActivityRecord
548
+
549
+ Stored activity snapshot returned by the plugin.
550
+
551
+ | Prop | Type | Description |
552
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
553
+ | **`activityId`** | <code>string</code> | Stable plugin activity identifier. |
554
+ | **`definition`** | <code><a href="#svgtemplatedefinition">SvgTemplateDefinition</a></code> | Full template definition. |
555
+ | **`state`** | <code><a href="#svgtemplatestate">SvgTemplateState</a></code> | Persisted JSON state. |
556
+ | **`timers`** | <code><a href="#record">Record</a>&lt;string, <a href="#svgtemplatetimerstate">SvgTemplateTimerState</a>&gt;</code> | Timer runtime state keyed by timer id. |
557
+ | **`status`** | <code>'active' \| 'ended'</code> | Current lifecycle status. |
558
+ | **`openUrl`** | <code>string</code> | Optional deep link opened when the widget body is tapped. |
559
+ | **`updatedAt`** | <code>number</code> | Last update timestamp. |
560
+ | **`revision`** | <code>number</code> | Monotonic revision incremented on every state change. |
561
+
562
+
563
+ #### SvgTemplateDefinition
564
+
565
+ Generic SVG template definition stored by the plugin.
566
+
567
+ | Prop | Type | Description |
568
+ | -------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------- |
569
+ | **`id`** | <code>string</code> | Stable template identifier. |
570
+ | **`version`** | <code>string</code> | Optional version marker for migrations. |
571
+ | **`layouts`** | <code><a href="#svgtemplatelayouts">SvgTemplateLayouts</a></code> | Available WidgetKit layouts. |
572
+ | **`actions`** | <code>SvgTemplateActionDefinition[]</code> | Optional declarative actions. |
573
+ | **`timers`** | <code>SvgTemplateTimerDefinition[]</code> | Optional timer definitions exposed to the template runtime. |
574
+ | **`metadata`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional JSON metadata mirrored in the runtime scope under `meta.template`. |
575
+
576
+
577
+ #### SvgTemplateLayouts
578
+
579
+ Bundle of optional WidgetKit surface layouts.
580
+
581
+ | Prop | Type | Description |
582
+ | ---------------------------------- | --------------------------------------------------------------- | ------------------------------------------------ |
583
+ | **`lockScreen`** | <code><a href="#svgtemplatelayout">SvgTemplateLayout</a></code> | Primary lock-screen / banner layout. |
584
+ | **`dynamicIslandExpanded`** | <code><a href="#svgtemplatelayout">SvgTemplateLayout</a></code> | Optional expanded Dynamic Island layout. |
585
+ | **`dynamicIslandCompactLeading`** | <code><a href="#svgtemplatelayout">SvgTemplateLayout</a></code> | Optional compact leading Dynamic Island layout. |
586
+ | **`dynamicIslandCompactTrailing`** | <code><a href="#svgtemplatelayout">SvgTemplateLayout</a></code> | Optional compact trailing Dynamic Island layout. |
587
+ | **`dynamicIslandMinimal`** | <code><a href="#svgtemplatelayout">SvgTemplateLayout</a></code> | Optional minimal Dynamic Island layout. |
588
+
589
+
590
+ #### SvgTemplateLayoutWithSvg
591
+
592
+ SVG layout variant backed by a base SVG string.
593
+
594
+ | Prop | Type | Description |
595
+ | -------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
596
+ | **`svg`** | <code>string</code> | Raw SVG template string used when no frame is selected. The runtime resolves `{{state.*}}`, `{{timers.*}}`, and `{{meta.*}}` placeholders before rendering. |
597
+ | **`frames`** | <code>SvgTemplateFrame[]</code> | Optional named SVG frames for click-driven or timer-driven frame changes. |
598
+ | **`frameIdPath`** | <code>string</code> | Optional state/runtime path that resolves to the active frame id. Examples: `state.frame`, `state.widgets.{{state.activeIndex}}.frame`, or `{{state.frame}}`. |
599
+ | **`defaultFrameId`** | <code>string</code> | Frame id used when `frameIdPath` is missing or resolves to an unknown frame. |
600
+ | **`width`** | <code>number</code> | Nominal SVG width used for scaling hotspots. |
601
+ | **`height`** | <code>number</code> | Nominal SVG height used for scaling hotspots. |
602
+ | **`hotspots`** | <code>SvgTemplateHotspot[]</code> | Interactive overlay regions. |
603
+
604
+
605
+ #### SvgTemplateFrame
606
+
607
+ Named SVG frame that can be selected by activity state.
608
+
609
+ | Prop | Type | Description |
610
+ | -------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
611
+ | **`id`** | <code>string</code> | Stable frame identifier. |
612
+ | **`svg`** | <code>string</code> | Raw SVG template string for this frame. The runtime resolves `{{state.*}}`, `{{timers.*}}`, and `{{meta.*}}` placeholders before rendering. |
613
+ | **`hotspots`** | <code>SvgTemplateHotspot[]</code> | Optional frame-specific interactive regions. When omitted, the parent layout hotspots are used. |
614
+
615
+
616
+ #### SvgTemplateHotspot
617
+
618
+ Interactive region overlaid on top of a rendered SVG layout.
619
+
620
+ | Prop | Type | Description |
621
+ | -------------- | ------------------------------------------------- | ----------------------------------------------------------------------- |
622
+ | **`id`** | <code>string</code> | Stable hotspot identifier. |
623
+ | **`actionId`** | <code>string</code> | Action identifier executed when the region is tapped. |
624
+ | **`x`** | <code>number</code> | X position in the SVG coordinate space. |
625
+ | **`y`** | <code>number</code> | Y position in the SVG coordinate space. |
626
+ | **`width`** | <code>number</code> | Hotspot width in the SVG coordinate space. |
627
+ | **`height`** | <code>number</code> | Hotspot height in the SVG coordinate space. |
628
+ | **`label`** | <code>string</code> | Optional accessibility label for the interactive region. |
629
+ | **`role`** | <code>'button' \| 'link'</code> | Optional semantic role. |
630
+ | **`payload`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional static payload forwarded when the hotspot triggers its action. |
631
+
632
+
633
+ #### JsonObject
634
+
635
+ JSON-safe object used as activity state.
636
+
637
+
638
+ #### SvgTemplateLayoutWithFrames
639
+
640
+ SVG layout variant backed by named SVG frames.
641
+
642
+ | Prop | Type | Description |
643
+ | -------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
644
+ | **`svg`** | <code>string</code> | Raw SVG template string used when no frame is selected. The runtime resolves `{{state.*}}`, `{{timers.*}}`, and `{{meta.*}}` placeholders before rendering. |
645
+ | **`frames`** | <code>SvgTemplateFrame[]</code> | Named SVG frames for click-driven or timer-driven frame changes. |
646
+ | **`frameIdPath`** | <code>string</code> | Optional state/runtime path that resolves to the active frame id. Examples: `state.frame`, `state.widgets.{{state.activeIndex}}.frame`, or `{{state.frame}}`. |
647
+ | **`defaultFrameId`** | <code>string</code> | Frame id used when `frameIdPath` is missing or resolves to an unknown frame. |
648
+ | **`width`** | <code>number</code> | Nominal SVG width used for scaling hotspots. |
649
+ | **`height`** | <code>number</code> | Nominal SVG height used for scaling hotspots. |
650
+ | **`hotspots`** | <code>SvgTemplateHotspot[]</code> | Interactive overlay regions. |
651
+
652
+
653
+ #### SvgTemplateActionDefinition
654
+
655
+ Declarative action attached to one or more hotspots.
656
+
657
+ | Prop | Type | Description |
658
+ | -------------------- | --------------------------------------- | ------------------------------------------------------------------ |
659
+ | **`id`** | <code>string</code> | Stable action identifier. |
660
+ | **`eventName`** | <code>string</code> | Optional event name used in the action log. |
661
+ | **`label`** | <code>string</code> | Optional UI label. |
662
+ | **`patches`** | <code>SvgTemplateStatePatch[]</code> | Ordered state mutations executed when the action runs. |
663
+ | **`timerMutations`** | <code>SvgTemplateTimerMutation[]</code> | Ordered timer mutations executed when the action runs. |
664
+ | **`frameMutations`** | <code>SvgTemplateFrameMutation[]</code> | Ordered frame mutations executed when the action runs. |
665
+ | **`openUrl`** | <code>string</code> | Optional deep link opened by the host widget when the action runs. |
666
+
667
+
668
+ #### SvgTemplateStatePatch
669
+
670
+ Declarative mutation applied to the stored activity state.
671
+
672
+ | Prop | Type | Description |
673
+ | ------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
674
+ | **`op`** | <code>'set' \| 'increment' \| 'toggle' \| 'unset' \| 'timestamp'</code> | Mutation operation. |
675
+ | **`path`** | <code>string</code> | Destination state path. The path may itself contain `{{...}}` placeholders. |
676
+ | **`value`** | <code><a href="#jsonvalue">JsonValue</a></code> | Optional literal value used by the mutation. |
677
+ | **`valuePath`** | <code>string</code> | Optional source path used to copy a value from the current runtime scope. The path may itself contain `{{...}}` placeholders. |
678
+ | **`valueTemplate`** | <code>string</code> | Optional template-resolved value. If the string is a single `{{...}}` token, the raw referenced JSON value is copied. Otherwise the resolved string is stored. |
679
+ | **`amount`** | <code>number</code> | Increment amount for `increment`. |
680
+
681
+
682
+ #### SvgTemplateTimerMutation
683
+
684
+ Declarative timer mutation triggered by an action.
685
+
686
+ | Prop | Type | Description |
687
+ | ------------------ | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
688
+ | **`op`** | <code>'toggle' \| 'start' \| 'stop' \| 'restart' \| 'pause' \| 'resume' \| 'reset' \| 'setDuration'</code> | Mutation operation. |
689
+ | **`timerId`** | <code>string</code> | Target timer identifier. |
690
+ | **`durationMs`** | <code>number</code> | Optional fixed duration override in milliseconds. |
691
+ | **`durationPath`** | <code>string</code> | Optional path that resolves to a duration override in milliseconds. The path may itself contain `{{...}}` placeholders. |
692
+
693
+
694
+ #### SvgTemplateFrameMutation
695
+
696
+ Declarative frame mutation triggered by an action.
697
+
698
+ | Prop | Type | Description |
699
+ | -------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
700
+ | **`op`** | <code>'set' \| 'toggle' \| 'next' \| 'previous'</code> | Mutation operation. |
701
+ | **`path`** | <code>string</code> | Destination state path that stores the active frame id. The path may itself contain `{{...}}` placeholders. |
702
+ | **`frameId`** | <code>string</code> | Frame id used by `set`, or the alternate frame id used by `toggle`. The value may contain `{{...}}` placeholders. |
703
+ | **`frameIds`** | <code>string[]</code> | Ordered frame ids used by `next`, `previous`, and `toggle`. When omitted, `surface` can be used to read frame ids from a layout definition. |
704
+ | **`surface`** | <code><a href="#svgtemplatesurface">SvgTemplateSurface</a></code> | Optional surface whose layout frames should be used when `frameIds` is omitted. |
705
+ | **`wrap`** | <code>boolean</code> | Whether `next` and `previous` wrap at the ends. Defaults to `true`. |
706
+
707
+
708
+ #### SvgTemplateTimerDefinition
709
+
710
+ Timer binding exposed to SVG templates.
711
+
712
+ | Prop | Type | Description |
713
+ | ------------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
714
+ | **`id`** | <code>string</code> | Stable timer identifier. |
715
+ | **`durationMs`** | <code>number</code> | Optional fixed duration in milliseconds. |
716
+ | **`durationPath`** | <code>string</code> | Optional state path that resolves to a duration in milliseconds. The path may itself contain `{{...}}` placeholders. |
717
+ | **`startAtPath`** | <code>string</code> | Optional state path that resolves to the timer start timestamp in milliseconds. The path may itself contain `{{...}}` placeholders. |
718
+ | **`autoStart`** | <code>boolean</code> | When true, the timer starts automatically when the activity is created. |
719
+
720
+
721
+ #### SvgTemplateTimerState
722
+
723
+ Persisted timer runtime state.
724
+
725
+ | Prop | Type | Description |
726
+ | ---------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
727
+ | **`id`** | <code>string</code> | Timer identifier. |
728
+ | **`startedAt`** | <code>number \| null</code> | Start timestamp in milliseconds, or `null` when the timer is idle. |
729
+ | **`elapsedMs`** | <code>number</code> | Elapsed milliseconds already accumulated before the current run. This is used to preserve timer progress while paused. |
730
+ | **`durationMs`** | <code>number</code> | Current timer duration in milliseconds. |
731
+ | **`status`** | <code>'idle' \| 'running' \| 'paused' \| 'finished' \| 'stopped'</code> | Current timer status. |
732
+ | **`updatedAt`** | <code>number</code> | Last update timestamp. |
733
+
734
+
735
+ #### StartTemplateActivityOptions
736
+
737
+ Options for starting a generic SVG template activity.
738
+
739
+ | Prop | Type | Description |
740
+ | ---------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
741
+ | **`activityId`** | <code>string</code> | Optional explicit activity identifier. When omitted, the native runtime creates one. |
742
+ | **`definition`** | <code><a href="#svgtemplatedefinition">SvgTemplateDefinition</a></code> | Generic SVG template definition. |
743
+ | **`state`** | <code><a href="#svgtemplatestate">SvgTemplateState</a></code> | Initial JSON state exposed under `state.*`. |
744
+ | **`openUrl`** | <code>string</code> | Optional deep link used when the widget body is tapped. |
745
+
746
+
747
+ #### TemplateActivityResult
748
+
749
+ Result when reading or updating a single activity.
750
+
751
+ | Prop | Type | Description |
752
+ | -------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------- |
753
+ | **`activity`** | <code><a href="#svgtemplateactivityrecord">SvgTemplateActivityRecord</a> \| null</code> | Stored activity snapshot, or `null` when not found. |
754
+
755
+
756
+ #### UpdateTemplateActivityOptions
757
+
758
+ Options for updating an existing template activity.
759
+
760
+ | Prop | Type | Description |
761
+ | ---------------- | ----------------------------------------------------------------------- | -------------------------------------------------------- |
762
+ | **`activityId`** | <code>string</code> | Activity identifier returned by `startTemplateActivity`. |
763
+ | **`definition`** | <code><a href="#svgtemplatedefinition">SvgTemplateDefinition</a></code> | Optional replacement definition. |
764
+ | **`state`** | <code><a href="#svgtemplatestate">SvgTemplateState</a></code> | Optional replacement state. |
765
+ | **`openUrl`** | <code>string</code> | Optional replacement deep link. |
766
+
767
+
768
+ #### EndTemplateActivityOptions
769
+
770
+ Options for ending a template activity.
771
+
772
+ | Prop | Type | Description |
773
+ | ---------------- | ------------------------------------------------------------- | -------------------------------------------------------- |
774
+ | **`activityId`** | <code>string</code> | Activity identifier returned by `startTemplateActivity`. |
775
+ | **`state`** | <code><a href="#svgtemplatestate">SvgTemplateState</a></code> | Optional final state persisted before ending. |
776
+
777
+
778
+ #### PerformTemplateActionResult
779
+
780
+ Result after executing an action.
781
+
782
+ | Prop | Type | Description |
783
+ | -------------- | ------------------------------------------------------------------------------- | ------------------------------------ |
784
+ | **`activity`** | <code><a href="#svgtemplateactivityrecord">SvgTemplateActivityRecord</a></code> | Updated activity snapshot. |
785
+ | **`event`** | <code><a href="#svgtemplateactionevent">SvgTemplateActionEvent</a></code> | Action event emitted by the runtime. |
786
+
787
+
788
+ #### SvgTemplateActionEvent
789
+
790
+ Event emitted whenever a declarative action is executed.
791
+
792
+ | Prop | Type | Description |
793
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
794
+ | **`eventId`** | <code>string</code> | Stable event identifier. |
795
+ | **`activityId`** | <code>string</code> | Activity identifier associated with the event. |
796
+ | **`actionId`** | <code>string</code> | Action identifier that produced the event. |
797
+ | **`eventName`** | <code>string</code> | Optional event name copied from the action definition. |
798
+ | **`sourceId`** | <code>string</code> | Optional source identifier, typically the hotspot id that triggered the action. |
799
+ | **`createdAt`** | <code>number</code> | Event creation timestamp in milliseconds. |
800
+ | **`acknowledgedAt`** | <code>number \| null</code> | Timestamp in milliseconds when the app acknowledged the event. |
801
+ | **`payload`** | <code><a href="#jsonobject">JsonObject</a> \| null</code> | Optional caller-provided payload. |
802
+ | **`state`** | <code><a href="#svgtemplatestate">SvgTemplateState</a></code> | State snapshot after the action was applied. |
803
+ | **`timers`** | <code><a href="#record">Record</a>&lt;string, <a href="#svgtemplatetimerstate">SvgTemplateTimerState</a>&gt;</code> | Timer snapshot after the action was applied. |
804
+
805
+
806
+ #### PerformTemplateActionOptions
807
+
808
+ Options for executing a declarative action.
809
+
810
+ | Prop | Type | Description |
811
+ | ---------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
812
+ | **`activityId`** | <code>string</code> | Activity identifier returned by `startTemplateActivity`. |
813
+ | **`actionId`** | <code>string</code> | Action identifier declared in the template definition. |
814
+ | **`sourceId`** | <code>string</code> | Optional source identifier, typically the hotspot id that triggered the action. |
815
+ | **`payload`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional payload stored with the emitted event and exposed to declarative patches under `{{action.payload.*}}`. |
816
+
817
+
818
+ #### GetTemplateActivityOptions
819
+
820
+ Options for reading one stored activity.
821
+
822
+ | Prop | Type | Description |
823
+ | ---------------- | ------------------- | ---------------------------- |
824
+ | **`activityId`** | <code>string</code> | Activity identifier to load. |
825
+
826
+
827
+ #### ListTemplateActivitiesResult
828
+
829
+ Result when listing stored activities.
830
+
831
+ | Prop | Type | Description |
832
+ | ---------------- | ---------------------------------------- | -------------------------- |
833
+ | **`activities`** | <code>SvgTemplateActivityRecord[]</code> | Stored activity snapshots. |
834
+
835
+
836
+ #### ListTemplateEventsResult
837
+
838
+ Result when listing action events.
839
+
840
+ | Prop | Type | Description |
841
+ | ------------ | ------------------------------------- | ----------------------- |
842
+ | **`events`** | <code>SvgTemplateActionEvent[]</code> | Matching action events. |
843
+
844
+
845
+ #### ListTemplateEventsOptions
846
+
847
+ Options when listing action events.
848
+
849
+ | Prop | Type | Description |
850
+ | ------------------------ | -------------------- | --------------------------------------------------- |
851
+ | **`activityId`** | <code>string</code> | Optional activity filter. |
852
+ | **`unacknowledgedOnly`** | <code>boolean</code> | When true, only unacknowledged events are returned. |
853
+
854
+
855
+ #### AcknowledgeTemplateEventsOptions
856
+
857
+ Options for acknowledging events after the host app processes them.
858
+
859
+ | Prop | Type | Description |
860
+ | ---------------- | --------------------- | ----------------------------------------------------------------------------- |
861
+ | **`eventIds`** | <code>string[]</code> | Optional explicit event ids to acknowledge. |
862
+ | **`activityId`** | <code>string</code> | Optional activity id shortcut that acknowledges every event for the activity. |
863
+
864
+
865
+ #### StartWidgetSessionResult
866
+
867
+ Result when starting a full-native widget session.
868
+
869
+ | Prop | Type | Description |
870
+ | ------------- | ------------------------------------------------------------------- | ------------------------ |
871
+ | **`session`** | <code><a href="#widgetsessionrecord">WidgetSessionRecord</a></code> | Stored session snapshot. |
872
+
873
+
874
+ #### WidgetSessionRecord
875
+
876
+ Stored full-native widget session.
877
+
878
+ | Prop | Type | Description |
879
+ | --------------- | ------------------------------------------------- | ----------------------------------------------------------------------- |
880
+ | **`widgetId`** | <code>string</code> | Stable widget/session identifier. |
881
+ | **`kind`** | <code>string</code> | Optional product-defined session kind. |
882
+ | **`state`** | <code><a href="#jsonobject">JsonObject</a></code> | JSON state shared synchronously between the app and native widget code. |
883
+ | **`metadata`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional JSON metadata for native widget code. |
884
+ | **`status`** | <code>'active' \| 'stopped'</code> | Current session status. |
885
+ | **`createdAt`** | <code>number</code> | Creation timestamp. |
886
+ | **`updatedAt`** | <code>number</code> | Last update timestamp. |
887
+ | **`revision`** | <code>number</code> | Monotonic revision incremented on every session state change. |
888
+
889
+
890
+ #### StartWidgetSessionOptions
891
+
892
+ Options for starting a full-native widget session.
893
+
894
+ | Prop | Type | Description |
895
+ | -------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------ |
896
+ | **`widgetId`** | <code>string</code> | Optional explicit widget/session identifier. When omitted, the native runtime creates one. |
897
+ | **`kind`** | <code>string</code> | Optional product-defined session kind. |
898
+ | **`state`** | <code><a href="#jsonobject">JsonObject</a></code> | Initial shared state. |
899
+ | **`metadata`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional metadata for native widget code. |
900
+
901
+
902
+ #### WidgetSessionResult
903
+
904
+ Result when reading or updating one full-native widget session.
905
+
906
+ | Prop | Type | Description |
907
+ | ------------- | --------------------------------------------------------------------------- | -------------------------------------------------- |
908
+ | **`session`** | <code><a href="#widgetsessionrecord">WidgetSessionRecord</a> \| null</code> | Stored session snapshot, or `null` when not found. |
909
+
910
+
911
+ #### UpdateWidgetSessionOptions
912
+
913
+ Options for updating a full-native widget session.
914
+
915
+ | Prop | Type | Description |
916
+ | -------------- | ------------------------------------------------- | ------------------------------------------------------------- |
917
+ | **`widgetId`** | <code>string</code> | Widget/session identifier returned by `startWidgetSession`. |
918
+ | **`state`** | <code><a href="#jsonobject">JsonObject</a></code> | Replacement or merge patch for shared state. |
919
+ | **`metadata`** | <code><a href="#jsonobject">JsonObject</a></code> | Replacement or merge patch for metadata. |
920
+ | **`merge`** | <code>boolean</code> | When true, object values are deep-merged instead of replaced. |
921
+
922
+
923
+ #### StopWidgetSessionOptions
924
+
925
+ Options for stopping a full-native widget session.
926
+
927
+ | Prop | Type | Description |
928
+ | -------------- | ------------------------------------------------- | ----------------------------------------------------------- |
929
+ | **`widgetId`** | <code>string</code> | Widget/session identifier returned by `startWidgetSession`. |
930
+ | **`state`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional final shared state. |
931
+
932
+
933
+ #### GetWidgetSessionOptions
934
+
935
+ Options for reading one full-native widget session.
936
+
937
+ | Prop | Type | Description |
938
+ | -------------- | ------------------- | ---------------------------------- |
939
+ | **`widgetId`** | <code>string</code> | Widget/session identifier to load. |
940
+
941
+
942
+ #### ListWidgetSessionsResult
943
+
944
+ Result when listing full-native widget sessions.
945
+
946
+ | Prop | Type | Description |
947
+ | -------------- | ---------------------------------- | ------------------------- |
948
+ | **`sessions`** | <code>WidgetSessionRecord[]</code> | Stored session snapshots. |
949
+
950
+
951
+ #### SendWidgetMessageResult
952
+
953
+ Result after sending a widget bridge message.
954
+
955
+ | Prop | Type | Description |
956
+ | ------------- | ------------------------------------------------------------------- | ------------------------ |
957
+ | **`message`** | <code><a href="#widgetbridgemessage">WidgetBridgeMessage</a></code> | Stored message snapshot. |
958
+
959
+
960
+ #### WidgetBridgeMessage
961
+
962
+ Queued message used for async app/widget jobs.
963
+
964
+ | Prop | Type | Description |
965
+ | --------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------- |
966
+ | **`messageId`** | <code>string</code> | Stable message identifier. |
967
+ | **`widgetId`** | <code>string</code> | Widget/session identifier associated with the message. |
968
+ | **`direction`** | <code><a href="#widgetmessagedirection">WidgetMessageDirection</a></code> | Message direction. |
969
+ | **`name`** | <code>string</code> | Product-defined message or job name. |
970
+ | **`payload`** | <code><a href="#jsonobject">JsonObject</a> \| null</code> | Optional JSON payload. |
971
+ | **`expectsResponse`** | <code>boolean</code> | Whether the sender expects a later response. |
972
+ | **`status`** | <code><a href="#widgetmessagestatus">WidgetMessageStatus</a></code> | Current message status. |
973
+ | **`createdAt`** | <code>number</code> | Message creation timestamp. |
974
+ | **`acknowledgedAt`** | <code>number \| null</code> | Timestamp in milliseconds when the receiver acknowledged the message. |
975
+ | **`completedAt`** | <code>number \| null</code> | Timestamp in milliseconds when the message was completed or failed. |
976
+ | **`response`** | <code><a href="#jsonobject">JsonObject</a> \| null</code> | Optional JSON response for async jobs. |
977
+ | **`error`** | <code>string \| null</code> | Optional failure message for async jobs. |
978
+
979
+
980
+ #### SendWidgetMessageOptions
981
+
982
+ Options for sending a full-native widget bridge message.
983
+
984
+ | Prop | Type | Description |
985
+ | --------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
986
+ | **`widgetId`** | <code>string</code> | Widget/session identifier associated with the message. |
987
+ | **`name`** | <code>string</code> | Product-defined message or job name. |
988
+ | **`direction`** | <code><a href="#widgetmessagedirection">WidgetMessageDirection</a></code> | Optional message direction. Defaults to `appToWidget` when called from the app. |
989
+ | **`payload`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional JSON payload. |
990
+ | **`expectsResponse`** | <code>boolean</code> | Whether the sender expects a later response. |
991
+
992
+
993
+ #### ListWidgetMessagesResult
994
+
995
+ Result when listing full-native widget bridge messages.
996
+
997
+ | Prop | Type | Description |
998
+ | -------------- | ---------------------------------- | ------------------ |
999
+ | **`messages`** | <code>WidgetBridgeMessage[]</code> | Matching messages. |
1000
+
1001
+
1002
+ #### ListWidgetMessagesOptions
1003
+
1004
+ Options when listing full-native widget bridge messages.
1005
+
1006
+ | Prop | Type | Description |
1007
+ | ------------------------ | ------------------------------------------------------------------------- | ----------------------------------------------------- |
1008
+ | **`widgetId`** | <code>string</code> | Optional widget/session filter. |
1009
+ | **`direction`** | <code><a href="#widgetmessagedirection">WidgetMessageDirection</a></code> | Optional direction filter. |
1010
+ | **`unacknowledgedOnly`** | <code>boolean</code> | When true, only unacknowledged messages are returned. |
1011
+ | **`pendingOnly`** | <code>boolean</code> | When true, only pending messages are returned. |
1012
+
1013
+
1014
+ #### AcknowledgeWidgetMessagesOptions
1015
+
1016
+ Options for acknowledging widget bridge messages after processing them.
1017
+
1018
+ | Prop | Type | Description |
1019
+ | ---------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------- |
1020
+ | **`messageIds`** | <code>string[]</code> | Optional explicit message ids to acknowledge. |
1021
+ | **`widgetId`** | <code>string</code> | Optional widget/session shortcut that acknowledges matching messages. |
1022
+ | **`direction`** | <code><a href="#widgetmessagedirection">WidgetMessageDirection</a></code> | Optional direction filter. |
1023
+
1024
+
1025
+ #### WidgetMessageResult
1026
+
1027
+ Result after completing a widget bridge message.
1028
+
1029
+ | Prop | Type | Description |
1030
+ | ------------- | --------------------------------------------------------------------------- | -------------------------------------------------- |
1031
+ | **`message`** | <code><a href="#widgetbridgemessage">WidgetBridgeMessage</a> \| null</code> | Stored message snapshot, or `null` when not found. |
1032
+
1033
+
1034
+ #### CompleteWidgetMessageOptions
1035
+
1036
+ Options for completing an async widget bridge message.
1037
+
1038
+ | Prop | Type | Description |
1039
+ | --------------- | ------------------------------------------------- | --------------------------------------------------------------------- |
1040
+ | **`messageId`** | <code>string</code> | Message identifier returned by `sendWidgetMessage`. |
1041
+ | **`response`** | <code><a href="#jsonobject">JsonObject</a></code> | Optional JSON response payload. |
1042
+ | **`error`** | <code>string</code> | Optional error string. When set, the message status becomes `failed`. |
1043
+
1044
+
1045
+ #### PluginVersionResult
1046
+
1047
+ Result payload for plugin version queries.
1048
+
1049
+ | Prop | Type | Description |
1050
+ | ------------- | ------------------- | ------------------------------------- |
1051
+ | **`version`** | <code>string</code> | Native implementation version marker. |
1052
+
1053
+
1054
+ ### Type Aliases
1055
+
1056
+
1057
+ #### SvgTemplateLayout
1058
+
1059
+ SVG layout variant for one WidgetKit surface.
1060
+
1061
+ <code><a href="#svgtemplatelayoutwithsvg">SvgTemplateLayoutWithSvg</a> | <a href="#svgtemplatelayoutwithframes">SvgTemplateLayoutWithFrames</a></code>
1062
+
1063
+
1064
+ #### JsonValue
1065
+
1066
+ Any JSON-safe value accepted by the plugin.
1067
+
1068
+ <code><a href="#jsonprimitive">JsonPrimitive</a> | <a href="#jsonobject">JsonObject</a> | <a href="#jsonarray">JsonArray</a></code>
1069
+
1070
+
1071
+ #### JsonPrimitive
1072
+
1073
+ JSON-safe primitive value.
1074
+
1075
+ <code>string | number | boolean | null</code>
1076
+
1077
+
1078
+ #### JsonArray
1079
+
1080
+ JSON-safe array used as activity state.
1081
+
1082
+ <code>JsonValue[]</code>
1083
+
1084
+
1085
+ #### SvgTemplateSurface
1086
+
1087
+ Named WidgetKit surface for one SVG layout variant.
1088
+
1089
+ <code>'lockScreen' | 'dynamicIslandExpanded' | 'dynamicIslandCompactLeading' | 'dynamicIslandCompactTrailing' | 'dynamicIslandMinimal'</code>
1090
+
1091
+
1092
+ #### SvgTemplateState
1093
+
1094
+ Structured state payload persisted for an activity.
1095
+
1096
+ <code><a href="#jsonobject">JsonObject</a></code>
1097
+
1098
+
1099
+ #### Record
1100
+
1101
+ Construct a type with a set of properties K of type T
1102
+
1103
+ <code>{
1104
  [P in K]: T;
1
1105
  }</code>
1106
+
1107
+
1108
+ #### WidgetMessageDirection
1109
+
1110
+ Message direction for the full-native widget bridge.
1111
+
1112
+ <code>'appToWidget' | 'widgetToApp'</code>
1113
+
1114
+
1115
+ #### WidgetMessageStatus
1116
+
1117
+ Completion status for a full-native widget bridge message.
1118
+
1119
+ <code>'pending' | 'completed' | 'failed'</code>
1120
+
1121
+ </docgen-api>