@dcloudio/uni-cli-shared 3.0.0-4020920240930001 → 3.0.0-4030620241128001

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 (73) hide show
  1. package/dist/deps.d.ts +2 -2
  2. package/dist/deps.js +45 -34
  3. package/dist/easycom.js +15 -8
  4. package/dist/env/define.js +1 -0
  5. package/dist/hbx/log.d.ts +1 -0
  6. package/dist/hbx/log.js +56 -25
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +4 -3
  9. package/dist/json/app/manifest/defaultManifestJson.js +8 -2
  10. package/dist/json/app/manifest/launchwebview.js +22 -1
  11. package/dist/json/app/manifest/merge.js +5 -1
  12. package/dist/json/app/manifest/plus.js +1 -0
  13. package/dist/json/app/manifest/safearea.js +8 -0
  14. package/dist/json/app/pages/uniConfig.js +2 -0
  15. package/dist/json/index.d.ts +1 -1
  16. package/dist/json/index.js +2 -1
  17. package/dist/json/manifest.js +2 -1
  18. package/dist/json/mp/pages.d.ts +1 -1
  19. package/dist/json/mp/pages.js +11 -1
  20. package/dist/json/mp/project.d.ts +1 -0
  21. package/dist/json/mp/project.js +16 -4
  22. package/dist/json/pages.js +1 -1
  23. package/dist/json/uni-x/index.d.ts +1 -1
  24. package/dist/json/uni-x/index.js +22 -5
  25. package/dist/json/uni-x/manifest.d.ts +1 -0
  26. package/dist/json/uni-x/manifest.js +9 -1
  27. package/dist/json/uni-x/uniConfig.d.ts +15 -1
  28. package/dist/json/uni-x/uniConfig.js +1 -1
  29. package/dist/logs/format.js +1 -0
  30. package/dist/mp/template.d.ts +14 -1
  31. package/dist/platform.js +1 -0
  32. package/dist/preprocess/context.d.ts +5 -0
  33. package/dist/preprocess/context.js +15 -5
  34. package/dist/resolve.d.ts +2 -1
  35. package/dist/resolve.js +14 -3
  36. package/dist/uni_modules.cloud.d.ts +49 -0
  37. package/dist/uni_modules.cloud.js +332 -0
  38. package/dist/uni_modules.d.ts +0 -49
  39. package/dist/uni_modules.js +7 -331
  40. package/dist/utils.d.ts +1 -0
  41. package/dist/utils.js +20 -6
  42. package/dist/uts.d.ts +9 -2
  43. package/dist/uts.js +173 -26
  44. package/dist/vite/autoImport.js +8 -1
  45. package/dist/vite/cloud.d.ts +1 -0
  46. package/dist/vite/cloud.js +52 -10
  47. package/dist/vite/extApi.d.ts +2 -0
  48. package/dist/vite/extApi.js +43 -0
  49. package/dist/vite/index.d.ts +1 -0
  50. package/dist/vite/index.js +1 -0
  51. package/dist/vite/plugins/copy.js +8 -1
  52. package/dist/vite/plugins/index.d.ts +2 -1
  53. package/dist/vite/plugins/index.js +3 -1
  54. package/dist/vite/plugins/pre.d.ts +6 -0
  55. package/dist/vite/plugins/pre.js +59 -0
  56. package/dist/vite/plugins/uts/uni_modules.d.ts +6 -0
  57. package/dist/vite/plugins/uts/uni_modules.js +310 -23
  58. package/dist/vite/plugins/vitejs/plugins/asset.js +4 -2
  59. package/dist/vite/plugins/vitejs/plugins/css.d.ts +1 -0
  60. package/dist/vite/plugins/vitejs/plugins/css.js +25 -5
  61. package/dist/vite/utils/index.js +2 -1
  62. package/dist/vite/utils/utils.js +12 -6
  63. package/dist/vue/transforms/index.d.ts +2 -0
  64. package/dist/vue/transforms/index.js +2 -0
  65. package/dist/vue/transforms/x/transformDirection.d.ts +6 -0
  66. package/dist/vue/transforms/x/transformDirection.js +52 -0
  67. package/dist/vue/transforms/x/transformMPBuiltInTag.d.ts +12 -0
  68. package/dist/vue/transforms/x/transformMPBuiltInTag.js +94 -0
  69. package/dist/vue/utils.d.ts +1 -0
  70. package/dist/vue/utils.js +13 -1
  71. package/dist/watcher.js +18 -3
  72. package/license.md +1 -1
  73. package/package.json +6 -6
