@dcloudio/uni-cli-shared 3.0.0-alpha-4020620240822002 → 3.0.0-alpha-4020720240905001

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.
@@ -30,6 +30,7 @@ export declare function getRouterOptions(manifestJson: Record<string, any>): {
30
30
  };
31
31
  export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
32
32
  export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
33
+ export declare function getPlatformManifestJson(manifestJson: any, platform?: UniApp.PLATFORM): any;
33
34
  export declare function getPlatformManifestJsonOnce(): any;
34
35
  export declare function validateThemeValue(value: string): boolean;
35
36
  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.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
6
+ exports.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getPlatformManifestJson = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = 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");
@@ -24,7 +24,8 @@ exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir, platform = 'h5') =
24
24
  const rpx2unit = platform === 'h5' || platform === 'app' || platform === 'app-harmony'
25
25
  ? uni_shared_1.defaultRpx2Unit
26
26
  : uni_shared_1.defaultMiniProgramRpx2Unit;
27
- const platformOptions = (0, exports.parseManifestJsonOnce)(inputDir)[platform];
27
+ const manifestJson = (0, exports.parseManifestJsonOnce)(inputDir);
28
+ let platformOptions = getPlatformManifestJson(manifestJson, platform);
28
29
  if (platformOptions && platformOptions.rpx) {
29
30
  return (0, shared_1.extend)({}, rpx2unit, platformOptions);
30
31
  }
