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

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 (202) 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 +1 -1
  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 +18 -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 +1 -1
  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 +5 -6
  41. package/dist/apis/index.ts +2 -0
  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} +3 -2
  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 +20 -18
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +2 -18
  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 +3 -0
  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 +1 -1
  103. package/dist/apis/{page → ui/scroll}/index.ts +27 -22
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/worker/index.ts +4 -0
  109. package/dist/apis/wxml/IntersectionObserver.ts +12 -21
  110. package/dist/apis/wxml/index.ts +7 -2
  111. package/dist/apis/wxml/nodesRef.ts +2 -2
  112. package/dist/apis/wxml/selectorQuery.ts +3 -4
  113. package/dist/components-harmony-ets/button.ets +97 -85
  114. package/dist/components-harmony-ets/checkbox.ets +68 -142
  115. package/dist/components-harmony-ets/form.ets +31 -140
  116. package/dist/components-harmony-ets/icon.ets +60 -75
  117. package/dist/components-harmony-ets/image.ets +14 -69
  118. package/dist/components-harmony-ets/innerHtml.ets +6 -74
  119. package/dist/components-harmony-ets/input.ets +62 -152
  120. package/dist/components-harmony-ets/label.ets +63 -96
  121. package/dist/components-harmony-ets/picker.ets +168 -198
  122. package/dist/components-harmony-ets/radio.ets +69 -146
  123. package/dist/components-harmony-ets/richText.ets +14 -70
  124. package/dist/components-harmony-ets/scrollView.ets +84 -156
  125. package/dist/components-harmony-ets/slider.ets +40 -88
  126. package/dist/components-harmony-ets/style.ets +154 -0
  127. package/dist/components-harmony-ets/swiper.ets +25 -166
  128. package/dist/components-harmony-ets/switch.ets +29 -72
  129. package/dist/components-harmony-ets/text.ets +37 -68
  130. package/dist/components-harmony-ets/textArea.ets +44 -132
  131. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  132. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  133. package/dist/components-harmony-ets/utils/flexManager.ets +45 -92
  134. package/dist/components-harmony-ets/utils/helper.ets +4 -64
  135. package/dist/components-harmony-ets/utils/index.ts +1 -1
  136. package/dist/components-harmony-ets/utils/styles.ets +62 -27
  137. package/dist/components-harmony-ets/video.ets +63 -122
  138. package/dist/components-harmony-ets/view.ets +52 -69
  139. package/dist/components-harmony-ets/webView.ets +50 -0
  140. package/dist/index.js +135 -8
  141. package/dist/index.js.map +1 -1
  142. package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
  143. package/dist/runtime-ets/bom/window.ts +2 -2
  144. package/dist/runtime-ets/dom/bind.ts +80 -0
  145. package/dist/runtime-ets/dom/class-list.ts +2 -4
  146. package/dist/runtime-ets/dom/comment.ts +1 -2
  147. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +31 -7
  148. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  149. package/dist/runtime-ets/dom/document.ts +35 -47
  150. package/dist/runtime-ets/dom/element/element.ts +163 -0
  151. package/dist/runtime-ets/dom/element/form.ts +406 -0
  152. package/dist/runtime-ets/dom/element/index.ts +92 -0
  153. package/dist/runtime-ets/dom/element/normal.ts +76 -0
  154. package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
  155. package/dist/runtime-ets/dom/element/text.ts +17 -0
  156. package/dist/runtime-ets/dom/element/video.ts +49 -0
  157. package/dist/runtime-ets/dom/element/webView.ts +61 -0
  158. package/dist/runtime-ets/dom/event.ts +24 -1
  159. package/dist/runtime-ets/dom/eventTarget.ts +2 -1
  160. package/dist/runtime-ets/dom/node.ts +87 -44
  161. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
  162. package/dist/runtime-ets/dom/stylesheet/index.ts +263 -288
  163. package/dist/runtime-ets/dom/stylesheet/type.ts +47 -11
  164. package/dist/runtime-ets/dom/stylesheet/util.ts +129 -7
  165. package/dist/runtime-ets/index.ts +1 -3
  166. package/dist/runtime-ets/interface/event.ts +2 -1
  167. package/dist/runtime-ets/utils/index.ts +18 -8
  168. package/dist/runtime-ets/utils/info.ts +22 -48
  169. package/dist/runtime-framework/react/app.ts +14 -27
  170. package/dist/runtime-framework/react/hooks.ts +3 -3
  171. package/dist/runtime-framework/react/index.ts +1 -0
  172. package/dist/runtime-framework/react/native-page.ts +344 -0
  173. package/dist/runtime-framework/react/page.ts +4 -11
  174. package/dist/runtime-framework/solid/hooks.ts +3 -3
  175. package/dist/runtime-framework/solid/page.ts +0 -6
  176. package/dist/runtime-utils.js +1216 -349
  177. package/dist/runtime-utils.js.map +1 -1
  178. package/dist/runtime.js +1216 -349
  179. package/dist/runtime.js.map +1 -1
  180. package/package.json +12 -11
  181. package/static/media/cancel.svg +1 -0
  182. package/static/media/circle.svg +1 -0
  183. package/static/media/clear.svg +1 -0
  184. package/static/media/download.svg +1 -0
  185. package/static/media/info.svg +1 -0
  186. package/static/media/info_circle.svg +1 -0
  187. package/static/media/search.svg +1 -0
  188. package/static/media/success.svg +1 -0
  189. package/static/media/success_no_circle.svg +1 -0
  190. package/static/media/taro_arrow_left.svg +1 -0
  191. package/static/media/taro_home.svg +1 -0
  192. package/static/media/waiting.svg +1 -0
  193. package/static/media/warn.svg +1 -0
  194. package/types/runtime.d.ts +6 -0
  195. package/LICENSE +0 -160
  196. package/dist/components-harmony-ets/base.ets +0 -63
  197. package/dist/components-harmony-ets/element.ets +0 -223
  198. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  199. package/dist/runtime-ets/dom/element.ts +0 -457
  200. package/dist/runtime-ets/dom/text.ts +0 -19
  201. package/dist/runtime-ets/utils/bind.ts +0 -35
  202. package/types/api.d.ts +0 -4
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * 鸿蒙SDK API Version 6
4
3
  * 将页面滚动到目标位置
