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.
- package/.eslintrc.js +2 -0
- package/README.md +244 -0
- package/android/build.gradle +22 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsLogger.kt +98 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsReceiver.kt +136 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsRemoteViewsProvider.kt +72 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetProvider.kt +47 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetSync.kt +78 -0
- package/android/src/main/java/expo/modules/targets/ExpoTargetsWidgetUpdateReceiver.kt +30 -0
- package/android/src/main/java/expo/modules/targets/extension/ExpoTargetsExtensionModule.kt +27 -0
- package/android/src/main/java/expo/modules/targets/messages/ExpoTargetsMessagesModule.kt +40 -0
- package/android/src/main/java/expo/modules/targets/storage/ExpoTargetsStorageModule.kt +119 -0
- package/app.plugin.js +1 -0
- package/build/metro/src/index.d.ts +2 -0
- package/build/metro/src/index.d.ts.map +1 -0
- package/build/metro/src/index.js +6 -0
- package/build/metro/src/index.js.map +1 -0
- package/build/metro/src/withTargetsMetro.d.ts +6 -0
- package/build/metro/src/withTargetsMetro.d.ts.map +1 -0
- package/build/metro/src/withTargetsMetro.js +171 -0
- package/build/metro/src/withTargetsMetro.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.js +56 -0
- package/build/plugin/src/android/config-plugins/withAndroidColors.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.js +70 -0
- package/build/plugin/src/android/config-plugins/withAndroidManifest.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.js +41 -0
- package/build/plugin/src/android/config-plugins/withAndroidModule.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.js +75 -0
- package/build/plugin/src/android/config-plugins/withAndroidResources.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.d.ts +28 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.js +28 -0
- package/build/plugin/src/android/config-plugins/withAndroidTarget.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.js +86 -0
- package/build/plugin/src/android/config-plugins/withGradleModule.js.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.d.ts +7 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.d.ts.map +1 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.js +23 -0
- package/build/plugin/src/android/config-plugins/withGradleSettings.js.map +1 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.d.ts +7 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.js +31 -0
- package/build/plugin/src/android/withAndroidAppBuildGradle.js.map +1 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.d.ts +3 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.js +24 -0
- package/build/plugin/src/android/withAndroidKotlinGradleProperty.js.map +1 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.d.ts +3 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.js +27 -0
- package/build/plugin/src/android/withAndroidProjectKotlinVersion.js.map +1 -0
- package/build/plugin/src/android/withAndroidTarget.d.ts +10 -0
- package/build/plugin/src/android/withAndroidTarget.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidTarget.js +22 -0
- package/build/plugin/src/android/withAndroidTarget.js.map +1 -0
- package/build/plugin/src/android/withAndroidWidget.d.ts +13 -0
- package/build/plugin/src/android/withAndroidWidget.d.ts.map +1 -0
- package/build/plugin/src/android/withAndroidWidget.js +564 -0
- package/build/plugin/src/android/withAndroidWidget.js.map +1 -0
- package/build/plugin/src/config.d.ts +141 -0
- package/build/plugin/src/config.d.ts.map +1 -0
- package/build/plugin/src/config.js +54 -0
- package/build/plugin/src/config.js.map +1 -0
- package/build/plugin/src/index.d.ts +9 -0
- package/build/plugin/src/index.d.ts.map +1 -0
- package/build/plugin/src/index.js +11 -0
- package/build/plugin/src/index.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts +11 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.js +49 -0
- package/build/plugin/src/ios/config-plugins/withEntitlements.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts +17 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.js +152 -0
- package/build/plugin/src/ios/config-plugins/withIOSTarget.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.d.ts +8 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.js +25 -0
- package/build/plugin/src/ios/config-plugins/withIosColorset.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.d.ts +8 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.js +52 -0
- package/build/plugin/src/ios/config-plugins/withIosStickerPack.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.d.ts +12 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.js +162 -0
- package/build/plugin/src/ios/config-plugins/withPodfile.js.map +1 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts +15 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.d.ts.map +1 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.js +646 -0
- package/build/plugin/src/ios/config-plugins/withXcodeChanges.js.map +1 -0
- package/build/plugin/src/ios/target.d.ts +41 -0
- package/build/plugin/src/ios/target.d.ts.map +1 -0
- package/build/plugin/src/ios/target.js +574 -0
- package/build/plugin/src/ios/target.js.map +1 -0
- package/build/plugin/src/ios/utils/asset.d.ts +60 -0
- package/build/plugin/src/ios/utils/asset.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/asset.js +375 -0
- package/build/plugin/src/ios/utils/asset.js.map +1 -0
- package/build/plugin/src/ios/utils/file.d.ts +33 -0
- package/build/plugin/src/ios/utils/file.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/file.js +88 -0
- package/build/plugin/src/ios/utils/file.js.map +1 -0
- package/build/plugin/src/ios/utils/index.d.ts +12 -0
- package/build/plugin/src/ios/utils/index.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/index.js +38 -0
- package/build/plugin/src/ios/utils/index.js.map +1 -0
- package/build/plugin/src/ios/utils/paths.d.ts +128 -0
- package/build/plugin/src/ios/utils/paths.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/paths.js +141 -0
- package/build/plugin/src/ios/utils/paths.js.map +1 -0
- package/build/plugin/src/ios/utils/plist.d.ts +29 -0
- package/build/plugin/src/ios/utils/plist.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/plist.js +114 -0
- package/build/plugin/src/ios/utils/plist.js.map +1 -0
- package/build/plugin/src/ios/utils/podfile.d.ts +82 -0
- package/build/plugin/src/ios/utils/podfile.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/podfile.js +408 -0
- package/build/plugin/src/ios/utils/podfile.js.map +1 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.d.ts +11 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.js +263 -0
- package/build/plugin/src/ios/utils/reactNativeSwift.js.map +1 -0
- package/build/plugin/src/ios/utils/xcode.d.ts +185 -0
- package/build/plugin/src/ios/utils/xcode.d.ts.map +1 -0
- package/build/plugin/src/ios/utils/xcode.js +706 -0
- package/build/plugin/src/ios/utils/xcode.js.map +1 -0
- package/build/plugin/src/logger.d.ts +10 -0
- package/build/plugin/src/logger.d.ts.map +1 -0
- package/build/plugin/src/logger.js +62 -0
- package/build/plugin/src/logger.js.map +1 -0
- package/build/plugin/src/parseTargetConfig.d.ts +3 -0
- package/build/plugin/src/parseTargetConfig.d.ts.map +1 -0
- package/build/plugin/src/parseTargetConfig.js +113 -0
- package/build/plugin/src/parseTargetConfig.js.map +1 -0
- package/build/plugin/src/withTargetsDir.d.ts +6 -0
- package/build/plugin/src/withTargetsDir.d.ts.map +1 -0
- package/build/plugin/src/withTargetsDir.js +90 -0
- package/build/plugin/src/withTargetsDir.js.map +1 -0
- package/build/src/Target.d.ts +43 -0
- package/build/src/Target.d.ts.map +1 -0
- package/build/src/Target.js +128 -0
- package/build/src/Target.js.map +1 -0
- package/build/src/index.d.ts +9 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +27 -0
- package/build/src/index.js.map +1 -0
- package/build/src/modules/extension/index.d.ts +18 -0
- package/build/src/modules/extension/index.d.ts.map +1 -0
- package/build/src/modules/extension/index.js +44 -0
- package/build/src/modules/extension/index.js.map +1 -0
- package/build/src/modules/messages/index.d.ts +40 -0
- package/build/src/modules/messages/index.d.ts.map +1 -0
- package/build/src/modules/messages/index.js +94 -0
- package/build/src/modules/messages/index.js.map +1 -0
- package/build/src/modules/storage/index.d.ts +16 -0
- package/build/src/modules/storage/index.d.ts.map +1 -0
- package/build/src/modules/storage/index.js +122 -0
- package/build/src/modules/storage/index.js.map +1 -0
- package/expo-module.config.json +17 -0
- package/ios/ExpoTargetsExtension.podspec +23 -0
- package/ios/ExpoTargetsExtensionModule.swift +181 -0
- package/ios/ExpoTargetsMessages.podspec +23 -0
- package/ios/ExpoTargetsMessagesModule.swift +267 -0
- package/ios/ExpoTargetsStorage.podspec +23 -0
- package/ios/ExpoTargetsStorageModule.swift +91 -0
- package/ios/Tests/.swiftlint.yml +52 -0
- package/ios/Tests/Helpers/MockExtensionContext.swift +58 -0
- package/ios/Tests/Helpers/MockUserDefaults.swift +70 -0
- package/ios/Tests/Helpers/MockWidgetCenter.swift +71 -0
- package/ios/Tests/Helpers/TestHelpers.swift +90 -0
- package/ios/Tests/Integration/TargetIntegrationTests.swift +478 -0
- package/ios/Tests/Main/AllTests.swift +80 -0
- package/ios/Tests/Package.swift +66 -0
- package/ios/Tests/Performance/StoragePerformanceTests.swift +461 -0
- package/ios/Tests/Unit/Extension/ExpoTargetsExtensionModuleTests.swift +501 -0
- package/ios/Tests/Unit/Storage/ExpoTargetsStorageModuleTests.swift +578 -0
- package/ios/Tests/Unit/Template/ShareExtensionTemplateTests.swift +421 -0
- package/ios/Tests/XCTestPlan.xctestplan +87 -0
- package/metro/src/index.ts +1 -0
- package/metro/src/withTargetsMetro.ts +247 -0
- package/metro/tsconfig.build.json +9 -0
- package/package.json +74 -0
- package/plugin/src/android/withAndroidAppBuildGradle.ts +34 -0
- package/plugin/src/android/withAndroidTarget.ts +26 -0
- package/plugin/src/android/withAndroidWidget.ts +778 -0
- package/plugin/src/config.ts +255 -0
- package/plugin/src/index.ts +19 -0
- package/plugin/src/ios/config-plugins/withEntitlements.ts +69 -0
- package/plugin/src/ios/config-plugins/withIOSTarget.ts +179 -0
- package/plugin/src/ios/config-plugins/withIosColorset.ts +29 -0
- package/plugin/src/ios/config-plugins/withIosStickerPack.ts +65 -0
- package/plugin/src/ios/config-plugins/withPodfile.ts +238 -0
- package/plugin/src/ios/config-plugins/withXcodeChanges.ts +891 -0
- package/plugin/src/ios/target.ts +668 -0
- package/plugin/src/ios/templates/MessagesViewController.swift +120 -0
- package/plugin/src/ios/templates/ReactNativeViewController.swift +240 -0
- package/plugin/src/ios/templates/action-extension-data.swift +106 -0
- package/plugin/src/ios/templates/clip-extension-data.swift +28 -0
- package/plugin/src/ios/templates/messages-extension-data.swift +28 -0
- package/plugin/src/ios/templates/share-extension-data.swift +113 -0
- package/plugin/src/ios/utils/asset.ts +490 -0
- package/plugin/src/ios/utils/file.ts +80 -0
- package/plugin/src/ios/utils/index.ts +12 -0
- package/plugin/src/ios/utils/paths.ts +253 -0
- package/plugin/src/ios/utils/plist.ts +101 -0
- package/plugin/src/ios/utils/podfile.ts +534 -0
- package/plugin/src/ios/utils/reactNativeSwift.ts +283 -0
- package/plugin/src/ios/utils/xcode.ts +989 -0
- package/plugin/src/logger.ts +63 -0
- package/plugin/src/parseTargetConfig.ts +115 -0
- package/plugin/src/types/normalize-colors.d.ts +3 -0
- package/plugin/src/withTargetsDir.ts +120 -0
- package/plugin/tsconfig.build.json +9 -0
- package/plugin/tsconfig.json +9 -0
- package/src/Target.ts +239 -0
- package/src/index.ts +52 -0
- package/src/modules/extension/index.ts +54 -0
- package/src/modules/messages/index.ts +124 -0
- package/src/modules/storage/index.ts +126 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.targets
|
|
2
|
+
|
|
3
|
+
import android.content.BroadcastReceiver
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import androidx.glance.appwidget.GlanceAppWidget
|
|
7
|
+
import kotlinx.coroutines.CoroutineScope
|
|
8
|
+
import kotlinx.coroutines.Dispatchers
|
|
9
|
+
import kotlinx.coroutines.launch
|
|
10
|
+
import kotlin.reflect.KClass
|
|
11
|
+
|
|
12
|
+
/** Base receiver for widget updates. Syncs SharedPreferences → Glance state automatically. */
|
|
13
|
+
abstract class ExpoTargetsWidgetUpdateReceiver<T : GlanceAppWidget>(
|
|
14
|
+
private val widgetClass: KClass<T>,
|
|
15
|
+
private val prefsName: String
|
|
16
|
+
) : BroadcastReceiver() {
|
|
17
|
+
|
|
18
|
+
override fun onReceive(context: Context, intent: Intent) {
|
|
19
|
+
ExpoTargetsLogger.init(context)
|
|
20
|
+
|
|
21
|
+
CoroutineScope(Dispatchers.IO).launch {
|
|
22
|
+
try {
|
|
23
|
+
ExpoTargetsWidgetSync.syncAndUpdate(context, widgetClass, prefsName)
|
|
24
|
+
} catch (e: Exception) {
|
|
25
|
+
ExpoTargetsLogger.e("UpdateReceiver", "Sync failed: ${widgetClass.simpleName}", e)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package expo.modules.targets.extension
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class ExpoTargetsExtensionModule : Module() {
|
|
7
|
+
override fun definition() = ModuleDefinition {
|
|
8
|
+
Name("ExpoTargetsExtension")
|
|
9
|
+
|
|
10
|
+
Function("closeExtension") {
|
|
11
|
+
// Android: Close the current activity/extension
|
|
12
|
+
// Implementation depends on context - for now, stub
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
Function("openHostApp") { path: String ->
|
|
16
|
+
// Android: Open the host app with a specific path
|
|
17
|
+
// Implementation will use Intent to launch main app
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Function("getSharedData") {
|
|
21
|
+
// Android: Get data shared to the extension
|
|
22
|
+
// Will extract data from Intent extras
|
|
23
|
+
return@Function null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package expo.modules.targets.messages
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class ExpoTargetsMessagesModule : Module() {
|
|
7
|
+
override fun definition() = ModuleDefinition {
|
|
8
|
+
Name("ExpoTargetsMessages")
|
|
9
|
+
|
|
10
|
+
// Android doesn't have iMessage equivalent
|
|
11
|
+
// These are stubs to maintain API compatibility
|
|
12
|
+
|
|
13
|
+
Function("getPresentationStyle") {
|
|
14
|
+
return@Function null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Function("requestPresentationStyle") { style: String ->
|
|
18
|
+
// No-op on Android
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Function("sendMessage") { layout: Map<String, Any?> ->
|
|
22
|
+
// No-op on Android
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Function("sendUpdate") { layout: Map<String, Any?>, sessionId: String ->
|
|
26
|
+
// No-op on Android
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
Function("createSession") {
|
|
30
|
+
return@Function ""
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Function("getConversationInfo") {
|
|
34
|
+
return@Function null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Events("onPresentationStyleChange")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
package expo.modules.targets.storage
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.SharedPreferences
|
|
5
|
+
import expo.modules.kotlin.modules.Module
|
|
6
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
7
|
+
import expo.modules.targets.ExpoTargetsLogger
|
|
8
|
+
import expo.modules.targets.ExpoTargetsReceiver
|
|
9
|
+
|
|
10
|
+
class ExpoTargetsStorageModule : Module() {
|
|
11
|
+
companion object {
|
|
12
|
+
private const val TAG = "Storage"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun definition() = ModuleDefinition {
|
|
16
|
+
Name("ExpoTargetsStorage")
|
|
17
|
+
|
|
18
|
+
OnCreate {
|
|
19
|
+
appContext.reactContext?.let { ExpoTargetsLogger.init(it) }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Function("setInt") { key: String, value: Int, suite: String? ->
|
|
23
|
+
ExpoTargetsLogger.d(TAG, "setInt: key=$key, value=$value, suite=$suite")
|
|
24
|
+
val prefs = getSharedPreferences(suite)
|
|
25
|
+
prefs.edit().putInt(key, value).commit().also { success ->
|
|
26
|
+
ExpoTargetsLogger.d(TAG, "setInt committed: $success")
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Function("setString") { key: String, value: String, suite: String? ->
|
|
31
|
+
ExpoTargetsLogger.d(TAG, "setString: key=$key, value=$value, suite=$suite")
|
|
32
|
+
val prefs = getSharedPreferences(suite)
|
|
33
|
+
prefs.edit().putString(key, value).commit().also { success ->
|
|
34
|
+
ExpoTargetsLogger.d(TAG, "setString committed: $success")
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Function("setObject") { key: String, value: Map<String, Any?>, suite: String? ->
|
|
39
|
+
ExpoTargetsLogger.d(TAG, "setObject: key=$key, value=$value, suite=$suite")
|
|
40
|
+
val prefs = getSharedPreferences(suite)
|
|
41
|
+
// Convert map to JSON string for storage
|
|
42
|
+
val jsonString = value.entries.joinToString(",", "{", "}") { (k, v) ->
|
|
43
|
+
"\"$k\":${when (v) {
|
|
44
|
+
is String -> "\"$v\""
|
|
45
|
+
is Number -> v.toString()
|
|
46
|
+
is Boolean -> v.toString()
|
|
47
|
+
null -> "null"
|
|
48
|
+
else -> "\"$v\""
|
|
49
|
+
}}"
|
|
50
|
+
}
|
|
51
|
+
val success = prefs.edit().putString(key, jsonString).commit()
|
|
52
|
+
ExpoTargetsLogger.d(TAG, "setObject committed: $success, json=$jsonString")
|
|
53
|
+
return@Function success
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Function("get") { key: String, suite: String? ->
|
|
57
|
+
val prefs = getSharedPreferences(suite)
|
|
58
|
+
val value = prefs.getString(key, null)
|
|
59
|
+
ExpoTargetsLogger.d(TAG, "get: key=$key, suite=$suite, value=$value")
|
|
60
|
+
return@Function value
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Function("remove") { key: String, suite: String? ->
|
|
64
|
+
ExpoTargetsLogger.d(TAG, "remove: key=$key, suite=$suite")
|
|
65
|
+
val prefs = getSharedPreferences(suite)
|
|
66
|
+
prefs.edit().remove(key).commit()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Function("getAllKeys") { suite: String? ->
|
|
70
|
+
val prefs = getSharedPreferences(suite)
|
|
71
|
+
val keys = prefs.all.keys.toList()
|
|
72
|
+
ExpoTargetsLogger.d(TAG, "getAllKeys: suite=$suite, keys=$keys")
|
|
73
|
+
return@Function keys
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
Function("getAllData") { suite: String? ->
|
|
77
|
+
val prefs = getSharedPreferences(suite)
|
|
78
|
+
val data = prefs.all
|
|
79
|
+
ExpoTargetsLogger.d(TAG, "getAllData: suite=$suite, data=$data")
|
|
80
|
+
return@Function data
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Function("clearAll") { suite: String? ->
|
|
84
|
+
ExpoTargetsLogger.d(TAG, "clearAll: suite=$suite")
|
|
85
|
+
val prefs = getSharedPreferences(suite)
|
|
86
|
+
prefs.edit().clear().commit()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Function("refreshTarget") { name: String? ->
|
|
90
|
+
ExpoTargetsLogger.d(TAG, "refreshTarget called: name=$name")
|
|
91
|
+
val context = appContext.reactContext
|
|
92
|
+
if (context == null) {
|
|
93
|
+
ExpoTargetsLogger.w(TAG, "refreshTarget: React context is null, cannot refresh")
|
|
94
|
+
return@Function
|
|
95
|
+
}
|
|
96
|
+
if (name != null) {
|
|
97
|
+
ExpoTargetsLogger.d(TAG, "refreshTarget: Calling ExpoTargetsReceiver.refreshWidget for '$name'")
|
|
98
|
+
ExpoTargetsReceiver.refreshWidget(context, name)
|
|
99
|
+
} else {
|
|
100
|
+
ExpoTargetsLogger.w(TAG, "refreshTarget: name is null, skipping refresh")
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
Function("getTargetsConfig") {
|
|
105
|
+
// Android: Read targets configuration
|
|
106
|
+
// Will read from app resources or manifest metadata
|
|
107
|
+
ExpoTargetsLogger.d(TAG, "getTargetsConfig called")
|
|
108
|
+
return@Function null
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private fun getSharedPreferences(suite: String?): SharedPreferences {
|
|
113
|
+
val context = appContext.reactContext ?: throw IllegalStateException("React context is null")
|
|
114
|
+
val prefsName = suite ?: "${context.packageName}_preferences"
|
|
115
|
+
ExpoTargetsLogger.d(TAG, "getSharedPreferences: prefsName=$prefsName")
|
|
116
|
+
return context.getSharedPreferences(prefsName, Context.MODE_PRIVATE)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/index');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../metro/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withTargetsMetro = void 0;
|
|
4
|
+
var withTargetsMetro_1 = require("./withTargetsMetro");
|
|
5
|
+
Object.defineProperty(exports, "withTargetsMetro", { enumerable: true, get: function () { return withTargetsMetro_1.withTargetsMetro; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../metro/src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTargetsMetro.d.ts","sourceRoot":"","sources":["../../../metro/src/withTargetsMetro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAkGhD,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACA,WAAW,CA6Ib"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.withTargetsMetro = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
function scanTargetsDirectory(projectRoot) {
|
|
30
|
+
console.log(`[expo-targets-metro] 🔍 Scanning targets directory...`);
|
|
31
|
+
console.log(`[expo-targets-metro] Project root: ${projectRoot}`);
|
|
32
|
+
const targetsDir = path.join(projectRoot, 'targets');
|
|
33
|
+
console.log(`[expo-targets-metro] Targets dir: ${targetsDir}`);
|
|
34
|
+
const entryPoints = [];
|
|
35
|
+
if (!fs.existsSync(targetsDir)) {
|
|
36
|
+
console.log(`[expo-targets-metro] ⚠️ Targets directory does not exist`);
|
|
37
|
+
return entryPoints;
|
|
38
|
+
}
|
|
39
|
+
const targetDirs = fs.readdirSync(targetsDir, { withFileTypes: true });
|
|
40
|
+
console.log(`[expo-targets-metro] Found ${targetDirs.length} items in targets directory`);
|
|
41
|
+
for (const dir of targetDirs) {
|
|
42
|
+
if (!dir.isDirectory()) {
|
|
43
|
+
console.log(`[expo-targets-metro] ⏭ Skipping non-directory: ${dir.name}`);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
console.log(`[expo-targets-metro] 📁 Checking target: ${dir.name}`);
|
|
47
|
+
const configPath = path.join(targetsDir, dir.name, 'expo-target.config.json');
|
|
48
|
+
if (!fs.existsSync(configPath)) {
|
|
49
|
+
console.log(`[expo-targets-metro] ⚠️ No config found at: ${configPath}`);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const configContent = fs.readFileSync(configPath, 'utf-8');
|
|
54
|
+
const config = JSON.parse(configContent);
|
|
55
|
+
console.log(`[expo-targets-metro] ✅ Config loaded: name="${config.name}", entry="${config.entry}"`);
|
|
56
|
+
// Check if config has entry field
|
|
57
|
+
if (config.entry) {
|
|
58
|
+
const entryPath = path.resolve(projectRoot, config.entry);
|
|
59
|
+
console.log(`[expo-targets-metro] 📝 Resolved entry path: ${entryPath}`);
|
|
60
|
+
console.log(`[expo-targets-metro] 📝 Entry exists: ${fs.existsSync(entryPath)}`);
|
|
61
|
+
entryPoints.push({
|
|
62
|
+
targetName: config.name || dir.name,
|
|
63
|
+
entryPath,
|
|
64
|
+
excludedPackages: config.excludedPackages,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.log(`[expo-targets-metro] ⏭ No entry field in config`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.warn(`[expo-targets-metro] Failed to parse config for ${dir.name}:`, error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
console.log(`[expo-targets-metro] 📊 Total entry points found: ${entryPoints.length}`);
|
|
76
|
+
return entryPoints;
|
|
77
|
+
}
|
|
78
|
+
function withTargetsMetro(metroConfig, options) {
|
|
79
|
+
console.log(`\n[expo-targets-metro] 🚀 Initializing Metro configuration...`);
|
|
80
|
+
const projectRoot = options?.projectRoot || process.cwd();
|
|
81
|
+
console.log(`[expo-targets-metro] 📂 Using project root: ${projectRoot}`);
|
|
82
|
+
const targetEntryPoints = scanTargetsDirectory(projectRoot);
|
|
83
|
+
if (targetEntryPoints.length > 0) {
|
|
84
|
+
console.log(`\n[expo-targets-metro] ✅ Found ${targetEntryPoints.length} target(s) with React Native entry points:`);
|
|
85
|
+
targetEntryPoints.forEach((t) => {
|
|
86
|
+
console.log(` - ${t.targetName}: ${t.entryPath}`);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
console.log(`\n[expo-targets-metro] ⚠️ No targets with React Native entry points found`);
|
|
91
|
+
}
|
|
92
|
+
// Create a map for quick lookup of target names to bundle roots and entry paths
|
|
93
|
+
const targetMap = new Map();
|
|
94
|
+
targetEntryPoints.forEach((target) => {
|
|
95
|
+
// Calculate the bundle root that would be used in ReactNativeViewController
|
|
96
|
+
// e.g., "./targets/rn-share/index.tsx" -> "targets/rn-share/index"
|
|
97
|
+
const relativeEntry = path.relative(projectRoot, target.entryPath);
|
|
98
|
+
const bundleRoot = relativeEntry.replace(/\.(tsx?|jsx?)$/, '');
|
|
99
|
+
targetMap.set(target.targetName, {
|
|
100
|
+
bundleRoot,
|
|
101
|
+
entryPath: target.entryPath,
|
|
102
|
+
});
|
|
103
|
+
console.log(`[expo-targets-metro] 📌 Registered: ${target.targetName} -> "${bundleRoot}"`);
|
|
104
|
+
});
|
|
105
|
+
const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
|
|
106
|
+
const originalRewriteRequestUrl = metroConfig.server?.rewriteRequestUrl;
|
|
107
|
+
console.log(`[expo-targets-metro] 🔧 Setting up URL rewriting for target entry points...`);
|
|
108
|
+
return {
|
|
109
|
+
...metroConfig,
|
|
110
|
+
resolver: {
|
|
111
|
+
...metroConfig.resolver,
|
|
112
|
+
// Keep custom resolver for initial module resolution
|
|
113
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
114
|
+
// Check if module matches any target bundle root
|
|
115
|
+
const normalizedModuleName = moduleName.replace(/^\.\//, '');
|
|
116
|
+
for (const [targetName, { bundleRoot, entryPath },] of targetMap.entries()) {
|
|
117
|
+
if (normalizedModuleName === bundleRoot ||
|
|
118
|
+
normalizedModuleName.startsWith(bundleRoot)) {
|
|
119
|
+
console.log(`[expo-targets-metro] ✅ Resolved "${moduleName}" -> "${entryPath}"`);
|
|
120
|
+
return {
|
|
121
|
+
type: 'sourceFile',
|
|
122
|
+
filePath: entryPath,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Fall back to default resolver
|
|
127
|
+
return context.resolveRequest(context, moduleName, platform);
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
server: {
|
|
131
|
+
...metroConfig.server,
|
|
132
|
+
rewriteRequestUrl: (url) => {
|
|
133
|
+
// Apply original URL rewrite first
|
|
134
|
+
const rewrittenUrl = originalRewriteRequestUrl
|
|
135
|
+
? originalRewriteRequestUrl(url)
|
|
136
|
+
: url;
|
|
137
|
+
// Check for target query parameter
|
|
138
|
+
const targetMatch = rewrittenUrl.match(/[?&]target=([^&]+)/);
|
|
139
|
+
if (targetMatch) {
|
|
140
|
+
const targetName = targetMatch[1];
|
|
141
|
+
const targetInfo = targetMap.get(targetName);
|
|
142
|
+
if (targetInfo) {
|
|
143
|
+
console.log(`[expo-targets-metro] 🔄 Rewriting URL for target: ${targetName}`);
|
|
144
|
+
// Keep the bundle root in the URL but flag it as a target bundle
|
|
145
|
+
return rewrittenUrl.replace('index.bundle', `index.${targetName}.bundle`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return rewrittenUrl;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
transformer: {
|
|
152
|
+
...metroConfig.transformer,
|
|
153
|
+
getTransformOptions: async (entryPoints, options, getDependenciesOf) => {
|
|
154
|
+
console.log(`[expo-targets-metro] 🔄 Transform requested for entry points:`, entryPoints);
|
|
155
|
+
const transformOptions = originalGetTransformOptions
|
|
156
|
+
? await originalGetTransformOptions(entryPoints, options, getDependenciesOf)
|
|
157
|
+
: {};
|
|
158
|
+
return {
|
|
159
|
+
...transformOptions,
|
|
160
|
+
transform: {
|
|
161
|
+
...transformOptions.transform,
|
|
162
|
+
experimentalImportSupport: false,
|
|
163
|
+
inlineRequires: true,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
exports.withTargetsMetro = withTargetsMetro;
|
|
171
|
+
//# sourceMappingURL=withTargetsMetro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTargetsMetro.js","sourceRoot":"","sources":["../../../metro/src/withTargetsMetro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,2CAA6B;AAiB7B,SAAS,oBAAoB,CAAC,WAAmB;IAC/C,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,wCAAwC,WAAW,EAAE,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,uCAAuC,UAAU,EAAE,CAAC,CAAC;IAEjE,MAAM,WAAW,GAAuB,EAAE,CAAC;IAE3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAC;QAC3E,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,UAAU,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,OAAO,CAAC,GAAG,CACT,gCAAgC,UAAU,CAAC,MAAM,6BAA6B,CAC/E,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CACT,qDAAqD,GAAG,CAAC,IAAI,EAAE,CAChE,CAAC;YACF,SAAS;QACX,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,8CAA8C,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+
/**
|
|
4
|
+
* Generates color resources for Android
|
|
5
|
+
*/
|
|
6
|
+
export declare const withAndroidColors: ConfigPlugin<AndroidTargetOptions>;
|
|
7
|
+
//# sourceMappingURL=withAndroidColors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAndroidColors.d.ts","sourceRoot":"","sources":["../../../../../plugin/src/android/config-plugins/withAndroidColors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,sBAAsB,CAAC;AAItE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,oBAAoB,CAsChE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.withAndroidColors = void 0;
|
|
7
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
/**
|
|
11
|
+
* Generates color resources for Android
|
|
12
|
+
*/
|
|
13
|
+
const withAndroidColors = (config, options) => {
|
|
14
|
+
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
15
|
+
'android',
|
|
16
|
+
async (config) => {
|
|
17
|
+
const { platformProjectRoot } = config.modRequest;
|
|
18
|
+
const { name, colors } = options;
|
|
19
|
+
if (!colors || Object.keys(colors).length === 0) {
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
const modulePath = path_1.default.join(platformProjectRoot, name);
|
|
23
|
+
const resPath = path_1.default.join(modulePath, 'src', 'main', 'res');
|
|
24
|
+
// Create res/values directory
|
|
25
|
+
const valuesPath = path_1.default.join(resPath, 'values');
|
|
26
|
+
fs_1.default.mkdirSync(valuesPath, { recursive: true });
|
|
27
|
+
// Create res/values-night directory
|
|
28
|
+
const valuesNightPath = path_1.default.join(resPath, 'values-night');
|
|
29
|
+
fs_1.default.mkdirSync(valuesNightPath, { recursive: true });
|
|
30
|
+
// Generate light colors
|
|
31
|
+
const lightColorsPath = path_1.default.join(valuesPath, 'colors.xml');
|
|
32
|
+
const lightColorsContent = generateColorsXml(colors, 'light');
|
|
33
|
+
fs_1.default.writeFileSync(lightColorsPath, lightColorsContent, 'utf-8');
|
|
34
|
+
// Generate dark colors
|
|
35
|
+
const darkColorsPath = path_1.default.join(valuesNightPath, 'colors.xml');
|
|
36
|
+
const darkColorsContent = generateColorsXml(colors, 'dark');
|
|
37
|
+
fs_1.default.writeFileSync(darkColorsPath, darkColorsContent, 'utf-8');
|
|
38
|
+
return config;
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
};
|
|
42
|
+
exports.withAndroidColors = withAndroidColors;
|
|
43
|
+
function generateColorsXml(colors, mode) {
|
|
44
|
+
const colorEntries = Object.entries(colors)
|
|
45
|
+
.map(([name, value]) => {
|
|
46
|
+
const colorValue = value[mode];
|
|
47
|
+
return ` <color name="${name}">${colorValue}</color>`;
|
|
48
|
+
})
|
|
49
|
+
.join('\n');
|
|
50
|
+
return `<?xml version="1.0" encoding="utf-8"?>
|
|
51
|
+
<resources>
|
|
52
|
+
${colorEntries}
|
|
53
|
+
</resources>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=withAndroidColors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAndroidColors.js","sourceRoot":"","sources":["../../../../../plugin/src/android/config-plugins/withAndroidColors.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAsE;AACtE,4CAAoB;AACpB,gDAAwB;AAIxB;;GAEG;AACI,MAAM,iBAAiB,GAAuC,CACnE,MAAM,EACN,OAAO,EACP,EAA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;YAChE,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC5D,YAAE,CAAC,aAAa,CAAC,cAAc,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;YAE7D,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAtCW,QAAA,iBAAiB,qBAsC5B;AAEF,SAAS,iBAAiB,CACxB,MAAuD,EACvD,IAAsB;IAEtB,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SACxC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACrB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,oBAAoB,IAAI,KAAK,UAAU,UAAU,CAAC;IAC3D,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;EAEP,YAAY;;CAEb,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import { AndroidTargetOptions } from './withAndroidTarget';
|
|
3
|
+
/**
|
|
4
|
+
* Adds widget receiver to AndroidManifest.xml
|
|
5
|
+
*/
|
|
6
|
+
export declare const withAndroidManifest: ConfigPlugin<AndroidTargetOptions>;
|
|
7
|
+
//# sourceMappingURL=withAndroidManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAndroidManifest.d.ts","sourceRoot":"","sources":["../../../../../plugin/src/android/config-plugins/withAndroidManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAEb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,oBAAoB,CAqFlE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withAndroidManifest = void 0;
|
|
4
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
5
|
+
/**
|
|
6
|
+
* Adds widget receiver to AndroidManifest.xml
|
|
7
|
+
*/
|
|
8
|
+
const withAndroidManifest = (config, options) => {
|
|
9
|
+
return (0, config_plugins_1.withAndroidManifest)(config, async (config) => {
|
|
10
|
+
const { modResults } = config;
|
|
11
|
+
const { type, packageName, displayName, updatePeriodMillis = 1800000, resizeMode = 'horizontal|vertical', widgetCategory = 'home_screen', permissions = [], } = options;
|
|
12
|
+
if (type !== 'widget') {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
15
|
+
// Get main application element
|
|
16
|
+
const mainApplication = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(modResults);
|
|
17
|
+
// Widget receiver class name
|
|
18
|
+
const receiverName = `${packageName}.${options.name}Receiver`;
|
|
19
|
+
// Check if receiver already exists
|
|
20
|
+
const existingReceiver = mainApplication.receiver?.find((r) => r.$?.['android:name'] === receiverName);
|
|
21
|
+
if (!existingReceiver) {
|
|
22
|
+
// Add receiver
|
|
23
|
+
if (!mainApplication.receiver) {
|
|
24
|
+
mainApplication.receiver = [];
|
|
25
|
+
}
|
|
26
|
+
mainApplication.receiver.push({
|
|
27
|
+
$: {
|
|
28
|
+
'android:name': receiverName,
|
|
29
|
+
'android:exported': 'false',
|
|
30
|
+
},
|
|
31
|
+
'intent-filter': [
|
|
32
|
+
{
|
|
33
|
+
action: [
|
|
34
|
+
{
|
|
35
|
+
$: {
|
|
36
|
+
'android:name': 'android.appwidget.action.APPWIDGET_UPDATE',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
'meta-data': [
|
|
43
|
+
{
|
|
44
|
+
$: {
|
|
45
|
+
'android:name': 'android.appwidget.provider',
|
|
46
|
+
'android:resource': `@xml/${options.name.toLowerCase()}_info`,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Add permissions if any
|
|
53
|
+
if (permissions.length > 0) {
|
|
54
|
+
if (!modResults.manifest['uses-permission']) {
|
|
55
|
+
modResults.manifest['uses-permission'] = [];
|
|
56
|
+
}
|
|
57
|
+
permissions.forEach((permission) => {
|
|
58
|
+
const existing = modResults.manifest['uses-permission']?.find((p) => p.$?.['android:name'] === permission);
|
|
59
|
+
if (!existing) {
|
|
60
|
+
modResults.manifest['uses-permission'].push({
|
|
61
|
+
$: { 'android:name': permission },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return config;
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
exports.withAndroidManifest = withAndroidManifest;
|
|
70
|
+
//# sourceMappingURL=withAndroidManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAndroidManifest.js","sourceRoot":"","sources":["../../../../../plugin/src/android/config-plugins/withAndroidManifest.ts"],"names":[],"mappings":";;;AAAA,yDAI8B;AAI9B;;GAEG;AACI,MAAM,mBAAmB,GAAuC,CACrE,MAAM,EACN,OAAO,EACP,EAAE;IACF,OAAO,IAAA,oCAAuB,EAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QACtD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QAC9B,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,WAAW,EACX,kBAAkB,GAAG,OAAO,EAC5B,UAAU,GAAG,qBAAqB,EAClC,cAAc,GAAG,aAAa,EAC9B,WAAW,GAAG,EAAE,GACjB,GAAG,OAAO,CAAC;QAEZ,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED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AM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAC3D,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,KAAK,UAAU,CACjD,CAAC;gBACF,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAE,CAAC,IAAI,CAAC;wBAC3C,CAAC,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE;qBAC3B,CAAC,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AArFW,QAAA,mBAAmB,uBAqF9B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import { AndroidTargetOptions } from './withAndroidTarget';
|
|
3
|
+
/**
|
|
4
|
+
* Copies Android source files from targets directory to android module
|
|
5
|
+
*/
|
|
6
|
+
export declare const withAndroidModule: ConfigPlugin<AndroidTargetOptions>;
|
|
7
|
+
//# sourceMappingURL=withAndroidModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAndroidModule.d.ts","sourceRoot":"","sources":["../../../../../plugin/src/android/config-plugins/withAndroidModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,sBAAsB,CAAC;AAItE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,oBAAoB,CAwChE,CAAC"}
|