expo-live-activity 0.2.1-alpha1 → 0.3.0-alpha1

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 (72) hide show
  1. package/.prettierignore +5 -0
  2. package/.prettierrc +6 -0
  3. package/README.md +152 -56
  4. package/app.plugin.js +1 -1
  5. package/build/ExpoLiveActivityModule.d.ts.map +1 -1
  6. package/build/ExpoLiveActivityModule.js.map +1 -1
  7. package/build/index.d.ts +18 -2
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +21 -33
  10. package/build/index.js.map +1 -1
  11. package/eslint.config.js +42 -0
  12. package/ios/ExpoLiveActivityModule.swift +154 -91
  13. package/ios/Helpers.swift +1 -2
  14. package/ios-files/Assets.xcassets/AccentColor.colorset/Contents.json +5 -5
  15. package/ios-files/Assets.xcassets/AppIcon.appiconset/Contents.json +19 -19
  16. package/ios-files/Assets.xcassets/Contents.json +3 -3
  17. package/ios-files/Assets.xcassets/WidgetBackground.colorset/Contents.json +5 -5
  18. package/ios-files/View+applyWidgetURL.swift +15 -1
  19. package/package.json +18 -6
  20. package/plugin/build/index.d.ts +1 -1
  21. package/plugin/build/index.js +8 -3
  22. package/plugin/build/lib/getWidgetExtensionEntitlements.d.ts +6 -2
  23. package/plugin/build/lib/getWidgetExtensionEntitlements.js +1 -1
  24. package/plugin/build/lib/getWidgetFiles.js +18 -17
  25. package/plugin/build/types.d.ts +1 -1
  26. package/plugin/build/withConfig.d.ts +1 -1
  27. package/plugin/build/withPlist.d.ts +5 -0
  28. package/plugin/build/withPlist.js +25 -0
  29. package/plugin/build/withPodfile.d.ts +1 -1
  30. package/plugin/build/withPodfile.js +5 -5
  31. package/plugin/build/withPushNotifications.d.ts +1 -1
  32. package/plugin/build/withPushNotifications.js +2 -2
  33. package/plugin/build/withWidgetExtensionEntitlements.d.ts +1 -1
  34. package/plugin/build/withWidgetExtensionEntitlements.js +1 -1
  35. package/plugin/build/withXcode.d.ts +1 -1
  36. package/plugin/build/withXcode.js +8 -8
  37. package/plugin/build/xcode/addBuildPhases.d.ts +2 -2
  38. package/plugin/build/xcode/addBuildPhases.js +8 -10
  39. package/plugin/build/xcode/addPbxGroup.d.ts +2 -2
  40. package/plugin/build/xcode/addPbxGroup.js +2 -2
  41. package/plugin/build/xcode/addProductFile.d.ts +1 -1
  42. package/plugin/build/xcode/addProductFile.js +3 -3
  43. package/plugin/build/xcode/addTargetDependency.d.ts +1 -1
  44. package/plugin/build/xcode/addTargetDependency.js +5 -7
  45. package/plugin/build/xcode/addToPbxNativeTargetSection.d.ts +1 -1
  46. package/plugin/build/xcode/addToPbxNativeTargetSection.js +5 -5
  47. package/plugin/build/xcode/addToPbxProjectSection.d.ts +1 -1
  48. package/plugin/build/xcode/addToPbxProjectSection.js +1 -2
  49. package/plugin/build/xcode/addXCConfigurationList.d.ts +1 -1
  50. package/plugin/build/xcode/addXCConfigurationList.js +6 -6
  51. package/plugin/src/index.ts +19 -18
  52. package/plugin/src/lib/getWidgetExtensionEntitlements.ts +10 -13
  53. package/plugin/src/lib/getWidgetFiles.ts +70 -74
  54. package/plugin/src/types.ts +3 -5
  55. package/plugin/src/withConfig.ts +15 -15
  56. package/plugin/src/withPlist.ts +27 -0
  57. package/plugin/src/withPodfile.ts +17 -24
  58. package/plugin/src/withPushNotifications.ts +7 -11
  59. package/plugin/src/withWidgetExtensionEntitlements.ts +14 -14
  60. package/plugin/src/withXcode.ts +32 -41
  61. package/plugin/src/xcode/addBuildPhases.ts +26 -41
  62. package/plugin/src/xcode/addPbxGroup.ts +9 -16
  63. package/plugin/src/xcode/addProductFile.ts +7 -7
  64. package/plugin/src/xcode/addTargetDependency.ts +7 -12
  65. package/plugin/src/xcode/addToPbxNativeTargetSection.ts +13 -15
  66. package/plugin/src/xcode/addToPbxProjectSection.ts +7 -17
  67. package/plugin/src/xcode/addXCConfigurationList.ts +16 -16
  68. package/plugin/tsconfig.tsbuildinfo +1 -1
  69. package/scripts/update-version.sh +15 -0
  70. package/src/ExpoLiveActivityModule.ts +2 -2
  71. package/src/index.ts +69 -55
  72. package/.eslintrc.js +0 -5
