@mpxjs/webpack-plugin 2.10.16-beta.7 → 2.10.16-beta.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.
@@ -10,6 +10,7 @@ export type KeyboardAvoidContextValue = MutableRefObject<{
10
10
  cursorSpacing: number
11
11
  ref: MutableRefObject<any>
12
12
  adjustPosition: boolean
13
+ holdKeyboard?: boolean
13
14
  keyboardHeight?: number
14
15
  onKeyboardShow?: () => void
15
16
  } | null>
@@ -7,6 +7,7 @@ export type KeyboardAvoidContextValue = MutableRefObject<{
7
7
  cursorSpacing: number;
8
8
  ref: MutableRefObject<any>;
9
9
  adjustPosition: boolean;
10
+ holdKeyboard?: boolean;
10
11
  keyboardHeight?: number;
11
12
  onKeyboardShow?: () => void;
12
13
  } | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG7D,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC/C,aAAa,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,KAAK,IAAI,CAAA;CAC/D,CAAC,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,gBAAgB,CAAC;IACvD,aAAa,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAA;IAC1B,cAAc,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAC5B,GAAG,IAAI,CAAC,CAAA;AAET,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;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import { Camera } from 'react-native-vision-camera';
3
2
  interface CameraProps {
4
3
  mode?: 'normal' | 'scanCode';
5
4
  resolution?: 'low' | 'medium' | 'high';
@@ -23,6 +22,6 @@ interface CameraProps {
23
22
  type HandlerRef<T, P> = {
24
23
  current: T | null;
25
24
  };
26
- declare const _camera: React.ForwardRefExoticComponent<CameraProps & React.RefAttributes<HandlerRef<Camera, CameraProps>>>;
25
+ declare const _camera: React.ForwardRefExoticComponent<CameraProps & React.RefAttributes<HandlerRef<any, CameraProps>>>;
27
26
  export default _camera;
28
27
  //# sourceMappingURL=mpx-camera.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mpx-camera.d.ts","sourceRoot":"","sources":["../mpx-camera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2E,MAAM,OAAO,CAAA;AAC/F,OAAO,EAAE,MAAM,EAAuE,MAAM,4BAA4B,CAAA;AAIxH,UAAU,WAAW;IACnB,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAA;IAC5B,UAAU,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;IACtC,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAAA;IAC7B,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAChD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAC/D,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;Q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B,CAAA;AAID,QAAA,MAAM,OAAO,kGAkNX,CAAA;AAIF,eAAe,OAAO,CAAA"}
@@ -1,8 +1,18 @@
1
1
  import React, { forwardRef, useRef, useCallback, useContext, useState, useEffect } from 'react';
2
- import { Camera, useCameraDevice, useCodeScanner, useCameraFormat } from 'react-native-vision-camera';
2
+ // import { Camera, useCameraDevice, useCodeScanner, useCameraFormat } from 'react-native-vision-camera'
3
3
  import { getCustomEvent } from './getInnerListeners';
4
+ import { noop } from '@mpxjs/utils';
4
5
  import { RouteContext } from './context';
6
+ const qualityValue = {
7
+ high: 90,
8
+ normal: 75,
9
+ low: 50,
10
+ original: 100
11
+ };
12
+ let RecordRes = null;
5
13
  const _camera = forwardRef((props, ref) => {
14
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
15
+ const { Camera, useCameraDevice, useCodeScanner, useCameraFormat } = require('react-native-vision-camera');
6
16
  const cameraRef = useRef(null);
7
17
  const { mode = 'normal', resolution = 'medium', devicePosition = 'back', flash = 'auto', frameSize = 'medium', bindinitdone, bindstop, bindscancode } = props;
8
18
  const isPhoto = mode === 'normal';
@@ -10,6 +20,7 @@ const _camera = forwardRef((props, ref) => {
10
20
  const { navigation } = useContext(RouteContext) || {};
11
21
  const [zoomValue, setZoomValue] = useState(1);
12
22
  const [hasPermission, setHasPermission] = useState(null);
23
+ const hasCamera = useRef(false);
13
24
  // 先定义常量,避免在条件判断后使用
14
25
  const maxZoom = device?.maxZoom || 1;
15
26
  const RESOLUTION_MAPPING = {
@@ -50,8 +61,116 @@ const _camera = forwardRef((props, ref) => {
50
61
  const onStopped = useCallback(() => {
51
62
  bindstop && bindstop();
52
63
  }, [bindstop]);
53
- // 检查相机权限
64
+ const camera = {
65
+ setZoom: (zoom) => {
66
+ setZoomValue(zoom);
67
+ },
68
+ takePhoto: (options = {}) => {
69
+ const { success = noop, fail = noop, complete = noop } = options;
70
+ cameraRef.current?.takePhoto?.({
71
+ quality: qualityValue[options.quality || 'normal']
72
+ }).then((res) => {
73
+ const result = {
74
+ errMsg: 'takePhoto:ok',
75
+ tempImagePath: res.path
76
+ };
77
+ success(result);
78
+ complete(result);
79
+ }).catch(() => {
80
+ const result = {
81
+ errMsg: 'takePhoto:fail'
82
+ };
83
+ fail(result);
84
+ complete(result);
85
+ });
86
+ },
87
+ startRecord: (options = {}) => {
88
+ let { timeout = 30, success = noop, fail = noop, complete = noop, timeoutCallback = noop } = options;
89
+ timeout = timeout > 300 ? 300 : timeout;
90
+ let recordTimer = null;
91
+ let isTimeout = false;
92
+ try {
93
+ const result = {
94
+ errMsg: 'startRecord:ok'
95
+ };
96
+ success(result);
97
+ complete(result);
98
+ cameraRef.current?.startRecording?.({
99
+ onRecordingError: (error) => {
100
+ if (recordTimer)
101
+ clearTimeout(recordTimer);
102
+ const errorResult = {
103
+ errMsg: 'startRecord:fail during recording',
104
+ error: error
105
+ };
106
+ timeoutCallback(errorResult);
107
+ },
108
+ onRecordingFinished: (video) => {
109
+ RecordRes = video;
110
+ if (recordTimer)
111
+ clearTimeout(recordTimer);
112
+ }
113
+ });
114
+ recordTimer = setTimeout(() => {
115
+ isTimeout = true;
116
+ cameraRef.current?.stopRecording().catch(() => {
117
+ // 忽略停止录制时的错误
118
+ });
119
+ }, timeout * 1000);
120
+ }
121
+ catch (error) {
122
+ if (recordTimer)
123
+ clearTimeout(recordTimer);
124
+ const result = {
125
+ errMsg: 'startRecord:fail ' + (error.message || 'unknown error')
126
+ };
127
+ fail(result);
128
+ complete(result);
129
+ }
130
+ },
131
+ stopRecord: (options = {}) => {
132
+ const { success = noop, fail = noop, complete = noop } = options;
133
+ try {
134
+ cameraRef.current?.stopRecording().then(() => {
135
+ setTimeout(() => {
136
+ if (RecordRes) {
137
+ const result = {
138
+ errMsg: 'stopRecord:ok',
139
+ tempVideoPath: RecordRes?.path,
140
+ duration: RecordRes.duration * 1000 // 转成ms
141
+ };
142
+ RecordRes = null;
143
+ success(result);
144
+ complete(result);
145
+ }
146
+ }, 200); // 延时200ms,确保录制结果已准备好
147
+ }).catch((e) => {
148
+ const result = {
149
+ errMsg: 'stopRecord:fail ' + (e.message || 'promise rejected')
150
+ };
151
+ fail(result);
152
+ complete(result);
153
+ });
154
+ }
155
+ catch (error) {
156
+ const result = {
157
+ errMsg: 'stopRecord:fail ' + (error.message || 'unknown error')
158
+ };
159
+ fail(result);
160
+ complete(result);
161
+ }
162
+ }
163
+ };
54
164
  useEffect(() => {
165
+ if (navigation) {
166
+ if (navigation && !navigation.camera) {
167
+ navigation.camera = camera;
168
+ }
169
+ else {
170
+ hasCamera.current = true;
171
+ navigation.camera.multi = true;
172
+ }
173
+ }
55
174
  const checkCameraPermission = async () => {
56
175
  try {
57
176
  const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission;
@@ -69,34 +188,10 @@ const _camera = forwardRef((props, ref) => {
69
188
  };
70
189
  checkCameraPermission();
71
190
  }, []);
72
- const camera = {
73
- setZoom: (zoom) => {
74
- setZoomValue(zoom);
75
- },
76
- getTakePhoto: () => {
77
- return cameraRef.current?.takePhoto;
78
- },
79
- getStartRecord: () => {
80
- return cameraRef.current?.startRecording;
81
- },
82
- getStopRecord: () => {
83
- return cameraRef.current?.stopRecording;
84
- }
85
- };
86
- if (navigation) {
87
- navigation.camera = camera;
88
- }
89
- // 所有 Hooks 调用完成后再进行条件判断
90
- if (hasPermission === null) {
91
- return null;
92
- }
93
- if (!hasPermission) {
94
- return null;
95
- }
96
- if (!device) {
191
+ if (!hasPermission || hasCamera.current || !device) {
97
192
  return null;
98
193
  }
99
- return (<Camera ref={cameraRef} isActive={true} photo={isPhoto} video={true} onInitialized={onInitialized} onStopped={onStopped} device={device} flash={flash} format={format} codeScanner={!isPhoto ? codeScanner : undefined} style={{ flex: 1 }} zoom={zoomValue} {...props}/>);
194
+ return (<Camera ref={cameraRef} isActive={true} photo={true} video={true} onInitialized={onInitialized} onStopped={onStopped} device={device} flash={flash} format={format} codeScanner={!isPhoto ? codeScanner : undefined} style={{ flex: 1 }} zoom={zoomValue} {...props}/>);
100
195
  });
101
196
  _camera.displayName = 'MpxCamera';
102
197
  export default _camera;
@@ -32,6 +32,7 @@ export interface InputProps {
32
32
  'parent-width'?: number;
33
33
  'parent-height'?: number;
34
34
  'adjust-position': boolean;
35
+ 'hold-keyboard'?: boolean;
35
36
  bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void;
36
37
  bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void;
37
38
  bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"mpx-input.d.ts","sourceRoot":"","sources":["../mpx-input.tsx"],"names":[],"mappings":";AAwCA,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,SAAS,EACT,iCAAiC,EACjC,uBAAuB,EAEvB,+BAA+B,EAEhC,MAAM,cAAc,CAAA;AAIrB,OAAoB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvD,KAAK,UAAU,GAAG,IAAI,CACpB,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAClD,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,mBAAmB,GACnB,qBAAqB,GACrB,sBAAsB,GACtB,yBAAyB,GACzB,wBAAwB,CAC3B,CAAA;AAED,KAAK,IAAI,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAA;AAElD,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAA;AAExE,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE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F,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IAClF,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IACjF,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,+BAA+B,GAAG,0BAA0B,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;IACzH,mBAAmB,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,iCAAiC,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACvG;AAED,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,mCAAmC,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACpG;AAED,KAAK,eAAe,GAAG,UAAU,GAAG,iBAAiB,CAAA;AASrD,QAAA,MAAM,KAAK,mJAwYT,CAAA;AAIF,eAAe,KAAK,CAAA"}
@@ -18,7 +18,7 @@
18
18
  * ✔ selection-start
19
19
  * ✔ selection-end
20
20
  * ✔ adjust-position
21
- * hold-keyboard
21
+ * hold-keyboard
22
22
  * ✘ safe-password-cert-path
23
23
  * ✘ safe-password-length
24
24
  * ✘ safe-password-time-stamp
@@ -52,7 +52,7 @@ const keyboardTypeMap = {
52
52
  digit: isIOS ? 'decimal-pad' : 'numeric'
53
53
  };
54
54
  const Input = forwardRef((props, ref) => {
55
- const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
55
+ const { style = {}, allowFontScaling = false, type = 'text', value, password, 'placeholder-style': placeholderStyle = {}, disabled, maxlength = 140, 'cursor-spacing': cursorSpacing = 0, 'auto-focus': autoFocus, focus, 'confirm-type': confirmType = 'done', 'confirm-hold': confirmHold = false, cursor, 'cursor-color': cursorColor, 'selection-start': selectionStart = -1, 'selection-end': selectionEnd = -1, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'adjust-position': adjustPosition = true, 'hold-keyboard': holdKeyboard = false, bindinput, bindfocus, bindblur, bindconfirm, bindselectionchange,
56
56
  // private
57
57
  multiline, 'auto-height': autoHeight, bindlinechange } = props;
58
58
  const formContext = useContext(FormContext);
@@ -145,7 +145,7 @@ const Input = forwardRef((props, ref) => {
145
145
  };
146
146
  const setKeyboardAvoidContext = () => {
147
147
  if (keyboardAvoid) {
148
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition };
148
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard };
149
149
  }
150
150
  };
151
151
  const onTouchStart = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"mpx-keyboard-avoiding-view.d.ts","sourceRoot":"","sources":["../mpx-keyboard-avoiding-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAA;AACvE,OAAO,EAAuD,SAAS,EAA0C,MAAM,cAAc,CAAA;AAKrI,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB,CAAC,EAAE,SAAS,CAAA;CAClC,CAAA;AAED,QAAA,MAAM,oBAAoB;iDAAgD,sBAAsB;;CA8G/F,CAAA;AAID,eAAe,oBAAoB,CAAA"}
1
+ {"version":3,"file":"mpx-keyboard-avoiding-view.d.ts","sourceRoot":"","sources":["../mpx-keyboard-avoiding-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAiC,MAAM,OAAO,CAAA;AACvE,OAAO,EAAuD,SAAS,EAA0C,MAAM,cAAc,CAAA;AAKrI,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,qBAAqB,CAAC,EAAE,SAAS,CAAA;CAClC,CAAA;AAED,QAAA,MAAM,oBAAoB;iDAAgD,sBAAsB;;CAiH/F,CAAA;AAID,eAAe,oBAAoB,CAAA"}
@@ -38,6 +38,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
38
38
  };
39
39
  const onTouchEnd = ({ nativeEvent }) => {
40
40
  if (nativeEvent.origin !== 'input') {
41
+ if (keyboardAvoid?.current?.holdKeyboard) {
42
+ return;
43
+ }
41
44
  Keyboard.isVisible() && Keyboard.dismiss();
42
45
  }
43
46
  };
@@ -1,8 +1,16 @@
1
1
  import React, { forwardRef, useRef, useCallback, useContext, useState, useEffect } from 'react'
2
- import { Camera, useCameraDevice, useCodeScanner, useCameraFormat, useFrameProcessor } from 'react-native-vision-camera'
2
+ // import { Camera, useCameraDevice, useCodeScanner, useCameraFormat } from 'react-native-vision-camera'
3
3
  import { getCustomEvent } from './getInnerListeners'
4
+ import { noop } from '@mpxjs/utils'
4
5
  import { RouteContext } from './context'
5
6
 
7
+ const qualityValue = {
8
+ high: 90,
9
+ normal: 75,
10
+ low: 50,
11
+ original: 100
12
+ }
13
+
6
14
  interface CameraProps {
7
15
  mode?: 'normal' | 'scanCode'
8
16
  resolution?: 'low' | 'medium' | 'high'
@@ -16,20 +24,44 @@ interface CameraProps {
16
24
  bindscancode?: (result: { type: string, data: string }) => void
17
25
  }
18
26
 
27
+ interface TakePhotoOptions {
28
+ quality?: 'high' | 'normal' | 'low' | 'original'
29
+ success?: (result: { errMsg: string, tempImagePath: string }) => void
30
+ fail?: (result: { errMsg: string }) => void
31
+ complete?: (result: { errMsg: string, tempImagePath?: string }) => void
32
+ }
33
+
34
+ interface RecordOptions {
35
+ timeout?: number
36
+ success?: (result: { errMsg: string }) => void
37
+ fail?: (result: { errMsg: string, error?: any }) => void
38
+ complete?: (result: { errMsg: string }) => void
39
+ timeoutCallback?: (result: { errMsg: string, error?: any }) => void
40
+ }
41
+
42
+ interface StopRecordOptions {
43
+ success?: (result: { errMsg: string, tempVideoPath: string, duration: number }) => void
44
+ fail?: (result: { errMsg: string }) => void
45
+ complete?: (result: { errMsg: string, tempVideoPath?: string, duration?: number }) => void
46
+ }
47
+
19
48
  interface CameraRef {
20
49
  setZoom: (zoom: number) => void
21
- getTakePhoto: () => (() => Promise<any>) | undefined
22
- getStartRecord: () => ((options: any) => void) | undefined
23
- getStopRecord: () => (() => void) | undefined
50
+ takePhoto: (options?: TakePhotoOptions) => void
51
+ startRecord: (options?: RecordOptions) => void
52
+ stopRecord: (options?: StopRecordOptions) => void
24
53
  }
25
54
 
26
55
  type HandlerRef<T, P> = {
27
- // 根据实际的 HandlerRef 类型定义调整
28
56
  current: T | null
29
57
  }
30
58
 
31
- const _camera = forwardRef<HandlerRef<Camera, CameraProps>, CameraProps>((props: CameraProps, ref): JSX.Element | null => {
32
- const cameraRef = useRef<Camera>(null)
59
+ let RecordRes: any = null
60
+
61
+ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: CameraProps, ref): JSX.Element | null => {
62
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
63
+ const { Camera, useCameraDevice, useCodeScanner, useCameraFormat } = require('react-native-vision-camera')
64
+ const cameraRef = useRef<any>(null)
33
65
  const {
34
66
  mode = 'normal',
35
67
  resolution = 'medium',
@@ -46,6 +78,7 @@ const _camera = forwardRef<HandlerRef<Camera, CameraProps>, CameraProps>((props:
46
78
  const { navigation } = useContext(RouteContext) || {}
47
79
  const [zoomValue, setZoomValue] = useState<number>(1)
48
80
  const [hasPermission, setHasPermission] = useState<boolean | null>(null)
81
+ const hasCamera = useRef(false)
49
82
 
50
83
  // 先定义常量,避免在条件判断后使用
51
84
  const maxZoom = device?.maxZoom || 1
@@ -70,7 +103,7 @@ const _camera = forwardRef<HandlerRef<Camera, CameraProps>, CameraProps>((props:
70
103
 
71
104
  const codeScanner = useCodeScanner({
72
105
  codeTypes: ['qr', 'ean-13'],
73
- onCodeScanned: (codes) => {
106
+ onCodeScanned: (codes: any[]) => {
74
107
  const result = codes.map(code => code.value).join(',')
75
108
  bindscancode && bindscancode(getCustomEvent('scancode', {}, {
76
109
  detail: {
@@ -92,8 +125,112 @@ const _camera = forwardRef<HandlerRef<Camera, CameraProps>, CameraProps>((props:
92
125
  bindstop && bindstop()
93
126
  }, [bindstop])
94
127
 
95
- // 检查相机权限
128
+ const camera: CameraRef = {
129
+ setZoom: (zoom: number) => {
130
+ setZoomValue(zoom)
131
+ },
132
+ takePhoto: (options: TakePhotoOptions = {}) => {
133
+ const { success = noop, fail = noop, complete = noop } = options
134
+ cameraRef.current?.takePhoto?.({
135
+ quality: qualityValue[options.quality || 'normal'] as number
136
+ } as any).then((res: { path: any }) => {
137
+ const result = {
138
+ errMsg: 'takePhoto:ok',
139
+ tempImagePath: res.path
140
+ }
141
+ success(result)
142
+ complete(result)
143
+ }).catch(() => {
144
+ const result = {
145
+ errMsg: 'takePhoto:fail'
146
+ }
147
+ fail(result)
148
+ complete(result)
149
+ })
150
+ },
151
+ startRecord: (options: RecordOptions = {}) => {
152
+ let { timeout = 30, success = noop, fail = noop, complete = noop, timeoutCallback = noop } = options
153
+ timeout = timeout > 300 ? 300 : timeout
154
+ let recordTimer: NodeJS.Timeout | null = null
155
+ let isTimeout = false
156
+ try {
157
+ const result = {
158
+ errMsg: 'startRecord:ok'
159
+ }
160
+ success(result)
161
+ complete(result)
162
+
163
+ cameraRef.current?.startRecording?.({
164
+ onRecordingError: (error: any) => {
165
+ if (recordTimer) clearTimeout(recordTimer)
166
+ const errorResult = {
167
+ errMsg: 'startRecord:fail during recording',
168
+ error: error
169
+ }
170
+ timeoutCallback(errorResult)
171
+ },
172
+ onRecordingFinished: (video: any) => {
173
+ RecordRes = video
174
+ if (recordTimer) clearTimeout(recordTimer)
175
+ }
176
+ })
177
+
178
+ recordTimer = setTimeout(() => { // 超时自动停止
179
+ isTimeout = true
180
+ cameraRef.current?.stopRecording().catch(() => {
181
+ // 忽略停止录制时的错误
182
+ })
183
+ }, timeout * 1000)
184
+ } catch (error: any) {
185
+ if (recordTimer) clearTimeout(recordTimer)
186
+ const result = {
187
+ errMsg: 'startRecord:fail ' + (error.message || 'unknown error')
188
+ }
189
+ fail(result)
190
+ complete(result)
191
+ }
192
+ },
193
+ stopRecord: (options: StopRecordOptions = {}) => {
194
+ const { success = noop, fail = noop, complete = noop } = options
195
+ try {
196
+ cameraRef.current?.stopRecording().then(() => {
197
+ setTimeout(() => {
198
+ if (RecordRes) {
199
+ const result = {
200
+ errMsg: 'stopRecord:ok',
201
+ tempVideoPath: RecordRes?.path,
202
+ duration: RecordRes.duration * 1000 // 转成ms
203
+ }
204
+ RecordRes = null
205
+ success(result)
206
+ complete(result)
207
+ }
208
+ }, 200) // 延时200ms,确保录制结果已准备好
209
+ }).catch((e: any) => {
210
+ const result = {
211
+ errMsg: 'stopRecord:fail ' + (e.message || 'promise rejected')
212
+ }
213
+ fail(result)
214
+ complete(result)
215
+ })
216
+ } catch (error: any) {
217
+ const result = {
218
+ errMsg: 'stopRecord:fail ' + (error.message || 'unknown error')
219
+ }
220
+ fail(result)
221
+ complete(result)
222
+ }
223
+ }
224
+ }
96
225
  useEffect(() => {
226
+ if (navigation) {
227
+ if (navigation && !navigation.camera) {
228
+ navigation.camera = camera
229
+ } else {
230
+ hasCamera.current = true
231
+ navigation.camera.multi = true
232
+ }
233
+ }
97
234
  const checkCameraPermission = async () => {
98
235
  try {
99
236
  const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission
@@ -107,39 +244,10 @@ const _camera = forwardRef<HandlerRef<Camera, CameraProps>, CameraProps>((props:
107
244
  setHasPermission(false)
108
245
  }
109
246
  }
110
-
111
247
  checkCameraPermission()
112
248
  }, [])
113
249
 
114
- const camera: CameraRef = {
115
- setZoom: (zoom: number) => {
116
- setZoomValue(zoom)
117
- },
118
- getTakePhoto: () => {
119
- return cameraRef.current?.takePhoto
120
- },
121
- getStartRecord: () => {
122
- return cameraRef.current?.startRecording
123
- },
124
- getStopRecord: () => {
125
- return cameraRef.current?.stopRecording
126
- }
127
- }
128
-
129
- if (navigation) {
130
- navigation.camera = camera
131
- }
132
-
133
- // 所有 Hooks 调用完成后再进行条件判断
134
- if (hasPermission === null) {
135
- return null
136
- }
137
-
138
- if (!hasPermission) {
139
- return null
140
- }
141
-
142
- if (!device) {
250
+ if (!hasPermission || hasCamera.current || !device) {
143
251
  return null
144
252
  }
145
253
 
@@ -147,7 +255,7 @@ const _camera = forwardRef<HandlerRef<Camera, CameraProps>, CameraProps>((props:
147
255
  <Camera
148
256
  ref={cameraRef}
149
257
  isActive={true}
150
- photo={isPhoto}
258
+ photo={true}
151
259
  video={true}
152
260
  onInitialized={onInitialized}
153
261
  onStopped={onStopped}
@@ -18,7 +18,7 @@
18
18
  * ✔ selection-start
19
19
  * ✔ selection-end
20
20
  * ✔ adjust-position
21
- * hold-keyboard
21
+ * hold-keyboard
22
22
  * ✘ safe-password-cert-path
23
23
  * ✘ safe-password-length
24
24
  * ✘ safe-password-time-stamp
@@ -102,6 +102,7 @@ export interface InputProps {
102
102
  'parent-width'?: number
103
103
  'parent-height'?: number
104
104
  'adjust-position': boolean,
105
+ 'hold-keyboard'?: boolean
105
106
  bindinput?: (evt: NativeSyntheticEvent<TextInputTextInputEventData> | unknown) => void
106
107
  bindfocus?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
107
108
  bindblur?: (evt: NativeSyntheticEvent<TextInputFocusEventData> | unknown) => void
@@ -150,6 +151,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
150
151
  'parent-width': parentWidth,
151
152
  'parent-height': parentHeight,
152
153
  'adjust-position': adjustPosition = true,
154
+ 'hold-keyboard': holdKeyboard = false,
153
155
  bindinput,
154
156
  bindfocus,
155
157
  bindblur,
@@ -281,7 +283,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
281
283
 
282
284
  const setKeyboardAvoidContext = () => {
283
285
  if (keyboardAvoid) {
284
- keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition }
286
+ keyboardAvoid.current = { cursorSpacing, ref: nodeRef, adjustPosition, holdKeyboard }
285
287
  }
286
288
  }
287
289
 
@@ -53,6 +53,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
53
53
 
54
54
  const onTouchEnd = ({ nativeEvent }: NativeSyntheticEvent<NativeTouchEvent & { origin?: string }>) => {
55
55
  if (nativeEvent.origin !== 'input') {
56
+ if (keyboardAvoid?.current?.holdKeyboard) {
57
+ return
58
+ }
56
59
  Keyboard.isVisible() && Keyboard.dismiss()
57
60
  }
58
61
  }
@@ -764,9 +764,7 @@ function parse (template, options) {
764
764
 
765
765
  const children = currentParent.children
766
766
 
767
- const isTextLikeParent = currentParent.tag === 'text' || currentParent.tag === 'mpx-text' || currentParent.tag === 'Text' || currentParent.tag === 'mpx-simple-text'
768
-
769
- if (!isTextLikeParent) {
767
+ if (currentParent.tag !== 'text') {
770
768
  text = text.trim()
771
769
  } else {
772
770
  text = text.trim() ? text : ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.16-beta.7",
3
+ "version": "2.10.16-beta.9",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"