@react-native-clipboard/clipboard 1.14.3 → 1.16.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 (36) hide show
  1. package/README.md +1 -4
  2. package/dist/Clipboard.d.ts +2 -2
  3. package/dist/Clipboard.js +27 -23
  4. package/dist/Clipboard.web.js +13 -15
  5. package/dist/NativeClipboard.d.ts +1 -1
  6. package/dist/NativeClipboard.js +9 -9
  7. package/dist/NativeClipboardModule.d.ts +3 -3
  8. package/dist/NativeClipboardModule.js +9 -9
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +1 -1
  11. package/dist/useClipboard.js +11 -9
  12. package/ios/RNCClipboard.mm +18 -2
  13. package/jest/clipboard-mock.js +14 -14
  14. package/package.json +112 -97
  15. package/src/Clipboard.ts +199 -199
  16. package/src/Clipboard.web.ts +29 -32
  17. package/src/NativeClipboardModule.ts +172 -172
  18. package/src/index.ts +2 -2
  19. package/src/useClipboard.ts +17 -15
  20. package/windows/Clipboard/Clipboard.cpp +11 -5
  21. package/windows/Clipboard/Clipboard.h +17 -8
  22. package/windows/Clipboard/Clipboard.rc +0 -0
  23. package/windows/Clipboard/Clipboard.vcxproj +89 -93
  24. package/windows/Clipboard/Clipboard.vcxproj.filters +32 -27
  25. package/windows/Clipboard/ReactPackageProvider.cpp +17 -10
  26. package/windows/Clipboard/ReactPackageProvider.h +14 -10
  27. package/windows/Clipboard/ReactPackageProvider.idl +8 -9
  28. package/windows/Clipboard/codegen/.clang-format +2 -0
  29. package/windows/Clipboard/codegen/NativeClipboardModuleSpec.g.h +130 -0
  30. package/windows/Clipboard/pch.cpp +1 -1
  31. package/windows/Clipboard/pch.h +29 -3
  32. package/windows/Clipboard/resource.h +5 -0
  33. package/windows/Clipboard/targetver.h +8 -0
  34. package/windows/Clipboard.sln +43 -0
  35. package/windows/README.md +2 -2
  36. package/windows/windows.sln +0 -295
