@dcloudio/uni-cli-shared 3.0.0-alpha-5010120260525001 → 3.0.0-alpha-5010220260604001

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/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export * from './platform';
26
26
  export * from './utsUtils';
27
27
  export * from './workers';
28
28
  export { parseUniExtApi, parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, formatExtApiProviderName, } from './uni_modules';
29
- export { getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
29
+ export { copyEncryptUniModulesDom2Bytes, getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
30
30
  import type { EncryptPackageJson } from './uni_modules.cloud';
31
31
  export type EncryptArtifacts = EncryptPackageJson['uni_modules']['artifacts'];
32
32
  export { M } from './messages';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
17
+ exports.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.copyEncryptUniModulesDom2Bytes = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
18
18
  __exportStar(require("./fs"), exports);
19
19
  __exportStar(require("./mp"), exports);
20
20
  __exportStar(require("./url"), exports);
@@ -49,6 +49,7 @@ Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function
49
49
  Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
50
50
  Object.defineProperty(exports, "formatExtApiProviderName", { enumerable: true, get: function () { return uni_modules_1.formatExtApiProviderName; } });
51
51
  var uni_modules_cloud_1 = require("./uni_modules.cloud");
52
+ Object.defineProperty(exports, "copyEncryptUniModulesDom2Bytes", { enumerable: true, get: function () { return uni_modules_cloud_1.copyEncryptUniModulesDom2Bytes; } });
52
53
  Object.defineProperty(exports, "getUniModulesEncryptType", { enumerable: true, get: function () { return uni_modules_cloud_1.getUniModulesEncryptType; } });
53
54
  Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_cloud_1.parseUniModulesArtifacts; } });
54
55
  Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_cloud_1.resolveEncryptUniModule; } });
