expo-widgets 58.0.15 → 58.0.17
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 +21 -0
- package/android/build.gradle +7 -2
- package/android/proguard-rules.pro +7 -0
- package/android/src/main/AndroidManifest.xml +6 -1
- package/android/src/main/java/expo/modules/widgets/ExpoWidgetEmittableTree.kt +7 -7
- package/android/src/main/java/expo/modules/widgets/ExpoWidgetsPeekWidget.kt +1 -1
- package/android/src/main/java/expo/modules/widgets/WidgetInteractionAction.kt +34 -4
- package/android/src/main/java/expo/modules/widgets/WidgetsEvents.kt +8 -4
- package/android/src/main/java/expo/modules/widgets/WidgetsModule.kt +45 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotification.kt +28 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotificationBuilder.kt +116 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotificationExceptions.kt +50 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotificationFactory.kt +36 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotificationOptions.kt +86 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotificationRenderer.kt +44 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotificationState.kt +65 -0
- package/android/src/main/java/expo/modules/widgets/notifications/CustomNotifications.kt +107 -0
- package/android/src/main/java/expo/modules/widgets/notifications/ExpoWidgetsNotificationReceiver.kt +67 -0
- package/android/src/main/res/values/expo_widgets_notifications.xml +4 -0
- package/build/CustomNotifications.d.ts +128 -0
- package/build/CustomNotifications.js +162 -0
- package/build/CustomNotifications.js.map +1 -0
- package/build/CustomNotifications.types.d.ts +124 -0
- package/build/CustomNotifications.types.js +3 -0
- package/build/CustomNotifications.types.js.map +1 -0
- package/build/ExpoWidgets.d.ts +3 -0
- package/build/ExpoWidgets.js +26 -0
- package/build/ExpoWidgets.js.map +1 -1
- package/build/ExpoWidgets.native.d.ts +5 -0
- package/build/ExpoWidgets.native.js.map +1 -1
- package/build/Widgets.d.ts +14 -0
- package/build/Widgets.js +14 -0
- package/build/Widgets.js.map +1 -1
- package/build/Widgets.types.d.ts +24 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/bundle/decorator.ts +13 -0
- package/bundle/index.ts +19 -2
- package/bundle/layout-registry-stub.ts +19 -0
- package/ios/ExpoWidgets.podspec +5 -7
- package/ios/Widgets/EntryView.swift +17 -1
- package/ios/Widgets/RedBoxView.swift +16 -0
- package/layout-registry.metro.config.js +9 -2
- package/package.json +4 -4
- package/plugin/build/android/withAndroidNotificationPermission.d.ts +6 -0
- package/plugin/build/android/withAndroidNotificationPermission.js +31 -0
- package/plugin/build/android/withAndroidNotificationPermission.js.map +1 -0
- package/plugin/build/android/withAndroidWidgets.d.ts +4 -2
- package/plugin/build/android/withAndroidWidgets.js +6 -1
- package/plugin/build/android/withAndroidWidgets.js.map +1 -1
- package/plugin/build/ios/withWidgetSourceFiles.js +1 -1
- package/plugin/build/withWidgets.js +1 -0
- package/plugin/build/withWidgets.js.map +1 -1
- package/plugin/src/android/withAndroidNotificationPermission.ts +22 -0
- package/plugin/src/android/withAndroidWidgets.ts +11 -1
- package/plugin/src/ios/withWidgetSourceFiles.ts +1 -1
- package/plugin/src/withWidgets.ts +2 -2
- package/src/CustomNotifications.ts +213 -0
- package/src/CustomNotifications.types.ts +138 -0
- package/src/ExpoWidgets.native.ts +8 -0
- package/src/ExpoWidgets.ts +41 -0
- package/src/Widgets.ts +14 -0
- package/src/Widgets.types.ts +24 -0
- package/src/index.ts +8 -0
package/build/ExpoWidgets.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EventSubscription } from 'expo';
|
|
2
|
+
import type { NativeCustomNotification, NativeCustomNotificationFactory } from './CustomNotifications.types';
|
|
2
3
|
import type { ExpoWidgetsEvents, NativeLiveActivity, NativeLiveActivityFactory, NativeWidgetObject } from './Widgets.types';
|
|
3
4
|
declare const ExpoWidgetsModule: {
|
|
4
5
|
widgetsDirectory: string;
|
|
@@ -6,6 +7,8 @@ declare const ExpoWidgetsModule: {
|
|
|
6
7
|
Widget: typeof NativeWidgetObject;
|
|
7
8
|
LiveActivityFactory: typeof NativeLiveActivityFactory;
|
|
8
9
|
LiveActivity: typeof NativeLiveActivity;
|
|
10
|
+
CustomNotificationFactory: typeof NativeCustomNotificationFactory;
|
|
11
|
+
CustomNotification: typeof NativeCustomNotification;
|
|
9
12
|
addListener<EventName extends keyof ExpoWidgetsEvents>(_eventName: EventName, _listener: ExpoWidgetsEvents[EventName]): EventSubscription;
|
|
10
13
|
};
|
|
11
14
|
export default ExpoWidgetsModule;
|
package/build/ExpoWidgets.js
CHANGED
|
@@ -35,12 +35,38 @@ class LiveActivityFactoryStub {
|
|
|
35
35
|
return [];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
class CustomNotificationStub {
|
|
39
|
+
getId() {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
async getProps() {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
async update(_props, _options) {}
|
|
46
|
+
async cancel() {}
|
|
47
|
+
}
|
|
48
|
+
class CustomNotificationFactoryStub {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
50
|
+
constructor(_name, _layout){}
|
|
51
|
+
async post(_id, _props, _options) {
|
|
52
|
+
return new CustomNotificationStub();
|
|
53
|
+
}
|
|
54
|
+
async get(_id) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
async getActive() {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
async cancelAll() {}
|
|
61
|
+
}
|
|
38
62
|
const ExpoWidgetsModule = {
|
|
39
63
|
widgetsDirectory: '',
|
|
40
64
|
reloadAllWidgets () {},
|
|
41
65
|
Widget: WidgetStub,
|
|
42
66
|
LiveActivityFactory: LiveActivityFactoryStub,
|
|
43
67
|
LiveActivity: LiveActivityStub,
|
|
68
|
+
CustomNotificationFactory: CustomNotificationFactoryStub,
|
|
69
|
+
CustomNotification: CustomNotificationStub,
|
|
44
70
|
addListener (_eventName, _listener) {
|
|
45
71
|
return noopSubscription;
|
|
46
72
|
}
|
package/build/ExpoWidgets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ExpoWidgets.ts"],"sourcesContent":[null],"names":["noopSubscription","remove","WidgetStub","_name","_layout","_initialProps","reload","updateSnapshot","_props","updateTimeline","_entries","getTimeline","setConfigurationParameterEnum","_parameterName","_options","LiveActivityStub","getId","update","end","_dismissalPolicy","_afterDate","_state","_contentDate","getPushToken","addListener","_eventName","_listener","LiveActivityFactoryStub","start","_url","getInstances","ExpoWidgetsModule","widgetsDirectory","reloadAllWidgets","Widget","LiveActivityFactory","LiveActivity"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["ExpoWidgets.ts"],"sourcesContent":[null],"names":["noopSubscription","remove","WidgetStub","_name","_layout","_initialProps","reload","updateSnapshot","_props","updateTimeline","_entries","getTimeline","setConfigurationParameterEnum","_parameterName","_options","LiveActivityStub","getId","update","end","_dismissalPolicy","_afterDate","_state","_contentDate","getPushToken","addListener","_eventName","_listener","LiveActivityFactoryStub","start","_url","getInstances","CustomNotificationStub","getProps","cancel","CustomNotificationFactoryStub","post","_id","get","getActive","cancelAll","ExpoWidgetsModule","widgetsDirectory","reloadAllWidgets","Widget","LiveActivityFactory","LiveActivity","CustomNotificationFactory","CustomNotification"],"mappings":"AAgBA,MAAMA,mBAAsC;IAAEC,WAAU;AAAE;AAE1D,MAAMC;IACJ,qEAAqE;IACrE,YAAYC,KAAa,EAAEC,OAAe,EAAEC,aAAmC,CAAE,CAAC;IAClFC,SAAe,CAAC;IAChBC,eAAeC,MAA2B,EAAQ,CAAC;IACnDC,eAAeC,QAA6B,EAAQ,CAAC;IACrD,MAAMC,cAA4C;QAChD,OAAO,EAAE;IACX;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 'expo';
|
|
2
|
+
import type { NativeCustomNotification, NativeCustomNotificationFactory } from './CustomNotifications.types';
|
|
2
3
|
import type { ExpoWidgetsEvents, NativeLiveActivity, NativeLiveActivityFactory, NativeWidgetObject } from './Widgets.types';
|
|
3
4
|
declare class ExpoWidgetsModule extends NativeModule<ExpoWidgetsEvents> {
|
|
4
5
|
widgetsDirectory: string;
|
|
5
6
|
reloadAllWidgets(): void;
|
|
6
7
|
readonly Widget: typeof NativeWidgetObject;
|
|
8
|
+
/** iOS only. */
|
|
7
9
|
readonly LiveActivityFactory: typeof NativeLiveActivityFactory;
|
|
8
10
|
readonly LiveActivity: typeof NativeLiveActivity;
|
|
11
|
+
/** Android only. */
|
|
12
|
+
readonly CustomNotificationFactory: typeof NativeCustomNotificationFactory;
|
|
13
|
+
readonly CustomNotification: typeof NativeCustomNotification;
|
|
9
14
|
}
|
|
10
15
|
declare const _default: ExpoWidgetsModule;
|
|
11
16
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ExpoWidgets.native.ts"],"sourcesContent":[null],"names":["NativeModule","requireNativeModule"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mBAAmB,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"sources":["ExpoWidgets.native.ts"],"sourcesContent":[null],"names":["NativeModule","requireNativeModule"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mBAAmB,QAAQ,OAAO;AAyBzD,eAAeA,oBAAuC,eAAe"}
|
package/build/Widgets.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class Widget<PropsType extends object = object, ConfigurationType
|
|
|
14
14
|
/**
|
|
15
15
|
* Schedules a series of updates for the widget's content and reloads the widget.
|
|
16
16
|
* @param entries Timeline entries, each specifying a date and the props to display at that time.
|
|
17
|
+
* @platform ios
|
|
17
18
|
*/
|
|
18
19
|
updateTimeline(entries: WidgetTimelineEntry<PropsType>[]): void;
|
|
19
20
|
/**
|
|
@@ -23,16 +24,19 @@ export declare class Widget<PropsType extends object = object, ConfigurationType
|
|
|
23
24
|
updateSnapshot(props: PropsType): void;
|
|
24
25
|
/**
|
|
25
26
|
* Returns the current timeline entries for the widget, including past and future entries.
|
|
27
|
+
* @platform ios
|
|
26
28
|
*/
|
|
27
29
|
getTimeline(): Promise<WidgetTimelineEntry<PropsType>[]>;
|
|
28
30
|
/**
|
|
29
31
|
* Replaces the runtime options for a dynamic enum configuration parameter.
|
|
30
32
|
* The app config values remain the fallback when no runtime options are set.
|
|
33
|
+
* @platform ios
|
|
31
34
|
*/
|
|
32
35
|
setConfigurationParameterEnum(parameterName: keyof ConfigurationType & string, options?: WidgetConfigurationEnum[]): void;
|
|
33
36
|
}
|
|
34
37
|
/**
|
|
35
38
|
* Represents a Live Activity instance. Provides methods to update its content and end it.
|
|
39
|
+
* @platform ios
|
|
36
40
|
*/
|
|
37
41
|
export declare class LiveActivity<T extends object = object> {
|
|
38
42
|
/** @hidden */
|
|
@@ -40,12 +44,14 @@ export declare class LiveActivity<T extends object = object> {
|
|
|
40
44
|
constructor(nativeLiveActivity: NativeLiveActivity);
|
|
41
45
|
/**
|
|
42
46
|
* Returns the stable ActivityKit identifier for this Live Activity.
|
|
47
|
+
* @platform ios
|
|
43
48
|
*/
|
|
44
49
|
getId(): string;
|
|
45
50
|
/**
|
|
46
51
|
* Updates the Live Activity's content. The UI reflects the new properties immediately.
|
|
47
52
|
* @param props The updated content properties.
|
|
48
53
|
* @param staleDate When set, the system may de-emphasize the activity after this date if content has not been refreshed.
|
|
54
|
+
* @platform ios
|
|
49
55
|
*/
|
|
50
56
|
update(props: T, staleDate?: Date): Promise<void>;
|
|
51
57
|
/**
|
|
@@ -54,11 +60,13 @@ export declare class LiveActivity<T extends object = object> {
|
|
|
54
60
|
* Can be `'default'`, `'immediate'`, or `after(date)`.
|
|
55
61
|
* @param props Final content properties to update after the activity ends.
|
|
56
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.
|
|
63
|
+
* @platform ios
|
|
57
64
|
*/
|
|
58
65
|
end(dismissalPolicy?: LiveActivityDismissalPolicy, props?: T, contentDate?: Date): Promise<void>;
|
|
59
66
|
/**
|
|
60
67
|
* Returns the push token for this Live Activity, used to send push notification updates via APNs.
|
|
61
68
|
* Returns `null` if push notifications are not enabled or the token is not yet available.
|
|
69
|
+
* @platform ios
|
|
62
70
|
*/
|
|
63
71
|
getPushToken(): Promise<string | null>;
|
|
64
72
|
/**
|
|
@@ -66,11 +74,13 @@ export declare class LiveActivity<T extends object = object> {
|
|
|
66
74
|
* The token can be used to send content updates to this specific activity via APNs.
|
|
67
75
|
* @param listener Callback invoked when a new push token is available.
|
|
68
76
|
* @returns An event subscription that can be used to remove the listener.
|
|
77
|
+
* @platform ios
|
|
69
78
|
*/
|
|
70
79
|
addPushTokenListener(listener: (event: PushTokenEvent) => void): EventSubscription;
|
|
71
80
|
}
|
|
72
81
|
/**
|
|
73
82
|
* Manages Live Activity instances of a specific type. Use it to start new activities and retrieve currently active ones.
|
|
83
|
+
* @platform ios
|
|
74
84
|
*/
|
|
75
85
|
export declare class LiveActivityFactory<T extends object = object> {
|
|
76
86
|
/** @hidden */
|
|
@@ -82,10 +92,12 @@ export declare class LiveActivityFactory<T extends object = object> {
|
|
|
82
92
|
* @param url An optional URL to associate with the Live Activity, used for deep linking.
|
|
83
93
|
* @param staleDate When set, the system may de-emphasize the activity after this date if content has not been refreshed.
|
|
84
94
|
* @returns The new Live Activity instance.
|
|
95
|
+
* @platform ios
|
|
85
96
|
*/
|
|
86
97
|
start(props: T, url?: string, staleDate?: Date): LiveActivity<T>;
|
|
87
98
|
/**
|
|
88
99
|
* Returns all currently active instances of this Live Activity type.
|
|
100
|
+
* @platform ios
|
|
89
101
|
*/
|
|
90
102
|
getInstances(): LiveActivity<T>[];
|
|
91
103
|
}
|
|
@@ -108,6 +120,7 @@ export declare function createWidget<PropsType extends object = object, Configur
|
|
|
108
120
|
* Creates a Live Activity Factory for managing Live Activities of a specific type.
|
|
109
121
|
* @param name The Live Activity name. Must match the `'name'` field in your widget configuration in the app config.
|
|
110
122
|
* @param liveActivity The Live Activity component, marked with the `'widget'` directive.
|
|
123
|
+
* @platform ios
|
|
111
124
|
*/
|
|
112
125
|
export declare function createLiveActivity<T extends object = object>(name: string, liveActivity: LiveActivityComponent<T>): LiveActivityFactory<T>;
|
|
113
126
|
/**
|
|
@@ -121,6 +134,7 @@ export declare function addUserInteractionListener(listener: ExpoWidgetsEvents['
|
|
|
121
134
|
* This token can be used to start live activities remotely via APNs.
|
|
122
135
|
* @param listener Callback function to handle push-to-start token events.
|
|
123
136
|
* @return An event subscription that can be used to remove the listener.
|
|
137
|
+
* @platform ios
|
|
124
138
|
*/
|
|
125
139
|
export declare function addPushToStartTokenListener(listener: ExpoWidgetsEvents['onExpoWidgetsPushToStartTokenReceived']): EventSubscription;
|
|
126
140
|
/**
|
package/build/Widgets.js
CHANGED
|
@@ -15,6 +15,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
15
15
|
/**
|
|
16
16
|
* Schedules a series of updates for the widget's content and reloads the widget.
|
|
17
17
|
* @param entries Timeline entries, each specifying a date and the props to display at that time.
|
|
18
|
+
* @platform ios
|
|
18
19
|
*/ updateTimeline(entries) {
|
|
19
20
|
if (Platform.OS === 'android') {
|
|
20
21
|
return;
|
|
@@ -41,6 +42,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Returns the current timeline entries for the widget, including past and future entries.
|
|
45
|
+
* @platform ios
|
|
44
46
|
*/ async getTimeline() {
|
|
45
47
|
return (await this.nativeWidgetObject.getTimeline()).map((entry)=>({
|
|
46
48
|
date: new Date(entry.timestamp),
|
|
@@ -50,12 +52,14 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
50
52
|
/**
|
|
51
53
|
* Replaces the runtime options for a dynamic enum configuration parameter.
|
|
52
54
|
* The app config values remain the fallback when no runtime options are set.
|
|
55
|
+
* @platform ios
|
|
53
56
|
*/ setConfigurationParameterEnum(parameterName, options) {
|
|
54
57
|
this.nativeWidgetObject.setConfigurationParameterEnum(parameterName, options);
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
/**
|
|
58
61
|
* Represents a Live Activity instance. Provides methods to update its content and end it.
|
|
62
|
+
* @platform ios
|
|
59
63
|
*/ export class LiveActivity {
|
|
60
64
|
/** @hidden */ nativeLiveActivity;
|
|
61
65
|
constructor(nativeLiveActivity){
|
|
@@ -63,6 +67,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* Returns the stable ActivityKit identifier for this Live Activity.
|
|
70
|
+
* @platform ios
|
|
66
71
|
*/ getId() {
|
|
67
72
|
return this.nativeLiveActivity.getId();
|
|
68
73
|
}
|
|
@@ -70,6 +75,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
70
75
|
* Updates the Live Activity's content. The UI reflects the new properties immediately.
|
|
71
76
|
* @param props The updated content properties.
|
|
72
77
|
* @param staleDate When set, the system may de-emphasize the activity after this date if content has not been refreshed.
|
|
78
|
+
* @platform ios
|
|
73
79
|
*/ update(props, staleDate) {
|
|
74
80
|
return this.nativeLiveActivity.update(JSON.stringify(props), staleDate?.getTime());
|
|
75
81
|
}
|
|
@@ -79,6 +85,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
79
85
|
* Can be `'default'`, `'immediate'`, or `after(date)`.
|
|
80
86
|
* @param props Final content properties to update after the activity ends.
|
|
81
87
|
* @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.
|
|
88
|
+
* @platform ios
|
|
82
89
|
*/ end(dismissalPolicy, props, contentDate) {
|
|
83
90
|
const serializedProps = props ? JSON.stringify(props) : undefined;
|
|
84
91
|
if (typeof dismissalPolicy === 'object' && dismissalPolicy !== null && 'after' in dismissalPolicy) {
|
|
@@ -89,6 +96,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
89
96
|
/**
|
|
90
97
|
* Returns the push token for this Live Activity, used to send push notification updates via APNs.
|
|
91
98
|
* Returns `null` if push notifications are not enabled or the token is not yet available.
|
|
99
|
+
* @platform ios
|
|
92
100
|
*/ getPushToken() {
|
|
93
101
|
return this.nativeLiveActivity.getPushToken();
|
|
94
102
|
}
|
|
@@ -97,12 +105,14 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
97
105
|
* The token can be used to send content updates to this specific activity via APNs.
|
|
98
106
|
* @param listener Callback invoked when a new push token is available.
|
|
99
107
|
* @returns An event subscription that can be used to remove the listener.
|
|
108
|
+
* @platform ios
|
|
100
109
|
*/ addPushTokenListener(listener) {
|
|
101
110
|
return this.nativeLiveActivity.addListener('onExpoWidgetsTokenReceived', listener);
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
113
|
/**
|
|
105
114
|
* Manages Live Activity instances of a specific type. Use it to start new activities and retrieve currently active ones.
|
|
115
|
+
* @platform ios
|
|
106
116
|
*/ export class LiveActivityFactory {
|
|
107
117
|
/** @hidden */ nativeLiveActivityFactory;
|
|
108
118
|
constructor(name, layout){
|
|
@@ -114,11 +124,13 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
114
124
|
* @param url An optional URL to associate with the Live Activity, used for deep linking.
|
|
115
125
|
* @param staleDate When set, the system may de-emphasize the activity after this date if content has not been refreshed.
|
|
116
126
|
* @returns The new Live Activity instance.
|
|
127
|
+
* @platform ios
|
|
117
128
|
*/ start(props, url, staleDate) {
|
|
118
129
|
return new LiveActivity(this.nativeLiveActivityFactory.start(JSON.stringify(props), url, staleDate?.getTime()));
|
|
119
130
|
}
|
|
120
131
|
/**
|
|
121
132
|
* Returns all currently active instances of this Live Activity type.
|
|
133
|
+
* @platform ios
|
|
122
134
|
*/ getInstances() {
|
|
123
135
|
return this.nativeLiveActivityFactory.getInstances().map((instance)=>new LiveActivity(instance));
|
|
124
136
|
}
|
|
@@ -144,6 +156,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
144
156
|
* Creates a Live Activity Factory for managing Live Activities of a specific type.
|
|
145
157
|
* @param name The Live Activity name. Must match the `'name'` field in your widget configuration in the app config.
|
|
146
158
|
* @param liveActivity The Live Activity component, marked with the `'widget'` directive.
|
|
159
|
+
* @platform ios
|
|
147
160
|
*/ export function createLiveActivity(name, liveActivity) {
|
|
148
161
|
return new LiveActivityFactory(name, liveActivity);
|
|
149
162
|
}
|
|
@@ -159,6 +172,7 @@ import ExpoWidgetsModule from './ExpoWidgets';
|
|
|
159
172
|
* This token can be used to start live activities remotely via APNs.
|
|
160
173
|
* @param listener Callback function to handle push-to-start token events.
|
|
161
174
|
* @return An event subscription that can be used to remove the listener.
|
|
175
|
+
* @platform ios
|
|
162
176
|
*/ export function addPushToStartTokenListener(listener) {
|
|
163
177
|
return ExpoWidgetsModule.addListener('onExpoWidgetsPushToStartTokenReceived', listener);
|
|
164
178
|
}
|
package/build/Widgets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Widgets.ts"],"sourcesContent":[null],"names":["Platform","ExpoWidgetsModule","Widget","nativeWidgetObject","name","layout","initialProps","reload","updateTimeline","entries","OS","map","entry","timestamp","date","getTime","props","updateSnapshot","Date","now","getTimeline","setConfigurationParameterEnum","parameterName","options","LiveActivity","nativeLiveActivity","getId","update","staleDate","JSON","stringify","end","dismissalPolicy","contentDate","serializedProps","undefined","after","getPushToken","addPushTokenListener","listener","addListener","LiveActivityFactory","nativeLiveActivityFactory","start","url","getInstances","instance","createWidget","widget","createLiveActivity","liveActivity","addUserInteractionListener","addPushToStartTokenListener","widgetsDirectory"],"mappings":"AACA,SAASA,QAAQ,QAAQ,eAAe;AAExC,OAAOC,uBAAuB,gBAAgB;AAc9C;;CAEC,GACD,OAAO,MAAMC;IAIX,YAAY,GACZ,AAAQC,mBAAuC;IAC/C,YACEC,IAAY,EACZC,MAGsB,EACtBC,YAAwB,CACxB;QACA,IAAI,CAACH,kBAAkB,GAAG,IAAIF,kBAAkBC,MAAM,CACpDE,MACAC,QACAC;IAEJ;IAEA;;GAEC,GACDC,SAAS;QACP,IAAI,CAACJ,kBAAkB,CAACI,MAAM;IAChC;IAEA
|
|
1
|
+
{"version":3,"sources":["Widgets.ts"],"sourcesContent":[null],"names":["Platform","ExpoWidgetsModule","Widget","nativeWidgetObject","name","layout","initialProps","reload","updateTimeline","entries","OS","map","entry","timestamp","date","getTime","props","updateSnapshot","Date","now","getTimeline","setConfigurationParameterEnum","parameterName","options","LiveActivity","nativeLiveActivity","getId","update","staleDate","JSON","stringify","end","dismissalPolicy","contentDate","serializedProps","undefined","after","getPushToken","addPushTokenListener","listener","addListener","LiveActivityFactory","nativeLiveActivityFactory","start","url","getInstances","instance","createWidget","widget","createLiveActivity","liveActivity","addUserInteractionListener","addPushToStartTokenListener","widgetsDirectory"],"mappings":"AACA,SAASA,QAAQ,QAAQ,eAAe;AAExC,OAAOC,uBAAuB,gBAAgB;AAc9C;;CAEC,GACD,OAAO,MAAMC;IAIX,YAAY,GACZ,AAAQC,mBAAuC;IAC/C,YACEC,IAAY,EACZC,MAGsB,EACtBC,YAAwB,CACxB;QACA,IAAI,CAACH,kBAAkB,GAAG,IAAIF,kBAAkBC,MAAM,CACpDE,MACAC,QACAC;IAEJ;IAEA;;GAEC,GACDC,SAAS;QACP,IAAI,CAACJ,kBAAkB,CAACI,MAAM;IAChC;IAEA;;;;GAIC,GACDC,eAAeC,OAAyC,EAAE;QACxD,IAAIT,SAASU,EAAE,KAAK,WAAW;YAC7B;QACF;QACA,IAAI,CAACP,kBAAkB,CAACK,cAAc,CACpCC,QAAQE,GAAG,CAAC,CAACC,QAAW,CAAA;gBAAEC,WAAWD,MAAME,IAAI,CAACC,OAAO;gBAAIC,OAAOJ,MAAMI,KAAK;YAAC,CAAA;IAElF;IAEA;;;GAGC,GACDC,eAAeD,KAAgB,EAAE;QAC/B,IAAIhB,SAASU,EAAE,KAAK,WAAW;YA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AAO,SAASa,4BACdb,QAAoE;IAEpE,OAAOtC,kBAAkBuC,WAAW,CAAC,yCAAyCD;AAChF;AAEA;;;CAGC,GACD,OAAO,MAAMc,mBAAmBpD,kBAAkBoD,gBAAgB,CAAC"}
|
package/build/Widgets.types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { after } from './Widgets';
|
|
|
6
6
|
* - `fullColor` — Home screen widgets (default).
|
|
7
7
|
* - `accented` — Tinted widgets (iOS 18+) and watchOS.
|
|
8
8
|
* - `vibrant` — Lock screen widgets.
|
|
9
|
+
* @platform ios
|
|
9
10
|
*/
|
|
10
11
|
export type WidgetRenderingMode = 'fullColor' | 'accented' | 'vibrant';
|
|
11
12
|
/**
|
|
@@ -88,9 +89,13 @@ export type WidgetEnvironment<T extends object | undefined = undefined> = {
|
|
|
88
89
|
*/
|
|
89
90
|
configuration: T;
|
|
90
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* @platform ios
|
|
94
|
+
*/
|
|
91
95
|
export type LiveActivityEnvironment = {
|
|
92
96
|
/**
|
|
93
97
|
* The color scheme of the activity's environment.
|
|
98
|
+
* @platform ios
|
|
94
99
|
*/
|
|
95
100
|
colorScheme: 'light' | 'dark';
|
|
96
101
|
/**
|
|
@@ -128,6 +133,9 @@ export type LiveActivityEnvironment = {
|
|
|
128
133
|
*/
|
|
129
134
|
levelOfDetail?: LevelOfDetail;
|
|
130
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* @platform ios
|
|
138
|
+
*/
|
|
131
139
|
export type WidgetTimelineEntry<T extends object = object> = {
|
|
132
140
|
/**
|
|
133
141
|
* Date when widget should update.
|
|
@@ -159,6 +167,7 @@ export type ExpoTimelineEntry = {
|
|
|
159
167
|
};
|
|
160
168
|
/**
|
|
161
169
|
* Defines the layout sections for an iOS Live Activity.
|
|
170
|
+
* @platform ios
|
|
162
171
|
*/
|
|
163
172
|
export type LiveActivityLayout = {
|
|
164
173
|
/**
|
|
@@ -200,6 +209,7 @@ export type LiveActivityLayout = {
|
|
|
200
209
|
};
|
|
201
210
|
/**
|
|
202
211
|
* A function that returns the layout for a Live Activity.
|
|
212
|
+
* @platform ios
|
|
203
213
|
*/
|
|
204
214
|
export type LiveActivityComponent<T extends object = object> = (props: T, environment: LiveActivityEnvironment) => LiveActivityLayout;
|
|
205
215
|
/**
|
|
@@ -214,6 +224,11 @@ export type UserInteractionEvent = {
|
|
|
214
224
|
* Button/toggle that was pressed.
|
|
215
225
|
*/
|
|
216
226
|
target: string;
|
|
227
|
+
/**
|
|
228
|
+
* The key of the custom notification that contains the button. Absent for widget interactions.
|
|
229
|
+
* @platform android
|
|
230
|
+
*/
|
|
231
|
+
notificationId?: string;
|
|
217
232
|
/**
|
|
218
233
|
* Timestamp of the event.
|
|
219
234
|
*/
|
|
@@ -225,6 +240,7 @@ export type UserInteractionEvent = {
|
|
|
225
240
|
};
|
|
226
241
|
/**
|
|
227
242
|
* Event emitted when a push token is received for a live activity.
|
|
243
|
+
* @platform ios
|
|
228
244
|
*/
|
|
229
245
|
export type PushTokenEvent = {
|
|
230
246
|
/**
|
|
@@ -238,6 +254,7 @@ export type PushTokenEvent = {
|
|
|
238
254
|
};
|
|
239
255
|
/**
|
|
240
256
|
* Event emitted when a push-to-start token is received.
|
|
257
|
+
* @platform ios
|
|
241
258
|
*/
|
|
242
259
|
export type PushToStartTokenEvent = {
|
|
243
260
|
/**
|
|
@@ -250,20 +267,27 @@ export type PushToStartTokenEvent = {
|
|
|
250
267
|
* - `'default'` - The system’s default dismissal policy for the Live Activity.
|
|
251
268
|
* - `'immediate'` - The system immediately removes the Live Activity that ended.
|
|
252
269
|
* - `after(date)` - The system removes the Live Activity that ended at the specified time within a four-hour window.
|
|
270
|
+
* @platform ios
|
|
253
271
|
*/
|
|
254
272
|
export type LiveActivityDismissalPolicy = 'default' | 'immediate' | ReturnType<typeof after>;
|
|
273
|
+
/** @hidden */
|
|
255
274
|
export type ExpoWidgetsEvents = {
|
|
256
275
|
/**
|
|
257
276
|
* Function that is invoked when user interacts with a widget.
|
|
258
277
|
* @param event Interaction event details.
|
|
278
|
+
* @platform ios
|
|
259
279
|
*/
|
|
260
280
|
onExpoWidgetsUserInteraction: (event: UserInteractionEvent) => void;
|
|
261
281
|
/**
|
|
262
282
|
* Function that is invoked when a push-to-start token is received.
|
|
263
283
|
* @param event Token event details.
|
|
284
|
+
* @platform ios
|
|
264
285
|
*/
|
|
265
286
|
onExpoWidgetsPushToStartTokenReceived: (event: PushToStartTokenEvent) => void;
|
|
266
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* @platform ios
|
|
290
|
+
*/
|
|
267
291
|
export type LiveActivityEvents = {
|
|
268
292
|
/**
|
|
269
293
|
* Function that is invoked when a push token is received for a live activity.
|
package/build/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export * from './CustomNotifications';
|
|
2
|
+
export type { CustomNotificationComponent, CustomNotificationEnvironment, CustomNotificationLayout, CustomNotificationOptions, CustomNotificationUpdateOptions, } from './CustomNotifications.types';
|
|
1
3
|
export * from './Widgets';
|
|
2
4
|
export type { ExpoWidgetsEvents, LevelOfDetail, LiveActivityComponent, LiveActivityDismissalPolicy, LiveActivityEnvironment, LiveActivityEvents, LiveActivityLayout, PushTokenEvent, PushToStartTokenEvent, UserInteractionEvent, WidgetConfigurationEnum, WidgetEnvironment, WidgetFamily, WidgetRenderingMode, WidgetTimelineEntry, } from './Widgets.types';
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,cAAc,YAAY"}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,cAAc,wBAAwB;AAQtC,cAAc,YAAY"}
|
package/bundle/decorator.ts
CHANGED
|
@@ -32,6 +32,15 @@ function decorateNode(
|
|
|
32
32
|
return node.map((child) => decorateNode(child, context));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
if (isSectionMap(node)) {
|
|
36
|
+
return Object.fromEntries(
|
|
37
|
+
Object.entries(node).map(([section, child]) => [
|
|
38
|
+
section,
|
|
39
|
+
decorateNode(child, { ...context, nearestParentKey: section }),
|
|
40
|
+
])
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
if (!isReactElementNode(node)) {
|
|
36
45
|
return node;
|
|
37
46
|
}
|
|
@@ -58,6 +67,10 @@ function isReactElementNode(node: unknown): node is ReactElementNode {
|
|
|
58
67
|
return Boolean(node) && typeof node === 'object' && 'type' in node && 'props' in node;
|
|
59
68
|
}
|
|
60
69
|
|
|
70
|
+
function isSectionMap(node: unknown): node is Record<string, unknown> {
|
|
71
|
+
return Boolean(node) && typeof node === 'object' && !isReactElementNode(node);
|
|
72
|
+
}
|
|
73
|
+
|
|
61
74
|
function buildButtonTargetId(index: number, parentKey: string | null) {
|
|
62
75
|
const baseTarget = `__expo_widgets_target_${index}`;
|
|
63
76
|
|
package/bundle/index.ts
CHANGED
|
@@ -48,9 +48,16 @@ function normalizeWidgetTree(node: unknown, position: string | number = 0): unkn
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
if (node && typeof node === 'object') {
|
|
51
|
-
// Live
|
|
51
|
+
// Live Activities and notifications return section maps. Native renderers need each root
|
|
52
|
+
// to be an element, even when a section returns an array of children.
|
|
52
53
|
return Object.fromEntries(
|
|
53
|
-
Object.entries(node).map(([section, child]) => [
|
|
54
|
+
Object.entries(node).map(([section, child]) => [
|
|
55
|
+
section,
|
|
56
|
+
normalizeWidgetTree(
|
|
57
|
+
Array.isArray(child) ? jsxRuntime.jsx(React.Fragment, { children: child }) : child,
|
|
58
|
+
section
|
|
59
|
+
),
|
|
60
|
+
])
|
|
54
61
|
);
|
|
55
62
|
}
|
|
56
63
|
return node;
|
|
@@ -77,6 +84,16 @@ const __expoWidgetHandlePress = function (
|
|
|
77
84
|
const { target, ...renderEnvironment } = environment;
|
|
78
85
|
|
|
79
86
|
function findAndCallOnPress(node?: Dictionary): Dictionary | undefined {
|
|
87
|
+
if (node && typeof node === 'object' && !('type' in node)) {
|
|
88
|
+
for (const section of Object.values(node)) {
|
|
89
|
+
const result = findAndCallOnPress(section as Dictionary);
|
|
90
|
+
if (result) {
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
const props = node?.props as {
|
|
81
98
|
onButtonPress?: () => Dictionary;
|
|
82
99
|
onButtonPressed?: () => Dictionary;
|
|
@@ -33,6 +33,25 @@ export function createLiveActivity() {
|
|
|
33
33
|
return noopLiveActivityFactory;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
const noopCustomNotificationFactory = {
|
|
37
|
+
post() {
|
|
38
|
+
return Promise.resolve({});
|
|
39
|
+
},
|
|
40
|
+
get() {
|
|
41
|
+
return Promise.resolve(null);
|
|
42
|
+
},
|
|
43
|
+
getActive() {
|
|
44
|
+
return Promise.resolve([]);
|
|
45
|
+
},
|
|
46
|
+
cancelAll() {
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function createCustomNotification() {
|
|
52
|
+
return noopCustomNotificationFactory;
|
|
53
|
+
}
|
|
54
|
+
|
|
36
55
|
export function addUserInteractionListener() {
|
|
37
56
|
return { remove() {} };
|
|
38
57
|
}
|
package/ios/ExpoWidgets.podspec
CHANGED
|
@@ -36,12 +36,9 @@ Pod::Spec.new do |s|
|
|
|
36
36
|
:name => 'Build ExpoWidgets Bundle',
|
|
37
37
|
:script => project_root_env_var + 'bash -l -c "\"$PODS_TARGET_SRCROOT/../scripts/xcode-build-bundle.sh\""',
|
|
38
38
|
:execution_position => :before_compile,
|
|
39
|
-
# NOTE
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"#{__dir__}/../bundle/build/ExpoWidgets.bundle",
|
|
43
|
-
"#{__dir__}/../bundle/build/ExpoWidgetsLayoutRegistry.json",
|
|
44
|
-
],
|
|
39
|
+
# NOTE: The bundle depends on JS sources that Xcode cannot track through input files (this
|
|
40
|
+
# package, `@expo/ui`, and the app's own widget layouts), so the phase declares no inputs or
|
|
41
|
+
# outputs.
|
|
45
42
|
}
|
|
46
43
|
copy_bundle_script = {
|
|
47
44
|
:name => 'Prepare ExpoWidgets Resources',
|
|
@@ -64,7 +61,8 @@ Pod::Spec.new do |s|
|
|
|
64
61
|
}
|
|
65
62
|
# :always_out_of_date is only available in CocoaPods 1.13.0 and later
|
|
66
63
|
if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.13.0')
|
|
67
|
-
# always run the
|
|
64
|
+
# always run the scripts without warning
|
|
65
|
+
build_bundle_script[:always_out_of_date] = "1"
|
|
68
66
|
copy_bundle_script[:always_out_of_date] = "1"
|
|
69
67
|
end
|
|
70
68
|
s.script_phases = [build_bundle_script, copy_bundle_script]
|
|
@@ -29,7 +29,23 @@ public struct WidgetsEntryView: View {
|
|
|
29
29
|
let node = evaluateLayout(layout: layout, props: entry.props, environment: widgetEnvironment)
|
|
30
30
|
WidgetsDynamicView(name: entry.name, kind: .widget, node: node, entryIndex: entry.entryIndex, environmentString: widgetEnvironmentString)
|
|
31
31
|
} else {
|
|
32
|
-
|
|
32
|
+
// No layout is stored until the app has run once after install or
|
|
33
|
+
// update. That's an expected state, not an error, so show a neutral,
|
|
34
|
+
// system-themed empty widget instead of the red box.
|
|
35
|
+
EmptyWidgetView()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Also used by the generated configurable widgets (withWidgetSourceFiles).
|
|
41
|
+
public struct EmptyWidgetView: View {
|
|
42
|
+
public init() {}
|
|
43
|
+
|
|
44
|
+
public var body: some View {
|
|
45
|
+
if #available(iOS 17.0, *) {
|
|
46
|
+
Color.clear.containerBackground(.fill.tertiary, for: .widget)
|
|
47
|
+
} else {
|
|
48
|
+
Color.clear
|
|
33
49
|
}
|
|
34
50
|
}
|
|
35
51
|
}
|
|
@@ -49,6 +49,22 @@ public struct RedBoxView: ExpoSwiftUI.View {
|
|
|
49
49
|
.padding(12)
|
|
50
50
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
51
51
|
}
|
|
52
|
+
.modifier(RedBoxContainerBackground(kind: props.kind))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// On iOS 17+, WidgetKit replaces any widget without a container background with
|
|
57
|
+
// its "Please adopt containerBackground API" placeholder, which would hide the error.
|
|
58
|
+
private struct RedBoxContainerBackground: ViewModifier {
|
|
59
|
+
let kind: WidgetsKind
|
|
60
|
+
|
|
61
|
+
@ViewBuilder
|
|
62
|
+
func body(content: Content) -> some View {
|
|
63
|
+
if #available(iOS 17.0, *), kind == .widget {
|
|
64
|
+
content.containerBackground(Color.red, for: .widget)
|
|
65
|
+
} else {
|
|
66
|
+
content
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
}
|
|
54
70
|
|
|
@@ -5,12 +5,19 @@ const baseResolveRequest = config.resolver.resolveRequest;
|
|
|
5
5
|
const expoWidgetsStubPath = path.join(__dirname, 'bundle/layout-registry-stub.ts');
|
|
6
6
|
const asyncRequireStubPath = path.join(__dirname, 'bundle/async-require-stub.ts');
|
|
7
7
|
// const emptyModuleStubPath = path.join(__dirname, 'bundle/empty-module-stub.js');
|
|
8
|
-
const
|
|
8
|
+
const relativeFileSpecifierRe = /^\.\.?(?:$|[\\/])/;
|
|
9
|
+
|
|
10
|
+
// Metro also resolves its own absolute paths (e.g. the empty module) through `resolveRequest`.
|
|
11
|
+
// `path.win32.isAbsolute` covers POSIX paths as well as Windows drive letter (`D:\`) and UNC paths,
|
|
12
|
+
// which would otherwise be stubbed as empty modules and make Metro recurse until the stack overflows.
|
|
13
|
+
function isFileSpecifier(moduleName) {
|
|
14
|
+
return path.win32.isAbsolute(moduleName) || relativeFileSpecifierRe.test(moduleName);
|
|
15
|
+
}
|
|
9
16
|
|
|
10
17
|
config.resolver = {
|
|
11
18
|
...config.resolver,
|
|
12
19
|
resolveRequest(context, moduleName, platform) {
|
|
13
|
-
if (
|
|
20
|
+
if (isFileSpecifier(moduleName)) {
|
|
14
21
|
return baseResolveRequest(context, moduleName, platform);
|
|
15
22
|
}
|
|
16
23
|
if (moduleName === 'expo-widgets') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-widgets",
|
|
3
|
-
"version": "58.0.
|
|
3
|
+
"version": "58.0.17",
|
|
4
4
|
"description": "Widgets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expo",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/plist": "^0.10.1",
|
|
31
|
-
"@expo/ui": "~58.0.
|
|
31
|
+
"@expo/ui": "~58.0.17"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@expo/internal-scripts": "58.0.
|
|
34
|
+
"@expo/internal-scripts": "58.0.2",
|
|
35
35
|
"@expo/spawn-async": "^1.8.0",
|
|
36
36
|
"@types/jest": "^30.0.0",
|
|
37
37
|
"@types/node": "^22.14.0",
|
|
38
38
|
"@types/react": "~19.3.0",
|
|
39
|
-
"expo": "58.0.
|
|
39
|
+
"expo": "58.0.10",
|
|
40
40
|
"react-native": "0.88.0-rc.4",
|
|
41
41
|
"resolve-workspace-root": "^2.0.0"
|
|
42
42
|
},
|