Skip to content

Commit

Permalink
Merge branch 'master' into feat-refreshcontrol-slot
Browse files Browse the repository at this point in the history
  • Loading branch information
lareinayanyu committed Mar 11, 2025
2 parents 4152958 + 7e4f9ab commit f766152
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/checkout@v4
# - run: npm run lint
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: |
npm i
echo "//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}" >> $HOME/.npmrc 2> /dev/null
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ jobs:
tsc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: npm i && npm run tsc:build

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: npm i && npm run lint

unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Cache node modules
id: cache
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
12 changes: 12 additions & 0 deletions docs-vitepress/guide/platform/rn.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# 跨端输出RN

## 快速使用 RN

``` bash
# ios
npx mpx-cli-service build --targets=ios
# android
npx mpx-cli-service build --targets=android
# harmony
npx mpx-cli-service build --targets=harmony
```
> 构建其他平台参考 [快速开始](../basic/start.html)
## 跨端样式定义
RN 样式属性和 Web/小程序中 CSS 样式属性是相交关系,RN 有一小部分样式属性(比如 tintColor、writingDirection 等等) CSS 不支持,CSS 也有少部分样式属性 RN 不支持(比如 clip-path、animation、transition 等等)。

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.10.0"
"version": "2.10.1"
}
14 changes: 7 additions & 7 deletions packages/api-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/api-proxy",
"version": "2.10.0",
"version": "2.10.1",
"description": "convert miniprogram API at each end",
"module": "src/index.js",
"types": "@types/index.d.ts",
Expand Down Expand Up @@ -41,12 +41,12 @@
"axios": "^1.7.3"
},
"peerDependencies": {
"@react-native-async-storage/async-storage": "^1.23.1",
"@react-native-community/netinfo": "^11.2.1",
"react-native-device-info": "^10.13.2",
"react-native-get-location": "^4.0.1",
"react-native-haptic-feedback": "^2.3.3",
"react-native-safe-area-context": "^4.10.1"
"@react-native-async-storage/async-storage": "*",
"@react-native-community/netinfo": "*",
"react-native-device-info": "*",
"react-native-get-location": "*",
"react-native-haptic-feedback": "*",
"react-native-safe-area-context": "*"
},
"peerDependenciesMeta": {
"@react-native-async-storage/async-storage": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-proxy/src/platform/api/next-tick/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function nextTick (cb) {
channel.port1.onmessage = cb
port.postMessage(1)
} else {
setTimeout(cb, 0)
setTimeout(cb)
}
}

Expand Down
22 changes: 11 additions & 11 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/core",
"version": "2.10.0",
"version": "2.10.1",
"description": "mpx runtime core",
"keywords": [
"miniprogram",
Expand All @@ -24,20 +24,20 @@
"miniprogram-api-typings": "^3.10.0"
},
"peerDependencies": {
"@d11/react-native-fast-image": "^8.6.12",
"@d11/react-native-fast-image": "*",
"@mpxjs/api-proxy": "^2.9.0",
"@mpxjs/store": "^2.9.0",
"@react-navigation/native": "^7.0.14",
"@react-navigation/native-stack": "^7.2.0",
"@react-navigation/native": "*",
"@react-navigation/native-stack": "*",
"react": "*",
"react-native": "*",
"react-native-gesture-handler": "^2.19.0",
"react-native-linear-gradient": "^2.8.3",
"react-native-reanimated": "^3.15.2",
"react-native-safe-area-context": "^4.14.0",
"react-native-screens": "^4.1.0",
"react-native-video": "^6.9.0",
"react-native-webview": "^13.10.5",
"react-native-gesture-handler": "*",
"react-native-linear-gradient": "*",
"react-native-reanimated": "*",
"react-native-safe-area-context": "*",
"react-native-screens": "*",
"react-native-video": "*",
"react-native-webview": "*",
"vue": "^2.7.10",
"vue-demi": "^0.14.6",
"vue-i18n": "^8.27.2",
Expand Down
10 changes: 9 additions & 1 deletion packages/core/src/observer/scheduler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { warn, isArray, callWithErrorHandling, isDev } from '@mpxjs/utils'
import { warn, isArray, callWithErrorHandling, isDev, isReact } from '@mpxjs/utils'
import Mpx from '../index'

let isFlushing = false
Expand Down Expand Up @@ -47,6 +47,14 @@ function findInsertionIndex (id) {
}

export function nextTick (fn) {
if (isReact) {
const p = new Promise((resolve) => {
setTimeout(() => {
resolve(fn && fn.call(this))
})
})
return p
}
const p = currentFlushPromise || resolvedPromise
return fn ? p.then(this ? fn.bind(this) : fn) : p
}
Expand Down
4 changes: 2 additions & 2 deletions packages/fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/fetch",
"version": "2.10.0",
"version": "2.10.1",
"description": "mpx fetch lib",
"author": "donghongping",
"license": "Apache-2.0",
Expand Down Expand Up @@ -29,7 +29,7 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@mpxjs/api-proxy": "^2.10.0",
"@mpxjs/api-proxy": "^2.10.1",
"@mpxjs/utils": "^2.10.0",
"path-to-regexp": "^6.2.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ interface EventConfig {
[key: string]: string[];
}

