one 2.6.21 → 2.7.0

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 (56) hide show
  1. package/android/src/main/java/dev/onejs/onenative/OneNativeCameraManager.kt +24 -0
  2. package/android/src/main/java/dev/onejs/onenative/OneNativeCameraView.kt +197 -2
  3. package/dist/cjs/platform/camera/index.cjs +3 -2
  4. package/dist/cjs/platform/camera/index.native.cjs +89 -3
  5. package/dist/cjs/platform/camera/index.native.js +89 -3
  6. package/dist/cjs/platform/camera/index.native.js.map +1 -1
  7. package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.cjs +37 -21
  8. package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.native.cjs +37 -21
  9. package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.native.js +37 -21
  10. package/dist/cjs/platform/specs/OneNativeCameraNativeComponent.native.js.map +3 -3
  11. package/dist/cjs/router/router.cjs +4 -1
  12. package/dist/cjs/useHeaderHeight.native.cjs +5 -23
  13. package/dist/cjs/useHeaderHeight.native.js +5 -23
  14. package/dist/cjs/useHeaderHeight.native.js.map +1 -1
  15. package/dist/esm/platform/camera/index.mjs +4 -2
  16. package/dist/esm/platform/camera/index.mjs.map +1 -1
  17. package/dist/esm/platform/camera/index.native.js +90 -4
  18. package/dist/esm/platform/camera/index.native.js.map +1 -1
  19. package/dist/esm/platform/specs/OneNativeCameraNativeComponent.mjs +25 -9
  20. package/dist/esm/platform/specs/OneNativeCameraNativeComponent.mjs.map +3 -3
  21. package/dist/esm/platform/specs/OneNativeCameraNativeComponent.native.js +25 -9
  22. package/dist/esm/platform/specs/OneNativeCameraNativeComponent.native.js.map +3 -3
  23. package/dist/esm/router/router.mjs +5 -2
  24. package/dist/esm/router/router.mjs.map +1 -1
  25. package/dist/esm/useHeaderHeight.native.js +3 -21
  26. package/dist/esm/useHeaderHeight.native.js.map +1 -1
  27. package/ios/Nitro/HybridOneImageManipulator.swift +1 -1
  28. package/ios/OneNativeCameraComponentView.mm +28 -0
  29. package/ios/OneNativeCameraView.swift +163 -0
  30. package/package.json +27 -27
  31. package/src/index.ts +3 -0
  32. package/src/platform/camera/index.native.tsx +116 -12
  33. package/src/platform/camera/index.tsx +15 -4
  34. package/src/platform/camera/types.ts +22 -0
  35. package/src/platform/index.native.ts +4 -0
  36. package/src/platform/index.ts +4 -0
  37. package/src/platform/specs/OneNativeCameraNativeComponent.ts +35 -2
  38. package/src/router/router.ts +7 -4
  39. package/src/useHeaderHeight.native.ts +7 -0
  40. package/types/index.d.ts +1 -1
  41. package/types/index.d.ts.map +1 -1
  42. package/types/platform/camera/index.d.ts +3 -3
  43. package/types/platform/camera/index.d.ts.map +1 -1
  44. package/types/platform/camera/index.native.d.ts +3 -3
  45. package/types/platform/camera/index.native.d.ts.map +1 -1
  46. package/types/platform/camera/types.d.ts +18 -0
  47. package/types/platform/camera/types.d.ts.map +1 -1
  48. package/types/platform/index.d.ts +1 -1
  49. package/types/platform/index.d.ts.map +1 -1
  50. package/types/platform/index.native.d.ts +1 -1
  51. package/types/platform/index.native.d.ts.map +1 -1
  52. package/types/platform/specs/OneNativeCameraNativeComponent.d.ts +18 -2
  53. package/types/platform/specs/OneNativeCameraNativeComponent.d.ts.map +1 -1
  54. package/types/router/router.d.ts.map +1 -1
  55. package/types/useHeaderHeight.native.d.ts +2 -0
  56. package/types/useHeaderHeight.native.d.ts.map +1 -0
@@ -1,32 +1,36 @@
1
1
  var i = Object.defineProperty;
2
2
  var s = Object.getOwnPropertyDescriptor;
3
- var v = Object.getOwnPropertyNames;
4
- var m = Object.prototype.hasOwnProperty;
3
+ var m = Object.getOwnPropertyNames;
4
+ var c = Object.prototype.hasOwnProperty;
5
5
  var d = (t, e) => {
6
- for (var r in e)
7
- i(t, r, { get: e[r], enumerable: true });
6
+ for (var a in e)
7
+ i(t, a, { get: e[a], enumerable: true });
8
8
  };
