@mpxjs/api-proxy 2.10.0-beta.1 → 2.10.1-beta.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.10.0-beta.1",
3
+ "version": "2.10.1-beta.1",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -41,12 +41,12 @@
41
41
  "axios": "^1.7.3"
42
42
  },
43
43
  "peerDependencies": {
44
- "@react-native-async-storage/async-storage": "^1.23.1",
45
- "@react-native-community/netinfo": "^11.2.1",
46
- "react-native-device-info": "^10.13.2",
47
- "react-native-get-location": "^4.0.1",
48
- "react-native-haptic-feedback": "^2.3.3",
49
- "react-native-safe-area-context": "^4.10.1"
44
+ "@react-native-async-storage/async-storage": "*",
45
+ "@react-native-community/netinfo": "*",
46
+ "react-native-device-info": "*",
47
+ "react-native-get-location": "*",
48
+ "react-native-haptic-feedback": "*",
49
+ "react-native-safe-area-context": "*"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@react-native-async-storage/async-storage": {
@@ -44,7 +44,8 @@ const blackList = [
44
44
  'getExptInfoSync',
45
45
  'reserveChannelsLive',
46
46
  'getNFCAdapter',
47
- 'isVKSupport'
47
+ 'isVKSupport',
48
+ 'getState'
48
49
  ]
49
50
 
50
51
  function getMapFromList (list) {
@@ -16,7 +16,7 @@ function nextTick (cb) {
16
16
  channel.port1.onmessage = cb
17
17
  port.postMessage(1)
18
18
  } else {
19
- setTimeout(cb, 0)
19
+ setTimeout(cb)
20
20
  }
21
21
  }
22
22
 
@@ -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)
@@ -163,16 +163,21 @@ function reset (options = {}) {
163
163
  failHandle(res, options.fail, options.complete)
164
164
  return
165
165
  }
166
+ const resetOption = Object.getOwnPropertyNames(options).reduce((resOpt, key) => {
167
+ if (key !== 'fail' && key !== 'complete' && key !== 'success') {
168
+ resOpt[key] = options[key]
169
+ }
170
+ return resOpt
171
+ }, {})
166
172
  const navigation = Object.values(global.__mpxPagesMap || {})[0]?.[1]
167
173
  const navigationHelper = global.__navigationHelper
168
174
  if (isLock(navigationHelper, 'reset', options)) {
169
175
  return
170
176
  }
171
177
  if (navigation && navigationHelper) {
172
- navigation.reset({
173
- index: routes.length - 1,
174
- routes
175
- })
178
+ navigation.reset(Object.assign(resetOption, {
179
+ index: routes.length - 1
180
+ }))
176
181
  navigationHelper.lastSuccessCallback = () => {
177
182
  const res = { errMsg: 'reset:ok' }
178
183
  successHandle(res, options.success, options.complete)
@@ -184,11 +189,20 @@ function reset (options = {}) {
184
189
  }
185
190
  }
186
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
+
187
200
  export {
188
201
  redirectTo,
189
202
  navigateTo,
190
203
  navigateBack,
191
204
  reLaunch,
192
205
  switchTab,
193
- reset
206
+ reset,
207
+ getState
194
208
  }
@@ -12,11 +12,14 @@ const switchTab = ENV_OBJ.switchTab || envError('switchTab')
12
12
 
13
13
  const reset = envError('reset')
14
14
 
15
+ const getState = envError('getState')
16
+
15
17
  export {
16
18
  redirectTo,
17
19
  navigateTo,
18
20
  navigateBack,
19
21
  reLaunch,
20
22
  switchTab,
21
- reset
23
+ reset,
24
+ getState
22
25
  }
@@ -185,11 +185,14 @@ function switchTab (options = {}) {
185
185
 
186
186
  const reset = envError('reset')
187
187
 
188
+ const getState = envError('getState')
189
+
188
190
  export {
189
191
  redirectTo,
190
192
  navigateTo,
191
193
  navigateBack,
192
194
  reLaunch,
193
195
  switchTab,
194
- reset
196
+ reset,
197
+ getState
195
198
  }