@ohos-cpf/3rdloop 0.0.8 → 0.0.9

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 (219) hide show
  1. package/README.md +25 -0
  2. package/lib/cli.js +22 -5
  3. package/lib/doctor.js +111 -10
  4. package/lib/mcp.js +498 -0
  5. package/package.json +6 -2
  6. package/vendor/Archive/data/.index/meta.json +7 -0
  7. package/vendor/Archive/data/.index/search.db +0 -0
  8. package/vendor/Archive/data/docs/experiences/arkts-check-tool-pitfalls-baseline-comparison.md +13 -0
  9. package/vendor/Archive/data/docs/experiences/arkts-deep-path-import-recognition.md +31 -0
  10. package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-entry-file-case-mismatch.md +25 -0
  11. package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-import-trailing-slash.md +20 -0
  12. package/vendor/Archive/data/docs/experiences/arkts-library-source-files-may-be-ts.md +18 -0
  13. package/vendor/Archive/data/docs/experiences/arkts-typedarray-buffer-interface-cast-compile-fixes.md +36 -0
  14. package/vendor/Archive/data/docs/experiences/arkts-xts-compile-error-clustering-fix.md +24 -0
  15. package/vendor/Archive/data/docs/experiences/arkts-xts-doc-expected-value-runtime-probe.md +35 -0
  16. package/vendor/Archive/data/docs/experiences/arkts-xts-fixture-rawfile-testability-injection.md +33 -0
  17. package/vendor/Archive/data/docs/experiences/code-linter-chinese-comment-false-positive.md +16 -0
  18. package/vendor/Archive/data/docs/experiences/esobject-new-expression-variable-tracking.md +33 -0
  19. package/vendor/Archive/data/docs/experiences/filesystem-case-sensitivity-module-resolution.md +31 -0
  20. package/vendor/Archive/data/docs/experiences/gitcode-clone-redirect-warning-normal.md +13 -0
  21. package/vendor/Archive/data/docs/experiences/kn_msgvq1w585ec8319.md +77 -0
  22. package/vendor/Archive/data/docs/experiences/kn_msovnm6rd46de72c.md +98 -0
  23. package/vendor/Archive/data/docs/experiences/kn_mspt8vntfe708576.md +87 -0
  24. package/vendor/Archive/data/docs/experiences/kn_mspu1ei77adbbb48.md +133 -0
  25. package/vendor/Archive/data/docs/experiences/kn_mspubgak8d30bfce.md +128 -0
  26. package/vendor/Archive/data/docs/experiences/kn_mspug2de3cb1f7c3.md +115 -0
  27. package/vendor/Archive/data/docs/experiences/kn_skill_opt_001.md +38 -0
  28. package/vendor/Archive/data/docs/experiences/loop-artifacts-verification-evidence-triangle.md +19 -0
  29. package/vendor/Archive/data/docs/experiences/macos-bash-replace-build-ps1.md +19 -0
  30. package/vendor/Archive/data/docs/experiences/macos-bsd-diff-q-illegal-option.md +15 -0
  31. package/vendor/Archive/data/docs/experiences/migrate-cjs-compatible-api-version-map-limit.md +17 -0
  32. package/vendor/Archive/data/docs/experiences/mp3agic-arkts-library-behavior-quirks.md +21 -0
  33. package/vendor/Archive/data/docs/experiences/ohos-face-detection-scan-api-mapping.md +15 -0
  34. package/vendor/Archive/data/docs/experiences/pr-metadata-and-diff-integrity-verification.md +12 -0
  35. package/vendor/Archive/data/docs/experiences/rn-coverage-index-signature-pseudo-member-false-negative.md +32 -0
  36. package/vendor/Archive/data/docs/experiences/rn-memory-check-severity-calibration.md +21 -0
  37. package/vendor/Archive/data/docs/experiences/rn-platform-specific-api-exclusion-evidence.md +24 -0
  38. package/vendor/Archive/data/docs/experiences/rn-upstream-version-diff-pitfalls.md +17 -0
  39. package/vendor/Archive/data/docs/experiences/rn-version-gap-risk-rating-rules.md +13 -0
  40. package/vendor/Archive/data/docs/experiences/rn-view-lib-native-contract-diff-fabric-spec.md +16 -0
  41. package/vendor/Archive/data/docs/experiences/rnoh-adapter-package-version-field-semantics.md +18 -0
  42. package/vendor/Archive/data/docs/experiences/rnoh-arkts-sqlite-rows-array-format.md +18 -0
  43. package/vendor/Archive/data/docs/experiences/rnoh-dependency-residue-scan-strategy.md +18 -0
  44. package/vendor/Archive/data/docs/experiences/rnoh-example-local-lib-dep-use-tgz.md +53 -0
  45. package/vendor/Archive/data/docs/experiences/rnoh-example-prereserve-rntesterlist.md +17 -0
  46. package/vendor/Archive/data/docs/experiences/rnoh-example-template-compatiblesdkversion-upgrade.md +29 -0
  47. package/vendor/Archive/data/docs/experiences/rnoh-example-turbomodule-shell-adaptation-checklist.md +41 -0
  48. package/vendor/Archive/data/docs/experiences/rnoh-mcp-build-project-tool-risk.md +18 -0
  49. package/vendor/Archive/data/docs/experiences/rnoh-npm-devdependencies-version-precheck.md +29 -0
  50. package/vendor/Archive/data/docs/experiences/rnoh-repo-baseline-version-verification.md +13 -0
  51. package/vendor/Archive/data/docs/experiences/rnoh-repo-upstream-directory-mapping.md +18 -0
  52. package/vendor/Archive/data/docs/experiences/rnoh-stateless-library-zero-leak-verification.md +31 -0
  53. package/vendor/Archive/data/docs/experiences/rnoh-template-npmrc-credential-removal.md +15 -0
  54. package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-codegen-wiring-verification.md +19 -0
  55. package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-cpp-methodmap-compatibility-check.md +20 -0
  56. package/vendor/Archive/data/docs/experiences/scenario-doc-vs-source-signature-diff-four-patterns.md +24 -0
  57. package/vendor/Archive/data/docs/experiences/static-analysis-grep-cross-validation.md +29 -0
  58. package/vendor/Archive/demo.js +489 -0
  59. package/vendor/Archive/index.js +43 -0
  60. package/vendor/Archive/package.json +16 -0
  61. package/vendor/Archive/src/constants.js +83 -0
  62. package/vendor/Archive/src/data/stopwords.txt +110 -0
  63. package/vendor/Archive/src/data/synonyms.json +25 -0
  64. package/vendor/Archive/src/data/terms.txt +59 -0
  65. package/vendor/Archive/src/db/sqlite-backend.js +312 -0
  66. package/vendor/Archive/src/db/sqlite-schema.js +64 -0
  67. package/vendor/Archive/src/engine.js +501 -0
  68. package/vendor/Archive/src/index/index-manager.js +203 -0
  69. package/vendor/Archive/src/index/index-state.js +94 -0
  70. package/vendor/Archive/src/index/search-text-builder.js +106 -0
  71. package/vendor/Archive/src/index.js +22 -0
  72. package/vendor/Archive/src/parser/api-identifiers.js +121 -0
  73. package/vendor/Archive/src/parser/api-suffixes.js +48 -0
  74. package/vendor/Archive/src/parser/heading-normalize.js +40 -0
  75. package/vendor/Archive/src/parser/markdown-splitter.js +215 -0
  76. package/vendor/Archive/src/search/catalog-routing.js +87 -0
  77. package/vendor/Archive/src/search/fts-search.js +289 -0
  78. package/vendor/Archive/src/search/query-normalizer.js +159 -0
  79. package/vendor/Archive/src/search/query-rewriter.js +72 -0
  80. package/vendor/Archive/src/search/search-engine.js +72 -0
  81. package/vendor/Archive/src/search/snippet.js +64 -0
  82. package/vendor/Archive/src/store/dir-store.js +103 -0
  83. package/vendor/Archive/src/store/doc-store.js +36 -0
  84. package/vendor/Archive/src/tokenizer/lexicon.js +151 -0
  85. package/vendor/Archive/src/tokenizer/tokenizer.js +167 -0
  86. package/vendor/Archive/src/types.js +86 -0
  87. package/vendor/Archive/src/utils/hash.js +16 -0
  88. package/vendor/Archive/src/utils/lock.js +73 -0
  89. package/vendor/Archive/src/utils/path-safety.js +96 -0
  90. package/vendor/Archive/src/utils/paths.js +39 -0
  91. package/vendor/BadCase/rn/INDEX.md +127 -0
  92. package/vendor/BadCase/rn/cases/KI-001-webview/350/247/206/351/242/221/346/227/240/346/263/225/346/250/252/345/261/217.md +52 -0
  93. package/vendor/BadCase/rn/cases/KI-002-fastImage/347/203/255/346/233/264/346/226/260/345/233/276/347/211/207/345/244/261/350/264/245.md +37 -0
  94. package/vendor/BadCase/rn/cases/KI-003-wechat/347/274/251/347/225/245/345/233/276/346/234/254/345/234/260/345/233/276/347/211/207.md +62 -0
  95. package/vendor/BadCase/rn/cases/KI-004-wechat/345/233/236/350/260/203/346/227/266/345/272/217.md +47 -0
  96. package/vendor/BadCase/rn/cases/KI-005-geolocation/345/257/274/345/205/245/350/267/257/345/276/204/345/220/216/347/274/200.md +31 -0
  97. package/vendor/BadCase/rn/cases/KI-006-SmartRefreshLayout/346/231/272/350/203/275/346/214/207/351/222/210/345/264/251/346/272/203.md +55 -0
  98. package/vendor/BadCase/rn/cases/KI-007-orientation-locker/344/274/240/346/204/237/345/231/250/345/210/235/345/247/213/345/214/226.md +58 -0
  99. package/vendor/BadCase/rn/cases/KI-008-orientation-locker/344/274/240/346/204/237/345/231/250/345/274/225/347/224/250/350/256/241/346/225/260.md +47 -0
  100. package/vendor/BadCase/rn/cases/KI-009-pager-view/345/265/214/345/245/227/346/273/221/345/212/250.md +38 -0
  101. package/vendor/BadCase/rn/cases/KI-010-screens/346/211/213/345/212/277/345/206/262/347/252/201.md +48 -0
  102. package/vendor/BadCase/rn/cases/KI-011-spring-scrollview/346/211/213/345/212/277/351/207/215/345/244/215/347/273/221/345/256/232.md +49 -0
  103. package/vendor/BadCase/rn/cases/KI-012-qr-camera/346/250/252/345/261/217/351/200/202/351/205/215.md +59 -0
  104. package/vendor/BadCase/rn/cases/KI-013-webview/346/267/261/350/211/262/346/250/241/345/274/217/350/203/214/346/231/257/350/211/262.md +37 -0
  105. package/vendor/BadCase/rn/cases/KI-014-amap-geolocation/345/233/236/350/260/203/347/274/272/345/244/261.md +42 -0
  106. package/vendor/BadCase/rn/cases/KI-015-reanimated/350/277/220/350/241/214/346/227/266/346/236/220/346/236/204/345/264/251/346/272/203.md +54 -0
  107. package/vendor/BadCase/rn/cases/KI-016-fs/346/226/207/344/273/266/350/257/273/345/217/226/347/274/226/347/240/201.md +58 -0
  108. package/vendor/BadCase/rn/cases/KI-017-blob-util/345/217/202/346/225/260/347/274/226/347/240/201/351/224/231/350/257/257.md +39 -0
  109. package/vendor/BadCase/rn/cases/KI-018-modal/345/274/271/347/252/227/351/227/252/347/203/201.md +53 -0
  110. package/vendor/BadCase/rn/cases/KI-019-code-push/351/207/215/345/220/257/351/200/273/350/276/221/345/244/261/346/225/210.md +79 -0
  111. package/vendor/BadCase/rn/cases/KI-020-netinfo/346/225/217/346/204/237/344/277/241/346/201/257/346/263/204/351/234/262.md +60 -0
  112. package/vendor/BadCase/rn/cases/KI-021-video/346/234/254/345/234/260/350/247/206/351/242/221/346/222/255/346/224/276/345/274/202/345/270/270.md +79 -0
  113. package/vendor/BadCase/rn/cases/KI-022-audio-recorder-player/346/236/232/344/270/276/347/274/272/345/244/261.md +38 -0
  114. package/vendor/BadCase/rn/cases/KI-023-svg/346/270/220/345/217/230/347/273/247/346/211/277/345/244/261/346/225/210.md +62 -0
  115. package/vendor/BadCase/rn/generalization-log.md +55 -0
  116. package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.json +328 -0
  117. package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.md +382 -0
  118. package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.json +1351 -0
  119. package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.md +1176 -0
  120. package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.json +538 -0
  121. package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.md +1488 -0
  122. package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.json +211 -0
  123. package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.md +35 -0
  124. package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.json +2048 -0
  125. package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.md +3866 -0
  126. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.json +198 -0
  127. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.md +40 -0
  128. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.json +751 -0
  129. package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.md +883 -0
  130. package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.json +1544 -0
  131. package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.md +2598 -0
  132. package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.json +246 -0
  133. package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.md +554 -0
  134. package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.json +211 -0
  135. package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.md +54 -0
  136. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.json +1626 -0
  137. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.md +2213 -0
  138. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.json +208 -0
  139. package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.md +77 -0
  140. package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.json +377 -0
  141. package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.md +174 -0
  142. package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.json +232 -0
  143. package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.md +194 -0
  144. package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.json +198 -0
  145. package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.md +67 -0
  146. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.json +198 -0
  147. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.md +38 -0
  148. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.json +208 -0
  149. package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.md +34 -0
  150. package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.json +222 -0
  151. package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.md +56 -0
  152. package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.json +463 -0
  153. package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.md +383 -0
  154. package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.json +464 -0
  155. package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.md +565 -0
  156. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.json +198 -0
  157. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.md +47 -0
  158. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.json +232 -0
  159. package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.md +422 -0
  160. package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.json +295 -0
  161. package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.md +1038 -0
  162. package/vendor/BadCase/rn/rules/R-01-/345/205/250/345/261/217/347/252/227/345/217/243/347/212/266/346/200/201/347/256/241/347/220/206/345/256/214/346/225/264/346/200/247.md +20 -0
  163. package/vendor/BadCase/rn/rules/R-02-/350/265/204/346/272/220URI/345/275/242/346/200/201/345/210/206/346/224/257/350/246/206/347/233/226.md +21 -0
  164. package/vendor/BadCase/rn/rules/R-03-/351/231/204/345/261/236/346/223/215/344/275/234/345/244/261/350/264/245/351/230/273/346/226/255/344/270/273/346/265/201/347/250/213.md +20 -0
  165. package/vendor/BadCase/rn/rules/R-04-/345/274/202/346/255/245/345/233/236/350/260/203/346/263/250/345/206/214/346/227/266/345/272/217.md +20 -0
  166. package/vendor/BadCase/rn/rules/R-05-/346/250/241/345/235/227/345/257/274/345/205/245/350/267/257/345/276/204/350/247/204/350/214/203.md +19 -0
  167. package/vendor/BadCase/rn/rules/R-06-/344/274/240/346/204/237/345/231/250/347/241/254/344/273/266/346/235/203/351/231/220/346/214/211/351/234/200/350/216/267/345/217/226.md +21 -0
  168. package/vendor/BadCase/rn/rules/R-07-/346/231/272/350/203/275/346/214/207/351/222/210/347/224/237/345/221/275/345/221/250/346/234/237/347/256/241/347/220/206.md +20 -0
  169. package/vendor/BadCase/rn/rules/R-08-/346/211/213/345/212/277/344/272/213/344/273/266/346/263/250/345/206/214/344/270/216/345/206/262/347/252/201/345/244/204/347/220/206.md +22 -0
  170. package/vendor/BadCase/rn/rules/R-09-/346/250/252/347/253/226/345/261/217/345/244/232/345/275/242/346/200/201/345/270/203/345/261/200/351/200/202/351/205/215.md +20 -0
  171. package/vendor/BadCase/rn/rules/R-10-/346/267/261/350/211/262/346/250/241/345/274/217/344/270/273/351/242/230/351/242/234/350/211/262/351/200/202/351/205/215.md +19 -0
  172. package/vendor/BadCase/rn/rules/R-11-/346/216/245/345/217/243/345/233/236/350/260/203/345/256/236/347/216/260/345/256/214/346/225/264/346/200/247.md +20 -0
  173. package/vendor/BadCase/rn/rules/R-12-/345/216/237/347/224/237/350/277/220/350/241/214/346/227/266/350/265/204/346/272/220/346/236/220/346/236/204/346/227/266/345/272/217.md +20 -0
  174. package/vendor/BadCase/rn/rules/R-13-/346/226/207/344/273/266/346/225/260/346/215/256/347/274/226/347/240/201/344/270/216/346/240/274/345/274/217/345/205/274/345/256/271.md +21 -0
  175. package/vendor/BadCase/rn/rules/R-14-/345/212/250/347/224/273/345/210/235/345/247/213/345/214/226/346/227/266/345/272/217/344/270/216/347/212/266/346/200/201/345/220/214/346/255/245.md +20 -0
  176. package/vendor/BadCase/rn/rules/R-15-/347/212/266/346/200/201/346/214/201/344/271/205/345/214/226/344/270/216/351/207/215/345/220/257/351/200/273/350/276/221/344/270/200/350/207/264/346/200/247.md +20 -0
  177. package/vendor/BadCase/rn/rules/R-16-/346/225/217/346/204/237/344/277/241/346/201/257/346/227/245/345/277/227/346/263/204/351/234/262.md +19 -0
  178. package/vendor/BadCase/rn/rules/R-17-/345/252/222/344/275/223/350/265/204/346/272/220/347/224/237/345/221/275/345/221/250/346/234/237/344/270/216/351/224/231/350/257/257/345/244/204/347/220/206.md +21 -0
  179. package/vendor/BadCase/rn/rules/R-18-/350/203/275/345/212/233/346/236/232/344/270/276/351/205/215/347/275/256/345/256/214/346/225/264/346/200/247.md +19 -0
  180. package/vendor/BadCase/rn/rules/R-19-/345/233/276/345/275/242/346/270/262/346/237/223/345/261/236/346/200/247/347/273/247/346/211/277/344/270/216/351/207/215/347/275/256.md +19 -0
  181. package/vendor/MCP/README.md +490 -0
  182. package/vendor/MCP/config.json +29 -0
  183. package/vendor/MCP/package.json +23 -0
  184. package/vendor/MCP/scripts/analyze-demo-coverage.cjs +1203 -0
  185. package/vendor/MCP/scripts/analyze-xts-coverage.cjs +1245 -0
  186. package/vendor/MCP/scripts/deveco_docs.js +247 -0
  187. package/vendor/MCP/scripts/extract-interfaces.cjs +1487 -0
  188. package/vendor/MCP/scripts/flutter-analyze-demo-coverage.cjs +666 -0
  189. package/vendor/MCP/scripts/flutter-analyze-xts-coverage.cjs +684 -0
  190. package/vendor/MCP/scripts/flutter-extract-interfaces.cjs +1251 -0
  191. package/vendor/MCP/scripts/flutter-render-spec-doc.cjs +351 -0
  192. package/vendor/MCP/scripts/render-spec-doc.cjs +347 -0
  193. package/vendor/MCP/scripts/rn-analyze-demo-coverage.cjs +645 -0
  194. package/vendor/MCP/scripts/rn-analyze-test-coverage.cjs +614 -0
  195. package/vendor/MCP/scripts/rn-extract-interfaces.cjs +1462 -0
  196. package/vendor/MCP/scripts/rn-render-spec-doc.cjs +327 -0
  197. package/vendor/MCP/scripts/rn-scan-exports.cjs +1336 -0
  198. package/vendor/MCP/src/client/MCPClientPool.js +220 -0
  199. package/vendor/MCP/src/config/ConfigLoader.js +189 -0
  200. package/vendor/MCP/src/executor/ScriptExecutor.js +110 -0
  201. package/vendor/MCP/src/gateway/Gateway.js +451 -0
  202. package/vendor/MCP/src/index.js +87 -0
  203. package/vendor/MCP/src/library/KBToolProvider.js +229 -0
  204. package/vendor/MCP/src/library/logger.js +60 -0
  205. package/vendor/MCP/src/registry/ScriptRegistry.js +238 -0
  206. package/vendor/MCP/src/registry/ToolRegistry.js +111 -0
  207. package/vendor/MCP/src/types.js +115 -0
  208. package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +4 -2
  209. package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +3 -3
  210. package/vendor/Server/Skills/knowledge-import/SKILL.md +1 -1
  211. package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +12 -4
  212. package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +5 -4
  213. package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +2 -2
  214. package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +2 -2
  215. package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +1 -2
  216. package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +1 -1
  217. package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +1 -2
  218. package/vendor/Server/package.json +5 -1
  219. package/vendor/VERSION +3 -3
