@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.
- package/README.md +0 -7
- package/dist/index.js +1236 -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 +25 -23
- package/static/@taro-oh/library-4.1.1-alpha.0.har +0 -0
- package/LICENSE +0 -174
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import fs from '@ohos.file.fs'
|
|
2
|
+
import photoAccessHelper from '@ohos.file.photoAccessHelper'
|
|
3
|
+
import image from '@ohos.multimedia.image'
|
|
4
|
+
import { Current, eventCenter } from '@tarojs/runtime'
|
|
5
|
+
import { isNull } from '@tarojs/shared'
|
|
6
|
+
|
|
7
|
+
import { getSystemInfoSync } from '../../base'
|
|
8
|
+
import {
|
|
9
|
+
callAsyncFail,
|
|
10
|
+
callAsyncSuccess,
|
|
11
|
+
ETS_METHODS_TRIGGER_EVENTNAME,
|
|
12
|
+
MethodHandler,
|
|
13
|
+
temporarilyNotSupport,
|
|
14
|
+
validateParams,
|
|
15
|
+
} from '../../utils'
|
|
16
|
+
|
|
17
|
+
import type Taro from '@tarojs/taro/types'
|
|
18
|
+
|
|
19
|
+
const scope = 'media'
|
|
20
|
+
const type = 'method'
|
|
21
|
+
|
|
22
|
+
export const previewImage: typeof Taro.previewImage = function (options) {
|
|
23
|
+
const name = 'previewImage'
|
|
24
|
+
const { success, fail, complete } = options
|
|
25
|
+
const handle = new MethodHandler({ name, success, fail, complete })
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
|
|
28
|
+
name,
|
|
29
|
+
args: [options],
|
|
30
|
+
scope,
|
|
31
|
+
type,
|
|
32
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
33
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject }),
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface IPackingOptionOHOS {
|
|
39
|
+
format: string
|
|
40
|
+
quality: number
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface IChooseImageData {
|
|
44
|
+
tempFilePaths?: string[]
|
|
45
|
+
|
|
46
|
+
tempFiles?: {
|
|
47
|
+
path: string
|
|
48
|
+
size: number
|
|
49
|
+
}[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const getImageInfoSchema = {
|
|
53
|
+
src: 'String',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const compressImageSchema = {
|
|
57
|
+
src: 'String',
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const chooseImageSchema = {
|
|
61
|
+
count: 'Number',
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions()
|
|
65
|
+
|
|
66
|
+
export const getImageInfo: typeof Taro.getImageInfo = function (options) {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
try {
|
|
69
|
+
validateParams('getImageInfo', options, getImageInfoSchema)
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const res = { errMsg: error.message }
|
|
72
|
+
return callAsyncFail(reject, res, options)
|
|
73
|
+
}
|
|
74
|
+
const { src } = options
|
|
75
|
+
// FIX: 调试发现在版本api7中 source 为 undefined, 需鸿蒙侧确认
|
|
76
|
+
const source = image.createImageSource(src)
|
|
77
|
+
if (isNull(source)) {
|
|
78
|
+
const createImageSourceError = { errMsg: 'getImageInfo fail: createImageSource has failed.' }
|
|
79
|
+
callAsyncFail(reject, createImageSourceError, options)
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
source
|
|
83
|
+
.getImageInfo()
|
|
84
|
+
.then((value) => {
|
|
85
|
+
callAsyncSuccess(resolve, value, options)
|
|
86
|
+
})
|
|
87
|
+
.catch((error) => {
|
|
88
|
+
callAsyncFail(reject, error, options)
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class CompressedImageInfo {
|
|
94
|
+
imageUri = '' // 压缩后图片保存位置的uri
|
|
95
|
+
imageByteLength = 0 // 压缩后图片字节长度
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function saveImage(compressedImageData, compressedImageUri) {
|
|
99
|
+
const tempArr = compressedImageUri.split('/')
|
|
100
|
+
const name = tempArr[tempArr.length - 1]
|
|
101
|
+
const context = getContext(Current?.page)
|
|
102
|
+
const applicationContext = context.getApplicationContext()
|
|
103
|
+
const tempDir = applicationContext.tempDir
|
|
104
|
+
const filePath = `${tempDir}/${name}`
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const res = fs.accessSync(filePath)
|
|
108
|
+
if (res) {
|
|
109
|
+
// 如果图片afterCompressiona.jpeg已存在,则删除
|
|
110
|
+
fs.unlinkSync(filePath)
|
|
111
|
+
}
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.error(
|
|
114
|
+
`[Taro] saveImage Error: AccessSync failed with error message: ${err.message}, error code: ${err.code}`
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 知识点:保存图片。获取最终图片压缩数据compressedImageData,保存图片。
|
|
119
|
+
// 压缩图片数据写入文件
|
|
120
|
+
const file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE)
|
|
121
|
+
fs.writeSync(file.fd, compressedImageData)
|
|
122
|
+
fs.closeSync(file)
|
|
123
|
+
|
|
124
|
+
// 获取压缩图片信息
|
|
125
|
+
const compressedImageInfo = new CompressedImageInfo()
|
|
126
|
+
compressedImageInfo.imageUri = filePath
|
|
127
|
+
compressedImageInfo.imageByteLength = compressedImageData.byteLength
|
|
128
|
+
|
|
129
|
+
return compressedImageInfo
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const compressImage: typeof Taro.compressImage = function (options) {
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
try {
|
|
135
|
+
validateParams('compressImage', options, compressImageSchema)
|
|
136
|
+
} catch (error) {
|
|
137
|
+
const res = { errMsg: error.message }
|
|
138
|
+
return callAsyncFail(reject, res, options)
|
|
139
|
+
}
|
|
140
|
+
const { src, quality = 80, compressedWidth, compressedHeight } = options
|
|
141
|
+
let srcAfterCompress = src.includes('_after_compress') ? src : src.split('.').join('_after_compress.')
|
|
142
|
+
eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
|
|
143
|
+
name: 'compressImage',
|
|
144
|
+
args: [src, quality, compressedWidth, compressedHeight],
|
|
145
|
+
scope: 'taskpool',
|
|
146
|
+
type: 'method',
|
|
147
|
+
successHandler(pixelMap) {
|
|
148
|
+
const packer = image.createImagePacker()
|
|
149
|
+
if (isNull(packer)) {
|
|
150
|
+
const createImagePackerError = { errMsg: 'compressImage fail: createImagePacker has failed.' }
|
|
151
|
+
callAsyncFail(reject, createImagePackerError, options)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
const isPNG = src.endsWith('.png')
|
|
155
|
+
const suffix = isPNG ? 'png' : 'jpeg'
|
|
156
|
+
const packingOptionsOHOS: IPackingOptionOHOS = {
|
|
157
|
+
format: isPNG ? 'image/png' : 'image/jpeg',
|
|
158
|
+
quality: quality,
|
|
159
|
+
}
|
|
160
|
+
const temp = srcAfterCompress.split('.')
|
|
161
|
+
temp[temp.length - 1] = suffix
|
|
162
|
+
srcAfterCompress = temp.join('.')
|
|
163
|
+
packer
|
|
164
|
+
.packing(pixelMap, packingOptionsOHOS)
|
|
165
|
+
.then((value) => {
|
|
166
|
+
saveImage(value, srcAfterCompress).then((result) => {
|
|
167
|
+
callAsyncSuccess(resolve, { tempFilePath: result.imageUri }, options)
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
.catch((error) => {
|
|
171
|
+
callAsyncFail(reject, error, options)
|
|
172
|
+
})
|
|
173
|
+
},
|
|
174
|
+
errorHandler(res) {
|
|
175
|
+
callAsyncFail(reject, res, options)
|
|
176
|
+
},
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const chooseImage: typeof Taro.chooseImage = function (options) {
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
try {
|
|
184
|
+
validateParams('chooseImage', options, chooseImageSchema)
|
|
185
|
+
} catch (error) {
|
|
186
|
+
const res = { errMsg: error.message }
|
|
187
|
+
return callAsyncFail(reject, res, options)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const { count = 9 } = options
|
|
191
|
+
const photoViewPicker = new photoAccessHelper.PhotoViewPicker()
|
|
192
|
+
let sizeType = options.sizeType
|
|
193
|
+
|
|
194
|
+
if (!sizeType || !sizeType.length) {
|
|
195
|
+
sizeType = ['compressed', 'original']
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
photoSelectOptions.maxSelectNumber = count // 选择媒体文件的最大数目
|
|
199
|
+
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE // 过滤选择媒体文件类型为IMAGE
|
|
200
|
+
photoSelectOptions.isOriginalSupported = true // 支持选择原图
|
|
201
|
+
photoViewPicker
|
|
202
|
+
.select(photoSelectOptions)
|
|
203
|
+
.then((photoSelectResult) => {
|
|
204
|
+
const result: IChooseImageData = {}
|
|
205
|
+
const isOrigin = photoSelectResult.isOriginalPhoto
|
|
206
|
+
|
|
207
|
+
if (isOrigin) {
|
|
208
|
+
const getSizeAction = photoSelectResult.photoUris.map((uri) => {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
|
|
211
|
+
name: 'getImageSize',
|
|
212
|
+
args: [uri],
|
|
213
|
+
scope: 'taskpool',
|
|
214
|
+
type: 'method',
|
|
215
|
+
successHandler({ data }) {
|
|
216
|
+
resolve({
|
|
217
|
+
size: data,
|
|
218
|
+
path: uri,
|
|
219
|
+
})
|
|
220
|
+
},
|
|
221
|
+
errorHandler(res) {
|
|
222
|
+
reject(res)
|
|
223
|
+
},
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
Promise.all(getSizeAction).then((tempFiles) => {
|
|
228
|
+
result.tempFiles = tempFiles
|
|
229
|
+
result.tempFilePaths = tempFiles.map((item) => item.path)
|
|
230
|
+
callAsyncSuccess(resolve, result, options)
|
|
231
|
+
})
|
|
232
|
+
} else {
|
|
233
|
+
const actions: Promise<string>[] = photoSelectResult.photoUris.map((uri) => {
|
|
234
|
+
return new Promise<string>((resolve, reject) => {
|
|
235
|
+
compressImage({
|
|
236
|
+
src: uri,
|
|
237
|
+
compressedWidth: getSystemInfoSync().screenWidth / 2,
|
|
238
|
+
compressedHeight: getSystemInfoSync().screenHeight / 2,
|
|
239
|
+
success: (compressResult) => {
|
|
240
|
+
resolve(compressResult.tempFilePath)
|
|
241
|
+
},
|
|
242
|
+
fail: (err) => {
|
|
243
|
+
reject(err)
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
const sizeAction = actions.map((p) => {
|
|
250
|
+
return new Promise<{ size: number, path: string }>((resolve, reject) => {
|
|
251
|
+
p.then((uri) => {
|
|
252
|
+
eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
|
|
253
|
+
name: 'getImageSize',
|
|
254
|
+
args: [uri],
|
|
255
|
+
scope: 'taskpool',
|
|
256
|
+
type: 'method',
|
|
257
|
+
successHandler({ data }) {
|
|
258
|
+
resolve({
|
|
259
|
+
size: data,
|
|
260
|
+
path: uri,
|
|
261
|
+
})
|
|
262
|
+
},
|
|
263
|
+
errorHandler(res) {
|
|
264
|
+
reject(res)
|
|
265
|
+
},
|
|
266
|
+
})
|
|
267
|
+
}).catch((e) => {
|
|
268
|
+
reject(e)
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
Promise.all(sizeAction)
|
|
274
|
+
.then((tempFiles) => {
|
|
275
|
+
result.tempFilePaths = tempFiles.map((item) => item.path)
|
|
276
|
+
result.tempFiles = tempFiles
|
|
277
|
+
callAsyncSuccess(resolve, result, options)
|
|
278
|
+
})
|
|
279
|
+
.catch((error) => {
|
|
280
|
+
const res = { errMsg: error }
|
|
281
|
+
return callAsyncFail(reject, res, options)
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
})
|
|
285
|
+
.catch((error) => {
|
|
286
|
+
callAsyncFail(reject, error, options)
|
|
287
|
+
})
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum')
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './audio'
|
|
2
|
+
export * from './background-audio'
|
|
3
|
+
export * from './camera'
|
|
4
|
+
export * from './common'
|
|
5
|
+
export * from './image'
|
|
6
|
+
export * from './live'
|
|
7
|
+
export * from './map'
|
|
8
|
+
export * from './media-recorder'
|
|
9
|
+
export * from './recorder'
|
|
10
|
+
export * from './video'
|
|
11
|
+
export * from './video-decoder'
|
|
12
|
+
export * from './video-processing'
|
|
13
|
+
export * from './voip'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 实时音视频
|
|
4
|
+
export const createLivePusherContext = /* @__PURE__ */ temporarilyNotSupport('createLivePusherContext')
|
|
5
|
+
export const createLivePlayerContext = /* @__PURE__ */ temporarilyNotSupport('createLivePlayerContext')
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 录音
|
|
4
|
+
export const stopRecord = /* @__PURE__ */ temporarilyNotSupport('stopRecord')
|
|
5
|
+
export const startRecord = /* @__PURE__ */ temporarilyNotSupport('startRecord')
|
|
6
|
+
export const getRecorderManager = /* @__PURE__ */ temporarilyNotSupport('getRecorderManager')
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { document } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
4
|
+
|
|
5
|
+
import type { TaroVideoElement } from '@tarojs/runtime'
|
|
6
|
+
import type Taro from '@tarojs/taro/types'
|
|
7
|
+
|
|
8
|
+
export class VideoContext implements Taro.VideoContext {
|
|
9
|
+
id: string
|
|
10
|
+
|
|
11
|
+
video: TaroVideoElement
|
|
12
|
+
|
|
13
|
+
controller: VideoController
|
|
14
|
+
|
|
15
|
+
constructor (id: string) {
|
|
16
|
+
this.id = id
|
|
17
|
+
this.video = document.getElementById(id)
|
|
18
|
+
|
|
19
|
+
if (this.video) {
|
|
20
|
+
this.controller = this.video.controller
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
play () {
|
|
25
|
+
if (!this.controller) return
|
|
26
|
+
|
|
27
|
+
this.controller.play()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
pause () {
|
|
31
|
+
if (!this.controller) return
|
|
32
|
+
|
|
33
|
+
this.controller.pause()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
stop () {
|
|
37
|
+
if (!this.controller) return
|
|
38
|
+
|
|
39
|
+
this.controller.stop()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
seek (position: number) {
|
|
43
|
+
if (!this.controller) return
|
|
44
|
+
|
|
45
|
+
this.controller.setCurrentTime(position)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
requestFullScreen () {
|
|
49
|
+
if (!this.controller) return
|
|
50
|
+
|
|
51
|
+
this.controller.requestFullscreen(true)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exitFullScreen () {
|
|
55
|
+
if (!this.controller) return
|
|
56
|
+
|
|
57
|
+
this.controller.exitFullscreen()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback')
|
|
61
|
+
exitBackgroundPlayback = temporarilyNotSupport('VideoContext.exitBackgroundPlayback')
|
|
62
|
+
exitPictureInPicture = temporarilyNotSupport('VideoContext.exitPictureInPicture')
|
|
63
|
+
hideStatusBar = temporarilyNotSupport('VideoContext.hideStatusBar')
|
|
64
|
+
playbackRate = temporarilyNotSupport('VideoContext.playbackRate')
|
|
65
|
+
sendDanmu = temporarilyNotSupport('VideoContext.sendDanmu')
|
|
66
|
+
showStatusBar = temporarilyNotSupport('VideoContext.showStatusBar')
|
|
67
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import photoAccessHelper from '@ohos.file.photoAccessHelper'
|
|
2
|
+
|
|
3
|
+
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
|
|
4
|
+
import { VideoContext } from './VideoContext'
|
|
5
|
+
|
|
6
|
+
import type { TaroAny } from '@tarojs/runtime'
|
|
7
|
+
import type Taro from '@tarojs/taro/types'
|
|
8
|
+
|
|
9
|
+
export const createVideoContext: typeof Taro.createVideoContext = (id: string, _: TaroAny) => {
|
|
10
|
+
return new VideoContext(id)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// TODO: 1.返回属性补全
|
|
14
|
+
// TODO: 2.只支持从相册选择,补充摄像头拍摄功能,需要HarmonyOS提供选择组件
|
|
15
|
+
export const chooseVideo: typeof Taro.chooseVideo = function (options = {}) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
try {
|
|
18
|
+
validateParams('chooseVideo', [options], ['Object'])
|
|
19
|
+
} catch (error) {
|
|
20
|
+
const res = { errMsg: error.message }
|
|
21
|
+
return callAsyncFail(reject, res, options)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const photoViewPicker = new photoAccessHelper.PhotoViewPicker()
|
|
25
|
+
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions()
|
|
26
|
+
photoSelectOptions.maxSelectNumber = 9 // 选择媒体文件的最大数目
|
|
27
|
+
photoSelectOptions.MIMEType = photoAccessHelper.PhotoViewMIMETypes.VIDEO_TYPE // 过滤选择媒体文件类型为IMAGE
|
|
28
|
+
photoSelectOptions.isOriginalSupported = true // 支持选择原图
|
|
29
|
+
photoViewPicker
|
|
30
|
+
.select(photoSelectOptions)
|
|
31
|
+
.then((photoSelectResult) => {
|
|
32
|
+
const uris = photoSelectResult.photoUris
|
|
33
|
+
callAsyncSuccess(resolve, { tempFilePaths: uris })
|
|
34
|
+
})
|
|
35
|
+
.catch((error) => {
|
|
36
|
+
callAsyncFail(reject, error, options)
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const compressVideo = /* @__PURE__ */ temporarilyNotSupport('compressVideo')
|
|
42
|
+
export const getVideoInfo = /* @__PURE__ */ temporarilyNotSupport('getVideoInfo')
|
|
43
|
+
export const openVideoEditor = /* @__PURE__ */ temporarilyNotSupport('openVideoEditor')
|
|
44
|
+
|
|
45
|
+
export const saveVideoToPhotosAlbum = temporarilyNotSupport('saveVideoToPhotosAlbum')
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 实时语音
|
|
4
|
+
export const updateVoIPChatMuteConfig = /* @__PURE__ */ temporarilyNotSupport('updateVoIPChatMuteConfig')
|
|
5
|
+
export const subscribeVoIPVideoMembers = /* @__PURE__ */ temporarilyNotSupport('subscribeVoIPVideoMembers')
|
|
6
|
+
export const setEnable1v1Chat = /* @__PURE__ */ temporarilyNotSupport('setEnable1v1Chat')
|
|
7
|
+
export const onVoIPVideoMembersChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPVideoMembersChanged')
|
|
8
|
+
export const onVoIPChatStateChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatStateChanged')
|
|
9
|
+
export const onVoIPChatSpeakersChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatSpeakersChanged')
|
|
10
|
+
export const onVoIPChatMembersChanged = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatMembersChanged')
|
|
11
|
+
export const onVoIPChatInterrupted = /* @__PURE__ */ temporarilyNotSupport('onVoIPChatInterrupted')
|
|
12
|
+
export const offVoIPChatSpeakersChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatSpeakersChanged')
|
|
13
|
+
export const offVoIPVideoMembersChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPVideoMembersChanged')
|
|
14
|
+
export const offVoIPChatStateChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatStateChanged')
|
|
15
|
+
export const offVoIPChatMembersChanged = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatMembersChanged')
|
|
16
|
+
export const offVoIPChatInterrupted = /* @__PURE__ */ temporarilyNotSupport('offVoIPChatInterrupted')
|
|
17
|
+
export const joinVoIPChat = /* @__PURE__ */ temporarilyNotSupport('joinVoIPChat')
|
|
18
|
+
export const join1v1Chat = /* @__PURE__ */ temporarilyNotSupport('join1v1Chat')
|
|
19
|
+
export const exitVoIPChat = /* @__PURE__ */ temporarilyNotSupport('exitVoIPChat')
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// 跳转
|
|
4
|
+
export const openEmbeddedMiniProgram = /* @__PURE__ */ temporarilyNotSupport('openEmbeddedMiniProgram')
|
|
5
|
+
export const navigateToMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateToMiniProgram')
|
|
6
|
+
export const navigateBackMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateBackMiniProgram')
|
|
7
|
+
export const exitMiniProgram = /* @__PURE__ */ temporarilyNotSupport('exitMiniProgram')
|
|
8
|
+
export const openBusinessView = /* @__PURE__ */ temporarilyNotSupport('openBusinessView')
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { ETS_METHODS_TRIGGER_EVENTNAME, MethodHandler, validateParams } from '../utils'
|
|
4
|
+
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
7
|
+
const downloadFileSchema = {
|
|
8
|
+
url: 'String'
|
|
9
|
+
}
|
|
10
|
+
export const downloadFile: typeof Taro.uploadFile = function (options) {
|
|
11
|
+
let task
|
|
12
|
+
let isComplete = false
|
|
13
|
+
const progressHandles: ((args: { progress: number }) => any)[] = []
|
|
14
|
+
const requestTask: any = new Promise((resolve, reject) => {
|
|
15
|
+
const { url, header, filePath, success, fail, complete } = options
|
|
16
|
+
const handle = new MethodHandler<any>({ name: 'downloadFile', success, fail, complete })
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
validateParams('downloadFile', options, downloadFileSchema)
|
|
20
|
+
} catch (error) {
|
|
21
|
+
const res = { errMsg: error.message }
|
|
22
|
+
return handle.fail(res, { resolve, reject })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const params = {
|
|
26
|
+
url,
|
|
27
|
+
header,
|
|
28
|
+
filePath,
|
|
29
|
+
context: getContext(this),
|
|
30
|
+
success: (requestData: object) => {
|
|
31
|
+
const reswx = {
|
|
32
|
+
data: requestData
|
|
33
|
+
}
|
|
34
|
+
handle.success(reswx, { resolve, reject })
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
fail: (data) => {
|
|
38
|
+
handle.fail(data, { resolve, reject })
|
|
39
|
+
},
|
|
40
|
+
complete: () => {
|
|
41
|
+
isComplete = true
|
|
42
|
+
},
|
|
43
|
+
progress: (loaded, total) => {
|
|
44
|
+
const progress = loaded / total
|
|
45
|
+
progressHandles.forEach(fn => fn({ progress }))
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
|
|
50
|
+
name: 'downloadFile',
|
|
51
|
+
args: [params],
|
|
52
|
+
scope: 'network',
|
|
53
|
+
type: 'method',
|
|
54
|
+
onInit: (obj) => {
|
|
55
|
+
task = obj
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
requestTask.abort = function () {
|
|
61
|
+
task?.abort?.()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
requestTask.onProgressUpdate = (fn:(args: { progress: number }) => any) => {
|
|
65
|
+
if (isComplete) {
|
|
66
|
+
fn({ progress: 1 })
|
|
67
|
+
} else {
|
|
68
|
+
task?.onProgressUpdate(fn)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
requestTask.offProgressUpdate = (fn:(args: { progress: number }) => any) => {
|
|
73
|
+
task?.offProgressUpdate?.(fn)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
requestTask.onHeadersReceived = (fn:(args: { header: object }) => any) => {
|
|
77
|
+
task?.onHeadersReceived?.(fn)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
requestTask.offHeadersReceived = (fn:(args: { header: object }) => any) => {
|
|
81
|
+
task?.offHeadersReceived?.(fn)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return requestTask
|
|
85
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
// mDNS
|
|
4
|
+
export const stopLocalServiceDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopLocalServiceDiscovery')
|
|
5
|
+
export const startLocalServiceDiscovery = /* @__PURE__ */ temporarilyNotSupport('startLocalServiceDiscovery')
|
|
6
|
+
export const onLocalServiceResolveFail = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceResolveFail')
|
|
7
|
+
export const onLocalServiceLost = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceLost')
|
|
8
|
+
export const onLocalServiceFound = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceFound')
|
|
9
|
+
export const onLocalServiceDiscoveryStop = /* @__PURE__ */ temporarilyNotSupport('onLocalServiceDiscoveryStop')
|
|
10
|
+
export const offLocalServiceResolveFail = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceResolveFail')
|
|
11
|
+
export const offLocalServiceLost = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceLost')
|
|
12
|
+
export const offLocalServiceFound = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceFound')
|
|
13
|
+
export const offLocalServiceDiscoveryStop = /* @__PURE__ */ temporarilyNotSupport('offLocalServiceDiscoveryStop')
|