@@ -9,26 +8,31 @@
9
8
  import { AREA_CHANGE_EVENT_NAME, Current, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate } from '@tarojs/runtime'
10
9
  import { pxTransformHelper } from '@tarojs/taro'
11
10
 
12
- import { callAsyncFail, callAsyncSuccess } from '../utils'
11
+ import { MethodHandler } from '../../utils/handler'
13
12
 
14
- import type Taro from '@tarojs/api'
15
-
16
- // TODO
17
- export const getCurrentPages = () => []
13
+ import type Taro from '@tarojs/taro/types'
18
14
 
15
+ /**
16
+ * 将页面滚动到目标位置
17
+ */
19
18
  export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
19
+ const { scrollTop, selector = '', duration = 300, offsetTop = 0, success, fail, complete } = options || {}
20
+ const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete })
20
21
  // eslint-disable-next-line no-async-promise-executor
21
22
  return new Promise(async (resolve, reject) => {
22
- const taro = (Current as any).taro
23
- const page = taro.getCurrentInstance().page
24
- const res = { errMsg: 'pageScrollTo:ok' }
25
- const error = { errMsg: 'pageScrollTo:fail' }
26
- const { scrollTop, selector = '', duration = 300, offsetTop = 0 } = options
23
+ if (scrollTop === undefined && !selector) {
24
+ return handle.fail({
25
+ errMsg: 'scrollTop" "selector" 需要其之一'
26
+ }, { resolve, reject })
27
+ }
27
28
 
28
29
  if (scrollTop && selector) {
29
30
  console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector')
30
31
  }
31
32
 
33
+ const taro = (Current as any).taro
34
+ const page = taro.getCurrentInstance().page
35
+
32
36
  let scrollValue = -1
33
37
  let scroller = page.scroller
34
38
  const currentPageNode = getPageScrollerOrNode(page.node, page)
@@ -38,20 +42,17 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
38
42
  } else if (selector) {
39
43
  const node = findChildNodeWithDFS(currentPageNode, selector)
40
44
 
41
- if (!node || !node._instance) return
42
-
43
- const instance = node._instance
44
- const id = node?._nid
45
+ if (!node) return
45
46
 
46
47
  // 获取 areaInfo,需要先调用 setNodeEventCallbackAndTriggerComponentUpdate 更新一次组件并获取组件信息
47
48
  await setNodeEventCallbackAndTriggerComponentUpdate(node, AREA_CHANGE_EVENT_NAME, null, true)
48
49
 
49
- const { areaInfo } = instance?.nodeInfoMap?.[id] || {}
50
+ const { areaInfo } = node._nodeInfo || {}
50
51
 
51
52
  let parent = node?.parentNode
52
53
  while (!!parent && parent !== currentPageNode) {
53
- if (parent?._instance?.scroller) {
54
- scroller = parent._instance.scroller
54
+ if (parent?.scroller) {
55
+ scroller = parent.scroller
55
56
  break
56
57
  }
57
58
  parent = parent?.parentNode
@@ -68,7 +69,9 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
68
69
  const { xOffset } = scroller.currentOffset()
69
70
 
70
71
  if (scrollValue === -1) {
71
- return callAsyncFail(reject, { errMsg: 'pageScrollTo:fail, 请检查传入的 scrollTop 或 selector 是否合法' }, options)
72
+ return handle.fail({
73
+ errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
74
+ }, { resolve, reject })
72
75
  }
73
76
 
74
77
  try {
@@ -83,10 +86,12 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
83
86
  })
84
87
 
85
88
  setTimeout(() => {
86
- callAsyncSuccess(resolve, res, options)
89
+ handle.success({}, { resolve, reject })
87
90
  }, duration)
88
- } catch (_) {
89
- callAsyncFail(reject, error, options)
91
+ } catch (err) {
92
+ return handle.fail({
93
+ errMsg: err.message
94
+ }, { resolve, reject })
90
95
  }
91
96
  })
