@dcloudio/uni-cli-shared 3.0.0-alpha-3060820221027001 → 3.0.0-alpha-3060820221027003

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.
@@ -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;
@@ -14,7 +14,7 @@ const theme_1 = require("../../theme");
14
14
  function normalizeAppUniConfig(pagesJson, manifestJson) {
15
15
  var _a;
16
16
  const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
17
- const platformConfig = manifestJson[process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM] || {};
17
+ const platformConfig = (0, manifest_1.getPlatformManifestJsonOnce)();
18
18
  const config = {
19
19
  pages: [],
20
20
  globalStyle: pagesJson.globalStyle,
@@ -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");
@@ -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;
@@ -111,9 +111,11 @@ function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages:
111
111
  // 缓存页面列表
112
112
  pagesCacheSet.clear();
113
113
  pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
114
- return process.env.UNI_PLATFORM === 'app' || !process.env.UNI_INPUT_DIR
115
- ? pagesJson
116
- : (0, theme_1.initTheme)((0, manifest_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR), pagesJson);
114
+ const manifestJsonPlatform = (0, manifest_1.getPlatformManifestJsonOnce)();
115
+ if (!manifestJsonPlatform.darkmode) {
116
+ pagesJson = (0, theme_1.initTheme)(manifestJsonPlatform, pagesJson);
117
+ }
118
+ return pagesJson;
117
119
  }
118
120
  exports.normalizePagesJson = normalizePagesJson;
119
121
  function validatePages(pagesJson, jsonStr) {
@@ -289,7 +291,7 @@ function normalizeNavigationBar(pageStyle) {
289
291
  navigationBar.shadowColorType = pageStyle.navigationBarShadow.colorType;
290
292
  delete pageStyle.navigationBarShadow;
291
293
  }
292
- const parsedNavigationBar = (0, theme_1.initTheme)((0, manifest_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR), navigationBar);
294
+ const parsedNavigationBar = (0, theme_1.initTheme)((0, manifest_1.getPlatformManifestJsonOnce)(), navigationBar);
293
295
  if ((0, shared_1.isArray)(navigationBar.buttons)) {
294
296
  navigationBar.buttons = navigationBar.buttons.map((btn) => normalizeNavigationBarButton(btn, navigationBar.type, parsedNavigationBar.titleColor));
295
297
  }
@@ -344,20 +346,6 @@ function normalizeTabBar(tabBar, platform) {
344
346
  return;
345
347
  }
346
348
  tabBar = (0, shared_1.extend)({}, DEFAULT_TAB_BAR, tabBar);
347
- if (platform === 'h5') {
348
- const len = list.length;
349
- if (len % 2 === 0 && (0, shared_1.isPlainObject)(midButton)) {
350
- list.splice(Math.floor(len / 2), 0, (0, shared_1.extend)({
351
- type: 'midButton',
352
- width: '50px',
353
- height: '50px',
354
- iconWidth: '24px',
355
- }, midButton));
356
- }
357
- else {
358
- delete tabBar.midButton;
359
- }
360
- }
361
349
  list.forEach((item) => {
362
350
  if (item.iconPath) {
363
351
  item.iconPath = normalizeFilepath(item.iconPath);
@@ -365,10 +353,10 @@ function normalizeTabBar(tabBar, platform) {
365
353
  if (item.selectedIconPath) {
366
354
  item.selectedIconPath = normalizeFilepath(item.selectedIconPath);
367
355
  }
368
- if (item.type === 'midButton' && item.backgroundImage) {
369
- item.backgroundImage = normalizeFilepath(item.backgroundImage);
370
- }
371
356
  });
357
+ if (midButton && midButton.backgroundImage) {
358
+ midButton.backgroundImage = normalizeFilepath(midButton.backgroundImage);
359
+ }
372
360
  tabBar.selectedIndex = 0;
373
361
  tabBar.shown = true;
374
362
  return tabBar;
@@ -376,6 +364,9 @@ function normalizeTabBar(tabBar, platform) {
376
364
  const SCHEME_RE = /^([a-z-]+:)?\/\//i;
377
365
  const DATA_RE = /^data:.*,.*/;
378
366
  function normalizeFilepath(filepath) {
367
+ const manifestJsonPlatform = (0, manifest_1.getPlatformManifestJsonOnce)();
368
+ if (manifestJsonPlatform.darkmode && filepath.startsWith('@'))
369
+ return filepath;
379
370
  if (!(SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) &&
380
371
  filepath.indexOf('/') !== 0) {
381
372
  return (0, uni_shared_1.addLeadingSlash)(filepath);
@@ -9,7 +9,7 @@ const path_1 = __importDefault(require("path"));
9
9
  const json_1 = require("./json");
10
10
  const uni_shared_1 = require("@dcloudio/uni-shared");
11
11
  const parseThemeJson = (themeLocation = 'theme.json') => {
12
- if (!themeLocation) {
12
+ if (!themeLocation || !process.env.UNI_INPUT_DIR) {
13
13
  return {};
14
14
  }
15
15
  themeLocation = path_1.default.join(process.env.UNI_INPUT_DIR, themeLocation);
@@ -19,6 +19,7 @@ declare const _default: {
19
19
  readonly 'mp.component.args[1]': "{0} requires two parameters";
20
20
  readonly 'mp.360.unsupported': "360 is unsupported";
21
21
  readonly 'file.notfound': "{file} is not found";
22
- readonly 'uts.ios.tips': "The project uses the uts plug-in. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect";
22
+ readonly 'uts.ios.tips': "The project uses the uts plugin. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect";
23
+ readonly 'uts.android.compiler.server': "The project uses the uts plugin, installing the uts Android runtime extension...";
23
24
  };
24
25
  export default _default;
@@ -21,5 +21,6 @@ exports.default = {
21
21
  'mp.component.args[1]': '{0} requires two parameters',
22
22
  'mp.360.unsupported': '360 is unsupported',
23
23
  'file.notfound': '{file} is not found',
24
- 'uts.ios.tips': 'The project uses the uts plug-in. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect',
24
+ 'uts.ios.tips': 'The project uses the uts plugin. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect',
25
+ 'uts.android.compiler.server': 'The project uses the uts plugin, installing the uts Android runtime extension...',
25
26
  };
@@ -20,6 +20,7 @@ export declare const M: {
20
20
  readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
21
21
  readonly 'file.notfound': "{file} 文件不存在";
22
22
  readonly 'uts.ios.tips': "项目使用了uts插件,iOS平台uts插件代码修改后需要重新生成[自定义基座](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground)才能生效";
23
+ readonly 'uts.android.compiler.server': "项目使用了uts插件,正在安装 uts Android 运行扩展...";
23
24
  } | {
24
25
  readonly 'app.compiler.version': "Compiler version: {version}";
25
26
  readonly compiling: "Compiling...";
@@ -41,5 +42,6 @@ export declare const M: {
41
42
  readonly 'mp.component.args[1]': "{0} requires two parameters";
42
43
  readonly 'mp.360.unsupported': "360 is unsupported";
43
44
  readonly 'file.notfound': "{file} is not found";
44
- readonly 'uts.ios.tips': "The project uses the uts plug-in. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect";
45
+ readonly 'uts.ios.tips': "The project uses the uts plugin. After the uts plug-in code is modified, the [Custom playground native runner](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground) needs to be regenerated to take effect";
46
+ readonly 'uts.android.compiler.server': "The project uses the uts plugin, installing the uts Android runtime extension...";
45
47
  };
@@ -20,5 +20,6 @@ declare const _default: {
20
20
  readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
21
21
  readonly 'file.notfound': "{file} 文件不存在";
22
22
  readonly 'uts.ios.tips': "项目使用了uts插件,iOS平台uts插件代码修改后需要重新生成[自定义基座](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground)才能生效";
23
+ readonly 'uts.android.compiler.server': "项目使用了uts插件,正在安装 uts Android 运行扩展...";
23
24
  };
24
25
  export default _default;
@@ -22,4 +22,5 @@ exports.default = {
22
22
  'mp.360.unsupported': 'vue3暂不支持360小程序',
23
23
  'file.notfound': '{file} 文件不存在',
24
24
  'uts.ios.tips': '项目使用了uts插件,iOS平台uts插件代码修改后需要重新生成[自定义基座](https://uniapp.dcloud.net.cn/tutorial/run/run-app.html#customplayground)才能生效',
25
+ 'uts.android.compiler.server': '项目使用了uts插件,正在安装 uts Android 运行扩展...',
25
26
  };
@@ -7,6 +7,6 @@ export * from './assets';
7
7
  export * from './template';
8
8
  export * from './constants';
9
9
  export { HTML_TO_MINI_PROGRAM_TAGS } from './tags';
10
- export { copyMiniProgramPluginJson } from './plugin';
10
+ export { copyMiniProgramPluginJson, copyMiniProgramThemeJson } from './plugin';
11
11
  export { parseMainDescriptor, parseScriptDescriptor, parseTemplateDescriptor, transformDynamicImports, updateMiniProgramGlobalComponents, updateMiniProgramComponentsByMainFilename, updateMiniProgramComponentsByScriptFilename, updateMiniProgramComponentsByTemplateFilename, } from './usingComponents';
12
12
  export { hasExternalClasses, parseExternalClasses, findMiniProgramComponentExternalClasses, updateMiniProgramComponentExternalClasses, } from './externalClasses';
package/dist/mp/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.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.parseExternalClasses = exports.hasExternalClasses = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.transformDynamicImports = exports.parseTemplateDescriptor = exports.parseScriptDescriptor = exports.parseMainDescriptor = exports.copyMiniProgramPluginJson = exports.HTML_TO_MINI_PROGRAM_TAGS = void 0;
17
+ exports.updateMiniProgramComponentExternalClasses = exports.findMiniProgramComponentExternalClasses = exports.parseExternalClasses = exports.hasExternalClasses = exports.updateMiniProgramComponentsByTemplateFilename = exports.updateMiniProgramComponentsByScriptFilename = exports.updateMiniProgramComponentsByMainFilename = exports.updateMiniProgramGlobalComponents = exports.transformDynamicImports = exports.parseTemplateDescriptor = exports.parseScriptDescriptor = exports.parseMainDescriptor = exports.copyMiniProgramThemeJson = exports.copyMiniProgramPluginJson = exports.HTML_TO_MINI_PROGRAM_TAGS = void 0;
18
18
  __exportStar(require("./ast"), exports);
19
19
  __exportStar(require("./wxs"), exports);
20
20
  __exportStar(require("./nvue"), exports);
@@ -27,6 +27,7 @@ var tags_1 = require("./tags");
27
27
  Object.defineProperty(exports, "HTML_TO_MINI_PROGRAM_TAGS", { enumerable: true, get: function () { return tags_1.HTML_TO_MINI_PROGRAM_TAGS; } });
28
28
  var plugin_1 = require("./plugin");
29
29
  Object.defineProperty(exports, "copyMiniProgramPluginJson", { enumerable: true, get: function () { return plugin_1.copyMiniProgramPluginJson; } });
30
+ Object.defineProperty(exports, "copyMiniProgramThemeJson", { enumerable: true, get: function () { return plugin_1.copyMiniProgramThemeJson; } });
30
31
  var usingComponents_1 = require("./usingComponents");
31
32
  Object.defineProperty(exports, "parseMainDescriptor", { enumerable: true, get: function () { return usingComponents_1.parseMainDescriptor; } });
32
33
  Object.defineProperty(exports, "parseScriptDescriptor", { enumerable: true, get: function () { return usingComponents_1.parseScriptDescriptor; } });
@@ -1,2 +1,3 @@
1
1
  import { UniViteCopyPluginTarget } from '../vite/plugins/copy';
2
2
  export declare const copyMiniProgramPluginJson: UniViteCopyPluginTarget;
3
+ export declare const copyMiniProgramThemeJson: () => UniViteCopyPluginTarget[];
package/dist/mp/plugin.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.copyMiniProgramPluginJson = void 0;
3
+ exports.copyMiniProgramThemeJson = exports.copyMiniProgramPluginJson = void 0;
4
4
  const json_1 = require("../json/json");
5
+ const manifest_1 = require("../json/manifest");
5
6
  exports.copyMiniProgramPluginJson = {
6
7
  src: ['plugin.json'],
7
8
  get dest() {
@@ -11,3 +12,23 @@ exports.copyMiniProgramPluginJson = {
11
12
  return JSON.stringify((0, json_1.parseJson)(source.toString(), true), null, 2);
12
13
  },
13
14
  };
15
+ const copyMiniProgramThemeJson = () => {
16
+ if (!process.env.UNI_INPUT_DIR)
17
+ return [];
18
+ const manifestJson = (0, manifest_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR)[process.env.UNI_PLATFORM] || {};
19
+ return (manifestJson.darkmode && manifestJson.themeLocation) ||
20
+ (manifestJson.themeLocation = 'theme.json')
21
+ ? [
22
+ {
23
+ src: [manifestJson.themeLocation],
24
+ get dest() {
25
+ return process.env.UNI_OUTPUT_DIR;
26
+ },
27
+ transform(source) {
28
+ return JSON.stringify((0, json_1.parseJson)(source.toString(), true), null, 2);
29
+ },
30
+ },
31
+ ]
32
+ : [];
33
+ };
34
+ exports.copyMiniProgramThemeJson = copyMiniProgramThemeJson;
@@ -56,6 +56,19 @@ function walkDecls(rpx2unit) {
56
56
  decl.value = rpx2unit(decl.value);
57
57
  };
58
58
  }
59
+ function filterPrefersColorScheme(root) {
60
+ var _a;
61
+ if (process.env.VUE_APP_DARK_MODE !== 'true') {
62
+ const filePath = (_a = root.source) === null || _a === void 0 ? void 0 : _a.input.file;
63
+ if (filePath && filePath.includes('@dcloudio')) {
64
+ root.walkAtRules((rule) => {
65
+ if (rule.params.includes('prefers-color-scheme')) {
66
+ rule.remove();
67
+ }
68
+ });
69
+ }
70
+ }
71
+ }
59
72
  const baiduTags = {
60
73
  navigator: 'nav',
61
74
  };
@@ -96,6 +109,7 @@ const uniapp = (opts) => {
96
109
  OnceExit(root) {
97
110
  root.walkDecls(walkDecls(rpx2unit));
98
111
  const rewriteTag = transforms[platform];
112
+ filterPrefersColorScheme(root);
99
113
  if (rewriteTag) {
100
114
  root.walkRules(walkRules({
101
115
  rewriteTag,
package/lib/.DS_Store ADDED
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3060820221027001",
3
+ "version": "3.0.0-alpha-3060820221027003",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@ampproject/remapping": "^2.1.2",
25
- "@babel/core": "^7.18.13",
26
- "@babel/parser": "^7.18.13",
27
- "@babel/types": "^7.17.0",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3060820221027001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3060820221027001",
25
+ "@babel/core": "^7.19.6",
26
+ "@babel/parser": "^7.19.6",
27
+ "@babel/types": "^7.20.0",
28
+ "@dcloudio/uni-i18n": "3.0.0-alpha-3060820221027003",
29
+ "@dcloudio/uni-shared": "3.0.0-alpha-3060820221027003",
30
30
  "@intlify/core-base": "9.1.9",
31
31
  "@intlify/shared": "9.1.9",
32
32
  "@intlify/vue-devtools": "9.1.9",
@@ -36,7 +36,7 @@
36
36
  "@vue/compiler-sfc": "3.2.41",
37
37
  "@vue/server-renderer": "3.2.41",
38
38
  "@vue/shared": "3.2.41",
39
- "autoprefixer": "^10.4.12",
39
+ "autoprefixer": "^10.4.13",
40
40
  "base64url": "^3.0.1",
41
41
  "chokidar": "^3.5.3",
42
42
  "compare-versions": "^3.6.0",
@@ -48,7 +48,7 @@
48
48
  "fs-extra": "^10.0.0",
49
49
  "hash-sum": "^2.0.0",
50
50
  "jsonc-parser": "^3.0.0",
51
- "magic-string": "^0.26.3",
51
+ "magic-string": "^0.26.7",
52
52
  "merge": "^2.1.1",
53
53
  "mime": "^3.0.0",
54
54
  "module-alias": "^2.2.2",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
66
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3060820221027001",
67
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-3060820221027003",
68
68
  "@types/babel__core": "^7.1.19",
69
69
  "@types/debug": "^4.1.7",
70
70
  "@types/estree": "^0.0.51",