@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1237 -0
- package/dist/runtime/apis/apis.ts +20 -0
- package/dist/runtime/apis/base/crypto.ts +4 -0
- package/dist/runtime/apis/base/debug.ts +5 -0
- package/dist/runtime/apis/base/index.ts +13 -0
- package/dist/runtime/apis/base/performance.ts +8 -0
- package/dist/runtime/apis/base/system.ts +181 -0
- package/dist/runtime/apis/base/update.ts +5 -0
- package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
- package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/runtime/apis/canvas/index.ts +27 -0
- package/dist/runtime/apis/data-analysis/index.ts +6 -0
- package/dist/runtime/apis/device/accelerometer.ts +79 -0
- package/dist/runtime/apis/device/accessibility.ts +4 -0
- package/dist/runtime/apis/device/battery.ts +24 -0
- package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
- package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/runtime/apis/device/bluetooth.ts +16 -0
- package/dist/runtime/apis/device/calendar.ts +5 -0
- package/dist/runtime/apis/device/clipboard.ts +85 -0
- package/dist/runtime/apis/device/compass.ts +21 -0
- package/dist/runtime/apis/device/contact.ts +5 -0
- package/dist/runtime/apis/device/crypto.ts +4 -0
- package/dist/runtime/apis/device/gyroscope.ts +77 -0
- package/dist/runtime/apis/device/iBeacon.ts +10 -0
- package/dist/runtime/apis/device/index.ts +24 -0
- package/dist/runtime/apis/device/keyboard.ts +63 -0
- package/dist/runtime/apis/device/memory.ts +11 -0
- package/dist/runtime/apis/device/motion.ts +6 -0
- package/dist/runtime/apis/device/network.ts +123 -0
- package/dist/runtime/apis/device/nfc.ts +10 -0
- package/dist/runtime/apis/device/phone.ts +44 -0
- package/dist/runtime/apis/device/scan.ts +4 -0
- package/dist/runtime/apis/device/screen.ts +80 -0
- package/dist/runtime/apis/device/sms.ts +4 -0
- package/dist/runtime/apis/device/vibrate.ts +32 -0
- package/dist/runtime/apis/device/wifi.ts +15 -0
- package/dist/runtime/apis/ext/index.ts +5 -0
- package/dist/runtime/apis/files/index.ts +136 -0
- package/dist/runtime/apis/files/manager.ts +942 -0
- package/dist/runtime/apis/framework/index.ts +48 -0
- package/dist/runtime/apis/harmony/task-pool.ts +39 -0
- package/dist/runtime/apis/index.ts +61 -0
- package/dist/runtime/apis/location/index.ts +133 -0
- package/dist/runtime/apis/media/EditorContext.ts +32 -0
- package/dist/runtime/apis/media/audio/index.ts +36 -0
- package/dist/runtime/apis/media/background-audio/index.ts +16 -0
- package/dist/runtime/apis/media/camera.ts +16 -0
- package/dist/runtime/apis/media/common.ts +58 -0
- package/dist/runtime/apis/media/image/index.ts +291 -0
- package/dist/runtime/apis/media/index.ts +13 -0
- package/dist/runtime/apis/media/live.ts +5 -0
- package/dist/runtime/apis/media/map.ts +4 -0
- package/dist/runtime/apis/media/media-recorder.ts +4 -0
- package/dist/runtime/apis/media/recorder.ts +6 -0
- package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
- package/dist/runtime/apis/media/video/index.ts +45 -0
- package/dist/runtime/apis/media/video-decoder.ts +4 -0
- package/dist/runtime/apis/media/video-processing.ts +4 -0
- package/dist/runtime/apis/media/voip.ts +19 -0
- package/dist/runtime/apis/navigate/index.ts +8 -0
- package/dist/runtime/apis/network/downloadFile.ts +85 -0
- package/dist/runtime/apis/network/index.ts +7 -0
- package/dist/runtime/apis/network/mdns.ts +13 -0
- package/dist/runtime/apis/network/request.ts +140 -0
- package/dist/runtime/apis/network/tcp.ts +4 -0
- package/dist/runtime/apis/network/udp.ts +4 -0
- package/dist/runtime/apis/network/uploadFile.ts +105 -0
- package/dist/runtime/apis/network/webSocket.ts +126 -0
- package/dist/runtime/apis/open-api/account.ts +4 -0
- package/dist/runtime/apis/open-api/address.ts +4 -0
- package/dist/runtime/apis/open-api/authorize.ts +5 -0
- package/dist/runtime/apis/open-api/card.ts +5 -0
- package/dist/runtime/apis/open-api/channels-live.ts +11 -0
- package/dist/runtime/apis/open-api/customer-service.ts +4 -0
- package/dist/runtime/apis/open-api/device-voip.ts +5 -0
- package/dist/runtime/apis/open-api/facial.ts +7 -0
- package/dist/runtime/apis/open-api/favorites.ts +5 -0
- package/dist/runtime/apis/open-api/group.ts +4 -0
- package/dist/runtime/apis/open-api/index.ts +21 -0
- package/dist/runtime/apis/open-api/invoice.ts +5 -0
- package/dist/runtime/apis/open-api/license-plate.ts +4 -0
- package/dist/runtime/apis/open-api/login.ts +6 -0
- package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/runtime/apis/open-api/privacy.ts +7 -0
- package/dist/runtime/apis/open-api/red-package.ts +4 -0
- package/dist/runtime/apis/open-api/settings.ts +5 -0
- package/dist/runtime/apis/open-api/soter.ts +6 -0
- package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
- package/dist/runtime/apis/open-api/user-info.ts +70 -0
- package/dist/runtime/apis/open-api/werun.ts +5 -0
- package/dist/runtime/apis/payment/index.ts +6 -0
- package/dist/runtime/apis/route/index.ts +88 -0
- package/dist/runtime/apis/share/index.ts +33 -0
- package/dist/runtime/apis/storage/background-fetch.ts +7 -0
- package/dist/runtime/apis/storage/cache-manager.ts +4 -0
- package/dist/runtime/apis/storage/index.ts +203 -0
- package/dist/runtime/apis/ui/animation/animation.ts +264 -0
- package/dist/runtime/apis/ui/animation/index.ts +7 -0
- package/dist/runtime/apis/ui/background.ts +20 -0
- package/dist/runtime/apis/ui/custom-component.ts +1 -0
- package/dist/runtime/apis/ui/fonts.ts +4 -0
- package/dist/runtime/apis/ui/index.ts +12 -0
- package/dist/runtime/apis/ui/interaction/index.ts +198 -0
- package/dist/runtime/apis/ui/menu.ts +4 -0
- package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
- package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
- package/dist/runtime/apis/ui/scroll/index.ts +82 -0
- package/dist/runtime/apis/ui/sticky.ts +4 -0
- package/dist/runtime/apis/ui/tab-bar.ts +144 -0
- package/dist/runtime/apis/ui/window.ts +20 -0
- package/dist/runtime/apis/utils/constant.ts +1 -0
- package/dist/runtime/apis/utils/handler.ts +117 -0
- package/dist/runtime/apis/utils/index.ts +105 -0
- package/dist/runtime/apis/utils/permissions.ts +6 -0
- package/dist/runtime/apis/utils/types.ts +12 -0
- package/dist/runtime/apis/utils/unit.ts +104 -0
- package/dist/runtime/apis/utils/validate.ts +87 -0
- package/dist/runtime/apis/worker/index.ts +4 -0
- package/dist/runtime/apis/wxml/index.ts +17 -0
- package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
- package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
- package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
- package/dist/runtime/apischunk/index.d.ts +802 -0
- package/dist/runtime/apischunk/index.js +5054 -0
- package/dist/runtime/components/deprecated.ets +43 -0
- package/dist/runtime/components/index.ets +49 -0
- package/dist/runtime/components/innerHtml.ets +16 -0
- package/dist/runtime/components/navigationBar.ets +65 -0
- package/dist/runtime/components/pageMeta.ets +94 -0
- package/dist/runtime/components/richText.ets +24 -0
- package/dist/runtime/components/slider.ets +119 -0
- package/dist/runtime/components/style.ets +286 -0
- package/dist/runtime/components/switch.ets +73 -0
- package/dist/runtime/components/tag.ts +58 -0
- package/dist/runtime/components/utils/AttributeManager.ets +252 -0
- package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
- package/dist/runtime/components/utils/constant/event.ets +25 -0
- package/dist/runtime/components/utils/constant/style.ets +91 -0
- package/dist/runtime/components/utils/events.ts +26 -0
- package/dist/runtime/components/utils/flexManager.ets +49 -0
- package/dist/runtime/components/utils/helper.ets +51 -0
- package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
- package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
- package/dist/runtime/components/utils/index.ts +77 -0
- package/dist/runtime/components/utils/styles.ets +41 -0
- package/dist/runtime/components/video.ets +119 -0
- package/dist/runtime/components/webView.ets +55 -0
- package/dist/runtime/components/xComponent.ets +89 -0
- package/dist/runtime/framework/app.ts +248 -0
- package/dist/runtime/framework/connect.ts +24 -0
- package/dist/runtime/framework/constant.ts +3 -0
- package/dist/runtime/framework/hooks.ts +99 -0
- package/dist/runtime/framework/index.ts +15 -0
- package/dist/runtime/framework/native-page.ts +511 -0
- package/dist/runtime/framework/page.ts +256 -0
- package/dist/runtime/framework/utils/index.ts +17 -0
- package/dist/runtime/framework/utils/is.ts +26 -0
- package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
- package/dist/runtime/framework-reconciler/constant.ts +86 -0
- package/dist/runtime/framework-reconciler/domInput.ts +90 -0
- package/dist/runtime/framework-reconciler/event.ts +108 -0
- package/dist/runtime/framework-reconciler/index.ts +99 -0
- package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
- package/dist/runtime/framework-reconciler/props.ts +132 -0
- package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
- package/dist/runtime/framework-reconciler/render.ts +139 -0
- package/dist/runtime/framework-reconciler/workTags.ts +53 -0
- package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
- package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
- package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
- package/dist/runtime/runtime-cpp/constant.ts +29 -0
- package/dist/runtime/runtime-cpp/current.ts +48 -0
- package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
- package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
- package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
- package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
- package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
- package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
- package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
- package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
- package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
- package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
- package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
- package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
- package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
- package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
- package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
- package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
- package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
- package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
- package/dist/runtime/runtime-cpp/env.ts +1 -0
- package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
- package/dist/runtime/runtime-cpp/index.ts +79 -0
- package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
- package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
- package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
- package/dist/runtime/runtime-cpp/system.ts +213 -0
- package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
- package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
- package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
- package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
- package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
- package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
- package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
- package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
- package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
- package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
- package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
- package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
- package/dist/runtime/runtime-harmony/index.ets +41 -0
- package/dist/runtime/runtime-harmony/utils.ts +53 -0
- package/package.json +24 -23
- 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,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,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,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,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,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,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,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,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')
|