@mpxjs/api-proxy 2.8.28-beta.11 → 2.8.40-test

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.
Files changed (111) hide show
  1. package/package.json +3 -3
  2. package/src/common/js/index.js +0 -1
  3. package/src/{mini → common/js}/promisify.js +4 -2
  4. package/src/common/js/utils.js +32 -1
  5. package/src/common/js/web.js +16 -0
  6. package/src/common/stylus/Preview.styl +29 -0
  7. package/src/index.js +3 -77
  8. package/src/install.js +56 -0
  9. package/src/{web → platform}/api/action-sheet/ActionSheet.js +2 -7
  10. package/src/platform/api/action-sheet/index.ali.js +28 -0
  11. package/src/platform/api/action-sheet/index.js +9 -0
  12. package/src/platform/api/add-phone-contact/index.ali.js +13 -0
  13. package/src/platform/api/add-phone-contact/index.js +9 -0
  14. package/src/platform/api/animation/index.js +9 -0
  15. package/src/platform/api/app/index.js +24 -0
  16. package/src/platform/api/audio/index.js +9 -0
  17. package/src/platform/api/base/index.js +12 -0
  18. package/src/platform/api/ble-connection/index.ali.js +17 -0
  19. package/src/platform/api/ble-connection/index.js +15 -0
  20. package/src/platform/api/canvas/index.ali.js +16 -0
  21. package/src/platform/api/canvas/index.js +15 -0
  22. package/src/platform/api/check-session/index.js +9 -0
  23. package/src/platform/api/clipboard-data/index.ali.js +30 -0
  24. package/src/platform/api/clipboard-data/index.js +12 -0
  25. package/src/{web → platform}/api/create-intersection-observer/IntersectionObserver.js +2 -10
  26. package/src/platform/api/create-intersection-observer/index.ali.js +7 -0
  27. package/src/platform/api/create-intersection-observer/index.js +9 -0
  28. package/src/{web → platform}/api/create-selector-query/SelectQuery.js +11 -3
  29. package/src/platform/api/create-selector-query/index.ali.js +35 -0
  30. package/src/platform/api/create-selector-query/index.js +9 -0
  31. package/src/platform/api/device/network/index.js +15 -0
  32. package/src/{web/api/event-channel/index.js → platform/api/event-channel/index.web.js} +13 -14
  33. package/src/platform/api/file/index.ali.js +35 -0
  34. package/src/platform/api/file/index.js +12 -0
  35. package/src/platform/api/get-user-info/index.ali.js +18 -0
  36. package/src/platform/api/get-user-info/index.js +9 -0
  37. package/src/platform/api/image/Preview.js +80 -0
  38. package/src/platform/api/image/index.ali.js +36 -0
  39. package/src/platform/api/image/index.js +12 -0
  40. package/src/platform/api/image/index.web.js +12 -0
  41. package/src/platform/api/login/index.ali.js +15 -0
  42. package/src/platform/api/login/index.js +9 -0
  43. package/src/platform/api/make-phone-call/index.ali.js +12 -0
  44. package/src/platform/api/make-phone-call/index.js +9 -0
  45. package/src/{web → platform}/api/modal/Modal.js +2 -7
  46. package/src/platform/api/modal/index.ali.js +32 -0
  47. package/src/platform/api/modal/index.js +9 -0
  48. package/src/platform/api/next-tick/index.ali.js +7 -0
  49. package/src/platform/api/next-tick/index.js +9 -0
  50. package/src/platform/api/next-tick/index.tt.js +7 -0
  51. package/src/platform/api/page-scroll-to/index.js +9 -0
  52. package/src/platform/api/pull-down/index.js +12 -0
  53. package/src/{web/api/pull-down/index.js → platform/api/pull-down/index.web.js} +14 -22
  54. package/src/platform/api/request/index.ali.js +26 -0
  55. package/src/platform/api/request/index.js +9 -0
  56. package/src/{web/api/request/index.js → platform/api/request/index.web.js} +14 -7
  57. package/src/platform/api/request-payment/index.ali.js +45 -0
  58. package/src/platform/api/request-payment/index.js +9 -0
  59. package/src/platform/api/route/index.js +21 -0
  60. package/src/{web/api/route/index.js → platform/api/route/index.web.js} +71 -78
  61. package/src/platform/api/scan-code/index.ali.js +17 -0
  62. package/src/platform/api/scan-code/index.js +9 -0
  63. package/src/platform/api/screen-brightness/index.ali.js +26 -0
  64. package/src/platform/api/screen-brightness/index.js +12 -0
  65. package/src/platform/api/set-navigation-bar/index.ali.js +25 -0
  66. package/src/platform/api/set-navigation-bar/index.js +12 -0
  67. package/src/{web/api/set-navigation-bar/index.js → platform/api/set-navigation-bar/index.web.js} +0 -1
  68. package/src/{web → platform}/api/socket/SocketTask.js +1 -1
  69. package/src/platform/api/socket/index.js +9 -0
  70. package/src/platform/api/storage/index.ali.js +59 -0
  71. package/src/platform/api/storage/index.js +36 -0
  72. package/src/{web/api/storage/index.js → platform/api/storage/index.web.js} +0 -10
  73. package/src/platform/api/system/index.ali.js +38 -0
  74. package/src/platform/api/system/index.js +12 -0
  75. package/src/{web/api/system/index.js → platform/api/system/index.web.js} +0 -1
  76. package/src/platform/api/tab-bar/index.js +18 -0
  77. package/src/{web/api/tab-bar/index.js → platform/api/tab-bar/index.web.js} +0 -8
  78. package/src/{web → platform}/api/toast/Toast.js +1 -10
  79. package/src/platform/api/toast/index.ali.js +39 -0
  80. package/src/platform/api/toast/index.js +18 -0
  81. package/src/platform/api/video/index.js +9 -0
  82. package/src/platform/api/window/index.js +12 -0
  83. package/src/platform/index.js +106 -0
  84. package/src/web/api/index.js +3 -0
  85. package/src/common/js/ToPromise.js +0 -25
  86. package/src/index.web.js +0 -27
  87. package/src/mini/platform/wxToAli.js +0 -676
  88. package/src/mini/platform/wxToQq.js +0 -20
  89. package/src/mini/platform/wxToTt.js +0 -9
  90. package/src/mini/transform.js +0 -71
  91. /package/src/{web/api/action-sheet/index.js → platform/api/action-sheet/index.web.js} +0 -0
  92. /package/src/{web → platform}/api/animation/animation.js +0 -0
  93. /package/src/{web/api/animation/index.js → platform/api/animation/index.web.js} +0 -0
  94. /package/src/{web/api/app/index.js → platform/api/app/index.web.js} +0 -0
  95. /package/src/{web/api/audio/index.js → platform/api/audio/index.web.js} +0 -0
  96. /package/src/{web → platform}/api/base/base64.js +0 -0
  97. /package/src/{web/api/base/index.js → platform/api/base/index.web.js} +0 -0
  98. /package/src/{web/api/create-intersection-observer/index.js → platform/api/create-intersection-observer/index.web.js} +0 -0
  99. /package/src/{web → platform}/api/create-selector-query/NodesRef.js +0 -0
  100. /package/src/{web/api/create-selector-query/index.js → platform/api/create-selector-query/index.web.js} +0 -0
  101. /package/src/{web → platform}/api/device/network/getNetworkType.js +0 -0
  102. /package/src/{web/api/device/network/index.js → platform/api/device/network/index.web.js} +0 -0
  103. /package/src/{web → platform}/api/device/network/onNetworkStatusChange.js +0 -0
  104. /package/src/{web/api/modal/index.js → platform/api/modal/index.web.js} +0 -0
  105. /package/src/{web/api/next-tick/index.js → platform/api/next-tick/index.web.js} +0 -0
  106. /package/src/{web/api/page-scroll-to/index.js → platform/api/page-scroll-to/index.web.js} +0 -0
  107. /package/src/{web → platform}/api/request/RequestTask.js +0 -0
  108. /package/src/{web/api/socket/index.js → platform/api/socket/index.web.js} +0 -0
  109. /package/src/{web/api/toast/index.js → platform/api/toast/index.web.js} +0 -0
  110. /package/src/{web/api/video/index.js → platform/api/video/index.web.js} +0 -0
  111. /package/src/{web/api/window/index.js → platform/api/window/index.web.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.8.28-beta.11",
3
+ "version": "2.8.40-test",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "promise"
32
32
  ],
