@tarojs/plugin-platform-harmony-ets 4.0.0-beta.2 → 4.0.0-beta.21
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 +53 -20
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +3 -1
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +124 -60
- package/dist/apis/wxml/IntersectionObserver.ts +5 -3
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +41 -78
- package/dist/components-harmony-ets/checkbox.ets +19 -209
- package/dist/components-harmony-ets/form.ets +38 -160
- package/dist/components-harmony-ets/icon.ets +31 -83
- package/dist/components-harmony-ets/image.ets +22 -78
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +10 -67
- package/dist/components-harmony-ets/label.ets +52 -173
- package/dist/components-harmony-ets/movableArea.ets +89 -0
- package/dist/components-harmony-ets/movableView.ets +67 -0
- package/dist/components-harmony-ets/picker.ets +32 -147
- package/dist/components-harmony-ets/progress.ets +47 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +19 -210
- package/dist/components-harmony-ets/richText.ets +22 -102
- package/dist/components-harmony-ets/scrollView.ets +66 -169
- package/dist/components-harmony-ets/slider.ets +10 -72
- package/dist/components-harmony-ets/style.ets +244 -0
- package/dist/components-harmony-ets/swiper.ets +30 -87
- package/dist/components-harmony-ets/switch.ets +9 -71
- package/dist/components-harmony-ets/text.ets +38 -89
- package/dist/components-harmony-ets/textArea.ets +10 -67
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +8 -7
- package/dist/components-harmony-ets/utils/helper.ets +5 -4
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/index.ts +55 -2
- package/dist/components-harmony-ets/utils/styles.ets +45 -85
- package/dist/components-harmony-ets/video.ets +33 -88
- package/dist/components-harmony-ets/view.ets +47 -160
- package/dist/components-harmony-ets/webView.ets +44 -99
- package/dist/index.d.ts +151 -0
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +4 -2
- package/dist/runtime-ets/current.ts +2 -0
- package/dist/runtime-ets/dom/bind.ts +0 -1
- package/dist/runtime-ets/dom/cssNesting.ts +311 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
- package/dist/runtime-ets/dom/document.ts +21 -8
- package/dist/runtime-ets/dom/element/element.ts +53 -9
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +12 -1
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -3
- 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/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +184 -207
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
- package/dist/runtime-ets/dom/stylesheet/util.ts +19 -15
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +24 -9
- package/dist/runtime-framework/react/app.ts +5 -1
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/native-page.ts +14 -9
- package/dist/runtime-framework/react/page.ts +1 -0
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- 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-utils.js +185 -91
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +185 -91
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +10 -10
- package/types/index.d.ts +4 -0
- package/dist/runtime-ets/utils/bind.ts +0 -24
package/dist/index.js
CHANGED
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var helper = require('@tarojs/helper');
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var runnerUtils = require('@tarojs/runner-utils');
|
|
8
|
-
var shared = require('@tarojs/shared');
|
|
9
8
|
var service = require('@tarojs/service');
|
|
10
9
|
var _package = require('@tarojs/service/dist/utils/package');
|
|
10
|
+
var shared = require('@tarojs/shared');
|
|
11
11
|
var webpackSources = require('webpack-sources');
|
|
12
12
|
var template = require('@tarojs/shared/dist/template');
|
|
13
13
|
|
|
@@ -244,10 +244,11 @@ class TaroPlatformHarmony extends service.TaroPlatform {
|
|
|
244
244
|
FRAMEWORK: JSON.stringify(this.config.framework),
|
|
245
245
|
TARO_ENV: JSON.stringify(this.platform),
|
|
246
246
|
TARO_PLATFORM: JSON.stringify(this.platformType),
|
|
247
|
-
TARO_VERSION: JSON.stringify(_package.getPkgVersion())
|
|
247
|
+
TARO_VERSION: JSON.stringify(_package.getPkgVersion()),
|
|
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, useNesting: config.useNesting, useJSON5: this.useJSON5 }), extraOptions);
|
|
251
252
|
}
|
|
252
253
|
/**
|
|
253
254
|
* 调用 runner 开始编译
|
|
@@ -316,14 +317,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
316
317
|
['react', /^react$|react[\\/]cjs/],
|
|
317
318
|
['react/jsx-runtime', /^react[\\/]jsx-runtime$/], // Note: React 环境下自动注入,避免重复
|
|
318
319
|
];
|
|
320
|
+
this.harmonyScope = [...HARMONY_SCOPES];
|
|
321
|
+
const that = this;
|
|
319
322
|
this.setupTransaction.addWrapper({
|
|
320
323
|
close() {
|
|
321
|
-
|
|
324
|
+
that.modifyViteConfig();
|
|
322
325
|
},
|
|
323
326
|
});
|
|
324
327
|
ctx.onBuildFinish(() => {
|
|
325
328
|
const outDir = path__namespace.resolve(process.cwd(), config.outputRoot);
|
|
326
|
-
|
|
329
|
+
that.handleResourceEmit(outDir);
|
|
327
330
|
});
|
|
328
331
|
}
|
|
329
332
|
get framework() {
|
|
@@ -335,6 +338,11 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
335
338
|
get apiLibrary() {
|
|
336
339
|
return path__namespace.resolve(__dirname, './apis');
|
|
337
340
|
}
|
|
341
|
+
get apiEntry() {
|
|
342
|
+
return [
|
|
343
|
+
/(@tarojs[\\/]plugin-platform-harmony-ets|taro-platform-harmony)[\\/]dist[\\/]apis[\\/]index\.ts/,
|
|
344
|
+
];
|
|
345
|
+
}
|
|
338
346
|
get componentLibrary() {
|
|
339
347
|
return path__namespace.resolve(__dirname, './components-harmony-ets');
|
|
340
348
|
}
|
|
@@ -371,8 +379,8 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
371
379
|
return;
|
|
372
380
|
if (this.excludeLibraries.some(e => typeof e === 'string' ? e === lib : e.test(lib)))
|
|
373
381
|
return;
|
|
382
|
+
const { outputRoot, chorePackagePrefix } = this.ctx.runOpts.config;
|
|
374
383
|
if (sync) {
|
|
375
|
-
const { outputRoot } = this.ctx.runOpts.config;
|
|
376
384
|
const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES);
|
|
377
385
|
// FIXME 不支持 alias 配置
|
|
378
386
|
const libName = lib;
|
|
@@ -423,6 +431,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
423
431
|
if ((/(?:import\s|from\s|require\()['"]([\\/.][^'"\s]+)['"]\)?/g.test(code)
|
|
424
432
|
|| /\/{3}\s<reference\spath=['"][^'"\s]+['"]\s\/>/g.test(code))
|
|
425
433
|
&& `${libName}${path__namespace.extname(libDir)}` !== libDir) {
|
|
434
|
+
// Note: 文件包含包内引用的依赖
|
|
426
435
|
const pkgPath = path__namespace.relative(libName, libDir);
|
|
427
436
|
if (new RegExp(`^index(${this.extensions.map(e => e.replace('.', '\\.')).join('|')})$`).test(pkgPath)) {
|
|
428
437
|
// Note: 入口为 index 场景
|
|
@@ -473,16 +482,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
473
482
|
}
|
|
474
483
|
else if (stat.isFile()) {
|
|
475
484
|
let code = helper.fs.readFileSync(lib, { encoding: 'utf8' });
|
|
476
|
-
|
|
477
|
-
if ([/taro-platform-harmony[\\/]dist[\\/]apis[\\/]index\.ts/].some(e => e.test(lib))) {
|
|
485
|
+
if (this.apiEntry.some(e => e.test(lib))) {
|
|
478
486
|
code = apiLoader(code);
|
|
479
487
|
}
|
|
480
488
|
if (this.extensions.includes(path__namespace.extname(lib))) {
|
|
481
|
-
|
|
489
|
+
// Note: 查询 externals 内的依赖,并将它们添加到 externalDeps 中
|
|
490
|
+
code = code.replace(/(?:import\s|from\s|require\()['"]([^\\/.][^'"\s]+)['"]\)?/g, (src, p1) => {
|
|
482
491
|
const { outputRoot } = this.ctx.runOpts.config;
|
|
483
492
|
const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES, p1);
|
|
484
493
|
const relativePath = parseRelativePath(path__namespace.dirname(target), targetPath);
|
|
485
|
-
if (
|
|
494
|
+
if (this.harmonyScope.every(e => !e.test(p1))) {
|
|
486
495
|
if (this.indexOfLibraries(p1) === -1 && !/\.(d\.ts|flow\.js)$/.test(lib)) {
|
|
487
496
|
this.externalDeps.push([p1, new RegExp(`^${p1.replace(/([-\\/$])/g, '\\$1')}$`)]);
|
|
488
497
|
this.moveLibraries(p1, targetPath, path__namespace.dirname(lib), true);
|
|
@@ -500,9 +509,16 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
|
|
|
500
509
|
if (['.ts'].includes(ext)) {
|
|
501
510
|
code = '// @ts-nocheck\n' + code;
|
|
502
511
|
}
|
|
512
|
+
// 处理嵌套样式的编译,需要针对ReactElement进行props操作,dev模式下会Object.freeze,所以需要在开发模式下注入Object.freeze来覆盖解锁
|
|
513
|
+
// 处理的方法再taro-platform-harmony/src/runtime-ets/dom/cssNesting: ele.props.style = declaration
|
|
514
|
+
if (/react\/jsx-runtime/.test(lib) && process.env.NODE_ENV === 'development') {
|
|
515
|
+
code = 'Object.freeze = (obj) => obj \n' + code;
|
|
516
|
+
}
|
|
503
517
|
}
|
|
504
|
-
|
|
505
|
-
|
|
518
|
+
// Note: 传入 chorePackagePrefix 时,不生成核心依赖库
|
|
519
|
+
if (!chorePackagePrefix) {
|
|
520
|
+
if (/tarojs[\\/]taro[\\/]types[\\/]index.d.ts/.test(target)) {
|
|
521
|
+
code = `/// <reference path="global.d.ts" />
|
|
506
522
|
|
|
507
523
|
/// <reference path="taro.api.d.ts" />
|
|
508
524
|
/// <reference path="taro.component.d.ts" />
|
|
@@ -522,14 +538,15 @@ declare global {
|
|
|
522
538
|
const defineAppConfig: (config: Taro.Config) => Taro.Config
|
|
523
539
|
const definePageConfig: (config: Taro.Config) => Taro.Config
|
|
524
540
|
}`;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
const targetPath = target.replace(new RegExp(`\\b${helper.NODE_MODULES}\\b`), 'npm');
|
|
544
|
+
helper.fs.ensureDirSync(path__namespace.dirname(targetPath));
|
|
545
|
+
helper.fs.writeFileSync(targetPath, code);
|
|
546
|
+
}
|
|
547
|
+
catch (e) {
|
|
548
|
+
console.error(`[taro-arkts] inject ${lib} to ${target} failed`, e);
|
|
549
|
+
}
|
|
533
550
|
}
|
|
534
551
|
}
|
|
535
552
|
else if (stat.isSymbolicLink()) {
|
|
@@ -551,7 +568,7 @@ declare global {
|
|
|
551
568
|
const that = this;
|
|
552
569
|
const { appPath } = that.ctx.paths;
|
|
553
570
|
const { config } = that.ctx.runOpts;
|
|
554
|
-
const { outputRoot } = config;
|
|
571
|
+
const { outputRoot, ohPackage = {}, chorePackagePrefix } = config;
|
|
555
572
|
if (!that.framework.includes('vue')) {
|
|
556
573
|
that.excludeLibraries.push(/\bvue\b/);
|
|
557
574
|
}
|
|
@@ -567,11 +584,21 @@ declare global {
|
|
|
567
584
|
/^solid-js\/universal$/,
|
|
568
585
|
]);
|
|
569
586
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
587
|
+
const externals = Object.keys(ohPackage.dependencies || []).concat(Object.keys(ohPackage.devDependencies || []));
|
|
588
|
+
function modifyResolveId({ source = '', name = 'modifyResolveId' }) {
|
|
589
|
+
if (externals.includes(source)) {
|
|
590
|
+
return {
|
|
591
|
+
external: true,
|
|
592
|
+
id: source,
|
|
593
|
+
resolvedBy: name,
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (chorePackagePrefix && that.indexOfLibraries(source) > -1) {
|
|
597
|
+
return {
|
|
598
|
+
external: true,
|
|
599
|
+
id: path__namespace.join(chorePackagePrefix, source),
|
|
600
|
+
resolvedBy: name,
|
|
601
|
+
};
|
|
575
602
|
}
|
|
576
603
|
// Note: 映射 Taro 相关依赖到注入 taro 目录
|
|
577
604
|
if (that.indexOfLibraries(source) > -1) {
|
|
@@ -1150,7 +1177,7 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1150
1177
|
const outDir = path.join(compsOutDir, name);
|
|
1151
1178
|
helper.fs.copy(src, outDir);
|
|
1152
1179
|
});
|
|
1153
|
-
this.
|
|
1180
|
+
this.modifyHostPackage(config.harmony);
|
|
1154
1181
|
});
|
|
1155
1182
|
}
|
|
1156
1183
|
modifyWebpackConfig() {
|
|
@@ -1213,13 +1240,13 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1213
1240
|
console.warn(helper.chalk.red('设置鸿蒙 Hap 配置失败:', err));
|
|
1214
1241
|
});
|
|
1215
1242
|
}
|
|
1216
|
-
|
|
1243
|
+
modifyHostPackage({ projectPath, hapName = 'entry' }) {
|
|
1217
1244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1245
|
+
const packageJsonFile = path.join(projectPath, hapName, 'package.json');
|
|
1218
1246
|
const hmsDeps = {
|
|
1219
1247
|
'@hmscore/hms-js-base': '^6.1.0-300',
|
|
1220
1248
|
'@hmscore/hms-jsb-account': '^1.0.300'
|
|
1221
1249
|
};
|
|
1222
|
-
const packageJsonFile = path.resolve(dest, '../../../../../package.json');
|
|
1223
1250
|
const isExists = yield helper.fs.pathExists(packageJsonFile);
|
|
1224
1251
|
if (!isExists)
|
|
1225
1252
|
return;
|
|
@@ -1236,6 +1263,7 @@ class Harmony extends service.TaroPlatformBase {
|
|
|
1236
1263
|
}
|
|
1237
1264
|
packageJson = JSON.stringify(packageJson);
|
|
1238
1265
|
yield helper.fs.writeFile(packageJsonFile, packageJson);
|
|
1266
|
+
return packageJson;
|
|
1239
1267
|
});
|
|
1240
1268
|
}
|
|
1241
1269
|
getChunkEntryModule(compilation, chunk, compiler = 'webpack4') {
|
|
@@ -1304,6 +1332,7 @@ function assertHarmonyConfig(ctx, config) {
|
|
|
1304
1332
|
}
|
|
1305
1333
|
}
|
|
1306
1334
|
|
|
1335
|
+
exports.HarmonyOS_ArkTS = Harmony$1;
|
|
1307
1336
|
exports.HarmonyOS_JSUI = Harmony;
|
|
1308
1337
|
exports.default = index;
|
|
1309
1338
|
//# sourceMappingURL=index.js.map
|