@dcloudio/uni-cli-shared 3.0.0-3090820231124001 → 3.0.0-4000620240325001

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.
Files changed (72) hide show
  1. package/dist/constants.d.ts +1 -1
  2. package/dist/constants.js +4 -6
  3. package/dist/easycom.d.ts +5 -0
  4. package/dist/easycom.js +54 -3
  5. package/dist/env/define.d.ts +1 -0
  6. package/dist/env/define.js +1 -0
  7. package/dist/hbx/alias.js +33 -9
  8. package/dist/hbx/log.js +2 -1
  9. package/dist/json/app/pages/uniConfig.d.ts +5 -0
  10. package/dist/json/app/pages/uniConfig.js +2 -1
  11. package/dist/json/index.d.ts +1 -1
  12. package/dist/json/index.js +7 -3
  13. package/dist/json/json.js +5 -1
  14. package/dist/json/manifest.js +4 -0
  15. package/dist/json/mp/jsonFile.d.ts +1 -1
  16. package/dist/json/mp/jsonFile.js +6 -0
  17. package/dist/json/mp/pages.js +2 -2
  18. package/dist/json/pages.d.ts +1 -0
  19. package/dist/json/pages.js +70 -4
  20. package/dist/json/uni-x/index.d.ts +10 -0
  21. package/dist/json/uni-x/index.js +225 -0
  22. package/dist/json/uni-x/manifest.d.ts +2 -0
  23. package/dist/json/uni-x/manifest.js +21 -0
  24. package/dist/json/uni-x/uniConfig.d.ts +1 -0
  25. package/dist/json/uni-x/uniConfig.js +18 -0
  26. package/dist/logs/format.js +6 -0
  27. package/dist/messages/en.d.ts +1 -0
  28. package/dist/messages/en.js +1 -0
  29. package/dist/messages/index.d.ts +2 -0
  30. package/dist/messages/zh_CN.d.ts +1 -0
  31. package/dist/messages/zh_CN.js +1 -0
  32. package/dist/mp/template.d.ts +1 -1
  33. package/dist/postcss/plugins/uniapp.js +1 -1
  34. package/dist/preprocess/context.js +1 -1
  35. package/dist/preprocess/index.js +6 -0
  36. package/dist/uni_modules.d.ts +7 -2
  37. package/dist/uni_modules.js +26 -3
  38. package/dist/utils.d.ts +4 -2
  39. package/dist/utils.js +20 -1
  40. package/dist/uts.d.ts +3 -1
  41. package/dist/uts.js +43 -5
  42. package/dist/vite/autoImport.js +55 -2
  43. package/dist/vite/index.d.ts +1 -0
  44. package/dist/vite/index.js +21 -1
  45. package/dist/vite/plugins/easycom.d.ts +8 -0
  46. package/dist/vite/plugins/easycom.js +52 -0
  47. package/dist/vite/plugins/index.d.ts +4 -2
  48. package/dist/vite/plugins/index.js +5 -1
  49. package/dist/vite/plugins/inject.d.ts +1 -0
  50. package/dist/vite/plugins/inject.js +1 -1
  51. package/dist/vite/plugins/uts/ext-api.d.ts +12 -0
  52. package/dist/vite/plugins/uts/ext-api.js +81 -0
  53. package/dist/vite/plugins/uts/uni_modules.d.ts +7 -0
  54. package/dist/vite/plugins/uts/uni_modules.js +59 -9
  55. package/dist/vite/plugins/uts/uvue.js +11 -8
  56. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
  57. package/dist/vite/plugins/vitejs/plugins/asset.js +2 -2
  58. package/dist/vite/plugins/vitejs/plugins/css.d.ts +8 -1
  59. package/dist/vite/plugins/vitejs/plugins/css.js +78 -7
  60. package/dist/vite/plugins/vitejs/utils.d.ts +9 -1
  61. package/dist/vite/plugins/vitejs/utils.js +45 -14
  62. package/dist/vite/utils/plugin.d.ts +1 -1
  63. package/dist/vite/utils/utils.d.ts +5 -0
  64. package/dist/vite/utils/utils.js +40 -1
  65. package/dist/vue/transforms/index.d.ts +1 -0
  66. package/dist/vue/transforms/index.js +1 -0
  67. package/dist/vue/transforms/transformUTSComponent.d.ts +8 -0
  68. package/dist/vue/transforms/transformUTSComponent.js +22 -0
  69. package/lib/preprocess/lib/preprocess.js +92 -91
  70. package/package.json +17 -12
  71. package/dist/json/uniAppX.d.ts +0 -1
  72. package/dist/json/uniAppX.js +0 -79