@@ -49,6 +49,7 @@ export interface EncryptPackageJson {
49
49
  export declare function initCheckEnv(): Record<string, unknown>;
50
50
  export declare function resolveEncryptUniModule(id: string, platform: typeof process.env.UNI_UTS_PLATFORM, isX?: boolean): string | undefined;
51
51
  type CloudCompileSdkType = 'utssdk' | 'easycom' | 'all';
52
+ type VaporRenderTarget = 'bytecode' | 'nativecode';
52
53
  export interface CloudCompileParams {
53
54
  mode: 'development' | 'production';
54
55
  packType: 'debug' | 'release';
@@ -57,6 +58,8 @@ export interface CloudCompileParams {
57
58
  appname: string;
58
59
  platform: typeof process.env.UNI_UTS_PLATFORM;
59
60
  'uni-app-x': boolean;
61
+ vapor: boolean;
62
+ vaporRenderTarget?: VaporRenderTarget;
60
63
  env: Record<string, string>;
61
64
  }
62
65
  export declare function checkEncryptUniModules(inputDir: string, params: CloudCompileParams, sdkType?: CloudCompileSdkType): Promise<{} | undefined>;
@@ -67,5 +70,6 @@ export declare function parseUniModulesArtifacts(): {
67
70
  scopedSlots: string[];
68
71
  declaration: string;
69
72
  }[];
73
+ export declare function copyEncryptUniModulesDom2Bytes(): boolean | Promise<boolean>;
70
74
  export declare function virtualComponentPath(filepath: string): string;
71
75
  export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.virtualComponentPath = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.packUploadEncryptUniModules = exports.findUploadEncryptUniModulesFiles = exports.findCloudEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.genEncryptUTSModuleCode = exports.genEncryptEasyComModuleCode = void 0;
6
+ exports.virtualComponentPath = exports.copyEncryptUniModulesDom2Bytes = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.packUploadEncryptUniModules = exports.findUploadEncryptUniModulesFiles = exports.findCloudEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.genEncryptUTSModuleCode = exports.genEncryptEasyComModuleCode = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const fast_glob_1 = require("fast-glob");
@@ -429,6 +429,7 @@ async function checkEncryptUniModules(inputDir, params, sdkType = 'all') {
429
429
  const AdmZip = require('adm-zip');
430
430
  const zip = new AdmZip(downloadFile);
431
431
  zip.extractAllTo(cacheDir, true);
432
+ await Promise.resolve(copyEncryptUniModulesDom2Bytes());
432
433
  fs_extra_1.default.unlinkSync(zipFile);
433
434
  fs_extra_1.default.unlinkSync(downloadFile);
434
435
  R({
@@ -446,6 +447,7 @@ async function checkEncryptUniModules(inputDir, params, sdkType = 'all') {
446
447
  }
447
448
  }
448
449
  else {
450
+ await Promise.resolve(copyEncryptUniModulesDom2Bytes());
449
451
  const useUniAppXAndroidNative = (0, x_1.isUniAppXAndroidNative)(params.platform);
450
452
  // 仅旧版 Android x 需要在缓存命中时额外初始化
451
453
  if (useUniAppXAndroidNative) {
@@ -480,6 +482,83 @@ function parseUniModulesArtifacts() {
480
482
  return res;
481
483
  }
482
484
  exports.parseUniModulesArtifacts = parseUniModulesArtifacts;
485
+ function copyEncryptUniModulesDom2Bytes() {
486
+ if (process.env.UNI_APP_X_DOM2 !== 'true') {
487
+ return false;
488
+ }
489
+ if (!['app-android', 'app-ios', 'app-harmony'].includes(process.env.UNI_UTS_PLATFORM)) {
490
+ return false;
491
+ }
492
+ const cacheDir = process.env.UNI_MODULES_ENCRYPT_CACHE_DIR;
493
+ const outputDir = process.env.UNI_OUTPUT_DIR;
494
+ if (!cacheDir || !outputDir) {
495
+ return false;
496
+ }
497
+ if (process.env.UNI_APP_X_VAPOR_RENDER_TARGET === 'bytecode') {
498
+ return copyEncryptUniModulesDom2BytesTarget(cacheDir, outputDir);
499
+ }
500
+ if (process.env.UNI_APP_X_VAPOR_RENDER_TARGET === 'nativecode') {
501
+ return copyEncryptUniModulesDom2CppTarget(cacheDir, outputDir);
502
+ }
503
+ return false;
504
+ }
505
+ exports.copyEncryptUniModulesDom2Bytes = copyEncryptUniModulesDom2Bytes;
506
+ function copyEncryptUniModulesDom2BytesTarget(cacheDir, outputDir) {
507
+ // 只依赖编译环境变量定位缓存目录和输出目录,避免拼接具体 unpackage/dist 路径。
508
+ const sourceBytesDir = path_1.default.resolve(cacheDir, 'bytes');
509
+ if (!fs_extra_1.default.existsSync(sourceBytesDir) ||
510
+ !fs_extra_1.default.statSync(sourceBytesDir).isDirectory()) {
511
+ return false;
512
+ }
513
+ const outputBytesDir = path_1.default.resolve(outputDir, 'bytes');
514
+ // 云编译产出的 bytecode 在缓存目录中,这里只合并复制到当前编译输出目录。
515
+ fs_extra_1.default.copySync(sourceBytesDir, outputBytesDir, { overwrite: true });
516
+ return true;
517
+ }
518
+ async function copyEncryptUniModulesDom2CppTarget(cacheDir, outputDir) {
519
+ const sourceCppDir = path_1.default.resolve(cacheDir, 'cpp');
520
+ if (!fs_extra_1.default.existsSync(sourceCppDir) ||
521
+ !fs_extra_1.default.statSync(sourceCppDir).isDirectory()) {
522
+ return false;
523
+ }
524
+ const outputCppDir = process.env.UNI_APP_X_DOM2_CPP_DIR || path_1.default.resolve(outputDir, 'cpp');
525
+ // nativecode 的 cpp/h 暂时不走 DUM 解密,直接复制云端产物。
526
+ // const cppFiles = sync('**/*.{cpp,h}', {
527
+ // absolute: false,
528
+ // cwd: sourceCppDir,
529
+ // onlyFiles: true,
530
+ // }).filter((file) => !isIgnoreDom2CppFile(file))
531
+ // if (cppFiles.length) {
532
+ // const files = cppFiles.reduce((files, file) => {
533
+ // files[path.resolve(sourceCppDir, file)] = path.resolve(outputCppDir, file)
534
+ // return files
535
+ // }, {} as Record<string, string>)
536
+ // const { DUM } = requireUniHelpers()
537
+ // const errMsg = await DUM(path.basename(sourceCppDir), files)
538
+ // if (errMsg) {
539
+ // console.error(errMsg)
540
+ // process.exit(0)
541
+ // }
542
+ // }
543
+ // cpp 目录保持原目录结构直接复制,shared_data_init.h 由当前编译流程生成,不复制云端缓存版本。
544
+ fs_extra_1.default.copySync(sourceCppDir, outputCppDir, {
545
+ filter(src) {
546
+ if (fs_extra_1.default.statSync(src).isDirectory()) {
547
+ return true;
548
+ }
549
+ // shared_data_init.h 由当前编译生成,不能复制云端缓存里的旧文件覆盖本地结果。
550
+ if (isIgnoreDom2CppFile(src)) {
551
+ return false;
552
+ }
553
+ return true;
554
+ },
555
+ overwrite: true,
556
+ });
557
+ return true;
558
+ }
559
+ function isIgnoreDom2CppFile(filename) {
560
+ return path_1.default.basename(filename) === 'shared_data_init.h';
561
+ }
483
562
  const uniComponentPrefix = 'uniComponent://';
484
563
  function virtualComponentPath(filepath) {
485
564
  return uniComponentPrefix + (0, url_1.encodeBase64Url)(filepath);
@@ -623,8 +623,13 @@ function uniDecryptUniModulesPlugin() {
623
623
  appname: manifest.name,
624
624
  platform: process.env.UNI_UTS_PLATFORM,
625
625
  'uni-app-x': isX,
626
+ vapor: process.env.UNI_APP_X_DOM2 === 'true',
626
627
  env,
627
628
  };
629
+ if (options.vapor) {
630
+ options.vaporRenderTarget =
631
+ process.env.UNI_APP_X_VAPOR_RENDER_TARGET || 'bytecode';
632
+ }
628
633
  // 鸿蒙平台需要拆分两次云编译
629
634
  if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
630
635
  const harmonyEnv = {
@@ -27415,7 +27415,8 @@ const transformVBind = (dir, node, context) => {
27415
27415
  exp = createSimpleExpression("", true, loc);
27416
27416
  }
27417
27417
  const isComponent = node.tagType === 1;
27418
- exp = resolveExpression(exp, isComponent);
27418
+ const isDom2DataAttr = context.options.platform && arg.isStatic && arg.content.length > 5 && arg.content.startsWith("data-");
27419
+ exp = resolveExpression(exp, isComponent || isDom2DataAttr);
27419
27420
  arg = resolveExpression(arg);
27420
27421
  if (arg.isStatic && isReservedProp(arg.content)) return;
27421
27422
  let camel = false;
@@ -27593,7 +27594,8 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
27593
27594
  node,
27594
27595
  element: context.reference(),
27595
27596
  props: dynamicArgs,
27596
- tag
27597
+ tag,
27598
+ root: singleRoot && context.effectiveParent === context.root && context.options.componentType === "component"
27597
27599
  }, getEffectIndex);
27598
27600
  } else {
27599
27601
  const changeProps = [];
@@ -27621,6 +27623,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
27621
27623
  }
27622
27624
  let hasStaticStyle = false;
27623
27625
  let hasClass = false;
27626
+ const datasetProps = [];
27624
27627
  let prevWasQuoted = false;
27625
27628
  for (const prop of propsResult[1]) {
27626
27629
  const { key, values } = prop;
@@ -27679,6 +27682,17 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
27679
27682
  }
27680
27683
  }
27681
27684
  if (hasStaticStyle && hasClass) template += ` ext:style`;
27685
+ if (datasetProps.length) {
27686
+ const expressions = datasetProps.flatMap((prop) => prop.values);
27687
+ context.registerEffect(expressions, {
27688
+ type: 3,
27689
+ node,
27690
+ element: context.reference(),
27691
+ prop: _objectSpread2(_objectSpread2({}, datasetProps[0]), {}, { datasetProps }),
27692
+ tag,
27693
+ root: singleRoot && context.effectiveParent === context.root && context.options.componentType === "component"
27694
+ }, getEffectIndex);
27695
+ }
27682
27696
  }
27683
27697
  template += `>` + context.childrenTemplate.join("");
27684
27698
  if (!isVoidTag(tag) && !omitEndTag) template += `</${tag}>`;
@@ -2530,7 +2530,8 @@ const transformVBind = (dir, node, context) => {
2530
2530
  exp = (0, _vue_compiler_dom.createSimpleExpression)("", true, loc);
2531
2531
  }
2532
2532
  const isComponent = node.tagType === 1;
2533
- exp = resolveExpression(exp, isComponent);
2533
+ const isDom2DataAttr = context.options.platform && arg.isStatic && arg.content.length > 5 && arg.content.startsWith("data-");
2534
+ exp = resolveExpression(exp, isComponent || isDom2DataAttr);
2534
2535
  arg = resolveExpression(arg);
2535
2536
  if (arg.isStatic && isReservedProp(arg.content)) return;
2536
2537
  let camel = false;
@@ -2707,7 +2708,8 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
2707
2708
  node,
2708
2709
  element: context.reference(),
2709
2710
  props: dynamicArgs,
2710
- tag
2711
+ tag,
2712
+ root: singleRoot && context.effectiveParent === context.root && context.options.componentType === "component"
2711
2713
  }, getEffectIndex);
2712
2714
  } else {
2713
2715
  const changeProps = [];
@@ -2735,6 +2737,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
2735
2737
  }