92
97
  }
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 置顶
4
+ export const setTopBarText = /* @__PURE__ */ temporarilyNotSupport('setTopBarText')
@@ -1,11 +1,9 @@
1
- // eslint-disable-next-line import/no-duplicates
2
- import { Current } from '@tarojs/runtime'
3
- // eslint-disable-next-line import/no-duplicates
4
- import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
1
+ import { Current } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
2
+ import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
5
3
 
6
4
  import { callAsyncFail, callAsyncSuccess } from '../utils'
7
5
 
8
- import type Taro from '@tarojs/api'
6
+ import type Taro from '@tarojs/taro/types'
9
7
 
10
8
  interface ShowTabBar {
11
9
  type: 'show'
@@ -0,0 +1,20 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ import type Taro from '@tarojs/taro/types'
4
+
5
+ /**
6
+ * 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
7
+ */
8
+ export const setWindowSize = /* @__PURE__ */ temporarilyNotSupport('setWindowSize')
9
+
10
+ /**
11
+ * 监听窗口尺寸变化事件
12
+ */
13
+ export const onWindowResize: typeof Taro.onWindowResize = /* @__PURE__ */ temporarilyNotSupport('onWindowResize')
14
+
15
+ /**
16
+ * 取消监听窗口尺寸变化事件
17
+ */
18
+ export const offWindowResize: typeof Taro.offWindowResize = /* @__PURE__ */ temporarilyNotSupport('offWindowResize')
19
+
20
+ export const checkIsPictureInPictureActive = /* @__PURE__ */ temporarilyNotSupport('checkIsPictureInPictureActive')
@@ -11,7 +11,7 @@ interface IMethodParam<T = Partial<ICallbackResult>> {
11
11
  name: string
12
12
  success?: TCallback<T & ICallbackResult>
13
13
  fail?: TCallback
14
- complete?: TCallback
14
+ complete?: TCallback<T | ICallbackResult>
15
15
  }
16
16
  interface IMockPromise {
17
17
  resolve?: typeof Promise.resolve | TFunc
@@ -23,7 +23,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
23
23
 
24
24
  protected __success?: TCallback<T>
25
25
  protected __fail?: TCallback
26
- protected __complete?: TCallback
26
+ protected __complete?: TCallback<T | ICallbackResult>
27
27
 
28
28
  protected isHandlerError = false
29
29
 
@@ -41,7 +41,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
41
41
  res.errMsg = `${this.methodName}:ok`
42
42
  }
43
43
  isFunction(this.__success) && this.__success(res as T)
44
- isFunction(this.__complete) && this.__complete(res)
44
+ isFunction(this.__complete) && this.__complete(res as T)
45
45
 
46
46
  const { resolve = Promise.resolve.bind(Promise) } = promise
47
47
  return resolve(res as Required<T & U & ICallbackResult>)
@@ -54,7 +54,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
54
54
  res.errMsg = `${this.methodName}:fail ${res.errMsg}`
55
55
  }