export const TAP_EVENTS = ['bindtap', 'catchtap', 'capture-bindtap', 'capture-catchtap']

const eventConfigMap: { [key: string]: { bitFlag: string; events: string[] } } = {
bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRef, useMemo, RefObject } from 'react'
import { hasOwn, collectDataset } from '@mpxjs/utils'
import { omit, extendObject, useNavigation } from './utils'
import eventConfigMap from './event.config'
import eventConfigMap, { TAP_EVENTS } from './event.config'
import {
Props,
AdditionalProps,
Expand Down Expand Up @@ -197,12 +197,16 @@ function handleTouchmove (e: NativeTouchEvent, type: 'bubble' | 'capture', ref:
const currentTouchEvent =
type === 'bubble' ? bubbleTouchEvent : captureTouchEvent
handleEmitEvent(currentTouchEvent, 'touchmove', e, propsRef, config, navigation)
checkIsNeedPress(e, type, ref)
if (TAP_EVENTS.some(eventName => propsRef.current[eventName])) {
checkIsNeedPress(e, type, ref)
}
}

function handleTouchend (e: NativeTouchEvent, type: 'bubble' | 'capture', ref: RefObject<InnerRef>, propsRef: Record<string, any>, config: UseInnerPropsConfig, navigation: Navigation) {
// move event may not be triggered
checkIsNeedPress(e, type, ref)
if (TAP_EVENTS.some(eventName => propsRef.current[eventName])) {
checkIsNeedPress(e, type, ref)
}
const bubbleTouchEvent = ['catchtouchend', 'bindtouchend']
const bubbleTapEvent = ['catchtap', 'bindtap']
const captureTouchEvent = [
Expand Down
6 changes: 5 additions & 1 deletion packages/webpack-plugin/lib/template-compiler/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1832,9 +1832,13 @@ function processRefReact (el, meta) {
selectors.push({ prefix: '', selector: `"${refConf.key}"` })
}
const selectorsConf = selectors.map(item => `["${item.prefix}", ${item.selector}]`)
const refFnId = forScopes.reduce((preV, curV) => {
return `${preV} + "_" + ${curV.index}`
}, `"ref_fn_${++refId}"`)

addAttrs(el, [{
name: 'ref',
value: `{{ this.__getRefVal('${type}', [${selectorsConf}], 'ref_fn_${++refId}') }}`
value: `{{ this.__getRefVal('${type}', [${selectorsConf}], ${refFnId}) }}`
}])
}

Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/webpack-plugin",
"version": "2.10.0",
"version": "2.10.1",
"description": "mpx compile core",
"keywords": [
"mpx"
Expand Down Expand Up @@ -84,7 +84,7 @@
"devDependencies": {
"@ant-design/react-native": "^5.2.2",
"@d11/react-native-fast-image": "^8.6.12",
"@mpxjs/api-proxy": "^2.10.0",
"@mpxjs/api-proxy": "^2.10.1",
"@types/babel-traverse": "^6.25.4",
"@types/babel-types": "^7.0.4",
"@types/react": "^18.2.79",
Expand Down

0 comments on commit f766152

Please sign in to comment.