@tarojs/taro-h5 3.3.11 → 3.3.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": "@tarojs/taro-h5",
3
- "version": "3.3.11",
3
+ "version": "3.3.15",
4
4
  "description": "Taro h5 framework",
5
5
  "main:h5": "src/index.js",
6
6
  "main": "dist/index.cjs.js",
@@ -33,9 +33,9 @@
33
33
  "author": "O2Team",
34
34
  "license": "MIT",
35
35
  "dependencies": {
36
- "@tarojs/api": "3.3.11",
37
- "@tarojs/router": "3.3.11",
38
- "@tarojs/runtime": "3.3.11",
36
+ "@tarojs/api": "3.3.15",
37
+ "@tarojs/router": "3.3.15",
38
+ "@tarojs/runtime": "3.3.15",
39
39
  "base64-js": "^1.3.0",
40
40
  "jsonp-retry": "^1.0.3",
41
41
  "mobile-detect": "^1.4.2",
@@ -45,5 +45,5 @@
45
45
  "devDependencies": {
46
46
  "jest-fetch-mock": "^3.0.3"
47
47
  },
48
- "gitHead": "dad3664e58bb1fe7ab752365d9cc0d0dd444c40a"
48
+ "gitHead": "4a11ab9a8950f6a580e1278c160f6b4aaa8ac4f2"
49
49
  }
@@ -1,4 +1,4 @@
1
- import { shouleBeObject, getParameterError } from '../utils'
1
+ import { shouldBeObject, getParameterError } from '../utils'
2
2
 
3
3
  /**
4
4
  * 从本地相册选择图片或使用相机拍照。
@@ -13,7 +13,7 @@ import { shouleBeObject, getParameterError } from '../utils'
13
13
  */
