@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,48 @@
|
|
|
1
|
+
import { Current, getCurrentInstance } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../utils'
|
|
4
|
+
|
|
5
|
+
import type { TaroAny } from '@tarojs/runtime'
|
|
6
|
+
|
|
7
|
+
export const ENV_TYPE = {
|
|
8
|
+
WEAPP: 'WEAPP',
|
|
9
|
+
SWAN: 'SWAN',
|
|
10
|
+
ALIPAY: 'ALIPAY',
|
|
11
|
+
TT: 'TT',
|
|
12
|
+
QQ: 'QQ',
|
|
13
|
+
JD: 'JD',
|
|
14
|
+
WEB: 'WEB',
|
|
15
|
+
RN: 'RN',
|
|
16
|
+
HARMONY: 'HARMONY',
|
|
17
|
+
QUICKAPP: 'QUICKAPP'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getEnv () {
|
|
21
|
+
return ENV_TYPE.HARMONY
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// TODO
|
|
25
|
+
export const getCurrentPages = () => []
|
|
26
|
+
|
|
27
|
+
export { Current, getCurrentInstance }
|
|
28
|
+
|
|
29
|
+
export const requirePlugin = temporarilyNotSupport('requirePlugin')
|
|
30
|
+
|
|
31
|
+
/** 鸿蒙专属 */
|
|
32
|
+
export function updatePageSync () {
|
|
33
|
+
const node = (getCurrentInstance()?.page as TaroAny)?.node
|
|
34
|
+
|
|
35
|
+
if (!node) return
|
|
36
|
+
|
|
37
|
+
Current.nativeModule.updatePageSync(node)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function unstable_SetPageIsTextNeedLayout(isNeed: boolean) {
|
|
41
|
+
const node = (getCurrentInstance()?.page as TaroAny)?.node
|
|
42
|
+
|
|
43
|
+
if (!node) return
|
|
44
|
+
|
|
45
|
+
Current.nativeModule.unstable_SetPageIsTextNeedLayout(node, isNeed)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { eventCenter, Events, History } from '@tarojs/runtime'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { eventCenter } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { ETS_METHODS_TRIGGER_EVENTNAME, MethodHandler } from '../utils'
|
|
4
|
+
|
|
5
|
+
import type { TaroAny } from '@tarojs/runtime'
|
|
6
|
+
|
|
7
|
+
const scope = 'taskpool'
|
|
8
|
+
const type = 'method'
|
|
9
|
+
|
|
10
|
+
// TaskPool 专属方法
|
|
11
|
+
export const triggerTaskPoolMethods = ({
|
|
12
|
+
name = '',
|
|
13
|
+
args = [],
|
|
14
|
+
complete,
|
|
15
|
+
fail,
|
|
16
|
+
success,
|
|
17
|
+
}: {
|
|
18
|
+
name?: string
|
|
19
|
+
args?: TaroAny[]
|
|
20
|
+
complete?: (res: TaroAny) => void
|
|
21
|
+
fail?: (res: TaroAny) => void
|
|
22
|
+
success?: (res: TaroAny) => void
|
|
23
|
+
} = {}) => {
|
|
24
|
+
if (!name) {
|
|
25
|
+
throw new Error('triggerTaskPoolMethods 方法必须传入 name 参数')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const handle = new MethodHandler({ name, success, fail, complete })
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
|
|
31
|
+
name,
|
|
32
|
+
args,
|
|
33
|
+
scope,
|
|
34
|
+
type,
|
|
35
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
36
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Current, hooks } from '@tarojs/runtime'
|
|
2
|
+
import { PLATFORM_TYPE } from '@tarojs/shared'
|
|
3
|
+
|
|
4
|
+
import * as apis from './apis'
|
|
5
|
+
import { permanentlyNotSupport } from './utils'
|
|
6
|
+
import { initPxTransform, pxTransform } from './utils/unit'
|
|
7
|
+
|
|
8
|
+
const taro = Object.assign({}, apis)
|
|
9
|
+
|
|
10
|
+
const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin')
|
|
11
|
+
export function initNativeApi (taro) {
|
|
12
|
+
Current.taro = taro
|
|
13
|
+
taro.requirePlugin = requirePlugin
|
|
14
|
+
taro.getApp = getApp
|
|
15
|
+
taro.pxTransform = pxTransform
|
|
16
|
+
taro.initPxTransform = initPxTransform
|
|
17
|
+
taro.canIUseWebp = canIUseWebp
|
|
18
|
+
taro.getAppInfo = getAppInfo
|
|
19
|
+
taro.getUIContext = getUIContext
|
|
20
|
+
|
|
21
|
+
if (hooks.isExist('initNativeApi')) {
|
|
22
|
+
hooks.call('initNativeApi', taro)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function getApp () {
|
|
27
|
+
if (Current.page && Current.page.$isUseReact18) {
|
|
28
|
+
return Current.entryAsync || {}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return Current.app || {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export * from './utils/unit'
|
|
35
|
+
|
|
36
|
+
export function canIUseWebp () {
|
|
37
|
+
return true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function getAppInfo () {
|
|
41
|
+
const config = Current.taro?.config
|
|
42
|
+
return {
|
|
43
|
+
platform: process.env.TARO_PLATFORM || PLATFORM_TYPE.HARMONY,
|
|
44
|
+
taroVersion: process.env.TARO_VERSION || 'unknown',
|
|
45
|
+
designWidth: config?.designWidth,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getUIContext () {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
const uiContext = Current?.page?.getUIContext?.()
|
|
52
|
+
|
|
53
|
+
if (!uiContext) return null
|
|
54
|
+
|
|
55
|
+
return uiContext
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
initNativeApi(taro)
|
|
59
|
+
|
|
60
|
+
export * from './apis'
|
|
61
|
+
export default taro
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// HarmonyOS 文档: https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-geolocation-0000001199568865#section13752433138
|
|
2
|
+
// WX 文档: https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html
|
|
3
|
+
// ✅ wx.offLocationChange
|
|
4
|
+
// ✅ wx.getLocation
|
|
5
|
+
// ✅ wx.onLocationChange
|
|
6
|
+
|
|
7
|
+
// 不支持实现
|
|
8
|
+
// ❌ wx.startLocationUpdateBackground
|
|
9
|
+
// ❌ wx.onLocationChangeError
|
|
10
|
+
// ❌ wx.offLocationChangeError
|
|
11
|
+
// ❌ wx.openLocation 地图相关
|
|
12
|
+
// ❌ wx.choosePoi 地图相关
|
|
13
|
+
// ❌ wx.chooseLocation 地图相关
|
|
14
|
+
// ❌ wx.stopLocationUpdate
|
|
15
|
+
// ❌ wx.startLocationUpdate
|
|
16
|
+
|
|
17
|
+
import geoLocationManager from '@ohos.geoLocationManager'
|
|
18
|
+
|
|
19
|
+
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
|
|
20
|
+
import { MethodHandler } from '../utils/handler'
|
|
21
|
+
|
|
22
|
+
import type Taro from '@tarojs/taro/types'
|
|
23
|
+
|
|
24
|
+
interface ILocation {
|
|
25
|
+
latitude: number
|
|
26
|
+
longitude: number
|
|
27
|
+
altitude: number
|
|
28
|
+
accuracy: number
|
|
29
|
+
speed: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 位置
|
|
33
|
+
export const stopLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('stopLocationUpdate')
|
|
34
|
+
export const startLocationUpdateBackground = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdateBackground')
|
|
35
|
+
export const startLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdate')
|
|
36
|
+
export const openLocation = /* @__PURE__ */ temporarilyNotSupport('openLocation')
|
|
37
|
+
|
|
38
|
+
function formatLocation (location: ILocation) {
|
|
39
|
+
const wxLocate = {
|
|
40
|
+
latitude: location.latitude,
|
|
41
|
+
longitude: location.longitude,
|
|
42
|
+
altitude: location.altitude,
|
|
43
|
+
accuracy: location.accuracy,
|
|
44
|
+
speed: location.speed,
|
|
45
|
+
verticalAccuracy: 0, // OHOS 不支持返回此参数,直接设置为默认值
|
|
46
|
+
horizontalAccuracy: 0 // OHOS 不支持返回此参数,直接设置为默认值
|
|
47
|
+
}
|
|
48
|
+
return wxLocate
|
|
49
|
+
}
|
|
50
|
+
// TODO:增加参数校验
|
|
51
|
+
// const getLocationSchema = {
|
|
52
|
+
// type: 'String',
|
|
53
|
+
// altitude: 'Boolean',
|
|
54
|
+
// ishighAccuracy: 'Boolean',
|
|
55
|
+
// highAccuracyExpireTime: 'number'
|
|
56
|
+
// }
|
|
57
|
+
|
|
58
|
+
export const getLocation: typeof Taro.getLocation = function (options = {}) {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
/**
|
|
61
|
+
* ohos 有 priority, scenario, maxAccuracy, timeoutMs
|
|
62
|
+
* wx 有 type, altitude, isHighAccuracy, highAccuracyExpireTime
|
|
63
|
+
* 二者参数不一致
|
|
64
|
+
*/
|
|
65
|
+
const { type, altitude, isHighAccuracy, highAccuracyExpireTime } = options
|
|
66
|
+
try {
|
|
67
|
+
return geoLocationManager.getCurrentLocation({
|
|
68
|
+
type,
|
|
69
|
+
altitude,
|
|
70
|
+
isHighAccuracy,
|
|
71
|
+
highAccuracyExpireTime
|
|
72
|
+
}).then((location: any) => {
|
|
73
|
+
if (location.code !== 0) {
|
|
74
|
+
callAsyncFail(reject, location, options)
|
|
75
|
+
} else {
|
|
76
|
+
const wxLocate = formatLocation(location.data)
|
|
77
|
+
callAsyncSuccess(resolve, wxLocate, options)
|
|
78
|
+
}
|
|
79
|
+
}).catch(error => {
|
|
80
|
+
callAsyncFail(reject, error, options)
|
|
81
|
+
})
|
|
82
|
+
} catch (error) {
|
|
83
|
+
callAsyncFail(reject, error, options)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const onLocationChange: typeof Taro.onLocationChange = function (callback) {
|
|
89
|
+
const name = 'onLocationChange'
|
|
90
|
+
const handle = new MethodHandler<Partial<Taro.onLocationChange.CallbackResult>>({ name, complete: callback })
|
|
91
|
+
try {
|
|
92
|
+
validateParams(name, [callback], ['Function'])
|
|
93
|
+
geoLocationManager.on('locationChange', {}, (location: any) => {
|
|
94
|
+
if (location) {
|
|
95
|
+
const wxLocate = formatLocation(location)
|
|
96
|
+
callback(wxLocate)
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
} catch (error) {
|
|
100
|
+
handle.fail({
|
|
101
|
+
errMsg: error
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const offLocationChange: typeof Taro.offLocationChange = function (callback) {
|
|
107
|
+
const name = 'offLocationChange'
|
|
108
|
+
const handle = new MethodHandler<Partial<Taro.onLocationChange.CallbackResult>>({ name, complete: callback })
|
|
109
|
+
try {
|
|
110
|
+
validateParams(name, [callback], ['Function'])
|
|
111
|
+
geoLocationManager.off('locationChange', (location: any) => {
|
|
112
|
+
const status = {
|
|
113
|
+
errCode: 200,
|
|
114
|
+
errMsg: location ? 'offLocationChange is off' : 'offLocationChange err'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (callback) {
|
|
118
|
+
callback(status as any)
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
} catch (error) {
|
|
122
|
+
handle.fail({
|
|
123
|
+
errMsg: error
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const onLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('onLocationChangeError')
|
|
129
|
+
export const offLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('offLocationChangeError')
|
|
130
|
+
|
|
131
|
+
export const choosePoi = /* @__PURE__ */ temporarilyNotSupport('choosePoi')
|
|
132
|
+
export const chooseLocation = /* @__PURE__ */ temporarilyNotSupport('chooseLocation')
|
|
133
|
+
export const getFuzzyLocation = /* @__PURE__ */ temporarilyNotSupport('getFuzzyLocation')
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
import type Taro from '@tarojs/taro/types'
|
|
4
|
+
|
|
5
|
+
// 富文本
|
|
6
|
+
export class EditorContext implements Taro.EditorContext {
|
|
7
|
+
blur = temporarilyNotSupport('EditorContext.blur')
|
|
8
|
+
|
|
9
|
+
clear = temporarilyNotSupport('EditorContext.clear')
|
|
10
|
+
|
|
11
|
+
format = temporarilyNotSupport('EditorContext.format')
|
|
12
|
+
|
|
13
|
+
getContents = temporarilyNotSupport('EditorContext.getContents')
|
|
14
|
+
|
|
15
|
+
getSelectionText = temporarilyNotSupport('EditorContext.getSelectionText')
|
|
16
|
+
|
|
17
|
+
insertDivider = temporarilyNotSupport('EditorContext.insertDivider')
|
|
18
|
+
|
|
19
|
+
insertImage = temporarilyNotSupport('EditorContext.insertImage')
|
|
20
|
+
|
|
21
|
+
insertText = temporarilyNotSupport('EditorContext.insertText')
|
|
22
|
+
|
|
23
|
+
redo = temporarilyNotSupport('EditorContext.redo')
|
|
24
|
+
|
|
25
|
+
removeFormat = temporarilyNotSupport('EditorContext.removeFormat')
|
|
26
|
+
|
|
27
|
+
scrollIntoView = temporarilyNotSupport('EditorContext.scrollIntoView')
|
|
28
|
+
|
|
29
|
+
setContents = temporarilyNotSupport('EditorContext.setContents')
|
|
30
|
+
|
|
31
|
+
undo = temporarilyNotSupport('EditorContext.undo')
|
|
32
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import audio from '@ohos.multimedia.audio'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
4
|
+
|
|
5
|
+
// 音频
|
|
6
|
+
|
|
7
|
+
export const stopVoice = /* @__PURE__ */ temporarilyNotSupport('stopVoice')
|
|
8
|
+
export const setInnerAudioOption = /* @__PURE__ */ temporarilyNotSupport('setInnerAudioOption')
|
|
9
|
+
export const playVoice = /* @__PURE__ */ temporarilyNotSupport('playVoice')
|
|
10
|
+
export const pauseVoice = /* @__PURE__ */ temporarilyNotSupport('pauseVoice')
|
|
11
|
+
export const getAvailableAudioSources = /* @__PURE__ */ temporarilyNotSupport('getAvailableAudioSources')
|
|
12
|
+
export const createWebAudioContext = /* @__PURE__ */ temporarilyNotSupport('createWebAudioContext')
|
|
13
|
+
export const createMediaAudioPlayer = /* @__PURE__ */ temporarilyNotSupport('createMediaAudioPlayer')
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 创建内部 audio 上下文 InnerAudioContext 对象。
|
|
17
|
+
*/
|
|
18
|
+
export const createInnerAudioContext = /* @__PURE__ */ temporarilyNotSupport('createInnerAudioContext')
|
|
19
|
+
|
|
20
|
+
export const createAudioContext = /* @__PURE__ */ temporarilyNotSupport('createAudioContext')
|
|
21
|
+
|
|
22
|
+
/** Harmony 专属,更新 audio 状态 */
|
|
23
|
+
export const refreshAudioSession = () => {
|
|
24
|
+
const audioManager = audio.getAudioManager()
|
|
25
|
+
const audioSessionManager = audioManager.getSessionManager()
|
|
26
|
+
if (audioSessionManager) {
|
|
27
|
+
audioSessionManager.deactivateAudioSession().then(() => {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
const strategy = {
|
|
30
|
+
concurrencyMode: audio.AudioConcurrencyMode.CONCURRENCY_PAUSE_OTHERS
|
|
31
|
+
}
|
|
32
|
+
audioSessionManager.activateAudioSession(strategy)
|
|
33
|
+
}, 100)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
+
|
|
3
|
+
// 背景音频
|
|
4
|
+
export const stopBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('stopBackgroundAudio')
|
|
5
|
+
export const seekBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('seekBackgroundAudio')
|
|
6
|
+
export const playBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('playBackgroundAudio')
|
|
7
|
+
export const pauseBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('pauseBackgroundAudio')
|
|
8
|
+
export const onBackgroundAudioStop = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioStop')
|
|
9
|
+
export const onBackgroundAudioPlay = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPlay')
|
|
10
|
+
export const onBackgroundAudioPause = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPause')
|
|
11
|
+
export const getBackgroundAudioPlayerState = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioPlayerState')
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 获取全局唯一的背景音频管理器
|
|
15
|
+
*/
|
|
16
|
+
export const getBackgroundAudioManager = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioManager')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
import type Taro from '@tarojs/taro/types'
|
|
4
|
+
|
|
5
|
+
// 相机
|
|
6
|
+
class CameraContext implements Taro.CameraContext {
|
|
7
|
+
onCameraFrame = temporarilyNotSupport('CameraContext.onCameraFrame') as unknown as Taro.CameraContext['onCameraFrame']
|
|
8
|
+
setZoom = temporarilyNotSupport('CameraContext.setZoom')
|
|
9
|
+
startRecord = temporarilyNotSupport('CameraContext.startRecord')
|
|
10
|
+
stopRecord = temporarilyNotSupport('CameraContext.stopRecord')
|
|
11
|
+
takePhoto = temporarilyNotSupport('CameraContext.takePhoto')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const createCameraContext: typeof Taro.createCameraContext = (_?: string) => {
|
|
15
|
+
return new CameraContext()
|
|
16
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-media-0000001103383404
|
|
2
|
+
// WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html
|
|
3
|
+
// ✅ wx.previewMedia(Object object)
|
|
4
|
+
// ✅ wx.chooseMedia
|
|
5
|
+
|
|
6
|
+
import photoAccessHelper from '@ohos.file.photoAccessHelper'
|
|
7
|
+
|
|
8
|
+
import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
|
|
9
|
+
|
|
10
|
+
import type Taro from '@tarojs/taro/types'
|
|
11
|
+
|
|
12
|
+
// TODO: 扩展支持预览video
|
|
13
|
+
export const previewMedia = temporarilyNotSupport('previewMedia')
|
|
14
|
+
|
|
15
|
+
export const chooseMedia: typeof Taro.chooseMedia = function (options) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
try {
|
|
18
|
+
validateParams('chooseMedia', [options], ['Object'])
|
|
19
|
+
} catch (error) {
|
|
20
|
+
const res = { errMsg: error.message }
|
|
21
|
+
return callAsyncFail(reject, res, options)
|
|
22
|
+
}
|
|
23
|
+
const { count = 9, mediaType = ['image'] } = options
|
|
24
|
+
|
|
25
|
+
const mediaTypeAdapter = {
|
|
26
|
+
0b1: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
|
|
27
|
+
0b10: photoAccessHelper.PhotoViewMIMETypes.VIDEO_TYPE,
|
|
28
|
+
0b11: photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const photoViewPicker = new photoAccessHelper.PhotoViewPicker()
|
|
32
|
+
const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions()
|
|
33
|
+
photoSelectOptions.maxSelectNumber = count // 选择媒体文件的最大数目
|
|
34
|
+
photoSelectOptions.MIMEType =
|
|
35
|
+
mediaTypeAdapter[
|
|
36
|
+
mediaType.reduce((acc: number, cur: string) => {
|
|
37
|
+
switch (cur) {
|
|
38
|
+
case 'image':
|
|
39
|
+
return acc | 0b1
|
|
40
|
+
case 'video':
|
|
41
|
+
return acc | 0b10
|
|
42
|
+
default:
|
|
43
|
+
return acc
|
|
44
|
+
}
|
|
45
|
+
}, 0b1)
|
|
46
|
+
]
|
|
47
|
+
photoSelectOptions.isOriginalSupported = true
|
|
48
|
+
photoViewPicker
|
|
49
|
+
.select(photoSelectOptions)
|
|
50
|
+
.then((photoSelectResult) => {
|
|
51
|
+
const uris = photoSelectResult.photoUris
|
|
52
|
+
callAsyncSuccess(resolve, { tempFilePaths: uris })
|
|
53
|
+
})
|
|
54
|
+
.catch((error) => {
|
|
55
|
+
callAsyncFail(reject, error, options)
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
}
|