@react-native-ohos/react-native-haptic-feedback 2.3.4-rc.1 → 2.3.4

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 (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.OpenSource +10 -10
  3. package/README.md +12 -12
  4. package/RNReactNativeHapticFeedback.podspec +29 -29
  5. package/harmony/haptic_feedback/BuildProfile.ets +16 -16
  6. package/harmony/haptic_feedback/build-profile.json5 +27 -27
  7. package/harmony/haptic_feedback/hvigorfile.ts +6 -6
  8. package/harmony/haptic_feedback/index.ets +25 -25
  9. package/harmony/haptic_feedback/obfuscation-rules.txt +17 -17
  10. package/harmony/haptic_feedback/oh-package-lock.json5 +31 -0
  11. package/harmony/haptic_feedback/oh-package.json5 +12 -12
  12. package/harmony/haptic_feedback/src/main/cpp/CMakeLists.txt +6 -6
  13. package/harmony/haptic_feedback/src/main/cpp/RNHapticFeedback.cpp +21 -21
  14. package/harmony/haptic_feedback/src/main/cpp/RNHapticFeedback.h +21 -21
  15. package/harmony/haptic_feedback/src/main/cpp/RNHapticFeedbackPackage.h +37 -37
  16. package/harmony/haptic_feedback/src/main/ets/Logger.ts +45 -45
  17. package/harmony/haptic_feedback/src/main/ets/RNHapticFeedbackPackage.ts +28 -28
  18. package/harmony/haptic_feedback/src/main/ets/RNHapticFeedbackTurboModule.ts +151 -151
  19. package/harmony/haptic_feedback/src/main/ets/generated/components/ts.ts +8 -8
  20. package/harmony/haptic_feedback/src/main/ets/generated/index.ets +8 -8
  21. package/harmony/haptic_feedback/src/main/ets/generated/ts.ts +9 -9
  22. package/harmony/haptic_feedback/src/main/ets/generated/turboModules/RNHapticFeedback.ts +16 -16
  23. package/harmony/haptic_feedback/src/main/ets/generated/turboModules/ts.ts +8 -8
  24. package/harmony/haptic_feedback/src/main/module.json5 +11 -11
  25. package/harmony/haptic_feedback/src/main/resources/base/element/color.json +7 -7
  26. package/harmony/haptic_feedback/src/main/resources/base/element/string.json +15 -15
  27. package/harmony/haptic_feedback/src/main/resources/base/media/layered_image.json +6 -6
  28. package/harmony/haptic_feedback/src/main/resources/base/profile/main_pages.json +5 -5
  29. package/harmony/haptic_feedback/src/main/resources/en_US/element/string.json +15 -15
  30. package/harmony/haptic_feedback/src/main/resources/rawfile/effectClick.json +27 -27
  31. package/harmony/haptic_feedback/src/main/resources/rawfile/effectDoubleClick.json +37 -37
  32. package/harmony/haptic_feedback/src/main/resources/rawfile/effectHeavyClick.json +27 -27
  33. package/harmony/haptic_feedback/src/main/resources/rawfile/effectTick.json +27 -27
  34. package/harmony/haptic_feedback/src/main/resources/rawfile/impactHeavy.json +27 -27
  35. package/harmony/haptic_feedback/src/main/resources/rawfile/impactLight.json +27 -27
  36. package/harmony/haptic_feedback/src/main/resources/rawfile/impactMedium.json +27 -27
  37. package/harmony/haptic_feedback/src/main/resources/rawfile/notificationError.json +57 -57
  38. package/harmony/haptic_feedback/src/main/resources/rawfile/notificationSuccess.json +37 -37
  39. package/harmony/haptic_feedback/src/main/resources/rawfile/notificationWarning.json +37 -37
  40. package/harmony/haptic_feedback/src/main/resources/rawfile/rigid.json +27 -27
  41. package/harmony/haptic_feedback/src/main/resources/rawfile/selection.json +27 -27
  42. package/harmony/haptic_feedback/src/main/resources/rawfile/soft.json +27 -27
  43. package/harmony/haptic_feedback/src/main/resources/zh_CN/element/string.json +15 -15
  44. package/harmony/haptic_feedback/ts.ts +25 -25
  45. package/harmony/haptic_feedback.har +0 -0
  46. package/package.json +115 -117
  47. package/src/codegenSpec/NativeHapticFeedback.ts +14 -14
  48. package/src/index.ts +31 -31
  49. package/src/types.ts +29 -29
@@ -1,38 +1,38 @@
1
- {
2
- "MetaData": {
3
- "Create": "2024-05-29",
4
- "Description": "a haptic case",
5
- "Version": 1.0,
6
- "ChannelNumber": 1
7
- },
8
- "Channels": [
9
- {
10
- "Parameters": {
11
- "Index": 0
12
- },
13
- "Pattern": [
14
- {
15
- "Event": {
16
- "Type": "transient",
17
- "StartTime": 0,
18
- "Parameters": {
19
- "Intensity": 60,
20
- "Frequency": 10
21
- }
22
- }
23
- },
24
- {
25
- "Event": {
26
- "Type": "transient",
27
- "StartTime": 200,
28
- "Parameters": {
29
- "Intensity": 100,
30
- "Frequency": 10
31
- }
32
- }
33
- }
34
-
35
- ]
36
- }
37
- ]
1
+ {
2
+ "MetaData": {
3
+ "Create": "2024-05-29",
4
+ "Description": "a haptic case",
5
+ "Version": 1.0,
6
+ "ChannelNumber": 1
7
+ },
8
+ "Channels": [
9
+ {
10
+ "Parameters": {
11
+ "Index": 0
12
+ },
13
+ "Pattern": [
14
+ {
15
+ "Event": {
16
+ "Type": "transient",
17
+ "StartTime": 0,
18
+ "Parameters": {
19
+ "Intensity": 60,
20
+ "Frequency": 10
21
+ }
22
+ }
23
+ },
24
+ {
25
+ "Event": {
26
+ "Type": "transient",
27
+ "StartTime": 200,
28
+ "Parameters": {
29
+ "Intensity": 100,
30
+ "Frequency": 10
31
+ }
32
+ }
33
+ }
34
+
35
+ ]
36
+ }
37
+ ]
38
38
  }
@@ -1,28 +1,28 @@
1
- {
2
- "MetaData": {
3
- "Create": "2024-05-29",
4
- "Description": "a haptic case",
5
- "Version": 1.0,
6
- "ChannelNumber": 1
7
- },
8
- "Channels": [
9
- {
10
- "Parameters": {
11
- "Index": 0
12
- },
13
- "Pattern": [
14
- {
15
- "Event": {
16
- "Type": "transient",
17
- "StartTime": 0,
18
- "Parameters": {
19
- "Frequency": 50,
20
- "Intensity": 30
21
- }
22
- }
23
- }
24
-
25
- ]
26
- }
27
- ]
1
+ {
2
+ "MetaData": {
3
+ "Create": "2024-05-29",
4
+ "Description": "a haptic case",
5
+ "Version": 1.0,
6
+ "ChannelNumber": 1
7
+ },
8
+ "Channels": [
9
+ {
10
+ "Parameters": {
11
+ "Index": 0
12
+ },
13
+ "Pattern": [
14
+ {
15
+ "Event": {
16
+ "Type": "transient",
17
+ "StartTime": 0,
18
+ "Parameters": {
19
+ "Frequency": 50,
20
+ "Intensity": 30
21
+ }
22
+ }
23
+ }
24
+
25
+ ]
26
+ }
27
+ ]
28
28
  }
@@ -1,28 +1,28 @@
1
- {
2
- "MetaData": {
3
- "Create": "2024-05-29",
4
- "Description": "a haptic case",
5
- "Version": 1.0,
6
- "ChannelNumber": 1
7
- },
8
- "Channels": [
9
- {
10
- "Parameters": {
11
- "Index": 0
12
- },
13
- "Pattern": [
14
- {
15
- "Event": {
16
- "Type": "transient",
17
- "StartTime": 0,
18
- "Parameters": {
19
- "Frequency": 80,
20
- "Intensity": 20
21
- }
22
- }
23
- }
24
-
25
- ]
26
- }
27
- ]
1
+ {
2
+ "MetaData": {
3
+ "Create": "2024-05-29",
4
+ "Description": "a haptic case",
5
+ "Version": 1.0,
6
+ "ChannelNumber": 1
7
+ },
8
+ "Channels": [
9
+ {
10
+ "Parameters": {
11
+ "Index": 0
12
+ },
13
+ "Pattern": [
14
+ {
15
+ "Event": {
16
+ "Type": "transient",
17
+ "StartTime": 0,
18
+ "Parameters": {
19
+ "Frequency": 80,
20
+ "Intensity": 20
21
+ }
22
+ }
23
+ }
24
+
25
+ ]
26
+ }
27
+ ]
28
28
  }
@@ -1,28 +1,28 @@
1
- {
2
- "MetaData": {
3
- "Create": "2024-05-29",
4
- "Description": "a haptic case",
5
- "Version": 1.0,
6
- "ChannelNumber": 1
7
- },
8
- "Channels": [
9
- {
10
- "Parameters": {
11
- "Index": 0
12
- },
13
- "Pattern": [
14
- {
15
- "Event": {
16
- "Type": "transient",
17
- "StartTime": 0,
18
- "Parameters": {
19
- "Frequency": 40,
20
- "Intensity": 60
21
- }
22
- }
23
- }
24
-
25
- ]
26
- }
27
- ]
1
+ {
2
+ "MetaData": {
3
+ "Create": "2024-05-29",
4
+ "Description": "a haptic case",
5
+ "Version": 1.0,
6
+ "ChannelNumber": 1
7
+ },
8
+ "Channels": [
9
+ {
10
+ "Parameters": {
11
+ "Index": 0
12
+ },
13
+ "Pattern": [
14
+ {
15
+ "Event": {
16
+ "Type": "transient",
17
+ "StartTime": 0,
18
+ "Parameters": {
19
+ "Frequency": 40,
20
+ "Intensity": 60
21
+ }
22
+ }
23
+ }
24
+
25
+ ]
26
+ }
27
+ ]
28
28
  }
@@ -1,16 +1,16 @@
1
- {
2
- "string": [
3
- {
4
- "name": "module_desc",
5
- "value": "模块描述"
6
- },
7
- {
8
- "name": "Haptic_feedbackAbility_desc",
9
- "value": "description"
10
- },
11
- {
12
- "name": "Haptic_feedbackAbility_label",
13
- "value": "label"
14
- }
15
- ]
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "模块描述"
6
+ },
7
+ {
8
+ "name": "Haptic_feedbackAbility_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "Haptic_feedbackAbility_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
16
  }
@@ -1,26 +1,26 @@
1
- /**
2
- * MIT License
3
- *
4
- * Copyright (C) 2025 Huawei Device Co., Ltd.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- export * from './src/main/ets/RNHapticFeedbackPackage';
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ export * from './src/main/ets/RNHapticFeedbackPackage';
26
26
  export * from "./src/main/ets/RNHapticFeedbackTurboModule"
Binary file
package/package.json CHANGED
@@ -1,117 +1,115 @@
1
- {
2
- "name": "@react-native-ohos/react-native-haptic-feedback",
3
- "version": "2.3.4-rc.1",
4
- "description": "Basic haptic feedback for iOS and android",
5
- "license": "MIT",
6
- "source": "src/index.ts",
7
- "main": "./lib/commonjs/index.js",
8
- "react-native": "src/index.ts",
9
- "module": "./lib/module/index.js",
10
- "types": "lib/typescript/index.d.ts",
11
- "scripts": {
12
- "typecheck": "tsc --noEmit --project tsconfig.test.json",
13
- "test": "jest",
14
- "build": "bob build",
15
- "lint": "eslint \"**/*.{js,ts,tsx}\"",
16
- "bob": "bob build",
17
- "prepare": "npm run bob"
18
- },
19
- "keywords": [
20
- "react-native",
21
- "haptic",
22
- "haptic-feedback",
23
- "android",
24
- "ios",
25
- "native",
26
- "feedback",
27
- "harmony"
28
- ],
29
- "files": [
30
- "src",
31
- "lib",
32
- "android",
33
- "ios",
34
- "cpp",
35
- "harmony",
36
- "*.podspec",
37
- "!ios/build",
38
- "!android/build",
39
- "!android/gradle",
40
- "!android/gradlew",
41
- "!android/gradlew.bat",
42
- "!android/local.properties",
43
- "!**/__tests__",
44
- "!**/__fixtures__",
45
- "!**/__mocks__",
46
- "!**/.*"
47
- ],
48
- "author": "Michael Kuczera",
49
- "peerDependencies": {
50
- "react-native": ">=0.60.0"
51
- },
52
- "publishConfig": {
53
- "registry": "https://registry.npmjs.org/"
54
- },
55
- "repository": {
56
- "type": "git",
57
- "url": "https://github.com/react-native-oh-library/react-native-haptic-feedback.git"
58
- },
59
- "homepage": "https://github.com/mkuczera/react-native-haptic-feedback",
60
- "readme": "https://github.com/mkuczera/react-native-haptic-feedback#readme",
61
- "bugs": {
62
- "url": "https://github.com/mkuczera/react-native-haptic-feedback/issues"
63
- },
64
- "codegenConfig": {
65
- "name": "RNHapticFeedbackSpec",
66
- "type": "modules",
67
- "jsSrcsDir": "./src/codegenSpec",
68
- "android": {
69
- "javaPackageName": "com.mkuczera"
70
- }
71
- },
72
- "devDependencies": {
73
- "@babel/core": "^7.25.2",
74
- "@babel/preset-env": "^7.25.3",
75
- "@babel/preset-react": "^7.24.7",
76
- "@babel/runtime": "^7.21.0",
77
- "@eslint/js": "^9.8.0",
78
- "@react-native/eslint-config": "^0.74.86",
79
- "@types/jest": "^29.5.12",
80
- "@types/node": "^22.1.0",
81
- "@types/react": "^18.0.28",
82
- "@types/react-native": "^0.71.3",
83
- "babel-jest": "^29.7.0",
84
- "eslint": "9.x",
85
- "eslint-config-prettier": "^9.1.0",
86
- "eslint-plugin-prettier": "^5.2.1",
87
- "globals": "^15.9.0",
88
- "jest": "^29.7.0",
89
- "prettier": "^2.8.5",
90
- "react-native": "^0.77.1",
91
- "react-native-builder-bob": "^0.29.0",
92
- "ts-jest": "^29.2.4",
93
- "tslib": "^2.6.3",
94
- "turbo": "^2.0.11",
95
- "typescript": "^5.5.4",
96
- "typescript-eslint": "^8.0.0"
97
- },
98
- "packageManager": "yarn@3.6.4",
99
- "resolutions": {
100
- "@types/react": "^18.2.44"
101
- },
102
- "dependencies": {
103
- "react-native-haptic-feedback": "^2.3.3"
104
- },
105
- "react-native-builder-bob": {
106
- "source": "src",
107
- "output": "lib",
108
- "targets": [
109
- "commonjs",
110
- "module",
111
- "typescript"
112
- ]
113
- },
114
- "harmony": {
115
- "alias": "react-native-haptic-feedback"
116
- }
117
- }
1
+ {
2
+ "name": "@react-native-ohos/react-native-haptic-feedback",
3
+ "version": "2.3.4",
4
+ "description": "Basic haptic feedback for iOS and android",
5
+ "license": "MIT",
6
+ "source": "src/index.ts",
7
+ "main": "./lib/commonjs/index.js",
8
+ "react-native": "src/index.ts",
9
+ "module": "./lib/module/index.js",
10
+ "types": "lib/typescript/index.d.ts",
11
+ "scripts": {
12
+ "typecheck": "tsc --noEmit --project tsconfig.test.json",
13
+ "test": "jest",
14
+ "build": "bob build",
15
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
16
+ "bob": "bob build",
17
+ "prepare": "npm run bob"
18
+ },
19
+ "keywords": [
20
+ "react-native",
21
+ "haptic",
22
+ "haptic-feedback",
23
+ "native",
24
+ "feedback",
25
+ "harmony"
26
+ ],
27
+ "files": [
28
+ "src",
29
+ "lib",
30
+ "android",
31
+ "ios",
32
+ "cpp",
33
+ "harmony",
34
+ "*.podspec",
35
+ "!ios/build",
36
+ "!android/build",
37
+ "!android/gradle",
38
+ "!android/gradlew",
39
+ "!android/gradlew.bat",
40
+ "!android/local.properties",
41
+ "!**/__tests__",
42
+ "!**/__fixtures__",
43
+ "!**/__mocks__",
44
+ "!**/.*"
45
+ ],
46
+ "author": "Michael Kuczera",
47
+ "peerDependencies": {
48
+ "react-native": ">=0.60.0"
49
+ },
50
+ "publishConfig": {
51
+ "registry": "https://registry.npmjs.org/"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback.git"
56
+ },
57
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback",
58
+ "readme": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback#readme",
59
+ "bugs": {
60
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback/issues"
61
+ },
62
+ "codegenConfig": {
63
+ "name": "RNHapticFeedbackSpec",
64
+ "type": "modules",
65
+ "jsSrcsDir": "./src/codegenSpec",
66
+ "android": {
67
+ "javaPackageName": "com.mkuczera"
68
+ }
69
+ },
70
+ "devDependencies": {
71
+ "@babel/core": "^7.25.2",
72
+ "@babel/preset-env": "^7.25.3",
73
+ "@babel/preset-react": "^7.24.7",
74
+ "@babel/runtime": "^7.21.0",
75
+ "@eslint/js": "^9.8.0",
76
+ "@react-native/eslint-config": "^0.74.86",
77
+ "@types/jest": "^29.5.12",
78
+ "@types/node": "^22.1.0",
79
+ "@types/react": "^18.0.28",
80
+ "@types/react-native": "^0.71.3",
81
+ "babel-jest": "^29.7.0",
82
+ "eslint": "9.x",
83
+ "eslint-config-prettier": "^9.1.0",
84
+ "eslint-plugin-prettier": "^5.2.1",
85
+ "globals": "^15.9.0",
86
+ "jest": "^29.7.0",
87
+ "prettier": "^2.8.5",
88
+ "react-native": "^0.77.1",
89
+ "react-native-builder-bob": "^0.29.0",
90
+ "ts-jest": "^29.2.4",
91
+ "tslib": "^2.6.3",
92
+ "turbo": "^2.0.11",
93
+ "typescript": "^5.5.4",
94
+ "typescript-eslint": "^8.0.0"
95
+ },
96
+ "packageManager": "yarn@3.6.4",
97
+ "resolutions": {
98
+ "@types/react": "^18.2.44"
99
+ },
100
+ "dependencies": {
101
+ "react-native-haptic-feedback": "^2.3.3"
102
+ },
103
+ "react-native-builder-bob": {
104
+ "source": "src",
105
+ "output": "lib",
106
+ "targets": [
107
+ "commonjs",
108
+ "module",
109
+ "typescript"
110
+ ]
111
+ },
112
+ "harmony": {
113
+ "alias": "react-native-haptic-feedback"
114
+ }
115
+ }
@@ -1,14 +1,14 @@
1
- import type { TurboModule } from "react-native";
2
- import { TurboModuleRegistry } from "react-native";
3
-
4
- export interface Spec extends TurboModule {
5
- // your module methods go here, for example:
6
- trigger(
7
- type: string,
8
- options?: {
9
- enableVibrateFallback?: boolean;
10
- ignoreAndroidSystemSettings?: boolean;
11
- },
12
- ): void;
13
- }
14
- export default TurboModuleRegistry.getEnforcing<Spec>("RNHapticFeedback") as Spec | null;
1
+ import type { TurboModule } from "react-native";
2
+ import { TurboModuleRegistry } from "react-native";
3
+
4
+ export interface Spec extends TurboModule {
5
+ // your module methods go here, for example:
6
+ trigger(
7
+ type: string,
8
+ options?: {
9
+ enableVibrateFallback?: boolean;
10
+ ignoreAndroidSystemSettings?: boolean;
11
+ },
12
+ ): void;
13
+ }
14
+ export default TurboModuleRegistry.getEnforcing<Spec>("RNHapticFeedback") as Spec | null;
package/src/index.ts CHANGED
@@ -1,31 +1,31 @@
1
- import NativeHapticFeedback from './codegenSpec/NativeHapticFeedback';
2
- import { HapticFeedbackTypes } from "./types";
3
- import type { HapticOptions } from "./types";
4
-
5
- const defaultOptions = {
6
- enableVibrateFallback: false,
7
- ignoreAndroidSystemSettings: false,
8
- };
9
-
10
- const RNHapticFeedback = {
11
- trigger(
12
- type:
13
- | keyof typeof HapticFeedbackTypes
14
- | HapticFeedbackTypes = HapticFeedbackTypes.selection,
15
- options: HapticOptions = {},
16
- ) {
17
- try {
18
- if (NativeHapticFeedback) {
19
- NativeHapticFeedback.trigger(type, { ...defaultOptions, ...options });
20
- } else {
21
- console.warn("RNReactNativeHapticFeedback is null");
22
- }
23
- } catch {
24
- console.warn("RNReactNativeHapticFeedback is not available");
25
- }
26
- }
27
- }
28
-
29
- export * from "./types";
30
- export const { trigger } = RNHapticFeedback;
31
- export default RNHapticFeedback;
1
+ import NativeHapticFeedback from './codegenSpec/NativeHapticFeedback';
2
+ import { HapticFeedbackTypes } from "./types";
3
+ import type { HapticOptions } from "./types";
4
+
5
+ const defaultOptions = {
6
+ enableVibrateFallback: false,
7
+ ignoreAndroidSystemSettings: false,
8
+ };
9
+
10
+ const RNHapticFeedback = {
11
+ trigger(
12
+ type:
13
+ | keyof typeof HapticFeedbackTypes
14
+ | HapticFeedbackTypes = HapticFeedbackTypes.selection,
15
+ options: HapticOptions = {},
16
+ ) {
17
+ try {
18
+ if (NativeHapticFeedback) {
19
+ NativeHapticFeedback.trigger(type, { ...defaultOptions, ...options });
20
+ } else {
21
+ console.warn("RNReactNativeHapticFeedback is null");
22
+ }
23
+ } catch {
24
+ console.warn("RNReactNativeHapticFeedback is not available");
25
+ }
26
+ }
27
+ }
28
+
29
+ export * from "./types";
30
+ export const { trigger } = RNHapticFeedback;
31
+ export default RNHapticFeedback;