@dcloudio/uni-cli-shared 3.0.0-3060520221121001 → 3.0.0-3061420221215001

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 (68) hide show
  1. package/dist/checkUpdate.js +1 -0
  2. package/dist/constants.d.ts +1 -0
  3. package/dist/constants.js +2 -1
  4. package/dist/env/define.d.ts +1 -0
  5. package/dist/env/define.js +2 -0
  6. package/dist/esbuild.d.ts +1 -1
  7. package/dist/filter.d.ts +1 -1
  8. package/dist/hbx/alias.js +19 -3
  9. package/dist/hbx/env.d.ts +1 -0
  10. package/dist/hbx/env.js +32 -2
  11. package/dist/hbx/log.js +37 -7
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +4 -1
  14. package/dist/json/app/manifest/checksystemwebview.js +8 -3
  15. package/dist/json/app/manifest/index.js +6 -1
  16. package/dist/json/app/manifest/nvue.d.ts +1 -1
  17. package/dist/json/app/manifest/plus.js +8 -0
  18. package/dist/json/app/manifest/statusbar.js +5 -3
  19. package/dist/json/app/manifest/tabBar.js +1 -7
  20. package/dist/json/app/pages/uniConfig.js +4 -0
  21. package/dist/json/index.d.ts +1 -0
  22. package/dist/json/index.js +1 -0
  23. package/dist/json/manifest.d.ts +1 -0
  24. package/dist/json/manifest.js +11 -4
  25. package/dist/json/mp/jsonFile.d.ts +1 -1
  26. package/dist/json/mp/jsonFile.js +11 -2
  27. package/dist/json/mp/pages.js +17 -6
  28. package/dist/json/mp/types.d.ts +3 -2
  29. package/dist/json/pages.d.ts +1 -0
  30. package/dist/json/pages.js +33 -21
  31. package/dist/json/theme.d.ts +4 -0
  32. package/dist/json/theme.js +37 -0
  33. package/dist/logs/index.d.ts +1 -1
  34. package/dist/messages/en.d.ts +5 -0
  35. package/dist/messages/en.js +5 -0
  36. package/dist/messages/index.d.ts +10 -0
  37. package/dist/messages/zh_CN.d.ts +5 -0
  38. package/dist/messages/zh_CN.js +5 -0
  39. package/dist/mp/index.d.ts +1 -1
  40. package/dist/mp/index.js +2 -1
  41. package/dist/mp/plugin.d.ts +1 -0
  42. package/dist/mp/plugin.js +29 -1
  43. package/dist/mp/template.d.ts +12 -3
  44. package/dist/mp/usingComponents.d.ts +2 -1
  45. package/dist/mp/usingComponents.js +5 -1
  46. package/dist/platform.d.ts +1 -0
  47. package/dist/platform.js +5 -1
  48. package/dist/postcss/plugins/uniapp.js +14 -0
  49. package/dist/resolve.d.ts +0 -9
  50. package/dist/resolve.js +7 -72
  51. package/dist/uni_modules.d.ts +35 -0
  52. package/dist/uni_modules.js +104 -0
  53. package/dist/utils.d.ts +3 -1
  54. package/dist/utils.js +23 -3
  55. package/dist/uts.d.ts +10 -0
  56. package/dist/uts.js +101 -0
  57. package/dist/vite/features.d.ts +1 -1
  58. package/dist/vite/plugins/copy.d.ts +1 -1
  59. package/dist/vite/plugins/inject.d.ts +1 -1
  60. package/dist/vite/plugins/inject.js +1 -1
  61. package/dist/vite/plugins/vitejs/plugins/asset.js +16 -3
  62. package/dist/vite/plugins/vitejs/plugins/css.js +12 -7
  63. package/dist/vite/plugins/vitejs/utils.js +1 -1
  64. package/dist/vite/utils/plugin.d.ts +1 -1
  65. package/dist/vite/utils/url.d.ts +3 -0
  66. package/dist/vite/utils/url.js +5 -3
  67. package/dist/watcher.d.ts +1 -1
  68. package/package.json +18 -17
