@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +0 -7
  2. package/dist/index.js +1236 -0
  3. package/dist/runtime/apis/apis.ts +20 -0
  4. package/dist/runtime/apis/base/crypto.ts +4 -0
  5. package/dist/runtime/apis/base/debug.ts +5 -0
  6. package/dist/runtime/apis/base/index.ts +13 -0
  7. package/dist/runtime/apis/base/performance.ts +8 -0
  8. package/dist/runtime/apis/base/system.ts +181 -0
  9. package/dist/runtime/apis/base/update.ts +5 -0
  10. package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
  11. package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
  12. package/dist/runtime/apis/canvas/index.ts +27 -0
  13. package/dist/runtime/apis/data-analysis/index.ts +6 -0
  14. package/dist/runtime/apis/device/accelerometer.ts +79 -0
  15. package/dist/runtime/apis/device/accessibility.ts +4 -0
  16. package/dist/runtime/apis/device/battery.ts +24 -0
  17. package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
  18. package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
  19. package/dist/runtime/apis/device/bluetooth.ts +16 -0
  20. package/dist/runtime/apis/device/calendar.ts +5 -0
  21. package/dist/runtime/apis/device/clipboard.ts +85 -0
  22. package/dist/runtime/apis/device/compass.ts +21 -0
  23. package/dist/runtime/apis/device/contact.ts +5 -0
  24. package/dist/runtime/apis/device/crypto.ts +4 -0
  25. package/dist/runtime/apis/device/gyroscope.ts +77 -0
  26. package/dist/runtime/apis/device/iBeacon.ts +10 -0
  27. package/dist/runtime/apis/device/index.ts +24 -0
  28. package/dist/runtime/apis/device/keyboard.ts +63 -0
  29. package/dist/runtime/apis/device/memory.ts +11 -0
  30. package/dist/runtime/apis/device/motion.ts +6 -0
  31. package/dist/runtime/apis/device/network.ts +123 -0
  32. package/dist/runtime/apis/device/nfc.ts +10 -0
  33. package/dist/runtime/apis/device/phone.ts +44 -0
  34. package/dist/runtime/apis/device/scan.ts +4 -0
  35. package/dist/runtime/apis/device/screen.ts +80 -0
  36. package/dist/runtime/apis/device/sms.ts +4 -0
  37. package/dist/runtime/apis/device/vibrate.ts +32 -0
  38. package/dist/runtime/apis/device/wifi.ts +15 -0
  39. package/dist/runtime/apis/ext/index.ts +5 -0
  40. package/dist/runtime/apis/files/index.ts +136 -0
  41. package/dist/runtime/apis/files/manager.ts +942 -0
  42. package/dist/runtime/apis/framework/index.ts +48 -0
  43. package/dist/runtime/apis/harmony/task-pool.ts +39 -0
  44. package/dist/runtime/apis/index.ts +61 -0
  45. package/dist/runtime/apis/location/index.ts +133 -0
  46. package/dist/runtime/apis/media/EditorContext.ts +32 -0
  47. package/dist/runtime/apis/media/audio/index.ts +36 -0
  48. package/dist/runtime/apis/media/background-audio/index.ts +16 -0
  49. package/dist/runtime/apis/media/camera.ts +16 -0
  50. package/dist/runtime/apis/media/common.ts +58 -0
  51. package/dist/runtime/apis/media/image/index.ts +291 -0
  52. package/dist/runtime/apis/media/index.ts +13 -0
  53. package/dist/runtime/apis/media/live.ts +5 -0
  54. package/dist/runtime/apis/media/map.ts +4 -0
  55. package/dist/runtime/apis/media/media-recorder.ts +4 -0
  56. package/dist/runtime/apis/media/recorder.ts +6 -0
  57. package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
  58. package/dist/runtime/apis/media/video/index.ts +45 -0
  59. package/dist/runtime/apis/media/video-decoder.ts +4 -0
  60. package/dist/runtime/apis/media/video-processing.ts +4 -0
  61. package/dist/runtime/apis/media/voip.ts +19 -0
  62. package/dist/runtime/apis/navigate/index.ts +8 -0
  63. package/dist/runtime/apis/network/downloadFile.ts +85 -0
  64. package/dist/runtime/apis/network/index.ts +7 -0
  65. package/dist/runtime/apis/network/mdns.ts +13 -0
  66. package/dist/runtime/apis/network/request.ts +140 -0
  67. package/dist/runtime/apis/network/tcp.ts +4 -0
  68. package/dist/runtime/apis/network/udp.ts +4 -0
  69. package/dist/runtime/apis/network/uploadFile.ts +105 -0
  70. package/dist/runtime/apis/network/webSocket.ts +126 -0
  71. package/dist/runtime/apis/open-api/account.ts +4 -0
  72. package/dist/runtime/apis/open-api/address.ts +4 -0
  73. package/dist/runtime/apis/open-api/authorize.ts +5 -0
  74. package/dist/runtime/apis/open-api/card.ts +5 -0
  75. package/dist/runtime/apis/open-api/channels-live.ts +11 -0
  76. package/dist/runtime/apis/open-api/customer-service.ts +4 -0
  77. package/dist/runtime/apis/open-api/device-voip.ts +5 -0
  78. package/dist/runtime/apis/open-api/facial.ts +7 -0
  79. package/dist/runtime/apis/open-api/favorites.ts +5 -0
  80. package/dist/runtime/apis/open-api/group.ts +4 -0
  81. package/dist/runtime/apis/open-api/index.ts +21 -0
  82. package/dist/runtime/apis/open-api/invoice.ts +5 -0
  83. package/dist/runtime/apis/open-api/license-plate.ts +4 -0
  84. package/dist/runtime/apis/open-api/login.ts +6 -0
  85. package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
  86. package/dist/runtime/apis/open-api/privacy.ts +7 -0
  87. package/dist/runtime/apis/open-api/red-package.ts +4 -0
  88. package/dist/runtime/apis/open-api/settings.ts +5 -0
  89. package/dist/runtime/apis/open-api/soter.ts +6 -0
  90. package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
  91. package/dist/runtime/apis/open-api/user-info.ts +70 -0
  92. package/dist/runtime/apis/open-api/werun.ts +5 -0
  93. package/dist/runtime/apis/payment/index.ts +6 -0
  94. package/dist/runtime/apis/route/index.ts +88 -0
  95. package/dist/runtime/apis/share/index.ts +33 -0
  96. package/dist/runtime/apis/storage/background-fetch.ts +7 -0
  97. package/dist/runtime/apis/storage/cache-manager.ts +4 -0
  98. package/dist/runtime/apis/storage/index.ts +203 -0
  99. package/dist/runtime/apis/ui/animation/animation.ts +264 -0
  100. package/dist/runtime/apis/ui/animation/index.ts +7 -0
  101. package/dist/runtime/apis/ui/background.ts +20 -0
  102. package/dist/runtime/apis/ui/custom-component.ts +1 -0
  103. package/dist/runtime/apis/ui/fonts.ts +4 -0
  104. package/dist/runtime/apis/ui/index.ts +12 -0
  105. package/dist/runtime/apis/ui/interaction/index.ts +198 -0
  106. package/dist/runtime/apis/ui/menu.ts +4 -0
  107. package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
  108. package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
  109. package/dist/runtime/apis/ui/scroll/index.ts +82 -0
  110. package/dist/runtime/apis/ui/sticky.ts +4 -0
  111. package/dist/runtime/apis/ui/tab-bar.ts +144 -0
  112. package/dist/runtime/apis/ui/window.ts +20 -0
  113. package/dist/runtime/apis/utils/constant.ts +1 -0
  114. package/dist/runtime/apis/utils/handler.ts +117 -0
  115. package/dist/runtime/apis/utils/index.ts +105 -0
  116. package/dist/runtime/apis/utils/permissions.ts +6 -0
  117. package/dist/runtime/apis/utils/types.ts +12 -0
  118. package/dist/runtime/apis/utils/unit.ts +104 -0
  119. package/dist/runtime/apis/utils/validate.ts +87 -0
  120. package/dist/runtime/apis/worker/index.ts +4 -0
  121. package/dist/runtime/apis/wxml/index.ts +17 -0
  122. package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
  123. package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
  124. package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
  125. package/dist/runtime/apischunk/index.d.ts +802 -0
  126. package/dist/runtime/apischunk/index.js +5054 -0
  127. package/dist/runtime/components/deprecated.ets +43 -0
  128. package/dist/runtime/components/index.ets +49 -0
  129. package/dist/runtime/components/innerHtml.ets +16 -0
  130. package/dist/runtime/components/navigationBar.ets +65 -0
  131. package/dist/runtime/components/pageMeta.ets +94 -0
  132. package/dist/runtime/components/richText.ets +24 -0
  133. package/dist/runtime/components/slider.ets +119 -0
  134. package/dist/runtime/components/style.ets +286 -0
  135. package/dist/runtime/components/switch.ets +73 -0
  136. package/dist/runtime/components/tag.ts +58 -0
  137. package/dist/runtime/components/utils/AttributeManager.ets +252 -0
  138. package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
  139. package/dist/runtime/components/utils/constant/event.ets +25 -0
  140. package/dist/runtime/components/utils/constant/style.ets +91 -0
  141. package/dist/runtime/components/utils/events.ts +26 -0
  142. package/dist/runtime/components/utils/flexManager.ets +49 -0
  143. package/dist/runtime/components/utils/helper.ets +51 -0
  144. package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
  145. package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
  146. package/dist/runtime/components/utils/index.ts +77 -0
  147. package/dist/runtime/components/utils/styles.ets +41 -0
  148. package/dist/runtime/components/video.ets +119 -0
  149. package/dist/runtime/components/webView.ets +55 -0
  150. package/dist/runtime/components/xComponent.ets +89 -0
  151. package/dist/runtime/framework/app.ts +248 -0
  152. package/dist/runtime/framework/connect.ts +24 -0
  153. package/dist/runtime/framework/constant.ts +3 -0
  154. package/dist/runtime/framework/hooks.ts +99 -0
  155. package/dist/runtime/framework/index.ts +15 -0
  156. package/dist/runtime/framework/native-page.ts +511 -0
  157. package/dist/runtime/framework/page.ts +256 -0
  158. package/dist/runtime/framework/utils/index.ts +17 -0
  159. package/dist/runtime/framework/utils/is.ts +26 -0
  160. package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
  161. package/dist/runtime/framework-reconciler/constant.ts +86 -0
  162. package/dist/runtime/framework-reconciler/domInput.ts +90 -0
  163. package/dist/runtime/framework-reconciler/event.ts +108 -0
  164. package/dist/runtime/framework-reconciler/index.ts +99 -0
  165. package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
  166. package/dist/runtime/framework-reconciler/props.ts +132 -0
  167. package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
  168. package/dist/runtime/framework-reconciler/render.ts +139 -0
  169. package/dist/runtime/framework-reconciler/workTags.ts +53 -0
  170. package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
  171. package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
  172. package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
  173. package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
  174. package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
  175. package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
  176. package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
  177. package/dist/runtime/runtime-cpp/constant.ts +29 -0
  178. package/dist/runtime/runtime-cpp/current.ts +48 -0
  179. package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
  180. package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
  181. package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
  182. package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
  183. package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
  184. package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
  185. package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
  186. package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
  187. package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
  188. package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
  189. package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
  190. package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
  191. package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
  192. package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
  193. package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
  194. package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
  195. package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
  196. package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
  197. package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
  198. package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
  199. package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
  200. package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
  201. package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
  202. package/dist/runtime/runtime-cpp/env.ts +1 -0
  203. package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
  204. package/dist/runtime/runtime-cpp/index.ts +79 -0
  205. package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
  206. package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
  207. package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
  208. package/dist/runtime/runtime-cpp/system.ts +213 -0
  209. package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
  210. package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
  211. package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
  212. package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
  213. package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
  214. package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
  215. package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
  216. package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
  217. package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
  218. package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
  219. package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
  220. package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
  221. package/dist/runtime/runtime-harmony/index.ets +41 -0
  222. package/dist/runtime/runtime-harmony/utils.ts +53 -0
  223. package/package.json +25 -23
  224. package/static/@taro-oh/library-4.1.1-alpha.0.har +0 -0
  225. package/LICENSE +0 -174
