@mpxjs/api-proxy 2.9.28 → 2.9.39
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 +2 -2
- package/src/common/js/utils.js +17 -1
- package/src/platform/api/create-intersection-observer/IntersectionObserver.js +7 -4
- package/src/platform/api/create-selector-query/SelectQuery.js +2 -1
- package/src/platform/api/device/network/onNetworkStatusChange.js +1 -1
- package/src/platform/api/window/index.web.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/api-proxy",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.39",
|
|
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": "^1.6.7"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "87957d360b18806f16d169612d924d383ac043c4"
|
|
43
43
|
}
|
package/src/common/js/utils.js
CHANGED
|
@@ -79,6 +79,7 @@ function warn (msg) {
|
|
|
79
79
|
function error (msg) {
|
|
80
80
|
console.error && console.error(`[@mpxjs/api-proxy error]:\n ${msg}`)
|
|
81
81
|
}
|
|
82
|
+
|
|
82
83
|
function envError (method) {
|
|
83
84
|
return () => {
|
|
84
85
|
console.error && console.error(`[@mpxjs/api-proxy error]:\n ${__mpx_mode__}环境不支持${method}方法`)
|
|
@@ -95,6 +96,20 @@ function makeMap (arr) {
|
|
|
95
96
|
}, {})
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
function parseDataset (dataset) {
|
|
100
|
+
const parsed = {}
|
|
101
|
+
for (const key in dataset) {
|
|
102
|
+
if (hasOwn(dataset, key)) {
|
|
103
|
+
try {
|
|
104
|
+
parsed[key] = JSON.parse(dataset[key])
|
|
105
|
+
} catch (e) {
|
|
106
|
+
parsed[key] = dataset[key]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return parsed
|
|
111
|
+
}
|
|
112
|
+
|
|
98
113
|
const isBrowser = typeof window !== 'undefined'
|
|
99
114
|
|
|
100
115
|
function throwSSRWarning (info) {
|
|
@@ -115,5 +130,6 @@ export {
|
|
|
115
130
|
isBrowser,
|
|
116
131
|
hasOwn,
|
|
117
132
|
throwSSRWarning,
|
|
118
|
-
ENV_OBJ
|
|
133
|
+
ENV_OBJ,
|
|
134
|
+
parseDataset
|
|
119
135
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nextTick } from '../next-tick'
|
|
2
|
+
import { parseDataset } from '../../../common/js'
|
|
2
3
|
|
|
3
4
|
let isInit = true
|
|
4
5
|
|
|
@@ -27,14 +28,16 @@ class WebIntersectionObserver {
|
|
|
27
28
|
if (!isInit || (isInit && (entry.intersectionRatio !== initialRatio && (this._minThreshold <= entry.intersectionRatio)))) {
|
|
28
29
|
Object.defineProperties(entry, {
|
|
29
30
|
id: {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
get () {
|
|
32
|
+
return entry.target.id || ''
|
|
33
|
+
},
|
|
32
34
|
enumerable: true,
|
|
33
35
|
configurable: true
|
|
34
36
|
},
|
|
35
37
|
dataset: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
get () {
|
|
39
|
+
return parseDataset(entry.target.dataset)
|
|
40
|
+
},
|
|
38
41
|
enumerable: true,
|
|
39
42
|
configurable: true
|
|
40
43
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import NodesRef from './NodesRef'
|
|
2
|
+
import { parseDataset } from '../../../common/js'
|
|
2
3
|
|
|
3
4
|
class SelectQuery {
|
|
4
5
|
constructor () {
|
|
@@ -82,7 +83,7 @@ class SelectQuery {
|
|
|
82
83
|
const res = {}
|
|
83
84
|
const isViewport = selector === 'html'
|
|
84
85
|
if (id) res.id = el.id
|
|
85
|
-
if (dataset) res.dataset =
|
|
86
|
+
if (dataset) res.dataset = parseDataset(el.dataset)
|
|
86
87
|
if (rect) {
|
|
87
88
|
if (isViewport) {
|
|
88
89
|
res.left = 0
|