@@ -1,6 +1,5 @@
1
1
  export declare const PUBLIC_DIR = "static";
2
2
  export declare const EXTNAME_JS: string[];
3
- export declare const X_EXTNAME_JS: string[];
4
3
  export declare const EXTNAME_TS: string[];
5
4
  export declare const EXTNAME_VUE: string[];
6
5
  export declare const X_EXTNAME_VUE: string[];
@@ -31,6 +30,7 @@ export declare const H5_API_STYLE_PATH = "@dcloudio/uni-h5/style/api/";
31
30
  export declare const H5_FRAMEWORK_STYLE_PATH = "@dcloudio/uni-h5/style/framework/";
32
31
  export declare const H5_COMPONENTS_STYLE_PATH = "@dcloudio/uni-h5/style/";
33
32
  export declare const BASE_COMPONENTS_STYLE_PATH = "@dcloudio/uni-components/style/";
33
+ export declare const X_BASE_COMPONENTS_STYLE_PATH = "@dcloudio/uni-components/style-x/";
34
34
  export declare const COMMON_EXCLUDE: RegExp[];
35
35
  export declare const KNOWN_ASSET_TYPES: string[];
36
36
  export declare const DEFAULT_ASSETS_RE: RegExp;
package/dist/constants.js CHANGED
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEXT_STYLE = exports.DEFAULT_ASSETS_RE = exports.KNOWN_ASSET_TYPES = exports.COMMON_EXCLUDE = 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.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.X_EXTNAME_JS = 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.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
- exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
6
- exports.X_EXTNAME_JS = ['.uts', ...exports.EXTNAME_JS];
5
+ exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx', '.uts'];
7
6
  exports.EXTNAME_TS = ['.ts', '.tsx'];
8
7
  exports.EXTNAME_VUE = ['.vue', '.nvue', '.uvue'];
9
8
  exports.X_EXTNAME_VUE = ['.uvue', '.vue'];
10
9
  exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.uvue', '.jsx', '.tsx'];
11
10
  exports.EXTNAME_VUE_RE = /\.(vue|nvue|uvue)$/;
12
- exports.EXTNAME_JS_RE = /\.(js|jsx|ts|tsx|mjs)$/;
11
+ exports.EXTNAME_JS_RE = /\.(js|jsx|ts|uts|tsx|mjs)$/;
13
12
  exports.EXTNAME_TS_RE = /\.tsx?$/;
