@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.36 → 4.0.0-alpha.37

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 (68) hide show
  1. package/dist/apis/base/weapp/life-cycle.ts +1 -1
  2. package/dist/apis/framework/index.ts +1 -1
  3. package/dist/apis/media/image/index.ts +135 -124
  4. package/dist/apis/route/index.ts +2 -1
  5. package/dist/apis/ui/background.ts +1 -1
  6. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  7. package/dist/apis/ui/tab-bar.ts +2 -1
  8. package/dist/components-harmony-ets/button.ets +1 -1
  9. package/dist/components-harmony-ets/checkbox.ets +2 -1
  10. package/dist/components-harmony-ets/form.ets +1 -0
  11. package/dist/components-harmony-ets/index.ets +90 -37
  12. package/dist/components-harmony-ets/input.ets +2 -2
  13. package/dist/components-harmony-ets/label.ets +2 -1
  14. package/dist/components-harmony-ets/listView.ets +1 -1
  15. package/dist/components-harmony-ets/movableArea.ets +3 -3
  16. package/dist/components-harmony-ets/navigationBar.ets +1 -1
  17. package/dist/components-harmony-ets/pageMeta.ets +1 -1
  18. package/dist/components-harmony-ets/pseudo.ets +1 -1
  19. package/dist/components-harmony-ets/radio.ets +3 -2
  20. package/dist/components-harmony-ets/scrollList.ets +2 -2
  21. package/dist/components-harmony-ets/scrollView.ets +1 -1
  22. package/dist/components-harmony-ets/slider.ets +1 -1
  23. package/dist/components-harmony-ets/style.ets +6 -7
  24. package/dist/components-harmony-ets/swiper.ets +1 -1
  25. package/dist/components-harmony-ets/switch.ets +1 -1
  26. package/dist/components-harmony-ets/text.ets +2 -2
  27. package/dist/components-harmony-ets/utils/helper.ets +2 -2
  28. package/dist/components-harmony-ets/utils/styles.ets +6 -5
  29. package/dist/components-harmony-ets/video.ets +1 -1
  30. package/dist/components-harmony-ets/view.ets +2 -1
  31. package/dist/components-harmony-ets/webView.ets +1 -1
  32. package/dist/index.js +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/runtime-ets/bom/document.ts +2 -1
  35. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -1
  36. package/dist/runtime-ets/bom/navigator.ts +21 -1
  37. package/dist/runtime-ets/bom/raf.ts +37 -1
  38. package/dist/runtime-ets/bom/window.ts +5 -4
  39. package/dist/runtime-ets/constant.ts +10 -17
  40. package/dist/runtime-ets/current.ts +1 -0
  41. package/dist/runtime-ets/dom/document.ts +1 -1
  42. package/dist/runtime-ets/dom/element/canvas.ts +2 -3
  43. package/dist/runtime-ets/dom/element/element.ts +5 -6
  44. package/dist/runtime-ets/dom/element/movableView.ts +8 -12
  45. package/dist/runtime-ets/dom/eventTarget.ts +1 -1
  46. package/dist/runtime-ets/dom/node.ts +3 -2
  47. package/dist/runtime-ets/index.ts +7 -21
  48. package/dist/runtime-ets/interface/index.ts +0 -6
  49. package/dist/runtime-ets/utils/index.ts +6 -4
  50. package/dist/runtime-framework/react/app.ts +2 -1
  51. package/dist/runtime-framework/react/hooks.ts +1 -1
  52. package/dist/runtime-framework/react/native-page.ts +15 -44
  53. package/dist/runtime-framework/react/page.ts +2 -1
  54. package/dist/runtime-framework/solid/app.ts +2 -1
  55. package/dist/runtime-framework/solid/hooks.ts +1 -1
  56. package/dist/runtime-framework/solid/page.ts +2 -1
  57. package/dist/runtime-utils.js +166 -134
  58. package/dist/runtime-utils.js.map +1 -1
  59. package/dist/runtime.js +166 -134
  60. package/dist/runtime.js.map +1 -1
  61. package/package.json +9 -9
  62. package/dist/runtime-ets/bom/URL.ts +0 -2
  63. package/dist/runtime-ets/bom/history.ts +0 -1
  64. package/dist/runtime-ets/bom/location.ts +0 -1
  65. package/dist/runtime-ets/dom/event-source.ts +0 -1
  66. package/dist/runtime-ets/emitter/emitter.ts +0 -1
  67. package/dist/runtime-ets/env.ts +0 -1
  68. package/dist/runtime-ets/utils/router.ts +0 -9
