Skip to content

Commit

Permalink
Merge branch 'fix-drn' of https://github.com/didi/mpx into fix-drn
Browse files Browse the repository at this point in the history
  • Loading branch information
wangcuijuan committed Jan 21, 2025
2 parents e08ea03 + 3baaaa5 commit 302ba85
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 264 deletions.
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.9.69"
}
"version": "2.9.69-beta.4"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "mpx monorepo",
"private": true,
"scripts": {
"lerna:publish": "lerna publish from-package --yes",
"lerna:publish": "lerna publish from-package --yes --dist-tag beta",
"lint": "eslint --ext .js,.ts,.tsx packages/",
"fix": "eslint --fix --ext .js,.ts,.tsx packages/",
"lint:js": "eslint --ext .js packages/",
Expand Down
2 changes: 1 addition & 1 deletion 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.9.69-beta.2",
"version": "2.9.69-beta.5",
"description": "convert miniprogram API at each end",
"module": "src/index.js",
"types": "@types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/core",
"version": "2.9.69-beta.3",
"version": "2.9.69-beta.5",
"description": "mpx runtime core",
"keywords": [
"miniprogram",
Expand Down
28 changes: 19 additions & 9 deletions packages/core/src/platform/env/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isFunction, isNumber, isString } from '@mpxjs/utils'
import { createI18n } from '../builtInMixins/i18nMixin'

export function init (Mpx) {
Expand Down Expand Up @@ -30,21 +31,30 @@ function initGlobalErrorHandling () {
})
}

function onUnhandledRejection (event) {
if (global.__mpxAppCbs && global.__mpxAppCbs.rejection && global.__mpxAppCbs.rejection.length) {
global.__mpxAppCbs.rejection.forEach((cb) => {
cb(event)
})
} else {
console.warn(`UNHANDLED PROMISE REJECTION ${(isNumber(event.id) || isString(event.id)) ? '(id:' + event.id + ')' : ''}: ${event.reason}\n`)
}
}
const rejectionTrackingOptions = {
allRejections: true,
onUnhandled (id, error) {
if (global.__mpxAppCbs && global.__mpxAppCbs.rejection && global.__mpxAppCbs.rejection.length) {
global.__mpxAppCbs.rejection.forEach((cb) => {
cb(error, id)
})
} else {
console.warn(`UNHANDLED PROMISE REJECTION (id: ${id}): ${error}\n`)
}
onUnhandledRejection({ id, reason: error, promise: null })
}
}

if (global?.HermesInternal?.hasPromise?.()) {
global.HermesInternal?.enablePromiseRejectionTracker?.(rejectionTrackingOptions)
// 支持 core-js promise polyfill
const oldOnUnhandledRejection = global.onunhandledrejection
global.onunhandledrejection = function onunhandledrejection (event) {
onUnhandledRejection(event)
isFunction(oldOnUnhandledRejection) && oldOnUnhandledRejection.call(this, event)
}
if (global.HermesInternal?.hasPromise?.()) {
global.HermesInternal.enablePromiseRejectionTracker?.(rejectionTrackingOptions)
} else {
require('promise/setimmediate/rejection-tracking').enable(rejectionTrackingOptions)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/platform/env/index.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function initGlobalErrorHandling () {
window.addEventListener('unhandledrejection', (event) => {
if (global.__mpxAppCbs && global.__mpxAppCbs.rejection && global.__mpxAppCbs.rejection.length) {
global.__mpxAppCbs.rejection.forEach((cb) => {
cb(event.reason, event.promise)
cb(event)
})
} else {
console.warn(`UNHANDLED PROMISE REJECTION: ${event.reason}\n`)
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/platform/patch/getDefaultOptions.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,14 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
if (!global.__mpxAppHotLaunched && global.__mpxAppOnLaunch) {
global.__mpxAppOnLaunch(props.navigation)
}
const loadParams = {}
// 此处拿到的props.route.params内属性的value被进行过了一次decode, 不符合预期,此处额外进行一次encode来与微信对齐
if (isObject(props.route.params)) {
for (let key in props.route.params) {
props.route.params[key] = encodeURIComponent(props.route.params[key])
for (const key in props.route.params) {
loadParams[key] = encodeURIComponent(props.route.params[key])
}
}
proxy.callHook(ONLOAD, [props.route.params || {}])
proxy.callHook(ONLOAD, [loadParams])
}
proxy.mounted()
return () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/utils",
"version": "2.9.69-beta.2",
"version": "2.9.69-beta.5",
"description": "A toolkit for mpx framework",
"main": "src/index.js",
"scripts": {
Expand Down
Loading

0 comments on commit 302ba85

Please sign in to comment.