@mpxjs/api-proxy 2.10.3-beta.2 → 2.10.3-beta.4
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/@types/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/common/js/promisify.js +2 -1
- package/src/platform/api/route/index.ios.js +45 -2
- package/src/platform/api/route/index.js +7 -1
- package/src/platform/api/route/index.web.js +8 -2
- package/src/platform/api/screen-brightness/index.ali.js +11 -2
- package/src/platform/api/screen-brightness/index.js +10 -1
- package/src/platform/api/screen-brightness/rnScreenBrightness.js +11 -2
package/@types/index.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ export const switchTab: WechatMiniprogram.Wx['switchTab']
|
|
|
83
83
|
export const scanCode: WechatMiniprogram.Wx['scanCode']
|
|
84
84
|
export const setScreenBrightness: WechatMiniprogram.Wx['setScreenBrightness']
|
|
85
85
|
export const getScreenBrightness: WechatMiniprogram.Wx['getScreenBrightness']
|
|
86
|
+
export const setVisualEffectOnCapture: WechatMiniprogram.Wx['setVisualEffectOnCapture']
|
|
87
|
+
export const onUserCaptureScreen: WechatMiniprogram.Wx['onUserCaptureScreen']
|
|
88
|
+
export const offUserCaptureScreen: WechatMiniprogram.Wx['offUserCaptureScreen']
|
|
86
89
|
export const setNavigationBarTitle: WechatMiniprogram.Wx['setNavigationBarTitle']
|
|
87
90
|
export const setNavigationBarColor: WechatMiniprogram.Wx['setNavigationBarColor']
|
|
88
91
|
export const connectSocket: WechatMiniprogram.Wx['connectSocket']
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ function resolvePath (relative, base) {
|
|
|
34
34
|
return stack.join('/')
|
|
35
35
|
}
|
|
36
36
|
let timerId = null
|
|
37
|
-
function isLock (navigationHelper, type, options) {
|
|
37
|
+
function isLock (navigationHelper = {}, type, options) {
|
|
38
38
|
if (navigationHelper.lastSuccessCallback && navigationHelper.lastFailCallback) {
|
|
39
39
|
const res = { errMsg: `${type}:fail the previous routing event didn't complete` }
|
|
40
40
|
failHandle(res, options.fail, options.complete)
|
|
@@ -156,10 +156,53 @@ function switchTab () {
|
|
|
156
156
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
function reset (options = {}) {
|
|
160
|
+
const routes = options.routes || []
|
|
161
|
+
if (!routes.length) {
|
|
162
|
+
const res = { errMsg: 'reset:fail routes cannot be an empty array' }
|
|
163
|
+
failHandle(res, options.fail, options.complete)
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
const resetOption = Object.keys(options).reduce((resOpt, key) => {
|
|
167
|
+
if (key !== 'fail' && key !== 'complete' && key !== 'success') {
|
|
168
|
+
resOpt[key] = options[key]
|
|
169
|
+
}
|
|
170
|
+
return resOpt
|
|
171
|
+
}, {})
|
|
172
|
+
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
173
|
+
const navigationHelper = global.__navigationHelper
|
|
174
|
+
if (isLock(navigationHelper, 'reset', options)) {
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
if (navigation && navigationHelper) {
|
|
178
|
+
navigation.reset(Object.assign(resetOption, {
|
|
179
|
+
index: routes.length - 1
|
|
180
|
+
}))
|
|
181
|
+
navigationHelper.lastSuccessCallback = () => {
|
|
182
|
+
const res = { errMsg: 'reset:ok' }
|
|
183
|
+
successHandle(res, options.success, options.complete)
|
|
184
|
+
}
|
|
185
|
+
navigationHelper.lastFailCallback = (msg) => {
|
|
186
|
+
const res = { errMsg: `reset:fail ${msg}` }
|
|
187
|
+
failHandle(res, options.fail, options.complete)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getState () {
|
|
193
|
+
const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
|
|
194
|
+
if (navigation) {
|
|
195
|
+
return navigation.getState()
|
|
196
|
+
}
|
|
197
|
+
return {}
|
|
198
|
+
}
|
|
199
|
+
|
|
159
200
|
export {
|
|
160
201
|
redirectTo,
|
|
161
202
|
navigateTo,
|
|
162
203
|
navigateBack,
|
|
163
204
|
reLaunch,
|
|
164
|
-
switchTab
|
|
205
|
+
switchTab,
|
|
206
|
+
reset,
|
|
207
|
+
getState
|
|
165
208
|
}
|
|
@@ -10,10 +10,16 @@ const reLaunch = ENV_OBJ.reLaunch || envError('reLaunch')
|
|
|
10
10
|
|
|
11
11
|
const switchTab = ENV_OBJ.switchTab || envError('switchTab')
|
|
12
12
|
|
|
13
|
+
const reset = envError('reset')
|
|
14
|
+
|
|
15
|
+
const getState = envError('getState')
|
|
16
|
+
|
|
13
17
|
export {
|
|
14
18
|
redirectTo,
|
|
15
19
|
navigateTo,
|
|
16
20
|
navigateBack,
|
|
17
21
|
reLaunch,
|
|
18
|
-
switchTab
|
|
22
|
+
switchTab,
|
|
23
|
+
reset,
|
|
24
|
+
getState
|
|
19
25
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { successHandle, failHandle, isTabBarPage, throwSSRWarning, isBrowser } from '../../../common/js'
|
|
1
|
+
import { successHandle, failHandle, isTabBarPage, throwSSRWarning, isBrowser, envError } from '../../../common/js'
|
|
2
2
|
import { EventChannel } from '../event-channel'
|
|
3
3
|
|
|
4
4
|
let routeCount = 0
|
|
@@ -183,10 +183,16 @@ function switchTab (options = {}) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
const reset = envError('reset')
|
|
187
|
+
|
|
188
|
+
const getState = envError('getState')
|
|
189
|
+
|
|
186
190
|
export {
|
|
187
191
|
redirectTo,
|
|
188
192
|
navigateTo,
|
|
189
193
|
navigateBack,
|
|
190
194
|
reLaunch,
|
|
191
|
-
switchTab
|
|
195
|
+
switchTab,
|
|
196
|
+
reset,
|
|
197
|
+
getState
|
|
192
198
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ENV_OBJ, changeOpts, handleSuccess } from '../../../common/js'
|
|
1
|
+
import { ENV_OBJ, changeOpts, handleSuccess, envError } from '../../../common/js'
|
|
2
2
|
|
|
3
3
|
function setScreenBrightness (options = {}) {
|
|
4
4
|
const opts = changeOpts(options, {
|
|
@@ -20,7 +20,16 @@ function getScreenBrightness (options = {}) {
|
|
|
20
20
|
return ENV_OBJ.getScreenBrightness(opts)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const setVisualEffectOnCapture = ENV_OBJ.setVisualEffectOnCapture || envError('setVisualEffectOnCapture')
|
|
24
|
+
|
|
25
|
+
const onUserCaptureScreen = ENV_OBJ.onUserCaptureScreen || envError('onUserCaptureScreen')
|
|
26
|
+
|
|
27
|
+
const offUserCaptureScreen = ENV_OBJ.offUserCaptureScreen || envError('offUserCaptureScreen')
|
|
28
|
+
|
|
23
29
|
export {
|
|
24
30
|
setScreenBrightness,
|
|
25
|
-
getScreenBrightness
|
|
31
|
+
getScreenBrightness,
|
|
32
|
+
setVisualEffectOnCapture,
|
|
33
|
+
onUserCaptureScreen,
|
|
34
|
+
offUserCaptureScreen
|
|
26
35
|
}
|
|
@@ -4,7 +4,16 @@ const setScreenBrightness = ENV_OBJ.setScreenBrightness || envError('setScreenBr
|
|
|
4
4
|
|
|
5
5
|
const getScreenBrightness = ENV_OBJ.getScreenBrightness || envError('getScreenBrightness')
|
|
6
6
|
|
|
7
|
+
const setVisualEffectOnCapture = ENV_OBJ.setVisualEffectOnCapture || envError('setVisualEffectOnCapture')
|
|
8
|
+
|
|
9
|
+
const onUserCaptureScreen = ENV_OBJ.onUserCaptureScreen || envError('onUserCaptureScreen')
|
|
10
|
+
|
|
11
|
+
const offUserCaptureScreen = ENV_OBJ.offUserCaptureScreen || envError('offUserCaptureScreen')
|
|
12
|
+
|
|
7
13
|
export {
|
|
8
14
|
setScreenBrightness,
|
|
9
|
-
getScreenBrightness
|
|
15
|
+
getScreenBrightness,
|
|
16
|
+
setVisualEffectOnCapture,
|
|
17
|
+
onUserCaptureScreen,
|
|
18
|
+
offUserCaptureScreen
|
|
10
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Brightness from 'expo-brightness'
|
|
2
|
-
import { successHandle, failHandle } from '../../../common/js'
|
|
2
|
+
import { successHandle, failHandle, envError } from '../../../common/js'
|
|
3
3
|
|
|
4
4
|
function getScreenBrightness (options = {}) {
|
|
5
5
|
const { success, fail, complete } = options
|
|
@@ -32,7 +32,16 @@ function setScreenBrightness (options = {}) {
|
|
|
32
32
|
})
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
const setVisualEffectOnCapture = envError('setVisualEffectOnCapture')
|
|
36
|
+
|
|
37
|
+
const onUserCaptureScreen = envError('onUserCaptureScreen')
|
|
38
|
+
|
|
39
|
+
const offUserCaptureScreen = envError('offUserCaptureScreen')
|
|
40
|
+
|
|
35
41
|
export {
|
|
36
42
|
getScreenBrightness,
|
|
37
|
-
setScreenBrightness
|
|
43
|
+
setScreenBrightness,
|
|
44
|
+
setVisualEffectOnCapture,
|
|
45
|
+
onUserCaptureScreen,
|
|
46
|
+
offUserCaptureScreen
|
|
38
47
|
}
|