@tarojs/plugin-platform-harmony-ets 4.0.0-beta.10 → 4.0.0-beta.12
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/base/system.ts +40 -22
- package/dist/components-harmony-ets/button.ets +34 -31
- package/dist/components-harmony-ets/checkbox.ets +5 -4
- package/dist/components-harmony-ets/form.ets +31 -28
- package/dist/components-harmony-ets/icon.ets +22 -18
- package/dist/components-harmony-ets/image.ets +15 -11
- package/dist/components-harmony-ets/innerHtml.ets +9 -5
- package/dist/components-harmony-ets/input.ets +1 -1
- package/dist/components-harmony-ets/label.ets +44 -40
- package/dist/components-harmony-ets/movableArea.ets +67 -0
- package/dist/components-harmony-ets/movableView.ets +66 -0
- package/dist/components-harmony-ets/picker.ets +7 -6
- package/dist/components-harmony-ets/progress.ets +45 -0
- package/dist/components-harmony-ets/radio.ets +5 -5
- package/dist/components-harmony-ets/richText.ets +14 -9
- package/dist/components-harmony-ets/scrollView.ets +40 -35
- package/dist/components-harmony-ets/slider.ets +1 -1
- package/dist/components-harmony-ets/swiper.ets +23 -19
- package/dist/components-harmony-ets/switch.ets +1 -1
- package/dist/components-harmony-ets/text.ets +28 -22
- package/dist/components-harmony-ets/textArea.ets +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +2 -2
- package/dist/components-harmony-ets/video.ets +26 -21
- package/dist/components-harmony-ets/view.ets +34 -30
- package/dist/components-harmony-ets/webView.ets +37 -32
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/element/element.ts +0 -4
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +9 -1
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +12 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -2
- package/dist/runtime-ets/dom/element/progress.ts +13 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -0
- package/dist/runtime-ets/dom/element/video.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +8 -0
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/dist/runtime-utils.js +43 -21
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +43 -21
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
|
@@ -14,37 +14,42 @@ interface IError {
|
|
|
14
14
|
error: WebResourceError
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
@
|
|
18
|
-
export default
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
@Component
|
|
18
|
+
export default struct TaroWebView {
|
|
19
|
+
@ObjectLink node: TaroWebViewElement
|
|
20
|
+
|
|
21
|
+
build () {
|
|
22
|
+
Web({ src: this.node._attrs.src, controller: this.node.controller })
|
|
23
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
24
|
+
.onPageEnd((e: IPageLoad) => {
|
|
25
|
+
// 1. 创建消息端口
|
|
26
|
+
this.node.ports = this.node.controller.createWebMessagePorts(true)
|
|
27
|
+
// 2. 发送端口1到HTML5
|
|
28
|
+
this.node.controller.postMessage('init_web_messageport', [this.node.ports[1]], '*');
|
|
29
|
+
// 3. 保存端口0到本地
|
|
30
|
+
this.node.nativePort = this.node.ports[0]
|
|
31
|
+
// 4. 设置回调函数
|
|
32
|
+
this.node.nativePort.onMessageEventExt((result) => {
|
|
33
|
+
const message = this.node.handleMessageFromWeb(result)
|
|
34
|
+
const messageEvent: TaroEvent = createTaroEvent('message', { detail: { data: message } }, this.node)
|
|
35
|
+
|
|
36
|
+
eventHandler(messageEvent, 'message', this.node)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const onLoadEvent: TaroEvent = createTaroEvent('load', { detail: { src: this.node._attrs.src } }, this.node)
|
|
40
|
+
|
|
41
|
+
eventHandler(onLoadEvent, 'load', this.node)
|
|
34
42
|
})
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
node._nodeInfo.areaInfo = res[1]
|
|
48
|
-
}))
|
|
49
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
43
|
+
.onErrorReceive(shouldBindEvent((e: IError) => {
|
|
44
|
+
const event: TaroEvent = createTaroEvent('error', { detail: { url: this.node._attrs.src, fullUrl: e.request.getRequestUrl() } }, this.node)
|
|
45
|
+
|
|
46
|
+
eventHandler(event, 'error', this.node)
|
|
47
|
+
}, this.node, ['error']))
|
|
48
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
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
|
+
|
|
54
|
+
}
|
|
50
55
|
}
|
package/dist/index.js
CHANGED
|
@@ -158,7 +158,7 @@ export {
|
|
|
158
158
|
const PLATFORM_NAME = 'harmony';
|
|
159
159
|
const PACKAGE_NAME = '@tarojs/plugin-platform-harmony-ets';
|
|
160
160
|
const PLUGIN_NAME = 'TaroHarmony';
|
|
161
|
-
const HARMONY_SCOPES = [/^@system\./, /^@ohos\./, /^@hmscore\//];
|
|
161
|
+
const HARMONY_SCOPES = [/^@system\./, /^@ohos\./, /^@hmscore\//, /^@jd-oh\//];
|
|
162
162
|
|
|
163
163
|
function parseRelativePath(from, to) {
|
|
164
164
|
const relativePath = path.relative(from, to).replace(/\\/g, '/');
|
|
@@ -372,8 +372,8 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
372
372
|
return;
|
|
373
373
|
if (this.excludeLibraries.some(e => typeof e === 'string' ? e === lib : e.test(lib)))
|
|
374
374
|
return;
|
|
375
|
+
const { outputRoot, chorePackagePrefix } = this.ctx.runOpts.config;
|
|
375
376
|
if (sync) {
|
|
376
|
-
const { outputRoot } = this.ctx.runOpts.config;
|
|
377
377
|
const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES);
|
|
378
378
|
// FIXME 不支持 alias 配置
|
|
379
379
|
const libName = lib;
|
|
@@ -479,6 +479,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
479
479
|
code = apiLoader(code);
|
|
480
480
|
}
|
|
481
481
|
if (this.extensions.includes(path__namespace.extname(lib))) {
|
|
482
|
+
// Note: 查询 externals 内的依赖,并将它们添加到 externalDeps 中
|
|
482
483
|
code = code.replace(/(?:import\s|from\s|require\()['"]([^.][^'"\s]+)['"]\)?/g, (src, p1) => {
|
|
483
484
|
const { outputRoot } = this.ctx.runOpts.config;
|
|
484
485
|
const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES, p1);
|
|
@@ -502,8 +503,10 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
502
503
|
code = '// @ts-nocheck\n' + code;
|
|
503
504
|
}
|
|
504
505
|
}
|
|
505
|
-
|
|
506
|
-
|
|
506
|
+
// Note: 传入 chorePackagePrefix 时,不生成核心依赖库
|
|
507
|
+
if (!chorePackagePrefix) {
|
|
508
|
+
if (/tarojs[\\/]taro[\\/]types[\\/]index.d.ts/.test(target)) {
|
|
509
|
+
code = `/// <reference path="global.d.ts" />
|
|
507
510
|
|
|
508
511
|
/// <reference path="taro.api.d.ts" />
|
|
509
512
|
/// <reference path="taro.component.d.ts" />
|
|
@@ -523,14 +526,15 @@ declare global {
|
|
|
523
526
|
const defineAppConfig: (config: Taro.Config) => Taro.Config
|
|
524
527
|
const definePageConfig: (config: Taro.Config) => Taro.Config
|
|
525
528
|
}`;
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
529
|
+
}
|
|
530
|
+
try {
|
|
531
|
+
const targetPath = target.replace(new RegExp(`\\b${helper.NODE_MODULES}\\b`), 'npm');
|
|
532
|
+
helper.fs.ensureDirSync(path__namespace.dirname(targetPath));
|
|
533
|
+
helper.fs.writeFileSync(targetPath, code);
|
|
534
|
+
}
|
|
535
|
+
catch (e) {
|
|
536
|
+
console.error(`[taro-arkts] inject ${lib} to ${target} failed`, e);
|
|
537
|
+
}
|
|
534
538
|
}
|
|
535
539
|
}
|
|
536
540
|
else if (stat.isSymbolicLink()) {
|
|
@@ -552,7 +556,7 @@ declare global {
|
|
|
552
556
|
const that = this;
|
|
553
557
|
const { appPath } = that.ctx.paths;
|
|
554
558
|
const { config } = that.ctx.runOpts;
|
|
555
|
-
const { outputRoot } = config;
|
|
559
|
+
const { outputRoot, ohPackage = {}, chorePackagePrefix } = config;
|
|
556
560
|
if (!that.framework.includes('vue')) {
|
|
557
561
|
that.excludeLibraries.push(/\bvue\b/);
|
|
558
562
|
}
|
|
@@ -568,7 +572,22 @@ declare global {
|
|
|
568
572
|
/^solid-js\/universal$/,
|
|
569
573
|
]);
|
|
570
574
|
}
|
|
575
|
+
const externals = Object.keys(ohPackage.dependencies || []).concat(Object.keys(ohPackage.devDependencies || []));
|
|
571
576
|
function modifyResolveId({ source = '', importer = '', options = {}, name = 'modifyResolveId', resolve }) {
|
|
577
|
+
if (externals.includes(source)) {
|
|
578
|
+
return {
|
|
579
|
+
external: true,
|
|
580
|
+
id: source,
|
|
581
|
+
resolvedBy: name,
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
if (chorePackagePrefix && that.indexOfLibraries(source) > -1) {
|
|
585
|
+
return {
|
|
586
|
+
external: true,
|
|
587
|
+
id: path__namespace.join(chorePackagePrefix, source),
|
|
588
|
+
resolvedBy: name,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
572
591
|
if (shared.isFunction(resolve)) {
|
|
573
592
|
if (source === that.runtimePath || that.runtimePath.includes(source)) {
|
|
574
593
|
return resolve('@tarojs/runtime', importer, options);
|
|
@@ -1151,7 +1170,7 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1151
1170
|
const outDir = path.join(compsOutDir, name);
|
|
1152
1171
|
helper.fs.copy(src, outDir);
|
|
1153
1172
|
});
|
|
1154
|
-
this.
|
|
1173
|
+
this.modifyHostPackage(config.harmony);
|
|
1155
1174
|
});
|
|
1156
1175
|
}
|
|
1157
1176
|
modifyWebpackConfig() {
|
|
@@ -1214,13 +1233,13 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1214
1233
|
console.warn(helper.chalk.red('设置鸿蒙 Hap 配置失败:', err));
|
|
1215
1234
|
});
|
|
1216
1235
|
}
|
|
1217
|
-
|
|
1236
|
+
modifyHostPackage({ projectPath, hapName = 'entry' }) {
|
|
1218
1237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1238
|
+
const packageJsonFile = path.join(projectPath, hapName, 'package.json');
|
|
1219
1239
|
const hmsDeps = {
|
|
1220
1240
|
'@hmscore/hms-js-base': '^6.1.0-300',
|
|
1221
1241
|
'@hmscore/hms-jsb-account': '^1.0.300'
|
|
1222
1242
|
};
|
|
1223
|
-
const packageJsonFile = path.resolve(dest, '../../../../../package.json');
|
|
1224
1243
|
const isExists = yield helper.fs.pathExists(packageJsonFile);
|
|
1225
1244
|
if (!isExists)
|
|
1226
1245
|
return;
|
|
@@ -1237,6 +1256,7 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1237
1256
|
}
|
|
1238
1257
|
packageJson = JSON.stringify(packageJson);
|
|
1239
1258
|
yield helper.fs.writeFile(packageJsonFile, packageJson);
|
|
1259
|
+
return packageJson;
|
|
1240
1260
|
});
|
|
1241
1261
|
}
|
|
1242
1262
|
getChunkEntryModule(compilation, chunk, compiler = 'webpack4') {
|