Skip to content

Commit

Permalink
Merge branch 'master' into feat-layout-hook
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Oct 18, 2024
2 parents 9a121b4 + 120abe7 commit 1633c25
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
1 change: 1 addition & 0 deletions packages/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Mpx.config = {
ignoreProxyWhiteList: ['id', 'dataset', 'data'],
observeClassInstance: false,
errorHandler: null,
warnHandler: null,
proxyEventHandler: null,
setDataHandler: null,
forceFlushSync: false,
Expand Down
8 changes: 7 additions & 1 deletion packages/utils/src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ export function warn (msg, location, e) {
} else if (condition instanceof RegExp) {
ignore = condition.test(msg)
}
if (!ignore) return log('warn', msg, location, e)
if (!ignore) {
const warnHandler = global.__mpx?.config.warnHandler
if (isFunction(warnHandler)) {
warnHandler(msg, location, e)
}
return log('warn', msg, location, e)
}
}

export function error (msg, location, e) {
Expand Down
4 changes: 1 addition & 3 deletions packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,6 @@ try {
}

if (isWeb(mpx.mode)) {
const mpxStyleOptions = queryObj.mpxStyleOptions
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
let cssLoaderIndex = -1
Expand All @@ -1837,8 +1836,7 @@ try {
}
if (loaderIndex > -1) {
loaders.splice(loaderIndex + 1, 0, {
loader: styleCompilerPath,
options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {}
loader: styleCompilerPath
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function wrapImage (imageStyle?: ExtendedViewStyle) {
}
}

return <View key='viewBgImg' {...needLayout ? { onLayout } : null} style={{ ...StyleSheet.absoluteFillObject, width: '100%', height: '100%', overflow: 'hidden' }}>
return <View key='backgroundImage' {...needLayout ? { onLayout } : null} style={{ ...StyleSheet.absoluteFillObject, width: '100%', height: '100%', overflow: 'hidden' }}>
{show && <Image {...imageStyleToProps(preImageInfo, sizeInfo.current as Size, layoutInfo.current as Size)} />}
</View>
}
Expand Down
13 changes: 0 additions & 13 deletions packages/webpack-plugin/lib/runtime/components/react/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,6 @@ function transformCalc (styleObj: Record<string, any>, calcKeyPaths: Array<Array
})
}

function transformLineHeight (styleObj: Record<string, any>) {
let { lineHeight } = styleObj
if (typeof lineHeight === 'string' && PERCENT_REGEX.test(lineHeight)) {
const hasFontSize = hasOwn(styleObj, 'fontSize')
if (!hasFontSize) {
warn('The fontSize property could not be read correctly, so the default fontSize of 16 will be used as the basis for calculating the lineHeight!')
}
const fontSize = hasFontSize ? styleObj.fontSize : DEFAULT_FONT_SIZE
lineHeight = (parseFloat(lineHeight) / 100) * fontSize
styleObj.lineHeight = lineHeight
}
}

interface TransformStyleConfig {
enableVar?: boolean
externalVarContext?: Record<string, any>
Expand Down
7 changes: 2 additions & 5 deletions packages/webpack-plugin/lib/web/processStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ module.exports = function (styles, options, callback) {
attrs (style) {
const attrs = Object.assign({}, style.attrs)
if (options.autoScope) attrs.scoped = true
attrs.mpxStyleOptions = JSON.stringify({
// scoped: !!options.autoScope,
// query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理
mid: options.moduleId
})
// query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理
attrs.mid = options.moduleId
return attrs
}
})
Expand Down

0 comments on commit 1633c25

Please sign in to comment.