@react-native-ohos/react-native-qr-decode-image-camera 1.1.4-rc.1 → 1.1.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/.github/workflows/codeql-analysis.yml +68 -0
  2. package/COMMITTERS.md +6 -6
  3. package/LICENSE +21 -21
  4. package/OAT.xml +88 -88
  5. package/QrCode.podspec +14 -14
  6. package/README.OpenSource +10 -10
  7. package/README.md +13 -13
  8. package/SECURITY.md +21 -21
  9. package/harmony/qr_decode_image_camera/BuildProfile.ets +16 -16
  10. package/harmony/qr_decode_image_camera/Index.ets +9 -8
  11. package/harmony/qr_decode_image_camera/build-profile.json5 +27 -27
  12. package/harmony/qr_decode_image_camera/obfuscation-rules.txt +17 -17
  13. package/harmony/qr_decode_image_camera/oh-package-lock.json5 +17 -17
  14. package/harmony/qr_decode_image_camera/oh-package.json5 +12 -12
  15. package/harmony/qr_decode_image_camera/src/main/cpp/CMakeLists.txt +3 -2
  16. package/harmony/qr_decode_image_camera/src/main/cpp/QrDecodeImageCameraPackage.h +16 -10
  17. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/BaseReactNativeQrDecodeImageCameraPackage.h +70 -72
  18. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/components/NativeScanJSIBinder.h +30 -0
  19. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/turbo_modules/QrDecodeImageCameraNativeModule.cpp +16 -16
  20. package/harmony/qr_decode_image_camera/src/main/cpp/generated/RNOH/generated/turbo_modules/QrDecodeImageCameraNativeModule.h +16 -16
  21. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/ComponentDescriptors.h +22 -24
  22. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/EventEmitters.cpp +26 -16
  23. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/EventEmitters.h +27 -17
  24. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/Props.cpp +29 -19
  25. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/Props.h +31 -18
  26. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/ShadowNodes.cpp +19 -17
  27. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/ShadowNodes.h +34 -23
  28. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/States.cpp +18 -16
  29. package/harmony/qr_decode_image_camera/src/main/cpp/generated/react/renderer/components/react_native_qr_decode_image_camera/States.h +36 -19
  30. package/harmony/qr_decode_image_camera/src/main/ets/Logger.ts +45 -45
  31. package/harmony/qr_decode_image_camera/src/main/ets/NativeScan.ets +150 -150
  32. package/harmony/qr_decode_image_camera/src/main/ets/{RNQrDecodeImageCameraPackage.ts → RNQrDecodeImageCameraPackage.ets} +29 -28
  33. package/harmony/qr_decode_image_camera/src/main/ets/RNQrDecodeImageCameraTurboModule.ts +46 -46
  34. package/harmony/qr_decode_image_camera/src/main/ets/generated/components/NativeScan.ts +120 -125
  35. package/harmony/qr_decode_image_camera/src/main/ets/generated/components/ts.ts +5 -8
  36. package/harmony/qr_decode_image_camera/src/main/ets/generated/index.ets +5 -5
  37. package/harmony/qr_decode_image_camera/src/main/ets/generated/ts.ts +6 -6
  38. package/harmony/qr_decode_image_camera/src/main/ets/generated/turboModules/QrDecodeImageCameraNativeModule.ts +16 -16
  39. package/harmony/qr_decode_image_camera/src/main/ets/generated/turboModules/ts.ts +5 -5
  40. package/harmony/qr_decode_image_camera/src/main/ets/pages/Index.ets +25 -25
  41. package/harmony/qr_decode_image_camera/src/main/ets/qr_decode_image_camera/qr_decode_image_camera.ets +47 -47
  42. package/harmony/qr_decode_image_camera/src/main/module.json5 +10 -10
  43. package/harmony/qr_decode_image_camera/src/main/resources/base/element/color.json +7 -7
  44. package/harmony/qr_decode_image_camera/src/main/resources/base/element/string.json +15 -15
  45. package/harmony/qr_decode_image_camera/src/main/resources/base/media/layered_image.json +6 -6
  46. package/harmony/qr_decode_image_camera/src/main/resources/base/profile/main_pages.json +5 -5
  47. package/harmony/qr_decode_image_camera/src/main/resources/en_US/element/string.json +15 -15
  48. package/harmony/qr_decode_image_camera/src/main/resources/zh_CN/element/string.json +15 -15
  49. package/harmony/qr_decode_image_camera/src/mock/mock-config.json5 +1 -1
  50. package/harmony/qr_decode_image_camera/src/ohosTest/ets/test/Ability.test.ets +34 -34
  51. package/harmony/qr_decode_image_camera/src/ohosTest/ets/test/List.test.ets +4 -4
  52. package/harmony/qr_decode_image_camera/src/ohosTest/ets/testability/TestAbility.ets +46 -46
  53. package/harmony/qr_decode_image_camera/src/ohosTest/ets/testability/pages/Index.ets +16 -16
  54. package/harmony/qr_decode_image_camera/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +89 -89
  55. package/harmony/qr_decode_image_camera/src/ohosTest/module.json5 +36 -36
  56. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/element/color.json +7 -7
  57. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/element/string.json +15 -15
  58. package/harmony/qr_decode_image_camera/src/ohosTest/resources/base/profile/test_pages.json +5 -5
  59. package/harmony/qr_decode_image_camera/src/test/List.test.ets +4 -4
  60. package/harmony/qr_decode_image_camera/src/test/LocalUnit.test.ets +32 -32
  61. package/harmony/qr_decode_image_camera/{ts.ts → ts.ets} +7 -7
  62. package/harmony/qr_decode_image_camera.har +0 -0
  63. package/index.js +14 -14
  64. package/package.json +48 -39
  65. package/src/Camera.tsx +57 -57
  66. package/src/NativeQrDecodeImageCamera.ts +16 -16
  67. package/src/NativeScan.ts +24 -24
  68. package/src/QRScanner.harmony.jsx +225 -225
  69. package/src/QRScanner.jsx +281 -281
  70. package/src/QRScannerView.js +381 -381
