@mpxjs/api-proxy 2.9.14 → 2.9.18

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.9.14",
3
+ "version": "2.9.18",
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
- "axios": "^0.21.1"
40
+ "axios": "^1.6.7"
41
41
  },
42
- "gitHead": "e8ab845a544d2db0619a6a7d6c04d9d384d1a6ca"
42
+ "gitHead": "ec6a5d714daf59eed0e5651aa4611a9f9383d233"
43
43
  }
@@ -1,5 +1,3 @@
1
- import { isBrowser } from './utils'
2
-
3
1
  function webHandleSuccess (result, success, complete) {
4
2
  typeof success === 'function' && success(result)
5
3
  typeof complete === 'function' && complete(result)
@@ -35,30 +33,9 @@ function createDom (tag, attrs = {}, children = []) {
35
33
  // 在H5中,直接绑定 click 可能出现延时问题,很多点击可以关闭的组件被唤出之后,有概率立马触发点击事件,导致组件被关闭。
36
34
  // 使用该方法通过 touchstart 和 touchend 模拟 click 事件,解决延时问题。
37
35
  function bindTap (dom, handler) {
38
- const isTouchDevice = isBrowser && document && ('ontouchstart' in document.documentElement)
39
- if (isTouchDevice) {
40
- let startTime = 0; let x = 0; let y = 0
41
- const touchStart = (e) => {
42
- startTime = Date.now()
43
- x = e.touches[0].pageX
44
- y = e.touches[0].pageY
45
- }
46
- const touchEnd = (e) => {
47
- if (Date.now() - startTime < 300 && Math.abs(e.changedTouches[0].pageX - x) < 10 && Math.abs(e.changedTouches[0].pageY - y) < 10) {
48
- handler(e)
49
- }
50
- }
51
- dom.addEventListener('touchstart', touchStart)
52
- dom.addEventListener('touchend', touchEnd)
53
- return () => {
54
- dom.removeEventListener('touchstart', touchStart)
55
- dom.removeEventListener('touchend', touchEnd)
56
- }
57
- } else {
58
- dom.addEventListener('click', handler)
59
- return () => {
60
- dom.removeEventListener('click', handler)
61
- }
36
+ dom.addEventListener('tap', handler)
37
+ return () => {
38
+ dom.removeEventListener('tap', handler)
62
39
  }
63
40
  }
64
41
 
@@ -1,5 +1,5 @@
1
1
  import Preview from './Preview'
2
- import { envError } from '../../../common/js'
2
+ import { isBrowser, throwSSRWarning, envError } from '../../../common/js'
3
3
 
4
4
  let preview = null
5
5
 
@@ -8,6 +8,10 @@ let preview = null
8
8
  * @param {Object} options - 预览图片的配置项
9
9
  */
10
10
  const previewImage = (options) => {
11
+ if (!isBrowser) {
12
+ throwSSRWarning('previewImage API is running in non browser environments')
13
+ return
14
+ }
11
15
  if (!preview) preview = new Preview()
12
16
  preview.show(options)
13
17
  }
@@ -0,0 +1,7 @@
1
+ function getEnterOptionsSync () {
2
+ my.getEnterOptionsSync()
3
+ }
4
+
5
+ export {
6
+ getEnterOptionsSync
7
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const getEnterOptionsSync = ENV_OBJ.getEnterOptionsSync || envError('getEnterOptionsSync')
6
+
7
+ export {
8
+ getEnterOptionsSync
9
+ }
@@ -0,0 +1,12 @@
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
+ }
@@ -104,3 +104,6 @@ export * from './api/video'
104
104
 
105
105
  // onWindowResize, offWindowResize
106
106
  export * from './api/window'
107
+
108
+ // getEnterOptionsSync
109
+ export * from './api/lifecycle'