@tarojs/taro-h5 3.4.0-beta.1 → 3.4.1

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 (158) hide show
  1. package/dist/api/ad/index.js +4 -0
  2. package/dist/api/ai/facial.js +5 -0
  3. package/dist/api/ai/index.js +2 -0
  4. package/dist/api/ai/visual.js +3 -0
  5. package/dist/api/alipay/index.js +3 -0
  6. package/dist/api/base/crypto.js +3 -0
  7. package/dist/api/base/debug.js +4 -0
  8. package/dist/api/base/index.js +17 -0
  9. package/dist/api/base/performance.js +4 -0
  10. package/dist/api/base/system/index.js +2 -0
  11. package/dist/api/base/system/info.js +57 -0
  12. package/dist/api/base/system/network.js +63 -0
  13. package/dist/api/base/update.js +4 -0
  14. package/dist/api/base/weapp/app-event.js +18 -0
  15. package/dist/api/base/weapp/life-cycle.js +4 -0
  16. package/dist/api/canvas/CanvasContext.js +191 -0
  17. package/dist/api/canvas/canvasGetImageData.js +25 -0
  18. package/dist/api/canvas/canvasPutImageData.js +22 -0
  19. package/dist/api/canvas/canvasToTempFilePath.js +22 -0
  20. package/dist/api/canvas/createCanvasContext.js +16 -0
  21. package/dist/api/canvas/index.js +8 -0
  22. package/dist/api/cloud/index.js +21 -0
  23. package/dist/api/data-analysis/index.js +5 -0
  24. package/dist/api/device/accelerometer.js +83 -0
  25. package/dist/api/device/accessibility.js +3 -0
  26. package/dist/api/device/battery.js +4 -0
  27. package/dist/api/device/bluetooth-ble.js +18 -0
  28. package/dist/api/device/bluetooth-peripheral.js +5 -0
  29. package/dist/api/device/bluetooth.js +15 -0
  30. package/dist/api/device/calendar.js +4 -0
  31. package/dist/api/device/clipboard.js +65 -0
  32. package/dist/api/device/compass.js +64 -0
  33. package/dist/api/device/contact.js +4 -0
  34. package/dist/api/device/crypto.js +3 -0
  35. package/dist/api/device/gyroscope.js +6 -0
  36. package/dist/api/device/iBeacon.js +9 -0
  37. package/dist/api/device/index.js +22 -0
  38. package/dist/api/device/keyboard.js +6 -0
  39. package/dist/api/device/memory.js +4 -0
  40. package/dist/api/device/motion.js +81 -0
  41. package/dist/api/device/nfc.js +9 -0
  42. package/dist/api/device/phone.js +24 -0
  43. package/dist/api/device/scan.js +6 -0
  44. package/dist/api/device/screen.js +8 -0
  45. package/dist/api/device/vibrate.js +35 -0
  46. package/dist/api/device/wifi.js +12 -0
  47. package/dist/api/ext/index.js +4 -0
  48. package/dist/api/files/index.js +10 -0
  49. package/dist/api/framework/index.js +7 -0
  50. package/dist/api/index.js +24 -0
  51. package/dist/api/location/chooseLocation.js +93 -0
  52. package/dist/api/location/index.js +13 -0
  53. package/dist/api/location/style.css +79 -0
  54. package/dist/api/media/EditorContext.js +18 -0
  55. package/dist/api/media/audio/InnerAudioContext.js +84 -0
  56. package/dist/api/media/audio/index.js +15 -0
  57. package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
  58. package/dist/api/media/background-audio/index.js +15 -0
  59. package/dist/api/media/camera.js +3 -0
  60. package/dist/api/media/image/chooseImage.js +74 -0
  61. package/dist/api/media/image/getImageInfo.js +31 -0
  62. package/dist/api/media/image/index.js +9 -0
  63. package/dist/api/media/image/previewImage.js +67 -0
  64. package/dist/api/media/index.js +12 -0
  65. package/dist/api/media/live.js +4 -0
  66. package/dist/api/media/map.js +3 -0
  67. package/dist/api/media/media-recorder.js +3 -0
  68. package/dist/api/media/recorder.js +5 -0
  69. package/dist/api/media/video/index.js +74 -0
  70. package/dist/api/media/video-decoder.js +3 -0
  71. package/dist/api/media/video-processing.js +3 -0
  72. package/dist/api/media/voip.js +16 -0
  73. package/dist/api/navigate/index.js +6 -0
  74. package/dist/api/network/download.js +124 -0
  75. package/dist/api/network/index.js +7 -0
  76. package/dist/api/network/mdns.js +12 -0
  77. package/dist/api/network/request/index.js +125 -0
  78. package/dist/api/network/tcp.js +3 -0
  79. package/dist/api/network/udp.js +3 -0
  80. package/dist/api/network/upload.js +151 -0
  81. package/dist/api/network/utils.js +65 -0
  82. package/dist/api/network/websocket/index.js +70 -0
  83. package/dist/api/network/websocket/socketTask.js +63 -0
  84. package/dist/api/open-api/account.js +3 -0
  85. package/dist/api/open-api/address.js +3 -0
  86. package/dist/api/open-api/authorize.js +4 -0
  87. package/dist/api/open-api/card.js +4 -0
  88. package/dist/api/open-api/channels-live.js +8 -0
  89. package/dist/api/open-api/customer-service.js +3 -0
  90. package/dist/api/open-api/facial.js +6 -0
  91. package/dist/api/open-api/favorites.js +4 -0
  92. package/dist/api/open-api/group.js +3 -0
  93. package/dist/api/open-api/index.js +18 -0
  94. package/dist/api/open-api/invoice.js +4 -0
  95. package/dist/api/open-api/license-plate.js +3 -0
  96. package/dist/api/open-api/login.js +5 -0
  97. package/dist/api/open-api/red-package.js +3 -0
  98. package/dist/api/open-api/settings.js +4 -0
  99. package/dist/api/open-api/soter.js +5 -0
  100. package/dist/api/open-api/subscribe-message.js +3 -0
  101. package/dist/api/open-api/user-info.js +4 -0
  102. package/dist/api/open-api/werun.js +4 -0
  103. package/dist/api/payment/index.js +4 -0
  104. package/dist/api/route/index.js +3 -0
  105. package/dist/api/share/index.js +12 -0
  106. package/dist/api/storage/background-fetch.js +6 -0
  107. package/dist/api/storage/index.js +157 -0
  108. package/dist/api/swan/index.js +26 -0
  109. package/dist/api/taro.js +47 -0
  110. package/dist/api/ui/animation/index.js +288 -0
  111. package/dist/api/ui/background.js +4 -0
  112. package/dist/api/ui/custom-component.js +3 -0
  113. package/dist/api/ui/fonts.js +3 -0
  114. package/dist/api/ui/index.js +12 -0
  115. package/dist/api/ui/interaction/actionSheet.js +188 -0
  116. package/dist/api/ui/interaction/index.js +268 -0
  117. package/dist/api/ui/interaction/modal.js +207 -0
  118. package/dist/api/ui/interaction/toast.js +195 -0
  119. package/dist/api/ui/menu.js +3 -0
  120. package/dist/api/ui/navigation-bar/index.js +42 -0
  121. package/dist/api/ui/pull-down-refresh.js +26 -0
  122. package/dist/api/ui/scroll/index.js +83 -0
  123. package/dist/api/ui/sticky.js +3 -0
  124. package/dist/api/ui/tab-bar.js +282 -0
  125. package/dist/api/ui/window.js +31 -0
  126. package/dist/api/utils/handler.js +80 -0
  127. package/dist/api/utils/index.js +172 -0
  128. package/dist/api/worker/index.js +3 -0
  129. package/dist/api/wxml/index.js +6 -0
  130. package/dist/api/wxml/nodesRef.js +42 -0
  131. package/dist/api/wxml/selectorQuery.js +201 -0
  132. package/dist/index.cjs.js +4756 -6934
  133. package/dist/index.js +4 -10767
  134. package/dist/taroApis.js +1 -1
  135. package/dist/types/type.js +2 -0
  136. package/package.json +11 -13
  137. package/src/api/canvas/CanvasContext.ts +36 -33
  138. package/src/api/canvas/createCanvasContext.ts +2 -2
  139. package/src/api/cloud/index.ts +4 -0
  140. package/src/api/location/chooseLocation.ts +2 -2
  141. package/src/api/media/{editor.ts → EditorContext.ts} +0 -0
  142. package/src/api/media/audio/InnerAudioContext.ts +98 -0
  143. package/src/api/media/audio/index.ts +1 -86
  144. package/src/api/media/background-audio/BackgroundAudioManager.ts +103 -0
  145. package/src/api/media/{background-audio.ts → background-audio/index.ts} +7 -2
  146. package/src/api/media/image/previewImage.ts +4 -25
  147. package/src/api/media/index.ts +0 -1
  148. package/src/api/network/download.ts +5 -5
  149. package/src/api/network/upload.ts +6 -6
  150. package/src/api/network/websocket/index.ts +1 -1
  151. package/src/api/ui/animation/index.ts +11 -12
  152. package/src/api/ui/interaction/index.ts +12 -10
  153. package/src/api/ui/navigation-bar/index.ts +2 -2
  154. package/src/api/ui/scroll/index.ts +3 -3
  155. package/src/api/utils/index.ts +34 -13
  156. package/src/api/wxml/nodesRef.ts +10 -3
  157. package/src/api/wxml/selectorQuery.ts +68 -23
  158. package/src/index.ts +2 -2
