@mpxjs/webpack-plugin 2.10.13-beta.2 → 2.10.14-beta.1
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/index.js +51 -71
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +7 -10
- package/lib/runtime/components/react/mpx-swiper.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +7 -10
- package/lib/runtime/components/web/mpx-input.vue +1 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1880,92 +1880,72 @@ try {
|
|
|
1880
1880
|
normalModuleFactory.hooks.afterResolve.tap('MpxWebpackPlugin', ({ createData }) => {
|
|
1881
1881
|
const { queryObj } = parseRequest(createData.request)
|
|
1882
1882
|
const loaders = createData.loaders
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
const vueProcessFlag = queryObj.vue && queryObj.mpx !== MPX_PROCESSED_FLAG
|
|
1886
|
-
if (mpxProcessFlag || vueProcessFlag) {
|
|
1883
|
+
if (queryObj.mpx && queryObj.mpx !== MPX_PROCESSED_FLAG) {
|
|
1884
|
+
const type = queryObj.type
|
|
1887
1885
|
const extract = queryObj.extract
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
'node_modules/less-loader': -1,
|
|
1893
|
-
'node_modules/css-loader': -1
|
|
1894
|
-
}
|
|
1886
|
+
|
|
1887
|
+
if (type === 'styles') {
|
|
1888
|
+
let insertBeforeIndex = -1
|
|
1889
|
+
// 单次遍历收集所有索引
|
|
1895
1890
|
loaders.forEach((loader, index) => {
|
|
1896
1891
|
const currentLoader = toPosix(loader.loader)
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
loaderTypes[key] = index
|
|
1900
|
-
break
|
|
1901
|
-
}
|
|
1892
|
+
if (currentLoader.includes('node_modules/stylus-loader') || currentLoader.includes('node_modules/sass-loader') || currentLoader.includes('node_modules/less-loader')) {
|
|
1893
|
+
insertBeforeIndex = index
|
|
1902
1894
|
}
|
|
1903
1895
|
})
|
|
1904
|
-
const insertStripLoaders = (index) => {
|
|
1905
|
-
if (index !== -1) {
|
|
1906
|
-
loaders.splice(index, 0, { loader: styleStripConditionalPath, options: {id: 0} })
|
|
1907
|
-
loaders.splice(index + 2, 0, { loader: styleStripConditionalPath, options: {id: 1} })
|
|
1908
|
-
return true
|
|
1909
|
-
}
|
|
1910
|
-
return false
|
|
1911
|
-
}
|
|
1912
1896
|
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
if (insertStripLoaders(loaderTypes[loaderKey])) {
|
|
1916
|
-
break
|
|
1917
|
-
}
|
|
1897
|
+
if (insertBeforeIndex !== -1) {
|
|
1898
|
+
loaders.splice(insertBeforeIndex, 0, { loader: styleStripConditionalPath })
|
|
1918
1899
|
}
|
|
1900
|
+
loaders.push({ loader: styleStripConditionalPath })
|
|
1919
1901
|
}
|
|
1920
1902
|
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
insertBeforeIndex = index
|
|
1934
|
-
}
|
|
1935
|
-
})
|
|
1936
|
-
if (insertBeforeIndex > -1) {
|
|
1937
|
-
loaders.splice(insertBeforeIndex + 1, 0, {
|
|
1938
|
-
loader: info[2]
|
|
1939
|
-
})
|
|
1903
|
+
switch (type) {
|
|
1904
|
+
case 'styles':
|
|
1905
|
+
case 'template': {
|
|
1906
|
+
let insertBeforeIndex = -1
|
|
1907
|
+
const info = typeLoaderProcessInfo[type]
|
|
1908
|
+
loaders.forEach((loader, index) => {
|
|
1909
|
+
const currentLoader = toPosix(loader.loader)
|
|
1910
|
+
if (currentLoader.includes(info[0])) {
|
|
1911
|
+
loader.loader = info[1]
|
|
1912
|
+
insertBeforeIndex = index
|
|
1913
|
+
} else if (currentLoader.includes(info[1])) {
|
|
1914
|
+
insertBeforeIndex = index
|
|
1940
1915
|
}
|
|
1941
|
-
|
|
1916
|
+
})
|
|
1917
|
+
if (insertBeforeIndex > -1) {
|
|
1918
|
+
loaders.splice(insertBeforeIndex + 1, 0, {
|
|
1919
|
+
loader: info[2]
|
|
1920
|
+
})
|
|
1942
1921
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
})
|
|
1948
|
-
} else if (queryObj.isPlugin) {
|
|
1949
|
-
loaders.unshift({
|
|
1950
|
-
loader: jsonPluginCompilerPath
|
|
1951
|
-
})
|
|
1952
|
-
} else {
|
|
1953
|
-
loaders.unshift({
|
|
1954
|
-
loader: jsonCompilerPath
|
|
1955
|
-
})
|
|
1956
|
-
}
|
|
1957
|
-
break
|
|
1958
|
-
case 'wxs':
|
|
1922
|
+
break
|
|
1923
|
+
}
|
|
1924
|
+
case 'json':
|
|
1925
|
+
if (queryObj.isTheme) {
|
|
1959
1926
|
loaders.unshift({
|
|
1960
|
-
loader:
|
|
1927
|
+
loader: jsonThemeCompilerPath
|
|
1961
1928
|
})
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1929
|
+
} else if (queryObj.isPlugin) {
|
|
1930
|
+
loaders.unshift({
|
|
1931
|
+
loader: jsonPluginCompilerPath
|
|
1932
|
+
})
|
|
1933
|
+
} else {
|
|
1934
|
+
loaders.unshift({
|
|
1935
|
+
loader: jsonCompilerPath
|
|
1936
|
+
})
|
|
1937
|
+
}
|
|
1938
|
+
break
|
|
1939
|
+
case 'wxs':
|
|
1965
1940
|
loaders.unshift({
|
|
1966
|
-
loader:
|
|
1941
|
+
loader: wxsLoaderPath
|
|
1967
1942
|
})
|
|
1968
|
-
|
|
1943
|
+
break
|
|
1944
|
+
}
|
|
1945
|
+
if (extract) {
|
|
1946
|
+
loaders.unshift({
|
|
1947
|
+
loader: extractorPath
|
|
1948
|
+
})
|
|
1969
1949
|
}
|
|
1970
1950
|
createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
|
|
1971
1951
|
}
|
|
@@ -662,7 +662,7 @@ const SwiperWrapper = forwardRef((props, ref) => {
|
|
|
662
662
|
const moveDistance = e[strAbso] - preAbsolutePos.value;
|
|
663
663
|
const eventData = {
|
|
664
664
|
translation: moveDistance,
|
|
665
|
-
transdir: moveDistance
|
|
665
|
+
transdir: moveDistance
|
|
666
666
|
};
|
|
667
667
|
// 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
|
|
668
668
|
const { half } = computeHalf(eventData);
|
|
@@ -203,16 +203,13 @@ function backgroundSize(imageProps, preImageInfo, imageSize, layoutInfo) {
|
|
|
203
203
|
else { // 数值类型 ImageStyle
|
|
204
204
|
// 数值类型设置为 stretch
|
|
205
205
|
imageProps.resizeMode = 'stretch';
|
|
206
|
-
if (type === 'linear') {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
height: dimensionHeight
|
|
214
|
-
};
|
|
215
|
-
}
|
|
206
|
+
if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
|
|
207
|
+
// ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
|
|
208
|
+
// 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
|
|
209
|
+
dimensions = {
|
|
210
|
+
width: 0,
|
|
211
|
+
height: 0
|
|
212
|
+
};
|
|
216
213
|
}
|
|
217
214
|
else {
|
|
218
215
|
dimensions = {
|
|
@@ -755,7 +755,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
|
|
|
755
755
|
const moveDistance = e[strAbso] - preAbsolutePos.value
|
|
756
756
|
const eventData = {
|
|
757
757
|
translation: moveDistance,
|
|
758
|
-
transdir: moveDistance
|
|
758
|
+
transdir: moveDistance
|
|
759
759
|
}
|
|
760
760
|
// 1. 支持滑动中超出一半更新索引的能力:只更新索引并不会影响onFinalize依据当前offset计算的索引
|
|
761
761
|
const { half } = computeHalf(eventData)
|
|
@@ -287,16 +287,13 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
|
|
|
287
287
|
} else { // 数值类型 ImageStyle
|
|
288
288
|
// 数值类型设置为 stretch
|
|
289
289
|
imageProps.resizeMode = 'stretch'
|
|
290
|
-
if (type === 'linear') {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
height: dimensionHeight
|
|
298
|
-
} as { width: NumberVal, height: NumberVal }
|
|
299
|
-
}
|
|
290
|
+
if (type === 'linear' && (!layoutWidth || !layoutHeight)) {
|
|
291
|
+
// ios 上 linear 组件只要重新触发渲染,在渲染过程中外层容器 width 或者 height 被设置为 0,通过设置 % 的方式会渲染不出来,即使后面再更新为正常宽高也渲染不出来
|
|
292
|
+
// 所以 hack 手动先将 linear 宽高也设置为 0,后面再更新为正确的数值或 %。
|
|
293
|
+
dimensions = {
|
|
294
|
+
width: 0,
|
|
295
|
+
height: 0
|
|
296
|
+
} as { width: NumberVal, height: NumberVal }
|
|
300
297
|
} else {
|
|
301
298
|
dimensions = {
|
|
302
299
|
width: isPercent(width) ? width : +width,
|
|
@@ -56,19 +56,7 @@
|
|
|
56
56
|
if (val !== -1) this.setSelectionRange(undefined, val)
|
|
57
57
|
},
|
|
58
58
|
immediate: true
|
|
59
|
-
}
|
|
60
|
-
focus (val) {
|
|
61
|
-
if (val) {
|
|
62
|
-
this.$nextTick(() => {
|
|
63
|
-
this.$refs.input.focus()
|
|
64
|
-
})
|
|
65
|
-
} else {
|
|
66
|
-
this.$nextTick(() => {
|
|
67
|
-
this.$refs.input.blur()
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
immediate: true
|
|
59
|
+
}
|
|
72
60
|
},
|
|
73
61
|
render (createElement) {
|
|
74
62
|
const mergeBefore = {
|