@@ -1,10 +1,10 @@
1
+ import { eventSource } from '@tarojs/runtime/dist/runtime.esm'
1
2
  import { isUndefined } from '@tarojs/shared'
2
3
 
3
4
  import { Current } from '../current'
4
5
  import { findChildNodeWithDFS, getPageScrollerOrNode } from '../utils'
5
6
  import { TaroComment } from './comment'
6
7
  import { TaroElement } from './element/element'
7
- import { eventSource } from './event-source'
8
8
  import { NodeType, TaroNode, TaroTextNode } from './node'
9
9
 
10
10
  import type { Window } from '../bom/window'
@@ -1,9 +1,8 @@
1
- import { eventSource } from '../event-source'
2
- import { TaroNode } from '../node'
1
+ import { eventSource, TaroAny, TaroNode } from '@tarojs/runtime'
2
+
3
3
  import { TaroElement } from './element'
4
4
 
5
5
  import type { CanvasProps, CanvasTouchEvent } from '@tarojs/components/types'
6
- import type { TaroAny } from '../../interface'
7
6
 
8
7
  export class CanvasRenderingContext2DWXAdapter extends CanvasRenderingContext2D {
9
8
  // constructor(settings?: RenderingContextSetting) {
@@ -1,22 +1,20 @@
1
1
  // @ts-ignore
2
2
  import { getPageById } from '@tarojs/plugin-framework-react/dist/runtime'
3
+ import { eventCenter, eventSource } from '@tarojs/runtime/dist/runtime.esm'
3
4
  import { EMPTY_OBJ, toCamelCase } from '@tarojs/shared'
4
5
 
5
6
  import { ATTRIBUTES_CALLBACK_TRIGGER_MAP, ID } from '../../constant'
6
7
  import { Current } from '../../current'
7
- import { eventCenter } from '../../emitter/emitter'
8
8
  import { findChildNodeWithDFS } from '../../utils'
9
9
  import { initComponentNodeInfo, triggerAttributesCallback } from '../../utils/info'
10
10
  import { bindAnimation } from '../bind'
11
11
  import { ClassList } from '../class-list'
12
- import { createCSSStyleDeclaration } from '../cssStyleDeclaration'
13
- import { eventSource } from '../event-source'
12
+ import { type ICSSStyleDeclaration, createCSSStyleDeclaration } from '../cssStyleDeclaration'
14
13
  import { NodeType, TaroNode } from '../node'
15
14
  import StyleSheet, { HarmonyStyle, TaroStyleType } from '../stylesheet'
16
15
 
17
16
  import type { BaseTouchEvent, ITouchEvent, StandardProps } from '@tarojs/components/types'
18
- import type { TaroAny } from '../../interface'
19
- import type { ICSSStyleDeclaration } from '../cssStyleDeclaration'
17
+ import type { TaroAny } from '../../utils'
20
18
 
21
19
  type NamedNodeMap = { name: string, value: string }[]
22
20
 
@@ -93,7 +91,7 @@ export class TaroElement<
93
91
  }
94
92
 
95
93
  public get id(): string {
96
- return this.getAttribute('id') || `${this._nid}`
94
+ return this.getAttribute('id') || this._nid
97
95
  }
98
96
 