56
56
  isFunction(this.__fail) && this.__fail(res)
57
- isFunction(this.__complete) && this.__complete(res)
57
+ isFunction(this.__complete) && this.__complete(res as ICallbackResult)
58
58
 
59
59
  const {
60
60
  resolve = Promise.resolve.bind(Promise),
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // Worker
4
+ export const createWorker = /* @__PURE__ */ temporarilyNotSupport('createWorker')
@@ -1,9 +1,9 @@
1
- import Taro from '@tarojs/api'
2
- // @ts-ignore
3
1
  import { Current, disconnectEvent, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate, TaroElement, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
4
2
 
5
3
  import { temporarilyNotSupport } from '../utils'
6
4
 
5
+ import type Taro from '@tarojs/taro/types'
6
+
7
7
  export class IntersectionObserver implements Taro.IntersectionObserver {
8
8
  // 自定义组件实例
9
9
  private _component: any
@@ -29,17 +29,15 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
29
29
  if (this._observerNodes instanceof Array) {
30
30
  this._observerNodes.forEach((n: TaroElement & any) => {
31
31
  disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME)
32
- if (n._instance) {
33
- // @ts-ignore
34
- n._instance?.nodeInfoMap?.[n._nid]?.thresholds = null
35
- }
32
+ // @ts-ignore
33
+ n._nodeInfo?.thresholds = null
36
34
  })
37
35
  } else {
38
36
  disconnectEvent(this._observerNodes, VISIBLE_CHANGE_EVENT_NAME)
39
37
  // @ts-ignore
40
- if (this._observerNodes._instance) {
38
+ if (this._observerNodes._nodeInfo) {
41
39
  // @ts-ignore
42
- this._observerNodes._instance?.nodeInfoMap?.[this._observerNodes._nid]?.thresholds = null
40
+ this._observerNodes._nodeInfo?.thresholds = null
43
41
  }
44
42
  }
45
43
  }
@@ -50,29 +48,22 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
50
48
  const node = findChildNodeWithDFS(this._component, targetSelector, observeAll)
51
49
  this._observerNodes = node
52
50
 
53
-
54
51
  if (node) {
55
52
  if (node instanceof Array) {
56
53
  node.forEach(n => {
57
54
  // @ts-ignore
58
- n.awaitAppear.then(() => {
59
- // @ts-ignore
60
- n._instance?.nodeInfoMap?.[n._nid]?.thresholds = thresholds
55
+ n._nodeInfo?.thresholds = thresholds
61
56
 
62
- setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
63
- callback(this.handleResult(isVisible, currentRatio))
64
- })
57
+ setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
58
+ callback(this.handleResult(isVisible, currentRatio))
65
59
  })
66
60
  })
67
61
  } else {
68
62
  // @ts-ignore
69
- node.awaitAppear.then(() => {
70
- // @ts-ignore
71
- node._instance?.nodeInfoMap?.[node._nid]?.thresholds = thresholds
63
+ node._nodeInfo?.thresholds = thresholds
72
64
 
73
- setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
74
- callback(this.handleResult(isVisible, currentRatio))
75
- })
65
+ setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
66
+ callback(this.handleResult(isVisible, currentRatio))
76
67
  })
