@tarojs/plugin-platform-harmony-ets 4.0.0-beta.73 → 4.0.0-beta.75

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.
@@ -112,7 +112,7 @@ export const chooseImage: typeof Taro.chooseImage = function (options) {
112
112
  photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE // 过滤选择媒体文件类型为IMAGE
113
113
 
114
114
  photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => {
115
- callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris })
115
+ callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris }, options)
116
116
  }).catch((error) => {
117
117
  callAsyncFail(reject, error, options)
118
118
  })
@@ -1,14 +1,17 @@
1
1
  import { Current } from '@tarojs/runtime'
2
2
 
3
- import { callAsyncSuccess } from '../utils'
3
+ import { callAsyncFail, callAsyncSuccess } from '../utils'
4
4
 
5
5
  import type Taro from '@tarojs/taro/types'
6
6
 
7
7
  export const startPullDownRefresh: typeof Taro.startPullDownRefresh = function (options) {
8
- return new Promise(resolve => {
8
+ return new Promise((resolve, reject) => {
9
9
  const taro = (Current as any).taro
10
10
  const page = taro.getCurrentInstance().page
11
11
 
12
+ if (!page) {
13
+ return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options)
14
+ }
12
15
  if (page.isRefreshing instanceof Array) {
13
16
  const index = page.tabBarCurrentIndex || 0
14
17
  page.isRefreshing[index] = true
@@ -23,10 +26,13 @@ export const startPullDownRefresh: typeof Taro.startPullDownRefresh = function (
23
26
  }
24
27
 
25
28
  export const stopPullDownRefresh: typeof Taro.stopPullDownRefresh = function (options) {
26
- return new Promise(resolve => {
29
+ return new Promise((resolve, reject) => {
27
30
  const taro = (Current as any).taro
28
31
  const page = taro.getCurrentInstance().page
29
32
 
33
+ if (!page) {
34
+ return callAsyncFail(reject, { errMsg: 'stopPullDownRefresh:fail' }, options)
35
+ }
30
36
  if (page.isRefreshing instanceof Array) {
31
37
  const index = page.tabBarCurrentIndex || 0
32
38
  page.isRefreshing[index] = false
@@ -34,8 +34,8 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
34
34
  const page = taro.getCurrentInstance().page
35
35
 
36
36
  let scrollValue = -1
37
- let scroller = getPageScrollerOrNode(page.scroller, page)
38
- const currentPageNode = getPageScrollerOrNode(page.node, page)
37
+ let scroller = getPageScrollerOrNode(page?.scroller, page)
38
+ const currentPageNode = getPageScrollerOrNode(page?.node, page)
39
39
 
40
40
  if (scrollTop || typeof scrollTop === 'number') {
41
41
  scrollValue = scrollTop
@@ -66,14 +66,14 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
66
66
  scrollValue = areaInfo.globalPosition.y + yOffset + pxTransformHelper(offsetTop, 'px', true)
67
67
  }
68
68
  }
69
- const { xOffset } = scroller.currentOffset()
70
-
71
- if (scrollValue === -1) {
69
+ if (!scroller || scrollValue === -1) {
72
70
  return handle.fail({
73
71
  errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
74
72
  }, { resolve, reject })
75
73
  }
76
74
 
75
+ const { xOffset } = scroller.currentOffset()
76
+
77
77
  try {
78
78
  scroller.scrollTo({
79
79
  xOffset,
@@ -22,7 +22,7 @@ const toggleTabBar = function<T extends ToggleAPIs['type']> (type: T): Extract<T
22
22
  return new Promise((resolve, reject) => {
23
23
  const taro = (Current as any).taro
24
24
  const page = taro.getCurrentInstance().page
25
- const currentData = page._data?.taroTabBar || page.tabBar
25
+ const currentData = page?._data?.taroTabBar || page?.tabBar
26
26
  const res = { errMsg: `${type}TabBar:ok` }
27
27
  const error = { errMsg: `${type}TabBar:fail not TabBar page` }
28
28
 
@@ -49,7 +49,7 @@ export const setTabBarStyle: typeof Taro.setTabBarStyle = function (options = {}
49
49
  return new Promise((resolve, reject) => {
50
50
  const taro = (Current as any).taro
51
51
  const page = taro.getCurrentInstance().page
52
- const currentData = page._data?.taroTabBar || page.tabBar
52
+ const currentData = page?._data?.taroTabBar || page?.tabBar
53
53
  const res = { errMsg: 'setTabBarStyle:ok' }
54
54
  const error = { errMsg: 'setTabBarStyle:fail not TabBar page' }
55
55
 
@@ -74,7 +74,7 @@ export const setTabBarItem: typeof Taro.setTabBarItem = function (options) {
74
74
  return new Promise((resolve, reject) => {
75
75
  const taro = (Current as any).taro
76
76
  const page = taro.getCurrentInstance().page
77
- const currentData = page._data?.taroTabBar || page.tabBar
77
+ const currentData = page?._data?.taroTabBar || page?.tabBar
78
78
  const res = { errMsg: 'setTabBarItem:ok' }
79
79
  const error = { errMsg: 'setTabBarItem:fail not TabBar page' }
80
80
 
@@ -192,9 +192,9 @@ function queryBat (queue, cb) {
192
192
  const result: any = []
193
193
  const taro = (Current as any).taro
194
194
  const page = taro.getCurrentInstance().page
195
- const element = getPageScrollerOrNode(page.node, page)
195
+ const element = getPageScrollerOrNode(page?.node, page)
196
196
 
197
- if (element == null) return null
197
+ if (!element) return null
198
198
 
199
199
  arr = []
200
200
  traversalDFSDom(element)
@@ -12,8 +12,8 @@ import { isUndefined } from '@tarojs/shared'
12
12
  function handleTargetChange (id: string) {
13
13
  const taro: TaroAny = Current.taro
14
14
  const page: TaroAny = taro.getCurrentInstance().page
15
- const currentPageNode: TaroElement = getPageScrollerOrNode(page.node, page)
16
- const node: TaroElement | null = currentPageNode.getElementById(id)
15
+ const currentPageNode: TaroElement = getPageScrollerOrNode(page?.node, page)
16
+ const node: TaroElement | null = currentPageNode?.getElementById(id)
17
17
 
18
18
  if (!node) return
19
19
 
@@ -47,7 +47,7 @@ export default struct TaroMovableView {
47
47
  .visibility(this.node.visibility)
48
48
  .gesture(
49
49
  GestureGroup(GestureMode.Parallel,
50
- PanGesture({ fingers: 1 }).onActionStart((e: GestureEvent) => {
50
+ PanGesture(getPanOption(this.node)).onActionStart((e: GestureEvent) => {
51
51
 
52
52
  this.node.startMove()
53
53
  this.node.callTouchEventFnFromGesture('touchstart', e)
@@ -71,3 +71,21 @@ export default struct TaroMovableView {
71
71
  )
72
72
  }
73
73
  }
74
+
75
+
76
+ function getPanOption(node: TaroMovableViewElement) {
77
+ const attrDirection = node.getAttribute('direction')
78
+ let panDirection = PanDirection.All
79
+
80
+ if(node.getAttribute('disabled')) {
81
+ panDirection = PanDirection.None
82
+ } else if(attrDirection === 'horizontal') {
83
+ panDirection = PanDirection.Horizontal
84
+ } else if (attrDirection === 'vertical') {
85
+ panDirection = PanDirection.Vertical
86
+ }
87
+ return new PanGestureOptions({
88
+ direction: panDirection,
89
+ fingers: 1
90
+ })
91
+ }
@@ -9,6 +9,11 @@ export class DynamicCenter {
9
9
 
10
10
  uninstall (node: TaroElement) {
11
11
  if (!node._isCompileMode || !node._instance) return
12
+
13
+ if (node._attrs?._dynamicID) {
14
+ node._instance[node._attrs._dynamicID] = new TaroElement('Ignore')
15
+ }
16
+ node._instance = null
12
17
  }
13
18
 
14
19
  bindComponentToNodeWithDFS (node: TaroElement, component: TaroAny) {
package/dist/index.js CHANGED
@@ -236,6 +236,7 @@ class TaroPlatformHarmony extends service.TaroPlatform {
236
236
  * @param extraOptions 需要额外合入 Options 的配置项
237
237
  */
238
238
  getOptions(extraOptions = {}) {
239
+ var _a, _b, _c;
239
240
  const { ctx } = this;
240
241
  const { recursiveMerge } = ctx.helper;
241
242
  const config = recursiveMerge(Object.assign({}, this.config), {
@@ -247,7 +248,7 @@ class TaroPlatformHarmony extends service.TaroPlatform {
247
248
  SUPPORT_TARO_POLYFILL: 'disabled',
248
249
  },
249
250
  });
250
- return Object.assign(Object.assign(Object.assign({}, config), { buildAdapter: config.platform, fileType: this.fileType, platformType: this.platformType, useETS: this.useETS, useJSON5: this.useJSON5 }), extraOptions);
251
+ return Object.assign(Object.assign(Object.assign({}, config), { buildAdapter: config.platform, fileType: this.fileType, platformType: this.platformType, useETS: this.useETS, useJSON5: this.useJSON5, isPure: Boolean((_c = (_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.runOpts) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.args) === null || _c === void 0 ? void 0 : _c.pure) }), extraOptions);
251
252
  }
252
253
  /**
253
254
  * 调用 runner 开始编译