@react-native-ohos/clipboard 1.16.3-rc.1

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 (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +13 -0
  4. package/RNCClipboard.podspec +37 -0
  5. package/dist/Clipboard.d.ts +159 -0
  6. package/dist/Clipboard.js +232 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.js +7 -0
  9. package/harmony/clipboard/LICENSE +21 -0
  10. package/harmony/clipboard/NOTICE +33 -0
  11. package/harmony/clipboard/OAT.xml +38 -0
  12. package/harmony/clipboard/README.OpenSource +11 -0
  13. package/harmony/clipboard/README.md +307 -0
  14. package/harmony/clipboard/build-profile.json5 +8 -0
  15. package/harmony/clipboard/hvigorfile.ts +1 -0
  16. package/harmony/clipboard/index.ets +25 -0
  17. package/harmony/clipboard/oh-package.json5 +12 -0
  18. package/harmony/clipboard/src/main/cpp/CMakeLists.txt +7 -0
  19. package/harmony/clipboard/src/main/cpp/ClipboardPackage.h +58 -0
  20. package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.cpp +198 -0
  21. package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.h +39 -0
  22. package/harmony/clipboard/src/main/ets/ClipboardPackage.ts +46 -0
  23. package/harmony/clipboard/src/main/ets/Logger.ts +64 -0
  24. package/harmony/clipboard/src/main/ets/RNCClipboardTurboModule.ts +482 -0
  25. package/harmony/clipboard/src/main/module.json5 +7 -0
  26. package/harmony/clipboard/src/main/resources/base/element/string.json +8 -0
  27. package/harmony/clipboard/src/main/resources/en_US/element/string.json +8 -0
  28. package/harmony/clipboard/src/main/resources/zh_CN/element/string.json +8 -0
  29. package/harmony/clipboard/ts.ts +26 -0
  30. package/harmony/clipboard.har +0 -0
  31. package/package.json +90 -0
  32. package/src/Clipboard.ts +211 -0
  33. package/src/index.ts +3 -0
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@react-native-ohos/clipboard",
3
+ "version": "1.16.3-rc.1",
4
+ "description": "React Native Clipboard API",
5
+ "harmony": {
6
+ "alias": "@react-native-clipboard/clipboard"
7
+ },
8
+ "keywords": [
9
+ "Clipboard",
10
+ "getString",
11
+ "react-native",
12
+ "setString"
13
+ ],
14
+ "homepage": "https://github.com/react-native-clipboard/clipboard#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/react-native-clipboard/clipboard/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/react-native-oh-library/clipboard.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "M.Haris Baig <harisbaig100@gmail.com>",
24
+ "main": "dist/index.js",
25
+ "types": "dist/index.d.ts",
26
+ "files": [
27
+ "dist",
28
+ "RNCClipboard.podspec",
29
+ "harmony",
30
+ "src",
31
+ "!harmony/oh_modules",
32
+ "!harmony/**/build",
33
+ "!harmony/**/oh_modules"
34
+ ],
35
+ "scripts": {
36
+ "windows": "cd example && react-native run-windows",
37
+ "start": "react-native start",
38
+ "build": "tsc",
39
+ "format": "biome format --write .",
40
+ "lint": "biome lint --write .",
41
+ "prepare": "npm run build",
42
+ "test": "jest",
43
+ "type-check": "tsc --noEmit"
44
+ },
45
+ "jest": {
46
+ "preset": "react-native"
47
+ },
48
+ "devDependencies": {
49
+ "@babel/core": "^7.12.9",
50
+ "@biomejs/biome": "1.9.4",
51
+ "@callstack/react-native-visionos": "^0.76.0",
52
+ "@react-native/babel-preset": "^0.75.0",
53
+ "@react-native/metro-config": "^0.75.0",
54
+ "@rnx-kit/align-deps": "^2.4.1",
55
+ "@rnx-kit/metro-config": "^2.0.0",
56
+ "@types/react": "^18.2.0",
57
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
58
+ "babel-jest": "^26.1.0",
59
+ "jest": "^29.2.1",
60
+ "react": "^18.3.1",
61
+ "react-native": "^0.77.1",
62
+ "react-native-macos": "0.76.0",
63
+ "react-native-test-app": "^4.0.5",
64
+ "react-native-windows": "^0.75.0",
65
+ "react-test-renderer": "^18.2.0",
66
+ "typescript": "^4.4.3"
67
+ },
68
+ "dependencies": {
69
+ "@react-native-clipboard/clipboard": "1.16.2"
70
+ },
71
+ "peerDependencies": {
72
+ "react": ">= 16.9.0",
73
+ "react-native": ">= 0.61.5",
74
+ "react-native-macos": ">= 0.61.0",
75
+ "react-native-windows": ">= 0.61.0"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "react-native-macos": {
79
+ "optional": true
80
+ },
81
+ "react-native-windows": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "publishConfig": {
86
+ "registry": "https://registry.npmjs.org/",
87
+ "access": "public"
88
+ },
89
+ "packageManager": "yarn@4.1.1"
90
+ }
@@ -0,0 +1,211 @@
1
+ import { type EmitterSubscription, Platform } from "react-native";
2
+ import NativeClipboard, {
3
+ addListener,
4
+ removeAllListeners,
5
+ } from '@react-native-clipboard/clipboard/src/NativeClipboardModule';
6
+
7
+ /**
8
+ * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
9
+ */
10
+ export const Clipboard = {
11
+ /**
12
+ * Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
13
+ * ```javascript
14
+ * async _getContent() {
15
+ * var content = await Clipboard.getString();
16
+ * }
17
+ * ```
18
+ */
19
+ getString(): Promise<string> {
20
+ return NativeClipboard.getString();
21
+ },
22
+ /**
23
+ * (iOS Only)
24
+ * Get contents of string array type, this method returns a `Promise`, so you can use following code to get clipboard content
25
+ * ```javascript
26
+ * async _getContent() {
27
+ * var content = await Clipboard.getStrings();
28
+ * }
29
+ * ```
30
+ */
31
+ getStrings(): Promise<string[]> {
32
+ return NativeClipboard.getStrings();
33
+ },
34
+ /**
35
+ * Get clipboard image as PNG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
36
+ * ```javascript
37
+ * async _getContent() {
38
+ * var content = await Clipboard.getImagePNG();
39
+ * }
40
+ * ```
41
+ */
42
+ getImagePNG(): Promise<string> {
43
+ return NativeClipboard.getImagePNG();
44
+ },
45
+ /**
46
+ * Get clipboard image as JPG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
47
+ * ```javascript
48
+ * async _getContent() {
49
+ * var content = await Clipboard.getImageJPG();
50
+ * }
51
+ * ```
52
+ */
53
+ getImageJPG(): Promise<string> {
54
+ return NativeClipboard.getImageJPG();
55
+ },
56
+ /**
57
+ * (iOS Only)
58
+ * Set content of base64 image type. You can use following code to set clipboard content
59
+ * ```javascript
60
+ * _setContent() {
61
+ * Clipboard.setImage(...);
62
+ * }
63
+ * ```
64
+ * @param the content to be stored in the clipboard.
65
+ */
66
+ setImage(content: string) {
67
+ // @ts-ignore
68
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
69
+ NativeClipboard.setImage(content);
70
+ }
71
+ return;
72
+ },
73
+ /**
74
+ * (iOS and Android Only)
75
+ * Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
76
+ * ```javascript
77
+ * async _getContent() {
78
+ * var content = await Clipboard.getImage();
79
+ * }
80
+ * ```
81
+ */
82
+ getImage(): Promise<string> {
83
+ return NativeClipboard.getImage();
84
+ },
85
+ /**
86
+ * Set content of string type. You can use following code to set clipboard content
87
+ * ```javascript
88
+ * _setContent() {
89
+ * Clipboard.setString('hello world');
90
+ * }
91
+ * ```
92
+ * @param the content to be stored in the clipboard.
93
+ */
94
+ setString(content: string) {
95
+ NativeClipboard.setString(content);
96
+ },
97
+ /**
98
+ * Set content of string array type. You can use following code to set clipboard content
99
+ * ```javascript
100
+ * _setContent() {
101
+ * Clipboard.setStrings(['hello world', 'second string']);
102
+ * }
103
+ * ```
104
+ * @param the content to be stored in the clipboard.
105
+ */
106
+ setStrings(content: string[]) {
107
+ NativeClipboard.setStrings(content);
108
+ },
109
+ /**
110
+ * Returns whether the clipboard has content or is empty.
111
+ * This method returns a `Promise`, so you can use following code to get clipboard content
112
+ * ```javascript
113
+ * async _hasContent() {
114
+ * var hasContent = await Clipboard.hasString();
115
+ * }
116
+ * ```
117
+ */
118
+ hasString() {
119
+ return NativeClipboard.hasString();
120
+ },
121
+ /**
122
+ * Returns whether the clipboard has an image or is empty.
123
+ * This method returns a `Promise`, so you can use following code to check clipboard content
124
+ * ```javascript
125
+ * async _hasContent() {
126
+ * var hasContent = await Clipboard.hasImage();
127
+ * }
128
+ * ```
129
+ */
130
+ hasImage() {
131
+ return NativeClipboard.hasImage();
132
+ },
133
+ /**
134
+ * (iOS Only)
135
+ * Returns whether the clipboard has a URL content. Can check
136
+ * if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
137
+ * This method returns a `Promise`, so you can use following code to check for url content in clipboard.
138
+ * ```javascript
139
+ * async _hasURL() {
140
+ * var hasURL = await Clipboard.hasURL();
141
+ * }
142
+ * ```
143
+ */
144
+ hasURL() {
145
+ // @ts-ignore
146
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
147
+ return NativeClipboard.hasURL();
148
+ }
149
+ return;
150
+ },
151
+ /**
152
+ * (iOS 14+ Only)
153
+ * Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
154
+ * if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
155
+ * This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
156
+ * ```javascript
157
+ * async _hasNumber() {
158
+ * var hasNumber = await Clipboard.hasNumber();
159
+ * }
160
+ * ```
161
+ */
162
+ hasNumber() {
163
+ // @ts-ignore
164
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
165
+ return NativeClipboard.hasNumber();
166
+ }
167
+ return;
168
+ },
169
+ /**
170
+ * (iOS 14+ Only)
171
+ * Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
172
+ * if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
173
+ * This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
174
+ * ```javascript
175
+ * async _hasWebURL() {
176
+ * var hasWebURL = await Clipboard.hasWebURL();
177
+ * }
178
+ * ```
179
+ */
180
+ hasWebURL() {
181
+ // @ts-ignore
182
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
183
+ return NativeClipboard.hasWebURL();
184
+ }
185
+ return;
186
+ },
187
+ /**
188
+ * (iOS and Android Only)
189
+ * Adds a listener to get notifications when the clipboard has changed.
190
+ * If this is the first listener, turns on clipboard notifications on the native side.
191
+ * It returns EmitterSubscription where you can call "remove" to remove listener
192
+ * ```javascript
193
+ * const listener = () => console.log("changed!");
194
+ * Clipboard.addListener(listener);
195
+ * ```
196
+ */
197
+ addListener(callback: () => void): EmitterSubscription {
198
+ return addListener(callback);
199
+ },
200
+
201
+ /**
202
+ * (iOS and Android Only)
203
+ * Removes all previously registered listeners and turns off notifications on the native side.
204
+ * ```javascript
205
+ * Clipboard.removeAllListeners();
206
+ * ```
207
+ */
208
+ removeAllListeners() {
209
+ removeAllListeners();
210
+ },
211
+ };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Clipboard } from "./Clipboard";
2
+ export { useClipboard } from "@react-native-clipboard/clipboard/src/useClipboard";
3
+ export default Clipboard;