14
13
  const COMMON_EXTENSIONS = [
15
14
  '.uts',
@@ -45,6 +44,7 @@ exports.H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/';
45
44
  exports.H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/';
46
45
  exports.H5_COMPONENTS_STYLE_PATH = '@dcloudio/uni-h5/style/';
47
46
  exports.BASE_COMPONENTS_STYLE_PATH = '@dcloudio/uni-components/style/';
47
+ exports.X_BASE_COMPONENTS_STYLE_PATH = '@dcloudio/uni-components/style-x/';
48
48
  exports.COMMON_EXCLUDE = [
49
49
  /\/pages\.json\.js$/,
50
50
  /\/manifest\.json\.js$/,
@@ -55,8 +55,6 @@ exports.COMMON_EXCLUDE = [
55
55
  /\/vue-i18n\//,
56
56
  /\/@dcloudio\/uni-h5-vue/,
57
57
  /\/@dcloudio\/uni-shared/,
58
- /\/@dcloudio\/uni-h5\/style/,
59
- /\/@dcloudio\/uni-components\/style/,
60
58
  ];
61
59
  exports.KNOWN_ASSET_TYPES = [
62
60
  // images
package/dist/easycom.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  interface EasycomOption {
2
+ isX?: boolean;
2
3
  dirs?: string[];
3
4
  rootDir: string;
4
5
  extensions: string[];
@@ -28,4 +29,8 @@ export declare function matchEasycom(tag: string): string | false | undefined;
28
29
  export declare function addImportDeclaration(importDeclarations: string[], local: string, source: string, imported?: string): string;
29
30
  export declare function genResolveEasycomCode(importDeclarations: string[], code: string, name: string): string;
30
31
  export declare const UNI_EASYCOM_EXCLUDE: RegExp[];
32
+ export declare function getUTSEasyComAutoImports(): Record<string, [[string, string]]>;
33
+ export declare function addUTSEasyComAutoImports(source: string, imports: [string, string]): void;
34
+ export declare function genUTSComponentPublicInstanceIdent(tagName: string): string;
35
+ export declare function genUTSComponentPublicInstanceImported(root: string, fileName: string): string;
31
36
  export {};
package/dist/easycom.js CHANGED
@@ -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.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
6
+ exports.genUTSComponentPublicInstanceImported = exports.genUTSComponentPublicInstanceIdent = exports.addUTSEasyComAutoImports = exports.getUTSEasyComAutoImports = exports.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const debug_1 = __importDefault(require("debug"));
@@ -31,6 +31,7 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
31
31
  // 初始化时,从once中读取缓存,refresh时,实时读取
32
32
  const { easycom } = pagesJson || (0, pages_1.parsePagesJson)(inputDir, platform, false);
33
33
  const easycomOptions = {
34
+ isX,
34
35
  dirs: easycom && easycom.autoscan === false
35
36
  ? [...dirs] // 禁止自动扫描
36
37
  : [
@@ -57,6 +58,10 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
57
58
  easycoms.push(item);
58
59
  }
59
60
  });
61
+ if (isX && globalThis.uts2jsSourceCodeMap) {
62
+ ;
63
+ globalThis.uts2jsSourceCodeMap.initUts2jsEasycom(easycoms);
64
+ }
60
65
  };
61
66
  initEasycom(options);
62
67
  initUTSEasycom();
@@ -96,11 +101,26 @@ function initUniModulesEasycomDirs(uniModulesDir) {
96
101
  })
97
102
  .filter(Boolean);
98
103
  }
