@mpxjs/webpack-plugin 2.10.15 → 2.10.16-beta.11
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/dependencies/AppEntryDependency.js +2 -2
- package/lib/dependencies/DynamicEntryDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +102 -0
- package/lib/dependencies/RecordModuleIdMapDependency.js +49 -0
- package/lib/dependencies/ResolveDependency.js +1 -1
- package/lib/{retry-runtime-module.js → dependencies/RetryRuntimeModule.js} +1 -1
- package/lib/file-loader.js +13 -3
- package/lib/helpers.js +2 -0
- package/lib/index.js +51 -25
- package/lib/json-compiler/helper.js +72 -2
- package/lib/json-compiler/index.js +16 -56
- package/lib/json-compiler/plugin.js +2 -2
- package/lib/loader.js +10 -4
- package/lib/native-loader.js +6 -3
- package/lib/platform/json/wx/index.js +30 -29
- package/lib/platform/style/wx/index.js +8 -1
- package/lib/platform/template/wx/component-config/ad.js +5 -0
- package/lib/platform/template/wx/component-config/button.js +21 -5
- 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/component.js +31 -33
- 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/fix-component-name.js +2 -2
- 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 +10 -0
- 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 +20 -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 +19 -2
- 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/index.js +2 -0
- package/lib/react/processJSON.js +39 -71
- package/lib/react/processStyles.js +3 -2
- package/lib/react/processTemplate.js +8 -6
- package/lib/react/script-helper.js +6 -16
- package/lib/react/style-helper.js +10 -2
- package/lib/resolver/AddEnvPlugin.js +13 -0
- package/lib/resolver/AddModePlugin.js +18 -0
- package/lib/runtime/components/react/context.ts +13 -6
- package/lib/runtime/components/react/dist/context.d.ts +76 -0
- package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/event.config.d.ts +8 -0
- package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +8 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts +69 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-camera.jsx +197 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +11 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts +28 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts +22 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.jsx +81 -37
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts +51 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +40 -12
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +61 -50
- package/lib/runtime/components/react/dist/mpx-label.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +66 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +107 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +4 -3
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +12 -18
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +8 -11
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +20 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +30 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-progress.jsx +26 -22
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +2 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +25 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +55 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -14
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +18 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +9 -5
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.jsx +33 -5
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +102 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts +35 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.jsx +8 -11
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +1 -1
- package/lib/runtime/components/react/dist/parser.d.ts +40 -0
- package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +33 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +12 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.d.ts +123 -0
- package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.jsx +16 -6
- package/lib/runtime/components/react/mpx-camera.tsx +275 -0
- package/lib/runtime/components/react/mpx-image.tsx +89 -42
- package/lib/runtime/components/react/mpx-input.tsx +50 -18
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +69 -49
- package/lib/runtime/components/react/mpx-nav.tsx +155 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +5 -2
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +26 -21
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +8 -12
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +55 -0
- package/lib/runtime/components/react/mpx-portal/index.tsx +8 -2
- package/lib/runtime/components/react/mpx-progress.tsx +26 -24
- package/lib/runtime/components/react/mpx-scroll-view.tsx +6 -17
- package/lib/runtime/components/react/mpx-slider.tsx +444 -0
- package/lib/runtime/components/react/mpx-swiper.tsx +9 -5
- package/lib/runtime/components/react/mpx-text.tsx +38 -5
- package/lib/runtime/components/react/mpx-view.tsx +8 -11
- package/lib/runtime/components/react/mpx-web-view.tsx +1 -1
- package/lib/runtime/components/react/types/common.d.ts +19 -0
- package/lib/runtime/components/react/utils.tsx +15 -6
- package/lib/runtime/components/web/mpx-input.vue +1 -1
- package/lib/runtime/components/web/mpx-scroll-view.vue +7 -1
- package/lib/runtime/components/web/mpx-video.vue +12 -1
- package/lib/runtime/optionProcessor.js +3 -1
- package/lib/runtime/optionProcessorReact.js +4 -2
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +2 -2
- package/lib/style-compiler/index.js +3 -2
- package/lib/style-compiler/load-postcss-config.js +1 -1
- package/lib/style-compiler/plugins/trans-special.js +10 -2
- package/lib/style-compiler/strip-conditional-loader.js +178 -15
- package/lib/template-compiler/bind-this.js +2 -2
- package/lib/template-compiler/compiler.js +277 -77
- package/lib/template-compiler/gen-node-react.js +18 -6
- package/lib/template-compiler/index.js +12 -10
- package/lib/template-compiler/parse-exps.js +1 -1
- package/lib/utils/chain-assign.js +47 -0
- package/lib/utils/check-core-version-match.js +75 -15
- package/lib/utils/const.js +2 -1
- package/lib/utils/dom-tag-config.js +6 -6
- package/lib/utils/env.js +6 -1
- package/lib/utils/get-build-tag-component.js +35 -0
- package/lib/utils/pre-process-json.js +5 -0
- package/lib/web/index.js +2 -0
- package/lib/web/processJSON.js +44 -16
- package/lib/web/processScript.js +1 -1
- package/lib/web/processTemplate.js +6 -4
- package/lib/web/script-helper.js +19 -9
- package/lib/wxs/pre-loader.js +6 -6
- package/lib/wxss/loader.js +1 -9
- package/package.json +17 -5
- package/LICENSE +0 -433
- package/lib/dependencies/ImportDependencyTemplate.js +0 -50
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
2
|
+
import { NativeSyntheticEvent, Animated } from 'react-native';
|
|
3
|
+
export type LabelContextValue = MutableRefObject<{
|
|
4
|
+
triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void;
|
|
5
|
+
}>;
|
|
6
|
+
export type KeyboardAvoidContextValue = MutableRefObject<{
|
|
7
|
+
cursorSpacing: number;
|
|
8
|
+
ref: MutableRefObject<any>;
|
|
9
|
+
adjustPosition: boolean;
|
|
10
|
+
holdKeyboard?: boolean;
|
|
11
|
+
keyboardHeight?: number;
|
|
12
|
+
onKeyboardShow?: () => void;
|
|
13
|
+
} | null>;
|
|
14
|
+
export interface GroupValue {
|
|
15
|
+
[key: string]: {
|
|
16
|
+
checked: boolean;
|
|
17
|
+
setValue: Dispatch<SetStateAction<boolean>>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface GroupContextValue {
|
|
21
|
+
groupValue: GroupValue;
|
|
22
|
+
notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface FormFieldValue {
|
|
25
|
+
getValue: () => any;
|
|
26
|
+
resetValue: ({ newVal, type }: {
|
|
27
|
+
newVal?: any;
|
|
28
|
+
type?: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface FormContextValue {
|
|
32
|
+
formValuesMap: Map<string, FormFieldValue>;
|
|
33
|
+
submit: () => void;
|
|
34
|
+
reset: () => void;
|
|
35
|
+
}
|
|
36
|
+
export interface IntersectionObserver {
|
|
37
|
+
[key: number]: {
|
|
38
|
+
throttleMeasure: () => void;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface PortalContextValue {
|
|
42
|
+
mount: (children: React.ReactNode, key?: number | null, id?: number | null) => number | undefined;
|
|
43
|
+
update: (key: number, children: React.ReactNode) => void;
|
|
44
|
+
unmount: (key: number) => void;
|
|
45
|
+
}
|
|
46
|
+
export interface ScrollViewContextValue {
|
|
47
|
+
gestureRef: React.RefObject<any> | null;
|
|
48
|
+
scrollOffset: Animated.Value;
|
|
49
|
+
}
|
|
50
|
+
export interface RouteContextValue {
|
|
51
|
+
pageId: number;
|
|
52
|
+
navigation: Record<string, any>;
|
|
53
|
+
}
|
|
54
|
+
export interface StickyContextValue {
|
|
55
|
+
registerStickyHeader: Function;
|
|
56
|
+
unregisterStickyHeader: Function;
|
|
57
|
+
}
|
|
58
|
+
export declare const MovableAreaContext: import("react").Context<{
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
}>;
|
|
62
|
+
export declare const FormContext: import("react").Context<FormContextValue | null>;
|
|
63
|
+
export declare const CheckboxGroupContext: import("react").Context<GroupContextValue | null>;
|
|
64
|
+
export declare const RadioGroupContext: import("react").Context<GroupContextValue | null>;
|
|
65
|
+
export declare const LabelContext: import("react").Context<LabelContextValue | null>;
|
|
66
|
+
export declare const PickerContext: import("react").Context<null>;
|
|
67
|
+
export declare const VarContext: import("react").Context<{}>;
|
|
68
|
+
export declare const IntersectionObserverContext: import("react").Context<IntersectionObserver | null>;
|
|
69
|
+
export declare const RouteContext: import("react").Context<RouteContextValue | null>;
|
|
70
|
+
export declare const SwiperContext: import("react").Context<{}>;
|
|
71
|
+
export declare const KeyboardAvoidContext: import("react").Context<KeyboardAvoidContextValue | null>;
|
|
72
|
+
export declare const ScrollViewContext: import("react").Context<ScrollViewContextValue>;
|
|
73
|
+
export declare const PortalContext: import("react").Context<PortalContextValue>;
|
|
74
|
+
export declare const StickyContext: import("react").Context<StickyContextValue>;
|
|
75
|
+
export declare const ProviderContext: import("react").Context<null>;
|
|
76
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAE,gBAAgB,EAAE,cA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zE,eAAO,MAAM,aAAa,6BAAoB,CAAA;AAE9C,eAAO,MAAM,oBAAoB,2DAAwD,CAAA;AAEzF,eAAO,MAAM,iBAAiB,iDAAmG,CAAA;AAEjI,eAAO,MAAM,aAAa,6CAAiD,CAAA;AAE3E,eAAO,MAAM,aAAa,6CAAkG,CAAA;AAE5H,eAAO,MAAM,eAAe,+BAAsB,CAAA"}
|
|
@@ -15,3 +15,4 @@ export const KeyboardAvoidContext = createContext(null);
|
|
|
15
15
|
export const ScrollViewContext = createContext({ gestureRef: null, scrollOffset: new Animated.Value(0) });
|
|
16
16
|
export const PortalContext = createContext(null);
|
|
17
17
|
export const StickyContext = createContext({ registerStickyHeader: noop, unregisterStickyHeader: noop });
|
|
18
|
+
export const ProviderContext = createContext(null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.config.d.ts","sourceRoot":"","sources":["../event.config.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAyB3E,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Props, RawConfig, RemoveProps, LayoutRef, ExtendedNativeTouchEvent } from './types/getInnerListeners';
|
|
2
|
+
export declare const getCustomEvent: (type: string | undefined, oe: any, { detail, layoutRef }: {
|
|
3
|
+
detail?: Record<string, unknown> | undefined;
|
|
4
|
+
layoutRef?: LayoutRef | undefined;
|
|
5
|
+
}, props?: Props) => any;
|
|
6
|
+
declare const useInnerProps: (props?: Props, userRemoveProps?: RemoveProps, rawConfig?: RawConfig) => Record<string, (e: ExtendedNativeTouchEvent) => void> & Omit<Props, string>;
|
|
7
|
+
export default useInnerProps;
|
|
8
|
+
//# sourceMappingURL=getInnerListeners.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getInnerListeners.d.ts","sourceRoot":"","sources":["../getInnerListeners.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,EAEL,SAAS,EAET,WAAW,EAEX,SAAS,EACT,wBAAwB,EAEzB,MAAM,2BAA2B,CAAA;AAsElC,eAAO,MAAM,cAAc,iCAErB,GAAG;;;WAKA,KAAK,QAgBb,CAAA;AAyID,QAAA,MAAM,aAAa,WACV,KAAK,6CAEA,SAAS,wBA8Dc,wBAAwB,KAAK,IAAI,uBA2BrE,CAAA;AACD,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
interface AsyncSuspenseProps {
|
|
3
|
+
type: 'component' | 'page';
|
|
4
|
+
chunkName: string;
|
|
5
|
+
moduleId: string;
|
|
6
|
+
innerProps: any;
|
|
7
|
+
getLoading?: () => ComponentType<unknown>;
|
|
8
|
+
getFallback?: () => ComponentType<unknown>;
|
|
9
|
+
getChildren: () => Promise<ReactNode>;
|
|
10
|
+
}
|
|
11
|
+
declare const AsyncSuspense: React.FC<AsyncSuspenseProps>;
|
|
12
|
+
export default AsyncSuspense;
|
|
13
|
+
//# sourceMappingURL=mpx-async-suspense.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-async-suspense.d.ts","sourceRoot":"","sources":["../mpx-async-suspense.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAkC,SAAS,EAAiB,MAAM,OAAO,CAAA;AAiGzG,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,GAAG,MAAM,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,GAAG,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;IACzC,WAAW,CAAC,EAAE,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;IAC1C,WAAW,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;CACtC;AAID,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6E/C,CAAA;AAID,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✔ size
|
|
3
|
+
* ✔ type
|
|
4
|
+
* ✔ plain
|
|
5
|
+
* ✔ disabled
|
|
6
|
+
* ✔ loading
|
|
7
|
+
* ✔ form-type
|
|
8
|
+
* - open-type: Partially. Only support `share`、`getUserInfo`
|
|
9
|
+
* ✔ hover-class: Convert hoverClass to hoverStyle.
|
|
10
|
+
* ✔ hover-style
|
|
11
|
+
* ✘ hover-stop-propagation
|
|
12
|
+
* ✔ hover-start-time
|
|
13
|
+
* ✔ hover-stay-time
|
|
14
|
+
* ✘ lang
|
|
15
|
+
* ✘ session-from
|
|
16
|
+
* ✘ send-message-title
|
|
17
|
+
* ✘ send-message-path
|
|
18
|
+
* ✘ send-message-img
|
|
19
|
+
* ✘ app-parameter
|
|
20
|
+
* ✘ show-message-card
|
|
21
|
+
* ✘ phone-number-no-quota-toast
|
|
22
|
+
* ✘ bindgetuserinfo
|
|
23
|
+
* ✘ bindcontact
|
|
24
|
+
* ✘ createliveactivity
|
|
25
|
+
* ✘ bindgetphonenumber
|
|
26
|
+
* ✘ bindgetphonenumber
|
|
27
|
+
* ✘ bindgetrealtimephonenumber
|
|
28
|
+
* ✘ binderror
|
|
29
|
+
* ✘ bindopensetting
|
|
30
|
+
* ✘ bindlaunchapp
|
|
31
|
+
* ✘ bindlaunchapp
|
|
32
|
+
* ✘ bindchooseavatar
|
|
33
|
+
* ✘ bindchooseavatar
|
|
34
|
+
* ✘ bindagreeprivacyauthorization
|
|
35
|
+
* ✔ bindtap
|
|
36
|
+
*/
|
|
37
|
+
import { ReactNode } from 'react';
|
|
38
|
+
import { View, ViewStyle, TextStyle, NativeSyntheticEvent } from 'react-native';
|
|
39
|
+
import { HandlerRef } from './useNodesRef';
|
|
40
|
+
import type { ExtendedViewStyle } from './types/common';
|
|
41
|
+
export type Type = 'default' | 'primary' | 'warn';
|
|
42
|
+
export type OpenType = 'share' | 'getUserInfo';
|
|
43
|
+
export type OpenTypeEvent = 'onShareAppMessage' | 'onUserInfo';
|
|
44
|
+
export interface ButtonProps {
|
|
45
|
+
size?: string;
|
|
46
|
+
type?: Type;
|
|
47
|
+
plain?: boolean;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
loading?: boolean;
|
|
50
|
+
'hover-class'?: string;
|
|
51
|
+
'hover-style'?: ExtendedViewStyle;
|
|
52
|
+
'hover-start-time'?: number;
|
|
53
|
+
'hover-stay-time'?: number;
|
|
54
|
+
'open-type'?: OpenType;
|
|
55
|
+
'form-type'?: 'submit' | 'reset';
|
|
56
|
+
'enable-offset'?: boolean;
|
|
57
|
+
'enable-var'?: boolean;
|
|
58
|
+
'external-var-context'?: Record<string, any>;
|
|
59
|
+
'parent-font-size'?: number;
|
|
60
|
+
'parent-width'?: number;
|
|
61
|
+
'parent-height'?: number;
|
|
62
|
+
style?: ViewStyle & TextStyle & Record<string, any>;
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
bindgetuserinfo?: (userInfo: any) => void;
|
|
65
|
+
bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
66
|
+
}
|
|
67
|
+
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HandlerRef<View, ButtonProps>>>;
|
|
68
|
+
export default Button;
|
|
69
|
+
//# sourceMappingURL=mpx-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mpx-button.d.ts","sourceRoot":"","sources":["../mpx-button.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAoC,SAAS,EAA+B,MAAM,OAAO,CAAA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AAQ,EAAE,GAAG,KAAK,IAAI,CAAA;IACzC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,UAAU,CAAC,GAAG,OAAO,KAAK,IAAI,CAAA;CACpE;AA4GD,QAAA,MAAM,MAAM,uHAqOV,CAAA;AAIF,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
22
|
+
type HandlerRef<T, P> = {
|
|
23
|
+
current: T | null;
|
|
24
|
+
};
|
|
25
|
+
declare const _camera: React.ForwardRefExoticComponent<CameraProps & React.RefAttributes<HandlerRef<any, CameraProps>>>;
|
|
26
|
+
export default _camera;
|
|
27
|
+
//# sourceMappingURL=mpx-camera.d.ts.map
|
|
@@ -0,0 +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,kGAkNX,CAAA;AAIF,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
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 } = props;
|
|
18
|
+
const isPhoto = mode === 'normal';
|
|
19
|
+
const device = useCameraDevice(devicePosition || 'back');
|
|
20
|
+
const { navigation } = useContext(RouteContext) || {};
|
|
21
|
+
const [zoomValue, setZoomValue] = useState(1);
|
|
22
|
+
const [hasPermission, setHasPermission] = useState(null);
|
|
23
|
+
const hasCamera = useRef(false);
|
|
24
|
+
// 先定义常量,避免在条件判断后使用
|
|
25
|
+
const maxZoom = device?.maxZoom || 1;
|
|
26
|
+
const RESOLUTION_MAPPING = {
|
|
27
|
+
low: { width: 640, height: 480 },
|
|
28
|
+
medium: { width: 1280, height: 720 },
|
|
29
|
+
high: { width: 1920, height: 1080 }
|
|
30
|
+
};
|
|
31
|
+
const FRAME_SIZE_MAPPING = {
|
|
32
|
+
small: { width: 480, height: 360 },
|
|
33
|
+
medium: { width: 720, height: 540 },
|
|
34
|
+
large: { width: 1080, height: 810 }
|
|
35
|
+
};
|
|
36
|
+
// 所有 Hooks 必须在条件判断之前调用
|
|
37
|
+
const format = useCameraFormat(device, [
|
|
38
|
+
{
|
|
39
|
+
photoResolution: RESOLUTION_MAPPING[resolution],
|
|
40
|
+
videoResolution: FRAME_SIZE_MAPPING[frameSize] || RESOLUTION_MAPPING[resolution]
|
|
41
|
+
}
|
|
42
|
+
]);
|
|
43
|
+
const codeScanner = useCodeScanner({
|
|
44
|
+
codeTypes: ['qr', 'ean-13'],
|
|
45
|
+
onCodeScanned: (codes) => {
|
|
46
|
+
const result = codes.map(code => code.value).join(',');
|
|
47
|
+
bindscancode && bindscancode(getCustomEvent('scancode', {}, {
|
|
48
|
+
detail: {
|
|
49
|
+
result: codes.map(code => code.value).join(',')
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const onInitialized = useCallback(() => {
|
|
55
|
+
bindinitdone && bindinitdone(getCustomEvent('initdone', {}, {
|
|
56
|
+
detail: {
|
|
57
|
+
maxZoom
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
}, [bindinitdone, maxZoom]);
|
|
61
|
+
const onStopped = useCallback(() => {
|
|
62
|
+
bindstop && bindstop();
|
|
63
|
+
}, [bindstop]);
|
|
64
|
+
const camera = {
|
|
65
|
+
setZoom: (zoom) => {
|
|
66
|
+
setZoomValue(zoom);
|
|
67
|
+
},
|
|
68
|
+
takePhoto: (options = {}) => {
|
|
69
|
+
const { success = noop, fail = noop, complete = noop } = options;
|
|
70
|
+
cameraRef.current?.takePhoto?.({
|
|
71
|
+
quality: qualityValue[options.quality || 'normal']
|
|
72
|
+
}).then((res) => {
|
|
73
|
+
const result = {
|
|
74
|
+
errMsg: 'takePhoto:ok',
|
|
75
|
+
tempImagePath: res.path
|
|
76
|
+
};
|
|
77
|
+
success(result);
|
|
78
|
+
complete(result);
|
|
79
|
+
}).catch(() => {
|
|
80
|
+
const result = {
|
|
81
|
+
errMsg: 'takePhoto:fail'
|
|
82
|
+
};
|
|
83
|
+
fail(result);
|
|
84
|
+
complete(result);
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
startRecord: (options = {}) => {
|
|
88
|
+
let { timeout = 30, success = noop, fail = noop, complete = noop, timeoutCallback = noop } = options;
|
|
89
|
+
timeout = timeout > 300 ? 300 : timeout;
|
|
90
|
+
let recordTimer = null;
|
|
91
|
+
let isTimeout = false;
|
|
92
|
+
try {
|
|
93
|
+
const result = {
|
|
94
|
+
errMsg: 'startRecord:ok'
|
|
95
|
+
};
|
|
96
|
+
success(result);
|
|
97
|
+
complete(result);
|
|
98
|
+
cameraRef.current?.startRecording?.({
|
|
99
|
+
onRecordingError: (error) => {
|
|
100
|
+
if (recordTimer)
|
|
101
|
+
clearTimeout(recordTimer);
|
|
102
|
+
const errorResult = {
|
|
103
|
+
errMsg: 'startRecord:fail during recording',
|
|
104
|
+
error: error
|
|
105
|
+
};
|
|
106
|
+
timeoutCallback(errorResult);
|
|
107
|
+
},
|
|
108
|
+
onRecordingFinished: (video) => {
|
|
109
|
+
RecordRes = video;
|
|
110
|
+
if (recordTimer)
|
|
111
|
+
clearTimeout(recordTimer);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
recordTimer = setTimeout(() => {
|
|
115
|
+
isTimeout = true;
|
|
116
|
+
cameraRef.current?.stopRecording().catch(() => {
|
|
117
|
+
// 忽略停止录制时的错误
|
|
118
|
+
});
|
|
119
|
+
}, timeout * 1000);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (recordTimer)
|
|
123
|
+
clearTimeout(recordTimer);
|
|
124
|
+
const result = {
|
|
125
|
+
errMsg: 'startRecord:fail ' + (error.message || 'unknown error')
|
|
126
|
+
};
|
|
127
|
+
fail(result);
|
|
128
|
+
complete(result);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
stopRecord: (options = {}) => {
|
|
132
|
+
const { success = noop, fail = noop, complete = noop } = options;
|
|
133
|
+
try {
|
|
134
|
+
cameraRef.current?.stopRecording().then(() => {
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
if (RecordRes) {
|
|
137
|
+
const result = {
|
|
138
|
+
errMsg: 'stopRecord:ok',
|
|
139
|
+
tempVideoPath: RecordRes?.path,
|
|
140
|
+
duration: RecordRes.duration * 1000 // 转成ms
|
|
141
|
+
};
|
|
142
|
+
RecordRes = null;
|
|
143
|
+
success(result);
|
|
144
|
+
complete(result);
|
|
145
|
+
}
|
|
146
|
+
}, 200); // 延时200ms,确保录制结果已准备好
|
|
147
|
+
}).catch((e) => {
|
|
148
|
+
const result = {
|
|
149
|
+
errMsg: 'stopRecord:fail ' + (e.message || 'promise rejected')
|
|
150
|
+
};
|
|
151
|
+
fail(result);
|
|
152
|
+
complete(result);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
const result = {
|
|
157
|
+
errMsg: 'stopRecord:fail ' + (error.message || 'unknown error')
|
|
158
|
+
};
|
|
159
|
+
fail(result);
|
|
160
|
+
complete(result);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
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) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
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}/>);
|
|
195
|
+
});
|
|
196
|
+
_camera.displayName = 'MpxCamera';
|
|
197
|
+
export default _camera;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
interface Message {
|
|
3
|
+
id?: string;
|
|
4
|
+
type: string;
|
|
5
|
+
payload?: any;
|
|
6
|
+
}
|
|
7
|
+
export default class Bus {
|
|
8
|
+
_paused: Boolean;
|
|
9
|
+
_messageListeners: {
|
|
10
|
+
[key: string]: (message: Message) => void;
|
|
11
|
+
};
|
|
12
|
+
_queue: Message[];
|
|
13
|
+
_send: (message: Message | Message[]) => void;
|
|
14
|
+
_timeoutId: NodeJS.Timeout | null;
|
|
15
|
+
constructor(send: (message: Message | Message[]) => void);
|
|
16
|
+
post(message: Message): Promise<any>;
|
|
17
|
+
handle(message: Message): void;
|
|
18
|
+
pause(): void;
|
|
19
|
+
resume(): void;
|
|
20
|
+
startBatching(): void;
|
|
21
|
+
clearBatchingTimeout(): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bus.d.ts","sourceRoot":"","sources":["../../mpx-canvas/Bus.ts"],"names":[],"mappings":";AACA,UAAU,OAAO;IACf,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,GAAG,CAAA;CACd;AACD,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO,EAAE,OAAO,CAAS;IACzB,iBAAiB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAK;IACrE,MAAM,EAAE,OAAO,EAAE,CAAK;IACtB,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,KAAK,IAAI,CAAA;IAC7C,UAAU,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAO;gBAC3B,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,KAAK,IAAI;IAIzD,IAAI,CAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;IAerC,MAAM,CAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAY/B,KAAK,IAAK,IAAI;IAId,MAAM,IAAK,IAAI;IAMf,aAAa,IAAK,IAAI;IAUtB,oBAAoB,IAAK,IAAI;CAM9B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WebviewMessage, CanvasInstance } from './utils';
|
|
2
|
+
export default class CanvasGradient {
|
|
3
|
+
private canvas;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
constructor(canvas: CanvasInstance, noOnConstruction?: boolean);
|
|
6
|
+
postMessage(message: WebviewMessage): Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=CanvasGradient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanvasGradient.d.ts","sourceRoot":"","sources":["../../mpx-canvas/CanvasGradient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAA0B,MAAM,SAAS,CAAA;AAGhF,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,MAAM,CAAiB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBACN,MAAM,EAAE,cAAc,EAAE,gBAAgB,UAAQ;IAQ7D,WAAW,CAAE,OAAO,EAAE,cAAc;CAGrC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanvasInstance, WebviewMessage } from './utils';
|
|
2
|
+
export default class CanvasRenderingContext2D {
|
|
3
|
+
canvas: CanvasInstance;
|
|
4
|
+
constructor(canvas: CanvasInstance);
|
|
5
|
+
postMessage(message: WebviewMessage): Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=CanvasRenderingContext2D.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanvasRenderingContext2D.d.ts","sourceRoot":"","sources":["../../mpx-canvas/CanvasRenderingContext2D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAA4E,MAAM,SAAS,CAAA;AA0ElI,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAC3C,MAAM,EAAE,cAAc,CAAA;gBACT,MAAM,EAAE,cAAc;IAOnC,WAAW,CAAE,OAAO,EAAE,cAAc;CAGrC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WebviewMessage, WEBVIEW_TARGET, CanvasInstance } from './utils';
|
|
2
|
+
export declare class Image {
|
|
3
|
+
[WEBVIEW_TARGET]: string;
|
|
4
|
+
canvas: any;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
private _loadListener;
|
|
8
|
+
private _errorListener;
|
|
9
|
+
private _onload;
|
|
10
|
+
private _onerror;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
constructor(canvas: CanvasInstance, width?: number, height?: number, noOnConstruction?: boolean);
|
|
13
|
+
postMessage(message: WebviewMessage): any;
|
|
14
|
+
addEventListener(type: 'load' | 'error', callbackFn: Function): any;
|
|
15
|
+
set onload(callback: ((...args: any[]) => void));
|
|
16
|
+
get onload(): ((...args: any[]) => void);
|
|
17
|
+
set onerror(callback: ((...args: any[]) => void));
|
|
18
|
+
get onerror(): ((...args: any[]) => void);
|
|
19
|
+
}
|
|
20
|
+
export declare function createImage(canvas: CanvasInstance, width?: number, height?: number): Image;
|
|
21
|
+
//# sourceMappingURL=Image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../mpx-canvas/Image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAA6B,cAAc,EAAE,MAAM,SAAS,CAAA;AAUnG,qBAAa,KAAK;IAChB,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,GAAG,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,aAAa,CAAM;IAC3B,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,QAAQ,CAA6B;IAC7C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBAEN,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,gBAAgB,UAAQ;IAuB9F,WAAW,CAAE,OAAO,EAAE,cAAc;IAIpC,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,UAAU,EAAE,QAAQ;IAsB9D,IAAI,MAAM,CAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,EAQ/C;IAED,IAAI,MAAM,IAAK,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAExC;IAED,IAAI,OAAO,CAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,EAQhD;IAED,IAAI,OAAO,IAAM,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAE1C;CACF;AAED,wBAAgB,WAAW,CAAE,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,SAEnF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WebviewMessage, CanvasInstance } from './utils';
|
|
2
|
+
export default class ImageData {
|
|
3
|
+
canvas: CanvasInstance;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
constructor(canvas: CanvasInstance, dataArray: number[], width: number, height: number, noOnConstruction?: boolean);
|
|
6
|
+
postMessage: (message: WebviewMessage) => Promise<any>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createImageData(canvas: CanvasInstance, dataArray: number[], width: number, height: number): ImageData;
|
|
9
|
+
//# sourceMappingURL=ImageData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageData.d.ts","sourceRoot":"","sources":["../../mpx-canvas/ImageData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,MAAM,EAAE,cAAc,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBACN,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO;IAOnH,WAAW,YAAa,cAAc,kBAEpC;CACH;AAED,wBAAgB,eAAe,CAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAE1G"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WebviewConstructor } from './utils';
|
|
2
|
+
export declare enum ConstructorType {
|
|
3
|
+
Image = "Image",
|
|
4
|
+
CanvasGradient = "CanvasGradient",
|
|
5
|
+
ImageData = "ImageData"
|
|
6
|
+
}
|
|
7
|
+
export declare function useConstructorsRegistry(): {
|
|
8
|
+
register: (registerWebviewConstructor: Function) => void;
|
|
9
|
+
getConstructor: (type: ConstructorType) => WebviewConstructor | undefined;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=constructorsRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructorsRegistry.d.ts","sourceRoot":"","sources":["../../mpx-canvas/constructorsRegistry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5C,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,cAAc,mBAAmB;IACjC,SAAS,cAAc;CACxB;AAaD,wBAAgB,uBAAuB;2CACS,QAAQ,KAAG,IAAI;2BAM/B,eAAe,KAAG,kBAAkB,GAAG,SAAS;EAQ/E"}
|
|
@@ -0,0 +1,3 @@
|
|
|
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
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../mpx-canvas/html.ts"],"names":[],"mappings":";AAAA,wBAoVe"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ✘ type
|
|
3
|
+
* ✘ canvas-id
|
|
4
|
+
* ✘ disable-scroll
|
|
5
|
+
* ✔ bindtouchstart
|
|
6
|
+
* ✔ bindtouchmove
|
|
7
|
+
* ✔ bindtouchend
|
|
8
|
+
* ✔ bindtouchcancel
|
|
9
|
+
* ✔ bindlongtap
|
|
10
|
+
* ✔ binderror
|
|
11
|
+
*/
|
|
12
|
+
import { TouchEvent } from 'react';
|
|
13
|
+
import { View, NativeSyntheticEvent } from 'react-native';
|
|
14
|
+
import { HandlerRef } from '../useNodesRef';
|
|
15
|
+
import './CanvasGradient';
|
|
16
|
+
interface CanvasProps {
|
|
17
|
+
style?: Record<string, any>;
|
|
18
|
+
originWhitelist?: Array<string>;
|
|
19
|
+
'enable-var'?: boolean;
|
|
20
|
+
'parent-font-size'?: number;
|
|
21
|
+
'parent-width'?: number;
|
|
22
|
+
'parent-height'?: number;
|
|
23
|
+
'external-var-context'?: Record<string, any>;
|
|
24
|
+
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
25
|
+
bindtouchmove?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
26
|
+
bindtouchend?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
27
|
+
bindtouchcancel?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
28
|
+
bindlongtap?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
29
|
+
binderror?: (event: NativeSyntheticEvent<ErrorEvent>) => void;
|
|
30
|
+
}
|
|
31
|
+
declare const _Canvas: import("react").ForwardRefExoticComponent<CanvasProps & import("react").RefAttributes<HandlerRef<CanvasProps & View, CanvasProps>>>;
|
|
32
|
+
export default _Canvas;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../mpx-canvas/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAA4E,UAAU,EAAoB,MAAM,OAAO,CAAA;AAC9H,OAAO,EAAE,IAAI,EAAwB,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAE/E,OAAoB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAexD,OAAO,kBAAkB,CAAA;AAqBzB,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAA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