@sip-protocol/react-native 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.
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Clipboard Utilities for React Native
3
+ *
4
+ * Provides cross-platform clipboard access with fallback support.
5
+ */
6
+
7
+ /**
8
+ * Check if clipboard module is available
9
+ */
10
+ let Clipboard: { setString: (text: string) => void; getString: () => Promise<string> } | null = null
11
+ try {
12
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
13
+ Clipboard = require('@react-native-clipboard/clipboard').default
14
+ } catch {
15
+ // Clipboard not available
16
+ }
17
+
18
+ /**
19
+ * Copy text to clipboard
20
+ *
21
+ * @param text - Text to copy
22
+ * @returns true if successful
23
+ */
24
+ export async function copyToClipboard(text: string): Promise<boolean> {
25
+ if (!Clipboard) {
26
+ console.warn(
27
+ '@react-native-clipboard/clipboard is not available. ' +
28
+ 'Install it for clipboard functionality.'
29
+ )
30
+ return false
31
+ }
32
+
33
+ try {
34
+ Clipboard.setString(text)
35
+ return true
36
+ } catch {
37
+ return false
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Read text from clipboard
43
+ *
44
+ * @returns Clipboard contents or empty string
45
+ */
46
+ export async function readFromClipboard(): Promise<string> {
47
+ if (!Clipboard) {
48
+ console.warn(
49
+ '@react-native-clipboard/clipboard is not available. ' +
50
+ 'Install it for clipboard functionality.'
51
+ )
52
+ return ''
53
+ }
54
+
55
+ try {
56
+ return await Clipboard.getString()
57
+ } catch {
58
+ return ''
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Check if clipboard is available
64
+ */
65
+ export function isClipboardAvailable(): boolean {
66
+ return !!Clipboard
67
+ }
@@ -0,0 +1 @@
1
+ export { copyToClipboard, readFromClipboard, isClipboardAvailable } from './clipboard'