9
- var p = (t, e, r, n) => {
9
+ var v = (t, e, a, o) => {
10
10
  if (e && typeof e === "object" || typeof e === "function") {
11
- for (let a of v(e))
12
- if (!m.call(t, a) && a !== r)
13
- i(t, a, { get: () => e[a], enumerable: !(n = s(e, a)) || n.enumerable });
11
+ for (let r of m(e))
12
+ if (!c.call(t, r) && r !== a)
13
+ i(t, r, { get: () => e[r], enumerable: !(o = s(e, r)) || o.enumerable });
14
14
  }
15
15
  return t;
16
16
  };
17
- var C = (t) => p(i({}, "__esModule", { value: true }), t);
18
- var y = {};
19
- d(y, {
20
- __INTERNAL_VIEW_CONFIG: () => o,
21
- default: () => l
17
+ var C = (t) => v(i({}, "__esModule", { value: true }), t);
18
+ var f = {};
19
+ d(f, {
20
+ Commands: () => y,
21
+ __INTERNAL_VIEW_CONFIG: () => n,
22
+ default: () => g
22
23
  });
23
- module.exports = C(y);
24
- const N = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
24
+ module.exports = C(f);
25
+ const p = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
25
26
  const {
26
- ConditionallyIgnoredEventHandlers: c
27
+ ConditionallyIgnoredEventHandlers: u
27
28
  } = require("react-native/Libraries/NativeComponent/ViewConfigIgnore");
28
- let g = "OneNativeCamera";
29
- const o = {
29
+ const {
30
+ dispatchCommand: N
31
+ } = require("react-native/Libraries/ReactNative/RendererProxy");
32
+ let l = "OneNativeCamera";
33
+ const n = {
30
34
  uiViewClassName: "OneNativeCamera",
31
35
  directEventTypes: {
32
36
  topNativeCameraState: {
@@ -34,16 +38,28 @@ const o = {
34
38
  },
35
39
  topNativeCameraCode: {
36
40
  registrationName: "onNativeCameraCode"
41
+ },
42
+ topNativeCameraPicture: {
43
+ registrationName: "onNativeCameraPicture"
37
44
  }
38
45
  },
39
46
  validAttributes: {
40
47
  active: true,
41
48
  facing: true,
42
49
  codeTypes: true,
43
- ...c({
50
+ flash: true,
51
+ enableTorch: true,
52
+ zoom: true,
53
+ ...u({
44
54
  onNativeCameraState: true,
45
- onNativeCameraCode: true
55
+ onNativeCameraCode: true,
56
+ onNativeCameraPicture: true
46
57
  })
47
58
  }
48
59
  };
49
- var l = N.get(g, () => o);
60
+ var g = p.get(l, () => n);
61
+ const y = {
62
+ takePicture(t, e, a, o) {
63
+ N(t, "takePicture", [e, a, o]);
64
+ }
65
+ };
@@ -1,32 +1,36 @@
1
1
  var i = Object.defineProperty;
2
2
  var s = Object.getOwnPropertyDescriptor;
3
- var v = Object.getOwnPropertyNames;
4
- var m = Object.prototype.hasOwnProperty;
3
+ var m = Object.getOwnPropertyNames;
4
+ var c = Object.prototype.hasOwnProperty;
5
5
  var d = (t, e) => {
6
- for (var r in e)
7
- i(t, r, { get: e[r], enumerable: true });
6
+ for (var a in e)
7
+ i(t, a, { get: e[a], enumerable: true });
8
8
  };
9
- var p = (t, e, r, n) => {
9
+ var v = (t, e, a, o) => {
10
10
  if (e && typeof e === "object" || typeof e === "function") {
11
- for (let a of v(e))
12
- if (!m.call(t, a) && a !== r)
13
- i(t, a, { get: () => e[a], enumerable: !(n = s(e, a)) || n.enumerable });
11
+ for (let r of m(e))
12
+ if (!c.call(t, r) && r !== a)
13
+ i(t, r, { get: () => e[r], enumerable: !(o = s(e, r)) || o.enumerable });
14
14
  }
15
15
  return t;
16
16
  };
17
- var C = (t) => p(i({}, "__esModule", { value: true }), t);
18
- var y = {};
19
- d(y, {
20
- __INTERNAL_VIEW_CONFIG: () => o,
21
- default: () => l
17
+ var C = (t) => v(i({}, "__esModule", { value: true }), t);
18
+ var f = {};
19
+ d(f, {
20
+ Commands: () => y,
21
+ __INTERNAL_VIEW_CONFIG: () => n,
22
+ default: () => g
22
23
  });
23
- module.exports = C(y);
24
- const N = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
24
+ module.exports = C(f);
25
+ const p = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
25
26
  const {
26
- ConditionallyIgnoredEventHandlers: c
27
+ ConditionallyIgnoredEventHandlers: u
27
28
  } = require("react-native/Libraries/NativeComponent/ViewConfigIgnore");
28
- let g = "OneNativeCamera";
29
- const o = {
29
+ const {
30
+ dispatchCommand: N
31
+ } = require("react-native/Libraries/ReactNative/RendererProxy");
32
+ let l = "OneNativeCamera";
33
+ const n = {
30
34
  uiViewClassName: "OneNativeCamera",
31
35
  directEventTypes: {
32
36
  topNativeCameraState: {
@@ -34,16 +38,28 @@ const o = {
34
38
  },
35
39
  topNativeCameraCode: {
36
40
  registrationName: "onNativeCameraCode"
41
+ },
42
+ topNativeCameraPicture: {
43
+ registrationName: "onNativeCameraPicture"
37
44
  }
38
45
  },
39
46
  validAttributes: {
40
47
  active: true,
41
48
  facing: true,
42
49
  codeTypes: true,
43
- ...c({
50
+ flash: true,
51
+ enableTorch: true,
52
+ zoom: true,
53
+ ...u({
44
54
  onNativeCameraState: true,
45
- onNativeCameraCode: true
55
+ onNativeCameraCode: true,
56
+ onNativeCameraPicture: true
46
57
  })
47
58
  }
48
59
  };
49
- var l = N.get(g, () => o);
60
+ var g = p.get(l, () => n);
61
+ const y = {
62
+ takePicture(t, e, a, o) {
63
+ N(t, "takePicture", [e, a, o]);
64
+ }
65
+ };
@@ -1,32 +1,36 @@
1
1
  var i = Object.defineProperty;
2
2
  var s = Object.getOwnPropertyDescriptor;
3
- var v = Object.getOwnPropertyNames;
4
- var m = Object.prototype.hasOwnProperty;
3
+ var m = Object.getOwnPropertyNames;
4
+ var c = Object.prototype.hasOwnProperty;
5
5
  var d = (t, e) => {
6
- for (var r in e)
7
- i(t, r, { get: e[r], enumerable: true });
6
+ for (var a in e)
7
+ i(t, a, { get: e[a], enumerable: true });
8
8
  };
9
- var p = (t, e, r, n) => {
9
+ var v = (t, e, a, o) => {
10
10
  if (e && typeof e === "object" || typeof e === "function") {
11
- for (let a of v(e))
12
- if (!m.call(t, a) && a !== r)
13
- i(t, a, { get: () => e[a], enumerable: !(n = s(e, a)) || n.enumerable });
11
+ for (let r of m(e))
12
+ if (!c.call(t, r) && r !== a)
13
+ i(t, r, { get: () => e[r], enumerable: !(o = s(e, r)) || o.enumerable });
14
14
  }
15
15
  return t;
16
16
  };
17
- var C = (t) => p(i({}, "__esModule", { value: true }), t);
18
- var y = {};
19
- d(y, {
20
- __INTERNAL_VIEW_CONFIG: () => o,
21
- default: () => l
17
+ var C = (t) => v(i({}, "__esModule", { value: true }), t);
18
+ var f = {};
19
+ d(f, {
20
+ Commands: () => y,
21
+ __INTERNAL_VIEW_CONFIG: () => n,
22
+ default: () => g
22
23
  });
23
- module.exports = C(y);
24
- const N = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
24
+ module.exports = C(f);
25
+ const p = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
25
26
  const {
26
- ConditionallyIgnoredEventHandlers: c
27
+ ConditionallyIgnoredEventHandlers: u
27
28
  } = require("react-native/Libraries/NativeComponent/ViewConfigIgnore");
28
- let g = "OneNativeCamera";
29
- const o = {
29
+ const {
30
+ dispatchCommand: N
31
+ } = require("react-native/Libraries/ReactNative/RendererProxy");
32
+ let l = "OneNativeCamera";
33
+ const n = {
30
34
  uiViewClassName: "OneNativeCamera",
31
35
  directEventTypes: {
32
36
  topNativeCameraState: {
@@ -34,17 +38,29 @@ const o = {
34
38
  },
35
39
  topNativeCameraCode: {
36
40
  registrationName: "onNativeCameraCode"
41
+ },
42
+ topNativeCameraPicture: {
43
+ registrationName: "onNativeCameraPicture"
37
44
  }
38
45
  },
39
46
  validAttributes: {
40
47
  active: true,
41
48
  facing: true,
42
49
  codeTypes: true,
43
- ...c({
50
+ flash: true,
51
+ enableTorch: true,
52
+ zoom: true,
53
+ ...u({
44
54
  onNativeCameraState: true,
45
- onNativeCameraCode: true
55
+ onNativeCameraCode: true,
56
+ onNativeCameraPicture: true
46
57
  })
47
58
  }
48
59
  };
49
- var l = N.get(g, () => o);
60
+ var g = p.get(l, () => n);
61
+ const y = {
62
+ takePicture(t, e, a, o) {
63
+ N(t, "takePicture", [e, a, o]);
64
+ }
65
+ };
50
66
  //# sourceMappingURL=OneNativeCameraNativeComponent.native.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/platform/specs/OneNativeCameraNativeComponent.ts"],
4
- "sourcesContent": ["import type { ViewProps } from 'react-native';\nimport type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ninterface NativeProps extends ViewProps {\n active: boolean;\n facing: string;\n codeTypes: ReadonlyArray<string>;\n onNativeCameraState?: DirectEventHandler<Readonly<{\n state: string;\n }>>;\n onNativeCameraCode?: DirectEventHandler<Readonly<{\n type: string;\n data: string;\n }>>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneNativeCamera';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneNativeCamera\",\n directEventTypes: {\n topNativeCameraState: {\n registrationName: \"onNativeCameraState\"\n },\n topNativeCameraCode: {\n registrationName: \"onNativeCameraCode\"\n }\n },\n validAttributes: {\n active: true,\n facing: true,\n codeTypes: true,\n ...ConditionallyIgnoredEventHandlers({\n onNativeCameraState: true,\n onNativeCameraCode: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA;AAAAC,EAAAD,GAAA;AAAA,gCAAAE;AAAA,EAAA,eAAAC;AAAA;AAAA,iBAAAC,EAAAJ;AAeA,MAAMK,IAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ,mCAAAC;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAIC,IAAsB;AACnB,MAAML,IAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,sBAAsB;AAAA,MACpB,kBAAkB;AAAA,IACpB;AAAA,IACA,qBAAqB;AAAA,MACnB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,GAAGI,EAAkC;AAAA,MACnC,qBAAqB;AAAA,MACrB,oBAAoB;AAAA,IACtB,CAAC;AAAA,EACH;AACF;AACA,IAAOH,IAAQE,EAAwB,IAAIE,GAAqB,MAAML,CAAsB;",
6
- "names": ["OneNativeCameraNativeComponent_exports", "__export", "__INTERNAL_VIEW_CONFIG", "OneNativeCameraNativeComponent_default", "__toCommonJS", "NativeComponentRegistry", "ConditionallyIgnoredEventHandlers", "nativeComponentName"]
4
+ "sourcesContent": ["import type { HostComponent, ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double, Int32 } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\nimport type * as React from 'react';\ninterface NativeProps extends ViewProps {\n active: boolean;\n facing: string;\n codeTypes: ReadonlyArray<string>;\n flash: string;\n enableTorch: boolean;\n zoom: Double;\n onNativeCameraState?: DirectEventHandler<Readonly<{\n state: string;\n }>>;\n onNativeCameraCode?: DirectEventHandler<Readonly<{\n type: string;\n data: string;\n }>>;\n // error is empty on success, otherwise \"<code>: <message>\".\n onNativeCameraPicture?: DirectEventHandler<Readonly<{\n requestId: Int32;\n uri: string;\n width: Int32;\n height: Int32;\n base64: string;\n error: string;\n }>>;\n}\ninterface NativeCommands {\n takePicture(viewRef: React.ElementRef<HostComponent<NativeProps>>, requestId: Int32, quality: Double, base64: boolean): void;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nconst {\n dispatchCommand\n} = require(\"react-native/Libraries/ReactNative/RendererProxy\");\nlet nativeComponentName = 'OneNativeCamera';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneNativeCamera\",\n directEventTypes: {\n topNativeCameraState: {\n registrationName: \"onNativeCameraState\"\n },\n topNativeCameraCode: {\n registrationName: \"onNativeCameraCode\"\n },\n topNativeCameraPicture: {\n registrationName: \"onNativeCameraPicture\"\n }\n },\n validAttributes: {\n active: true,\n facing: true,\n codeTypes: true,\n flash: true,\n enableTorch: true,\n zoom: true,\n ...ConditionallyIgnoredEventHandlers({\n onNativeCameraState: true,\n onNativeCameraCode: true,\n onNativeCameraPicture: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);\nexport const Commands = {\n takePicture(ref, requestId, quality, base64) {\n dispatchCommand(ref, \"takePicture\", [requestId, quality, base64]);\n }\n};"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA,IAAAA,IAAA;AAAAC,EAAAD,GAAA;AAAA,kBAAAE;AAAA,EAAA,8BAAAC;AAAA,EAAA,eAAAC;AAAA;AAAA,iBAAAC,EAAAL;AAgCA,MAAMM,IAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ,mCAAAC;AACF,IAAI,QAAQ,yDAAyD;AACrE,MAAM;AAAA,EACJ,iBAAAC;AACF,IAAI,QAAQ,kDAAkD;AAC9D,IAAIC,IAAsB;AACnB,MAAMN,IAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,sBAAsB;AAAA,MACpB,kBAAkB;AAAA,IACpB;AAAA,IACA,qBAAqB;AAAA,MACnB,kBAAkB;AAAA,IACpB;AAAA,IACA,wBAAwB;AAAA,MACtB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,IACN,GAAGI,EAAkC;AAAA,MACnC,qBAAqB;AAAA,MACrB,oBAAoB;AAAA,MACpB,uBAAuB;AAAA,IACzB,CAAC;AAAA,EACH;AACF;AACA,IAAOH,IAAQE,EAAwB,IAAIG,GAAqB,MAAMN,CAAsB;AACrF,MAAMD,IAAW;AAAA,EACtB,YAAYQ,GAAKC,GAAWC,GAASC,GAAQ;AAC3C,IAAAL,EAAgBE,GAAK,eAAe,CAACC,GAAWC,GAASC,CAAM,CAAC;AAAA,EAClE;AACF;",
6
+ "names": ["OneNativeCameraNativeComponent_exports", "__export", "Commands", "__INTERNAL_VIEW_CONFIG", "OneNativeCameraNativeComponent_default", "__toCommonJS", "NativeComponentRegistry", "ConditionallyIgnoredEventHandlers", "dispatchCommand", "nativeComponentName", "ref", "requestId", "quality", "base64"]
7
7
  }
@@ -640,7 +640,10 @@ function preloadRoute(href, injectCSS = false) {
640
640
  }
641
641
  return data;
642
642
  }, (err) => {
643
- if (injectCSS && process.env.ONE_SKEW_PROTECTION !== "false" && (0, import_dynamicImport.isChunkLoadError)(err) && (0, import_dynamicImport.handleSkewError)()) return new Promise(() => {});
643
+ if (injectCSS && process.env.ONE_SKEW_PROTECTION !== "false" && (0, import_dynamicImport.isChunkLoadError)(err)) {
644
+ window.location.href = href;
645
+ return new Promise(() => {});
646
+ }
644
647
  return null;
645
648
  });
646
649
  }
@@ -20,30 +20,12 @@ var __copyProps = (to, from, except, desc) => {
20
20
  return to;
21
21
  };
22
22
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var useHeaderHeight_exports = {};
24
- __export(useHeaderHeight_exports, { useHeaderHeight: () => useHeaderHeight });
25
- module.exports = __toCommonJS(useHeaderHeight_exports);
23
+ var useHeaderHeight_native_exports = {};
24
+ __export(useHeaderHeight_native_exports, { useHeaderHeight: () => useHeaderHeight });
25
+ module.exports = __toCommonJS(useHeaderHeight_native_exports);
26
+ var import_elements = require("@react-navigation/elements");
26
27
  var import_react = require("react");
27
- var contextsKey = "__react_navigation__elements_contexts";
28
- var contextName = "HeaderHeightContext";
29
- var headerHeightContext;
30
- function getHeaderHeightContext() {
31
- if (headerHeightContext) return headerHeightContext;
32
- var contexts = Reflect.get(globalThis, contextsKey);
33
- if (!contexts) {
34
- contexts = /* @__PURE__ */ new Map();
35
- Reflect.set(globalThis, contextsKey, contexts);
36
- }
37
- var context = contexts.get(contextName);
38
- if (!context) {
39
- context = (0, import_react.createContext)(void 0);
40
- context.displayName = contextName;
41
- contexts.set(contextName, context);
42
- }
43
- headerHeightContext = context;
44
- return context;
45
- }
46
28
  function useHeaderHeight() {
47
29
  var _useContext;
48
- return (_useContext = (0, import_react.useContext)(getHeaderHeightContext())) !== null && _useContext !== void 0 ? _useContext : 0;
30
+ return (_useContext = (0, import_react.useContext)(import_elements.HeaderHeightContext)) !== null && _useContext !== void 0 ? _useContext : 0;
49
31
  }
@@ -20,32 +20,14 @@ var __copyProps = (to, from, except, desc) => {
20
20
  return to;
21
21
  };
22
22
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var useHeaderHeight_exports = {};
24
- __export(useHeaderHeight_exports, { useHeaderHeight: () => useHeaderHeight });
25
- module.exports = __toCommonJS(useHeaderHeight_exports);
23
+ var useHeaderHeight_native_exports = {};
24
+ __export(useHeaderHeight_native_exports, { useHeaderHeight: () => useHeaderHeight });
25
+ module.exports = __toCommonJS(useHeaderHeight_native_exports);
26
+ var import_elements = require("@react-navigation/elements");
26
27
  var import_react = require("react");
27
- var contextsKey = "__react_navigation__elements_contexts";
28
- var contextName = "HeaderHeightContext";
29
- var headerHeightContext;
30
- function getHeaderHeightContext() {
31
- if (headerHeightContext) return headerHeightContext;
32
- var contexts = Reflect.get(globalThis, contextsKey);
33
- if (!contexts) {
34
- contexts = /* @__PURE__ */ new Map();
35
- Reflect.set(globalThis, contextsKey, contexts);
36
- }
37
- var context = contexts.get(contextName);
38
- if (!context) {
39
- context = (0, import_react.createContext)(void 0);
40
- context.displayName = contextName;
41
- contexts.set(contextName, context);
42
- }
43
- headerHeightContext = context;
44
- return context;
45
- }
46
28
  function useHeaderHeight() {
47
29
  var _useContext;
48
- return (_useContext = (0, import_react.useContext)(getHeaderHeightContext())) !== null && _useContext !== void 0 ? _useContext : 0;
30
+ return (_useContext = (0, import_react.useContext)(import_elements.HeaderHeightContext)) !== null && _useContext !== void 0 ? _useContext : 0;
49
31
  }
50
32
 
51
33
  //# sourceMappingURL=useHeaderHeight.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useHeaderHeight.native.js","names":[],"sources":["cjs/useHeaderHeight.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useHeaderHeight_exports = {};\n__export(useHeaderHeight_exports, {\n useHeaderHeight: () => useHeaderHeight\n});\nmodule.exports = __toCommonJS(useHeaderHeight_exports);\nvar import_react = require(\"react\");\nvar contextsKey = \"__react_navigation__elements_contexts\";\nvar contextName = \"HeaderHeightContext\";\nvar headerHeightContext;\nfunction getHeaderHeightContext() {\n if (headerHeightContext) return headerHeightContext;\n var contexts = Reflect.get(globalThis, contextsKey);\n if (!contexts) {\n contexts = /* @__PURE__ */ new Map();\n Reflect.set(globalThis, contextsKey, contexts);\n }\n var context = contexts.get(contextName);\n if (!context) {\n context = (0, import_react.createContext)(void 0);\n context.displayName = contextName;\n contexts.set(contextName, context);\n }\n headerHeightContext = context;\n return context;\n}\nfunction useHeaderHeight() {\n var _useContext;\n return (_useContext = (0, import_react.useContext)(getHeaderHeightContext())) !== null && _useContext !== void 0 ? _useContext : 0;\n}\n//# sourceMappingURL=useHeaderHeight.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,0BAA0B,CAAC;AAC/B,SAAS,yBAAyB,EAChC,uBAAuB,gBACzB,CAAC;AACD,OAAO,UAAU,aAAa,uBAAuB;AACrD,IAAI,eAAe,QAAQ,OAAO;AAClC,IAAI,cAAc;AAClB,IAAI,cAAc;AAClB,IAAI;AACJ,SAAS,yBAAyB;CAChC,IAAI,qBAAqB,OAAO;CAChC,IAAI,WAAW,QAAQ,IAAI,YAAY,WAAW;CAClD,IAAI,CAAC,UAAU;EACb,2BAA2B,IAAI,IAAI;EACnC,QAAQ,IAAI,YAAY,aAAa,QAAQ;CAC/C;CACA,IAAI,UAAU,SAAS,IAAI,WAAW;CACtC,IAAI,CAAC,SAAS;EACZ,WAAW,GAAG,aAAa,cAAa,CAAE,KAAK,CAAC;EAChD,QAAQ,cAAc;EACtB,SAAS,IAAI,aAAa,OAAO;CACnC;CACA,sBAAsB;CACtB,OAAO;AACT;AACA,SAAS,kBAAkB;CACzB,IAAI;CACJ,QAAQ,eAAe,GAAG,aAAa,WAAU,CAAE,uBAAuB,CAAC,OAAO,QAAQ,gBAAgB,KAAK,IAAI,cAAc;AACnI"}
1
+ {"version":3,"file":"useHeaderHeight.native.js","names":[],"sources":["cjs/useHeaderHeight.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useHeaderHeight_native_exports = {};\n__export(useHeaderHeight_native_exports, {\n useHeaderHeight: () => useHeaderHeight\n});\nmodule.exports = __toCommonJS(useHeaderHeight_native_exports);\nvar import_elements = require(\"@react-navigation/elements\");\nvar import_react = require(\"react\");\nfunction useHeaderHeight() {\n var _useContext;\n return (_useContext = (0, import_react.useContext)(import_elements.HeaderHeightContext)) !== null && _useContext !== void 0 ? _useContext : 0;\n}\n//# sourceMappingURL=useHeaderHeight.native.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,iCAAiC,CAAC;AACtC,SAAS,gCAAgC,EACvC,uBAAuB,gBACzB,CAAC;AACD,OAAO,UAAU,aAAa,8BAA8B;AAC5D,IAAI,kBAAkB,QAAQ,4BAA4B;AAC1D,IAAI,eAAe,QAAQ,OAAO;AAClC,SAAS,kBAAkB;CACzB,IAAI;CACJ,QAAQ,eAAe,GAAG,aAAa,WAAU,CAAE,gBAAgB,mBAAmB,OAAO,QAAQ,gBAAgB,KAAK,IAAI,cAAc;AAC9I"}
@@ -1,6 +1,8 @@
1
- function CameraView(_props) {
1
+ import { forwardRef } from "react";
2
+
3
+ const CameraView = forwardRef(function CameraView2() {
2
4
  throw new Error("CameraView requires a native build");
3
- }
5
+ });
4
6
 
5
7
  export { CameraView };
6
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["esm/platform/camera/index.js"],"sourcesContent":["function CameraView(_props) {\n throw new Error(\"CameraView requires a native build\");\n}\nexport {\n CameraView\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";AAAA,SAAS,WAAW,QAAQ;CAC1B,MAAM,IAAI,MAAM,oCAAoC;AACtD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["esm/platform/camera/index.js"],"sourcesContent":["import { forwardRef } from \"react\";\nconst CameraView = forwardRef(function CameraView2() {\n throw new Error(\"CameraView requires a native build\");\n});\nexport {\n CameraView\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,MAAM,aAAa,WAAW,SAAS,cAAc;CACnD,MAAM,IAAI,MAAM,oCAAoC;AACtD,CAAC"}
@@ -1,7 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
2
3
  import { Platform } from "react-native";
3
- import NativeCamera from "../specs/OneNativeCameraNativeComponent.native.js";
4
+ import NativeCamera, { Commands } from "../specs/OneNativeCameraNativeComponent.native.js";
4
5
 
6
+ var nextRequestId = 1;
7
+ function codedError(code, message) {
8
+ return Object.assign(new Error(message), { code });
9
+ }
10
+ function nativeError(value) {
11
+ var coded = /^((?:E|ERR)_[A-Z0-9_]+): ([\s\S]*)$/.exec(value);
12
+ return coded ? codedError(coded[1], coded[2]) : new Error(value);
13
+ }
5
14
  function cameraState(value) {
6
15
  switch (value) {
7
16
  case "inactive":
@@ -32,8 +41,8 @@ function codeType(value) {
32
41
  if (!isCodeType(value)) throw new Error(`CameraView received an unknown code type: ${value}`);
33
42
  return value;
34
43
  }
35
- function CameraView(param) {
36
- var { active = true, facing = "back", codeTypes = ["qr"], onStateChange, onCodeScanned, ...viewProps } = param;
44
+ var CameraView = /* @__PURE__ */ forwardRef(function CameraView2(param, ref) {
45
+ var { active = true, facing = "back", codeTypes = ["qr"], flash = "off", enableTorch = false, zoom = 0, onStateChange, onCodeScanned, ...viewProps } = param;
37
46
  if (Platform.OS !== "ios" && Platform.OS !== "android") throw new Error("CameraView requires a native build");
38
47
  if (typeof active !== "boolean") throw new TypeError("CameraView.active must be a boolean");
39
48
  if (facing !== "back" && facing !== "front") {
@@ -44,11 +53,71 @@ function CameraView(param) {
44
53
  })) {
45
54
  throw new TypeError("CameraView.codeTypes contains an unsupported code type");
46
55
  }
56
+ if (flash !== "off" && flash !== "on" && flash !== "auto") {
57
+ throw new TypeError("CameraView.flash must be off, on or auto");
58
+ }
59
+ if (typeof enableTorch !== "boolean") {
60
+ throw new TypeError("CameraView.enableTorch must be a boolean");
61
+ }
62
+ if (typeof zoom !== "number" || !(zoom >= 0 && zoom <= 1)) {
63
+ throw new RangeError("CameraView.zoom must be a number from 0 to 1");
64
+ }
65
+ var nativeRef = useRef(null);
66
+ var pending = useRef(/* @__PURE__ */ new Map());
67
+ useEffect(function() {
68
+ var requests = pending.current;
69
+ return function() {
70
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
71
+ try {
72
+ for (var _iterator = requests.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
73
+ var request = _step.value;
74
+ request.reject(codedError("E_CAMERA_UNMOUNTED", "CameraView unmounted before the picture was taken"));
75
+ }
76
+ } catch (err) {
77
+ _didIteratorError = true;
78
+ _iteratorError = err;
79
+ } finally {
80
+ try {
81
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
82
+ _iterator.return();
83
+ }
84
+ } finally {
85
+ if (_didIteratorError) {
86
+ throw _iteratorError;
87
+ }
88
+ }
89
+ }
90
+ requests.clear();
91
+ };
92
+ }, []);
93
+ useImperativeHandle(ref, function() {
94
+ return { takePicture() {
95
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
96
+ var { quality = 1, base64 = false } = options;
97
+ if (typeof quality !== "number" || !(quality >= 0 && quality <= 1)) return Promise.reject(new RangeError("takePicture quality must be a number from 0 to 1"));
98
+ if (typeof base64 !== "boolean") return Promise.reject(new TypeError("takePicture base64 must be a boolean"));
99
+ var view = nativeRef.current;
100
+ if (!view) return Promise.reject(codedError("E_CAMERA_UNMOUNTED", "CameraView is not mounted"));
101
+ var requestId = nextRequestId++;
102
+ return new Promise(function(resolve, reject) {
103
+ pending.current.set(requestId, {
104
+ resolve,
105
+ reject,
106
+ base64
107
+ });
108
+ Commands.takePicture(view, requestId, quality, base64);
109
+ });
110
+ } };
111
+ }, []);
47
112
  return /* @__PURE__ */ jsx(NativeCamera, {
48
113
  ...viewProps,
114
+ ref: nativeRef,
49
115
  active,
50
116
  facing,
51
117
  codeTypes: [...new Set(codeTypes)],
118
+ flash,
119
+ enableTorch,
120
+ zoom,
52
121
  onNativeCameraState: function onNativeCameraState(param2) {
53
122
  var { nativeEvent } = param2;
54
123
  return onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(cameraState(nativeEvent.state));
@@ -59,9 +128,26 @@ function CameraView(param) {
59
128
  type: codeType(nativeEvent.type),
60
129
  data: nativeEvent.data
61
130
  });
131
+ },
132
+ onNativeCameraPicture: function onNativeCameraPicture(param2) {
133
+ var { nativeEvent } = param2;
134
+ var request = pending.current.get(nativeEvent.requestId);
135
+ if (!request) return;
136
+ pending.current.delete(nativeEvent.requestId);
137
+ if (nativeEvent.error) {
138
+ request.reject(nativeError(nativeEvent.error));
139
+ return;
140
+ }
141
+ request.resolve({
142
+ uri: nativeEvent.uri,
143
+ width: nativeEvent.width,
144
+ height: nativeEvent.height,
145
+ format: "jpg",
146
+ ...request.base64 ? { base64: nativeEvent.base64 } : {}
147
+ });
62
148
  }
63
149
  });
64
- }
150
+ });
65
151
 
66
152
  export { CameraView };
67
153
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.js","names":[],"sources":["esm/platform/camera/index.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { Platform } from \"react-native\";\nimport NativeCamera from \"../specs/OneNativeCameraNativeComponent\";\nfunction cameraState(value) {\n switch (value) {\n case \"inactive\":\n case \"permission-required\":\n case \"unavailable\":\n case \"ready\":\n case \"unsupported\":\n case \"failed\":\n return value;\n default:\n throw new Error(`CameraView received an unknown native state: ${value}`);\n }\n}\nfunction isCodeType(value) {\n switch (value) {\n case \"qr\":\n case \"ean13\":\n case \"ean8\":\n case \"upce\":\n case \"code128\":\n case \"code39\":\n case \"code93\":\n case \"pdf417\":\n case \"aztec\":\n case \"dataMatrix\":\n return true;\n default:\n return false;\n }\n}\nfunction codeType(value) {\n if (!isCodeType(value)) throw new Error(`CameraView received an unknown code type: ${value}`);\n return value;\n}\nfunction CameraView(param) {\n var { active = true, facing = \"back\", codeTypes = [\n \"qr\"\n ], onStateChange, onCodeScanned, ...viewProps } = param;\n if (Platform.OS !== \"ios\" && Platform.OS !== \"android\") throw new Error(\"CameraView requires a native build\");\n if (typeof active !== \"boolean\") throw new TypeError(\"CameraView.active must be a boolean\");\n if (facing !== \"back\" && facing !== \"front\") {\n throw new TypeError(\"CameraView.facing must be back or front\");\n }\n if (!Array.isArray(codeTypes) || codeTypes.some(function(type) {\n return !isCodeType(type);\n })) {\n throw new TypeError(\"CameraView.codeTypes contains an unsupported code type\");\n }\n return /* @__PURE__ */ _jsx(NativeCamera, {\n ...viewProps,\n active,\n facing,\n codeTypes: [\n ...new Set(codeTypes)\n ],\n onNativeCameraState: function onNativeCameraState(param2) {\n var { nativeEvent } = param2;\n return onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(cameraState(nativeEvent.state));\n },\n onNativeCameraCode: function onNativeCameraCode(param2) {\n var { nativeEvent } = param2;\n return onCodeScanned === null || onCodeScanned === void 0 ? void 0 : onCodeScanned({\n type: codeType(nativeEvent.type),\n data: nativeEvent.data\n });\n }\n });\n}\nexport {\n CameraView\n};\n//# sourceMappingURL=index.native.js.map\n"],"mappings":";;;;;AAGA,SAAS,YAAY,OAAO;CAC1B,QAAQ,OAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,gDAAgD,OAAO;CAC3E;AACF;AACA,SAA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{"version":3,"file":"index.native.js","names":[],"sources":["esm/platform/camera/index.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { Platform } from \"react-native\";\nimport NativeCamera, { Commands } from \"../specs/OneNativeCameraNativeComponent\";\nvar nextRequestId = 1;\nfunction codedError(code, message) {\n return Object.assign(new Error(message), {\n code\n });\n}\nfunction nativeError(value) {\n var coded = /^((?:E|ERR)_[A-Z0-9_]+): ([\\s\\S]*)$/.exec(value);\n return coded ? codedError(coded[1], coded[2]) : new Error(value);\n}\nfunction cameraState(value) {\n switch (value) {\n case \"inactive\":\n case \"permission-required\":\n case \"unavailable\":\n case \"ready\":\n case \"unsupported\":\n case \"failed\":\n return value;\n default:\n throw new Error(`CameraView received an unknown native state: ${value}`);\n }\n}\nfunction isCodeType(value) {\n switch (value) {\n case \"qr\":\n case \"ean13\":\n case \"ean8\":\n case \"upce\":\n case \"code128\":\n case \"code39\":\n case \"code93\":\n case \"pdf417\":\n case \"aztec\":\n case \"dataMatrix\":\n return true;\n default:\n return false;\n }\n}\nfunction codeType(value) {\n if (!isCodeType(value)) throw new Error(`CameraView received an unknown code type: ${value}`);\n return value;\n}\nvar CameraView = /* @__PURE__ */ forwardRef(function CameraView2(param, ref) {\n var { active = true, facing = \"back\", codeTypes = [\n \"qr\"\n ], flash = \"off\", enableTorch = false, zoom = 0, onStateChange, onCodeScanned, ...viewProps } = param;\n if (Platform.OS !== \"ios\" && Platform.OS !== \"android\") throw new Error(\"CameraView requires a native build\");\n if (typeof active !== \"boolean\") throw new TypeError(\"CameraView.active must be a boolean\");\n if (facing !== \"back\" && facing !== \"front\") {\n throw new TypeError(\"CameraView.facing must be back or front\");\n }\n if (!Array.isArray(codeTypes) || codeTypes.some(function(type) {\n return !isCodeType(type);\n })) {\n throw new TypeError(\"CameraView.codeTypes contains an unsupported code type\");\n }\n if (flash !== \"off\" && flash !== \"on\" && flash !== \"auto\") {\n throw new TypeError(\"CameraView.flash must be off, on or auto\");\n }\n if (typeof enableTorch !== \"boolean\") {\n throw new TypeError(\"CameraView.enableTorch must be a boolean\");\n }\n if (typeof zoom !== \"number\" || !(zoom >= 0 && zoom <= 1)) {\n throw new RangeError(\"CameraView.zoom must be a number from 0 to 1\");\n }\n var nativeRef = useRef(null);\n var pending = useRef(/* @__PURE__ */ new Map());\n useEffect(function() {\n var requests = pending.current;\n return function() {\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = requests.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var request = _step.value;\n request.reject(codedError(\"E_CAMERA_UNMOUNTED\", \"CameraView unmounted before the picture was taken\"));\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n requests.clear();\n };\n }, []);\n useImperativeHandle(ref, function() {\n return {\n takePicture() {\n var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var { quality = 1, base64 = false } = options;\n if (typeof quality !== \"number\" || !(quality >= 0 && quality <= 1)) return Promise.reject(new RangeError(\"takePicture quality must be a number from 0 to 1\"));\n if (typeof base64 !== \"boolean\") return Promise.reject(new TypeError(\"takePicture base64 must be a boolean\"));\n var view = nativeRef.current;\n if (!view) return Promise.reject(codedError(\"E_CAMERA_UNMOUNTED\", \"CameraView is not mounted\"));\n var requestId = nextRequestId++;\n return new Promise(function(resolve, reject) {\n pending.current.set(requestId, {\n resolve,\n reject,\n base64\n });\n Commands.takePicture(view, requestId, quality, base64);\n });\n }\n };\n }, []);\n return /* @__PURE__ */ _jsx(NativeCamera, {\n ...viewProps,\n ref: nativeRef,\n active,\n facing,\n codeTypes: [\n ...new Set(codeTypes)\n ],\n flash,\n enableTorch,\n zoom,\n onNativeCameraState: function onNativeCameraState(param2) {\n var { nativeEvent } = param2;\n return onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(cameraState(nativeEvent.state));\n },\n onNativeCameraCode: function onNativeCameraCode(param2) {\n var { nativeEvent } = param2;\n return onCodeScanned === null || onCodeScanned === void 0 ? void 0 : onCodeScanned({\n type: codeType(nativeEvent.type),\n data: nativeEvent.data\n });\n },\n onNativeCameraPicture: function onNativeCameraPicture(param2) {\n var { nativeEvent } = param2;\n var request = pending.current.get(nativeEvent.requestId);\n if (!request) return;\n pending.current.delete(nativeEvent.requestId);\n if (nativeEvent.error) {\n request.reject(nativeError(nativeEvent.error));\n return;\n }\n request.resolve({\n uri: nativeEvent.uri,\n width: nativeEvent.width,\n height: nativeEvent.height,\n format: \"jpg\",\n ...request.base64 ? {\n base64: nativeEvent.base64\n } : {}\n });\n }\n });\n});\nexport {\n CameraView\n};\n//# sourceMappingURL=index.native.js.map\n"],"mappings":";;;;;;AAIA,IAAI,gBAAgB;AACpB,SAAS,WAAW,MAAM,SAAS;CACjC,OAAO,OAAO,OAAO,IAAI,MAAM,OAAO,GAAG,EACvC,KACF,CAAC;AACH;AACA,SAAS,YAAY,OAAO;CAC1B,IAAI,QAAQ,sCAAsC,KAAK,KAAK;CAC5D,OAAO,QAAQ,WAAW,MAAM,IAAI,MAAM,EAAE,IAAI,IAAI,MAAM,KAAK;AACjE;AACA,SAAS,YAAY,OAAO;CAC1B,QAAQ,OAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACH,OAAO;EACT,SACE,MAAM,IAAI,MAAM,gDAAgD,OAAO;CAC3E;AACF;AACA,SAAS,WAAW,OAAO;CACzB,QAAQ,OAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,cACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AACA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IAAI,cAAc,YAAY,YAAY,KAAK,CAAC;EACnH;EACA,oBAAoB,SAAS,mBAAmB,QAAQ;GACtD,IAAI,EAAE,gBAAgB;GACtB,OAAO,kBAAkB,QAAQ,kBAAkB,KAAK,IAAI,KAAK,IAAI,cAAc;IACjF,MAAM,SAAS,YAAY,IAAI;IAC/B,MAAM,YAAY;GACpB,CAAC;EACH;EACA,uBAAuB,SAAS,sBAAsB,QAAQ;GAC5D,IAAI,EAAE,gBAAgB;GACtB,IAAI,UAAU,QAAQ,QAAQ,IAAI,YAAY,SAAS;GACvD,IAAI,CAAC,SAAS;GACd,QAAQ,QAAQ,OAAO,YAAY,SAAS;GAC5C,IAAI,YAAY,OAAO;IACrB,QAAQ,OAAO,YAAY,YAAY,KAAK,CAAC;IAC7C;GACF;GACA,QAAQ,QAAQ;IACd,KAAK,YAAY;IACjB,OAAO,YAAY;IACnB,QAAQ,YAAY;IACpB,QAAQ;IACR,GAAG,QAAQ,SAAS,EAClB,QAAQ,YAAY,OACtB,IAAI,CAAC;GACP,CAAC;EACH;CACF,CAAC;AACH,CAAC"}
@@ -1,9 +1,12 @@
1
- const e = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
1
+ const o = require("react-native/Libraries/NativeComponent/NativeComponentRegistry");
2
2
  const {
3
- ConditionallyIgnoredEventHandlers: t
3
+ ConditionallyIgnoredEventHandlers: i
4
4
  } = require("react-native/Libraries/NativeComponent/ViewConfigIgnore");
5
- let a = "OneNativeCamera";
6
- const r = {
5
+ const {
6
+ dispatchCommand: n
7
+ } = require("react-native/Libraries/ReactNative/RendererProxy");
8
+ let s = "OneNativeCamera";
9
+ const m = {
7
10
  uiViewClassName: "OneNativeCamera",
8
11
  directEventTypes: {
9
12
  topNativeCameraState: {
@@ -11,21 +14,34 @@ const r = {
11
14
  },
12
15
  topNativeCameraCode: {
13
16
  registrationName: "onNativeCameraCode"
17
+ },
18
+ topNativeCameraPicture: {
19
+ registrationName: "onNativeCameraPicture"
14
20
  }
15
21
  },
16
22
  validAttributes: {
17
23
  active: true,
18
24
  facing: true,
19
25
  codeTypes: true,
20
- ...t({
26
+ flash: true,
27
+ enableTorch: true,
28
+ zoom: true,
29
+ ...i({
21
30
  onNativeCameraState: true,
22
- onNativeCameraCode: true
31
+ onNativeCameraCode: true,
32
+ onNativeCameraPicture: true
23
33
  })
24
34
  }
25
35
  };
26
- var o = e.get(a, () => r);
36
+ var p = o.get(s, () => m);
37
+ const u = {
38
+ takePicture(e, t, a, r) {
39
+ n(e, "takePicture", [t, a, r]);
40
+ }
41
+ };
27
42
  export {
28
- r as __INTERNAL_VIEW_CONFIG,
29
- o as default
43
+ u as Commands,
44
+ m as __INTERNAL_VIEW_CONFIG,
45
+ p as default
30
46
  };
31
47
  //# sourceMappingURL=OneNativeCameraNativeComponent.mjs.map