@mpxjs/api-proxy 2.9.67 → 2.9.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/platform/api/next-tick/index.ios.js +7 -1
- package/src/platform/api/route/index.ios.js +18 -8
- package/src/platform/api/system/index.ali.js +7 -1
- package/src/platform/api/system/index.js +7 -1
- package/src/platform/api/system/index.web.js +77 -16
- package/src/platform/api/system/rnSystem.js +18 -1
- package/src/platform/index.js +0 -3
- package/src/platform/api/lifecycle/index.ali.js +0 -9
- package/src/platform/api/lifecycle/index.js +0 -7
- package/src/platform/api/lifecycle/index.web.js +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.69",
|
|
4
4
|
"description": "convert miniprogram API at each end",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"types": "@types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/didi/mpx#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@mpxjs/utils": "^2.9.
|
|
40
|
+
"@mpxjs/utils": "^2.9.69",
|
|
41
41
|
"axios": "^1.7.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"optional": true
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "e23c51acc4c2ffdd31fcc6c27aae1aed42d1ade2"
|
|
76
76
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { successHandle, failHandle } from '../../../common/js'
|
|
2
2
|
import { parseUrlQuery as parseUrl } from '@mpxjs/utils'
|
|
3
|
+
import { nextTick } from '../next-tick'
|
|
3
4
|
|
|
4
5
|
function getBasePath (navigation) {
|
|
5
6
|
if (navigation) {
|
|
@@ -75,14 +76,23 @@ function navigateBack (options = {}) {
|
|
|
75
76
|
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
76
77
|
const navigationHelper = global.__navigationHelper
|
|
77
78
|
if (navigation && navigationHelper) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
const delta = options.delta || 1
|
|
80
|
+
const routeLength = navigation.getState().routes.length
|
|
81
|
+
if (delta >= routeLength && global.__mpx?.config.rnConfig.onAppBack?.(delta - routeLength + 1)) {
|
|
82
|
+
nextTick(() => {
|
|
83
|
+
const res = { errMsg: 'navigateBack:ok' }
|
|
84
|
+
successHandle(res, options.success, options.complete)
|
|
85
|
+
})
|
|
86
|
+
} else {
|
|
87
|
+
navigation.pop(delta)
|
|
88
|
+
navigationHelper.lastSuccessCallback = () => {
|
|
89
|
+
const res = { errMsg: 'navigateBack:ok' }
|
|
90
|
+
successHandle(res, options.success, options.complete)
|
|
91
|
+
}
|
|
92
|
+
navigationHelper.lastFailCallback = (msg) => {
|
|
93
|
+
const res = { errMsg: `navigateBack:fail ${msg}` }
|
|
94
|
+
failHandle(res, options.fail, options.complete)
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
}
|
|
88
98
|
}
|
|
@@ -40,9 +40,15 @@ const getDeviceInfo = function () {
|
|
|
40
40
|
|
|
41
41
|
const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
42
42
|
|
|
43
|
+
const getLaunchOptionsSync = ENV_OBJ.getLaunchOptionsSync || envError('getLaunchOptionsSync')
|
|
44
|
+
|
|
45
|
+
const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
|
|
46
|
+
|
|
43
47
|
export {
|
|
44
48
|
getSystemInfo,
|
|
45
49
|
getSystemInfoSync,
|
|
46
50
|
getDeviceInfo,
|
|
47
|
-
getWindowInfo
|
|
51
|
+
getWindowInfo,
|
|
52
|
+
getLaunchOptionsSync,
|
|
53
|
+
getEnterOptionsSync
|
|
48
54
|
}
|
|
@@ -8,9 +8,15 @@ const getDeviceInfo = ENV_OBJ.getDeviceInfo || envError('getDeviceInfo')
|
|
|
8
8
|
|
|
9
9
|
const getWindowInfo = ENV_OBJ.getWindowInfo || envError('getWindowInfo')
|
|
10
10
|
|
|
11
|
+
const getLaunchOptionsSync = ENV_OBJ.getLaunchOptionsSync || envError('getLaunchOptionsSync')
|
|
12
|
+
|
|
13
|
+
const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
|
|
14
|
+
|
|
11
15
|
export {
|
|
12
16
|
getSystemInfo,
|
|
13
17
|
getSystemInfoSync,
|
|
14
18
|
getDeviceInfo,
|
|
15
|
-
getWindowInfo
|
|
19
|
+
getWindowInfo,
|
|
20
|
+
getLaunchOptionsSync,
|
|
21
|
+
getEnterOptionsSync
|
|
16
22
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isBrowser, throwSSRWarning, successHandle } from '../../../common/js'
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
if (!isBrowser) {
|
|
5
|
-
throwSSRWarning('getSystemInfoSync API is running in non browser environments')
|
|
6
|
-
return
|
|
7
|
-
}
|
|
3
|
+
const getDeviceInfo = function () {
|
|
8
4
|
const ua = navigator.userAgent.split('(')[1]?.split(')')[0] || ''
|
|
9
5
|
const phones = new Map([
|
|
10
6
|
['iPhone', /iPhone|iPad|iPod|iOS/i],
|
|
@@ -37,20 +33,57 @@ function getSystemInfoSync () {
|
|
|
37
33
|
} else {
|
|
38
34
|
system = `Android ${ua.replace(/^.*Android ([\d.]+);.*$/, '$1')}`
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
return {
|
|
42
|
-
|
|
37
|
+
abi: null,
|
|
38
|
+
deviceAbi: null,
|
|
39
|
+
benchmarkLevel: null,
|
|
40
|
+
brand,
|
|
43
41
|
model: brand,
|
|
42
|
+
system,
|
|
43
|
+
platform: navigator.platform,
|
|
44
|
+
cpuType: null,
|
|
45
|
+
memorySize: null
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const getWindowInfo = function () {
|
|
50
|
+
return {
|
|
44
51
|
pixelRatio: window.devicePixelRatio,
|
|
45
52
|
screenWidth: window.screen.width,
|
|
46
53
|
screenHeight: window.screen.height,
|
|
47
54
|
windowWidth: document.documentElement.clientWidth,
|
|
48
55
|
windowHeight: document.documentElement.clientHeight,
|
|
49
56
|
statusBarHeight: null,
|
|
57
|
+
safeArea: null,
|
|
58
|
+
screenTop: null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getSystemInfoSync () {
|
|
63
|
+
if (!isBrowser) {
|
|
64
|
+
throwSSRWarning('getSystemInfoSync API is running in non browser environments')
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
pixelRatio,
|
|
70
|
+
screenWidth,
|
|
71
|
+
screenHeight,
|
|
72
|
+
windowWidth,
|
|
73
|
+
windowHeight,
|
|
74
|
+
statusBarHeight,
|
|
75
|
+
safeArea
|
|
76
|
+
} = getWindowInfo()
|
|
77
|
+
const {
|
|
78
|
+
benchmarkLevel,
|
|
79
|
+
brand,
|
|
80
|
+
model,
|
|
81
|
+
system,
|
|
82
|
+
platform
|
|
83
|
+
} = getDeviceInfo()
|
|
84
|
+
const result = Object.assign({
|
|
50
85
|
language: navigator.language,
|
|
51
86
|
version: null,
|
|
52
|
-
system,
|
|
53
|
-
platform: navigator.platform,
|
|
54
87
|
fontSizeSetting: null,
|
|
55
88
|
SDKVersion: null,
|
|
56
89
|
benchmarkLevel: null,
|
|
@@ -64,9 +97,23 @@ function getSystemInfoSync () {
|
|
|
64
97
|
notificationSoundAuthorized: null,
|
|
65
98
|
bluetoothEnabled: null,
|
|
66
99
|
locationEnabled: null,
|
|
67
|
-
wifiEnabled: null
|
|
68
|
-
|
|
69
|
-
|
|
100
|
+
wifiEnabled: null
|
|
101
|
+
}, {
|
|
102
|
+
pixelRatio,
|
|
103
|
+
screenWidth,
|
|
104
|
+
screenHeight,
|
|
105
|
+
windowWidth,
|
|
106
|
+
windowHeight,
|
|
107
|
+
statusBarHeight,
|
|
108
|
+
safeArea
|
|
109
|
+
}, {
|
|
110
|
+
benchmarkLevel,
|
|
111
|
+
brand,
|
|
112
|
+
model,
|
|
113
|
+
system,
|
|
114
|
+
platform
|
|
115
|
+
})
|
|
116
|
+
return result
|
|
70
117
|
}
|
|
71
118
|
|
|
72
119
|
function getSystemInfo (options = {}) {
|
|
@@ -79,13 +126,27 @@ function getSystemInfo (options = {}) {
|
|
|
79
126
|
successHandle(res, options.success, options.complete)
|
|
80
127
|
}
|
|
81
128
|
|
|
82
|
-
const
|
|
129
|
+
const getEnterOptionsSync = function () {
|
|
130
|
+
if (!isBrowser) {
|
|
131
|
+
throwSSRWarning('getEnterOptionsSync API is running in non browser environments')
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
return global.__mpxEnterOptions || {}
|
|
135
|
+
}
|
|
83
136
|
|
|
84
|
-
const
|
|
137
|
+
const getLaunchOptionsSync = function () {
|
|
138
|
+
if (!isBrowser) {
|
|
139
|
+
throwSSRWarning('getLaunchOptionsSync API is running in non browser environments')
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
return global.__mpxEnterOptions || {}
|
|
143
|
+
}
|
|
85
144
|
|
|
86
145
|
export {
|
|
87
146
|
getSystemInfo,
|
|
88
147
|
getSystemInfoSync,
|
|
89
148
|
getDeviceInfo,
|
|
90
|
-
getWindowInfo
|
|
149
|
+
getWindowInfo,
|
|
150
|
+
getLaunchOptionsSync,
|
|
151
|
+
getEnterOptionsSync
|
|
91
152
|
}
|
|
@@ -75,9 +75,26 @@ const getDeviceInfo = function () {
|
|
|
75
75
|
return deviceInfo
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
const getLaunchOptionsSync = function () {
|
|
79
|
+
const options = global.__mpxEnterOptions || {}
|
|
80
|
+
const { path, scene, query } = options
|
|
81
|
+
return {
|
|
82
|
+
path,
|
|
83
|
+
scene,
|
|
84
|
+
query
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const getEnterOptionsSync = function () {
|
|
89
|
+
const result = getLaunchOptionsSync()
|
|
90
|
+
return result
|
|
91
|
+
}
|
|
92
|
+
|
|
78
93
|
export {
|
|
79
94
|
getSystemInfo,
|
|
80
95
|
getSystemInfoSync,
|
|
81
96
|
getDeviceInfo,
|
|
82
|
-
getWindowInfo
|
|
97
|
+
getWindowInfo,
|
|
98
|
+
getLaunchOptionsSync,
|
|
99
|
+
getEnterOptionsSync
|
|
83
100
|
}
|
package/src/platform/index.js
CHANGED
|
@@ -105,9 +105,6 @@ export * from './api/video'
|
|
|
105
105
|
// onWindowResize, offWindowResize
|
|
106
106
|
export * from './api/window'
|
|
107
107
|
|
|
108
|
-
// getEnterOptionsSync
|
|
109
|
-
export * from './api/lifecycle'
|
|
110
|
-
|
|
111
108
|
// getLocation, openLocation, chooseLocation
|
|
112
109
|
export * from './api/location'
|
|
113
110
|
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isBrowser, throwSSRWarning } from '../../../common/js'
|
|
2
|
-
function getEnterOptionsSync () {
|
|
3
|
-
if (!isBrowser) {
|
|
4
|
-
throwSSRWarning('getEnterOptionsSync API is running in non browser environments')
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
return global.__mpxEnterOptions || {}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
getEnterOptionsSync
|
|
12
|
-
}
|