@mpxjs/webpack-plugin 2.10.15-3 → 2.10.15-5
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/runtime/components/react/dist/mpx-movable-view.jsx +9 -9
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +13 -2
- package/lib/runtime/components/react/mpx-movable-view.tsx +10 -10
- package/lib/runtime/components/react/mpx-scroll-view.tsx +15 -2
- package/lib/runtime/components/web/filterTag.js +9 -0
- package/lib/runtime/optionProcessor.js +3 -2
- package/lib/template-compiler/compiler.js +12 -1
- package/lib/web/processScript.js +4 -1
- package/lib/web/processTemplate.js +4 -2
- package/package.json +1 -1
|
@@ -100,15 +100,6 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
|
|
|
100
100
|
layoutRef
|
|
101
101
|
}, propsRef.current));
|
|
102
102
|
}, []);
|
|
103
|
-
// 节流版本的 change 事件触发
|
|
104
|
-
const handleTriggerChangeThrottled = useCallback(({ x, y, type }) => {
|
|
105
|
-
'worklet';
|
|
106
|
-
const now = Date.now();
|
|
107
|
-
if (now - lastChangeTime.value >= changeThrottleTime) {
|
|
108
|
-
lastChangeTime.value = now;
|
|
109
|
-
runOnJS(runOnJSCallback)('handleTriggerChange', { x, y, type });
|
|
110
|
-
}
|
|
111
|
-
}, [changeThrottleTime]);
|
|
112
103
|
useEffect(() => {
|
|
113
104
|
runOnUI(() => {
|
|
114
105
|
if (offsetX.value !== x || offsetY.value !== y) {
|
|
@@ -302,6 +293,15 @@ const _MovableView = forwardRef((movableViewProps, ref) => {
|
|
|
302
293
|
triggerEndOnJS
|
|
303
294
|
});
|
|
304
295
|
const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef);
|
|
296
|
+
// 节流版本的 change 事件触发
|
|
297
|
+
const handleTriggerChangeThrottled = useCallback(({ x, y, type }) => {
|
|
298
|
+
'worklet';
|
|
299
|
+
const now = Date.now();
|
|
300
|
+
if (now - lastChangeTime.value >= changeThrottleTime) {
|
|
301
|
+
lastChangeTime.value = now;
|
|
302
|
+
runOnJS(runOnJSCallback)('handleTriggerChange', { x, y, type });
|
|
303
|
+
}
|
|
304
|
+
}, [changeThrottleTime]);
|
|
305
305
|
const gesture = useMemo(() => {
|
|
306
306
|
const handleTriggerMove = (e) => {
|
|
307
307
|
'worklet';
|
|
@@ -79,6 +79,16 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
79
79
|
const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
|
|
80
80
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
81
81
|
const scrollViewRef = useRef(null);
|
|
82
|
+
const propsRef = useRef(props);
|
|
83
|
+
const refresherStateRef = useRef({
|
|
84
|
+
hasRefresher,
|
|
85
|
+
refresherTriggered
|
|
86
|
+
});
|
|
87
|
+
propsRef.current = props;
|
|
88
|
+
refresherStateRef.current = {
|
|
89
|
+
hasRefresher,
|
|
90
|
+
refresherTriggered
|
|
91
|
+
};
|
|
82
92
|
const runOnJSCallbackRef = useRef({
|
|
83
93
|
setEnableScroll,
|
|
84
94
|
setScrollBounces,
|
|
@@ -347,6 +357,7 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
347
357
|
}
|
|
348
358
|
// 处理刷新
|
|
349
359
|
function onRefresh() {
|
|
360
|
+
const { hasRefresher, refresherTriggered } = refresherStateRef.current;
|
|
350
361
|
if (hasRefresher && refresherTriggered === undefined) {
|
|
351
362
|
// 处理使用了自定义刷新组件,又没设置 refresherTriggered 的情况
|
|
352
363
|
setRefreshing(true);
|
|
@@ -358,9 +369,9 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
|
|
|
358
369
|
}
|
|
359
370
|
}, 500);
|
|
360
371
|
}
|
|
361
|
-
const { bindrefresherrefresh } =
|
|
372
|
+
const { bindrefresherrefresh } = propsRef.current;
|
|
362
373
|
bindrefresherrefresh &&
|
|
363
|
-
bindrefresherrefresh(getCustomEvent('refresherrefresh', {}, { layoutRef },
|
|
374
|
+
bindrefresherrefresh(getCustomEvent('refresherrefresh', {}, { layoutRef }, propsRef.current));
|
|
364
375
|
}
|
|
365
376
|
function getRefresherContent(children) {
|
|
366
377
|
let refresherContent = null;
|
|
@@ -200,16 +200,6 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
200
200
|
)
|
|
201
201
|
}, [])
|
|
202
202
|
|
|
203
|
-
// 节流版本的 change 事件触发
|
|
204
|
-
const handleTriggerChangeThrottled = useCallback(({ x, y, type }: { x: number; y: number; type?: string }) => {
|
|
205
|
-
'worklet'
|
|
206
|
-
const now = Date.now()
|
|
207
|
-
if (now - lastChangeTime.value >= changeThrottleTime) {
|
|
208
|
-
lastChangeTime.value = now
|
|
209
|
-
runOnJS(runOnJSCallback)('handleTriggerChange', { x, y, type })
|
|
210
|
-
}
|
|
211
|
-
}, [changeThrottleTime])
|
|
212
|
-
|
|
213
203
|
useEffect(() => {
|
|
214
204
|
runOnUI(() => {
|
|
215
205
|
if (offsetX.value !== x || offsetY.value !== y) {
|
|
@@ -414,6 +404,16 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
|
|
|
414
404
|
})
|
|
415
405
|
const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef)
|
|
416
406
|
|
|
407
|
+
// 节流版本的 change 事件触发
|
|
408
|
+
const handleTriggerChangeThrottled = useCallback(({ x, y, type }: { x: number; y: number; type?: string }) => {
|
|
409
|
+
'worklet'
|
|
410
|
+
const now = Date.now()
|
|
411
|
+
if (now - lastChangeTime.value >= changeThrottleTime) {
|
|
412
|
+
lastChangeTime.value = now
|
|
413
|
+
runOnJS(runOnJSCallback)('handleTriggerChange', { x, y, type })
|
|
414
|
+
}
|
|
415
|
+
}, [changeThrottleTime])
|
|
416
|
+
|
|
417
417
|
const gesture = useMemo(() => {
|
|
418
418
|
const handleTriggerMove = (e: GestureTouchEvent) => {
|
|
419
419
|
'worklet'
|
|
@@ -211,6 +211,18 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
211
211
|
|
|
212
212
|
const scrollViewRef = useRef<ScrollView>(null)
|
|
213
213
|
|
|
214
|
+
const propsRef = useRef(props)
|
|
215
|
+
const refresherStateRef = useRef({
|
|
216
|
+
hasRefresher,
|
|
217
|
+
refresherTriggered
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
propsRef.current = props
|
|
221
|
+
refresherStateRef.current = {
|
|
222
|
+
hasRefresher,
|
|
223
|
+
refresherTriggered
|
|
224
|
+
}
|
|
225
|
+
|
|
214
226
|
const runOnJSCallbackRef = useRef({
|
|
215
227
|
setEnableScroll,
|
|
216
228
|
setScrollBounces,
|
|
@@ -524,6 +536,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
524
536
|
|
|
525
537
|
// 处理刷新
|
|
526
538
|
function onRefresh () {
|
|
539
|
+
const { hasRefresher, refresherTriggered } = refresherStateRef.current
|
|
527
540
|
if (hasRefresher && refresherTriggered === undefined) {
|
|
528
541
|
// 处理使用了自定义刷新组件,又没设置 refresherTriggered 的情况
|
|
529
542
|
setRefreshing(true)
|
|
@@ -535,10 +548,10 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
|
|
|
535
548
|
}
|
|
536
549
|
}, 500)
|
|
537
550
|
}
|
|
538
|
-
const { bindrefresherrefresh } =
|
|
551
|
+
const { bindrefresherrefresh } = propsRef.current
|
|
539
552
|
bindrefresherrefresh &&
|
|
540
553
|
bindrefresherrefresh(
|
|
541
|
-
getCustomEvent('refresherrefresh', {}, { layoutRef },
|
|
554
|
+
getCustomEvent('refresherrefresh', {}, { layoutRef }, propsRef.current)
|
|
542
555
|
)
|
|
543
556
|
}
|
|
544
557
|
|
|
@@ -88,7 +88,16 @@ function parseHTML (html, options) {
|
|
|
88
88
|
match.end = index
|
|
89
89
|
handleStartTag(match)
|
|
90
90
|
}
|
|
91
|
+
continue
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// If we reach here, the `<` at position 0 does not start a valid tag/comment/end tag
|
|
95
|
+
// Treat it as plain text to avoid infinite loop on stray '<'
|
|
96
|
+
if (options.chars) {
|
|
97
|
+
options.chars('<')
|
|
91
98
|
}
|
|
99
|
+
advance(1)
|
|
100
|
+
continue
|
|
92
101
|
}
|
|
93
102
|
let text, rest, next
|
|
94
103
|
if (textEnd >= 0) {
|
|
@@ -14,7 +14,8 @@ export function processComponentOption (
|
|
|
14
14
|
componentGenerics,
|
|
15
15
|
genericsInfo,
|
|
16
16
|
wxsMixin,
|
|
17
|
-
hasApp
|
|
17
|
+
hasApp,
|
|
18
|
+
disablePageTransition
|
|
18
19
|
}
|
|
19
20
|
) {
|
|
20
21
|
// 局部注册页面和组件中依赖的组件
|
|
@@ -79,7 +80,7 @@ registered in parent context!`)
|
|
|
79
80
|
transitionName: ''
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
if (!
|
|
83
|
+
if (!disablePageTransition) {
|
|
83
84
|
option.watch = {
|
|
84
85
|
$route: {
|
|
85
86
|
handler () {
|
|
@@ -1936,7 +1936,18 @@ function processAttrs (el, options) {
|
|
|
1936
1936
|
el.attrsList.forEach((attr) => {
|
|
1937
1937
|
const isTemplateData = el.tag === 'template' && attr.name === 'data'
|
|
1938
1938
|
const needWrap = isTemplateData && mode !== 'swan'
|
|
1939
|
-
|
|
1939
|
+
let value = needWrap ? `{${attr.value}}` : attr.value
|
|
1940
|
+
|
|
1941
|
+
// 修复React Native环境下属性值中插值表达式带空格的问题
|
|
1942
|
+
if (isReact(mode) && typeof value === 'string') {
|
|
1943
|
+
// 检查是否为带空格的插值表达式
|
|
1944
|
+
const trimmedValue = value.trim()
|
|
1945
|
+
if (trimmedValue.startsWith('{{') && trimmedValue.endsWith('}}')) {
|
|
1946
|
+
// 如果是纯插值表达式但带有前后空格,则使用去除空格后的值进行解析
|
|
1947
|
+
value = trimmedValue
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1940
1951
|
const parsed = parseMustacheWithContext(value)
|
|
1941
1952
|
if (parsed.hasBinding) {
|
|
1942
1953
|
// 该属性判断用于提供给运行时对于计算属性作为props传递时提出警告
|
package/lib/web/processScript.js
CHANGED
|
@@ -27,6 +27,8 @@ module.exports = function (script, {
|
|
|
27
27
|
}, callback) {
|
|
28
28
|
const { projectRoot, appInfo, webConfig, i18n } = loaderContext.getMpx()
|
|
29
29
|
|
|
30
|
+
const { disablePageTransition = true } = webConfig
|
|
31
|
+
|
|
30
32
|
let output = '/* script */\n'
|
|
31
33
|
|
|
32
34
|
let scriptSrcMode = srcMode
|
|
@@ -86,7 +88,8 @@ module.exports = function (script, {
|
|
|
86
88
|
componentGenerics: ${JSON.stringify(componentGenerics)},
|
|
87
89
|
genericsInfo: ${JSON.stringify(genericsInfo)},
|
|
88
90
|
wxsMixin: getWxsMixin(wxsModules),
|
|
89
|
-
hasApp: ${hasApp}
|
|
91
|
+
hasApp: ${hasApp},
|
|
92
|
+
disablePageTransition: ${JSON.stringify(disablePageTransition)},
|
|
90
93
|
})\n`
|
|
91
94
|
return content
|
|
92
95
|
}
|
|
@@ -35,11 +35,13 @@ module.exports = function (template, {
|
|
|
35
35
|
let output = '/* template */\n'
|
|
36
36
|
|
|
37
37
|
if (ctorType === 'app') {
|
|
38
|
-
const { el } = webConfig
|
|
38
|
+
const { el, disablePageTransition = true } = webConfig
|
|
39
39
|
const idName = (el && el.match(/#(.*)/) && el.match(/#(.*)/)[1]) || 'app'
|
|
40
40
|
template = {
|
|
41
41
|
tag: 'template',
|
|
42
|
-
content:
|
|
42
|
+
content: disablePageTransition
|
|
43
|
+
? `<div id="${idName}"><mpx-keep-alive><router-view></router-view></mpx-keep-alive></div>`
|
|
44
|
+
: `<div id="${idName}"><transition :name="transitionName"><mpx-keep-alive><router-view></router-view></mpx-keep-alive></transition></div>`
|
|
43
45
|
}
|
|
44
46
|
builtInComponentsMap['mpx-keep-alive'] = {
|
|
45
47
|
resource: addQuery('@mpxjs/webpack-plugin/lib/runtime/components/web/mpx-keep-alive.vue', { isComponent: true })
|