package/package.json CHANGED
@@ -1,99 +1,114 @@
1
1
  {
2
- "name": "@react-native-clipboard/clipboard",
3
- "version": "1.14.3",
4
- "description": "React Native Clipboard API for macOS, iOS, Android, and Windows",
5
- "keywords": [
6
- "Clipboard",
7
- "getString",
8
- "react-native",
9
- "setString"
10
- ],
11
- "homepage": "https://github.com/react-native-clipboard/clipboard#readme",
12
- "bugs": {
13
- "url": "https://github.com/react-native-clipboard/clipboard/issues"
14
- },
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/react-native-clipboard/clipboard.git"
18
- },
19
- "license": "MIT",
20
- "author": "M.Haris Baig <harisbaig100@gmail.com>",
21
- "main": "dist/index.js",
22
- "types": "dist/index.d.ts",
23
- "files": [
24
- "dist",
25
- "RNCClipboard.podspec",
26
- "ios",
27
- "macos",
28
- "android",
29
- "windows",
30
- "jest",
31
- "src",
32
- "!android/**/build/*"
33
- ],
34
- "scripts": {
35
- "ios": "react-native run-ios --project-path \"./example/ios\"",
36
- "android": "react-native run-android --root example",
37
- "windows": "cd example && react-native run-windows",
38
- "start": "react-native start",
39
- "build": "tsc",
40
- "lint": "eslint src --ext .ts,.tsx --cache",
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
- "@callstack/react-native-visionos": "^0.73.0",
51
- "@react-native/babel-preset": "^0.73.0",
52
- "@react-native/eslint-config": "^0.73.0",
53
- "@react-native/metro-config": "^0.73.0",
54
- "@rnx-kit/align-deps": "^2.4.1",
55
- "@rnx-kit/metro-config": "^1.3.15",
56
- "@types/react": "^18.2.0",
57
- "babel-jest": "^26.1.0",
58
- "eslint": "^7.32.0",
59
- "eslint-plugin-prettier": "^3.1.2",
60
- "jest": "^29.2.1",
61
- "prettier": "^2.4.1",
62
- "react": "18.2.0",
63
- "react-native": "^0.73.0",
64
- "react-native-macos": "^0.73.0",
65
- "react-native-test-app": "^3.5.3",
66
- "react-native-windows": "^0.73.0",
67
- "react-test-renderer": "18.2.0",
68
- "typescript": "^4.4.3"
69
- },
70
- "peerDependencies": {
71
- "react": ">= 16.9.0",
72
- "react-native": ">= 0.61.5",
73
- "react-native-macos": ">= 0.61.0",
74
- "react-native-windows": ">= 0.61.0"
75
- },
76
- "peerDependenciesMeta": {
77
- "react-native-macos": {
78
- "optional": true
79
- },
80
- "react-native-windows": {
81
- "optional": true
82
- }
83
- },
84
- "publishConfig": {
85
- "access": "public"
86
- },
87
- "codegenConfig": {
88
- "name": "rnclipboard",
89
- "type": "modules",
90
- "jsSrcsDir": "./src",
91
- "android": {
92
- "javaPackageName": "com.reactnativecommunity.clipboard"
93
- }
94
- },
95
- "packageManager": "yarn@4.1.1",
96
- "workspaces": [
97
- "example"
98
- ]
2
+ "name": "@react-native-clipboard/clipboard",
3
+ "version": "1.16.0",
4
+ "description": "React Native Clipboard API for macOS, iOS, Android, and Windows",
5
+ "keywords": [
6
+ "Clipboard",
7
+ "getString",
8
+ "react-native",
9
+ "setString"
10
+ ],
11
+ "homepage": "https://github.com/react-native-clipboard/clipboard#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/react-native-clipboard/clipboard/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/react-native-clipboard/clipboard.git"
18
+ },
19
+ "license": "MIT",
20
+ "author": "M.Haris Baig <harisbaig100@gmail.com>",
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "files": [
24
+ "dist",
25
+ "RNCClipboard.podspec",
26
+ "ios",
27
+ "macos",
28
+ "android",
29
+ "windows",
30
+ "jest",
31
+ "src",
32
+ "!android/**/build/*"
33
+ ],
34
+ "scripts": {
35
+ "ios": "react-native run-ios",
36
+ "android": "react-native run-android --root example",
37
+ "windows": "cd example && react-native run-windows",
38
+ "start:windows": "install-windows-test-app -p example/windows && react-native run-windows --root example --logging",
39
+ "start:windows:fabric": "install-windows-test-app -p example/windows --use-fabric && react-native run-windows --root example --logging",
40
+ "start": "react-native start",
41
+ "build": "tsc",
42
+ "format": "biome format --write .",
43
+ "lint": "biome lint --write .",
44
+ "prepare": "npm run build",
45
+ "test": "jest",
46
+ "type-check": "tsc --noEmit"
47
+ },
48
+ "jest": {
49
+ "preset": "react-native"
50
+ },
51
+ "dependencies": {
52
+ "react-native": "^0.75.3",
53
+ "react-native-windows": "^0.75.0"
54
+ },
55
+ "devDependencies": {
56
+ "@babel/core": "^7.12.9",
57
+ "@biomejs/biome": "1.9.4",
58
+ "@callstack/react-native-visionos": "^0.76.0",
59
+ "@react-native/babel-preset": "^0.75.0",
60
+ "@react-native/metro-config": "^0.75.0",
61
+ "@rnx-kit/align-deps": "^2.4.1",
62
+ "@rnx-kit/metro-config": "^2.0.0",
63
+ "@types/react": "^18.2.0",
64
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
65
+ "babel-jest": "^26.1.0",
66
+ "jest": "^29.2.1",
67
+ "react": "^18.3.1",
68
+ "react-native-macos": "0.76.0",
69
+ "react-native-test-app": "^4.0.5",
70
+ "react-test-renderer": "^18.2.0",
71
+ "typescript": "^4.4.3"
72
+ },
73
+ "peerDependencies": {
74
+ "react": ">= 16.9.0",
75
+ "react-native": ">= 0.61.5",
76
+ "react-native-macos": ">= 0.61.0",
77
+ "react-native-windows": ">= 0.61.0"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "react-native-macos": {
81
+ "optional": true
82
+ },
83
+ "react-native-windows": {
84
+ "optional": true
85
+ }
86
+ },
87
+ "publishConfig": {
88
+ "access": "public"
89
+ },
90
+ "codegenConfig": {
91
+ "name": "rnclipboard",
92
+ "type": "modules",
93
+ "jsSrcsDir": "./src",
94
+ "android": {
95
+ "javaPackageName": "com.reactnativecommunity.clipboard"
96
+ },
97
+ "windows": {
98
+ "namespace": "ClipboardCodegen",
99
+ "outputDirectory": "windows/Clipboard/codegen",
100
+ "separateDataTypes": true
101
+ }
102
+ },
103
+ "packageManager": "yarn@4.1.1",
104
+ "workspaces": [
105
+ "example"
106
+ ],
107
+ "react-native-windows": {
108
+ "init-windows": {
109
+ "name": "Clipboard",
110
+ "namespace": "Clipboard",
111
+ "template": "cpp-lib"
112
+ }
113
+ }
99
114
  }