2736
2738
  let hasStaticStyle = false;
2737
2739
  let hasClass = false;
2740
+ const datasetProps = [];
2738
2741
  let prevWasQuoted = false;
2739
2742
  for (const prop of propsResult[1]) {
2740
2743
  const { key, values } = prop;
@@ -2793,6 +2796,20 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
2793
2796
  }
2794
2797
  }
2795
2798
  if (hasStaticStyle && hasClass) template += ` ext:style`;
2799
+ if (datasetProps.length) {
2800
+ const expressions = datasetProps.flatMap((prop) => prop.values);
2801
+ context.registerEffect(expressions, {
2802
+ type: 3,
2803
+ node,
2804
+ element: context.reference(),
2805
+ prop: {
2806
+ ...datasetProps[0],
2807
+ datasetProps
2808
+ },
2809
+ tag,
2810
+ root: singleRoot && context.effectiveParent === context.root && context.options.componentType === "component"
2811
+ }, getEffectIndex);
2812
+ }
2796
2813
  }
2797
2814
  template += `>` + context.childrenTemplate.join("");
2798
2815
  if (!(0, _vue_shared.isVoidTag)(tag) && !omitEndTag) template += `</${tag}>`;
@@ -22385,6 +22385,10 @@ export interface IRProp extends Omit<DirectiveTransformResult, "value"> {
22385
22385
  ident?: string;
22386
22386
  classRef?: string;
22387
22387
  };