@@ -0,0 +1,84 @@
1
+ import Taro from '@tarojs/api';
2
+ import { permanentlyNotSupport } from '../../utils';
3
+ import { CallbackManager } from '../../utils/handler';
4
+ export class InnerAudioContext {
5
+ constructor() {
6
+ this.__startTime = 0;
7
+ this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
8
+ this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
9
+ this.stop = () => {
10
+ this.pause();
11
+ this.seek(0);
12
+ this.stopStack.trigger();
13
+ };
14
+ this.seek = (position) => {
15
+ if (this.Instance) {
16
+ this.Instance.currentTime = position;
17
+ }
18
+ };
19
+ /**
20
+ * @TODO destroy得并不干净
21
+ */
22
+ this.destroy = () => {
23
+ this.stop();
24
+ if (this.Instance) {
25
+ document.body.removeChild(this.Instance);
26
+ this.Instance = undefined;
27
+ }
28
+ };
29
+ this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
30
+ this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
31
+ this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
32
+ this.onStop = (callback = () => { }) => this.stopStack.add(callback);
33
+ this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
34
+ this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
35
+ this.onError = (callback) => this.errorStack.add(callback);
36
+ this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
37
+ this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
38
+ this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
39
+ this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
40
+ this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
41
+ this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
42
+ this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
43
+ this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
44
+ this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
45
+ this.offError = (callback = () => { }) => this.errorStack.remove(callback);
46
+ this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
47
+ this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
48
+ this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
49
+ this.Instance = new Audio();
50
+ this.errorStack = new CallbackManager();
51
+ this.stopStack = new CallbackManager();
52
+ Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
53
+ this.onPlay(() => {
54
+ if (this.currentTime !== this.startTime) {
55
+ this.seek(this.startTime);
56
+ }
57
+ });
58
+ }
59
+ set autoplay(e) { this.setProperty('autoplay', e); }
60
+ get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
61
+ get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
62
+ get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
63
+ get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
64
+ set loop(e) { this.setProperty('loop', e); }
65
+ get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
66
+ get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
67
+ set src(e) { this.setProperty('src', e); }
68
+ get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
69
+ set volume(e) { this.setProperty('volume', e); }
70
+ get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
71
+ set playbackRate(e) { this.setProperty('playbackRate', e); }
72
+ get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
73
+ set obeyMuteSwitch(_e) { permanentlyNotSupport('InnerAudioContext.obeyMuteSwitch')(); }
74
+ get obeyMuteSwitch() { return true; }
75
+ set startTime(e) { this.__startTime = e; }
76
+ get startTime() { return this.__startTime || 0; }
77
+ set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
78
+ get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
79
+ setProperty(key, value) {
80
+ if (this.Instance) {
81
+ this.Instance[key] = value;
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,15 @@
1
+ import { temporarilyNotSupport } from '../../utils';
2
+ import { InnerAudioContext } from './InnerAudioContext';
3
+ // 音频
4
+ export const stopVoice = temporarilyNotSupport('stopVoice');
5
+ export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption');
6
+ export const playVoice = temporarilyNotSupport('playVoice');
7
+ export const pauseVoice = temporarilyNotSupport('pauseVoice');
8
+ export const getAvailableAudioSources = temporarilyNotSupport('getAvailableAudioSources');
9
+ export const createWebAudioContext = temporarilyNotSupport('createWebAudioContext');
10
+ export const createMediaAudioPlayer = temporarilyNotSupport('createMediaAudioPlayer');
11
+ /**
12
+ * 创建内部 audio 上下文 InnerAudioContext 对象。
13
+ */
14
+ export const createInnerAudioContext = () => new InnerAudioContext();
15
+ export const createAudioContext = temporarilyNotSupport('createAudioContext');
@@ -0,0 +1,86 @@
1
+ import { permanentlyNotSupport } from '../../utils';
2
+ import { CallbackManager } from '../../utils/handler';
3
+ export class BackgroundAudioManager {
4
+ constructor() {
5
+ this.__startTime = 0;
6
+ this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
7
+ this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
8
+ this.seek = (position) => {
9
+ if (this.Instance) {
10
+ this.Instance.currentTime = position;
11
+ }
12
+ };
13
+ this.stop = () => {
14
+ this.pause();
15
+ this.seek(0);
16
+ this.stopStack.trigger();
17
+ };
18
+ this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
19
+ this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
20
+ this.onError = (callback) => this.errorStack.add(callback);
21
+ this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
22
+ this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
23
+ this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
24
+ this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
25
+ this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
26
+ this.onStop = (callback = () => { }) => this.stopStack.add(callback);
27
+ this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
28
+ this.onPrev = permanentlyNotSupport('BackgroundAudioManager.onPrev');
29
+ this.onNext = permanentlyNotSupport('BackgroundAudioManager.onNext');
30
+ this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
31
+ this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
32
+ this.offError = (callback = () => { }) => this.errorStack.remove(callback);
33
+ this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
34
+ this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
35
+ this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
36
+ this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
37
+ this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
38
+ this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
39
+ this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
40
+ this.offPrev = permanentlyNotSupport('BackgroundAudioManager.offPrev');
41
+ this.offNext = permanentlyNotSupport('BackgroundAudioManager.offNext');
42
+ this.Instance = new Audio();
43
+ this.errorStack = new CallbackManager();
44
+ this.stopStack = new CallbackManager();
45
+ this.Instance.autoplay = true;
46
+ this.onPlay(() => {
47
+ if (this.currentTime !== this.startTime) {
48
+ this.seek(this.startTime);
49
+ }
50
+ });
51
+ }
52
+ set src(e) { this.setProperty('src', e); }
53
+ get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
54
+ set startTime(e) { this.__startTime = e; }
55
+ get startTime() { return this.__startTime || 0; }
56
+ set title(e) { this.dataset('title', e); }
57
+ get title() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.title) || ''; }
58
+ set epname(e) { this.dataset('epname', e); }
59
+ get epname() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.epname) || ''; }
60
+ set singer(e) { this.dataset('singer', e); }
61
+ get singer() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.singer) || ''; }
62
+ set coverImgUrl(e) { this.dataset('coverImgUrl', e); }
63
+ get coverImgUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.coverImgUrl) || ''; }
64
+ set webUrl(e) { this.dataset('webUrl', e); }
65
+ get webUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.webUrl) || ''; }
66
+ set protocol(e) { this.dataset('protocol', e); }
67
+ get protocol() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.protocol) || ''; }
68
+ set playbackRate(e) { this.setProperty('playbackRate', e); }
69
+ get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
70
+ get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
71
+ get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
72
+ get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || false; }
73
+ get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
74
+ set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
75
+ get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
76
+ setProperty(key, value) {
77
+ if (this.Instance) {
78
+ this.Instance[key] = value;
79
+ }
80
+ }
81
+ dataset(key, value) {
82
+ if (this.Instance) {
83
+ this.Instance.dataset[key] = value;
84
+ }
85
+ }
86
+ }
@@ -0,0 +1,15 @@
1
+ import { temporarilyNotSupport } from '../../utils';
2
+ import { BackgroundAudioManager } from './BackgroundAudioManager';
3
+ // 背景音频
4
+ export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio');
5
+ export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio');
6
+ export const playBackgroundAudio = temporarilyNotSupport('playBackgroundAudio');
7
+ export const pauseBackgroundAudio = temporarilyNotSupport('pauseBackgroundAudio');
8
+ export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioStop');
9
+ export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay');
10
+ export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause');
11
+ export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState');
12
+ /**
13
+ * 获取全局唯一的背景音频管理器
14
+ */
15
+ export const getBackgroundAudioManager = () => new BackgroundAudioManager();
@@ -0,0 +1,3 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 相机
3
+ export const createCameraContext = temporarilyNotSupport('createCameraContext');
@@ -0,0 +1,74 @@
1
+ import { MethodHandler } from '../../utils/handler';
2
+ import { shouldBeObject, getParameterError } from '../../utils';
3
+ /**
4
+ * 从本地相册选择图片或使用相机拍照。
5
+ */
6
+ export const chooseImage = function (options) {
7
+ // options must be an Object
8
+ const isObject = shouldBeObject(options);
9
+ if (!isObject.flag) {
10
+ const res = { errMsg: `chooseImage:fail ${isObject.msg}` };
11
+ console.error(res.errMsg);
12
+ return Promise.reject(res);
13
+ }
14
+ const { count = 1, success, fail, complete, imageId = 'taroChooseImage' } = options;
15
+ const handle = new MethodHandler({ name: 'chooseImage', success, fail, complete });
16
+ const res = {
17
+ tempFilePaths: [],
18
+ tempFiles: []
19
+ };
20
+ if (count && typeof count !== 'number') {
21
+ res.errMsg = getParameterError({
22
+ para: 'count',
23
+ correct: 'Number',
24
+ wrong: count
25
+ });
26
+ return handle.fail(res);
27
+ }
28
+ let el = document.getElementById(imageId);
29
+ if (!el) {
30
+ const obj = document.createElement('input');
31
+ obj.setAttribute('type', 'file');
32
+ obj.setAttribute('id', imageId);
33
+ if (count > 1) {
34
+ obj.setAttribute('multiple', 'multiple');
35
+ }
36
+ obj.setAttribute('accept', 'image/*');
37
+ obj.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
38
+ document.body.appendChild(obj);
39
+ el = document.getElementById(imageId);
40
+ }
41
+ else {
42
+ if (count > 1) {
43
+ el.setAttribute('multiple', 'multiple');
44
+ }
45
+ else {
46
+ el.removeAttribute('multiple');
47
+ }
48
+ }
49
+ return new Promise(resolve => {
50
+ const TaroMouseEvents = document.createEvent('MouseEvents');
51
+ TaroMouseEvents.initEvent('click', true, true);
52
+ if (el) {
53
+ el.dispatchEvent(TaroMouseEvents);
54
+ el.onchange = function (e) {
55
+ const target = e.target;
56
+ if (target) {
57
+ const files = target.files || [];
58
+ const arr = [...files];
59
+ arr && arr.forEach(item => {
60
+ var _a, _b;
61
+ const blob = new Blob([item], {
62
+ type: item.type
63
+ });
64
+ const url = URL.createObjectURL(blob);
65
+ (_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
66
+ (_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
67
+ });
68
+ handle.success(res, resolve);
69
+ target.value = '';
70
+ }
71
+ };
72
+ }
73
+ });
74
+ };
@@ -0,0 +1,31 @@
1
+ import { shouldBeObject } from '../../utils';
2
+ import { MethodHandler } from '../../utils/handler';
3
+ /**
4
+ * 获取图片信息。网络图片需先配置download域名才能生效。
5
+ */
6
+ export const getImageInfo = (options) => {
7
+ // options must be an Object
8
+ const isObject = shouldBeObject(options);
9
+ if (!isObject.flag) {
10
+ const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
11
+ console.error(res.errMsg);
12
+ return Promise.reject(res);
13
+ }
14
+ const { src, success, fail, complete } = options;
15
+ const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
16
+ return new Promise((resolve, reject) => {
17
+ const image = new Image();
18
+ image.onload = () => {
19
+ handle.success({
20
+ width: image.naturalWidth,
21
+ height: image.naturalHeight
22
+ }, resolve);
23
+ };
24
+ image.onerror = (e) => {
25
+ handle.fail({
26
+ errMsg: e.message
27
+ }, reject);
28
+ };
29
+ image.src = src;
30
+ });
31
+ };
@@ -0,0 +1,9 @@
1
+ import { temporarilyNotSupport } from '../../utils';
2
+ // 图片
3
+ export const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum');
4
+ export const previewMedia = temporarilyNotSupport('previewMedia');
5
+ export * from './previewImage';
6
+ export * from './getImageInfo';
7
+ export const compressImage = temporarilyNotSupport('compressImage');
8
+ export const chooseMessageFile = temporarilyNotSupport('chooseMessageFile');
9
+ export * from './chooseImage';
@@ -0,0 +1,67 @@
1
+ import { shouldBeObject } from '../../utils';
2
+ import { MethodHandler } from '../../utils/handler';
3
+ /**
4
+ * previewImage api基于开源的React组件[react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer)开发,感谢!
5
+ */
6
+ /**
7
+ * 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
8
+ */
9
+ export const previewImage = async (options) => {
10
+ function loadImage(url, loadFail) {
11
+ return new Promise((resolve) => {
12
+ const item = document.createElement('taro-swiper-item-core');
13
+ item.style.cssText = 'display:flex;align-items:start;justify-content:center;overflow-y:scroll;';
14
+ const image = new Image();
15
+ image.style.maxWidth = '100%';
16
+ image.src = url;
17
+ const div = document.createElement('div');
18
+ div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
19
+ div.appendChild(image);
20
+ item.appendChild(div);
21
+ // Note: 等待图片加载完后返回,会导致轮播被卡住
22
+ resolve(item);
23
+ if (typeof loadFail === 'function') {
24
+ image.addEventListener('error', (err) => {
25
+ loadFail({ errMsg: err.message });
26
+ });
27
+ }
28
+ });
29
+ }
30
+ // options must be an Object
31
+ const isObject = shouldBeObject(options);
32
+ if (!isObject.flag) {
33
+ const res = { errMsg: `previewImage:fail ${isObject.msg}` };
34
+ console.error(res.errMsg);
35
+ return Promise.reject(res);
36
+ }
37
+ const { urls = [], current = '', success, fail, complete } = options;
38
+ const handle = new MethodHandler({ name: 'previewImage', success, fail, complete });
39
+ const container = document.createElement('div');
40
+ container.classList.add('preview-image');
41
+ container.style.cssText = 'position:fixed;top:0;left:0;z-index:1050;width:100%;height:100%;overflow:hidden;outline:0;background-color:#111;';
42
+ container.addEventListener('click', () => {
43
+ container.remove();
44
+ });
45
+ const swiper = document.createElement('taro-swiper-core');
46
+ // @ts-ignore
47
+ swiper.full = true;
48
+ let children = [];
49
+ try {
50
+ children = await Promise.all(urls.map(e => loadImage(e, fail)));
51
+ }
52
+ catch (error) {
53
+ return handle.fail({
54
+ errMsg: error
55
+ });
56
+ }
57
+ for (let i = 0; i < children.length; i++) {
58
+ const child = children[i];
59
+ swiper.appendChild(child);
60
+ }
61
+ const currentIndex = urls.indexOf(current);
62
+ // @ts-ignore
63
+ swiper.current = currentIndex;
64
+ container.appendChild(swiper);
65
+ document.body.appendChild(container);
66
+ return handle.success();
67
+ };
@@ -0,0 +1,12 @@
1
+ export * from './audio';
2
+ export * from './background-audio';
3
+ export * from './camera';
4
+ export * from './image';
5
+ export * from './live';
6
+ export * from './map';
7
+ export * from './media-recorder';
8
+ export * from './recorder';
9
+ export * from './video';
10
+ export * from './video-decoder';
11
+ export * from './video-processing';
12
+ export * from './voip';
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 实时音视频
3
+ export const createLivePusherContext = temporarilyNotSupport('createLivePusherContext');
4
+ export const createLivePlayerContext = temporarilyNotSupport('createLivePlayerContext');
@@ -0,0 +1,3 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 地图
3
+ export const createMapContext = temporarilyNotSupport('createMapContext');
@@ -0,0 +1,3 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 画面录制器
3
+ export const createMediaRecorder = temporarilyNotSupport('createMediaRecorder');
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 录音
3
+ export const stopRecord = temporarilyNotSupport('stopRecord');
4
+ export const startRecord = temporarilyNotSupport('startRecord');
5
+ export const getRecorderManager = temporarilyNotSupport('getRecorderManager');
@@ -0,0 +1,74 @@
1
+ import { MethodHandler } from '../../utils/handler';
2
+ import { findDOM, shouldBeObject, temporarilyNotSupport } from '../../utils';
3
+ // 视频
4
+ export const saveVideoToPhotosAlbum = temporarilyNotSupport('saveVideoToPhotosAlbum');
5
+ export const openVideoEditor = temporarilyNotSupport('openVideoEditor');
6
+ export const getVideoInfo = temporarilyNotSupport('getVideoInfo');
7
+ /**
8
+ * 创建 video 上下文 VideoContext 对象。
9
+ */
10
+ export const createVideoContext = (id, inst) => {
11
+ const el = findDOM(inst);
12
+ // TODO HTMLVideoElement to VideoContext
13
+ return el === null || el === void 0 ? void 0 : el.querySelector(`taro-video-core[id=${id}]`);
14
+ };
15
+ export const compressVideo = temporarilyNotSupport('compressVideo');
16
+ /**
17
+ * 拍摄视频或从手机相册中选视频。
18
+ */
19
+ export const chooseVideo = (options) => {
20
+ // options must be an Object
21
+ const isObject = shouldBeObject(options);
22
+ if (!isObject.flag) {
23
+ const res = { errMsg: `chooseVideo:fail ${isObject.msg}` };
24
+ console.error(res.errMsg);
25
+ return Promise.reject(res);
26
+ }
27
+ const { success, fail, complete } = options;
28
+ const handle = new MethodHandler({ name: 'chooseVideo', success, fail, complete });
29
+ const res = {
30
+ tempFilePath: '',
31
+ duration: 0,
32
+ size: 0,
33
+ height: 0,
34
+ width: 0
35
+ };
36
+ const inputEl = document.createElement('input');
37
+ inputEl.setAttribute('type', 'file');
38
+ inputEl.setAttribute('multiple', 'multiple');
39
+ inputEl.setAttribute('accept', 'video/*');
40
+ inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
41
+ document.body.appendChild(inputEl);
42
+ return new Promise(resolve => {
43
+ const TaroMouseEvents = document.createEvent('MouseEvents');
44
+ TaroMouseEvents.initEvent('click', true, true);
45
+ inputEl.dispatchEvent(TaroMouseEvents);
46
+ inputEl.onchange = function (e) {
47
+ var _a;
48
+ const target = e.target;
49
+ const file = (_a = target.files) === null || _a === void 0 ? void 0 : _a[0];
50
+ const reader = new FileReader();
51
+ reader.onload = function (event) {
52
+ var _a;
53
+ const videoEl = document.createElement('video');
54
+ const url = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result;
55
+ videoEl.preload = 'metadata';
56
+ videoEl.src = url;
57
+ videoEl.onloadedmetadata = () => {
58
+ res.tempFilePath = url;
59
+ res.duration = videoEl.duration;
60
+ res.size = event.total;
61
+ res.height = videoEl.videoHeight;
62
+ res.width = videoEl.videoHeight;
63
+ return handle.success(res, resolve);
64
+ };
65
+ };
66
+ if (file) {
67
+ reader.readAsDataURL(file);
68
+ }
69
+ };
70
+ }).finally(() => {
71
+ document.body.removeChild(inputEl);
72
+ });
73
+ };
74
+ export const chooseMedia = temporarilyNotSupport('chooseMedia');
@@ -0,0 +1,3 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 视频解码器
3
+ export const createVideoDecoder = temporarilyNotSupport('createVideoDecoder');
@@ -0,0 +1,3 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 音视频合成
3
+ export const createMediaContainer = temporarilyNotSupport('createMediaContainer');
@@ -0,0 +1,16 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 实时语音
3
+ export const updateVoIPChatMuteConfig = temporarilyNotSupport('updateVoIPChatMuteConfig');
4
+ export const subscribeVoIPVideoMembers = temporarilyNotSupport('subscribeVoIPVideoMembers');
5
+ export const setEnable1v1Chat = temporarilyNotSupport('setEnable1v1Chat');
6
+ export const onVoIPVideoMembersChanged = temporarilyNotSupport('onVoIPVideoMembersChanged');
7
+ export const onVoIPChatStateChanged = temporarilyNotSupport('onVoIPChatStateChanged');
8
+ export const onVoIPChatSpeakersChanged = temporarilyNotSupport('onVoIPChatSpeakersChanged');
9
+ export const onVoIPChatMembersChanged = temporarilyNotSupport('onVoIPChatMembersChanged');
10
+ export const onVoIPChatInterrupted = temporarilyNotSupport('onVoIPChatInterrupted');
11
+ export const offVoIPVideoMembersChanged = temporarilyNotSupport('offVoIPVideoMembersChanged');
12
+ export const offVoIPChatStateChanged = temporarilyNotSupport('offVoIPChatStateChanged');
13
+ export const offVoIPChatMembersChanged = temporarilyNotSupport('offVoIPChatMembersChanged');
14
+ export const offVoIPChatInterrupted = temporarilyNotSupport('offVoIPChatInterrupted');
15
+ export const joinVoIPChat = temporarilyNotSupport('joinVoIPChat');
16
+ export const exitVoIPChat = temporarilyNotSupport('exitVoIPChat');
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 跳转
3
+ export const openEmbeddedMiniProgram = temporarilyNotSupport('openEmbeddedMiniProgram');
4
+ export const navigateToMiniProgram = temporarilyNotSupport('navigateToMiniProgram');
5
+ export const navigateBackMiniProgram = temporarilyNotSupport('navigateBackMiniProgram');
6
+ export const exitMiniProgram = temporarilyNotSupport('exitMiniProgram');