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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +0 -7
  2. package/dist/index.js +1236 -0
  3. package/dist/runtime/apis/apis.ts +20 -0
  4. package/dist/runtime/apis/base/crypto.ts +4 -0
  5. package/dist/runtime/apis/base/debug.ts +5 -0
  6. package/dist/runtime/apis/base/index.ts +13 -0
  7. package/dist/runtime/apis/base/performance.ts +8 -0
  8. package/dist/runtime/apis/base/system.ts +181 -0
  9. package/dist/runtime/apis/base/update.ts +5 -0
  10. package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
  11. package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
  12. package/dist/runtime/apis/canvas/index.ts +27 -0
  13. package/dist/runtime/apis/data-analysis/index.ts +6 -0
  14. package/dist/runtime/apis/device/accelerometer.ts +79 -0
  15. package/dist/runtime/apis/device/accessibility.ts +4 -0
  16. package/dist/runtime/apis/device/battery.ts +24 -0
  17. package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
  18. package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
  19. package/dist/runtime/apis/device/bluetooth.ts +16 -0
  20. package/dist/runtime/apis/device/calendar.ts +5 -0
  21. package/dist/runtime/apis/device/clipboard.ts +85 -0
  22. package/dist/runtime/apis/device/compass.ts +21 -0
  23. package/dist/runtime/apis/device/contact.ts +5 -0
  24. package/dist/runtime/apis/device/crypto.ts +4 -0
  25. package/dist/runtime/apis/device/gyroscope.ts +77 -0
  26. package/dist/runtime/apis/device/iBeacon.ts +10 -0
  27. package/dist/runtime/apis/device/index.ts +24 -0
  28. package/dist/runtime/apis/device/keyboard.ts +63 -0
  29. package/dist/runtime/apis/device/memory.ts +11 -0
  30. package/dist/runtime/apis/device/motion.ts +6 -0
  31. package/dist/runtime/apis/device/network.ts +123 -0
  32. package/dist/runtime/apis/device/nfc.ts +10 -0
  33. package/dist/runtime/apis/device/phone.ts +44 -0
  34. package/dist/runtime/apis/device/scan.ts +4 -0
  35. package/dist/runtime/apis/device/screen.ts +80 -0
  36. package/dist/runtime/apis/device/sms.ts +4 -0
  37. package/dist/runtime/apis/device/vibrate.ts +32 -0
  38. package/dist/runtime/apis/device/wifi.ts +15 -0
  39. package/dist/runtime/apis/ext/index.ts +5 -0
  40. package/dist/runtime/apis/files/index.ts +136 -0
  41. package/dist/runtime/apis/files/manager.ts +942 -0
  42. package/dist/runtime/apis/framework/index.ts +48 -0
  43. package/dist/runtime/apis/harmony/task-pool.ts +39 -0
  44. package/dist/runtime/apis/index.ts +61 -0
  45. package/dist/runtime/apis/location/index.ts +133 -0
  46. package/dist/runtime/apis/media/EditorContext.ts +32 -0
  47. package/dist/runtime/apis/media/audio/index.ts +36 -0
  48. package/dist/runtime/apis/media/background-audio/index.ts +16 -0
  49. package/dist/runtime/apis/media/camera.ts +16 -0
  50. package/dist/runtime/apis/media/common.ts +58 -0
  51. package/dist/runtime/apis/media/image/index.ts +291 -0
  52. package/dist/runtime/apis/media/index.ts +13 -0
  53. package/dist/runtime/apis/media/live.ts +5 -0
  54. package/dist/runtime/apis/media/map.ts +4 -0
  55. package/dist/runtime/apis/media/media-recorder.ts +4 -0
  56. package/dist/runtime/apis/media/recorder.ts +6 -0
  57. package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
  58. package/dist/runtime/apis/media/video/index.ts +45 -0
  59. package/dist/runtime/apis/media/video-decoder.ts +4 -0
  60. package/dist/runtime/apis/media/video-processing.ts +4 -0
  61. package/dist/runtime/apis/media/voip.ts +19 -0
  62. package/dist/runtime/apis/navigate/index.ts +8 -0
  63. package/dist/runtime/apis/network/downloadFile.ts +85 -0
  64. package/dist/runtime/apis/network/index.ts +7 -0
  65. package/dist/runtime/apis/network/mdns.ts +13 -0
  66. package/dist/runtime/apis/network/request.ts +140 -0
  67. package/dist/runtime/apis/network/tcp.ts +4 -0
  68. package/dist/runtime/apis/network/udp.ts +4 -0
  69. package/dist/runtime/apis/network/uploadFile.ts +105 -0
  70. package/dist/runtime/apis/network/webSocket.ts +126 -0
  71. package/dist/runtime/apis/open-api/account.ts +4 -0
  72. package/dist/runtime/apis/open-api/address.ts +4 -0
  73. package/dist/runtime/apis/open-api/authorize.ts +5 -0
  74. package/dist/runtime/apis/open-api/card.ts +5 -0
  75. package/dist/runtime/apis/open-api/channels-live.ts +11 -0
  76. package/dist/runtime/apis/open-api/customer-service.ts +4 -0
  77. package/dist/runtime/apis/open-api/device-voip.ts +5 -0
  78. package/dist/runtime/apis/open-api/facial.ts +7 -0
  79. package/dist/runtime/apis/open-api/favorites.ts +5 -0
  80. package/dist/runtime/apis/open-api/group.ts +4 -0
  81. package/dist/runtime/apis/open-api/index.ts +21 -0
  82. package/dist/runtime/apis/open-api/invoice.ts +5 -0
  83. package/dist/runtime/apis/open-api/license-plate.ts +4 -0
  84. package/dist/runtime/apis/open-api/login.ts +6 -0
  85. package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
  86. package/dist/runtime/apis/open-api/privacy.ts +7 -0
  87. package/dist/runtime/apis/open-api/red-package.ts +4 -0
  88. package/dist/runtime/apis/open-api/settings.ts +5 -0
  89. package/dist/runtime/apis/open-api/soter.ts +6 -0
  90. package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
  91. package/dist/runtime/apis/open-api/user-info.ts +70 -0
  92. package/dist/runtime/apis/open-api/werun.ts +5 -0
  93. package/dist/runtime/apis/payment/index.ts +6 -0
  94. package/dist/runtime/apis/route/index.ts +88 -0
  95. package/dist/runtime/apis/share/index.ts +33 -0
  96. package/dist/runtime/apis/storage/background-fetch.ts +7 -0
  97. package/dist/runtime/apis/storage/cache-manager.ts +4 -0
  98. package/dist/runtime/apis/storage/index.ts +203 -0
  99. package/dist/runtime/apis/ui/animation/animation.ts +264 -0
  100. package/dist/runtime/apis/ui/animation/index.ts +7 -0
  101. package/dist/runtime/apis/ui/background.ts +20 -0
  102. package/dist/runtime/apis/ui/custom-component.ts +1 -0
  103. package/dist/runtime/apis/ui/fonts.ts +4 -0
  104. package/dist/runtime/apis/ui/index.ts +12 -0
  105. package/dist/runtime/apis/ui/interaction/index.ts +198 -0
  106. package/dist/runtime/apis/ui/menu.ts +4 -0
  107. package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
  108. package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
  109. package/dist/runtime/apis/ui/scroll/index.ts +82 -0
  110. package/dist/runtime/apis/ui/sticky.ts +4 -0
  111. package/dist/runtime/apis/ui/tab-bar.ts +144 -0
  112. package/dist/runtime/apis/ui/window.ts +20 -0
  113. package/dist/runtime/apis/utils/constant.ts +1 -0
  114. package/dist/runtime/apis/utils/handler.ts +117 -0
  115. package/dist/runtime/apis/utils/index.ts +105 -0
  116. package/dist/runtime/apis/utils/permissions.ts +6 -0
  117. package/dist/runtime/apis/utils/types.ts +12 -0
  118. package/dist/runtime/apis/utils/unit.ts +104 -0
  119. package/dist/runtime/apis/utils/validate.ts +87 -0
  120. package/dist/runtime/apis/worker/index.ts +4 -0
  121. package/dist/runtime/apis/wxml/index.ts +17 -0
  122. package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
  123. package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
  124. package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
  125. package/dist/runtime/apischunk/index.d.ts +802 -0
  126. package/dist/runtime/apischunk/index.js +5054 -0
  127. package/dist/runtime/components/deprecated.ets +43 -0
  128. package/dist/runtime/components/index.ets +49 -0
  129. package/dist/runtime/components/innerHtml.ets +16 -0
  130. package/dist/runtime/components/navigationBar.ets +65 -0
  131. package/dist/runtime/components/pageMeta.ets +94 -0
  132. package/dist/runtime/components/richText.ets +24 -0
  133. package/dist/runtime/components/slider.ets +119 -0
  134. package/dist/runtime/components/style.ets +286 -0
  135. package/dist/runtime/components/switch.ets +73 -0
  136. package/dist/runtime/components/tag.ts +58 -0
  137. package/dist/runtime/components/utils/AttributeManager.ets +252 -0
  138. package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
  139. package/dist/runtime/components/utils/constant/event.ets +25 -0
  140. package/dist/runtime/components/utils/constant/style.ets +91 -0
  141. package/dist/runtime/components/utils/events.ts +26 -0
  142. package/dist/runtime/components/utils/flexManager.ets +49 -0
  143. package/dist/runtime/components/utils/helper.ets +51 -0
  144. package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
  145. package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
  146. package/dist/runtime/components/utils/index.ts +77 -0
  147. package/dist/runtime/components/utils/styles.ets +41 -0
  148. package/dist/runtime/components/video.ets +119 -0
  149. package/dist/runtime/components/webView.ets +55 -0
  150. package/dist/runtime/components/xComponent.ets +89 -0
  151. package/dist/runtime/framework/app.ts +248 -0
  152. package/dist/runtime/framework/connect.ts +24 -0
  153. package/dist/runtime/framework/constant.ts +3 -0
  154. package/dist/runtime/framework/hooks.ts +99 -0
  155. package/dist/runtime/framework/index.ts +15 -0
  156. package/dist/runtime/framework/native-page.ts +511 -0
  157. package/dist/runtime/framework/page.ts +256 -0
  158. package/dist/runtime/framework/utils/index.ts +17 -0
  159. package/dist/runtime/framework/utils/is.ts +26 -0
  160. package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
  161. package/dist/runtime/framework-reconciler/constant.ts +86 -0
  162. package/dist/runtime/framework-reconciler/domInput.ts +90 -0
  163. package/dist/runtime/framework-reconciler/event.ts +108 -0
  164. package/dist/runtime/framework-reconciler/index.ts +99 -0
  165. package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
  166. package/dist/runtime/framework-reconciler/props.ts +132 -0
  167. package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
  168. package/dist/runtime/framework-reconciler/render.ts +139 -0
  169. package/dist/runtime/framework-reconciler/workTags.ts +53 -0
  170. package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
  171. package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
  172. package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
  173. package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
  174. package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
  175. package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
  176. package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
  177. package/dist/runtime/runtime-cpp/constant.ts +29 -0
  178. package/dist/runtime/runtime-cpp/current.ts +48 -0
  179. package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
  180. package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
  181. package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
  182. package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
  183. package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
  184. package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
  185. package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
  186. package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
  187. package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
  188. package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
  189. package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
  190. package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
  191. package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
  192. package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
  193. package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
  194. package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
  195. package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
  196. package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
  197. package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
  198. package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
  199. package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
  200. package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
  201. package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
  202. package/dist/runtime/runtime-cpp/env.ts +1 -0
  203. package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
  204. package/dist/runtime/runtime-cpp/index.ts +79 -0
  205. package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
  206. package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
  207. package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
  208. package/dist/runtime/runtime-cpp/system.ts +213 -0
  209. package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
  210. package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
  211. package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
  212. package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
  213. package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
  214. package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
  215. package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
  216. package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
  217. package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
  218. package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
  219. package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
  220. package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
  221. package/dist/runtime/runtime-harmony/index.ets +41 -0
  222. package/dist/runtime/runtime-harmony/utils.ts +53 -0
  223. package/package.json +25 -23
  224. package/static/@taro-oh/library-4.1.1-alpha.0.har +0 -0
  225. package/LICENSE +0 -174
