@mpxjs/webpack-plugin 2.10.17 → 2.10.18-beta.2
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 +231 -0
- package/lib/index.js +70 -73
- package/lib/init.js +3 -0
- 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 +102 -72
- 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 +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 +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 +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/LoadAsyncChunkModule.js +1 -1
- package/lib/react/processStyles.js +21 -9
- package/lib/react/script-helper.js +2 -2
- package/lib/react/style-helper.js +76 -13
- package/lib/resolver/AddModePlugin.js +17 -7
- package/lib/resolver/ExtendComponentsPlugin.js +60 -0
- package/lib/runtime/components/ali/mpx-section-list.mpx +566 -0
- package/lib/runtime/components/ali/mpx-sticky-header.mpx +212 -0
- package/lib/runtime/components/ali/mpx-sticky-section.mpx +17 -0
- package/lib/runtime/components/react/animationHooks/index.ts +75 -0
- package/lib/runtime/components/react/animationHooks/useAnimationAPIHooks.ts +197 -0
- package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +301 -0
- package/lib/runtime/components/react/animationHooks/utils.ts +197 -0
- package/lib/runtime/components/react/context.ts +12 -3
- 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 +181 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +3 -0
- package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +279 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +109 -0
- package/lib/runtime/components/react/dist/animationHooks/utils.js +151 -0
- package/lib/runtime/components/react/dist/context.d.ts +10 -3
- package/lib/runtime/components/react/dist/context.js +1 -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-async-suspense.jsx +3 -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-image.jsx +2 -2
- 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 +66 -50
- 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 +35 -6
- 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-scroll-view.jsx +84 -78
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +48 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +292 -0
- 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-header.jsx +20 -20
- 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 +136 -83
- 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-textarea.jsx +1 -0
- 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 +10 -9
- package/lib/runtime/components/react/dist/utils.jsx +47 -24
- package/lib/runtime/components/react/mpx-async-suspense.tsx +3 -1
- package/lib/runtime/components/react/mpx-camera.tsx +327 -0
- package/lib/runtime/components/react/mpx-image.tsx +2 -2
- package/lib/runtime/components/react/mpx-input.tsx +77 -54
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +35 -6
- package/lib/runtime/components/react/mpx-portal/portal-manager.tsx +2 -2
- package/lib/runtime/components/react/mpx-scroll-view.tsx +110 -114
- package/lib/runtime/components/react/mpx-section-list.tsx +439 -0
- package/lib/runtime/components/react/mpx-sticky-header.tsx +24 -24
- package/lib/runtime/components/react/mpx-swiper.tsx +156 -81
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -0
- 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 +51 -27
- package/lib/runtime/components/web/mpx-scroll-view.vue +5 -2
- package/lib/runtime/components/web/mpx-section-list.vue +551 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-footer.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-header.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/list-item.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list-default/section-header.mpx +26 -0
- package/lib/runtime/components/wx/mpx-section-list.mpx +209 -0
- package/lib/runtime/components/wx/mpx-sticky-header.mpx +40 -0
- package/lib/runtime/components/wx/mpx-sticky-section.mpx +31 -0
- package/lib/runtime/optionProcessor.js +5 -0
- package/lib/runtime/optionProcessorReact.js +7 -0
- package/lib/runtime/stringify.wxs +2 -2
- package/lib/script-setup-compiler/index.js +1 -2
- package/lib/style-compiler/strip-conditional.js +244 -0
- package/lib/template-compiler/compiler.js +9 -8
- package/lib/utils/const.js +29 -0
- package/lib/utils/dom-tag-config.js +1 -1
- package/lib/utils/string.js +25 -1
- package/lib/wxss/loader.js +4 -1
- package/lib/wxss/utils.js +7 -2
- package/package.json +7 -14
- package/LICENSE +0 -433
- 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
- package/lib/style-compiler/strip-conditional-loader.js +0 -289
|
@@ -4,9 +4,8 @@ import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn } fr
|
|
|
4
4
|
import { VarContext, ScrollViewContext, RouteContext } from './context'
|
|
5
5
|
import { ExpressionParser, parseFunc, ReplaceSource } from './parser'
|
|
6
6
|
import { initialWindowMetrics } from 'react-native-safe-area-context'
|
|
7
|
-
import
|
|
7
|
+
import type { FastImageProps } from '@d11/react-native-fast-image'
|
|
8
8
|
import type { AnyFunc, ExtendedFunctionComponent } from './types/common'
|
|
9
|
-
import { runOnJS } from 'react-native-reanimated'
|
|
10
9
|
import { Gesture } from 'react-native-gesture-handler'
|
|
11
10
|
|
|
12
11
|
export const TEXT_STYLE_REGEX = /color|font.*|text.*|letterSpacing|lineHeight|includeFontPadding|writingDirection/
|
|
@@ -31,6 +30,7 @@ const varUseRegExp = /var\(/
|
|
|
31
30
|
const unoVarDecRegExp = /^--un-/
|
|
32
31
|
const unoVarUseRegExp = /var\(--un-/
|
|
33
32
|
const calcUseRegExp = /calc\(/
|
|
33
|
+
const calcPercentExp = /^calc\(.*-?\d+(\.\d+)?%.*\)$/
|
|
34
34
|
const envUseRegExp = /env\(/
|
|
35
35
|
const filterRegExp = /(calc|env|%)/
|
|
36
36
|
|
|
@@ -41,6 +41,8 @@ const safeAreaInsetMap: Record<string, 'top' | 'right' | 'bottom' | 'left'> = {
|
|
|
41
41
|
'safe-area-inset-left': 'left'
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export const extendObject = Object.assign
|
|
45
|
+
|
|
44
46
|
function getSafeAreaInset (name: string, navigation: Record<string, any> | undefined) {
|
|
45
47
|
const insets = extendObject({}, initialWindowMetrics?.insets, navigation?.insets)
|
|
46
48
|
return insets[safeAreaInsetMap[name]]
|
|
@@ -143,16 +145,17 @@ export function splitStyle<T extends Record<string, any>> (styleObj: T): {
|
|
|
143
145
|
innerStyle: Partial<T>
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
|
-
|
|
147
|
-
const selfPercentRule: Record<string, 'height' | 'width'> = {
|
|
148
|
-
translateX: 'width',
|
|
149
|
-
translateY: 'height',
|
|
148
|
+
const radiusPercentRule: Record<string, 'height' | 'width'> = {
|
|
150
149
|
borderTopLeftRadius: 'width',
|
|
151
150
|
borderBottomLeftRadius: 'width',
|
|
152
151
|
borderBottomRightRadius: 'width',
|
|
153
152
|
borderTopRightRadius: 'width',
|
|
154
153
|
borderRadius: 'width'
|
|
155
154
|
}
|
|
155
|
+
const selfPercentRule: Record<string, 'height' | 'width'> = extendObject({
|
|
156
|
+
translateX: 'width',
|
|
157
|
+
translateY: 'height'
|
|
158
|
+
}, radiusPercentRule)
|
|
156
159
|
|
|
157
160
|
const parentHeightPercentRule: Record<string, boolean> = {
|
|
158
161
|
height: true,
|
|
@@ -216,16 +219,22 @@ function resolveVar (input: string, varContext: Record<string, any>) {
|
|
|
216
219
|
const replaced = new ReplaceSource(input)
|
|
217
220
|
|
|
218
221
|
for (const { start, end, args } of parsed) {
|
|
222
|
+
// NOTE:
|
|
223
|
+
// - CSS var() fallback 允许包含空格、逗号等字符(如 font-family 的 fallback)
|
|
224
|
+
// - parseFunc 会按逗号分割 args,因此这里把 args[1..] 重新 join 回 fallback
|
|
219
225
|
const varName = args[0]
|
|
220
|
-
const fallback = args
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
226
|
+
const fallback: string | undefined = args.length > 1 ? args.slice(1).join(',').trim() : undefined
|
|
227
|
+
|
|
228
|
+
// 先处理 varValue
|
|
229
|
+
let varValue = hasOwn(varContext, varName) ? varContext[varName] : undefined
|
|
230
|
+
if (varValue !== undefined) {
|
|
231
|
+
varValue = varUseRegExp.test(varValue) ? resolveVar(varValue, varContext) : global.__formatValue(varValue)
|
|
232
|
+
}
|
|
233
|
+
// 再处理 fallback
|
|
234
|
+
if (varValue === undefined && fallback !== undefined) {
|
|
235
|
+
varValue = varUseRegExp.test(fallback) ? resolveVar(fallback, varContext) : global.__formatValue(fallback)
|
|
228
236
|
}
|
|
237
|
+
if (varValue === undefined) return
|
|
229
238
|
replaced.replace(start, end - 1, varValue)
|
|
230
239
|
}
|
|
231
240
|
|
|
@@ -288,6 +297,10 @@ function transformStringify (styleObj: Record<string, any>) {
|
|
|
288
297
|
if (isNumber(styleObj.fontWeight)) {
|
|
289
298
|
styleObj.fontWeight = '' + styleObj.fontWeight
|
|
290
299
|
}
|
|
300
|
+
// transformOrigin 20px 需要转换为 transformOrigin '20'
|
|
301
|
+
if (isNumber(styleObj.transformOrigin)) {
|
|
302
|
+
styleObj.transformOrigin = '' + styleObj.transformOrigin
|
|
303
|
+
}
|
|
291
304
|
}
|
|
292
305
|
|
|
293
306
|
function transformPosition (styleObj: Record<string, any>, meta: PositionMeta) {
|
|
@@ -297,7 +310,7 @@ function transformPosition (styleObj: Record<string, any>, meta: PositionMeta) {
|
|
|
297
310
|
}
|
|
298
311
|
}
|
|
299
312
|
// 多value解析
|
|
300
|
-
function parseValues (str: string, char = ' ') {
|
|
313
|
+
export function parseValues (str: string, char = ' ') {
|
|
301
314
|
let stack = 0
|
|
302
315
|
let temp = ''
|
|
303
316
|
const result = []
|
|
@@ -308,11 +321,11 @@ function parseValues (str: string, char = ' ') {
|
|
|
308
321
|
stack--
|
|
309
322
|
}
|
|
310
323
|
// 非括号内 或者 非分隔字符且非空
|
|
311
|
-
if (stack !== 0 ||
|
|
324
|
+
if (stack !== 0 || str[i] !== char) {
|
|
312
325
|
temp += str[i]
|
|
313
326
|
}
|
|
314
327
|
if ((stack === 0 && str[i] === char) || i === str.length - 1) {
|
|
315
|
-
result.push(temp)
|
|
328
|
+
result.push(temp.trim())
|
|
316
329
|
temp = ''
|
|
317
330
|
}
|
|
318
331
|
}
|
|
@@ -321,6 +334,8 @@ function parseValues (str: string, char = ' ') {
|
|
|
321
334
|
// parse string transform, eg: transform: 'rotateX(45deg) rotateZ(0.785398rad)'
|
|
322
335
|
function parseTransform (transformStr: string) {
|
|
323
336
|
const values = parseValues(transformStr)
|
|
337
|
+
// Todo transform 排序不一致时,transform动画会闪烁,故这里同样的排序输出 transform
|
|
338
|
+
values.sort()
|
|
324
339
|
const transform: { [propName: string]: string | number | number[] }[] = []
|
|
325
340
|
values.forEach(item => {
|
|
326
341
|
const match = item.match(/([/\w]+)\((.+)\)/)
|
|
@@ -390,9 +405,10 @@ interface TransformStyleConfig {
|
|
|
390
405
|
parentFontSize?: number
|
|
391
406
|
parentWidth?: number
|
|
392
407
|
parentHeight?: number
|
|
408
|
+
transformRadiusPercent?: boolean
|
|
393
409
|
}
|
|
394
410
|
|
|
395
|
-
export function useTransformStyle (styleObj: Record<string, any> = {}, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }: TransformStyleConfig) {
|
|
411
|
+
export function useTransformStyle (styleObj: Record<string, any> = {}, { enableVar, transformRadiusPercent, externalVarContext, parentFontSize, parentWidth, parentHeight }: TransformStyleConfig) {
|
|
396
412
|
const varStyle: Record<string, any> = {}
|
|
397
413
|
const unoVarStyle: Record<string, any> = {}
|
|
398
414
|
const normalStyle: Record<string, any> = {}
|
|
@@ -440,14 +456,21 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
|
|
|
440
456
|
}
|
|
441
457
|
}
|
|
442
458
|
|
|
443
|
-
function calcVisitor ({ value, keyPath }: VisitorArg) {
|
|
459
|
+
function calcVisitor ({ key, value, keyPath }: VisitorArg) {
|
|
444
460
|
if (calcUseRegExp.test(value)) {
|
|
461
|
+
// calc translate & border-radius 的百分比计算
|
|
462
|
+
if (hasOwn(selfPercentRule, key) && calcPercentExp.test(value)) {
|
|
463
|
+
hasSelfPercent = true
|
|
464
|
+
percentKeyPaths.push(keyPath.slice())
|
|
465
|
+
}
|
|
445
466
|
calcKeyPaths.push(keyPath.slice())
|
|
446
467
|
}
|
|
447
468
|
}
|
|
448
469
|
|
|
449
470
|
function percentVisitor ({ key, value, keyPath }: VisitorArg) {
|
|
450
|
-
|
|
471
|
+
// fixme 去掉 translate & border-radius 的百分比计算
|
|
472
|
+
// fixme Image 组件 borderRadius 仅支持 number
|
|
473
|
+
if (transformRadiusPercent && hasOwn(radiusPercentRule, key) && PERCENT_REGEX.test(value)) {
|
|
451
474
|
hasSelfPercent = true
|
|
452
475
|
percentKeyPaths.push(keyPath.slice())
|
|
453
476
|
} else if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
@@ -463,7 +486,6 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
|
|
|
463
486
|
|
|
464
487
|
// traverse var & generate normalStyle
|
|
465
488
|
traverseStyle(styleObj, [varVisitor])
|
|
466
|
-
|
|
467
489
|
hasVarDec = hasVarDec || !!externalVarContext
|
|
468
490
|
enableVar = enableVar || hasVarDec || hasVarUse
|
|
469
491
|
const enableVarRef = useRef(enableVar)
|
|
@@ -527,8 +549,7 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
|
|
|
527
549
|
transformStringify(normalStyle)
|
|
528
550
|
// transform rpx to px
|
|
529
551
|
transformBoxShadow(normalStyle)
|
|
530
|
-
|
|
531
|
-
// transform 字符串格式转化数组格式
|
|
552
|
+
// transform 字符串格式转化数组格式(先转数组再处理css var)
|
|
532
553
|
transformTransform(normalStyle)
|
|
533
554
|
|
|
534
555
|
return {
|
|
@@ -726,8 +747,6 @@ export function flatGesture (gestures: Array<GestureHandler> = []) {
|
|
|
726
747
|
})) || []
|
|
727
748
|
}
|
|
728
749
|
|
|
729
|
-
export const extendObject = Object.assign
|
|
730
|
-
|
|
731
750
|
export function getCurrentPage (pageId: number | null | undefined) {
|
|
732
751
|
if (!global.getCurrentPages) return
|
|
733
752
|
const pages = global.getCurrentPages()
|
|
@@ -736,9 +755,14 @@ export function getCurrentPage (pageId: number | null | undefined) {
|
|
|
736
755
|
|
|
737
756
|
export function renderImage (
|
|
738
757
|
imageProps: ImageProps | FastImageProps,
|
|
739
|
-
enableFastImage =
|
|
758
|
+
enableFastImage = true
|
|
740
759
|
) {
|
|
741
|
-
|
|
760
|
+
let Component: React.ComponentType<ImageProps | FastImageProps> = Image
|
|
761
|
+
if (enableFastImage) {
|
|
762
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
763
|
+
const fastImageModule = require('@d11/react-native-fast-image')
|
|
764
|
+
Component = fastImageModule.default || fastImageModule
|
|
765
|
+
}
|
|
742
766
|
return createElement(Component, imageProps)
|
|
743
767
|
}
|
|
744
768
|
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
const top = item.offsetTop
|
|
381
381
|
const width = item.offsetWidth
|
|
382
382
|
const height = item.offsetHeight
|
|
383
|
-
|
|
383
|
+
|
|
384
384
|
minLeft = getMinLength(minLeft, left)
|
|
385
385
|
minTop = getMinLength(minTop, top)
|
|
386
386
|
maxRight = getMaxLength(maxRight, left + width)
|
|
@@ -414,6 +414,9 @@
|
|
|
414
414
|
if (this.bs) this.bs.refresh()
|
|
415
415
|
}
|
|
416
416
|
},
|
|
417
|
+
forceUpdateRefreshVersion () {
|
|
418
|
+
this.refreshVersion++
|
|
419
|
+
},
|
|
417
420
|
compare(num1, num2, scale = 1) {
|
|
418
421
|
return Math.abs(num1 - num2) < scale
|
|
419
422
|
},
|
|
@@ -588,4 +591,4 @@
|
|
|
588
591
|
background: rgba(255, 255, 255, .7)
|
|
589
592
|
100%
|
|
590
593
|
background: rgba(255, 255, 255, .3)
|
|
591
|
-
</style>
|
|
594
|
+
</style>
|