@tarojs/taro-h5 3.7.0-alpha.1 → 3.7.0-alpha.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.
Files changed (282) hide show
  1. package/dist/api/ad/index.js +2 -2
  2. package/dist/api/ad/index.js.map +1 -1
  3. package/dist/api/ai/facial.js +3 -3
  4. package/dist/api/ai/facial.js.map +1 -1
  5. package/dist/api/ai/index.d.ts +1 -0
  6. package/dist/api/ai/index.js +1 -0
  7. package/dist/api/ai/index.js.map +1 -1
  8. package/dist/api/ai/inference.d.ts +3 -0
  9. package/dist/api/ai/inference.js +8 -0
  10. package/dist/api/ai/inference.js.map +1 -0
  11. package/dist/api/ai/visual.js +2 -2
  12. package/dist/api/ai/visual.js.map +1 -1
  13. package/dist/api/alipay/index.js +1 -1
  14. package/dist/api/alipay/index.js.map +1 -1
  15. package/dist/api/base/crypto.js +1 -1
  16. package/dist/api/base/crypto.js.map +1 -1
  17. package/dist/api/base/debug.js +3 -3
  18. package/dist/api/base/debug.js.map +1 -1
  19. package/dist/api/base/index.d.ts +1 -2
  20. package/dist/api/base/index.js +6 -6
  21. package/dist/api/base/index.js.map +1 -1
  22. package/dist/api/base/performance.d.ts +4 -1
  23. package/dist/api/base/performance.js +6 -3
  24. package/dist/api/base/performance.js.map +1 -1
  25. package/dist/api/base/system.d.ts +4 -1
  26. package/dist/api/base/system.js +6 -3
  27. package/dist/api/base/system.js.map +1 -1
  28. package/dist/api/base/update.js +2 -2
  29. package/dist/api/base/update.js.map +1 -1
  30. package/dist/api/base/weapp/app-event.d.ts +13 -11
  31. package/dist/api/base/weapp/app-event.js +84 -14
  32. package/dist/api/base/weapp/app-event.js.map +1 -1
  33. package/dist/api/canvas/CanvasContext.d.ts +2 -1
  34. package/dist/api/canvas/CanvasContext.js.map +1 -1
  35. package/dist/api/canvas/index.js +1 -1
  36. package/dist/api/canvas/index.js.map +1 -1
  37. package/dist/api/data-analysis/index.js +4 -4
  38. package/dist/api/data-analysis/index.js.map +1 -1
  39. package/dist/api/device/accelerometer.js +1 -2
  40. package/dist/api/device/accelerometer.js.map +1 -1
  41. package/dist/api/device/accessibility.js +1 -1
  42. package/dist/api/device/accessibility.js.map +1 -1
  43. package/dist/api/device/battery.js +1 -1
  44. package/dist/api/device/battery.js.map +1 -1
  45. package/dist/api/device/bluetooth-ble.js +16 -16
  46. package/dist/api/device/bluetooth-ble.js.map +1 -1
  47. package/dist/api/device/bluetooth-peripheral.js +3 -3
  48. package/dist/api/device/bluetooth-peripheral.js.map +1 -1
  49. package/dist/api/device/bluetooth.js +13 -13
  50. package/dist/api/device/bluetooth.js.map +1 -1
  51. package/dist/api/device/calendar.d.ts +3 -2
  52. package/dist/api/device/calendar.js +142 -3
  53. package/dist/api/device/calendar.js.map +1 -1
  54. package/dist/api/device/compass.js +1 -2
  55. package/dist/api/device/compass.js.map +1 -1
  56. package/dist/api/device/contact.js +2 -2
  57. package/dist/api/device/contact.js.map +1 -1
  58. package/dist/api/device/crypto.js +1 -1
  59. package/dist/api/device/crypto.js.map +1 -1
  60. package/dist/api/device/gyroscope.js +4 -4
  61. package/dist/api/device/gyroscope.js.map +1 -1
  62. package/dist/api/device/iBeacon.js +7 -7
  63. package/dist/api/device/iBeacon.js.map +1 -1
  64. package/dist/api/device/index.d.ts +1 -0
  65. package/dist/api/device/index.js +3 -2
  66. package/dist/api/device/index.js.map +1 -1
  67. package/dist/api/device/keyboard.js +4 -4
  68. package/dist/api/device/keyboard.js.map +1 -1
  69. package/dist/api/device/memory.js +2 -2
  70. package/dist/api/device/memory.js.map +1 -1
  71. package/dist/api/device/motion.js +1 -2
  72. package/dist/api/device/motion.js.map +1 -1
  73. package/dist/api/device/network.js +3 -3
  74. package/dist/api/device/network.js.map +1 -1
  75. package/dist/api/device/nfc.js +7 -7
  76. package/dist/api/device/nfc.js.map +1 -1
  77. package/dist/api/device/scan.js +1 -1
  78. package/dist/api/device/scan.js.map +1 -1
  79. package/dist/api/device/screen.d.ts +4 -1
  80. package/dist/api/device/screen.js +10 -7
  81. package/dist/api/device/screen.js.map +1 -1
  82. package/dist/api/device/sms.d.ts +2 -0
  83. package/dist/api/device/sms.js +7 -0
  84. package/dist/api/device/sms.js.map +1 -0
  85. package/dist/api/device/wifi.d.ts +2 -1
  86. package/dist/api/device/wifi.js +13 -12
  87. package/dist/api/device/wifi.js.map +1 -1
  88. package/dist/api/ext/index.js +2 -2
  89. package/dist/api/ext/index.js.map +1 -1
  90. package/dist/api/files/index.js +8 -8
  91. package/dist/api/files/index.js.map +1 -1
  92. package/dist/api/framework/index.d.ts +1 -1
  93. package/dist/api/index.d.ts +1 -0
  94. package/dist/api/index.js +24 -14
  95. package/dist/api/index.js.map +1 -1
  96. package/dist/api/location/chooseLocation.js +9 -5
  97. package/dist/api/location/chooseLocation.js.map +1 -1
  98. package/dist/api/location/getLocation.js +1 -1
  99. package/dist/api/location/getLocation.js.map +1 -1
  100. package/dist/api/location/index.js +10 -10
  101. package/dist/api/location/index.js.map +1 -1
  102. package/dist/api/media/audio/InnerAudioContext.d.ts +2 -0
  103. package/dist/api/media/audio/InnerAudioContext.js +4 -1
  104. package/dist/api/media/audio/InnerAudioContext.js.map +1 -1
  105. package/dist/api/media/audio/index.js +8 -8
  106. package/dist/api/media/audio/index.js.map +1 -1
  107. package/dist/api/media/background-audio/index.js +8 -8
  108. package/dist/api/media/background-audio/index.js.map +1 -1
  109. package/dist/api/media/camera.js +1 -1
  110. package/dist/api/media/camera.js.map +1 -1
  111. package/dist/api/media/image/chooseImage.d.ts +1 -0
  112. package/dist/api/media/image/chooseImage.js +28 -71
  113. package/dist/api/media/image/chooseImage.js.map +1 -1
  114. package/dist/api/media/image/index.d.ts +6 -3
  115. package/dist/api/media/image/index.js +8 -7
  116. package/dist/api/media/image/index.js.map +1 -1
  117. package/dist/api/media/image/previewImage.js +5 -5
  118. package/dist/api/media/image/previewImage.js.map +1 -1
  119. package/dist/api/media/image/saveImageToPhotosAlbum.d.ts +3 -0
  120. package/dist/api/media/image/saveImageToPhotosAlbum.js +30 -0
  121. package/dist/api/media/image/saveImageToPhotosAlbum.js.map +1 -0
  122. package/dist/api/media/index.js +3 -3
  123. package/dist/api/media/live.js +2 -2
  124. package/dist/api/media/live.js.map +1 -1
  125. package/dist/api/media/map.js +1 -1
  126. package/dist/api/media/map.js.map +1 -1
  127. package/dist/api/media/media-recorder.js +1 -1
  128. package/dist/api/media/media-recorder.js.map +1 -1
  129. package/dist/api/media/recorder.js +3 -3
  130. package/dist/api/media/recorder.js.map +1 -1
  131. package/dist/api/media/video/chooseMedia.d.ts +6 -0
  132. package/dist/api/media/video/chooseMedia.js +208 -0
  133. package/dist/api/media/video/chooseMedia.js.map +1 -0
  134. package/dist/api/media/video/chooseVideo.d.ts +7 -0
  135. package/dist/api/media/video/chooseVideo.js +44 -0
  136. package/dist/api/media/video/chooseVideo.js.map +1 -0
  137. package/dist/api/media/video/getVideoInfo.d.ts +3 -0
  138. package/dist/api/media/video/getVideoInfo.js +63 -0
  139. package/dist/api/media/video/getVideoInfo.js.map +1 -0
  140. package/dist/api/media/video/index.d.ts +5 -8
  141. package/dist/api/media/video/index.js +8 -67
  142. package/dist/api/media/video/index.js.map +1 -1
  143. package/dist/api/media/video/saveVideoToPhotosAlbum.d.ts +3 -0
  144. package/dist/api/media/video/saveVideoToPhotosAlbum.js +30 -0
  145. package/dist/api/media/video/saveVideoToPhotosAlbum.js.map +1 -0
  146. package/dist/api/media/video-decoder.js +1 -1
  147. package/dist/api/media/video-decoder.js.map +1 -1
  148. package/dist/api/media/video-processing.js +1 -1
  149. package/dist/api/media/video-processing.js.map +1 -1
  150. package/dist/api/media/voip.d.ts +3 -1
  151. package/dist/api/media/voip.js +17 -15
  152. package/dist/api/media/voip.js.map +1 -1
  153. package/dist/api/navigate/index.js +5 -5
  154. package/dist/api/navigate/index.js.map +1 -1
  155. package/dist/api/network/mdns.js +10 -10
  156. package/dist/api/network/mdns.js.map +1 -1
  157. package/dist/api/network/request/index.d.ts +1 -1
  158. package/dist/api/network/request/index.js +23 -18
  159. package/dist/api/network/request/index.js.map +1 -1
  160. package/dist/api/network/tcp.js +1 -1
  161. package/dist/api/network/tcp.js.map +1 -1
  162. package/dist/api/network/udp.js +1 -1
  163. package/dist/api/network/udp.js.map +1 -1
  164. package/dist/api/network/upload.js.map +1 -1
  165. package/dist/api/open-api/account.js +1 -1
  166. package/dist/api/open-api/account.js.map +1 -1
  167. package/dist/api/open-api/address.js +1 -1
  168. package/dist/api/open-api/address.js.map +1 -1
  169. package/dist/api/open-api/authorize.js +2 -2
  170. package/dist/api/open-api/authorize.js.map +1 -1
  171. package/dist/api/open-api/card.js +2 -2
  172. package/dist/api/open-api/card.js.map +1 -1
  173. package/dist/api/open-api/channels-live.d.ts +3 -1
  174. package/dist/api/open-api/channels-live.js +9 -7
  175. package/dist/api/open-api/channels-live.js.map +1 -1
  176. package/dist/api/open-api/customer-service.js +1 -1
  177. package/dist/api/open-api/customer-service.js.map +1 -1
  178. package/dist/api/open-api/device-voip.d.ts +3 -0
  179. package/dist/api/open-api/device-voip.js +8 -0
  180. package/dist/api/open-api/device-voip.js.map +1 -0
  181. package/dist/api/open-api/facial.js +4 -4
  182. package/dist/api/open-api/facial.js.map +1 -1
  183. package/dist/api/open-api/favorites.js +3 -3
  184. package/dist/api/open-api/favorites.js.map +1 -1
  185. package/dist/api/open-api/group.js +1 -1
  186. package/dist/api/open-api/group.js.map +1 -1
  187. package/dist/api/open-api/index.d.ts +1 -0
  188. package/dist/api/open-api/index.js +3 -2
  189. package/dist/api/open-api/index.js.map +1 -1
  190. package/dist/api/open-api/invoice.js +2 -2
  191. package/dist/api/open-api/invoice.js.map +1 -1
  192. package/dist/api/open-api/license-plate.js +1 -1
  193. package/dist/api/open-api/license-plate.js.map +1 -1
  194. package/dist/api/open-api/login.js +3 -3
  195. package/dist/api/open-api/login.js.map +1 -1
  196. package/dist/api/open-api/red-package.js +1 -1
  197. package/dist/api/open-api/red-package.js.map +1 -1
  198. package/dist/api/open-api/settings.js +2 -2
  199. package/dist/api/open-api/settings.js.map +1 -1
  200. package/dist/api/open-api/soter.js +3 -3
  201. package/dist/api/open-api/soter.js.map +1 -1
  202. package/dist/api/open-api/subscribe-message.d.ts +2 -1
  203. package/dist/api/open-api/subscribe-message.js +4 -2
  204. package/dist/api/open-api/subscribe-message.js.map +1 -1
  205. package/dist/api/open-api/user-info.js +2 -2
  206. package/dist/api/open-api/user-info.js.map +1 -1
  207. package/dist/api/open-api/werun.js +2 -2
  208. package/dist/api/open-api/werun.js.map +1 -1
  209. package/dist/api/payment/index.d.ts +2 -1
  210. package/dist/api/payment/index.js +4 -3
  211. package/dist/api/payment/index.js.map +1 -1
  212. package/dist/api/qq/index.d.ts +2 -0
  213. package/dist/api/qq/index.js +7 -0
  214. package/dist/api/qq/index.js.map +1 -0
  215. package/dist/api/share/index.d.ts +10 -0
  216. package/dist/api/share/index.js +21 -11
  217. package/dist/api/share/index.js.map +1 -1
  218. package/dist/api/storage/background-fetch.js +4 -4
  219. package/dist/api/storage/background-fetch.js.map +1 -1
  220. package/dist/api/storage/cache-manager.d.ts +2 -0
  221. package/dist/api/storage/cache-manager.js +7 -0
  222. package/dist/api/storage/cache-manager.js.map +1 -0
  223. package/dist/api/storage/index.d.ts +6 -1
  224. package/dist/api/storage/index.js +8 -3
  225. package/dist/api/storage/index.js.map +1 -1
  226. package/dist/api/swan/index.js +21 -21
  227. package/dist/api/swan/index.js.map +1 -1
  228. package/dist/api/taro.d.ts +7 -2
  229. package/dist/api/taro.js +13 -4
  230. package/dist/api/taro.js.map +1 -1
  231. package/dist/api/ui/background.js +2 -2
  232. package/dist/api/ui/background.js.map +1 -1
  233. package/dist/api/ui/index.js +1 -1
  234. package/dist/api/ui/interaction/index.d.ts +1 -1
  235. package/dist/api/ui/interaction/index.js +4 -4
  236. package/dist/api/ui/interaction/index.js.map +1 -1
  237. package/dist/api/ui/interaction/modal.js +6 -0
  238. package/dist/api/ui/interaction/modal.js.map +1 -1
  239. package/dist/api/ui/interaction/toast.js +4 -0
  240. package/dist/api/ui/interaction/toast.js.map +1 -1
  241. package/dist/api/ui/menu.js +1 -1
  242. package/dist/api/ui/menu.js.map +1 -1
  243. package/dist/api/ui/navigation-bar/index.js +3 -3
  244. package/dist/api/ui/navigation-bar/index.js.map +1 -1
  245. package/dist/api/ui/scroll/index.js +4 -3
  246. package/dist/api/ui/scroll/index.js.map +1 -1
  247. package/dist/api/ui/sticky.js +1 -1
  248. package/dist/api/ui/sticky.js.map +1 -1
  249. package/dist/api/ui/window.d.ts +2 -1
  250. package/dist/api/ui/window.js +3 -2
  251. package/dist/api/ui/window.js.map +1 -1
  252. package/dist/api/worker/index.js +1 -1
  253. package/dist/api/worker/index.js.map +1 -1
  254. package/dist/api/wxml/IntersectionObserver.d.ts +1 -1
  255. package/dist/api/wxml/IntersectionObserver.js +8 -6
  256. package/dist/api/wxml/IntersectionObserver.js.map +1 -1
  257. package/dist/api/wxml/MediaQueryObserver.d.ts +1 -1
  258. package/dist/api/wxml/MediaQueryObserver.js +1 -2
  259. package/dist/api/wxml/MediaQueryObserver.js.map +1 -1
  260. package/dist/api/wxml/selectorQuery.js +9 -6
  261. package/dist/api/wxml/selectorQuery.js.map +1 -1
  262. package/dist/index.cjs.d.ts +95 -51
  263. package/dist/index.cjs.js +2459 -1943
  264. package/dist/index.cjs.js.map +1 -1
  265. package/dist/index.esm.d.ts +95 -51
  266. package/dist/index.esm.js +2400 -1913
  267. package/dist/index.esm.js.map +1 -1
  268. package/dist/index.js +29 -15
  269. package/dist/index.js.map +1 -1
  270. package/dist/utils/handler.d.ts +13 -26
  271. package/dist/utils/handler.js +4 -16
  272. package/dist/utils/handler.js.map +1 -1
  273. package/dist/utils/helper.d.ts +2 -0
  274. package/dist/utils/helper.js +11 -0
  275. package/dist/utils/helper.js.map +1 -0
  276. package/dist/utils/index.d.ts +5 -4
  277. package/dist/utils/index.js +4 -12
  278. package/dist/utils/index.js.map +1 -1
  279. package/package.json +20 -14
  280. package/dist/utils/lodash.d.ts +0 -3
  281. package/dist/utils/lodash.js +0 -32
  282. package/dist/utils/lodash.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasContext.js","sources":["../../../src/api/canvas/CanvasContext.ts"],"sourcesContent":["import { CanvasGradient } from '@tarojs/api'\n\ninterface IAction {\n func: (...arr: any[]) => void\n args: any[]\n}\n\nconst TextBaseLineMap: Record<keyof Taro.CanvasContext.TextBaseline, CanvasTextBaseline> = {\n top: 'top',\n bottom: 'bottom',\n middle: 'middle',\n normal: 'alphabetic'\n}\n\nexport class CanvasContext implements Taro.CanvasContext {\n __raw__: CanvasRenderingContext2D\n actions: IAction[] = []\n\n constructor (canvas, ctx) {\n this.canvas = canvas\n this.ctx = ctx\n }\n\n set ctx (e: CanvasRenderingContext2D) {\n this.__raw__ = e\n }\n\n get ctx () {\n return this.__raw__ || {}\n }\n\n canvas: HTMLCanvasElement\n\n protected emptyActions () {\n this.actions.length = 0\n }\n\n protected enqueueActions (func: IAction['func'], ...args) {\n this.actions.push({\n func,\n args\n })\n }\n\n set fillStyle (e) { this.enqueueActions(() => { this.ctx.fillStyle = e }) }\n get fillStyle () { return this.ctx.fillStyle as string }\n set font (e) { this.ctx.font = e }\n get font () { return this.ctx.font }\n set globalAlpha (e) { this.enqueueActions(() => { this.ctx.globalAlpha = e }) }\n get globalAlpha () { return this.ctx.globalAlpha }\n set globalCompositeOperation (e) { this.enqueueActions(() => { this.ctx.globalCompositeOperation = e }) }\n get globalCompositeOperation () { return this.ctx.globalCompositeOperation }\n set lineCap (e) { this.enqueueActions(() => { this.ctx.lineCap = e }) }\n get lineCap () { return this.ctx.lineCap }\n set lineDashOffset (e) { this.enqueueActions(() => { this.ctx.lineDashOffset = e }) }\n get lineDashOffset () { return this.ctx.lineDashOffset }\n set lineJoin (e) { this.enqueueActions(() => { this.ctx.lineJoin = e }) }\n get lineJoin () { return this.ctx.lineJoin }\n set lineWidth (e) { this.enqueueActions(() => { this.ctx.lineWidth = e }) }\n get lineWidth () { return this.ctx.lineWidth }\n set miterLimit (e) { this.enqueueActions(() => { this.ctx.miterLimit = e }) }\n get miterLimit () { return this.ctx.miterLimit }\n set shadowBlur (e) { this.enqueueActions(() => { this.ctx.shadowBlur = e }) }\n get shadowBlur () { return this.ctx.shadowBlur }\n set shadowColor (e) { this.enqueueActions(() => { this.ctx.shadowColor = e }) }\n get shadowColor () { return this.ctx.shadowColor }\n set shadowOffsetX (e) { this.enqueueActions(() => { this.ctx.shadowOffsetX = e }) }\n get shadowOffsetX () { return this.ctx.shadowOffsetX }\n set shadowOffsetY (e) { this.enqueueActions(() => { this.ctx.shadowOffsetY = e }) }\n get shadowOffsetY () { return this.ctx.shadowOffsetY }\n set strokeStyle (e) { this.enqueueActions(() => { this.ctx.strokeStyle = e }) }\n get strokeStyle () { return this.ctx.strokeStyle as string }\n /** 小程序文档中不包括 ↓↓↓ */\n set textAlign (e) { this.ctx.textAlign = e }\n get textAlign () { return this.ctx.textAlign }\n set textBaseline (e) { this.ctx.textBaseline = e }\n get textBaseline () { return this.ctx.textBaseline }\n set direction (e) { this.ctx.direction = e }\n get direction () { return this.ctx.direction }\n set imageSmoothingEnabled (e) { this.enqueueActions(() => { this.ctx.imageSmoothingEnabled = e }) }\n get imageSmoothingEnabled () { return this.ctx.imageSmoothingEnabled }\n set imageSmoothingQuality (e) { this.enqueueActions(() => { this.ctx.imageSmoothingQuality = e }) }\n get imageSmoothingQuality () { return this.ctx.imageSmoothingQuality }\n set filter (e) { this.enqueueActions(() => { this.ctx.filter = e }) }\n get filter () { return this.ctx.filter }\n /** 小程序文档中不包括 ↑↑↑ */\n\n arc (...args) { return this.enqueueActions(this.ctx.arc, ...args) }\n arcTo (...args) { return this.enqueueActions(this.ctx.arcTo, ...args) }\n beginPath (...args) { return this.enqueueActions(this.ctx.beginPath, ...args) }\n bezierCurveTo (...args) { return this.enqueueActions(this.ctx.bezierCurveTo, ...args) }\n clearRect (...args) { return this.enqueueActions(this.ctx.clearRect, ...args) }\n clip (...args) { return this.enqueueActions(this.ctx.clip, ...args) }\n closePath (...args) { return this.enqueueActions(this.ctx.closePath, ...args) }\n\n createPattern (image: string, repetition: keyof Taro.CanvasContext.Repetition): void {\n return this.createPattern(image, repetition)\n }\n\n /**\n * 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。\n * @todo 每次 draw 都会读取 width 和 height\n */\n async draw (reserve?: boolean, callback?: (...args: any[]) => any): Promise<void> {\n try {\n if (!reserve) {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n }\n\n // 部分 action 是异步的\n for (const { func, args } of this.actions) {\n await func.apply(this.ctx, args)\n }\n\n this.emptyActions()\n callback && callback()\n } catch (e) {\n /* eslint-disable no-throw-literal */\n throw {\n errMsg: e.message\n }\n }\n }\n\n drawImage (imageResource: string, ...extra: any[]): void {\n type TExtra = [number, number]\n this.enqueueActions(() => {\n // 需要转换为 Image\n if (typeof imageResource === 'string') {\n const img = new Image()\n img.src = imageResource\n return new Promise<void>((resolve, reject) => {\n img.onload = () => {\n this.ctx.drawImage(img, ...extra as TExtra)\n resolve()\n }\n img.onerror = reject\n })\n }\n\n this.ctx.drawImage(imageResource, ...extra as TExtra)\n })\n }\n\n fill (...args) { return this.enqueueActions(this.ctx.fill, ...args) }\n fillRect (...args) { return this.enqueueActions(this.ctx.fillRect, ...args) }\n fillText (...args) { return this.enqueueActions(this.ctx.fillText, ...args) }\n lineTo (...args) { return this.enqueueActions(this.ctx.lineTo, ...args) }\n moveTo (...args) { return this.enqueueActions(this.ctx.moveTo, ...args) }\n quadraticCurveTo (...args) { return this.enqueueActions(this.ctx.quadraticCurveTo, ...args) }\n rect (...args) { return this.enqueueActions(this.ctx.rect, ...args) }\n restore (...args) { return this.enqueueActions(this.ctx.restore, ...args) }\n rotate (...args) { return this.enqueueActions(this.ctx.rotate, ...args) }\n save (...args) { return this.enqueueActions(this.ctx.save, ...args) }\n scale (...args) { return this.enqueueActions(this.ctx.scale, ...args) }\n\n setFillStyle (color: string | CanvasGradient): void {\n this.enqueueActions(() => { this.ctx.fillStyle = color })\n }\n\n setFontSize (fontSize: number): void {\n this.font = `${fontSize}px`\n }\n\n setGlobalAlpha (alpha: number): void {\n this.globalAlpha = alpha\n }\n\n setLineCap (lineCap: keyof Taro.CanvasContext.LineCap): void {\n this.lineCap = lineCap\n }\n\n setLineDash (pattern: number[], offset: number): void {\n this.enqueueActions(() => {\n this.ctx.setLineDash(pattern)\n this.ctx.lineDashOffset = offset\n })\n }\n\n setLineJoin (lineJoin: keyof Taro.CanvasContext.LineJoin): void {\n this.lineJoin = lineJoin\n }\n\n setLineWidth (lineWidth: number): void {\n this.lineWidth = lineWidth\n }\n\n setMiterLimit (miterLimit: number): void {\n this.miterLimit = miterLimit\n }\n\n setShadow (offsetX: number, offsetY: number, blur: number, color: string): void {\n this.enqueueActions(() => {\n this.ctx.shadowOffsetX = offsetX\n this.ctx.shadowOffsetY = offsetY\n this.ctx.shadowColor = color\n this.ctx.shadowBlur = blur\n })\n }\n\n setStrokeStyle (color: string | CanvasGradient): void {\n this.enqueueActions(() => { this.ctx.strokeStyle = color })\n }\n\n setTextAlign (align: keyof Taro.CanvasContext.Align): void {\n this.textAlign = align\n }\n\n setTextBaseline (textBaseline: keyof Taro.CanvasContext.TextBaseline): void {\n this.textBaseline = TextBaseLineMap[textBaseline] || 'alphabetic'\n }\n\n setTransform (...args) { return this.enqueueActions(this.ctx.setTransform, ...args) }\n stroke (...args) { return this.enqueueActions(this.ctx.stroke, ...args) }\n strokeRect (...args) { return this.enqueueActions(this.ctx.strokeRect, ...args) }\n strokeText (...args) { return this.enqueueActions(this.ctx.strokeText, ...args) }\n transform (...args) { return this.enqueueActions(this.ctx.transform, ...args) }\n translate (...args) { return this.enqueueActions(this.ctx.translate, ...args) }\n\n measureText (text: string): TextMetrics {\n return this.ctx.measureText(text)\n }\n\n createCircularGradient (x: number, y: number, r: number): CanvasGradient {\n const radialGradient = this.ctx.createRadialGradient(x, y, 0, x, y, r)\n\n return radialGradient\n }\n\n createLinearGradient (x0: number, y0: number, x1: number, y1: number): CanvasGradient {\n return this.ctx.createLinearGradient(x0, y0, x1, y1)\n }\n}\n"],"names":[],"mappings":";;AAOA,MAAM,eAAe,GAAsE;AACzF,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,YAAY;CACrB,CAAA;MAEY,aAAa,CAAA;IAIxB,WAAa,CAAA,MAAM,EAAE,GAAG,EAAA;QAFxB,IAAO,CAAA,OAAA,GAAc,EAAE,CAAA;AAGrB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;AACpB,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;KACf;IAED,IAAI,GAAG,CAAE,CAA2B,EAAA;AAClC,QAAA,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;KACjB;AAED,IAAA,IAAI,GAAG,GAAA;AACL,QAAA,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;KAC1B;IAIS,YAAY,GAAA;AACpB,QAAA,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;KACxB;AAES,IAAA,cAAc,CAAE,IAAqB,EAAE,GAAG,IAAI,EAAA;AACtD,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,IAAI;YACJ,IAAI;AACL,SAAA,CAAC,CAAA;KACH;IAED,IAAI,SAAS,CAAE,CAAC,EAAI,EAAA,IAAI,CAAC,cAAc,CAAC,MAAQ,EAAA,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAA,EAAE,CAAC,CAAA,EAAE;IAC3E,IAAI,SAAS,GAAM,EAAA,OAAO,IAAI,CAAC,GAAG,CAAC,SAAmB,CAAA,EAAE;AACxD,IAAA,IAAI,IAAI,CAAE,CAAC,EAAA,EAAI,IAAI,CAAC,GAAG,CAAC,IAAI,GAA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AAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;KACrD;AACF;;;;"}
1
+ {"version":3,"file":"CanvasContext.js","sources":["../../../src/api/canvas/CanvasContext.ts"],"sourcesContent":["import Taro, { CanvasGradient } from '@tarojs/api'\n\ninterface IAction {\n func: (...arr: any[]) => void\n args: any[]\n}\n\nconst TextBaseLineMap: Record<keyof Taro.CanvasContext.TextBaseline, CanvasTextBaseline> = {\n top: 'top',\n bottom: 'bottom',\n middle: 'middle',\n normal: 'alphabetic'\n}\n\nexport class CanvasContext implements Taro.CanvasContext {\n __raw__: CanvasRenderingContext2D\n actions: IAction[] = []\n\n constructor (canvas, ctx) {\n this.canvas = canvas\n this.ctx = ctx\n }\n\n set ctx (e: CanvasRenderingContext2D) {\n this.__raw__ = e\n }\n\n get ctx () {\n return this.__raw__ || {}\n }\n\n canvas: HTMLCanvasElement\n\n protected emptyActions () {\n this.actions.length = 0\n }\n\n protected enqueueActions (func: IAction['func'], ...args) {\n this.actions.push({\n func,\n args\n })\n }\n\n set fillStyle (e) { this.enqueueActions(() => { this.ctx.fillStyle = e }) }\n get fillStyle () { return this.ctx.fillStyle as string }\n set font (e) { this.ctx.font = e }\n get font () { return this.ctx.font }\n set globalAlpha (e) { this.enqueueActions(() => { this.ctx.globalAlpha = e }) }\n get globalAlpha () { return this.ctx.globalAlpha }\n set globalCompositeOperation (e) { this.enqueueActions(() => { this.ctx.globalCompositeOperation = e }) }\n get globalCompositeOperation () { return this.ctx.globalCompositeOperation }\n set lineCap (e) { this.enqueueActions(() => { this.ctx.lineCap = e }) }\n get lineCap () { return this.ctx.lineCap }\n set lineDashOffset (e) { this.enqueueActions(() => { this.ctx.lineDashOffset = e }) }\n get lineDashOffset () { return this.ctx.lineDashOffset }\n set lineJoin (e) { this.enqueueActions(() => { this.ctx.lineJoin = e }) }\n get lineJoin () { return this.ctx.lineJoin }\n set lineWidth (e) { this.enqueueActions(() => { this.ctx.lineWidth = e }) }\n get lineWidth () { return this.ctx.lineWidth }\n set miterLimit (e) { this.enqueueActions(() => { this.ctx.miterLimit = e }) }\n get miterLimit () { return this.ctx.miterLimit }\n set shadowBlur (e) { this.enqueueActions(() => { this.ctx.shadowBlur = e }) }\n get shadowBlur () { return this.ctx.shadowBlur }\n set shadowColor (e) { this.enqueueActions(() => { this.ctx.shadowColor = e }) }\n get shadowColor () { return this.ctx.shadowColor }\n set shadowOffsetX (e) { this.enqueueActions(() => { this.ctx.shadowOffsetX = e }) }\n get shadowOffsetX () { return this.ctx.shadowOffsetX }\n set shadowOffsetY (e) { this.enqueueActions(() => { this.ctx.shadowOffsetY = e }) }\n get shadowOffsetY () { return this.ctx.shadowOffsetY }\n set strokeStyle (e) { this.enqueueActions(() => { this.ctx.strokeStyle = e }) }\n get strokeStyle () { return this.ctx.strokeStyle as string }\n /** 小程序文档中不包括 ↓↓↓ */\n set textAlign (e) { this.ctx.textAlign = e }\n get textAlign () { return this.ctx.textAlign }\n set textBaseline (e) { this.ctx.textBaseline = e }\n get textBaseline () { return this.ctx.textBaseline }\n set direction (e) { this.ctx.direction = e }\n get direction () { return this.ctx.direction }\n set imageSmoothingEnabled (e) { this.enqueueActions(() => { this.ctx.imageSmoothingEnabled = e }) }\n get imageSmoothingEnabled () { return this.ctx.imageSmoothingEnabled }\n set imageSmoothingQuality (e) { this.enqueueActions(() => { this.ctx.imageSmoothingQuality = e }) }\n get imageSmoothingQuality () { return this.ctx.imageSmoothingQuality }\n set filter (e) { this.enqueueActions(() => { this.ctx.filter = e }) }\n get filter () { return this.ctx.filter }\n /** 小程序文档中不包括 ↑↑↑ */\n\n arc (...args) { return this.enqueueActions(this.ctx.arc, ...args) }\n arcTo (...args) { return this.enqueueActions(this.ctx.arcTo, ...args) }\n beginPath (...args) { return this.enqueueActions(this.ctx.beginPath, ...args) }\n bezierCurveTo (...args) { return this.enqueueActions(this.ctx.bezierCurveTo, ...args) }\n clearRect (...args) { return this.enqueueActions(this.ctx.clearRect, ...args) }\n clip (...args) { return this.enqueueActions(this.ctx.clip, ...args) }\n closePath (...args) { return this.enqueueActions(this.ctx.closePath, ...args) }\n\n createPattern (image: string, repetition: keyof Taro.CanvasContext.Repetition): void {\n return this.createPattern(image, repetition)\n }\n\n /**\n * 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。\n * @todo 每次 draw 都会读取 width 和 height\n */\n async draw (reserve?: boolean, callback?: (...args: any[]) => any): Promise<void> {\n try {\n if (!reserve) {\n this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)\n }\n\n // 部分 action 是异步的\n for (const { func, args } of this.actions) {\n await func.apply(this.ctx, args)\n }\n\n this.emptyActions()\n callback && callback()\n } catch (e) {\n /* eslint-disable no-throw-literal */\n throw {\n errMsg: e.message\n }\n }\n }\n\n drawImage (imageResource: string, ...extra: any[]): void {\n type TExtra = [number, number]\n this.enqueueActions(() => {\n // 需要转换为 Image\n if (typeof imageResource === 'string') {\n const img = new Image()\n img.src = imageResource\n return new Promise<void>((resolve, reject) => {\n img.onload = () => {\n this.ctx.drawImage(img, ...extra as TExtra)\n resolve()\n }\n img.onerror = reject\n })\n }\n\n this.ctx.drawImage(imageResource, ...extra as TExtra)\n })\n }\n\n fill (...args) { return this.enqueueActions(this.ctx.fill, ...args) }\n fillRect (...args) { return this.enqueueActions(this.ctx.fillRect, ...args) }\n fillText (...args) { return this.enqueueActions(this.ctx.fillText, ...args) }\n lineTo (...args) { return this.enqueueActions(this.ctx.lineTo, ...args) }\n moveTo (...args) { return this.enqueueActions(this.ctx.moveTo, ...args) }\n quadraticCurveTo (...args) { return this.enqueueActions(this.ctx.quadraticCurveTo, ...args) }\n rect (...args) { return this.enqueueActions(this.ctx.rect, ...args) }\n restore (...args) { return this.enqueueActions(this.ctx.restore, ...args) }\n rotate (...args) { return this.enqueueActions(this.ctx.rotate, ...args) }\n save (...args) { return this.enqueueActions(this.ctx.save, ...args) }\n scale (...args) { return this.enqueueActions(this.ctx.scale, ...args) }\n\n setFillStyle (color: string | CanvasGradient): void {\n this.enqueueActions(() => { this.ctx.fillStyle = color })\n }\n\n setFontSize (fontSize: number): void {\n this.font = `${fontSize}px`\n }\n\n setGlobalAlpha (alpha: number): void {\n this.globalAlpha = alpha\n }\n\n setLineCap (lineCap: keyof Taro.CanvasContext.LineCap): void {\n this.lineCap = lineCap\n }\n\n setLineDash (pattern: number[], offset: number): void {\n this.enqueueActions(() => {\n this.ctx.setLineDash(pattern)\n this.ctx.lineDashOffset = offset\n })\n }\n\n setLineJoin (lineJoin: keyof Taro.CanvasContext.LineJoin): void {\n this.lineJoin = lineJoin\n }\n\n setLineWidth (lineWidth: number): void {\n this.lineWidth = lineWidth\n }\n\n setMiterLimit (miterLimit: number): void {\n this.miterLimit = miterLimit\n }\n\n setShadow (offsetX: number, offsetY: number, blur: number, color: string): void {\n this.enqueueActions(() => {\n this.ctx.shadowOffsetX = offsetX\n this.ctx.shadowOffsetY = offsetY\n this.ctx.shadowColor = color\n this.ctx.shadowBlur = blur\n })\n }\n\n setStrokeStyle (color: string | CanvasGradient): void {\n this.enqueueActions(() => { this.ctx.strokeStyle = color })\n }\n\n setTextAlign (align: keyof Taro.CanvasContext.Align): void {\n this.textAlign = align\n }\n\n setTextBaseline (textBaseline: keyof Taro.CanvasContext.TextBaseline): void {\n this.textBaseline = TextBaseLineMap[textBaseline] || 'alphabetic'\n }\n\n setTransform (...args) { return this.enqueueActions(this.ctx.setTransform, ...args) }\n stroke (...args) { return this.enqueueActions(this.ctx.stroke, ...args) }\n strokeRect (...args) { return this.enqueueActions(this.ctx.strokeRect, ...args) }\n strokeText (...args) { return this.enqueueActions(this.ctx.strokeText, ...args) }\n transform (...args) { return this.enqueueActions(this.ctx.transform, ...args) }\n translate (...args) { return this.enqueueActions(this.ctx.translate, ...args) }\n\n measureText (text: string): TextMetrics {\n return this.ctx.measureText(text)\n }\n\n createCircularGradient (x: number, y: number, r: number): CanvasGradient {\n const radialGradient = this.ctx.createRadialGradient(x, y, 0, x, y, r)\n\n return radialGradient\n }\n\n createLinearGradient (x0: number, y0: number, x1: number, y1: number): CanvasGradient {\n return this.ctx.createLinearGradient(x0, y0, x1, y1)\n }\n}\n"],"names":[],"mappings":";;AAOA,MAAM,eAAe,GAAsE;AACzF,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,MAAM,EAAE,YAAY;CACrB,CAAA;MAEY,aAAa,CAAA;IAIxB,WAAa,CAAA,MAAM,EAAE,GAAG,EAAA;QAFxB,IAAO,CAAA,OAAA,GAAc,EAAE,CAAA;AAGrB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;AACpB,QAAA,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;KACf;IAED,IAAI,GAAG,CAAE,CAA2B,EAAA;AAClC,QAAA,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA;KACjB;AAED,IAAA,IAAI,GAAG,GAAA;AACL,QAAA,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,CAAA;KAC1B;IAIS,YAAY,GAAA;AACpB,QAAA,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;KACxB;AAES,IAAA,cAAc,CAAE,IAAqB,EAAE,GAAG,IAAI,EAAA;AACtD,QAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,IAAI;YACJ,IAAI;AACL,SAAA,CAAC,CAAA;KACH;IAED,IAAI,SAAS,CAAE,CAAC,EAAI,EAAA,IAAI,CAAC,cAAc,CAAC,MAAQ,EAAA,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAA,EAAE,CAAC,CAAA,EAAE;IAC3E,IAAI,SAAS,GAAM,EAAA,OAAO,IAAI,CAAC,GAAG,CAAC,SAAmB,CAAA,EAAE;AACxD,IAAA,IAAI,IAAI,CAAE,CAAC,EAAA,EAAI,IAAI,CAAC,GAAG,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E,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;KACrD;AACF;;;;"}
@@ -6,7 +6,7 @@ export { canvasGetImageData } from './canvasGetImageData.js';
6
6
 
7
7
  // 画布
8
8
  /** 创建离屏 canvas 实例 */
9
- const createOffscreenCanvas = temporarilyNotSupport('createOffscreenCanvas');
9
+ const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas');
10
10
 
11
11
  export { createOffscreenCanvas };
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/api/canvas/index.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\r\n\r\n// 画布\r\n\r\n/** 创建离屏 canvas 实例 */\r\nexport const createOffscreenCanvas = temporarilyNotSupport('createOffscreenCanvas')\r\n\r\n/** 创建 canvas 的绘图上下文 CanvasContext 对象 */\r\nexport * from './createCanvasContext'\r\n\r\n/** 把当前画布指定区域的内容导出生成指定大小的图片 */\r\nexport * from './canvasToTempFilePath'\r\n\r\n/** 将像素数据绘制到画布 */\r\nexport * from './canvasPutImageData'\r\n\r\n/** 获取 canvas 区域隐含的像素数据 */\r\nexport * from './canvasGetImageData'\r\n"],"names":[],"mappings":";;;;;;AAEA;AAEA;MACa,qBAAqB,GAAG,qBAAqB,CAAC,uBAAuB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/api/canvas/index.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\r\n\r\n// 画布\r\n\r\n/** 创建离屏 canvas 实例 */\r\nexport const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')\r\n\r\n/** 创建 canvas 的绘图上下文 CanvasContext 对象 */\r\nexport * from './createCanvasContext'\r\n\r\n/** 把当前画布指定区域的内容导出生成指定大小的图片 */\r\nexport * from './canvasToTempFilePath'\r\n\r\n/** 将像素数据绘制到画布 */\r\nexport * from './canvasPutImageData'\r\n\r\n/** 获取 canvas 区域隐含的像素数据 */\r\nexport * from './canvasGetImageData'\r\n"],"names":[],"mappings":";;;;;;AAEA;AAEA;AACa,MAAA,qBAAqB,mBAAmB,qBAAqB,CAAC,uBAAuB;;;;"}
@@ -1,9 +1,9 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
- const reportMonitor = temporarilyNotSupport('reportMonitor');
4
- const reportAnalytics = temporarilyNotSupport('reportAnalytics');
5
- const reportEvent = temporarilyNotSupport('reportEvent');
6
- const getExptInfoSync = temporarilyNotSupport('getExptInfoSync');
3
+ const reportMonitor = /* @__PURE__ */ temporarilyNotSupport('reportMonitor');
4
+ const reportAnalytics = /* @__PURE__ */ temporarilyNotSupport('reportAnalytics');
5
+ const reportEvent = /* @__PURE__ */ temporarilyNotSupport('reportEvent');
6
+ const getExptInfoSync = /* @__PURE__ */ temporarilyNotSupport('getExptInfoSync');
7
7
 
8
8
  export { getExptInfoSync, reportAnalytics, reportEvent, reportMonitor };
9
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/api/data-analysis/index.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\nexport const reportMonitor = temporarilyNotSupport('reportMonitor')\nexport const reportAnalytics = temporarilyNotSupport('reportAnalytics')\nexport const reportEvent = temporarilyNotSupport('reportEvent')\nexport const getExptInfoSync = temporarilyNotSupport('getExptInfoSync')\n"],"names":[],"mappings":";;MAEa,aAAa,GAAG,qBAAqB,CAAC,eAAe,EAAC;MACtD,eAAe,GAAG,qBAAqB,CAAC,iBAAiB,EAAC;MAC1D,WAAW,GAAG,qBAAqB,CAAC,aAAa,EAAC;MAClD,eAAe,GAAG,qBAAqB,CAAC,iBAAiB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/api/data-analysis/index.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\nexport const reportMonitor = /* @__PURE__ */ temporarilyNotSupport('reportMonitor')\nexport const reportAnalytics = /* @__PURE__ */ temporarilyNotSupport('reportAnalytics')\nexport const reportEvent = /* @__PURE__ */ temporarilyNotSupport('reportEvent')\nexport const getExptInfoSync = /* @__PURE__ */ temporarilyNotSupport('getExptInfoSync')\n"],"names":[],"mappings":";;AAEa,MAAA,aAAa,mBAAmB,qBAAqB,CAAC,eAAe,EAAC;AACtE,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB,EAAC;AAC1E,MAAA,WAAW,mBAAmB,qBAAqB,CAAC,aAAa,EAAC;AAClE,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB;;;;"}
@@ -1,6 +1,5 @@
1
- import '../../utils/index.js';
1
+ import throttle from 'lodash-es/throttle';
2
2
  import { CallbackManager, MethodHandler } from '../../utils/handler.js';
3
- import { throttle } from '../../utils/lodash.js';
4
3
 
5
4
  const callbackManager = new CallbackManager();
6
5
  let devicemotionListener;
@@ -1 +1 @@
1
- {"version":3,"file":"accelerometer.js","sources":["../../../src/api/device/accelerometer.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\n\r\nimport { throttle } from '../../utils'\r\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\r\n\r\nconst callbackManager = new CallbackManager()\r\nlet devicemotionListener\r\n\r\n/**\r\n * 停止监听加速度数据。\r\n */\r\nexport const stopAccelerometer: typeof Taro.stopAccelerometer = ({ success, fail, complete } = {}) => {\r\n const res: Partial<TaroGeneral.CallbackResult> = {}\r\n const handle = new MethodHandler({ name: 'stopAccelerometer', success, fail, complete })\r\n try {\r\n window.removeEventListener('devicemotion', devicemotionListener, true)\r\n return handle.success(res)\r\n } catch (e) {\r\n res.errMsg = e.message\r\n return handle.fail(res)\r\n }\r\n}\r\n\r\nconst INTERVAL_MAP = {\r\n game: {\r\n interval: 20,\r\n frequency: 50\r\n },\r\n ui: {\r\n interval: 60,\r\n frequency: 16.67\r\n },\r\n normal: {\r\n interval: 200,\r\n frequency: 5\r\n }\r\n}\r\n\r\n/**\r\n * 开始监听加速度数据。\r\n */\r\nexport const startAccelerometer: typeof Taro.startAccelerometer = ({ interval = 'normal', success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'startAccelerometer', success, fail, complete })\r\n try {\r\n if (window.DeviceMotionEvent) {\r\n const intervalObj = INTERVAL_MAP[interval]\r\n if (devicemotionListener) {\r\n stopAccelerometer()\r\n }\r\n devicemotionListener = throttle((evt: DeviceMotionEvent) => {\r\n callbackManager.trigger({\r\n x: evt.acceleration?.x || 0,\r\n y: evt.acceleration?.y || 0,\r\n z: evt.acceleration?.z || 0\r\n })\r\n }, intervalObj.interval)\r\n window.addEventListener('devicemotion', devicemotionListener, true)\r\n } else {\r\n throw new Error('accelerometer is not supported')\r\n }\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 监听加速度数据事件。频率根据 Taro.startAccelerometer() 的 interval 参数。可使用 Taro.stopAccelerometer() 停止监听。\r\n */\r\nexport const onAccelerometerChange: typeof Taro.onAccelerometerChange = callback => {\r\n callbackManager.add(callback)\r\n}\r\n\r\n/**\r\n * 取消监听加速度数据事件,参数为空,则取消所有的事件监听\r\n */\r\nexport const offAccelerometerChange: typeof Taro.offAccelerometerChange = callback => {\r\n callbackManager.remove(callback)\r\n}\r\n"],"names":[],"mappings":";;;;AAKA,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,IAAI,oBAAoB,CAAA;AAExB;;AAEG;AACI,MAAM,iBAAiB,GAAkC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI;IACnG,MAAM,GAAG,GAAwC,EAAE,CAAA;AACnD,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAA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le from 'lodash-es/throttle'\r\n\r\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\r\n\r\nconst callbackManager = new CallbackManager()\r\nlet devicemotionListener\r\n\r\n/**\r\n * 停止监听加速度数据。\r\n */\r\nexport const stopAccelerometer: typeof Taro.stopAccelerometer = ({ success, fail, complete } = {}) => {\r\n const res: Partial<TaroGeneral.CallbackResult> = {}\r\n const handle = new MethodHandler({ name: 'stopAccelerometer', success, fail, complete })\r\n try {\r\n window.removeEventListener('devicemotion', devicemotionListener, true)\r\n return handle.success(res)\r\n } catch (e) {\r\n res.errMsg = e.message\r\n return handle.fail(res)\r\n }\r\n}\r\n\r\nconst INTERVAL_MAP = {\r\n game: {\r\n interval: 20,\r\n frequency: 50\r\n },\r\n ui: {\r\n interval: 60,\r\n frequency: 16.67\r\n },\r\n normal: {\r\n interval: 200,\r\n frequency: 5\r\n }\r\n}\r\n\r\n/**\r\n * 开始监听加速度数据。\r\n */\r\nexport const startAccelerometer: typeof Taro.startAccelerometer = ({ interval = 'normal', success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'startAccelerometer', success, fail, complete })\r\n try {\r\n if (window.DeviceMotionEvent) {\r\n const intervalObj = INTERVAL_MAP[interval]\r\n if (devicemotionListener) {\r\n stopAccelerometer()\r\n }\r\n devicemotionListener = throttle((evt: DeviceMotionEvent) => {\r\n callbackManager.trigger({\r\n x: evt.acceleration?.x || 0,\r\n y: evt.acceleration?.y || 0,\r\n z: evt.acceleration?.z || 0\r\n })\r\n }, intervalObj.interval)\r\n window.addEventListener('devicemotion', devicemotionListener, true)\r\n } else {\r\n throw new Error('accelerometer is not supported')\r\n }\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 监听加速度数据事件。频率根据 Taro.startAccelerometer() 的 interval 参数。可使用 Taro.stopAccelerometer() 停止监听。\r\n */\r\nexport const onAccelerometerChange: typeof Taro.onAccelerometerChange = callback => {\r\n callbackManager.add(callback)\r\n}\r\n\r\n/**\r\n * 取消监听加速度数据事件,参数为空,则取消所有的事件监听\r\n */\r\nexport const offAccelerometerChange: typeof Taro.offAccelerometerChange = callback => {\r\n callbackManager.remove(callback)\r\n}\r\n"],"names":[],"mappings":";;;AAKA,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,IAAI,oBAAoB,CAAA;AAExB;;AAEG;AACI,MAAM,iBAAiB,GAAkC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI;IACnG,MAAM,GAAG,GAAwC,EAAE,CAAA;AACnD,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACxF,IAAI;QACF,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAA;AACtE,QAAA,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AAC3B,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;AACV,QAAA,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,CAAA;AACtB,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACxB,KAAA;AACH,EAAC;AAED,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE;AACJ,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,SAAS,EAAE,EAAE;AACd,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,SAAS,EAAE,KAAK;AACjB,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,SAAS,EAAE,CAAC;AACb,KAAA;CACF,CAAA;AAED;;AAEG;AACU,MAAA,kBAAkB,GAAmC,CAAC,EAAE,QAAQ,GAAG,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AO,EAAE,CAAA;AACxB,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAC1C,KAAA;AACH,EAAC;AAED;;AAEG;AACU,MAAA,qBAAqB,GAAsC,QAAQ,IAAG;AACjF,IAAA,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/B,EAAC;AAED;;AAEG;AACU,MAAA,sBAAsB,GAAuC,QAAQ,IAAG;AACnF,IAAA,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAClC;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
3
  // 无障碍
4
- const checkIsOpenAccessibility = temporarilyNotSupport('checkIsOpenAccessibility');
4
+ const checkIsOpenAccessibility = /* @__PURE__ */ temporarilyNotSupport('checkIsOpenAccessibility');
5
5
 
6
6
  export { checkIsOpenAccessibility };
7
7
  //# sourceMappingURL=accessibility.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.js","sources":["../../../src/api/device/accessibility.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 无障碍\nexport const checkIsOpenAccessibility = temporarilyNotSupport('checkIsOpenAccessibility')\n"],"names":[],"mappings":";;AAEA;MACa,wBAAwB,GAAG,qBAAqB,CAAC,0BAA0B;;;;"}
1
+ {"version":3,"file":"accessibility.js","sources":["../../../src/api/device/accessibility.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 无障碍\nexport const checkIsOpenAccessibility = /* @__PURE__ */ temporarilyNotSupport('checkIsOpenAccessibility')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,wBAAwB,mBAAmB,qBAAqB,CAAC,0BAA0B;;;;"}
@@ -4,7 +4,7 @@ import { MethodHandler } from '../../utils/handler.js';
4
4
 
5
5
  // 电量
6
6
  // Note: 浏览器标准下不支持,其他实现方案不准确,不建议开发者使用
7
- const getBatteryInfoSync = permanentlyNotSupport('getBatteryInfoSync');
7
+ const getBatteryInfoSync = /* @__PURE__ */ permanentlyNotSupport('getBatteryInfoSync');
8
8
  const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
9
9
  var _a;
10
10
  const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
@@ -1 +1 @@
1
- {"version":3,"file":"battery.js","sources":["../../../src/api/device/battery.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nimport { permanentlyNotSupport } from '../../utils'\nimport { MethodHandler } from '../../utils/handler'\n\n// 电量\n\n// Note: 浏览器标准下不支持,其他实现方案不准确,不建议开发者使用\nexport const getBatteryInfoSync = permanentlyNotSupport('getBatteryInfoSync')\n\nexport const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {\n const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete })\n try {\n // @ts-ignore\n const battery = await navigator.getBattery?.()\n return handle.success({\n isCharging: battery.charging,\n level: Number(battery.level || 0) * 100\n })\n } catch (error) {\n return handle.fail({\n errMsg: error?.message || error\n })\n }\n}\n"],"names":[],"mappings":";;;;AAKA;AAEA;MACa,kBAAkB,GAAG,qBAAqB,CAAC,oBAAoB,EAAC;AAEtE,MAAM,cAAc,GAA+B,CAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;;AACnG,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACrF,IAAI;;QAEF,MAAM,OAAO,GAAG,OAAM,CAAA,EAAA,GAAA,SAAS,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,SAAA,CAAA,CAAA,CAAA;QAC9C,OAAO,MAAM,CAAC,OAAO,CAAC;YACpB,UAAU,EAAE,OAAO,CAAC,QAAQ;YAC5B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,GAAG;AACxC,SAAA,CAAC,CAAA;AACH,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;QACd,OAAO,MAAM,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE,CAAA,KAAK,KAAL,IAAA,IAAA,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,KAAK;AAChC,SAAA,CAAC,CAAA;AACH,KAAA;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"battery.js","sources":["../../../src/api/device/battery.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nimport { permanentlyNotSupport } from '../../utils'\nimport { MethodHandler } from '../../utils/handler'\n\n// 电量\n\n// Note: 浏览器标准下不支持,其他实现方案不准确,不建议开发者使用\nexport const getBatteryInfoSync = /* @__PURE__ */ permanentlyNotSupport('getBatteryInfoSync')\n\nexport const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {\n const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete })\n try {\n // @ts-ignore\n const battery = await navigator.getBattery?.()\n return handle.success({\n isCharging: battery.charging,\n level: Number(battery.level || 0) * 100\n })\n } catch (error) {\n return handle.fail({\n errMsg: error?.message || error\n })\n }\n}\n"],"names":[],"mappings":";;;;AAKA;AAEA;AACa,MAAA,kBAAkB,mBAAmB,qBAAqB,CAAC,oBAAoB,EAAC;AAEtF,MAAM,cAAc,GAA+B,CAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;;AACnG,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACrF,IAAI;;QAEF,MAAM,OAAO,GAAG,OAAM,CAAA,EAAA,GAAA,SAAS,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,SAAA,CAAA,CAAA,CAAA;QAC9C,OAAO,MAAM,CAAC,OAAO,CAAC;YACpB,UAAU,EAAE,OAAO,CAAC,QAAQ;YAC5B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,GAAG;AACxC,SAAA,CAAC,CAAA;AACH,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;QACd,OAAO,MAAM,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE,CAAA,KAAK,KAAL,IAAA,IAAA,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,KAAK;AAChC,SAAA,CAAC,CAAA;AACH,KAAA;AACH,CAAC;;;;"}
@@ -1,22 +1,22 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
3
  // 蓝牙-低功耗中心设备
4
- const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue');
5
- const setBLEMTU = temporarilyNotSupport('setBLEMTU');
6
- const readBLECharacteristicValue = temporarilyNotSupport('readBLECharacteristicValue');
7
- const onBLEMTUChange = temporarilyNotSupport('onBLEMTUChange');
8
- const onBLEConnectionStateChange = temporarilyNotSupport('onBLEConnectionStateChange');
9
- const onBLECharacteristicValueChange = temporarilyNotSupport('onBLECharacteristicValueChange');
10
- const offBLEMTUChange = temporarilyNotSupport('offBLEMTUChange');
11
- const offBLEConnectionStateChange = temporarilyNotSupport('offBLEConnectionStateChange');
12
- const offBLECharacteristicValueChange = temporarilyNotSupport('offBLECharacteristicValueChange');
13
- const notifyBLECharacteristicValueChange = temporarilyNotSupport('notifyBLECharacteristicValueChange');
14
- const getBLEMTU = temporarilyNotSupport('getBLEMTU');
15
- const getBLEDeviceServices = temporarilyNotSupport('getBLEDeviceServices');
16
- const getBLEDeviceRSSI = temporarilyNotSupport('getBLEDeviceRSSI');
17
- const getBLEDeviceCharacteristics = temporarilyNotSupport('getBLEDeviceCharacteristics');
18
- const createBLEConnection = temporarilyNotSupport('createBLEConnection');
19
- const closeBLEConnection = temporarilyNotSupport('closeBLEConnection');
4
+ const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue');
5
+ const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU');
6
+ const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue');
7
+ const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange');
8
+ const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange');
9
+ const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange');
10
+ const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange');
11
+ const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange');
12
+ const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange');
13
+ const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange');
14
+ const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU');
15
+ const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices');
16
+ const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI');
17
+ const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics');
18
+ const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection');
19
+ const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection');
20
20
 
21
21
  export { closeBLEConnection, createBLEConnection, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, notifyBLECharacteristicValueChange, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, readBLECharacteristicValue, setBLEMTU, writeBLECharacteristicValue };
22
22
  //# sourceMappingURL=bluetooth-ble.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bluetooth-ble.js","sources":["../../../src/api/device/bluetooth-ble.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗中心设备\nexport const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue')\nexport const setBLEMTU = temporarilyNotSupport('setBLEMTU')\nexport const readBLECharacteristicValue = temporarilyNotSupport('readBLECharacteristicValue')\nexport const onBLEMTUChange = temporarilyNotSupport('onBLEMTUChange')\nexport const onBLEConnectionStateChange = temporarilyNotSupport('onBLEConnectionStateChange')\nexport const onBLECharacteristicValueChange = temporarilyNotSupport('onBLECharacteristicValueChange')\nexport const offBLEMTUChange = temporarilyNotSupport('offBLEMTUChange')\nexport const offBLEConnectionStateChange = temporarilyNotSupport('offBLEConnectionStateChange')\nexport const offBLECharacteristicValueChange = temporarilyNotSupport('offBLECharacteristicValueChange')\nexport const notifyBLECharacteristicValueChange = temporarilyNotSupport('notifyBLECharacteristicValueChange')\nexport const getBLEMTU = temporarilyNotSupport('getBLEMTU')\nexport const getBLEDeviceServices = temporarilyNotSupport('getBLEDeviceServices')\nexport const getBLEDeviceRSSI = temporarilyNotSupport('getBLEDeviceRSSI')\nexport const getBLEDeviceCharacteristics = temporarilyNotSupport('getBLEDeviceCharacteristics')\nexport const createBLEConnection = temporarilyNotSupport('createBLEConnection')\nexport const closeBLEConnection = temporarilyNotSupport('closeBLEConnection')\n"],"names":[],"mappings":";;AAEA;MACa,2BAA2B,GAAG,qBAAqB,CAAC,6BAA6B,EAAC;MAClF,SAAS,GAAG,qBAAqB,CAAC,WAAW,EAAC;MAC9C,0BAA0B,GAAG,qBAAqB,CAAC,4BAA4B,EAAC;MAChF,cAAc,GAAG,qBAAqB,CAAC,gBAAgB,EAAC;MACxD,0BAA0B,GAAG,qBAAqB,CAAC,4BAA4B,EAAC;MAChF,8BAA8B,GAAG,qBAAqB,CAAC,gCAAgC,EAAC;MACxF,eAAe,GAAG,qBAAqB,CAAC,iBAAiB,EAAC;MAC1D,2BAA2B,GAAG,qBAAqB,CAAC,6BAA6B,EAAC;MAClF,+BAA+B,GAAG,qBAAqB,CAAC,iCAAiC,EAAC;MAC1F,kCAAkC,GAAG,qBAAqB,CAAC,oCAAoC,EAAC;MAChG,SAAS,GAAG,qBAAqB,CAAC,WAAW,EAAC;MAC9C,oBAAoB,GAAG,qBAAqB,CAAC,sBAAsB,EAAC;MACpE,gBAAgB,GAAG,qBAAqB,CAAC,kBAAkB,EAAC;MAC5D,2BAA2B,GAAG,qBAAqB,CAAC,6BAA6B,EAAC;MAClF,mBAAmB,GAAG,qBAAqB,CAAC,qBAAqB,EAAC;MAClE,kBAAkB,GAAG,qBAAqB,CAAC,oBAAoB;;;;"}
1
+ {"version":3,"file":"bluetooth-ble.js","sources":["../../../src/api/device/bluetooth-ble.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗中心设备\nexport const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue')\nexport const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU')\nexport const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue')\nexport const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange')\nexport const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange')\nexport const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange')\nexport const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange')\nexport const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange')\nexport const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange')\nexport const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange')\nexport const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU')\nexport const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices')\nexport const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI')\nexport const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics')\nexport const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection')\nexport const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,2BAA2B,mBAAmB,qBAAqB,CAAC,6BAA6B,EAAC;AAClG,MAAA,SAAS,mBAAmB,qBAAqB,CAAC,WAAW,EAAC;AAC9D,MAAA,0BAA0B,mBAAmB,qBAAqB,CAAC,4BAA4B,EAAC;AAChG,MAAA,cAAc,mBAAmB,qBAAqB,CAAC,gBAAgB,EAAC;AACxE,MAAA,0BAA0B,mBAAmB,qBAAqB,CAAC,4BAA4B,EAAC;AAChG,MAAA,8BAA8B,mBAAmB,qBAAqB,CAAC,gCAAgC,EAAC;AACxG,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB,EAAC;AAC1E,MAAA,2BAA2B,mBAAmB,qBAAqB,CAAC,6BAA6B,EAAC;AAClG,MAAA,+BAA+B,mBAAmB,qBAAqB,CAAC,iCAAiC,EAAC;AAC1G,MAAA,kCAAkC,mBAAmB,qBAAqB,CAAC,oCAAoC,EAAC;AAChH,MAAA,SAAS,mBAAmB,qBAAqB,CAAC,WAAW,EAAC;AAC9D,MAAA,oBAAoB,mBAAmB,qBAAqB,CAAC,sBAAsB,EAAC;AACpF,MAAA,gBAAgB,mBAAmB,qBAAqB,CAAC,kBAAkB,EAAC;AAC5E,MAAA,2BAA2B,mBAAmB,qBAAqB,CAAC,6BAA6B,EAAC;AAClG,MAAA,mBAAmB,mBAAmB,qBAAqB,CAAC,qBAAqB,EAAC;AAClF,MAAA,kBAAkB,mBAAmB,qBAAqB,CAAC,oBAAoB;;;;"}
@@ -1,9 +1,9 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
3
  // 蓝牙-低功耗外围设备
4
- const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
5
- const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
6
- const createBLEPeripheralServer = temporarilyNotSupport('createBLEPeripheralServer');
4
+ const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
5
+ const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
6
+ const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer');
7
7
 
8
8
  export { createBLEPeripheralServer, offBLEPeripheralConnectionStateChanged, onBLEPeripheralConnectionStateChanged };
9
9
  //# sourceMappingURL=bluetooth-peripheral.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bluetooth-peripheral.js","sources":["../../../src/api/device/bluetooth-peripheral.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗外围设备\nexport const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged')\nexport const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged')\nexport const createBLEPeripheralServer = temporarilyNotSupport('createBLEPeripheralServer')\n"],"names":[],"mappings":";;AAEA;MACa,qCAAqC,GAAG,qBAAqB,CAAC,uCAAuC,EAAC;MACtG,sCAAsC,GAAG,qBAAqB,CAAC,wCAAwC,EAAC;MACxG,yBAAyB,GAAG,qBAAqB,CAAC,2BAA2B;;;;"}
1
+ {"version":3,"file":"bluetooth-peripheral.js","sources":["../../../src/api/device/bluetooth-peripheral.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗外围设备\nexport const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged')\nexport const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged')\nexport const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,qCAAqC,mBAAmB,qBAAqB,CAAC,uCAAuC,EAAC;AACtH,MAAA,sCAAsC,mBAAmB,qBAAqB,CAAC,wCAAwC,EAAC;AACxH,MAAA,yBAAyB,mBAAmB,qBAAqB,CAAC,2BAA2B;;;;"}
@@ -1,19 +1,19 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
3
  // 蓝牙-通用
4
- const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
5
- const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery');
6
- const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter');
7
- const onBluetoothDeviceFound = temporarilyNotSupport('onBluetoothDeviceFound');
8
- const onBluetoothAdapterStateChange = temporarilyNotSupport('onBluetoothAdapterStateChange');
9
- const offBluetoothDeviceFound = temporarilyNotSupport('offBluetoothDeviceFound');
10
- const offBluetoothAdapterStateChange = temporarilyNotSupport('offBluetoothAdapterStateChange');
11
- const makeBluetoothPair = temporarilyNotSupport('makeBluetoothPair');
12
- const isBluetoothDevicePaired = temporarilyNotSupport('isBluetoothDevicePaired');
13
- const getConnectedBluetoothDevices = temporarilyNotSupport('getConnectedBluetoothDevices');
14
- const getBluetoothDevices = temporarilyNotSupport('getBluetoothDevices');
15
- const getBluetoothAdapterState = temporarilyNotSupport('getBluetoothAdapterState');
16
- const closeBluetoothAdapter = temporarilyNotSupport('closeBluetoothAdapter');
4
+ const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery');
5
+ const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery');
6
+ const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter');
7
+ const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound');
8
+ const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange');
9
+ const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound');
10
+ const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange');
11
+ const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair');
12
+ const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired');
13
+ const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices');
14
+ const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices');
15
+ const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState');
16
+ const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter');
17
17
 
18
18
  export { closeBluetoothAdapter, getBluetoothAdapterState, getBluetoothDevices, getConnectedBluetoothDevices, isBluetoothDevicePaired, makeBluetoothPair, offBluetoothAdapterStateChange, offBluetoothDeviceFound, onBluetoothAdapterStateChange, onBluetoothDeviceFound, openBluetoothAdapter, startBluetoothDevicesDiscovery, stopBluetoothDevicesDiscovery };
19
19
  //# sourceMappingURL=bluetooth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bluetooth.js","sources":["../../../src/api/device/bluetooth.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-通用\nexport const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery')\nexport const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery')\nexport const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter')\nexport const onBluetoothDeviceFound = temporarilyNotSupport('onBluetoothDeviceFound')\nexport const onBluetoothAdapterStateChange = temporarilyNotSupport('onBluetoothAdapterStateChange')\nexport const offBluetoothDeviceFound = temporarilyNotSupport('offBluetoothDeviceFound')\nexport const offBluetoothAdapterStateChange = temporarilyNotSupport('offBluetoothAdapterStateChange')\nexport const makeBluetoothPair = temporarilyNotSupport('makeBluetoothPair')\nexport const isBluetoothDevicePaired = temporarilyNotSupport('isBluetoothDevicePaired')\nexport const getConnectedBluetoothDevices = temporarilyNotSupport('getConnectedBluetoothDevices')\nexport const getBluetoothDevices = temporarilyNotSupport('getBluetoothDevices')\nexport const getBluetoothAdapterState = temporarilyNotSupport('getBluetoothAdapterState')\nexport const closeBluetoothAdapter = temporarilyNotSupport('closeBluetoothAdapter')\n"],"names":[],"mappings":";;AAEA;MACa,6BAA6B,GAAG,qBAAqB,CAAC,+BAA+B,EAAC;MACtF,8BAA8B,GAAG,qBAAqB,CAAC,gCAAgC,EAAC;MACxF,oBAAoB,GAAG,qBAAqB,CAAC,sBAAsB,EAAC;MACpE,sBAAsB,GAAG,qBAAqB,CAAC,wBAAwB,EAAC;MACxE,6BAA6B,GAAG,qBAAqB,CAAC,+BAA+B,EAAC;MACtF,uBAAuB,GAAG,qBAAqB,CAAC,yBAAyB,EAAC;MAC1E,8BAA8B,GAAG,qBAAqB,CAAC,gCAAgC,EAAC;MACxF,iBAAiB,GAAG,qBAAqB,CAAC,mBAAmB,EAAC;MAC9D,uBAAuB,GAAG,qBAAqB,CAAC,yBAAyB,EAAC;MAC1E,4BAA4B,GAAG,qBAAqB,CAAC,8BAA8B,EAAC;MACpF,mBAAmB,GAAG,qBAAqB,CAAC,qBAAqB,EAAC;MAClE,wBAAwB,GAAG,qBAAqB,CAAC,0BAA0B,EAAC;MAC5E,qBAAqB,GAAG,qBAAqB,CAAC,uBAAuB;;;;"}
1
+ {"version":3,"file":"bluetooth.js","sources":["../../../src/api/device/bluetooth.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-通用\nexport const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery')\nexport const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery')\nexport const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter')\nexport const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound')\nexport const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange')\nexport const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound')\nexport const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange')\nexport const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair')\nexport const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired')\nexport const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices')\nexport const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices')\nexport const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState')\nexport const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,6BAA6B,mBAAmB,qBAAqB,CAAC,+BAA+B,EAAC;AACtG,MAAA,8BAA8B,mBAAmB,qBAAqB,CAAC,gCAAgC,EAAC;AACxG,MAAA,oBAAoB,mBAAmB,qBAAqB,CAAC,sBAAsB,EAAC;AACpF,MAAA,sBAAsB,mBAAmB,qBAAqB,CAAC,wBAAwB,EAAC;AACxF,MAAA,6BAA6B,mBAAmB,qBAAqB,CAAC,+BAA+B,EAAC;AACtG,MAAA,uBAAuB,mBAAmB,qBAAqB,CAAC,yBAAyB,EAAC;AAC1F,MAAA,8BAA8B,mBAAmB,qBAAqB,CAAC,gCAAgC,EAAC;AACxG,MAAA,iBAAiB,mBAAmB,qBAAqB,CAAC,mBAAmB,EAAC;AAC9E,MAAA,uBAAuB,mBAAmB,qBAAqB,CAAC,yBAAyB,EAAC;AAC1F,MAAA,4BAA4B,mBAAmB,qBAAqB,CAAC,8BAA8B,EAAC;AACpG,MAAA,mBAAmB,mBAAmB,qBAAqB,CAAC,qBAAqB,EAAC;AAClF,MAAA,wBAAwB,mBAAmB,qBAAqB,CAAC,0BAA0B,EAAC;AAC5F,MAAA,qBAAqB,mBAAmB,qBAAqB,CAAC,uBAAuB;;;;"}
@@ -1,3 +1,4 @@
1
- declare const addPhoneRepeatCalendar: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
2
- declare const addPhoneCalendar: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
1
+ import Taro from '@tarojs/api';
2
+ declare const addPhoneRepeatCalendar: typeof Taro.addPhoneRepeatCalendar;
3
+ declare const addPhoneCalendar: typeof Taro.addPhoneCalendar;
3
4
  export { addPhoneRepeatCalendar, addPhoneCalendar };
@@ -1,8 +1,147 @@
1
- import { temporarilyNotSupport } from '../../utils/index.js';
1
+ import * as ics from 'ics';
2
+ import { shouldBeObject, getParameterError } from '../../utils/index.js';
3
+ import { MethodHandler } from '../../utils/handler.js';
4
+ import { createDownload } from '../../utils/helper.js';
2
5
 
3
6
  // 日历
4
- const addPhoneRepeatCalendar = temporarilyNotSupport('addPhoneRepeatCalendar');
5
- const addPhoneCalendar = temporarilyNotSupport('addPhoneCalendar');
7
+ const addPhoneRepeatCalendar = (options) => {
8
+ const methodName = 'addPhoneRepeatCalendar';
9
+ // options must be an Object
10
+ const isObject = shouldBeObject(options);
11
+ if (!isObject.flag) {
12
+ const res = { errMsg: `${methodName}:fail ${isObject.msg}` };
13
+ console.error(res.errMsg);
14
+ return Promise.reject(res);
15
+ }
16
+ const { title, startTime = new Date().getTime(), allDay = false, description = '', location = '', endTime, alarm = true, alarmOffset = 0, repeatInterval = 'month', repeatEndTime, success, fail, complete, } = options;
17
+ const handle = new MethodHandler({ name: methodName, success, fail, complete });
18
+ if (typeof title !== 'string') {
19
+ return handle.fail({
20
+ errMsg: getParameterError({
21
+ para: 'title',
22
+ correct: 'String',
23
+ wrong: title
24
+ })
25
+ });
26
+ }
27
+ const start = new Date(startTime);
28
+ const end = new Date(endTime || startTime);
29
+ if (!endTime && allDay) {
30
+ end.setDate(end.getDate() + 1);
31
+ }
32
+ const interval = 1000 * 60 * 60 * 24;
33
+ let days = 1;
34
+ let repeat = 1;
35
+ if (repeatEndTime) {
36
+ const repeatEnd = new Date(repeatEndTime);
37
+ if (repeatEnd < start) {
38
+ return handle.fail({
39
+ errMsg: 'repeatEndTime must be greater than startTime'
40
+ });
41
+ }
42
+ switch (repeatInterval) {
43
+ case 'week':
44
+ days = 7;
45
+ break;
46
+ case 'month':
47
+ days = 30;
48
+ break;
49
+ case 'year':
50
+ days = 365;
51
+ break;
52
+ default:
53
+ }
54
+ repeat = Math.ceil((repeatEnd.getTime() - start.getTime()) / (interval * days));
55
+ }
56
+ const { error, value } = ics.createEvent({
57
+ title,
58
+ start: parseTime2Array(start, allDay),
59
+ description,
60
+ location,
61
+ end: parseTime2Array(end, allDay),
62
+ alarms: alarm ? [{
63
+ action: 'display',
64
+ description,
65
+ trigger: {
66
+ before: true,
67
+ seconds: alarmOffset,
68
+ },
69
+ duration: {
70
+ days,
71
+ },
72
+ repeat,
73
+ }] : [],
74
+ });
75
+ if (error || !value) {
76
+ return handle.fail({
77
+ errMsg: error === null || error === void 0 ? void 0 : error.message
78
+ });
79
+ }
80
+ const url = URL.createObjectURL(new Blob([value]));
81
+ createDownload(url, `${title}.ics`);
82
+ return handle.success();
83
+ };
84
+ const addPhoneCalendar = (options) => {
85
+ const methodName = 'addPhoneCalendar';
86
+ // options must be an Object
87
+ const isObject = shouldBeObject(options);
88
+ if (!isObject.flag) {
89
+ const res = { errMsg: `${methodName}:fail ${isObject.msg}` };
90
+ console.error(res.errMsg);
91
+ return Promise.reject(res);
92
+ }
93
+ const { title, startTime = new Date().getTime(), allDay = false, description = '', location = '', endTime, alarm = true, alarmOffset = 0, success, fail, complete, } = options;
94
+ const handle = new MethodHandler({ name: methodName, success, fail, complete });
95
+ if (typeof title !== 'string') {
96
+ return handle.fail({
97
+ errMsg: getParameterError({
98
+ para: 'title',
99
+ correct: 'String',
100
+ wrong: title
101
+ })
102
+ });
103
+ }
104
+ const start = new Date(startTime);
105
+ const end = new Date(endTime || startTime);
106
+ if (!endTime && allDay) {
107
+ end.setDate(end.getDate() + 1);
108
+ }
109
+ const { error, value } = ics.createEvent({
110
+ title,
111
+ start: parseTime2Array(start, allDay),
112
+ description,
113
+ location,
114
+ end: parseTime2Array(end, allDay),
115
+ alarms: alarm ? [{
116
+ action: 'display',
117
+ description,
118
+ trigger: {
119
+ before: true,
120
+ seconds: alarmOffset,
121
+ },
122
+ }] : [],
123
+ });
124
+ if (error || !value) {
125
+ return handle.fail({
126
+ errMsg: error === null || error === void 0 ? void 0 : error.message
127
+ });
128
+ }
129
+ const url = URL.createObjectURL(new Blob([value]));
130
+ createDownload(url, `${title}.ics`);
131
+ return handle.success();
132
+ };
133
+ function parseTime2Array(time, allDay = false) {
134
+ const t = new Date(time);
135
+ const timeArr = [
136
+ t.getFullYear(),
137
+ t.getMonth() + 1,
138
+ t.getDate(),
139
+ ];
140
+ if (!allDay) {
141
+ timeArr.push(t.getHours(), t.getMinutes());
142
+ }
143
+ return timeArr;
144
+ }
6
145
 
7
146
  export { addPhoneCalendar, addPhoneRepeatCalendar };
8
147
  //# sourceMappingURL=calendar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","sources":["../../../src/api/device/calendar.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 日历\nexport const addPhoneRepeatCalendar = temporarilyNotSupport('addPhoneRepeatCalendar')\nexport const addPhoneCalendar = temporarilyNotSupport('addPhoneCalendar')\n"],"names":[],"mappings":";;AAEA;MACa,sBAAsB,GAAG,qBAAqB,CAAC,wBAAwB,EAAC;MACxE,gBAAgB,GAAG,qBAAqB,CAAC,kBAAkB;;;;"}
1
+ {"version":3,"file":"calendar.js","sources":["../../../src/api/device/calendar.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport * as ics from 'ics'\n\nimport { createDownload, getParameterError, shouldBeObject } from '../../utils'\nimport { MethodHandler } from '../../utils/handler'\n\nimport type { DateArray } from 'ics'\n\n// 日历\nexport const addPhoneRepeatCalendar: typeof Taro.addPhoneRepeatCalendar = (options) => {\n const methodName = 'addPhoneRepeatCalendar'\n // options must be an Object\n const isObject = shouldBeObject(options)\n if (!isObject.flag) {\n const res = { errMsg: `${methodName}:fail ${isObject.msg}` }\n console.error(res.errMsg)\n return Promise.reject(res)\n }\n\n const {\n title,\n startTime = new Date().getTime(),\n allDay = false,\n description = '',\n location = '',\n endTime,\n alarm = true,\n alarmOffset = 0,\n repeatInterval = 'month',\n repeatEndTime,\n success,\n fail,\n complete,\n } = options\n const handle = new MethodHandler({ name: methodName, success, fail, complete })\n if (typeof title !== 'string') {\n return handle.fail({\n errMsg: getParameterError({\n para: 'title',\n correct: 'String',\n wrong: title\n })\n })\n }\n\n const start = new Date(startTime)\n const end = new Date(endTime || startTime)\n if (!endTime && allDay) {\n end.setDate(end.getDate() + 1)\n }\n\n const interval = 1000 * 60 * 60 * 24\n let days = 1\n let repeat = 1\n if (repeatEndTime) {\n const repeatEnd = new Date(repeatEndTime)\n if (repeatEnd < start) {\n return handle.fail({\n errMsg: 'repeatEndTime must be greater than startTime'\n })\n }\n switch (repeatInterval) {\n case 'week':\n days = 7\n break\n case 'month':\n days = 30\n break\n case 'year':\n days = 365\n break\n default:\n }\n repeat = Math.ceil((repeatEnd.getTime() - start.getTime()) / (interval * days))\n }\n const { error, value } = ics.createEvent({\n title,\n start: parseTime2Array(start, allDay),\n description,\n location,\n end: parseTime2Array(end, allDay),\n alarms: alarm ? [{\n action: 'display',\n description,\n trigger: {\n before: true,\n seconds: alarmOffset,\n },\n duration: {\n days,\n },\n repeat,\n }] : [],\n })\n if (error || !value) {\n return handle.fail({\n errMsg: error?.message\n })\n }\n const url = URL.createObjectURL(new Blob([value]))\n createDownload(url, `${title}.ics`)\n return handle.success()\n}\n\nexport const addPhoneCalendar: typeof Taro.addPhoneCalendar = (options) => {\n const methodName = 'addPhoneCalendar'\n // options must be an Object\n const isObject = shouldBeObject(options)\n if (!isObject.flag) {\n const res = { errMsg: `${methodName}:fail ${isObject.msg}` }\n console.error(res.errMsg)\n return Promise.reject(res)\n }\n\n const {\n title,\n startTime = new Date().getTime(),\n allDay = false,\n description = '',\n location = '',\n endTime,\n alarm = true,\n alarmOffset = 0,\n success,\n fail,\n complete,\n } = options\n const handle = new MethodHandler({ name: methodName, success, fail, complete })\n if (typeof title !== 'string') {\n return handle.fail({\n errMsg: getParameterError({\n para: 'title',\n correct: 'String',\n wrong: title\n })\n })\n }\n\n const start = new Date(startTime)\n const end = new Date(endTime || startTime)\n if (!endTime && allDay) {\n end.setDate(end.getDate() + 1)\n }\n const { error, value } = ics.createEvent({\n title,\n start: parseTime2Array(start, allDay),\n description,\n location,\n end: parseTime2Array(end, allDay),\n alarms: alarm ? [{\n action: 'display',\n description,\n trigger: {\n before: true,\n seconds: alarmOffset,\n },\n }] : [],\n })\n if (error || !value) {\n return handle.fail({\n errMsg: error?.message\n })\n }\n const url = URL.createObjectURL(new Blob([value]))\n createDownload(url, `${title}.ics`)\n return handle.success()\n}\n\nfunction parseTime2Array (time: Date, allDay = false): DateArray {\n const t = new Date(time)\n const timeArr: DateArray = [\n t.getFullYear(),\n t.getMonth() + 1,\n t.getDate(),\n ]\n if (!allDay) {\n timeArr.push(t.getHours(), t.getMinutes())\n }\n return timeArr\n}\n"],"names":[],"mappings":";;;;;AAQA;AACa,MAAA,sBAAsB,GAAuC,CAAC,OAAO,KAAI;IACpF,MAAM,UAAU,GAAG,wBAAwB,CAAA;;AAE3C,IAAA,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;AACxC,IAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;AAClB,QAAA,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,CAAA,EAAG,UAAU,CAAA,MAAA,EAAS,QAAQ,CAAC,GAAG,CAAA,CAAE,EAAE,CAAA;AAC5D,QAAA,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACzB,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAC3B,KAAA;IAED,MAAM,EACJ,KAAK,EACL,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAChC,MAAM,GAAG,KAAK,EACd,WAAW,GAAG,EAAE,EAChB,QAAQ,GAAG,EAAE,EACb,OAAO,EACP,KAAK,GAAG,IAAI,EACZ,WAAW,GAAG,CAAC,EACf,cAAc,GAAG,OAAO,EACxB,aAAa,EACb,OAAO,EACP,IAAI,EACJ,QAAQ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MAAM,OAAO,GAAc;QACzB,CAAC,CAAC,WAAW,EAAE;AACf,QAAA,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC;QAChB,CAAC,CAAC,OAAO,EAAE;KACZ,CAAA;IACD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAA;AAC3C,KAAA;AACD,IAAA,OAAO,OAAO,CAAA;AAChB;;;;"}
@@ -1,7 +1,6 @@
1
- import '../../utils/index.js';
1
+ import throttle from 'lodash-es/throttle';
2
2
  import { CallbackManager, MethodHandler } from '../../utils/handler.js';
3
3
  import { getDeviceInfo } from '../base/system.js';
4
- import { throttle } from '../../utils/lodash.js';
5
4
 
6
5
  const callbackManager = new CallbackManager();
7
6
  let compassListener;
@@ -1 +1 @@
1
- {"version":3,"file":"compass.js","sources":["../../../src/api/device/compass.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\n\r\nimport { throttle } from '../../utils'\r\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\r\nimport { getDeviceInfo } from '../base/system'\r\n\r\nconst callbackManager = new CallbackManager()\r\nlet compassListener\r\n\r\n/**\r\n * Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation\r\n */\r\nconst deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {\r\n if ('on' + item in window) {\r\n return item\r\n }\r\n}) || ''\r\n\r\n/**\r\n * 停止监听罗盘数据\r\n */\r\nexport const stopCompass: typeof Taro.stopCompass = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete })\r\n try {\r\n window.removeEventListener(deviceorientationEventName, compassListener, true)\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\nlet CompassChangeTrigger = false\r\n/**\r\n * 开始监听罗盘数据\r\n */\r\nexport const startCompass: typeof Taro.startCompass = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'startCompass', success, fail, complete })\r\n try {\r\n if (deviceorientationEventName !== '') {\r\n if (compassListener) {\r\n stopCompass()\r\n }\r\n compassListener = throttle((evt: DeviceOrientationEvent) => {\r\n const isAndroid = getDeviceInfo().system === 'AndroidOS'\r\n if (isAndroid && !evt.absolute && !CompassChangeTrigger) {\r\n CompassChangeTrigger = true\r\n console.warn('Warning: In \\'onCompassChange\\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .')\r\n }\r\n const alpha = evt.alpha || 0\r\n /**\r\n * 由于平台差异,accuracy 在 iOS/Android 的值不同。\r\n * - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。\r\n * - Android:accuracy 是一个 string 类型的枚举值。\r\n */\r\n const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha\r\n callbackManager.trigger({\r\n direction: 360 - alpha,\r\n accuracy: accuracy\r\n } as unknown as Parameters<typeof Taro.onCompassChange>[number])\r\n }, 5000)\r\n window.addEventListener(deviceorientationEventName, compassListener, true)\r\n } else {\r\n throw new Error('compass is not supported')\r\n }\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。\r\n */\r\nexport const onCompassChange: typeof Taro.onCompassChange = callback => {\r\n callbackManager.add(callback)\r\n}\r\n\r\n/**\r\n * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。\r\n */\r\nexport const offCompassChange: typeof Taro.offCompassChange = callback => {\r\n callbackManager.remove(callback)\r\n}\r\n"],"names":[],"mappings":";;;;;AAMA,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,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3,"file":"compass.js","sources":["../../../src/api/device/compass.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\nimport throttle from 'lodash-es/throttle'\r\n\r\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\r\nimport { getDeviceInfo } from '../base/system'\r\n\r\nconst callbackManager = new CallbackManager()\r\nlet compassListener\r\n\r\n/**\r\n * Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation\r\n */\r\nconst deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {\r\n if ('on' + item in window) {\r\n return item\r\n }\r\n}) || ''\r\n\r\n/**\r\n * 停止监听罗盘数据\r\n */\r\nexport const stopCompass: typeof Taro.stopCompass = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete })\r\n try {\r\n window.removeEventListener(deviceorientationEventName, compassListener, true)\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\nlet CompassChangeTrigger = false\r\n/**\r\n * 开始监听罗盘数据\r\n */\r\nexport const startCompass: typeof Taro.startCompass = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'startCompass', success, fail, complete })\r\n try {\r\n if (deviceorientationEventName !== '') {\r\n if (compassListener) {\r\n stopCompass()\r\n }\r\n compassListener = throttle((evt: DeviceOrientationEvent) => {\r\n const isAndroid = getDeviceInfo().system === 'AndroidOS'\r\n if (isAndroid && !evt.absolute && !CompassChangeTrigger) {\r\n CompassChangeTrigger = true\r\n console.warn('Warning: In \\'onCompassChange\\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .')\r\n }\r\n const alpha = evt.alpha || 0\r\n /**\r\n * 由于平台差异,accuracy 在 iOS/Android 的值不同。\r\n * - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。\r\n * - Android:accuracy 是一个 string 类型的枚举值。\r\n */\r\n const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha\r\n callbackManager.trigger({\r\n direction: 360 - alpha,\r\n accuracy: accuracy\r\n } as unknown as Parameters<typeof Taro.onCompassChange>[number])\r\n }, 5000)\r\n window.addEventListener(deviceorientationEventName, compassListener, true)\r\n } else {\r\n throw new Error('compass is not supported')\r\n }\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。\r\n */\r\nexport const onCompassChange: typeof Taro.onCompassChange = callback => {\r\n callbackManager.add(callback)\r\n}\r\n\r\n/**\r\n * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。\r\n */\r\nexport const offCompassChange: typeof Taro.offCompassChange = callback => {\r\n callbackManager.remove(callback)\r\n}\r\n"],"names":[],"mappings":";;;;AAMA,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,IAAI,eAAe,CAAA;AAEnB;;AAEG;AACH,MAAM,0BAA0B,GAAG,CAAC,2BAA2B,EAAE,2BAA2B,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,IAAG;AAC7H,IAAA,IAAI,IAAI,GAAG,IAAI,IAAI,MAAM,EAAE;AACzB,QAAA,OAAO,IAAI,CAAA;AACZ,KAAA;AACH,CAAC,CAAC,IAAI,EAAE,CAAA;AAER;;AAEG;AACI,MAAM,WAAW,GAA4B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI;AACvF,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAClF,IAAI;QACF,MAAM,CAAC,mBAAmB,CAAC,0BAA0B,EA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C,iBAAA,CAAC,CAAA;aACjE,EAAE,IAAI,CAAC,CAAA;YACR,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,eAAe,EAAE,IAAI,CAAC,CAAA;AAC3E,SAAA;AAAM,aAAA;AACL,YAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;AAC5C,SAAA;AACD,QAAA,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;AACxB,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAC1C,KAAA;AACH,EAAC;AAED;;AAEG;AACU,MAAA,eAAe,GAAgC,QAAQ,IAAG;AACrE,IAAA,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/B,EAAC;AAED;;AAEG;AACU,MAAA,gBAAgB,GAAiC,QAAQ,IAAG;AACvE,IAAA,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAClC;;;;"}
@@ -1,8 +1,8 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
3
  // 联系人
4
- const chooseContact = temporarilyNotSupport('chooseContact');
5
- const addPhoneContact = temporarilyNotSupport('addPhoneContact');
4
+ const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact');
5
+ const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact');
6
6
 
7
7
  export { addPhoneContact, chooseContact };
8
8
  //# sourceMappingURL=contact.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contact.js","sources":["../../../src/api/device/contact.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 联系人\nexport const chooseContact = temporarilyNotSupport('chooseContact')\nexport const addPhoneContact = temporarilyNotSupport('addPhoneContact')\n"],"names":[],"mappings":";;AAEA;MACa,aAAa,GAAG,qBAAqB,CAAC,eAAe,EAAC;MACtD,eAAe,GAAG,qBAAqB,CAAC,iBAAiB;;;;"}
1
+ {"version":3,"file":"contact.js","sources":["../../../src/api/device/contact.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 联系人\nexport const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact')\nexport const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,aAAa,mBAAmB,qBAAqB,CAAC,eAAe,EAAC;AACtE,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { temporarilyNotSupport } from '../../utils/index.js';
2
2
 
3
3
  // 加密
4
- const getRandomValues = temporarilyNotSupport('getRandomValues');
4
+ const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues');
5
5
 
6
6
  export { getRandomValues };
7
7
  //# sourceMappingURL=crypto.js.map