@@ -157,6 +157,7 @@ function getMac() {
157
157
  else if (
158
158
  // Node >= v18
159
159
  typeof item.family === 'number' &&
160
+ // @ts-ignore
160
161
  (item.family === 4 || item.family === 6)) {
161
162
  mac = item.mac;
162
163
  break;
@@ -27,3 +27,4 @@ export declare const BASE_COMPONENTS_STYLE_PATH = "@dcloudio/uni-components/styl
27
27
  export declare const COMMON_EXCLUDE: RegExp[];
28
28
  export declare const KNOWN_ASSET_TYPES: string[];
29
29
  export declare const DEFAULT_ASSETS_RE: RegExp;
30
+ export declare const TEXT_STYLE: string[];
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.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_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = 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.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = 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_JS = exports.PAGES_JSON_JS = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = 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'];
6
6
  exports.EXTNAME_TS = ['.ts', '.tsx'];
@@ -77,3 +77,4 @@ exports.KNOWN_ASSET_TYPES = [
77
77
  'txt',
78
78
  ];
79
79
  exports.DEFAULT_ASSETS_RE = new RegExp(`\\.(` + exports.KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
80
+ exports.TEXT_STYLE = ['black', 'white'];
@@ -15,4 +15,5 @@ export declare function initDefine(stringifyBoolean?: boolean): {
15
15
  'process.env.UNI_CLOUD_PROVIDER': string;
16
16
  'process.env.UNICLOUD_DEBUG': string;
17
17
  'process.env.VUE_APP_PLATFORM': string;
18
+ 'process.env.VUE_APP_DARK_MODE': string;
18
19
  };
@@ -5,6 +5,7 @@ const env_1 = require("../hbx/env");
5
5
  const json_1 = require("../json");
6
6
  function initDefine(stringifyBoolean = false) {
7
7
  const manifestJson = (0, json_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
8
+ const platformManifestJson = (0, json_1.getPlatformManifestJsonOnce)();
8
9
  const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
9
10
  const isDebug = !!manifestJson.debug;
10
11
  return {
@@ -30,6 +31,7 @@ function initDefine(stringifyBoolean = false) {
30
31
  'process.env.UNICLOUD_DEBUG': JSON.stringify(process.env.UNICLOUD_DEBUG || ''),
31
32
  // 兼容旧版本
32
33
  'process.env.VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM || ''),
34
+ 'process.env.VUE_APP_DARK_MODE': JSON.stringify(platformManifestJson.darkmode || false),
33
35
  };
34
36
  }
35
37
  exports.initDefine = initDefine;
package/dist/esbuild.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { BuildOptions } from 'esbuild';
1
+ import type { BuildOptions } from 'esbuild';
2
2
  export declare function transformWithEsbuild(code: string, filename: string, options: BuildOptions): Promise<import("esbuild").BuildResult>;
3
3
  export declare function esbuild(options: BuildOptions): Promise<import("esbuild").BuildResult>;
package/dist/filter.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export declare function isWxs(id: string): boolean;
2
2
  export declare function isSjs(id: string): boolean;
3
3
  export declare function isRenderjs(id: string): boolean;
4
- declare type FilterType = 'wxs' | 'renderjs' | 'sjs';
4
+ type FilterType = 'wxs' | 'renderjs' | 'sjs';
5
5
  export declare function parseRenderjs(id: string): {
6
6
  type: FilterType;
7
7
  name: string;
package/dist/hbx/alias.js CHANGED
@@ -6,6 +6,7 @@ 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"));
9
10
  const env_1 = require("./env");
10
11
  const hbxPlugins = {
11
12
  // typescript: 'compile-typescript/node_modules/typescript',
@@ -16,15 +17,15 @@ const hbxPlugins = {
16
17
  };
17
18
  function initModuleAlias() {
18
19
  const compilerSfcPath = require.resolve('@vue/compiler-sfc');
19
- const serverRendererPath = require.resolve('@vue/server-renderer');
20
+ // const serverRendererPath = require.resolve('@vue/server-renderer')
20
21
  module_alias_1.default.addAliases({
21
22
  '@vue/shared': require.resolve('@vue/shared'),
22
23
  '@vue/shared/dist/shared.esm-bundler.js': require.resolve('@vue/shared/dist/shared.esm-bundler.js'),
23
24
  '@vue/compiler-dom': require.resolve('@vue/compiler-dom'),
24
25
  '@vue/compiler-sfc': compilerSfcPath,
25
- '@vue/server-renderer': serverRendererPath,
26
+ // '@vue/server-renderer': serverRendererPath,
26
27
  'vue/compiler-sfc': compilerSfcPath,
27
- 'vue/server-renderer': serverRendererPath,
28
+ // 'vue/server-renderer': serverRendererPath,
28
29
  });
29
30
  if (process.env.VITEST) {
30
31
  module_alias_1.default.addAliases({
@@ -32,9 +33,18 @@ function initModuleAlias() {
32
33
  });
33
34
  }
34
35
  if ((0, env_1.isInHBuilderX)()) {
36
+ // 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
35
37
  Object.keys(hbxPlugins).forEach((name) => {
36
38
  module_alias_1.default.addAlias(name, path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[name]));
37
39
  });
40
+ // https://github.com/vitejs/vite/blob/892916d040a035edde1add93c192e0b0c5c9dd86/packages/vite/src/node/plugins/css.ts#L1481
41
+ const oldSync = resolve_1.default.sync;
42
+ resolve_1.default.sync = (id, opts) => {
43
+ if (hbxPlugins[id]) {
44
+ return path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[id]);
45
+ }
46
+ return oldSync(id, opts);
47
+ };
38
48
  }
39
49
  }
40
50
  exports.initModuleAlias = initModuleAlias;
@@ -48,6 +58,7 @@ function installHBuilderXPlugin(plugin) {
48
58
  return console.error(`%HXRunUniAPPPluginName%${plugin}%HXRunUniAPPPluginName%`);
49
59
  }
50
60
  exports.installHBuilderXPlugin = installHBuilderXPlugin;
61
+ const installPreprocessorTips = {};
51
62
  exports.moduleAliasFormatter = {
52
63
  test(msg) {
53
64
  return msg.includes('Preprocessor dependency');
@@ -68,6 +79,11 @@ exports.moduleAliasFormatter = {
68
79
  preprocessor = 'compile-stylus';
69
80
  }
70
81
  if (lang) {
82
+ // 仅提醒一次
83
+ if (installPreprocessorTips[lang]) {
84
+ return '';
85
+ }
86
+ installPreprocessorTips[lang] = true;
71
87
  installHBuilderXPlugin(preprocessor);
72
88
  return formatInstallHBuilderXPluginTips(lang, preprocessor);
73
89
  }
package/dist/hbx/env.d.ts CHANGED
@@ -4,3 +4,4 @@ export declare const runByHBuilderX: () => boolean;
4
4
  * 增加 node_modules
5
5
  */
6
6
  export declare function initModulePaths(): void;
7
+ export declare function fixBinaryPath(): void;
package/dist/hbx/env.js CHANGED
@@ -3,10 +3,12 @@ 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.initModulePaths = exports.runByHBuilderX = exports.isInHBuilderX = void 0;
6
+ exports.fixBinaryPath = exports.initModulePaths = exports.runByHBuilderX = exports.isInHBuilderX = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const module_1 = __importDefault(require("module"));
9
9
  const uni_shared_1 = require("@dcloudio/uni-shared");
10
+ const resolve_1 = require("../resolve");
11
+ const utils_1 = require("../utils");
10
12
  exports.isInHBuilderX = (0, uni_shared_1.once)(() => {
11
13
  try {
12
14
  const { name } = require(path_1.default.resolve(process.cwd(), '../about/package.json'));
@@ -21,7 +23,8 @@ exports.isInHBuilderX = (0, uni_shared_1.once)(() => {
21
23
  return false;
22
24
  });
23
25
  exports.runByHBuilderX = (0, uni_shared_1.once)(() => {
24
- return !!process.env.UNI_HBUILDERX_PLUGINS;
26
+ return (!!process.env.UNI_HBUILDERX_PLUGINS &&
27
+ (!!process.env.RUN_BY_HBUILDERX || !!process.env.HX_Version));
25
28
  });
26
29
  /**
27
30
  * 增加 node_modules
@@ -42,3 +45,30 @@ function initModulePaths() {
42
45
  };
43
46
  }
44
47
  exports.initModulePaths = initModulePaths;
48
+ function resolveEsbuildModule(name) {
49
+ try {
50
+ return path_1.default.dirname(require.resolve(name + '/package.json', {
51
+ paths: [path_1.default.dirname((0, resolve_1.resolveBuiltIn)('esbuild/package.json'))],
52
+ }));
53
+ }
54
+ catch (e) { }
55
+ return '';
56
+ }
57
+ function fixBinaryPath() {
58
+ // cli 工程在 HBuilderX 中运行
59
+ if (!(0, exports.isInHBuilderX)() && (0, exports.runByHBuilderX)()) {
60
+ if (utils_1.isWindows) {
61
+ const win64 = resolveEsbuildModule('esbuild-windows-64');
62
+ if (win64) {
63
+ process.env.ESBUILD_BINARY_PATH = path_1.default.join(win64, 'esbuild.exe');
64
+ }
65
+ }
66
+ else {
67
+ const arm64 = resolveEsbuildModule('esbuild-darwin-arm64');
68
+ if (arm64) {
69
+ process.env.ESBUILD_BINARY_PATH = path_1.default.join(arm64, 'bin/esbuild');
70
+ }
71
+ }
72
+ }
73
+ }
74
+ exports.fixBinaryPath = fixBinaryPath;
package/dist/hbx/log.js CHANGED
@@ -12,11 +12,38 @@ const utils_1 = require("../utils");
12
12
  const constants_1 = require("../constants");
13
13
  const ast_1 = require("../vite/utils/ast");
14
14
  const utils_2 = require("../vite/plugins/vitejs/utils");
15
- const SIGNAL_H5_LOCAL = ' > Local:';
16
- const SIGNAL_H5_NETWORK = ' > Network:';
15
+ const SIGNAL_H5_LOCAL = ' ➜ Local:';
16
+ const SIGNAL_H5_NETWORK = ' ➜ Network:';
17
17
  const networkLogs = [];
18
+ const ZERO_WIDTH_CHAR = {
19
+ NOTE: '',
20
+ WARNING: '\u200B',
21
+ ERROR: '\u200C',
22
+ backup0: '\u200D',
23
+ backup1: '\u200E',
24
+ backup2: '\u200F',
25
+ backup3: '\uFEFF',
26
+ };
27
+ function overridedConsole(name, oldFn, char) {
28
+ console[name] = function (...args) {
29
+ oldFn.apply(this, args.map((arg) => {
30
+ let item;
31
+ if (typeof arg !== 'object') {
32
+ item = `${char}${arg}${char}`;
33
+ }
34
+ else {
35
+ item = `${char}${JSON.stringify(arg)}${char}`;
36
+ }
37
+ return item;
38
+ }));
39
+ };
40
+ }
41
+ if (typeof console !== 'undefined') {
42
+ overridedConsole('warn', console.log, ZERO_WIDTH_CHAR.WARNING);
43
+ // overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
44
+ }
18
45
  function formatAtFilename(filename, line, column) {
19
- return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR, filename.split('?')[0])) +
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])) +
20
47
  ':' +
21
48
  (line || 1) +
22
49
  ':' +
@@ -29,19 +56,22 @@ exports.h5ServeFormatter = {
29
56
  },
30
57
  format(msg) {
31
58
  if (msg.includes(SIGNAL_H5_NETWORK)) {
32
- networkLogs.push(msg);
59
+ networkLogs.push(msg.replace('➜ ', '*'));
33
60
  process.nextTick(() => {
34
61
  if (networkLogs.length) {
35
- // 延迟打印所有 network,仅最后一个 network 替换 > 为 -,通知 hbx
62
+ // 延迟打印所有 network,仅最后一个 network 替换 ➜ 为 -,通知 hbx
36
63
  const len = networkLogs.length - 1;
37
- networkLogs[len] = networkLogs[len].replace('>', '-');
64
+ networkLogs[len] = networkLogs[len].replace('* Network', '- Network');
38
65
  console.log(networkLogs.join('\n'));
39
66
  networkLogs.length = 0;
40
67
  }
41
68
  });
42
69
  return '';
43
70
  }
44
- return msg.replace('>', '-');
71
+ if (msg.includes(SIGNAL_H5_LOCAL)) {
72
+ return msg.replace('➜ ', '-');
73
+ }
74
+ return msg.replace('➜ ', '*');
45
75
  },
46
76
  };
47
77
  const REMOVED_MSGS = [
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './env';
5
5
  export * from './hbx';
6
6
  export * from './ssr';
7
7
  export * from './vue';
8
+ export * from './uts';
8
9
  export * from './logs';
9
10
  export * from './i18n';
10
11
  export * from './deps';
@@ -20,6 +21,7 @@ export * from './esbuild';
20
21
  export * from './resolve';
21
22
  export * from './scripts';
22
23
  export * from './platform';
24
+ export { parseUniExtApis } from './uni_modules';
23
25
  export { M } from './messages';
24
26
  export * from './exports';
25
27
  export { checkUpdate } from './checkUpdate';
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 = void 0;
17
+ exports.checkUpdate = exports.M = exports.parseUniExtApis = void 0;
18
18
  __exportStar(require("./fs"), exports);
19
19
  __exportStar(require("./mp"), exports);
20
20
  __exportStar(require("./url"), exports);
@@ -22,6 +22,7 @@ __exportStar(require("./env"), exports);
22
22
  __exportStar(require("./hbx"), exports);
23
23
  __exportStar(require("./ssr"), exports);
24
24
  __exportStar(require("./vue"), exports);
25
+ __exportStar(require("./uts"), exports);
25
26
  __exportStar(require("./logs"), exports);
26
27
  __exportStar(require("./i18n"), exports);
27
28
  __exportStar(require("./deps"), exports);
@@ -37,6 +38,8 @@ __exportStar(require("./esbuild"), exports);
37
38
  __exportStar(require("./resolve"), exports);
38
39
  __exportStar(require("./scripts"), exports);
39
40
  __exportStar(require("./platform"), exports);
41
+ var uni_modules_1 = require("./uni_modules");
42
+ Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
40
43
  var messages_1 = require("./messages");
41
44
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
42
45
  __exportStar(require("./exports"), exports);
@@ -3,10 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initCheckSystemWebview = void 0;
4
4
  function initCheckSystemWebview(manifestJson) {
5
5
  // 检查Android系统webview版本 || 下载X5后启动
6
- let plusWebview = manifestJson.plus.webView;
7
- if (plusWebview) {
8
- manifestJson.plus['uni-app'].webView = plusWebview;
6
+ let plusWebView = manifestJson.plus.webView;
7
+ if (plusWebView) {
8
+ manifestJson.plus['uni-app'].webView = plusWebView;
9
9
  delete manifestJson.plus.webView;
10
10
  }
11
+ else {
12
+ manifestJson.plus['uni-app'].webView = {
13
+ minUserAgentVersion: '49.0',
14
+ };
15
+ }
11
16
  }
12
17
  exports.initCheckSystemWebview = initCheckSystemWebview;
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.getNVueFlexDirection = exports.getNVueStyleCompiler = exports.getNVueCompiler = exports.hasConfusionFile = exports.isConfusionFile = exports.APP_CONFUSION_FILENAME = exports.normalizeAppManifestJson = void 0;
18
+ const shared_1 = require("@vue/shared");
18
19
  const merge_1 = require("./merge");
19
20
  const defaultManifestJson_1 = require("./defaultManifestJson");
20
21
  const statusbar_1 = require("./statusbar");
@@ -29,8 +30,12 @@ const launchwebview_1 = require("./launchwebview");
29
30
  const checksystemwebview_1 = require("./checksystemwebview");
30
31
  const tabBar_1 = require("./tabBar");
31
32
  const i18n_1 = require("./i18n");
33
+ const theme_1 = require("../../theme");
32
34
  function normalizeAppManifestJson(userManifestJson, pagesJson) {
33
- const manifestJson = (0, merge_1.initRecursiveMerge)((0, statusbar_1.initAppStatusbar)((0, defaultManifestJson_1.initDefaultManifestJson)(), pagesJson), userManifestJson);
35
+ const manifestJson = (0, merge_1.initRecursiveMerge)((0, defaultManifestJson_1.initDefaultManifestJson)(), userManifestJson);
36
+ const { pages, globalStyle, tabBar } = (0, theme_1.initTheme)(manifestJson, pagesJson);
37
+ (0, shared_1.extend)(pagesJson, JSON.parse(JSON.stringify({ pages, globalStyle, tabBar })));
38
+ (0, statusbar_1.initAppStatusbar)(manifestJson, pagesJson);
34
39
  (0, arguments_1.initArguments)(manifestJson, pagesJson);
35
40
  (0, plus_1.initPlus)(manifestJson, pagesJson);
36
41
  (0, nvue_1.initNVue)(manifestJson, pagesJson);
@@ -1,4 +1,4 @@
1
1
  export declare function initNVue(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
2
2
  export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "weex" | "vue" | "vite";
3
3
  export declare function getNVueStyleCompiler(manifestJson: Record<string, any>): "uni-app" | "weex";
4
- export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "row" | "row-reverse" | "column" | "column-reverse";
4
+ export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "column" | "row" | "row-reverse" | "column-reverse";
@@ -35,6 +35,14 @@ function initPlus(manifestJson, pagesJson) {
35
35
  manifestJson.plus.distribute.plugins = distribute.sdkConfigs;
36
36
  delete manifestJson.plus.distribute.sdkConfigs;
37
37
  }
38
+ if (manifestJson.plus.darkmode) {
39
+ if (!(distribute.google || (distribute.google = {})).defaultNightMode) {
40
+ distribute.google.defaultNightMode = 'auto';
41
+ }
42
+ if (!(distribute.apple || (distribute.apple = {})).UIUserInterfaceStyle) {
43
+ distribute.apple.UIUserInterfaceStyle = 'Automatic';
44
+ }
45
+ }
38
46
  }
39
47
  // 屏幕启动方向
40
48
  if (manifestJson.plus.screenOrientation) {
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initAppStatusbar = void 0;
4
4
  function initAppStatusbar(manifestJson, pagesJson) {
5
- var _a;
6
- const { titleColor = '#000', backgroundColor = '#000000' } = ((_a = pagesJson.globalStyle) === null || _a === void 0 ? void 0 : _a.navigationBar) || {};
5
+ const titleColor = pagesJson.pages[0].style.navigationBar.titleColor ||
6
+ pagesJson.globalStyle.navigationBar.titleColor ||
7
+ '#ffffff';
8
+ const backgroundColor = pagesJson.globalStyle.navigationBar.backgroundColor || '#000000';
7
9
  manifestJson.plus.statusbar = {
8
10
  immersed: 'supportedDevice',
9
- style: titleColor === '#000' ? 'dark' : 'light',
11
+ style: titleColor === '#000000' ? 'dark' : 'light',
10
12
  background: backgroundColor,
11
13
  };
12
14
  return manifestJson;
@@ -2,19 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initTabBar = void 0;
4
4
  const uni_shared_1 = require("@dcloudio/uni-shared");
5
- const borderStyles = {
6
- black: 'rgba(0,0,0,0.4)',
7
- white: 'rgba(255,255,255,0.4)',
8
- };
9
5
  function initTabBar(entryPagePath, manifestJson, pagesJson) {
10
6
  var _a, _b;
11
7
  if (!((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length)) {
12
8
  return;
13
9
  }
14
10
  const tabBar = JSON.parse(JSON.stringify(pagesJson.tabBar));
15
- if (tabBar.borderStyle in borderStyles) {
16
- tabBar.borderStyle = borderStyles[tabBar.borderStyle];
17
- }
11
+ tabBar.borderStyle = (0, uni_shared_1.normalizeTabBarStyles)(tabBar.borderStyle);
18
12
  if (!tabBar.selectedColor) {
19
13
  tabBar.selectedColor = uni_shared_1.SELECTED_COLOR;
20
14
  }
@@ -10,9 +10,11 @@ const manifest_1 = require("../../manifest");
10
10
  const manifest_2 = require("../manifest");
11
11
  const arguments_1 = require("../manifest/arguments");
12
12
  const splashscreen_1 = require("../manifest/splashscreen");
13
+ const theme_1 = require("../../theme");
13
14
  function normalizeAppUniConfig(pagesJson, manifestJson) {
14
15
  var _a;
15
16
  const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
17
+ const platformConfig = (0, manifest_1.getPlatformManifestJsonOnce)();
16
18
  const config = {
17
19
  pages: [],
18
20
  globalStyle: pagesJson.globalStyle,
@@ -32,6 +34,8 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
32
34
  networkTimeout: (0, manifest_1.normalizeNetworkTimeout)(manifestJson.networkTimeout),
33
35
  tabBar: pagesJson.tabBar,
34
36
  locales: (0, i18n_1.initLocales)(path_1.default.join(process.env.UNI_INPUT_DIR, 'locale')),
37
+ darkmode: platformConfig.darkmode || false,
38
+ themeConfig: (0, theme_1.normalizeThemeConfigOnce)(platformConfig),
35
39
  };
36
40
  // TODO 待支持分包
37
41
  return JSON.stringify(config);
@@ -3,3 +3,4 @@ export * from './app';
3
3
  export * from './json';
4
4
  export * from './pages';
5
5
  export * from './manifest';
6
+ export * from './theme';
@@ -19,3 +19,4 @@ __exportStar(require("./app"), exports);
19
19
  __exportStar(require("./json"), exports);
20
20
  __exportStar(require("./pages"), exports);
21
21
  __exportStar(require("./manifest"), exports);
22
+ __exportStar(require("./theme"), exports);
@@ -29,4 +29,5 @@ export declare function getRouterOptions(manifestJson: Record<string, any>): {
29
29
  };
30
30
  export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
31
31
  export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
32
+ export declare function getPlatformManifestJsonOnce(): any;
32
33
  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.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
6
+ exports.getPlatformManifestJsonOnce = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = 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");
@@ -73,12 +73,12 @@ function isEnableUniPushV2(inputDir, platform) {
73
73
  }
74
74
  exports.isEnableUniPushV2 = isEnableUniPushV2;
75
75
  function isEnableSecureNetwork(inputDir, platform) {
76
- var _a, _b;
76
+ var _a, _b, _c, _d;
77
77
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
78
78
  if (platform === 'app') {
79
- return false; // 暂未支持app
79
+ return !!((_b = (_a = manifest['app-plus']) === null || _a === void 0 ? void 0 : _a.modules) === null || _b === void 0 ? void 0 : _b.SecureNetwork);
80
80
  }
81
- return ((_b = (_a = manifest[platform]) === null || _a === void 0 ? void 0 : _a.secureNetwork) === null || _b === void 0 ? void 0 : _b.enable) === true;
81
+ return ((_d = (_c = manifest[platform]) === null || _c === void 0 ? void 0 : _c.secureNetwork) === null || _d === void 0 ? void 0 : _d.enable) === true;
82
82
  }
83
83
  exports.isEnableSecureNetwork = isEnableSecureNetwork;
84
84
  function isUniPushOffline(inputDir) {
@@ -103,3 +103,10 @@ function getDevServerOptions(manifestJson) {
103
103
  return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.devServer);
104
104
  }
105
105
  exports.getDevServerOptions = getDevServerOptions;
106
+ function getPlatformManifestJsonOnce() {
107
+ const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
108
+ return !process.env.UNI_INPUT_DIR
109
+ ? {}
110
+ : (0, exports.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR)[platform] || {};
111
+ }
112
+ exports.getPlatformManifestJsonOnce = getPlatformManifestJsonOnce;
@@ -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';
20
+ [name: string]: 'plugin' | 'component' | 'dynamicLib';
21
21
  }
22
22
  export declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: {
23
23
  filename: string;
@@ -124,8 +124,14 @@ function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, })
124
124
  (0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(globalUsingComponents, componentsDir));
125
125
  }
126
126
  const jsonFile = findJsonFile((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(filename, inputDir)));
127
- if (jsonFile === null || jsonFile === void 0 ? void 0 : jsonFile.usingComponents) {
128
- (0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir));
127
+ if (jsonFile) {
128
+ if (jsonFile.usingComponents) {
129
+ (0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingComponents, componentsDir));
130
+ }
131
+ // mp-baidu 特有
132
+ if (jsonFile.usingSwanComponents) {
133
+ (0, shared_1.extend)(miniProgramComponents, findMiniProgramUsingComponent(jsonFile.usingSwanComponents, componentsDir));
134
+ }
129
135
  }
130
136
  return miniProgramComponents;
131
137
  }
@@ -136,6 +142,9 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
136
142
  if (path.includes('plugin://')) {
137
143
  res[name] = 'plugin';
138
144
  }
145
+ else if (path.includes('dynamicLib://')) {
146
+ res[name] = 'dynamicLib';
147
+ }
139
148
  else if (componentsDir && path.includes(componentsDir + '/')) {
140
149
  res[name] = 'component';
141
150
  }
@@ -12,6 +12,8 @@ const pages_1 = require("../pages");
12
12
  const utils_1 = require("./utils");
13
13
  const utils_2 = require("../../utils");
14
14
  const project_1 = require("./project");
15
+ const manifest_1 = require("../manifest");
16
+ const theme_1 = require("../theme");
15
17
  function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
16
18
  return parsePagesJson(jsonStr, platform, options);
17
19
  }
@@ -37,11 +39,11 @@ exports.mergeMiniProgramAppJson = mergeMiniProgramAppJson;
37
39
  function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
38
40
  subpackages: false,
39
41
  }) {
40
- const appJson = {
42
+ let appJson = {
41
43
  pages: [],
42
44
  };
43
- const pageJsons = {};
44
- const nvuePages = [];
45
+ let pageJsons = {};
46
+ let nvuePages = [];
45
47
  // preprocess
46
48
  const pagesJson = (0, json_1.parseJson)(jsonStr, true);
47
49
  if (!pagesJson) {
@@ -123,9 +125,18 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
123
125
  if (networkTimeout) {
124
126
  appJson.networkTimeout = networkTimeout;
125
127
  }
126
- if (darkmode) {
127
- appJson.darkmode = true;
128
- appJson.themeLocation = 'theme.json';
128
+ const manifestJson = (0, manifest_1.getPlatformManifestJsonOnce)();
129
+ if (!darkmode) {
130
+ const { pages, window, tabBar } = (0, theme_1.initTheme)(manifestJson, appJson);
131
+ (0, shared_1.extend)(appJson, JSON.parse(JSON.stringify({ pages, window, tabBar })));
132
+ delete appJson.darkmode;
133
+ delete appJson.themeLocation;
134
+ pageJsons = (0, theme_1.initTheme)(manifestJson, pageJsons);
135
+ }
136
+ else {
137
+ const themeLocation = manifestJson.themeLocation || 'theme.json';
138
+ if ((0, theme_1.hasThemeJson)(path_1.default.join(process.env.UNI_INPUT_DIR, themeLocation)))
139
+ appJson.themeLocation = themeLocation;
129
140
  }
130
141
  return {
131
142
  appJson,
@@ -15,12 +15,13 @@ interface ShareWindowOptions {
15
15
  onReachBottomDistance?: number;
16
16
  pageOrientation?: 'portrait' | 'landscape' | 'auto';
17
17
  }
18
- declare type Style = 'v2' | string;
19
- declare type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string;
18
+ type Style = 'v2' | string;
19
+ type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string;
20
20
  export interface PageWindowOptions extends ShareWindowOptions {
21
21
  component?: true;
22
22
  disableScroll?: boolean;
23
23
  usingComponents?: UsingComponents;
24
+ usingSwanComponents?: UsingComponents;
24
25
  initialRenderingCache?: 'static' | string;
25
26
  style?: Style;
26
27
  singlePage?: SinglePage;
@@ -1,4 +1,5 @@
1
1
  export declare function isUniPageFile(file: string, inputDir?: string): boolean;
2
+ export declare function isUniPageSetupAndTs(file: string): boolean;
2
3
  export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
3
4
  /**
4
5
  * 小程序平台慎用,因为该解析不支持 subpackages