@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10

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 (239) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +74 -21
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +27 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +17 -9
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/memory.ts +10 -3
  28. package/dist/apis/device/motion.ts +6 -0
  29. package/dist/apis/device/network.ts +26 -9
  30. package/dist/apis/device/nfc.ts +10 -0
  31. package/dist/apis/device/phone.ts +2 -1
  32. package/dist/apis/device/scan.ts +4 -0
  33. package/dist/apis/device/screen.ts +2 -1
  34. package/dist/apis/device/sms.ts +4 -0
  35. package/dist/apis/device/vibrate.ts +19 -11
  36. package/dist/apis/device/wifi.ts +15 -0
  37. package/dist/apis/ext/index.ts +5 -0
  38. package/dist/apis/files/index.ts +2 -1
  39. package/dist/apis/files/manager.ts +2 -1
  40. package/dist/apis/framework/index.ts +3 -8
  41. package/dist/apis/index.ts +27 -17
  42. package/dist/apis/location/index.ts +61 -68
  43. package/dist/apis/media/EditorContext.ts +32 -0
  44. package/dist/apis/media/audio/index.ts +18 -0
  45. package/dist/apis/media/background-audio/index.ts +16 -0
  46. package/dist/apis/media/camera.ts +16 -0
  47. package/dist/apis/media/common.ts +2 -1
  48. package/dist/apis/media/{image.ts → image/index.ts} +4 -3
  49. package/dist/apis/media/index.ts +10 -0
  50. package/dist/apis/media/live.ts +5 -0
  51. package/dist/apis/media/map.ts +4 -0
  52. package/dist/apis/media/media-recorder.ts +4 -0
  53. package/dist/apis/media/recorder.ts +6 -0
  54. package/dist/apis/media/video/VideoContext.ts +68 -0
  55. package/dist/apis/media/{video.ts → video/index.ts} +13 -2
  56. package/dist/apis/media/video-decoder.ts +4 -0
  57. package/dist/apis/media/video-processing.ts +4 -0
  58. package/dist/apis/media/voip.ts +19 -0
  59. package/dist/apis/network/index.ts +3 -0
  60. package/dist/apis/network/mdns.ts +13 -0
  61. package/dist/apis/network/request.ts +7 -6
  62. package/dist/apis/network/tcp.ts +4 -0
  63. package/dist/apis/network/udp.ts +4 -0
  64. package/dist/apis/network/webSocket.ts +2 -6
  65. package/dist/apis/open-api/account.ts +4 -0
  66. package/dist/apis/open-api/address.ts +4 -0
  67. package/dist/apis/open-api/authorize.ts +5 -0
  68. package/dist/apis/open-api/card.ts +5 -0
  69. package/dist/apis/open-api/channels-live.ts +11 -0
  70. package/dist/apis/open-api/customer-service.ts +4 -0
  71. package/dist/apis/open-api/device-voip.ts +5 -0
  72. package/dist/apis/open-api/facial.ts +7 -0
  73. package/dist/apis/open-api/favorites.ts +5 -0
  74. package/dist/apis/open-api/group.ts +4 -0
  75. package/dist/apis/open-api/index.ts +20 -6
  76. package/dist/apis/open-api/invoice.ts +5 -0
  77. package/dist/apis/open-api/license-plate.ts +4 -0
  78. package/dist/apis/open-api/login.ts +6 -0
  79. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  80. package/dist/apis/open-api/privacy.ts +7 -0
  81. package/dist/apis/open-api/red-package.ts +4 -0
  82. package/dist/apis/open-api/settings.ts +5 -0
  83. package/dist/apis/open-api/soter.ts +6 -0
  84. package/dist/apis/open-api/subscribe-message.ts +6 -0
  85. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  86. package/dist/apis/open-api/werun.ts +5 -0
  87. package/dist/apis/payment/index.ts +6 -0
  88. package/dist/apis/route/index.ts +19 -28
  89. package/dist/apis/share/index.ts +33 -0
  90. package/dist/apis/storage/background-fetch.ts +7 -0
  91. package/dist/apis/storage/cache-manager.ts +4 -0
  92. package/dist/apis/storage/index.ts +158 -88
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +4 -19
  96. package/dist/apis/ui/custom-component.ts +8 -0
  97. package/dist/apis/ui/fonts.ts +4 -0
  98. package/dist/apis/ui/index.ts +8 -10
  99. package/dist/apis/ui/interaction/index.ts +45 -59
  100. package/dist/apis/ui/menu.ts +4 -0
  101. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  102. package/dist/apis/ui/pull-down-refresh.ts +10 -4
  103. package/dist/apis/{page → ui/scroll}/index.ts +32 -27
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/utils/index.ts +1 -1
  109. package/dist/apis/worker/index.ts +4 -0
  110. package/dist/apis/wxml/IntersectionObserver.ts +24 -25
  111. package/dist/apis/wxml/index.ts +7 -2
  112. package/dist/apis/wxml/nodesRef.ts +2 -2
  113. package/dist/apis/wxml/selectorQuery.ts +29 -17
  114. package/dist/components-harmony-ets/button.ets +106 -80
  115. package/dist/components-harmony-ets/canvas.ets +51 -0
  116. package/dist/components-harmony-ets/checkbox.ets +82 -148
  117. package/dist/components-harmony-ets/form.ets +45 -132
  118. package/dist/components-harmony-ets/icon.ets +66 -69
  119. package/dist/components-harmony-ets/image.ets +26 -61
  120. package/dist/components-harmony-ets/index.ets +92 -0
  121. package/dist/components-harmony-ets/innerHtml.ets +7 -70
  122. package/dist/components-harmony-ets/input.ets +60 -146
  123. package/dist/components-harmony-ets/label.ets +86 -92
  124. package/dist/components-harmony-ets/listView.ets +26 -0
  125. package/dist/components-harmony-ets/movableArea.ets +124 -0
  126. package/dist/components-harmony-ets/movableView.ets +93 -0
  127. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  128. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  129. package/dist/components-harmony-ets/picker.ets +172 -198
  130. package/dist/components-harmony-ets/progress.ets +52 -0
  131. package/dist/components-harmony-ets/pseudo.ets +80 -0
  132. package/dist/components-harmony-ets/radio.ets +85 -155
  133. package/dist/components-harmony-ets/richText.ets +15 -87
  134. package/dist/components-harmony-ets/scrollList.ets +94 -0
  135. package/dist/components-harmony-ets/scrollView.ets +81 -149
  136. package/dist/components-harmony-ets/slider.ets +47 -94
  137. package/dist/components-harmony-ets/stickySection.ets +42 -0
  138. package/dist/components-harmony-ets/style.ets +396 -0
  139. package/dist/components-harmony-ets/swiper.ets +51 -151
  140. package/dist/components-harmony-ets/switch.ets +35 -76
  141. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  142. package/dist/components-harmony-ets/text.ets +131 -76
  143. package/dist/components-harmony-ets/textArea.ets +64 -140
  144. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  145. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  146. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  147. package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
  148. package/dist/components-harmony-ets/utils/helper.ets +18 -65
  149. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  150. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  151. package/dist/components-harmony-ets/utils/index.ts +55 -51
  152. package/dist/components-harmony-ets/utils/styles.ets +177 -65
  153. package/dist/components-harmony-ets/video.ets +70 -116
  154. package/dist/components-harmony-ets/view.ets +58 -64
  155. package/dist/components-harmony-ets/webView.ets +56 -0
  156. package/dist/index.d.ts +152 -0
  157. package/dist/index.js +230 -60
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime-ets/bom/document.ts +6 -4
  160. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  161. package/dist/runtime-ets/bom/window.ts +9 -2
  162. package/dist/runtime-ets/current.ts +3 -0
  163. package/dist/runtime-ets/dom/bind.ts +96 -0
  164. package/dist/runtime-ets/dom/class-list.ts +4 -6
  165. package/dist/runtime-ets/dom/comment.ts +1 -2
  166. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  167. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
  168. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  169. package/dist/runtime-ets/dom/document.ts +36 -51
  170. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  171. package/dist/runtime-ets/dom/element/element.ts +439 -0
  172. package/dist/runtime-ets/dom/element/form.ts +403 -0
  173. package/dist/runtime-ets/dom/element/index.ts +120 -0
  174. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  175. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  176. package/dist/runtime-ets/dom/element/normal.ts +103 -0
  177. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  178. package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
  179. package/dist/runtime-ets/dom/element/text.ts +10 -0
  180. package/dist/runtime-ets/dom/element/video.ts +50 -0
  181. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  182. package/dist/runtime-ets/dom/event.ts +26 -5
  183. package/dist/runtime-ets/dom/eventTarget.ts +3 -3
  184. package/dist/runtime-ets/dom/node.ts +114 -49
  185. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  186. package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
  187. package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
  188. package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
  189. package/dist/runtime-ets/index.ts +2 -3
  190. package/dist/runtime-ets/interface/event.ts +3 -2
  191. package/dist/runtime-ets/utils/index.ts +87 -17
  192. package/dist/runtime-ets/utils/info.ts +21 -47
  193. package/dist/runtime-framework/react/app.ts +20 -28
  194. package/dist/runtime-framework/react/hooks.ts +3 -4
  195. package/dist/runtime-framework/react/index.ts +1 -2
  196. package/dist/runtime-framework/react/native-page.ts +421 -0
  197. package/dist/runtime-framework/react/page.ts +5 -17
  198. package/dist/runtime-framework/solid/app.ts +25 -45
  199. package/dist/runtime-framework/solid/connect.ts +21 -3
  200. package/dist/runtime-framework/solid/hooks.ts +17 -12
  201. package/dist/runtime-framework/solid/index.ts +6 -2
  202. package/dist/runtime-framework/solid/page.ts +84 -36
  203. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  204. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  205. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  206. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  207. package/dist/runtime-utils.d.ts +827 -0
  208. package/dist/runtime-utils.js +1633 -549
  209. package/dist/runtime-utils.js.map +1 -1
  210. package/dist/runtime.d.ts +1 -0
  211. package/dist/runtime.js +1633 -549
  212. package/dist/runtime.js.map +1 -1
  213. package/index.js +3 -1
  214. package/package.json +14 -15
  215. package/static/media/cancel.svg +1 -0
  216. package/static/media/circle.svg +1 -0
  217. package/static/media/clear.svg +1 -0
  218. package/static/media/download.svg +1 -0
  219. package/static/media/info.svg +1 -0
  220. package/static/media/info_circle.svg +1 -0
  221. package/static/media/search.svg +1 -0
  222. package/static/media/success.svg +1 -0
  223. package/static/media/success_no_circle.svg +1 -0
  224. package/static/media/taro_arrow_left.svg +1 -0
  225. package/static/media/taro_home.svg +1 -0
  226. package/static/media/waiting.svg +1 -0
  227. package/static/media/warn.svg +1 -0
  228. package/types/harmony.d.ts +4 -0
  229. package/types/index.d.ts +4 -0
  230. package/types/runtime.d.ts +7 -1
  231. package/LICENSE +0 -160
  232. package/dist/components-harmony-ets/base.ets +0 -63
  233. package/dist/components-harmony-ets/element.ets +0 -223
  234. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  235. package/dist/runtime-ets/dom/element.ts +0 -457
  236. package/dist/runtime-ets/dom/text.ts +0 -19
  237. package/dist/runtime-ets/utils/bind.ts +0 -35
  238. package/types/api.d.ts +0 -4
  239. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -3,131 +3,201 @@
