@tarojs/plugin-platform-harmony-ets 4.0.0-beta.16 → 4.0.0-beta.18
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.
- package/dist/components-harmony-ets/button.ets +32 -29
- package/dist/components-harmony-ets/checkbox.ets +2 -2
- package/dist/components-harmony-ets/form.ets +28 -25
- package/dist/components-harmony-ets/icon.ets +18 -16
- package/dist/components-harmony-ets/image.ets +13 -11
- package/dist/components-harmony-ets/innerHtml.ets +1 -1
- package/dist/components-harmony-ets/input.ets +1 -1
- package/dist/components-harmony-ets/label.ets +39 -36
- package/dist/components-harmony-ets/movableArea.ets +1 -1
- package/dist/components-harmony-ets/movableView.ets +1 -1
- package/dist/components-harmony-ets/picker.ets +1 -1
- package/dist/components-harmony-ets/progress.ets +1 -1
- package/dist/components-harmony-ets/radio.ets +2 -2
- package/dist/components-harmony-ets/richText.ets +10 -31
- package/dist/components-harmony-ets/scrollView.ets +45 -43
- package/dist/components-harmony-ets/slider.ets +1 -1
- package/dist/components-harmony-ets/style.ets +30 -5
- package/dist/components-harmony-ets/swiper.ets +19 -17
- package/dist/components-harmony-ets/switch.ets +1 -1
- package/dist/components-harmony-ets/text.ets +11 -9
- package/dist/components-harmony-ets/textArea.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/index.ts +26 -0
- package/dist/components-harmony-ets/video.ets +3 -1
- package/dist/components-harmony-ets/view.ets +29 -27
- package/dist/components-harmony-ets/webView.ets +34 -33
- package/dist/index.d.ts +149 -0
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/bind.ts +0 -1
- package/dist/runtime-ets/dom/cssNesting.ts +24 -27
- package/dist/runtime-ets/dom/document.ts +0 -1
- package/dist/runtime-ets/dom/element/movableView.ts +0 -1
- package/dist/runtime-ets/dom/element/normal.ts +0 -1
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/stylesheet/index.ts +0 -2
- package/dist/runtime-ets/dom/stylesheet/type.ts +7 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +18 -14
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +0 -1
- package/dist/runtime-framework/react/native-page.ts +0 -1
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +825 -0
- package/dist/runtime.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +8 -8
|
@@ -45,23 +45,25 @@ export default struct TaroSwiper {
|
|
|
45
45
|
@ObjectLink node: TaroSwiperElement
|
|
46
46
|
|
|
47
47
|
build () {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
49
|
+
Swiper(this.node.controller) {
|
|
50
|
+
createLazyChildren(this.node)
|
|
51
|
+
}
|
|
52
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
53
|
+
.swiperAttr(getSwiperAttributes(this.node))
|
|
54
|
+
.indicatorStyle({
|
|
55
|
+
color: this.node.getAttribute('indicatorColor'),
|
|
56
|
+
selectedColor: this.node.getAttribute('indicatorActiveColor')
|
|
57
|
+
})
|
|
58
|
+
.onChange((index: number) => {
|
|
59
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
|
|
60
|
+
eventHandler(event, 'change', this.node)
|
|
61
|
+
})
|
|
62
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
63
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
64
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
65
|
+
}))
|
|
66
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
50
67
|
}
|
|
51
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
52
|
-
.swiperAttr(getSwiperAttributes(this.node))
|
|
53
|
-
.indicatorStyle({
|
|
54
|
-
color: this.node.getAttribute('indicatorColor'),
|
|
55
|
-
selectedColor: this.node.getAttribute('indicatorActiveColor')
|
|
56
|
-
})
|
|
57
|
-
.onChange((index: number) => {
|
|
58
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { current: index } }, this.node)
|
|
59
|
-
eventHandler(event, 'change', this.node)
|
|
60
|
-
})
|
|
61
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
62
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
63
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
64
|
-
}))
|
|
65
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -38,7 +38,7 @@ export default struct TaroSwitch {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
build () {
|
|
41
|
-
if (this.node) {
|
|
41
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
42
42
|
Toggle({
|
|
43
43
|
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
44
44
|
isOn: this.node.checked,
|
|
@@ -60,15 +60,17 @@ export default struct TaroText {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
} else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.node
|
|
71
|
-
|
|
63
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
64
|
+
Text(this.node.textContent)
|
|
65
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
66
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
67
|
+
.textNormalFontStyle(getNormalAttributes(this.node))
|
|
68
|
+
.textSpecialFontStyle(getFontAttributes(this.node))
|
|
69
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
70
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
71
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
72
|
+
}))
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
}
|
|
@@ -45,7 +45,7 @@ export default struct TaroTextArea {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
build () {
|
|
48
|
-
if (this.node) {
|
|
48
|
+
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
49
49
|
TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
50
50
|
.key(this.node._nid)
|
|
51
51
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { convertNumber2VP } from '@tarojs/runtime'
|
|
2
2
|
import { isNumber } from '@tarojs/shared'
|
|
3
3
|
|
|
4
|
+
import type { RichTextProps } from '@tarojs/components/types/RichText'
|
|
5
|
+
import type { TaroRichTextElement } from '@tarojs/runtime'
|
|
6
|
+
|
|
4
7
|
export function getSingleSelector(range, rangeKey): any[] {
|
|
5
8
|
return range.map((data) => data[rangeKey])
|
|
6
9
|
}
|
|
@@ -81,3 +84,26 @@ export function getNodeMarginOrPaddingData (dataValue: string) {
|
|
|
81
84
|
}
|
|
82
85
|
})
|
|
83
86
|
}
|
|
87
|
+
|
|
88
|
+
export function generateText (node: TaroRichTextElement): string {
|
|
89
|
+
return parseHtmlNode(node._attrs.nodes || '')
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 将nodeTree转换成harmony需要的string结构
|
|
93
|
+
function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
|
|
94
|
+
if (node.type === 'text') {
|
|
95
|
+
return node.text;
|
|
96
|
+
}
|
|
97
|
+
if (node.attrs) {
|
|
98
|
+
const attributes = Object.entries(node.attrs)
|
|
99
|
+
.map((item: [string, string]) => `${item[0]}="${item[1]}"`)
|
|
100
|
+
.join(' ');
|
|
101
|
+
const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
|
|
102
|
+
return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
|
|
103
|
+
}
|
|
104
|
+
return ''
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
|
|
108
|
+
return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
|
|
109
|
+
}
|
|
@@ -83,7 +83,8 @@ export default struct TaroVideo {
|
|
|
83
83
|
@ObjectLink node: TaroVideoElement
|
|
84
84
|
|
|
85
85
|
build () {
|
|
86
|
-
|
|
86
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
87
|
+
Video(getVideoData(this.node))
|
|
87
88
|
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
88
89
|
.props(getVideoProps(this.node))
|
|
89
90
|
.aspectRatio(4 / 3)
|
|
@@ -102,6 +103,7 @@ export default struct TaroVideo {
|
|
|
102
103
|
this.node._nodeInfo.areaInfo = res[1]
|
|
103
104
|
}))
|
|
104
105
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
|
|
107
109
|
}
|
|
@@ -33,34 +33,36 @@ export default struct TaroView {
|
|
|
33
33
|
@ObjectLink node: TaroViewElement
|
|
34
34
|
|
|
35
35
|
build () {
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
37
|
+
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
38
|
+
Row() {
|
|
39
|
+
PseduoChildren(this.node)
|
|
40
|
+
}
|
|
41
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
42
|
+
.rowAttrs(getNormalAttributes(this.node))
|
|
43
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
44
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
45
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
46
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
47
|
+
}))
|
|
48
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
49
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
50
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
51
|
+
} else {
|
|
52
|
+
Column() {
|
|
53
|
+
PseduoChildren(this.node)
|
|
54
|
+
}
|
|
55
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
56
|
+
.columnAttrs(getNormalAttributes(this.node))
|
|
57
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
58
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
59
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
60
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
61
|
+
}))
|
|
62
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
63
|
+
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
64
|
+
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
39
65
|
}
|
|
40
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
41
|
-
.rowAttrs(getNormalAttributes(this.node))
|
|
42
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
43
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
44
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
45
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
46
|
-
}))
|
|
47
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
48
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
49
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
50
|
-
} else {
|
|
51
|
-
Column() {
|
|
52
|
-
PseduoChildren(this.node)
|
|
53
|
-
}
|
|
54
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
55
|
-
.columnAttrs(getNormalAttributes(this.node))
|
|
56
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
57
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
58
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
59
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
60
|
-
}))
|
|
61
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
62
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
63
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import {
|
|
4
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
5
5
|
|
|
6
|
-
import type { TaroAny, TaroWebViewElement,
|
|
6
|
+
import type { TaroAny, TaroWebViewElement, TaroEvent } from '@tarojs/runtime'
|
|
7
7
|
|
|
8
8
|
interface IPageLoad {
|
|
9
9
|
url: string
|
|
@@ -19,37 +19,38 @@ export default struct TaroWebView {
|
|
|
19
19
|
@ObjectLink node: TaroWebViewElement
|
|
20
20
|
|
|
21
21
|
build () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
if (this.node.hmStyle?.display !== 'none') {
|
|
23
|
+
Web({ src: this.node._attrs.src, controller: this.node.controller })
|
|
24
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
25
|
+
.onPageEnd((e: IPageLoad) => {
|
|
26
|
+
// 1. 创建消息端口
|
|
27
|
+
this.node.ports = this.node.controller.createWebMessagePorts(true)
|
|
28
|
+
// 2. 发送端口1到HTML5
|
|
29
|
+
this.node.controller.postMessage('init_web_messageport', [this.node.ports[1]], '*');
|
|
30
|
+
// 3. 保存端口0到本地
|
|
31
|
+
this.node.nativePort = this.node.ports[0]
|
|
32
|
+
// 4. 设置回调函数
|
|
33
|
+
this.node.nativePort.onMessageEventExt((result) => {
|
|
34
|
+
const message = this.node.handleMessageFromWeb(result)
|
|
35
|
+
const messageEvent: TaroEvent = createTaroEvent('message', { detail: { data: message } }, this.node)
|
|
36
|
+
|
|
37
|
+
eventHandler(messageEvent, 'message', this.node)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const onLoadEvent: TaroEvent = createTaroEvent('load', { detail: { src: this.node._attrs.src } }, this.node)
|
|
41
|
+
|
|
42
|
+
eventHandler(onLoadEvent, 'load', this.node)
|
|
37
43
|
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
50
|
-
this.node._nodeInfo.areaInfo = res[1]
|
|
51
|
-
}))
|
|
52
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
53
|
-
|
|
44
|
+
.onErrorReceive(shouldBindEvent((e: IError) => {
|
|
45
|
+
const event: TaroEvent = createTaroEvent('error', { detail: { url: this.node._attrs.src, fullUrl: e.request.getRequestUrl() } }, this.node)
|
|
46
|
+
|
|
47
|
+
eventHandler(event, 'error', this.node)
|
|
48
|
+
}, this.node, ['error']))
|
|
49
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
50
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
51
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
52
|
+
}))
|
|
53
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
54
|
+
}
|
|
54
55
|
}
|
|
55
56
|
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { IFileType, TConfig, TaroPlatform, IPluginContext, TaroPlatformBase } from "@tarojs/service";
|
|
3
|
+
import { PLATFORM_TYPE } from "@tarojs/shared";
|
|
4
|
+
declare abstract class TaroPlatformHarmony<T extends TConfig = TConfig> extends TaroPlatform<T> {
|
|
5
|
+
platformType: PLATFORM_TYPE;
|
|
6
|
+
globalObject: string;
|
|
7
|
+
abstract fileType: IFileType;
|
|
8
|
+
abstract useETS: boolean;
|
|
9
|
+
abstract useJSON5: boolean;
|
|
10
|
+
taroComponentsPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* 1. 清空 dist 文件夹
|
|
13
|
+
* 2. 输出编译提示
|
|
14
|
+
*/
|
|
15
|
+
private setup;
|
|
16
|
+
private setupHarmonyApp;
|
|
17
|
+
protected printDevelopmentTip(): void;
|
|
18
|
+
/**
|
|
19
|
+
* 返回当前项目内的 runner 包
|
|
20
|
+
*/
|
|
21
|
+
protected getRunner(): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* 准备 runner 参数
|
|
24
|
+
* @param extraOptions 需要额外合入 Options 的配置项
|
|
25
|
+
*/
|
|
26
|
+
protected getOptions(extraOptions?: {}): any;
|
|
27
|
+
/**
|
|
28
|
+
* 调用 runner 开始编译
|
|
29
|
+
* @param extraOptions 需要额外传入 runner 的配置项
|
|
30
|
+
*/
|
|
31
|
+
private build;
|
|
32
|
+
private buildHarmonyApp;
|
|
33
|
+
/**
|
|
34
|
+
* 调用 runner 开启编译
|
|
35
|
+
*/
|
|
36
|
+
start(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
declare class Harmony extends TaroPlatformHarmony {
|
|
39
|
+
#private;
|
|
40
|
+
platform: string;
|
|
41
|
+
globalObject: string;
|
|
42
|
+
fileType: {
|
|
43
|
+
templ: string;
|
|
44
|
+
style: string;
|
|
45
|
+
config: string;
|
|
46
|
+
script: string;
|
|
47
|
+
};
|
|
48
|
+
useETS: boolean;
|
|
49
|
+
useJSON5: boolean;
|
|
50
|
+
runtimePath: string[] | string;
|
|
51
|
+
taroComponentsPath: string;
|
|
52
|
+
constructor(ctx: IPluginContext, config: TConfig);
|
|
53
|
+
get framework(): "vue3" | "react" | "preact" | "nerv" | "vue";
|
|
54
|
+
get aliasFramework(): string;
|
|
55
|
+
get apiLibrary(): string;
|
|
56
|
+
get componentLibrary(): string;
|
|
57
|
+
get runtimeLibrary(): string;
|
|
58
|
+
get runtimeFrameworkLibrary(): string;
|
|
59
|
+
get defineConstants(): Record<string, string> | undefined;
|
|
60
|
+
extensions: string[];
|
|
61
|
+
excludeLibraries: (string | RegExp)[];
|
|
62
|
+
externalDeps: [
|
|
63
|
+
string,
|
|
64
|
+
RegExp,
|
|
65
|
+
string?
|
|
66
|
+
][];
|
|
67
|
+
indexOfLibraries(lib: string): number;
|
|
68
|
+
removeFromLibraries(lib: string): void;
|
|
69
|
+
moveLibraries(lib: string, target?: string, basedir?: string, sync?: boolean): void;
|
|
70
|
+
replaceDefineValue(code: string, define: Record<string, string>): string;
|
|
71
|
+
/**
|
|
72
|
+
* 修改 Vite 配置
|
|
73
|
+
*/
|
|
74
|
+
modifyViteConfig(): void;
|
|
75
|
+
handleResourceEmit(outDir: string, basedir?: string): void;
|
|
76
|
+
}
|
|
77
|
+
declare module HarmonyWrapper {
|
|
78
|
+
export { Harmony };
|
|
79
|
+
}
|
|
80
|
+
import HarmonyOS_ArkTS = HarmonyWrapper.Harmony;
|
|
81
|
+
declare class Harmony$0 extends TaroPlatformBase {
|
|
82
|
+
platform: string;
|
|
83
|
+
globalObject: string;
|
|
84
|
+
runtimePath: string;
|
|
85
|
+
taroComponentsPath: string;
|
|
86
|
+
fileType: {
|
|
87
|
+
templ: string;
|
|
88
|
+
style: string;
|
|
89
|
+
config: string;
|
|
90
|
+
script: string;
|
|
91
|
+
};
|
|
92
|
+
template: any;
|
|
93
|
+
/**
|
|
94
|
+
* 1. setupTransaction - init
|
|
95
|
+
* 2. setup
|
|
96
|
+
* 3. setupTransaction - close
|
|
97
|
+
* 4. buildTransaction - init
|
|
98
|
+
* 5. build
|
|
99
|
+
* 6. buildTransaction - close
|
|
100
|
+
*/
|
|
101
|
+
constructor(ctx: any, config: any);
|
|
102
|
+
/**
|
|
103
|
+
* 增加组件或修改组件属性
|
|
104
|
+
*/
|
|
105
|
+
modifyComponents(): void;
|
|
106
|
+
/**
|
|
107
|
+
* 不需要转 rpx
|
|
108
|
+
*/
|
|
109
|
+
modifyPostcssConfigs(config: Record<string, any>): void;
|
|
110
|
+
/**
|
|
111
|
+
* 模板自定义组件 js
|
|
112
|
+
* 等鸿蒙支持 template 后需要重构
|
|
113
|
+
*/
|
|
114
|
+
addEntry(): void;
|
|
115
|
+
/**
|
|
116
|
+
* 把 app、pages、自定义组件的 js 改造为鸿蒙的 export default 导出形式
|
|
117
|
+
*/
|
|
118
|
+
modifyTaroExport(): void;
|
|
119
|
+
/**
|
|
120
|
+
* 修改最终的编译产物
|
|
121
|
+
* 1. 生成模板自定义组件的 xml、css 文件
|
|
122
|
+
* 2. 删除多余的文件
|
|
123
|
+
* 3. 把 components-harmony 中被使用到的组件移动到输出目录
|
|
124
|
+
*/
|
|
125
|
+
modifyBuildAssets(ctx: any, config: any): void;
|
|
126
|
+
modifyWebpackConfig(): void;
|
|
127
|
+
modifyHarmonyConfig(pages: any, { projectPath, hapName, name }: {
|
|
128
|
+
projectPath: any;
|
|
129
|
+
hapName: any;
|
|
130
|
+
name: any;
|
|
131
|
+
}): void;
|
|
132
|
+
modifyHostPackage({ projectPath, hapName }: {
|
|
133
|
+
projectPath: any;
|
|
134
|
+
hapName?: string | undefined;
|
|
135
|
+
}): Promise<any>;
|
|
136
|
+
getChunkEntryModule(compilation: any, chunk: any, compiler?: string): any;
|
|
137
|
+
checkMetaType(entryModule: any): boolean;
|
|
138
|
+
isHarmonyRequest(request: string): boolean;
|
|
139
|
+
}
|
|
140
|
+
declare module HarmonyWrapper {
|
|
141
|
+
export { Harmony$0 as Harmony };
|
|
142
|
+
}
|
|
143
|
+
import HarmonyOS_JSUI = HarmonyWrapper.Harmony;
|
|
144
|
+
interface IOptions {
|
|
145
|
+
disableArkTS?: boolean;
|
|
146
|
+
useConfigName?: string;
|
|
147
|
+
}
|
|
148
|
+
declare const _default: (ctx: IPluginContext, options?: IOptions) => void;
|
|
149
|
+
export { _default as default, HarmonyOS_ArkTS, HarmonyOS_JSUI, IOptions };
|
package/dist/index.js
CHANGED
|
@@ -248,7 +248,7 @@ class TaroPlatformHarmony extends service.TaroPlatform {
|
|
|
248
248
|
SUPPORT_TARO_POLYFILL: 'disabled',
|
|
249
249
|
},
|
|
250
250
|
});
|
|
251
|
-
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, useNesting: config.useNesting, useJSON5: this.useJSON5 }), extraOptions);
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* 调用 runner 开始编译
|
|
@@ -502,6 +502,11 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
502
502
|
if (['.ts'].includes(ext)) {
|
|
503
503
|
code = '// @ts-nocheck\n' + code;
|
|
504
504
|
}
|
|
505
|
+
// 处理嵌套样式的编译,需要针对ReactElement进行props操作,dev模式下会Object.freeze,所以需要在开发模式下注入Object.freeze来覆盖解锁
|
|
506
|
+
// 处理的方法再taro-platform-harmony/src/runtime-ets/dom/cssNesting: ele.props.style = declaration
|
|
507
|
+
if (/react\/jsx-runtime/.test(lib) && process.env.NODE_ENV === 'development') {
|
|
508
|
+
code = 'Object.freeze = (obj) => obj \n' + code;
|
|
509
|
+
}
|
|
505
510
|
}
|
|
506
511
|
// Note: 传入 chorePackagePrefix 时,不生成核心依赖库
|
|
507
512
|
if (!chorePackagePrefix) {
|