14
14
  const chooseImage = function (options) {
15
15
  // options must be an Object
16
- const isObject = shouleBeObject(options)
16
+ const isObject = shouldBeObject(options)
17
17
  if (!isObject.res) {
18
18
  const res = { errMsg: `chooseImage${isObject.msg}` }
19
19
  console.error(res.errMsg)
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
4
3
  * @param {Object} options
@@ -67,13 +66,23 @@ function loadImage (url, fail) {
67
66
  const item = document.createElement('taro-swiper-item-core')
68
67
  item.style.cssText = `
69
68
  display: flex;
70
- align-items: center;
69
+ align-items: start;
71
70
  justify-content: center;
71
+ overflow-y: scroll;
72
72
  `
73
73
  const image = new Image()
74
74
  image.style.maxWidth = '100%'
75
75
  image.src = url
76
- item.appendChild(image)
76
+ const div = document.createElement('div')
77
+ div.style.cssText = `
78
+ display: flex;
79
+ align-items: center;
80
+ justify-content: center;
81
+ max-width: 100%;
82
+ min-height: 100%;
83
+ `
84
+ div.appendChild(image)
85
+ item.appendChild(div)
77
86
  // Note: 等待图片加载完后返回,会导致轮播被卡住
78
87
  resolve(item)
79
88
  if (typeof fail === 'function') {
@@ -1,8 +1,8 @@
1
- import { shouleBeObject, getParameterError } from '../utils'
1
+ import { shouldBeObject, getParameterError } from '../utils'
2
2
 
3
3
  export function setNavigationBarTitle (options) {
4
4
  // options must be an Object
5
- const isObject = shouleBeObject(options)
5
+ const isObject = shouldBeObject(options)
6
6
  if (!isObject.res) {
7
7
  const res = { errMsg: `setNavigationBarTitle${isObject.msg}` }
8
8
  console.error(res.errMsg)
@@ -1,5 +1,5 @@
1
1
  import { fromByteArray, toByteArray } from 'base64-js'
2
- import { shouleBeObject, getParameterError } from '../utils'
2
+ import { shouldBeObject, getParameterError } from '../utils'
3
3
 
4
4
  export function arrayBufferToBase64 (arrayBuffer) {
5
5
  return fromByteArray(arrayBuffer)
@@ -11,7 +11,7 @@ export function base64ToArrayBuffer (base64) {
11
11
 
12
12
  export function makePhoneCall (options) {
13
13
  // options must be an Object
14
- const isObject = shouleBeObject(options)
14
+ const isObject = shouldBeObject(options)
15
15
  if (!isObject.res) {
16
16
  const res = { errMsg: `makePhoneCall${isObject.msg}` }
17
17
  console.error(res.errMsg)
@@ -1,8 +1,8 @@
1
- import { shouleBeObject, getParameterError } from '../utils'
1
+ import { shouldBeObject, getParameterError } from '../utils'
2
2
 
3
3
  function setStorage (options) {
4
4
  // options must be an Object
5
- const isObject = shouleBeObject(options)
5
+ const isObject = shouldBeObject(options)
6
6
  if (!isObject.res) {
7
7
  const res = { errMsg: `setStorage${isObject.msg}` }
8
8
  console.error(res.errMsg)
@@ -56,7 +56,7 @@ function setStorageSync (key, data = '') {
56
56
 
57
57
  function getStorage (options) {
58
58
  // options must be an Object
59
- const isObject = shouleBeObject(options)
59
+ const isObject = shouldBeObject(options)
60
60
  if (!isObject.res) {
61
61
  const res = { errMsg: `getStorage${isObject.msg}` }
62
62
  console.error(res.errMsg)
@@ -149,7 +149,7 @@ function getStorageInfoSync () {
149
149
 
150
150
  function removeStorage (options) {
151
151
  // options must be an Object
152
- const isObject = shouleBeObject(options)
152
+ const isObject = shouldBeObject(options)
153
153
  if (!isObject.res) {
154
154
  const res = { errMsg: `removeStorage${isObject.msg}` }
155
155
  console.error(res.errMsg)
@@ -1,12 +1,10 @@
1
1
  import Taro from '@tarojs/api'
2
- import { shouleBeObject, getParameterError, isValidColor, successHandler, errorHandler } from '../utils'
2
+ import { shouldBeObject, getParameterError, isValidColor, successHandler, errorHandler } from '../utils'
3
3
 
4
4
  let tabConf
5
- let App
6
5
 
7
- export function initTabBarApis (_App = {}) {
8
- tabConf = _App.state.__tabs
9
- App = _App
6
+ export function initTabBarApis (config = {}) {
7
+ tabConf = config.tabBar
10
8
  }
11
9
 
12
10
  /**
@@ -20,7 +18,7 @@ export function initTabBarApis (_App = {}) {
20
18
  */
21
19
  export function setTabBarBadge (options = {}) {
22
20
  // options must be an Object
23
- const isObject = shouleBeObject(options)
21
+ const isObject = shouldBeObject(options)
24
22
  if (!isObject.res) {
25
23
  const res = { errMsg: `setTabBarBadge${isObject.msg}` }
26
24
  console.error(res.errMsg)
@@ -64,8 +62,6 @@ export function setTabBarBadge (options = {}) {
64
62
  successHandler: successHandler(success, complete),
65
63
  errorHandler: errorHandler(fail, complete)
66
64
  })
67
-
68
- return successHandler(success, complete)(res)
69
65
  }
70
66
 
71
67
  /**
@@ -78,7 +74,7 @@ export function setTabBarBadge (options = {}) {
78
74
  */
79
75
  export function removeTabBarBadge (options = {}) {
80
76
  // options must be an Object
81
- const isObject = shouleBeObject(options)
77
+ const isObject = shouldBeObject(options)
82
78
  if (!isObject.res) {
83
79
  const res = { errMsg: `removeTabBarBadge${isObject.msg}` }
84
80
  console.error(res.errMsg)
@@ -109,8 +105,6 @@ export function removeTabBarBadge (options = {}) {
109
105
  successHandler: successHandler(success, complete),
110
106
  errorHandler: errorHandler(fail, complete)
111
107
  })
112
-
113
- return successHandler(success, complete)(res)
114
108
  }
115
109
 
116
110
  /**
@@ -123,7 +117,7 @@ export function removeTabBarBadge (options = {}) {
123
117
  */
124
118
  export function showTabBarRedDot (options = {}) {
125
119
  // options must be an Object
126
- const isObject = shouleBeObject(options)
120
+ const isObject = shouldBeObject(options)
127
121
  if (!isObject.res) {
128
122
  const res = { errMsg: `showTabBarRedDot${isObject.msg}` }
129
123
  console.error(res.errMsg)
@@ -154,8 +148,6 @@ export function showTabBarRedDot (options = {}) {
154
148
  successHandler: successHandler(success, complete),
155
149
  errorHandler: errorHandler(fail, complete)
156
150
  })
157
-
158
- return successHandler(success, complete)(res)
159
151
  }
160
152
 
161
153
  /**
@@ -168,7 +160,7 @@ export function showTabBarRedDot (options = {}) {
168
160
  */
169
161
  export function hideTabBarRedDot (options = {}) {
170
162
  // options must be an Object
171
- const isObject = shouleBeObject(options)
163
+ const isObject = shouldBeObject(options)
172
164
  if (!isObject.res) {
173
165
  const res = { errMsg: `hideTabBarRedDot${isObject.msg}` }
174
166
  console.error(res.errMsg)
@@ -199,8 +191,6 @@ export function hideTabBarRedDot (options = {}) {
199
191
  successHandler: successHandler(success, complete),
200
192
  errorHandler: errorHandler(fail, complete)
201
193
  })
202
-
203
- return successHandler(success, complete)(res)
204
194
  }
205
195
 
206
196
  /**
@@ -213,7 +203,7 @@ export function hideTabBarRedDot (options = {}) {
213
203
  */
214
204
  export function showTabBar (options = {}) {
215
205
  // options must be an Object
216
- const isObject = shouleBeObject(options)
206
+ const isObject = shouldBeObject(options)
217
207
  if (!isObject.res) {
218
208
  const res = { errMsg: `showTabBar${isObject.msg}` }
219
209
  console.error(res.errMsg)
@@ -245,8 +235,6 @@ export function showTabBar (options = {}) {
245
235
  successHandler: successHandler(success, complete),
246
236
  errorHandler: errorHandler(success, complete)
247
237
  })
248
-
249
- return successHandler(success, complete)(res)
250
238
  }
251
239
 
252
240
  /**
@@ -259,7 +247,7 @@ export function showTabBar (options = {}) {
259
247
  */
260
248
  export function hideTabBar (options = {}) {
261
249
  // options must be an Object
262
- const isObject = shouleBeObject(options)
250
+ const isObject = shouldBeObject(options)
263
251
  if (!isObject.res) {
264
252
  const res = { errMsg: `hideTabBar${isObject.msg}` }
265
253
  console.error(res.errMsg)
@@ -291,8 +279,6 @@ export function hideTabBar (options = {}) {
291
279
  successHandler: successHandler(success, complete),
292
280
  errorHandler: errorHandler(success, complete)
293
281
  })
294
-
295
- return successHandler(success, complete)(res)
296
282
  }
297
283
 
298
284
  /**
@@ -308,7 +294,7 @@ export function hideTabBar (options = {}) {
308
294
  */
309
295
  export function setTabBarStyle (options = {}) {
310
296
  // options must be an Object
311
- const isObject = shouleBeObject(options)
297
+ const isObject = shouldBeObject(options)
312
298
  if (!isObject.res) {
313
299
  const res = { errMsg: `setTabBarStyle${isObject.msg}` }
314
300
  console.error(res.errMsg)
@@ -353,10 +339,14 @@ export function setTabBarStyle (options = {}) {
353
339
  if (backgroundColor) obj.backgroundColor = backgroundColor
354
340
  if (borderStyle) obj.borderStyle = borderStyle
355
341
 
356
- const temp = Object.assign({}, tabConf, obj)
357
- App.setState && App.setState({ __tabs: temp })
358
-
359
- return successHandler(success, complete)(res)
342
+ Taro.eventCenter.trigger('__taroSetTabBarStyle', {
343
+ color,
344
+ selectedColor,
345
+ backgroundColor,
346
+ borderStyle,
347
+ successHandler: successHandler(success, complete),
348
+ errorHandler: errorHandler(success, complete)
349
+ })
360
350
  }
361
351
 
362
352
  /**
@@ -372,7 +362,7 @@ export function setTabBarStyle (options = {}) {
372
362
  */
373
363
  export function setTabBarItem (options = {}) {
374
364
  // options must be an Object
375
- const isObject = shouleBeObject(options)
365
+ const isObject = shouldBeObject(options)
376
366
  if (!isObject.res) {
377
367
  const res = { errMsg: `setTabBarItem${isObject.msg}` }
378
368
  console.error(res.errMsg)
@@ -401,24 +391,12 @@ export function setTabBarItem (options = {}) {
401
391
  return errorHandler(fail, complete)(res)
402
392
  }
403
393
 
404
- if (
405
- !tabConf ||
406
- !tabConf.list ||
407
- !tabConf.list[index]
408
- ) {
409
- res.errMsg = 'setTabBarItem:fail tabbar item not found'
410
- return errorHandler(fail, complete)(res)
411
- }
412
-
413
- const obj = {}
414
- if (text) obj.text = text
415
- if (iconPath) obj.iconPath = iconPath
416
- if (selectedIconPath) obj.selectedIconPath = selectedIconPath
417
-
418
- const temp = Object.assign({}, tabConf)
419
- temp.list[index] = Object.assign({}, temp.list[index], obj)
420
-
421
- App.setState && App.setState({ __tabs: temp })
422
-
423
- return successHandler(success, complete)(res)
394
+ Taro.eventCenter.trigger('__taroSetTabBarItem', {
395
+ index,
396
+ text,
397
+ iconPath,
398
+ selectedIconPath,
399
+ successHandler: successHandler(success, complete),
400
+ errorHandler: errorHandler(success, complete)
401
+ })
424
402
  }
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable prefer-promise-reject-errors */
2
2
  import { Current, container, SERVICE_IDENTIFIER } from '@tarojs/runtime'
3
3
 
4
- function shouleBeObject (target) {
4
+ function shouldBeObject (target) {
5
5
  if (target && typeof target === 'object') return { res: true }
6
6
  return {
7
7
  res: false,
@@ -229,7 +229,7 @@ const getTimingFunc = (easeFunc, frameCnt) => {
229
229
  }
230
230
 
231
231
  export {
232
- shouleBeObject,
232
+ shouldBeObject,
233
233
  getParameterError,
234
234
  inlineStyle,
235
235
  setTransform,
@@ -1,4 +1,4 @@
1
- import { shouleBeObject, getParameterError, findDOM } from '../utils'
1
+ import { shouldBeObject, getParameterError, findDOM } from '../utils'
2
2
 
3
3
  /**
4
4
  * @typedef {Object} ChooseVideoParam
@@ -18,7 +18,7 @@ import { shouleBeObject, getParameterError, findDOM } from '../utils'
18
18
  export function chooseVideo (options) {
19
19
  // options must be an Object
20
20
 
21
- const isObject = shouleBeObject(options)
21
+ const isObject = shouldBeObject(options)
22
22
  if (!isObject.res) {
23
23
  const res = { errMsg: `chooseVideo${isObject.msg}` }
24
24
  console.error(res.errMsg)
@@ -1,5 +1,5 @@
1
1
  import SocketTask from './socketTask'
2
- import { shouleBeObject, getParameterError } from '../utils'
2
+ import { shouldBeObject, getParameterError } from '../utils'
3
3
 
4
4
  let socketTasks = []
5
5
  let socketsCounter = 1
@@ -9,7 +9,7 @@ function connectSocket (options) {
9
9
 
10
10
  return new Promise((resolve, reject) => {
11
11
  // options must be an Object
12
- const isObject = shouleBeObject(options)
12
+ const isObject = shouldBeObject(options)
13
13
  if (!isObject.res) {
14
14
  const res = { errMsg: `${name}${isObject.msg}` }
15
15
  console.error(res.errMsg)
package/src/taro/index.js CHANGED
@@ -85,7 +85,7 @@ const initPxTransform = getInitPxTransform(taro)
85
85
 
86
86
  const requirePlugin = permanentlyNotSupport('requirePlugin')
87
87
  const getApp = function () {
88
- return taro._$app
88
+ return getCurrentInstance().app
89
89
  }
90
90
 
91
91
  const pxTransform = function (size) {