Skip to content

Commit

Permalink
Merge branch 'master' into fix-picker-view-1129
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshunnn committed Dec 23, 2024
2 parents 7f032a6 + 0fd875f commit 8395ee1
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 20 deletions.
7 changes: 7 additions & 0 deletions packages/api-proxy/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ export const createVideoContext: WechatMiniprogram.Wx['createVideoContext']
export const onWindowResize: WechatMiniprogram.Wx['onWindowResize']
export const offWindowResize: WechatMiniprogram.Wx['offWindowResize']
export const createAnimation: WechatMiniprogram.Wx['createAnimation']
export const hideHomeButton: WechatMiniprogram.Wx['hideHomeButton']
export const getSetting: WechatMiniprogram.Wx['getSetting']
export const openSetting: WechatMiniprogram.Wx['openSetting']
export const enableAlertBeforeUnload: WechatMiniprogram.Wx['enableAlertBeforeUnload']
export const disableAlertBeforeUnload: WechatMiniprogram.Wx['disableAlertBeforeUnload']
export const getMenuButtonBoundingClientRect: WechatMiniprogram.Wx['getMenuButtonBoundingClientRect']
export const getImageInfo: WechatMiniprogram.Wx['getImageInfo']
export const vibrateShort: WechatMiniprogram.Wx['vibrateShort']
export const vibrateLong: WechatMiniprogram.Wx['vibrateLong']
export const getExtConfig: WechatMiniprogram.Wx['getExtConfig']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function showActionSheet (options = {}) {
remove()
}
return (
<TouchableHighlight underlayColor="rgba(0,0,0,0.6)" onPress={cancelAction} style={styles.actionActionMask}>
<TouchableHighlight underlayColor="rgba(0,0,0,0.6)" activeOpacity={1} onPress={cancelAction} style={styles.actionActionMask}>
<Animated.View style={[styles.actionSheetContent, animatedStyles]} >
{ alertText ? <View style={ styles.itemStyle }><Text style={[styles.itemTextStyle, { color: '#666666' }]}>{alertText}</Text></View> : null }
{ itemList.map((item, index) => <TouchableHighlight key={index} underlayColor="#ececec" onPress={() => selectAction(index)} style={ [styles.itemStyle, itemList.length -1 === index ? {
Expand Down
5 changes: 4 additions & 1 deletion packages/api-proxy/src/platform/api/image/index.ali.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ function compressImage (options = {}) {
return ENV_OBJ.compressImage(opts)
}

const getImageInfo = ENV_OBJ.getImageInfo

export {
previewImage,
compressImage
compressImage,
getImageInfo
}
45 changes: 45 additions & 0 deletions packages/api-proxy/src/platform/api/image/index.ios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js'
import { Image } from 'react-native'

const previewImage = envError('previewImage')

const compressImage = envError('compressImage')

const getImageInfo = function (options = {}) {
const { src, success, fail, complete } = options
if (src === undefined) {
const result = {
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;',
errno: 1001
}
failHandle(result, fail, complete)
return
}
if (src === '') {
const result = {
errMsg: 'getImageInfo:fail image not found'
}
failHandle(result, fail, complete)
return
}
Image.getSize(src, (width, height) => {
const result = {
errMsg: 'getImageInfo:ok',
width,
height
}
defineUnsupportedProps(result, ['path', 'orientation', 'type'])
successHandle(result, success, complete)
}, (err) => {
const result = {
errMsg: 'getImageInfo:fail download image fail. reason: ' + err
}
failHandle(result, fail, complete)
})
}

export {
previewImage,
compressImage,
getImageInfo
}
5 changes: 4 additions & 1 deletion packages/api-proxy/src/platform/api/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const previewImage = ENV_OBJ.previewImage || envError('previewImage')

const compressImage = ENV_OBJ.compressImage || envError('compressImage')

const getImageInfo = ENV_OBJ.getImageInfo || envError('getImageInfo')

export {
previewImage,
compressImage
compressImage,
getImageInfo
}
48 changes: 46 additions & 2 deletions packages/api-proxy/src/platform/api/image/index.web.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Preview from './Preview'
import { isBrowser, throwSSRWarning, envError } from '../../../common/js'
import { isBrowser, throwSSRWarning, envError, defineUnsupportedProps, successHandle, failHandle } from '../../../common/js'

let preview = null

Expand All @@ -15,9 +15,53 @@ const previewImage = (options) => {
if (!preview) preview = new Preview()
preview.show(options)
}

const compressImage = envError('compressImage')

const getImageInfo = function (options = {}) {
const { src, success, fail, complete } = options

if (src === undefined) {
const result = {
errMsg: 'getImageInfo:fail parameter error: parameter.src should be String instead of Undefined;',
errno: 1001
}
failHandle(result, fail, complete)
return
}
if (src === '') {
const result = {
errMsg: 'getImageInfo:fail image not found'
}
failHandle(result, fail, complete)
return
}

const img = new Image()
img.src = src

img.onload = function () {
const width = img.width
const height = img.height
const result = {
errMsg: 'getImageInfo:ok',
width,
height
}
defineUnsupportedProps(result, ['path', 'orientation', 'type'])
successHandle(result, success, complete)
}

img.onerror = function () {
const result = {
errMsg: 'getImageInfo:fail download image fail. '
}
failHandle(result, fail, complete)
}
}

export {
previewImage,
compressImage
compressImage,
getImageInfo
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ function setNavigationBarColor (options = {}) {
return ENV_OBJ.setNavigationBar(options)
}

function hideHomeButton (options = {}) {
return ENV_OBJ.hideBackHome(options)
}

export {
setNavigationBarTitle,
setNavigationBarColor
setNavigationBarColor,
hideHomeButton
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { successHandle, failHandle, getFocusedNavigation } from '../../../common/js'
import { successHandle, failHandle, getFocusedNavigation, envError } from '../../../common/js'
import { nextTick } from '../next-tick'
function setNavigationBarTitle (options = {}) {
const { title = '', success, fail, complete } = options
Expand Down Expand Up @@ -31,7 +31,10 @@ function setNavigationBarColor (options = {}) {
}
}

const hideHomeButton = envError('hideHomeButton')

export {
setNavigationBarTitle,
setNavigationBarColor
setNavigationBarColor,
hideHomeButton
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const setNavigationBarTitle = ENV_OBJ.setNavigationBarTitle || envError('setNavi

const setNavigationBarColor = ENV_OBJ.setNavigationBarColor || envError('setNavigationBarColor')

const hideHomeButton = ENV_OBJ.hideHomeButton || envError('hideHomeButton')

export {
setNavigationBarTitle,
setNavigationBarColor
setNavigationBarColor,
hideHomeButton
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
import { isBrowser, envError, throwSSRWarning, successHandle } from '../../../common/js'

function setNavigationBarTitle (options = {}) {
if (!isBrowser) {
Expand Down Expand Up @@ -26,7 +26,10 @@ function setNavigationBarColor (options = {}) {
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
}

const hideHomeButton = envError('hideHomeButton')

export {
setNavigationBarTitle,
setNavigationBarColor
setNavigationBarColor,
hideHomeButton
}
19 changes: 19 additions & 0 deletions packages/api-proxy/src/platform/api/setting/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ENV_OBJ, envError } from '../../../common/js'

const getSetting = ENV_OBJ.getSetting || envError('getSetting')

const openSetting = ENV_OBJ.openSetting || envError('openSetting')

const enableAlertBeforeUnload = ENV_OBJ.enableAlertBeforeUnload || envError('enableAlertBeforeUnload')

const disableAlertBeforeUnload = ENV_OBJ.disableAlertBeforeUnload || envError('disableAlertBeforeUnload')

const getMenuButtonBoundingClientRect = ENV_OBJ.getMenuButtonBoundingClientRect || envError('getMenuButtonBoundingClientRect')

export {
getSetting,
openSetting,
enableAlertBeforeUnload,
disableAlertBeforeUnload,
getMenuButtonBoundingClientRect
}
5 changes: 4 additions & 1 deletion packages/api-proxy/src/platform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export * from './api/file'
// getUserInfo
export * from './api/get-user-info'

// previewImage, compressImage
// previewImage, compressImage, getImageInfo
export * from './api/image'

// login
Expand Down Expand Up @@ -116,3 +116,6 @@ export * from './api/vibrate'

// onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard
export * from './api/keyboard'

// getSetting, openSetting, enableAlertBeforeUnload, disableAlertBeforeUnload, getMenuButtonBoundingClientRect
export * from './api/setting'
4 changes: 2 additions & 2 deletions packages/core/src/platform/patch/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as ReactNative from 'react-native'
import { ReactiveEffect } from '../../observer/effect'
import { watch } from '../../observer/watch'
import { reactive, set, del } from '../../observer/reactive'
import { hasOwn, isFunction, noop, isObject, isArray, getByPath, collectDataset, hump2dash, wrapMethodsWithErrorHandling } from '@mpxjs/utils'
import { hasOwn, isFunction, noop, isObject, isArray, getByPath, collectDataset, hump2dash, callWithErrorHandling, wrapMethodsWithErrorHandling } from '@mpxjs/utils'
import MpxProxy from '../../core/proxy'
import { BEFOREUPDATE, ONLOAD, UPDATED, ONSHOW, ONHIDE, ONRESIZE, REACTHOOKSEXEC } from '../../core/innerLifecycle'
import mergeOptions from '../../core/mergeOptions'
Expand Down Expand Up @@ -52,7 +52,7 @@ function createEffect (proxy, components) {
proxy.effect = new ReactiveEffect(() => {
// reset instance
proxy.target.__resetInstance()
return proxy.target.__injectedRender(innerCreateElement, getComponent)
return callWithErrorHandling(proxy.target.__injectedRender.bind(proxy.target), proxy, 'render function', [innerCreateElement, getComponent])
}, () => queueJob(update), proxy.scope)
// render effect允许自触发
proxy.toggleRecurse(true)
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/errorHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function callWithErrorHandling (fn, instance, info, args) {
}

export function wrapMethodsWithErrorHandling (methods, instance) {
if (process.env.NODE_ENV === 'production') return methods
// if (process.env.NODE_ENV === 'production') return methods
const newMethods = {}
Object.keys(methods).forEach((key) => {
if (isFunction(methods[key])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { AnimationProp } from './useAnimationHooks'
import { ExtendedViewStyle } from './types/common'
import useNodesRef, { HandlerRef } from './useNodesRef'
import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject } from './utils'
import { error } from '@mpxjs/utils'
import LinearGradient from 'react-native-linear-gradient'

export interface _ViewProps extends ViewProps {
Expand Down Expand Up @@ -716,7 +717,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
enableBackground = enableBackground || !!backgroundStyle
const enableBackgroundRef = useRef(enableBackground)
if (enableBackgroundRef.current !== enableBackground) {
throw new Error('[Mpx runtime error]: background use should be stable in the component lifecycle, or you can set [enable-background] with true.')
error('[Mpx runtime error]: background use should be stable in the component lifecycle, or you can set [enable-background] with true.')
}

const nodeRef = useRef(null)
Expand Down Expand Up @@ -774,9 +775,9 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
enableAnimation = enableAnimation || !!animation
const enableAnimationRef = useRef(enableAnimation)
if (enableAnimationRef.current !== enableAnimation) {
throw new Error('[Mpx runtime error]: animation use should be stable in the component lifecycle, or you can set [enable-animation] with true.')
error('[Mpx runtime error]: animation use should be stable in the component lifecycle, or you can set [enable-animation] with true.')
}
const finalStyle = enableAnimation
const finalStyle = enableAnimationRef.current
? [viewStyle, useAnimationHooks({
animation,
style: viewStyle
Expand Down
32 changes: 30 additions & 2 deletions packages/webpack-plugin/lib/style-compiler/plugins/scope-id.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const selectorParser = require('postcss-selector-parser')
// scope-id

function isSpaceCombinator (node) {
return node.type === 'combinator' && /^\s+$/.test(node.value)
}
module.exports = ({ id }) => {
return {
postcssPlugin: 'scope-id',
Expand Down Expand Up @@ -31,10 +33,36 @@ module.exports = ({ id }) => {
n.spaces.before = n.spaces.after = ''
return false
}
if (n.type === 'pseudo' && n.value === ':deep') {
if (n.nodes.length) {
let last = n
n.nodes[0].each((ss) => {
selector.insertAfter(last, ss)
last = ss
})
const prev = n.prev()
if (!prev || !isSpaceCombinator(prev)) {
selector.insertAfter(
n,
selectorParser.combinator({
value: ' '
})
)
}
n.remove()
} else {
const prev = n.prev()
if (prev && isSpaceCombinator(prev)) {
prev.remove()
}
n.remove()
}
return false
}
// /deep/ alias for >>>, since >>> doesn't work in SASS
if (n.type === 'tag' && n.value === '/deep/') {
const prev = n.prev()
if (prev && prev.type === 'combinator' && prev.value === ' ') {
if (prev && isSpaceCombinator(prev)) {
prev.remove()
}
n.remove()
Expand Down

0 comments on commit 8395ee1

Please sign in to comment.