@@ -1,33 +1,33 @@
1
- import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2
-
3
- export default function localUnitTest() {
4
- describe('localUnitTest', () => {
5
- // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6
- beforeAll(() => {
7
- // Presets an action, which is performed only once before all test cases of the test suite start.
8
- // This API supports only one parameter: preset action function.
9
- });
10
- beforeEach(() => {
11
- // Presets an action, which is performed before each unit test case starts.
12
- // The number of execution times is the same as the number of test cases defined by **it**.
13
- // This API supports only one parameter: preset action function.
14
- });
15
- afterEach(() => {
16
- // Presets a clear action, which is performed after each unit test case ends.
17
- // The number of execution times is the same as the number of test cases defined by **it**.
18
- // This API supports only one parameter: clear action function.
19
- });
20
- afterAll(() => {
21
- // Presets a clear action, which is performed after all test cases of the test suite end.
22
- // This API supports only one parameter: clear action function.
23
- });
24
- it('assertContain', 0, () => {
25
- // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26
- let a = 'abc';
27
- let b = 'b';
28
- // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29
- expect(a).assertContain(b);
30
- expect(a).assertEqual(a);
31
- });
32
- });
1
+ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2
+
3
+ export default function localUnitTest() {
4
+ describe('localUnitTest', () => {
5
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6
+ beforeAll(() => {
7
+ // Presets an action, which is performed only once before all test cases of the test suite start.
8
+ // This API supports only one parameter: preset action function.
9
+ });
10
+ beforeEach(() => {
11
+ // Presets an action, which is performed before each unit test case starts.
12
+ // The number of execution times is the same as the number of test cases defined by **it**.
13
+ // This API supports only one parameter: preset action function.
14
+ });
15
+ afterEach(() => {
16
+ // Presets a clear action, which is performed after each unit test case ends.
17
+ // The number of execution times is the same as the number of test cases defined by **it**.
18
+ // This API supports only one parameter: clear action function.
19
+ });
20
+ afterAll(() => {
21
+ // Presets a clear action, which is performed after all test cases of the test suite end.
22
+ // This API supports only one parameter: clear action function.
23
+ });
24
+ it('assertContain', 0, () => {
25
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26
+ let a = 'abc';
27
+ let b = 'b';
28
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29
+ expect(a).assertContain(b);
30
+ expect(a).assertEqual(a);
31
+ });
32
+ });
33
33
  }
@@ -1,8 +1,8 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- export * from './src/main/ets/RNQrDecodeImageCameraPackage';
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ export * from './src/main/ets/RNQrDecodeImageCameraPackage';
8
8
  export * from "./src/main/ets/RNQrDecodeImageCameraTurboModule";
Binary file
package/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import QRscanner from './src/QRScanner'
2
- import { NativeModules } from 'react-native';
3
- import { Platform, TurboModuleRegistry } from "react-native"
4
- var getQr = TurboModuleRegistry ?
5
- TurboModuleRegistry.get('QrDecodeImageCameraNativeModule') : NativeModules.QRScanReader;
6
- const QRreader = (fileUrl) => {
7
- if (Platform.OS == 'harmony') {
8
- return getQr.QRreader(fileUrl)
9
- } else {
10
- var QRScanReader = NativeModules.QRScanReader;
11
- return QRScanReader.readerQR(fileUrl);
12
- }
13
- }
14
-
1
+ import QRscanner from './src/QRScanner'
2
+ import { NativeModules } from 'react-native';
3
+ import { Platform, TurboModuleRegistry } from "react-native"
4
+ var getQr = TurboModuleRegistry ?
5
+ TurboModuleRegistry.get('QrDecodeImageCameraNativeModule') : NativeModules.QRScanReader;
6
+ const QRreader = (fileUrl) => {
7
+ if (Platform.OS == 'harmony') {
8
+ return getQr.QRreader(fileUrl)
9
+ } else {
10
+ var QRScanReader = NativeModules.QRScanReader;
11
+ return QRScanReader.readerQR(fileUrl);
12
+ }
13
+ }
14
+
15
15
  export { QRscanner, QRreader }
package/package.json CHANGED
@@ -1,39 +1,48 @@
1
- {
2
- "name": "@react-native-ohos/react-native-qr-decode-image-camera",
3
- "version": "1.1.4-rc.1",
4
- "description": "Decode react native from gallery and camera",
5
- "license": "MIT",
6
- "main": "index.js",
7
- "nativePackage": true,
8
- "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-qr-decode-image-camera --cpp-output-path ./harmony/qr_decode_image_camera/src/main/cpp/generated --ets-output-path ./harmony/qr_decode_image_camera/src/main/ets/generated --turbo-modules-spec-paths ./src/NativeQrDecodeImageCamera.ts"
11
- },
12
- "harmony": {
13
- "alias": "react-native-qr-decode-image-camera"
14
- },
15
- "keywords": [
16
- "QRCode",
17
- "Decode",
18
- "scanner",
19
- "react-native",
20
- "harmony"
21
- ],
22
- "dependencies": {
23
- "prop-types": "^15.8.1",
24
- "react-native-qr-decode-image-camera":"^1.1.3",
25
- "react-native": "0.72.2",
26
- "@react-native-oh/react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@^0.0.27"
27
- },
28
- "homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-qr-decode-image-camera#readme",
29
- "repository": {
30
- "type": "git",
31
- "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-qr-decode-image-camera.git"
32
- },
33
- "devDependencies": {
34
- "react": "^18.2.0",
35
- "react-native": "^0.69.0",
36
- "react-native-vision-camera":"^4.0.1",
37
- "react-native-qr-decode-image-camera":"^1.1.3"
38
- }
39
- }
1
+ {
2
+ "name": "@react-native-ohos/react-native-qr-decode-image-camera",
3
+ "version": "1.1.5-rc.1",
4
+ "description": "Decode react native from gallery and camera",
5
+ "license": "MIT",
6
+ "main": "index.js",
7
+ "nativePackage": true,
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1",
10
+ "codegen-lib": "react-native codegen-lib-harmony --no-safety-check --npm-package-name react-native-qr-decode-image-camera --cpp-output-path ./harmony/qr_decode_image_camera/src/main/cpp/generated --ets-output-path ./harmony/qr_decode_image_camera/src/main/ets/generated --turbo-modules-spec-paths ./src/NativeQrDecodeImageCamera.ts --arkts-components-spec-paths ./src"
11
+ },
12
+ "harmony": {
13
+ "alias": "react-native-qr-decode-image-camera",
14
+ "autolinking": {
15
+ "etsPackageClassName":"QrDecodeImageCameraPackage",
16
+ "cppPackageClassName":"QrDecodeImageCameraPackage",
17
+ "cmakeLibraryTargetName": "rnoh_qr_decode_image_camera",
18
+ "ohPackageName": "@react-native-ohos/react-native-qr-decode-image-camera"
19
+ }
20
+ },
21
+ "keywords": [
22
+ "QRCode",
23
+ "Decode",
24
+ "scanner",
25
+ "react-native",
26
+ "harmony"
27
+ ],
28
+ "dependencies": {
29
+ "prop-types": "^15.8.1",
30
+ "react-native-qr-decode-image-camera":"^1.1.3"
31
+ },
32
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-qr-decode-image-camera",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-qr-decode-image-camera.git"
36
+ },
37
+ "devDependencies": {
38
+ "react": "^18.2.0",
39
+ "react-native": "^0.69.0",
40
+ "react-native-vision-camera":"^4.0.1",
41
+ "react-native-qr-decode-image-camera":"^1.1.3"
42
+ },
43
+ "publishConfig": {
44
+ "registry": "https://registry.npmjs.org/",
45
+ "access": "public"
46
+ },
47
+ "author": "deepanrajkumar"
48
+ }
package/src/Camera.tsx CHANGED
@@ -1,58 +1,58 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import React, { useState, useEffect } from 'react';
8
- import {
9
- PixelRatio
10
- } from "react-native";
11
- import { Camera, useCameraDevice, useCameraPermission } from 'react-native-vision-camera'
12
- export const ComponentCamera = (props) => {
13
- const CODE_TYPES = [
14
- 'code-128',
15
- 'code-39',
16
- 'code-93',
17
- 'codabar',
18
- 'ean-13',
19
- 'ean-8',
20
- 'itf',
21
- 'upc-e',
22
- 'upc-a',
23
- 'qr',
24
- 'pdf-417',
25
- 'aztec',
26
- 'data-matrix'
27
- ]
28
- const device = useCameraDevice('back');
29
- const { hasPermission, requestPermission } = useCameraPermission();
30
-
31
- if (!hasPermission) {
32
- requestPermission();
33
- }
34
-
35
- const codeScanner = {
36
- codeTypes: CODE_TYPES,
37
- onCodeScanned: (codes) => {
38
- // console.log(`Scanned ${codes.length} codes:`, codes)
39
- const value = codes[0]
40
- if (value) {
41
- props.onRead(value)
42
- } else {
43
- if (value == null) return
44
- }
45
- }
46
- }
47
-
48
-
49
- return (
50
- <Camera
51
- isActive={props.isActive}
52
- preview={true}
53
- device={device}
54
- codeScanner={codeScanner}
55
- torch={props.torch ? "on" : "off"}
56
- />
57
- )
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import React, { useState, useEffect } from 'react';
8
+ import {
9
+ PixelRatio
10
+ } from "react-native";
11
+ import { Camera, useCameraDevice, useCameraPermission } from 'react-native-vision-camera'
12
+ export const ComponentCamera = (props) => {
13
+ const CODE_TYPES = [
14
+ 'code-128',
15
+ 'code-39',
16
+ 'code-93',
17
+ 'codabar',
18
+ 'ean-13',
19
+ 'ean-8',
20
+ 'itf',
21
+ 'upc-e',
22
+ 'upc-a',
23
+ 'qr',
24
+ 'pdf-417',
25
+ 'aztec',
26
+ 'data-matrix'
27
+ ]
28
+ const device = useCameraDevice('back');
29
+ const { hasPermission, requestPermission } = useCameraPermission();
30
+
31
+ if (!hasPermission) {
32
+ requestPermission();
33
+ }
34
+
35
+ const codeScanner = {
36
+ codeTypes: CODE_TYPES,
37
+ onCodeScanned: (codes) => {
38
+ // console.log(`Scanned ${codes.length} codes:`, codes)
39
+ const value = codes[0]
40
+ if (value) {
41
+ props.onRead(value)
42
+ } else {
43
+ if (value == null) return
44
+ }
45
+ }
46
+ }
47
+
48
+
49
+ return (
50
+ <Camera
51
+ isActive={props.isActive}
52
+ preview={true}
53
+ device={device}
54
+ codeScanner={codeScanner}
55
+ torch={props.torch ? "on" : "off"}
56
+ />
57
+ )
58
58
  }
@@ -1,17 +1,17 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
8
- import { TurboModuleRegistry } from 'react-native';
9
-
10
- interface IPath {
11
- uri:string;
12
- }
13
- export interface Spec extends TurboModule {
14
- QRreader: (path:IPath) => Promise<any>;
15
- }
16
-
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
8
+ import { TurboModuleRegistry } from 'react-native';
9
+
10
+ interface IPath {
11
+ uri:string;
12
+ }
13
+ export interface Spec extends TurboModule {
14
+ QRreader: (path:IPath) => Promise<any>;
15
+ }
16
+
17
17
  export default TurboModuleRegistry.get<Spec>('QrDecodeImageCameraNativeModule') as Spec | null;
package/src/NativeScan.ts CHANGED
@@ -1,25 +1,25 @@
1
- /*
2
- * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
- * Use of this source code is governed by a MIT license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
8
- import type { HostComponent } from "react-native";
9
- import type {
10
- BubblingEventHandler, Float, Int32,
11
- } from 'react-native/Libraries/Types/CodegenTypes';
12
- import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
13
-
14
- type OnReadEvent = Readonly<{
15
- result: string;
16
- }>
17
-
18
- export interface NativeProps extends ViewProps {
19
- text?: string,
20
- onRead?: BubblingEventHandler<OnReadEvent>,
21
- flashMode?:boolean | null,
22
- zoom?:Float,
23
- }
24
-
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ import type { ViewProps } from "react-native/Libraries/Components/View/ViewPropTypes";
8
+ import type { HostComponent } from "react-native";
9
+ import type {
10
+ BubblingEventHandler, Float, Int32,
11
+ } from 'react-native/Libraries/Types/CodegenTypes';
12
+ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
13
+
14
+ type OnReadEvent = Readonly<{
15
+ result: string;
16
+ }>
17
+
18
+ export interface NativeProps extends ViewProps {
19
+ text?: string,
20
+ onRead?: BubblingEventHandler<OnReadEvent>,
21
+ flashMode?:boolean | null,
22
+ zoom?:Float,
23
+ }
24
+
25
25
  export default codegenNativeComponent<NativeProps>("NativeScan") as HostComponent<NativeProps>;