expo-targets 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/.eslintrc.js +2 -0
  2. package/README.md +244 -0
  3. package/android/build.gradle +22 -0
  4. package/android/src/main/java/expo/modules/targets/ExpoTargetsLogger.kt +98 -0
  5. package/android/src/main/java/expo/modules/targets/ExpoTargetsReceiver.kt +136 -0
  6. package/android/src/main/java/expo/modules/targets/ExpoTargetsRemoteViewsProvider.kt +72 -0
  7. package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetProvider.kt +47 -0
  8. package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetSync.kt +78 -0
  9. package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetUpdateReceiver.kt +30 -0
  10. package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsExtensionModule.kt +27 -0
  11. package/android/src/main/java/expo/modules/targets/messages/ExpoTargetsMessagesModule.kt +40 -0
  12. package/android/src/main/java/expo/modules/targets/storage/ExpoTargetsStorageModule.kt +119 -0
  13. package/app.plugin.js +1 -0
  14. package/build/metro/src/index.d.ts +2 -0
  15. package/build/metro/src/index.d.ts.map +1 -0
  16. package/build/metro/src/index.js +6 -0
  17. package/build/metro/src/index.js.map +1 -0
  18. package/build/metro/src/withTargetsMetro.d.ts +6 -0
  19. package/build/metro/src/withTargetsMetro.d.ts.map +1 -0
  20. package/build/metro/src/withTargetsMetro.js +171 -0
  21. package/build/metro/src/withTargetsMetro.js.map +1 -0
  22. package/build/plugin/src/android/config-plugins/withAndroidColors.d.ts +7 -0
  23. package/build/plugin/src/android/config-plugins/withAndroidColors.d.ts.map +1 -0
  24. package/build/plugin/src/android/config-plugins/withAndroidColors.js +56 -0
  25. package/build/plugin/src/android/config-plugins/withAndroidColors.js.map +1 -0
  26. package/build/plugin/src/android/config-plugins/withAndroidManifest.d.ts +7 -0
  27. package/build/plugin/src/android/config-plugins/withAndroidManifest.d.ts.map +1 -0
  28. package/build/plugin/src/android/config-plugins/withAndroidManifest.js +70 -0
  29. package/build/plugin/src/android/config-plugins/withAndroidManifest.js.map +1 -0
  30. package/build/plugin/src/android/config-plugins/withAndroidModule.d.ts +7 -0
  31. package/build/plugin/src/android/config-plugins/withAndroidModule.d.ts.map +1 -0
  32. package/build/plugin/src/android/config-plugins/withAndroidModule.js +41 -0
  33. package/build/plugin/src/android/config-plugins/withAndroidModule.js.map +1 -0
  34. package/build/plugin/src/android/config-plugins/withAndroidResources.d.ts +7 -0
  35. package/build/plugin/src/android/config-plugins/withAndroidResources.d.ts.map +1 -0
  36. package/build/plugin/src/android/config-plugins/withAndroidResources.js +75 -0
  37. package/build/plugin/src/android/config-plugins/withAndroidResources.js.map +1 -0
  38. package/build/plugin/src/android/config-plugins/withAndroidTarget.d.ts +28 -0
  39. package/build/plugin/src/android/config-plugins/withAndroidTarget.d.ts.map +1 -0
  40. package/build/plugin/src/android/config-plugins/withAndroidTarget.js +28 -0
  41. package/build/plugin/src/android/config-plugins/withAndroidTarget.js.map +1 -0
  42. package/build/plugin/src/android/config-plugins/withGradleModule.d.ts +7 -0
  43. package/build/plugin/src/android/config-plugins/withGradleModule.d.ts.map +1 -0
  44. package/build/plugin/src/android/config-plugins/withGradleModule.js +86 -0
  45. package/build/plugin/src/android/config-plugins/withGradleModule.js.map +1 -0
  46. package/build/plugin/src/android/config-plugins/withGradleSettings.d.ts +7 -0
  47. package/build/plugin/src/android/config-plugins/withGradleSettings.d.ts.map +1 -0
  48. package/build/plugin/src/android/config-plugins/withGradleSettings.js +23 -0
  49. package/build/plugin/src/android/config-plugins/withGradleSettings.js.map +1 -0
  50. package/build/plugin/src/android/withAndroidAppBuildGradle.d.ts +7 -0
  51. package/build/plugin/src/android/withAndroidAppBuildGradle.d.ts.map +1 -0
  52. package/build/plugin/src/android/withAndroidAppBuildGradle.js +31 -0
  53. package/build/plugin/src/android/withAndroidAppBuildGradle.js.map +1 -0
  54. package/build/plugin/src/android/withAndroidKotlinGradleProperty.d.ts +3 -0
  55. package/build/plugin/src/android/withAndroidKotlinGradleProperty.d.ts.map +1 -0
  56. package/build/plugin/src/android/withAndroidKotlinGradleProperty.js +24 -0
  57. package/build/plugin/src/android/withAndroidKotlinGradleProperty.js.map +1 -0
  58. package/build/plugin/src/android/withAndroidProjectKotlinVersion.d.ts +3 -0
  59. package/build/plugin/src/android/withAndroidProjectKotlinVersion.d.ts.map +1 -0
  60. package/build/plugin/src/android/withAndroidProjectKotlinVersion.js +27 -0
  61. package/build/plugin/src/android/withAndroidProjectKotlinVersion.js.map +1 -0
  62. package/build/plugin/src/android/withAndroidTarget.d.ts +10 -0
  63. package/build/plugin/src/android/withAndroidTarget.d.ts.map +1 -0
  64. package/build/plugin/src/android/withAndroidTarget.js +22 -0
  65. package/build/plugin/src/android/withAndroidTarget.js.map +1 -0
  66. package/build/plugin/src/android/withAndroidWidget.d.ts +13 -0
  67. package/build/plugin/src/android/withAndroidWidget.d.ts.map +1 -0
  68. package/build/plugin/src/android/withAndroidWidget.js +564 -0
  69. package/build/plugin/src/android/withAndroidWidget.js.map +1 -0
  70. package/build/plugin/src/config.d.ts +141 -0
  71. package/build/plugin/src/config.d.ts.map +1 -0
  72. package/build/plugin/src/config.js +54 -0
  73. package/build/plugin/src/config.js.map +1 -0
  74. package/build/plugin/src/index.d.ts +9 -0
  75. package/build/plugin/src/index.d.ts.map +1 -0
  76. package/build/plugin/src/index.js +11 -0
  77. package/build/plugin/src/index.js.map +1 -0
  78. package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts +11 -0
  79. package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts.map +1 -0
  80. package/build/plugin/src/ios/config-plugins/withEntitlements.js +49 -0
  81. package/build/plugin/src/ios/config-plugins/withEntitlements.js.map +1 -0
  82. package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts +17 -0
  83. package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts.map +1 -0
  84. package/build/plugin/src/ios/config-plugins/withIOSTarget.js +152 -0
  85. package/build/plugin/src/ios/config-plugins/withIOSTarget.js.map +1 -0
  86. package/build/plugin/src/ios/config-plugins/withIosColorset.d.ts +8 -0
  87. package/build/plugin/src/ios/config-plugins/withIosColorset.d.ts.map +1 -0
  88. package/build/plugin/src/ios/config-plugins/withIosColorset.js +25 -0
  89. package/build/plugin/src/ios/config-plugins/withIosColorset.js.map +1 -0
  90. package/build/plugin/src/ios/config-plugins/withIosStickerPack.d.ts +8 -0
  91. package/build/plugin/src/ios/config-plugins/withIosStickerPack.d.ts.map +1 -0
  92. package/build/plugin/src/ios/config-plugins/withIosStickerPack.js +52 -0
  93. package/build/plugin/src/ios/config-plugins/withIosStickerPack.js.map +1 -0
  94. package/build/plugin/src/ios/config-plugins/withPodfile.d.ts +12 -0
  95. package/build/plugin/src/ios/config-plugins/withPodfile.d.ts.map +1 -0
  96. package/build/plugin/src/ios/config-plugins/withPodfile.js +162 -0
  97. package/build/plugin/src/ios/config-plugins/withPodfile.js.map +1 -0
  98. package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts +15 -0
  99. package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts.map +1 -0
  100. package/build/plugin/src/ios/config-plugins/withXcodeChanges.js +646 -0
  101. package/build/plugin/src/ios/config-plugins/withXcodeChanges.js.map +1 -0
  102. package/build/plugin/src/ios/target.d.ts +41 -0
  103. package/build/plugin/src/ios/target.d.ts.map +1 -0
  104. package/build/plugin/src/ios/target.js +574 -0
  105. package/build/plugin/src/ios/target.js.map +1 -0
  106. package/build/plugin/src/ios/utils/asset.d.ts +60 -0
  107. package/build/plugin/src/ios/utils/asset.d.ts.map +1 -0
  108. package/build/plugin/src/ios/utils/asset.js +375 -0
  109. package/build/plugin/src/ios/utils/asset.js.map +1 -0
  110. package/build/plugin/src/ios/utils/file.d.ts +33 -0
  111. package/build/plugin/src/ios/utils/file.d.ts.map +1 -0
  112. package/build/plugin/src/ios/utils/file.js +88 -0
  113. package/build/plugin/src/ios/utils/file.js.map +1 -0
  114. package/build/plugin/src/ios/utils/index.d.ts +12 -0
  115. package/build/plugin/src/ios/utils/index.d.ts.map +1 -0
  116. package/build/plugin/src/ios/utils/index.js +38 -0
  117. package/build/plugin/src/ios/utils/index.js.map +1 -0
  118. package/build/plugin/src/ios/utils/paths.d.ts +128 -0
  119. package/build/plugin/src/ios/utils/paths.d.ts.map +1 -0
  120. package/build/plugin/src/ios/utils/paths.js +141 -0
  121. package/build/plugin/src/ios/utils/paths.js.map +1 -0
  122. package/build/plugin/src/ios/utils/plist.d.ts +29 -0
  123. package/build/plugin/src/ios/utils/plist.d.ts.map +1 -0
  124. package/build/plugin/src/ios/utils/plist.js +114 -0
  125. package/build/plugin/src/ios/utils/plist.js.map +1 -0
  126. package/build/plugin/src/ios/utils/podfile.d.ts +82 -0
  127. package/build/plugin/src/ios/utils/podfile.d.ts.map +1 -0
  128. package/build/plugin/src/ios/utils/podfile.js +408 -0
  129. package/build/plugin/src/ios/utils/podfile.js.map +1 -0
  130. package/build/plugin/src/ios/utils/reactNativeSwift.d.ts +11 -0
  131. package/build/plugin/src/ios/utils/reactNativeSwift.d.ts.map +1 -0
  132. package/build/plugin/src/ios/utils/reactNativeSwift.js +263 -0
  133. package/build/plugin/src/ios/utils/reactNativeSwift.js.map +1 -0
  134. package/build/plugin/src/ios/utils/xcode.d.ts +185 -0
  135. package/build/plugin/src/ios/utils/xcode.d.ts.map +1 -0
  136. package/build/plugin/src/ios/utils/xcode.js +706 -0
  137. package/build/plugin/src/ios/utils/xcode.js.map +1 -0
  138. package/build/plugin/src/logger.d.ts +10 -0
  139. package/build/plugin/src/logger.d.ts.map +1 -0
  140. package/build/plugin/src/logger.js +62 -0
  141. package/build/plugin/src/logger.js.map +1 -0
  142. package/build/plugin/src/parseTargetConfig.d.ts +3 -0
  143. package/build/plugin/src/parseTargetConfig.d.ts.map +1 -0
  144. package/build/plugin/src/parseTargetConfig.js +113 -0
  145. package/build/plugin/src/parseTargetConfig.js.map +1 -0
  146. package/build/plugin/src/withTargetsDir.d.ts +6 -0
  147. package/build/plugin/src/withTargetsDir.d.ts.map +1 -0
  148. package/build/plugin/src/withTargetsDir.js +90 -0
  149. package/build/plugin/src/withTargetsDir.js.map +1 -0
  150. package/build/src/Target.d.ts +43 -0
  151. package/build/src/Target.d.ts.map +1 -0
  152. package/build/src/Target.js +128 -0
  153. package/build/src/Target.js.map +1 -0
  154. package/build/src/index.d.ts +9 -0
  155. package/build/src/index.d.ts.map +1 -0
  156. package/build/src/index.js +27 -0
  157. package/build/src/index.js.map +1 -0
  158. package/build/src/modules/extension/index.d.ts +18 -0
  159. package/build/src/modules/extension/index.d.ts.map +1 -0
  160. package/build/src/modules/extension/index.js +44 -0
  161. package/build/src/modules/extension/index.js.map +1 -0
  162. package/build/src/modules/messages/index.d.ts +40 -0
  163. package/build/src/modules/messages/index.d.ts.map +1 -0
  164. package/build/src/modules/messages/index.js +94 -0
  165. package/build/src/modules/messages/index.js.map +1 -0
  166. package/build/src/modules/storage/index.d.ts +16 -0
  167. package/build/src/modules/storage/index.d.ts.map +1 -0
  168. package/build/src/modules/storage/index.js +122 -0
  169. package/build/src/modules/storage/index.js.map +1 -0
  170. package/expo-module.config.json +17 -0
  171. package/ios/ExpoTargetsExtension.podspec +23 -0
  172. package/ios/ExpoTargetsExtensionModule.swift +181 -0
  173. package/ios/ExpoTargetsMessages.podspec +23 -0
  174. package/ios/ExpoTargetsMessagesModule.swift +267 -0
  175. package/ios/ExpoTargetsStorage.podspec +23 -0
  176. package/ios/ExpoTargetsStorageModule.swift +91 -0
  177. package/ios/Tests/.swiftlint.yml +52 -0
  178. package/ios/Tests/Helpers/MockExtensionContext.swift +58 -0
  179. package/ios/Tests/Helpers/MockUserDefaults.swift +70 -0
  180. package/ios/Tests/Helpers/MockWidgetCenter.swift +71 -0
  181. package/ios/Tests/Helpers/TestHelpers.swift +90 -0
  182. package/ios/Tests/Integration/TargetIntegrationTests.swift +478 -0
  183. package/ios/Tests/Main/AllTests.swift +80 -0
  184. package/ios/Tests/Package.swift +66 -0
  185. package/ios/Tests/Performance/StoragePerformanceTests.swift +461 -0
  186. package/ios/Tests/Unit/Extension/ExpoTargetsExtensionModuleTests.swift +501 -0
  187. package/ios/Tests/Unit/Storage/ExpoTargetsStorageModuleTests.swift +578 -0
  188. package/ios/Tests/Unit/Template/ShareExtensionTemplateTests.swift +421 -0
  189. package/ios/Tests/XCTestPlan.xctestplan +87 -0
  190. package/metro/src/index.ts +1 -0
  191. package/metro/src/withTargetsMetro.ts +247 -0
  192. package/metro/tsconfig.build.json +9 -0
  193. package/package.json +74 -0
  194. package/plugin/src/android/withAndroidAppBuildGradle.ts +34 -0
  195. package/plugin/src/android/withAndroidTarget.ts +26 -0
  196. package/plugin/src/android/withAndroidWidget.ts +778 -0
  197. package/plugin/src/config.ts +255 -0
  198. package/plugin/src/index.ts +19 -0
  199. package/plugin/src/ios/config-plugins/withEntitlements.ts +69 -0
  200. package/plugin/src/ios/config-plugins/withIOSTarget.ts +179 -0
  201. package/plugin/src/ios/config-plugins/withIosColorset.ts +29 -0
  202. package/plugin/src/ios/config-plugins/withIosStickerPack.ts +65 -0
  203. package/plugin/src/ios/config-plugins/withPodfile.ts +238 -0
  204. package/plugin/src/ios/config-plugins/withXcodeChanges.ts +891 -0
  205. package/plugin/src/ios/target.ts +668 -0
  206. package/plugin/src/ios/templates/MessagesViewController.swift +120 -0
  207. package/plugin/src/ios/templates/ReactNativeViewController.swift +240 -0
  208. package/plugin/src/ios/templates/action-extension-data.swift +106 -0
  209. package/plugin/src/ios/templates/clip-extension-data.swift +28 -0
  210. package/plugin/src/ios/templates/messages-extension-data.swift +28 -0
  211. package/plugin/src/ios/templates/share-extension-data.swift +113 -0
  212. package/plugin/src/ios/utils/asset.ts +490 -0
  213. package/plugin/src/ios/utils/file.ts +80 -0
  214. package/plugin/src/ios/utils/index.ts +12 -0
  215. package/plugin/src/ios/utils/paths.ts +253 -0
  216. package/plugin/src/ios/utils/plist.ts +101 -0
  217. package/plugin/src/ios/utils/podfile.ts +534 -0
  218. package/plugin/src/ios/utils/reactNativeSwift.ts +283 -0
  219. package/plugin/src/ios/utils/xcode.ts +989 -0
  220. package/plugin/src/logger.ts +63 -0
  221. package/plugin/src/parseTargetConfig.ts +115 -0
  222. package/plugin/src/types/normalize-colors.d.ts +3 -0
  223. package/plugin/src/withTargetsDir.ts +120 -0
  224. package/plugin/tsconfig.build.json +9 -0
  225. package/plugin/tsconfig.json +9 -0
  226. package/src/Target.ts +239 -0
  227. package/src/index.ts +52 -0
  228. package/src/modules/extension/index.ts +54 -0
  229. package/src/modules/messages/index.ts +124 -0
  230. package/src/modules/storage/index.ts +126 -0
  231. package/tsconfig.json +8 -0