33
33
  "author": "httpsxiao",
34
- "license": "Apache-2.0",
34
+ "license": "ISC",
35
35
  "bugs": {
36
36
  "url": "https://github.com/didi/mpx/issues"
37
37
  },
@@ -39,5 +39,5 @@
39
39
  "dependencies": {
40
40
  "axios": "^0.21.1"
41
41
  },
42
- "gitHead": "8c7fa579da9c3e71908eb9bfb5833a7d9477505d"
42
+ "gitHead": "8524f9b69ebcfb0667ebff2608cf6f675f14f141"
43
43
  }
@@ -1,3 +1,2 @@
1
- export * from './ToPromise'
2
1
  export * from './web'
3
2
  export * from './utils'
@@ -1,4 +1,4 @@
1
- import { genFromMap, getEnvObj, noop } from '../common/js'
1
+ import { genFromMap, getEnvObj, noop } from './utils'
2
2
 
3
3
  const envObj = getEnvObj()
4
4
 
@@ -28,7 +28,9 @@ const blackList = [
28
28
  'getMenuButtonBoundingClientRect',
29
29
  'reportMonitor',
30
30
  'createOffscreenCanvas',
31
- 'reportEvent'
31
+ 'reportEvent',
32
+ 'connectSocket',
33
+ 'base64ToArrayBuffer'
32
34
  ]
