@dcloudio/uni-cli-shared 3.0.0-alpha-1000920260615733 → 3.0.0-alpha-5010420260626001

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 (66) hide show
  1. package/dist/dom2/index.d.ts +1 -0
  2. package/dist/dom2/index.js +1 -0
  3. package/dist/dom2/rootScrollView.d.ts +47 -0
  4. package/dist/dom2/rootScrollView.js +283 -0
  5. package/dist/hbx/alias.js +2 -21
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +2 -1
  8. package/dist/json/app/manifest/plus.js +9 -1
  9. package/dist/json/app/pages/definePage.js +1 -1
  10. package/dist/logs/console.js +1 -4
  11. package/dist/messages/en.d.ts +4 -2
  12. package/dist/messages/en.js +4 -2
  13. package/dist/messages/index.d.ts +8 -4
  14. package/dist/messages/zh_CN.d.ts +4 -2
  15. package/dist/messages/zh_CN.js +4 -2
  16. package/dist/postcss/plugins/stylePluginExternal.d.ts +9 -10
  17. package/dist/postcss/plugins/stylePluginExternal.js +51 -45
  18. package/dist/uni_modules.cloud.d.ts +5 -0
  19. package/dist/uni_modules.cloud.js +102 -1
  20. package/dist/utils.d.ts +1 -1
  21. package/dist/vite/cloud.js +0 -2
  22. package/dist/vite/plugins/console.js +1 -2
  23. package/dist/vite/plugins/inject.js +2 -7
  24. package/dist/vite/plugins/pre.js +2 -0
  25. package/dist/vite/plugins/sfc.js +1 -4
  26. package/dist/vite/plugins/stats.d.ts +5 -1
  27. package/dist/vite/plugins/stats.js +71 -2
  28. package/dist/vite/plugins/uts/uni_modules.js +5 -0
  29. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +0 -1
  30. package/dist/vite/plugins/vitejs/plugins/asset.js +1 -6
  31. package/dist/vite/plugins/vitejs/plugins/css.js +1 -5
  32. package/dist/vue/transforms/index.d.ts +1 -0
  33. package/dist/vue/transforms/index.js +1 -0
  34. package/dist/vue/transforms/templateTransformAssetUrl.js +4 -4
  35. package/dist/vue/transforms/templateTransformSrcset.js +4 -4
  36. package/dist/vue/transforms/transformTeleport.d.ts +2 -0
  37. package/dist/vue/transforms/transformTeleport.js +63 -0
  38. package/dist/vue/transforms/x/transformDirection.js +33 -4
  39. package/dist/watcher.d.ts +0 -1
  40. package/dist/x.d.ts +0 -1
  41. package/dist/x.js +1 -5
  42. package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +23 -16
  43. package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +23 -16
  44. package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +23 -16
  45. package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +66 -23
  46. package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +115 -67
  47. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +1 -1
  48. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +1 -1
  49. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +1 -1
  50. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +1 -1
  51. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +1 -1
  52. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +1 -1
  53. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +1 -1
  54. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +1 -1
  55. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +1 -1
  56. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +1 -1
  57. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +3 -3
  58. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +217 -45
  59. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +218 -43
  60. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +62 -12
  61. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +228 -44
  62. package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
  63. package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +1 -1
  64. package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +1 -1
  65. package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +1 -1
  66. package/package.json +19 -18
@@ -1,3 +1,4 @@
1
1
  export * from './sharedData';
2
2
  export * from './vue';
3
3
  export * from './fontFamily';
4
+ export * from './rootScrollView';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./sharedData"), exports);
18
18
  __exportStar(require("./vue"), exports);
19
19
  __exportStar(require("./fontFamily"), exports);