@@ -0,0 +1,88 @@
1
+ import { eventCenter } from '@tarojs/runtime'
2
+
3
+ import { ETS_METHODS_TRIGGER_EVENTNAME, MethodHandler } from '../utils'
4
+
5
+ import type Taro from '@tarojs/taro/types'
6
+
7
+ const scope = 'route'
8
+ const type = 'method'
9
+
10
+ export const navigateTo: typeof Taro.navigateTo = (options) => {
11
+ const name = 'navigateTo'
12
+ const { success, fail, complete } = options
13
+ const handle = new MethodHandler({ name, success, fail, complete })
14
+ return new Promise((resolve, reject) => {
15
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
16
+ name,
17
+ args: [options],
18
+ scope,
19
+ type,
20
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
21
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
22
+ })
23
+ })
24
+ }
25
+
26
+ export const redirectTo: typeof Taro.redirectTo = (options) => {
27
+ const name = 'redirectTo'
28
+ const { success, fail, complete } = options
29
+ const handle = new MethodHandler({ name, success, fail, complete })
30
+ return new Promise((resolve, reject) => {
31
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
32
+ name,
33
+ args: [options],
34
+ scope,
35
+ type,
36
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
37
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
38
+ })
39
+ })
40
+ }
41
+
42
+ export const navigateBack: typeof Taro.navigateBack = (options = {}) => {
43
+ const name = 'navigateBack'
44
+ const { success, fail, complete } = options
45
+ const handle = new MethodHandler({ name, success, fail, complete })
46
+ return new Promise((resolve, reject) => {
47
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
48
+ name,
49
+ args: [options],
50
+ scope,
51
+ type,
52
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
53
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
54
+ })
55
+ })
56
+ }
57
+
58
+ export const reLaunch: typeof Taro.reLaunch = (options) => {
59
+ const name = 'reLaunch'
60
+ const { success, fail, complete } = options
61
+ const handle = new MethodHandler({ name, success, fail, complete })
62
+ return new Promise((resolve, reject) => {
63
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
64
+ name,
65
+ args: [options],
66
+ scope,
67
+ type,
68
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
69
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
70
+ })
71
+ })
72
+ }
73
+
74
+ export const switchTab: typeof Taro.switchTab = (options) => {
75
+ const name = 'switchTab'
76
+ const { success, fail, complete } = options
77
+ const handle = new MethodHandler({ name, success, fail, complete })
78
+ return new Promise((resolve, reject) => {
79
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
80
+ name,
81
+ args: [options],
82
+ scope,
83
+ type,
84
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
85
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
86
+ })
87
+ })
88
+ }
@@ -0,0 +1,33 @@
1
+ import { permanentlyNotSupport, temporarilyNotSupport } from '../utils'
2
+
3
+ // 转发
4
+
5
+ /** 更新转发属性 */
6
+ export const updateShareMenu = /* @__PURE__ */ temporarilyNotSupport('updateShareMenu')
7
+
8
+ /** 显示当前页面的转发按钮 */
9
+ export const showShareMenu = /* @__PURE__ */ temporarilyNotSupport('showShareMenu')
10
+
11
+ /** 打开分享图片弹窗,可以将图片发送给朋友、收藏或下载 */
12
+ export const showShareImageMenu = /* @__PURE__ */ temporarilyNotSupport('showShareImageMenu')
13
+
14
+ /** 转发视频到聊天 */
15
+ export const shareVideoMessage = /* @__PURE__ */ temporarilyNotSupport('shareVideoMessage')
16
+
17
+ /** 转发文件到聊天 */
18
+ export const shareFileMessage = /* @__PURE__ */ temporarilyNotSupport('shareFileMessage')
19
+
20
+ /** 监听用户点击右上角菜单的「复制链接」按钮时触发的事件 */
21
+ export const onCopyUrl = /* @__PURE__ */ temporarilyNotSupport('onCopyUrl')
22
+
23
+ /** 移除用户点击右上角菜单的「复制链接」按钮时触发的事件的监听函数 */
24
+ export const offCopyUrl = /* @__PURE__ */ temporarilyNotSupport('offCopyUrl')
25
+
26
+ /** 隐藏当前页面的转发按钮 */
27
+ export const hideShareMenu = /* @__PURE__ */ temporarilyNotSupport('hideShareMenu')
28
+
29
+ /** 获取转发详细信息 */
30
+ export const getShareInfo = /* @__PURE__ */ temporarilyNotSupport('getShareInfo')
31
+
32
+ /** 验证私密消息。 */
33
+ export const authPrivateMessage = /* @__PURE__ */ permanentlyNotSupport('authPrivateMessage')
@@ -0,0 +1,7 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 周期性更新
4
+ export const setBackgroundFetchToken = /* @__PURE__ */ temporarilyNotSupport('setBackgroundFetchToken')
5
+ export const onBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('onBackgroundFetchData')
6
+ export const getBackgroundFetchToken = /* @__PURE__ */ temporarilyNotSupport('getBackgroundFetchToken')
7
+ export const getBackgroundFetchData = /* @__PURE__ */ temporarilyNotSupport('getBackgroundFetchData')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 周期性更新
4
+ export const createCacheManager = /* @__PURE__ */ temporarilyNotSupport('createCacheManager')
@@ -0,0 +1,203 @@
1
+ /**
2
+ * 从API Version 6开始,该模块不再维护,可以使用模块@ohos.data.storage。在API Version 9后,推荐使用新模块@ohos.data.preferences。
3
+ * https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
4
+ */
5
+ import bundleManager from '@ohos.bundle.bundleManager'
6
+ import distributedKVStore from '@ohos.data.distributedKVStore'
7
+ import { Current } from '@tarojs/runtime'
8
+
9
+ import { temporarilyNotSupport, validateParams } from '../utils'
10
+ import { MethodHandler } from '../utils/handler'
11
+
12
+ import type Taro from '@tarojs/taro/types'
13
+
14
+ let context
15
+ let kvManager: distributedKVStore.KVManager
16
+ let kvStore: distributedKVStore.SingleKVStore
17
+ let kvStorePromise: Promise<void>
18
+
19
+ Current.contextPromise.then((ctx) => {
20
+ context = ctx
21
+ const kvManagerConfig: distributedKVStore.KVManagerConfig = {
22
+ context: context,
23
+ bundleName: 'com.example.taro'
24
+ }
25
+
26
+ try {
27
+ // 创建KVManager实例
28
+ kvManager = distributedKVStore.createKVManager(kvManagerConfig)
29
+ // 继续创建获取数据库
30
+ const options: distributedKVStore.Options = {
31
+ createIfMissing: true,
32
+ encrypt: false,
33
+ backup: false,
34
+ autoSync: false,
35
+ // kvStoreType不填时,默认创建多设备协同数据库
36
+ kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,
37
+ // 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,
38
+ securityLevel: distributedKVStore.SecurityLevel.S1
39
+ }
40
+
41
+ const data = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
42
+ kvStorePromise = new Promise(resolve => {
43
+ kvManager.getKVStore<distributedKVStore.SingleKVStore>(`${data.appInfo.uid}Store`, options, (err, store: distributedKVStore.SingleKVStore) => {
44
+ if (err) {
45
+ console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`)
46
+ return
47
+ }
48
+ kvStore = store
49
+ // 请确保获取到键值数据库实例后,再进行相关数据操作
50
+ resolve()
51
+ })
52
+ })
53
+ } catch (e) {
54
+ console.error(`Failed to create KVManager. Code:${e.code},message:${e.message}`)
55
+ }
56
+
57
+ return context
58
+ })
59
+
60
+ const storageSchema = {
61
+ key: 'String'
62
+ }
63
+
64
+ function checkContextExist (api: string, isAsync = false) {
65
+ if (!context) {
66
+ const message = `${api} 调用失败,Taro 不支持过早地调用 ${api},请确保页面已经渲染完成再调用此 API`
67
+ if (isAsync) {
68
+ return {
69
+ isExist: false,
70
+ error: Promise.reject(new Error(message))
71
+ }
72
+ } else {
73
+ console.warn(message)
74
+
75
+ return {
76
+ isExist: false,
77
+ }
78
+ }
79
+ }
80
+
81
+ return {
82
+ isExist: true,
83
+ }
84
+ }
85
+
86
+ export function getStorage<T = any> (options: Taro.getStorage.Option<T>) {
87
+ const name = 'getStorage'
88
+ const { isExist, error } = checkContextExist(name, true)
89
+
90
+ if (!isExist) {
91
+ return error
92
+ }
93
+
94
+ const { key, success, fail, complete } = options || {}
95
+ const handle = new MethodHandler<{data: any}>({ name, success, fail, complete })
96
+
97
+ return new Promise((resolve, reject) => {
98
+ kvStorePromise.then(() => {
99
+ try {
100
+ validateParams(name, options, storageSchema)
101
+ } catch (error) {
102
+ const res = { errMsg: error.message }
103
+ return handle.fail(res, { resolve, reject })
104
+ }
105
+
106
+ kvStore = kvStore as distributedKVStore.SingleKVStore
107
+ kvStore.get(key, (err, data) => {
108
+ if (err) {
109
+ handle.fail({ errMsg: `Failed to get data. Code:${err.code},message:${err.message}` }, { resolve, reject })
110
+ return
111
+ }
112
+
113
+ handle.success({ data }, { resolve, reject })
114
+ })
115
+ })
116
+ })
117
+ }
118
+
119
+ export function setStorage (options: Taro.setStorage.Option) {
120
+ const name = 'setStorage'
121
+ const { isExist, error } = checkContextExist(name, true)
122
+
123
+ if (!isExist) {
124
+ return error
125
+ }
126
+
127
+ const { key, data, success, fail, complete } = options || {}
128
+ const handle = new MethodHandler({ name, success, fail, complete })
129
+
130
+ return new Promise((resolve, reject) => {
131
+ kvStorePromise.then(() => {
132
+ try {
133
+ validateParams(name, options, storageSchema)
134
+ } catch (error) {
135
+ const res = { errMsg: error.message }
136
+ return handle.fail(res, { resolve, reject })
137
+ }
138
+
139
+ kvStore = kvStore as distributedKVStore.SingleKVStore
140
+ kvStore.put(key, data, (err) => {
141
+ if (err) {
142
+ handle.fail({ errMsg: `Failed to put data. Code:${err.code},message:${err.message}` }, { resolve, reject })
143
+ return
144
+ }
145
+
146
+ handle.success({}, { resolve, reject })
147
+ })
148
+ })
149
+ })
150
+ }
151
+
152
+ export function removeStorage (options: Taro.removeStorage.Option) {
153
+ const name = 'removeStorage'
154
+ const { isExist, error } = checkContextExist(name, true)
155
+
156
+ if (!isExist) {
157
+ return error
158
+ }
159
+
160
+ const { key, success, fail, complete } = options || {}
161
+ const handle = new MethodHandler({ name, success, fail, complete })
162
+
163
+ return new Promise((resolve, reject) => {
164
+ kvStorePromise.then(() => {
165
+ try {
166
+ validateParams(name, options, storageSchema)
167
+ } catch (error) {
168
+ const res = { errMsg: error.message }
169
+ return handle.fail(res, { resolve, reject })
170
+ }
171
+
172
+ kvStore = kvStore as distributedKVStore.SingleKVStore
173
+ kvStore.delete(key, (err) => {
174
+ if (err) {
175
+ handle.fail({ errMsg: `Failed to delete data. Code:${err.code},message:${err.message}` }, { resolve, reject })
176
+ return
177
+ }
178
+
179
+ handle.success({}, { resolve, reject })
180
+ })
181
+ })
182
+ })
183
+ }
184
+
185
+ export const getStorageInfoSync = temporarilyNotSupport('getStorageInfoSync')
186
+ export const getStorageInfo = temporarilyNotSupport('getStorageInfo')
187
+
188
+ export const createBufferURL = /* @__PURE__ */ temporarilyNotSupport('createBufferURL')
189
+ export const revokeBufferURL = /* @__PURE__ */ temporarilyNotSupport('revokeBufferURL')
190
+
191
+ export const batchSetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchSetStorageSync')
192
+ export const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage')
193
+ export const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync')
194
+ export const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage')
195
+
196
+ export const clearStorage = temporarilyNotSupport('clearStorage')
197
+ export const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage')
198
+ export const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage')
199
+ export const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage')
200
+ export const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage')
201
+
202
+ export * from './background-fetch'
203
+ export * from './cache-manager'
@@ -0,0 +1,264 @@
1
+ import matrix4 from '@ohos.matrix4'
2
+ import { isUndefined } from '@tarojs/shared'
3
+
4
+ import { temporarilyNotSupport } from '../../utils'
5
+
6
+ import type Taro from '@tarojs/taro/types'
7
+
8
+ interface IAnimationAttr {
9
+ duration: number
10
+ delay: number
11
+ timingFunction: string
12
+ transformOrigin: string
13
+ }
14
+
15
+ type TStep = {
16
+ delay: number
17
+ duration: number
18
+ timingFunction: string
19
+ transformOrigin: string
20
+ rule: TRule
21
+ }
22
+
23
+ type TRule = Record<string, any>
24
+
25
+ export class Animation implements Taro.Animation {
26
+ unit: string
27
+ DEFAULT: IAnimationAttr
28
+
29
+ // 组合动画
30
+ steps: TStep[] = []
31
+ // 属性组合
32
+ rule: TRule = {}
33
+
34
+ constructor({
35
+ duration = 400,
36
+ delay = 0,
37
+ timingFunction = 'linear',
38
+ transformOrigin = '50% 50% 0',
39
+ unit = 'px'
40
+ }: Taro.createAnimation.Option = {}) {
41
+ this.unit = unit
42
+ this.setDefault(duration, delay, timingFunction, transformOrigin)
43
+ }
44
+
45
+ // 设置默认值
46
+ setDefault (duration, delay, timingFunction, transformOrigin) {
47
+ this.DEFAULT = { duration, delay, timingFunction, transformOrigin }
48
+ }
49
+
50
+ export (): { actions: any[] } {
51
+ const actions = this.steps.slice()
52
+ this.steps = []
53
+ this.rule = {}
54
+ return {
55
+ actions
56
+ }
57
+ }
58
+
59
+ step (arg: Partial<IAnimationAttr> = {}): Taro.Animation {
60
+ const { DEFAULT } = this
61
+ const {
62
+ duration = DEFAULT.duration,
63
+ delay = DEFAULT.delay,
64
+ timingFunction = DEFAULT.timingFunction,
65
+ transformOrigin = DEFAULT.transformOrigin
66
+ } = arg
67
+ this.steps.push({
68
+ duration,
69
+ delay,
70
+ timingFunction,
71
+ transformOrigin,
72
+ rule: Object.assign({}, this.rule)
73
+ })
74
+ if (this.rule.transform) {
75
+ this.rule.transform = Object.assign({}, this.rule.transform)
76
+ }
77
+ return this
78
+ }
79
+
80
+ matrix (a: number, b: number, c: number, d: number, tx: number, ty: number): Taro.Animation {
81
+ this.rule.transform = matrix4.init([a, b, c, d, tx, ty])
82
+ return this
83
+ }
84
+
85
+ matrix3d (a1: number, b1: number, c1: number, d1: number, a2: number, b2: number, c2: number, d2: number, a3: number, b3: number, c3: number, d3: number, a4: number, b4: number, c4: number, d4: number): Taro.Animation {
86
+ this.rule.transform = matrix4.init([a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4])
87
+ return this
88
+ }
89
+
90
+ rotate (angle: number): Taro.Animation {
91
+ if (!this.rule.transform) {
92
+ this.rule.transform = {}
93
+ }
94
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle }
95
+ return this
96
+ }
97
+
98
+ rotate3d (x: number, y?: number | undefined, z?: number | undefined, angle?: number | undefined): Taro.Animation {
99
+ if (!this.rule.transform) {
100
+ this.rule.transform = {}
101
+ }
102
+ this.rule.transform.Rotate = { x, y, z, angle }
103
+ return this
104
+ }
105
+
106
+ rotateX (angle: number): Taro.Animation {
107
+ if (!this.rule.transform) {
108
+ this.rule.transform = {}
109
+ }
110
+ this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle }
111
+ return this
112
+ }
113
+
114
+ rotateY (angle: number): Taro.Animation {
115
+ if (!this.rule.transform) {
116
+ this.rule.transform = {}
117
+ }
118
+ this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle }
119
+ return this
120
+ }
121
+
122
+ rotateZ (angle: number): Taro.Animation {
123
+ if (!this.rule.transform) {
124
+ this.rule.transform = {}
125
+ }
126
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle }
127
+ return this
128
+ }
129
+
130
+ scale (sx: number, sy?: number | undefined): Taro.Animation {
131
+ if (!this.rule.transform) {
132
+ this.rule.transform = {}
133
+ }
134
+ this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy }
135
+ return this
136
+ }
137
+
138
+ scale3d (sx: number, sy: number, sz: number): Taro.Animation {
139
+ if (!this.rule.transform) {
140
+ this.rule.transform = {}
141
+ }
142
+ this.rule.transform.Scale = { x: sx, y: sy, z: sz }
143
+ return this
144
+ }
145
+
146
+ scaleX (scale: number): Taro.Animation {
147
+ if (!this.rule.transform) {
148
+ this.rule.transform = {}
149
+ }
150
+ this.rule.transform.Scale = { x: scale }
151
+ return this
152
+ }
153
+
154
+ scaleY (scale: number): Taro.Animation {
155
+ if (!this.rule.transform) {
156
+ this.rule.transform = {}
157
+ }
158
+ this.rule.transform.Scale = { y: scale }
159
+ return this
160
+ }
161
+
162
+ scaleZ (scale: number): Taro.Animation {
163
+ if (!this.rule.transform) {
164
+ this.rule.transform = {}
165
+ }
166
+ this.rule.transform.Scale = { z: scale }
167
+ return this
168
+ }
169
+
170
+ skew (ax: number, ay: number): Taro.Animation {
171
+ temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay)
172
+ return this
173
+ }
174
+
175
+ skewX (angle: number): Taro.Animation {
176
+ temporarilyNotSupport('animation.skewX:' + angle)(angle)
177
+ return this
178
+ }
179
+
180
+ skewY (angle: number): Taro.Animation {
181
+ temporarilyNotSupport('animation.skewY:' + angle)(angle)
182
+ return this
183
+ }
184
+
185
+ translate (tx?: number | undefined, ty?: number | undefined): Taro.Animation {
186
+ if (!this.rule.transform) {
187
+ this.rule.transform = {}
188
+ }
189
+ this.rule.transform.Translate = { x: tx, y: ty }
190
+ return this
191
+ }
192
+
193
+ translate3d (tx?: number | undefined, ty?: number | undefined, tz?: number | undefined): Taro.Animation {
194
+ if (!this.rule.transform) {
195
+ this.rule.transform = {}
196
+ }
197
+ this.rule.transform.Translate = { x: tx, y: ty, z: tz }
198
+ return this
199
+ }
200
+
201
+ translateX (translation: number): Taro.Animation {
202
+ if (!this.rule.transform) {
203
+ this.rule.transform = {}
204
+ }
205
+ this.rule.transform.Translate = { x: translation }
206
+ return this
207
+ }
208
+
209
+ translateY (translation: number): Taro.Animation {
210
+ if (!this.rule.transform) {
211
+ this.rule.transform = {}
212
+ }
213
+ this.rule.transform.Translate = { y: translation }
214
+ return this
215
+ }
216
+
217
+ translateZ (translation: number): Taro.Animation {
218
+ if (!this.rule.transform) {
219
+ this.rule.transform = {}
220
+ }
221
+ this.rule.transform.Translate = { z: translation }
222
+ return this
223
+ }
224
+
225
+ opacity (value: number): Taro.Animation {
226
+ this.rule.opacity = value
227
+ return this
228
+ }
229
+
230
+ backgroundColor (value: string): Taro.Animation {
231
+ this.rule.backgroundColor = value
232
+ return this
233
+ }
234
+
235
+ width (value: string | number): Taro.Animation {
236
+ this.rule.width = value
237
+ return this
238
+ }
239
+
240
+ height (value: string | number): Taro.Animation {
241
+ this.rule.height = value
242
+ return this
243
+ }
244
+
245
+ left (value: string | number): Taro.Animation {
246
+ this.rule.left = value
247
+ return this
248
+ }
249
+
250
+ right (value: string | number): Taro.Animation {
251
+ temporarilyNotSupport('animation.right:' + value)(value)
252
+ return this
253
+ }
254
+
255
+ top (value: string | number): Taro.Animation {
256
+ this.rule.top = value
257
+ return this
258
+ }
259
+
260
+ bottom (value: string | number): Taro.Animation {
261
+ temporarilyNotSupport('animation.bottom:' + value)(value)
262
+ return this
263
+ }
264
+ }
@@ -0,0 +1,7 @@
1
+ import { Animation } from './animation'
2
+
3
+ import type Taro from '@tarojs/taro/types'
4
+
5
+ export const createAnimation = (option: Taro.createAnimation.Option) => {
6
+ return new Animation(option)
7
+ }
@@ -0,0 +1,20 @@
1
+ import { eventCenter } from '@tarojs/runtime'
2
+
3
+ import { temporarilyNotSupport } from '../utils'
4
+ import { MethodHandler } from '../utils/handler'
5
+
6
+ export const setBackgroundTextStyle = /* @__PURE__ */ temporarilyNotSupport('setBackgroundTextStyle')
7
+
8
+ export function setBackgroundColor(options: Taro.setBackgroundColor.Option) {
9
+ const { success, fail, complete } = options || {}
10
+ const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete })
11
+
12
+ return new Promise((resolve, reject) => {
13
+ eventCenter.trigger('__taroPageStyle', {
14
+ backgroundColor: options.backgroundColorBottom || options.backgroundColor,
15
+ backgroundColorContext: options.backgroundColorTop || options.backgroundColor
16
+ })
17
+
18
+ return handle.success({}, { resolve, reject })
19
+ })
20
+ }
@@ -0,0 +1 @@
1
+ export { nextTick } from '@tarojs/runtime'
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 字体
4
+ export const loadFontFace = /* @__PURE__ */ temporarilyNotSupport('getMenuButtonBoundingClientRect')
@@ -0,0 +1,12 @@
1
+ export * from './animation'
2
+ export * from './background'
3
+ export * from './custom-component'
4
+ export * from './fonts'
5
+ export * from './interaction'
6
+ export * from './menu'
7
+ export * from './navigation-bar'
8
+ export * from './pull-down-refresh'
9
+ export * from './scroll'
10
+ export * from './sticky'
11
+ export * from './tab-bar'
12
+ export * from './window'