sitepong 0.1.10 → 0.1.11

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.
package/README.md CHANGED
@@ -694,27 +694,92 @@ Targeting options (provide at least one):
694
694
 
695
695
  #### Live Activities (iOS)
696
696
 
697
- Register the per-instance push token from your native bridge:
697
+ SitePong ships a turnkey Live Activity package — a generic SwiftUI Widget Extension that the bundled config plugin generates at prebuild, plus a JavaScript API that drives it from data. **No Swift required.** Customers compose their Live Activity using SF Symbols, custom progress bars, and styled text fields entirely from JS.
698
+
699
+ Install the package:
700
+
701
+ ```bash
702
+ npm install @sitepong/expo-live-activity
703
+ ```
704
+
705
+ Add the config plugin to `app.json` / `app.config.js`:
706
+
707
+ ```json
708
+ {
709
+ "plugins": ["@sitepong/expo-live-activity"]
710
+ }
711
+ ```
712
+
713
+ Then prebuild and rebuild your app (`npx expo prebuild --clean`). The plugin creates a Widget Extension target named `SitePongLiveActivityWidget` containing the SitePong template, sets `NSSupportsLiveActivities` in the main app, and wires the extension into the Xcode project.
714
+
715
+ Start a Live Activity from JavaScript:
698
716
 
699
717
  ```typescript
700
- import {
701
- registerLiveActivityToken,
702
- registerPushToStartToken,
703
- endLiveActivity,
704
- } from '@sitepong/sdk/react-native';
718
+ import { startLiveActivity, updateLiveActivity, endLiveActivity } from '@sitepong/expo-live-activity';
719
+
720
+ const { activityId } = await startLiveActivity({
721
+ activityType: 'order-tracking',
722
+ attributes: { id: '#1234' },
723
+ contentState: {
724
+ title: 'Order #1234',
725
+ subtitle: 'Driver is on the way',
726
+ titleStyle: { size: 16, weight: 'bold', color: '#111827' },
727
+ subtitleStyle: { size: 14, weight: 'regular', color: '#6b7280' },
728
+ leadingIcon: { symbol: 'shippingbox.fill', color: '#3b82f6' },
729
+ trailingIcon: { symbol: 'checkmark.seal.fill', color: '#10b981' }, // hidden until you set it
730
+ progress: {
731
+ style: 'bar-with-icon', // 'bar' | 'bar-with-icon' | 'circular' | 'timer'
732
+ value: 0.6,
733
+ icon: 'car.fill', // SF Symbol slides along the track
734
+ iconColor: '#3b82f6',
735
+ trackColor: '#e5e7eb',
736
+ fillColor: '#3b82f6',
737
+ label: '15 minutes away',
738
+ },
739
+ },
740
+ });
741
+ ```
705
742
 
706
- // When ActivityKit gives you a push token for a running activity
707
- registerLiveActivityToken('DeliveryActivityAttributes', activity.id, pushToken, {
708
- environment: 'production',
743
+ Update it locally as state changes:
744
+
745
+ ```typescript
746
+ await updateLiveActivity(activityId, {
747
+ title: 'Order #1234',
748
+ subtitle: 'Driver is two blocks away',
749
+ progress: { style: 'bar-with-icon', value: 0.9, icon: 'car.fill', fillColor: '#3b82f6' },
709
750
  });
751
+ ```
710
752
 
711
- // Or register a push-to-start token (iOS 17.2+) so the activity can be launched remotely
712
- registerPushToStartToken('DeliveryActivityAttributes', pushToStartToken, {
713
- environment: 'production',
753
+ Or update it remotely from your backend by calling `POST /api/push/live-activity` (see endpoint table below). The package automatically forwards the per-activity push token to SitePong on `startLiveActivity`, so backend updates reach the right device with no extra wiring.
754
+
755
+ End the activity when the work completes:
756
+
757
+ ```typescript
758
+ await endLiveActivity(activityId, {
759
+ finalContentState: {
760
+ title: 'Delivered',
761
+ leadingIcon: { symbol: 'checkmark.seal.fill', color: '#10b981' },
762
+ },
763
+ dismissalDate: Date.now() + 60_000, // remove from lock screen after 1 minute
714
764
  });
765
+ ```
766
+
767
+ **Visibility-driven slots.** Every visual element in `contentState` is optional. The SwiftUI template hides slots whose value is omitted, so you control layout density entirely from data. Set `trailingIcon` only on the final "delivered" update and it appears; omit it everywhere else and it stays hidden.
768
+
769
+ **Available styles.** Title and subtitle accept `size`, `weight` (`ultraLight`...`black`), `color` (hex), `italic`, `monospacedDigit`. Icons accept any SF Symbol name plus `color`, `weight`, `size`. Progress supports `bar`, `bar-with-icon` (the Uber-Eats-style sliding icon), `circular`, and `timer` (Apple's auto-updating countdown).
770
+
771
+ **Bringing your own widget.** If you need a visually distinctive Live Activity beyond what the template covers, you can skip `@sitepong/expo-live-activity` and write the Widget Extension yourself in Swift, then call the lower-level token registration directly:
772
+
773
+ ```typescript
774
+ import {
775
+ registerLiveActivityToken,
776
+ registerPushToStartToken,
777
+ endLiveActivity as endLiveActivityToken,
778
+ } from 'sitepong/react-native';
715
779
 
716
- // When the activity ends, deactivate its token
717
- endLiveActivity('DeliveryActivityAttributes', activity.id);
780
+ registerLiveActivityToken('MyActivityAttributes', activity.id, pushToken, { environment: 'production' });
781
+ registerPushToStartToken('MyActivityAttributes', pushToStartToken, { environment: 'production' });
782
+ endLiveActivityToken('MyActivityAttributes', activity.id);
718
783
  ```
719
784
 
720
785
  #### Token invalidation