33
35
 
34
36
  function getMapFromList (list) {
@@ -29,7 +29,6 @@ function changeOpts (options, updateOrRemoveOpt = {}, extraOpt = {}) {
29
29
  })
30
30
 
31
31
  opts = Object.assign({}, opts, extraOpt)
32
-
33
32
  return opts
34
33
  }
35
34
 
@@ -77,6 +76,31 @@ function getEnvObj () {
77
76
  return qa
78
77
  case 'dd':
79
78
  return dd
79
+ case 'web':
80
+ return {}
81
+ }
82
+ }
83
+
84
+ function getEnvStr () {
85
+ switch (__mpx_mode__) {
86
+ case 'wx':
87
+ return 'wx'
88
+ case 'ali':
89
+ return 'ali'
90
+ case 'swan':
91
+ return 'swan'
92
+ case 'qq':
93
+ return 'qq'
94
+ case 'tt':
95
+ return 'tt'
96
+ case 'jd':
97
+ return 'jd'
98
+ case 'qa':
99
+ return 'qa'
100
+ case 'dd':
101
+ return 'dd'
102
+ case 'web':
103
+ return 'web'
80
104
  }
81
105
  }
82
106
 
@@ -87,6 +111,11 @@ function warn (msg) {
87
111
  function error (msg) {
88
112
  console.error && console.error(`[@mpxjs/api-proxy error]:\n ${msg}`)
89
113
  }
114
+ function envError (method) {
115
+ return () => {
116
+ console.error && console.error(`[@mpxjs/api-proxy error]:\n ${__mpx_mode__}环境不支持${method}方法`)
117
+ }
118
+ }
90
119
 
91
120
  function noop () {
92
121
  }
@@ -105,7 +134,9 @@ export {
105
134
  handleSuccess,
106
135
  genFromMap,
107
136
  getEnvObj,
137
+ getEnvStr,
108
138
  error,
139
+ envError,
109
140
  warn,
110
141
  noop,
111
142
  makeMap,
@@ -15,8 +15,24 @@ function isTabBarPage (url, router) {
15
15
  return !!tabBarPagesMap[path.slice(1)]
16
16
  }
17
17
 
18
+ /**
19
+ * Creates a new DOM element with the specified tag, attributes, and children.
20
+ *
21
+ * @param {string} tag - The tag name of the new element.
22
+ * @param {Object.<string, string>} [attrs={}] - An object containing the attributes to set on the new element.
23
+ * @param {Array.<HTMLElement>} [children=[]] - An array of child elements to append to the new element.
24
+ * @returns {HTMLElement} The newly created DOM element.
25
+ */
26
+ function createDom (tag, attrs = {}, children = []) {
27
+ const dom = document.createElement(tag)
28
+ Object.keys(attrs).forEach(k => dom.setAttribute(k, attrs[k]))
29
+ children.length && children.forEach(child => dom.appendChild(child))
30
+ return dom
31
+ }
32
+
18
33
  export {
19
34
  webHandleSuccess,
20
35
  webHandleFail,
36
+ createDom,
21
37
  isTabBarPage
22
38
  }
@@ -0,0 +1,29 @@
1
+ .__mpx_preview__
2
+ display none
3
+ width 100%
4
+ height 100%
5
+ background black
6
+ position fixed
7
+ top 0
8
+ left 0
9
+ z-index 1000
10
+ .__mpx_preview_tip__
11
+ position absolute
12
+ top 0
13
+ left 50%
14
+ transform translateX(-50%)
15
+ color white
16
+ font-size 48px
17
+ letter-spacing 0.3em
18
+ .__mpx_preview_images__
19
+ display flex
20
+ width 100%
21
+ height 100%
22
+ transition transform 0.3s ease-in-out
23
+ &>div
24
+ flex-shrink 0
25
+ width 100%
26
+ height 100%
27
+ background-position center
28
+ background-size contain
29
+ background-repeat no-repeat
package/src/index.js CHANGED
@@ -1,77 +1,3 @@
1
- import transformApi from './mini/transform'
2
- import promisify from './mini/promisify'
3
-
4
- export default function install (target, options = {}) {
5
- const {
6
- usePromise = false, // 是否转为 promise 格式
7
- whiteList = [], // 强制变成 promise 格式的 api
8
- blackList = [], // 强制不变成 promise 格式的 api
9
- platform = {},
10
- exclude = ['shareImageMessage'], // 强制不进行代理的api,临时fix微信分享朋友圈白屏
11
- custom = {}, // 自定义转化规则
12
- fallbackMap = {}, // 对于不支持的API,允许配置一个映射表,接管不存在的API
13
- optimize = false // 内部一些实验优化的开关,外部用户慎用
14
- } = options
15
-
16
- let { from = '', to = '' } = platform
17
- /* eslint-disable camelcase, no-undef */
18
- if (typeof __mpx_src_mode__ !== 'undefined') {
19
- if (from && from !== __mpx_src_mode__) {
20
- console.warn && console.warn('the platform from field inconsistent with the current environment value\n')
21
- }
22
- from = `__mpx_src_mode_${__mpx_src_mode__}__`
23
- } else {
24
- if (!from) {
25
- from = 'wx'
26
- console.warn && console.warn('the platform from field is empty, wx will be used by default\n')
27
- }
28
- from = `__mpx_src_mode_${from}__`
29
- }
30
-
31
- if (typeof __mpx_mode__ !== 'undefined') {
32
- to = __mpx_mode__
33
- } else if (!to) {
34
- console.warn && console.warn('the platform to field is empty, ali will be used by default\n')
35
- to = 'wx'
36
- }
37
- /* eslint-enable */
38
-
39
- const transedApi = transformApi({
40
- exclude,
41
- from,
42
- to,
43
- custom,
44
- optimize
45
- })
46
-
47
- const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {}
48
- const allApi = Object.assign({}, transedApi, promisedApi)
49
-
50
- Object.keys(allApi).forEach(api => {
51
- try {
52
- if (typeof allApi[api] !== 'function') {
53
- target[api] = allApi[api]
54
- return
55
- }
56
-
57
- target[api] = (...args) => {
58
- return allApi[api].apply(target, args)
59
- }
60
- } catch (e) {
61
- } // 支付宝不支持重写 call 方法
62
- })
63
-
64
- // Fallback Map option
65
- Object.keys(fallbackMap)
66
- .forEach(k => {
67
- if (!target[k]) {
68
- target[k] = fallbackMap[k]
69
- }
70
- })
71
- }
72
-
73
- export function getProxy (options = {}) {
74
- const apiProxy = {}
75
- install(apiProxy, options)
76
- return apiProxy
77
- }
1
+ import install from './install'
2
+ export * from './platform'
3
+ export default install
package/src/install.js ADDED
@@ -0,0 +1,56 @@
1
+ import * as platformApi from './platform'
2
+ import { getEnvObj, getEnvStr } from './common/js'
3
+ import promisify from './common/js/promisify'
4
+
5
+ export default function install (target, options = {}) {
6
+ const {
7
+ usePromise = false, // 是否转为 promise 格式
8
+ whiteList = [], // 强制变成 promise 格式的 api
9
+ blackList = [], // 强制不变成 promise 格式的 api
10
+ custom = {}, // 自定义转化规则
11
+ fallbackMap = {} // 对于不支持的API,允许配置一个映射表,接管不存在的API
12
+ } = options
13
+
14
+ let transedApi = {}
15
+ const envStr = getEnvStr()
16
+
17
+ if (__mpx_env__ === 'web') {
18
+ transedApi = platformApi
19
+ } else {
20
+ const envObj = getEnvObj()
21
+ Object.keys(envObj).concat(Object.keys(platformApi)).forEach((key) => {
22
+ transedApi[key] = platformApi[key] || envObj[key]
23
+ })
24
+ }
25
+
26
+ const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {}
27
+ const allApi = Object.assign({}, transedApi, promisedApi)
28
+
29
+ Object.keys(allApi).forEach(api => {
30
+ try {
31
+ if (typeof allApi[api] !== 'function') {
32
+ target[api] = allApi[api]
33
+ return
34
+ }
35
+ target[api] = (...args) => {
36
+ return allApi[api].apply(target, args)
37
+ }
38
+ } catch (e) {
39
+ } // 支付宝不支持重写 call 方法
40
+ })
41
+ if (custom[envStr]) {
42
+ Object.keys(custom[envStr])
43
+ .forEach(k => {
44
+ target[k] = (...args) => {
45
+ return custom[envStr][k].apply(target, args)
46
+ }
47
+ })
48
+ }
49
+ // Fallback Map option
50
+ Object.keys(fallbackMap)
51
+ .forEach(k => {
52
+ if (!target[k]) {
53
+ target[k] = fallbackMap[k]
54
+ }
55
+ })
56
+ }
@@ -1,9 +1,8 @@
1
- import { ToPromise, webHandleSuccess, webHandleFail } from '../../../common/js'
1
+ import { webHandleSuccess, webHandleFail } from '../../../common/js'
2
2
  import '../../../common/stylus/ActionSheet.styl'
3
3
 
4
- export default class ActionSheet extends ToPromise {
4
+ export default class ActionSheet {
5
5
  constructor () {
6
- super()
7
6
  this.defaultOpts = {
8
7
  itemList: [],
9
8
  itemColor: '#000000',
@@ -64,7 +63,6 @@ export default class ActionSheet extends ToPromise {
64
63
  tapIndex: index
65
64
  }
66
65
  webHandleSuccess(res, opts.success, opts.complete)
67
- this.toPromiseResolve(res)
68
66
  }
69
67
  list.appendChild(sheet)
70
68
  })
@@ -77,13 +75,10 @@ export default class ActionSheet extends ToPromise {
77
75
  this.hide()
78
76
  const err = { errMsg: 'showActionSheet:fail cancel' }
79
77
  webHandleFail(err, opts.fail, opts.complete)
80
- !opts.fail && this.toPromiseReject(err)
81
78
  }
82
79
 
83
80
  this.box.classList.add('show')
84
81
  this.actionSheet.classList.add('show')
85
-
86
- return this.toPromiseInitPromise()
87
82
  }
88
83
 
89
84
  hide () {
@@ -0,0 +1,28 @@
1
+ import { changeOpts, noop } from '../../../common/js'
2
+ function showActionSheet (options = {}) {
3
+ const opts = changeOpts(options, {
4
+ itemList: 'items'
5
+ })
6
+
7
+ const cacheSuc = opts.success || noop
8
+ const cacheFail = opts.fail || noop
9
+
10
+ opts.success = function (res) {
11
+ const sucRes = changeOpts(res, {
12
+ index: 'tapIndex'
13
+ })
14
+ if (sucRes.tapIndex === -1) {
15
+ cacheFail.call(this, {
16
+ errMsg: 'showActionSheet:fail cancel'
17
+ })
18
+ } else {
19
+ cacheSuc.call(this, sucRes)
20
+ }
21
+ }
22
+
23
+ my.showActionSheet(opts)
24
+ }
25
+
26
+ export {
27
+ showActionSheet
28
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const showActionSheet = ENV_OBJ.showActionSheet || envError('showActionSheet')
6
+
7
+ export {
8
+ showActionSheet
9
+ }
@@ -0,0 +1,13 @@
1
+ import { changeOpts } from '../../../common/js'
2
+
3
+ function addPhoneContact (options = {}) {
4
+ const opts = changeOpts(options, {
5
+ weChatNumber: 'alipayAccount'
6
+ })
7
+
8
+ my.addPhoneContact(opts)
9
+ }
10
+
11
+ export {
12
+ addPhoneContact
13
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const addPhoneContact = ENV_OBJ.addPhoneContact || envError('addPhoneContact')
6
+
7
+ export {
8
+ addPhoneContact
9
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const createAnimation = ENV_OBJ.createAnimation || envError('createAnimation')
6
+
7
+ export {
8
+ createAnimation
9
+ }
@@ -0,0 +1,24 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const onError = ENV_OBJ.onError || envError('onError')
6
+
7
+ const offError = ENV_OBJ.offError || envError('offError')
8
+
9
+ const onAppShow = ENV_OBJ.onAppShow || envError('onAppShow')
10
+
11
+ const offAppShow = ENV_OBJ.offAppShow || envError('offAppShow')
12
+
13
+ const onAppHide = ENV_OBJ.onAppHide || envError('onAppHide')
14
+
15
+ const offAppHide = ENV_OBJ.offAppHide || envError('offAppHide')
16
+
17
+ export {
18
+ onAppShow,
19
+ onAppHide,
20
+ offAppShow,
21
+ offAppHide,
22
+ onError,
23
+ offError
24
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const createInnerAudioContext = ENV_OBJ.createInnerAudioContext || envError('createInnerAudioContext')
6
+
7
+ export {
8
+ createInnerAudioContext
9
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const base64ToArrayBuffer = ENV_OBJ.base64ToArrayBuffer || envError('base64ToArrayBuffer')
6
+
7
+ const arrayBufferToBase64 = ENV_OBJ.arrayBufferToBase64 || envError('arrayBufferToBase64')
8
+
9
+ export {
10
+ base64ToArrayBuffer,
11
+ arrayBufferToBase64
12
+ }
@@ -0,0 +1,17 @@
1
+ function closeBLEConnection (options = {}) {
2
+ my.disconnectBLEDevice(options)
3
+ }
4
+
5
+ function createBLEConnection (options = {}) {
6
+ my.connectBLEDevice(options)
7
+ }
8
+
9
+ function onBLEConnectionStateChange (callback) {
10
+ my.onBLEConnectionStateChanged(callback)
11
+ }
12
+
13
+ export {
14
+ closeBLEConnection,
15
+ createBLEConnection,
16
+ onBLEConnectionStateChange
17
+ }
@@ -0,0 +1,15 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const closeBLEConnection = ENV_OBJ.closeBLEConnection || envError('closeBLEConnection')
6
+
7
+ const createBLEConnection = ENV_OBJ.createBLEConnection || envError('createBLEConnection')
8
+
9
+ const onBLEConnectionStateChange = ENV_OBJ.onBLEConnectionStateChange || envError('onBLEConnectionStateChange')
10
+
11
+ export {
12
+ closeBLEConnection,
13
+ createBLEConnection,
14
+ onBLEConnectionStateChange
15
+ }
@@ -0,0 +1,16 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function canvasToTempFilePath (options = {}) {
4
+ handleSuccess(options, res => {
5
+ return changeOpts(
6
+ res,
7
+ { errMsg: 'canvasToTempFilePath:ok' }
8
+ )
9
+ })
10
+
11
+ my.canvasToTempFilePath(options)
12
+ }
13
+
14
+ export {
15
+ canvasToTempFilePath
16
+ }
@@ -0,0 +1,15 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const createCanvasContext = ENV_OBJ.createCanvasContext || envError('createCanvasContext')
6
+
7
+ const canvasToTempFilePath = ENV_OBJ.canvasToTempFilePath || envError('canvasToTempFilePath')
8
+
9
+ const canvasGetImageData = ENV_OBJ.canvasGetImageData || envError('canvasGetImageData')
10
+
11
+ export {
12
+ createCanvasContext,
13
+ canvasToTempFilePath,
14
+ canvasGetImageData
15
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const checkSession = ENV_OBJ.checkSession || envError('checkSession')
6
+
7
+ export {
8
+ checkSession
9
+ }
@@ -0,0 +1,30 @@
1
+ import { changeOpts, handleSuccess } from '../../../common/js'
2
+
3
+ function setClipboardData (options = {}) {
4
+ const opts = changeOpts(options, {
5
+ data: 'text'
6
+ })
7
+ handleSuccess(opts, res => {
8
+ return changeOpts(res, {
9
+ success: ''
10
+ }, {
11
+ errMsg: 'setClipboardData:ok'
12
+ })
13
+ })
14
+ my.setClipboard(opts)
15
+ }
16
+
17
+ function getClipboardData (options = {}) {
18
+ const opts = changeOpts(options)
19
+
20
+ handleSuccess(opts, res => {
21
+ return changeOpts(res, { text: 'data' })
22
+ })
23
+
24
+ my.getClipboard(opts)
25
+ }
26
+
27
+ export {
28
+ setClipboardData,
29
+ getClipboardData
30
+ }
@@ -0,0 +1,12 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const setClipboardData = ENV_OBJ.setClipboardData || envError('setClipboardData')
6
+
7
+ const getClipboardData = ENV_OBJ.getClipboardData || envError('getClipboardData')
8
+
9
+ export {
10
+ setClipboardData,
11
+ getClipboardData
12
+ }
@@ -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
@@ -0,0 +1,7 @@
1
+ function createIntersectionObserver (component, options = {}) {
2
+ return my.createIntersectionObserver(options)
3
+ }
4
+
5
+ export {
6
+ createIntersectionObserver
7
+ }
@@ -0,0 +1,9 @@
1
+ import { getEnvObj, envError } from '../../../common/js'
2
+
3
+ const ENV_OBJ = getEnvObj()
4
+
5
+ const createIntersectionObserver = ENV_OBJ.createIntersectionObserver || envError('createIntersectionObserver')
6
+
7
+ export {
8
+ createIntersectionObserver
9
+ }
@@ -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
 
@@ -136,8 +136,16 @@ class SelectQuery {
136
136
  }
137
137
  }
138
138
  if (scrollOffset) {
139
- res.scrollLeft = el.scrollLeft
140
- res.scrollTop = el.scrollTop
139
+ if (el.isBScrollContainer) {
140
+ const bs = el?.__vue__?.bs
141
+ res.scrollLeft = -bs.x
142
+ res.scrollTop = -bs.y
143
+ } else {
144
+ res.scrollLeft = el.scrollLeft
145
+ res.scrollTop = el.scrollTop
146
+ }
147
+ res.scrollHeight = el.scrollHeight
148
+ res.scrollWidth = el.scrollWidth
141
149
  }
142
150
  properties.forEach(prop => {
143
151
  const attr = el.getAttribute(prop)