22388
+ /**
22389
+ * fixed by uts synthetic data-* group for dom2 dataset callbacks.
22390
+ */
22391
+ datasetProps?: IRProp[];
22388
22392
  }
22389
22393
  export declare enum IRDynamicPropsKind {
22390
22394
  EXPRESSION = 0,
@@ -22556,6 +22560,10 @@ export interface SetPropIRNode extends BaseIRNode {
22556
22560
  element: number;
22557
22561
  prop: IRProp;
22558
22562
  tag: string;
22563
+ /**
22564
+ * fixed by uts 当前操作的目标元素是否为组件模板单根根节点,可用于后续 root-only 逻辑。
22565
+ */
22566
+ root?: boolean;
22559
22567
  isChangeProp?: boolean;
22560
22568
  }
22561
22569
  export interface SetDynamicPropsIRNode extends BaseIRNode {
@@ -22564,6 +22572,10 @@ export interface SetDynamicPropsIRNode extends BaseIRNode {
22564
22572
  props: IRProps[];
22565
22573
  tag: string;
22566
22574
  /**
22575
+ * fixed by uts 当前操作的目标元素是否为组件模板单根根节点,可用于后续 root-only 逻辑。
22576
+ */
22577
+ root?: boolean;
22578
+ /**
22567
22579
  * fixed by uts 当前整个动态绑定表达式对应的标识符,因为动态绑定需要在sharedData层对数据做格式化,不能单个生成标识符,不然需要在c层再格式化一次
22568
22580
  */
22569
22581
  sharedData?: SimpleExpressionNode["sharedData"];
@@ -21425,7 +21425,8 @@ const transformVBind = (dir, node, context) => {
21425
21425
  exp = createSimpleExpression("", true, loc);
21426
21426
  }
21427
21427
  const isComponent = node.tagType === 1;
21428
- exp = resolveExpression(exp, isComponent);
21428
+ const isDom2DataAttr = context.options.platform && arg.isStatic && arg.content.length > 5 && arg.content.startsWith("data-");
21429
+ exp = resolveExpression(exp, isComponent || isDom2DataAttr);
21429
21430
  arg = resolveExpression(arg);
21430
21431
  if (arg.isStatic && isReservedProp(arg.content)) return;
21431
21432
  let camel = false;
@@ -21663,7 +21664,8 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
21663
21664
  node,
21664
21665
  element: context.reference(),
21665
21666
  props: dynamicArgs,
21666
- tag
21667
+ tag,
21668
+ root: singleRoot && context.effectiveParent === context.root && context.options.componentType === "component"
21667
21669
  }, getEffectIndex);
21668
21670
  } else {
21669
21671
  const changeProps = [];
@@ -21691,6 +21693,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
21691
21693
  }
21692
21694
  let hasStaticStyle = false;
21693
21695
  let hasClass = false;
21696
+ const datasetProps = [];
21694
21697
  let prevWasQuoted = false;
21695
21698
  for (const prop of propsResult[1]) {
21696
21699
  const { key, values } = prop;
@@ -21749,6 +21752,17 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
21749
21752
  }
21750
21753
  }
21751
21754
  if (hasStaticStyle && hasClass) template += ` ext:style`;
21755
+ if (datasetProps.length) {
21756
+ const expressions = datasetProps.flatMap((prop) => prop.values);
21757
+ context.registerEffect(expressions, {
21758
+ type: 3,
21759
+ node,
21760
+ element: context.reference(),
21761
+ prop: _objectSpread2(_objectSpread2({}, datasetProps[0]), {}, { datasetProps }),
21762
+ tag,
21763
+ root: singleRoot && context.effectiveParent === context.root && context.options.componentType === "component"
21764
+ }, getEffectIndex);
21765
+ }
21752
21766
  }
21753
21767
  template += `>` + context.childrenTemplate.join("");
21754
21768
  if (!isVoidTag(tag) && !omitEndTag) template += `</${tag}>`;