99
- function initEasycom({ dirs, rootDir, custom, extensions }) {
104
+ function initEasycom({ isX, dirs, rootDir, custom, extensions, }) {
100
105
  clearEasycom();
106
+ rootDir = (0, utils_1.normalizePath)(rootDir);
101
107
  const easycomsObj = Object.create(null);
102
108
  if (dirs && dirs.length && rootDir) {
103
- (0, shared_1.extend)(easycomsObj, initAutoScanEasycoms(dirs, rootDir, extensions));
109
+ const autoEasyComObj = initAutoScanEasycoms(dirs, rootDir, extensions);
110
+ if (isX) {
111
+ Object.keys(autoEasyComObj).forEach((tagName) => {
112
+ let source = autoEasyComObj[tagName];
113
+ tagName = tagName.slice(1, -1);
114
+ if (path_1.default.isAbsolute(source) && source.startsWith(rootDir)) {
115
+ source = '@/' + (0, utils_1.normalizePath)(path_1.default.relative(rootDir, source));
116
+ }
117
+ addUTSEasyComAutoImports(source, [
118
+ genUTSComponentPublicInstanceImported(rootDir, source),
119
+ genUTSComponentPublicInstanceIdent(tagName),
120
+ ]);
121
+ });
122
+ }
123
+ (0, shared_1.extend)(easycomsObj, autoEasyComObj);
104
124
  }
105
125
  if (custom) {
106
126
  Object.keys(custom).forEach((name) => {
@@ -219,3 +239,34 @@ function genResolveEasycomCode(importDeclarations, code, name) {
219
239
  }
220
240
  exports.genResolveEasycomCode = genResolveEasycomCode;
221
241
  exports.UNI_EASYCOM_EXCLUDE = [/App.vue$/, /@dcloudio\/uni-h5/];
242
+ const utsEasyComAutoImports = {};
243
+ function getUTSEasyComAutoImports() {
244
+ return utsEasyComAutoImports;
245
+ }
246
+ exports.getUTSEasyComAutoImports = getUTSEasyComAutoImports;
247
+ function addUTSEasyComAutoImports(source, imports) {
248
+ if (!utsEasyComAutoImports[source]) {
249
+ utsEasyComAutoImports[source] = [imports];
250
+ }
251
+ else {
252
+ if (!utsEasyComAutoImports[source].find((item) => item[0] === imports[0])) {
253
+ utsEasyComAutoImports[source].push(imports);
254
+ }
255
+ }
256
+ }
257
+ exports.addUTSEasyComAutoImports = addUTSEasyComAutoImports;
258
+ function genUTSComponentPublicInstanceIdent(tagName) {
259
+ return (0, shared_1.capitalize)((0, shared_1.camelize)(tagName)) + 'ComponentPublicInstance';
260
+ }
261
+ exports.genUTSComponentPublicInstanceIdent = genUTSComponentPublicInstanceIdent;
262
+ function genUTSComponentPublicInstanceImported(root, fileName) {
263
+ root = (0, utils_1.normalizePath)(root);
264
+ if (path_1.default.isAbsolute(fileName) && fileName.startsWith(root)) {
265
+ fileName = (0, utils_1.normalizePath)(path_1.default.relative(root, fileName));
266
+ }
267
+ if (fileName.startsWith('@/')) {
268
+ return ((0, uts_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
269
+ }
270
+ return (0, uts_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
271
+ }
272
+ exports.genUTSComponentPublicInstanceImported = genUTSComponentPublicInstanceImported;
@@ -12,6 +12,7 @@ export declare function initDefine(stringifyBoolean?: boolean): {
12
12
  'process.env.UNI_COMPILER_VERSION': string;
13
13
  'process.env.RUN_BY_HBUILDERX': string | boolean;
14
14
  'process.env.UNI_AUTOMATOR_WS_ENDPOINT': string;
15
+ 'process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC': string;
15
16
  'process.env.UNI_CLOUD_PROVIDER': string;
16
17
  'process.env.UNICLOUD_DEBUG': string;
17
18
  'process.env.VUE_APP_PLATFORM': string;
@@ -27,6 +27,7 @@ function initDefine(stringifyBoolean = false) {
27
27
  ? JSON.stringify(isRunByHBuilderX)
28
28
  : isRunByHBuilderX,
29
29
  'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT || ''),
30
+ 'process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC': JSON.stringify(process.env.UNI_AUTOMATOR_APP_WEBVIEW_SRC || ''),
30
31
  'process.env.UNI_CLOUD_PROVIDER': JSON.stringify(process.env.UNI_CLOUD_PROVIDER || ''),
31
32
  'process.env.UNICLOUD_DEBUG': JSON.stringify(process.env.UNICLOUD_DEBUG || ''),
32
33
  // 兼容旧版本
package/dist/hbx/alias.js CHANGED
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.formatInstallHBuilderXPluginTips = exports.moduleAliasFormatter = exports.installHBuilderXPlugin = exports.initModuleAlias = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const module_alias_1 = __importDefault(require("module-alias"));
9
- const resolve_1 = __importDefault(require("resolve"));
10
9
  const env_1 = require("./env");
11
10
  const hbxPlugins = {
12
11
  // typescript: 'compile-typescript/node_modules/typescript',
@@ -38,14 +37,39 @@ function initModuleAlias() {
38
37
  Object.keys(hbxPlugins).forEach((name) => {
39
38
  module_alias_1.default.addAlias(name, path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[name]));
40
39
  });
41
- // https://github.com/vitejs/vite/blob/892916d040a035edde1add93c192e0b0c5c9dd86/packages/vite/src/node/plugins/css.ts#L1481
42
- const oldSync = resolve_1.default.sync;
43
- resolve_1.default.sync = (id, opts) => {
44
- if (hbxPlugins[id]) {
45
- return path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[id]);
46
- }
47
- return oldSync(id, opts);
48
- };
40
+ // web 平台用了 vite 内置 css 插件,该插件会加载预编译器如scss、less等,需要转向到 HBuilderX 的对应编译器插件
41
+ if (process.env.UNI_PLATFORM === 'h5' ||
42
+ process.env.UNI_PLATFORM === 'web') {
43
+ // https://github.com/vitejs/vite/blob/main/packages/vite/src/node/packages.ts#L92
44
+ // 拦截预编译器
45
+ const join = path_1.default.join;
46
+ path_1.default.join = function (...paths) {
47
+ if (paths.length === 4) {
48
+ // path.join(basedir, 'node_modules', pkgName, 'package.json')
49
+ // const basedir = paths[0]
50
+ const nodeModules = paths[1]; // = node_modules
51
+ const pkgName = paths[2];
52
+ const packageJson = paths[3]; // = package.json
53
+ if (nodeModules === 'node_modules' &&
54
+ packageJson === 'package.json' &&
55
+ hbxPlugins[pkgName]) {
56
+ return path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[pkgName], packageJson);
57
+ }
58
+ }
59
+ return join(...paths);
60
+ };
61
+ // https://github.com/vitejs/vite/blob/892916d040a035edde1add93c192e0b0c5c9dd86/packages/vite/src/node/plugins/css.ts#L1481
62
+ // const oldSync = resovle.sync
63
+ // resovle.sync = (id: string, opts?: SyncOpts) => {
64
+ // if ((hbxPlugins as any)[id]) {
65
+ // return path.resolve(
66
+ // process.env.UNI_HBUILDERX_PLUGINS,
67
+ // hbxPlugins[id as keyof typeof hbxPlugins]
68
+ // )
69
+ // }
70
+ // return oldSync(id, opts)
71
+ // }
72
+ }
49
73
  }
50
74
  }
51
75
  exports.initModuleAlias = initModuleAlias;
package/dist/hbx/log.js CHANGED
@@ -43,7 +43,8 @@ if (typeof console !== 'undefined') {
43
43
  // overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
44
44
  }
45
45
  function formatAtFilename(filename, line, column) {
46
- return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename.replace('\x00', '').split('?')[0])) +
46
+ const file = path_1.default.relative(process.env.UNI_INPUT_DIR, filename.replace('\x00', '').split('?')[0]);
47
+ return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(file === 'pages-json-uts' ? 'pages.json' : file) +
47
48
  ':' +
48
49
  (line || 1) +
49
50
  ':' +
@@ -1 +1,6 @@
1
1
  export declare function normalizeAppUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
2
+ export declare function parseEntryPagePath(pagesJson: UniApp.PagesJson): {
3
+ entryPagePath: string;
4
+ entryPageQuery: string;
5
+ realEntryPagePath: string;
6
+ };
@@ -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.normalizeAppUniConfig = void 0;
6
+ exports.parseEntryPagePath = exports.normalizeAppUniConfig = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const i18n_1 = require("../../../i18n");
9
9
  const manifest_1 = require("../../manifest");
@@ -70,3 +70,4 @@ function parseEntryPagePath(pagesJson) {
70
70
  }
71
71
  return res;
72
72
  }
73
+ exports.parseEntryPagePath = parseEntryPagePath;
@@ -4,4 +4,4 @@ export * from './json';
4
4
  export * from './pages';
5
5
  export * from './manifest';
6
6
  export * from './theme';
7
- export { normalizeUniAppXAppPagesJson } from './uniAppX';
7
+ export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, checkPagesJson, parseUniXFlexDirection, parseUniXSplashScreen, } from './uni-x';
@@ -14,12 +14,16 @@ 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.normalizeUniAppXAppPagesJson = void 0;
17
+ exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.checkPagesJson = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
18
18
  __exportStar(require("./mp"), exports);
19
19
  __exportStar(require("./app"), exports);
20
20
  __exportStar(require("./json"), exports);
21
21
  __exportStar(require("./pages"), exports);
22
22
  __exportStar(require("./manifest"), exports);
23
23
  __exportStar(require("./theme"), exports);
24
- var uniAppX_1 = require("./uniAppX");
25
- Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uniAppX_1.normalizeUniAppXAppPagesJson; } });
24
+ var uni_x_1 = require("./uni-x");
25
+ Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppPagesJson; } });
26
+ Object.defineProperty(exports, "normalizeUniAppXAppConfig", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppConfig; } });
27
+ Object.defineProperty(exports, "checkPagesJson", { enumerable: true, get: function () { return uni_x_1.checkPagesJson; } });
28
+ Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return uni_x_1.parseUniXFlexDirection; } });
29
+ Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return uni_x_1.parseUniXSplashScreen; } });
package/dist/json/json.js CHANGED
@@ -4,6 +4,10 @@ exports.parseJson = void 0;
4
4
  const jsonc_parser_1 = require("jsonc-parser");