@@ -2,9 +2,10 @@ import ActivityKit
2
2
  import ExpoModulesCore
3
3
 
4
4
  enum LiveActivityErrors: Error {
5
- case unsupportedOS
6
- case liveActivitiesNotEnabled
7
- case unexpetedError(Error)
5
+ case unsupportedOS
6
+ case notFound
7
+ case liveActivitiesNotEnabled
8
+ case unexpectedError(Error)
8
9
  }
9
10
 
10
11
  public class ExpoLiveActivityModule: Module {
@@ -40,7 +41,7 @@ public class ExpoLiveActivityModule: Module {
40
41
 
41
42
  @Field
42
43
  var progressViewLabelColor: String?
43
-
44
+
44
45
  @Field
45
46
  var deepLinkUrl: String?
46
47
 
@@ -53,136 +54,198 @@ public class ExpoLiveActivityModule: Module {
53
54
  case digital
54
55
  }
55
56
 
56
- func sendPushToken(activityID: String, activityPushToken: String) {
57
+ @available(iOS 16.1, *)
58
+ private func sendPushToken(activity: Activity<LiveActivityAttributes>, activityPushToken: String) {
57
59
  sendEvent(
58
60
  "onTokenReceived",
59
61
  [
60
- "activityID": activityID,
62
+ "activityID": activity.id,
63
+ "activityName": activity.attributes.name,
61
64
  "activityPushToken": activityPushToken,
62
65
  ]
63
66
  )
64
67
  }
65
68
 
66
- func updateImages(state: LiveActivityState, newState: inout LiveActivityAttributes.ContentState) async throws {
69
+ private func sendPushToStartToken(activityPushToStartToken: String) {
70
+ sendEvent(
71
+ "onPushToStartTokenReceived",
72
+ [
73
+ "activityPushToStartToken": activityPushToStartToken
74
+ ]
75
+ )
76
+ }
77
+
78
+ @available(iOS 16.1, *)
79
+ private func sendStateChange(activity: Activity<LiveActivityAttributes>, activityState: ActivityState) {
80
+ sendEvent(
81
+ "onStateChange",
82
+ [
83
+ "activityID": activity.id,
84
+ "activityName": activity.attributes.name,
85
+ "activityState": String(describing: activityState),
86
+ ]
87
+ )
88
+ }
89
+
90
+ private func updateImages(state: LiveActivityState, newState: inout LiveActivityAttributes.ContentState) async throws
91
+ {
67
92
  if let name = state.imageName {
68
- print("imageName: \(name)")
69
93
  newState.imageName = try await resolveImage(from: name)
70
94
  }
71
95
 
72
96
  if let name = state.dynamicIslandImageName {
73
- print("dynamicIslandImageName: \(name)")
74
97
  newState.dynamicIslandImageName = try await resolveImage(from: name)
75
98
  }
76
99
  }
77
100
 
78
- public func definition() -> ModuleDefinition {
79
- Name("ExpoLiveActivity")
101
+ private func observePushToStartToken() {
102
+ guard #available(iOS 17.2, *), ActivityAuthorizationInfo().areActivitiesEnabled else { return }
80
103
 
81
- Events("onTokenReceived")
104
+ print("Observing push to start token updates...")
105
+ Task {
106
+ for await data in Activity<LiveActivityAttributes>.pushToStartTokenUpdates {
107
+ let token = data.reduce("") { $0 + String(format: "%02x", $1) }
108
+ sendPushToStartToken(activityPushToStartToken: token)
109
+ }
110
+ }
111
+ }
82
112
 
83
- Function("startActivity") { (state: LiveActivityState, maybeConfig: LiveActivityConfig?) -> String in
84
- print("Starting activity")
85
- if #available(iOS 16.2, *) {
86
- if ActivityAuthorizationInfo().areActivitiesEnabled {
87
- do {
88
- let config = maybeConfig ?? LiveActivityConfig()
89
- let attributes = LiveActivityAttributes(
90
- name: "ExpoLiveActivity",
91
- backgroundColor: config.backgroundColor,
92
- titleColor: config.titleColor,
93
- subtitleColor: config.subtitleColor,
94
- progressViewTint: config.progressViewTint,
95
- progressViewLabelColor: config.progressViewLabelColor,
96
- deepLinkUrl: config.deepLinkUrl,
97
- timerType: config.timerType == .digital ? .digital : .circular
98
- )
99
- let initialState = LiveActivityAttributes.ContentState(
100
- title: state.title,
101
- subtitle: state.subtitle,
102
- timerEndDateInMilliseconds: state.date,
103
- )
104
- let pushNotificationsEnabled =
105
- Bundle.main.object(forInfoDictionaryKey: "ExpoLiveActivity_EnablePushNotifications") as? Bool
106
- let activity = try Activity.request(
107
- attributes: attributes,
108
- content: .init(state: initialState, staleDate: nil),
109
- pushType: pushNotificationsEnabled == true ? .token : nil
110
- )
113
+ private func observeLiveActivityUpdates() {
114
+ guard #available(iOS 16.2, *) else { return }
115
+
116
+ Task {
117
+ for await activityUpdate in Activity<LiveActivityAttributes>.activityUpdates {
118
+ let activityId = activityUpdate.id
119
+ let activityState = activityUpdate.activityState
120
+
121
+ print("Received activity update: \(activityId), \(activityState)")
122
+
123
+ guard
124
+ let activity = Activity<LiveActivityAttributes>.activities.first(where: {
125
+ $0.id == activityId
126
+ })
127
+ else { return print("Didn't find activity with ID \(activityId)") }
128
+
129
+ if case .active = activityState {
130
+ Task {
131
+ for await state in activity.activityStateUpdates {
132
+ sendStateChange(activity: activity, activityState: state)
133
+ }
134
+ }
111
135
 
136
+ if pushNotificationsEnabled {
137
+ print("Adding push token observer for activity \(activity.id)")
112
138
  Task {
113
139
  for await pushToken in activity.pushTokenUpdates {
114
140
  let pushTokenString = pushToken.reduce("") { $0 + String(format: "%02x", $1) }
115
141
 
116
- sendPushToken(activityID: activity.id, activityPushToken: pushTokenString)
142
+ sendPushToken(activity: activity, activityPushToken: pushTokenString)
117
143
  }
118
144
  }
119
-
120
- Task {
121
- var newState = activity.content.state
122
- try await updateImages(state: state, newState: &newState)
123
- await activity.update(ActivityContent(state: newState, staleDate: nil))
124
- }
125
-
126
- return activity.id
127
- } catch (let error) {
128
- print("Error with live activity: \(error)")
129
- throw LiveActivityErrors.unexpetedError(error)
130
145
  }
131
146
  }
132
- throw LiveActivityErrors.liveActivitiesNotEnabled
133
- } else {
134
- throw LiveActivityErrors.unsupportedOS
135
147
  }
136
148
  }
149
+ }
137
150
 
138
- Function("stopActivity") { (activityId: String, state: LiveActivityState) -> Void in
139
- if #available(iOS 16.2, *) {
140
- print("Attempting to stop")
141
- var newState = LiveActivityAttributes.ContentState(
151
+ private var pushNotificationsEnabled: Bool {
152
+ Bundle.main.object(forInfoDictionaryKey: "ExpoLiveActivity_EnablePushNotifications") as? Bool ?? false
153
+ }
154
+
155
+ public func definition() -> ModuleDefinition {
156
+ Name("ExpoLiveActivity")
157
+
158
+ OnCreate {
159
+ if pushNotificationsEnabled {
160
+ observePushToStartToken()
161
+ }
162
+ observeLiveActivityUpdates()
163
+ }
164
+
165
+ Events("onTokenReceived", "onPushToStartTokenReceived", "onStateChange")
166
+
167
+ Function("startActivity") { (state: LiveActivityState, maybeConfig: LiveActivityConfig?) -> String in
168
+ guard #available(iOS 16.2, *) else { throw LiveActivityErrors.unsupportedOS }
169
+ guard ActivityAuthorizationInfo().areActivitiesEnabled else { throw LiveActivityErrors.liveActivitiesNotEnabled }
170
+
171
+ do {
172
+ let config = maybeConfig ?? LiveActivityConfig()
173
+ let attributes = LiveActivityAttributes(
174
+ name: "ExpoLiveActivity",
175
+ backgroundColor: config.backgroundColor,
176
+ titleColor: config.titleColor,
177
+ subtitleColor: config.subtitleColor,
178
+ progressViewTint: config.progressViewTint,
179
+ progressViewLabelColor: config.progressViewLabelColor,
180
+ deepLinkUrl: config.deepLinkUrl,
181
+ timerType: config.timerType == .digital ? .digital : .circular
182
+ )
183
+ let initialState = LiveActivityAttributes.ContentState(
142
184
  title: state.title,
143
185
  subtitle: state.subtitle,
144
- timerEndDateInMilliseconds: state.date,
186
+ timerEndDateInMilliseconds: state.date
145
187
  )
146
- if let activity = Activity<LiveActivityAttributes>.activities.first(where: {
147
- $0.id == activityId
148
- }) {
149
- Task {
150
- print("Stopping activity with id: \(activityId)")
151
- try await updateImages(state: state, newState: &newState)
152
- await activity.end(
153
- ActivityContent(state: newState, staleDate: nil),
154
- dismissalPolicy: .immediate
155
- )
156
- }
157
- } else {
158
- print("Didn't find activity with ID \(activityId)")
188
+
189
+ let activity = try Activity.request(
190
+ attributes: attributes,
191
+ content: .init(state: initialState, staleDate: nil),
192
+ pushType: pushNotificationsEnabled ? .token : nil
193
+ )
194
+
195
+ Task {
196
+ var newState = activity.content.state
197
+ try await updateImages(state: state, newState: &newState)
198
+ await activity.update(ActivityContent(state: newState, staleDate: nil))
159
199
  }
160
- } else {
161
- throw LiveActivityErrors.unsupportedOS
200
+
201
+ return activity.id
202
+ } catch let error {
203
+ print("Error with live activity: \(error)")
204
+ throw LiveActivityErrors.unexpectedError(error)
205
+
162
206
  }
163
207
  }
164
208
 
165
- Function("updateActivity") { (activityId: String, state: LiveActivityState) -> Void in
166
- if #available(iOS 16.2, *) {
167
- print("Attempting to update")
209
+ Function("stopActivity") { (activityId: String, state: LiveActivityState) in
210
+ guard #available(iOS 16.2, *) else { throw LiveActivityErrors.unsupportedOS }
211
+ guard
212
+ let activity = Activity<LiveActivityAttributes>.activities.first(where: {
213
+ $0.id == activityId
214
+ })
215
+ else { throw LiveActivityErrors.notFound }
216
+
217
+ Task {
218
+ print("Stopping activity with id: \(activityId)")
168
219
  var newState = LiveActivityAttributes.ContentState(
169
220
  title: state.title,
170
221
  subtitle: state.subtitle,
171
- timerEndDateInMilliseconds: state.date,
222
+ timerEndDateInMilliseconds: state.date
172
223
  )
173
- if let activity = Activity<LiveActivityAttributes>.activities.first(where: {
224
+ try await updateImages(state: state, newState: &newState)
225
+ await activity.end(
226
+ ActivityContent(state: newState, staleDate: nil),
227
+ dismissalPolicy: .immediate
228
+ )
229
+ }
230
+ }
231
+
232
+ Function("updateActivity") { (activityId: String, state: LiveActivityState) in
233
+ guard #available(iOS 16.2, *) else { throw LiveActivityErrors.unsupportedOS }
234
+ guard
235
+ let activity = Activity<LiveActivityAttributes>.activities.first(where: {
174
236
  $0.id == activityId
175
- }) {
176
- Task {
177
- print("Updating activity with id: \(activityId)")
178
- try await updateImages(state: state, newState: &newState)
179
- await activity.update(ActivityContent(state: newState, staleDate: nil))
180
- }
181
- } else {
182
- print("Didn't find activity with ID \(activityId)")
183
- }
184
- } else {
185
- throw LiveActivityErrors.unsupportedOS
237
+ })
238
+ else { throw LiveActivityErrors.notFound }
239
+
240
+ Task {
241
+ print("Updating activity with id: \(activityId)")
242
+ var newState = LiveActivityAttributes.ContentState(
243
+ title: state.title,
244
+ subtitle: state.subtitle,
245
+ timerEndDateInMilliseconds: state.date
246
+ )
247
+ try await updateImages(state: state, newState: &newState)
248
+ await activity.update(ActivityContent(state: newState, staleDate: nil))
186
249
  }
187
250
  }
188
251
  }
package/ios/Helpers.swift CHANGED
@@ -9,8 +9,7 @@ func resolveImage(from string: String) async throws -> String {
9
9
  if let url = URL(string: string), url.scheme?.hasPrefix("http") == true,
10
10
  let container = FileManager.default.containerURL(
11
11
  forSecurityApplicationGroupIdentifier: "group.expoLiveActivity.sharedData"
12
- )
13
- {
12
+ ) {
14
13
  let data = try await Data.download(from: url)
15
14
  let filename = UUID().uuidString + ".png"
16
15
  let fileURL = container.appendingPathComponent(filename)
@@ -1,11 +1,11 @@
1
1
  {
2
- "colors" : [
2
+ "colors": [
3
3
  {
4
- "idiom" : "universal"
4
+ "idiom": "universal"
5
5
  }
6
6
  ],
7
- "info" : {
8
- "author" : "xcode",
9
- "version" : 1
7
+ "info": {
8
+ "author": "xcode",
9
+ "version": 1
10
10
  }
11
11
  }
@@ -1,35 +1,35 @@
1
1
  {
2
- "images" : [
2
+ "images": [
3
3
  {
4
- "idiom" : "universal",
5
- "platform" : "ios",
6
- "size" : "1024x1024"
4
+ "idiom": "universal",
5
+ "platform": "ios",
6
+ "size": "1024x1024"
7
7
  },
8
8
  {
9
- "appearances" : [
9
+ "appearances": [
10
10
  {
11
- "appearance" : "luminosity",
12
- "value" : "dark"
11
+ "appearance": "luminosity",
12
+ "value": "dark"
13
13
  }
14
14
  ],
15
- "idiom" : "universal",
16
- "platform" : "ios",
17
- "size" : "1024x1024"
15
+ "idiom": "universal",
16
+ "platform": "ios",
17
+ "size": "1024x1024"
18
18
  },
19
19
  {
20
- "appearances" : [
20
+ "appearances": [
21
21
  {
22
- "appearance" : "luminosity",
23
- "value" : "tinted"
22
+ "appearance": "luminosity",
23
+ "value": "tinted"
24
24
  }
25
25
  ],
26
- "idiom" : "universal",
27
- "platform" : "ios",
28
- "size" : "1024x1024"
26
+ "idiom": "universal",
27
+ "platform": "ios",
28
+ "size": "1024x1024"
29
29
  }
30
30
  ],
31
- "info" : {
32
- "author" : "xcode",
33
- "version" : 1
31
+ "info": {
32
+ "author": "xcode",
33
+ "version": 1
34
34
  }
35
35
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "info" : {
3
- "author" : "xcode",
4
- "version" : 1
2
+ "info": {
3
+ "author": "xcode",
4
+ "version": 1
5
5
  }
6
6
  }
@@ -1,11 +1,11 @@
1
1
  {
2
- "colors" : [
2
+ "colors": [
3
3
  {
4
- "idiom" : "universal"
4
+ "idiom": "universal"
5
5
  }
6
6
  ],
7
- "info" : {
8
- "author" : "xcode",
9
- "version" : 1
7
+ "info": {
8
+ "author": "xcode",
9
+ "version": 1
10
10
  }
11
11
  }
@@ -7,9 +7,23 @@
7
7
 
8
8
  import SwiftUI
9
9
 
10
+ private let cachedScheme: String? = {
11
+ guard
12
+ let urlTypes = Bundle.main.infoDictionary?["CFBundleURLTypes"] as? [[String: Any]],
13
+ let schemes = urlTypes.first?["CFBundleURLSchemes"] as? [String],
14
+ let firstScheme = schemes.first
15
+ else {
16
+ return nil
17
+ }
18
+
19
+ return firstScheme
20
+ }()
21
+
10
22
  extension View {
11
23
  @ViewBuilder
12
24
  func applyWidgetURL(from urlString: String?) -> some View {
13
- applyIfPresent(urlString) { view, string in view.widgetURL(URL(string: string))}
25
+ applyIfPresent(urlString) { view, string in
26
+ applyIfPresent(cachedScheme) { view, scheme in view.widgetURL(URL(string: scheme + "://" + string)) }
27
+ }
14
28
  }
15
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-live-activity",
3
- "version": "0.2.1-alpha1",
3
+ "version": "0.3.0-alpha1",
4
4
  "description": "A module for adding Live Activity to a React Native app for iOS.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -8,9 +8,12 @@
8
8
  "build": "expo-module build",
9
9
  "clean": "expo-module clean",
10
10
  "clean:plugin": "rm -rf plugin/build plugin/tsconfig.tsbuildinfo",
11
- "lint": "expo-module lint",
11
+ "format:check": "prettier --check .",
12
+ "lint": "expo-module eslint",
13
+ "lint:libOnly": "expo-module eslint --ignore-pattern 'example/*'",
12
14
  "test": "expo-module test",
13
- "prepare": "expo-module prepare",
15
+ "postinstall": "cd example && npm install",
16
+ "prepare": "expo-module prepare && rm .eslintrc.js",
14
17
  "prepublishOnly": "expo-module prepublishOnly",
15
18
  "expo-module": "expo-module",
16
19
  "open:ios": "xed example/ios"
@@ -27,17 +30,26 @@
27
30
  "Anna Olak <anna.olak@swmansion.com> (https://github.com/anna1901)",
28
31
  "Artur Bilski <artur.bilski@swmansion.com> (https://github.com/arthwood)"
29
32
  ],
30
- "repository": "https://github.com/software-mansion-labs/expo-live-activity.git",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/software-mansion-labs/expo-live-activity.git"
36
+ },
31
37
  "bugs": {
32
38
  "url": "https://github.com/software-mansion-labs/expo-live-activity/issues"
33
39
  },
34
40
  "license": "MIT",
35
41
  "homepage": "https://github.com/software-mansion-labs/expo-live-activity#readme",
36
- "dependencies": {},
37
42
  "devDependencies": {
38
43
  "@types/react": "~19.0.0",
39
- "expo-module-scripts": "^4.1.6",
44
+ "eslint": "^9.33.0",
45
+ "eslint-config-expo": "^9.2.0",
46
+ "eslint-import-resolver-alias": "^1.1.2",
47
+ "eslint-plugin-import": "^2.32.0",
48
+ "eslint-plugin-prettier": "^5.5.4",
49
+ "eslint-plugin-simple-import-sort": "^12.1.1",
40
50
  "expo": "~53.0.0",
51
+ "expo-module-scripts": "^4.1.6",
52
+ "prettier": "^3.6.2",
41
53
  "react-native": "0.79.1"
42
54
  },
43
55
  "peerDependencies": {
@@ -1,3 +1,3 @@
1
- import type { LiveActivityConfigPlugin } from "./types";
1
+ import type { LiveActivityConfigPlugin } from './types';
2
2
  declare const withWidgetsAndLiveActivities: LiveActivityConfigPlugin;
3
3
  export default withWidgetsAndLiveActivities;
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const config_plugins_1 = require("expo/config-plugins");
4
7
  const withConfig_1 = require("./withConfig");
8
+ const withPlist_1 = __importDefault(require("./withPlist"));
5
9
  const withPodfile_1 = require("./withPodfile");
6
- const withXcode_1 = require("./withXcode");
7
- const withWidgetExtensionEntitlements_1 = require("./withWidgetExtensionEntitlements");
8
10
  const withPushNotifications_1 = require("./withPushNotifications");
11
+ const withWidgetExtensionEntitlements_1 = require("./withWidgetExtensionEntitlements");
12
+ const withXcode_1 = require("./withXcode");
9
13
  const withWidgetsAndLiveActivities = (config, props) => {
10
- const deploymentTarget = "16.2";
14
+ const deploymentTarget = '16.2';
11
15
  const targetName = `${config_plugins_1.IOSConfig.XcodeUtils.sanitizedName(config.name)}LiveActivity`;
12
16
  const bundleIdentifier = `${config.ios?.bundleIdentifier}.${targetName}`;
13
17
  config.ios = {
@@ -19,6 +23,7 @@ const withWidgetsAndLiveActivities = (config, props) => {
19
23
  },
20
24
  };
21
25
  config = (0, config_plugins_1.withPlugins)(config, [
26
+ [withPlist_1.default, { targetName }],
22
27
  [
23
28
  withXcode_1.withXcode,
24
29
  {
@@ -1,3 +1,7 @@
1
- import { ExportedConfig, InfoPlist } from "@expo/config-plugins";
2
- export declare function getWidgetExtensionEntitlements(iosConfig: ExportedConfig["ios"], {}: {}): InfoPlist;
1
+ import { ExportedConfig, InfoPlist } from '@expo/config-plugins';
2
+ interface Options {
3
+ groupIdentifier?: string;
4
+ }
5
+ export declare function getWidgetExtensionEntitlements(_iosConfig: ExportedConfig['ios'], _options?: Options | undefined): InfoPlist;
3
6
  export declare function addApplicationGroupsEntitlement(entitlements: InfoPlist, groupIdentifier?: string): InfoPlist;
7
+ export {};
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWidgetExtensionEntitlements = getWidgetExtensionEntitlements;
4
4
  exports.addApplicationGroupsEntitlement = addApplicationGroupsEntitlement;
5
- function getWidgetExtensionEntitlements(iosConfig, {}) {
5
+ function getWidgetExtensionEntitlements(_iosConfig, _options = {}) {
6
6
  const entitlements = {};
7
7
  addApplicationGroupsEntitlement(entitlements);
8
8
  return entitlements;
@@ -40,13 +40,13 @@ const path = __importStar(require("path"));
40
40
  function getWidgetFiles(targetPath) {
41
41
  let packagePath;
42
42
  try {
43
- packagePath = path.dirname(require.resolve("expo-live-activity/package.json"));
43
+ packagePath = path.dirname(require.resolve('expo-live-activity/package.json'));
44
44
  }
45
45
  catch {
46
- console.log("Building for example app");
46
+ console.log('Building for example app');
47
47
  }
48
- const liveActivityFilesPath = path.join(packagePath ? packagePath : "..", "/ios-files");
49
- const imageAssetsPath = "./assets/liveActivity";
48
+ const liveActivityFilesPath = path.join(packagePath ? packagePath : '..', '/ios-files');
49
+ const imageAssetsPath = './assets/liveActivity';
50
50
  const widgetFiles = {
51
51
  swiftFiles: [],
52
52
  entitlementFiles: [],
@@ -61,20 +61,20 @@ function getWidgetFiles(targetPath) {
61
61
  if (fs.lstatSync(liveActivityFilesPath).isDirectory()) {
62
62
  const files = fs.readdirSync(liveActivityFilesPath);
63
63
  files.forEach((file) => {
64
- const fileExtension = file.split(".").pop();
65
- if (fileExtension === "swift") {
64
+ const fileExtension = file.split('.').pop();
65
+ if (fileExtension === 'swift') {
66
66
  widgetFiles.swiftFiles.push(file);
67
67
  }
68
- else if (fileExtension === "entitlements") {
68
+ else if (fileExtension === 'entitlements') {
69
69
  widgetFiles.entitlementFiles.push(file);
70
70
  }
71
- else if (fileExtension === "plist") {
71
+ else if (fileExtension === 'plist') {
72
72
  widgetFiles.plistFiles.push(file);
73
73
  }
74
- else if (fileExtension === "xcassets") {
74
+ else if (fileExtension === 'xcassets') {
75
75
  widgetFiles.assetDirectories.push(file);
76
76
  }
77
- else if (fileExtension === "intentdefinition") {
77
+ else if (fileExtension === 'intentdefinition') {
78
78
  widgetFiles.intentFiles.push(file);
79
79
  }
80
80
  else {
@@ -83,6 +83,7 @@ function getWidgetFiles(targetPath) {
83
83
  });
84
84
  }
85
85
  // Copy files
86
+ ;
86
87
  [
87
88
  ...widgetFiles.swiftFiles,
88
89
  ...widgetFiles.entitlementFiles,
@@ -94,11 +95,11 @@ function getWidgetFiles(targetPath) {
94
95
  copyFileSync(source, targetPath);
95
96
  });
96
97
  // Copy assets directory
97
- const imagesXcassetsSource = path.join(liveActivityFilesPath, "Assets.xcassets");
98
+ const imagesXcassetsSource = path.join(liveActivityFilesPath, 'Assets.xcassets');
98
99
  copyFolderRecursiveSync(imagesXcassetsSource, targetPath);
99
100
  // Move images to assets directory
100
101
  if (fs.existsSync(imageAssetsPath) && fs.lstatSync(imageAssetsPath).isDirectory()) {
101
- const imagesXcassetsTarget = path.join(targetPath, "Assets.xcassets");
102
+ const imagesXcassetsTarget = path.join(targetPath, 'Assets.xcassets');
102
103
  const files = fs.readdirSync(imageAssetsPath);
103
104
  files.forEach((file) => {
104
105
  if (path.extname(file).match(/\.(png|jpg|jpeg)$/)) {
@@ -116,13 +117,13 @@ function getWidgetFiles(targetPath) {
116
117
  images: [
117
118
  {
118
119
  filename: file,
119
- idiom: "universal"
120
- }
120
+ idiom: 'universal',
121
+ },
121
122
  ],
122
123
  info: {
123
- author: "xcode",
124
- version: 1
125
- }
124
+ author: 'xcode',
125
+ version: 1,
126
+ },
126
127
  };
127
128
  fs.writeFileSync(path.join(imageSetDir, 'Contents.json'), JSON.stringify(contentsJson, null, 2));
128
129
  }
@@ -1,4 +1,4 @@
1
- import { ConfigPlugin } from "@expo/config-plugins";
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
2
  interface ConfigPluginProps {
3
3
  enablePushNotifications?: boolean;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { ConfigPlugin } from "@expo/config-plugins";
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
2
  export declare const withConfig: ConfigPlugin<{
3
3
  bundleIdentifier: string;
4
4
  targetName: string;