@tarojs/plugin-platform-harmony-ets 4.0.0-beta.0 → 4.0.0-beta.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.
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- package/dist/components-harmony-ets/button.ets +57 -27
- package/dist/components-harmony-ets/checkbox.ets +237 -72
- package/dist/components-harmony-ets/form.ets +143 -27
- package/dist/components-harmony-ets/icon.ets +53 -19
- package/dist/components-harmony-ets/image.ets +53 -19
- package/dist/components-harmony-ets/input.ets +57 -18
- package/dist/components-harmony-ets/label.ets +155 -33
- package/dist/components-harmony-ets/picker.ets +155 -41
- package/dist/components-harmony-ets/radio.ets +240 -75
- package/dist/components-harmony-ets/richText.ets +52 -18
- package/dist/components-harmony-ets/scrollView.ets +103 -45
- package/dist/components-harmony-ets/slider.ets +57 -18
- package/dist/components-harmony-ets/swiper.ets +52 -18
- package/dist/components-harmony-ets/switch.ets +92 -41
- package/dist/components-harmony-ets/text.ets +60 -23
- package/dist/components-harmony-ets/textArea.ets +58 -19
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/flexManager.ets +44 -7
- package/dist/components-harmony-ets/utils/helper.ets +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +57 -20
- package/dist/components-harmony-ets/video.ets +52 -18
- package/dist/components-harmony-ets/view.ets +111 -46
- package/dist/components-harmony-ets/webView.ets +113 -0
- package/dist/index.js +101 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
- package/dist/runtime-ets/dom/element/element.ts +1 -0
- package/dist/runtime-ets/dom/element/form.ts +11 -2
- package/dist/runtime-ets/dom/element/index.ts +4 -1
- package/dist/runtime-ets/dom/element/normal.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +61 -0
- package/dist/runtime-ets/dom/node.ts +29 -16
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
- package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +6 -1
- package/dist/runtime-ets/utils/info.ts +3 -1
- package/dist/runtime-framework/react/app.ts +12 -22
- package/dist/runtime-framework/react/index.ts +1 -0
- package/dist/runtime-framework/react/native-page.ts +344 -0
- package/dist/runtime-framework/react/page.ts +2 -2
- package/dist/runtime-utils.js +56 -15
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +56 -15
- package/dist/runtime.js.map +1 -1
- package/package.json +10 -9
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/runtime.d.ts +2 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
4
|
+
|
|
5
|
+
import type { TaroAny, TaroWebViewElement, TaroStyleType, TaroEvent } from '@tarojs/runtime'
|
|
6
|
+
|
|
7
|
+
interface IPageLoad {
|
|
8
|
+
url: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface IError {
|
|
12
|
+
request: WebResourceRequest
|
|
13
|
+
error: WebResourceError
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Extend(Web)
|
|
17
|
+
function attrs (style: TaroStyleType) {
|
|
18
|
+
.id(style.id)
|
|
19
|
+
.key(style.id)
|
|
20
|
+
.flexGrow(style.flexGrow)
|
|
21
|
+
.flexShrink(style.flexShrink)
|
|
22
|
+
.flexBasis(style.flexBasis)
|
|
23
|
+
.alignSelf(style.alignSelf)
|
|
24
|
+
.padding({
|
|
25
|
+
top: style.paddingTop,
|
|
26
|
+
right: style.paddingRight,
|
|
27
|
+
bottom: style.paddingBottom,
|
|
28
|
+
left: style.paddingLeft
|
|
29
|
+
})
|
|
30
|
+
.margin({
|
|
31
|
+
top: style.marginTop,
|
|
32
|
+
right: style.marginRight,
|
|
33
|
+
bottom: style.marginBottom,
|
|
34
|
+
left: style.marginLeft
|
|
35
|
+
})
|
|
36
|
+
.width(style.width)
|
|
37
|
+
.height(style.height)
|
|
38
|
+
.constraintSize({
|
|
39
|
+
minWidth: style.minWidth,
|
|
40
|
+
maxWidth: style.maxWidth,
|
|
41
|
+
minHeight: style.minHeight,
|
|
42
|
+
maxHeight: style.maxHeight
|
|
43
|
+
})
|
|
44
|
+
.backgroundColor(style.backgroundColor)
|
|
45
|
+
.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
|
|
46
|
+
.backgroundImageSize(style.backgroundSize)
|
|
47
|
+
.backgroundImagePosition(style.backgroundPosition)
|
|
48
|
+
.borderStyle({
|
|
49
|
+
top: style.borderTopStyle,
|
|
50
|
+
right: style.borderRightStyle,
|
|
51
|
+
bottom: style.borderBottomStyle,
|
|
52
|
+
left: style.borderLeftStyle
|
|
53
|
+
})
|
|
54
|
+
.borderWidth({
|
|
55
|
+
top: style.borderTopWidth,
|
|
56
|
+
right: style.borderRightWidth,
|
|
57
|
+
bottom: style.borderBottomWidth,
|
|
58
|
+
left: style.borderLeftWidth
|
|
59
|
+
})
|
|
60
|
+
.borderColor({
|
|
61
|
+
top: style.borderTopColor,
|
|
62
|
+
right: style.borderRightColor,
|
|
63
|
+
bottom: style.borderBottomColor,
|
|
64
|
+
left: style.borderLeftColor
|
|
65
|
+
})
|
|
66
|
+
.borderRadius({
|
|
67
|
+
topLeft: style.borderTopLeftRadius,
|
|
68
|
+
topRight: style.borderTopRightRadius,
|
|
69
|
+
bottomLeft: style.borderBottomLeftRadius,
|
|
70
|
+
bottomRight: style.borderBottomRightRadius
|
|
71
|
+
})
|
|
72
|
+
.zIndex(style.zIndex)
|
|
73
|
+
.opacity(style.opacity)
|
|
74
|
+
.clip(style.overflow)
|
|
75
|
+
.rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
|
|
76
|
+
.scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
|
|
77
|
+
.transform(style.transform)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Builder
|
|
81
|
+
export default function TaroWebView (node: TaroWebViewElement) {
|
|
82
|
+
Web({ src: node._attrs.src, controller: node.controller })
|
|
83
|
+
.attrs(getNormalAttributes(node))
|
|
84
|
+
.onPageEnd((e: IPageLoad) => {
|
|
85
|
+
// 1. 创建消息端口
|
|
86
|
+
node.ports = node.controller.createWebMessagePorts(true)
|
|
87
|
+
// 2. 发送端口1到HTML5
|
|
88
|
+
node.controller.postMessage('init_web_messageport', [node.ports[1]], '*');
|
|
89
|
+
// 3. 保存端口0到本地
|
|
90
|
+
node.nativePort = node.ports[0]
|
|
91
|
+
// 4. 设置回调函数
|
|
92
|
+
node.nativePort.onMessageEventExt((result) => {
|
|
93
|
+
const message = node.handleMessageFromWeb(result)
|
|
94
|
+
const messageEvent: TaroEvent = createTaroEvent('message', { detail: { data: message } }, node)
|
|
95
|
+
|
|
96
|
+
eventHandler(messageEvent, 'message', node)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const onLoadEvent: TaroEvent = createTaroEvent('load', { detail: { src: node._attrs.src } }, node)
|
|
100
|
+
|
|
101
|
+
eventHandler(onLoadEvent, 'load', node)
|
|
102
|
+
})
|
|
103
|
+
.onErrorReceive(shouldBindEvent((e: IError) => {
|
|
104
|
+
const event: TaroEvent = createTaroEvent('error', { detail: { url: node._attrs.src, fullUrl: e.request.getRequestUrl() } }, node)
|
|
105
|
+
|
|
106
|
+
eventHandler(event, 'error', node)
|
|
107
|
+
}, node, ['error']))
|
|
108
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
109
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
110
|
+
node._nodeInfo.areaInfo = res[1]
|
|
111
|
+
}))
|
|
112
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
113
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
44
44
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
45
45
|
PERFORMANCE OF THIS SOFTWARE.
|
|
46
46
|
***************************************************************************** */
|
|
47
|
-
/* global Reflect, Promise */
|
|
47
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
@@ -68,6 +68,91 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
|
68
68
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
69
69
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
70
70
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
74
|
+
var e = new Error(message);
|
|
75
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
function apiLoader(str) {
|
|
79
|
+
return `import {
|
|
80
|
+
useAddToFavorites,
|
|
81
|
+
useDidHide,
|
|
82
|
+
useDidShow,
|
|
83
|
+
useError,
|
|
84
|
+
useLaunch,
|
|
85
|
+
useLoad,
|
|
86
|
+
useOptionMenuClick,
|
|
87
|
+
usePageNotFound,
|
|
88
|
+
usePageScroll,
|
|
89
|
+
usePullDownRefresh,
|
|
90
|
+
usePullIntercept,
|
|
91
|
+
useReachBottom,
|
|
92
|
+
useReady,
|
|
93
|
+
useResize,
|
|
94
|
+
useRouter,
|
|
95
|
+
useSaveExitState,
|
|
96
|
+
useShareAppMessage,
|
|
97
|
+
useShareTimeline,
|
|
98
|
+
useTabItemTap,
|
|
99
|
+
useTitleClick,
|
|
100
|
+
useScope,
|
|
101
|
+
useUnhandledRejection,
|
|
102
|
+
useUnload
|
|
103
|
+
} from '@tarojs/plugin-framework-react/dist/runtime'
|
|
104
|
+
${str}
|
|
105
|
+
|
|
106
|
+
taro.useAddToFavorites = useAddToFavorites
|
|
107
|
+
taro.useDidHide = useDidHide
|
|
108
|
+
taro.useDidShow = useDidShow
|
|
109
|
+
taro.useError = useError
|
|
110
|
+
taro.useLaunch = useLaunch
|
|
111
|
+
taro.useLoad = useLoad
|
|
112
|
+
taro.useOptionMenuClick = useOptionMenuClick
|
|
113
|
+
taro.usePageNotFound = usePageNotFound
|
|
114
|
+
taro.usePageScroll = usePageScroll
|
|
115
|
+
taro.usePullDownRefresh = usePullDownRefresh
|
|
116
|
+
taro.usePullIntercept = usePullIntercept
|
|
117
|
+
taro.useReachBottom = useReachBottom
|
|
118
|
+
taro.useReady = useReady
|
|
119
|
+
taro.useResize = useResize
|
|
120
|
+
taro.useRouter = useRouter
|
|
121
|
+
taro.useSaveExitState = useSaveExitState
|
|
122
|
+
taro.useShareAppMessage = useShareAppMessage
|
|
123
|
+
taro.useShareTimeline = useShareTimeline
|
|
124
|
+
taro.useTabItemTap = useTabItemTap
|
|
125
|
+
taro.useTitleClick = useTitleClick
|
|
126
|
+
taro.useScope = useScope
|
|
127
|
+
taro.useUnhandledRejection = useUnhandledRejection
|
|
128
|
+
taro.useUnload = useUnload
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
useAddToFavorites,
|
|
132
|
+
useDidHide,
|
|
133
|
+
useDidShow,
|
|
134
|
+
useError,
|
|
135
|
+
useLaunch,
|
|
136
|
+
useLoad,
|
|
137
|
+
useOptionMenuClick,
|
|
138
|
+
usePageNotFound,
|
|
139
|
+
usePageScroll,
|
|
140
|
+
usePullDownRefresh,
|
|
141
|
+
usePullIntercept,
|
|
142
|
+
useReachBottom,
|
|
143
|
+
useReady,
|
|
144
|
+
useResize,
|
|
145
|
+
useRouter,
|
|
146
|
+
useSaveExitState,
|
|
147
|
+
useShareAppMessage,
|
|
148
|
+
useShareTimeline,
|
|
149
|
+
useTabItemTap,
|
|
150
|
+
useTitleClick,
|
|
151
|
+
useScope,
|
|
152
|
+
useUnhandledRejection,
|
|
153
|
+
useUnload
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
71
156
|
}
|
|
72
157
|
|
|
73
158
|
const PLATFORM_NAME = 'harmony';
|
|
@@ -364,8 +449,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
364
449
|
? path__namespace.join(path__namespace.dirname(target), `${basename}${ext}`)
|
|
365
450
|
: path__namespace.join(target, `index${isDTS ? '.d.ts' : ext}`);
|
|
366
451
|
}
|
|
367
|
-
else
|
|
368
|
-
|
|
452
|
+
else {
|
|
453
|
+
const libPath = path__namespace.relative(targetPath, target);
|
|
454
|
+
if (libDir !== libPath) {
|
|
455
|
+
if (path__namespace.relative(libPath, libDir).startsWith('.')) {
|
|
456
|
+
target = path__namespace.join(targetPath, libDir);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
target = path__namespace.join(targetPath, libName, `index${ext}`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
369
462
|
}
|
|
370
463
|
}
|
|
371
464
|
}
|
|
@@ -380,6 +473,10 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
380
473
|
}
|
|
381
474
|
else if (stat.isFile()) {
|
|
382
475
|
let code = helper.fs.readFileSync(lib, { encoding: 'utf8' });
|
|
476
|
+
// TODO: 后续这部分代码应该根据使用的框架抽离到对应的平台插件处
|
|
477
|
+
if ([/taro-platform-harmony[\\/]dist[\\/]apis[\\/]index\.ts/].some(e => e.test(lib))) {
|
|
478
|
+
code = apiLoader(code);
|
|
479
|
+
}
|
|
383
480
|
if (this.extensions.includes(path__namespace.extname(lib))) {
|
|
384
481
|
code = code.replace(/(?:import\s|from\s|require\()['"]([^.][^'"\s]+)['"]\)?/g, (src, p1) => {
|
|
385
482
|
const { outputRoot } = this.ctx.runOpts.config;
|
|
@@ -552,7 +649,7 @@ function App(props) {
|
|
|
552
649
|
isFile: (file) => {
|
|
553
650
|
try {
|
|
554
651
|
const stat = helper.fs.lstatSync(file);
|
|
555
|
-
return stat.isFile() || (file.endsWith(mediaPath) && stat.isDirectory());
|
|
652
|
+
return stat.isFile() || (file.endsWith(mediaPath.replace('/', path__namespace.sep)) && stat.isDirectory());
|
|
556
653
|
}
|
|
557
654
|
catch (_) { } // eslint-disable-line no-empty
|
|
558
655
|
return false;
|