expo-widgets 55.0.1 β 55.0.2
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/CHANGELOG.md +14 -0
- package/build/Widgets.d.ts +12 -1
- package/build/Widgets.d.ts.map +1 -1
- package/build/Widgets.js +19 -2
- package/build/Widgets.js.map +1 -1
- package/build/Widgets.types.d.ts +6 -2
- package/build/Widgets.types.d.ts.map +1 -1
- package/build/Widgets.types.js.map +1 -1
- package/ios/LiveActivity.swift +11 -8
- package/ios/WidgetsModule.swift +2 -2
- package/ios/WidgetsRecords.swift +16 -0
- package/metro.config.js +13 -6
- package/package.json +3 -5
- package/plugin/build/withIosWarning.d.ts +1 -1
- package/plugin/build/withIosWarning.js +1 -1
- package/plugin/src/withIosWarning.ts +2 -2
- package/src/Widgets.ts +32 -2
- package/src/Widgets.types.ts +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,20 @@
|
|
|
10
10
|
|
|
11
11
|
### π‘ Others
|
|
12
12
|
|
|
13
|
+
## 55.0.2 β 2026-02-26
|
|
14
|
+
|
|
15
|
+
### π New features
|
|
16
|
+
|
|
17
|
+
- Add support for `after(date)` dismissal policy, final content state, and `contentDate` when ending a Live Activity. ([#43472](https://github.com/expo/expo/pull/43472) by [@jakex7](https://github.com/jakex7))
|
|
18
|
+
|
|
19
|
+
### π Bug fixes
|
|
20
|
+
|
|
21
|
+
- Add missing project root to `watchFolders` in `metro.config.js` ([#43449](https://github.com/expo/expo/pull/43449) by [@kitten](https://github.com/kitten))
|
|
22
|
+
|
|
23
|
+
### π‘ Others
|
|
24
|
+
|
|
25
|
+
- Remove extraneous `@expo/config-plugins` dependency ([#43452](https://github.com/expo/expo/pull/43452) by [@kitten](https://github.com/kitten))
|
|
26
|
+
|
|
13
27
|
## 55.0.1 β 2026-02-25
|
|
14
28
|
|
|
15
29
|
### π Bug fixes
|
package/build/Widgets.d.ts
CHANGED
|
@@ -41,8 +41,11 @@ export declare class LiveActivity<T extends object = object> {
|
|
|
41
41
|
/**
|
|
42
42
|
* Ends the Live Activity.
|
|
43
43
|
* @param dismissalPolicy Controls when the Live Activity is removed from the Lock Screen after ending.
|
|
44
|
+
* Can be `'default'`, `'immediate'`, or `after(date)`.
|
|
45
|
+
* @param props Final content properties to update after the activity ends.
|
|
46
|
+
* @param contentDate The time the data in the payload was generated. If this is older than a previous update or push payload, the system ignores this update.
|
|
44
47
|
*/
|
|
45
|
-
end(dismissalPolicy?: LiveActivityDismissalPolicy): Promise<void>;
|
|
48
|
+
end(dismissalPolicy?: LiveActivityDismissalPolicy, props?: T, contentDate?: Date): Promise<void>;
|
|
46
49
|
/**
|
|
47
50
|
* Returns the push token for this Live Activity, used to send push notification updates via APNs.
|
|
48
51
|
* Returns `null` if push notifications are not enabled or the token is not yet available.
|
|
@@ -75,6 +78,14 @@ export declare class LiveActivityFactory<T extends object = object> {
|
|
|
75
78
|
*/
|
|
76
79
|
getInstances(): LiveActivity<T>[];
|
|
77
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a dismissal policy that removes the Live Activity at the specified time within a four-hour window.
|
|
83
|
+
* @param date The date after which the Live Activity should be removed from the Lock Screen.
|
|
84
|
+
* @hidden
|
|
85
|
+
*/
|
|
86
|
+
export declare function after(date: Date): {
|
|
87
|
+
after: Date;
|
|
88
|
+
};
|
|
78
89
|
/**
|
|
79
90
|
* Creates a Widget instance.
|
|
80
91
|
* @param name The widget name. Must match the `'name'` field in your widget configuration in the app config.
|
package/build/Widgets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Widgets.d.ts","sourceRoot":"","sources":["../src/Widgets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,EAGlB,cAAc,EACd,UAAU,EACV,mBAAmB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BAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACpD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,GAClD,MAAM,CAAC,CAAC,CAAC,CAEX;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC1D,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACrC,mBAAmB,CAAC,CAAC,CAAC,CAExB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,iBAAiB,CAAC,8BAA8B,CAAC,GAC1D,iBAAiB,CAEnB;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,iBAAiB,CAAC,uCAAuC,CAAC,GACnE,iBAAiB,CAEnB"}
|
package/build/Widgets.js
CHANGED
|
@@ -57,9 +57,18 @@ export class LiveActivity {
|
|
|
57
57
|
/**
|
|
58
58
|
* Ends the Live Activity.
|
|
59
59
|
* @param dismissalPolicy Controls when the Live Activity is removed from the Lock Screen after ending.
|
|
60
|
+
* Can be `'default'`, `'immediate'`, or `after(date)`.
|
|
61
|
+
* @param props Final content properties to update after the activity ends.
|
|
62
|
+
* @param contentDate The time the data in the payload was generated. If this is older than a previous update or push payload, the system ignores this update.
|
|
60
63
|
*/
|
|
61
|
-
end(dismissalPolicy) {
|
|
62
|
-
|
|
64
|
+
end(dismissalPolicy, props, contentDate) {
|
|
65
|
+
const serializedProps = props ? JSON.stringify(props) : undefined;
|
|
66
|
+
if (typeof dismissalPolicy === 'object' &&
|
|
67
|
+
dismissalPolicy !== null &&
|
|
68
|
+
'after' in dismissalPolicy) {
|
|
69
|
+
return this.nativeLiveActivity.end('after', dismissalPolicy.after?.getTime(), serializedProps, contentDate?.getTime());
|
|
70
|
+
}
|
|
71
|
+
return this.nativeLiveActivity.end(dismissalPolicy, undefined, serializedProps, contentDate?.getTime());
|
|
63
72
|
}
|
|
64
73
|
/**
|
|
65
74
|
* Returns the push token for this Live Activity, used to send push notification updates via APNs.
|
|
@@ -105,6 +114,14 @@ export class LiveActivityFactory {
|
|
|
105
114
|
.map((instance) => new LiveActivity(instance));
|
|
106
115
|
}
|
|
107
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates a dismissal policy that removes the Live Activity at the specified time within a four-hour window.
|
|
119
|
+
* @param date The date after which the Live Activity should be removed from the Lock Screen.
|
|
120
|
+
* @hidden
|
|
121
|
+
*/
|
|
122
|
+
export function after(date) {
|
|
123
|
+
return { after: date };
|
|
124
|
+
}
|
|
108
125
|
/**
|
|
109
126
|
* Creates a Widget instance.
|
|
110
127
|
* @param name The widget name. Must match the `'name'` field in your widget configuration in the app config.
|
package/build/Widgets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Widgets.js","sourceRoot":"","sources":["../src/Widgets.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAa9C;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,cAAc;IACN,kBAAkB,CAAqB;IAC/C,YAAY,IAAY,EAAE,MAA+C;QACvE,IAAI,CAAC,kBAAkB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,MAA2B,CAAC,CAAC;IAC5F,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,OAAiC;QAC9C,IAAI,CAAC,kBAAkB,CAAC,cAAc,CACpC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,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IAC7D,YAAY,IAAY,EAAE,MAAgC;QACxD,IAAI,CAAC,yBAAyB,GAAG,IAAI,iBAAiB,CAAC,mBAAmB,CACxE,IAAI,EACJ,MAA2B,CAC5B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAQ,EAAE,GAAY;QAC1B,OAAO,IAAI,YAAY,CAAI,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/F,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,yBAAyB;aAClC,YAAY,EAAE;aACd,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,YAAY,CAAI,QAAQ,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,MAAmD;IAEnD,OAAO,IAAI,MAAM,CAAI,IAAI,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,YAAsC;IAEtC,OAAO,IAAI,mBAAmB,CAAI,IAAI,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAA2D;IAE3D,OAAO,iBAAiB,CAAC,WAAW,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAC;AACjF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAoE;IAEpE,OAAO,iBAAiB,CAAC,WAAW,CAAC,uCAAuC,EAAE,QAAQ,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\n\nimport ExpoWidgetsModule from './ExpoWidgets';\nimport type {\n ExpoWidgetsEvents,\n LiveActivityComponent,\n LiveActivityDismissalPolicy,\n NativeLiveActivity,\n NativeLiveActivityFactory,\n NativeWidgetObject,\n PushTokenEvent,\n WidgetBase,\n WidgetTimelineEntry,\n} from './Widgets.types';\n\n/**\n * Represents a widget instance. Provides methods to manage the widget's timeline.\n */\nexport class Widget<T extends object = object> {\n /** @hidden */\n private nativeWidgetObject: NativeWidgetObject;\n constructor(name: string, layout: (p: WidgetBase<T>) => React.JSX.Element) {\n this.nativeWidgetObject = new ExpoWidgetsModule.Widget(name, layout as unknown as string);\n }\n\n /**\n * Force reloads the widget, causing it to refresh its content and timeline.\n */\n reload() {\n this.nativeWidgetObject.reload();\n }\n\n /**\n * Schedules a series of updates for the widget's content and reloads the widget.\n * @param entries Timeline entries, each specifying a date and the props to display at that time.\n */\n updateTimeline(entries: WidgetTimelineEntry<T>[]) {\n this.nativeWidgetObject.updateTimeline(\n entries.map((entry) => ({ timestamp: entry.date.getTime(), props: entry.props }))\n );\n }\n\n /**\n * Sets the widget's content to the given props immediately, without scheduling a timeline.\n * @param props The properties to display in the widget.\n */\n updateSnapshot(props: T) {\n this.nativeWidgetObject.updateTimeline([{ timestamp: Date.now(), props }]);\n }\n\n /**\n * Returns the current timeline entries for the widget, including past and future entries.\n */\n async getTimeline(): Promise<WidgetTimelineEntry<T>[]> {\n return (await this.nativeWidgetObject.getTimeline()).map((entry) => ({\n date: new Date(entry.timestamp),\n props: entry.props as T,\n }));\n }\n}\n\n/**\n * Represents a Live Activity instance. Provides methods to update its content and end it.\n */\nexport class LiveActivity<T extends object = object> {\n /** @hidden */\n private nativeLiveActivity: NativeLiveActivity;\n constructor(nativeLiveActivity: NativeLiveActivity) {\n this.nativeLiveActivity = nativeLiveActivity;\n }\n\n /**\n * Updates the Live Activity's content. The UI reflects the new properties immediately.\n * @param props The updated content properties.\n */\n update(props: T): Promise<void> {\n return this.nativeLiveActivity.update(JSON.stringify(props));\n }\n\n /**\n * Ends the Live Activity.\n * @param dismissalPolicy Controls when the Live Activity is removed from the Lock Screen after ending.\n */\n end(dismissalPolicy?: LiveActivityDismissalPolicy): Promise<void> {\n return this.nativeLiveActivity.end(dismissalPolicy);\n }\n\n /**\n * Returns the push token for this Live Activity, used to send push notification updates via APNs.\n * Returns `null` if push notifications are not enabled or the token is not yet available.\n */\n getPushToken(): Promise<string | null> {\n return this.nativeLiveActivity.getPushToken();\n }\n\n /**\n * Adds a listener for push token update events on this Live Activity instance.\n * The token can be used to send content updates to this specific activity via APNs.\n * @param listener Callback invoked when a new push token is available.\n * @returns An event subscription that can be used to remove the listener.\n */\n addPushTokenListener(listener: (event: PushTokenEvent) => void): EventSubscription {\n return this.nativeLiveActivity.addListener('onExpoWidgetsTokenReceived', listener);\n }\n}\n\n/**\n * Manages Live Activity instances of a specific type. Use it to start new activities and retrieve currently active ones.\n */\nexport class LiveActivityFactory<T extends object = object> {\n /** @hidden */\n private nativeLiveActivityFactory: NativeLiveActivityFactory;\n constructor(name: string, layout: LiveActivityComponent<T>) {\n this.nativeLiveActivityFactory = new ExpoWidgetsModule.LiveActivityFactory(\n name,\n layout as unknown as string\n );\n }\n\n /**\n * Starts a new Live Activity with the given properties.\n * @param props The initial content properties for the Live Activity.\n * @param url An optional URL to associate with the Live Activity, used for deep linking.\n * @returns The new Live Activity instance.\n */\n start(props: T, url?: string) {\n return new LiveActivity<T>(this.nativeLiveActivityFactory.start(JSON.stringify(props), url));\n }\n\n /**\n * Returns all currently active instances of this Live Activity type.\n */\n getInstances() {\n return this.nativeLiveActivityFactory\n .getInstances()\n .map((instance) => new LiveActivity<T>(instance));\n }\n}\n\n/**\n * Creates a Widget instance.\n * @param name The widget name. Must match the `'name'` field in your widget configuration in the app config.\n * @param widget The widget component, marked with the `'widget'` directive.\n */\nexport function createWidget<T extends object = object>(\n name: string,\n widget: (props: WidgetBase<T>) => React.JSX.Element\n): Widget<T> {\n return new Widget<T>(name, widget);\n}\n\n/**\n * Creates a Live Activity Factory for managing Live Activities of a specific type.\n * @param name The Live Activity name. Must match the `'name'` field in your widget configuration in the app config.\n * @param liveActivity The Live Activity component, marked with the `'widget'` directive.\n */\nexport function createLiveActivity<T extends object = object>(\n name: string,\n liveActivity: LiveActivityComponent<T>\n): LiveActivityFactory<T> {\n return new LiveActivityFactory<T>(name, liveActivity);\n}\n\n/**\n * Adds a listener for widget interaction events (for example, button taps).\n * @param listener Callback function to handle user interaction events.\n * @return An event subscription that can be used to remove the listener.\n */\nexport function addUserInteractionListener(\n listener: ExpoWidgetsEvents['onExpoWidgetsUserInteraction']\n): EventSubscription {\n return ExpoWidgetsModule.addListener('onExpoWidgetsUserInteraction', listener);\n}\n\n/**\n * Adds a listener for push-to-start token events.\n * This token can be used to start live activities remotely via APNs.\n * @param listener Callback function to handle push-to-start token events.\n * @return An event subscription that can be used to remove the listener.\n */\nexport function addPushToStartTokenListener(\n listener: ExpoWidgetsEvents['onExpoWidgetsPushToStartTokenReceived']\n): EventSubscription {\n return ExpoWidgetsModule.addListener('onExpoWidgetsPushToStartTokenReceived', listener);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Widgets.js","sourceRoot":"","sources":["../src/Widgets.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAa9C;;GAEG;AACH,MAAM,OAAO,MAAM;IACjB,cAAc;IACN,kBAAkB,CAAqB;IAC/C,YAAY,IAAY,EAAE,MAA+C;QACvE,IAAI,CAAC,kBAAkB,GAAG,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,MAA2B,CAAC,CAAC;IAC5F,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,OAAiC;QAC9C,IAAI,CAAC,kBAAkB,CAAC,cAAc,CACpC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE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;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,YAAsC;IAEtC,OAAO,IAAI,mBAAmB,CAAI,IAAI,EAAE,YAAY,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAA2D;IAE3D,OAAO,iBAAiB,CAAC,WAAW,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAC;AACjF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAoE;IAEpE,OAAO,iBAAiB,CAAC,WAAW,CAAC,uCAAuC,EAAE,QAAQ,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["import { type EventSubscription } from 'expo-modules-core';\n\nimport ExpoWidgetsModule from './ExpoWidgets';\nimport type {\n ExpoWidgetsEvents,\n LiveActivityComponent,\n LiveActivityDismissalPolicy,\n NativeLiveActivity,\n NativeLiveActivityFactory,\n NativeWidgetObject,\n PushTokenEvent,\n WidgetBase,\n WidgetTimelineEntry,\n} from './Widgets.types';\n\n/**\n * Represents a widget instance. Provides methods to manage the widget's timeline.\n */\nexport class Widget<T extends object = object> {\n /** @hidden */\n private nativeWidgetObject: NativeWidgetObject;\n constructor(name: string, layout: (p: WidgetBase<T>) => React.JSX.Element) {\n this.nativeWidgetObject = new ExpoWidgetsModule.Widget(name, layout as unknown as string);\n }\n\n /**\n * Force reloads the widget, causing it to refresh its content and timeline.\n */\n reload() {\n this.nativeWidgetObject.reload();\n }\n\n /**\n * Schedules a series of updates for the widget's content and reloads the widget.\n * @param entries Timeline entries, each specifying a date and the props to display at that time.\n */\n updateTimeline(entries: WidgetTimelineEntry<T>[]) {\n this.nativeWidgetObject.updateTimeline(\n entries.map((entry) => ({ timestamp: entry.date.getTime(), props: entry.props }))\n );\n }\n\n /**\n * Sets the widget's content to the given props immediately, without scheduling a timeline.\n * @param props The properties to display in the widget.\n */\n updateSnapshot(props: T) {\n this.nativeWidgetObject.updateTimeline([{ timestamp: Date.now(), props }]);\n }\n\n /**\n * Returns the current timeline entries for the widget, including past and future entries.\n */\n async getTimeline(): Promise<WidgetTimelineEntry<T>[]> {\n return (await this.nativeWidgetObject.getTimeline()).map((entry) => ({\n date: new Date(entry.timestamp),\n props: entry.props as T,\n }));\n }\n}\n\n/**\n * Represents a Live Activity instance. Provides methods to update its content and end it.\n */\nexport class LiveActivity<T extends object = object> {\n /** @hidden */\n private nativeLiveActivity: NativeLiveActivity;\n constructor(nativeLiveActivity: NativeLiveActivity) {\n this.nativeLiveActivity = nativeLiveActivity;\n }\n\n /**\n * Updates the Live Activity's content. The UI reflects the new properties immediately.\n * @param props The updated content properties.\n */\n update(props: T): Promise<void> {\n return this.nativeLiveActivity.update(JSON.stringify(props));\n }\n\n /**\n * Ends the Live Activity.\n * @param dismissalPolicy Controls when the Live Activity is removed from the Lock Screen after ending.\n * Can be `'default'`, `'immediate'`, or `after(date)`.\n * @param props Final content properties to update after the activity ends.\n * @param contentDate The time the data in the payload was generated. If this is older than a previous update or push payload, the system ignores this update.\n */\n end(dismissalPolicy?: LiveActivityDismissalPolicy, props?: T, contentDate?: Date): Promise<void> {\n const serializedProps = props ? JSON.stringify(props) : undefined;\n if (\n typeof dismissalPolicy === 'object' &&\n dismissalPolicy !== null &&\n 'after' in dismissalPolicy\n ) {\n return this.nativeLiveActivity.end(\n 'after',\n dismissalPolicy.after?.getTime(),\n serializedProps,\n contentDate?.getTime()\n );\n }\n return this.nativeLiveActivity.end(\n dismissalPolicy,\n undefined,\n serializedProps,\n contentDate?.getTime()\n );\n }\n\n /**\n * Returns the push token for this Live Activity, used to send push notification updates via APNs.\n * Returns `null` if push notifications are not enabled or the token is not yet available.\n */\n getPushToken(): Promise<string | null> {\n return this.nativeLiveActivity.getPushToken();\n }\n\n /**\n * Adds a listener for push token update events on this Live Activity instance.\n * The token can be used to send content updates to this specific activity via APNs.\n * @param listener Callback invoked when a new push token is available.\n * @returns An event subscription that can be used to remove the listener.\n */\n addPushTokenListener(listener: (event: PushTokenEvent) => void): EventSubscription {\n return this.nativeLiveActivity.addListener('onExpoWidgetsTokenReceived', listener);\n }\n}\n\n/**\n * Manages Live Activity instances of a specific type. Use it to start new activities and retrieve currently active ones.\n */\nexport class LiveActivityFactory<T extends object = object> {\n /** @hidden */\n private nativeLiveActivityFactory: NativeLiveActivityFactory;\n constructor(name: string, layout: LiveActivityComponent<T>) {\n this.nativeLiveActivityFactory = new ExpoWidgetsModule.LiveActivityFactory(\n name,\n layout as unknown as string\n );\n }\n\n /**\n * Starts a new Live Activity with the given properties.\n * @param props The initial content properties for the Live Activity.\n * @param url An optional URL to associate with the Live Activity, used for deep linking.\n * @returns The new Live Activity instance.\n */\n start(props: T, url?: string) {\n return new LiveActivity<T>(this.nativeLiveActivityFactory.start(JSON.stringify(props), url));\n }\n\n /**\n * Returns all currently active instances of this Live Activity type.\n */\n getInstances() {\n return this.nativeLiveActivityFactory\n .getInstances()\n .map((instance) => new LiveActivity<T>(instance));\n }\n}\n\n/**\n * Creates a dismissal policy that removes the Live Activity at the specified time within a four-hour window.\n * @param date The date after which the Live Activity should be removed from the Lock Screen.\n * @hidden\n */\nexport function after(date: Date): { after: Date } {\n return { after: date };\n}\n\n/**\n * Creates a Widget instance.\n * @param name The widget name. Must match the `'name'` field in your widget configuration in the app config.\n * @param widget The widget component, marked with the `'widget'` directive.\n */\nexport function createWidget<T extends object = object>(\n name: string,\n widget: (props: WidgetBase<T>) => React.JSX.Element\n): Widget<T> {\n return new Widget<T>(name, widget);\n}\n\n/**\n * Creates a Live Activity Factory for managing Live Activities of a specific type.\n * @param name The Live Activity name. Must match the `'name'` field in your widget configuration in the app config.\n * @param liveActivity The Live Activity component, marked with the `'widget'` directive.\n */\nexport function createLiveActivity<T extends object = object>(\n name: string,\n liveActivity: LiveActivityComponent<T>\n): LiveActivityFactory<T> {\n return new LiveActivityFactory<T>(name, liveActivity);\n}\n\n/**\n * Adds a listener for widget interaction events (for example, button taps).\n * @param listener Callback function to handle user interaction events.\n * @return An event subscription that can be used to remove the listener.\n */\nexport function addUserInteractionListener(\n listener: ExpoWidgetsEvents['onExpoWidgetsUserInteraction']\n): EventSubscription {\n return ExpoWidgetsModule.addListener('onExpoWidgetsUserInteraction', listener);\n}\n\n/**\n * Adds a listener for push-to-start token events.\n * This token can be used to start live activities remotely via APNs.\n * @param listener Callback function to handle push-to-start token events.\n * @return An event subscription that can be used to remove the listener.\n */\nexport function addPushToStartTokenListener(\n listener: ExpoWidgetsEvents['onExpoWidgetsPushToStartTokenReceived']\n): EventSubscription {\n return ExpoWidgetsModule.addListener('onExpoWidgetsPushToStartTokenReceived', listener);\n}\n"]}
|
package/build/Widgets.types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SharedObject } from 'expo';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { after } from './Widgets';
|
|
3
4
|
/**
|
|
4
5
|
* The widget family (size).
|
|
5
6
|
* - `systemSmall` - Small square widget (2x2 grid).
|
|
@@ -128,8 +129,11 @@ export type PushToStartTokenEvent = {
|
|
|
128
129
|
};
|
|
129
130
|
/**
|
|
130
131
|
* Dismissal policy for ending a live activity.
|
|
132
|
+
* - `'default'` - The systemβs default dismissal policy for the Live Activity.
|
|
133
|
+
* - `'immediate'` - The system immediately removes the Live Activity that ended.
|
|
134
|
+
* - `after(date)` - The system removes the Live Activity that ended at the specified time within a four-hour window.
|
|
131
135
|
*/
|
|
132
|
-
export type LiveActivityDismissalPolicy = 'default' | 'immediate'
|
|
136
|
+
export type LiveActivityDismissalPolicy = 'default' | 'immediate' | ReturnType<typeof after>;
|
|
133
137
|
export type ExpoWidgetsEvents = {
|
|
134
138
|
/**
|
|
135
139
|
* Function that is invoked when user interacts with a widget.
|
|
@@ -162,7 +166,7 @@ export declare class NativeLiveActivityFactory extends SharedObject {
|
|
|
162
166
|
}
|
|
163
167
|
export declare class NativeLiveActivity extends SharedObject<LiveActivityEvents> {
|
|
164
168
|
update(props: string): Promise<void>;
|
|
165
|
-
end(dismissalPolicy?:
|
|
169
|
+
end(dismissalPolicy?: string, afterDate?: number, state?: string, contentDate?: number): Promise<void>;
|
|
166
170
|
getPushToken(): Promise<string | null>;
|
|
167
171
|
}
|
|
168
172
|
//# sourceMappingURL=Widgets.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Widgets.types.d.ts","sourceRoot":"","sources":["../src/Widgets.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,mBAAmB,GACnB,sBAAsB,GACtB,iBAAiB,CAAC;AAEtB;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAClD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;CACtB,GAAG,CAAC,CAAC;AAEN,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAC3D;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IACX;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,eAAe,CAAC,EAAE,SAAS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AAkB,EAAE;CACrC;AAED,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAC9E,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACpC,GAAG,CACD,eAAe,CAAC,EAAE,MAAM,EACxB,SAAS,CAAC,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAChB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Widgets.types.js","sourceRoot":"","sources":["../src/Widgets.types.ts"],"names":[],"mappings":"","sourcesContent":["import { SharedObject } from 'expo';\nimport { ReactNode } from 'react';\n\n/**\n * The widget family (size).\n * - `systemSmall` - Small square widget (2x2 grid).\n * - `systemMedium` - Medium widget (4x2 grid).\n * - `systemLarge` - Large widget (4x4 grid).\n * - `systemExtraLarge` - Extra large widget (iPad only, 6x4 grid).\n * - `accessoryCircular` - Circular accessory widget for the Lock Screen.\n * - `accessoryRectangular` - Rectangular accessory widget for the Lock Screen.\n * - `accessoryInline` - Inline accessory widget for the Lock Screen.\n */\nexport type WidgetFamily =\n | 'systemSmall'\n | 'systemMedium'\n | 'systemLarge'\n | 'systemExtraLarge'\n | 'accessoryCircular'\n | 'accessoryRectangular'\n | 'accessoryInline';\n\n/**\n * Props passed to a widget component.\n */\nexport type WidgetBase<T extends object = object> = {\n /**\n * The date of this timeline entry.\n */\n date: Date;\n /**\n * The widget family.\n */\n family: WidgetFamily;\n} & T;\n\nexport type WidgetTimelineEntry<T extends object = object> = {\n /**\n * Date when widget should update.\n */\n date: Date;\n /**\n * Props to be passed to the widget.\n */\n props: T;\n};\n\nexport type ExpoTimelineEntry = {\n timestamp: number;\n props: Record<string, any>;\n};\n\n/**\n * Defines the layout sections for an iOS Live Activity.\n */\nexport type LiveActivityLayout = {\n /**\n * The main banner content displayed in Notifications Center.\n */\n banner: ReactNode;\n /**\n * The small banner content displayed in CarPlay and WatchOS. Falls back to `banner` if not provided.\n */\n bannerSmall?: ReactNode;\n /**\n * The leading content in the compact Dynamic Island presentation.\n */\n compactLeading?: ReactNode;\n /**\n * The trailing content in the compact Dynamic Island presentation.\n */\n compactTrailing?: ReactNode;\n /**\n * The minimal content shown when the Dynamic Island is in its smallest form.\n */\n minimal?: ReactNode;\n /**\n * The center content in the expanded Dynamic Island presentation.\n */\n expandedCenter?: ReactNode;\n /**\n * The leading content in the expanded Dynamic Island presentation.\n */\n expandedLeading?: ReactNode;\n /**\n * The trailing content in the expanded Dynamic Island presentation.\n */\n expandedTrailing?: ReactNode;\n /**\n * The bottom content in the expanded Dynamic Island presentation.\n */\n expandedBottom?: ReactNode;\n};\n\n/**\n * A function that returns the layout for a Live Activity.\n */\nexport type LiveActivityComponent<T extends object = object> = (props?: T) => LiveActivityLayout;\n\n/**\n * Event emitted when a user interacts with a widget.\n */\nexport type UserInteractionEvent = {\n /**\n * Widget that triggered the interaction.\n */\n source: string;\n /**\n * Button/toggle that was pressed.\n */\n target: string;\n /**\n * Timestamp of the event.\n */\n timestamp: number;\n /**\n * The event type identifier.\n */\n type: 'ExpoWidgetsUserInteraction';\n};\n\n/**\n * Event emitted when a push token is received for a live activity.\n */\nexport type PushTokenEvent = {\n /**\n * The ID of the live activity.\n */\n activityId: string;\n /**\n * The push token for the live activity.\n */\n pushToken: string;\n};\n\n/**\n * Event emitted when a push-to-start token is received.\n */\nexport type PushToStartTokenEvent = {\n /**\n * The push-to-start token for starting live activities remotely.\n */\n activityPushToStartToken: string;\n};\n\n/**\n * Dismissal policy for ending a live activity.\n */\nexport type LiveActivityDismissalPolicy = 'default' | 'immediate'
|
|
1
|
+
{"version":3,"file":"Widgets.types.js","sourceRoot":"","sources":["../src/Widgets.types.ts"],"names":[],"mappings":"","sourcesContent":["import { SharedObject } from 'expo';\nimport { ReactNode } from 'react';\n\nimport { after } from './Widgets';\n\n/**\n * The widget family (size).\n * - `systemSmall` - Small square widget (2x2 grid).\n * - `systemMedium` - Medium widget (4x2 grid).\n * - `systemLarge` - Large widget (4x4 grid).\n * - `systemExtraLarge` - Extra large widget (iPad only, 6x4 grid).\n * - `accessoryCircular` - Circular accessory widget for the Lock Screen.\n * - `accessoryRectangular` - Rectangular accessory widget for the Lock Screen.\n * - `accessoryInline` - Inline accessory widget for the Lock Screen.\n */\nexport type WidgetFamily =\n | 'systemSmall'\n | 'systemMedium'\n | 'systemLarge'\n | 'systemExtraLarge'\n | 'accessoryCircular'\n | 'accessoryRectangular'\n | 'accessoryInline';\n\n/**\n * Props passed to a widget component.\n */\nexport type WidgetBase<T extends object = object> = {\n /**\n * The date of this timeline entry.\n */\n date: Date;\n /**\n * The widget family.\n */\n family: WidgetFamily;\n} & T;\n\nexport type WidgetTimelineEntry<T extends object = object> = {\n /**\n * Date when widget should update.\n */\n date: Date;\n /**\n * Props to be passed to the widget.\n */\n props: T;\n};\n\nexport type ExpoTimelineEntry = {\n timestamp: number;\n props: Record<string, any>;\n};\n\n/**\n * Defines the layout sections for an iOS Live Activity.\n */\nexport type LiveActivityLayout = {\n /**\n * The main banner content displayed in Notifications Center.\n */\n banner: ReactNode;\n /**\n * The small banner content displayed in CarPlay and WatchOS. Falls back to `banner` if not provided.\n */\n bannerSmall?: ReactNode;\n /**\n * The leading content in the compact Dynamic Island presentation.\n */\n compactLeading?: ReactNode;\n /**\n * The trailing content in the compact Dynamic Island presentation.\n */\n compactTrailing?: ReactNode;\n /**\n * The minimal content shown when the Dynamic Island is in its smallest form.\n */\n minimal?: ReactNode;\n /**\n * The center content in the expanded Dynamic Island presentation.\n */\n expandedCenter?: ReactNode;\n /**\n * The leading content in the expanded Dynamic Island presentation.\n */\n expandedLeading?: ReactNode;\n /**\n * The trailing content in the expanded Dynamic Island presentation.\n */\n expandedTrailing?: ReactNode;\n /**\n * The bottom content in the expanded Dynamic Island presentation.\n */\n expandedBottom?: ReactNode;\n};\n\n/**\n * A function that returns the layout for a Live Activity.\n */\nexport type LiveActivityComponent<T extends object = object> = (props?: T) => LiveActivityLayout;\n\n/**\n * Event emitted when a user interacts with a widget.\n */\nexport type UserInteractionEvent = {\n /**\n * Widget that triggered the interaction.\n */\n source: string;\n /**\n * Button/toggle that was pressed.\n */\n target: string;\n /**\n * Timestamp of the event.\n */\n timestamp: number;\n /**\n * The event type identifier.\n */\n type: 'ExpoWidgetsUserInteraction';\n};\n\n/**\n * Event emitted when a push token is received for a live activity.\n */\nexport type PushTokenEvent = {\n /**\n * The ID of the live activity.\n */\n activityId: string;\n /**\n * The push token for the live activity.\n */\n pushToken: string;\n};\n\n/**\n * Event emitted when a push-to-start token is received.\n */\nexport type PushToStartTokenEvent = {\n /**\n * The push-to-start token for starting live activities remotely.\n */\n activityPushToStartToken: string;\n};\n\n/**\n * Dismissal policy for ending a live activity.\n * - `'default'` - The systemβs default dismissal policy for the Live Activity.\n * - `'immediate'` - The system immediately removes the Live Activity that ended.\n * - `after(date)` - The system removes the Live Activity that ended at the specified time within a four-hour window.\n */\nexport type LiveActivityDismissalPolicy = 'default' | 'immediate' | ReturnType<typeof after>;\n\nexport type ExpoWidgetsEvents = {\n /**\n * Function that is invoked when user interacts with a widget.\n * @param event Interaction event details.\n */\n onExpoWidgetsUserInteraction: (event: UserInteractionEvent) => void;\n /**\n * Function that is invoked when a push-to-start token is received.\n * @param event Token event details.\n */\n onExpoWidgetsPushToStartTokenReceived: (event: PushToStartTokenEvent) => void;\n};\n\nexport type LiveActivityEvents = {\n /**\n * Function that is invoked when a push token is received for a live activity.\n * @param event Token event details.\n */\n onExpoWidgetsTokenReceived: (event: PushTokenEvent) => void;\n};\n\nexport declare class NativeWidgetObject extends SharedObject {\n constructor(name: string, layout: string);\n reload(): void;\n updateTimeline(entries: ExpoTimelineEntry[]): void;\n getTimeline(): Promise<ExpoTimelineEntry[]>;\n}\n\nexport declare class NativeLiveActivityFactory extends SharedObject {\n constructor(name: string, layout: string);\n start(props: string, url?: string): NativeLiveActivity;\n getInstances(): NativeLiveActivity[];\n}\n\nexport declare class NativeLiveActivity extends SharedObject<LiveActivityEvents> {\n update(props: string): Promise<void>;\n end(\n dismissalPolicy?: string,\n afterDate?: number,\n state?: string,\n contentDate?: number\n ): Promise<void>;\n getPushToken(): Promise<string | null>;\n}\n"]}
|
package/ios/LiveActivity.swift
CHANGED
|
@@ -23,22 +23,25 @@ final class LiveActivity: SharedObject {
|
|
|
23
23
|
await activity.update(ActivityContent(state: newState, staleDate: nil))
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
func end(dismissalPolicy: String?) async throws {
|
|
26
|
+
func end(dismissalPolicy: LiveActivityDismissalPolicy?, afterDate: Date?, props: String?, contentDate: Date?) async throws {
|
|
27
27
|
guard #available(iOS 16.2, *) else { throw LiveActivitiesNotSupportedException() }
|
|
28
28
|
|
|
29
29
|
guard let activity = Activity<LiveActivityAttributes>.activities.first(where: { $0.id == id }) else {
|
|
30
30
|
throw LiveActivityNotFoundException(id)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
policy = .default
|
|
33
|
+
let content: ActivityContent<LiveActivityAttributes.ContentState>?
|
|
34
|
+
if let props {
|
|
35
|
+
content = ActivityContent(state: LiveActivityAttributes.ContentState(name: name, props: props), staleDate: nil)
|
|
36
|
+
} else {
|
|
37
|
+
content = nil
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
guard let contentDate, #available(iOS 17.2, *) else {
|
|
41
|
+
return await activity.end(content, dismissalPolicy: dismissalPolicy?.toDismissalPolicy(date: afterDate) ?? .default)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await activity.end(content, dismissalPolicy: dismissalPolicy?.toDismissalPolicy(date: afterDate) ?? .default, timestamp: contentDate)
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
func getPushToken() throws -> String? {
|
package/ios/WidgetsModule.swift
CHANGED
|
@@ -86,8 +86,8 @@ public final class WidgetsModule: Module {
|
|
|
86
86
|
try await instance.update(props: props)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
AsyncFunction("end") { (instance: LiveActivity, dismissalPolicy: String?) in
|
|
90
|
-
try await instance.end(dismissalPolicy: dismissalPolicy)
|
|
89
|
+
AsyncFunction("end") { (instance: LiveActivity, dismissalPolicy: LiveActivityDismissalPolicy?, afterDate: Date?, props: String?, contentDate: Date?) in
|
|
90
|
+
try await instance.end(dismissalPolicy: dismissalPolicy, afterDate: afterDate, props: props, contentDate: contentDate)
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
AsyncFunction("getPushToken") { (instance: LiveActivity) in
|
package/ios/WidgetsRecords.swift
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
|
+
import ActivityKit
|
|
2
3
|
|
|
3
4
|
struct WidgetsJSTimelineEntry: Record {
|
|
4
5
|
@Field var timestamp: Int
|
|
5
6
|
@Field var props: [String: Any] = [:]
|
|
6
7
|
}
|
|
8
|
+
|
|
9
|
+
internal enum LiveActivityDismissalPolicy: String, Enumerable {
|
|
10
|
+
case `default`
|
|
11
|
+
case immediate
|
|
12
|
+
case after
|
|
13
|
+
|
|
14
|
+
@available(iOS 16.1, *)
|
|
15
|
+
internal func toDismissalPolicy(date: Date?) -> ActivityUIDismissalPolicy {
|
|
16
|
+
return switch self {
|
|
17
|
+
case .default: .default
|
|
18
|
+
case .immediate: .immediate
|
|
19
|
+
case .after: .after(date ?? Date.now)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/metro.config.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
const { getDefaultConfig } = require('expo/metro-config');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const projectRoot = process.cwd();
|
|
5
|
+
const config = getDefaultConfig(projectRoot);
|
|
5
6
|
|
|
6
7
|
const expoStubPath = path.resolve(__dirname, './bundle/expo-module-stub.ts');
|
|
7
8
|
const reactStubPath = path.resolve(__dirname, './bundle/react-stub.ts');
|
|
8
9
|
const jsxRuntimeStubPath = path.resolve(__dirname, './bundle/jsx-runtime-stub.ts');
|
|
9
10
|
|
|
11
|
+
// The `projectRoot` won't be included by default, since we alter it to be `__dirname`
|
|
12
|
+
// to bundle from `expo-widgets` as the main module
|
|
13
|
+
// NOTE: We check the `watchFolders` to start with `projectRoot`, since `expo/metro-config`
|
|
14
|
+
// might add folders if we're in a monorepo
|
|
15
|
+
const watchFolders = config.watchFolders;
|
|
16
|
+
if (!watchFolders.some((entry) => !entry.startsWith(projectRoot))) {
|
|
17
|
+
watchFolders.push(projectRoot);
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
const buildConfig = {
|
|
11
21
|
...config,
|
|
12
|
-
projectRoot: __dirname,
|
|
13
|
-
watchFolders
|
|
14
|
-
...config.watchFolders,
|
|
15
|
-
__dirname,
|
|
16
|
-
],
|
|
22
|
+
projectRoot: __dirname, // Override root to be expo-widgets
|
|
23
|
+
watchFolders,
|
|
17
24
|
resolver: {
|
|
18
25
|
...config.resolver,
|
|
19
26
|
resolveRequest(context, moduleName, platform) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-widgets",
|
|
3
|
-
"version": "55.0.
|
|
3
|
+
"version": "55.0.2",
|
|
4
4
|
"description": "Widgets.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -32,10 +32,8 @@
|
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/widgets/",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@expo/config-plugins": "~55.0.6",
|
|
36
|
-
"@expo/config-types": "^55.0.5",
|
|
37
35
|
"@expo/plist": "^0.5.2",
|
|
38
|
-
"@expo/ui": "55.0.1"
|
|
36
|
+
"@expo/ui": "~55.0.1"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
39
|
"expo-module-scripts": "^55.0.2"
|
|
@@ -44,5 +42,5 @@
|
|
|
44
42
|
"expo": "*",
|
|
45
43
|
"react": "*"
|
|
46
44
|
},
|
|
47
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "413b0450434d3e456eb391eca792ee9ac1e1efec"
|
|
48
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const config_plugins_1 = require("
|
|
3
|
+
const config_plugins_1 = require("expo/config-plugins");
|
|
4
4
|
// Hack to display the warning only once
|
|
5
5
|
const withIosWarning = (config, { property, warning }) => (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
6
6
|
config_plugins_1.WarningAggregator.addWarningIOS(property, warning);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExpoConfig } from 'expo/config';
|
|
2
|
+
import { ConfigPlugin, WarningAggregator, withInfoPlist } from 'expo/config-plugins';
|
|
3
3
|
|
|
4
4
|
type WithIosWarningProps = { property: string; warning: string };
|
|
5
5
|
|
package/src/Widgets.ts
CHANGED
|
@@ -80,9 +80,30 @@ export class LiveActivity<T extends object = object> {
|
|
|
80
80
|
/**
|
|
81
81
|
* Ends the Live Activity.
|
|
82
82
|
* @param dismissalPolicy Controls when the Live Activity is removed from the Lock Screen after ending.
|
|
83
|
+
* Can be `'default'`, `'immediate'`, or `after(date)`.
|
|
84
|
+
* @param props Final content properties to update after the activity ends.
|
|
85
|
+
* @param contentDate The time the data in the payload was generated. If this is older than a previous update or push payload, the system ignores this update.
|
|
83
86
|
*/
|
|
84
|
-
end(dismissalPolicy?: LiveActivityDismissalPolicy): Promise<void> {
|
|
85
|
-
|
|
87
|
+
end(dismissalPolicy?: LiveActivityDismissalPolicy, props?: T, contentDate?: Date): Promise<void> {
|
|
88
|
+
const serializedProps = props ? JSON.stringify(props) : undefined;
|
|
89
|
+
if (
|
|
90
|
+
typeof dismissalPolicy === 'object' &&
|
|
91
|
+
dismissalPolicy !== null &&
|
|
92
|
+
'after' in dismissalPolicy
|
|
93
|
+
) {
|
|
94
|
+
return this.nativeLiveActivity.end(
|
|
95
|
+
'after',
|
|
96
|
+
dismissalPolicy.after?.getTime(),
|
|
97
|
+
serializedProps,
|
|
98
|
+
contentDate?.getTime()
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return this.nativeLiveActivity.end(
|
|
102
|
+
dismissalPolicy,
|
|
103
|
+
undefined,
|
|
104
|
+
serializedProps,
|
|
105
|
+
contentDate?.getTime()
|
|
106
|
+
);
|
|
86
107
|
}
|
|
87
108
|
|
|
88
109
|
/**
|
|
@@ -137,6 +158,15 @@ export class LiveActivityFactory<T extends object = object> {
|
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Creates a dismissal policy that removes the Live Activity at the specified time within a four-hour window.
|
|
163
|
+
* @param date The date after which the Live Activity should be removed from the Lock Screen.
|
|
164
|
+
* @hidden
|
|
165
|
+
*/
|
|
166
|
+
export function after(date: Date): { after: Date } {
|
|
167
|
+
return { after: date };
|
|
168
|
+
}
|
|
169
|
+
|
|
140
170
|
/**
|
|
141
171
|
* Creates a Widget instance.
|
|
142
172
|
* @param name The widget name. Must match the `'name'` field in your widget configuration in the app config.
|
package/src/Widgets.types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SharedObject } from 'expo';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
+
import { after } from './Widgets';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* The widget family (size).
|
|
6
8
|
* - `systemSmall` - Small square widget (2x2 grid).
|
|
@@ -145,8 +147,11 @@ export type PushToStartTokenEvent = {
|
|
|
145
147
|
|
|
146
148
|
/**
|
|
147
149
|
* Dismissal policy for ending a live activity.
|
|
150
|
+
* - `'default'` - The systemβs default dismissal policy for the Live Activity.
|
|
151
|
+
* - `'immediate'` - The system immediately removes the Live Activity that ended.
|
|
152
|
+
* - `after(date)` - The system removes the Live Activity that ended at the specified time within a four-hour window.
|
|
148
153
|
*/
|
|
149
|
-
export type LiveActivityDismissalPolicy = 'default' | 'immediate'
|
|
154
|
+
export type LiveActivityDismissalPolicy = 'default' | 'immediate' | ReturnType<typeof after>;
|
|
150
155
|
|
|
151
156
|
export type ExpoWidgetsEvents = {
|
|
152
157
|
/**
|
|
@@ -184,6 +189,11 @@ export declare class NativeLiveActivityFactory extends SharedObject {
|
|
|
184
189
|
|
|
185
190
|
export declare class NativeLiveActivity extends SharedObject<LiveActivityEvents> {
|
|
186
191
|
update(props: string): Promise<void>;
|
|
187
|
-
end(
|
|
192
|
+
end(
|
|
193
|
+
dismissalPolicy?: string,
|
|
194
|
+
afterDate?: number,
|
|
195
|
+
state?: string,
|
|
196
|
+
contentDate?: number
|
|
197
|
+
): Promise<void>;
|
|
188
198
|
getPushToken(): Promise<string | null>;
|
|
189
199
|
}
|