20
+ __exportStar(require("./rootScrollView"), exports);
@@ -0,0 +1,47 @@
1
+ export interface VueCodePosition {
2
+ line: number;
3
+ column: number;
4
+ }
5
+ export interface VueCodeEditRange {
6
+ start: VueCodePosition;
7
+ end: VueCodePosition;
8
+ /**
9
+ * 调用方替换时建议只移除非换行字符,用于尽量保持错误定位和调试行号不变。
10
+ */
11
+ preserveLineBreaks: true;
12
+ /**
13
+ * 开始范围包含首个子节点前的缩进,调用方需要保留这段缩进,避免改变子节点格式。
14
+ */
15
+ preserveEndIndent?: true;
16
+ }
17
+ export type VueCodeEditRangesResult = Record<string, VueCodeEditRange[]>;
18
+ /**
19
+ * 批量定位由 `#ifdef APP` 包裹的根 scroll-view 需要移除的范围。
20
+ * 只返回需要修改的行列号,不修改文件,也不返回修改后的文件内容。
21
+ */
22
+ export declare function resolveAppRootScrollViewEditRanges(vueFiles: string[], inputDir: string): VueCodeEditRangesResult;
23
+ /**
24
+ * 蒸汽模式下,页面根节点会自动补一个 scroll-view。
25
+ * 这里仅用正则做精确匹配:命中范围宁可保守,也不能误报。
26
+ */
27
+ export declare function hasAppRootScrollViewWrappedByIfdef(code: string): boolean;
28
+ /**
29
+ * 仅在 dom2 页面整文件预处理时定位需要提示优化建议的根 scroll-view 节点。
30
+ */
31
+ export declare function resolveDom2RootScrollViewWarnLocation(code: string, filename: string, isVueSubRequest: boolean): {
32
+ loc: import("@vue/compiler-core").SourceLocation | {
33
+ start: {
34
+ line: number;
35
+ column: number;
36
+ offset: number;
37
+ };
38
+ end: {
39
+ line: number;
40
+ column: number;
41
+ offset: number;
42
+ };
43
+ };
44
+ source: string;
45
+ } | undefined;
46
+ export declare function warnDom2RootScrollView(code: string, filename: string, isVueSubRequest: boolean): void;
47
+ export declare function resolveAppRootScrollViewEditRangesByCode(code: string, filename: string): VueCodeEditRange[];
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveAppRootScrollViewEditRangesByCode = exports.warnDom2RootScrollView = exports.resolveDom2RootScrollViewWarnLocation = exports.hasAppRootScrollViewWrappedByIfdef = exports.resolveAppRootScrollViewEditRanges = void 0;
4
+ const fs_extra_1 = require("fs-extra");
5
+ const path_1 = require("path");
6
+ const compiler_sfc_1 = require("@vue/compiler-sfc");
7
+ const json_1 = require("../json");
8
+ const logs_1 = require("../logs");
9
+ const messages_1 = require("../messages");
10
+ const utils_1 = require("../utils");
11
+ const utils_2 = require("../vite/plugins/vitejs/utils");
12
+ const { preprocess: preprocessHtml } = require('../../lib/preprocess');
13
+ const TEMPLATE_BLOCK_RE = /<template\b[^>]*>([\s\S]*?)<\/template>/i;
14
+ const ROOT_SCROLL_VIEW_ATTR_RE = /^\s+style\s*=\s*(["'])\s*flex\s*:\s*1\s*;?\s*\1\s*$/;
15
+ const APP_ROOT_SCROLL_VIEW_RE = /^\s*<!--\s*#ifdef APP\s*-->\s*<scroll-view([^>]*)>[\s\S]*<\/scroll-view>\s*<!--\s*#endif\s*-->\s*$/;
16
+ const SPLIT_APP_ROOT_SCROLL_VIEW_RE = /^\s*<!--\s*#ifdef APP\s*-->\s*<scroll-view([^>]*)>\s*<!--\s*#endif\s*-->[\s\S]*<!--\s*#ifdef APP\s*-->\s*<\/scroll-view>\s*<!--\s*#endif\s*-->\s*$/;
17
+ /**
18
+ * 批量定位由 `#ifdef APP` 包裹的根 scroll-view 需要移除的范围。
19
+ * 只返回需要修改的行列号,不修改文件,也不返回修改后的文件内容。
20
+ */
21
+ function resolveAppRootScrollViewEditRanges(vueFiles, inputDir) {
22
+ const result = {};
23
+ vueFiles.forEach((file) => {
24
+ const filename = resolveVueFilename(inputDir, file);
25
+ if (!(0, fs_extra_1.existsSync)(filename)) {
26
+ return;
27
+ }
28
+ const content = (0, fs_extra_1.readFileSync)(filename, 'utf8');
29
+ const ranges = resolveAppRootScrollViewEditRangesByCode(content, filename);
30
+ if (ranges.length) {
31
+ result[file] = ranges;
32
+ }
33
+ });
34
+ return result;
35
+ }
36
+ exports.resolveAppRootScrollViewEditRanges = resolveAppRootScrollViewEditRanges;
37
+ /**
38
+ * 蒸汽模式下,页面根节点会自动补一个 scroll-view。
39
+ * 这里仅用正则做精确匹配:命中范围宁可保守,也不能误报。
40
+ */
41
+ function hasAppRootScrollViewWrappedByIfdef(code) {
42
+ const templateContent = getTemplateContent(code);
43
+ if (!templateContent) {
44
+ return false;
45
+ }
46
+ return (matchesAppRootScrollViewTemplate(templateContent, APP_ROOT_SCROLL_VIEW_RE) ||
47
+ matchesAppRootScrollViewTemplate(templateContent, SPLIT_APP_ROOT_SCROLL_VIEW_RE));
48
+ }
49
+ exports.hasAppRootScrollViewWrappedByIfdef = hasAppRootScrollViewWrappedByIfdef;
50
+ /**
51
+ * 仅在 dom2 页面整文件预处理时定位需要提示优化建议的根 scroll-view 节点。
52
+ */
53
+ function resolveDom2RootScrollViewWarnLocation(code, filename, isVueSubRequest) {
54
+ if (process.env.UNI_PLATFORM !== 'app' ||
55
+ process.env.UNI_APP_X_DOM2 !== 'true' ||
56
+ isVueSubRequest ||
57
+ !(0, json_1.parseUniXPageOptions)(filename) ||
58
+ !code.includes('scroll-view') ||
59
+ !code.includes('#ifdef APP')) {
60
+ return;
61
+ }
62
+ if (!hasAppRootScrollViewWrappedByIfdef(code)) {
63
+ return;
64
+ }
65
+ return resolveAppRootScrollViewNodeLocByCode(code, filename);
66
+ }
67
+ exports.resolveDom2RootScrollViewWarnLocation = resolveDom2RootScrollViewWarnLocation;
68
+ function warnDom2RootScrollView(code, filename, isVueSubRequest) {
69
+ const location = resolveDom2RootScrollViewWarnLocation(code, filename, isVueSubRequest);
70
+ if (!location) {
71
+ return;
72
+ }
73
+ (0, logs_1.onCompileLog)('warn', {
74
+ message: messages_1.M['dom2.root.scroll.view'],
75
+ name: 'Warn',
76
+ loc: location.loc,
77
+ }, createWarnCodeFrameSource(location), (0, utils_1.normalizePath)((0, path_1.relative)(process.env.UNI_INPUT_DIR, filename)));
78
+ }
79
+ exports.warnDom2RootScrollView = warnDom2RootScrollView;
80
+ function resolveVueFilename(inputDir, file) {
81
+ if ((0, path_1.isAbsolute)(file)) {
82
+ const root = (0, path_1.parse)(file).root;
83
+ // HBuilderX/uni-app 里页面路径可能写成 `/pages/a/b.uvue`,
84
+ // 这种是项目内绝对路径,不是磁盘绝对路径,需要仍然基于 inputDir 解析。
85
+ if (root === '/' || root === '\\') {
86
+ return (0, path_1.resolve)(inputDir, removeLeadingRootSlash(file));
87
+ }
88
+ return file;
89
+ }
90
+ return (0, path_1.resolve)(inputDir, file);
91
+ }
92
+ function removeLeadingRootSlash(file) {
93
+ let index = 0;
94
+ while (file.charAt(index) === '/' || file.charAt(index) === '\\') {
95
+ index++;
96
+ }
97
+ return file.slice(index);
98
+ }
99
+ function getTemplateContent(code) {
100
+ return code.match(TEMPLATE_BLOCK_RE)?.[1];
101
+ }
102
+ function matchesAppRootScrollViewTemplate(template, regex) {
103
+ const match = template.match(regex);
104
+ return !!match && ROOT_SCROLL_VIEW_ATTR_RE.test(match[1]);
105
+ }
106
+ function resolveAppRootScrollViewNodeLocByCode(code, filename) {
107
+ const template = parseSfcTemplate(code, filename);
108
+ if (!template) {
109
+ return;
110
+ }
111
+ const children = template.ast.children;
112
+ if (children.length !== 3) {
113
+ return;
114
+ }
115
+ const [, scrollViewNode] = children;
116
+ if (!isRootScrollView(scrollViewNode)) {
117
+ return;
118
+ }
119
+ return {
120
+ loc: createStartTagLoc(code, scrollViewNode),
121
+ source: resolveStartTagSource(scrollViewNode),
122
+ };
123
+ }
124
+ function createStartTagLoc(code, node) {
125
+ const source = node.loc.source || '';
126
+ const endOffsetInSource = source.indexOf('>');
127
+ if (endOffsetInSource === -1) {
128
+ return {
129
+ start: node.loc.start,
130
+ end: node.loc.end,
131
+ };
132
+ }
133
+ return (0, utils_2.offsetToStartAndEnd)(code, node.loc.start.offset, node.loc.start.offset + endOffsetInSource + 1);
134
+ }
135
+ function resolveStartTagSource(node) {
136
+ const source = node.loc.source || '';
137
+ const endOffsetInSource = source.indexOf('>');
138
+ if (endOffsetInSource === -1) {
139
+ return source;
140
+ }
141
+ return source.slice(0, endOffsetInSource + 1);
142
+ }
143
+ function createWarnCodeFrameSource(location) {
144
+ return `${'\n'.repeat(Math.max(location.loc.start.line - 1, 0))}${location.source}`;
145
+ }
146
+ function resolveAppRootScrollViewEditRangesByCode(code, filename) {
147
+ const template = parseSfcTemplate(code, filename);
148
+ if (!template) {
149
+ return [];
150
+ }
151
+ const children = template.ast.children;
152
+ if (children.length !== 3) {
153
+ return [];
154
+ }
155
+ const [ifdefNode, scrollViewNode, endifNode] = children;
156
+ if (!isAppIfdefComment(ifdefNode) ||
157
+ !isRootScrollView(scrollViewNode) ||
158
+ !isEndifComment(endifNode)) {
159
+ return [];
160
+ }
161
+ // 使用项目既有的条件编译实现先跑一遍,再交给 Vue 编译器确认 APP 分支根节点。
162
+ if (!isPreprocessedRootScrollView(template.content, filename)) {
163
+ return [];
164
+ }
165
+ return createRootScrollViewEditRanges(ifdefNode, scrollViewNode, endifNode);
166
+ }
167
+ exports.resolveAppRootScrollViewEditRangesByCode = resolveAppRootScrollViewEditRangesByCode;
168
+ function parseSfcTemplate(code, filename) {
169
+ const { descriptor, errors } = (0, compiler_sfc_1.parse)(code, {
170
+ filename,
171
+ sourceMap: false,
172
+ });
173
+ if (errors.length || !descriptor.template?.ast) {
174
+ return;
175
+ }
176
+ return {
177
+ content: descriptor.template.content,
178
+ ast: descriptor.template.ast,
179
+ };
180
+ }
181
+ function isPreprocessedRootScrollView(content, filename) {
182
+ try {
183
+ const preprocessed = preprocessHtml(content, createAppPreContext(), {
184
+ type: 'html',
185
+ });
186
+ const template = parseSfcTemplate(`<template>${preprocessed}</template>`, filename);
187
+ const root = template?.ast.children[0];
188
+ return (!!root && template.ast.children.length === 1 && root.tag === 'scroll-view');
189
+ }
190
+ catch (e) {
191
+ return false;
192
+ }
193
+ }
194
+ function createAppPreContext() {
195
+ // 这里只声明本函数需要的 APP/UVue 上下文,避免改动全局条件编译上下文。
196
+ return {
197
+ APP: true,
198
+ APP_UVUE: true,
199
+ UNI_APP_X: true,
200
+ VUE3: true,
201
+ VUE3_VAPOR: true,
202
+ };
203
+ }
204
+ function isAppIfdefComment(node) {
205
+ return (node.type === 3 /* NodeTypes.COMMENT */ && node.content?.trim() === '#ifdef APP');
206
+ }
207
+ function isEndifComment(node) {
208
+ return node.type === 3 /* NodeTypes.COMMENT */ && node.content?.trim() === '#endif';
209
+ }
210
+ function isRootScrollView(node) {
211
+ return (node.type === 1 /* NodeTypes.ELEMENT */ &&
212
+ node.tag === 'scroll-view' &&
213
+ hasOnlyFlexStyle(node));
214
+ }
215
+ function hasOnlyFlexStyle(node) {
216
+ if (!node.props || node.props.length !== 1) {
217
+ return false;
218
+ }
219
+ const style = node.props[0];
220
+ return (style.type === 6 /* NodeTypes.ATTRIBUTE */ &&
221
+ style.name === 'style' &&
222
+ !!style.value &&
223
+ normalizeFlexStyle(style.value.content) === 'flex:1');
224
+ }
225
+ function normalizeFlexStyle(style) {
226
+ let normalized = '';
227
+ for (let i = 0; i < style.length; i++) {
228
+ const char = style.charAt(i);
229
+ if (char !== ' ' && char !== '\t' && char !== '\n' && char !== '\r') {
230
+ normalized += char;
231
+ }
232
+ }
233
+ if (normalized.endsWith(';')) {
234
+ return normalized.slice(0, -1);
235
+ }
236
+ return normalized;
237
+ }
238
+ function createRootScrollViewEditRanges(ifdefNode, scrollViewNode, endifNode) {
239
+ const children = scrollViewNode.children || [];
240
+ if (!children.length) {
241
+ return [createEditRange(ifdefNode, endifNode)];
242
+ }
243
+ const firstChild = children[0];
244
+ const lastChild = children[children.length - 1];
245
+ // 兼容如下写法:条件编译分别包裹 scroll-view 的开始标签和结束标签。
246
+ // <!-- #ifdef APP -->
247
+ // <scroll-view style="flex:1">
248
+ // <!-- #endif -->
249
+ // ...
250
+ // <!-- #ifdef APP -->
251
+ // </scroll-view>
252
+ // <!-- #endif -->
253
+ if (isEndifComment(firstChild) && isAppIfdefComment(lastChild)) {
254
+ return [
255
+ createEditRangeByLoc(ifdefNode.loc.start, firstChild.loc.end),
256
+ createEditRangeByLoc(lastChild.loc.start, endifNode.loc.end),
257
+ ];
258
+ }
259
+ return [
260
+ createEditRangeByLoc(ifdefNode.loc.start, firstChild.loc.start, true),
261
+ createEditRangeByLoc(lastChild.loc.end, endifNode.loc.end),
262
+ ];
263
+ }
264
+ function createEditRange(startNode, endNode) {
265
+ return createEditRangeByLoc(startNode.loc.start, endNode.loc.end);
266
+ }
267
+ function createEditRangeByLoc(start, end, preserveEndIndent = false) {
268
+ const range = {
269
+ start: toPosition(start),
270
+ end: toPosition(end),
271
+ preserveLineBreaks: true,
272
+ };
273
+ if (preserveEndIndent) {
274
+ range.preserveEndIndent = true;
275
+ }
276
+ return range;
277
+ }
278
+ function toPosition(loc) {
279
+ return {
280
+ line: loc.line,
281
+ column: loc.column,
282
+ };
283
+ }
package/dist/hbx/alias.js CHANGED
@@ -78,27 +78,8 @@ function initModuleAlias() {
78
78
  if (process.env.UNI_APP_PLATFORM ||
79
79
  process.env.UNI_PLATFORM === 'app-harmony') {
80
80
  if (!process.env.UNI_APP_X_VAPOR_RENDER_TARGET) {
81
- // ios harmony 平台默认使用 bytecode 目标,存在 .native 文件时使用 native 目标;其他平台如果存在 .dynamic 文件则使用 bytecode 目标,否则使用 native 目标
82
- if (process.env.UNI_APP_PLATFORM === 'ios' ||
83
- process.env.UNI_APP_PLATFORM === 'harmony' ||
84
- process.env.UNI_PLATFORM === 'app-harmony') {
85
- if (process.env.UNI_INPUT_DIR &&
86
- fs_1.default.existsSync(path_1.default.resolve(process.env.UNI_INPUT_DIR, '.native'))) {
87
- process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'nativecode';
88
- }
89
- else {
90
- process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
91
- }
92
- }
93
- else {
94
- if (process.env.UNI_INPUT_DIR &&
95
- fs_1.default.existsSync(path_1.default.resolve(process.env.UNI_INPUT_DIR, '.dynamic'))) {
96
- process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
97
- }
98
- else {
99
- process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'nativecode';
100
- }
101
- }
81
+ // 默认 app 平台使用 bytecode 目标
82
+ process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
102
83
  }
103
84
  if (process.env.UNI_APP_X_VAPOR_RENDER_TARGET?.includes('bytecode')) {
104
85
  process.env.UNI_APP_X_DOM2_DYNAMIC = 'true';
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export * from './platform';
26
26
  export * from './utsUtils';
27
27
  export * from './workers';
28
28
  export { parseUniExtApi, parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, formatExtApiProviderName, } from './uni_modules';
29
- export { getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
29
+ export { copyEncryptUniModulesDom2Bytes, getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
30
30
  import type { EncryptPackageJson } from './uni_modules.cloud';
31
31
  export type EncryptArtifacts = EncryptPackageJson['uni_modules']['artifacts'];
32
32
  export { M } from './messages';
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.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
17
+ exports.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = exports.copyEncryptUniModulesDom2Bytes = 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);
@@ -49,6 +49,7 @@ Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function
49
49
  Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
50
50
  Object.defineProperty(exports, "formatExtApiProviderName", { enumerable: true, get: function () { return uni_modules_1.formatExtApiProviderName; } });
51
51
  var uni_modules_cloud_1 = require("./uni_modules.cloud");
52
+ Object.defineProperty(exports, "copyEncryptUniModulesDom2Bytes", { enumerable: true, get: function () { return uni_modules_cloud_1.copyEncryptUniModulesDom2Bytes; } });
52
53
  Object.defineProperty(exports, "getUniModulesEncryptType", { enumerable: true, get: function () { return uni_modules_cloud_1.getUniModulesEncryptType; } });
53
54
  Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_cloud_1.parseUniModulesArtifacts; } });
54
55
  Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_cloud_1.resolveEncryptUniModule; } });
