@mpxjs/api-proxy 2.8.46 → 2.8.58

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.8.46",
3
+ "version": "2.8.58",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "dependencies": {
40
40
  "axios": "^0.21.1"
41
41
  },
42
- "gitHead": "dcf6f000660d56207ff414cb776e8bc6d5ce651f"
42
+ "gitHead": "42e08109b8890516ea12d47598f42e2c0a9f4682"
43
43
  }
@@ -97,16 +97,8 @@ class WebIntersectionObserver {
97
97
  nextTick(() => {
98
98
  const marginsTemp = margins || {}
99
99
  const { left = 0, right = 0, top = 0, bottom = 0 } = marginsTemp
100
- this._root = document.querySelector('html')
101
- const viewportWidth = window.innerWidth || document.documentElement.clientWidth
102
- const viewportHeight = window.innerHeight || document.documentElement.clientHeight
103
- const rootWidth = this._root.offsetWidth || 0
104
- const rootHeight = this._root.offsetHeight || 0
105
- if (rootHeight >= viewportHeight) {
106
- this._rootMargin = `${top}px ${viewportWidth - rootWidth + right}px ${viewportHeight - rootHeight + bottom}px ${left}px`
107
- } else {
108
- this._rootMargin = `${top}px ${right}px ${bottom}px ${left}px`
109
- }
100
+ this._root = null
101
+ this._rootMargin = `${top}px ${right}px ${bottom}px ${left}px`
110
102
  this._relativeInfo.push({ selector: null, margins })
111
103
  })
112
104
  return this
@@ -75,7 +75,7 @@ class SelectQuery {
75
75
  }
76
76
 
77
77
  _handleFields (fields, el, selector) {
78
- if (!el) return null
78
+ if (!el || (el && !el.getBoundingClientRect)) return null
79
79
  const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [], node } = fields
80
80
  const { left, right, top, bottom, width, height } = el.getBoundingClientRect()
81
81
 
@@ -39,7 +39,17 @@ function request (options = { url: '' }) {
39
39
  headers: header,
40
40
  responseType,
41
41
  timeout,
42
- cancelToken: source.token
42
+ cancelToken: source.token,
43
+ transitional: {
44
+ // silent JSON parsing mode
45
+ // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
46
+ // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
47
+ silentJSONParsing: true, // default value for the current Axios version
48
+ // try to parse the response string as JSON even if `responseType` is not 'json'
49
+ forcedJSONParsing: false,
50
+ // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
51
+ clarifyTimeoutError: false
52
+ }
43
53
  }
44
54
 
45
55
  if (method === 'GET') {
@@ -49,7 +59,7 @@ function request (options = { url: '' }) {
49
59
 
50
60
  const promise = axios(rOptions).then(res => {
51
61
  let data = res.data
52
- if (responseType === 'text' && dataType === 'json') {
62
+ if (dataType === 'json' && typeof data === 'string') {
53
63
  try {
54
64
  data = JSON.parse(data)
55
65
  } catch (e) {
@@ -81,7 +81,11 @@ function navigateTo (options = {}) {
81
81
  function navigateBack (options = {}) {
82
82
  const router = global.__mpxRouter
83
83
  if (router) {
84
- const delta = options.delta || 1
84
+ let delta = options.delta || 1
85
+ const stackLength = router.stack.length
86
+ if (stackLength > 1 && delta >= stackLength) {
87
+ delta = stackLength - 1
88
+ }
85
89
  router.__mpxAction = {
86
90
  type: 'back',
87
91
  delta