@mpxjs/webpack-plugin 2.10.17-beta.3 → 2.10.17-beta.6
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 +60 -0
- package/lib/file-loader.js +4 -1
- package/lib/global.d.ts +245 -0
- package/lib/index.js +29 -2
- package/lib/json-compiler/index.js +13 -4
- package/lib/loader.js +4 -0
- package/lib/platform/json/wx/index.js +6 -0
- package/lib/platform/style/wx/index.js +57 -33
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +10 -3
- package/lib/platform/template/wx/component-config/camera.js +25 -3
- package/lib/platform/template/wx/component-config/canvas.js +8 -1
- package/lib/platform/template/wx/component-config/cover-image.js +7 -2
- package/lib/platform/template/wx/component-config/cover-view.js +3 -1
- package/lib/platform/template/wx/component-config/form.js +27 -2
- package/lib/platform/template/wx/component-config/image.js +5 -0
- package/lib/platform/template/wx/component-config/input.js +11 -1
- package/lib/platform/template/wx/component-config/label.js +10 -2
- package/lib/platform/template/wx/component-config/map.js +11 -0
- package/lib/platform/template/wx/component-config/movable-area.js +4 -1
- package/lib/platform/template/wx/component-config/movable-view.js +17 -2
- package/lib/platform/template/wx/component-config/navigator.js +26 -0
- package/lib/platform/template/wx/component-config/picker-view.js +12 -0
- package/lib/platform/template/wx/component-config/picker.js +3 -1
- package/lib/platform/template/wx/component-config/progress.js +11 -1
- package/lib/platform/template/wx/component-config/rich-text.js +5 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +12 -1
- package/lib/platform/template/wx/component-config/slider.js +8 -0
- package/lib/platform/template/wx/component-config/swiper-item.js +5 -2
- package/lib/platform/template/wx/component-config/swiper.js +10 -0
- package/lib/platform/template/wx/component-config/text.js +5 -0
- package/lib/platform/template/wx/component-config/textarea.js +20 -3
- package/lib/platform/template/wx/component-config/unsupported.js +10 -1
- package/lib/platform/template/wx/component-config/video.js +10 -0
- package/lib/platform/template/wx/index.js +21 -1
- package/lib/react/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +23 -8
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +198 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +297 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +196 -0
- package/lib/runtime/components/react/context.ts +7 -1
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +15 -0
- package/lib/runtime/components/react/dist/animationHooks/index.js +67 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.js +182 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +274 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +150 -0
- package/lib/runtime/components/react/dist/context.d.ts +6 -2
- package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +236 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +10 -9
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +11 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +71 -39
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts +3 -3
- package/lib/runtime/components/react/dist/mpx-view.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/parser.d.ts +0 -1
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts +1 -1
- package/lib/runtime/components/react/dist/utils.jsx +34 -13
- package/lib/runtime/components/react/mpx-camera.tsx +327 -0
- package/lib/runtime/components/react/mpx-input.tsx +15 -9
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +7 -2
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-swiper.tsx +86 -37
- package/lib/runtime/components/react/mpx-view.tsx +27 -12
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/tsconfig.json +26 -0
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +34 -16
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/style-compiler/strip-conditional-loader/rebaseUrl.js +225 -0
- package/lib/style-compiler/strip-conditional-loader.js +76 -185
- package/lib/template-compiler/compiler.js +1 -3
- package/lib/utils/dom-tag-config.js +1 -1
- package/lib/utils/string.js +25 -1
- package/package.json +6 -4
- package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
- 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.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
- 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/useAnimationHooks.js +0 -289
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
- package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
- package/lib/runtime/components/react/useAnimationHooks.ts +0 -320
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { AnimatableValue, WithTimingConfig, AnimationCallback, EasingFunction } from 'react-native-reanimated';
|
|
2
|
+
import type { ExtendedViewStyle } from '../types/common';
|
|
3
|
+
import type { _ViewProps } from '../mpx-view';
|
|
4
|
+
export type TimingFunction = 'linear' | 'ease' | 'ease-in' | 'ease-in-out' | 'ease-out';
|
|
5
|
+
export type AnimatedOption = {
|
|
6
|
+
duration: number;
|
|
7
|
+
delay?: number;
|
|
8
|
+
useNativeDriver?: boolean;
|
|
9
|
+
timingFunction?: TimingFunction;
|
|
10
|
+
transformOrigin?: string;
|
|
11
|
+
};
|
|
12
|
+
export type ExtendWithTimingConfig = WithTimingConfig & {
|
|
13
|
+
delay?: number;
|
|
14
|
+
};
|
|
15
|
+
export type AnimationStepItem = {
|
|
16
|
+
animatedOption: AnimatedOption;
|
|
17
|
+
rules: Map<string, number | string>;
|
|
18
|
+
transform: Map<string, number>;
|
|
19
|
+
};
|
|
20
|
+
export type AnimationProp = {
|
|
21
|
+
id: number;
|
|
22
|
+
actions: AnimationStepItem[];
|
|
23
|
+
};
|
|
24
|
+
export type CustomAnimationCallback = (finished?: boolean, current?: AnimatableValue, duration?: number) => void;
|
|
25
|
+
export type TransitionMap = {
|
|
26
|
+
[propName: string]: {
|
|
27
|
+
duration: number;
|
|
28
|
+
delay?: number;
|
|
29
|
+
easing: EasingFunction;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type InterpolateOutput = {
|
|
33
|
+
[propName: string]: string[];
|
|
34
|
+
};
|
|
35
|
+
export type AnimationHooksPropsType = _ViewProps & {
|
|
36
|
+
transitionend?: CustomAnimationCallback;
|
|
37
|
+
};
|
|
38
|
+
export declare const secondRegExp: RegExp;
|
|
39
|
+
export declare const cubicBezierExp: RegExp;
|
|
40
|
+
export declare const percentExp: RegExp;
|
|
41
|
+
export declare const easingKey: {
|
|
42
|
+
linear: (t: number) => number;
|
|
43
|
+
ease: EasingFunction;
|
|
44
|
+
'ease-in': EasingFunction;
|
|
45
|
+
'ease-in-out': EasingFunction;
|
|
46
|
+
'ease-out': EasingFunction;
|
|
47
|
+
};
|
|
48
|
+
export declare const transformInitial: ExtendedViewStyle;
|
|
49
|
+
export declare const animationAPIInitialValue: ExtendedViewStyle;
|
|
50
|
+
export declare const transitionSupportedProperty: {
|
|
51
|
+
color: string;
|
|
52
|
+
borderColor: string;
|
|
53
|
+
borderBottomColor: string;
|
|
54
|
+
borderLeftColor: string;
|
|
55
|
+
borderRightColor: string;
|
|
56
|
+
borderTopColor: string;
|
|
57
|
+
borderTopLeftRadius: number;
|
|
58
|
+
borderTopRightRadius: number;
|
|
59
|
+
borderBottomLeftRadius: number;
|
|
60
|
+
borderBottomRightRadius: number;
|
|
61
|
+
borderRadius: number;
|
|
62
|
+
borderBottomWidth: number;
|
|
63
|
+
borderLeftWidth: number;
|
|
64
|
+
borderRightWidth: number;
|
|
65
|
+
borderTopWidth: number;
|
|
66
|
+
borderWidth: number;
|
|
67
|
+
margin: number;
|
|
68
|
+
marginBottom: number;
|
|
69
|
+
marginLeft: number;
|
|
70
|
+
marginRight: number;
|
|
71
|
+
marginTop: number;
|
|
72
|
+
marginHorizontal: number;
|
|
73
|
+
marginVertical: number;
|
|
74
|
+
maxHeight: number;
|
|
75
|
+
maxWidth: number;
|
|
76
|
+
minHeight: number;
|
|
77
|
+
minWidth: number;
|
|
78
|
+
padding: number;
|
|
79
|
+
paddingBottom: number;
|
|
80
|
+
paddingLeft: number;
|
|
81
|
+
paddingRight: number;
|
|
82
|
+
paddingTop: number;
|
|
83
|
+
paddingHorizontal: number;
|
|
84
|
+
paddingVertical: number;
|
|
85
|
+
fontSize: number;
|
|
86
|
+
letterSpacing: number;
|
|
87
|
+
} & import("react-native/types").ViewStyle & {
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
backgroundImage?: string | undefined;
|
|
90
|
+
backgroundSize?: ("auto" | "contain" | "cover" | import("../types/common").NumberVal)[] | undefined;
|
|
91
|
+
borderRadius?: string | number | undefined;
|
|
92
|
+
backgroundPosition?: import("../types/common").backgroundPositionList | undefined;
|
|
93
|
+
transform?: {
|
|
94
|
+
[key: string]: string | number;
|
|
95
|
+
}[] | undefined;
|
|
96
|
+
};
|
|
97
|
+
export declare const isTransform: (key: string) => boolean;
|
|
98
|
+
export declare function getTransformObj(transforms: {
|
|
99
|
+
[propName: string]: string | number;
|
|
100
|
+
}[]): {
|
|
101
|
+
[propName: string]: string | number;
|
|
102
|
+
};
|
|
103
|
+
export declare function getInitialVal(style: ExtendedViewStyle, key: string): any;
|
|
104
|
+
export declare function formatAnimatedKeys(keys: string[]): (string | string[])[];
|
|
105
|
+
export declare function getUnit(duration: string): number;
|
|
106
|
+
export declare function getAnimation({ key, value }: {
|
|
107
|
+
key: string;
|
|
108
|
+
value: string | number;
|
|
109
|
+
}, { delay, duration, easing }: ExtendWithTimingConfig, callback?: AnimationCallback): string | number;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Easing, withTiming, withDelay } from 'react-native-reanimated';
|
|
2
|
+
import { hasOwn } from '@mpxjs/utils';
|
|
3
|
+
// ms s 单位匹配
|
|
4
|
+
export const secondRegExp = /^\s*(\d*(?:\.\d+)?)(s|ms)?\s*$/;
|
|
5
|
+
export const cubicBezierExp = /cubic-bezier\(["']?(.*?)["']?\)/;
|
|
6
|
+
export const percentExp = /^((-?(\d+(\.\d+)?|\.\d+))%)$/;
|
|
7
|
+
// export const PropNameColorExp = /^c|Color$/
|
|
8
|
+
// export const NumberExp = /^((opacity|flex-grow|flex-shrink|gap|left|right|top|bottom)|(.+-(width|height|left|right|top|bottom|radius|spacing|size|gap|index|offset|opacity)))$/
|
|
9
|
+
// export const ColorExp = /^(color|(.+Color))$/
|
|
10
|
+
// transform
|
|
11
|
+
// export const transform = 'transform'
|
|
12
|
+
// export const transformOrigin = 'transformOrigin'
|
|
13
|
+
// export const transition = 'transition'
|
|
14
|
+
// 微信 timingFunction 和 RN Easing 对应关系
|
|
15
|
+
export const easingKey = {
|
|
16
|
+
linear: Easing.linear,
|
|
17
|
+
ease: Easing.inOut(Easing.ease),
|
|
18
|
+
'ease-in': Easing.in(Easing.poly(3)),
|
|
19
|
+
'ease-in-out': Easing.inOut(Easing.poly(3)),
|
|
20
|
+
'ease-out': Easing.out(Easing.poly(3))
|
|
21
|
+
// 'step-start': '',
|
|
22
|
+
// 'step-end': ''
|
|
23
|
+
};
|
|
24
|
+
export const transformInitial = {
|
|
25
|
+
// matrix: 0,
|
|
26
|
+
// matrix3d: 0,
|
|
27
|
+
// rotate: '0deg',
|
|
28
|
+
rotateX: '0deg',
|
|
29
|
+
rotateY: '0deg',
|
|
30
|
+
rotateZ: '0deg',
|
|
31
|
+
// rotate3d:[0,0,0]
|
|
32
|
+
// scale: 1,
|
|
33
|
+
// scale3d: [1, 1, 1],
|
|
34
|
+
scaleX: 1,
|
|
35
|
+
scaleY: 1,
|
|
36
|
+
// scaleZ: 1,
|
|
37
|
+
// skew: 0,
|
|
38
|
+
skewX: '0deg',
|
|
39
|
+
skewY: '0deg',
|
|
40
|
+
// translate: 0,
|
|
41
|
+
// translate3d: 0,
|
|
42
|
+
translateX: 0,
|
|
43
|
+
translateY: 0
|
|
44
|
+
// translateZ: 0,
|
|
45
|
+
};
|
|
46
|
+
// animation api 动画默认初始值
|
|
47
|
+
export const animationAPIInitialValue = Object.assign({
|
|
48
|
+
opacity: 1,
|
|
49
|
+
backgroundColor: 'transparent',
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0,
|
|
52
|
+
top: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
bottom: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
transformOrigin: ['50%', '50%', 0]
|
|
57
|
+
}, transformInitial);
|
|
58
|
+
// transition property
|
|
59
|
+
export const transitionSupportedProperty = Object.assign({
|
|
60
|
+
color: 'transparent',
|
|
61
|
+
borderColor: 'transparent',
|
|
62
|
+
borderBottomColor: 'transparent',
|
|
63
|
+
borderLeftColor: 'transparent',
|
|
64
|
+
borderRightColor: 'transparent',
|
|
65
|
+
borderTopColor: 'transparent',
|
|
66
|
+
borderTopLeftRadius: 0,
|
|
67
|
+
borderTopRightRadius: 0,
|
|
68
|
+
borderBottomLeftRadius: 0,
|
|
69
|
+
borderBottomRightRadius: 0,
|
|
70
|
+
borderRadius: 0,
|
|
71
|
+
borderBottomWidth: 0,
|
|
72
|
+
borderLeftWidth: 0,
|
|
73
|
+
borderRightWidth: 0,
|
|
74
|
+
borderTopWidth: 0,
|
|
75
|
+
borderWidth: 0,
|
|
76
|
+
margin: 0,
|
|
77
|
+
marginBottom: 0,
|
|
78
|
+
marginLeft: 0,
|
|
79
|
+
marginRight: 0,
|
|
80
|
+
marginTop: 0,
|
|
81
|
+
marginHorizontal: 0,
|
|
82
|
+
marginVertical: 0,
|
|
83
|
+
maxHeight: 0,
|
|
84
|
+
maxWidth: 0,
|
|
85
|
+
minHeight: 0,
|
|
86
|
+
minWidth: 0,
|
|
87
|
+
padding: 0,
|
|
88
|
+
paddingBottom: 0,
|
|
89
|
+
paddingLeft: 0,
|
|
90
|
+
paddingRight: 0,
|
|
91
|
+
paddingTop: 0,
|
|
92
|
+
paddingHorizontal: 0,
|
|
93
|
+
paddingVertical: 0,
|
|
94
|
+
fontSize: 0,
|
|
95
|
+
letterSpacing: 0 // Todo
|
|
96
|
+
}, animationAPIInitialValue);
|
|
97
|
+
// export type PropertyType = keyof transitionSupportedProperty
|
|
98
|
+
// transform
|
|
99
|
+
export const isTransform = (key) => hasOwn(transformInitial, key);
|
|
100
|
+
// transform 数组转对象
|
|
101
|
+
export function getTransformObj(transforms) {
|
|
102
|
+
'worklet';
|
|
103
|
+
return (transforms || []).reduce((transformObj, item) => {
|
|
104
|
+
return Object.assign(transformObj, item);
|
|
105
|
+
}, {});
|
|
106
|
+
}
|
|
107
|
+
// 获取样式初始值(prop style or 默认值)
|
|
108
|
+
export function getInitialVal(style, key) {
|
|
109
|
+
if (isTransform(key) && Array.isArray(style.transform)) {
|
|
110
|
+
let initialVal = transitionSupportedProperty[key];
|
|
111
|
+
// 仅支持 { transform: [{rotateX: '45deg'}, {rotateZ: '0.785398rad'}] } 格式的初始样式
|
|
112
|
+
style.transform.forEach(item => {
|
|
113
|
+
if (item[key] !== undefined)
|
|
114
|
+
initialVal = item[key];
|
|
115
|
+
});
|
|
116
|
+
return initialVal;
|
|
117
|
+
}
|
|
118
|
+
return style[key] === undefined ? transitionSupportedProperty[key] : style[key];
|
|
119
|
+
}
|
|
120
|
+
// animated key transform 格式化
|
|
121
|
+
export function formatAnimatedKeys(keys) {
|
|
122
|
+
// console.log('formatAnimatedKeys keys=', keys)
|
|
123
|
+
const animatedKeys = [];
|
|
124
|
+
const transforms = [];
|
|
125
|
+
keys.forEach(key => {
|
|
126
|
+
if (isTransform(key)) {
|
|
127
|
+
transforms.push(key);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
animatedKeys.push(key);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (transforms.length)
|
|
134
|
+
animatedKeys.push(transforms);
|
|
135
|
+
// console.log('formatAnimatedKeys animatedKeys=', animatedKeys)
|
|
136
|
+
return animatedKeys;
|
|
137
|
+
}
|
|
138
|
+
// 解析动画时长
|
|
139
|
+
export function getUnit(duration) {
|
|
140
|
+
const match = secondRegExp.exec(duration);
|
|
141
|
+
return match ? match[2] === 's' ? +match[1] * 1000 : +match[1] : 0;
|
|
142
|
+
}
|
|
143
|
+
// 根据动画数据创建单个animation
|
|
144
|
+
export function getAnimation({ key, value }, { delay = 0, duration, easing }, callback) {
|
|
145
|
+
// console.log('getAnimation', key, value, delay, duration, easing)
|
|
146
|
+
const animation = typeof callback === 'function'
|
|
147
|
+
? withTiming(value, { duration, easing }, callback)
|
|
148
|
+
: withTiming(value, { duration, easing });
|
|
149
|
+
return delay ? withDelay(delay, animation) : animation;
|
|
150
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
2
|
-
import { NativeSyntheticEvent, Animated } from 'react-native';
|
|
2
|
+
import { NativeSyntheticEvent, Animated, ScaledSize } from 'react-native';
|
|
3
3
|
export type LabelContextValue = MutableRefObject<{
|
|
4
4
|
triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void;
|
|
5
5
|
}>;
|
|
@@ -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>;
|
|
@@ -50,6 +51,10 @@ export interface RouteContextValue {
|
|
|
50
51
|
pageId: number;
|
|
51
52
|
navigation: Record<string, any>;
|
|
52
53
|
}
|
|
54
|
+
export interface DimensionsValue {
|
|
55
|
+
window: ScaledSize;
|
|
56
|
+
screen: ScaledSize;
|
|
57
|
+
}
|
|
53
58
|
export interface StickyContextValue {
|
|
54
59
|
registerStickyHeader: Function;
|
|
55
60
|
unregisterStickyHeader: Function;
|
|
@@ -72,4 +77,3 @@ export declare const ScrollViewContext: import("react").Context<ScrollViewContex
|
|
|
72
77
|
export declare const PortalContext: import("react").Context<PortalContextValue>;
|
|
73
78
|
export declare const StickyContext: import("react").Context<StickyContextValue>;
|
|
74
79
|
export declare const ProviderContext: import("react").Context<null>;
|
|
75
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -5,4 +5,3 @@ export declare const getCustomEvent: (type: string | undefined, oe: any, { detai
|
|
|
5
5
|
}, props?: Props) => any;
|
|
6
6
|
declare const useInnerProps: (props?: Props, userRemoveProps?: RemoveProps, rawConfig?: RawConfig) => Record<string, (e: ExtendedNativeTouchEvent) => void> & Omit<Props, string>;
|
|
7
7
|
export default useInnerProps;
|
|
8
|
-
//# sourceMappingURL=getInnerListeners.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface CameraProps {
|
|
3
|
+
mode?: 'normal' | 'scanCode';
|
|
4
|
+
resolution?: 'low' | 'medium' | 'high';
|
|
5
|
+
devicePosition?: 'front' | 'back';
|
|
6
|
+
flash?: 'auto' | 'on' | 'off';
|
|
7
|
+
frameSize?: 'small' | 'medium' | 'large';
|
|
8
|
+
style?: Record<string, any>;
|
|
9
|
+
bindstop?: () => void;
|
|
10
|
+
binderror?: (error: {
|
|
11
|
+
message: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
bindinitdone?: (result: {
|
|
14
|
+
type: string;
|
|
15
|
+
data: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
bindscancode?: (result: {
|
|
18
|
+
type: string;
|
|
19
|
+
data: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
'parent-font-size'?: number;
|
|
22
|
+
'parent-width'?: number;
|
|
23
|
+
'parent-height'?: number;
|
|
24
|
+
'enable-var'?: boolean;
|
|
25
|
+
'external-var-context'?: any;
|
|
26
|
+
}
|
|
27
|
+
type HandlerRef<T, P> = {
|
|
28
|
+
current: T | null;
|
|
29
|
+
};
|
|
30
|
+
declare const _camera: React.ForwardRefExoticComponent<CameraProps & React.RefAttributes<HandlerRef<any, CameraProps>>>;
|
|
31
|
+
export default _camera;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { createElement, forwardRef, useRef, useCallback, useContext, useState, useEffect } from 'react';
|
|
2
|
+
import { useTransformStyle, useLayout, extendObject } from './utils';
|
|
3
|
+
import useInnerProps, { getCustomEvent } from './getInnerListeners';
|
|
4
|
+
import { noop } from '@mpxjs/utils';
|
|
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;
|
|
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');
|
|
16
|
+
const cameraRef = useRef(null);
|
|
17
|
+
const { mode = 'normal', resolution = 'medium', devicePosition = 'back', flash = 'auto', frameSize = 'medium', bindinitdone, bindstop, bindscancode, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'enable-var': enableVar, 'external-var-context': externalVarContext, style = {} } = props;
|
|
18
|
+
const styleObj = extendObject({}, style);
|
|
19
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, {
|
|
20
|
+
enableVar,
|
|
21
|
+
externalVarContext,
|
|
22
|
+
parentFontSize,
|
|
23
|
+
parentWidth,
|
|
24
|
+
parentHeight
|
|
25
|
+
});
|
|
26
|
+
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: cameraRef });
|
|
27
|
+
const isPhoto = mode === 'normal';
|
|
28
|
+
const device = useCameraDevice(devicePosition || 'back');
|
|
29
|
+
const { navigation } = useContext(RouteContext) || {};
|
|
30
|
+
const [zoomValue, setZoomValue] = useState(1);
|
|
31
|
+
const [hasPermission, setHasPermission] = useState(null);
|
|
32
|
+
const hasCamera = useRef(false);
|
|
33
|
+
// 先定义常量,避免在条件判断后使用
|
|
34
|
+
const maxZoom = device?.maxZoom || 1;
|
|
35
|
+
const RESOLUTION_MAPPING = {
|
|
36
|
+
low: { width: 640, height: 480 },
|
|
37
|
+
medium: { width: 1280, height: 720 },
|
|
38
|
+
high: { width: 1920, height: 1080 }
|
|
39
|
+
};
|
|
40
|
+
const FRAME_SIZE_MAPPING = {
|
|
41
|
+
small: { width: 480, height: 360 },
|
|
42
|
+
medium: { width: 720, height: 540 },
|
|
43
|
+
large: { width: 1080, height: 810 }
|
|
44
|
+
};
|
|
45
|
+
const format = useCameraFormat(device, [
|
|
46
|
+
{
|
|
47
|
+
photoResolution: RESOLUTION_MAPPING[resolution],
|
|
48
|
+
videoResolution: FRAME_SIZE_MAPPING[frameSize] || RESOLUTION_MAPPING[resolution]
|
|
49
|
+
}
|
|
50
|
+
]);
|
|
51
|
+
const codeScanner = useCodeScanner({
|
|
52
|
+
codeTypes: ['qr', 'ean-13'],
|
|
53
|
+
onCodeScanned: (codes) => {
|
|
54
|
+
const result = codes.map(code => code.value).join(',');
|
|
55
|
+
bindscancode && bindscancode(getCustomEvent('scancode', {}, {
|
|
56
|
+
detail: {
|
|
57
|
+
result: codes.map(code => code.value).join(',')
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const onInitialized = useCallback(() => {
|
|
63
|
+
bindinitdone && bindinitdone(getCustomEvent('initdone', {}, {
|
|
64
|
+
detail: {
|
|
65
|
+
maxZoom
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
}, [bindinitdone, maxZoom]);
|
|
69
|
+
const onStopped = useCallback(() => {
|
|
70
|
+
bindstop && bindstop();
|
|
71
|
+
}, [bindstop]);
|
|
72
|
+
const camera = {
|
|
73
|
+
setZoom: (zoom) => {
|
|
74
|
+
setZoomValue(zoom);
|
|
75
|
+
},
|
|
76
|
+
takePhoto: (options = {}) => {
|
|
77
|
+
const { success = noop, fail = noop, complete = noop } = options;
|
|
78
|
+
cameraRef.current?.takePhoto?.({
|
|
79
|
+
flash,
|
|
80
|
+
quality: qualityValue[options.quality || 'normal']
|
|
81
|
+
}).then((res) => {
|
|
82
|
+
const result = {
|
|
83
|
+
errMsg: 'takePhoto:ok',
|
|
84
|
+
tempImagePath: res.path
|
|
85
|
+
};
|
|
86
|
+
success(result);
|
|
87
|
+
complete(result);
|
|
88
|
+
}).catch(() => {
|
|
89
|
+
const result = {
|
|
90
|
+
errMsg: 'takePhoto:fail'
|
|
91
|
+
};
|
|
92
|
+
fail(result);
|
|
93
|
+
complete(result);
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
startRecord: (options = {}) => {
|
|
97
|
+
let { timeout = 30, success = noop, fail = noop, complete = noop, timeoutCallback = noop } = options;
|
|
98
|
+
timeout = timeout > 300 ? 300 : timeout;
|
|
99
|
+
let recordTimer = null;
|
|
100
|
+
let isTimeout = false;
|
|
101
|
+
try {
|
|
102
|
+
const result = {
|
|
103
|
+
errMsg: 'startRecord:ok'
|
|
104
|
+
};
|
|
105
|
+
success(result);
|
|
106
|
+
complete(result);
|
|
107
|
+
cameraRef.current?.startRecording?.({
|
|
108
|
+
flash,
|
|
109
|
+
onRecordingError: (error) => {
|
|
110
|
+
if (recordTimer)
|
|
111
|
+
clearTimeout(recordTimer);
|
|
112
|
+
const errorResult = {
|
|
113
|
+
errMsg: 'startRecord:fail during recording',
|
|
114
|
+
error: error
|
|
115
|
+
};
|
|
116
|
+
timeoutCallback(errorResult);
|
|
117
|
+
},
|
|
118
|
+
onRecordingFinished: (video) => {
|
|
119
|
+
RecordRes = video;
|
|
120
|
+
if (recordTimer)
|
|
121
|
+
clearTimeout(recordTimer);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
recordTimer = setTimeout(() => {
|
|
125
|
+
isTimeout = true;
|
|
126
|
+
cameraRef.current?.stopRecording().catch(() => {
|
|
127
|
+
// 忽略停止录制时的错误
|
|
128
|
+
});
|
|
129
|
+
}, timeout * 1000);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (recordTimer)
|
|
133
|
+
clearTimeout(recordTimer);
|
|
134
|
+
const result = {
|
|
135
|
+
errMsg: 'startRecord:fail ' + (error.message || 'unknown error')
|
|
136
|
+
};
|
|
137
|
+
fail(result);
|
|
138
|
+
complete(result);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
stopRecord: (options = {}) => {
|
|
142
|
+
const { success = noop, fail = noop, complete = noop } = options;
|
|
143
|
+
try {
|
|
144
|
+
cameraRef.current?.stopRecording().then(() => {
|
|
145
|
+
setTimeout(() => {
|
|
146
|
+
if (RecordRes) {
|
|
147
|
+
const result = {
|
|
148
|
+
errMsg: 'stopRecord:ok',
|
|
149
|
+
tempVideoPath: RecordRes?.path,
|
|
150
|
+
duration: RecordRes.duration * 1000 // 转成ms
|
|
151
|
+
};
|
|
152
|
+
RecordRes = null;
|
|
153
|
+
success(result);
|
|
154
|
+
complete(result);
|
|
155
|
+
}
|
|
156
|
+
}, 200); // 延时200ms,确保录制结果已准备好
|
|
157
|
+
}).catch((e) => {
|
|
158
|
+
const result = {
|
|
159
|
+
errMsg: 'stopRecord:fail ' + (e.message || 'promise rejected')
|
|
160
|
+
};
|
|
161
|
+
fail(result);
|
|
162
|
+
complete(result);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
const result = {
|
|
167
|
+
errMsg: 'stopRecord:fail ' + (error.message || 'unknown error')
|
|
168
|
+
};
|
|
169
|
+
fail(result);
|
|
170
|
+
complete(result);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (navigation) {
|
|
176
|
+
if (navigation && !navigation.camera) {
|
|
177
|
+
navigation.camera = camera;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
hasCamera.current = true;
|
|
181
|
+
navigation.camera.multi = true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const checkCameraPermission = async () => {
|
|
185
|
+
try {
|
|
186
|
+
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission;
|
|
187
|
+
if (typeof cameraPermission === 'function') {
|
|
188
|
+
const permissionResult = await cameraPermission();
|
|
189
|
+
setHasPermission(permissionResult === true);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
setHasPermission(true);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
setHasPermission(false);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
checkCameraPermission();
|
|
200
|
+
return () => {
|
|
201
|
+
if (navigation && navigation.camera) {
|
|
202
|
+
navigation.camera = null;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}, []);
|
|
206
|
+
const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
|
|
207
|
+
ref: cameraRef,
|
|
208
|
+
style: extendObject({}, normalStyle, layoutStyle),
|
|
209
|
+
isActive: true,
|
|
210
|
+
photo: true,
|
|
211
|
+
video: true,
|
|
212
|
+
onInitialized,
|
|
213
|
+
onStopped,
|
|
214
|
+
device,
|
|
215
|
+
format,
|
|
216
|
+
codeScanner: !isPhoto ? codeScanner : undefined,
|
|
217
|
+
zoom: zoomValue
|
|
218
|
+
}), [
|
|
219
|
+
'mode',
|
|
220
|
+
'resolution',
|
|
221
|
+
'frame-size',
|
|
222
|
+
'bindinitdone',
|
|
223
|
+
'bindstop',
|
|
224
|
+
'flash',
|
|
225
|
+
'bindscancode',
|
|
226
|
+
'binderror'
|
|
227
|
+
], {
|
|
228
|
+
layoutRef
|
|
229
|
+
});
|
|
230
|
+
if (!hasPermission || hasCamera.current || !device) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
return createElement(Camera, innerProps);
|
|
234
|
+
});
|
|
235
|
+
_camera.displayName = 'MpxCamera';
|
|
236
|
+
export default _camera;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
declare const _default: "<html><head>\n <meta content=\"width=device-width, initial-scale=1, maximum-scale=1, user-scaleable=no\" name=\"viewport\">\n <style>\n html {\n -ms-content-zooming: none;\n -ms-touch-action: pan-x pan-y;\n }\n body {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n margin: 0;\n padding: 0;\n overflow: hidden;\n }\n * {\n user-select: none;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n }\n </style>\n </head>\n <body>\n <script>\n var scale = function (ratio) {\n return function (item) {\n if (typeof item === \"number\") {\n return item * ratio;\n }\n return item;\n };\n};\nfunction autoScaleCanvas(canvas) {\n var ctx = canvas.getContext(\"2d\");\n var ratio = window.devicePixelRatio || 1;\n if (ratio !== 1) {\n canvas.width *= ratio;\n canvas.height *= ratio;\n ctx.scale(ratio, ratio);\n ctx.isPointInPath = function () {\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n return CanvasRenderingContext2D.prototype.isPointInPath.apply(ctx, args.map(scale(ratio)));\n };\n }\n return canvas;\n}\nwindow.autoScaleCanvas = autoScaleCanvas;\n</script>\n<script>\n\nvar WEBVIEW_TARGET = '@@WEBVIEW_TARGET';\n\nvar ID = function () {\n return Math.random().toString(32).slice(2);\n};\n\nvar flattenObjectCopyValue = function (flatObj, srcObj, key) {\n var value = srcObj[key];\n if (typeof value === 'function') {\n return;\n }\n if (typeof value === 'object' && value instanceof Node) {\n return;\n }\n flatObj[key] = flattenObject(value);\n};\n\nvar flattenObject = function (object) {\n if (typeof object !== 'object' || object === null) {\n return object;\n }\n // Handle TypedArray\n if (object instanceof Uint8ClampedArray) {\n return Array.from(object);\n }\n var flatObject = {};\n for (var key in object) {\n flattenObjectCopyValue(flatObject, object, key);\n }\n for (var key in Object.getOwnPropertyNames(object)) {\n flattenObjectCopyValue(flatObject, object, key);\n }\n return flatObject;\n};\n\nvar AutoScaledCanvas = function (element) {\n this.element = element;\n};\n\nAutoScaledCanvas.prototype.toDataURL = function () {\n return this.element.toDataURL.apply(this.element, arguments);\n};\n\nAutoScaledCanvas.prototype.autoScale = function () {\n if (this.savedHeight !== undefined) {\n this.element.height = this.savedHeight;\n }\n if (this.savedWidth !== undefined) {\n this.element.width = this.savedWidth;\n }\n window.autoScaleCanvas(this.element);\n};\n\nObject.defineProperty(AutoScaledCanvas.prototype, 'width', {\n get: function () {\n return this.element.width;\n },\n set: function (value) {\n this.savedWidth = value;\n this.autoScale();\n return value;\n },\n});\n\nObject.defineProperty(AutoScaledCanvas.prototype, 'height', {\n get: function () {\n return this.element.height;\n },\n set: function (value) {\n this.savedHeight = value;\n this.autoScale();\n return value;\n },\n});\nvar toMessage = function (result) {\n if (result instanceof Blob) {\n return {\n type: 'blob',\n payload: btoa(result),\n meta: {},\n };\n }\n if (result instanceof Object) {\n if (!result[WEBVIEW_TARGET]) {\n var id = ID();\n result[WEBVIEW_TARGET] = id;\n targets[id] = result;\n }\n return {\n type: 'json',\n payload: flattenObject(result),\n args: toArgs(flattenObject(result)),\n meta: {\n target: result[WEBVIEW_TARGET],\n constructor: result.__constructorName__ || result.constructor.name,\n },\n };\n }\n return {\n type: 'json',\n payload: typeof result === 'string' ? result : JSON.stringify(result),\n meta: {},\n };\n};\nvar toArgs = function (result) {\n var args = [];\n for (var key in result) {\n if (result[key] !== undefined && key !== '@@WEBVIEW_TARGET') {\n args.push(result[key]);\n }\n }\n return args;\n};\n\nvar createObjectsFromArgs = function (args) {\n for (var index = 0; index < args.length; index += 1) {\n var currentArg = args[index];\n if (currentArg && currentArg.className !== undefined) {\n var className = currentArg.className, classArgs = currentArg.classArgs;\n // new ImageData,第一个参数需要是 Uint8ClampedArray\n var object = new (Function.prototype.bind.apply(constructors[className], [null].concat(classArgs)))();\n args[index] = object;\n }\n }\n return args;\n};\n\nvar canvas = document.createElement('canvas');\ncanvas.style.width = '100%';\ncanvas.style.height = '100%';\nvar autoScaledCanvas = new AutoScaledCanvas(canvas);\n\nvar targets = {\n canvas: autoScaledCanvas,\n context2D: canvas.getContext('2d'),\n};\n\nvar constructors = {\n CanvasGradient: CanvasGradient,\n Image: Image,\n ImageData: ImageData,\n Uint8ClampedArray: Uint8ClampedArray,\n};\n\nImage.bind =\n Image.bind ||\n function () {\n return Image;\n };\n\nImageData.bind =\n ImageData.bind ||\n function () {\n return ImageData;\n };\nUint8ClampedArray.bind =\n Uint8ClampedArray.bind ||\n function () {\n return Uint8ClampedArray;\n };\n\nvar populateRefs = function (arg) {\n if (arg && arg.__ref__) {\n return targets[arg.__ref__];\n }\n return arg;\n};\ndocument.body.appendChild(canvas);\n\nvar mergeObjects = function (target, source) {\n for (var key in source) {\n if (source.hasOwnProperty(key)) {\n target[key] = source[key];\n }\n }\n return target;\n};\n\nfunction handleMessage(message) {\n var id = message.id,\n type = message.type,\n payload = message.payload;\n\n switch (type) {\n case 'exec': {\n var target = payload.target,\n method = payload.method,\n args = payload.args;\n var result = targets[target][method].apply(targets[target], args.map(populateRefs));\n var msg = toMessage(result);\n\n if (typeof result === 'object' && !msg.meta.constructor) {\n for (var constructorName in constructors) {\n if (result instanceof constructors[constructorName]) {\n msg.meta.constructor = constructorName;\n }\n }\n }\n window.ReactNativeWebView.postMessage(JSON.stringify(mergeObjects({ id: id }, msg)));\n break;\n }\n case 'set': {\n var target = payload.target,\n key = payload.key,\n value = payload.value;\n targets[target][key] = populateRefs(value);\n break;\n }\n case 'construct': {\n var constructor = payload.constructor,\n target = payload.id,\n args = payload.args || [];\n var newArgs = createObjectsFromArgs(args);\n var object;\n try {\n object = new (Function.prototype.bind.apply(constructors[constructor], [null].concat(newArgs)))();\n }\n catch (error) {\n throw new Error('Error while constructing '.concat(constructor, ' ').concat(error.message));\n }\n object.__constructorName__ = constructor;\n var msg = toMessage({});\n targets[target] = object;\n window.ReactNativeWebView.postMessage(JSON.stringify(mergeObjects({ id: id }, msg)));\n break;\n }\n case 'listen': {\n var types = payload.types,\n target = payload.target;\n for (var i = 0; i < types.length; i++) {\n var eventType = types[i];\n targets[target].addEventListener(eventType, function (e) {\n const message = toMessage({\n type: 'event',\n payload: {\n type: e.type,\n target: mergeObjects(flattenObject(targets[target]), {\n [WEBVIEW_TARGET]: target,\n }),\n },\n });\n window.ReactNativeWebView.postMessage(\n JSON.stringify(mergeObjects({ id: id }, message))\n );\n });\n }\n break;\n}\n }\n}\nvar handleError = function (err, message) {\n window.ReactNativeWebView.postMessage(JSON.stringify({\n id: message.id,\n type: 'error',\n payload: {\n message: err.message,\n stack: err.stack,\n },\n }));\n document.removeEventListener('message', handleIncomingMessage);\n};\n\nfunction handleIncomingMessage(data) {\n if (Array.isArray(data)) {\n for (var i = 0; i < data.length; i++) {\n try {\n handleMessage(data[i]);\n } catch (err) {\n handleError(err, data[i]);\n }\n }\n } else {\n try {\n handleMessage(data);\n } catch (err) {\n handleError(err, data);\n }\n }\n}\n\nwindow.mpxWebviewMessageCallback = handleIncomingMessage\n</script>\n \n\n</body></html>";
|
|
2
2
|
export default _default;
|
|
3
|
-
//# sourceMappingURL=html.d.ts.map
|
|
@@ -18,4 +18,3 @@ export interface CheckboxGroupProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare const CheckboxGroup: import("react").ForwardRefExoticComponent<CheckboxGroupProps & import("react").RefAttributes<HandlerRef<View, CheckboxGroupProps>>>;
|
|
20
20
|
export default CheckboxGroup;
|
|
21
|
-
//# sourceMappingURL=mpx-checkbox-group.d.ts.map
|
|
@@ -30,4 +30,3 @@ export interface CheckboxProps extends Selection {
|
|
|
30
30
|
}
|
|
31
31
|
declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxProps & import("react").RefAttributes<HandlerRef<View, CheckboxProps>>>;
|
|
32
32
|
export default Checkbox;
|
|
33
|
-
//# sourceMappingURL=mpx-checkbox.d.ts.map
|