@@ -50,10 +51,8 @@ function normalizeNetworkTimeout(networkTimeout) {
50
51
  exports.normalizeNetworkTimeout = normalizeNetworkTimeout;
51
52
  function getUniStatistics(inputDir, platform) {
52
53
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
53
- if (platform === 'app') {
54
- platform = 'app-plus';
55
- }
56
- return (0, shared_1.extend)({}, manifest.uniStatistics, manifest[platform] && manifest[platform].uniStatistics);
54
+ let platformManifest = getPlatformManifestJson(manifest, platform);
55
+ return (0, shared_1.extend)({}, manifest.uniStatistics, platformManifest && platformManifest.uniStatistics);
57
56
  }
58
57
  exports.getUniStatistics = getUniStatistics;
59
58
  function isEnableUniPushV1(inputDir, platform) {
@@ -72,19 +71,20 @@ function isEnableUniPushV1(inputDir, platform) {
72
71
  exports.isEnableUniPushV1 = isEnableUniPushV1;
73
72
  function isEnableUniPushV2(inputDir, platform) {
74
73
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
74
+ const platformManifest = getPlatformManifestJson(manifest, platform);
75
75
  if (platform === 'app') {
76
- return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.version ==
77
- '2');
76
+ return (platformManifest?.distribute?.sdkConfigs?.push?.unipush?.version == '2');
78
77
  }
79
- return manifest[platform]?.unipush?.enable === true;
78
+ return platformManifest?.unipush?.enable === true;
80
79
  }
81
80
  exports.isEnableUniPushV2 = isEnableUniPushV2;
82
81
  function isEnableSecureNetwork(inputDir, platform) {
83
82
  const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
83
+ const platformManifest = getPlatformManifestJson(manifest, platform);
84
84
  if (platform === 'app') {
85
- return !!manifest['app-plus']?.modules?.SecureNetwork;
85
+ return !!platformManifest?.modules?.SecureNetwork;
86
86
  }
87
- return manifest[platform]?.secureNetwork?.enable === true;
87
+ return platformManifest?.secureNetwork?.enable === true;
88
88
  }
89
89
  exports.isEnableSecureNetwork = isEnableSecureNetwork;
90
90
  function hasPushModule(inputDir) {
@@ -99,7 +99,7 @@ function isUniPushOffline(inputDir) {
99
99
  }
100
100
  exports.isUniPushOffline = isUniPushOffline;
101
101
  function getRouterOptions(manifestJson) {
102
- return (0, shared_1.extend)({}, manifestJson.h5?.router);
102
+ return (0, shared_1.extend)({}, getPlatformManifestJson(manifestJson, 'h5')?.router);
103
103
  }
104
104
  exports.getRouterOptions = getRouterOptions;
105
105
  function isEnableTreeShaking(manifestJson) {
@@ -107,18 +107,33 @@ function isEnableTreeShaking(manifestJson) {
107
107
  if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
108
108
  return false;
109
109
  }
110
- return manifestJson.h5?.optimization?.treeShaking?.enable !== false;
110
+ const platformManifest = getPlatformManifestJson(manifestJson, 'h5');
111
+ return platformManifest?.optimization?.treeShaking?.enable !== false;
111
112
  }
112
113
  exports.isEnableTreeShaking = isEnableTreeShaking;
113
114
  function getDevServerOptions(manifestJson) {
114
- return (0, shared_1.extend)({}, manifestJson.h5?.devServer);
115
+ const platformManifest = getPlatformManifestJson(manifestJson, 'h5');
116
+ return (0, shared_1.extend)({}, platformManifest?.devServer);
115
117
  }
116
118
  exports.getDevServerOptions = getDevServerOptions;
119
+ function getPlatformManifestJson(manifestJson, platform) {
120
+ if (!platform) {
121
+ platform = process.env.UNI_PLATFORM;
122
+ }
123
+ if (platform === 'app') {
124
+ return manifestJson['app-plus'] || manifestJson['plus'] || {};
125
+ }
126
+ if (platform === 'h5') {
127
+ return manifestJson.web || manifestJson.h5 || {};
128
+ }
129
+ return manifestJson[platform] || {};
130
+ }
131
+ exports.getPlatformManifestJson = getPlatformManifestJson;
117
132
  function getPlatformManifestJsonOnce() {
118
- const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
119
- return !process.env.UNI_INPUT_DIR
133
+ const manifestJson = !process.env.UNI_INPUT_DIR
120
134
  ? {}
121
- : (0, exports.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR)[platform] || {};
135
+ : (0, exports.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
136
+ return getPlatformManifestJson(manifestJson);
122
137
  }
123
138
  exports.getPlatformManifestJsonOnce = getPlatformManifestJsonOnce;
124
139
  const themeValues = ['dark', 'light', 'auto'];
@@ -1,4 +1,4 @@
1
1
  export * from './jsonFile';
2
- export { AppJson, ComponentJson } from './types';
2
+ export { AppJson, ComponentJson, MiniProgramComponentsType } from './types';
3
3
  export { mergeMiniProgramAppJson, parseMiniProgramPagesJson } from './pages';
4
4
  export { parseMiniProgramProjectJson } from './project';
@@ -1,4 +1,4 @@
1
- import type { ComponentJson, PageWindowOptions, UsingComponents } from './types';
1
+ import type { ComponentJson, MiniProgramComponentsType, PageWindowOptions, UsingComponents } from './types';
2
2
  export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
3
3
  export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
4
4
  export declare function hasJsonFile(filename: string): boolean;
@@ -17,11 +17,12 @@ export declare function isMiniProgramUsingComponent(name: string, options: {
17
17
  componentsDir?: string;
18
18
  }): boolean;
19
19
  interface MiniProgramComponents {
20
- [name: string]: 'plugin' | 'component' | 'dynamicLib' | 'ext';
20
+ [name: string]: MiniProgramComponentsType;
21
21
  }
22
22
  export declare function findMiniProgramUsingComponents({ filename, inputDir, componentsDir, }: {
23
23
  filename: string;
24
24
  inputDir: string;
25
25
  componentsDir?: string;
26
26
  }): MiniProgramComponents;
27
+ export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string): Record<any, any>;
27
28
  export {};
@@ -3,8 +3,9 @@ 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.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
6
+ exports.findUsingComponentsJson = exports.findMiniProgramUsingComponents = exports.isMiniProgramUsingComponent = exports.addMiniProgramUsingComponents = exports.addMiniProgramComponentJson = exports.addMiniProgramPageJson = exports.addMiniProgramAppJson = exports.findChangedJsonFiles = exports.normalizeJsonFilename = exports.findUsingComponents = exports.findJsonFile = exports.getComponentJsonFilenames = exports.hasJsonFile = exports.isMiniProgramPageSfcFile = exports.isMiniProgramPageFile = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("fs"));
8
9
  const shared_1 = require("@vue/shared");
9
10
  const utils_1 = require("../../utils");
10
11
  const resolve_1 = require("../../resolve");
@@ -152,9 +153,39 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
152
153
  // mp-toutiao
153
154
  res[name] = 'ext';
154
155
  }
156
+ else if (componentsDir &&
157
+ path.includes(componentsDir + '/') &&
158
+ findUsingComponentsJson(path, componentsDir).renderer === 'xr-frame') {
159
+ // mp-weixin & x-frame
160
+ res[name] = 'xr-frame';
161
+ }
155
162
  else if (componentsDir && path.includes(componentsDir + '/')) {
156
163
  res[name] = 'component';
157
164
  }
158
165
  return res;
159
166
  }, {});
160
167
  }