package/dist/deps.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const API_DEPS_CSS: {
1
+ export declare const API_DEPS_CSS: (isX: boolean) => {
2
2
  showModal: string[];
3
3
  showToast: string[];
4
4
  showActionSheet: string[];
@@ -6,7 +6,7 @@ export declare const API_DEPS_CSS: {
6
6
  openLocation: string[];
7
7
  chooseLocation: string[];
8
8
  };
9
- export declare const COMPONENT_DEPS_CSS: {
9
+ export declare const COMPONENT_DEPS_CSS: (isX: boolean) => {
10
10
  canvas: string[];
11
11
  image: string[];
12
12
  'movable-area': string[];
package/dist/deps.js CHANGED
@@ -4,39 +4,50 @@ exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = void 0;
4
4
  const constants_1 = require("./constants");
5
5
  const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
6
6
  const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
7
- exports.API_DEPS_CSS = {
8
- showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
9
- showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
10
- showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
11
- previewImage: [
12
- RESIZE_SENSOR_CSS,
13
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper.css`,
14
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper-item.css`,
15
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-area.css`,
16
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
17
- ],
18
- openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
19
- chooseLocation: [
20
- `${constants_1.H5_API_STYLE_PATH}/location-picker.css`,
21
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
22
- `${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
23
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
24
- ],
7
+ const API_DEPS_CSS = (isX) => {
8
+ return {
9
+ showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
10
+ showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
11
+ showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
12
+ previewImage: [
13
+ RESIZE_SENSOR_CSS,
14
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper.css`,
15
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper-item.css`,
16
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-area.css`,
17
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
18
+ ],
19
+ openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
20
+ chooseLocation: [
21
+ ...(isX
22
+ ? [
23
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/view.css`,
24
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/text.css`,
25
+ ]
26
+ : [`${constants_1.H5_API_STYLE_PATH}/location-picker.css`]),
27
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
28
+ `${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
29
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
30
+ ],
31
+ };
25
32
  };
26
- exports.COMPONENT_DEPS_CSS = {
27
- canvas: [RESIZE_SENSOR_CSS],
28
- image: [RESIZE_SENSOR_CSS],
29
- 'movable-area': [RESIZE_SENSOR_CSS],
30
- 'picker-view': [RESIZE_SENSOR_CSS],
31
- 'picker-view-column': [RESIZE_SENSOR_CSS],
32
- 'rich-text': [RESIZE_SENSOR_CSS],
33
- textarea: [RESIZE_SENSOR_CSS],
34
- 'web-view': [RESIZE_SENSOR_CSS],
35
- picker: [
36
- RESIZE_SENSOR_CSS,
37
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
38
- `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
39
- ],
40
- 'scroll-view': [REFRESHER_CSS],
41
- 'list-view': [RESIZE_SENSOR_CSS, REFRESHER_CSS],
33
+ exports.API_DEPS_CSS = API_DEPS_CSS;
34
+ const COMPONENT_DEPS_CSS = (isX) => {
35
+ return {
36
+ canvas: [RESIZE_SENSOR_CSS],
37
+ image: [RESIZE_SENSOR_CSS],
38
+ 'movable-area': [RESIZE_SENSOR_CSS],
39
+ 'picker-view': [RESIZE_SENSOR_CSS],
40
+ 'picker-view-column': [RESIZE_SENSOR_CSS],
41
+ 'rich-text': [RESIZE_SENSOR_CSS],
42
+ textarea: [RESIZE_SENSOR_CSS],
43
+ 'web-view': [RESIZE_SENSOR_CSS],
44
+ picker: [
45
+ RESIZE_SENSOR_CSS,
46
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
47
+ `${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
48
+ ],
49
+ 'scroll-view': [REFRESHER_CSS],
50
+ 'list-view': [RESIZE_SENSOR_CSS, REFRESHER_CSS],
51
+ };
42
52
  };
53
+ exports.COMPONENT_DEPS_CSS = COMPONENT_DEPS_CSS;
package/dist/easycom.js CHANGED
@@ -64,8 +64,11 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
64
64
  globalThis.uts2jsSourceCodeMap.initUts2jsEasycom(easycoms);
65
65
  }
66
66
  };
67
- initEasycom(options);
68
- initUTSEasycom();
67
+ // ext-api 模式下,不存在 easycom 特性
68
+ if (process.env.UNI_COMPILE_TARGET !== 'ext-api') {
69
+ initEasycom(options);
70
+ initUTSEasycom();
71
+ }
69
72
  const componentExtNames = isX ? 'uvue|vue' : 'vue';
70
73
  const res = {
71
74
  options,
@@ -79,8 +82,10 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
79
82
  }),
80
83
  refresh() {
81
84
  res.options = initEasycomOptions();
82
- initEasycom(res.options);
83
- initUTSEasycom();
85
+ if (process.env.UNI_COMPILE_TARGET !== 'ext-api') {
86
+ initEasycom(res.options);
87
+ initUTSEasycom();
88
+ }
84
89
  },
85
90
  easycoms,
86
91
  };
@@ -186,11 +191,13 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
186
191
  return easycoms;
187
192
  }
188
193
  const is_uni_modules = path_1.default.basename(path_1.default.resolve(dir, '../..')) === 'uni_modules';
189
- const is_encrypt_uni_modules = // uni_modules模式不需要此逻辑
194
+ const is_easycom_encrypt_uni_modules = // uni_modules模式不需要此逻辑
190
195
  process.env.UNI_COMPILE_TARGET !== 'uni_modules' &&
191
196
  is_uni_modules &&
192
- fs_1.default.existsSync(path_1.default.resolve(dir, '../encrypt'));
193
- const uni_modules_plugin_id = is_encrypt_uni_modules && path_1.default.basename(path_1.default.resolve(dir, '..'));
197
+ // 前端加密插件,不能包含utssdk目录
198
+ fs_1.default.existsSync(path_1.default.resolve(dir, '../encrypt')) &&
199
+ !fs_1.default.existsSync(path_1.default.resolve(dir, '../utssdk'));
200
+ const uni_modules_plugin_id = is_easycom_encrypt_uni_modules && path_1.default.basename(path_1.default.resolve(dir, '..'));
194
201
  fs_1.default.readdirSync(dir).forEach((name) => {
195
202
  const folder = path_1.default.resolve(dir, name);
196
203
  if (!isDir(folder)) {
@@ -202,7 +209,7 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
202
209
  for (let i = 0; i < extensions.length; i++) {
203
210
  const ext = extensions[i];
204
211
  if (files.includes(name + ext)) {
205
- easycoms[`^${name}$`] = is_encrypt_uni_modules
212
+ easycoms[`^${name}$`] = is_easycom_encrypt_uni_modules
206
213
  ? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${
207
214
  // android 走 proxy
208
215
  process.env.UNI_APP_X === 'true' &&
@@ -8,6 +8,7 @@ function initDefine(stringifyBoolean = false) {
8
8
  const platformManifestJson = (0, json_1.getPlatformManifestJsonOnce)();
9
9
  const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
10
10
  const isDebug = !!manifestJson.debug;
11
+ process.env['UNI_APP_ID'] = manifestJson.appid;
11
12
  return {
12
13
  ...initCustomDefine(),
13
14
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
package/dist/hbx/log.d.ts CHANGED
@@ -4,4 +4,5 @@ export declare function formatAtFilename(filename: string, line?: number, column
4
4
  export declare const h5ServeFormatter: Formatter;
5
5
  export declare const removeInfoFormatter: Formatter;
6
6
  export declare const removeWarnFormatter: Formatter;
7
+ export declare const removeDuplicatePluginFormatter: Formatter;
7
8
  export declare const errorFormatter: Formatter<LogErrorOptions>;
package/dist/hbx/log.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.errorFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
6
+ exports.errorFormatter = exports.removeDuplicatePluginFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const picocolors_1 = __importDefault(require("picocolors"));
@@ -44,7 +44,10 @@ if (typeof console !== 'undefined') {
44
44
  // overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
45
45
  }
46
46
  function formatAtFilename(filename, line, column) {
47
- const file = path_1.default.relative(process.env.UNI_INPUT_DIR, filename.replace('\x00', '').split('?')[0]);
47
+ filename = filename.replace('\x00', '').split('?')[0];
48
+ const file = process.env.UNI_INPUT_DIR
49
+ ? path_1.default.relative(process.env.UNI_INPUT_DIR, filename)
50
+ : filename;
48
51
  return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(file === 'pages-json-uts' ? 'pages.json' : file) +
49
52
  ':' +
50
53
  (line || 1) +
@@ -100,6 +103,20 @@ exports.removeWarnFormatter = {
100
103
  return '';
101
104
  },
102
105
  };
106
+ exports.removeDuplicatePluginFormatter = {
107
+ test() {
108
+ return true;
109
+ },
110
+ format(msg) {
111
+ // [plugin:vite:vue] [plugin vite:vue]
112
+ // 正则匹配获取第一个插件名称,然后移除 [plugin vite:vue]
113
+ const pluginName = msg.match(/\[plugin\s([^\]]+)\]/)?.[1];
114
+ if (pluginName) {
115
+ return msg.replace(`[plugin ${pluginName}]`, '');
116
+ }
117
+ return msg;
118
+ },
119
+ };
103
120
  exports.errorFormatter = {
104
121
  test(_, opts) {
105
122
  return !!(opts && opts.error);
@@ -110,32 +127,46 @@ exports.errorFormatter = {
110
127
  };
111
128
  function buildErrorMessage(err, args = [], includeStack = true) {
112
129
  if (err.plugin) {
113
- const otherMsgs = [];
114
- if (err.message.includes(': [plugin ')) {
115
- const messages = err.message.split(': [plugin ');
116
- err.message = messages[0];
117
- messages.slice(1).forEach((msg) => {
118
- otherMsgs.push(`[plugin:${msg}`);
119
- });
130
+ // 避免出现这样的错误:[plugin:vite:vue] [plugin vite:vue]
131
+ if (err.message.startsWith(`[plugin ${err.plugin}]`)) {
132
+ let msg = err.message.replace(`[plugin ${err.plugin}]`, '');
133
+ if (err.loc) {
134
+ // [plugin:vite:vue] pages/index/index.vue (2:12): v-on="" is not supported
135
+ const locStr = `(${err.loc.line}:${err.loc.column}):`;
136
+ if (msg.includes(locStr)) {
137
+ msg = msg.split(locStr)[1];
138
+ }
139
+ }
140
+ args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(msg)}`);
120
141
  }
121
- args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
122
- args.push(...otherMsgs);
123
- if (err.loc &&
124
- err.hook === 'transform' &&
125
- err.plugin === 'rollup-plugin-dynamic-import-variables' &&
126
- err.id &&
127
- constants_1.EXTNAME_VUE_RE.test(err.id)) {
128
- try {
129
- const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
130
- const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
131
- if (scriptNode) {
132
- const scriptLoc = scriptNode.loc;
133
- args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
134
- // correct error location
135
- err.loc.line = scriptLoc.start.line + err.loc.line - 1;
142
+ else {
143
+ const otherMsgs = [];
144
+ if (err.message.includes(': [plugin ')) {
145
+ const messages = err.message.split(': [plugin ');
146
+ err.message = messages[0];
147
+ messages.slice(1).forEach((msg) => {
148
+ otherMsgs.push(`[plugin:${msg}`);
149
+ });
150
+ }
151
+ args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
152
+ args.push(...otherMsgs);
153
+ if (err.loc &&
154
+ err.hook === 'transform' &&
155
+ err.plugin === 'rollup-plugin-dynamic-import-variables' &&
156
+ err.id &&
157
+ constants_1.EXTNAME_VUE_RE.test(err.id)) {
158
+ try {
159
+ const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
160
+ const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
161
+ if (scriptNode) {
162
+ const scriptLoc = scriptNode.loc;
163
+ args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
164
+ // correct error location
165
+ err.loc.line = scriptLoc.start.line + err.loc.line - 1;
166
+ }
136
167
  }
168
+ catch (e) { }
137
169
  }
138
- catch (e) { }
139
170
  }
140
171
  }
141
172
  else {
package/dist/index.d.ts CHANGED
@@ -22,7 +22,8 @@ export * from './resolve';
22
22
  export * from './scripts';
23
23
  export * from './platform';
24
24
  export * from './utsUtils';
25
- export { parseUniExtApi, parseUniExtApis, parseInjects, parseUniModulesArtifacts, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, resolveEncryptUniModule, formatExtApiProviderName, } from './uni_modules';
25
+ export { parseUniExtApi, parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, formatExtApiProviderName, } from './uni_modules';
26
+ export { parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
26
27
  export { M } from './messages';
27
28
  export * from './exports';
28
29
  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 = exports.formatExtApiProviderName = exports.resolveEncryptUniModule = exports.getUniExtApiProviderRegisters = exports.parseUniModulesArtifacts = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
17
+ exports.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
18
18
  __exportStar(require("./fs"), exports);
19
19
  __exportStar(require("./mp"), exports);
20
20
  __exportStar(require("./url"), exports);
@@ -43,10 +43,11 @@ var uni_modules_1 = require("./uni_modules");
43
43
  Object.defineProperty(exports, "parseUniExtApi", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApi; } });
44
44
  Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
45
45
  Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function () { return uni_modules_1.parseInjects; } });
46
- Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_1.parseUniModulesArtifacts; } });
47
46
  Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
48
- Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_1.resolveEncryptUniModule; } });
49
47
  Object.defineProperty(exports, "formatExtApiProviderName", { enumerable: true, get: function () { return uni_modules_1.formatExtApiProviderName; } });
48
+ var uni_modules_cloud_1 = require("./uni_modules.cloud");
49
+ Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_cloud_1.parseUniModulesArtifacts; } });
50
+ Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_cloud_1.resolveEncryptUniModule; } });
50
51
  var messages_1 = require("./messages");
51
52
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
52
53
  __exportStar(require("./exports"), exports);
@@ -26,7 +26,7 @@ const defaultManifestJson = `{
26
26
  "permissions": {},
27
27
  "plus": {
28
28
  "useragent": {
29
- "value": "uni-app appservice",
29
+ "value": "",
30
30
  "concatenate": true
31
31
  },
32
32
  "splashscreen": {
@@ -37,5 +37,11 @@ const defaultManifestJson = `{
37
37
  },
38
38
  "popGesture": "close",
39
39
  "launchwebview": {}
40
+ },
41
+ "app-harmony": {
42
+ "useragent": {
43
+ "value": "",
44
+ "concatenate": true
45
+ }
40
46
  }
41
- }`;
47
+ }`;
@@ -14,7 +14,28 @@ function initLaunchwebview(manifestJson, pagesJson) {
14
14
  }
15
15
  catch (e) { }
16
16
  }
17
- manifestJson.plus.useragent.value = 'uni-app';
17
+ if (manifestJson.plus.useragent.concatenate) {
18
+ if (manifestJson.plus.useragent.value) {
19
+ manifestJson.plus.useragent.value = [
20
+ 'uni-app',
21
+ manifestJson.plus.useragent.value,
22
+ ].join(' ');
23
+ }
24
+ else {
25
+ manifestJson.plus.useragent.value = 'uni-app';
26
+ }
27
+ }
28
+ if (manifestJson['app-harmony'].useragent.concatenate) {
29
+ if (manifestJson['app-harmony'].useragent.value) {
30
+ manifestJson['app-harmony'].useragent.value = [
31
+ 'uni-app',
32
+ manifestJson['app-harmony'].useragent.value,
33
+ ].join(' ');
34
+ }
35
+ else {
36
+ manifestJson['app-harmony'].useragent.value = 'uni-app';
37
+ }
38
+ }
18
39
  (0, shared_1.extend)(manifestJson.plus.launchwebview, {
19
40
  id: '1',
20
41
  kernel: 'WKWebview',
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initRecursiveMerge = void 0;
4
4
  const merge_1 = require("merge");
5
5
  function initRecursiveMerge(manifestJson, userManifestJson) {
6
+ const platformConfig = {
7
+ plus: userManifestJson['app-plus'],
8
+ };
9
+ platformConfig['app-harmony'] = userManifestJson['app-harmony'];
6
10
  return (0, merge_1.recursive)(true, manifestJson, {
7
11
  id: userManifestJson.appid || '',
8
12
  name: userManifestJson.name || '',
@@ -13,6 +17,6 @@ function initRecursiveMerge(manifestJson, userManifestJson) {
13
17
  },
14
18
  locale: userManifestJson.locale,
15
19
  uniStatistics: userManifestJson.uniStatistics,
16
- }, { plus: userManifestJson['app-plus'] });
20
+ }, platformConfig);
17
21
  }
18
22
  exports.initRecursiveMerge = initRecursiveMerge;
@@ -95,6 +95,7 @@ function initUniStatistics(manifestJson) {
95
95
  // 根节点配置了统计
96
96
  if (manifestJson.uniStatistics) {
97
97
  manifestJson.plus.uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson.plus.uniStatistics);
98
+ manifestJson['app-harmony'].uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson['app-harmony'].uniStatistics);
98
99
  delete manifestJson.uniStatistics;
99
100
  }
100
101
  if (!process.env.UNI_CLOUD_PROVIDER) {
@@ -12,6 +12,14 @@ function initSafearea(manifestJson, pagesJson) {
12
12
  },
13
13
  };
14
14
  }
15
+ if (!manifestJson['app-harmony'].safearea) {
16
+ manifestJson['app-harmony'].safearea = {
17
+ background: pagesJson.tabBar.backgroundColor || '#FFFFFF',
18
+ bottom: {
19
+ offset: 'auto',
20
+ },
21
+ };
22
+ }
15
23
  }
16
24
  else {
17
25
  if (!manifestJson.plus.launchwebview) {
@@ -36,6 +36,8 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
36
36
  locales: (0, i18n_1.initLocales)(path_1.default.join(process.env.UNI_INPUT_DIR, 'locale')),
37
37
  darkmode: platformConfig.darkmode || false,
38
38
  themeConfig: (0, theme_1.normalizeThemeConfigOnce)(platformConfig),
39
+ // @ts-expect-error
40
+ qqMapKey: platformConfig?.distribute?.sdkConfigs?.maps?.tencent?.key,
39
41
  };
40
42
  // TODO 待支持分包
41
43
  return JSON.stringify(config);
@@ -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, normalizeUniAppXAppConfig, checkPagesJson, parseUniXFlexDirection, parseUniXSplashScreen, } from './uni-x';
7
+ export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, checkPagesJson, parseUniXFlexDirection, parseUniXSplashScreen, parseUniXUniStatistics, } from './uni-x';
@@ -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.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.checkPagesJson = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
17
+ exports.parseUniXUniStatistics = 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);
@@ -27,3 +27,4 @@ Object.defineProperty(exports, "normalizeUniAppXAppConfig", { enumerable: true,
27
27
  Object.defineProperty(exports, "checkPagesJson", { enumerable: true, get: function () { return uni_x_1.checkPagesJson; } });
28
28
  Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return uni_x_1.parseUniXFlexDirection; } });
29
29
  Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return uni_x_1.parseUniXSplashScreen; } });
30
+ Object.defineProperty(exports, "parseUniXUniStatistics", { enumerable: true, get: function () { return uni_x_1.parseUniXUniStatistics; } });
@@ -9,10 +9,11 @@ const path_1 = __importDefault(require("path"));
9
9
  const shared_1 = require("@vue/shared");
10
10
  const uni_shared_1 = require("@dcloudio/uni-shared");
11
11
  const json_1 = require("./json");
12
+ const utils_1 = require("../utils");
12
13
  const parseManifestJson = (inputDir) => {
13
14
  const manifestFilename = path_1.default.join(inputDir, 'manifest.json');
14
15
  if (!fs_1.default.existsSync(manifestFilename)) {
15
- if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
16
+ if (!(0, utils_1.isNormalCompileTarget)()) {
16
17
  return {};
17
18
  }
18
19
  }
@@ -13,5 +13,5 @@ export declare function parseMiniProgramPagesJson(jsonStr: string, platform: Uni
13
13
  pageJsons: Record<string, PageWindowOptions>;
14
14
  nvuePages: string[];
15
15
  };
16
- export declare function mergeMiniProgramAppJson(appJson: Record<string, any>, platformJson?: Record<string, any>): void;
16
+ export declare function mergeMiniProgramAppJson(appJson: Record<string, any>, platformJson?: Record<string, any>, source?: Record<string, any>): void;
17
17
  export {};
@@ -14,7 +14,12 @@ const utils_2 = require("../../utils");
14
14
  const project_1 = require("./project");
15
15
  const manifest_1 = require("../manifest");
16
16
  const theme_1 = require("../theme");
17
+ const uni_x_1 = require("../uni-x");
17
18
  function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
19
+ if (process.env.UNI_APP_X === 'true') {
20
+ // 目前仅对x开放
21
+ (0, uni_x_1.checkPagesJson)(jsonStr, process.env.UNI_INPUT_DIR);
22
+ }
18
23
  return parsePagesJson(jsonStr, platform, options);
19
24
  }
20
25
  exports.parseMiniProgramPagesJson = parseMiniProgramPagesJson;
@@ -28,7 +33,12 @@ const NON_APP_JSON_KEYS = [
28
33
  'mergeVirtualHostAttributes',
29
34
  'styleIsolation',
30
35
  ];
31
- function mergeMiniProgramAppJson(appJson, platformJson = {}) {
36
+ function mergeMiniProgramAppJson(appJson, platformJson = {}, source = {}) {
37
+ Object.keys(source).forEach((key) => {
38
+ if (!project_1.projectKeys.includes(key)) {
39
+ project_1.projectKeys.push(key);
40
+ }
41
+ });
32
42
  Object.keys(platformJson).forEach((name) => {
33
43
  if (!(0, project_1.isMiniProgramProjectJsonKey)(name) &&
34
44
  !NON_APP_JSON_KEYS.includes(name)) {
@@ -9,6 +9,7 @@ interface ProjectConfig {
9
9
  miniprogram?: UniApp.PagesJson['condition'];
10
10
  };
11
11
  }
12
+ export declare const projectKeys: string[];
12
13
  export declare function isMiniProgramProjectJsonKey(name: string): boolean;
13
14
  export declare function parseMiniProgramProjectJson(jsonStr: string, platform: UniApp.PLATFORM, { template, pagesJson }: ParseMiniProgramProjectJsonOptions): ProjectConfig;
14
15
  export {};
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMiniProgramProjectJson = exports.isMiniProgramProjectJsonKey = void 0;
3
+ exports.parseMiniProgramProjectJson = exports.isMiniProgramProjectJsonKey = exports.projectKeys = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
5
  const merge_1 = require("merge");
6
6
  const json_1 = require("../json");
7
- const projectKeys = [
7
+ exports.projectKeys = [
8
8
  'appid',
9
9
  'setting',
10
10
  'miniprogramRoot',
@@ -20,7 +20,7 @@ const projectKeys = [
20
20
  'cloudbaseRoot',
21
21
  ];
22
22
  function isMiniProgramProjectJsonKey(name) {
23
- return projectKeys.includes(name);
23
+ return exports.projectKeys.includes(name);
24
24
  }
25
25
  exports.isMiniProgramProjectJsonKey = isMiniProgramProjectJsonKey;
26
26
  function parseMiniProgramProjectJson(jsonStr, platform, { template, pagesJson }) {
@@ -28,9 +28,10 @@ function parseMiniProgramProjectJson(jsonStr, platform, { template, pagesJson })
28
28
  const manifestJson = (0, json_1.parseJson)(jsonStr);
29
29
  if (manifestJson) {
30
30
  projectJson.projectname = manifestJson.name;
31
+ // 用户的平台配置
31
32
  const platformConfig = manifestJson[platform];
32
33
  if (platformConfig) {
33
- projectKeys.forEach((name) => {
34
+ const setProjectJson = (name) => {
34
35
  if ((0, shared_1.hasOwn)(platformConfig, name)) {
35
36
  if ((0, shared_1.isPlainObject)(platformConfig[name]) &&
36
37
  (0, shared_1.isPlainObject)(projectJson[name])) {
@@ -42,6 +43,16 @@ function parseMiniProgramProjectJson(jsonStr, platform, { template, pagesJson })
42
43
  projectJson[name] = platformConfig[name];
43
44
  }
44
45
  }
46
+ };
47
+ // 读取 template 中的配置
48
+ Object.keys(template).forEach((name) => {
49
+ if (!exports.projectKeys.includes(name)) {
50
+ exports.projectKeys.push(name);
51
+ }
52
+ });
53
+ // common mp config
54
+ exports.projectKeys.forEach((name) => {
55
+ setProjectJson(name);
45
56
  });
46
57
  // 使用了微信小程序手势系统,自动开启 ES6=>ES5
47
58
  platform === 'mp-weixin' &&
@@ -57,6 +68,7 @@ function parseMiniProgramProjectJson(jsonStr, platform, { template, pagesJson })
57
68
  }
58
69
  projectJson.condition.miniprogram = miniprogram;
59
70
  }
71
+ // appid
60
72
  if (!projectJson.appid) {
61
73
  projectJson.appid = 'touristappid';
62
74
  }
@@ -45,7 +45,7 @@ exports.isUniPageSfcFile = isUniPageSfcFile;
45
45
  const parsePagesJson = (inputDir, platform, normalize = true) => {
46
46
  const pagesFilename = path_1.default.join(inputDir, 'pages.json');
47
47
  if (!fs_1.default.existsSync(pagesFilename)) {
48
- if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
48
+ if (!(0, utils_1.isNormalCompileTarget)()) {
49
49
  return {
50
50
  pages: [],
51
51
  globalStyle: { navigationBar: {} },
@@ -1,4 +1,4 @@
1
- export { parseUniXFlexDirection, parseUniXSplashScreen } from './manifest';
1
+ export * from './manifest';
2
2
  export declare function checkPagesJson(jsonStr: string, inputDir: string): boolean;
3
3
  export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
4
4
  /**
@@ -1,9 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
18
  };
5
19
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = exports.checkPagesJson = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
20
+ exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = exports.checkPagesJson = void 0;
7
21
  const fs_1 = __importDefault(require("fs"));
8
22
  const path_1 = __importDefault(require("path"));
9
23
  const shared_1 = require("@vue/shared");
@@ -15,9 +29,7 @@ const uniRoutes_1 = require("../app/pages/uniRoutes");
15
29
  const uniConfig_1 = require("./uniConfig");
16
30
  const utils_2 = require("../../vite/plugins/vitejs/utils");
17
31
  const preprocess_1 = require("../../preprocess");
18
- var manifest_1 = require("./manifest");
19
- Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return manifest_1.parseUniXFlexDirection; } });
20
- Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return manifest_1.parseUniXSplashScreen; } });
32
+ __exportStar(require("./manifest"), exports);
21
33
  function checkPagesJson(jsonStr, inputDir) {
22
34
  if (!inputDir) {
23
35
  return false;
@@ -217,7 +229,12 @@ function normalizePageStyle(pageStyle) {
217
229
  * @returns
218
230
  */
219
231
  function normalizeUniAppXAppConfig(pagesJson, manifestJson) {
220
- return `const __uniConfig = ${(0, uniConfig_1.normalizeAppXUniConfig)(pagesJson, manifestJson)};
232
+ const uniConfig = (0, uniConfig_1.normalizeAppXUniConfig)(pagesJson, manifestJson);
233
+ const tabBar = uniConfig.tabBar;
234
+ delete uniConfig.tabBar;
235
+ return `const __uniConfig = ${JSON.stringify(uniConfig)};
236
+ __uniConfig.getTabBarConfig = () => {return ${tabBar ? JSON.stringify(tabBar) : 'undefined'}};
237
+ __uniConfig.tabBar = __uniConfig.getTabBarConfig();
221
238
  const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute));
222
239
 
223
240
  `;