@@ -117,7 +117,15 @@ function initUniStatistics(manifestJson) {
117
117
  if (!uniStatistics) {
118
118
  return;
119
119
  }
120
- if (uniStatistics.version === 2 || uniStatistics.version === '2') {
120
+ /**
121
+ * 判断是否为私有版统计:
122
+ * - 新配置:type === 'private'
123
+ * - 旧配置兼容:version === 2
124
+ */
125
+ const isPrivateStat = uniStatistics.type === 'private' ||
126
+ uniStatistics.version === 2 ||
127
+ uniStatistics.version === '2';
128
+ if (isPrivateStat) {
121
129
  if (uniStatistics.uniCloud && uniStatistics.uniCloud.spaceId) {
122
130
  return;
123
131
  }
@@ -46,7 +46,7 @@ function defineNVuePageCode(pagesJson) {
46
46
  }
47
47
  const pagePathWithExtname = (0, utils_1.normalizePagePath)(page.path, 'app');
48
48
  if (pagePathWithExtname) {
49
- importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>res.default)`);
49
+ importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>{res()})`);
50
50
  }
51
51
  });
52
52
  return importNVuePagesCode.join('\n');
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.appendConsoleExpr = exports.restoreConsoleExpr = exports.rewriteConsoleExpr = void 0;
7
7
  const magic_string_1 = __importDefault(require("magic-string"));
