@tarojs/taro-h5 3.4.0-beta.2 → 3.4.2

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 (168) 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 +5 -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.js +187 -0
  11. package/dist/api/base/update.js +4 -0
  12. package/dist/api/base/weapp/app-event.js +18 -0
  13. package/dist/api/base/weapp/life-cycle.js +4 -0
  14. package/dist/api/canvas/CanvasContext.js +191 -0
  15. package/dist/api/canvas/canvasGetImageData.js +25 -0
  16. package/dist/api/canvas/canvasPutImageData.js +22 -0
  17. package/dist/api/canvas/canvasToTempFilePath.js +22 -0
  18. package/dist/api/canvas/createCanvasContext.js +16 -0
  19. package/dist/api/canvas/index.js +12 -0
  20. package/dist/api/cloud/index.js +21 -0
  21. package/dist/api/data-analysis/index.js +5 -0
  22. package/dist/api/device/accelerometer.js +83 -0
  23. package/dist/api/device/accessibility.js +3 -0
  24. package/dist/api/device/battery.js +21 -0
  25. package/dist/api/device/bluetooth-ble.js +18 -0
  26. package/dist/api/device/bluetooth-peripheral.js +5 -0
  27. package/dist/api/device/bluetooth.js +15 -0
  28. package/dist/api/device/calendar.js +4 -0
  29. package/dist/api/device/clipboard.js +65 -0
  30. package/dist/api/device/compass.js +64 -0
  31. package/dist/api/device/contact.js +4 -0
  32. package/dist/api/device/crypto.js +3 -0
  33. package/dist/api/device/gyroscope.js +6 -0
  34. package/dist/api/device/iBeacon.js +9 -0
  35. package/dist/api/device/index.js +23 -0
  36. package/dist/api/device/keyboard.js +6 -0
  37. package/dist/api/device/memory.js +4 -0
  38. package/dist/api/device/motion.js +81 -0
  39. package/dist/api/device/network.js +78 -0
  40. package/dist/api/device/nfc.js +9 -0
  41. package/dist/api/device/phone.js +24 -0
  42. package/dist/api/device/scan.js +6 -0
  43. package/dist/api/device/screen.js +8 -0
  44. package/dist/api/device/vibrate.js +35 -0
  45. package/dist/api/device/wifi.js +13 -0
  46. package/dist/api/ext/index.js +4 -0
  47. package/dist/api/files/index.js +10 -0
  48. package/dist/api/framework/index.js +7 -0
  49. package/dist/api/index.js +24 -0
  50. package/dist/api/location/chooseLocation.js +93 -0
  51. package/dist/api/location/index.js +13 -0
  52. package/dist/api/location/style.css +79 -0
  53. package/dist/api/media/EditorContext.js +19 -0
  54. package/dist/api/media/audio/InnerAudioContext.js +84 -0
  55. package/dist/api/media/audio/index.js +15 -0
  56. package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
  57. package/dist/api/media/background-audio/index.js +15 -0
  58. package/dist/api/media/camera.js +3 -0
  59. package/dist/api/media/image/chooseImage.js +74 -0
  60. package/dist/api/media/image/getImageInfo.js +31 -0
  61. package/dist/api/media/image/index.js +9 -0
  62. package/dist/api/media/image/previewImage.js +67 -0
  63. package/dist/api/media/index.js +12 -0
  64. package/dist/api/media/live.js +4 -0
  65. package/dist/api/media/map.js +3 -0
  66. package/dist/api/media/media-recorder.js +3 -0
  67. package/dist/api/media/recorder.js +5 -0
  68. package/dist/api/media/video/index.js +74 -0
  69. package/dist/api/media/video-decoder.js +3 -0
  70. package/dist/api/media/video-processing.js +3 -0
  71. package/dist/api/media/voip.js +16 -0
  72. package/dist/api/navigate/index.js +6 -0
  73. package/dist/api/network/download.js +124 -0
  74. package/dist/api/network/index.js +7 -0
  75. package/dist/api/network/mdns.js +12 -0
  76. package/dist/api/network/request/index.js +125 -0
  77. package/dist/api/network/tcp.js +3 -0
  78. package/dist/api/network/udp.js +3 -0
  79. package/dist/api/network/upload.js +146 -0
  80. package/dist/api/network/utils.js +65 -0
  81. package/dist/api/network/websocket/index.js +70 -0
  82. package/dist/api/network/websocket/socketTask.js +63 -0
  83. package/dist/api/open-api/account.js +3 -0
  84. package/dist/api/open-api/address.js +3 -0
  85. package/dist/api/open-api/authorize.js +4 -0
  86. package/dist/api/open-api/card.js +4 -0
  87. package/dist/api/open-api/channels-live.js +8 -0
  88. package/dist/api/open-api/customer-service.js +3 -0
  89. package/dist/api/open-api/facial.js +6 -0
  90. package/dist/api/open-api/favorites.js +4 -0
  91. package/dist/api/open-api/group.js +3 -0
  92. package/dist/api/open-api/index.js +18 -0
  93. package/dist/api/open-api/invoice.js +4 -0
  94. package/dist/api/open-api/license-plate.js +3 -0
  95. package/dist/api/open-api/login.js +5 -0
  96. package/dist/api/open-api/red-package.js +3 -0
  97. package/dist/api/open-api/settings.js +4 -0
  98. package/dist/api/open-api/soter.js +5 -0
  99. package/dist/api/open-api/subscribe-message.js +3 -0
  100. package/dist/api/open-api/user-info.js +4 -0
  101. package/dist/api/open-api/werun.js +4 -0
  102. package/dist/api/payment/index.js +4 -0
  103. package/dist/api/route/index.js +3 -0
  104. package/dist/api/share/index.js +12 -0
  105. package/dist/api/storage/background-fetch.js +6 -0
  106. package/dist/api/storage/index.js +157 -0
  107. package/dist/api/swan/index.js +26 -0
  108. package/dist/api/taro.js +47 -0
  109. package/dist/api/ui/animation/index.js +288 -0
  110. package/dist/api/ui/background.js +4 -0
  111. package/dist/api/ui/custom-component.js +3 -0
  112. package/dist/api/ui/fonts.js +51 -0
  113. package/dist/api/ui/index.js +12 -0
  114. package/dist/api/ui/interaction/actionSheet.js +188 -0
  115. package/dist/api/ui/interaction/index.js +268 -0
  116. package/dist/api/ui/interaction/modal.js +207 -0
  117. package/dist/api/ui/interaction/toast.js +195 -0
  118. package/dist/api/ui/menu.js +3 -0
  119. package/dist/api/ui/navigation-bar/index.js +42 -0
  120. package/dist/api/ui/pull-down-refresh.js +26 -0
  121. package/dist/api/ui/scroll/index.js +83 -0
  122. package/dist/api/ui/sticky.js +3 -0
  123. package/dist/api/ui/tab-bar.js +282 -0
  124. package/dist/api/ui/window.js +31 -0
  125. package/dist/api/utils/handler.js +80 -0
  126. package/dist/api/utils/index.js +172 -0
  127. package/dist/api/worker/index.js +3 -0
  128. package/dist/api/wxml/index.js +6 -0
  129. package/dist/api/wxml/nodesRef.js +42 -0
  130. package/dist/api/wxml/selectorQuery.js +201 -0
  131. package/dist/index.cjs.js +5028 -6988
  132. package/dist/index.js +4 -10767
  133. package/dist/taroApis.js +1 -1
  134. package/dist/types/type.js +2 -0
  135. package/package.json +11 -13
  136. package/src/api/ai/visual.ts +3 -0
  137. package/src/api/base/system.ts +207 -0
  138. package/src/api/canvas/CanvasContext.ts +42 -39
  139. package/src/api/canvas/createCanvasContext.ts +2 -2
  140. package/src/api/canvas/index.ts +10 -2
  141. package/src/api/cloud/index.ts +4 -0
  142. package/src/api/device/battery.ts +18 -1
  143. package/src/api/device/index.ts +1 -0
  144. package/src/api/{base/system → device}/network.ts +35 -15
  145. package/src/api/device/wifi.ts +1 -0
  146. package/src/api/location/chooseLocation.ts +2 -2
  147. package/src/api/media/{editor.ts → EditorContext.ts} +2 -0
  148. package/src/api/media/audio/InnerAudioContext.ts +98 -0
  149. package/src/api/media/audio/index.ts +1 -86
  150. package/src/api/media/background-audio/BackgroundAudioManager.ts +103 -0
  151. package/src/api/media/{background-audio.ts → background-audio/index.ts} +7 -2
  152. package/src/api/media/image/previewImage.ts +4 -25
  153. package/src/api/media/index.ts +0 -1
  154. package/src/api/network/download.ts +5 -5
  155. package/src/api/network/upload.ts +7 -13
  156. package/src/api/network/websocket/index.ts +1 -1
  157. package/src/api/ui/animation/index.ts +11 -12
  158. package/src/api/ui/fonts.ts +61 -2
  159. package/src/api/ui/interaction/index.ts +12 -10
  160. package/src/api/ui/navigation-bar/index.ts +2 -2
  161. package/src/api/ui/scroll/index.ts +3 -3
  162. package/src/api/utils/handler.ts +4 -4
  163. package/src/api/utils/index.ts +34 -13
  164. package/src/api/wxml/nodesRef.ts +10 -3
  165. package/src/api/wxml/selectorQuery.ts +68 -23
  166. package/src/index.ts +2 -2
  167. package/src/api/base/system/index.ts +0 -2
  168. package/src/api/base/system/info.ts +0 -64