@@ -0,0 +1,2598 @@
1
+ # PR #24: fix:去除index.ets,ts.ets中导包带入的.ets
2
+
3
+ - **状态**: merged
4
+ - **作者**: chenbaodi123
5
+ - **创建时间**: 2026-07-07T11:02:00+08:00
6
+ - **分支**: br_rnoh0.72 → br_rnoh0.72
7
+ - **变更文件数**: 55
8
+
9
+ ## PR 描述
10
+
11
+ 问题原因:index.ets,ts.ets的导包带了.ets的后缀,导致ide显示爆红,但是不影响使用,影响开发者使用体验,以为是三方库有问题
12
+ 解决方案:去除index.ets,ts.ets中导包带入的.ets后缀
13
+
14
+ ## 变更文件
15
+
16
+ | 文件 | 变更 | +行 | -行 |
17
+ |------|------|-----|-----|
18
+ | `OAT.xml` | ? | +46 | -1 |
19
+ | `README.md` | ? | +296 | -7 |
20
+ | `README_en.md` | added | +301 | -0 |
21
+ | `example/.eslintrc` | added | +37 | -0 |
22
+ | `example/.gitignore` | added | +71 | -0 |
23
+ | `example/.node-version` | added | +24 | -0 |
24
+ | `example/.prettierrc.js` | added | +7 | -0 |
25
+ | `example/.watchmanconfig` | added | +1 | -0 |
26
+ | `example/app.json` | added | +4 | -0 |
27
+ | `example/babel.config.js` | added | +6 | -0 |
28
+ | `example/contexts.ts` | added | +27 | -0 |
29
+ | `example/harmony/.gitignore` | added | +24 | -0 |
30
+ | `example/harmony/AppScope/app.json5` | added | +10 | -0 |
31
+ | `example/harmony/AppScope/resources/base/element/string.json` | added | +8 | -0 |
32
+ | `example/harmony/AppScope/resources/base/media/app_icon.png` | added | +0 | -0 |
33
+ | `example/harmony/build-profile.template.json5` | added | +44 | -0 |
34
+ | `example/harmony/codelinter.json` | added | +32 | -0 |
35
+ | `example/harmony/entry/.gitignore` | added | +7 | -0 |
36
+ | `example/harmony/entry/build-profile.json5` | added | +22 | -0 |
37
+ | `example/harmony/entry/hvigorfile.ts` | added | +26 | -0 |
38
+ | `example/harmony/entry/oh-package.json5` | added | +11 | -0 |
39
+ | `example/harmony/entry/src/main/cpp/.gitignore` | added | +2 | -0 |
40
+ | `example/harmony/entry/src/main/cpp/CMakeLists.txt` | added | +41 | -0 |
41
+ | `example/harmony/entry/src/main/cpp/PackageProvider.cpp` | added | +37 | -0 |
42
+ | `example/harmony/entry/src/main/ets/RNPackagesFactory.ets` | added | +32 | -0 |
43
+ | `example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf` | added | +0 | -0 |
44
+ | `example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf` | added | +0 | -0 |
45
+ | `example/harmony/entry/src/main/ets/entryability/EntryAbility.ets` | added | +40 | -0 |
46
+ | `example/harmony/entry/src/main/ets/pages/Index.ets` | added | +136 | -0 |
47
+ | `example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets` | added | +153 | -0 |
48
+ | `example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets` | added | +62 | -0 |
49
+ | `example/harmony/entry/src/main/module.json5` | added | +62 | -0 |
50
+ | `example/harmony/entry/src/main/resources/.gitignore` | added | +1 | -0 |
51
+ | `example/harmony/entry/src/main/resources/base/element/color.json` | added | +8 | -0 |
52
+ | `example/harmony/entry/src/main/resources/base/element/string.json` | added | +20 | -0 |
53
+ | `example/harmony/entry/src/main/resources/base/media/icon.png` | added | +0 | -0 |
54
+ | `example/harmony/entry/src/main/resources/base/profile/main_pages.json` | added | +5 | -0 |
55
+ | `example/harmony/entry/src/main/resources/rawfile/1.txt` | added | +1 | -0 |
56
+ | `example/harmony/format.ps1` | added | +36 | -0 |
57
+ | `example/harmony/hvigor/.gitignore` | added | +1 | -0 |
58
+ | `example/harmony/hvigor/hvigor-config.json5` | added | +21 | -0 |
59
+ | `example/harmony/hvigorfile.ts` | added | +27 | -0 |
60
+ | `example/harmony/oh-package.json5` | added | +12 | -0 |
61
+ | `example/index.js` | added | +29 | -0 |
62
+ | `example/jest.config.js` | added | +29 | -0 |
63
+ | `example/metro.config.js` | added | +48 | -0 |
64
+ | `example/package.json` | added | +61 | -0 |
65
+ | `example/react-native.config.js` | added | +29 | -0 |
66
+ | `example/scripts/create-build-profile.js` | added | +64 | -0 |
67
+ | `example/src/index.tsx` | added | +40 | -0 |
68
+ | `example/tsconfig.json` | added | +14 | -0 |
69
+ | `harmony/geolocation/index.ets` | ? | +2 | -2 |
70
+ | `harmony/geolocation/ts.ets` | ? | +2 | -2 |
71
+ | `package.json` | ? | +1 | -0 |
72
+ | `react-native-geolocation.podspec` | deleted | +0 | -35 |
73
+
74
+ ## Diff
75
+
76
+ ### `OAT.xml`
77
+
78
+ ```diff
79
+ @@ -2,6 +2,18 @@
80
+ <configuration>
81
+ <oatconfig>
82
+ <licensefile>LICENSE</licensefile>
83
+ + <policylist>
84
+ + <policy name="projectPolicy" desc="">
85
+ + <policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
86
+ + </policy>
87
+ + <policy name="projectPolicy" desc="">
88
+ + <policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
89
+ + <policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
90
+ + <policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
91
+ + <policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
92
+ + <policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
93
+ + </policy>
94
+ + </policylist>
95
+ <filefilterlist>
96
+ <filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
97
+ <filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
98
+ @@ -14,7 +26,23 @@
99
+ <filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
100
+ <filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
101
+ <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
102
+ - <filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
103
+ + <filteritem type="filename" name="LICENSE" desc="disan原三方库证书文件无需更改,因此添加过滤"/>
104
+ + <filteritem type="filepath" name="example/harmony/entry/src/main/cpp/generated/.*" desc="Codegen生成文件,不手动修改"/>
105
+ + <filteritem type="filepath" name="example/.prettierrc.js" desc="工程模板,不添加许可证头"/>
106
+ + <filteritem type="filepath" name="example/.watchmanconfig" desc="工程模板,不添加许可证头"/>
107
+ + <filteritem type="filepath" name="example/babel.config.js" desc="工程模板,不添加许可证头"/>
108
+ + <filteritem type="filepath" name="example/harmony/.clang-tidy" desc="工程模板,不添加许可证头"/>
109
+ + <filteritem type="filepath" name="example/harmony/.clangd" desc="工程模板,不添加许可证头"/>
110
+ + <filteritem type="filepath" name=".releaserc" desc="工程模板,不添加许可证头"/>
111
+ + <filteritem type="filepath" name="babel.config.js" desc="工程模板,不添加许可证头"/>
112
+ + <filteritem type="filepath" name="yarn.lock" desc="工程模板,不添加许可证头"/>
113
+ + <filteritem type="filepath" name="example/harmony/entry/src/main/resources/rawfile/bundle.harmony.js" desc="编译生成文件"/>
114
+ + <filteritem type="filepath" name="js/index.ts" desc="原三方库源码,不修改版权头,以防有修改版权风险"/>
115
+ + <filteritem type="filepath" name="example/harmony/format.ps1" desc="工程模板,不添加许可证头"/>
116
+ + <filteritem type="filepath" name="example/.eslintrc" desc="工程模板,不添加许可证头"/>
117
+ + <filteritem type="filepath" name="example/.node-version" desc="工程模板,不添加许可证头"/>
118
+ + <filteritem type="filepath" name="example/.eslintrc" desc="工程模板,不添加许可证头"/>
119
+ + <filteritem type="filepath" name="example/scripts/create-build-profile.js" desc="工程模板,不添加许可证头"/>
120
+ </filefilter>
121
+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
122
+ <filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
123
+ @@ -28,6 +56,22 @@
124
+ <filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
125
+ <filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
126
+ <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
127
+ + <filteritem type="filepath" name="example/harmony/entry/src/main/cpp/generated/.*" desc="Codegen生成文件,不手动修改"/>
128
+ + <filteritem type="filepath" name="example/.prettierrc.js" desc="工程模板,不添加许可证头"/>
129
+ + <filteritem type="filepath" name="example/.watchmanconfig" desc="工程模板,不添加许可证头"/>
130
+ + <filteritem type="filepath" name="example/babel.config.js" desc="工程模板,不添加许可证头"/>
131
+ + <filteritem type="filepath" name="example/harmony/.clang-tidy" desc="工程模板,不添加许可证头"/>
132
+ + <filteritem type="filepath" name="example/harmony/.clangd" desc="工程模板,不添加许可证头"/>
133
+ + <filteritem type="filepath" name=".releaserc" desc="工程模板,不添加许可证头"/>
134
+ + <filteritem type="filepath" name="babel.config.js" desc="工程模板,不添加许可证头"/>
135
+ + <filteritem type="filepath" name="yarn.lock" desc="工程模板,不添加许可证头"/>
136
+ + <filteritem type="filepath" name="example/harmony/entry/src/main/resources/rawfile/bundle.harmony.js" desc="编译生成文件"/>
137
+ + <filteritem type="filepath" name="js/index.ts" desc="原三方库源码,不修改版权头,以防有修改版权风险"/>
138
+ + <filteritem type="filepath" name="example/harmony/format.ps1" desc="工程模板,不添加许可证头"/>
139
+ + <filteritem type="filepath" name="example/.eslintrc" desc="工程模板,不添加许可证头"/>
140
+ + <filteritem type="filepath" name="example/.node-version" desc="工程模板,不添加许可证头"/>
141
+ + <filteritem type="filepath" name="example/.eslintrc" desc="工程模板,不添加许可证头"/>
142
+ + <filteritem type="filepath" name="example/scripts/create-build-profile.js" desc="工程模板,不添加许可证头"/>
143
+ </filefilter>
144
+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
145
+ <filteritem type="filepath" name="harmony/geolocation.har" desc="项目打包文件" />
146
+ @@ -35,6 +79,7 @@
147
+ <filteritem type="filename" name="app_icon.png" desc="应用图标"/>
148
+ <filteritem type="filename" name="warn.png" desc="页面展示图标"/>
149
+ <filteritem type="filename" name="*.png" desc="展示图标"/>
150
+ + <filteritem type="filepath" name="example/harmony/entry/src/main/ets/assets/fonts/.*" desc="字体资源文件"/>
151
+ </filefilter>
152
+ </filefilterlist>
153
+ </oatconfig>
154
+
155
+ ```
156
+
157
+ ### `README.md`
158
+
159
+ ```diff
160
+ @@ -1,13 +1,302 @@
161
+ -# @react-native-ohos/react-native-geolocation
162
+ +> 模板版本:v0.4.0
163
+
164
+ -This project is based on [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation)@3.4.0
165
+ +<p align="center">
166
+ + <h1 align="center"> @react-native-community/geolocation</code> </h1>
167
+ +</p>
168
+
169
+ -## Documentation
170
+ +本项目基于 [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation) 开发。
171
+
172
+ -- [中文](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-community-geolocation.md)
173
+ +该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/geolocation` 版本所属关系如下:
174
+ +| 三方库名称 | 三方库版本 | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | npm地址 |
175
+ +| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
176
+ +| @react-native-ohos/geolocation | ~ 3.5.0 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-geolocation/releases) | 0.82.* | 是 | API12+ | 3.4.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/geolocation) |
177
+ +| @react-native-ohos/geolocation | ~ 3.4.1 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-geolocation/releases) | 0.77.* | 否 | API12+ | 3.4.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/geolocation) |
178
+ +| @react-native-ohos/geolocation | ~ 3.1.1 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-geolocation/releases) | 0.72.* | 是 | API12+ | 3.1.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/geolocation) |
179
+ +| @react-native-oh-tpl/react-native-geolocation | <= 3.1.0-0.0.7@deprecated | [Github Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases) | 0.72.* | 否 | API12+ | 3.1.0 | [Npm Address](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-geolocation) |
180
+
181
+ -- [English](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-community-geolocation.md)
182
+ +## 安装与使用
183
+
184
+ -## License
185
+ +进入到工程目录并输入以下命令:
186
+ +
187
+ +<!-- tabs:start -->
188
+ +
189
+ +#### **npm**
190
+ +
191
+ +```bash
192
+ +npm install @react-native-ohos/geolocation
193
+ +```
194
+ +
195
+ +#### **yarn**
196
+ +
197
+ +```bash
198
+ +yarn add @react-native-ohos/geolocation
199
+ +```
200
+ +
201
+ +<!-- tabs:end -->
202
+ +
203
+ +下面的代码展示了这个库的基本使用场景:
204
+ +
205
+ +> [!WARNING] 使用时 import 的库名不变。
206
+ +
207
+ +```js
208
+ +import Geolocation from "@react-native-community/geolocation";
209
+ +import { Button } from "react-native";
210
+ +import React from 'react';
211
+ +
212
+ +export function GeolocationDemo(): JSX.Element {
213
+ + const tap = () => {
214
+ + Geolocation.setRNConfiguration({
215
+ + skipPermissionRequests: true,
216
+ + authorizationLevel: "auto",
217
+ + enableBackgroundLocationUpdates: true,
218
+ + locationProvider: "auto",
219
+ + });
220
+ + console.log("tap");
221
+ + };
222
+ +
223
+ + return <Button title='test' onPress={tap} />;
224
+ +}
225
+ +```
226
+ +
227
+ +## Link
228
+ +
229
+ +| | 是否支持autolink | RN框架版本 |
230
+ +|--------------------------------------|-----------------|------------|
231
+ +| ~3.5.0 | Yes | 0.82 |
232
+ +| ~3.4.1 | No | 0.77 |
233
+ +| ~3.1.1 | Yes | 0.72 |
234
+ +| <= 3.1.0-0.0.7@deprecated | No | 0.72 |
235
+ +
236
+ +使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
237
+ +
238
+ +如您使用的版本支持 Autolink,并且工程已接入 Autolink,可跳过ManualLink配置。
239
+ +<details>
240
+ + <summary>ManualLink: 此步骤为手动配置原生依赖项的指导</summary>
241
+ +
242
+ +首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
243
+ +
244
+ +### 1.在工程根目录的 `oh-package.json5` 添加 overrides 字段
245
+ +
246
+ +```json
247
+ +{
248
+ + ...
249
+ + "overrides": {
250
+ + "@rnoh/react-native-openharmony" : "./react_native_openharmony"
251
+ + }
252
+ +}
253
+ +```
254
+ +
255
+ +### 2.引入原生端代码
256
+ +
257
+ +目前有两种方法:
258
+ +
259
+ +1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
260
+ +2. 直接链接源码。
261
+ +
262
+ +方法一:通过 har 包引入(推荐)
263
+ +
264
+ +> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
265
+ +
266
+ +打开 `entry/oh-package.json5`,添加以下依赖
267
+ +
268
+ +```json
269
+ +"dependencies": {
270
+ + "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
271
+ + "@react-native-ohos/geolocation": "file:../../node_modules/@react-native-ohos/geolocation/harmony/geolocation.har"
272
+ + }
273
+ +```
274
+ +
275
+ +点击右上角的 `sync` 按钮
276
+ +
277
+ +或者在终端执行:
278
+ +
279
+ +```bash
280
+ +cd entry
281
+ +ohpm install
282
+ +```
283
+ +
284
+ +方法二:直接链接源码
285
+ +
286
+ +> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](./link-source-code.md)
287
+ +
288
+ +### 3.配置 CMakeLists 和引入 geolocation
289
+ +
290
+ +> 若使用的是 <= 3.1.0-0.0.7 版本,请跳过本章。
291
+ +
292
+ +打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
293
+ +
294
+ +```diff
295
+ +project(rnapp)
296
+ +cmake_minimum_required(VERSION 3.4.1)
297
+ +set(CMAKE_SKIP_BUILD_RPATH TRUE)
298
+ +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
299
+ +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
300
+ ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
301
+ +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
302
+ +set(LOG_VERBOSITY_LEVEL 1)
303
+ +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
304
+ +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
305
+ +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
306
+ +add_compile_definitions(WITH_HITRACE_SYSTRACE)
307
+ +
308
+ +add_subdirectory("${RNOH_CPP_DIR}" ./rn)
309
+ +
310
+ +# RNOH_BEGIN: manual_package_linking_1
311
+ +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
312
+ ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/geolocation/src/main/cpp" ./geolocation)
313
+ +# RNOH_END: manual_package_linking_1
314
+ +
315
+ +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
316
+ +
317
+ +add_library(rnoh_app SHARED
318
+ + ${GENERATED_CPP_FILES}
319
+ + "./PackageProvider.cpp"
320
+ + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
321
+ +)
322
+ +
323
+ +target_link_libraries(rnoh_app PUBLIC rnoh)
324
+ +
325
+ +# RNOH_BEGIN: manual_package_linking_2
326
+ +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
327
+ ++ target_link_libraries(rnoh_app PUBLIC rnoh_geolocation)
328
+ +# RNOH_END: manual_package_linking_2
329
+ +```
330
+ +
331
+ +打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
332
+ +
333
+ +```diff
334
+ +#include "RNOH/PackageProvider.h"
335
+ +#include "SamplePackage.h"
336
+ ++ #include "GeoLocationPackage.h"
337
+ +
338
+ +using namespace rnoh;
339
+ +
340
+ +std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
341
+ + return {
342
+ + std::make_shared<SamplePackage>(ctx),
343
+ ++ std::make_shared<GeoLocationPackage>(ctx)
344
+ + };
345
+ +}
346
+ +```
347
+ +
348
+ +### 4.在 ArkTs 侧引入 GeolocationPackage
349
+ +
350
+ +打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
351
+ +
352
+ +```diff
353
+ + ...
354
+ ++ import {GeoLocationPackage} from '@react-native-ohos/geolocation/ts';
355
+ +
356
+ +export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
357
+ + return [
358
+ + new SamplePackage(ctx),
359
+ ++ new GeoLocationPackage(ctx)
360
+ + ];
361
+ +}
362
+ +```
363
+ +</details>
364
+ +
365
+ +## 运行
366
+ +
367
+ +点击右上角的 `sync` 按钮
368
+ +
369
+ +或者在终端执行:
370
+ +
371
+ +```bash
372
+ +cd entry
373
+ +ohpm install
374
+ +```
375
+ +
376
+ +然后编译、运行即可。
377
+ +
378
+ +## 约束与限制
379
+ +
380
+ +### 兼容性
381
+ +
382
+ +要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
383
+ +
384
+ +在以下版本验证通过:
385
+ +
386
+ +1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
387
+ +2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71;
388
+ +3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
389
+ +4. RNOH: 0.82.1; SDK: HarmonyOS 6.0.1 Release SDK; IDE: DevEco Studio 6.0.1 Release; ROM:6.0.0.120 SP7;
390
+ +
391
+ +
392
+ +### 权限要求
393
+ +
394
+ +1.打开 `entry/src/main/module.json5`,添加相关配置
395
+ +
396
+ +```diff
397
+ +...
398
+ +{
399
+ + "module": {
400
+ + "requestPermissions": [
401
+ ++ {
402
+ ++ "name": "ohos.permission.APPROXIMATELY_LOCATION",
403
+ ++ "reason": "$string:Access_location",
404
+ ++ "usedScene": {
405
+ ++ "abilities": [
406
+ ++ "EntryAbility"
407
+ ++ ],
408
+ ++ "when": "always"
409
+ ++ }
410
+ ++ },
411
+ ++ {
412
+ ++ "name": "ohos.permission.LOCATION",
413
+ ++ "reason": "$string:Access_location",
414
+ ++ "usedScene": {
415
+ ++ "abilities": [
416
+ ++ "EntryAbility"
417
+ ++ ],
418
+ ++ "when": "always"
419
+ ++ }
420
+ ++ },
421
+ ++ {
422
+ ++ "name": "ohos.permission.INTERNET"
423
+ ++ }
424
+ + ]
425
+ + }
426
+ +}
427
+ +```
428
+ +
429
+ +2.在 entry 目录下添加申请权限的原因
430
+ +
431
+ +打开 `entry/src/main/resources/base/element/string.json`,添加:
432
+ +
433
+ +```diff
434
+ +...
435
+ +{
436
+ + "string": [
437
+ ++ {
438
+ ++ "name": "Access_location",
439
+ ++ "value": "access location"
440
+ ++ }
441
+ + ]
442
+ +}
443
+ +```
444
+ +
445
+ +## 属性
446
+ +
447
+ +> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
448
+ +
449
+ +> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
450
+ +
451
+ +| Name | Description | Type | Required | Platform | HarmonyOS Support | Notes |
452
+ +| -------------------- | ------------------------------------------------------------------ | ----------------------------------------------- | -------- | ----------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
453
+ +| setRNConfiguration | 设置将在所有位置请求中使用的配置选项 | function(config) | NO | iOS Android | partially | config only supports skipPermissionRequests |
454
+ +| requestAuthorization | 请求合适的位置权限 | function(success,error) | YES | iOS Android | partially | error: Only code and message are supported. |
455
+ +| getCurrentPosition | 使用最新位置信息调用成功回调一次 | function(success(position),error(error),option) | NO | iOS Android | partially | In position, only altitudeAccuracy is not supported. In option, only timeout and maximumAge are supported. In error, only code and message are supported. |
456
+ +| watchPosition | 每当位置发生变化时调用成功回调。返回一个 watchId (数字) | function(success(postion),error(error),option) | NO | iOS Android | partially | In position, only altitudeAccuracy is not supported. In error, only code and message are supported. In option, only interval and distanceFilter are supported. |
457
+ +| clearWatch | 通过 watchPosition() 返回的 ID 清除观察者 | function(watchID) | NO | iOS Android | yes | watchID supports only the default value 0. |
458
+ +
459
+ +## 遗留问题
460
+ +
461
+ +- [ ] @react-native-oh-tpl/geolocation 部分属性未完全实现 HarmonyOS 化,maximumAge 延时问题: [issue#6](https://github.com/react-native-oh-library/react-native-geolocation/issues/6)
462
+ +
463
+ +## 其他
464
+ +
465
+ +## 开源协议
466
+ +
467
+ +本项目基于 [The MIT License(MIT)](https://github.com/michalchudziak/react-native-geolocation/blob/master/LICENSE) ,请自由地享受和参与开源。
468
+
469
+ -This library is licensed under [The MIT License (MIT)](https://github.com/michalchudziak/react-native-geolocation/blob/master/LICENSE)
470
+
471
+ ```
472
+
473
+ ### `README_en.md`
474
+
475
+ ```diff
476
+ @@ -0,0 +1,301 @@
477
+ +> Template version: v0.4.0
478
+ +
479
+ +<p align="center">
480
+ + <h1 align="center"> @react-native-community/geolocation</code> </h1>
481
+ +</p>
482
+ +
483
+ +This project is based on [@react-native-community/geolocation](https://github.com/michalchudziak/react-native-geolocation).
484
+ +
485
+ +This third-party library has been migrated to Gitcode and is now available for direct download from npm, the new package name is: `@react-native-ohos/geolocation`, The version correspondence details are as follows:
486
+ +
487
+ +| Name | Version | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | npm Address |
488
+ +| --------------| -------------- | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
489
+ +| @react-native-ohos/geolocation | ~ 3.5.0 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-geolocation/releases) | 0.82.* | Yes | API12+ | 3.4.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/geolocation) |
490
+ +| @react-native-ohos/geolocation | ~ 3.4.1 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-geolocation/releases) | 0.77.* | NO | API12+ | 3.4.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/geolocation) |
491
+ +| @react-native-ohos/geolocation | ~ 3.1.1 | [Gitcode Releases](https://gitcode.com/openharmony-sig/rntpc_react-native-geolocation/releases) | 0.72.* | Yes | API12+ | 3.1.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/geolocation) |
492
+ +| @react-native-oh-tpl/react-native-geolocation | <= 3.1.0-0.0.7@deprecated | [Github Releases](https://github.com/react-native-oh-library/react-native-geolocation/releases) | 0.72.* | NO | API12+ | 3.1.0 | [Npm Address](https://www.npmjs.com/package/@react-native-oh-tpl/react-native-geolocation) |
493
+ +
494
+ +## Installation and Usage
495
+ +
496
+ +Go to the project directory and execute the following instruction:
497
+ +
498
+ +
499
+ +
500
+ +<!-- tabs:start -->
501
+ +
502
+ +#### **npm**
503
+ +
504
+ +```bash
505
+ +npm install @react-native-ohos/geolocation
506
+ +```
507
+ +
508
+ +#### **yarn**
509
+ +
510
+ +```bash
511
+ +yarn add @react-native-ohos/geolocation
512
+ +```
513
+ +
514
+ +<!-- tabs:end -->
515
+ +
516
+ +The following code shows the basic use scenario of the repository:
517
+ +
518
+ +> [!WARNING] The name of the imported repository remains unchanged.
519
+ +
520
+ +```js
521
+ +import Geolocation from "@react-native-community/geolocation";
522
+ +import { Button } from "react-native";
523
+ +import React from 'react';
524
+ +
525
+ +export function GeolocationDemo(): JSX.Element {
526
+ + const tap = () => {
527
+ + Geolocation.setRNConfiguration({
528
+ + skipPermissionRequests: true,
529
+ + authorizationLevel: "auto",
530
+ + enableBackgroundLocationUpdates: true,
531
+ + locationProvider: "auto",
532
+ + });
533
+ + console.log("tap");
534
+ + };
535
+ +
536
+ + return <Button title='test' onPress={tap} />;
537
+ +}
538
+ +```
539
+ +
540
+ +## Link
541
+ +
542
+ +| | Is supported autolink | Supported RN Version |
543
+ +|--------------------------------------|-----------------------|----------------------|
544
+ +| ~3.5.0 | Yes | 0.82 |
545
+ +| ~3.4.1 | No | 0.77 |
546
+ +| ~3.1.1 | Yes | 0.72 |
547
+ +| <= 3.1.0-0.0.7@deprecated | No | 0.72 |
548
+ +
549
+ +Using AutoLink need to be configured according to this document, Autolink Framework Guide Documentation: https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
550
+ +
551
+ +If the version you use supports Autolink and the project has been connected to Autolink, skip the ManualLink configuration.
552
+ +<details>
553
+ + <summary>ManualLink: this step is a guide to manually configure native dependencies.</summary>
554
+ +
555
+ +Open the `harmony` directory of the HarmonyOS project in DevEco Studio.
556
+ +
557
+ +### 1. Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project
558
+ +
559
+ +```json
560
+ +{
561
+ + ...
562
+ + "overrides": {
563
+ + "@rnoh/react-native-openharmony" : "./react_native_openharmony"
564
+ + }
565
+ +}
566
+ +```
567
+ +
568
+ +### 2. Introducing Native Code
569
+ +
570
+ +Currently, two methods are available:
571
+ +
572
+ +Method 1 (recommended): Use the HAR file.
573
+ +
574
+ +> [!TIP] The HAR file is stored in the `harmony` directory in the installation path of the third-party library.
575
+ +
576
+ +Open `entry/oh-package.json5` file and add the following dependencies:
577
+ +
578
+ +```json
579
+ +"dependencies": {
580
+ + "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
581
+ + "@react-native-ohos/geolocation": "file:../../node_modules/@react-native-ohos/geolocation/harmony/geolocation.har"
582
+ + }
583
+ +```
584
+ +
585
+ +Click the `sync` button in the upper right corner.
586
+ +
587
+ +Alternatively, run the following instruction on the terminal:
588
+ +
589
+ +```bash
590
+ +cd entry
591
+ +ohpm install
592
+ +```
593
+ +
594
+ +Method 2: Directly link to the source code.
595
+ +
596
+ +> [!TIP] For details, see [Directly Linking Source Code](./link-source-code.md).
597
+ +
598
+ +### 3. Configuring CMakeLists and Introducing geolocation
599
+ +
600
+ +> If you are using version <= 3.1.0-0.0.7, please skip this chapter.
601
+ +
602
+ +Open `entry/src/main/cpp/CMakeLists.txt` and add the following code:
603
+ +
604
+ +```diff
605
+ +project(rnapp)
606
+ +cmake_minimum_required(VERSION 3.4.1)
607
+ +set(CMAKE_SKIP_BUILD_RPATH TRUE)
608
+ +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
609
+ +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
610
+ ++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
611
+ +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
612
+ +set(LOG_VERBOSITY_LEVEL 1)
613
+ +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
614
+ +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
615
+ +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
616
+ +add_compile_definitions(WITH_HITRACE_SYSTRACE)
617
+ +
618
+ +add_subdirectory("${RNOH_CPP_DIR}" ./rn)
619
+ +
620
+ +# RNOH_BEGIN: manual_package_linking_1
621
+ +add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
622
+ ++ add_subdirectory("${OH_MODULES}/@react-native-ohos/geolocation/src/main/cpp" ./geolocation)
623
+ +# RNOH_END: manual_package_linking_1
624
+ +
625
+ +file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
626
+ +
627
+ +add_library(rnoh_app SHARED
628
+ + ${GENERATED_CPP_FILES}
629
+ + "./PackageProvider.cpp"
630
+ + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
631
+ +)
632
+ +
633
+ +target_link_libraries(rnoh_app PUBLIC rnoh)
634
+ +
635
+ +# RNOH_BEGIN: manual_package_linking_2
636
+ +target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
637
+ ++ target_link_libraries(rnoh_app PUBLIC rnoh_geolocation)
638
+ +# RNOH_END: manual_package_linking_2
639
+ +```
640
+ +
641
+ +Open `entry/src/main/cpp/PackageProvider.cpp` and add the following code:
642
+ +
643
+ +```diff
644
+ +#include "RNOH/PackageProvider.h"
645
+ +#include "SamplePackage.h"
646
+ ++ #include "GeoLocationPackage.h"
647
+ +
648
+ +using namespace rnoh;
649
+ +
650
+ +std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
651
+ + return {
652
+ + std::make_shared<SamplePackage>(ctx),
653
+ ++ std::make_shared<GeoLocationPackage>(ctx)
654
+ + };
655
+ +}
656
+ +```
657
+ +
658
+ +### 4. Introducing GeolocationPackage to ArkTS
659
+ +
660
+ +Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code:
661
+ +
662
+ +```diff
663
+ + ...
664
+ ++ import {GeoLocationPackage} from '@react-native-ohos/geolocation/ts';
665
+ +
666
+ +export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
667
+ + return [
668
+ + new SamplePackage(ctx),
669
+ ++ new GeoLocationPackage(ctx)
670
+ + ];
671
+ +}
672
+ +```
673
+ +</details>
674
+ +
675
+ +## Running
676
+ +
677
+ +Click the `sync` button in the upper right corner.
678
+ +
679
+ +Alternatively, run the following instruction on the terminal:
680
+ +
681
+ +```bash
682
+ +cd entry
683
+ +ohpm install
684
+ +```
685
+ +
686
+ +Then build and run the code.
687
+ +
688
+ +## Constraints
689
+ +
690
+ +### Compatibility
691
+ +
692
+ +To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.
693
+ +
694
+ +Verified in the following versions.
695
+ +
696
+ +1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
697
+ +2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71;
698
+ +3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
699
+ +4. RNOH: 0.82.1; SDK: HarmonyOS 6.0.1 Release SDK; IDE: DevEco Studio 6.0.1 Release; ROM:6.0.0.120 SP7;
700
+ +
701
+ +
702
+ +### Permission Requirements
703
+ +
704
+ +1. Include applicable permissions in the module.json5 file within the entry directory.
705
+ +
706
+ +```diff
707
+ +...
708
+ +{
709
+ + "module": {
710
+ + "requestPermissions": [
711
+ ++ {
712
+ ++ "name": "ohos.permission.APPROXIMATELY_LOCATION",
713
+ ++ "reason": "$string:Access_location",
714
+ ++ "usedScene": {
715
+ ++ "abilities": [
716
+ ++ "EntryAbility"
717
+ ++ ],
718
+ ++ "when": "always"
719
+ ++ }
720
+ ++ },
721
+ ++ {
722
+ ++ "name": "ohos.permission.LOCATION",
723
+ ++ "reason": "$string:Access_location",
724
+ ++ "usedScene": {
725
+ ++ "abilities": [
726
+ ++ "EntryAbility"
727
+ ++ ],
728
+ ++ "when": "always"
729
+ ++ }
730
+ ++ },
731
+ ++ {
732
+ ++ "name": "ohos.permission.INTERNET"
733
+ ++ }
734
+ + ]
735
+ + }
736
+ +}
737
+ +```
738
+ +
739
+ +2. Apply the reasons for applicable permission in the entry directory.
740
+ +
741
+ +Open the `entry/src/main/resources/base/element/string.json` file and add the following code:
742
+ +
743
+ +```diff
744
+ +...
745
+ +{
746
+ + "string": [
747
+ ++ {
748
+ ++ "name": "Access_location",
749
+ ++ "value": "access location"
750
+ ++ }
751
+ + ]
752
+ +}
753
+ +```
754
+ +
755
+ +## Properties
756
+ +
757
+ +> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
758
+ +
759
+ +> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
760
+ +
761
+ +| Name | Description | Type | Required | Platform | HarmonyOS Support | Notes |
762
+ +| -------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------- | -------- | ----------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
763
+ +| setRNConfiguration | Sets configuration options that will be used in all location requests | function(config) | NO | iOS Android | partially | config only supports skipPermissionRequests |
764
+ +| requestAuthorization | Request suitable Location permission | function(success,error) | YES | iOS Android | partially | error: Only code and message are supported. |
765
+ +| getCurrentPosition | Invokes the success callback once with the latest location info | function(success(position),error(error),option) | NO | iOS Android | partially | In position, only altitudeAccuracy is not supported. In option, only timeout and maximumAge are supported. In error, only code and message are supported. |
766
+ +| watchPosition | Invokes the success callback whenever the location changes. Returns a watchId (number) | function(success(postion),error(error),option) | NO | iOS Android | partially | In position, only altitudeAccuracy is not supported. In error, only code and message are supported. In option, only interval and distanceFilter are supported. |
767
+ +| clearWatch | Clears watch observer by id returned by watchPosition() | function(watchID) | NO | iOS Android | yes | watchID supports only the default value 0. |
768
+ +
769
+ +## Known Issues
770
+ +
771
+ + [ ] Some attributes of @react-native-oh-tpl/geolocation have not been fully implemented for HarmonyOS, and there is a delay issue with maximumAge: [issue#6](https://github.com/react-native-oh-library/react-native-geolocation/issues/6).
772
+ +
773
+ +## Others
774
+ +
775
+ +## License
776
+ +
777
+ +This project is licensed under [The MIT License(MIT)](https://github.com/michalchudziak/react-native-geolocation/blob/master/LICENSE).
778
+
779
+ ```
780
+
781
+ ### `example/.eslintrc`
782
+
783
+ ```diff
784
+ @@ -0,0 +1,37 @@
785
+ +/**
786
+ + * MIT License
787
+ + *
788
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
789
+ + *
790
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
791
+ + * of this software and associated documentation files (the "Software"), to deal
792
+ + * in the Software without restriction, including without limitation the rights
793
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
794
+ + * copies of the Software, and to permit persons to whom the Software is
795
+ + * furnished to do so, subject to the following conditions:
796
+ + *
797
+ + * The above copyright notice and this permission notice shall be included in all
798
+ + * copies or substantial portions of the Software.
799
+ + *
800
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
801
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
802
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
803
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
804
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
805
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
806
+ + * SOFTWARE.
807
+ + */
808
+ +
809
+ +{
810
+ + "extends": "@react-native",
811
+ + "rules": {
812
+ + "react-native/no-inline-styles": "off",
813
+ + "react/no-unstable-nested-components": "off",
814
+ + "react/react-in-jsx-scope": "off",
815
+ + "@typescript-eslint/no-unused-vars": "warn",
816
+ + "react-hooks/exhaustive-deps": "off",
817
+ + "radix": "off",
818
+ + "prettier/prettier": "warn",
819
+ + "max-lines": "off"
820
+ + }
821
+ +}
822
+
823
+
824
+ ```
825
+
826
+ ### `example/.gitignore`
827
+
828
+ ```diff
829
+ @@ -0,0 +1,71 @@
830
+ +.husky
831
+ +bundle.harmony.js
832
+ +package-lock.json
833
+ +*.hbc
834
+ +lintCppResult.txt
835
+ +
836
+ +# ---
837
+ +
838
+ +# OSX
839
+ +#
840
+ +.DS_Store
841
+ +
842
+ +# Xcode
843
+ +#
844
+ +build/
845
+ +*.pbxuser
846
+ +!default.pbxuser
847
+ +*.mode1v3
848
+ +!default.mode1v3
849
+ +*.mode2v3
850
+ +!default.mode2v3
851
+ +*.perspectivev3
852
+ +!default.perspectivev3
853
+ +xcuserdata
854
+ +*.xccheckout
855
+ +*.moved-aside
856
+ +DerivedData
857
+ +*.hmap
858
+ +*.ipa
859
+ +*.xcuserstate
860
+ +
861
+ +# Android/IntelliJ
862
+ +#
863
+ +build/
864
+ +.idea
865
+ +.gradle
866
+ +local.properties
867
+ +*.iml
868
+ +*.hprof
869
+ +.cxx/
870
+ +*.keystore
871
+ +!debug.keystore
872
+ +BuildProfile.ets
873
+ +
874
+ +# node.js
875
+ +#
876
+ +node_modules/
877
+ +npm-debug.log
878
+ +yarn-error.log
879
+ +
880
+ +# fastlane
881
+ +#
882
+ +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
883
+ +# screenshots whenever they are needed.
884
+ +# For more information about the recommended setup visit:
885
+ +# https://docs.fastlane.tools/best-practices/source-control/
886
+ +
887
+ +**/fastlane/report.xml
888
+ +**/fastlane/Preview.html
889
+ +**/fastlane/screenshots
890
+ +**/fastlane/test_output
891
+ +
892
+ +# Bundle artifact
893
+ +*.jsbundle
894
+ +
895
+ +# Ruby / CocoaPods
896
+ +/vendor/bundle/
897
+ +
898
+ +# Temporary files created by Metro to check the health of the file watcher
899
+ +.metro-health-check*
900
+ +*.htrace
901
+
902
+
903
+ ```
904
+
905
+ ### `example/.node-version`
906
+
907
+ ```diff
908
+ @@ -0,0 +1,24 @@
909
+ +/**
910
+ + * MIT License
911
+ + *
912
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
913
+ + *
914
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
915
+ + * of this software and associated documentation files (the "Software"), to deal
916
+ + * in the Software without restriction, including without limitation the rights
917
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
918
+ + * copies of the Software, and to permit persons to whom the Software is
919
+ + * furnished to do so, subject to the following conditions:
920
+ + *
921
+ + * The above copyright notice and this permission notice shall be included in all
922
+ + * copies or substantial portions of the Software.
923
+ + *
924
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
925
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
926
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
927
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
928
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
929
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
930
+ + * SOFTWARE.
931
+ + */
932
+ +18
933
+
934
+ ```
935
+
936
+ ### `example/.prettierrc.js`
937
+
938
+ ```diff
939
+ @@ -0,0 +1,7 @@
940
+ +module.exports = {
941
+ + arrowParens: 'avoid',
942
+ + bracketSameLine: true,
943
+ + bracketSpacing: true,
944
+ + singleQuote: true,
945
+ + trailingComma: 'all',
946
+ +};
947
+
948
+ ```
949
+
950
+ ### `example/.watchmanconfig`
951
+
952
+ ```diff
953
+ @@ -0,0 +1 @@
954
+ +{}
955
+
956
+
957
+ ```
958
+
959
+ ### `example/app.json`
960
+
961
+ ```diff
962
+ @@ -0,0 +1,4 @@
963
+ +{
964
+ + "name": "app_name",
965
+ + "displayName": "tester"
966
+ +}
967
+
968
+
969
+ ```
970
+
971
+ ### `example/babel.config.js`
972
+
973
+ ```diff
974
+ @@ -0,0 +1,6 @@
975
+ +module.exports = {
976
+ + presets: ['module:@react-native/babel-preset'],
977
+ + plugins: [
978
+ + 'react-native-reanimated/plugin',
979
+ + ],
980
+ +};
981
+
982
+ ```
983
+
984
+ ### `example/contexts.ts`
985
+
986
+ ```diff
987
+ @@ -0,0 +1,27 @@
988
+ +/**
989
+ + * MIT License
990
+ + *
991
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
992
+ + *
993
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
994
+ + * of this software and associated documentation files (the "Software"), to deal
995
+ + * in the Software without restriction, including without limitation the rights
996
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
997
+ + * copies of the Software, and to permit persons to whom the Software is
998
+ + * furnished to do so, subject to the following conditions:
999
+ + *
1000
+ + * The above copyright notice and this permission notice shall be included in all
1001
+ + * copies or substantial portions of the Software.
1002
+ + *
1003
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1004
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1005
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1006
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1007
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1008
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1009
+ + * SOFTWARE.
1010
+ + */
1011
+ +
1012
+ +import React from 'react';
1013
+ +
1014
+ +export const AppParamsContext = React.createContext(undefined);
1015
+
1016
+ ```
1017
+
1018
+ ### `example/harmony/.gitignore`
1019
+
1020
+ ```diff
1021
+ @@ -0,0 +1,24 @@
1022
+ +# it may cause some issues when building the project when switching branches
1023
+ +package-lock.json
1024
+ +# we add this because we want to keep the signing configs out of git
1025
+ +/build-profile.json5
1026
+ +
1027
+ +rnoh_modules
1028
+ +
1029
+ +**/oh-package-lock.json5
1030
+ +# ---
1031
+ +
1032
+ +/node_modules
1033
+ +/local.properties
1034
+ +/.idea
1035
+ +**/build
1036
+ +/.hvigor
1037
+ +.cxx
1038
+ +/.clangd
1039
+ +/.clang-format
1040
+ +/.clang-tidy
1041
+ +/oh_modules
1042
+ +hvigorw
1043
+ +hvigorw.bat
1044
+ +hvigor/hvigor-wrapper.js
1045
+ +
1046
+
1047
+ ```
1048
+
1049
+ ### `example/harmony/AppScope/app.json5`
1050
+
1051
+ ```diff
1052
+ @@ -0,0 +1,10 @@
1053
+ +{
1054
+ + "app": {
1055
+ + "bundleName": "com.harmony.wechat.lib.demo",
1056
+ + "vendor": "example",
1057
+ + "versionCode": 1000000,
1058
+ + "versionName": "1.0.0",
1059
+ + "icon": "$media:app_icon",
1060
+ + "label": "$string:app_name"
1061
+ + }
1062
+ +}
1063
+
1064
+ ```
1065
+
1066
+ ### `example/harmony/AppScope/resources/base/element/string.json`
1067
+
1068
+ ```diff
1069
+ @@ -0,0 +1,8 @@
1070
+ +{
1071
+ + "string": [
1072
+ + {
1073
+ + "name": "app_name",
1074
+ + "value": "RN Tester"
1075
+ + }
1076
+ + ]
1077
+ +}
1078
+
1079
+ ```
1080
+
1081
+ ### `example/harmony/AppScope/resources/base/media/app_icon.png`
1082
+
1083
+ ```diff
1084
+ Binary files no preview for this file type
1085
+ ```
1086
+
1087
+ ### `example/harmony/build-profile.template.json5`
1088
+
1089
+ ```diff
1090
+ @@ -0,0 +1,44 @@
1091
+ +{
1092
+ + "app": {
1093
+ + "products": [
1094
+ + {
1095
+ + "name": 'default',
1096
+ + "signingConfig": 'default',
1097
+ + "compatibleSdkVersion": '5.0.0(12)',
1098
+ + "runtimeOS": 'HarmonyOS',
1099
+ + "buildOption": {
1100
+ + "strictMode": {
1101
+ + "useNormalizedOHMUrl": true
1102
+ + }
1103
+ + }
1104
+ + },
1105
+ + ],
1106
+ + "buildModeSet": [
1107
+ + {
1108
+ + "name": 'debug',
1109
+ + },
1110
+ + {
1111
+ + "name": 'release',
1112
+ + },
1113
+ + ],
1114
+ + "signingConfigs": []
1115
+ + },
1116
+ + "modules": [
1117
+ + {
1118
+ + "name": 'entry',
1119
+ + "srcPath": './entry',
1120
+ + "targets": [
1121
+ + {
1122
+ + "name": 'default',
1123
+ + "applyToProducts": [
1124
+ + 'default'
1125
+ + ],
1126
+ + },
1127
+ + ],
1128
+ + },
1129
+ + {
1130
+ + "name": 'geolocation',
1131
+ + "srcPath": '../../harmony/geolocation'
1132
+ + }
1133
+ + ],
1134
+ +}
1135
+
1136
+
1137
+ ```
1138
+
1139
+ ### `example/harmony/codelinter.json`
1140
+
1141
+ ```diff
1142
+ @@ -0,0 +1,32 @@
1143
+ +{
1144
+ + "files": ["**/*.ts", "**/*.ets"],
1145
+ + "ignore": [
1146
+ + "**/ohosTest/**/*",
1147
+ + "**/node_modules/**/*",
1148
+ + "**/hvigorfile.ts",
1149
+ + "**/node_modules/**/*",
1150
+ + "**/oh_modules/**/*",
1151
+ + "**/build/**/*",
1152
+ + "**/.preview/**/*"
1153
+ + ],
1154
+ + "plugins": ["@typescript-eslint"],
1155
+ + "ruleSet": [],
1156
+ + "rules": {
1157
+ + "@typescript-eslint/await-thenable": "warn",
1158
+ + "@typescript-eslint/consistent-type-imports": "warn",
1159
+ + "@typescript-eslint/explicit-function-return-type": "warn",
1160
+ + "@typescript-eslint/explicit-module-boundary-types": "warn",
1161
+ + "@typescript-eslint/no-dynamic-delete": "warn",
1162
+ + "@typescript-eslint/no-explicit-any": "warn",
1163
+ + "@typescript-eslint/no-for-in-array": "warn",
1164
+ + "@typescript-eslint/no-this-alias": "warn",
1165
+ + "@typescript-eslint/no-unnecessary-type-constraint": "warn",
1166
+ + "@typescript-eslint/no-unsafe-argument": "warn",
1167
+ + "@typescript-eslint/no-unsafe-assignment": "warn",
1168
+ + "@typescript-eslint/no-unsafe-call": "warn",
1169
+ + "@typescript-eslint/no-unsafe-member-access": "warn",
1170
+ + "@typescript-eslint/no-unsafe-return": "warn",
1171
+ + "@typescript-eslint/prefer-literal-enum-member": "warn"
1172
+ + },
1173
+ + "overrides": []
1174
+ +}
1175
+
1176
+ ```
1177
+
1178
+ ### `example/harmony/entry/.gitignore`
1179
+
1180
+ ```diff
1181
+ @@ -0,0 +1,7 @@
1182
+ +/node_modules
1183
+ +/.preview
1184
+ +/build
1185
+ +/.cxx
1186
+ +package-lock.json
1187
+ +/oh_modules
1188
+ +/assets
1189
+
1190
+ ```
1191
+
1192
+ ### `example/harmony/entry/build-profile.json5`
1193
+
1194
+ ```diff
1195
+ @@ -0,0 +1,22 @@
1196
+ +{
1197
+ + "apiType": 'stageMode',
1198
+ + "buildOption": {
1199
+ + "externalNativeOptions": {
1200
+ + "path": "./src/main/cpp/CMakeLists.txt",
1201
+ + "arguments": "",
1202
+ + "cppFlags": "-s",
1203
+ + "abiFilters": [
1204
+ + "arm64-v8a",
1205
+ + "x86_64"
1206
+ + ]
1207
+ + },
1208
+ + },
1209
+ + "targets": [
1210
+ + {
1211
+ + "name": "default",
1212
+ + },
1213
+ + {
1214
+ + "name": "ohosTest",
1215
+ + }
1216
+ + ]
1217
+ +}
1218
+
1219
+
1220
+ ```
1221
+
1222
+ ### `example/harmony/entry/hvigorfile.ts`
1223
+
1224
+ ```diff
1225
+ @@ -0,0 +1,26 @@
1226
+ +/**
1227
+ + * MIT License
1228
+ + *
1229
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1230
+ + *
1231
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1232
+ + * of this software and associated documentation files (the "Software"), to deal
1233
+ + * in the Software without restriction, including without limitation the rights
1234
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1235
+ + * copies of the Software, and to permit persons to whom the Software is
1236
+ + * furnished to do so, subject to the following conditions:
1237
+ + *
1238
+ + * The above copyright notice and this permission notice shall be included in all
1239
+ + * copies or substantial portions of the Software.
1240
+ + *
1241
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1242
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1243
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1244
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1245
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1246
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1247
+ + * SOFTWARE.
1248
+ + */
1249
+ +
1250
+ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
1251
+ +export { hapTasks } from '@ohos/hvigor-ohos-plugin';
1252
+
1253
+ ```
1254
+
1255
+ ### `example/harmony/entry/oh-package.json5`
1256
+
1257
+ ```diff
1258
+ @@ -0,0 +1,11 @@
1259
+ +{
1260
+ + "license": "ISC",
1261
+ + "devDependencies": {},
1262
+ + "name": "entry",
1263
+ + "description": "example description",
1264
+ + "version": "1.0.0",
1265
+ + "dependencies": {
1266
+ + "@rnoh/react-native-openharmony": "file:../../node_modules/react-native-harmony/react_native_openharmony.har",
1267
+ + "@react-native-ohos/geolocation": "file:../../node_modules/@react-native-ohos/geolocation/harmony/geolocation.har"
1268
+ + }
1269
+ +}
1270
+
1271
+
1272
+ ```
1273
+
1274
+ ### `example/harmony/entry/src/main/cpp/.gitignore`
1275
+
1276
+ ```diff
1277
+ @@ -0,0 +1,2 @@
1278
+ +jsbundle.h
1279
+ +generated/
1280
+
1281
+ ```
1282
+
1283
+ ### `example/harmony/entry/src/main/cpp/CMakeLists.txt`
1284
+
1285
+ ```diff
1286
+ @@ -0,0 +1,41 @@
1287
+ +project(rnapp)
1288
+ +cmake_minimum_required(VERSION 3.4.1)
1289
+ +set(CMAKE_SKIP_BUILD_RPATH TRUE)
1290
+ +set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
1291
+ +set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
1292
+ +set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
1293
+ +set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
1294
+ +set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
1295
+ +set(LOG_VERBOSITY_LEVEL 1)
1296
+ +set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
1297
+ +set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
1298
+ +set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
1299
+ +
1300
+ +set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
1301
+ +add_compile_definitions(WITH_HITRACE_SYSTRACE)
1302
+ +
1303
+ +# (VM) Define a variable and assign it to the current module's cpp directory
1304
+ +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
1305
+ +
1306
+ +# Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here
1307
+ +include_directories(${NATIVERENDER_ROOT_PATH}
1308
+ + ${NATIVERENDER_ROOT_PATH}/include)
1309
+ +
1310
+ +add_subdirectory("${RNOH_CPP_DIR}" ./rn)
1311
+ +
1312
+ +# RNOH_BEGIN: manual_package_linking_1
1313
+ +add_subdirectory("${OH_MODULES}/@react-native-ohos/geolocation/src/main/cpp" ./geolocation)
1314
+ +# RNOH_END: manual_package_linking_1
1315
+ +
1316
+ +file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
1317
+ +
1318
+ +add_library(rnoh_app SHARED
1319
+ + ${GENERATED_CPP_FILES}
1320
+ + "./PackageProvider.cpp"
1321
+ + "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
1322
+ +)
1323
+ +target_link_libraries(rnoh_app PUBLIC rnoh)
1324
+ +
1325
+ +# RNOH_BEGIN: manual_package_linking_2
1326
+ +target_link_libraries(rnoh_app PUBLIC rnoh_geolocation)
1327
+ +# RNOH_END: manual_package_linking_2
1328
+
1329
+ ```
1330
+
1331
+ ### `example/harmony/entry/src/main/cpp/PackageProvider.cpp`
1332
+
1333
+ ```diff
1334
+ @@ -0,0 +1,37 @@
1335
+ +/**
1336
+ + * MIT License
1337
+ + *
1338
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1339
+ + *
1340
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1341
+ + * of this software and associated documentation files (the "Software"), to deal
1342
+ + * in the Software without restriction, including without limitation the rights
1343
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1344
+ + * copies of the Software, and to permit persons to whom the Software is
1345
+ + * furnished to do so, subject to the following conditions:
1346
+ + *
1347
+ + * The above copyright notice and this permission notice shall be included in all
1348
+ + * copies or substantial portions of the Software.
1349
+ + *
1350
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1351
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1352
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1353
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1354
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1355
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1356
+ + * SOFTWARE.
1357
+ + */
1358
+ +
1359
+ +#include "RNOH/PackageProvider.h"
1360
+ +#include "generated/RNOHGeneratedPackage.h"
1361
+ +#include "GeoLocationPackage.h"
1362
+ +
1363
+ +using namespace rnoh;
1364
+ +
1365
+ +std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx)
1366
+ +{
1367
+ + return {
1368
+ + std::make_shared<RNOHGeneratedPackage>(ctx), // generated by codegen v1
1369
+ + std::make_shared<GeoLocationPackage>(ctx),
1370
+ + };
1371
+ +}
1372
+
1373
+
1374
+ ```
1375
+
1376
+ ### `example/harmony/entry/src/main/ets/RNPackagesFactory.ets`
1377
+
1378
+ ```diff
1379
+ @@ -0,0 +1,32 @@
1380
+ +/**
1381
+ + * MIT License
1382
+ + *
1383
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1384
+ + *
1385
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1386
+ + * of this software and associated documentation files (the "Software"), to deal
1387
+ + * in the Software without restriction, including without limitation the rights
1388
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1389
+ + * copies of the Software, and to permit persons to whom the Software is
1390
+ + * furnished to do so, subject to the following conditions:
1391
+ + *
1392
+ + * The above copyright notice and this permission notice shall be included in all
1393
+ + * copies or substantial portions of the Software.
1394
+ + *
1395
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1396
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1397
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1398
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1399
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1400
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1401
+ + * SOFTWARE.
1402
+ + */
1403
+ +
1404
+ +import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
1405
+ +import {GeoLocationPackage} from '@react-native-ohos/geolocation/ts';
1406
+ +
1407
+ +export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
1408
+ + return [
1409
+ + new GeoLocationPackage(ctx),
1410
+ + ];
1411
+ +}
1412
+
1413
+ ```
1414
+
1415
+ ### `example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf`
1416
+
1417
+ ```diff
1418
+ Binary files no preview for this file type
1419
+ ```
1420
+
1421
+ ### `example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf`
1422
+
1423
+ ```diff
1424
+ Binary files no preview for this file type
1425
+ ```
1426
+
1427
+ ### `example/harmony/entry/src/main/ets/entryability/EntryAbility.ets`
1428
+
1429
+ ```diff
1430
+ @@ -0,0 +1,40 @@
1431
+ +/**
1432
+ + * MIT License
1433
+ + *
1434
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1435
+ + *
1436
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1437
+ + * of this software and associated documentation files (the "Software"), to deal
1438
+ + * in the Software without restriction, including without limitation the rights
1439
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1440
+ + * copies of the Software, and to permit persons to whom the Software is
1441
+ + * furnished to do so, subject to the following conditions:
1442
+ + *
1443
+ + * The above copyright notice and this permission notice shall be included in all
1444
+ + * copies or substantial portions of the Software.
1445
+ + *
1446
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1447
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1448
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1449
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1450
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1451
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1452
+ + * SOFTWARE.
1453
+ + */
1454
+ +
1455
+ +import { RNAbility } from '@rnoh/react-native-openharmony';
1456
+ +import { AbilityConstant, Want } from '@kit.AbilityKit';
1457
+ +
1458
+ +export default class EntryAbility extends RNAbility {
1459
+ + onCreate(want: Want) {
1460
+ + super.onCreate(want)
1461
+ + }
1462
+ +
1463
+ + getPagePath() {
1464
+ + return 'pages/Index';
1465
+ + }
1466
+ +
1467
+ + onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void {
1468
+ +
1469
+ + }
1470
+ +}
1471
+
1472
+ ```
1473
+
1474
+ ### `example/harmony/entry/src/main/ets/pages/Index.ets`
1475
+
1476
+ ```diff
1477
+ @@ -0,0 +1,136 @@
1478
+ +/**
1479
+ + * MIT License
1480
+ + *
1481
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1482
+ + *
1483
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1484
+ + * of this software and associated documentation files (the "Software"), to deal
1485
+ + * in the Software without restriction, including without limitation the rights
1486
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1487
+ + * copies of the Software, and to permit persons to whom the Software is
1488
+ + * furnished to do so, subject to the following conditions:
1489
+ + *
1490
+ + * The above copyright notice and this permission notice shall be included in all
1491
+ + * copies or substantial portions of the Software.
1492
+ + *
1493
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1494
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1495
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1496
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1497
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1498
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1499
+ + * SOFTWARE.
1500
+ + */
1501
+ +
1502
+ +import {
1503
+ + AnyJSBundleProvider,
1504
+ + ComponentBuilderContext,
1505
+ + FileJSBundleProvider,
1506
+ + MetroJSBundleProvider,
1507
+ + ResourceJSBundleProvider,
1508
+ + RNApp,
1509
+ + RNOHErrorDialog,
1510
+ + RNOHLogger,
1511
+ + TraceJSBundleProviderDecorator,
1512
+ + RNOHCoreContext
1513
+ +} from '@rnoh/react-native-openharmony';
1514
+ +import font from '@ohos.font';
1515
+ +import { createRNPackages } from '../RNPackagesFactory';
1516
+ +
1517
+ +const arkTsComponentNames: Array<string> = [
1518
+ +];
1519
+ +
1520
+ +@Builder
1521
+ +export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
1522
+ + // There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided.
1523
+ + Stack() {
1524
+ + }
1525
+ + .position({ x: 0, y: 0 })
1526
+ +
1527
+ +}
1528
+ +
1529
+ +const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)
1530
+ +
1531
+ +/**
1532
+ + * If you want to use custom fonts, you need to register them here.
1533
+ + * We should support react-native-asset to handle registering fonts automatically.
1534
+ + */
1535
+ +const fonts: font.FontOptions[] = [
1536
+ + {
1537
+ + familyName: 'Pacifico-Regular',
1538
+ + familySrc: '/assets/fonts/Pacifico-Regular.ttf'
1539
+ + },
1540
+ + {
1541
+ + familyName: 'StintUltraCondensed-Regular',
1542
+ + familySrc: '/assets/fonts/StintUltraCondensed-Regular.ttf'
1543
+ + }
1544
+ +]
1545
+ +
1546
+ +@Entry
1547
+ +@Component
1548
+ +struct Index {
1549
+ + @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
1550
+ + @State shouldShow: boolean = false
1551
+ + private logger!: RNOHLogger
1552
+ + bundlePath: string = 'bunlde.harmony.js'
1553
+ + @State hasBundle: boolean = false
1554
+ +
1555
+ + aboutToAppear() {
1556
+ + this.logger = this.rnohCoreContext!.logger.clone("Index")
1557
+ + const stopTracing = this.logger.clone("aboutToAppear").startTracing()
1558
+ + for (const customFont of fonts) {
1559
+ + font.registerFont(customFont)
1560
+ + }
1561
+ +
1562
+ + this.shouldShow = true
1563
+ + stopTracing()
1564
+ + }
1565
+ +
1566
+ + onBackPress(): boolean | undefined {
1567
+ + // NOTE: this is required since `Ability`'s `onBackPressed` function always
1568
+ + // terminates or puts the app in the background, but we want Ark to ignore it completely
1569
+ + // when handled by RN
1570
+ + this.rnohCoreContext!.dispatchBackPress()
1571
+ + return true
1572
+ + }
1573
+ +
1574
+ + build() {
1575
+ + Column() {
1576
+ + if (this.rnohCoreContext && this.shouldShow) {
1577
+ + if (this.rnohCoreContext?.isDebugModeEnabled) {
1578
+ + RNOHErrorDialog({ ctx: this.rnohCoreContext })
1579
+ + }
1580
+ + RNApp({
1581
+ + rnInstanceConfig: {
1582
+ + createRNPackages,
1583
+ + enableNDKTextMeasuring: true,
1584
+ + enableBackgroundExecutor: false,
1585
+ + enableCAPIArchitecture: true,
1586
+ + arkTsComponentNames: arkTsComponentNames,
1587
+ + },
1588
+ + initialProps: { "foo": "bar" } as Record<string, string>,
1589
+ + appKey: "app_name",
1590
+ + wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
1591
+ + onSetUp: (rnInstance) => {
1592
+ + rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
1593
+ + },
1594
+ + jsBundleProvider: new TraceJSBundleProviderDecorator(
1595
+ + new AnyJSBundleProvider([
1596
+ + new MetroJSBundleProvider(),
1597
+ + // NOTE: to load the bundle from file, place it in
1598
+ + // `/data/app/el2/100/base/com.rnoh.tester/files/bundle.harmony.js`
1599
+ + // on your device. The path mismatch is due to app sandboxing on HarmonyOS
1600
+ + new FileJSBundleProvider('/data/storage/el2/base/files/bundle.harmony.js'),
1601
+ + // new FileJSBundleProvider(context.filesDir + '/' + this.bundlePath),
1602
+ + new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
1603
+ + new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
1604
+ + ]),
1605
+ + this.rnohCoreContext.logger),
1606
+ + })
1607
+ + }
1608
+ + Text("1233333333122 1212323")
1609
+ + }
1610
+ + .height('100%')
1611
+ + .width('100%')
1612
+ + }
1613
+ +}
1614
+
1615
+ ```
1616
+
1617
+ ### `example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets`
1618
+
1619
+ ```diff
1620
+ @@ -0,0 +1,153 @@
1621
+ +/**
1622
+ + * MIT License
1623
+ + *
1624
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1625
+ + *
1626
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1627
+ + * of this software and associated documentation files (the "Software"), to deal
1628
+ + * in the Software without restriction, including without limitation the rights
1629
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1630
+ + * copies of the Software, and to permit persons to whom the Software is
1631
+ + * furnished to do so, subject to the following conditions:
1632
+ + *
1633
+ + * The above copyright notice and this permission notice shall be included in all
1634
+ + * copies or substantial portions of the Software.
1635
+ + *
1636
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1637
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1638
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1639
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1640
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1641
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1642
+ + * SOFTWARE.
1643
+ + */
1644
+ +import { RNInstance, JSBundleProvider, RNAbility, RNSurface } from '@rnoh/react-native-openharmony'
1645
+ +import { CustomComponentBuilder } from "@rnoh/react-native-openharmony/src/main/ets/RNOHCorePackage"
1646
+ +import { SurfaceConfig2 } from '@rnoh/react-native-openharmony/src/main/ets/RNSurface'
1647
+ +
1648
+ +
1649
+ +@Component
1650
+ +export struct SurfaceDeadlockTest {
1651
+ + public jsBundleProvider: JSBundleProvider | undefined = undefined
1652
+ + public appKeys: string[] = []
1653
+ + public numberOfIterations: number = 1
1654
+ + @BuilderParam public buildCustomComponent!: CustomComponentBuilder
1655
+ + // -------------------------------------------------------------------------------------------------------------------
1656
+ + @StorageLink('RNAbility') private rnAbility: RNAbility = {} as RNAbility
1657
+ + private rnInstance!: RNInstance
1658
+ + @State private shouldShow: boolean = false
1659
+ + private shouldDestroyRNInstance: boolean = false
1660
+ + private cleanUpCallbacks: (() => void)[] = []
1661
+ +
1662
+ + aboutToAppear() {
1663
+ + this.getOrCreateRNInstance().then(rnInstance => {
1664
+ + this.rnInstance = rnInstance
1665
+ + const jsBundleExecutionStatus = this.rnInstance.getBundleExecutionStatus(this.jsBundleProvider?.getURL())
1666
+ + if (this.jsBundleProvider && jsBundleExecutionStatus === undefined) {
1667
+ + this.rnInstance.runJSBundle(this.jsBundleProvider).then(() => {
1668
+ + this.shouldShow = true
1669
+ + })
1670
+ + return;
1671
+ + }
1672
+ + }).catch((reason: string | Error) => {
1673
+ + if (typeof reason === "string")
1674
+ + this.rnAbility.getLogger().error(reason)
1675
+ + else if (reason instanceof Error) {
1676
+ + this.rnAbility.getLogger().error(reason.message)
1677
+ + } else {
1678
+ + this.rnAbility.getLogger().error("Fatal exception")
1679
+ + }
1680
+ + })
1681
+ + }
1682
+ +
1683
+ + aboutToDisappear() {
1684
+ + if (this.shouldDestroyRNInstance)
1685
+ + this.rnAbility.destroyAndUnregisterRNInstance(this.rnInstance)
1686
+ + this.cleanUpCallbacks.forEach(cleanUp => cleanUp())
1687
+ + }
1688
+ +
1689
+ + private getOrCreateRNInstance(): Promise<RNInstance> {
1690
+ + return this.rnAbility.createAndRegisterRNInstance({ createRNPackages: () => [] })
1691
+ + }
1692
+ +
1693
+ + build() {
1694
+ + Stack() {
1695
+ + if (this.shouldShow) {
1696
+ + ForEach(this.appKeys, (appKey: string, idx) => {
1697
+ + Stack() {
1698
+ + Blinker({
1699
+ + minDelayInMs: 1000,
1700
+ + maxDelayInMs: 2000,
1701
+ + blinksCount: this.numberOfIterations,
1702
+ + randomnessPrecisionInMs: 500
1703
+ + }) {
1704
+ + RNSurface({
1705
+ + ctx: this.rnAbility.createRNOHContext({ rnInstance: this.rnInstance }),
1706
+ + surfaceConfig: {
1707
+ + initialProps: {},
1708
+ + appKey: appKey,
1709
+ + } as SurfaceConfig2,
1710
+ + buildCustomComponent: this.buildCustomComponent,
1711
+ + })
1712
+ + }
1713
+ + }.height(`${100 / this.appKeys.length}%`)
1714
+ + .position({ x: 0, y: `${(idx / this.appKeys.length) * 100}%` })
1715
+ + })
1716
+ + }
1717
+ + }.width("100%")
1718
+ + .height("100%")
1719
+ + }
1720
+ +}
1721
+ +
1722
+ +
1723
+ +@Component
1724
+ +struct Blinker {
1725
+ + public minDelayInMs: number = 0
1726
+ + public maxDelayInMs: number = 1000
1727
+ + public blinksCount: number = 0
1728
+ + public randomnessPrecisionInMs: number = 250
1729
+ + @BuilderParam public renderChildren: () => void
1730
+ + private currentBlinksCount = 0
1731
+ + @State private isVisible: boolean = false
1732
+ + private timeout: number = 0
1733
+ +
1734
+ + aboutToAppear() {
1735
+ + this.blink(this.minDelayInMs)
1736
+ + }
1737
+ +
1738
+ + aboutToDisappear() {
1739
+ + clearTimeout(this.timeout)
1740
+ + }
1741
+ +
1742
+ + private blink(ms: number) {
1743
+ + this.isVisible = !this.isVisible
1744
+ + this.currentBlinksCount += 1
1745
+ + if (this.currentBlinksCount >= this.blinksCount) {
1746
+ + if (this.timeout) {
1747
+ + clearTimeout(this.timeout)
1748
+ + }
1749
+ + this.isVisible = true
1750
+ + return;
1751
+ + }
1752
+ + this.timeout = setTimeout(() => {
1753
+ + this.blink(this.getNextDelay())
1754
+ + }, ms)
1755
+ + }
1756
+ +
1757
+ + private getNextDelay(): number {
1758
+ + return ((Math.floor(Math.random() * (Number.MAX_VALUE / this.randomnessPrecisionInMs)) * this.randomnessPrecisionInMs) % this.maxDelayInMs) + this.minDelayInMs
1759
+ + }
1760
+ +
1761
+ + build() {
1762
+ + Stack() {
1763
+ + if (this.isVisible) {
1764
+ + this.renderChildren()
1765
+ + }
1766
+ + }
1767
+ + }
1768
+ +}
1769
+ +
1770
+ +
1771
+ +
1772
+ +
1773
+ +
1774
+
1775
+ ```
1776
+
1777
+ ### `example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets`
1778
+
1779
+ ```diff
1780
+ @@ -0,0 +1,62 @@
1781
+ +/**
1782
+ + * MIT License
1783
+ + *
1784
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
1785
+ + *
1786
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
1787
+ + * of this software and associated documentation files (the "Software"), to deal
1788
+ + * in the Software without restriction, including without limitation the rights
1789
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1790
+ + * copies of the Software, and to permit persons to whom the Software is
1791
+ + * furnished to do so, subject to the following conditions:
1792
+ + *
1793
+ + * The above copyright notice and this permission notice shall be included in all
1794
+ + * copies or substantial portions of the Software.
1795
+ + *
1796
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1797
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1798
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1799
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1800
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1802
+ + * SOFTWARE.
1803
+ + */
1804
+ +
1805
+ +
1806
+ +@Component
1807
+ +export struct TouchDisplayer {
1808
+ + @State currentTouches: TouchObject[] = []
1809
+ + @State touchIndicatorOpacity: number = 0
1810
+ + @BuilderParam buildChildren: () => void
1811
+ + build() {
1812
+ + Stack() {
1813
+ + this.buildChildren()
1814
+ + ForEach(this.currentTouches, (activeTouch: TouchObject) => {
1815
+ + Stack() {
1816
+ + }
1817
+ + .width(64)
1818
+ + .height(64)
1819
+ + .backgroundColor("blue")
1820
+ + .borderWidth(2)
1821
+ + .borderColor("white")
1822
+ + .opacity(this.touchIndicatorOpacity)
1823
+ + .position({ x: activeTouch.x - 32, y: activeTouch.y - 32 })
1824
+ + .borderRadius(1000)
1825
+ + .hitTestBehavior(HitTestMode.Transparent)
1826
+ + })
1827
+ + }
1828
+ + .width("100%")
1829
+ + .height("100%")
1830
+ + .hitTestBehavior(HitTestMode.Transparent)
1831
+ + .onTouch(e => {
1832
+ + this.currentTouches = e.touches
1833
+ + this.touchIndicatorOpacity = 0.5
1834
+ + animateTo({
1835
+ + duration: 500,
1836
+ + curve: Curve.Linear,
1837
+ + }, () => {
1838
+ + this.touchIndicatorOpacity = 0
1839
+ + })
1840
+ + })
1841
+ + }
1842
+ +}
1843
+
1844
+
1845
+ ```
1846
+
1847
+ ### `example/harmony/entry/src/main/module.json5`
1848
+
1849
+ ```diff
1850
+ @@ -0,0 +1,62 @@
1851
+ +{
1852
+ + "module": {
1853
+ + "name": "entry",
1854
+ + "type": "entry",
1855
+ + "description": "$string:module_desc",
1856
+ + "mainElement": "EntryAbility",
1857
+ + "deviceTypes": [
1858
+ + "default"
1859
+ + ],
1860
+ + "querySchemes": [
1861
+ + "weixin",
1862
+ + ],
1863
+ + "deliveryWithInstall": true,
1864
+ + "installationFree": false,
1865
+ + "pages": "$profile:main_pages",
1866
+ + // below property is supported from 5.0.0 - it is needed by bundleManager.canOpenLink to check if the app can open some url
1867
+ + // "querySchemes": ["maps", "http", "https", "customDomain"],
1868
+ + "requestPermissions": [
1869
+ + {
1870
+ + "name": "ohos.permission.INTERNET"
1871
+ + },
1872
+ + {
1873
+ + "name": "ohos.permission.MICROPHONE",
1874
+ + "reason": "$string:Access_Create_Audio",
1875
+ + "usedScene": {
1876
+ + "abilities": [
1877
+ + "EntryAbility"
1878
+ + ],
1879
+ + "when": "always"
1880
+ + }
1881
+ + }
1882
+ + ],
1883
+ + "metadata": [
1884
+ + {
1885
+ + "name": "OPTLazyForEach",
1886
+ + "value": "true",
1887
+ + }
1888
+ + ],
1889
+ + "abilities": [
1890
+ + {
1891
+ + "name": "EntryAbility",
1892
+ + "srcEntry": "./ets/entryability/EntryAbility.ets",
1893
+ + "description": "$string:EntryAbility_desc",
1894
+ + "icon": "$media:icon",
1895
+ + "label": "$string:EntryAbility_label",
1896
+ + "startWindowIcon": "$media:icon",
1897
+ + "startWindowBackground": "$color:start_window_background",
1898
+ + "visible": true,
1899
+ + "skills": [
1900
+ + {
1901
+ + "entities": [
1902
+ + "entity.system.home"
1903
+ + ],
1904
+ + "actions": [
1905
+ + "action.system.home"
1906
+ + ]
1907
+ + }
1908
+ + ]
1909
+ + }
1910
+ + ]
1911
+ + }
1912
+ +}
1913
+
1914
+
1915
+ ```
1916
+
1917
+ ### `example/harmony/entry/src/main/resources/.gitignore`
1918
+
1919
+ ```diff
1920
+ @@ -0,0 +1 @@
1921
+ +rawfile/assets
1922
+
1923
+ ```
1924
+
1925
+ ### `example/harmony/entry/src/main/resources/base/element/color.json`
1926
+
1927
+ ```diff
1928
+ @@ -0,0 +1,8 @@
1929
+ +{
1930
+ + "color": [
1931
+ + {
1932
+ + "name": "start_window_background",
1933
+ + "value": "#FFFFFF"
1934
+ + }
1935
+ + ]
1936
+ +}
1937
+
1938
+
1939
+ ```
1940
+
1941
+ ### `example/harmony/entry/src/main/resources/base/element/string.json`
1942
+
1943
+ ```diff
1944
+ @@ -0,0 +1,20 @@
1945
+ +{
1946
+ + "string": [
1947
+ + {
1948
+ + "name": "module_desc",
1949
+ + "value": "module description"
1950
+ + },
1951
+ + {
1952
+ + "name": "EntryAbility_desc",
1953
+ + "value": "description"
1954
+ + },
1955
+ + {
1956
+ + "name": "EntryAbility_label",
1957
+ + "value": "RN Tester"
1958
+ + },
1959
+ + {
1960
+ + "name": "Access_Create_Audio",
1961
+ + "value": "access create Audio"
1962
+ + }
1963
+ + ]
1964
+ +}
1965
+
1966
+
1967
+ ```
1968
+
1969
+ ### `example/harmony/entry/src/main/resources/base/media/icon.png`
1970
+
1971
+ ```diff
1972
+ Binary files no preview for this file type
1973
+ ```
1974
+
1975
+ ### `example/harmony/entry/src/main/resources/base/profile/main_pages.json`
1976
+
1977
+ ```diff
1978
+ @@ -0,0 +1,5 @@
1979
+ +{
1980
+ + "src": [
1981
+ + "pages/Index"
1982
+ + ]
1983
+ +}
1984
+
1985
+ ```
1986
+
1987
+ ### `example/harmony/entry/src/main/resources/rawfile/1.txt`
1988
+
1989
+ ```diff
1990
+ @@ -0,0 +1 @@
1991
+ +text test
1992
+
1993
+
1994
+ ```
1995
+
1996
+ ### `example/harmony/format.ps1`
1997
+
1998
+ ```diff
1999
+ @@ -0,0 +1,36 @@
2000
+ +/**
2001
+ + * MIT License
2002
+ + *
2003
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2004
+ + *
2005
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2006
+ + * of this software and associated documentation files (the "Software"), to deal
2007
+ + * in the Software without restriction, including without limitation the rights
2008
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2009
+ + * copies of the Software, and to permit persons to whom the Software is
2010
+ + * furnished to do so, subject to the following conditions:
2011
+ + *
2012
+ + * The above copyright notice and this permission notice shall be included in all
2013
+ + * copies or substantial portions of the Software.
2014
+ + *
2015
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2016
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2017
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2018
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2019
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2021
+ + * SOFTWARE.
2022
+ + */
2023
+ +
2024
+ +$directoryPath = Split-Path -Parent $MyInvocation.MyCommand.Path
2025
+ +$filePaths = Get-ChildItem $directoryPath -Recurse -Include *.h, *.cpp |
2026
+ +Where-Object {
2027
+ + $_.DirectoryName -notmatch 'third-party' -and
2028
+ + $_.DirectoryName -notmatch 'patches' -and
2029
+ + $_.DirectoryName -notmatch 'node_modules' -and
2030
+ + $_.DirectoryName -notmatch '.cxx' -and
2031
+ + $_.DirectoryName -notmatch 'build'
2032
+ +}
2033
+ +foreach ($filePath in $filePaths) {
2034
+ + & "clang-format.exe" -style=file -i $filePath.FullName
2035
+ +}
2036
+
2037
+
2038
+ ```
2039
+
2040
+ ### `example/harmony/hvigor/.gitignore`
2041
+
2042
+ ```diff
2043
+ @@ -0,0 +1 @@
2044
+ +*.tgz
2045
+
2046
+ ```
2047
+
2048
+ ### `example/harmony/hvigor/hvigor-config.json5`
2049
+
2050
+ ```diff
2051
+ @@ -0,0 +1,21 @@
2052
+ +{
2053
+ + "modelVersion": "5.0.0",
2054
+ + "dependencies": {
2055
+ + },
2056
+ + "execution": {
2057
+ + // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
2058
+ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
2059
+ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
2060
+ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
2061
+ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
2062
+ + },
2063
+ + "logging": {
2064
+ + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
2065
+ + },
2066
+ + "debugging": {
2067
+ + "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
2068
+ + },
2069
+ + "nodeOptions": {
2070
+ + // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
2071
+ + }
2072
+ +}
2073
+
2074
+
2075
+ ```
2076
+
2077
+ ### `example/harmony/hvigorfile.ts`
2078
+
2079
+ ```diff
2080
+ @@ -0,0 +1,27 @@
2081
+ +/**
2082
+ + * MIT License
2083
+ + *
2084
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2085
+ + *
2086
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2087
+ + * of this software and associated documentation files (the "Software"), to deal
2088
+ + * in the Software without restriction, including without limitation the rights
2089
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2090
+ + * copies of the Software, and to permit persons to whom the Software is
2091
+ + * furnished to do so, subject to the following conditions:
2092
+ + *
2093
+ + * The above copyright notice and this permission notice shall be included in all
2094
+ + * copies or substantial portions of the Software.
2095
+ + *
2096
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2097
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2098
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2099
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2100
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2101
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2102
+ + * SOFTWARE.
2103
+ + */
2104
+ +
2105
+ +
2106
+ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
2107
+ +export { appTasks } from '@ohos/hvigor-ohos-plugin';
2108
+
2109
+
2110
+ ```
2111
+
2112
+ ### `example/harmony/oh-package.json5`
2113
+
2114
+ ```diff
2115
+ @@ -0,0 +1,12 @@
2116
+ +{
2117
+ + "modelVersion": "5.0.0",
2118
+ + "license": "ISC",
2119
+ + "name": "rnoh",
2120
+ + "description": "example description",
2121
+ + "repository": {},
2122
+ + "version": "1.0.0",
2123
+ + "overrides": {
2124
+ + "@rnoh/react-native-openharmony": "file:./../node_modules/react-native-harmony/react_native_openharmony.har"
2125
+ + },
2126
+ + "dynamicDependencies": {}
2127
+ +}
2128
+
2129
+
2130
+ ```
2131
+
2132
+ ### `example/index.js`
2133
+
2134
+ ```diff
2135
+ @@ -0,0 +1,29 @@
2136
+ +/**
2137
+ + * MIT License
2138
+ + *
2139
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2140
+ + *
2141
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2142
+ + * of this software and associated documentation files (the "Software"), to deal
2143
+ + * in the Software without restriction, including without limitation the rights
2144
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2145
+ + * copies of the Software, and to permit persons to whom the Software is
2146
+ + * furnished to do so, subject to the following conditions:
2147
+ + *
2148
+ + * The above copyright notice and this permission notice shall be included in all
2149
+ + * copies or substantial portions of the Software.
2150
+ + *
2151
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2152
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2153
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2154
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2155
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2156
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2157
+ + * SOFTWARE.
2158
+ + */
2159
+ +
2160
+ +import {AppRegistry, View, Text} from 'react-native';
2161
+ +import {name as appName} from './app.json';
2162
+ +import App from './src/index';
2163
+ +
2164
+ +AppRegistry.registerComponent(appName, () => App);
2165
+
2166
+
2167
+ ```
2168
+
2169
+ ### `example/jest.config.js`
2170
+
2171
+ ```diff
2172
+ @@ -0,0 +1,29 @@
2173
+ +/**
2174
+ + * MIT License
2175
+ + *
2176
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2177
+ + *
2178
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2179
+ + * of this software and associated documentation files (the "Software"), to deal
2180
+ + * in the Software without restriction, including without limitation the rights
2181
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2182
+ + * copies of the Software, and to permit persons to whom the Software is
2183
+ + * furnished to do so, subject to the following conditions:
2184
+ + *
2185
+ + * The above copyright notice and this permission notice shall be included in all
2186
+ + * copies or substantial portions of the Software.
2187
+ + *
2188
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2189
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2190
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2191
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2192
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2193
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2194
+ + * SOFTWARE.
2195
+ + */
2196
+ +
2197
+ +/** @type {import('ts-jest').JestConfigWithTsJest} */
2198
+ +module.exports = {
2199
+ + preset: 'ts-jest',
2200
+ + testEnvironment: 'node',
2201
+ +};
2202
+
2203
+ ```
2204
+
2205
+ ### `example/metro.config.js`
2206
+
2207
+ ```diff
2208
+ @@ -0,0 +1,48 @@
2209
+ +/**
2210
+ + * MIT License
2211
+ + *
2212
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2213
+ + *
2214
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2215
+ + * of this software and associated documentation files (the "Software"), to deal
2216
+ + * in the Software without restriction, including without limitation the rights
2217
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2218
+ + * copies of the Software, and to permit persons to whom the Software is
2219
+ + * furnished to do so, subject to the following conditions:
2220
+ + *
2221
+ + * The above copyright notice and this permission notice shall be included in all
2222
+ + * copies or substantial portions of the Software.
2223
+ + *
2224
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2225
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2226
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2227
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2228
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2229
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2230
+ + * SOFTWARE.
2231
+ + */
2232
+ +
2233
+ +const {mergeConfig, getDefaultConfig} = require('@react-native/metro-config');
2234
+ +const {createHarmonyMetroConfig} = require('react-native-harmony/metro.config');
2235
+ +
2236
+ +/**
2237
+ + * @type {import("metro-config").ConfigT}
2238
+ + */
2239
+ +const config = {
2240
+ + transformer: {
2241
+ + getTransformOptions: async () => ({
2242
+ + transform: {
2243
+ + experimentalImportSupport: false,
2244
+ + inlineRequires: true,
2245
+ + },
2246
+ + }),
2247
+ + },
2248
+ +};
2249
+ +
2250
+ +module.exports = mergeConfig(
2251
+ + getDefaultConfig(__dirname),
2252
+ + createHarmonyMetroConfig({
2253
+ + reactNativeHarmonyPackageName: 'react-native-harmony',
2254
+ + }),
2255
+ + config,
2256
+ +);
2257
+
2258
+ ```
2259
+
2260
+ ### `example/package.json`
2261
+
2262
+ ```diff
2263
+ @@ -0,0 +1,61 @@
2264
+ +{
2265
+ + "name": "react-native-harmony-tester",
2266
+ + "version": "1.0.0",
2267
+ + "private": true,
2268
+ + "scripts": {
2269
+ + "i": "cd ../ && npm i && npm run pack && cd ./example && npm i",
2270
+ + "reStart": "npm run install:pkg && npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start",
2271
+ + "start": "hdc rport tcp:8081 tcp:8081 && react-native start",
2272
+ + "codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/entry/oh_modules/@rnoh/react-native-openharmony",
2273
+ + "pack:pkg": "cd ../ && npm pack && cd ./example",
2274
+ + "install:pkg": "npm uninstall @react-native-ohos/geolocation && npm run pack:pkg && npm i @react-native-ohos/geolocation@file:../react-native-ohos-geolocation-3.1.1.tgz",
2275
+ + "dev": "npm run codegen && react-native bundle-harmony --dev --minify=false",
2276
+ + "prod": "npm run codegen && react-native bundle-harmony --dev=false --minify=true",
2277
+ + "postinstall": "node ./scripts/create-build-profile",
2278
+ + "fast-install-project": "cd ../ && npm i --force && npm run pack && rm -r node_modules && cd ./example && npm i --force",
2279
+ + "fast:pkg": "npm run fast-install-project && npm run dev"
2280
+ + },
2281
+ + "dependencies": {
2282
+ + "@gorhom/portal": "^1.0.14",
2283
+ + "@react-native-ohos/geolocation": "file:../react-native-ohos-geolocation-3.1.1.tgz",
2284
+ + "react": "18.3.1",
2285
+ + "react-native": "0.77.1",
2286
+ + "react-native-harmony": "npm:@react-native-oh/react-native-harmony@0.77.18-1",
2287
+ + "react-native-reanimated": "^3.6.0"
2288
+ + },
2289
+ + "devDependencies": {
2290
+ + "@babel/core": "^7.25.2",
2291
+ + "@babel/preset-env": "^7.25.3",
2292
+ + "@babel/runtime": "^7.25.0",
2293
+ + "@react-native-community/cli": "15.0.1",
2294
+ + "@react-native-community/cli-platform-android": "15.0.1",
2295
+ + "@react-native-community/cli-platform-ios": "15.0.1",
2296
+ + "@react-native-community/eslint-config": "^3.2.0",
2297
+ + "@react-native/babel-preset": "0.77.1",
2298
+ + "@react-native/eslint-config": "0.77.1",
2299
+ + "@react-native/metro-config": "^0.77.1",
2300
+ + "@react-native/typescript-config": "0.77.1",
2301
+ + "@rnoh/react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@0.77.18-1",
2302
+ + "@tsconfig/react-native": "^3.0.0",
2303
+ + "@types/d3-scale-chromatic": "^3.0.0",
2304
+ + "@types/jest": "^29.5.13",
2305
+ + "@types/react": "^18.2.6",
2306
+ + "@types/react-test-renderer": "^18.0.0",
2307
+ + "babel-jest": "^29.6.3",
2308
+ + "eslint": "^8.19.0",
2309
+ + "jest": "^29.7.0",
2310
+ + "metro-react-native-babel-preset": "0.76.8",
2311
+ + "prettier": "2.8.8",
2312
+ + "react-test-renderer": "18.3.1",
2313
+ + "typescript": "5.5.4"
2314
+ + },
2315
+ + "overrides": {
2316
+ + "@react-native-community/cli": "15.0.1"
2317
+ + },
2318
+ + "resolutions": {
2319
+ + "@react-native-community/cli": "15.0.1"
2320
+ + },
2321
+ + "engines": {
2322
+ + "node": ">=18"
2323
+ + }
2324
+ +}
2325
+
2326
+ ```
2327
+
2328
+ ### `example/react-native.config.js`
2329
+
2330
+ ```diff
2331
+ @@ -0,0 +1,29 @@
2332
+ +/**
2333
+ + * MIT License
2334
+ + *
2335
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2336
+ + *
2337
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2338
+ + * of this software and associated documentation files (the "Software"), to deal
2339
+ + * in the Software without restriction, including without limitation the rights
2340
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2341
+ + * copies of the Software, and to permit persons to whom the Software is
2342
+ + * furnished to do so, subject to the following conditions:
2343
+ + *
2344
+ + * The above copyright notice and this permission notice shall be included in all
2345
+ + * copies or substantial portions of the Software.
2346
+ + *
2347
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2348
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2349
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2350
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2351
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2352
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2353
+ + * SOFTWARE.
2354
+ + */
2355
+ +
2356
+ +module.exports = {
2357
+ + project: {
2358
+ + },
2359
+ + assets: ['./assets/fonts/'],
2360
+ +};
2361
+
2362
+ ```
2363
+
2364
+ ### `example/scripts/create-build-profile.js`
2365
+
2366
+ ```diff
2367
+ @@ -0,0 +1,64 @@
2368
+ +/**
2369
+ + * MIT License
2370
+ + *
2371
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2372
+ + *
2373
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2374
+ + * of this software and associated documentation files (the "Software"), to deal
2375
+ + * in the Software without restriction, including without limitation the rights
2376
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2377
+ + * copies of the Software, and to permit persons to whom the Software is
2378
+ + * furnished to do so, subject to the following conditions:
2379
+ + *
2380
+ + * The above copyright notice and this permission notice shall be included in all
2381
+ + * copies or substantial portions of the Software.
2382
+ + *
2383
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2384
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2385
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2386
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2387
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2388
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2389
+ + * SOFTWARE.
2390
+ + */
2391
+ +
2392
+ +
2393
+ +const fs = require('fs');
2394
+ +const JSON5 = require('json5');
2395
+ +const path = require('path');
2396
+ +
2397
+ +const templatePath = path.join(
2398
+ + __dirname,
2399
+ + '..',
2400
+ + 'harmony',
2401
+ + 'build-profile.template.json5',
2402
+ +);
2403
+ +const existingProfilePath = path.join(
2404
+ + __dirname,
2405
+ + '..',
2406
+ + 'harmony',
2407
+ + 'build-profile.json5',
2408
+ +);
2409
+ +
2410
+ +if (fs.existsSync(existingProfilePath)) {
2411
+ + let existingProfile = JSON5.parse(
2412
+ + fs.readFileSync(existingProfilePath, 'utf-8'),
2413
+ + );
2414
+ + let template = JSON5.parse(fs.readFileSync(templatePath, 'utf-8'));
2415
+ + let signingConfigs =
2416
+ + existingProfile.app && existingProfile.app.signingConfigs;
2417
+ +
2418
+ + existingProfile = {...template};
2419
+ +
2420
+ + if (signingConfigs) {
2421
+ + existingProfile.app.signingConfigs = signingConfigs;
2422
+ + }
2423
+ +
2424
+ + fs.writeFileSync(
2425
+ + existingProfilePath,
2426
+ + JSON5.stringify(existingProfile, null, 2),
2427
+ + );
2428
+ +} else {
2429
+ + // File doesn't exist, create a copy from the template
2430
+ + fs.copyFileSync(templatePath, existingProfilePath);
2431
+ +}
2432
+
2433
+
2434
+ ```
2435
+
2436
+ ### `example/src/index.tsx`
2437
+
2438
+ ```diff
2439
+ @@ -0,0 +1,40 @@
2440
+ +/**
2441
+ + * MIT License
2442
+ + *
2443
+ + * Copyright (C) 2023 Huawei Device Co., Ltd.
2444
+ + *
2445
+ + * Permission is hereby granted, free of charge, to any person obtaining a copy
2446
+ + * of this software and associated documentation files (the "Software"), to deal
2447
+ + * in the Software without restriction, including without limitation the rights
2448
+ + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2449
+ + * copies of the Software, and to permit persons to whom the Software is
2450
+ + * furnished to do so, subject to the following conditions:
2451
+ + *
2452
+ + * The above copyright notice and this permission notice shall be included in all
2453
+ + * copies or substantial portions of the Software.
2454
+ + *
2455
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2456
+ + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2457
+ + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2458
+ + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2459
+ + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2460
+ + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2461
+ + * SOFTWARE.
2462
+ + */
2463
+ +import Geolocation from "@react-native-community/geolocation";
2464
+ +import { Button } from "react-native";
2465
+ +import React from 'react';
2466
+ +
2467
+ +export function GeolocationDemo(): JSX.Element {
2468
+ + const tap = () => {
2469
+ + Geolocation.setRNConfiguration({
2470
+ + skipPermissionRequests: true,
2471
+ + authorizationLevel: "auto",
2472
+ + enableBackgroundLocationUpdates: true,
2473
+ + locationProvider: "auto",
2474
+ + });
2475
+ + console.log("tap");
2476
+ + };
2477
+ +
2478
+ + return <Button title='test' onPress={tap} />;
2479
+ +}
2480
+
2481
+
2482
+ ```
2483
+
2484
+ ### `example/tsconfig.json`
2485
+
2486
+ ```diff
2487
+ @@ -0,0 +1,14 @@
2488
+ +{
2489
+ + "extends": "@react-native/typescript-config/tsconfig.json",
2490
+ + "compilerOptions": {
2491
+ + "jsx": "react-native",
2492
+ + "paths": {
2493
+ + "react-native": [
2494
+ + "./node_modules/react-native-harmony"
2495
+ + ],
2496
+ + },
2497
+ + },
2498
+ + "exclude": [
2499
+ + "harmony"
2500
+ + ]
2501
+ +}
2502
+
2503
+
2504
+ ```
2505
+
2506
+ ### `harmony/geolocation/index.ets`
2507
+
2508
+ ```diff
2509
+ @@ -21,6 +21,6 @@
2510
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2511
+ * SOFTWARE.
2512
+ */
2513
+ -import { GeoLocationPackage } from './src/main/ets/GeoLocationPackage.ets';
2514
+ -export * from './ts.ets';
2515
+ +import { GeoLocationPackage } from './src/main/ets/GeoLocationPackage';
2516
+ +export * from './ts';
2517
+ export default GeoLocationPackage;
2518
+
2519
+ ```
2520
+
2521
+ ### `harmony/geolocation/ts.ets`
2522
+
2523
+ ```diff
2524
+ @@ -13,7 +13,7 @@
2525
+ * The above copyright notice and this permission notice shall be included in all
2526
+ * copies or substantial portions of the Software.
2527
+ *
2528
+ - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANT KIND, EXPRESS OR
2529
+ + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2530
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2531
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2532
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2533
+ @@ -22,5 +22,5 @@
2534
+ * SOFTWARE.
2535
+ */
2536
+
2537
+ -export * from './src/main/ets/GeoLocationPackage.ets'
2538
+ +export * from './src/main/ets/GeoLocationPackage'
2539
+ export * from './src/main/ets/RNCGeolocationTurboModule'
2540
+
2541
+
2542
+ ```
2543
+
2544
+ ### `package.json`
2545
+
2546
+ ```diff
2547
+ @@ -33,6 +33,7 @@
2548
+ "homepage": "https://gitcode.com/michalchudziak/react-native-geolocation#README.md",
2549
+ "license": "MIT",
2550
+ "scripts": {
2551
+ + "pack": "npm pack --ignore-scripts",
2552
+ "start": "react-native start",
2553
+ "test": "yarn validate:eslint && yarn validate:typescript && yarn test:jest",
2554
+ "validate:eslint": "eslint \"**/*.{js,ts,tsx}\"",
2555
+
2556
+ ```
2557
+
2558
+ ### `react-native-geolocation.podspec`
2559
+
2560
+ ```diff
2561
+ @@ -1,35 +0,0 @@
2562
+ -require 'json'
2563
+ -
2564
+ -package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
2565
+ -folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
2566
+ -
2567
+ -Pod::Spec.new do |s|
2568
+ - s.name = "react-native-geolocation"
2569
+ - s.version = package['version']
2570
+ - s.summary = package['description']
2571
+ - s.license = package['license']
2572
+ -
2573
+ - s.authors = package['author']
2574
+ - s.homepage = package['homepage']
2575
+ - s.platform = :ios, "9.0"
2576
+ -
2577
+ - s.source = { :git => "https://github.com/react-native-community/react-native-geolocation.git", :tag => "v#{s.version}" }
2578
+ - s.source_files = "ios/**/*.{h,m,mm}"
2579
+ -
2580
+ - s.dependency 'React-Core'
2581
+ - s.frameworks = 'CoreLocation'
2582
+ -
2583
+ - if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
2584
+ - s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
2585
+ - s.pod_target_xcconfig = {
2586
+ - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
2587
+ - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
2588
+ - }
2589
+ -
2590
+ - s.dependency "React-Codegen"
2591
+ - s.dependency "RCT-Folly"
2592
+ - s.dependency "RCTRequired"
2593
+ - s.dependency "RCTTypeSafety"
2594
+ - s.dependency "ReactCommon/turbomodule/core"
2595
+ - end
2596
+ -end
2597
+
2598
+ ```