3
3
  * https://developer.harmonyos.com/cn/docs/documentation/doc-references-V3/js-apis-data-preferences-0000001427745052-V3
4
4
  */
5
5
  import bundleManager from '@ohos.bundle.bundleManager'
6
- import dataPreferences from '@ohos.data.preferences'
7
- import hilog from '@ohos.hilog'
6
+ import distributedKVStore from '@ohos.data.distributedKVStore'
8
7
  import { Current } from '@tarojs/runtime'
9
8
 
10
- import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
9
+ import { temporarilyNotSupport, validateParams } from '../utils'
10
+ import { MethodHandler } from '../utils/handler'
11
11
 
12
- import type { IAsyncParams } from '../utils/types'
12
+ import type Taro from '@tarojs/taro/types'
13
13
 
14
- interface IGetStorageParams extends IAsyncParams {
15
- key: string
16
- }
17
- interface ISetStorageParams extends IAsyncParams {
18
- key: string
19
- data: number | string | boolean
20
- }
21
-
22
- interface IRemoveStorageParams extends IAsyncParams {
23
- key: string
24
- }
14
+ let context
15
+ let kvManager: distributedKVStore.KVManager
16
+ let kvStore: distributedKVStore.SingleKVStore
17
+ let kvStorePromise: Promise<void>
25
18
 
