@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/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ *.pbxproj -text
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "bracketSpacing": true,
3
+ "jsxBracketSameLine": false,
4
+ "singleQuote": false,
5
+ "trailingComma": "all",
6
+ "tabWidth": 2,
7
+ "semi": true
8
+ }
package/COMMITTERS.md ADDED
@@ -0,0 +1,11 @@
1
+ ## Committers列表
2
+
3
+ ### 以下是此项目的committer人员
4
+
5
+ 不区分先后顺序
6
+
7
+ - [MaDiXin](https://gitee.com/MaDiXin)
8
+ - [xiafeng_xf_admin](https://gitee.com/xiafeng_xf_admin)
9
+ - [ChenLixi](https://gitee.com/Louis-C7)
10
+ - [LinJiacheng](https://gitee.com/LLLLLLin)
11
+ - [ZhengJinshou](https://gitee.com/longziz)
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Michael Kuczera
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/OAT.xml ADDED
@@ -0,0 +1,73 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <configuration>
3
+ <oatconfig>
4
+ <licensefile>LICENSE</licensefile>
5
+ <policylist>
6
+ <policy name="projectPolicy" desc="">
7
+ <policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
8
+ </policy>
9
+ <policy name="projectPolicy" desc="">
10
+ <policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
11
+ <policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
12
+ <policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
13
+ <policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
14
+ <policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
15
+ </policy>
16
+ </policylist>
17
+
18
+ <filefilterlist>
19
+ <filefilter name="defaultFilter" desc="Files not to check">
20
+ <filteritem type="filename" name="*.json|*.txt|*.gitignore|*.node-version|*.prettierrc|*.tool-versions|*.watchmanconfig|*.lock|*.podspec|*.pdf|*.har|*.gif|*.npmignore" desc="desc files"/>
21
+ <filteritem type="filename" name="LICENSE" desc="版权文件,不添加版权头"/>
22
+ <filteritem type="filepath" name="src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
23
+ <filteritem type="filepath" name="lib/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
24
+ <filteritem type="filepath" name="scripts/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
25
+ <filteritem type="filepath" name="js/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
26
+ <filteritem type="filepath" name="src/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
27
+ <filteritem type="filepath" name="src/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
28
+ <filteritem type="filepath" name="*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
29
+ <filteritem type="filepath" name="*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
30
+ <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
31
+ <filteritem type="filename" name="*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
32
+ <filteritem type="filename" name="*/*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
33
+ <filteritem type="filepath" name="types/.*" desc="非业务代码,不添加许可证头"/>
34
+ <filteritem type="filepath" name="harmony/haptic_feedback/src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
35
+ <filteritem type="filepath" name="harmony/haptic_feedback/index.ets" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
36
+ <filteritem type="filepath" name="harmony/haptic_feedback/ts.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
37
+ <filteritem type="filepath" name="harmony/haptic_feedback/BuildProfile.ets" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
38
+ <filteritem type="filepath" name="harmony/haptic_feedback/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
39
+ <filteritem type="filename" name="harmony/haptic_feedback/*.json5" desc="工程项目文件,DevEco Studio自动生成,不手动修改"/>
40
+ <filteritem type="filepath" name="harmony/haptic_feedback/src/main/cpp/generated/.*" desc="Codegen生成文件,不手动修改"/>
41
+ <filteritem type="filepath" name="harmony/haptic_feedback/src/main/ets/generated/.*" desc="Codegen生成文件,不手动修改"/>
42
+ </filefilter>
43
+
44
+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
45
+ <filteritem type="filename" name="*.json|*.txt|*.gitignore|*.node-version|*.prettierrc|*.tool-versions|*.watchmanconfig|*.lock|*.podspec|*.pdf|*.har|*.gif|*.npmignore" desc="desc files"/>
46
+ <filteritem type="filename" name="LICENSE" desc="版权文件,不添加版权头"/>
47
+ <filteritem type="filepath" name="src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
48
+ <filteritem type="filepath" name="lib/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
49
+ <filteritem type="filepath" name="scripts/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
50
+ <filteritem type="filepath" name="js/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
51
+ <filteritem type="filepath" name="src/*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
52
+ <filteritem type="filepath" name="src/*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
53
+ <filteritem type="filepath" name="*.js" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
54
+ <filteritem type="filepath" name="*.ts" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
55
+ <filteritem type="filepath" name="index.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
56
+ <filteritem type="filename" name="*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
57
+ <filteritem type="filename" name="*/*.json5" desc="hvigor配置文件,DevEco Studio自动生成,不手动修改"/>
58
+ <filteritem type="filepath" name="types/.*" desc="非业务代码,不添加许可证头"/>
59
+ <filteritem type="filepath" name="harmony/haptic_feedback/src/.*" desc="第三方开源软件源码,不修改版权头,以防有修改版权风险"/>
60
+ <filteritem type="filepath" name="harmony/haptic_feedback/index.ets" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
61
+ <filteritem type="filepath" name="harmony/haptic_feedback/ts.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
62
+ <filteritem type="filepath" name="harmony/haptic_feedback/BuildProfile.ets" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
63
+ <filteritem type="filepath" name="harmony/haptic_feedback/hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不手动修改"/>
64
+ <filteritem type="filename" name="harmony/haptic_feedback/*.json5" desc="工程项目文件,DevEco Studio自动生成,不手动修改"/>
65
+ <filteritem type="filepath" name="harmony/haptic_feedback/src/main/cpp/generated/.*" desc="Codegen生成文件,不手动修改"/>
66
+ <filteritem type="filepath" name="harmony/haptic_feedback/src/main/ets/generated/.*" desc="Codegen生成文件,不手动修改"/>
67
+ </filefilter>
68
+
69
+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies">
70
+ </filefilter>
71
+ </filefilterlist>
72
+ </oatconfig>
73
+ </configuration>
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "react-native-haptic-feedback",
4
+ "License": "MIT License",
5
+ "License File": "https://github.com/mkuczera/react-native-haptic-feedback/blob/master/LICENSE",
6
+ "Version Number": "2.2.0",
7
+ "Owner" : "xiafeng@huawei.com",
8
+ "Upstream URL": "https://github.com/mkuczera/react-native-haptic-feedback",
9
+ "Description": " Basic haptic feedback"
10
+ }
11
+ ]
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @react-native-oh-tpl/react-native-haptic-feedback
2
+
3
+ This project is based on [react-native-haptic-feedback@2.2.0](https://github.com/mkuczera/react-native-haptic-feedback/tree/v2.2.0)
4
+
5
+ ## Documentation
6
+
7
+ - [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-haptic-feedback.md)
8
+
9
+ - [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-haptic-feedback.md)
10
+
11
+ ## License
12
+
13
+ This library is licensed under [The MIT License (MIT)](https://github.com/mkuczera/react-native-haptic-feedback/blob/master/LICENSE)
@@ -0,0 +1,40 @@
1
+ require 'json'
2
+ package = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'package.json')))
3
+
4
+ Pod::Spec.new do |s|
5
+ s.name = "RNReactNativeHapticFeedback"
6
+ s.version = package["version"]
7
+ s.summary = package["description"]
8
+ s.description = <<-DESC
9
+ react-native-haptic-feedback
10
+ DESC
11
+ s.homepage = "https://github.com/mkuczera/react-native-haptic-feedback"
12
+ s.license = "MIT"
13
+ # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
14
+ s.author = { "author" => "m.kuczera@gmail.com" }
15
+ s.platform = :ios, "12.4"
16
+ s.source = { :git => "https://github.com/mkuczera/react-native-haptic-feedback.git", :tag => "master" }
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+ s.requires_arc = true
19
+
20
+ s.dependency 'React-Core'
21
+
22
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
23
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
24
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
25
+
26
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
27
+ s.pod_target_xcconfig = {
28
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
29
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
30
+ }
31
+
32
+ s.dependency "React-Codegen"
33
+ s.dependency "RCT-Folly"
34
+ s.dependency "RCTRequired"
35
+ s.dependency "RCTTypeSafety"
36
+ s.dependency "ReactCommon/turbomodule/core"
37
+ end
38
+ end
39
+
40
+
@@ -0,0 +1,28 @@
1
+ {
2
+ "apiType": "stageMode",
3
+ "buildOption": {
4
+ },
5
+ "buildOptionSet": [
6
+ {
7
+ "name": "release",
8
+ "arkOptions": {
9
+ "obfuscation": {
10
+ "ruleOptions": {
11
+ "enable": true,
12
+ "files": [
13
+ "./obfuscation-rules.txt"
14
+ ]
15
+ }
16
+ }
17
+ }
18
+ },
19
+ ],
20
+ "targets": [
21
+ {
22
+ "name": "default"
23
+ },
24
+ {
25
+ "name": "ohosTest",
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,6 @@
1
+ import { harTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -0,0 +1,3 @@
1
+ import { RNHapticFeedbackPackage as HapticFeedbackPackage } from './src/main/ets/RNHapticFeedbackPackage';
2
+ export * from "./ts";
3
+ export default HapticFeedbackPackage;
@@ -0,0 +1,18 @@
1
+ # Define project specific obfuscation rules here.
2
+ # You can include the obfuscation configuration files in the current module's build-profile.json5.
3
+ #
4
+ # For more details, see
5
+ # https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
6
+
7
+ # Obfuscation options:
8
+ # -disable-obfuscation: disable all obfuscations
9
+ # -enable-property-obfuscation: obfuscate the property names
10
+ # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11
+ # -compact: remove unnecessary blank spaces and all line feeds
12
+ # -remove-log: remove all console.* statements
13
+ # -print-namecache: print the name cache that contains the mapping from the old names to new names
14
+ # -apply-namecache: reuse the given cache file
15
+
16
+ # Keep options:
17
+ # -keep-property-name: specifies property names that you want to keep
18
+ # -keep-global-name: specifies names that you want to keep in the global scope
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-haptic-feedback",
3
+ "version": "2.2.2-rc.1",
4
+ "description": "Please describe the basic information.",
5
+ "main": "index.ets",
6
+ "author": "",
7
+ "license": "Apache-2.0",
8
+ "dependencies": {
9
+ "@rnoh/react-native-openharmony": 'file:../react_native_openharmony'
10
+ }
11
+ }
12
+
@@ -0,0 +1,9 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+ set(CMAKE_VERBOSE_MAKEFILE on)
3
+
4
+ set(rnoh_haptic_feedback_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated")
5
+ file(GLOB_RECURSE rnoh_haptic_feedback_generated_SRC "${rnoh_haptic_feedback_generated_dir}/**/*.cpp")
6
+ file(GLOB rnoh_haptic_feedback_SRC CONFIGURE_DEPENDS *.cpp)
7
+ add_library(rnoh_haptic_feedback SHARED ${rnoh_haptic_feedback_SRC} ${rnoh_haptic_feedback_generated_SRC})
8
+ target_include_directories(rnoh_haptic_feedback PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_haptic_feedback_generated_dir})
9
+ target_link_libraries(rnoh_haptic_feedback PUBLIC rnoh)
@@ -0,0 +1,36 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 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
+ #ifndef HAPTICFEEDBACKPACKAGE_H
25
+ #define HAPTICFEEDBACKPACKAGE_H
26
+
27
+ #include "generated/RNOH/generated/BaseReactNativeHapticFeedbackPackage.h"
28
+ #pragma once
29
+
30
+ namespace rnoh {
31
+ class HapticFeedbackPackage : public BaseReactNativeHapticFeedbackPackage {
32
+ using Super = BaseReactNativeHapticFeedbackPackage;
33
+ using Super::Super;
34
+ };
35
+ } // namespace rnoh
36
+ #endif // HapticFeedbackPACKAGE_H
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #pragma once
6
+
7
+ #include "RNOH/Package.h"
8
+ #include "RNOH/ArkTSTurboModule.h"
9
+ #include "RNOH/generated/turbo_modules/HapticFeedbackNativeModule.h"
10
+
11
+ namespace rnoh {
12
+
13
+ class BaseReactNativeHapticFeedbackPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate {
14
+ public:
15
+ SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
16
+ if (name == "HapticFeedbackNativeModule") {
17
+ return std::make_shared<HapticFeedbackNativeModule>(ctx, name);
18
+ }
19
+ return nullptr;
20
+ };
21
+ };
22
+
23
+ class BaseReactNativeHapticFeedbackPackageEventEmitRequestHandler : public EventEmitRequestHandler {
24
+ public:
25
+ void handleEvent(Context const &ctx) override {
26
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
27
+ if (eventEmitter == nullptr) {
28
+ return;
29
+ }
30
+
31
+ std::vector<std::string> supportedEventNames = {
32
+ };
33
+ if (std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
34
+ eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
35
+ }
36
+ }
37
+ };
38
+
39
+
40
+ class BaseReactNativeHapticFeedbackPackage : public Package {
41
+ public:
42
+ BaseReactNativeHapticFeedbackPackage(Package::Context ctx) : Package(ctx){};
43
+
44
+ std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
45
+ return std::make_unique<BaseReactNativeHapticFeedbackPackageTurboModuleFactoryDelegate>();
46
+ }
47
+
48
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
49
+ return {
50
+ };
51
+ }
52
+
53
+ ComponentJSIBinderByString createComponentJSIBinderByName() override {
54
+ return {
55
+ };
56
+ };
57
+
58
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override {
59
+ return {
60
+ std::make_shared<BaseReactNativeHapticFeedbackPackageEventEmitRequestHandler>(),
61
+ };
62
+ }
63
+ };
64
+
65
+ } // namespace rnoh
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #include "HapticFeedbackNativeModule.h"
6
+
7
+ namespace rnoh {
8
+ using namespace facebook;
9
+
10
+ HapticFeedbackNativeModule::HapticFeedbackNativeModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) {
11
+ methodMap_ = {
12
+ ARK_METHOD_METADATA(trigger, 2),
13
+ };
14
+ }
15
+
16
+ } // namespace rnoh
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ #pragma once
6
+
7
+ #include "RNOH/ArkTSTurboModule.h"
8
+
9
+ namespace rnoh {
10
+
11
+ class JSI_EXPORT HapticFeedbackNativeModule : public ArkTSTurboModule {
12
+ public:
13
+ HapticFeedbackNativeModule(const ArkTSTurboModule::Context ctx, const std::string name);
14
+ };
15
+
16
+ } // namespace rnoh
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import hilog from '@ohos.hilog';
8
+
9
+ class Logger {
10
+ private domain: number;
11
+ private prefix: string;
12
+ private format: string = '%{public}s, %{public}s';
13
+ private isDebug: boolean;
14
+
15
+ /**
16
+ * constructor.
17
+ *
18
+ * @param Prefix Identifies the log tag.
19
+ * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
20
+ */
21
+ constructor(prefix: string = 'RNCToolbarAndroid', domain: number = 0xFF00, isDebug = false) {
22
+ this.prefix = prefix;
23
+ this.domain = domain;
24
+ this.isDebug = isDebug;
25
+ }
26
+
27
+ debug(...args: string[]): void {
28
+ if (this.isDebug) {
29
+ hilog.debug(this.domain, this.prefix, this.format, args);
30
+ }
31
+ }
32
+
33
+ info(...args: string[]): void {
34
+ hilog.info(this.domain, this.prefix, this.format, args);
35
+ }
36
+
37
+ warn(...args: string[]): void {
38
+ hilog.warn(this.domain, this.prefix, this.format, args);
39
+ }
40
+
41
+ error(...args: string[]): void {
42
+ hilog.error(this.domain, this.prefix, this.format, args);
43
+ }
44
+ }
45
+
46
+ export default new Logger('RNTextSizeTurboModule', 0xFF00, false)
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
8
+ import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
9
+ import { RNOHPackage } from "@rnoh/react-native-openharmony";
10
+ import { TM } from './generated/ts';
11
+ import { RNHapticFeedbackTurboModule } from './RNHapticFeedbackTurboModule';
12
+
13
+ class RNHapticFeedbackTurboModuleFactory extends TurboModulesFactory {
14
+ createTurboModule(name: string): TurboModule | null {
15
+ if (this.hasTurboModule(name)) {
16
+ return new RNHapticFeedbackTurboModule(this.ctx);
17
+ }
18
+ return null;
19
+ }
20
+
21
+ hasTurboModule(name: string): boolean {
22
+ return name === TM.HapticFeedbackNativeModule.NAME;
23
+ }
24
+ }
25
+
26
+ export class RNHapticFeedbackPackage extends RNOHPackage {
27
+ createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
28
+ return new RNHapticFeedbackTurboModuleFactory(ctx);
29
+ }
30
+ }
@@ -0,0 +1,149 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+ import { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
7
+ import { TM } from './generated/ts';
8
+ import Logger from './Logger';
9
+ import vibrator from '@ohos.vibrator';
10
+ import audio from '@ohos.multimedia.audio';
11
+ import { BusinessError } from '@ohos.base';
12
+ import common from '@ohos.app.ability.common';
13
+ export class RNHapticFeedbackTurboModule extends TurboModule implements TM.HapticFeedbackNativeModule.Spec {
14
+ private context: common.UIAbilityContext
15
+ constructor(ctx: TurboModuleContext) {
16
+ super(ctx);
17
+ this.context = ctx.uiAbilityContext
18
+ }
19
+ public trigger(type: string, options?: { enableVibrateFallback: boolean,ignoreAndroidSystemSettings:boolean }): void {
20
+ let ignoreHOSSystemSettingsVal = options?.ignoreAndroidSystemSettings || false
21
+ let singleObj = {
22
+ impactLight: { type: 'preset', effectId: 'haptic.effect.hard', intensity: 30 },
23
+ impactMedium: { type: 'preset', effectId: 'haptic.effect.hard', intensity: 60 },
24
+ impactHeavy: { type: 'preset', effectId: 'haptic.effect.hard' },
25
+ rigid: { type: 'preset', effectId: 'haptic.effect.sharp' },
26
+ soft: { type: 'preset', effectId: 'haptic.effect.soft' },
27
+ selection: { type: 'preset', effectId: 'haptic.effect.sharp', intensity: 50 },
28
+ effectClick: { type: 'preset', effectId: 'haptic.effect.soft', intensity: 60 },
29
+ effectHeavyClick: { type: 'preset', effectId: 'haptic.effect.soft', intensity: 80 },
30
+ effectTick: { type: 'preset', effectId: 'haptic.effect.soft', intensity: 70 },
31
+ }
32
+
33
+ let constantObj={
34
+ clockTick:{type: 'time',duration:4},
35
+ contextClick:{type: 'time',duration:6},
36
+ keyboardPress:{type: 'time',duration:3},
37
+ keyboardRelease:{type: 'time',duration:7},
38
+ keyboardTap:{type: 'time',duration:3},
39
+ longPress:{type: 'time',duration:0},
40
+ textHandleMove:{type: 'time',duration:9},
41
+ virtualKey:{type: 'time',duration:1},
42
+ virtualKeyRelease:{type: 'time',duration:8},
43
+ }
44
+
45
+ let multipleObj = {
46
+ notificationSuccess: { type: 'file' },
47
+ notificationWarning: { type: 'file' },
48
+ notificationError: { type: 'file' },
49
+ effectDoubleClick: { type: 'file' },
50
+ }
51
+ let audioManager = audio.getAudioManager();
52
+ let audioVolumeManager: audio.AudioVolumeManager = audioManager.getVolumeManager();
53
+ try {
54
+ let audioVolumeGroupManager: audio.AudioVolumeGroupManager =
55
+ audioVolumeManager.getVolumeGroupManagerSync(audio.DEFAULT_VOLUME_GROUP_ID);
56
+ Logger.info(`Get audioVolumeGroupManager success.`);
57
+ let value: audio.AudioRingMode = audioVolumeGroupManager.getRingerModeSync()
58
+ let isVolumeOn = value != 0
59
+ let isVibrateMode = value == 1
60
+ Logger.info(`Indicate that the ringer mode is obtained ${value}. finalBollen:${ignoreHOSSystemSettingsVal ==
61
+ false && !(isVolumeOn || isVibrateMode)} isVolumeOn:${isVolumeOn} isVibrateMode:${isVibrateMode}`);
62
+ if (ignoreHOSSystemSettingsVal == false && !(isVolumeOn || isVibrateMode)) {
63
+ return
64
+ }
65
+ if (singleObj[type]) {
66
+ try {
67
+ vibrator.startVibration({
68
+ type: singleObj[type].type,
69
+ effectId: singleObj[type].effectId,
70
+ count: 1,
71
+ intensity: singleObj[type].intensity || 100
72
+ }, {
73
+ id: 0,
74
+ usage: 'unknown'
75
+ }, (error: BusinessError) => {
76
+ if (error) {
77
+ Logger.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
78
+ return;
79
+ }
80
+ Logger.info('Succeed in starting vibration');
81
+ });
82
+ } catch (err) {
83
+ let e: BusinessError = err as BusinessError;
84
+ Logger.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);
85
+ }
86
+ } else if (multipleObj[type]) {
87
+ let rawFd = this.context.resourceManager.getRawFdSync(`${type}.json`);
88
+ try {
89
+ vibrator.startVibration({
90
+ type: multipleObj[type].type,
91
+ hapticFd: { fd: rawFd.fd, offset: rawFd.offset, length: rawFd.length }
92
+ }, {
93
+ id: 0,
94
+ usage: 'unknown'
95
+ }).then(() => {
96
+ Logger.info(`Succeed in starting vibration!!!!!! type:${type}.json fd:${rawFd.fd} offset: ${rawFd.offset} length: ${rawFd.length}`);
97
+ }, (error: BusinessError) => {
98
+ Logger.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
99
+ });
100
+ } catch (err) {
101
+ let e: BusinessError = err as BusinessError;
102
+ Logger.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);
103
+ }
104
+ this.context.resourceManager.closeRawFdSync(`${type}.json`)
105
+ }else if(constantObj[type]){
106
+ try {
107
+ vibrator.startVibration({
108
+ type: constantObj[type].type,
109
+ duration: constantObj[type].duration
110
+ }, {
111
+ id: 0,
112
+ usage: 'unknown'
113
+ }).then(() => {
114
+ Logger.info('Succeed in starting vibration');
115
+ }, (error: BusinessError) => {
116
+ Logger.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
117
+ });
118
+ } catch (err) {
119
+ let e: BusinessError = err as BusinessError;
120
+ Logger.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);
121
+ }
122
+ }else{
123
+ try {
124
+ vibrator.startVibration({
125
+ type: 'preset',
126
+ effectId: 'haptic.effect.sharp',
127
+ count: 1,
128
+ intensity: 50
129
+ }, {
130
+ id: 0,
131
+ usage: 'unknown'
132
+ }, (error: BusinessError) => {
133
+ if (error) {
134
+ Logger.error(`Failed to start vibration. Code: ${error.code}, message: ${error.message}`);
135
+ return;
136
+ }
137
+ Logger.info('Succeed in starting vibration');
138
+ });
139
+ } catch (err) {
140
+ let e: BusinessError = err as BusinessError;
141
+ Logger.error(`An unexpected error occurred. Code: ${e.code}, message: ${e.message}`);
142
+ }
143
+ }
144
+ } catch (err) {
145
+ let error = err as BusinessError;
146
+ Logger.error(`Failed to get audioVolumeGroupManager, error: ${error}`);
147
+ }
148
+ }
149
+ }