@@ -0,0 +1,140 @@
1
+ import { eventCenter } from '@tarojs/runtime'
2
+
3
+ import { ETS_METHODS_TRIGGER_EVENTNAME, MethodHandler, validateParams } from '../utils'
4
+
5
+ import type { TaroAny } from '@tarojs/runtime'
6
+ import type Taro from '@tarojs/taro/types'
7
+
8
+ type TRequest = typeof Taro.request
9
+ const METHOD: string [] = ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'CONNECT']
10
+
11
+ const scope = 'network'
12
+ const type = 'method'
13
+ const requestSchema = {
14
+ url: 'String',
15
+ }
16
+ /**
17
+ * 请求成功返回类型
18
+ */
19
+ interface SuccessResponseType {
20
+ status: number
21
+ statusText: string
22
+ data: TaroAny
23
+ headers: TaroAny
24
+ }
25
+
26
+ interface FailResponseType extends Error {
27
+ code: number
28
+ customProps?: string
29
+ errorType?: string
30
+ }
31
+
32
+ interface IRequestTask {
33
+ abort: () => void
34
+ onHeadersReceived: (callback: (res: TaroAny) => void) => void
35
+ offHeadersReceived: (callback?: (res: TaroAny) => void) => void
36
+ onChunkReceived: (callback: (res: TaroAny) => void) => void
37
+ offChunkReceived: (callback?: (res: TaroAny) => void) => void
38
+ }
39
+
40
+ export const request: TRequest = (options) => {
41
+ let task: IRequestTask
42
+ const requestTask: any = new Promise((resolve, reject) => {
43
+ let { method = 'GET' } = options
44
+ const {
45
+ url,
46
+ header = {},
47
+ timeout = 60000,
48
+ dataType = 'json',
49
+ data,
50
+ enableHttpDNS = false,
51
+ success,
52
+ fail,
53
+ complete,
54
+ } = options
55
+
56
+ const handle = new MethodHandler<any>({ name: 'request', success, fail, complete })
57
+
58
+ // ** 校验入参 **
59
+ const isGetRequest = method.toUpperCase() === 'GET'
60
+ if (!isGetRequest) {
61
+ // -> 1.没有 content-type 的加上默认 application/json
62
+ const keyOfContentType = Object.keys(header).find((item) => item.toLowerCase() === 'content-type')
63
+ !keyOfContentType && (header['Content-Type'] = 'application/json')
64
+ }
65
+
66
+ // -> 2. 检查 method 是否正确
67
+ if (METHOD.includes(method.toUpperCase())) {
68
+ method = method.toUpperCase() as keyof Taro.request.Method
69
+ } else {
70
+ const error = {
71
+ errMsg: `request fail parameter error: the method value should be one of the ${METHOD.join(',')}`,
72
+ }
73
+ handle.fail(error, { resolve, reject })
74
+ }
75
+
76
+ // -> 3. 校验send的数据类型
77
+ try {
78
+ validateParams('send', options, requestSchema)
79
+ } catch (error) {
80
+ const res = { errMsg: error.message }
81
+ handle.fail(res, { resolve, reject })
82
+ }
83
+
84
+ // ** 校验入参 **
85
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
86
+ name: 'request',
87
+ args: [
88
+ {
89
+ ...options,
90
+ url,
91
+ method: method.toUpperCase(),
92
+ header,
93
+ timeout,
94
+ dataType,
95
+ data: data as string,
96
+ enableSuccessResponse: true,
97
+ enableHttpDNS,
98
+ success: (requestData: SuccessResponseType) => {
99
+ const reswx = {
100
+ data: requestData.data,
101
+ statusCode: requestData.status,
102
+ headers: requestData.headers,
103
+ }
104
+ handle.success(reswx, { resolve, reject })
105
+ },
106
+ fail: (data: FailResponseType) => {
107
+ handle.fail(data, { resolve, reject })
108
+ },
109
+ },
110
+ ],
111
+ scope,
112
+ type,
113
+ onInit: (obj) => {
114
+ task = obj
115
+ },
116
+ })
117
+ })
118
+
119
+ requestTask.abort = function () {
120
+ task?.abort?.()
121
+ }
122
+
123
+ requestTask.onHeadersReceived = (fn: (args: { header: object }) => any) => {
124
+ task?.onHeadersReceived?.(fn)
125
+ }
126
+
127
+ requestTask.offHeadersReceived = (fn: (args: { header: object }) => any) => {
128
+ task?.offHeadersReceived?.(fn)
129
+ }
130
+
131
+ requestTask.onChunkReceived = (fn: (args: { chunk: object }) => any) => {
132
+ task?.onChunkReceived?.(fn)
133
+ }
134
+
135
+ requestTask.offChunkReceived = (fn: (args: { chunk: object }) => any) => {
136
+ task?.offChunkReceived?.(fn)
137
+ }
138
+
139
+ return requestTask
140
+ }
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // TCP 通信
4
+ export const createTCPSocket = /* @__PURE__ */ temporarilyNotSupport('createTCPSocket')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // UDP 通信
4
+ export const createUDPSocket = /* @__PURE__ */ temporarilyNotSupport('createUDPSocket')
@@ -0,0 +1,105 @@
1
+ import { eventCenter } from '@tarojs/runtime'
2
+
3
+ import { ETS_METHODS_TRIGGER_EVENTNAME, MethodHandler, validateParams } from '../utils'
4
+
5
+ import type { TaroAny } from '@tarojs/runtime'
6
+ import type Taro from '@tarojs/taro/types'
7
+
8
+ const uploadSchema = {
9
+ url: 'String',
10
+ // filePath: 'String',
11
+ // name: 'String'
12
+ }
13
+
14
+ interface IUploadTask {
15
+ abort: () => void
16
+ onProgressUpdate: (callback: (res: TaroAny) => void) => void
17
+ offProgressUpdate: (callback?: (res: TaroAny) => void) => void
18
+ onHeadersReceived: (callback: (res: TaroAny) => void) => void
19
+ offHeadersReceived: (callback?: (res: TaroAny) => void) => void
20
+ }
21
+
22
+ export const uploadFile: typeof Taro.uploadFile = function (options) {
23
+ let task: IUploadTask
24
+ let isComplete = false
25
+ const progressHandles: ((args: { progress: number }) => any)[] = []
26
+ const requestTask: any = new Promise((resolve, reject) => {
27
+ // let timer
28
+ const { url, filePath, name, formData, header = {}, success, fail, complete } = options
29
+
30
+ const handle = new MethodHandler<any>({ name: 'uploadFile', success, fail, complete })
31
+
32
+ // -> 1.校验url格式
33
+ try {
34
+ validateParams('uploadFile', options, uploadSchema)
35
+ } catch (error) {
36
+ const res = { errMsg: error.message }
37
+ return handle.fail(res, { resolve, reject })
38
+ }
39
+
40
+
41
+ const param: Record<string, TaroAny> = {
42
+ url,
43
+ filePath,
44
+ formData,
45
+ name,
46
+ method: 'POST',
47
+ context: getContext(this),
48
+ header,
49
+ success: (requestData: object) => {
50
+ const reswx = {
51
+ data: requestData
52
+ }
53
+ handle.success(reswx, { resolve, reject })
54
+ },
55
+
56
+ fail: (data) => {
57
+ handle.fail(data, { resolve, reject })
58
+ },
59
+ complete: () => {
60
+ isComplete = true
61
+ },
62
+ progress: (loaded, total) => {
63
+ const progress = loaded / total
64
+ progressHandles.forEach(fn => fn({ progress }))
65
+ }
66
+ }
67
+
68
+
69
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
70
+ name: 'uploadFile',
71
+ args: [param],
72
+ scope: 'network',
73
+ type: 'method',
74
+ onInit: (obj) => {
75
+ task = obj
76
+ }
77
+ })
78
+ })
79
+
80
+ requestTask.abort = function () {
81
+ task?.abort?.()
82
+ }
83
+
84
+ requestTask.onProgressUpdate = (fn:(args: { progress: number }) => any) => {
85
+ if (isComplete) {
86
+ fn({ progress: 1 })
87
+ } else {
88
+ task?.onProgressUpdate(fn)
89
+ }
90
+ }
91
+
92
+ requestTask.offProgressUpdate = (fn:(args: { progress: number }) => any) => {
93
+ task?.offProgressUpdate?.(fn)
94
+ }
95
+
96
+ requestTask.onHeadersReceived = (fn:(args: { header: object }) => any) => {
97
+ task?.onHeadersReceived?.(fn)
98
+ }
99
+
100
+ requestTask.offHeadersReceived = (fn:(args: { header: object }) => any) => {
101
+ task?.offHeadersReceived?.(fn)
102
+ }
103
+
104
+ return requestTask
105
+ }
@@ -0,0 +1,126 @@
1
+ // OpenHarmony 不支持全局操作 WebSocket
2
+ // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-net-websocket-0000001168304641
3
+ // WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/wx.sendSocketMessage.html
4
+ // ✅ wx.connectSocket
5
+ // ✅ SocketTask
6
+ // ✅ SocketTask.close
7
+ // ✅ SocketTask.onClose
8
+ // ✅ SocketTask.onError
9
+ // ✅ SocketTask.onMessage
10
+ // ✅ SocketTask.onOpen
11
+ // ✅ SocketTask.send
12
+
13
+ // ❌ wx.sendSocketMessage
14
+ // ❌ wx.onSocketOpen
15
+ // ❌ wx.onSocketMessage
16
+ // ❌ wx.onSocketError
17
+ // ❌ wx.onSocketClose
18
+ // ❌ wx.closeSocket
19
+
20
+ import webSocket from '@ohos.net.webSocket'
21
+
22
+ import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils'
23
+
24
+ import type Taro from '@tarojs/taro/types'
25
+
26
+ const connectSocketSchema = {
27
+ url: 'String'
28
+ }
29
+
30
+ // const closetSocketSchema = {
31
+ // code: 'Number',
32
+ // reason: 'String'
33
+ // }
34
+
35
+ const sendSocketSchema = {
36
+ data: 'String'
37
+ }
38
+
39
+ export const connectSocket: typeof Taro.connectSocket = function (options) {
40
+ let ws
41
+ const SocketTaskWX: any = new Promise((resolve, reject) => {
42
+ ws = webSocket.createWebSocket()
43
+
44
+ const { url, header } = options
45
+
46
+ try {
47
+ validateParams('uploadFile', options, connectSocketSchema)
48
+ } catch (error) {
49
+ const res = { errMsg: error.message }
50
+ return callAsyncFail(reject, res, options)
51
+ }
52
+
53
+ const result = {
54
+ errMsg: 'websocket connect success'
55
+ }
56
+ ws.connect(url, { header }).then((value) => {
57
+ callAsyncSuccess(resolve, value, options)
58
+ }).catch((err) => {
59
+ result.errMsg = 'websocket connect fail'
60
+ callAsyncFail(reject, err, options)
61
+ })
62
+ })
63
+
64
+ SocketTaskWX.close = function (closeOptions) {
65
+ return new Promise((resolve, reject) => {
66
+ // TODO: 检验非必须参数
67
+ // try {
68
+ // validateParams('close', options, closeSocketSchema)
69
+ // } catch (error) {
70
+ // const res = { errMsg: error.message }
71
+ // return callAsyncFail(reject, res, options)
72
+ // }
73
+
74
+ ws.close(closeOptions).then(value => {
75
+ callAsyncSuccess(resolve, value, closeOptions)
76
+ }, error => {
77
+ callAsyncFail(reject, error, closeOptions)
78
+ })
79
+ })
80
+ }
81
+ SocketTaskWX.onClose = function (onCloseCallback) {
82
+ validateParams('onClose', [onCloseCallback], ['Function'])
83
+ ws.on('close', (err, value) => {
84
+ onCloseCallback(!err ? value : err)
85
+ })
86
+ }
87
+ SocketTaskWX.onError = function (onErrorCallback) {
88
+ validateParams('onError', [onErrorCallback], ['Function'])
89
+ ws.on('error', (err) => {
90
+ onErrorCallback(err)
91
+ })
92
+ }
93
+ SocketTaskWX.onMessage = function (onMessageCallback?: any) {
94
+ validateParams('onMessage', [onMessageCallback], ['Function'])
95
+ ws.on('onMessage', (err, value) => {
96
+ onMessageCallback(!err ? value : err)
97
+ })
98
+ }
99
+ SocketTaskWX.onOpen = function (onOpenCallback) {
100
+ validateParams('onOpen', [onOpenCallback], ['Function'])
101
+ ws.on('open', (err, value) => {
102
+ // TODO:返回数据字段完全不一样,无法兼容,暂不处理
103
+ // wx:{header, profile}, ohos:{err, value:{status, message}}
104
+ onOpenCallback(!err ? value : err)
105
+ })
106
+ }
107
+ SocketTaskWX.send = function (sendOptions: Taro.SocketTask.SendOption) {
108
+ return new Promise((resolve, reject) => {
109
+ const { data } = sendOptions
110
+ try {
111
+ validateParams('send', sendOptions, sendSocketSchema)
112
+ } catch (error) {
113
+ const res = { errMsg: error.message }
114
+ return callAsyncFail(reject, res, options)
115
+ }
116
+
117
+ ws.send(data).then(value => {
118
+ callAsyncSuccess(resolve, value, sendOptions)
119
+ }, error => {
120
+ callAsyncFail(reject, error, sendOptions)
121
+ })
122
+ })
123
+ }
124
+
125
+ return SocketTaskWX
126
+ }
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 帐号信息
4
+ export const getAccountInfoSync = /* @__PURE__ */ temporarilyNotSupport('getAccountInfoSync')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 收货地址
4
+ export const chooseAddress = /* @__PURE__ */ temporarilyNotSupport('chooseAddress')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 授权
4
+ export const authorizeForMiniProgram = /* @__PURE__ */ temporarilyNotSupport('authorizeForMiniProgram')
5
+ export const authorize = /* @__PURE__ */ temporarilyNotSupport('authorize')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 卡券
4
+ export const openCard = /* @__PURE__ */ temporarilyNotSupport('openCard')
5
+ export const addCard = /* @__PURE__ */ temporarilyNotSupport('addCard')
@@ -0,0 +1,11 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 视频号
4
+ export const reserveChannelsLive = /* @__PURE__ */ temporarilyNotSupport('reserveChannelsLive')
5
+ export const openChannelsUserProfile = /* @__PURE__ */ temporarilyNotSupport('openChannelsUserProfile')
6
+ export const openChannelsLive = /* @__PURE__ */ temporarilyNotSupport('openChannelsLive')
7
+ export const openChannelsEvent = /* @__PURE__ */ temporarilyNotSupport('openChannelsEvent')
8
+ export const openChannelsActivity = /* @__PURE__ */ temporarilyNotSupport('openChannelsActivity')
9
+ export const getChannelsShareKey = /* @__PURE__ */ temporarilyNotSupport('getChannelsShareKey')
10
+ export const getChannelsLiveNoticeInfo = /* @__PURE__ */ temporarilyNotSupport('getChannelsLiveNoticeInfo')
11
+ export const getChannelsLiveInfo = /* @__PURE__ */ temporarilyNotSupport('getChannelsLiveInfo')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 微信客服
4
+ export const openCustomerServiceChat = /* @__PURE__ */ temporarilyNotSupport('openCustomerServiceChat')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 设备(组)音视频通话
4
+ export const requestDeviceVoIP = /* @__PURE__ */ temporarilyNotSupport('requestDeviceVoIP')
5
+ export const getDeviceVoIPList = /* @__PURE__ */ temporarilyNotSupport('getDeviceVoIPList')
@@ -0,0 +1,7 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 过往接口
4
+ export const checkIsSupportFacialRecognition = /* @__PURE__ */ temporarilyNotSupport('checkIsSupportFacialRecognition')
5
+ export const startFacialRecognitionVerify = /* @__PURE__ */ temporarilyNotSupport('startFacialRecognitionVerify')
6
+ export const startFacialRecognitionVerifyAndUploadVideo = /* @__PURE__ */ temporarilyNotSupport('startFacialRecognitionVerifyAndUploadVideo')
7
+ export const faceVerifyForPay = /* @__PURE__ */ temporarilyNotSupport('faceVerifyForPay')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 收藏
4
+ export const addVideoToFavorites = /* @__PURE__ */ temporarilyNotSupport('addVideoToFavorites')
5
+ export const addFileToFavorites = /* @__PURE__ */ temporarilyNotSupport('addFileToFavorites')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 微信群
4
+ export const getGroupEnterInfo = /* @__PURE__ */ temporarilyNotSupport('getGroupEnterInfo')
@@ -0,0 +1,21 @@
1
+ export * from './account'
2
+ export * from './address'
3
+ export * from './authorize'
4
+ export * from './card'
5
+ export * from './channels-live'
6
+ export * from './customer-service'
7
+ export * from './device-voip'
8
+ export * from './facial'
9
+ export * from './favorites'
10
+ export * from './group'
11
+ export * from './invoice'
12
+ export * from './license-plate'
13
+ export * from './login'
14
+ export * from './my-miniprogram'
15
+ export * from './privacy'
16
+ export * from './red-package'
17
+ export * from './settings'
18
+ export * from './soter'
19
+ export * from './subscribe-message'
20
+ export * from './user-info'
21
+ export * from './werun'
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 发票
4
+ export const chooseInvoiceTitle = /* @__PURE__ */ temporarilyNotSupport('chooseInvoiceTitle')
5
+ export const chooseInvoice = /* @__PURE__ */ temporarilyNotSupport('chooseInvoice')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 车牌
4
+ export const chooseLicensePlate = /* @__PURE__ */ temporarilyNotSupport('chooseLicensePlate')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 帐号信息
4
+ export const pluginLogin = /* @__PURE__ */ temporarilyNotSupport('pluginLogin')
5
+ export const login = /* @__PURE__ */ temporarilyNotSupport('login')
6
+ export const checkSession = /* @__PURE__ */ temporarilyNotSupport('checkSession')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 我的小程序
4
+ export const checkIsAddedToMyMiniProgram = /* @__PURE__ */ temporarilyNotSupport('checkIsAddedToMyMiniProgram')
@@ -0,0 +1,7 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 隐私信息授权
4
+ export const requirePrivacyAuthorize = /* @__PURE__ */ temporarilyNotSupport('requirePrivacyAuthorize')
5
+ export const openPrivacyContract = /* @__PURE__ */ temporarilyNotSupport('openPrivacyContract')
6
+ export const onNeedPrivacyAuthorization = /* @__PURE__ */ temporarilyNotSupport('onNeedPrivacyAuthorization')
7
+ export const getPrivacySetting = /* @__PURE__ */ temporarilyNotSupport('getPrivacySetting')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 微信红包
4
+ export const showRedPackage = /* @__PURE__ */ temporarilyNotSupport('showRedPackage')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 设置
4
+ export const openSetting = /* @__PURE__ */ temporarilyNotSupport('openSetting')
5
+ export const getSetting = /* @__PURE__ */ temporarilyNotSupport('getSetting')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 生物认证
4
+ export const startSoterAuthentication = /* @__PURE__ */ temporarilyNotSupport('startSoterAuthentication')
5
+ export const checkIsSupportSoterAuthentication = /* @__PURE__ */ temporarilyNotSupport('checkIsSupportSoterAuthentication')
6
+ export const checkIsSoterEnrolledInDevice = /* @__PURE__ */ temporarilyNotSupport('checkIsSoterEnrolledInDevice')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 订阅消息
4
+ export const requestSubscribeMessage = /* @__PURE__ */ temporarilyNotSupport('requestSubscribeMessage')
5
+ // 订阅设备消息
6
+ export const requestSubscribeDeviceMessage = /* @__PURE__ */ temporarilyNotSupport('requestSubscribeDeviceMessage')
@@ -0,0 +1,70 @@
1
+ /**
2
+ * 用户相关API, Harmony ACE API 6
3
+ *
4
+ * 1. 华为账号场景介绍文档 @see https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides/harmonyos-js-login-0000001151310900
5
+ * 2. 华为账号API参考 @see https://developer.huawei.com/consumer/cn/doc/development/HMSCore-References/harmonyos-js-overview-0000001063532145
6
+ */
7
+
8
+ // import hmsJSAccount from '@hmscore/hms-jsb-account'
9
+ import { temporarilyNotSupport } from '../utils'
10
+
11
+ /**
12
+ * 通过Scope数组获取已登录的对应帐号信息(依赖login行为)
13
+ * @param options
14
+ */
15
+ export const getUserInfo = temporarilyNotSupport('getUserInfo')
16
+ // export function getUserInfo (options) {
17
+ // const { success, fail, complete } = options
18
+ // const res: Record<string, any> = {}
19
+
20
+ // // const result = hmsJSAccount.HuaweiIdAuthManager.getAuthResultWithScopes([hmsJSAccount.PROFILE])
21
+ // const result = null
22
+
23
+ // if (result) {
24
+ // res.data = { userInfo: generateUserInfo(result) }
25
+ // isFunction(success) && success(res)
26
+ // } else {
27
+ // res.errorMsg = 'getUserInfo result data is null'
28
+ // isFunction(fail) && fail(res)
29
+ // }
30
+ // isFunction(complete) && complete(res)
31
+ // }
32
+
33
+ /**
34
+ * 获取用户信息
35
+ */
36
+ export const getUserProfile = temporarilyNotSupport('getUserProfile')
37
+ // export const getUserProfile = (_options) => {
38
+ // return new Promise((resolve, reject) => {
39
+ // const res: Record<string, any> = {}
40
+ // hmsJSAccount.HuaweiIdAuthManager.addAuthScopes([hmsJSAccount.PROFILE])
41
+ // .then(result => {
42
+ // if (result) {
43
+ // res.data = { userInfo: generateUserInfo(result) }
44
+ // callAsyncSuccess(resolve, res, options)
45
+ // } else {
46
+ // res.errorMsg = 'getUserProfile result data is null'
47
+ // callAsyncFail(reject, res, options)
48
+ // }
49
+ // })
50
+ // .catch(error => {
51
+ // callAsyncFail(reject, error, options)
52
+ // })
53
+ // })
54
+ // }
55
+
56
+ // function generateUserInfo (hmsAuthInfo) {
57
+ // const userInfo = {
58
+ // nickName: String,
59
+ // avatarUrl: String,
60
+ // gender: Number,
61
+ // country: String
62
+ // }
63
+ // if (hmsAuthInfo) {
64
+ // userInfo.nickName = hmsAuthInfo.displayName
65
+ // userInfo.avatarUrl = hmsAuthInfo.photoUriString
66
+ // userInfo.gender = hmsAuthInfo.gender
67
+ // userInfo.country = hmsAuthInfo.country
68
+ // }
69
+ // return userInfo
70
+ // }
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 微信运动
4
+ export const shareToWeRun = /* @__PURE__ */ temporarilyNotSupport('shareToWeRun')
5
+ export const getWeRunData = /* @__PURE__ */ temporarilyNotSupport('getWeRunData')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 支付
4
+ export const requestPayment = /* @__PURE__ */ temporarilyNotSupport('requestPayment')
5
+ export const requestPluginPayment = /* @__PURE__ */ temporarilyNotSupport('requestPluginPayment')
6
+ export const requestOrderPayment = /* @__PURE__ */ temporarilyNotSupport('requestOrderPayment')