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