168
+ function findUsingComponentsJson(pathInpages, componentsDir) {
169
+ // 兼容test case
170
+ if (!process.env.UNI_INPUT_DIR)
171
+ return {};
172
+ let [, dir] = pathInpages.split(componentsDir);
173
+ if (dir === '') {
174
+ console.warn(`${pathInpages} 路径里没有找到对应的 ${componentsDir} 目录`);
175
+ return {};
176
+ }
177
+ dir = '.' + dir;
178
+ const fulldir = path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, dir);
179
+ let filename = path_1.default.parse(pathInpages).name + '.json';
180
+ let jsonPath = path_1.default.resolve(fulldir, filename);
181
+ if (fs_1.default.existsSync(jsonPath)) {
182
+ return require(jsonPath);
183
+ }
184
+ jsonPath = path_1.default.resolve(fulldir, 'index.json');
185
+ if (fs_1.default.existsSync(jsonPath)) {
186
+ return require(jsonPath);
187
+ }
188
+ console.warn(`${pathInpages} 路径下没有找到对应的json文件`);
189
+ return {};
190
+ }
191
+ exports.findUsingComponentsJson = findUsingComponentsJson;
@@ -119,4 +119,5 @@ export interface AppJson {
119
119
  restartStrategy?: RestartStrategy;
120
120
  [name: string]: unknown;
121
121
  }
122
+ export type MiniProgramComponentsType = 'plugin' | 'component' | 'dynamicLib' | 'ext' | 'xr-frame';
122
123
  export {};
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const json_1 = require("./json");
10
10
  const uni_shared_1 = require("@dcloudio/uni-shared");
11
+ const manifest_1 = require("./manifest");
11
12
  function hasThemeJson(themeLocation) {
12
13
  if (!fs_1.default.existsSync(themeLocation)) {
13
14
  return false;
@@ -84,7 +85,7 @@ exports.normalizeThemeConfigOnce = (0, uni_shared_1.once)((manifestJsonPlatform
84
85
  });
85
86
  function initTheme(manifestJson, pagesJson) {
86
87
  const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
87
- const manifestPlatform = manifestJson['plus'] || manifestJson[platform] || {};
88
+ const manifestPlatform = (0, manifest_1.getPlatformManifestJson)(manifestJson, platform) || {};
88
89
  const themeConfig = (0, exports.normalizeThemeConfigOnce)(manifestPlatform);
89
90
  return (0, uni_shared_1.normalizeStyles)(pagesJson, themeConfig);
90
91
  }
@@ -1,7 +1,8 @@
1
1
  import type { EmittedAsset } from 'rollup';
2
2
  import type { ElementNode } from '@vue/compiler-core';
3
+ import type { MiniProgramComponentsType } from '../json/mp/types';
3
4
  type LazyElementFn = (node: ElementNode, context: {
4
- isMiniProgramComponent(name: string): 'plugin' | 'component' | 'dynamicLib' | 'ext' | undefined;
5
+ isMiniProgramComponent(name: string): MiniProgramComponentsType | undefined;
5
6
  }) => {
6
7
  [name: string]: {
7
8
  name: 'on' | 'bind';
@@ -135,9 +135,10 @@ function initManifestFeature({ manifestJson, command, platform, }) {
135
135
  // features.wxs = false
136
136
  // features.longpress = false
137
137
  }
138
- if (manifestJson.h5 &&
139
- manifestJson.h5.router &&
140
- manifestJson.h5.router.mode === 'history') {
138
+ const webManifest = manifestJson.web || manifestJson.h5;
139
+ if (webManifest &&
140
+ webManifest.router &&
141
+ webManifest.router.mode === 'history') {
141
142
  features.routerMode = '"history"';
142
143
  }
143
144
  // TODO other features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4020620240822002",
3
+ "version": "3.0.0-alpha-4020720240905001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "@babel/core": "^7.23.3",
27
27
  "@babel/parser": "^7.23.9",
28
28
  "@babel/types": "^7.20.7",
29
- "@dcloudio/uni-i18n": "3.0.0-alpha-4020620240822002",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4020620240822002",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4020720240905001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4020720240905001",
31
31
  "@intlify/core-base": "9.1.9",
32
32
  "@intlify/shared": "9.1.9",
33
33
  "@intlify/vue-devtools": "9.1.9",
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
73
73
  "devDependencies": {
74
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4020620240822002",
74
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4020720240905001",
75
75
  "@types/adm-zip": "^0.5.5",
76
76
  "@types/babel__code-frame": "^7.0.6",
77
77
  "@types/babel__core": "^7.1.19",