@mpxjs/webpack-plugin 2.10.16-beta.9 → 2.10.16-xp.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.
- package/lib/config.js +0 -60
- package/lib/dependencies/AppEntryDependency.js +2 -2
- package/lib/dependencies/ResolveDependency.js +1 -1
- package/lib/file-loader.js +3 -13
- package/lib/helpers.js +0 -2
- package/lib/index.js +15 -40
- package/lib/json-compiler/helper.js +2 -72
- package/lib/json-compiler/index.js +56 -16
- package/lib/json-compiler/plugin.js +2 -2
- package/lib/loader.js +4 -10
- package/lib/native-loader.js +3 -6
- package/lib/platform/json/wx/index.js +29 -30
- package/lib/platform/style/wx/index.js +1 -8
- package/lib/platform/template/wx/component-config/ad.js +0 -5
- package/lib/platform/template/wx/component-config/button.js +5 -21
- package/lib/platform/template/wx/component-config/camera.js +3 -25
- package/lib/platform/template/wx/component-config/canvas.js +1 -8
- package/lib/platform/template/wx/component-config/component.js +33 -31
- package/lib/platform/template/wx/component-config/cover-image.js +2 -7
- package/lib/platform/template/wx/component-config/cover-view.js +1 -3
- package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
- package/lib/platform/template/wx/component-config/form.js +2 -27
- package/lib/platform/template/wx/component-config/image.js +0 -5
- package/lib/platform/template/wx/component-config/input.js +0 -10
- package/lib/platform/template/wx/component-config/label.js +2 -10
- package/lib/platform/template/wx/component-config/map.js +0 -11
- package/lib/platform/template/wx/component-config/movable-area.js +1 -4
- package/lib/platform/template/wx/component-config/movable-view.js +2 -17
- package/lib/platform/template/wx/component-config/navigator.js +0 -26
- package/lib/platform/template/wx/component-config/picker-view.js +0 -12
- package/lib/platform/template/wx/component-config/picker.js +1 -3
- package/lib/platform/template/wx/component-config/progress.js +1 -11
- package/lib/platform/template/wx/component-config/rich-text.js +0 -5
- package/lib/platform/template/wx/component-config/scroll-view.js +1 -12
- package/lib/platform/template/wx/component-config/slider.js +0 -8
- package/lib/platform/template/wx/component-config/swiper-item.js +2 -5
- package/lib/platform/template/wx/component-config/swiper.js +0 -10
- package/lib/platform/template/wx/component-config/text.js +0 -5
- package/lib/platform/template/wx/component-config/textarea.js +2 -19
- package/lib/platform/template/wx/component-config/unsupported.js +1 -10
- package/lib/platform/template/wx/component-config/video.js +0 -10
- package/lib/platform/template/wx/index.js +1 -21
- package/lib/react/index.js +0 -2
- package/lib/react/processJSON.js +71 -39
- package/lib/react/processStyles.js +2 -3
- package/lib/react/processTemplate.js +6 -8
- package/lib/react/script-helper.js +16 -6
- package/lib/react/style-helper.js +2 -10
- package/lib/runtime/components/react/context.ts +6 -13
- package/lib/runtime/components/react/dist/context.js +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +62 -100
- package/lib/runtime/components/react/dist/mpx-input.jsx +11 -37
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +50 -61
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +18 -12
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +11 -8
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +1 -5
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +14 -6
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-text.jsx +5 -33
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +6 -16
- package/lib/runtime/components/react/mpx-image.tsx +82 -123
- package/lib/runtime/components/react/mpx-input.tsx +17 -44
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +49 -69
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +2 -5
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +21 -26
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +12 -8
- package/lib/runtime/components/react/mpx-portal/index.tsx +2 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +17 -6
- package/lib/runtime/components/react/mpx-swiper.tsx +9 -5
- package/lib/runtime/components/react/mpx-text.tsx +5 -38
- package/lib/runtime/components/react/mpx-view.tsx +1 -1
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/types/common.d.ts +0 -19
- package/lib/runtime/components/react/utils.tsx +6 -15
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +2 -2
- package/lib/style-compiler/index.js +2 -3
- package/lib/style-compiler/load-postcss-config.js +1 -1
- package/lib/style-compiler/plugins/trans-special.js +2 -10
- package/lib/style-compiler/strip-conditional-loader.js +15 -178
- package/lib/template-compiler/bind-this.js +2 -2
- package/lib/template-compiler/compiler.js +71 -267
- package/lib/template-compiler/gen-node-react.js +6 -18
- package/lib/template-compiler/index.js +10 -12
- package/lib/template-compiler/parse-exps.js +1 -1
- package/lib/utils/const.js +1 -2
- package/lib/utils/dom-tag-config.js +6 -6
- package/lib/utils/env.js +1 -6
- package/lib/utils/pre-process-json.js +0 -5
- package/lib/web/index.js +0 -2
- package/lib/web/processJSON.js +16 -44
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +4 -6
- package/lib/web/script-helper.js +9 -19
- package/lib/wxs/pre-loader.js +1 -1
- package/lib/wxss/loader.js +9 -1
- package/package.json +4 -15
- package/lib/dependencies/RecordModuleIdMapDependency.js +0 -49
- package/lib/runtime/components/react/dist/context.d.ts +0 -76
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -8
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -8
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -69
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +0 -197
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -11
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -3
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -53
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -28
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -19
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -22
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -51
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -66
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.jsx +0 -132
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -10
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -3
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -7
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -107
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -33
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -9
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -15
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +0 -20
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -17
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -13
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -12
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -17
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -16
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -30
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -10
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -24
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -21
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -25
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -15
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -55
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -31
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -18
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -16
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -19
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +0 -53
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -27
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -8
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -102
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -35
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -23
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -40
- package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +0 -33
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -12
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +0 -123
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/mpx-camera.tsx +0 -275
- package/lib/runtime/components/react/mpx-nav.tsx +0 -155
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -55
- package/lib/utils/get-build-tag-component.js +0 -35
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useRef, useCallback, useContext, useState, useEffect } from 'react'
|
|
2
|
-
// import { Camera, useCameraDevice, useCodeScanner, useCameraFormat } from 'react-native-vision-camera'
|
|
3
|
-
import { getCustomEvent } from './getInnerListeners'
|
|
4
|
-
import { noop } from '@mpxjs/utils'
|
|
5
|
-
import { RouteContext } from './context'
|
|
6
|
-
|
|
7
|
-
const qualityValue = {
|
|
8
|
-
high: 90,
|
|
9
|
-
normal: 75,
|
|
10
|
-
low: 50,
|
|
11
|
-
original: 100
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface CameraProps {
|
|
15
|
-
mode?: 'normal' | 'scanCode'
|
|
16
|
-
resolution?: 'low' | 'medium' | 'high'
|
|
17
|
-
devicePosition?: 'front' | 'back'
|
|
18
|
-
flash?: 'auto' | 'on' | 'off'
|
|
19
|
-
frameSize?: 'small' | 'medium' | 'large'
|
|
20
|
-
style?: Record<string, any>
|
|
21
|
-
bindstop?: () => void
|
|
22
|
-
binderror?: (error: { message: string }) => void
|
|
23
|
-
bindinitdone?: (result: { type: string, data: string }) => void
|
|
24
|
-
bindscancode?: (result: { type: string, data: string }) => void
|
|
25
|
-
}
|
|
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
|
-
|
|
48
|
-
interface CameraRef {
|
|
49
|
-
setZoom: (zoom: number) => void
|
|
50
|
-
takePhoto: (options?: TakePhotoOptions) => void
|
|
51
|
-
startRecord: (options?: RecordOptions) => void
|
|
52
|
-
stopRecord: (options?: StopRecordOptions) => void
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
type HandlerRef<T, P> = {
|
|
56
|
-
current: T | null
|
|
57
|
-
}
|
|
58
|
-
|
|
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)
|
|
65
|
-
const {
|
|
66
|
-
mode = 'normal',
|
|
67
|
-
resolution = 'medium',
|
|
68
|
-
devicePosition = 'back',
|
|
69
|
-
flash = 'auto',
|
|
70
|
-
frameSize = 'medium',
|
|
71
|
-
bindinitdone,
|
|
72
|
-
bindstop,
|
|
73
|
-
bindscancode
|
|
74
|
-
} = props
|
|
75
|
-
|
|
76
|
-
const isPhoto = mode === 'normal'
|
|
77
|
-
const device = useCameraDevice(devicePosition || 'back')
|
|
78
|
-
const { navigation } = useContext(RouteContext) || {}
|
|
79
|
-
const [zoomValue, setZoomValue] = useState<number>(1)
|
|
80
|
-
const [hasPermission, setHasPermission] = useState<boolean | null>(null)
|
|
81
|
-
const hasCamera = useRef(false)
|
|
82
|
-
|
|
83
|
-
// 先定义常量,避免在条件判断后使用
|
|
84
|
-
const maxZoom = device?.maxZoom || 1
|
|
85
|
-
const RESOLUTION_MAPPING: Record<string, { width: number, height: number }> = {
|
|
86
|
-
low: { width: 640, height: 480 },
|
|
87
|
-
medium: { width: 1280, height: 720 },
|
|
88
|
-
high: { width: 1920, height: 1080 }
|
|
89
|
-
}
|
|
90
|
-
const FRAME_SIZE_MAPPING: Record<string, { width: number, height: number }> = {
|
|
91
|
-
small: { width: 480, height: 360 },
|
|
92
|
-
medium: { width: 720, height: 540 },
|
|
93
|
-
large: { width: 1080, height: 810 }
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 所有 Hooks 必须在条件判断之前调用
|
|
97
|
-
const format = useCameraFormat(device, [
|
|
98
|
-
{
|
|
99
|
-
photoResolution: RESOLUTION_MAPPING[resolution],
|
|
100
|
-
videoResolution: FRAME_SIZE_MAPPING[frameSize] || RESOLUTION_MAPPING[resolution]
|
|
101
|
-
}
|
|
102
|
-
])
|
|
103
|
-
|
|
104
|
-
const codeScanner = useCodeScanner({
|
|
105
|
-
codeTypes: ['qr', 'ean-13'],
|
|
106
|
-
onCodeScanned: (codes: any[]) => {
|
|
107
|
-
const result = codes.map(code => code.value).join(',')
|
|
108
|
-
bindscancode && bindscancode(getCustomEvent('scancode', {}, {
|
|
109
|
-
detail: {
|
|
110
|
-
result: codes.map(code => code.value).join(',')
|
|
111
|
-
}
|
|
112
|
-
}))
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
const onInitialized = useCallback(() => {
|
|
117
|
-
bindinitdone && bindinitdone(getCustomEvent('initdone', {}, {
|
|
118
|
-
detail: {
|
|
119
|
-
maxZoom
|
|
120
|
-
}
|
|
121
|
-
}))
|
|
122
|
-
}, [bindinitdone, maxZoom])
|
|
123
|
-
|
|
124
|
-
const onStopped = useCallback(() => {
|
|
125
|
-
bindstop && bindstop()
|
|
126
|
-
}, [bindstop])
|
|
127
|
-
|
|
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
|
-
}
|
|
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
|
-
}, [])
|
|
249
|
-
|
|
250
|
-
if (!hasPermission || hasCamera.current || !device) {
|
|
251
|
-
return null
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return (
|
|
255
|
-
<Camera
|
|
256
|
-
ref={cameraRef}
|
|
257
|
-
isActive={true}
|
|
258
|
-
photo={true}
|
|
259
|
-
video={true}
|
|
260
|
-
onInitialized={onInitialized}
|
|
261
|
-
onStopped={onStopped}
|
|
262
|
-
device={device}
|
|
263
|
-
flash={flash}
|
|
264
|
-
format={format}
|
|
265
|
-
codeScanner={!isPhoto ? codeScanner : undefined}
|
|
266
|
-
style={{ flex: 1 }}
|
|
267
|
-
zoom={zoomValue}
|
|
268
|
-
{...props}
|
|
269
|
-
/>
|
|
270
|
-
)
|
|
271
|
-
})
|
|
272
|
-
|
|
273
|
-
_camera.displayName = 'MpxCamera'
|
|
274
|
-
|
|
275
|
-
export default _camera
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/* eslint-disable space-before-function-paren */
|
|
2
|
-
import { useState, useMemo, memo } from 'react'
|
|
3
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
4
|
-
import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native'
|
|
5
|
-
|
|
6
|
-
function convertToHex(color?: string) {
|
|
7
|
-
try {
|
|
8
|
-
const intColor = processColor(color) as number | null | undefined
|
|
9
|
-
if (intColor === null || intColor === undefined) {
|
|
10
|
-
return null
|
|
11
|
-
}
|
|
12
|
-
// 将32位整数颜色值转换为RGBA
|
|
13
|
-
const r = (intColor >> 16) & 255
|
|
14
|
-
const g = (intColor >> 8) & 255
|
|
15
|
-
const b = intColor & 255
|
|
16
|
-
// 转换为十六进制
|
|
17
|
-
const hexR = r.toString(16).padStart(2, '0')
|
|
18
|
-
const hexG = g.toString(16).padStart(2, '0')
|
|
19
|
-
const hexB = b.toString(16).padStart(2, '0')
|
|
20
|
-
return `#${hexR}${hexG}${hexB}`
|
|
21
|
-
} catch (error) {
|
|
22
|
-
return null
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const titleHeight = 44
|
|
27
|
-
export function useInnerHeaderHeight(pageConfig: PageConfig) {
|
|
28
|
-
const safeArea = useSafeAreaInsets()
|
|
29
|
-
if (pageConfig.navigationStyle === 'custom') {
|
|
30
|
-
return 0
|
|
31
|
-
} else {
|
|
32
|
-
const safeAreaTop = safeArea?.top || 0
|
|
33
|
-
const headerHeight = safeAreaTop + titleHeight
|
|
34
|
-
return headerHeight
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const styles = StyleSheet.create({
|
|
39
|
-
header: {
|
|
40
|
-
elevation: 3
|
|
41
|
-
},
|
|
42
|
-
headerContent: {
|
|
43
|
-
flexDirection: 'row',
|
|
44
|
-
alignItems: 'center',
|
|
45
|
-
justifyContent: 'center'
|
|
46
|
-
},
|
|
47
|
-
backButton: {
|
|
48
|
-
position: 'absolute',
|
|
49
|
-
height: '100%',
|
|
50
|
-
width: 40,
|
|
51
|
-
left: 0,
|
|
52
|
-
top: 0,
|
|
53
|
-
alignItems: 'center',
|
|
54
|
-
justifyContent: 'center'
|
|
55
|
-
},
|
|
56
|
-
backButtonImage: {
|
|
57
|
-
width: 22,
|
|
58
|
-
height: 22
|
|
59
|
-
},
|
|
60
|
-
title: {
|
|
61
|
-
fontSize: 17,
|
|
62
|
-
fontWeight: 600,
|
|
63
|
-
width: '60%',
|
|
64
|
-
textAlign: 'center'
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
const NavColor = {
|
|
68
|
-
White: '#ffffff',
|
|
69
|
-
Black: '#000000'
|
|
70
|
-
}
|
|
71
|
-
// navigationBarTextStyle 只支持黑白 'white'/'black
|
|
72
|
-
const validBarTextStyle = (textStyle?: string) => {
|
|
73
|
-
const textStyleColor = convertToHex(textStyle)
|
|
74
|
-
if (textStyle && textStyleColor && [NavColor.White, NavColor.Black].includes(textStyleColor)) {
|
|
75
|
-
return textStyleColor
|
|
76
|
-
} else {
|
|
77
|
-
return NavColor.White
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface MpxNavProps {
|
|
82
|
-
pageConfig: PageConfig
|
|
83
|
-
navigation: any
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const BACK_ICON =
|
|
87
|
-
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg=='
|
|
88
|
-
|
|
89
|
-
const MpxNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
|
|
90
|
-
const [innerPageConfig, setPageConfig] = useState<PageConfig>(pageConfig || {})
|
|
91
|
-
const safeAreaTop = useSafeAreaInsets()?.top || 0
|
|
92
|
-
|
|
93
|
-
navigation.setPageConfig = (config: PageConfig) => {
|
|
94
|
-
setPageConfig(Object.assign({}, innerPageConfig, config))
|
|
95
|
-
}
|
|
96
|
-
const isCustom = innerPageConfig.navigationStyle === 'custom'
|
|
97
|
-
const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle])
|
|
98
|
-
// 状态栏的颜色
|
|
99
|
-
const statusBarElement = (
|
|
100
|
-
<StatusBar
|
|
101
|
-
translucent
|
|
102
|
-
backgroundColor='transparent'
|
|
103
|
-
barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
if (isCustom) return statusBarElement
|
|
107
|
-
// 假设是栈导航,获取栈的长度
|
|
108
|
-
const stackLength = navigation.getState()?.routes?.length
|
|
109
|
-
const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack
|
|
110
|
-
const isHandleStackTopBack = typeof onStackTopBack === 'function'
|
|
111
|
-
|
|
112
|
-
// 回退按钮与图标
|
|
113
|
-
// prettier-ignore
|
|
114
|
-
const backElement = stackLength > 1 || isHandleStackTopBack
|
|
115
|
-
? (
|
|
116
|
-
<TouchableWithoutFeedback
|
|
117
|
-
onPress={() => {
|
|
118
|
-
if (stackLength <= 1 && isHandleStackTopBack) {
|
|
119
|
-
onStackTopBack()
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
navigation.goBack()
|
|
123
|
-
}}>
|
|
124
|
-
<View style={[styles.backButton]}>
|
|
125
|
-
<Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
|
|
126
|
-
</View>
|
|
127
|
-
</TouchableWithoutFeedback>
|
|
128
|
-
)
|
|
129
|
-
: null
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<View
|
|
133
|
-
style={[
|
|
134
|
-
styles.header,
|
|
135
|
-
{
|
|
136
|
-
paddingTop: safeAreaTop,
|
|
137
|
-
backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
|
|
138
|
-
}
|
|
139
|
-
]}>
|
|
140
|
-
{statusBarElement}
|
|
141
|
-
{/* TODO: 确定 height 的有效性 */}
|
|
142
|
-
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
|
143
|
-
{/* @ts-expect-error */}
|
|
144
|
-
<View style={styles.headerContent} height={titleHeight}>
|
|
145
|
-
{backElement}
|
|
146
|
-
<Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
|
|
147
|
-
{innerPageConfig.navigationBarTitleText?.trim() || ''}
|
|
148
|
-
</Text>
|
|
149
|
-
</View>
|
|
150
|
-
</View>
|
|
151
|
-
)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
MpxNav.displayName = 'MpxNav'
|
|
155
|
-
export default MpxNav
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { LayoutChangeEvent, View } from 'react-native'
|
|
3
|
-
import { extendObject } from '../utils'
|
|
4
|
-
import { usePickerViewStyleContext } from '../mpx-picker-view/pickerVIewContext'
|
|
5
|
-
|
|
6
|
-
interface PickerColumnItemProps {
|
|
7
|
-
item: React.ReactElement
|
|
8
|
-
index: number
|
|
9
|
-
itemHeight: number
|
|
10
|
-
itemWidth?: number | '100%'
|
|
11
|
-
textStyle: Record<string, any>
|
|
12
|
-
textProps?: any
|
|
13
|
-
onItemLayout?: (e: LayoutChangeEvent) => void
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const PickerViewColumnItem: React.FC<PickerColumnItemProps> = ({
|
|
17
|
-
item,
|
|
18
|
-
index,
|
|
19
|
-
itemHeight,
|
|
20
|
-
itemWidth = '100%',
|
|
21
|
-
textStyle,
|
|
22
|
-
textProps,
|
|
23
|
-
onItemLayout
|
|
24
|
-
}) => {
|
|
25
|
-
const textStyleFromAncestor = usePickerViewStyleContext()
|
|
26
|
-
const strKey = `picker-column-item-${index}`
|
|
27
|
-
const restProps = index === 0 ? { onLayout: onItemLayout } : {}
|
|
28
|
-
const itemProps = extendObject(
|
|
29
|
-
{
|
|
30
|
-
style: extendObject(
|
|
31
|
-
{ height: itemHeight, width: '100%' },
|
|
32
|
-
textStyleFromAncestor,
|
|
33
|
-
textStyle,
|
|
34
|
-
item.props.style
|
|
35
|
-
)
|
|
36
|
-
},
|
|
37
|
-
textProps,
|
|
38
|
-
restProps
|
|
39
|
-
)
|
|
40
|
-
const realItem = React.cloneElement(item, itemProps)
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<View
|
|
44
|
-
key={strKey}
|
|
45
|
-
style={[
|
|
46
|
-
{ height: itemHeight, width: itemWidth, pointerEvents: 'none' }
|
|
47
|
-
]}
|
|
48
|
-
>
|
|
49
|
-
{realItem}
|
|
50
|
-
</View>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
PickerViewColumnItem.displayName = 'MpxPickerViewColumnItem'
|
|
55
|
-
export default PickerViewColumnItem
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const normalize = require('./normalize')
|
|
2
|
-
const { isBuildInWebTag, isBuildInReactTag } = require('./dom-tag-config')
|
|
3
|
-
|
|
4
|
-
module.exports = function getBuildInTagComponent (mode, tag) {
|
|
5
|
-
const aliBuildTag = ['view', 'text'].reduce((obj, name) => {
|
|
6
|
-
obj[name] = {
|
|
7
|
-
name: `mpx-${name}`,
|
|
8
|
-
resource: normalize.lib(`runtime/components/ali/mpx-${name}.mpx`)
|
|
9
|
-
}
|
|
10
|
-
return obj
|
|
11
|
-
}, {})
|
|
12
|
-
|
|
13
|
-
switch (mode) {
|
|
14
|
-
case 'ali':
|
|
15
|
-
return aliBuildTag[tag]
|
|
16
|
-
case 'web':
|
|
17
|
-
if (isBuildInWebTag(`mpx-${tag}`)) {
|
|
18
|
-
return {
|
|
19
|
-
name: `mpx-${tag}`,
|
|
20
|
-
resource: normalize.lib(`runtime/components/web/mpx-${tag}.vue`)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return undefined
|
|
24
|
-
case 'ios':
|
|
25
|
-
case 'android':
|
|
26
|
-
case 'harmony':
|
|
27
|
-
if (isBuildInReactTag(`mpx-${tag}`)) {
|
|
28
|
-
return {
|
|
29
|
-
name: `mpx-${tag}`,
|
|
30
|
-
resource: normalize.lib(`runtime/components/react/dist/mpx-${tag}.jsx`)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return undefined
|
|
34
|
-
}
|
|
35
|
-
}
|