@react-native-ohos/react-native-haptic-feedback 2.2.2-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 (100) hide show
  1. package/.gitattributes +1 -0
  2. package/.prettierrc +8 -0
  3. package/COMMITTERS.md +11 -0
  4. package/LICENSE +21 -0
  5. package/OAT.xml +73 -0
  6. package/README.OpenSource +11 -0
  7. package/README.md +13 -0
  8. package/RNReactNativeHapticFeedback.podspec +40 -0
  9. package/harmony/haptic_feedback/build-profile.json5 +28 -0
  10. package/harmony/haptic_feedback/hvigorfile.ts +6 -0
  11. package/harmony/haptic_feedback/index.ets +3 -0
  12. package/harmony/haptic_feedback/obfuscation-rules.txt +18 -0
  13. package/harmony/haptic_feedback/oh-package.json5 +12 -0
  14. package/harmony/haptic_feedback/src/main/cpp/CMakeLists.txt +9 -0
  15. package/harmony/haptic_feedback/src/main/cpp/HapticFeedbackPackage.h +36 -0
  16. package/harmony/haptic_feedback/src/main/cpp/generated/RNOH/generated/BaseReactNativeHapticFeedbackPackage.h +65 -0
  17. package/harmony/haptic_feedback/src/main/cpp/generated/RNOH/generated/turbo_modules/HapticFeedbackNativeModule.cpp +16 -0
  18. package/harmony/haptic_feedback/src/main/cpp/generated/RNOH/generated/turbo_modules/HapticFeedbackNativeModule.h +16 -0
  19. package/harmony/haptic_feedback/src/main/ets/Logger.ts +46 -0
  20. package/harmony/haptic_feedback/src/main/ets/RNHapticFeedbackPackage.ets +30 -0
  21. package/harmony/haptic_feedback/src/main/ets/RNHapticFeedbackTurboModule.ts +149 -0
  22. package/harmony/haptic_feedback/src/main/ets/generated/components/ts.ts +5 -0
  23. package/harmony/haptic_feedback/src/main/ets/generated/index.ets +5 -0
  24. package/harmony/haptic_feedback/src/main/ets/generated/ts.ts +6 -0
  25. package/harmony/haptic_feedback/src/main/ets/generated/turboModules/HapticFeedbackNativeModule.ts +14 -0
  26. package/harmony/haptic_feedback/src/main/ets/generated/turboModules/ts.ts +5 -0
  27. package/harmony/haptic_feedback/src/main/module.json5 +12 -0
  28. package/harmony/haptic_feedback/src/main/resources/base/element/color.json +8 -0
  29. package/harmony/haptic_feedback/src/main/resources/base/element/string.json +16 -0
  30. package/harmony/haptic_feedback/src/main/resources/base/media/background.png +0 -0
  31. package/harmony/haptic_feedback/src/main/resources/base/media/foreground.png +0 -0
  32. package/harmony/haptic_feedback/src/main/resources/base/media/layered_image.json +7 -0
  33. package/harmony/haptic_feedback/src/main/resources/base/media/startIcon.png +0 -0
  34. package/harmony/haptic_feedback/src/main/resources/base/profile/main_pages.json +5 -0
  35. package/harmony/haptic_feedback/src/main/resources/en_US/element/string.json +16 -0
  36. package/harmony/haptic_feedback/src/main/resources/rawfile/effectClick.json +28 -0
  37. package/harmony/haptic_feedback/src/main/resources/rawfile/effectDoubleClick.json +38 -0
  38. package/harmony/haptic_feedback/src/main/resources/rawfile/effectHeavyClick.json +28 -0
  39. package/harmony/haptic_feedback/src/main/resources/rawfile/effectTick.json +28 -0
  40. package/harmony/haptic_feedback/src/main/resources/rawfile/impactHeavy.json +28 -0
  41. package/harmony/haptic_feedback/src/main/resources/rawfile/impactLight.json +28 -0
  42. package/harmony/haptic_feedback/src/main/resources/rawfile/impactMedium.json +28 -0
  43. package/harmony/haptic_feedback/src/main/resources/rawfile/notificationError.json +58 -0
  44. package/harmony/haptic_feedback/src/main/resources/rawfile/notificationSuccess.json +38 -0
  45. package/harmony/haptic_feedback/src/main/resources/rawfile/notificationWarning.json +38 -0
  46. package/harmony/haptic_feedback/src/main/resources/rawfile/rigid.json +28 -0
  47. package/harmony/haptic_feedback/src/main/resources/rawfile/selection.json +28 -0
  48. package/harmony/haptic_feedback/src/main/resources/rawfile/soft.json +28 -0
  49. package/harmony/haptic_feedback/src/main/resources/zh_CN/element/string.json +16 -0
  50. package/harmony/haptic_feedback/src/mock/mock-config.json5 +2 -0
  51. package/harmony/haptic_feedback/src/ohosTest/ets/test/Ability.test.ets +35 -0
  52. package/harmony/haptic_feedback/src/ohosTest/ets/test/List.test.ets +5 -0
  53. package/harmony/haptic_feedback/src/ohosTest/ets/testability/TestAbility.ets +47 -0
  54. package/harmony/haptic_feedback/src/ohosTest/ets/testability/pages/Index.ets +17 -0
  55. package/harmony/haptic_feedback/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +90 -0
  56. package/harmony/haptic_feedback/src/ohosTest/module.json5 +38 -0
  57. package/harmony/haptic_feedback/src/ohosTest/resources/base/element/color.json +8 -0
  58. package/harmony/haptic_feedback/src/ohosTest/resources/base/element/string.json +16 -0
  59. package/harmony/haptic_feedback/src/ohosTest/resources/base/media/icon.png +0 -0
  60. package/harmony/haptic_feedback/src/ohosTest/resources/base/profile/test_pages.json +5 -0
  61. package/harmony/haptic_feedback/src/test/List.test.ets +5 -0
  62. package/harmony/haptic_feedback/src/test/LocalUnit.test.ets +33 -0
  63. package/harmony/haptic_feedback/ts.ets +26 -0
  64. package/harmony/haptic_feedback.har +0 -0
  65. package/lib/commonjs/NativeHapticFeedback.js +9 -0
  66. package/lib/commonjs/NativeHapticFeedback.js.map +1 -0
  67. package/lib/commonjs/index.js +55 -0
  68. package/lib/commonjs/index.js.map +1 -0
  69. package/lib/commonjs/types.js +32 -0
  70. package/lib/commonjs/types.js.map +1 -0
  71. package/lib/module/NativeHapticFeedback.js +3 -0
  72. package/lib/module/NativeHapticFeedback.js.map +1 -0
  73. package/lib/module/index.js +36 -0
  74. package/lib/module/index.js.map +1 -0
  75. package/lib/module/types.js +26 -0
  76. package/lib/module/types.js.map +1 -0
  77. package/lib/typescript/lib/commonjs/NativeHapticFeedback.d.ts +5 -0
  78. package/lib/typescript/lib/commonjs/NativeHapticFeedback.d.ts.map +1 -0
  79. package/lib/typescript/lib/commonjs/index.d.ts +7 -0
  80. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
  81. package/lib/typescript/lib/commonjs/types.d.ts +3 -0
  82. package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
  83. package/lib/typescript/lib/module/NativeHapticFeedback.d.ts +3 -0
  84. package/lib/typescript/lib/module/NativeHapticFeedback.d.ts.map +1 -0
  85. package/lib/typescript/lib/module/index.d.ts +7 -0
  86. package/lib/typescript/lib/module/index.d.ts.map +1 -0
  87. package/lib/typescript/lib/module/types.d.ts +2 -0
  88. package/lib/typescript/lib/module/types.d.ts.map +1 -0
  89. package/lib/typescript/src/NativeHapticFeedback.d.ts +10 -0
  90. package/lib/typescript/src/NativeHapticFeedback.d.ts.map +1 -0
  91. package/lib/typescript/src/index.d.ts +9 -0
  92. package/lib/typescript/src/index.d.ts.map +1 -0
  93. package/lib/typescript/src/types.d.ts +29 -0
  94. package/lib/typescript/src/types.d.ts.map +1 -0
  95. package/package.json +90 -0
  96. package/src/NativeHapticFeedback.ts +14 -0
  97. package/src/index.ts +48 -0
  98. package/src/types.ts +29 -0
  99. package/tsconfig.build.json +4 -0
  100. package/tsconfig.json +36 -0
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-haptic-feedback",
3
+ "version": "2.2.2-rc.1",
4
+ "description": "Basic haptic feedback for iOS and android",
5
+ "license": "MIT",
6
+ "main": "lib/commonjs/index",
7
+ "module": "lib/module/index",
8
+ "typings": "lib/typescript/src/index.d.ts",
9
+ "react-native": "src/index",
10
+ "source": "src/index",
11
+ "nativePackage": true,
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "bob": "bob build",
16
+ "prepare": "npm run bob",
17
+ "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-haptic-feedback --cpp-output-path ./harmony/haptic_feedback/src/main/cpp/generated --ets-output-path ./harmony/haptic_feedback/src/main/ets/generated --turbo-modules-spec-paths ./src --arkts-components-spec-paths ./src"
18
+ },
19
+ "keywords": [
20
+ "react-native",
21
+ "haptic",
22
+ "haptic-feedback",
23
+ "android",
24
+ "ios",
25
+ "native",
26
+ "feedback",
27
+ "harmony"
28
+ ],
29
+ "author": "Michael Kuczera",
30
+ "peerDependencies": {
31
+ "react-native": ">=0.60.0"
32
+ },
33
+ "publishConfig": {
34
+ "registry": "https://registry.npmjs.org/",
35
+ "access": "public"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback.git"
40
+ },
41
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback",
42
+ "readme": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback#readme",
43
+ "bugs": {
44
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-haptic-feedback/issues"
45
+ },
46
+ "codegenConfig": {
47
+ "name": "RNHapticFeedbackSpec",
48
+ "type": "modules",
49
+ "jsSrcsDir": "src",
50
+ "android": {
51
+ "javaPackageName": "com.mkuczera"
52
+ }
53
+ },
54
+ "devDependencies": {
55
+ "@babel/core": "^7.21.3",
56
+ "@babel/runtime": "^7.21.0",
57
+ "@types/node": "^18.15.3",
58
+ "@types/react": "^18.0.28",
59
+ "@types/react-native": "^0.71.3",
60
+ "prettier": "^2.8.5",
61
+ "typescript": "^5.0.2",
62
+ "react-native-builder-bob": "^0.20.4"
63
+ },
64
+ "dependencies": {
65
+ "react-native-haptic-feedback": "^2.2.0"
66
+ },
67
+ "react-native-builder-bob": {
68
+ "source": "src",
69
+ "output": "lib",
70
+ "targets": [
71
+ "commonjs",
72
+ "module",
73
+ [
74
+ "typescript",
75
+ {
76
+ "project": "tsconfig.build.json"
77
+ }
78
+ ]
79
+ ]
80
+ },
81
+ "harmony": {
82
+ "alias": "react-native-haptic-feedback",
83
+ "autolinking": {
84
+ "etsPackageClassName":"HapticFeedbackPackage",
85
+ "cppPackageClassName":"HapticFeedbackPackage",
86
+ "cmakeLibraryTargetName": "rnoh_haptic_feedback",
87
+ "ohPackageName": "@react-native-ohos/react-native-haptic-feedback"
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,14 @@
1
+ import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
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.get<Spec>("HapticFeedbackNativeModule") as Spec | null;
package/src/index.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { NativeModules } from "react-native";
2
+ import { HapticFeedbackTypes } from "./types";
3
+ import type { HapticOptions } from "./types";
4
+
5
+ import type { Spec } from "./NativeHapticFeedback";
6
+ export * from "./types";
7
+
8
+ const defaultOptions = {
9
+ enableVibrateFallback: false,
10
+ ignoreAndroidSystemSettings: false,
11
+
12
+ };
13
+
14
+ class RNReactNativeHapticFeedback {
15
+ static trigger = (
16
+ type: string | HapticFeedbackTypes = HapticFeedbackTypes.selection,
17
+ options: HapticOptions = {},
18
+ ) => {
19
+ const triggerOptions = createTriggerOptions(options);
20
+
21
+ try {
22
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
23
+ const hapticFeedback = isTurboModuleEnabled
24
+ ? (require("./NativeHapticFeedback").default as Spec)
25
+ : NativeModules.RNHapticFeedback;
26
+
27
+ hapticFeedback.trigger(type, triggerOptions);
28
+ } catch (err) {
29
+ console.warn("RNReactNativeHapticFeedback is not available");
30
+ }
31
+ };
32
+ }
33
+
34
+ const createTriggerOptions = (options: HapticOptions) => {
35
+ // if options is a boolean we're using an api <=1.6 and we should pass use it to set the enableVibrateFallback option
36
+ if (typeof options === "boolean") {
37
+ return {
38
+ ...defaultOptions,
39
+ enableVibrateFallback: options,
40
+ };
41
+ } else {
42
+ return { ...defaultOptions, ...options };
43
+ }
44
+ };
45
+
46
+ export const trigger = RNReactNativeHapticFeedback.trigger;
47
+
48
+ export default RNReactNativeHapticFeedback;
package/src/types.ts ADDED
@@ -0,0 +1,29 @@
1
+ export enum HapticFeedbackTypes {
2
+ selection = "selection",
3
+ impactLight = "impactLight",
4
+ impactMedium = "impactMedium",
5
+ impactHeavy = "impactHeavy",
6
+ rigid = "rigid",
7
+ soft = "soft",
8
+ notificationSuccess = "notificationSuccess",
9
+ notificationWarning = "notificationWarning",
10
+ notificationError = "notificationError",
11
+ clockTick = "clockTick",
12
+ contextClick = "contextClick",
13
+ keyboardPress = "keyboardPress",
14
+ keyboardRelease = "keyboardRelease",
15
+ keyboardTap = "keyboardTap",
16
+ longPress = "longPress",
17
+ textHandleMove = "textHandleMove",
18
+ virtualKey = "virtualKey",
19
+ virtualKeyRelease = "virtualKeyRelease",
20
+ effectClick = "effectClick",
21
+ effectDoubleClick = "effectDoubleClick",
22
+ effectHeavyClick = "effectHeavyClick",
23
+ effectTick = "effectTick",
24
+ }
25
+
26
+ export interface HapticOptions {
27
+ enableVibrateFallback?: boolean;
28
+ ignoreAndroidSystemSettings?: boolean;
29
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig",
3
+ "exclude": ["example","harmony"]
4
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "es6",
5
+ "lib": ["es6"],
6
+ "allowJs": true,
7
+ "jsx": "react-native",
8
+ "noImplicitAny": false,
9
+ "incremental": true /* Enable incremental compilation */,
10
+ "isolatedModules": true,
11
+ "strict": true,
12
+ "moduleResolution": "node",
13
+ "baseUrl": "./",
14
+ "outDir": "build",
15
+ "noEmitHelpers": true,
16
+ "alwaysStrict": true,
17
+ "strictFunctionTypes": true,
18
+ "resolveJsonModule": true,
19
+ "importHelpers": false,
20
+ "experimentalDecorators": true,
21
+ "strictPropertyInitialization": false,
22
+ "allowSyntheticDefaultImports": true,
23
+ "strictNullChecks": true,
24
+ "skipDefaultLibCheck": true,
25
+ "skipLibCheck": true,
26
+ "esModuleInterop": true,
27
+ "typeRoots": ["./node_modules/@types", "./@types"],
28
+ "declaration": true /* Generates corresponding '.d.ts' file. */,
29
+ "sourceMap": true /* Generates corresponding '.map' file. */
30
+ },
31
+ "exclude": [
32
+ "Playground",
33
+ "node_modules",
34
+ "build",
35
+ ]
36
+ }