@@ -0,0 +1,24 @@
1
+ export * from './ad';
2
+ export * from './ai';
3
+ export * from './base';
4
+ export * from './canvas';
5
+ export * from './cloud';
6
+ export * from './data-analysis';
7
+ export * from './device';
8
+ export * from './ext';
9
+ export * from './files';
10
+ export * from './framework';
11
+ export * from './location';
12
+ export * from './media';
13
+ export * from './navigate';
14
+ export * from './network';
15
+ export * from './open-api';
16
+ export * from './payment';
17
+ export * from './route';
18
+ export * from './share';
19
+ export * from './storage';
20
+ export * from './ui';
21
+ export * from './worker';
22
+ export * from './wxml';
23
+ export * from './alipay';
24
+ export * from './swan';
@@ -0,0 +1,93 @@
1
+ import { MethodHandler } from '../utils/handler';
2
+ import './style.css';
3
+ function createLocationChooser(handler, key = LOCATION_APIKEY) {
4
+ var _a, _b;
5
+ const html = `
6
+ <div class='taro_choose_location'>
7
+ <div class='taro_choose_location_bar'>
8
+ <div class='taro_choose_location_back'></div>
9
+ <p class='taro_choose_location_title'>位置</p>
10
+ <button class='taro_choose_location_submit'>完成</button>
11
+ </div>
12
+ <iframe class='taro_choose_location_frame' frameborder='0' src='https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=myapp'></iframe>
13
+ </div>
14
+ `;
15
+ const container = document.createElement('div');
16
+ container.innerHTML = html;
17
+ const main = container.querySelector('.taro_choose_location');
18
+ function show() {
19
+ setTimeout(() => {
20
+ main.style.top = '0';
21
+ });
22
+ }
23
+ function hide() {
24
+ main.style.top = '100%';
25
+ }
26
+ function back() {
27
+ hide();
28
+ handler({ errMsg: 'cancel' });
29
+ }
30
+ function submit() {
31
+ hide();
32
+ handler();
33
+ }
34
+ function remove() {
35
+ container.remove();
36
+ window.removeEventListener('popstate', back);
37
+ }
38
+ (_a = container.querySelector('.taro_choose_location_back')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', back);
39
+ (_b = container.querySelector('.taro_choose_location_submit')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', submit);
40
+ window.addEventListener('popstate', back);
41
+ return {
42
+ show,
43
+ remove,
44
+ container
45
+ };
46
+ }
47
+ /**
48
+ * 打开地图选择位置。
49
+ */
50
+ export const chooseLocation = ({ success, fail, complete } = {}) => {
51
+ const key = LOCATION_APIKEY;
52
+ const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
53
+ return new Promise((resolve, reject) => {
54
+ const chooseLocation = {};
55
+ if (!key) {
56
+ console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
57
+ return handle.fail({
58
+ errMsg: 'LOCATION_APIKEY needed'
59
+ }, reject);
60
+ }
61
+ const onMessage = event => {
62
+ // 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
63
+ const loc = event.data;
64
+ // 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
65
+ if (!loc || loc.module !== 'locationPicker')
66
+ return;
67
+ chooseLocation.name = loc.poiname;
68
+ chooseLocation.address = loc.poiaddress;
69
+ chooseLocation.latitude = loc.latlng.lat;
70
+ chooseLocation.longitude = loc.latlng.lng;
71
+ };
72
+ const chooser = createLocationChooser(res => {
73
+ window.removeEventListener('message', onMessage, false);
74
+ setTimeout(() => {
75
+ chooser.remove();
76
+ }, 300);
77
+ if (res) {
78
+ return handle.fail(res, reject);
79
+ }
80
+ else {
81
+ if (chooseLocation.latitude && chooseLocation.longitude) {
82
+ return handle.success(chooseLocation, resolve);
83
+ }
84
+ else {
85
+ return handle.fail({}, reject);
86
+ }
87
+ }
88
+ }, key);
89
+ document.body.appendChild(chooser.container);
90
+ window.addEventListener('message', onMessage, false);
91
+ chooser.show();
92
+ });
93
+ };
@@ -0,0 +1,13 @@
1
+ import { processOpenApi, temporarilyNotSupport } from '../utils/index';
2
+ // 位置
3
+ export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate');
4
+ export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground');
5
+ export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate');
6
+ export const openLocation = processOpenApi('openLocation', { scale: 18 });
7
+ export const onLocationChangeError = temporarilyNotSupport('onLocationChangeError');
8
+ export const onLocationChange = temporarilyNotSupport('onLocationChange');
9
+ export const offLocationChangeError = temporarilyNotSupport('offLocationChangeError');
10
+ export const offLocationChange = temporarilyNotSupport('offLocationChange');
11
+ export const getLocation = processOpenApi('getLocation');
12
+ export const choosePoi = temporarilyNotSupport('choosePoi');
13
+ export * from './chooseLocation';
@@ -0,0 +1,79 @@
1
+ .taro_choose_location {
2
+ position: fixed;
3
+ display: flex;
4
+ flex-direction: column;
5
+ width: 100%;
6
+ height: 100%;
7
+ top: 100%;
8
+ background-color: #fff;
9
+ transition: ease top .3s;
10
+ z-index: 1;
11
+ }
12
+
13
+ .taro_choose_location_bar {
14
+ display: flex;
15
+ flex: 0 95px;
16
+ height: 95px;
17
+ background-color: #ededed;
18
+ color: #090909;
19
+ }
20
+
21
+ .taro_choose_location_back {
22
+ flex: 0 45px;
23
+ position: relative;
24
+ width: 33px;
25
+ height: 30px;
26
+ margin-top: 30px;
27
+ }
28
+
29
+ .taro_choose_location_back::before {
30
+ content: '';
31
+ position: absolute;
32
+ top: 0;
33
+ left: 0;
34
+ display: block;
35
+ width: 0;
36
+ height: 0;
37
+ border: solid 15px;
38
+ border-top-color: transparent;
39
+ border-right-color: #090909;
40
+ border-bottom-color: transparent;
41
+ border-left-color: transparent;
42
+ }
43
+
44
+ .taro_choose_location_back::after {
45
+ content: '';
46
+ position: absolute;
47
+ display: block;
48
+ width: 0;
49
+ height: 0;
50
+ top: 0;
51
+ left: 3px;
52
+ border: solid 15px;
53
+ border-top-color: transparent;
54
+ border-right-color: #ededed;
55
+ border-bottom-color: transparent;
56
+ border-left-color: transparent;
57
+ }
58
+
59
+ .taro_choose_location_title {
60
+ flex: 1;
61
+ line-height: 95px;
62
+ padding-left: 30px;
63
+ }
64
+
65
+ .taro_choose_location_submit {
66
+ width: 110px;
67
+ height: 60px;
68
+ color: #fff;
69
+ background-color: #08bf62;
70
+ border: none;
71
+ font-size: 28px;
72
+ line-height: 60px;
73
+ padding: 0;
74
+ margin: 18px 30px 0 0;
75
+ }
76
+
77
+ .taro_choose_location_frame {
78
+ flex: 1;
79
+ }
@@ -0,0 +1,19 @@
1
+ import { temporarilyNotSupport } from '../utils';
2
+ // 富文本
3
+ export class EditorContext {
4
+ constructor() {
5
+ this.blur = temporarilyNotSupport('EditorContext.blur');
6
+ this.clear = temporarilyNotSupport('EditorContext.clear');
7
+ this.format = temporarilyNotSupport('EditorContext.format');
8
+ this.getContents = temporarilyNotSupport('EditorContext.getContents');
9
+ this.getSelectionText = temporarilyNotSupport('EditorContext.getSelectionText');
10
+ this.insertDivider = temporarilyNotSupport('EditorContext.insertDivider');
11
+ this.insertImage = temporarilyNotSupport('EditorContext.insertImage');
12
+ this.insertText = temporarilyNotSupport('EditorContext.insertText');
13
+ this.redo = temporarilyNotSupport('EditorContext.redo');
14
+ this.removeFormat = temporarilyNotSupport('EditorContext.removeFormat');
15
+ this.scrollIntoView = temporarilyNotSupport('EditorContext.scrollIntoView');
16
+ this.setContents = temporarilyNotSupport('EditorContext.setContents');
17
+ this.undo = temporarilyNotSupport('EditorContext.undo');
18
+ }
19
+ }
@@ -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');