@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
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view wx:ref="recycleViewRef" class="mpx-section-list" scroll-y wx:style="{{ scrollViewStyle }}" type="custom"
|
|
3
|
+
enhanced="{{ enhanced }}" scroll-with-animation="{{ scrollWithAnimation }}" bounces="{{ bounces }}"
|
|
4
|
+
show-scrollbar="{{ showScrollbar }}" refresher-enabled="{{ refresherEnabled }}"
|
|
5
|
+
refresher-triggered="{{ refresherTriggered }}" bindscroll="onScroll" bindrefresherrefresh="onRefresh" scroll-into-view-offset="{{ scrollIntoViewOffset }}"
|
|
6
|
+
scroll-into-view="{{ scrollIntoViewId }}" scroll-into-view-alignment="{{ viewPosition }}">
|
|
7
|
+
<block wx:if="{{ useListHeader }}">
|
|
8
|
+
<list-header listHeaderData="{{ listHeaderData }}"></list-header>
|
|
9
|
+
</block>
|
|
10
|
+
<block wx:for="{{ convertedListData }}" wx:key="index">
|
|
11
|
+
<sticky-section>
|
|
12
|
+
<!-- section header -->
|
|
13
|
+
<block wx:if="{{ item.hasSectionHeader }}">
|
|
14
|
+
<block wx:if="{{ enableSticky }}">
|
|
15
|
+
<sticky-header>
|
|
16
|
+
<section-header itemData="{{ item.headerData }}" id="{{ item._domId }}"></section-header>
|
|
17
|
+
</sticky-header>
|
|
18
|
+
</block>
|
|
19
|
+
<block wx:else>
|
|
20
|
+
<section-header itemData="{{ item.headerData }}" id="{{ item._domId }}"></section-header>
|
|
21
|
+
</block>
|
|
22
|
+
|
|
23
|
+
</block>
|
|
24
|
+
<block wx:for="{{ item.data }}" wx:for-item="subItem" wx:key="subIndex">
|
|
25
|
+
<!-- section items -->
|
|
26
|
+
<recycle-item itemData="{{ subItem.itemData }}" id="{{ subItem._domId }}"></recycle-item>
|
|
27
|
+
</block>
|
|
28
|
+
</sticky-section>
|
|
29
|
+
</block>
|
|
30
|
+
<block wx:if="{{ useListFooter }}">
|
|
31
|
+
<list-footer listFooterData="{{ listFooterData }}"></list-footer>
|
|
32
|
+
</block>
|
|
33
|
+
</scroll-view>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import { createComponent } from '@mpxjs/core'
|
|
38
|
+
|
|
39
|
+
createComponent({
|
|
40
|
+
properties: {
|
|
41
|
+
height: {
|
|
42
|
+
type: Number,
|
|
43
|
+
value: null
|
|
44
|
+
},
|
|
45
|
+
width: {
|
|
46
|
+
type: Number,
|
|
47
|
+
value: null
|
|
48
|
+
},
|
|
49
|
+
listData: {
|
|
50
|
+
type: Array,
|
|
51
|
+
value: []
|
|
52
|
+
},
|
|
53
|
+
enableSticky: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
value: false
|
|
56
|
+
},
|
|
57
|
+
showScrollbar: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
value: false
|
|
60
|
+
},
|
|
61
|
+
enhanced: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
value: false
|
|
64
|
+
},
|
|
65
|
+
bounces: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
value: false
|
|
68
|
+
},
|
|
69
|
+
refresherEnabled: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
value: false
|
|
72
|
+
},
|
|
73
|
+
refresherTriggered: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
value: false
|
|
76
|
+
},
|
|
77
|
+
listHeaderData: {
|
|
78
|
+
type: Object,
|
|
79
|
+
value: null
|
|
80
|
+
},
|
|
81
|
+
scrollWithAnimation: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
value: false
|
|
84
|
+
},
|
|
85
|
+
useListHeader: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
value: false
|
|
88
|
+
},
|
|
89
|
+
listFooterData: {
|
|
90
|
+
type: Object,
|
|
91
|
+
value: null
|
|
92
|
+
},
|
|
93
|
+
useListFooter: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
value: false
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
data: {
|
|
99
|
+
convertedListData: [],
|
|
100
|
+
scrollIntoViewId: '',
|
|
101
|
+
scrollIntoViewOffset: 0,
|
|
102
|
+
viewPosition: 'start'
|
|
103
|
+
},
|
|
104
|
+
computed: {
|
|
105
|
+
scrollViewStyle() {
|
|
106
|
+
return `height: ${this.formatDimension(this.height)};width: ${this.formatDimension(this.width)}`
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
watch: {
|
|
110
|
+
listData: {
|
|
111
|
+
handler(newVal) {
|
|
112
|
+
this.convertedListData = this.convertToSectionListData(newVal)
|
|
113
|
+
},
|
|
114
|
+
immediate: true
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
formatDimension(value) {
|
|
119
|
+
return typeof value === 'number' ? `${value}px` : value || '100%'
|
|
120
|
+
},
|
|
121
|
+
onScroll(e) {
|
|
122
|
+
this.triggerEvent('scroll', e)
|
|
123
|
+
},
|
|
124
|
+
onRefresh(e) {
|
|
125
|
+
this.triggerEvent('refresh', e)
|
|
126
|
+
},
|
|
127
|
+
scrollToIndex({ index, viewPosition = 0, viewOffset = 0 }) {
|
|
128
|
+
if (index >= 0) {
|
|
129
|
+
this.scrollIntoViewId = `mpx-recycle-item-${index}`
|
|
130
|
+
switch (viewPosition) {
|
|
131
|
+
case 0:
|
|
132
|
+
this.viewPosition = 'start'
|
|
133
|
+
break
|
|
134
|
+
case 0.5:
|
|
135
|
+
this.viewPosition = 'center'
|
|
136
|
+
break
|
|
137
|
+
case 1:
|
|
138
|
+
this.viewPosition = 'end'
|
|
139
|
+
break
|
|
140
|
+
default:
|
|
141
|
+
this.viewPosition = 'start'
|
|
142
|
+
}
|
|
143
|
+
this.scrollIntoViewOffset = -viewOffset || 0
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
convertToSectionListData(data) {
|
|
147
|
+
const sections = []
|
|
148
|
+
let currentSection = null
|
|
149
|
+
|
|
150
|
+
data && data.forEach((item, index) => {
|
|
151
|
+
if (item.isSectionHeader) {
|
|
152
|
+
// 如果已经存在一个 section,先把它添加到 sections 中
|
|
153
|
+
if (currentSection) {
|
|
154
|
+
sections.push(currentSection)
|
|
155
|
+
}
|
|
156
|
+
// 创建新的 section
|
|
157
|
+
currentSection = {
|
|
158
|
+
headerData: item,
|
|
159
|
+
data: [],
|
|
160
|
+
hasSectionHeader: true,
|
|
161
|
+
_domId: `mpx-recycle-item-${index}`
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
// 如果没有当前 section,创建一个默认的
|
|
165
|
+
if (!currentSection) {
|
|
166
|
+
// 创建默认section (无header的section)
|
|
167
|
+
currentSection = {
|
|
168
|
+
headerData: null,
|
|
169
|
+
data: [],
|
|
170
|
+
hasSectionHeader: false
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
currentSection.data.push({
|
|
174
|
+
itemData: item,
|
|
175
|
+
_domId: `mpx-recycle-item-${index}`
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
// 添加最后一个 section
|
|
181
|
+
if (currentSection) {
|
|
182
|
+
sections.push(currentSection)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return sections
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<script type="application/json">
|
|
192
|
+
{
|
|
193
|
+
"component": true,
|
|
194
|
+
"componentGenerics": {
|
|
195
|
+
"recycle-item": {
|
|
196
|
+
"default": "./mpx-section-list-default/list-item.mpx"
|
|
197
|
+
},
|
|
198
|
+
"section-header": {
|
|
199
|
+
"default": "./mpx-section-list-default/section-header.mpx"
|
|
200
|
+
},
|
|
201
|
+
"list-header": {
|
|
202
|
+
"default": "./mpx-section-list-default/list-header.mpx"
|
|
203
|
+
},
|
|
204
|
+
"list-footer": {
|
|
205
|
+
"default": "./mpx-section-list-default/list-footer.mpx"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<sticky-header offset-top="{{offsetTop}}" padding="{{padding}}" allow-overlapping="{{allowOverlapping}}" bindstickontopchange="handleStickyChange">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</sticky-header>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { createComponent } from '@mpxjs/core'
|
|
9
|
+
|
|
10
|
+
createComponent({
|
|
11
|
+
options: {
|
|
12
|
+
virtualHost: true
|
|
13
|
+
},
|
|
14
|
+
properties: {
|
|
15
|
+
offsetTop: {
|
|
16
|
+
type: Number,
|
|
17
|
+
value: 0
|
|
18
|
+
},
|
|
19
|
+
padding: {
|
|
20
|
+
type: Array,
|
|
21
|
+
value: [0, 0, 0, 0]
|
|
22
|
+
},
|
|
23
|
+
allowOverlapping: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
value: false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
handleStickyChange(e) {
|
|
30
|
+
this.triggerEvent('stickontopchange', e.detail)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<script type="application/json">
|
|
37
|
+
{
|
|
38
|
+
"component": true
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<sticky-section padding="{{ padding }}" push-pinned-header="{{ pushPinnedHeader }}">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</sticky-section>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import { createComponent } from '@mpxjs/core'
|
|
9
|
+
|
|
10
|
+
createComponent({
|
|
11
|
+
options: {
|
|
12
|
+
virtualHost: true
|
|
13
|
+
},
|
|
14
|
+
properties: {
|
|
15
|
+
padding: {
|
|
16
|
+
type: Array,
|
|
17
|
+
value: [0, 0, 0, 0]
|
|
18
|
+
},
|
|
19
|
+
pushPinnedHeader: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
value: true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script type="application/json">
|
|
28
|
+
{
|
|
29
|
+
"component": true
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
@@ -2,6 +2,7 @@ import { hasOwn, isEmptyObject, extend } from './utils'
|
|
|
2
2
|
import { isBrowser } from './env'
|
|
3
3
|
import transRpxStyle from './transRpxStyle'
|
|
4
4
|
import animation from './animation'
|
|
5
|
+
import { error } from '@mpxjs/utils'
|
|
5
6
|
const dash2hump = require('../utils/hump-dash').dash2hump
|
|
6
7
|
|
|
7
8
|
export function processComponentOption (
|
|
@@ -107,6 +108,10 @@ registered in parent context!`)
|
|
|
107
108
|
|
|
108
109
|
export function getComponent (component, extendOptions) {
|
|
109
110
|
component = component.__esModule ? component.default : component
|
|
111
|
+
if (!component) {
|
|
112
|
+
error('getComponent() expected component options as the first argument, but got undefined.')
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
110
115
|
// eslint-disable-next-line
|
|
111
116
|
if (extendOptions && !component.__mpxExtended) {
|
|
112
117
|
extend(component, extendOptions, { __mpxExtended: true })
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import AsyncSuspense from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-async-suspense'
|
|
2
2
|
import { memo, forwardRef, createElement } from 'react'
|
|
3
|
+
import { error } from '@mpxjs/utils'
|
|
3
4
|
import { extend } from './utils'
|
|
4
5
|
|
|
5
6
|
export function getComponent (component, extendOptions) {
|
|
6
7
|
component = component.__esModule ? component.default : component
|
|
8
|
+
if (!component) {
|
|
9
|
+
error(
|
|
10
|
+
`getComponent expecting function/class component ${extendOptions?.displayName ? `[${extendOptions.displayName}] ` : ''}as the first argument, but got undefined.`
|
|
11
|
+
)
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
7
14
|
// eslint-disable-next-line
|
|
8
15
|
if (extendOptions && !component.__mpxExtended) {
|
|
9
16
|
extend(component, extendOptions, { __mpxExtended: true })
|
|
@@ -45,7 +45,7 @@ function objectKeys (obj) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function genRegExp (str, flags) {
|
|
48
|
-
if (!__mpx_wxs__) {
|
|
48
|
+
if (!__mpx_wxs__ || __mpx_mode__ === 'ks') {
|
|
49
49
|
return new RegExp(str, flags)
|
|
50
50
|
} else {
|
|
51
51
|
return getRegExp(str, flags)
|
|
@@ -234,4 +234,4 @@ module.exports = {
|
|
|
234
234
|
var parsedStaticStyle = typeof staticStyle === 'string' ? parseStyleText(staticStyle) : {}
|
|
235
235
|
return genStyleText(extend(parsedStaticStyle, normalizedDynamicStyle))
|
|
236
236
|
}
|
|
237
|
-
}
|
|
237
|
+
}
|
|
@@ -605,8 +605,7 @@ function compileScriptSetup (
|
|
|
605
605
|
if (node.key.name === 'properties' && hasDefinePropsCall) {
|
|
606
606
|
console.warn(`${DEFINE_PROPS} has been called, ${DEFINE_OPTIONS} set properties will be ignored`)
|
|
607
607
|
} else {
|
|
608
|
-
|
|
609
|
-
runtimeOptions += `\n ${node.key.name}: ${declCode},`
|
|
608
|
+
runtimeOptions += `\n ${content.slice(node.start, node.end).trim()},`
|
|
610
609
|
}
|
|
611
610
|
}
|
|
612
611
|
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
|
|
3
|
+
class Node {
|
|
4
|
+
constructor(type, condition = null) {
|
|
5
|
+
this.type = type // 'If', 'ElseIf', 'Else' 或 'Text'
|
|
6
|
+
this.condition = condition // If 或 Elif 的条件
|
|
7
|
+
this.children = []
|
|
8
|
+
this.value = ''
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 提取 css string 为 token
|
|
13
|
+
function tokenize(cssString) {
|
|
14
|
+
// Support /* ... */, // ..., and <!-- ... --> styles
|
|
15
|
+
// 1. : /\/\*\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*\*\//g
|
|
16
|
+
// 2. : /\/\/\s*@mpx-(if|elif|else|endif)(?:\s*\((.*?)\))?\s*$/gm
|
|
17
|
+
// 3. : /<!--\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*-->/g
|
|
18
|
+
// Combined:
|
|
19
|
+
const regex = /(?:\/\*\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*\*\/)|(?:\/\/\s*@mpx-(if|elif|else|endif)(?:\s*\((.*?)\))?\s*)|(?:<!--\s*@mpx-(if|elif|else|endif)(?:\s*\(([\s\S]*?)\))?\s*-->)/g
|
|
20
|
+
const tokens = []
|
|
21
|
+
let lastIndex = 0
|
|
22
|
+
let match
|
|
23
|
+
|
|
24
|
+
while ((match = regex.exec(cssString)) !== null) {
|
|
25
|
+
// 如果 token 前有普通文本,生成文本 token
|
|
26
|
+
if (match.index > lastIndex) {
|
|
27
|
+
const text = cssString.substring(lastIndex, match.index)
|
|
28
|
+
tokens.push({ type: 'text', content: text })
|
|
29
|
+
}
|
|
30
|
+
// 1,2: (/* ... */)
|
|
31
|
+
// 3,4: (// ...)
|
|
32
|
+
// 5,6: (<!-- ... -->)
|
|
33
|
+
const type = match[1] || match[3] || match[5]
|
|
34
|
+
const condition = (match[2] || match[4] || match[6])
|
|
35
|
+
|
|
36
|
+
tokens.push({
|
|
37
|
+
type: type,
|
|
38
|
+
condition: condition ? condition.trim() : null
|
|
39
|
+
})
|
|
40
|
+
lastIndex = regex.lastIndex
|
|
41
|
+
}
|
|
42
|
+
// 处理结尾剩余的文本
|
|
43
|
+
if (lastIndex < cssString.length) {
|
|
44
|
+
const text = cssString.substring(lastIndex)
|
|
45
|
+
tokens.push({ type: 'text', content: text })
|
|
46
|
+
}
|
|
47
|
+
return tokens
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// parse:将生成的 token 数组构造成嵌套的 AST
|
|
51
|
+
function parse(cssString) {
|
|
52
|
+
const tokens = tokenize(cssString)
|
|
53
|
+
const ast = []
|
|
54
|
+
const nodeStack = []
|
|
55
|
+
let currentChildren = ast
|
|
56
|
+
tokens.forEach(token => {
|
|
57
|
+
if (token.type === 'text') {
|
|
58
|
+
const node = new Node('Text')
|
|
59
|
+
node.value = token.content
|
|
60
|
+
currentChildren.push(node)
|
|
61
|
+
} else if (token.type === 'if') {
|
|
62
|
+
const node = new Node('If', token.condition)
|
|
63
|
+
currentChildren.push(node)
|
|
64
|
+
nodeStack.push(currentChildren)
|
|
65
|
+
currentChildren = node.children
|
|
66
|
+
} else if (token.type === 'elif') {
|
|
67
|
+
if (nodeStack.length === 0) {
|
|
68
|
+
throw new Error('[Mpx style error]: elif without a preceding if')
|
|
69
|
+
}
|
|
70
|
+
currentChildren = nodeStack[nodeStack.length - 1]
|
|
71
|
+
const node = new Node('ElseIf', token.condition)
|
|
72
|
+
currentChildren.push(node)
|
|
73
|
+
currentChildren = node.children
|
|
74
|
+
} else if (token.type === 'else') {
|
|
75
|
+
if (nodeStack.length === 0) {
|
|
76
|
+
throw new Error('[Mpx style error]: else without a preceding if')
|
|
77
|
+
}
|
|
78
|
+
currentChildren = nodeStack[nodeStack.length - 1]
|
|
79
|
+
const node = new Node('Else')
|
|
80
|
+
currentChildren.push(node)
|
|
81
|
+
currentChildren = node.children
|
|
82
|
+
} else if (token.type === 'endif') {
|
|
83
|
+
if (nodeStack.length > 0) {
|
|
84
|
+
currentChildren = nodeStack.pop()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
if (nodeStack.length > 0) {
|
|
89
|
+
throw new Error('[Mpx strip conditional error]: mpx-if without a matching endif')
|
|
90
|
+
}
|
|
91
|
+
return ast
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function evaluateCondition(condition, defs, filePath) {
|
|
95
|
+
try {
|
|
96
|
+
const keys = Object.keys(defs)
|
|
97
|
+
const values = keys.map(key => defs[key])
|
|
98
|
+
/* eslint-disable no-new-func */
|
|
99
|
+
const func = new Function(...keys, `return (${condition});`)
|
|
100
|
+
return func(...values)
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(`[Mpx style error] File: ${filePath}, Error evaluating condition: ${condition}`, e)
|
|
103
|
+
return false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function traverseAndEvaluate(ast, defs, filePath) {
|
|
108
|
+
let output = ''
|
|
109
|
+
let batchedIf = false
|
|
110
|
+
function traverse(nodes) {
|
|
111
|
+
for (const node of nodes) {
|
|
112
|
+
if (node.type === 'Text') {
|
|
113
|
+
output += node.value
|
|
114
|
+
} else if (node.type === 'If') {
|
|
115
|
+
// 直接判断 If 节点
|
|
116
|
+
batchedIf = false
|
|
117
|
+
if (evaluateCondition(node.condition, defs, filePath)) {
|
|
118
|
+
traverse(node.children)
|
|
119
|
+
batchedIf = true
|
|
120
|
+
}
|
|
121
|
+
} else if (node.type === 'ElseIf' && !batchedIf) {
|
|
122
|
+
if (evaluateCondition(node.condition, defs, filePath)) {
|
|
123
|
+
traverse(node.children)
|
|
124
|
+
batchedIf = true
|
|
125
|
+
}
|
|
126
|
+
} else if (node.type === 'Else' && !batchedIf) {
|
|
127
|
+
traverse(node.children)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
traverse(ast)
|
|
132
|
+
return output
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @param {string} content
|
|
138
|
+
* @param {Record<string, any>} defs
|
|
139
|
+
* @param {string} [filePath]
|
|
140
|
+
* @returns
|
|
141
|
+
*/
|
|
142
|
+
function stripCondition(content, defs, filePath) {
|
|
143
|
+
const ast = parse(content)
|
|
144
|
+
return traverseAndEvaluate(ast, defs, filePath || 'unknown')
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let proxyReadFileSync
|
|
148
|
+
let proxyReadFile
|
|
149
|
+
const rawReadFileSync = fs.readFileSync
|
|
150
|
+
const rawReadFile = fs.readFile
|
|
151
|
+
|
|
152
|
+
let isRewritten = false
|
|
153
|
+
let __compilation = null
|
|
154
|
+
|
|
155
|
+
function registerStripCompilation(compilation) {
|
|
156
|
+
__compilation = compilation
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function logStripError(path, e) {
|
|
160
|
+
const msg = `[Mpx strip conditional error]\n path: ${path}\n message: ${e && e.message}\n stack:\n${e && e.stack}`
|
|
161
|
+
console.error(msg)
|
|
162
|
+
if (__compilation && Array.isArray(__compilation.errors)) {
|
|
163
|
+
const err = new Error(msg)
|
|
164
|
+
err.file = path
|
|
165
|
+
__compilation.errors.push(err)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function rewriteFSForCss() {
|
|
170
|
+
if (isRewritten) return
|
|
171
|
+
isRewritten = true
|
|
172
|
+
fs.readFileSync = function () {
|
|
173
|
+
return (proxyReadFileSync || rawReadFileSync).apply(fs, arguments)
|
|
174
|
+
}
|
|
175
|
+
fs.readFile = function () {
|
|
176
|
+
return (proxyReadFile || rawReadFile).apply(fs, arguments)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function startFSStripForCss(defs) {
|
|
181
|
+
function shouldStrip(path) {
|
|
182
|
+
return typeof path === 'string' && /\.(styl|scss|sass|less|css|mpx)$/.test(path)
|
|
183
|
+
}
|
|
184
|
+
proxyReadFileSync = function (path, options) {
|
|
185
|
+
const content = rawReadFileSync.call(fs, path, options)
|
|
186
|
+
if (shouldStrip(path)) {
|
|
187
|
+
try {
|
|
188
|
+
if (typeof content === 'string') {
|
|
189
|
+
return stripCondition(content, defs, path)
|
|
190
|
+
} else if (Buffer.isBuffer(content)) {
|
|
191
|
+
const str = content.toString('utf-8')
|
|
192
|
+
const result = stripCondition(str, defs, path)
|
|
193
|
+
if (result !== str) {
|
|
194
|
+
return Buffer.from(result, 'utf-8')
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} catch (e) {
|
|
198
|
+
logStripError(path, e)
|
|
199
|
+
return content
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return content
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
proxyReadFile = function () {
|
|
206
|
+
const args = Array.from(arguments)
|
|
207
|
+
const callback = args[args.length - 1]
|
|
208
|
+
const path = args[0]
|
|
209
|
+
|
|
210
|
+
if (typeof callback !== 'function') {
|
|
211
|
+
return rawReadFile.apply(fs, args)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const wrappedCallback = (err, data) => {
|
|
215
|
+
if (err) return callback(err)
|
|
216
|
+
if (shouldStrip(path)) {
|
|
217
|
+
try {
|
|
218
|
+
if (typeof data === 'string') {
|
|
219
|
+
const result = stripCondition(data, defs, path)
|
|
220
|
+
return callback(null, result)
|
|
221
|
+
} else if (Buffer.isBuffer(data)) {
|
|
222
|
+
const content = data.toString('utf-8')
|
|
223
|
+
const result = stripCondition(content, defs, path)
|
|
224
|
+
if (result !== content) {
|
|
225
|
+
return callback(null, Buffer.from(result, 'utf-8'))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {
|
|
229
|
+
logStripError(path, e)
|
|
230
|
+
return callback(null, data)
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
callback(null, data)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
args[args.length - 1] = wrappedCallback
|
|
237
|
+
return rawReadFile.apply(fs, args)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
module.exports.stripCondition = stripCondition
|
|
242
|
+
module.exports.rewriteFSForCss = rewriteFSForCss
|
|
243
|
+
module.exports.startFSStripForCss = startFSStripForCss
|
|
244
|
+
module.exports.registerStripCompilation = registerStripCompilation
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const JSON5 = require('json5')
|
|
2
2
|
const he = require('he')
|
|
3
3
|
const config = require('../config')
|
|
4
|
-
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID, MPX_TAG_PAGE_SELECTOR } = require('../utils/const')
|
|
4
|
+
const { MPX_ROOT_VIEW, MPX_APP_MODULE_ID, PARENT_MODULE_ID, MPX_TAG_PAGE_SELECTOR, EXTEND_COMPONENT_CONFIG } = require('../utils/const')
|
|
5
5
|
const normalize = require('../utils/normalize')
|
|
6
6
|
const { normalizeCondition } = require('../utils/match-condition')
|
|
7
7
|
const isValidIdentifierStr = require('../utils/is-valid-identifier-str')
|
|
@@ -764,9 +764,7 @@ function parse (template, options) {
|
|
|
764
764
|
|
|
765
765
|
const children = currentParent.children
|
|
766
766
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (!isTextLikeParent) {
|
|
767
|
+
if (currentParent.tag !== 'text') {
|
|
770
768
|
text = text.trim()
|
|
771
769
|
} else {
|
|
772
770
|
text = text.trim() ? text : ''
|
|
@@ -2247,7 +2245,6 @@ function postProcessIfReact (el) {
|
|
|
2247
2245
|
delete el.elseif
|
|
2248
2246
|
el._if = true
|
|
2249
2247
|
addIfCondition(ifNode, {
|
|
2250
|
-
exp: el.elseif.exp,
|
|
2251
2248
|
block: el
|
|
2252
2249
|
})
|
|
2253
2250
|
removeNode(el, true)
|
|
@@ -2435,7 +2432,11 @@ function isRealNode (el) {
|
|
|
2435
2432
|
}
|
|
2436
2433
|
|
|
2437
2434
|
function isComponentNode (el) {
|
|
2438
|
-
return usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component' || componentGenerics[el.tag]
|
|
2435
|
+
return usingComponents.indexOf(el.tag) !== -1 || el.tag === 'component' || componentGenerics[el.tag] || isExtendComponentNode(el)
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
function isExtendComponentNode (el) {
|
|
2439
|
+
return EXTEND_COMPONENT_CONFIG[el.tag]?.[mode]
|
|
2439
2440
|
}
|
|
2440
2441
|
|
|
2441
2442
|
function getComponentInfo (el) {
|
|
@@ -2443,7 +2444,7 @@ function getComponentInfo (el) {
|
|
|
2443
2444
|
}
|
|
2444
2445
|
|
|
2445
2446
|
function isReactComponent (el) {
|
|
2446
|
-
return !isComponentNode(el) && isRealNode(el) && !el.isBuiltIn
|
|
2447
|
+
return !isComponentNode(el) && isRealNode(el) && !el.isBuiltIn && !isExtendComponentNode(el)
|
|
2447
2448
|
}
|
|
2448
2449
|
|
|
2449
2450
|
function processExternalClasses (el, options) {
|
|
@@ -2720,7 +2721,7 @@ function postProcessTemplate (el) {
|
|
|
2720
2721
|
}
|
|
2721
2722
|
}
|
|
2722
2723
|
|
|
2723
|
-
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,noMode')
|
|
2724
|
+
const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,ios,android,harmony,ks,noMode')
|
|
2724
2725
|
|
|
2725
2726
|
function isValidModeP (i) {
|
|
2726
2727
|
return isValidMode(i[0] === '_' ? i.slice(1) : i)
|
package/lib/utils/const.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const componentPrefixPath = '@mpxjs/webpack-plugin/lib/runtime/components'
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
MPX_PROCESSED_FLAG: 'mpx_processed',
|
|
3
5
|
MPX_DISABLE_EXTRACTOR_CACHE: 'mpx_disable_extractor_cache',
|
|
@@ -7,5 +9,32 @@ module.exports = {
|
|
|
7
9
|
MPX_ROOT_VIEW: 'mpx-root-view', // 根节点类名
|
|
8
10
|
MPX_APP_MODULE_ID: 'mpx-app-scope', // app文件moduleId
|
|
9
11
|
PARENT_MODULE_ID: '__pid',
|
|
12
|
+
// 扩展组件的平台配置:声明哪些组件在哪些平台有专用实现,哪些使用公共组件
|
|
13
|
+
EXTEND_COMPONENT_CONFIG: {
|
|
14
|
+
'section-list': {
|
|
15
|
+
wx: `${componentPrefixPath}/wx/mpx-section-list.mpx`,
|
|
16
|
+
ali: `${componentPrefixPath}/ali/mpx-section-list.mpx`,
|
|
17
|
+
web: `${componentPrefixPath}/web/mpx-section-list.vue`,
|
|
18
|
+
ios: `${componentPrefixPath}/react/dist/mpx-section-list.jsx`,
|
|
19
|
+
android: `${componentPrefixPath}/react/dist/mpx-section-list.jsx`,
|
|
20
|
+
harmony: `${componentPrefixPath}/react/dist/mpx-section-list.jsx`
|
|
21
|
+
},
|
|
22
|
+
'sticky-header': {
|
|
23
|
+
wx: `${componentPrefixPath}/wx/mpx-sticky-header.mpx`,
|
|
24
|
+
ali: `${componentPrefixPath}/ali/mpx-sticky-header.mpx`,
|
|
25
|
+
web: `${componentPrefixPath}/web/mpx-sticky-header.vue`,
|
|
26
|
+
ios: `${componentPrefixPath}/react/dist/mpx-sticky-header.jsx`,
|
|
27
|
+
android: `${componentPrefixPath}/react/dist/mpx-sticky-header.jsx`,
|
|
28
|
+
harmony: `${componentPrefixPath}/react/dist/mpx-sticky-header.jsx`
|
|
29
|
+
},
|
|
30
|
+
'sticky-section': {
|
|
31
|
+
wx: `${componentPrefixPath}/wx/mpx-sticky-section.mpx`,
|
|
32
|
+
ali: `${componentPrefixPath}/ali/mpx-sticky-section.mpx`,
|
|
33
|
+
web: `${componentPrefixPath}/web/mpx-sticky-section.vue`,
|
|
34
|
+
ios: `${componentPrefixPath}/react/dist/mpx-sticky-section.jsx`,
|
|
35
|
+
android: `${componentPrefixPath}/react/dist/mpx-sticky-section.jsx`,
|
|
36
|
+
harmony: `${componentPrefixPath}/react/dist/mpx-sticky-section.jsx`
|
|
37
|
+
}
|
|
38
|
+
},
|
|
10
39
|
MPX_TAG_PAGE_SELECTOR: 'mpx-page'
|
|
11
40
|
}
|
|
@@ -91,7 +91,7 @@ const isBuildInReactTag = makeMap(
|
|
|
91
91
|
'mpx-movable-area,mpx-label,mpx-input,' +
|
|
92
92
|
'mpx-image,mpx-form,mpx-checkbox,mpx-checkbox-group,mpx-button,' +
|
|
93
93
|
'mpx-rich-text,mpx-picker-view-column,mpx-picker-view,mpx-picker,' +
|
|
94
|
-
'mpx-icon,mpx-canvas'
|
|
94
|
+
'mpx-icon,mpx-canvas,mpx-camera'
|
|
95
95
|
)
|
|
96
96
|
|
|
97
97
|
const isSpace = makeMap('ensp,emsp,nbsp')
|