@tarojs/taro-h5 3.5.0-beta.2 → 3.5.0-beta.3
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/dist/api/base/weapp/app-event.js +55 -4
- package/dist/api/media/audio/InnerAudioContext.js +1 -1
- package/dist/index.cjs.js +53 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +54 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/api/base/weapp/app-event.ts +64 -4
- package/src/api/media/audio/InnerAudioContext.ts +1 -1
- package/src/api/network/websocket/socketTask.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-h5",
|
|
3
|
-
"version": "3.5.0-beta.
|
|
3
|
+
"version": "3.5.0-beta.3",
|
|
4
4
|
"description": "Taro h5 framework",
|
|
5
5
|
"browser": "dist/index.esm.js",
|
|
6
6
|
"main:h5": "dist/index.js",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"author": "O2Team",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tarojs/api": "3.5.0-beta.
|
|
37
|
-
"@tarojs/router": "3.5.0-beta.
|
|
38
|
-
"@tarojs/runtime": "3.5.0-beta.
|
|
36
|
+
"@tarojs/api": "3.5.0-beta.3",
|
|
37
|
+
"@tarojs/router": "3.5.0-beta.3",
|
|
38
|
+
"@tarojs/runtime": "3.5.0-beta.3",
|
|
39
39
|
"base64-js": "^1.3.0",
|
|
40
40
|
"jsonp-retry": "^1.0.3",
|
|
41
41
|
"mobile-detect": "^1.4.2",
|
|
42
42
|
"query-string": "^7.1.1",
|
|
43
43
|
"whatwg-fetch": "^3.4.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "bd1aa21707e51500eac9b16526e4ba4171fa8e5f"
|
|
46
46
|
}
|
|
@@ -1,4 +1,39 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import { parse } from 'query-string'
|
|
3
|
+
|
|
1
4
|
import { temporarilyNotSupport } from '../../../utils'
|
|
5
|
+
import { CallbackManager } from '../../../utils/handler'
|
|
6
|
+
|
|
7
|
+
const appShowCallbackManager = new CallbackManager()
|
|
8
|
+
const appHideCallbackManager = new CallbackManager()
|
|
9
|
+
|
|
10
|
+
const getApp = () => {
|
|
11
|
+
const path = Taro.Current.page?.path
|
|
12
|
+
return {
|
|
13
|
+
/** 小程序切前台的路径 */
|
|
14
|
+
path: path?.substring(0, path.indexOf('?')),
|
|
15
|
+
/** 小程序切前台的 query 参数 */
|
|
16
|
+
query: parse(location.search),
|
|
17
|
+
/** 来源信息。 */
|
|
18
|
+
referrerInfo: {},
|
|
19
|
+
/** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
20
|
+
scene: 0,
|
|
21
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
22
|
+
shareTicket: ''
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const appShowListener = () => {
|
|
27
|
+
if (document.visibilityState !== 'hidden') {
|
|
28
|
+
appShowCallbackManager.trigger(getApp())
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const appHideListener = () => {
|
|
33
|
+
if (document.visibilityState === 'hidden') {
|
|
34
|
+
appHideCallbackManager.trigger(getApp())
|
|
35
|
+
}
|
|
36
|
+
}
|
|
2
37
|
|
|
3
38
|
// 应用级事件
|
|
4
39
|
export const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection')
|
|
@@ -7,13 +42,38 @@ export const onPageNotFound = temporarilyNotSupport('onPageNotFound')
|
|
|
7
42
|
export const onError = temporarilyNotSupport('onError')
|
|
8
43
|
export const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd')
|
|
9
44
|
export const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin')
|
|
10
|
-
|
|
11
|
-
export const
|
|
45
|
+
|
|
46
|
+
export const onAppShow: typeof Taro.onAppShow = callback => {
|
|
47
|
+
appShowCallbackManager.add(callback)
|
|
48
|
+
if (appShowCallbackManager.count() === 1) {
|
|
49
|
+
window.addEventListener('visibilitychange', appShowListener)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const onAppHide: typeof Taro.onAppHide = callback => {
|
|
54
|
+
appHideCallbackManager.add(callback)
|
|
55
|
+
if (appHideCallbackManager.count() === 1) {
|
|
56
|
+
window.addEventListener('visibilitychange', appHideListener)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
12
60
|
export const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection')
|
|
13
61
|
export const offThemeChange = temporarilyNotSupport('offThemeChange')
|
|
14
62
|
export const offPageNotFound = temporarilyNotSupport('offPageNotFound')
|
|
15
63
|
export const offError = temporarilyNotSupport('offError')
|
|
16
64
|
export const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd')
|
|
17
65
|
export const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin')
|
|
18
|
-
|
|
19
|
-
export const
|
|
66
|
+
|
|
67
|
+
export const offAppShow: typeof Taro.offWindowResize = callback => {
|
|
68
|
+
appShowCallbackManager.remove(callback)
|
|
69
|
+
if (appShowCallbackManager.count() === 0) {
|
|
70
|
+
window.removeEventListener('visibilitychange', appShowListener)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const offAppHide: typeof Taro.offWindowResize = callback => {
|
|
75
|
+
appHideCallbackManager.remove(callback)
|
|
76
|
+
if (appHideCallbackManager.count() === 0) {
|
|
77
|
+
window.removeEventListener('visibilitychange', appHideListener)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -29,7 +29,7 @@ export class InnerAudioContext implements Taro.InnerAudioContext {
|
|
|
29
29
|
get duration () { return this.Instance?.duration || 0 }
|
|
30
30
|
set loop (e) { this.setProperty('loop', e) }
|
|
31
31
|
get loop () { return this.Instance?.loop || false }
|
|
32
|
-
get paused () { return this.Instance?.paused
|
|
32
|
+
get paused () { return this.Instance?.paused ?? true }
|
|
33
33
|
set src (e) { this.setProperty('src', e) }
|
|
34
34
|
get src () { return this.Instance?.src || '' }
|
|
35
35
|
set volume (e) { this.setProperty('volume', e) }
|