@@ -0,0 +1,255 @@
1
+ import type { ExpoConfig } from '@expo/config-types';
2
+
3
+ export type ExtensionType =
4
+ | 'widget'
5
+ | 'clip'
6
+ | 'stickers'
7
+ | 'messages'
8
+ | 'share'
9
+ | 'action'
10
+ | 'safari'
11
+ | 'notification-content'
12
+ | 'notification-service'
13
+ | 'intent'
14
+ | 'intent-ui'
15
+ | 'spotlight'
16
+ | 'bg-download'
17
+ | 'quicklook-thumbnail'
18
+ | 'location-push'
19
+ | 'credentials-provider'
20
+ | 'account-auth'
21
+ | 'app-intent'
22
+ | 'device-activity-monitor'
23
+ | 'matter'
24
+ | 'watch';
25
+
26
+ export interface Color {
27
+ light?: string;
28
+ dark?: string;
29
+ color?: string;
30
+ darkColor?: string;
31
+ }
32
+
33
+ // Share extension activation rules
34
+ export type ShareExtensionContentType =
35
+ | 'text'
36
+ | 'url'
37
+ | 'image'
38
+ | 'video'
39
+ | 'file'
40
+ | 'webpage';
41
+
42
+ export interface ShareExtensionActivationRule {
43
+ /**
44
+ * Type of content to accept
45
+ * - text: Plain text content
46
+ * - url: URLs (including web URLs)
47
+ * - image: Image files
48
+ * - video: Video files
49
+ * - file: Generic files
50
+ * - webpage: Web pages (requires preprocessingFile for full support)
51
+ */
52
+ type: ShareExtensionContentType;
53
+ /**
54
+ * Maximum number of items to accept (default: 1)
55
+ * Only applicable for url, image, video, and file types
56
+ */
57
+ maxCount?: number;
58
+ }
59
+
60
+ export interface StickerPack {
61
+ name: string;
62
+ assets: string[];
63
+ }
64
+
65
+ export const TYPE_MINIMUM_DEPLOYMENT_TARGETS: Record<ExtensionType, string> = {
66
+ widget: '14.0',
67
+ clip: '14.0',
68
+ stickers: '10.0',
69
+ messages: '10.0',
70
+ share: '8.0',
71
+ action: '8.0',
72
+ 'notification-content': '10.0',
73
+ 'notification-service': '10.0',
74
+ intent: '12.0',
75
+ 'intent-ui': '12.0',
76
+ safari: '15.0',
77
+ spotlight: '9.0',
78
+ 'bg-download': '7.0',
79
+ 'quicklook-thumbnail': '11.0',
80
+ 'location-push': '15.0',
81
+ 'credentials-provider': '12.0',
82
+ 'account-auth': '12.2',
83
+ 'app-intent': '16.0',
84
+ 'device-activity-monitor': '15.0',
85
+ matter: '16.1',
86
+ watch: '2.0',
87
+ };
88
+
89
+ export const TYPE_BUNDLE_IDENTIFIER_SUFFIXES: Record<ExtensionType, string> = {
90
+ widget: 'widget',
91
+ clip: 'clip',
92
+ stickers: 'stickers',
93
+ messages: 'messages',
94
+ share: 'share',
95
+ action: 'action',
96
+ safari: 'safari',
97
+ 'notification-content': 'notification-content',
98
+ 'notification-service': 'notification-service',
99
+ intent: 'intent',
100
+ 'intent-ui': 'intent-ui',
101
+ spotlight: 'spotlight',
102
+ 'bg-download': 'bg-download',
103
+ 'quicklook-thumbnail': 'quicklook-thumbnail',
104
+ 'location-push': 'location-push',
105
+ 'credentials-provider': 'credentials-provider',
106
+ 'account-auth': 'account-auth',
107
+ 'app-intent': 'app-intent',
108
+ 'device-activity-monitor': 'device-activity-monitor',
109
+ matter: 'matter',
110
+ watch: 'watch',
111
+ };
112
+
113
+ // Base configuration shared by all iOS targets
114
+ interface BaseIOSTargetConfig {
115
+ icon?: string;
116
+ deploymentTarget?: string;
117
+ bundleIdentifier?: string;
118
+ displayName?: string;
119
+ colors?: Record<string, string | Color>;
120
+ images?: Record<string, string>;
121
+ stickerPacks?: StickerPack[];
122
+ /**
123
+ * Icon for extension target
124
+ * - For stickers: Path to source image file (e.g., "./assets/imessage-icon.png")
125
+ * - For action extensions: SF Symbol name (e.g., "photo.fill") or image asset name
126
+ * @example
127
+ * targetIcon: "./assets/icon.png" // Sticker pack icon file path
128
+ * targetIcon: "photo.fill" // Action extension SF Symbol
129
+ * targetIcon: "MyActionIcon" // Action extension image asset name
130
+ */
131
+ targetIcon?: string;
132
+ frameworks?: string[];
133
+ entitlements?: Record<string, any>;
134
+ infoPlist?: Record<string, any>;
135
+
136
+ // CamelCase build settings
137
+ swiftVersion?: string;
138
+ targetedDeviceFamily?: string;
139
+ clangEnableModules?: boolean | string;
140
+ swiftEmitLocStrings?: boolean | string;
141
+
142
+ // Share extension configuration (only applies when type='share')
143
+ /**
144
+ * Content types this share extension accepts
145
+ * Only applies to share extension targets
146
+ * @example
147
+ * activationRules: [
148
+ * { type: 'text' },
149
+ * { type: 'url' },
150
+ * { type: 'image', maxCount: 5 }
151
+ * ]
152
+ */
153
+ activationRules?: ShareExtensionActivationRule[];
154
+ /**
155
+ * JavaScript file for preprocessing web content
156
+ * Only applies to share extension targets
157
+ * Enables NSExtensionActivationSupportsWebPageWithMaxCount
158
+ * @see https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/Share.html
159
+ */
160
+ preprocessingFile?: string;
161
+ }
162
+
163
+ // Types that support React Native rendering
164
+ export type ReactNativeCompatibleType =
165
+ | 'share'
166
+ | 'action'
167
+ | 'clip'
168
+ | 'messages';
169
+
170
+ // Types that do NOT support React Native (use native rendering)
171
+ export type NativeOnlyType = Exclude<ExtensionType, ReactNativeCompatibleType>;
172
+
173
+ // Config for React Native compatible types
174
+ export interface IOSTargetConfigWithReactNative extends BaseIOSTargetConfig {}
175
+
176
+ // Config for native-only types (no React Native options)
177
+ export interface IOSTargetConfigNativeOnly extends BaseIOSTargetConfig {}
178
+
179
+ // Union type based on target type
180
+ export type IOSTargetConfig =
181
+ | IOSTargetConfigWithReactNative
182
+ | IOSTargetConfigNativeOnly;
183
+
184
+ export interface AndroidTargetConfig {
185
+ resourceName?: string;
186
+ /**
187
+ * Widget rendering approach (default: 'glance')
188
+ * - 'glance': Modern Jetpack Compose-based widgets using Glance API
189
+ * - 'remoteviews': Traditional XML layout-based widgets using RemoteViews
190
+ */
191
+ widgetType?: 'glance' | 'remoteviews';
192
+ // Widget-specific configuration
193
+ minWidth?: string;
194
+ minHeight?: string;
195
+ resizeMode?: string;
196
+ updatePeriodMillis?: number;
197
+ widgetCategory?: string;
198
+ previewImage?: string;
199
+ description?: string;
200
+ maxResizeWidth?: string;
201
+ maxResizeHeight?: string;
202
+ targetCellWidth?: number;
203
+ targetCellHeight?: number;
204
+ initialLayout?: string;
205
+ colors?: Record<string, string | Color>;
206
+ }
207
+
208
+ // Base config shared by all targets
209
+ type BaseTargetConfig = {
210
+ name: string;
211
+ displayName?: string;
212
+ appGroup?: string;
213
+ platforms: string[];
214
+ android?: AndroidTargetConfig;
215
+ };
216
+
217
+ // Target config for React Native compatible types
218
+ type TargetConfigReactNativeCompatible = BaseTargetConfig & {
219
+ type: ReactNativeCompatibleType;
220
+ /**
221
+ * Entry point for React Native rendering (share, action, clip only)
222
+ * Path to JavaScript/TypeScript file that exports the extension component
223
+ * When specified, enables React Native rendering in the extension
224
+ * @example "./ShareExtension.tsx"
225
+ * @example "./targets/my-share/ShareExtension.js"
226
+ */
227
+ entry?: string;
228
+ /**
229
+ * Exclude specific Expo packages from the extension bundle
230
+ * Reduces bundle size by removing unused modules
231
+ * Only applies when `entry` is specified
232
+ * @example ['expo-dev-client', 'expo-updates']
233
+ */
234
+ excludedPackages?: string[];
235
+ ios?: IOSTargetConfigWithReactNative;
236
+ };
237
+
238
+ // Target config for native-only types
239
+ type TargetConfigNativeOnly = BaseTargetConfig & {
240
+ type: NativeOnlyType;
241
+ ios?: IOSTargetConfigNativeOnly;
242
+ };
243
+
244
+ // Main discriminated union
245
+ export type TargetConfig =
246
+ | TargetConfigReactNativeCompatible
247
+ | TargetConfigNativeOnly;
248
+
249
+ export type TargetConfigFunction = (config: ExpoConfig) => TargetConfig;
250
+
251
+ export const getAppGroup = (identifier: string) => `group.${identifier}`;
252
+ export const getTargetBundleIdentifier = (
253
+ appBundleId: string,
254
+ targetName: string
255
+ ) => `${appBundleId}.${targetName}`;
@@ -0,0 +1,19 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+
3
+ import { withAndroidAppBuildGradle } from './android/withAndroidAppBuildGradle';
4
+ import { withTargetsDir } from './withTargetsDir';
5
+
6
+ // Export types for use in config files
7
+ export type { TargetConfig, TargetConfigFunction } from './config';
8
+ export type { ExpoConfig } from '@expo/config-types';
9
+
10
+ const withExpoTargets: ConfigPlugin<{
11
+ debug?: boolean;
12
+ targetsRoot?: string;
13
+ }> = (config, options) => {
14
+ config = withTargetsDir(config, options || {});
15
+ config = withAndroidAppBuildGradle(config);
16
+ return config;
17
+ };
18
+
19
+ export default withExpoTargets;
@@ -0,0 +1,69 @@
1
+ import { ConfigPlugin, withDangerousMod } from '@expo/config-plugins';
2
+ import path from 'path';
3
+
4
+ import type { ExtensionType } from '../../config';
5
+ import { Logger } from '../../logger';
6
+ import { TYPE_CHARACTERISTICS } from '../target';
7
+ import { Plist, Paths } from '../utils';
8
+
9
+ export const withTargetEntitlements: ConfigPlugin<{
10
+ targetName: string;
11
+ targetDirectory: string;
12
+ type: ExtensionType;
13
+ entitlements?: Record<string, any>;
14
+ logger: Logger;
15
+ }> = (config, props) => {
16
+ return withDangerousMod(config, [
17
+ 'ios',
18
+ async (config) => {
19
+ const typeConfig = TYPE_CHARACTERISTICS[props.type];
20
+
21
+ // Asset-only targets don't need entitlements
22
+ if (!typeConfig.requiresEntitlements) {
23
+ props.logger.log(
24
+ `Skipping entitlements for asset-only target ${props.targetName}`
25
+ );
26
+ return config;
27
+ }
28
+
29
+ let entitlements = props.entitlements || {};
30
+
31
+ // Add App Clip specific entitlements
32
+ if (props.type === 'clip') {
33
+ entitlements = Plist.mergeAppClipEntitlements(
34
+ entitlements,
35
+ config.ios!.bundleIdentifier!
36
+ );
37
+ }
38
+
39
+ // Sync App Groups if needed
40
+ if (Plist.shouldUseAppGroups(props.type)) {
41
+ const mainAppGroups = config.ios?.entitlements?.[
42
+ 'com.apple.security.application-groups'
43
+ ] as string[] | undefined;
44
+
45
+ entitlements = Plist.syncAppGroups({
46
+ targetEntitlements: entitlements,
47
+ mainAppGroups,
48
+ });
49
+
50
+ if (mainAppGroups && mainAppGroups.length > 0) {
51
+ props.logger.log(`Syncing app groups to ${props.targetName}`);
52
+ }
53
+ }
54
+
55
+ // NEW: Generate entitlements in targets/TARGETNAME/ios/build/
56
+ const entitlementsPath = Paths.getTargetEntitlementsPath({
57
+ projectRoot: config.modRequest.projectRoot,
58
+ targetDirectory: props.targetDirectory,
59
+ });
60
+
61
+ Plist.writePlist(entitlementsPath, entitlements);
62
+ props.logger.log(
63
+ `Generated entitlements: ${path.relative(config.modRequest.projectRoot, entitlementsPath)}`
64
+ );
65
+
66
+ return config;
67
+ },
68
+ ]);
69
+ };
@@ -0,0 +1,179 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+
5
+ import { withTargetEntitlements } from './withEntitlements';
6
+ import { withTargetPodfile } from './withPodfile';
7
+ import { withXcodeChanges } from './withXcodeChanges';
8
+ import {
9
+ TYPE_MINIMUM_DEPLOYMENT_TARGETS,
10
+ type ExtensionType,
11
+ type IOSTargetConfigWithReactNative,
12
+ } from '../../config';
13
+ import { Logger } from '../../logger';
14
+ import { Paths } from '../utils';
15
+
16
+ interface IOSTargetProps extends IOSTargetConfigWithReactNative {
17
+ type: ExtensionType;
18
+ name: string;
19
+ displayName?: string;
20
+ appGroup?: string;
21
+ entry?: string;
22
+ excludedPackages?: string[];
23
+ directory: string;
24
+ configPath: string;
25
+ logger: Logger;
26
+ }
27
+
28
+ export const withIOSTarget: ConfigPlugin<IOSTargetProps> = (config, props) => {
29
+ const targetName = props.displayName || props.name;
30
+ props.logger.log(`Configuring iOS target: ${targetName} (${props.type})`);
31
+
32
+ // Validate React Native compatibility
33
+ const REACT_NATIVE_COMPATIBLE_TYPES: ExtensionType[] = [
34
+ 'share',
35
+ 'action',
36
+ 'clip',
37
+ 'messages',
38
+ ];
39
+
40
+ // Validate entry field
41
+ if (props.entry) {
42
+ if (!REACT_NATIVE_COMPATIBLE_TYPES.includes(props.type)) {
43
+ throw new Error(
44
+ `Target '${props.name}' (type: ${props.type}) does not support React Native. ` +
45
+ `'entry' can only be used with: ${REACT_NATIVE_COMPATIBLE_TYPES.join(', ')}`
46
+ );
47
+ }
48
+
49
+ // Validate that the entry file exists
50
+ const projectRoot = config._internal?.projectRoot || process.cwd();
51
+ const entryPath = path.resolve(projectRoot, props.entry);
52
+ if (!fs.existsSync(entryPath)) {
53
+ throw new Error(
54
+ `Target '${props.name}': Entry file not found at ${props.entry}. ` +
55
+ `Resolved path: ${entryPath}`
56
+ );
57
+ }
58
+ }
59
+
60
+ // Validate excludedPackages
61
+ if (props.excludedPackages && !props.entry) {
62
+ props.logger.warn(
63
+ `excludedPackages specified for ${props.name} but no 'entry' field provided. ` +
64
+ `excludedPackages will be ignored.`
65
+ );
66
+ }
67
+
68
+ // Resolve appGroup (inherit from main app if not specified)
69
+ let appGroup = props.appGroup;
70
+ if (!appGroup) {
71
+ const mainAppGroups =
72
+ config.ios?.entitlements?.['com.apple.security.application-groups'];
73
+ if (Array.isArray(mainAppGroups) && mainAppGroups.length > 0) {
74
+ appGroup = mainAppGroups[0];
75
+ props.logger.log(`Inherited App Group: ${appGroup}`);
76
+ }
77
+ }
78
+
79
+ // Validate App Group for types that require it
80
+ const REQUIRES_APP_GROUP: ExtensionType[] = [
81
+ 'widget',
82
+ 'clip',
83
+ 'share',
84
+ 'bg-download',
85
+ ];
86
+ if (REQUIRES_APP_GROUP.includes(props.type) && !appGroup) {
87
+ throw new Error(
88
+ `Target '${props.name}' (type: ${props.type}) requires an App Group. ` +
89
+ `Specify 'appGroup' in defineTarget() or add App Groups to main app entitlements in app.json`
90
+ );
91
+ }
92
+
93
+ // Resolve deploymentTarget (type-aware default)
94
+ const typeMinimum =
95
+ TYPE_MINIMUM_DEPLOYMENT_TARGETS[
96
+ props.type as keyof typeof TYPE_MINIMUM_DEPLOYMENT_TARGETS
97
+ ];
98
+ const mainAppTarget = (config.ios as any)?.deploymentTarget;
99
+ let deploymentTarget = props.deploymentTarget;
100
+
101
+ if (!deploymentTarget) {
102
+ if (mainAppTarget && parseFloat(mainAppTarget) > parseFloat(typeMinimum)) {
103
+ deploymentTarget = mainAppTarget;
104
+ props.logger.log(`Inherited deployment target: ${deploymentTarget}`);
105
+ } else {
106
+ deploymentTarget = typeMinimum;
107
+ props.logger.log(
108
+ `Using type minimum deployment target: ${deploymentTarget}`
109
+ );
110
+ }
111
+ }
112
+
113
+ // React Native extensions require ExpoModulesCore, which has minimum iOS 15.1
114
+ // Ensure deployment target meets this requirement when using React Native (entry specified)
115
+ const EXPO_MODULES_MINIMUM = '15.1';
116
+ if (
117
+ props.entry &&
118
+ parseFloat(deploymentTarget!) < parseFloat(EXPO_MODULES_MINIMUM)
119
+ ) {
120
+ props.logger.log(
121
+ `React Native extension requires ExpoModulesCore (iOS ${EXPO_MODULES_MINIMUM}), ` +
122
+ `raising deployment target from ${deploymentTarget} to ${EXPO_MODULES_MINIMUM}`
123
+ );
124
+ deploymentTarget = EXPO_MODULES_MINIMUM;
125
+ }
126
+
127
+ // Inherit accent color
128
+ const colors = props.colors || {};
129
+ const mainAppAccentColor = (config.ios as any)?.accentColor;
130
+ if (!colors.$accent && mainAppAccentColor) {
131
+ colors.$accent = mainAppAccentColor;
132
+ props.logger.log(`Inherited accent color: ${mainAppAccentColor}`);
133
+ }
134
+
135
+ const targetProductName = Paths.sanitizeTargetName(targetName);
136
+
137
+ // Pass resolved values to withXcodeChanges
138
+ config = withXcodeChanges(config, {
139
+ ...props,
140
+ deploymentTarget,
141
+ colors: Object.keys(colors).length > 0 ? colors : undefined,
142
+ logger: props.logger,
143
+ });
144
+
145
+ // Add Podfile target only for code-based targets (skip asset-only like stickers)
146
+ // Extensions with React Native need full RN setup, others need standalone config
147
+ const { TYPE_CHARACTERISTICS } = require('../target');
148
+ const typeConfig = TYPE_CHARACTERISTICS[props.type];
149
+
150
+ if (typeConfig.requiresCode) {
151
+ config = withTargetPodfile(config, {
152
+ targetName: targetProductName, // Use sanitized name to match Xcode target
153
+ deploymentTarget: deploymentTarget!, // Guaranteed to be set by resolution logic above
154
+ extensionType: props.type,
155
+ excludedPackages: props.excludedPackages,
156
+ standalone: !props.entry, // Standalone (no dependency inheritance) if not using React Native
157
+ logger: props.logger,
158
+ });
159
+ } else {
160
+ props.logger.log(
161
+ `Skipping Podfile for asset-only target: ${targetProductName}`
162
+ );
163
+ }
164
+
165
+ config = withTargetEntitlements(config, {
166
+ targetName,
167
+ targetDirectory: props.directory,
168
+ type: props.type,
169
+ entitlements: props.entitlements,
170
+ logger: props.logger,
171
+ });
172
+
173
+ // Note: Color generation is handled in withXcodeChanges where colors are created
174
+ // in targets/[name]/ios/build/Assets.xcassets/ (not in ios/[TargetName]/)
175
+ // Note: Assets.xcassets is added in withXcodeChanges where we have direct access to target.uuid
176
+ // Note: Sticker packs are also created in withXcodeChanges for proper execution order
177
+
178
+ return config;
179
+ };
@@ -0,0 +1,29 @@
1
+ import { ConfigPlugin, withDangerousMod } from '@expo/config-plugins';
2
+
3
+ import { Asset, Paths } from '../utils';
4
+
5
+ export const withIosColorset: ConfigPlugin<{
6
+ name: string;
7
+ color: string;
8
+ darkColor?: string;
9
+ targetName: string;
10
+ }> = (config, props) => {
11
+ return withDangerousMod(config, [
12
+ 'ios',
13
+ async (config) => {
14
+ const colorsetPath = Paths.getColorsetPath({
15
+ platformProjectRoot: config.modRequest.platformProjectRoot,
16
+ targetName: props.targetName,
17
+ colorName: props.name,
18
+ });
19
+
20
+ Asset.createColorset({
21
+ colorsetPath,
22
+ color: props.color,
23
+ darkColor: props.darkColor,
24
+ });
25
+
26
+ return config;
27
+ },
28
+ ]);
29
+ };
@@ -0,0 +1,65 @@
1
+ import { ConfigPlugin, withDangerousMod } from '@expo/config-plugins';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ import { Asset, Paths } from '../utils';
6
+
7
+ export const withIosStickerPack: ConfigPlugin<{
8
+ name: string;
9
+ assets: string[];
10
+ targetName: string;
11
+ targetDirectory: string;
12
+ }> = (config, props) => {
13
+ return withDangerousMod(config, [
14
+ 'ios',
15
+ async (config) => {
16
+ const stickerPackPath = Paths.getStickerPackPath({
17
+ platformProjectRoot: config.modRequest.platformProjectRoot,
18
+ targetName: props.targetName,
19
+ stickerPackName: props.name,
20
+ });
21
+
22
+ Asset.createStickerPack({
23
+ stickerPackPath,
24
+ name: props.name,
25
+ assets: props.assets,
26
+ });
27
+
28
+ // Copy sticker assets to the pack
29
+ props.assets.forEach((assetPath) => {
30
+ const absoluteAssetPath = path.isAbsolute(assetPath)
31
+ ? assetPath
32
+ : path.join(
33
+ config.modRequest.projectRoot,
34
+ props.targetDirectory,
35
+ assetPath
36
+ );
37
+
38
+ if (fs.existsSync(absoluteAssetPath)) {
39
+ const filename = path.basename(assetPath);
40
+ const baseName = path.basename(assetPath, path.extname(assetPath));
41
+ const stickerDirPath = path.join(
42
+ stickerPackPath,
43
+ `${baseName}.sticker`
44
+ );
45
+
46
+ // Create .sticker directory with Contents.json
47
+ Asset.createSticker({
48
+ stickerPath: stickerDirPath,
49
+ filename,
50
+ });
51
+
52
+ // Copy image into .sticker directory
53
+ const destPath = path.join(stickerDirPath, filename);
54
+ fs.copyFileSync(absoluteAssetPath, destPath);
55
+ } else {
56
+ console.warn(
57
+ `[expo-targets] Sticker asset not found: ${absoluteAssetPath}`
58
+ );
59
+ }
60
+ });
61
+
62
+ return config;
63
+ },
64
+ ]);
65
+ };