8
8
  const utils_1 = require("../utils");
9
- const x_1 = require("../x");
10
9
  function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
11
10
  filename = (0, utils_1.normalizePath)(filename);
12
11
  const re = /(console\.(log|info|debug|warn|error))\s*\(([^)]+)\)/g;
@@ -20,9 +19,7 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
20
19
  if (s.hasChanged()) {
21
20
  return {
22
21
  code: s.toString(),
23
- map: sourceMap
24
- ? s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() })
25
- : { mappings: '' },
22
+ map: sourceMap ? s.generateMap({ hires: true }) : { mappings: '' },
26
23
  };
27
24
  }
28
25
  return { code, map: null };
@@ -15,15 +15,17 @@ declare const _default: {
15
15
  readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
16
16
  readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
17
17
  readonly 'dev.watching.restart.vapor': "DONE Restart required. Switching vapor mode requires restarting to take effect.";
18
+ readonly 'dev.watching.vapor.render.target': "vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.";
18
19
  readonly 'build.failed': "DONE Build failed.";
19
20
  readonly 'compiler.build.failed': "Build failed with errors.";
20
21
  readonly 'stat.warn.appid': "The current application is not configured with Appid, and uni statistics cannot be used. For details, see https://ask.dcloud.net.cn/article/36303";
21
- readonly 'stat.warn.version': "The uni statistics version is not configured. The default version is 1.0.uni statistics version 2.0 is recommended, private deployment data is more secure and code is open source and customizable. details: https://uniapp.dcloud.io/uni-stat";
22
- readonly 'stat.warn.tip': "uni statistics version: {version}";
22
+ readonly 'stat.warn.version': "The uni statistics type is not configured. The default type is public. You can set it to public or private. Details: https://uniapp.dcloud.io/uni-stat";
23
+ readonly 'stat.warn.tip': "uni statistics enabled: {type}";
23
24
  readonly 'i18n.fallbackLocale.default': "fallbackLocale is missing in manifest.json, use: {locale}";
24
25
  readonly 'i18n.fallbackLocale.missing': "./local/{locale}.json is missing";
25
26
  readonly 'easycom.conflict': "easycom component conflict: ";
26
27
  readonly 'dom2.compatible.component': "Vapor mode does not support the uni-app compatibility component {name}. The implementation file {file} was detected. Please use the standard UTS component implementation for this purpose.";
28
+ readonly 'dom2.root.scroll.view': "Pages are scrollable in Vapor mode. Remove the root scroll-view to avoid nested scrolling. Details: https://doc.dcloud.net.cn/uni-app-x/page.html#disablescroll";
27
29
  readonly 'mp.component.args[0]': "The first parameter of {0} must be a static string";
28
30
  readonly 'mp.component.args[1]': "{0} requires two parameters";
29
31
  readonly 'mp.360.unsupported': "360 is unsupported";
@@ -17,15 +17,17 @@ exports.default = {
17
17
  'dev.watching.end.pages': 'DONE Build complete. PAGES:{pages}',
18
18
  'dev.watching.end.files': 'DONE Build complete. FILES:{files}',
19
19
  'dev.watching.restart.vapor': 'DONE Restart required. Switching vapor mode requires restarting to take effect.',
20
+ 'dev.watching.vapor.render.target': 'vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.',
20
21
  'build.failed': 'DONE Build failed.',
21
22
  'compiler.build.failed': 'Build failed with errors.',
22
23
  'stat.warn.appid': 'The current application is not configured with Appid, and uni statistics cannot be used. For details, see https://ask.dcloud.net.cn/article/36303',
23
- 'stat.warn.version': 'The uni statistics version is not configured. The default version is 1.0.uni statistics version 2.0 is recommended, private deployment data is more secure and code is open source and customizable. details: https://uniapp.dcloud.io/uni-stat',
24
- 'stat.warn.tip': 'uni statistics version: {version}',
24
+ 'stat.warn.version': 'The uni statistics type is not configured. The default type is public. You can set it to public or private. Details: https://uniapp.dcloud.io/uni-stat',
25
+ 'stat.warn.tip': 'uni statistics enabled: {type}',
25
26
  'i18n.fallbackLocale.default': 'fallbackLocale is missing in manifest.json, use: {locale}',
26
27
  'i18n.fallbackLocale.missing': './local/{locale}.json is missing',
27
28
  'easycom.conflict': 'easycom component conflict: ',
28
29
  'dom2.compatible.component': 'Vapor mode does not support the uni-app compatibility component {name}. The implementation file {file} was detected. Please use the standard UTS component implementation for this purpose.',
30
+ 'dom2.root.scroll.view': 'Pages are scrollable in Vapor mode. Remove the root scroll-view to avoid nested scrolling. Details: https://doc.dcloud.net.cn/uni-app-x/page.html#disablescroll',
29
31
  'mp.component.args[0]': 'The first parameter of {0} must be a static string',
30
32
  'mp.component.args[1]': '{0} requires two parameters',
31
33
  'mp.360.unsupported': '360 is unsupported',
@@ -15,15 +15,17 @@ export declare const M: {
15
15
  readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
16
16
  readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
17
17
  readonly 'dev.watching.restart.vapor': "DONE Restart required. 切换蒸汽模式需要重新运行才能生效。";
18
+ readonly 'dev.watching.vapor.render.target': "manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。";
18
19
  readonly 'build.failed': "DONE Build failed.";
19
20
  readonly 'compiler.build.failed': "编译失败";
20
21
  readonly 'stat.warn.appid': "当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303";
21
- readonly 'stat.warn.version': "当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情:https://uniapp.dcloud.io/uni-stat";
22
- readonly 'stat.warn.tip': "已开启 uni统计{version} 版本";
22
+ readonly 'stat.warn.version': "当前应用未配置 uni 统计版本,默认使用公有版;可配置为公有版或私有版。详情:https://uniapp.dcloud.io/uni-stat";
23
+ readonly 'stat.warn.tip': "已开启uni 统计 2.0{type}";
23
24
  readonly 'i18n.fallbackLocale.default': "当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}";
24
25
  readonly 'i18n.fallbackLocale.missing': "当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件";
25
26
  readonly 'easycom.conflict': "easycom组件冲突:";
26
27
  readonly 'dom2.compatible.component': "蒸汽模式不支持 uni-app 兼容模式组件 {name},检测到其实现文件为 {file}。请改用标准模式的UTS组件实现来实现。";
28
+ readonly 'dom2.root.scroll.view': "蒸汽模式下页面可滚动,建议移除根节点 scroll-view,以避免嵌套滚动。详情: https://doc.dcloud.net.cn/uni-app-x/page.html#disablescroll";
27
29
  readonly 'mp.component.args[0]': "{0}的第一个参数必须为静态字符串";
28
30
  readonly 'mp.component.args[1]': "{0}需要两个参数";
29
31
  readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
@@ -71,15 +73,17 @@ export declare const M: {
71
73
  readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
72
74
  readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
73
75
  readonly 'dev.watching.restart.vapor': "DONE Restart required. Switching vapor mode requires restarting to take effect.";
76
+ readonly 'dev.watching.vapor.render.target': "vapor-render-target in manifest.json was changed to {manifestTarget}, but the running console is still {runtimeTarget}.";
74
77
  readonly 'build.failed': "DONE Build failed.";
75
78
  readonly 'compiler.build.failed': "Build failed with errors.";
76
79
  readonly 'stat.warn.appid': "The current application is not configured with Appid, and uni statistics cannot be used. For details, see https://ask.dcloud.net.cn/article/36303";
77
- readonly 'stat.warn.version': "The uni statistics version is not configured. The default version is 1.0.uni statistics version 2.0 is recommended, private deployment data is more secure and code is open source and customizable. details: https://uniapp.dcloud.io/uni-stat";
78
- readonly 'stat.warn.tip': "uni statistics version: {version}";
80
+ readonly 'stat.warn.version': "The uni statistics type is not configured. The default type is public. You can set it to public or private. Details: https://uniapp.dcloud.io/uni-stat";
81
+ readonly 'stat.warn.tip': "uni statistics enabled: {type}";
79
82
  readonly 'i18n.fallbackLocale.default': "fallbackLocale is missing in manifest.json, use: {locale}";
80
83
  readonly 'i18n.fallbackLocale.missing': "./local/{locale}.json is missing";
81
84
  readonly 'easycom.conflict': "easycom component conflict: ";
82
85
  readonly 'dom2.compatible.component': "Vapor mode does not support the uni-app compatibility component {name}. The implementation file {file} was detected. Please use the standard UTS component implementation for this purpose.";
86
+ readonly 'dom2.root.scroll.view': "Pages are scrollable in Vapor mode. Remove the root scroll-view to avoid nested scrolling. Details: https://doc.dcloud.net.cn/uni-app-x/page.html#disablescroll";
83
87
  readonly 'mp.component.args[0]': "The first parameter of {0} must be a static string";
84
88
  readonly 'mp.component.args[1]': "{0} requires two parameters";
85
89
  readonly 'mp.360.unsupported': "360 is unsupported";
@@ -15,15 +15,17 @@ declare const _default: {
15
15
  readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
16
16
  readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
17
17
  readonly 'dev.watching.restart.vapor': "DONE Restart required. 切换蒸汽模式需要重新运行才能生效。";
18
+ readonly 'dev.watching.vapor.render.target': "manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。";
18
19
  readonly 'build.failed': "DONE Build failed.";
19
20
  readonly 'compiler.build.failed': "编译失败";
20
21
  readonly 'stat.warn.appid': "当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303";
21
- readonly 'stat.warn.version': "当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情:https://uniapp.dcloud.io/uni-stat";
22
- readonly 'stat.warn.tip': "已开启 uni统计{version} 版本";
22
+ readonly 'stat.warn.version': "当前应用未配置 uni 统计版本,默认使用公有版;可配置为公有版或私有版。详情:https://uniapp.dcloud.io/uni-stat";
23
+ readonly 'stat.warn.tip': "已开启uni 统计 2.0{type}";
23
24
  readonly 'i18n.fallbackLocale.default': "当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}";
24
25
  readonly 'i18n.fallbackLocale.missing': "当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件";
25
26
  readonly 'easycom.conflict': "easycom组件冲突:";
26
27
  readonly 'dom2.compatible.component': "蒸汽模式不支持 uni-app 兼容模式组件 {name},检测到其实现文件为 {file}。请改用标准模式的UTS组件实现来实现。";
28
+ readonly 'dom2.root.scroll.view': "蒸汽模式下页面可滚动,建议移除根节点 scroll-view,以避免嵌套滚动。详情: https://doc.dcloud.net.cn/uni-app-x/page.html#disablescroll";
27
29
  readonly 'mp.component.args[0]': "{0}的第一个参数必须为静态字符串";
28
30
  readonly 'mp.component.args[1]': "{0}需要两个参数";
29
31
  readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
@@ -17,15 +17,17 @@ exports.default = {
17
17
  'dev.watching.end.pages': 'DONE Build complete. PAGES:{pages}',
18
18
  'dev.watching.end.files': 'DONE Build complete. FILES:{files}',
19
19
  'dev.watching.restart.vapor': 'DONE Restart required. 切换蒸汽模式需要重新运行才能生效。',
20
+ 'dev.watching.vapor.render.target': 'manifest.json 中更改了视图层编译目标为{manifestTarget},但注意运行控制台还是{runtimeTarget}。',
20
21
  'build.failed': 'DONE Build failed.',
21
22
  'compiler.build.failed': '编译失败',
22
23
  'stat.warn.appid': '当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303',
23
- 'stat.warn.version': '当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情:https://uniapp.dcloud.io/uni-stat',
24
- 'stat.warn.tip': '已开启 uni统计{version} 版本',
24
+ 'stat.warn.version': '当前应用未配置 uni 统计版本,默认使用公有版;可配置为公有版或私有版。详情:https://uniapp.dcloud.io/uni-stat',
25
+ 'stat.warn.tip': '已开启uni 统计 2.0{type}',
25
26
  'i18n.fallbackLocale.default': '当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}',
26
27
  'i18n.fallbackLocale.missing': '当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件',
27
28
  'easycom.conflict': 'easycom组件冲突:',
28
29
  'dom2.compatible.component': '蒸汽模式不支持 uni-app 兼容模式组件 {name},检测到其实现文件为 {file}。请改用标准模式的UTS组件实现来实现。',
30
+ 'dom2.root.scroll.view': '蒸汽模式下页面可滚动,建议移除根节点 scroll-view,以避免嵌套滚动。详情: https://doc.dcloud.net.cn/uni-app-x/page.html#disablescroll',
29
31
  'mp.component.args[0]': '{0}的第一个参数必须为静态字符串',
30
32
  'mp.component.args[1]': '{0}需要两个参数',
31
33
  'mp.360.unsupported': 'vue3暂不支持360小程序',
@@ -1,17 +1,16 @@
1
1
  import type { PluginCreator } from 'postcss';
2
2
  /**
3
- * PostCSS plugin to boost specificity for page CSS based on externalClasses usage
3
+ * 基于页面 externalClasses 使用情况提升页面样式优先级
4
4
  *
5
- * For mini-program platforms (mp-*):
6
- * - If page has no externalClasses usage: no transformation
7
- * - If page has dynamic externalClasses: all selectors get page prefix
8
- * .a -> page .a
9
- * - If page has only static externalClasses: only matching selectors get page prefix
10
- * .foo -> page .foo (if "foo" is in staticClasses)
11
- * .bar -> .bar (unchanged, if "bar" is not in staticClasses)
5
+ * 小程序平台(mp-*):
6
+ * - 页面没有使用 externalClasses:不做转换
7
+ * - 页面存在动态 externalClasses:选择器最后一个 class 追加 [class]
8
+ * .a -> .a[class]
9
+ * - 页面只有静态 externalClasses:仅命中静态 class 的选择器追加 [class]
10
+ * .foo -> .foo[class](foo staticClasses 中)
11
+ * .bar -> .barbar 不在 staticClasses 中)
12
12
  *
13
- * This ensures page styles have higher specificity than component styles
14
- * while minimizing unnecessary transformations for performance
13
+ * 追加 [class] 可以提升 class 选择器优先级,同时避免原先插入 page 带来的结构影响。
15
14
  */
16
15
  declare const externalPlugin: PluginCreator<void>;
17
16
  export default externalPlugin;