@mpxjs/webpack-plugin 2.10.16-beta.8 → 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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpx-camera.d.ts","sourceRoot":"","sources":["../mpx-camera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2E,MAAM,OAAO,CAAA;AAa/F,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;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAChE;AA8BD,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI;IACtB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;CAClB,CAAA;AAID,QAAA,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"mpx-camera.d.ts","sourceRoot":"","sources":["../mpx-camera.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2E,MAAM,OAAO,CAAA;AAa/F,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;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAChE;AA8BD,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI;IACtB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;CAClB,CAAA;AAID,QAAA,MAAM,OAAO,kGAkNX,CAAA;AAIF,eAAe,OAAO,CAAA"}
|
|
@@ -20,6 +20,7 @@ const _camera = forwardRef((props, ref) => {
|
|
|
20
20
|
const { navigation } = useContext(RouteContext) || {};
|
|
21
21
|
const [zoomValue, setZoomValue] = useState(1);
|
|
22
22
|
const [hasPermission, setHasPermission] = useState(null);
|
|
23
|
+
const hasCamera = useRef(false);
|
|
23
24
|
// 先定义常量,避免在条件判断后使用
|
|
24
25
|
const maxZoom = device?.maxZoom || 1;
|
|
25
26
|
const RESOLUTION_MAPPING = {
|
|
@@ -60,25 +61,6 @@ const _camera = forwardRef((props, ref) => {
|
|
|
60
61
|
const onStopped = useCallback(() => {
|
|
61
62
|
bindstop && bindstop();
|
|
62
63
|
}, [bindstop]);
|
|
63
|
-
// 检查相机权限
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
const checkCameraPermission = async () => {
|
|
66
|
-
try {
|
|
67
|
-
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission;
|
|
68
|
-
if (typeof cameraPermission === 'function') {
|
|
69
|
-
const permissionResult = await cameraPermission();
|
|
70
|
-
setHasPermission(permissionResult === true);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
setHasPermission(true);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
setHasPermission(false);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
checkCameraPermission();
|
|
81
|
-
}, []);
|
|
82
64
|
const camera = {
|
|
83
65
|
setZoom: (zoom) => {
|
|
84
66
|
setZoomValue(zoom);
|
|
@@ -179,13 +161,34 @@ const _camera = forwardRef((props, ref) => {
|
|
|
179
161
|
}
|
|
180
162
|
}
|
|
181
163
|
};
|
|
182
|
-
|
|
183
|
-
navigation
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
174
|
+
const checkCameraPermission = async () => {
|
|
175
|
+
try {
|
|
176
|
+
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission;
|
|
177
|
+
if (typeof cameraPermission === 'function') {
|
|
178
|
+
const permissionResult = await cameraPermission();
|
|
179
|
+
setHasPermission(permissionResult === true);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
setHasPermission(true);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
setHasPermission(false);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
checkCameraPermission();
|
|
190
|
+
}, []);
|
|
191
|
+
if (!hasPermission || hasCamera.current || !device) {
|
|
189
192
|
return null;
|
|
190
193
|
}
|
|
191
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}/>);
|
|
@@ -78,6 +78,7 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
|
|
|
78
78
|
const { navigation } = useContext(RouteContext) || {}
|
|
79
79
|
const [zoomValue, setZoomValue] = useState<number>(1)
|
|
80
80
|
const [hasPermission, setHasPermission] = useState<boolean | null>(null)
|
|
81
|
+
const hasCamera = useRef(false)
|
|
81
82
|
|
|
82
83
|
// 先定义常量,避免在条件判断后使用
|
|
83
84
|
const maxZoom = device?.maxZoom || 1
|
|
@@ -124,25 +125,6 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
|
|
|
124
125
|
bindstop && bindstop()
|
|
125
126
|
}, [bindstop])
|
|
126
127
|
|
|
127
|
-
// 检查相机权限
|
|
128
|
-
useEffect(() => {
|
|
129
|
-
const checkCameraPermission = async () => {
|
|
130
|
-
try {
|
|
131
|
-
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission
|
|
132
|
-
if (typeof cameraPermission === 'function') {
|
|
133
|
-
const permissionResult = await cameraPermission()
|
|
134
|
-
setHasPermission(permissionResult === true)
|
|
135
|
-
} else {
|
|
136
|
-
setHasPermission(true)
|
|
137
|
-
}
|
|
138
|
-
} catch (error) {
|
|
139
|
-
setHasPermission(false)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
checkCameraPermission()
|
|
144
|
-
}, [])
|
|
145
|
-
|
|
146
128
|
const camera: CameraRef = {
|
|
147
129
|
setZoom: (zoom: number) => {
|
|
148
130
|
setZoomValue(zoom)
|
|
@@ -240,15 +222,32 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
|
|
|
240
222
|
}
|
|
241
223
|
}
|
|
242
224
|
}
|
|
243
|
-
|
|
244
|
-
navigation
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
+
}
|
|
234
|
+
const checkCameraPermission = async () => {
|
|
235
|
+
try {
|
|
236
|
+
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission
|
|
237
|
+
if (typeof cameraPermission === 'function') {
|
|
238
|
+
const permissionResult = await cameraPermission()
|
|
239
|
+
setHasPermission(permissionResult === true)
|
|
240
|
+
} else {
|
|
241
|
+
setHasPermission(true)
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
setHasPermission(false)
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
checkCameraPermission()
|
|
248
|
+
}, [])
|
|
250
249
|
|
|
251
|
-
if (!device) {
|
|
250
|
+
if (!hasPermission || hasCamera.current || !device) {
|
|
252
251
|
return null
|
|
253
252
|
}
|
|
254
253
|
|