77
68
  }
78
69
  }
@@ -1,8 +1,9 @@
1
- import Taro from '@tarojs/taro'
2
-
1
+ import { temporarilyNotSupport } from '../utils'
3
2
  import { IntersectionObserver } from './IntersectionObserver'
4
3
  import { SelectorQuery } from './selectorQuery'
5
4
 
5
+ import type Taro from '@tarojs/taro/types'
6
+
6
7
  export const createSelectorQuery = () => {
7
8
  return new SelectorQuery()
8
9
  }
@@ -10,3 +11,7 @@ export const createSelectorQuery = () => {
10
11
  export const createIntersectionObserver: typeof Taro.createIntersectionObserver = (component, options) => {
11
12
  return new IntersectionObserver(component, options)
12
13
  }
14
+
15
+ export const createMediaQueryObserver = /* @__PURE__ */ temporarilyNotSupport('createMediaQueryObserver')
16
+
17
+ export { IntersectionObserver }
@@ -1,7 +1,7 @@
1
- import Taro from '@tarojs/api'
2
-
3
1
  import { SelectorQuery } from './selectorQuery'
4
2
 
3
+ import type Taro from '@tarojs/taro/types'
4
+
5
5
  export class NodesRef implements Taro.NodesRef {
6
6
  _component?: any
7
7
  _selector: string
@@ -2,7 +2,7 @@ import { AREA_CHANGE_EVENT_NAME, Current, getPageScrollerOrNode, setNodeEventCal
2
2
 
3
3
  import { NodesRef } from './nodesRef'
4
4
 
5
- import type Taro from '@tarojs/api'
5
+ import type Taro from '@tarojs/taro/types'
6
6
 
7
7
  interface ISelectorQueryQueue {
8
8
  component: any
@@ -135,8 +135,7 @@ function filter (fields, dom) {
135
135
  // if (dataset) res.dataset = Object.assign({}, dom.dataset)
136
136
 
137
137
  if (rect || size) {
138
- const id = dom?._nid
139
- const { areaInfo } = dom?._instance?.nodeInfoMap?.[id] || {}
138
+ const { areaInfo } = dom?._nodeInfo || {}
140
139
 
141
140
  if (areaInfo) {
142
141
  if (rect) {
@@ -153,7 +152,7 @@ function filter (fields, dom) {
153
152
  }
154
153
  }
155
154
  if (scrollOffset) {
156
- const scroller = dom._instance.scroller
155
+ const scroller = dom.scroller
157
156
 
158
157
  if (scroller) {
159
158
  const { xOffset, yOffset } = scroller.currentOffset()
@@ -1,56 +1,37 @@
1
- import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo } from '@tarojs/runtime'
2
- import { createNode } from './render'
3
- import TaroComponentWrapper from './base'
4
- import { createTaroEvent } from './utils/events'
1
+ import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
+ import { createLazyChildren } from './render'
3
+ import commonStyleModify from './style'
5
4
  import { BUTTON_THEME_COLOR } from './utils/constant/style'
6
- import { AttributeManager } from './utils/AttributeManager'
7
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
8
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
9
7
 
10
- import type { TaroAny, TaroEvent } from '@tarojs/runtime'
11
- import type { TaroButtonElement, TaroElement } from './element'
12
- import type { TaroStyleType } from '@tarojs/runtime'
8
+ import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
13
9
 
14
10
  @Extend(Button)
15
- function attrs (style: TaroStyleType) {
16
- .id(style.id)
17
- .key(style.id)
18
- .padding(style.padding)
19
- .margin(style.margin)
20
- .width(style.width)
21
- .height(style.height)
22
- .constraintSize(style.constraintSize)
23
- .flexGrow(style.flexGrow)
24
- .flexShrink(style.flexShrink)
25
- .flexBasis(style.flexBasis)
26
- .alignSelf(style.alignSelf)
27
- .backgroundColor(style.backgroundColor)
28
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
29
- .backgroundImageSize(style.backgroundImageSize)
30
- .rotate(style.rotate)
31
- .scale(style.scale)
32
- .translate(style.translate)
33
- .transform(style.transform)
34
- .borderStyle(style.borderStyle)
35
- .borderWidth(style.borderWidth)
11
+ function themeStyles(style: TaroStyleType) {
12
+ .fontColor(style.color)
13
+ .opacity(style.opacity)
36
14
  .borderColor(style.borderColor)
15
+ .borderWidth(style.borderWidth)
37
16
  .borderRadius(style.borderRadius)
38
- .linearGradient(style.linearGradient)
39
- .zIndex(style.zIndex)
40
- .opacity(style.opacity)
41
- .clip(style.clip)
17
+ .backgroundColor(style.backgroundColor)
42
18
  }
43
19
 
20
+ export function getButtonColor (node: TaroButtonElement, color: ResourceColor) {
21
+ const _attrs = node._attrs
22
+ const isDisabled: boolean = _attrs.disabled || false
23
+ const isPlain: boolean = _attrs.plain || false
24
+ const type: string = _attrs.type || 'default'
44
25
 
45
- @Extend(Button)
46
- function themeStyles(style: TaroStyleType) {
47
- .border({
48
- width: 1,
49
- color: style.backgroundColor
50
- })
51
- .fontColor(style.color)
52
- .opacity(style.opacity)
53
- .backgroundColor(style.backgroundColor)
26
+ if (isDisabled && isPlain) {
27
+ return Color.Black
28
+ }
29
+
30
+ if (isPlain) {
31
+ return BUTTON_THEME_COLOR.get(type).plainText
32
+ }
33
+
34
+ return color
54
35
  }
55
36
 
56
37
  function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
@@ -61,59 +42,90 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
61
42
  const type: string = _attrs.type || 'default'
62
43
 
63
44
  return {
64
- opacity: isDisabled ? 0.4 : 1,
45
+ borderColor: {
46
+ top: hmStyle.borderTopColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
47
+ right: hmStyle.borderRightColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
48
+ bottom: hmStyle.borderBottomColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
49
+ left: hmStyle.borderLeftColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background)
50
+ },
51
+ borderWidth: {
52
+ top: hmStyle.borderTopWidth || 1,
53
+ right: hmStyle.borderRightWidth || 1,
54
+ bottom: hmStyle.borderBottomWidth || 1,
55
+ left: hmStyle.borderLeftWidth || 1
56
+ },
57
+ borderRadius: {
58
+ topLeft: hmStyle.borderTopLeftRadius || convertNumber2VP(10),
59
+ topRight: hmStyle.borderTopRightRadius || convertNumber2VP(10),
60
+ bottomLeft: hmStyle.borderBottomLeftRadius || convertNumber2VP(10),
61
+ bottomRight: hmStyle.borderBottomRightRadius || convertNumber2VP(10)
62
+ },
63
+ opacity: isDisabled ? 0.4 : hmStyle.opacity,
65
64
  backgroundColor: isPlain ? Color.Transparent : (hmStyle.backgroundColor || BUTTON_THEME_COLOR.get(type).background),
66
- color: hmStyle.color || BUTTON_THEME_COLOR.get(type).text,
65
+ color: hmStyle.color || getButtonColor(node, BUTTON_THEME_COLOR.get(type).text),
67
66
  }
68
67
  }
69
68
 
70
- @Component
71
- export default struct TaroButton {
72
- nodeInfoMap: TaroAny = {}
69
+ function getButtonWidth (node: TaroButtonElement) {
70
+ const isMini = node._attrs.size === 'mini'
71
+
72
+ return isMini ? convertNumber2VP(120) : '100%'
73
+ }
74
+
75
+ function getButtonHeight (node: TaroButtonElement) {
76
+ const isMini = node._attrs.size === 'mini'
73
77
 
74
- @ObjectLink node: TaroButtonElement
78
+ return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
79
+ }
75
80
 
76
- @Styles visibleChangeEvent () {
77
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
81
+ function getButtonMinWidth (node: TaroButtonElement): string | number | undefined {
82
+ if (node.hmStyle.width) {
83
+ return undefined
78
84
  }
79
85
 
80
- aboutToAppear () {
81
- initComponentNodeInfo(this, this.node)
82
- bindInstanceToNode(this.node, this)
83
- // 绑定动画
84
- bindAnimation(this.node)
86
+ return getButtonWidth(node)
87
+ }
88
+
89
+ function getButtonMinHeight (node: TaroButtonElement): string | number | undefined {
90
+ if (node.hmStyle.height) {
91
+ return undefined
85
92
  }
86
93
 
87
- build() {
88
- TaroComponentWrapper({ node: this.node }) {
89
- Button({ stateEffect: !this.node._attrs.disabled }) {
90
- Row() {
91
- if (this.node._attrs.loading) {
92
- LoadingProgress()
93
- .width(20).height(20)
94
- .color(getThemeAttributes(this.node).color)
95
- }
96
- ForEach(this.node.childNodes, (item: TaroElement) => {
97
- createNode(item)
98
- }, (item: TaroElement) => item._nid)
99
- }
94
+ return getButtonHeight(node)
95
+ }
96
+
97
+ @Builder
98
+ export default function TaroButton (node: TaroButtonElement) {
99
+ Button({ stateEffect: !node._attrs.disabled }) {
100
+ Row() {
101
+ if (node._attrs.loading) {
102
+ LoadingProgress()
103
+ .width(20).height(20)
104
+ .color(getThemeAttributes(node).color)
100
105
  }
101
- .attrs(getNormalAttributes(this.node))
102
- .themeStyles(getThemeAttributes(this.node))
103
- .onClick((e: ClickEvent) => {
104
- if (['submit', 'reset'].includes(this.node._attrs.formType)) {
105
- const eventName = this.node._attrs.formType + '-btn'
106
- const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
107
- eventHandler(event, eventName, this.node)
108
- }
109
- eventHandler(e, 'click', this.node)
110
- })
111
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
112
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
113
- const eventResult: TaroAny = res.eventResult
114
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
115
- }))
116
- .visibleChangeEvent()
106
+ createLazyChildren(node)
117
107
  }
118
108
  }
109
+ .themeStyles(getThemeAttributes(node))
110
+ .attributeModifier(commonStyleModify.setNode(node))
111
+ .constraintSize({
112
+ minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
113
+ minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
114
+ maxWidth: node.hmStyle?.maxWidth,
115
+ maxHeight: node.hmStyle?.maxHeight,
116
+ })
117
+ .type(ButtonType.Normal)
118
+ .onClick((e: ClickEvent) => {
119
+ if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
120
+ const eventName = node._attrs.formType + '-btn'
121
+ const event: TaroEvent = createTaroEvent(eventName, {}, node)
122
+ eventHandler(event, eventName, node)
123
+ }
124
+ eventHandler(e, 'click', node)
125
+ })
126
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
127
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
128
+ node._nodeInfo.areaInfo = res[1]
129
+ }))
130
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
119
131
  }