5
5
  const preprocess_1 = require("../preprocess");
6
6
  function parseJson(jsonStr, shouldPre = false) {
7
- return (0, jsonc_parser_1.parse)(shouldPre ? (0, preprocess_1.preJson)(jsonStr) : jsonStr);
7
+ return (0, jsonc_parser_1.parse)(shouldPre
8
+ ? process.env.UNI_APP_X === 'true'
9
+ ? (0, preprocess_1.preUVueJson)(jsonStr)
10
+ : (0, preprocess_1.preJson)(jsonStr)
11
+ : jsonStr);
8
12
  }
9
13
  exports.parseJson = parseJson;
@@ -97,6 +97,10 @@ function getRouterOptions(manifestJson) {
97
97
  }
98
98
  exports.getRouterOptions = getRouterOptions;
99
99
  function isEnableTreeShaking(manifestJson) {
100
+ // 自动化测试时,一定不摇树
101
+ if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
102
+ return false;
103
+ }
100
104
  return manifestJson.h5?.optimization?.treeShaking?.enable !== false;
101
105
  }
102
106
  exports.isEnableTreeShaking = isEnableTreeShaking;
@@ -17,7 +17,7 @@ export declare function isMiniProgramUsingComponent(name: string, options: {
17
17
  componentsDir?: string;
18
18
  }): boolean;