99
97
  public set className(value: string) {
@@ -340,6 +338,7 @@ export class TaroElement<
340
338
  public setLayer (value: number) {
341
339
  if (!this.parentNode) return // 没有父节点,不需要设置层级关系
342
340
 
341
+
343
342
  const currentPage = getPageById(this.getAttribute('__fixed'))
344
343
  if (currentPage) {
345
344
  this._page = currentPage
@@ -231,18 +231,14 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
231
231
  public callTouchEventFnFromGesture(eventName: string, gestureEvent: GestureEvent) {
232
232
  const touchFns = (this?.__listeners?.[eventName] || []) as Function[]
233
233
  touchFns.forEach(fn => {
234
- try {
235
- fn({
236
- _hmEvent: gestureEvent,
237
- target: this,
238
- changedTouches: gestureEvent.fingerList.map(finger => ({
239
- clientX: finger.globalX,
240
- clientY: finger.globalY
241
- }))
242
- })
243
- } catch (error) {
244
- console.error(error)
245
- }
234
+ fn({
235
+ _hmEvent: gestureEvent,
236
+ target: this,
237
+ changedTouches: gestureEvent.fingerList.map(finger => ({
238
+ clientX: finger.globalX,
239
+ clientY: finger.globalY
240
+ }))
241
+ })
246
242
  })
247
243
  }
248
244
  }
@@ -1,6 +1,6 @@
1
+ import { Events } from '@tarojs/runtime/dist/runtime.esm'
1
2
  import { isArray } from '@tarojs/shared'
2
3
 
3
- import { Events } from '../emitter/emitter'
4
4
  import { TaroEvent } from './event'
5
5
 
6
6
  import type { EventHandler } from '../interface'
@@ -1,8 +1,9 @@
1
+ import { eventSource } from '@tarojs/runtime/dist/runtime.esm'
2
+
1
3
  import TaroDataSourceElement from './dataSource'
2
- import { eventSource } from './event-source'
3
4
 
4
5
  import type { StandardProps } from '@tarojs/components/types'
5
- import type { TaroAny } from '../interface'
6
+ import type { TaroAny } from '../utils'
6
7
  import type { TaroDocument } from './document'
7
8
  import type { TaroElement } from './element/element'
8
9
 
@@ -1,32 +1,18 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // Current必须放在前面初始化
2
+ // eslint-disable-next-line simple-import-sort/exports
3
3
  export * from './current'
4
- export { hooks } from '@tarojs/shared'
5
- // bom
6
4
  export * from './bom/document'
7
5
  export * from './bom/getComputedStyle'
8
- export * from './bom/history'
9
- export * from './bom/location'
10
- export { navigator } from './bom/navigator'
11
- export { cancelAnimationFrame, now, requestAnimationFrame } from './bom/raf'
12
- export * from './bom/URL'
6
+ export { nav as navigator } from './bom/navigator'
7
+ export { caf as cancelAnimationFrame, now, raf as requestAnimationFrame } from './bom/raf'
13
8
  export * from './bom/window'
14
- // dom
15
9
  export * from './dom/element'
16
10
  export * from './dom/event'
17
11
  export * from './dom/node'
18
12
  export * from './dom/stylesheet'
19
13
  export * from './dom/cssNesting'
20
- // others
21
- export * from './env'
22
- export * from './constant'
23
- export * from './emitter/emitter'
24
- export * from './utils'
25
- // typings
26
14
  export * from './interface'
27
- export {
28
- Instance, PageProps,
29
- ReactPageComponent, ReactPageInstance, ReactAppInstance,
30
- PageLifeCycle, PageInstance,
31
- AppInstance,
32
- } from '@tarojs/runtime/dist/runtime.esm'
15
+ export * from './utils'
16
+ export * from './utils/info'
17
+ export { URL, URLSearchParams, eventSource, Events } from '@tarojs/runtime/dist/runtime.esm'
18
+ export { hooks } from '@tarojs/shared'
@@ -1,7 +1 @@
1
1
  export * from './event'
2
- export { PageConfig, TFunc } from '@tarojs/runtime/dist/runtime.esm'
3
-
4
- export type TaroAny = any
5
- export type TaroFunc = (...args: TaroAny[]) => TaroAny
6
- export type TaroIndent = string | number | boolean | undefined | null
7
- export type TaroObject = Record<string | number | symbol, TaroAny>
@@ -161,9 +161,9 @@ export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node:
161
161
  export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll): T[] | T | null {
162
162
  const queue = [node]
163
163
 
164
- const nodeList: T[] = []
164
+ const nodeList: TaroElement[] = []
165
165
  while (queue.length) {
166
- const currentNode = queue.shift() as T
166
+ const currentNode = queue.shift()
167
167
  if (currentNode) {
168
168
  if (typeof selector === 'string') {
169
169
  if (selector.startsWith('#')) {
@@ -200,5 +200,7 @@ export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node:
200
200
  return null
201
201
  }
202
202
 
203
- export * from './info'
204
- export * from './router'
203
+ export type TaroAny = any
204
+ export type TaroFunc = (...args: TaroAny[]) => TaroAny
205
+ export type TaroIndent = string | number | boolean | undefined | null
206
+ export type TaroObject = Record<string | number | symbol, TaroAny>
@@ -1,4 +1,5 @@
1
- import { Current, document, eventCenter } from '@tarojs/runtime'
1
+ import { Current, document } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
2
+ import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
2
3
 
3
4
  import { setReconciler } from './connect'
4
5
  import { injectPageInstance } from './page'
@@ -11,7 +11,7 @@ import type {
11
11
  PageLifeCycle,
12
12
  PageProps,
13
13
  TFunc
14
- } from '@tarojs/runtime'
14
+ } from '@tarojs/runtime/dist/runtime.esm'
15
15
 
16
16
  const createTaroHook = (lifecycle: keyof PageLifeCycle | keyof AppInstance) => {
17
17
  return (fn: TFunc) => {
@@ -1,4 +1,5 @@
1
- import { addLeadingSlash, CONTEXT_ACTIONS, Current, document, env, eventCenter, requestAnimationFrame, TaroElement, TFunc, window } from '@tarojs/runtime'
1
+ import { Current, document, requestAnimationFrame, TaroElement, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
2
+ import { addLeadingSlash, CONTEXT_ACTIONS, env, eventCenter, TFunc } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
2
3
  import { ensure, hooks, isUndefined } from '@tarojs/shared'
3
4
 
4
5
  import { ReactMeta as reactMeta } from './app'
@@ -28,11 +29,10 @@ interface InitNativeComponentEntryParams {
28
29
  cb?: TFunc
29
30
  // 是否使用默认的 DOM 入口 - app;默认为true,false的时候,会创建一个新的dom并且把它挂载在 app 下面
30
31
  isDefaultEntryDom?: boolean
31
- isUseReact18?: boolean
32
32
  }
33
33
 
34
34
  function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
35
- const { R, ReactDOM, cb, isDefaultEntryDom = true, isUseReact18 = false } = params
35
+ const { R, ReactDOM, cb, isDefaultEntryDom = true } = params
36
36
  interface IEntryState {
37
37
  components: {
38
38
  compId: string
@@ -60,8 +60,8 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
60
60
  // React 16 uncaught error 会导致整个应用 crash,
61
61
  // 目前把错误缩小到页面
62
62
  componentDidCatch (error, info: React.ErrorInfo) {
63
- console.warn(`Taro Error Page 报错信息:${error}`)
64
- console.error(`Taro Error Page 报错堆栈:${info.componentStack}`)
63
+ console.warn(error)
64
+ console.error(info.componentStack)
65
65
  }
66
66
 
67
67
  render () {
@@ -134,23 +134,14 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
134
134
  }),
135
135
  }
136
136
 
137
- if (isUseReact18) {
138
- ReactDOM.flushSync(() => {
139
- this.setState(
140
- {
141
- components: [...this.state.components, item],
142
- },
143
- () => cb && cb()
144
- )
145
- })
146
- } else {
137
+ ReactDOM.flushSync(() => {
147
138
  this.setState(
148
139
  {
149
140
  components: [...this.state.components, item],
150
141
  },
151
142
  () => cb && cb()
152
143
  )
153
- }
144
+ })
154
145
  }
155
146
 
156
147
  unmount (compId, cb?) {
@@ -158,20 +149,7 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
158
149
  const index = components.findIndex((item) => item.compId === compId)
159
150
  const next = [...components.slice(0, index), ...components.slice(index + 1)]
160
151
 
161
-
162
- if (isUseReact18) {
163
- ReactDOM.flushSync(() => {
164
- this.setState(
165
- {
166
- components: next,
167
- },
168
- () => {
169
- removePageInstance(compId)
170
- cb && cb()
171
- }
172
- )
173
- })
174
- } else {
152
+ ReactDOM.flushSync(() => {
175
153
  this.setState(
176
154
  {
177
155
  components: next,
@@ -181,7 +159,7 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
181
159
  cb && cb()
182
160
  }
183
161
  )
184
- }
162
+ })
185
163
  }
186
164
 
187
165
  render () {
@@ -202,16 +180,11 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
202
180
  app = nativeApp
203
181
  }
204
182
 
205
- if (isUseReact18) {
206
- const root = ReactDOM.createRoot(app)
183
+ const root = ReactDOM.createRoot(app)
207
184
 
208
- ReactDOM.flushSync(() => {
209
- root.render?.(h(Entry))
210
- })
211
- } else {
212
- // eslint-disable-next-line react/no-deprecated
213
- ReactDOM.render(h(Entry, {}), app)
214
- }
185
+ ReactDOM.flushSync(() => {
186
+ root.render?.(h(Entry))
187
+ })
215
188
  }
216
189
 
217
190
 
@@ -287,7 +260,7 @@ export function createNativePageConfig (
287
260
  const mountCallback = () => {
288
261
  pageElement = document.getElementById($taroPath)
289
262
 
290
- ensure(pageElement !== null, `Taro Error Page: ${$taroPath}, 该页面执行时出现了报错,导致没有找到页面实例。`)
263
+ ensure(pageElement !== null, '没有找到页面实例。')
291
264
 
292
265
  safeExecute($taroPath, ONLOAD, this.$taroParams)
293
266
  loadResolver()
@@ -300,7 +273,6 @@ export function createNativePageConfig (
300
273
  initNativeComponentEntry({
301
274
  R: react,
302
275
  ReactDOM,
303
- isUseReact18: pageConfig?.isUseReact18,
304
276
  cb: () => {
305
277
  Current.app!.mount!(Component, $taroPath, () => this, mountCallback)
306
278
  },
@@ -425,7 +397,7 @@ export function createNativeComponentConfig (
425
397
  h = react.createElement
426
398
  ReactDOM = reactdom
427
399
  setReconciler(ReactDOM)
428
- const { isNewBlended, isUseReact18 } = componentConfig
400
+ const { isNewBlended } = componentConfig
429
401
 
430
402
  const componentObj: Record<string, any> = {
431
403
  options: componentConfig,
@@ -462,7 +434,6 @@ export function createNativeComponentConfig (
462
434
  R: react,
463
435
  ReactDOM,
464
436
  isDefaultEntryDom: !isNewBlended,
465
- isUseReact18,
466
437
  cb: mountComponent,
467
438
  })
468
439
  } else {
@@ -1,4 +1,5 @@
1
- import { addLeadingSlash, CONTEXT_ACTIONS, Current, document, env, eventCenter, requestAnimationFrame, window } from '@tarojs/runtime'
1
+ import { Current, document, requestAnimationFrame, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
2
+ import { addLeadingSlash, CONTEXT_ACTIONS, env, eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
2
3
  import { hooks, isArray, isFunction, isUndefined } from '@tarojs/shared'
3
4
 
4
5
  import { ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, ON_UNLOAD } from './constant'
@@ -1,5 +1,6 @@
1
1
  import { createComponent, h, render } from '@tarojs/plugin-framework-solid/dist/reconciler'
2
- import { Current, document, eventCenter } from '@tarojs/runtime'
2
+ import { Current, document } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
3
+ import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
3
4
  import { hooks } from '@tarojs/shared'
4
5
  import { batch, createContext, createRoot, createSignal, For } from 'solid-js'
5
6
 
@@ -14,7 +14,7 @@ import type {
14
14
  AppInstance,
15
15
  PageLifeCycle,
16
16
  TFunc
17
- } from '@tarojs/runtime'
17
+ } from '@tarojs/runtime/dist/runtime.esm'
18
18
 
19
19
  const createTaroHook = (lifecycle: keyof PageLifeCycle | keyof AppInstance) => {
20
20
  return (fn: TFunc) => {
@@ -1,4 +1,5 @@
1
- import { addLeadingSlash, CONTEXT_ACTIONS, Current, document, env, eventCenter, requestAnimationFrame, window } from '@tarojs/runtime'
1
+ import { Current, document, requestAnimationFrame, window } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
2
+ import { addLeadingSlash, CONTEXT_ACTIONS, env, eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
2
3
  import { hooks, isArray, isFunction, isUndefined } from '@tarojs/shared'
3
4
 
4
5
  import { ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, ON_UNLOAD } from './constant'