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,124 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
|
|
4
|
+
const ExpoTargetsMessagesModule = requireNativeModule('ExpoTargetsMessages');
|
|
5
|
+
|
|
6
|
+
export type PresentationStyle = 'compact' | 'expanded';
|
|
7
|
+
|
|
8
|
+
export interface MessageLayout {
|
|
9
|
+
caption: string;
|
|
10
|
+
subcaption?: string;
|
|
11
|
+
trailingCaption?: string;
|
|
12
|
+
trailingSubcaption?: string;
|
|
13
|
+
imageUrl?: string;
|
|
14
|
+
mediaFileUrl?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ConversationInfo {
|
|
19
|
+
conversationId: string;
|
|
20
|
+
remoteParticipantIds: string[];
|
|
21
|
+
participantCount: number;
|
|
22
|
+
hasSelectedMessage: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SelectedMessage {
|
|
26
|
+
url?: string;
|
|
27
|
+
caption?: string;
|
|
28
|
+
subcaption?: string;
|
|
29
|
+
trailingCaption?: string;
|
|
30
|
+
trailingSubcaption?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class Messages {
|
|
34
|
+
getPresentationStyle(): PresentationStyle | null {
|
|
35
|
+
if (Platform.OS !== 'ios') return null;
|
|
36
|
+
return ExpoTargetsMessagesModule.getPresentationStyle();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
requestPresentationStyle(style: PresentationStyle): void {
|
|
40
|
+
if (Platform.OS !== 'ios') return;
|
|
41
|
+
ExpoTargetsMessagesModule.requestPresentationStyle(style);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
sendMessage(layout: MessageLayout): void {
|
|
45
|
+
if (Platform.OS !== 'ios') return;
|
|
46
|
+
ExpoTargetsMessagesModule.sendMessage(layout);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
sendUpdate(layout: MessageLayout, sessionId: string): void {
|
|
50
|
+
if (Platform.OS !== 'ios') return;
|
|
51
|
+
ExpoTargetsMessagesModule.sendUpdate(layout, sessionId);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createSession(): string | null {
|
|
55
|
+
if (Platform.OS !== 'ios') return null;
|
|
56
|
+
return ExpoTargetsMessagesModule.createSession();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
getConversationInfo(): ConversationInfo | null {
|
|
60
|
+
if (Platform.OS !== 'ios') return null;
|
|
61
|
+
return ExpoTargetsMessagesModule.getConversationInfo();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
addEventListener(
|
|
65
|
+
eventName: 'onPresentationStyleChange',
|
|
66
|
+
listener: (style: PresentationStyle) => void
|
|
67
|
+
) {
|
|
68
|
+
if (Platform.OS !== 'ios') {
|
|
69
|
+
return { remove: () => {} };
|
|
70
|
+
}
|
|
71
|
+
return ExpoTargetsMessagesModule.addListener(
|
|
72
|
+
eventName,
|
|
73
|
+
(event: { presentationStyle: PresentationStyle }) => {
|
|
74
|
+
listener(event.presentationStyle);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Standalone functions for backwards compatibility
|
|
81
|
+
export const getPresentationStyle = (): PresentationStyle | null => {
|
|
82
|
+
if (Platform.OS !== 'ios') return null;
|
|
83
|
+
return ExpoTargetsMessagesModule.getPresentationStyle();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const requestPresentationStyle = (style: PresentationStyle): void => {
|
|
87
|
+
if (Platform.OS !== 'ios') return;
|
|
88
|
+
ExpoTargetsMessagesModule.requestPresentationStyle(style);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const sendMessage = (layout: MessageLayout): void => {
|
|
92
|
+
if (Platform.OS !== 'ios') return;
|
|
93
|
+
ExpoTargetsMessagesModule.sendMessage(layout);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const sendUpdate = (layout: MessageLayout, sessionId: string): void => {
|
|
97
|
+
if (Platform.OS !== 'ios') return;
|
|
98
|
+
ExpoTargetsMessagesModule.sendUpdate(layout, sessionId);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const createSession = (): string | null => {
|
|
102
|
+
if (Platform.OS !== 'ios') return null;
|
|
103
|
+
return ExpoTargetsMessagesModule.createSession();
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const getConversationInfo = (): ConversationInfo | null => {
|
|
107
|
+
if (Platform.OS !== 'ios') return null;
|
|
108
|
+
return ExpoTargetsMessagesModule.getConversationInfo();
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const addEventListener = (
|
|
112
|
+
eventName: 'onPresentationStyleChange',
|
|
113
|
+
listener: (style: PresentationStyle) => void
|
|
114
|
+
) => {
|
|
115
|
+
if (Platform.OS !== 'ios') {
|
|
116
|
+
return { remove: () => {} };
|
|
117
|
+
}
|
|
118
|
+
return ExpoTargetsMessagesModule.addListener(
|
|
119
|
+
eventName,
|
|
120
|
+
(event: { presentationStyle: PresentationStyle }) => {
|
|
121
|
+
listener(event.presentationStyle);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
|
|
3
|
+
const ExpoTargetsStorageModule = requireNativeModule('ExpoTargetsStorage');
|
|
4
|
+
|
|
5
|
+
export class AppGroupStorage {
|
|
6
|
+
constructor(private readonly appGroup: string) {}
|
|
7
|
+
|
|
8
|
+
set(key: string, value: any) {
|
|
9
|
+
if (value === null || value === undefined) {
|
|
10
|
+
ExpoTargetsStorageModule.remove(key, this.appGroup);
|
|
11
|
+
} else if (typeof value === 'number') {
|
|
12
|
+
ExpoTargetsStorageModule.setInt(key, Math.floor(value), this.appGroup);
|
|
13
|
+
} else if (typeof value === 'string') {
|
|
14
|
+
ExpoTargetsStorageModule.setString(key, value, this.appGroup);
|
|
15
|
+
} else if (typeof value === 'boolean') {
|
|
16
|
+
ExpoTargetsStorageModule.setInt(key, value ? 1 : 0, this.appGroup);
|
|
17
|
+
} else if (Array.isArray(value)) {
|
|
18
|
+
ExpoTargetsStorageModule.setString(
|
|
19
|
+
key,
|
|
20
|
+
JSON.stringify(value),
|
|
21
|
+
this.appGroup
|
|
22
|
+
);
|
|
23
|
+
} else {
|
|
24
|
+
ExpoTargetsStorageModule.setString(
|
|
25
|
+
key,
|
|
26
|
+
JSON.stringify(value),
|
|
27
|
+
this.appGroup
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get<T = any>(key: string): T | null {
|
|
33
|
+
try {
|
|
34
|
+
const value = ExpoTargetsStorageModule.get(key, this.appGroup);
|
|
35
|
+
if (value === null || value === undefined) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof value === 'string') {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(value) as T;
|
|
42
|
+
} catch {
|
|
43
|
+
return value as T;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return value as T;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.warn(`Failed to get value for key "${key}":`, error);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
remove(key: string) {
|
|
55
|
+
ExpoTargetsStorageModule.remove(key, this.appGroup);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
clear() {
|
|
59
|
+
ExpoTargetsStorageModule.clearAll(this.appGroup);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setData(data: Record<string, any>) {
|
|
63
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
64
|
+
this.set(key, value);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getData<T extends Record<string, any>>(): T {
|
|
69
|
+
try {
|
|
70
|
+
const rawData = ExpoTargetsStorageModule.getAllData(this.appGroup);
|
|
71
|
+
if (!rawData || typeof rawData !== 'object') {
|
|
72
|
+
return {} as T;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const parsedData: Record<string, any> = {};
|
|
76
|
+
|
|
77
|
+
Object.entries(rawData).forEach(([key, value]) => {
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
try {
|
|
80
|
+
parsedData[key] = JSON.parse(value);
|
|
81
|
+
} catch {
|
|
82
|
+
parsedData[key] = value;
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
parsedData[key] = value;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return parsedData as T;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.warn('Failed to get all data:', error);
|
|
92
|
+
return {} as T;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getKeys(): string[] {
|
|
97
|
+
try {
|
|
98
|
+
return ExpoTargetsStorageModule.getAllKeys(this.appGroup);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.warn('Failed to get all keys:', error);
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
refresh(targetName?: string) {
|
|
106
|
+
ExpoTargetsStorageModule.refreshTarget(targetName);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function refreshAllTargets() {
|
|
111
|
+
ExpoTargetsStorageModule.refreshTarget(undefined);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function clearSharedData(appGroup: string) {
|
|
115
|
+
const storage = new AppGroupStorage(appGroup);
|
|
116
|
+
storage.clear();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function getTargetsConfigFromBundle(): any[] | null {
|
|
120
|
+
try {
|
|
121
|
+
return ExpoTargetsStorageModule.getTargetsConfig();
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.warn('Failed to read targets config from bundle:', error);
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|