19
19
  interface MiniProgramComponents {
20
- [name: string]: 'plugin' | 'component' | 'dynamicLib';
20
+ [name: string]: 'plugin' | 'component' | 'dynamicLib' | 'ext';
21
21
  }
22
22
  export declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: {
23
23
  filename: string;
@@ -141,11 +141,17 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
141
141
  return Object.keys(usingComponents).reduce((res, name) => {
142
142
  const path = usingComponents[name];
143
143
  if (path.includes('plugin://')) {
144
+ // mp-weixin & mp-alipay
144
145
  res[name] = 'plugin';
145
146
  }
146
147
  else if (path.includes('dynamicLib://')) {
148
+ // mp-baidu
147
149
  res[name] = 'dynamicLib';
148
150
  }
151
+ else if (path.includes('ext://')) {
152
+ // mp-toutiao
153
+ res[name] = 'ext';
154
+ }
149
155
  else if (componentsDir && path.includes(componentsDir + '/')) {
150
156
  res[name] = 'component';
151
157
  }
@@ -24,9 +24,9 @@ const NON_APP_JSON_KEYS = [
24
24
  'usingComponents',
25
25
  'optimization',
26
26
  'scopedSlotsCompiler',
27
- 'usingComponents',
28
27
  'uniStatistics',
29
28
  'mergeVirtualHostAttributes',
29
+ 'styleIsolation',
30
30
  ];
31
31
  function mergeMiniProgramAppJson(appJson, platformJson = {}) {
32
32
  Object.keys(platformJson).forEach((name) => {
@@ -114,7 +114,7 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
114
114
  appJson.tabBar = tabBar;
115
115
  }
116
116
  }
117
- ;
117
+ (0, pages_1.filterPlatformPages)(platform, pagesJson);
118
118
  ['preloadRule', 'workers', 'plugins', 'entryPagePath'].forEach((name) => {
119
119
  if ((0, shared_1.hasOwn)(pagesJson, name)) {
120
120
  appJson[name] = pagesJson[name];
@@ -28,4 +28,5 @@ export declare function removePlatformStyle(pageStyle: Record<string, any>): Rec
28
28
  export declare function normalizePagesRoute(pagesJson: UniApp.PagesJson): UniApp.UniRoute[];
29
29
  declare function parseSubpackagesRoot(inputDir: string, platform: UniApp.PLATFORM): string[];
30
30
  export declare const parseSubpackagesRootOnce: typeof parseSubpackagesRoot;
31
+ export declare function filterPlatformPages(platform: UniApp.PLATFORM, pagesJson: UniApp.PagesJson): void;
31
32
  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.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
6
+ exports.filterPlatformPages = exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const shared_1 = require("@vue/shared");
@@ -108,6 +108,8 @@ function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages:
108
108
  delete pagesJson.tabBar;
109
109
  }
110
110
  }
111
+ // 过滤平台page
112
+ filterPlatformPages(platform, pagesJson);
111
113
  // 缓存页面列表
112
114
  pagesCacheSet.clear();
113
115
  pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
@@ -122,16 +124,19 @@ exports.normalizePagesJson = normalizePagesJson;
122
124
  function validatePages(pagesJson, jsonStr) {
123
125
  if (!(0, shared_1.isArray)(pagesJson.pages)) {
124
126
  pagesJson.pages = [];
125
- throw new Error(`[uni-app] Error: pages.json->pages parse failed.`);
127
+ console.error(`[uni-app] Error: pages.json->pages parse failed.`);
128
+ process.exit(0);
126
129
  }
127
130
  else if (!pagesJson.pages.length) {
128
- throw new Error(`[uni-app] Error: pages.json->pages must contain at least 1 page.`);
131
+ console.error(`[uni-app] Error: pages.json->pages must contain at least 1 page.`);
132
+ process.exit(0);
129
133
  }
130
134
  else {
131
135
  const pages = [];
132
136
  pagesJson.pages.forEach((page) => {
133
137
  if (pages.indexOf(page.path) !== -1) {
134
- throw new Error(`[uni-app] Error: pages.json->${page.path} duplication.`);
138
+ console.error(`[uni-app] Error: pages.json->${page.path} duplication.`);
139
+ process.exit(0);
135
140
  }
136
141
  pages.push(page.path);
137
142
  });
@@ -441,3 +446,64 @@ function parseSubpackagesRoot(inputDir, platform) {
441
446
  return roots;
442
447
  }
443
448
  exports.parseSubpackagesRootOnce = (0, uni_shared_1.once)(parseSubpackagesRoot);
449
+ let isInvalidPagesWarned = false;
450
+ function filterPlatformPages(platform, pagesJson) {
451
+ const invalidPages = [];
452
+ pagesJson.pages = pagesJson.pages.filter(({ path }) => {
453
+ if (isPlatformPage(platform, path)) {
454
+ return true;
455
+ }
456
+ invalidPages.push(path);
457
+ return false;
458
+ });
459
+ if (pagesJson.subPackages) {
460
+ pagesJson.subPackages.forEach((subPackage) => {
461
+ if (subPackage.pages) {
462
+ subPackage.pages = subPackage.pages.filter(({ path }) => {
463
+ const pagePath = subPackage.root + '/' + path;
464
+ if (isPlatformPage(platform, pagePath)) {
465
+ return true;
466
+ }
467
+ invalidPages.push(pagePath);
468
+ return false;
469
+ });
470
+ }
471
+ });
472
+ }
473
+ if (pagesJson.subpackages) {
474
+ pagesJson.subpackages.forEach((subPackage) => {
475
+ if (subPackage.pages) {
476
+ subPackage.pages = subPackage.pages.filter(({ path }) => {
477
+ const pagePath = subPackage.root + '/' + path;
478
+ if (isPlatformPage(platform, pagePath)) {
479
+ return true;
480
+ }
481
+ invalidPages.push(pagePath);
482
+ return false;
483
+ });
484
+ }
485
+ });
486
+ }
487
+ // 目前仅启动的时候警告一次,该方法可能会被调用很多次
488
+ if (invalidPages.length) {
489
+ if (!isInvalidPagesWarned) {
490
+ isInvalidPagesWarned = true;
491
+ console.log(`已忽略页面:${invalidPages.join('、')}。详见:https://uniapp.dcloud.net.cn/tutorial/platform.html#platforms`);
492
+ }
493
+ }
494
+ }
495
+ exports.filterPlatformPages = filterPlatformPages;
496
+ function isPlatformPage(platform, pagePath) {
497
+ if (pagePath.startsWith('platforms/')) {
498
+ if (platform === 'app' || platform === 'app-plus') {
499
+ return (pagePath.startsWith('platforms/app/') ||
500
+ pagePath.startsWith('platforms/app-plus/'));
501
+ }
502
+ else if (platform === 'h5' || platform === 'web') {
503
+ return (pagePath.startsWith('platforms/h5/') ||
504
+ pagePath.startsWith('platforms/web/'));
505
+ }
506
+ return pagePath.startsWith('platforms/' + platform + '/');
507
+ }
508
+ return true;
509
+ }
@@ -0,0 +1,10 @@
1
+ export { parseUniXFlexDirection, parseUniXSplashScreen } from './manifest';
2
+ export declare function checkPagesJson(jsonStr: string, inputDir: string): boolean;
3
+ export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
4
+ /**
5
+ * TODO 应该闭包,通过globalThis赋值?
6
+ * @param pagesJson
7
+ * @param manifestJson
8
+ * @returns
9
+ */
10
+ export declare function normalizeUniAppXAppConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;