@mpxjs/api-proxy 2.10.13 → 2.10.15

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.13",
3
+ "version": "2.10.15",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -68,5 +68,5 @@
68
68
  "optional": true
69
69
  }
70
70
  },
71
- "gitHead": "1b4a2d4765341ef6c6b74e501f72a0f856f247f9"
71
+ "gitHead": "4ea4a54f55aa938ad139e080827cffbbf7bb82db"
72
72
  }
@@ -1,28 +1,14 @@
1
- import { ENV_OBJ } from './utils'
1
+ import { ENV_OBJ, warn } from './utils'
2
2
 
3
3
  // 特别指定的不进行Promise封装的方法
4
4
  const blackList = [
5
- 'clearStorage',
6
- 'hideToast',
7
- 'hideLoading',
8
5
  'drawCanvas',
9
6
  'canIUse',
10
- 'stopRecord',
11
- 'pauseVoice',
12
- 'stopVoice',
13
- 'pauseBackgroundAudio',
14
- 'stopBackgroundAudio',
15
- 'showNavigationBarLoading',
16
- 'hideNavigationBarLoading',
17
7
  'getPerformance',
18
- 'hideKeyboard',
19
- 'stopPullDownRefresh',
20
- 'pageScrollTo',
21
8
  'reportAnalytics',
22
9
  'getMenuButtonBoundingClientRect',
23
10
  'reportMonitor',
24
11
  'reportEvent',
25
- 'connectSocket',
26
12
  'base64ToArrayBuffer',
27
13
  'arrayBufferToBase64',
28
14
  'getDeviceInfo',
@@ -33,16 +19,12 @@ const blackList = [
33
19
  'postMessageToReferrerPage',
34
20
  'postMessageToReferrerMiniProgram',
35
21
  'reportPerformance',
36
- 'getPerformance',
37
- 'preDownloadSubpackage',
38
22
  'router',
39
23
  'nextTick',
40
24
  'checkIsPictureInPictureActive',
41
25
  'worklet',
42
26
  'revokeBufferURL',
43
- 'reportEvent',
44
27
  'getExptInfoSync',
45
- 'reserveChannelsLive',
46
28
  'getNFCAdapter',
47
29
  'isVKSupport'
48
30
  ]
@@ -79,18 +61,22 @@ function promisify (listObj, whiteList, customBlackList) {
79
61
  if (typeof listObj[key] !== 'function') {
80
62
  return
81
63
  }
82
-
83
- result[key] = function (...args) {
84
- const obj = args[0] || {}
85
- // 不需要转换 or 用户已定义回调,则不处理
86
- if (!promisifyFilter(key)) {
87
- return listObj[key].apply(ENV_OBJ, args)
88
- } else { // 其他情况进行转换
64
+ if (!promisifyFilter(key)) {
65
+ result[key] = listObj[key].bind(ENV_OBJ)
66
+ } else {
67
+ result[key] = function (...args) {
68
+ const obj = args[0] || {}
69
+ if (obj.usePromise === false) {
70
+ return listObj[key].apply(ENV_OBJ, args)
71
+ }
89
72
  if (!args[0]) args.unshift(obj)
90
73
  let returned
91
74
  const promise = new Promise((resolve, reject) => {
92
75
  const originSuccess = obj.success
93
76
  const originFail = obj.fail
77
+ if (originSuccess || originFail) {
78
+ warn(`The [${key}] method has been promisified, please use .then or .catch to handle the result, if you need to handle the result with options.success/fail, please set options.usePromise to false to close the promisify in this call temporarily. `)
79
+ }
94
80
  obj.success = function (res) {
95
81
  originSuccess && originSuccess.call(this, res)
96
82
  resolve(res)
@@ -1,5 +1,4 @@
1
1
  import { hasOwn, noop, getEnvObj, getFocusedNavigation, error as errorHandler, warn as warnHandler } from '@mpxjs/utils'
2
- import { getCurrentInstance } from '@mpxjs/core'
3
2
 
4
3
  /**
5
4
  *
@@ -90,8 +89,7 @@ function failHandle (result, fail, complete) {
90
89
  }
91
90
 
92
91
  function getCurrentPageId () {
93
- const currentInstance = getCurrentInstance()
94
- const id = currentInstance?.proxy?.getPageId() || getFocusedNavigation()?.pageId || null
92
+ const id = getFocusedNavigation()?.pageId || null
95
93
  return id
96
94
  }
97
95
 
@@ -28,7 +28,7 @@ const styles = StyleSheet.create({
28
28
  bottom: 0,
29
29
  right: 0,
30
30
  position: 'absolute',
31
- zIndex: 1000
31
+ zIndex: 10000
32
32
  },
33
33
  maskWrap: {
34
34
  left: 0,
@@ -65,8 +65,8 @@ const styles = StyleSheet.create({
65
65
  },
66
66
  itemTextStyle: {
67
67
  fontSize: 18,
68
- height: 22,
69
- lineHeight: 22
68
+ paddingTop: 2,
69
+ paddingBottom: 2
70
70
  },
71
71
  buttonStyle: {
72
72
  paddingTop: 10,
@@ -195,8 +195,8 @@ function ActionSheet ({ itemColor, height, success, fail, complete, alertText, i
195
195
  style={{
196
196
  color: '#000000',
197
197
  fontSize: 18,
198
- lineHeight: 22,
199
- height: 22,
198
+ paddingTop: 2,
199
+ paddingBottom: 2,
200
200
  width: '100%',
201
201
  textAlign: 'center'
202
202
  }}
@@ -41,10 +41,11 @@ const wrapFn = (fn) => {
41
41
  const getMeasureProps = (measureProps = []) => {
42
42
  return wrapFn((nodeInstance, resolve) => {
43
43
  const nodeRef = nodeInstance.nodeRef.current
44
- const navigation = getFocusedNavigation()
44
+ const navigation = getFocusedNavigation() || {}
45
45
  setTimeout(() => {
46
46
  nodeRef.measure(function (x, y, width, height, pageX, pageY) {
47
- pageY = pageY - navigation.layout.top
47
+ const layout = navigation.layout || {}
48
+ pageY = pageY - (layout.top || 0)
48
49
  const rectAndSize = {
49
50
  width,
50
51
  height,
@@ -41,7 +41,6 @@ export default class Preview {
41
41
  })
42
42
  // click to close
43
43
  bindTap(this.preview, () => {
44
- this.currentIndex = 0
45
44
  this.preview.style.display = 'none'
46
45
  this.preview.querySelector('.__mpx_preview_images__').remove()
47
46
  this.preview.remove()
@@ -54,10 +53,11 @@ export default class Preview {
54
53
  * @param {string[]} options.urls - 图片地址数组
55
54
  */
56
55
  show (options) {
57
- const supported = ['urls', 'success', 'fail', 'complete']
56
+ const supported = ['urls', 'success', 'fail', 'complete', 'current']
58
57
  Object.keys(options).forEach(key => !supported.includes(key) && warn(`previewImage: 暂不支持选项 ${key} !`))
59
- const { urls, success, fail, complete } = options
58
+ const { urls, current, success, fail, complete } = options
60
59
  try {
60
+ this.currentIndex = urls.indexOf(current) > -1 ? urls.indexOf(current) : 0
61
61
  getRootElement().appendChild(this.preview)
62
62
  this.preview.style.display = 'block'
63
63
  // create images with urls
@@ -65,6 +65,7 @@ export default class Preview {
65
65
  this.preview.appendChild(createDom('div', { class: '__mpx_preview_images__' }, urls.map(url => createDom('div', {
66
66
  style: `background-image: url(${url})`
67
67
  }))))
68
+ this.preview.querySelector('.__mpx_preview_images__').style.transform = `translateX(-${this.currentIndex * 100}%)`
68
69
  this.maxIndex = urls.length
69
70
  this.updateTextTip()
70
71
  successHandle({ errMsg: 'previewImage:ok' }, success, complete)
@@ -47,7 +47,8 @@ const showModal = function (options = {}) {
47
47
  alignItems: 'center',
48
48
  display: 'flex',
49
49
  backgroundColor: 'rgba(0,0,0,0.6)',
50
- position: 'absolute'
50
+ position: 'absolute',
51
+ zIndex: 10000
51
52
  },
52
53
  modalContent: {
53
54
  paddingTop: 20,
@@ -24,7 +24,7 @@ function isLock (navigationHelper, type, options) {
24
24
  navigationHelper.lastFailCallback('timeout')
25
25
  navigationHelper.lastFailCallback = null
26
26
  }
27
- }, 350)
27
+ }, 1000)
28
28
  return false
29
29
  }
30
30