package/src/Clipboard.ts CHANGED
@@ -1,208 +1,208 @@
1
- import {EmitterSubscription, Platform} from 'react-native';
1
+ import { type EmitterSubscription, Platform } from "react-native";
2
2
  import NativeClipboard, {
3
- addListener,
4
- removeAllListeners,
5
- } from './NativeClipboardModule';
3
+ addListener,
4
+ removeAllListeners,
5
+ } from "./NativeClipboardModule";
6
6
 
7
7
  /**
8
8
  * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
9
9
  */
10
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
- if (Platform.OS !== 'ios') {
68
- return;
69
- }
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
+ if (Platform.OS !== "ios") {
68
+ return;
69
+ }
70
70
 
71
- NativeClipboard.setImage(content);
72
- },
73
- /**
74
- * (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
- if (Platform.OS !== 'ios') {
146
- return;
147
- }
148
- return NativeClipboard.hasURL();
149
- },
150
- /**
151
- * (iOS 14+ Only)
152
- * Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
153
- * if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
154
- * This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
155
- * ```javascript
156
- * async _hasNumber() {
157
- * var hasNumber = await Clipboard.hasNumber();
158
- * }
159
- * ```
160
- */
161
- hasNumber() {
162
- if (Platform.OS !== 'ios') {
163
- return;
164
- }
165
- return NativeClipboard.hasNumber();
166
- },
167
- /**
168
- * (iOS 14+ Only)
169
- * Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
170
- * if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
171
- * This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
172
- * ```javascript
173
- * async _hasWebURL() {
174
- * var hasWebURL = await Clipboard.hasWebURL();
175
- * }
176
- * ```
177
- */
178
- hasWebURL() {
179
- if (Platform.OS !== 'ios') {
180
- return;
181
- }
182
- return NativeClipboard.hasWebURL();
183
- },
184
- /**
185
- * (iOS and Android Only)
186
- * Adds a listener to get notifications when the clipboard has changed.
187
- * If this is the first listener, turns on clipboard notifications on the native side.
188
- * It returns EmitterSubscription where you can call "remove" to remove listener
189
- * ```javascript
190
- * const listener = () => console.log("changed!");
191
- * Clipboard.addListener(listener);
192
- * ```
193
- */
194
- addListener(callback: () => void): EmitterSubscription {
195
- return addListener(callback);
196
- },
71
+ NativeClipboard.setImage(content);
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
+ if (Platform.OS !== "ios") {
146
+ return;
147
+ }
148
+ return NativeClipboard.hasURL();
149
+ },
150
+ /**
151
+ * (iOS 14+ Only)
152
+ * Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
153
+ * if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
154
+ * This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
155
+ * ```javascript
156
+ * async _hasNumber() {
157
+ * var hasNumber = await Clipboard.hasNumber();
158
+ * }
159
+ * ```
160
+ */
161
+ hasNumber() {
162
+ if (Platform.OS !== "ios") {
163
+ return;
164
+ }
165
+ return NativeClipboard.hasNumber();
166
+ },
167
+ /**
168
+ * (iOS 14+ Only)
169
+ * Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
170
+ * if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
171
+ * This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
172
+ * ```javascript
173
+ * async _hasWebURL() {
174
+ * var hasWebURL = await Clipboard.hasWebURL();
175
+ * }
176
+ * ```
177
+ */
178
+ hasWebURL() {
179
+ if (Platform.OS !== "ios") {
180
+ return;
181
+ }
182
+ return NativeClipboard.hasWebURL();
183
+ },
184
+ /**
185
+ * (iOS and Android Only)
186
+ * Adds a listener to get notifications when the clipboard has changed.
187
+ * If this is the first listener, turns on clipboard notifications on the native side.
188
+ * It returns EmitterSubscription where you can call "remove" to remove listener
189
+ * ```javascript
190
+ * const listener = () => console.log("changed!");
191
+ * Clipboard.addListener(listener);
192
+ * ```
193
+ */
194
+ addListener(callback: () => void): EmitterSubscription {
195
+ return addListener(callback);
196
+ },
197
197
 
198
- /**
199
- * (iOS and Android Only)
200
- * Removes all previously registered listeners and turns off notifications on the native side.
201
- * ```javascript
202
- * Clipboard.removeAllListeners();
203
- * ```
204
- */
205
- removeAllListeners() {
206
- removeAllListeners();
207
- },
198
+ /**
199
+ * (iOS and Android Only)
200
+ * Removes all previously registered listeners and turns off notifications on the native side.
201
+ * ```javascript
202
+ * Clipboard.removeAllListeners();
203
+ * ```
204
+ */
205
+ removeAllListeners() {
206
+ removeAllListeners();
207
+ },
208
208
  };