Skip to content

Commit

Permalink
Merge branch 'master' into feat-react-createSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderXL committed Aug 23, 2024
2 parents df36325 + 4c12cc7 commit cfce115
Show file tree
Hide file tree
Showing 94 changed files with 1,373 additions and 337 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- run: |
npm i
echo "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" >> $HOME/.npmrc 2> /dev/null
npm run tsc:build
npm run lerna:publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ yarn.lock
.DS_Store
docs-vuepress/.vuepress/dist
elevate/
packages/webpack-plugin/lib/runtime/components/react/dist/
9 changes: 2 additions & 7 deletions examples/mpx-webview/H5/webviewbridge.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.9.55"
"version": "2.9.57"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test": "jest",
"release": "npm run lint && npm run test && npx lerna version",
"docs:dev": "vuepress dev docs-vuepress",
"docs:build": "vuepress build docs-vuepress"
"docs:build": "vuepress build docs-vuepress",
"tsc:build": "npm --workspace=./packages/webpack-plugin run build"
},
"devDependencies": {
"@babel/core": "^7.8.7",
Expand Down
14 changes: 7 additions & 7 deletions packages/api-proxy/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

type AddPromise<W> = {
[K in keyof W]: W[K] extends (...args: any) => any
? Parameters<W[K]> extends [{ success?: (res: infer R) => any }?, ...any[]]
? (...args: Parameters<W[K]>) => ReturnType<W[K]> & Promise<R>
? Parameters<W[K]> extends [{ success?: (res: infer R) => any }?, ...any[]]
? (...args: Parameters<W[K]>) => ReturnType<W[K]> & Promise<R>
: W[K]
: W[K]
: W[K]
}

type AddParam<O, V extends (...args: any) => any> =
Parameters<V> extends [{ success?: (res: infer R) => any }, ...any[]]
? (options: O) => ReturnType<V> & Promise<R>
: (options: O) => ReturnType<V>
Parameters<V> extends [{ success?: (res: infer R) => any }, ...any[]]
? (options: O) => ReturnType<V> & Promise<R>
: (options: O) => ReturnType<V>
// @ts-ignore
type PickApiValue<T extends keyof WechatMiniprogram.Wx> = Pick<WechatMiniprogram.Wx, T>[T]
// @ts-ignore
Expand All @@ -33,7 +33,7 @@ declare module '@mpxjs/core' {

export const getProxy: (...args: any) => void

export const promisify: (listObj: object, whiteList: string[], customBlackList: string[]) => object
export const promisify: (listObj: object, whiteList?: string[], customBlackList?: string[]) => Record<string, any>

export const showActionSheet: WechatMiniprogram.Wx['showActionSheet']
export const addPhoneContact: WechatMiniprogram.Wx['addPhoneContact']
Expand Down
18 changes: 17 additions & 1 deletion packages/api-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
"@react-native-clipboard/clipboard": "^1.14.0",
"@react-native-community/netinfo": "^11.2.1",
"react-native-device-info": "^10.13.2",
"react-native-safe-area-context": "^4.10.1"
"react-native-safe-area-context": "^4.10.1",
"react-native-get-location": "^4.0.1",
"@ant-design/react-native": "^5.1.3",
"expo-brightness": "~11.8.0",
"react-native-webview": "^13.10.5"
},
"peerDependenciesMeta": {
"@react-native-async-storage/async-storage": {
Expand All @@ -62,6 +66,18 @@
},
"react-native-safe-area-context": {
"optional": true
},
"react-native-get-location": {
"optional": true
},
"@ant-design/react-native": {
"optional": true
},
"expo-brightness": {
"optional": true
},
"react-native-webview": {
"optional": true
}
}
}
4 changes: 3 additions & 1 deletion packages/api-proxy/src/common/js/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const blackList = [
'createOffscreenCanvas',
'reportEvent',
'connectSocket',
'base64ToArrayBuffer'
'base64ToArrayBuffer',
'getDeviceInfo',
'getWindowInfo'
]

function getMapFromList (list) {
Expand Down
14 changes: 13 additions & 1 deletion packages/api-proxy/src/common/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ function throwSSRWarning (info) {
console.error(`[Mpx runtime error]: Dangerous API! ${info}, It may cause some problems, please use this method with caution`)
}

function successHandle (result, success, complete) {
typeof success === 'function' && success(result)
typeof complete === 'function' && complete(result)
}

function failHandle (result, fail, complete) {
typeof fail === 'function' && fail(result)
typeof complete === 'function' && complete(result)
}

const ENV_OBJ = getEnvObj()

export {
Expand All @@ -88,5 +98,7 @@ export {
isBrowser,
throwSSRWarning,
ENV_OBJ,
defineUnsupportedProps
defineUnsupportedProps,
successHandle,
failHandle
}
12 changes: 0 additions & 12 deletions packages/api-proxy/src/common/js/web.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
function webHandleSuccess (result, success, complete) {
typeof success === 'function' && success(result)
typeof complete === 'function' && complete(result)
}

function webHandleFail (result, fail, complete) {
typeof fail === 'function' && fail(result)
typeof complete === 'function' && complete(result)
}

function isTabBarPage (url, router) {
const tabBarPagesMap = global.__tabBarPagesMap
if (!tabBarPagesMap || !url) return false
Expand Down Expand Up @@ -49,8 +39,6 @@ function getRootElement () {
}

export {
webHandleSuccess,
webHandleFail,
createDom,
bindTap,
getRootElement,
Expand Down
10 changes: 3 additions & 7 deletions packages/api-proxy/src/platform/api/action-sheet/ActionSheet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { webHandleSuccess, webHandleFail, createDom, bindTap, getRootElement } from '../../../common/js'
import { successHandle, failHandle, createDom, bindTap, getRootElement } from '../../../common/js'
import '../../../common/stylus/ActionSheet.styl'

export default class ActionSheet {
Expand Down Expand Up @@ -44,8 +44,7 @@ export default class ActionSheet {
errMsg: 'showActionSheet:ok',
tapIndex: index
}
webHandleSuccess(res, opts.success, opts.complete)
// this.toPromiseResolve(res)
successHandle(res, opts.success, opts.complete)
}))
list.appendChild(sheet)
})
Expand All @@ -57,17 +56,14 @@ export default class ActionSheet {
this.tempListeners.push(bindTap(this.cancelBtn, () => {
this.hide()
const err = { errMsg: 'showActionSheet:fail cancel' }
webHandleFail(err, opts.fail, opts.complete)
// !opts.fail && this.toPromiseReject(err)
failHandle(err, opts.fail, opts.complete)
}))
// make transition next frame
this.actionSheet.classList.add('show')
// 如果使用 requestAnimationFrame,第一次展示不会有动画效果,原因待确认,这里先使用 setTimeout
setTimeout(() => {
this.box.classList.add('show')
}, 17)

// return this.toPromiseInitPromise()
}

hide () {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './rnActionSheet'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './rnActionSheet'
Loading

0 comments on commit cfce115

Please sign in to comment.