@dcloudio/uni-cli-shared 3.0.0-5000420260318001 → 3.0.0-5000520260324002

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.
@@ -7,6 +7,7 @@ export declare const EXTNAME_VUE_TEMPLATE: string[];
7
7
  export declare const EXTNAME_VUE_RE: RegExp;
8
8
  export declare const EXTNAME_JS_RE: RegExp;
9
9
  export declare const EXTNAME_TS_RE: RegExp;
10
+ export declare const DEFAULT_APPID = "__UNI__uniappx";
10
11
  export declare const SPECIAL_CHARS: {
11
12
  WARN_BLOCK: string;
12
13
  ERROR_BLOCK: string;
@@ -39,6 +40,3 @@ export declare const COMMON_EXCLUDE: RegExp[];
39
40
  export declare const KNOWN_ASSET_TYPES: string[];
40
41
  export declare const DEFAULT_ASSETS_RE: RegExp;
41
42
  export declare const TEXT_STYLE: string[];
42
- export declare const JS_STYLE_PLACEHOLDER_MARKER = "__js_style_placeholder__";
43
- export declare const JS_STYLE_PLACEHOLDER_STR: string;
44
- export declare const JS_STYLE_PLACEHOLDER_RE: RegExp;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JS_STYLE_PLACEHOLDER_RE = exports.JS_STYLE_PLACEHOLDER_STR = exports.JS_STYLE_PLACEHOLDER_MARKER = exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.X_BASE_COMPONENTS_STYLE_PATH = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.SPECIAL_CHARS = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
3
+ exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = exports.X_BASE_COMPONENTS_STYLE_PATH = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.X_PAGE_EXTNAME_APP = exports.X_PAGE_EXTNAME = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_CONFIG_SERVICE = exports.APP_CONFIG = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.JSON_JS_MAP = exports.MANIFEST_JSON_UTS = exports.MANIFEST_JSON_JS = exports.PAGES_JSON_UTS = exports.PAGES_JSON_JS = exports.uni_app_x_extensions = exports.extensions = exports.SPECIAL_CHARS = exports.DEFAULT_APPID = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.X_EXTNAME_VUE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
4
4
  exports.PUBLIC_DIR = 'static';
5
5
  exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx', '.uts'];
6
6
  exports.EXTNAME_TS = ['.ts', '.tsx'];
@@ -10,6 +10,7 @@ exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.uvue', '.jsx', '.tsx'];
10
10
  exports.EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/;
11
11
  exports.EXTNAME_JS_RE = /\.(js|jsx|ts|uts|tsx|mjs)$/;
12
12
  exports.EXTNAME_TS_RE = /\.tsx?$/;
13
+ exports.DEFAULT_APPID = '__UNI__uniappx';
13
14
  exports.SPECIAL_CHARS = {
14
15
  WARN_BLOCK: '\uFEFF', // 警告块前后标识
15
16
  ERROR_BLOCK: '\u2060', // 错误块前后标识
@@ -88,8 +89,3 @@ exports.KNOWN_ASSET_TYPES = [
88
89
  ];
89
90
  exports.DEFAULT_ASSETS_RE = new RegExp(`\\.(` + exports.KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
90
91
  exports.TEXT_STYLE = ['black', 'white'];
91
- exports.JS_STYLE_PLACEHOLDER_MARKER = '__js_style_placeholder__';
92
- exports.JS_STYLE_PLACEHOLDER_STR = JSON.stringify({
93
- [exports.JS_STYLE_PLACEHOLDER_MARKER]: 0,
94
- });
95
- exports.JS_STYLE_PLACEHOLDER_RE = /\{\s*"__js_style_placeholder__"\s*:\s*0\s*}/g;
package/dist/deps.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare const API_DEPS_CSS: (isX: boolean) => {
5
5
  previewImage: string[];
6
6
  openLocation: string[];
7
7
  chooseLocation: string[];
8
+ showLoading: string[];
8
9
  };
9
10
  export declare const COMPONENT_DEPS_CSS: (isX: boolean) => {
10
11
  canvas: string[];
package/dist/deps.js CHANGED
@@ -6,9 +6,9 @@ const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-senso
6
6
  const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
7
7
  const API_DEPS_CSS = (isX) => {
8
8
  const deps_css = {
9
- showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
9
+ showModal: [],
10
10
  showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
11
- showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
11
+ showActionSheet: [],
12
12
  previewImage: [
13
13
  RESIZE_SENSOR_CSS,
14
14
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper.css`,
@@ -17,22 +17,31 @@ const API_DEPS_CSS = (isX) => {
17
17
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
18
18
  ],
19
19
  openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
20
- chooseLocation: [
21
- ...(isX
22
- ? [
23
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}/view.css`,
24
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}/text.css`,
25
- ]
26
- : [`${constants_1.H5_API_STYLE_PATH}/location-picker.css`]),
20
+ chooseLocation: [],
21
+ showLoading: [],
22
+ };
23
+ if (isX) {
24
+ deps_css.showModal = [`${constants_1.BASE_COMPONENTS_STYLE_PATH}textarea.css`];
25
+ deps_css.chooseLocation = [
26
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/view.css`,
27
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/text.css`,
27
28
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
28
29
  `${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
29
30
  `${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
30
- ],
31
- };
32
- if (isX) {
33
- // @ts-expect-error
31
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/image.css`,
32
+ ];
34
33
  deps_css.showLoading = [`${constants_1.X_BASE_COMPONENTS_STYLE_PATH}loading.css`];
35
34
  }
35
+ else {
36
+ deps_css.showModal = [`${constants_1.H5_API_STYLE_PATH}modal.css`];
37
+ deps_css.showActionSheet = [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`];
38
+ deps_css.chooseLocation = [
39
+ `${constants_1.H5_API_STYLE_PATH}/location-picker.css`,
40
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
41
+ `${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
42
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
43
+ ];
44
+ }
36
45
  return deps_css;
37
46
  };
38
47
  exports.API_DEPS_CSS = API_DEPS_CSS;
@@ -0,0 +1,4 @@
1
+ export declare const JS_STYLE_PLACEHOLDER_MARKER = "__js_style_placeholder__";
2
+ export declare function createJsStylePlaceholder(id: string): string;
3
+ export declare function createJsStylePlaceholderRegExp(id: string): RegExp;
4
+ export declare const ANY_JS_STYLE_PLACEHOLDER_RE: RegExp;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ANY_JS_STYLE_PLACEHOLDER_RE = exports.createJsStylePlaceholderRegExp = exports.createJsStylePlaceholder = exports.JS_STYLE_PLACEHOLDER_MARKER = void 0;
7
+ const hash_sum_1 = __importDefault(require("hash-sum"));
8
+ exports.JS_STYLE_PLACEHOLDER_MARKER = '__js_style_placeholder__';
9
+ function createJsStylePlaceholder(id) {
10
+ const hashId = (0, hash_sum_1.default)(id);
11
+ return JSON.stringify({
12
+ [exports.JS_STYLE_PLACEHOLDER_MARKER]: hashId,
13
+ });
14
+ }
15
+ exports.createJsStylePlaceholder = createJsStylePlaceholder;
16
+ function createJsStylePlaceholderRegExp(id) {
17
+ const hashId = (0, hash_sum_1.default)(id);
18
+ return new RegExp(`\\{\\s*"${exports.JS_STYLE_PLACEHOLDER_MARKER}"\\s*:\\s*"${hashId}"\\s*\\}`, 'g');
19
+ }
20
+ exports.createJsStylePlaceholderRegExp = createJsStylePlaceholderRegExp;
21
+ exports.ANY_JS_STYLE_PLACEHOLDER_RE = new RegExp(`\\{\\s*"${exports.JS_STYLE_PLACEHOLDER_MARKER}"\\s*:\\s*".+?"\\s*\\}`, 'g');
@@ -1 +1,3 @@
1
1
  export * from './sharedData';
2
+ export * from './vue';
3
+ export * from './fontFamily';
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./sharedData"), exports);
18
+ __exportStar(require("./vue"), exports);
19
+ __exportStar(require("./fontFamily"), exports);
@@ -1,2 +1,6 @@
1
1
  import type { Plugin } from 'vite';
2
2
  export declare function uniSharedDataPlugin(): Plugin;
3
+ export declare function initSourceFileCallback(): ((sourceFile: import('typescript').SourceFile) => void) | undefined;
4
+ export declare function initUts2jsSharedDataOptions(): {
5
+ resolveFieldMeta: any;
6
+ } | undefined;
@@ -1,19 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniSharedDataPlugin = void 0;
3
+ exports.initUts2jsSharedDataOptions = exports.initSourceFileCallback = exports.uniSharedDataPlugin = void 0;
4
4
  const uts_1 = require("../uts");
5
5
  const pages_1 = require("../json/pages");
6
6
  const utils_1 = require("../utils");
7
7
  const asset_1 = require("../vite/plugins/vitejs/plugins/asset");
8
- function uniSharedDataPlugin() {
9
- const { USDP } = (0, utils_1.requireUniHelpers)();
8
+ const x_1 = require("../x");
9
+ const manifest_1 = require("../json/uni-x/manifest");
10
+ const manifest_2 = require("../json/manifest");
11
+ function initSharedDataOptions() {
10
12
  const compiler = require('@dcloudio/compiler-vapor-dom2');
11
- return USDP({
13
+ const manifest = (0, manifest_2.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
14
+ return {
15
+ platform: process.env.UNI_UTS_PLATFORM,
12
16
  compilerVaporDom2: compiler,
13
17
  utsCompiler: (0, uts_1.resolveUTSCompiler)(),
14
18
  isUniPageFile: pages_1.isUniPageFile,
15
19
  getSharedDataResult: compiler.getSharedDataResult,
16
20
  getAssetFilenameById: asset_1.getAssetFilenameById,
17
- });
21
+ uvueScriptEngine: (0, x_1.isUniAppXAndroidNative)() ? 'native' : 'js',
22
+ compilerVersion: process.env.HX_Version || process.env.UNI_COMPILER_VERSION,
23
+ androidOptions: (0, x_1.isUniAppXAndroidJsEngine)()
24
+ ? {
25
+ package: (0, manifest_1.parseUniXAppAndroidPackage)(manifest.appid),
26
+ }
27
+ : undefined,
28
+ };
29
+ }
30
+ function uniSharedDataPlugin() {
31
+ return (0, utils_1.requireUniHelpers)().USDP(initSharedDataOptions());
18
32
  }
19
33
  exports.uniSharedDataPlugin = uniSharedDataPlugin;
34
+ function initSourceFileCallback() {
35
+ if (process.env.UNI_APP_X_DOM2 === 'true' && (0, x_1.isUniAppXAndroidNative)()) {
36
+ const { TSDBSF } = (0, utils_1.requireUniHelpers)();
37
+ const options = initSharedDataOptions();
38
+ return (sourceFile) => {
39
+ TSDBSF(sourceFile, options);
40
+ };
41
+ }
42
+ }
43
+ exports.initSourceFileCallback = initSourceFileCallback;
44
+ function initUts2jsSharedDataOptions() {
45
+ if (process.env.UNI_APP_X_DOM2 === 'true') {
46
+ return {
47
+ resolveFieldMeta: require('@dcloudio/compiler-vapor-dom2')
48
+ .resolveSharedDataFieldMeta,
49
+ };
50
+ }
51
+ }
52
+ exports.initUts2jsSharedDataOptions = initUts2jsSharedDataOptions;
@@ -0,0 +1,15 @@
1
+ import type { CompilerError, SFCDescriptor } from '@vue/compiler-sfc';
2
+ export declare function initVueTemplateCompilerExtraOptions(descriptor: SFCDescriptor): {
3
+ root: string;
4
+ platform: keyof UniApp.PagesJsonPagePlatformStyle;
5
+ componentType: string;
6
+ filename: string;
7
+ relativeFilename: string;
8
+ helper: any;
9
+ scriptCppBlocks: any;
10
+ disableStaticStyle: boolean;
11
+ onVueTemplateCompileLog(type: 'warn' | 'error', error: CompilerError): void;
12
+ r: any;
13
+ className: any;
14
+ inlineRender: boolean;
15
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initVueTemplateCompilerExtraOptions = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const utils_1 = require("../utils");
9
+ const json_1 = require("../json");
10
+ const vue_1 = require("../vue");
11
+ function initVueTemplateCompilerExtraOptions(descriptor) {
12
+ const filename = (0, utils_1.normalizePath)(descriptor.filename.split('?')[0]);
13
+ const relativeFilename = (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename));
14
+ const isDevX = process.env.UNI_HX_VERSION_DEV === 'true' &&
15
+ process.env.UNI_APP_X === 'true';
16
+ let disableStaticStyle = false;
17
+ if (isDevX && process.env.NODE_ENV === 'development') {
18
+ if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
19
+ // 开发版本、开发模式下,非鸿蒙release模式打包
20
+ disableStaticStyle = process.env.UNI_APP_HARMONY_RUN_MODE !== 'release';
21
+ }
22
+ }
23
+ const helper = (0, utils_1.requireUniHelpers)();
24
+ return {
25
+ root: (0, utils_1.normalizePath)(process.env.UNI_INPUT_DIR),
26
+ platform: process.env.UNI_UTS_PLATFORM,
27
+ componentType: (0, json_1.isUniPageFile)(filename) ? 'page' : 'component',
28
+ filename: filename,
29
+ relativeFilename,
30
+ helper,
31
+ scriptCppBlocks: descriptor.scriptCppBlocks,
32
+ disableStaticStyle,
33
+ onVueTemplateCompileLog(type, error) {
34
+ return (0, vue_1.onVueTemplateCompileLog)(type, error, descriptor.source, relativeFilename);
35
+ },
36
+ r: helper.K,
37
+ className: helper.GCN(descriptor.filename, process.env.UNI_INPUT_DIR),
38
+ inlineRender: process.env.UNI_UTS_PLATFORM === 'app-android',
39
+ };
40
+ }
41
+ exports.initVueTemplateCompilerExtraOptions = initVueTemplateCompilerExtraOptions;
package/dist/easycom.js CHANGED
@@ -10,6 +10,7 @@ const debug_1 = __importDefault(require("debug"));
10
10
  const shared_1 = require("@vue/shared");
11
11
  const pluginutils_1 = require("@rollup/pluginutils");
12
12
  const uni_shared_1 = require("@dcloudio/uni-shared");
13
+ const x_1 = require("./x");
13
14
  const utils_1 = require("./utils");
14
15
  const pages_1 = require("./json/pages");
15
16
  const messages_1 = require("./messages");
@@ -109,8 +110,8 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
109
110
  clearEasycom();
110
111
  (0, uts_1.clearUTSComponents)();
111
112
  (0, uts_1.clearUTSCustomElements)();
112
- initEasycom(easyComOptions);
113
- if (isX) {
113
+ initEasycom(res.easyComOptions);
114
+ if (supportCustomElements) {
114
115
  initUTSEasycomCustomElements();
115
116
  }
116
117
  initUTSEasycom();
@@ -197,6 +198,11 @@ function matchEasycom(tag) {
197
198
  source = tag.replace(matcher.pattern, matcher.replacement);
198
199
  easycomsCache.set(tag, source);
199
200
  debugEasycom('matchEasycom', tag, source);
201
+ // 检查 H5 专用组件 ask163203
202
+ const H5_ONLY_COMPONENTS = ['custom-tab-bar'];
203
+ if (H5_ONLY_COMPONENTS.includes(tag) && process.env.UNI_PLATFORM !== 'h5') {
204
+ console.warn(`[uni-app] 组件 <${tag}> 是 H5 平台专用组件,在 ${process.env.UNI_PLATFORM} 平台使用可能导致错误。如果你要引入自定义 tabBar 可重命名为其他名称。`);
205
+ }
200
206
  return source;
201
207
  }
202
208
  exports.matchEasycom = matchEasycom;
@@ -255,12 +261,7 @@ function initAutoScanEasycom(platform, dir, rootDir, extensions) {
255
261
  easycoms[`^${name}$`] =
256
262
  // mp平台,这里不处理,由uniEntryPlugin处理
257
263
  is_easycom_encrypt_uni_modules && !isMp
258
- ? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${
259
- // android 走 proxy
260
- process.env.UNI_APP_X === 'true' &&
261
- process.env.UNI_UTS_PLATFORM === 'app-android'
262
- ? 'uts-proxy'
263
- : 'uni_helpers'}`))
264
+ ? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${(0, x_1.isUniAppXAndroidNative)() ? 'uts-proxy' : 'uni_helpers'}`))
264
265
  : `${importDir}/${name}${ext}`;
265
266
  break;
266
267
  }
@@ -313,7 +314,10 @@ function createImportDeclaration(local, source, imported) {
313
314
  }
314
315
  const RESOLVE_EASYCOM_IMPORT_CODE = `import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';`;
315
316
  function genResolveEasycomCode(importDeclarations, code, name) {
316
- if (process.env.UNI_APP_X_DOM2 === 'true') {
317
+ if (process.env.UNI_APP_X_DOM2 === 'true' ||
318
+ // 内部 dev 版本,需要本地开发内置组件,比如web-view,此时需要直接返回本地easycom,不然会找到基座内置的
319
+ (process.env.UNI_HX_VERSION_DEV === 'true' &&
320
+ process.env.UNI_APP_X === 'true')) {
317
321
  // dom2 模式下,为了性能,不再考虑优先级问题,如果开发者需要区别,可以手动导入为其他名称
318
322
  return name;
319
323
  }
@@ -2,7 +2,6 @@ export declare function initDefine(stringifyBoolean?: boolean): {
2
2
  __X_STYLE_ISOLATION__: string | boolean;
3
3
  __X_STYLE_ISOLATION_UP_ARROW__: string | boolean;
4
4
  'process.env.UNI_APP_X_NEW_STYLE_ISOLATION': string | boolean;
5
- __UNI_FEATURE_VIRTUAL_HOST__: boolean;
6
5
  'process.env.NODE_ENV': string;
7
6
  'process.env.UNI_DEBUG': string | boolean;
8
7
  'process.env.UNI_APP_ID': string;
@@ -15,17 +15,9 @@ function initDefine(stringifyBoolean = false) {
15
15
  const isNewStyleIsolationUpArrow = isNewStyleIsolation && process.env.UNI_PLATFORM === 'mp-weixin';
16
16
  const isMP = process.env.UNI_PLATFORM && process.env.UNI_PLATFORM.startsWith('mp-');
17
17
  process.env['UNI_APP_ID'] = manifestJson.appid;
18
- let mpXDefine = isX && isMP
19
- ? {
20
- __UNI_FEATURE_VIRTUAL_HOST__: true,
21
- }
22
- : {
23
- __UNI_FEATURE_VIRTUAL_HOST__: false,
24
- };
25
- if (isX && isMP) {
26
- mpXDefine.__UNI_FEATURE_VIRTUAL_HOST__ =
27
- platformManifestJson.enableVirtualHost !== false;
28
- }
18
+ const mpXDefine = {
19
+ __UNI_FEATURE_VIRTUAL_HOST__: isX && isMP && platformManifestJson.enableVirtualHost !== false,
20
+ };
29
21
  const styleIsolation = stringifyBoolean
30
22
  ? JSON.stringify(isNewStyleIsolation)
31
23
  : isNewStyleIsolation;
package/dist/hbx/alias.js CHANGED
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
- // 注意:该文件尽可能少依赖其他文件,否则可能会导致还没有alias的时候,就加载了目标模块
3
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
4
  };
6
5
  Object.defineProperty(exports, "__esModule", { value: true });
7
6
  exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
7
+ // 注意:该文件尽可能少依赖其他文件,否则可能会导致还没有alias的时候,就加载了目标模块
8
+ const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
10
  const module_alias_1 = __importDefault(require("module-alias"));
10
11
  const utils_1 = require("./utils");
12
+ const jsonc_parser_1 = require("jsonc-parser");
11
13
  const hbxPlugins = {
12
14
  typescript: 'compile-typescript/node_modules/typescript',
13
15
  less: 'compile-less/node_modules/less',
@@ -19,19 +21,55 @@ function initModuleAlias() {
19
21
  const libDir = path_1.default.resolve(__dirname, '../../lib');
20
22
  const compilerSfcPath = path_1.default.resolve(libDir, '@vue/compiler-sfc');
21
23
  const serverRendererPath = require.resolve('@vue/server-renderer');
24
+ // 对路径进行兼容
25
+ if (!process.env.UNI_APP_X_DOM2_CPP_DIR &&
26
+ process.env.UNI_APP_HARMONY_DOM2_CPP_DIR) {
27
+ process.env.UNI_APP_X_DOM2_CPP_DIR =
28
+ process.env.UNI_APP_HARMONY_DOM2_CPP_DIR;
29
+ }
30
+ if (process.env.UNI_APP_PLATFORM === 'ios' ||
31
+ process.env.UNI_APP_PLATFORM === 'android') {
32
+ if (process.env.UNI_INPUT_DIR) {
33
+ const manifestJsonFilename = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'manifest.json');
34
+ if (fs_1.default.existsSync(manifestJsonFilename)) {
35
+ const manifestJsonStr = fs_1.default.readFileSync(manifestJsonFilename, 'utf-8');
36
+ const manifestJson = (0, jsonc_parser_1.parse)(manifestJsonStr);
37
+ if (manifestJson?.['uni-app-x']?.vapor === true) {
38
+ const vaporFilename = path_1.default.resolve(process.env.UNI_INPUT_DIR, '.vapor');
39
+ if (fs_1.default.existsSync(vaporFilename)) {
40
+ process.env.UNI_APP_X_DOM2 = 'true';
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
22
46
  if (process.env.UNI_APP_X_DOM2 === 'true') {
23
- if (
24
- // 该代码执行较早,不能使用UNI_UTS_PLATFORM
25
- process.env.UNI_PLATFORM === 'app-harmony') {
26
- if (process.env.UNI_OUTPUT_DIR) {
27
- if (!process.env.UNI_APP_HARMONY_DOM2_CPP_DIR) {
28
- process.env.UNI_APP_HARMONY_DOM2_CPP_DIR = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, 'cpp');
47
+ if (process.env.UNI_OUTPUT_DIR &&
48
+ (process.env.UNI_PLATFORM === 'app' ||
49
+ process.env.UNI_PLATFORM === 'app-plus' ||
50
+ process.env.UNI_PLATFORM === 'app-harmony')) {
51
+ if (!process.env.UNI_APP_X_DOM2_CPP_DIR) {
52
+ const baseDir = process.env.UNI_PLATFORM === 'app-harmony'
53
+ ? process.env.UNI_OUTPUT_DIR
54
+ : process.env.UNI_APP_X_CACHE_DIR || process.env.UNI_OUTPUT_DIR;
55
+ process.env.UNI_APP_X_DOM2_CPP_DIR = path_1.default.resolve(baseDir, 'cpp');
56
+ }
57
+ if (!process.env.UNI_APP_X_DOM2_KT_DIR) {
58
+ if (process.env.NODE_ENV !== 'development') {
59
+ process.env.UNI_APP_X_DOM2_KT_DIR = path_1.default.resolve(process.env.UNI_OUTPUT_DIR, 'src/.uniappx/android', 'src');
60
+ }
61
+ else {
62
+ process.env.UNI_APP_X_DOM2_KT_DIR = path_1.default.resolve(process.env.UNI_APP_X_CACHE_DIR ||
63
+ path_1.default.resolve(process.env.UNI_OUTPUT_DIR, '../.cache'), 'src');
29
64
  }
30
65
  }
31
66
  }
32
- else {
33
- // 目前仅支持 app-harmony 平台启用 dom2
34
- delete process.env.UNI_APP_X_DOM2;
67
+ if (process.env.UNI_APP_PLATFORM ||
68
+ process.env.UNI_PLATFORM === 'app-harmony') {
69
+ const dynamicFilename = path_1.default.resolve(process.env.UNI_INPUT_DIR, '.dynamic');
70
+ if (fs_1.default.existsSync(dynamicFilename)) {
71
+ process.env.UNI_APP_X_DOM2_DYNAMIC = 'true';
72
+ }
35
73
  }
36
74
  }
37
75
  if (process.env.UNI_APP_X_DOM2 === 'true') {
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './hbx';
6
6
  export * from './ssr';
7
7
  export * from './vue';
8
8
  export * from './uts';
9
+ export * from './x';
9
10
  export * from './logs';
10
11
  export * from './dom2';
11
12
  export * from './i18n';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./hbx"), exports);
23
23
  __exportStar(require("./ssr"), exports);
24
24
  __exportStar(require("./vue"), exports);
25
25
  __exportStar(require("./uts"), exports);
26
+ __exportStar(require("./x"), exports);
26
27
  __exportStar(require("./logs"), exports);
27
28
  __exportStar(require("./dom2"), exports);
28
29
  __exportStar(require("./i18n"), exports);
@@ -1,3 +1,3 @@
1
1
  export declare function parseUniXFlexDirection(manifestJson: Record<string, any>): any;
2
2
  export declare function parseUniXSplashScreen(platform: 'app-android' | 'app-ios' | 'app-harmony', manifestJson: Record<string, any>): false | object;
3
- export declare function parseUniXAppAndroidPackage(appid: string): string;
3
+ export declare function parseUniXAppAndroidPackage(appid?: string): string;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseUniXAppAndroidPackage = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
+ const constants_1 = require("../../constants");
5
6
  const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
6
7
  function parseUniXFlexDirection(manifestJson) {
7
8
  const flexDir = manifestJson?.['uni-app-x']?.['flex-direction'];
@@ -20,6 +21,6 @@ function parseUniXSplashScreen(platform, manifestJson) {
20
21
  }
21
22
  exports.parseUniXSplashScreen = parseUniXSplashScreen;
22
23
  function parseUniXAppAndroidPackage(appid) {
23
- return 'uni.' + appid.replace(/_/g, '');
24
+ return 'uni.' + (appid || constants_1.DEFAULT_APPID).replace(/_/g, '');
24
25
  }
25
26
  exports.parseUniXAppAndroidPackage = parseUniXAppAndroidPackage;
@@ -64,6 +64,30 @@ function checkPagesJson(jsonStr, inputDir) {
64
64
  });
65
65
  }
66
66
  });
67
+ const tabBarNode = root.children?.find((child) => child.type === 'property' &&
68
+ child.children?.length === 2 &&
69
+ child.children[0].value === 'tabBar');
70
+ if (process.env.UNI_APP_X_DOM2 !== 'true' && tabBarNode) {
71
+ // dom2下不支持tabBar配置项,这里先不校验
72
+ let allPages = []; // 收集全部页面,包含分包页面
73
+ let tabBarPages = []; // 收集 tabBar 页面
74
+ allPages.push(...pagePathNodes.map((node) => node.value));
75
+ findRootNode(tabBarNode.children[1], ['list']).forEach((node) => {
76
+ const pagePathNode = node.type === 'object' &&
77
+ node.children?.find((child) => child.type === 'property' &&
78
+ child.children?.length === 2 &&
79
+ child.children[0].value === 'pagePath');
80
+ if (pagePathNode) {
81
+ const pagePathValueNode = pagePathNode.children[1];
82
+ const pagePath = pagePathValueNode.value;
83
+ tabBarPages.push(pagePath);
84
+ if (!allPages.includes(pagePath) &&
85
+ !allPages.includes(pagePath.substring(1))) {
86
+ throwCompilerError(jsonStr, pagePathValueNode, messages_1.M['pages.json.tabbar.page.notfound'].replace('{pagePath}', pagePath));
87
+ }
88
+ }
89
+ });
90
+ }
67
91
  for (const node of pagePathNodes) {
68
92
  const pagePath = node.value ?? '';
69
93
  if (!pageExistsWithCaseSync(path_1.default.join(inputDir, pagePath))) {
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  readonly 'app.compiler.version': "Compiler version: {version}";
3
+ readonly 'style.isolation.version': "Style isolation version: {version}";
3
4
  readonly compiling: "Compiling...";
4
5
  readonly 'dev.performance': "Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.";
5
6
  readonly 'dev.performance.nvue': "Especially the sourcemap of app-nvue has a greater impact";
@@ -48,5 +49,6 @@ declare const _default: {
48
49
  readonly 'uni_modules.import': "Plug-in [{0}] only supports @/uni_modules/{1}.";
49
50
  readonly 'pages.json.page.notfound': "The page \"{pagePath}\" does not exist.";
50
51
  readonly 'pages.json.page.slash': "The Path \"{pagePath}\" cannot start with \"/\"";
52
+ readonly 'pages.json.tabbar.page.notfound': "The tabBar page \"{pagePath}\" is not declared in \"pages.json\".";
51
53
  };
52
54
  export default _default;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  'app.compiler.version': 'Compiler version: {version}',
5
+ 'style.isolation.version': 'Style isolation version: {version}',
5
6
  compiling: 'Compiling...',
6
7
  'dev.performance': 'Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.',
7
8
  'dev.performance.nvue': 'Especially the sourcemap of app-nvue has a greater impact',
@@ -50,4 +51,5 @@ exports.default = {
50
51
  'uni_modules.import': 'Plug-in [{0}] only supports @/uni_modules/{1}.',
51
52
  'pages.json.page.notfound': 'The page "{pagePath}" does not exist.',
52
53
  'pages.json.page.slash': 'The Path "{pagePath}" cannot start with "/"',
54
+ 'pages.json.tabbar.page.notfound': 'The tabBar page "{pagePath}" is not declared in "pages.json".',
53
55
  };
@@ -1,5 +1,6 @@
1
1
  export declare const M: {
2
2
  readonly 'app.compiler.version': "编译器版本:{version}";
3
+ readonly 'style.isolation.version': "当前样式隔离策略:{version}。详见:https://doc.dcloud.net.cn/uni-app-x/css/common/style-isolation.html";
3
4
  readonly compiling: "正在编译中...";
4
5
  readonly 'dev.performance': "请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。";
5
6
  readonly 'dev.performance.nvue': "尤其是 app-nvue 的 sourcemap 影响较大";
@@ -48,8 +49,10 @@ export declare const M: {
48
49
  readonly 'uni_modules.import': "插件[{0}]仅支持 @/uni_modules/{1} 方式引入,不支持直接导入内部文件 {2}。";
49
50
  readonly 'pages.json.page.notfound': "页面\"{pagePath}\"不存在,请确保填写的页面路径不包含文件后缀,且必须与真实的文件路径大小写保持一致。";
50
51
  readonly 'pages.json.page.slash': "路径 \"{pagePath}\" 不能以 \"/\" 开头";
52
+ readonly 'pages.json.tabbar.page.notfound': "tabBar 中配置的页面 \"{pagePath}\" 未在 pages.json 中注册。";
51
53
  } | {
52
54
  readonly 'app.compiler.version': "Compiler version: {version}";
55
+ readonly 'style.isolation.version': "Style isolation version: {version}";
53
56
  readonly compiling: "Compiling...";
54
57
  readonly 'dev.performance': "Please note that in running mode, due to log output, sourcemap, and uncompressed source code, the performance and package size are not as good as release mode.";
55
58
  readonly 'dev.performance.nvue': "Especially the sourcemap of app-nvue has a greater impact";
@@ -98,4 +101,5 @@ export declare const M: {
98
101
  readonly 'uni_modules.import': "Plug-in [{0}] only supports @/uni_modules/{1}.";
99
102
  readonly 'pages.json.page.notfound': "The page \"{pagePath}\" does not exist.";
100
103
  readonly 'pages.json.page.slash': "The Path \"{pagePath}\" cannot start with \"/\"";
104
+ readonly 'pages.json.tabbar.page.notfound': "The tabBar page \"{pagePath}\" is not declared in \"pages.json\".";
101
105
  };
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  readonly 'app.compiler.version': "编译器版本:{version}";
3
+ readonly 'style.isolation.version': "当前样式隔离策略:{version}。详见:https://doc.dcloud.net.cn/uni-app-x/css/common/style-isolation.html";
3
4
  readonly compiling: "正在编译中...";
4
5
  readonly 'dev.performance': "请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。";
5
6
  readonly 'dev.performance.nvue': "尤其是 app-nvue 的 sourcemap 影响较大";
@@ -48,5 +49,6 @@ declare const _default: {
48
49
  readonly 'uni_modules.import': "插件[{0}]仅支持 @/uni_modules/{1} 方式引入,不支持直接导入内部文件 {2}。";
49
50
  readonly 'pages.json.page.notfound': "页面\"{pagePath}\"不存在,请确保填写的页面路径不包含文件后缀,且必须与真实的文件路径大小写保持一致。";
50
51
  readonly 'pages.json.page.slash': "路径 \"{pagePath}\" 不能以 \"/\" 开头";
52
+ readonly 'pages.json.tabbar.page.notfound': "tabBar 中配置的页面 \"{pagePath}\" 未在 pages.json 中注册。";
51
53
  };
52
54
  export default _default;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  'app.compiler.version': '编译器版本:{version}',
5
+ 'style.isolation.version': '当前样式隔离策略:{version}。详见:https://doc.dcloud.net.cn/uni-app-x/css/common/style-isolation.html',
5
6
  compiling: '正在编译中...',
6
7
  'dev.performance': '请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。',
7
8
  'dev.performance.nvue': '尤其是 app-nvue 的 sourcemap 影响较大',
@@ -51,4 +52,5 @@ exports.default = {
51
52
  'uni_modules.import': '插件[{0}]仅支持 @/uni_modules/{1} 方式引入,不支持直接导入内部文件 {2}。',
52
53
  'pages.json.page.notfound': '页面"{pagePath}"不存在,请确保填写的页面路径不包含文件后缀,且必须与真实的文件路径大小写保持一致。',
53
54
  'pages.json.page.slash': '路径 "{pagePath}" 不能以 "/" 开头',
55
+ 'pages.json.tabbar.page.notfound': 'tabBar 中配置的页面 "{pagePath}" 未在 pages.json 中注册。',
54
56
  };
@@ -12,6 +12,7 @@ const easycom_1 = require("./easycom");
12
12
  const messages_1 = require("./messages");
13
13
  const constants_1 = require("./constants");
14
14
  const url_1 = require("./url");
15
+ const x_1 = require("./x");
15
16
  function genEncryptEasyComModuleIndex(pluginId, platform, components) {
16
17
  const isMp = platform.startsWith('mp-');
17
18
  const imports = [];
@@ -23,7 +24,7 @@ function genEncryptEasyComModuleIndex(pluginId, platform, components) {
23
24
  ids.push(id);
24
25
  }
25
26
  let instance = '';
26
- if (platform === 'app-android') {
27
+ if ((0, x_1.isUniAppXAndroidNative)(platform)) {
27
28
  instance = (0, easycom_1.genUTSComponentPublicInstanceIdent)(component);
28
29
  // 类型
29
30
  ids.push(instance);
@@ -307,14 +308,15 @@ const KNOWN_ASSET_TYPES = [
307
308
  'txt',
308
309
  ];
309
310
  function findUniModuleFiles(platform, id, inputDir) {
311
+ const useUniAppXAndroidNative = (0, x_1.isUniAppXAndroidNative)(platform);
310
312
  return (0, fast_glob_1.sync)(`uni_modules/${id}/**/*`, {
311
313
  cwd: inputDir,
312
314
  absolute: true,
313
315
  ignore: [
314
316
  '**/*.md',
315
- ...(platform !== 'app-android' // android 平台不需要扫描 assets
316
- ? [`**/*.{${KNOWN_ASSET_TYPES.join(',')}}`]
317
- : []),
317
+ ...(useUniAppXAndroidNative // 仅旧版 Android x 需要扫描 assets
318
+ ? []
319
+ : [`**/*.{${KNOWN_ASSET_TYPES.join(',')}}`]),
318
320
  ],
319
321
  });
320
322
  }
@@ -367,8 +369,10 @@ function resolveEncryptUniModule(id, platform, isX = true) {
367
369
  }
368
370
  }
369
371
  }
370
- // 原生平台走旧的uts-proxy
371
- return (0, utils_1.normalizePath)(path_1.default.join(process.env.UNI_INPUT_DIR, `uni_modules/${uniModuleId}?${isX && platform === 'app-android' ? 'uts-proxy' : 'uni_helpers'}`));
372
+ // 仅旧版 Android x 原生引擎走 uts-proxy,JS 引擎与其他平台统一走 uni_helpers
373
+ return (0, utils_1.normalizePath)(path_1.default.join(process.env.UNI_INPUT_DIR, `uni_modules/${uniModuleId}?${isX && (0, x_1.isUniAppXAndroidNative)(platform)
374
+ ? 'uts-proxy'
375
+ : 'uni_helpers'}`));
372
376
  }
373
377
  }
374
378
  }
@@ -383,15 +387,14 @@ async function checkEncryptUniModules(inputDir, params, sdkType = 'all') {
383
387
  return {};
384
388
  }
385
389
  const cacheDir = process.env.UNI_MODULES_ENCRYPT_CACHE_DIR;
386
- const { zipFile, modules } = packUploadEncryptUniModules(curEncryptUniModules, process.env.UNI_UTS_PLATFORM, inputDir, cacheDir);
390
+ const { zipFile, modules } = packUploadEncryptUniModules(curEncryptUniModules, params.platform, inputDir, cacheDir);
387
391
  if (zipFile) {
388
392
  const downloadFile = path_1.default.resolve(cacheDir, 'uni_modules.download.zip');
389
393
  const { C, D, R, U } = (0, utils_1.requireUniHelpers)();
390
394
  try {
391
395
  const isLogin = await C();
392
- const tips = process.env.UNI_UTS_PLATFORM !== 'app-android'
393
- ? '(此过程耗时较长)'
394
- : '';
396
+ const useUniAppXAndroidNative = (0, x_1.isUniAppXAndroidNative)(params.platform);
397
+ const tips = !useUniAppXAndroidNative ? '(此过程耗时较长)' : '';
395
398
  console.log(`正在云编译插件${isLogin ? '' : '(请先登录)'}${tips}:${modules.join(',')}...`);
396
399
  let downloadUrl = '';
397
400
  try {
@@ -431,8 +434,9 @@ async function checkEncryptUniModules(inputDir, params, sdkType = 'all') {
431
434
  }
432
435
  }
433
436
  else {
434
- // android 平台需要在这里初始化
435
- if (params.platform === 'app-android') {
437
+ const useUniAppXAndroidNative = (0, x_1.isUniAppXAndroidNative)(params.platform);
438
+ // 仅旧版 Android x 需要在缓存命中时额外初始化
439
+ if (useUniAppXAndroidNative) {
436
440
  const { R } = (0, utils_1.requireUniHelpers)();
437
441
  R({
438
442
  dir: process.env.UNI_INPUT_DIR,
@@ -7,6 +7,7 @@ exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.par
7
7
  // 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const x_1 = require("./x");
10
11
  const extApiProviders = [];
11
12
  const extApiPlugins = new Set();
12
13
  function getNonTreeShakingPlugins() {
@@ -228,7 +229,7 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
228
229
  // source = `${source}/utssdk/index.uts`
229
230
  // }
230
231
  }
231
- else if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
232
+ else if ((0, x_1.isUniAppXJsEngine)()) {
232
233
  if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-js', 'index.uts'))) {
233
234
  source = `${source}/utssdk/app-js/index.uts`;
234
235
  }
@@ -291,7 +292,7 @@ function parseInject(vite = true, platform, language, source, globalObject, defi
291
292
  const appOptions = defineOptions.app;
292
293
  if (isPlainObject(appOptions)) {
293
294
  // js engine 下且存在 app-js,不检查
294
- const skipCheck = (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' ||
295
+ const skipCheck = ((0, x_1.isUniAppXJsEngine)() ||
295
296
  process.env.UNI_UTS_PLATFORM === 'app-harmony') &&
296
297
  source.includes('app-js');
297
298
  if (!skipCheck) {
package/dist/uts.js CHANGED
@@ -12,6 +12,8 @@ const unimport_1 = require("unimport");
12
12
  const hbx_1 = require("./hbx");
13
13
  const utils_1 = require("./utils");
14
14
  const uni_modules_1 = require("./uni_modules");
15
+ const preprocess_1 = require("./preprocess");
16
+ const x_1 = require("./x");
15
17
  function once(fn, ctx = null) {
16
18
  let res;
17
19
  return ((...args) => {
@@ -36,7 +38,7 @@ function resolveUTSAppModule(platform, id, importer, includeUTSSDK = true) {
36
38
  if (parentDir === 'uni_modules' ||
37
39
  (includeUTSSDK && parentDir === 'utssdk')) {
38
40
  const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
39
- if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
41
+ if ((0, x_1.isUniAppXJsEngine)()) {
40
42
  // js engine
41
43
  if (parentDir === 'uni_modules') {
42
44
  const appJsIndex = path_1.default.resolve(id, basedir, 'app-js', 'index.uts');
@@ -510,7 +512,7 @@ async function parseUniExtApiAutoImports(uniExtApiAutoImports, extApis, parseSou
510
512
  const filename = `uni_modules/${pluginId}/utssdk/interface.uts`;
511
513
  const interfaceFileName = path_1.default.resolve(process.env.UNI_INPUT_DIR, filename);
512
514
  if (fs_extra_1.default.existsSync(interfaceFileName)) {
513
- const ids = await parseExportIdentifiers(interfaceFileName);
515
+ const ids = await parseExportIdentifiers(interfaceFileName, preprocess_1.preUVueJs);
514
516
  ids
515
517
  // 过滤掉 Uni
516
518
  .filter((id) => id !== 'Uni')
@@ -9,6 +9,7 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
9
9
  const uts_1 = require("../uts");
10
10
  const workers_1 = require("../workers");
11
11
  const utils_1 = require("../utils");
12
+ const x_1 = require("../x");
12
13
  const uniWebLifeCyclePreset = {
13
14
  from: '@dcloudio/uni-app',
14
15
  imports: [
@@ -284,8 +285,10 @@ const vuePreset = {
284
285
  function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
285
286
  rewriteAutoImportOnce();
286
287
  const autoImport = [vuePreset];
287
- // 只有app-ios和app-harmony平台特殊处理
288
- if (platform === 'app-ios' || platform === 'app-harmony') {
288
+ // JS 引擎的 App 平台统一走 vue 生命周期导入
289
+ if (platform === 'app-ios' ||
290
+ platform === 'app-harmony' ||
291
+ (0, x_1.isUniAppXAndroidJsEngine)(platform)) {
289
292
  autoImport.push(uniAppLifeCyclePreset);
290
293
  }
291
294
  else if (platform === 'web') {
@@ -317,8 +320,8 @@ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
317
320
  include: [/\.[u]?ts$/, /\.[u]?vue/],
318
321
  exclude,
319
322
  imports: imports.concat(
320
- // app-android 平台暂不注入其他
321
- platform === 'app-android' ? [] : autoImport),
323
+ // 旧版 Android x 仍由专有编译流程处理,Android Vapor 对齐 iOS 走通用自动导入
324
+ (0, x_1.isUniAppXAndroidNative)(platform) ? [] : autoImport),
322
325
  dts: false,
323
326
  };
324
327
  }
@@ -15,6 +15,8 @@ const uni_modules_1 = require("./plugins/uts/uni_modules");
15
15
  const utils_3 = require("./utils");
16
16
  const json_1 = require("../json");
17
17
  const workers_1 = require("../workers");
18
+ const dom2_1 = require("../dom2");
19
+ const x_1 = require("../x");
18
20
  function createEncryptCssUrlReplacer(resolve) {
19
21
  return async (url, importer) => {
20
22
  if (url.startsWith('/') && !url.startsWith('//')) {
@@ -64,6 +66,7 @@ exports.uniEncryptUniModulesAssetsPlugin = uniEncryptUniModulesAssetsPlugin;
64
66
  function uniEncryptUniModulesPlugin() {
65
67
  let resolvedConfig;
66
68
  const isMp = process.env.UNI_UTS_PLATFORM.startsWith('mp-');
69
+ const useUniAppXAndroidNative = (0, x_1.isUniAppXAndroidNative)();
67
70
  const encryptModuleOutputFiles = [];
68
71
  return {
69
72
  name: 'uni:encrypt-uni-modules',
@@ -92,7 +95,7 @@ function uniEncryptUniModulesPlugin() {
92
95
  resolvedConfig = config;
93
96
  },
94
97
  resolveId(id, importer) {
95
- if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
98
+ if (!useUniAppXAndroidNative) {
96
99
  if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
97
100
  id = (0, utils_2.normalizePath)(id);
98
101
  if (importer && (id.startsWith('./') || id.startsWith('../'))) {
@@ -106,7 +109,7 @@ function uniEncryptUniModulesPlugin() {
106
109
  }
107
110
  },
108
111
  load(id) {
109
- if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
112
+ if (!useUniAppXAndroidNative) {
110
113
  if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
111
114
  return {
112
115
  code: `export default ${JSON.stringify(id.replace(/\0/g, ''))}`,
@@ -119,8 +122,8 @@ function uniEncryptUniModulesPlugin() {
119
122
  Object.keys(bundle).forEach((fileName) => {
120
123
  if (fileName.endsWith('.module.js')) {
121
124
  const uniModuleId = path_1.default.basename(fileName).replace('.module.js', '');
122
- // app-android 不需要 js
123
- if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
125
+ // 仅旧版 Android x 不需要 js
126
+ if (!useUniAppXAndroidNative) {
124
127
  const newFileName = 'uni_modules/' +
125
128
  fileName.replace('.module.js', '/index.module.js');
126
129
  bundle[newFileName] = bundle[fileName];
@@ -171,12 +174,13 @@ function uniEncryptUniModulesPlugin() {
171
174
  }
172
175
  },
173
176
  async writeBundle() {
174
- if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
177
+ if (!useUniAppXAndroidNative) {
175
178
  return;
176
179
  }
177
180
  const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true'
178
181
  ? (0, uts_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce({
179
182
  resolveWorkers: () => (0, workers_1.getWorkers)(),
183
+ sourceFileCallback: (0, dom2_1.initSourceFileCallback)(),
180
184
  })
181
185
  : null;
182
186
  if (uniXKotlinCompiler) {
@@ -393,7 +397,10 @@ function compileCloudUniModuleWithTsc(platform, pluginDir) {
393
397
  const isX = process.env.UNI_APP_X === 'true';
394
398
  const resolveWorkers = () => (0, workers_1.getWorkers)();
395
399
  return compileUniModuleWithTsc(platform, pluginDir, platform === 'app-android'
396
- ? createUniXKotlinCompilerOnce({ resolveWorkers })
400
+ ? createUniXKotlinCompilerOnce({
401
+ resolveWorkers,
402
+ sourceFileCallback: (0, dom2_1.initSourceFileCallback)(),
403
+ })
397
404
  : platform === 'app-harmony'
398
405
  ? createUniXArkTSCompilerOnce({ resolveWorkers })
399
406
  : createUniXSwiftCompilerOnce({ resolveWorkers }), {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.uniUniModulesExtApiPlugin = void 0;
4
4
  const uts_1 = require("../uts");
5
5
  const resolve_1 = require("../resolve");
6
+ const x_1 = require("../x");
6
7
  function uniUniModulesExtApiPlugin() {
7
8
  return {
8
9
  name: 'uni:uni-modules_ext-api',
@@ -21,7 +22,9 @@ function uniUniModulesExtApiPlugin() {
21
22
  },
22
23
  };
23
24
  const build = {};
24
- if (['app-ios', 'app-harmony'].includes(process.env.UNI_UTS_PLATFORM)) {
25
+ if (process.env.UNI_UTS_PLATFORM === 'app-ios' ||
26
+ process.env.UNI_UTS_PLATFORM === 'app-harmony' ||
27
+ (0, x_1.isUniAppXAndroidJsEngine)()) {
25
28
  build.rollupOptions = rollupOptions;
26
29
  }
27
30
  return {
@@ -9,86 +9,19 @@ const json_1 = require("../../json");
9
9
  const preprocess_1 = require("../../preprocess");
10
10
  const utils_1 = require("../utils");
11
11
  function uniJsonPlugin() {
12
- const UTS_CAST_ARRAY_MARKER = '/*__UTS_CAST_UTSJSON_ARRAY__*/';
13
- const UTS_CAST_OBJECT_MARKER = '/*__UTS_CAST_UTSJSON_OBJECT__*/';
14
- const IS_UNI_X_ANDROID = process.env.UNI_APP_X === 'true' &&
15
- process.env.UNI_UTS_PLATFORM === 'app-android';
16
12
  return {
17
13
  name: 'uni:json',
18
14
  enforce: 'pre',
19
- generateBundle(options, bundle) {
20
- if (IS_UNI_X_ANDROID) {
21
- for (const [fileName, file] of Object.entries(bundle)) {
22
- if (fileName.endsWith('.json.ts')) {
23
- if (file.type === 'asset' && file.source) {
24
- const source = file.source.toString();
25
- if (source.includes(UTS_CAST_ARRAY_MARKER) ||
26
- source.includes(UTS_CAST_OBJECT_MARKER)) {
27
- file.source = source
28
- .replace(new RegExp(UTS_CAST_ARRAY_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ' as UTSJSONObject[]')
29
- .replace(new RegExp(UTS_CAST_OBJECT_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ' as UTSJSONObject');
30
- }
31
- }
32
- }
33
- }
34
- }
35
- },
36
15
  transform(code, id) {
37
16
  // 如果已经被其他插件处理过了,就不再处理,比如 commonjs 插件,ICAPRegistrar.json?commonjs-external
38
17
  if (id.startsWith('\0')) {
39
18
  return;
40
19
  }
41
- const { filename } = (0, utils_1.parseVueRequest)(id);
42
- if (path_1.default.extname(filename) !== '.json') {
20
+ if (path_1.default.extname((0, utils_1.parseVueRequest)(id).filename) !== '.json') {
43
21
  return;
44
22
  }
45
- let codeObj = (0, json_1.parseJson)((0, preprocess_1.preJson)(code, id), false, id);
46
- let codeJson = '';
47
- if (IS_UNI_X_ANDROID) {
48
- if (Array.isArray(codeObj)) {
49
- codeJson +=
50
- 'export default JSON.parseArray(`' +
51
- JSON.stringify(codeObj, null, 2) +
52
- '`)' +
53
- UTS_CAST_ARRAY_MARKER +
54
- ';\n';
55
- }
56
- else {
57
- codeJson +=
58
- 'let __jsonObj = JSON.parseObject(`' +
59
- JSON.stringify(codeObj, null, 2) +
60
- '`);\n';
61
- for (const key in codeObj) {
62
- if (!Object.hasOwn(codeObj, key))
63
- continue;
64
- const element = codeObj[key];
65
- if (Array.isArray(element)) {
66
- codeJson += `export const ${key} = __jsonObj?.getArray("${key}")${UTS_CAST_ARRAY_MARKER};\n`;
67
- }
68
- else if (typeof element === 'object' && element !== null) {
69
- codeJson += `export const ${key} = __jsonObj?.get("${key}")${UTS_CAST_OBJECT_MARKER};\n`;
70
- }
71
- else if (typeof element === 'string') {
72
- codeJson += `export const ${key} = __jsonObj?.getString("${key}") ?? '';\n`;
73
- }
74
- else if (typeof element === 'number') {
75
- codeJson += `export const ${key} = __jsonObj?.getNumber("${key}") ?? 0;\n`;
76
- }
77
- else if (typeof element === 'boolean') {
78
- codeJson += `export const ${key} = __jsonObj?.getBoolean("${key}") ?? false;\n`;
79
- }
80
- else {
81
- codeJson += `export const ${key} = __jsonObj?.get("${key}")${UTS_CAST_OBJECT_MARKER};\n`;
82
- }
83
- }
84
- codeJson += `export default __jsonObj;`;
85
- }
86
- }
87
- else {
88
- codeJson = JSON.stringify(codeObj, null, 2);
89
- }
90
23
  return {
91
- code: codeJson,
24
+ code: JSON.stringify((0, json_1.parseJson)((0, preprocess_1.preJson)(code, id), false, id), null, 2),
92
25
  map: {
93
26
  mappings: '',
94
27
  },
@@ -13,7 +13,8 @@ function uniStatsPlugin() {
13
13
  let resolvedConfig;
14
14
  let isManifestChanged = false;
15
15
  const shouldTrackManifestChange = process.env.UNI_APP_X === 'true' &&
16
- process.env.UNI_PLATFORM === 'app-harmony';
16
+ (process.env.UNI_PLATFORM === 'app' ||
17
+ process.env.UNI_PLATFORM === 'app-harmony');
17
18
  let isVapor = shouldTrackManifestChange && process.env.UNI_APP_X_DOM2 === 'true';
18
19
  return {
19
20
  name: 'uni:app-stats',
@@ -12,6 +12,7 @@ const uts_1 = require("../../../uts");
12
12
  const utils_1 = require("../../utils");
13
13
  const uni_modules_1 = require("../../../uni_modules");
14
14
  const uni_modules_cloud_1 = require("../../../uni_modules.cloud");
15
+ const x_1 = require("../../../x");
15
16
  const utils_2 = require("../../../utils");
16
17
  const json_1 = require("../../../json");
17
18
  const fs_1 = require("../../../fs");
@@ -19,6 +20,7 @@ const context_1 = require("../../../preprocess/context");
19
20
  const hbx_1 = require("../../../hbx");
20
21
  const console_1 = require("../../../logs/console");
21
22
  const workers_1 = require("../../../workers");
23
+ const dom2_1 = require("../../../dom2");
22
24
  /* eslint-disable no-restricted-globals */
23
25
  const { preprocess } = require('../../../../lib/preprocess');
24
26
  function rewriteUniModulesConsoleExpr(fileName, content) {
@@ -242,7 +244,10 @@ function uniUTSAppUniModulesPlugin(options = {}) {
242
244
  const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true' &&
243
245
  (process.env.UNI_UTS_PLATFORM === 'app-android' ||
244
246
  process.env.UNI_UTS_PLATFORM === 'app')
245
- ? createUniXKotlinCompilerOnce({ resolveWorkers })
247
+ ? createUniXKotlinCompilerOnce({
248
+ resolveWorkers,
249
+ sourceFileCallback: (0, dom2_1.initSourceFileCallback)(),
250
+ })
246
251
  : null;
247
252
  const uniXSwiftCompiler = process.env.UNI_APP_X_TSC === 'true' &&
248
253
  (process.env.UNI_UTS_PLATFORM === 'app-ios' ||
@@ -427,7 +432,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
427
432
  for (const plugin of plugins) {
428
433
  const pluginDir = path_1.default.resolve(inputDir, 'uni_modules', plugin.plugin);
429
434
  // 如果是 app-js 环境
430
- if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
435
+ if ((0, x_1.isUniAppXJsEngine)()) {
431
436
  if (fs_extra_1.default.existsSync(path_1.default.resolve(pluginDir, 'utssdk', 'app-js', 'index.uts'))) {
432
437
  continue;
433
438
  }
@@ -43,6 +43,7 @@ const preprocess_1 = require("../../../../preprocess");
43
43
  const uniapp_1 = require("../../../../postcss/plugins/uniapp");
44
44
  const cleanString_1 = require("../cleanString");
45
45
  const constants_1 = require("../../../../constants");
46
+ const fontFamily_1 = require("../../../../dom2/fontFamily");
46
47
  const utils_2 = require("../../../utils/utils");
47
48
  const compiler_core_1 = require("@vue/compiler-core");
48
49
  const utils_3 = require("../../../../utils");
@@ -223,7 +224,8 @@ function cssPostPlugin(config, { platform, isJsCode, preserveModules, chunkCssFi
223
224
  // styles initialization in buildStart causes a styling loss in watch
224
225
  const styles = new Map();
225
226
  let cssChunks;
226
- const isDom2Harmony = process.env.UNI_APP_X_DOM2 === 'true' && platform === 'app-harmony';
227
+ const isDom2 = process.env.UNI_APP_X_DOM2 === 'true';
228
+ const isDom2App = isDom2 && platform.startsWith('app');
227
229
  return {
228
230
  name: 'vite:css-post',
229
231
  buildStart() {
@@ -240,8 +242,8 @@ function cssPostPlugin(config, { platform, isJsCode, preserveModules, chunkCssFi
240
242
  return {
241
243
  code: modulesCode ||
242
244
  (isJsCode
243
- ? isDom2Harmony
244
- ? `export default ${constants_1.JS_STYLE_PLACEHOLDER_STR}`
245
+ ? isDom2App
246
+ ? `export default ${(0, fontFamily_1.createJsStylePlaceholder)(id)}`
245
247
  : 'export default {}'
246
248
  : ''),
247
249
  map: { mappings: '' },
@@ -251,7 +253,7 @@ function cssPostPlugin(config, { platform, isJsCode, preserveModules, chunkCssFi
251
253
  };
252
254
  },
253
255
  async renderChunk(_code, chunk, _opts) {
254
- if (isDom2Harmony) {
256
+ if (isDom2) {
255
257
  // 通过 generateBundle 实现
256
258
  return null;
257
259
  }
package/dist/workers.js CHANGED
@@ -13,6 +13,7 @@ const json_1 = require("./json");
13
13
  const uts_1 = require("./uts");
14
14
  const uni_modules_1 = require("./vite/plugins/uts/uni_modules");
15
15
  const resolve_1 = require("./resolve");
16
+ const dom2_1 = require("./dom2");
16
17
  const debugWorkers = (0, debug_1.default)('uni:workers');
17
18
  let workersRootDir = null;
18
19
  let workersRootDirs = [];
@@ -76,6 +77,7 @@ function uniWorkersPlugin() {
76
77
  const uniXKotlinCompiler = platform === 'app-android'
77
78
  ? (0, uts_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce({
78
79
  resolveWorkers,
80
+ sourceFileCallback: (0, dom2_1.initSourceFileCallback)(),
79
81
  })
80
82
  : null;
81
83
  const uniXSwiftCompiler = platform === 'app-ios'
package/dist/x.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ type AppXPlatform = typeof process.env.UNI_UTS_PLATFORM;
2
+ export declare function isUniAppX(): boolean;
3
+ export declare function isUniAppXAndroid(platform?: AppXPlatform): boolean;
4
+ export declare function isUniAppXIOS(platform?: AppXPlatform): boolean;
5
+ export declare function isUniAppXVapor(): boolean;
6
+ export declare function isUniAppXAndroidVapor(platform?: AppXPlatform): boolean;
7
+ export declare function isUniAppXJsEngine(): boolean;
8
+ export declare function isUniAppXAndroidJsEngine(platform?: AppXPlatform): boolean;
9
+ export declare function isUniAppXAndroidNative(platform?: AppXPlatform): boolean;
10
+ export {};
package/dist/x.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUniAppXAndroidNative = exports.isUniAppXAndroidJsEngine = exports.isUniAppXJsEngine = exports.isUniAppXAndroidVapor = exports.isUniAppXVapor = exports.isUniAppXIOS = exports.isUniAppXAndroid = exports.isUniAppX = void 0;
4
+ function isUniAppX() {
5
+ return process.env.UNI_APP_X === 'true';
6
+ }
7
+ exports.isUniAppX = isUniAppX;
8
+ function isUniAppXAndroid(platform = process.env.UNI_UTS_PLATFORM) {
9
+ return isUniAppX() && platform === 'app-android';
10
+ }
11
+ exports.isUniAppXAndroid = isUniAppXAndroid;
12
+ function isUniAppXIOS(platform = process.env.UNI_UTS_PLATFORM) {
13
+ return isUniAppX() && platform === 'app-ios';
14
+ }
15
+ exports.isUniAppXIOS = isUniAppXIOS;
16
+ function isUniAppXVapor() {
17
+ return isUniAppX() && process.env.UNI_APP_X_DOM2 === 'true';
18
+ }
19
+ exports.isUniAppXVapor = isUniAppXVapor;
20
+ function isUniAppXAndroidVapor(platform = process.env.UNI_UTS_PLATFORM) {
21
+ return isUniAppXAndroid(platform) && process.env.UNI_APP_X_DOM2 === 'true';
22
+ }
23
+ exports.isUniAppXAndroidVapor = isUniAppXAndroidVapor;
24
+ function isUniAppXJsEngine() {
25
+ return isUniAppX() && process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js';
26
+ }
27
+ exports.isUniAppXJsEngine = isUniAppXJsEngine;
28
+ function isUniAppXAndroidJsEngine(platform = process.env.UNI_UTS_PLATFORM) {
29
+ return (isUniAppXAndroid(platform) &&
30
+ process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js');
31
+ }
32
+ exports.isUniAppXAndroidJsEngine = isUniAppXAndroidJsEngine;
33
+ function isUniAppXAndroidNative(platform = process.env.UNI_UTS_PLATFORM) {
34
+ return (isUniAppXAndroid(platform) &&
35
+ // 非 Vapor 或者 Vapor 但使用 native 引擎
36
+ (process.env.UNI_APP_X_DOM2 !== 'true' ||
37
+ process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'native'));
38
+ }
39
+ exports.isUniAppXAndroidNative = isUniAppXAndroidNative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-5000420260318001",
3
+ "version": "3.0.0-5000520260324002",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -69,9 +69,9 @@
69
69
  "unimport": "4.1.1",
70
70
  "unplugin-auto-import": "19.1.0",
71
71
  "xregexp": "5.1.2",
72
- "@dcloudio/uni-i18n": "3.0.0-5000420260318001",
73
- "@dcloudio/uni-nvue-styler": "3.0.0-5000420260318001",
74
- "@dcloudio/uni-shared": "3.0.0-5000420260318001"
72
+ "@dcloudio/uni-shared": "3.0.0-5000520260324002",
73
+ "@dcloudio/uni-nvue-styler": "3.0.0-5000520260324002",
74
+ "@dcloudio/uni-i18n": "3.0.0-5000520260324002"
75
75
  },
76
76
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
77
77
  "devDependencies": {
@@ -91,6 +91,6 @@
91
91
  "code-frame": "link:@types/@babel/code-frame",
92
92
  "postcss": "8.4.45",
93
93
  "vue": "3.4.21",
94
- "@dcloudio/uni-uts-v1": "3.0.0-5000420260318001"
94
+ "@dcloudio/uni-uts-v1": "3.0.0-5000520260324002"
95
95
  }
96
96
  }