26
- const preferencesPromise = (Current as any).contextPromise
27
- .then((context) => {
28
- return bundleManager
29
- .getBundleInfoForSelf(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION)
30
- .then(data => {
31
- return dataPreferences
32
- .getPreferences(context, `${data.appInfo.uid}Store`)
33
- })
34
- })
35
- .catch((error) => {
36
- hilog.error(0x0000, 'TaroFailedTag', 'Failed to load the storage. Cause: %{public}s', error.code ? JSON.stringify(error) : error.message || error)
37
- })
19
+ (Current as any).contextPromise.then((ctx) => {
20
+ context = ctx
21
+ const kvManagerConfig: distributedKVStore.KVManagerConfig = {
22
+ context: context,
23
+ bundleName: 'com.example.taro'
24
+ }
38
25
 
39
- async function getItem (key: string): Promise<{ result: boolean, data?: number | string | boolean }> {
40
26
  try {
41
- const preferences = await preferencesPromise
42
- const item = await preferences.get(key, null)
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
+ }
43
40
 
44
- return { result: true, data: item }
45
- } catch (error) {
46
- return { result: false }
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}`)
47
55
  }
48
- }
56
+
57
+ return context
58
+ })
49
59
 
50
60
  const storageSchema = {
51
61
  key: 'String'
52
62
  }
53
63
 
54
- export function getStorage (options: IGetStorageParams) {
55
- return new Promise((resolve, reject) => {
56
- try {
57
- validateParams('getStorage', options, storageSchema)
58
- } catch (error) {
59
- const res = { errMsg: error.message }
60
- return callAsyncFail(reject, res, options)
61
- }
62
- getItem(options.key).then(({ result, data }) => {
63
- const res: Record<string, any> = { errMsg: 'getStorage:ok' }
64
-
65
- if (result) {
66
- res.data = data
67
- callAsyncSuccess(resolve, res, options)
68
- } else {
69
- res.errMsg = 'getStorage:fail data not found'
70
- callAsyncFail(reject, res, options)
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
71
  }
72
- })
73
- })
74
- }
72
+ } else {
73
+ console.warn(message)
75
74
 
76
- export function setStorage (options: ISetStorageParams) {
77
- return new Promise((resolve, reject) => {
78
- try {
79
- validateParams('setStorage', options, storageSchema)
80
- } catch (error) {
81
- const res = { errMsg: error.message }
82
- return callAsyncFail(reject, res, options)
75
+ return {
76
+ isExist: false,
77
+ }
83
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)
84
89
 
85
- const { key, data } = options
86
- const res = { errMsg: 'setStorage:ok' }
90
+ if (!isExist) {
91
+ return error
92
+ }
87
93
 
88
- preferencesPromise.then(async (preferences) => {
89
- await preferences.put(key, data)
90
- await preferences.flush()
94
+ const { key, success, fail, complete } = options || {}
95
+ const handle = new MethodHandler<{data: any}>({ name, success, fail, complete })
91
96
 
92
- callAsyncSuccess(resolve, res, options)
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
+ })
93
115
  })
94
116
  })
95
117
  }
96
118
 
97
- export function removeStorage (options: IRemoveStorageParams) {
98
- return new Promise((resolve, reject) => {
99
- try {
100
- validateParams('removeStorage', options, storageSchema)
101
- } catch (error) {
102
- const res = { errMsg: error.message }
103
- return callAsyncFail(reject, res, options)
104
- }
119
+ export function setStorage (options: Taro.setStorage.Option) {
120
+ const name = 'setStorage'
121
+ const { isExist, error } = checkContextExist(name, true)
105
122
 
106
- const { key } = options
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
+ }
107
138
 
108
- preferencesPromise.then(async (preferences) => {
109
- await preferences.delete(key)
110
- await preferences.flush()
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
+ }
111
145
 
112
- const res = { errMsg: 'removeStorage:ok' }
113
- callAsyncSuccess(resolve, res, options)
146
+ handle.success({}, { resolve, reject })
147
+ })
114
148
  })
115
149
  })
116
150
  }
117
151
 
118
- export function clearStorage (options: IAsyncParams) {
119
- return new Promise(resolve => {
120
- preferencesPromise.then(async (preferences) => {
121
- await preferences.clear()
122
- await preferences.flush()
152
+ export function removeStorage (options: Taro.removeStorage.Option) {
153
+ const name = 'removeStorage'
154
+ const { isExist, error } = checkContextExist(name, true)
123
155
 
124
- const res = { errMsg: 'clearStorage:ok' }
125
- callAsyncSuccess(resolve, res, options)
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
+ })
126
181
  })
127
182
  })
128
183
  }
129
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')
130
197
  export const getStorageSync = temporarilyNotSupport('getStorageSync', 'getStorage')
131
198
  export const setStorageSync = temporarilyNotSupport('setStorageSync', 'setStorage')
132
199
  export const clearStorageSync = temporarilyNotSupport('clearStorageSync', 'clearStorage')
133
200
  export const removeStorageSync = temporarilyNotSupport('removeStorageSync', 'removeStorage')
201
+
202
+ export * from './background-fetch'
203
+ export * from './cache-manager'
@@ -1,8 +1,9 @@
1
1
  import matrix4 from '@ohos.matrix4'
2
+ import { isUndefined } from '@tarojs/shared'
2
3
 
3
- import { temporarilyNotSupport } from '../utils'
4
+ import { temporarilyNotSupport } from '../../utils'
4
5
 
5
- import type Taro from '@tarojs/api'
6
+ import type Taro from '@tarojs/taro/types'
6
7
 
7
8
  interface IAnimationAttr {
8
9
  duration: number
@@ -22,7 +23,6 @@ type TStep = {
22
23
  type TRule = Record<string, any>
23
24
 
24
25
  export class Animation implements Taro.Animation {
25
-
26
26
  unit: string
27
27
  DEFAULT: IAnimationAttr
28
28
 
@@ -71,6 +71,9 @@ export class Animation implements Taro.Animation {
71
71
  transformOrigin,
72
72
  rule: Object.assign({}, this.rule)
73
73
  })
74
+ if (this.rule.transform) {
75
+ this.rule.transform = Object.assign({}, this.rule.transform)
76
+ }
74
77
  return this
75
78
  }
76
79
 
@@ -85,92 +88,137 @@ export class Animation implements Taro.Animation {
85
88
  }
86
89
 
87
90
  rotate (angle: number): Taro.Animation {
88
- this.rule.rotate = { x: 0, y: 0, z: 1, angle }
91
+ if (!this.rule.transform) {
92
+ this.rule.transform = {}
93
+ }
94
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle }
89
95
  return this
90
96
  }
91
97
 
92
98
  rotate3d (x: number, y?: number | undefined, z?: number | undefined, angle?: number | undefined): Taro.Animation {
93
- this.rule.rotate = { x, y, z, angle }
99
+ if (!this.rule.transform) {
100
+ this.rule.transform = {}
101
+ }
102
+ this.rule.transform.Rotate = { x, y, z, angle }
94
103
  return this
95
104
  }
96
105
 
97
106
  rotateX (angle: number): Taro.Animation {
98
- this.rule.rotate = { x: 1, y: 0, z: 0, angle }
107
+ if (!this.rule.transform) {
108
+ this.rule.transform = {}
109
+ }
110
+ this.rule.transform.Rotate = { x: 1, y: 0, z: 0, angle }
99
111
  return this
100
112
  }
101
113
 
102
114
  rotateY (angle: number): Taro.Animation {
103
- this.rule.rotate = { x: 0, y: 1, z: 0, angle }
115
+ if (!this.rule.transform) {
116
+ this.rule.transform = {}
117
+ }
118
+ this.rule.transform.Rotate = { x: 0, y: 1, z: 0, angle }
104
119
  return this
105
120
  }
106
121
 
107
122
  rotateZ (angle: number): Taro.Animation {
108
- this.rule.rotate = { x: 0, y: 0, z: 1, angle }
123
+ if (!this.rule.transform) {
124
+ this.rule.transform = {}
125
+ }
126
+ this.rule.transform.Rotate = { x: 0, y: 0, z: 1, angle }
109
127
  return this
110
128
  }
111
129
 
112
130
  scale (sx: number, sy?: number | undefined): Taro.Animation {
113
- this.rule.scale = { x: sx, y: sy }
131
+ if (!this.rule.transform) {
132
+ this.rule.transform = {}
133
+ }
134
+ this.rule.transform.Scale = { x: sx, y: isUndefined(sy) ? sx : sy }
114
135
  return this
115
136
  }
116
137
 
117
138
  scale3d (sx: number, sy: number, sz: number): Taro.Animation {
118
- this.rule.scale = { x: sx, y: sy, z: sz }
139
+ if (!this.rule.transform) {
140
+ this.rule.transform = {}
141
+ }
142
+ this.rule.transform.Scale = { x: sx, y: sy, z: sz }
119
143
  return this
120
144
  }
121
145
 
122
146
  scaleX (scale: number): Taro.Animation {
123
- this.rule.scale = { x: scale }
147
+ if (!this.rule.transform) {
148
+ this.rule.transform = {}
149
+ }
150
+ this.rule.transform.Scale = { x: scale }
124
151
  return this
125
152
  }
126
153
 
127
154
  scaleY (scale: number): Taro.Animation {
128
- this.rule.scale = { y: scale }
155
+ if (!this.rule.transform) {
156
+ this.rule.transform = {}
157
+ }
158
+ this.rule.transform.Scale = { y: scale }
129
159
  return this
130
160
  }
131
161
 
132
162
  scaleZ (scale: number): Taro.Animation {
133
- this.rule.scale = { z: scale }
163
+ if (!this.rule.transform) {
164
+ this.rule.transform = {}
165
+ }
166
+ this.rule.transform.Scale = { z: scale }
134
167
  return this
135
168
  }
136
169
 
137
170
  skew (ax: number, ay: number): Taro.Animation {
138
- this.rule.skew = { x: ax, y: ay }
171
+ temporarilyNotSupport('animation.skew:' + `${ax}, ${ay}`)(ax, ay)
139
172
  return this
140
173
  }
141
174
 
142
175
  skewX (angle: number): Taro.Animation {
143
- this.rule.skew = { x: angle }
176
+ temporarilyNotSupport('animation.skewX:' + angle)(angle)
144
177
  return this
145
178
  }
146
179
 
147
180
  skewY (angle: number): Taro.Animation {
148
- this.rule.skew = { y: angle }
181
+ temporarilyNotSupport('animation.skewY:' + angle)(angle)
149
182
  return this
150
183
  }
151
184
 
152
185
  translate (tx?: number | undefined, ty?: number | undefined): Taro.Animation {
153
- this.rule.translate = { x: tx, y: ty }
186
+ if (!this.rule.transform) {
187
+ this.rule.transform = {}
188
+ }
189
+ this.rule.transform.Translate = { x: tx, y: ty }
154
190
  return this
155
191
  }
156
192
 
157
193
  translate3d (tx?: number | undefined, ty?: number | undefined, tz?: number | undefined): Taro.Animation {
158
- this.rule.translate = { x: tx, y: ty, z: tz }
194
+ if (!this.rule.transform) {
195
+ this.rule.transform = {}
196
+ }
197
+ this.rule.transform.Translate = { x: tx, y: ty, z: tz }
159
198
  return this
160
199
  }
161
200
 
162
201
  translateX (translation: number): Taro.Animation {
163
- this.rule.translate = { x: translation }
202
+ if (!this.rule.transform) {
203
+ this.rule.transform = {}
204
+ }
205
+ this.rule.transform.Translate = { x: translation }
164
206
  return this
165
207
  }
166
208
 
167
209
  translateY (translation: number): Taro.Animation {
168
- this.rule.translate = { y: translation }
210
+ if (!this.rule.transform) {
211
+ this.rule.transform = {}
212
+ }
213
+ this.rule.transform.Translate = { y: translation }
169
214
  return this
170
215
  }
171
216
 
172
217
  translateZ (translation: number): Taro.Animation {
173
- this.rule.translate = { z: translation }
218
+ if (!this.rule.transform) {
219
+ this.rule.transform = {}
220
+ }
221
+ this.rule.transform.Translate = { z: translation }
174
222
  return this
175
223
  }
176
224
 
@@ -185,23 +233,17 @@ export class Animation implements Taro.Animation {
185
233
  }
186
234
 
187
235
  width (value: string | number): Taro.Animation {
188
- this.rule.size = {
189
- ...this.rule.size,
190
- width: value
191
- }
236
+ this.rule.width = value
192
237
  return this
193
238
  }
194
239
 
195
240
  height (value: string | number): Taro.Animation {
196
- this.rule.size = {
197
- ...this.rule.size,
198
- height: value
199
- }
241
+ this.rule.height = value
200
242
  return this
201
243
  }
202
244
 
203
245
  left (value: string | number): Taro.Animation {
204
- temporarilyNotSupport('animation.left:' + value)(value)
246
+ this.rule.left = value
205
247
  return this
206
248
  }
207
249
 
@@ -211,7 +253,7 @@ export class Animation implements Taro.Animation {
211
253
  }
212
254
 
213
255
  top (value: string | number): Taro.Animation {
214
- temporarilyNotSupport('animation.top:' + value)(value)
256
+ this.rule.top = value
215
257
  return this
216
258
  }
217
259
 
@@ -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
+ }
@@ -1,16 +1,9 @@
1
- // import window from '@ohos.window'
2
- // import { Current } from '@tarojs/runtime'
3
1
  import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
4
2
 
3
+ import { temporarilyNotSupport } from '../utils'
5
4
  import { MethodHandler } from '../utils/handler'
6
5
 
7
- // import { callAsyncFail, callAsyncSuccess } from '../utils'
8
-
9
-
10
- // const windowClassPromise = (Current as any).contextPromise
11
- // .then(context => {
12
- // return window.getTopWindow(context)
13
- // })
6
+ export const setBackgroundTextStyle = /* @__PURE__ */ temporarilyNotSupport('setBackgroundTextStyle')
14
7
 
15
8
  export function setBackgroundColor(options: Taro.setBackgroundColor.Option) {
16
9
  const { success, fail, complete } = options || {}
@@ -18,18 +11,10 @@ export function setBackgroundColor(options: Taro.setBackgroundColor.Option) {
18
11
 
19
12
  return new Promise((resolve, reject) => {
20
13
  eventCenter.trigger('__taroPageStyle', {
21
- backgroundColor: options.backgroundColor || options.backgroundColorTop || options.backgroundColorBottom,
14
+ backgroundColor: options.backgroundColorBottom || options.backgroundColor,
15
+ backgroundColorContext: options.backgroundColorTop || options.backgroundColor
22
16
  })
23
17
 
24
18
  return handle.success({}, { resolve, reject })
25
- // windowClassPromise.then(windowClass => {
26
- // windowClass.setBackgroundColor(color).then(() => {
27
- // const res = { errMsg: 'setBackgroundColor:ok' }
28
- // callAsyncSuccess(resolve, res, options)
29
- // }, (error) => {
30
- // const res = { errMsg: 'setBackgroundColor:fail' + error }
31
- // callAsyncFail(reject, res, options)
32
- // })
33
- // })
34
19
  })
35
20
  }
@@ -0,0 +1,8 @@
1
+ import type Taro from '@tarojs/taro/types'
2
+
3
+ // 自定义组件
4
+ export const nextTick: typeof Taro.nextTick = (cb: (...args: any[]) => any, ctx?: Record<string, any>) => {
5
+ setTimeout(function () {
6
+ ctx ? cb.call(ctx) : cb()
7
+ }, 1)
8
+ }
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 字体
4
+ export const loadFontFace = /* @__PURE__ */ temporarilyNotSupport('getMenuButtonBoundingClientRect')
@@ -1,14 +1,12 @@
1
- import { temporarilyNotSupport } from '../utils'
2
- import { Animation } from './animation'
3
-
4
- import type Taro from '@tarojs/api'
5
-
6
- export const createAnimation = (option: Taro.createAnimation.Option) => {
7
- return new Animation(option)
8
- }
9
- export const getMenuButtonBoundingClientRect = temporarilyNotSupport('getMenuButtonBoundingClientRect')
10
-
1
+ export * from './animation'
11
2
  export * from './background'
3
+ export * from './custom-component'
4
+ export * from './fonts'
12
5
  export * from './interaction'
6
+ export * from './menu'
13
7
  export * from './navigation-bar'
14
8
  export * from './pull-down-refresh'
9
+ export * from './scroll'
10
+ export * from './sticky'
11
+ export * from './tab-bar'
12
+ export * from './window'