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

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 (83) hide show
  1. package/dist/dom2/index.d.ts +0 -1
  2. package/dist/dom2/index.js +0 -1
  3. package/dist/hbx/alias.js +21 -2
  4. package/dist/hbx/index.d.ts +1 -1
  5. package/dist/i18n.js +32 -17
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -2
  8. package/dist/json/app/manifest/plus.js +1 -9
  9. package/dist/json/app/pages/definePage.js +1 -1
  10. package/dist/logs/console.js +15 -1
  11. package/dist/messages/en.d.ts +2 -4
  12. package/dist/messages/en.js +2 -4
  13. package/dist/messages/index.d.ts +4 -8
  14. package/dist/messages/zh_CN.d.ts +2 -4
  15. package/dist/messages/zh_CN.js +2 -4
  16. package/dist/mp/imports.d.ts +3 -1
  17. package/dist/mp/template.d.ts +2 -1
  18. package/dist/mp/usingComponents.d.ts +2 -1
  19. package/dist/postcss/plugins/stylePluginExternal.d.ts +10 -9
  20. package/dist/postcss/plugins/stylePluginExternal.js +45 -51
  21. package/dist/uni_modules.cloud.d.ts +0 -5
  22. package/dist/uni_modules.cloud.js +1 -102
  23. package/dist/vite/cloud.js +2 -5
  24. package/dist/vite/index.d.ts +2 -3
  25. package/dist/vite/plugins/console.js +31 -27
  26. package/dist/vite/plugins/copy.js +1 -0
  27. package/dist/vite/plugins/cssScoped.js +25 -16
  28. package/dist/vite/plugins/dynamicImportPolyfill.d.ts +8 -1
  29. package/dist/vite/plugins/easycom.js +46 -43
  30. package/dist/vite/plugins/inject.js +132 -113
  31. package/dist/vite/plugins/json.js +17 -14
  32. package/dist/vite/plugins/jsonJs.d.ts +2 -2
  33. package/dist/vite/plugins/jsonJs.js +7 -0
  34. package/dist/vite/plugins/mainJs.d.ts +1 -1
  35. package/dist/vite/plugins/mainJs.js +7 -0
  36. package/dist/vite/plugins/pre.js +35 -32
  37. package/dist/vite/plugins/sfc.js +15 -2
  38. package/dist/vite/plugins/sourceMap.js +4 -1
  39. package/dist/vite/plugins/stats.d.ts +1 -5
  40. package/dist/vite/plugins/stats.js +2 -71
  41. package/dist/vite/plugins/uts/ext-api.js +23 -17
  42. package/dist/vite/plugins/uts/uni_modules.js +66 -44
  43. package/dist/vite/plugins/uts/uvue.js +55 -48
  44. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +12 -4
  45. package/dist/vite/plugins/vitejs/plugins/asset.js +7 -2
  46. package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -1
  47. package/dist/vite/plugins/vitejs/plugins/css.js +102 -82
  48. package/dist/vite/utils/utils.d.ts +3 -2
  49. package/dist/vue/transforms/index.d.ts +0 -1
  50. package/dist/vue/transforms/index.js +0 -1
  51. package/dist/vue/transforms/x/transformDirection.js +4 -33
  52. package/dist/watcher.d.ts +1 -0
  53. package/dist/x.d.ts +1 -0
  54. package/dist/x.js +5 -1
  55. package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +16 -23
  56. package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +16 -23
  57. package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +16 -23
  58. package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +23 -66
  59. package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +67 -115
  60. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +1 -1
  61. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +1 -1
  62. package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +1 -1
  63. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +1 -1
  64. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +1 -1
  65. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +1 -1
  66. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +1 -1
  67. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +1 -1
  68. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +1 -1
  69. package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +1 -1
  70. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +3 -3
  71. package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +45 -217
  72. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +43 -218
  73. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +12 -62
  74. package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +44 -228
  75. package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
  76. package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +1 -1
  77. package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +1 -1
  78. package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +1 -1
  79. package/package.json +8 -9
  80. package/dist/dom2/rootScrollView.d.ts +0 -47
  81. package/dist/dom2/rootScrollView.js +0 -283
  82. package/dist/vue/transforms/transformTeleport.d.ts +0 -2
  83. package/dist/vue/transforms/transformTeleport.js +0 -63
@@ -1,4 +1,3 @@
1
1
  export * from './sharedData';
2
2
  export * from './vue';
3
3
  export * from './fontFamily';
4
- export * from './rootScrollView';
@@ -17,4 +17,3 @@ 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);
package/dist/hbx/alias.js CHANGED
@@ -78,8 +78,27 @@ 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
- // 默认 app 平台使用 bytecode 目标
82
- process.env.UNI_APP_X_VAPOR_RENDER_TARGET = 'bytecode';
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
+ }
83
102
  }
84
103
  if (process.env.UNI_APP_X_VAPOR_RENDER_TARGET?.includes('bytecode')) {
85
104
  process.env.UNI_APP_X_DOM2_DYNAMIC = 'true';
@@ -1,5 +1,5 @@
1
1
  export { formatAtFilename, createErrorWithBlockFlag } from './log';
2
2
  export * from './env';
3
3
  export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
4
- export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
4
+ export declare function uniHBuilderXConsolePlugin(method?: string): import("vite/dist/node").Plugin<any>;
5
5
  export declare function isEnableConsole(): boolean;
package/dist/i18n.js CHANGED
@@ -47,36 +47,51 @@ function isUniAppLocaleFile(filepath) {
47
47
  return localeJsonRE.test(path_1.default.basename(filepath));
48
48
  }
49
49
  exports.isUniAppLocaleFile = isUniAppLocaleFile;
50
+ const localeJsonCache = new Map();
50
51
  function parseLocaleJson(filepath) {
52
+ const { mtimeMs, size } = fs_1.default.statSync(filepath);
53
+ const cached = localeJsonCache.get(filepath);
54
+ if (cached && cached.mtimeMs === mtimeMs && cached.size === size) {
55
+ return cached.json;
56
+ }
51
57
  let jsonObj = (0, json_1.parseJson)(fs_1.default.readFileSync(filepath, 'utf8'), false, filepath);
52
58
  if (isUniAppLocaleFile(filepath)) {
53
59
  jsonObj = jsonObj.common || {};
54
60
  }
61
+ localeJsonCache.set(filepath, { mtimeMs, size, json: jsonObj });
55
62
  return jsonObj;
56
63
  }
64
+ const localeFilesCache = new Map();
57
65
  function getLocaleFiles(cwd) {
58
- return (0, fast_glob_1.sync)('*.json', { cwd, absolute: true });
66
+ let mtimeMs;
67
+ try {
68
+ mtimeMs = fs_1.default.statSync(cwd).mtimeMs;
69
+ }
70
+ catch {
71
+ return [];
72
+ }
73
+ const cached = localeFilesCache.get(cwd);
74
+ if (cached && cached.mtimeMs === mtimeMs) {
75
+ return cached.files;
76
+ }
77
+ const files = (0, fast_glob_1.sync)('*.json', { cwd, absolute: true });
78
+ localeFilesCache.set(cwd, { mtimeMs, files });
79
+ return files;
59
80
  }
60
81
  exports.getLocaleFiles = getLocaleFiles;
61
82
  function initLocales(dir, withMessages = true) {
62
- if (!fs_1.default.existsSync(dir)) {
63
- return {};
64
- }
65
- return fs_1.default.readdirSync(dir).reduce((res, filename) => {
66
- if (path_1.default.extname(filename) === '.json') {
67
- try {
68
- const locale = path_1.default
69
- .basename(filename)
70
- .replace(/(uni-app.)?(.*).json/, '$2');
71
- if (withMessages) {
72
- (0, shared_1.extend)(res[locale] || (res[locale] = {}), parseLocaleJson(path_1.default.join(dir, filename)));
73
- }
74
- else {
75
- res[locale] = {};
76
- }
83
+ return getLocaleFiles(dir).reduce((res, filepath) => {
84
+ const filename = path_1.default.basename(filepath);
85
+ try {
86
+ const locale = filename.replace(/(uni-app.)?(.*).json/, '$2');
87
+ if (withMessages) {
88
+ (0, shared_1.extend)(res[locale] || (res[locale] = {}), parseLocaleJson(filepath));
89
+ }
90
+ else {
91
+ res[locale] = {};
77
92
  }
78
- catch (e) { }
79
93
  }
94
+ catch { }
80
95
  return res;
81
96
  }, {});
82
97
  }
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 { copyEncryptUniModulesDom2Bytes, getUniModulesEncryptType, parseUniModulesArtifacts, resolveEncryptUniModule, } from './uni_modules.cloud';
29
+ export { 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.copyEncryptUniModulesDom2Bytes = exports.formatExtApiProviderName = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
17
+ exports.checkUpdate = exports.M = exports.resolveEncryptUniModule = exports.parseUniModulesArtifacts = exports.getUniModulesEncryptType = 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,7 +49,6 @@ 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; } });
53
52
  Object.defineProperty(exports, "getUniModulesEncryptType", { enumerable: true, get: function () { return uni_modules_cloud_1.getUniModulesEncryptType; } });
54
53
  Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_cloud_1.parseUniModulesArtifacts; } });
55
54
  Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_cloud_1.resolveEncryptUniModule; } });
@@ -117,15 +117,7 @@ function initUniStatistics(manifestJson) {
117
117
  if (!uniStatistics) {
118
118
  return;
119
119
  }
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) {
120
+ if (uniStatistics.version === 2 || uniStatistics.version === '2') {
129
121
  if (uniStatistics.uniCloud && uniStatistics.uniCloud.spaceId) {
130
122
  return;
131
123
  }
@@ -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()})`);
49
+ importNVuePagesCode.push(`import('./${pagePathWithExtname}').then((res)=>res.default)`);
50
50
  }
51
51
  });
52
52
  return importNVuePagesCode.join('\n');
@@ -6,6 +6,7 @@ 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");
9
10
  function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
10
11
  filename = (0, utils_1.normalizePath)(filename);
11
12
  const re = /(console\.(log|info|debug|warn|error))\s*\(([^)]+)\)/g;
@@ -19,12 +20,25 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
19
20
  if (s.hasChanged()) {
20
21
  return {
21
22
  code: s.toString(),
22
- map: sourceMap ? s.generateMap({ hires: true }) : { mappings: '' },
23
+ map: sourceMap
24
+ ? normalizeSourceMap(s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() }))
25
+ : { mappings: '' },
23
26
  };
24
27
  }
25
28
  return { code, map: null };
26
29
  }
27
30
  exports.rewriteConsoleExpr = rewriteConsoleExpr;
31
+ function normalizeSourceMap(map) {
32
+ return {
33
+ ...map,
34
+ file: map.file || '',
35
+ names: map.names || [],
36
+ sources: map.sources || [],
37
+ sourcesContent: map.sourcesContent || [],
38
+ toString: () => map.toString(),
39
+ toUrl: () => map.toUrl(),
40
+ };
41
+ }
28
42
  function restoreConsoleExpr(code) {
29
43
  return code.replace(/(?:uni\.)?__f__\('([^']+)','at ([^:]+):(\d+)',/g, 'console.$1(');
30
44
  }
@@ -15,17 +15,15 @@ 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}.";
19
18
  readonly 'build.failed': "DONE Build failed.";
20
19
  readonly 'compiler.build.failed': "Build failed with errors.";
21
20
  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";
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}";
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}";
24
23
  readonly 'i18n.fallbackLocale.default': "fallbackLocale is missing in manifest.json, use: {locale}";
25
24
  readonly 'i18n.fallbackLocale.missing': "./local/{locale}.json is missing";
26
25
  readonly 'easycom.conflict': "easycom component conflict: ";
27
26
  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";
29
27
  readonly 'mp.component.args[0]': "The first parameter of {0} must be a static string";
30
28
  readonly 'mp.component.args[1]': "{0} requires two parameters";
31
29
  readonly 'mp.360.unsupported': "360 is unsupported";
@@ -17,17 +17,15 @@ 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}.',
21
20
  'build.failed': 'DONE Build failed.',
22
21
  'compiler.build.failed': 'Build failed with errors.',
23
22
  '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',
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}',
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}',
26
25
  'i18n.fallbackLocale.default': 'fallbackLocale is missing in manifest.json, use: {locale}',
27
26
  'i18n.fallbackLocale.missing': './local/{locale}.json is missing',
28
27
  'easycom.conflict': 'easycom component conflict: ',
29
28
  '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',
31
29
  'mp.component.args[0]': 'The first parameter of {0} must be a static string',
32
30
  'mp.component.args[1]': '{0} requires two parameters',
33
31
  'mp.360.unsupported': '360 is unsupported',
@@ -15,17 +15,15 @@ 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}。";
19
18
  readonly 'build.failed': "DONE Build failed.";
20
19
  readonly 'compiler.build.failed': "编译失败";
21
20
  readonly 'stat.warn.appid': "当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303";
22
- readonly 'stat.warn.version': "当前应用未配置 uni 统计版本,默认使用公有版;可配置为公有版或私有版。详情:https://uniapp.dcloud.io/uni-stat";
23
- readonly 'stat.warn.tip': "已开启uni 统计 2.0{type}";
21
+ readonly 'stat.warn.version': "当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情:https://uniapp.dcloud.io/uni-stat";
22
+ readonly 'stat.warn.tip': "已开启 uni统计{version} 版本";
24
23
  readonly 'i18n.fallbackLocale.default': "当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}";
25
24
  readonly 'i18n.fallbackLocale.missing': "当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件";
26
25
  readonly 'easycom.conflict': "easycom组件冲突:";
27
26
  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";
29
27
  readonly 'mp.component.args[0]': "{0}的第一个参数必须为静态字符串";
30
28
  readonly 'mp.component.args[1]': "{0}需要两个参数";
31
29
  readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
@@ -73,17 +71,15 @@ export declare const M: {
73
71
  readonly 'dev.watching.end.pages': "DONE Build complete. PAGES:{pages}";
74
72
  readonly 'dev.watching.end.files': "DONE Build complete. FILES:{files}";
75
73
  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}.";
77
74
  readonly 'build.failed': "DONE Build failed.";
78
75
  readonly 'compiler.build.failed': "Build failed with errors.";
79
76
  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";
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}";
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}";
82
79
  readonly 'i18n.fallbackLocale.default': "fallbackLocale is missing in manifest.json, use: {locale}";
83
80
  readonly 'i18n.fallbackLocale.missing': "./local/{locale}.json is missing";
84
81
  readonly 'easycom.conflict': "easycom component conflict: ";
85
82
  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";
87
83
  readonly 'mp.component.args[0]': "The first parameter of {0} must be a static string";
88
84
  readonly 'mp.component.args[1]': "{0} requires two parameters";
89
85
  readonly 'mp.360.unsupported': "360 is unsupported";
@@ -15,17 +15,15 @@ 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}。";
19
18
  readonly 'build.failed': "DONE Build failed.";
20
19
  readonly 'compiler.build.failed': "编译失败";
21
20
  readonly 'stat.warn.appid': "当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303";
22
- readonly 'stat.warn.version': "当前应用未配置 uni 统计版本,默认使用公有版;可配置为公有版或私有版。详情:https://uniapp.dcloud.io/uni-stat";
23
- readonly 'stat.warn.tip': "已开启uni 统计 2.0{type}";
21
+ readonly 'stat.warn.version': "当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情:https://uniapp.dcloud.io/uni-stat";
22
+ readonly 'stat.warn.tip': "已开启 uni统计{version} 版本";
24
23
  readonly 'i18n.fallbackLocale.default': "当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}";
25
24
  readonly 'i18n.fallbackLocale.missing': "当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件";
26
25
  readonly 'easycom.conflict': "easycom组件冲突:";
27
26
  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";
29
27
  readonly 'mp.component.args[0]': "{0}的第一个参数必须为静态字符串";
30
28
  readonly 'mp.component.args[1]': "{0}需要两个参数";
31
29
  readonly 'mp.360.unsupported': "vue3暂不支持360小程序";
@@ -17,17 +17,15 @@ 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}。',
21
20
  'build.failed': 'DONE Build failed.',
22
21
  'compiler.build.failed': '编译失败',
23
22
  'stat.warn.appid': '当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303',
24
- 'stat.warn.version': '当前应用未配置 uni 统计版本,默认使用公有版;可配置为公有版或私有版。详情:https://uniapp.dcloud.io/uni-stat',
25
- 'stat.warn.tip': '已开启uni 统计 2.0{type}',
23
+ 'stat.warn.version': '当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情:https://uniapp.dcloud.io/uni-stat',
24
+ 'stat.warn.tip': '已开启 uni统计{version} 版本',
26
25
  'i18n.fallbackLocale.default': '当前应用未在 manifest.json 配置 fallbackLocale,默认使用:{locale}',
27
26
  'i18n.fallbackLocale.missing': '当前应用配置的 fallbackLocale 或 locale 为:{locale},但 locale 目录缺少该语言文件',
28
27
  'easycom.conflict': 'easycom组件冲突:',
29
28
  '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',
31
29
  'mp.component.args[0]': '{0}的第一个参数必须为静态字符串',
32
30
  'mp.component.args[1]': '{0}需要两个参数',
33
31
  'mp.360.unsupported': 'vue3暂不支持360小程序',
@@ -1,5 +1,6 @@
1
- import type { PluginContext } from 'rollup';
2
1
  import { type ImportSpecifier } from 'es-module-lexer';
2
+ import type { Rolldown } from 'vite';
3
+ type PluginContext = Rolldown.PluginContext;
3
4
  /**
4
5
  * 暂时没用
5
6
  * @param source
@@ -10,3 +11,4 @@ import { type ImportSpecifier } from 'es-module-lexer';
10
11
  export declare function findVueComponentImports(source: string, importer: string, resolve: PluginContext['resolve']): Promise<(ImportSpecifier & {
11
12
  i: string;
12
13
  })[]>;
14
+ export {};
@@ -1,6 +1,7 @@
1
- import type { EmittedAsset } from 'rollup';
1
+ import type { Rolldown } from 'vite';
2
2
  import type { AttributeNode, DirectiveNode, ElementNode } from '@vue/compiler-core';
3
3
  import type { MiniProgramComponentsType } from '../json/mp/types';
4
+ type EmittedAsset = Rolldown.EmittedAsset;
4
5
  type LazyElementFn = (node: ElementNode, context: {
5
6
  isMiniProgramComponent(name: string): MiniProgramComponentsType | undefined;
6
7
  }) => {
@@ -1,5 +1,6 @@
1
1
  import { type ImportDeclaration, type Program } from '@babel/types';
2
- import type { PluginContext } from 'rollup';
2
+ import type { Rolldown } from 'vite';
3
+ type PluginContext = Rolldown.PluginContext;
3
4
  type BindingComponents = Record<string, {
4
5
  tag: string;
5
6
  type: 'unknown' | 'setup' | 'self';
@@ -1,16 +1,17 @@
1
1
  import type { PluginCreator } from 'postcss';
2
2
  /**
3
- * 基于页面 externalClasses 使用情况提升页面样式优先级
3
+ * PostCSS plugin to boost specificity for page CSS based on externalClasses usage
4
4
  *
5
- * 小程序平台(mp-*):
6
- * - 页面没有使用 externalClasses:不做转换
7
- * - 页面存在动态 externalClasses:选择器最后一个 class 追加 [class]
8
- * .a -> .a[class]
9
- * - 页面只有静态 externalClasses:仅命中静态 class 的选择器追加 [class]
10
- * .foo -> .foo[class](foo 在 staticClasses 中)
11
- * .bar -> .bar(bar 不在 staticClasses 中)
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)
12
12
  *
13
- * 追加 [class] 可以提升 class 选择器优先级,同时避免原先插入 page 带来的结构影响。
13
+ * This ensures page styles have higher specificity than component styles
14
+ * while minimizing unnecessary transformations for performance
14
15
  */
15
16
  declare const externalPlugin: PluginCreator<void>;
16
17
  export default externalPlugin;
@@ -7,17 +7,18 @@ const postcss_selector_parser_1 = __importDefault(require("postcss-selector-pars
7
7
  const pages_1 = require("../../json/pages");
8
8
  const externalClasses_1 = require("../../mp/externalClasses");
9
9
  /**
10
- * 基于页面 externalClasses 使用情况提升页面样式优先级
10
+ * PostCSS plugin to boost specificity for page CSS based on externalClasses usage
11
11
  *
12
- * 小程序平台(mp-*):
13
- * - 页面没有使用 externalClasses:不做转换
14
- * - 页面存在动态 externalClasses:选择器最后一个 class 追加 [class]
15
- * .a -> .a[class]
16
- * - 页面只有静态 externalClasses:仅命中静态 class 的选择器追加 [class]
17
- * .foo -> .foo[class](foo 在 staticClasses 中)
18
- * .bar -> .bar(bar 不在 staticClasses 中)
12
+ * For mini-program platforms (mp-*):
13
+ * - If page has no externalClasses usage: no transformation
14
+ * - If page has dynamic externalClasses: all selectors get page prefix
15
+ * .a -> page .a
16
+ * - If page has only static externalClasses: only matching selectors get page prefix
17
+ * .foo -> page .foo (if "foo" is in staticClasses)
18
+ * .bar -> .bar (unchanged, if "bar" is not in staticClasses)
19
19
  *
20
- * 追加 [class] 可以提升 class 选择器优先级,同时避免原先插入 page 带来的结构影响。
20
+ * This ensures page styles have higher specificity than component styles
21
+ * while minimizing unnecessary transformations for performance
21
22
  */
22
23
  const externalPlugin = () => {
23
24
  return {
@@ -26,21 +27,21 @@ const externalPlugin = () => {
26
27
  const processedRules = new WeakSet();
27
28
  return {
28
29
  OnceExit(root) {
29
- // 只有小程序平台需要处理 externalClasses 的样式优先级
30
+ // Only mini-program platforms need page selector prepend
30
31
  const platform = process.env.UNI_PLATFORM || '';
31
32
  if (!platform.startsWith('mp-')) {
32
33
  return;
33
34
  }
34
- // 从 postcss source 中获取当前样式所属文件
35
+ // Get file path from postcss source
35
36
  const filePath = root.source?.input?.file;
36
37
  if (!filePath) {
37
38
  return;
38
39
  }
39
- // 只处理页面文件,组件文件保持原样
40
+ // Only process page files
40
41
  if (!(0, pages_1.isUniPageFile)(filePath)) {
41
42
  return;
42
43
  }
43
- // 获取页面中收集到的 externalClasses 使用信息
44
+ // Get page's externalClasses info
44
45
  const externalClassesInfo = (0, externalClasses_1.findPageExternalClasses)(filePath);
45
46
  let staticClasses = new Set();
46
47
  let hasDynamic = false;
@@ -54,7 +55,7 @@ const externalPlugin = () => {
54
55
  hasDynamic = true;
55
56
  }
56
57
  }
57
- // 没有静态 class,也没有动态绑定时,直接跳过,避免无意义遍历
58
+ // If no static classes and no dynamic, skip processing
58
59
  if (staticClasses.size === 0 && !hasDynamic) {
59
60
  return;
60
61
  }
@@ -67,67 +68,60 @@ const externalPlugin = () => {
67
68
  };
68
69
  };
69
70
  function processRule(rule, processedRules, staticClasses, hasDynamic) {
70
- // 同一个 Rule 只处理一次,避免被重复追加 [class]
71
+ // Skip already processed rules
71
72
  if (processedRules.has(rule)) {
72
73
  return;
73
74
  }
74
- // keyframes 内部的 from/to 不是普通选择器,不能处理
75
+ // Skip keyframes rules
75
76
  if (rule.parent &&
76
77
  rule.parent.type === 'atrule' &&
77
78
  /-?keyframes$/.test(rule.parent.name)) {
78
79
  return;
79
80
  }
80
81
  processedRules.add(rule);
81
- // 根据 externalClasses 情况处理选择器
82
+ // Process selector based on externalClasses info
82
83
  rule.selector = (0, postcss_selector_parser_1.default)((selectorRoot) => {
83
84
  selectorRoot.each((selector) => {
84
- let classNode;
85
85
  if (hasDynamic) {
86
- // 动态绑定无法提前知道具体 class,所有包含 class 的选择器都提升优先级
87
- classNode = findLastClassNode(selector);
86
+ // Dynamic externalClasses: prepend page to all selectors
87
+ prependPageSelector(selector);
88
88
  }
89
89
  else {
90
- // 静态绑定只处理命中 staticClasses 的选择器,减少无关 CSS 变更
91
- classNode = findLastClassNode(selector, staticClasses);
92
- }
93
- if (classNode) {
94
- appendClassAttribute(selector, classNode);
90
+ // Static only: only prepend page if selector contains any staticClasses
91
+ if (selectorContainsClasses(selector, staticClasses)) {
92
+ prependPageSelector(selector);
93
+ }
95
94
  }
96
95
  });
97
96
  }).processSync(rule.selector);
98
97
  }
99
98
  /**
100
- * 找到选择器最右侧的 class 节点。
101
- * 传入 classes 时,仅在选择器包含目标 class 后才返回最右侧 class,
102
- * 这样 .a .b 在命中 .a 时也能输出 .a .b[class],符合整体提权预期。
99
+ * Check if selector contains any of the specified classes
103
100
  */
104
- function findLastClassNode(selector, classes) {
105
- let lastClassNode;
106
- for (let i = selector.nodes.length - 1; i >= 0; i--) {
107
- const node = selector.nodes[i];
108
- if (node.type !== 'class') {
109
- continue;
110
- }
111
- if (!lastClassNode) {
112
- lastClassNode = node;
113
- }
114
- if (!classes || classes.has(node.value)) {
115
- return lastClassNode;
101
+ function selectorContainsClasses(selector, classes) {
102
+ let found = false;
103
+ selector.walk((node) => {
104
+ if (node.type === 'class' && classes.has(node.value)) {
105
+ found = true;
106
+ return false; // stop walking
116
107
  }
117
- }
108
+ });
109
+ return found;
118
110
  }
119
111
  /**
120
- * 在 class 后追加 [class] 提升优先级。
121
- * .a -> .a[class]
122
- * .a[class] -> .a[class][class]
123
- * .a .b -> .a .b[class]
112
+ * Prepend 'page' selector for mini-program platforms
113
+ * .a -> page .a
114
+ * .b .c -> page .b .c
124
115
  */
125
- function appendClassAttribute(selector, classNode) {
126
- selector.insertAfter(classNode, postcss_selector_parser_1.default.attribute({
127
- attribute: 'class',
128
- value: undefined,
129
- raws: {},
130
- }));
116
+ function prependPageSelector(selector) {
117
+ // Skip if selector already starts with 'page'
118
+ const firstNode = selector.first;
119
+ if (firstNode && firstNode.type === 'tag' && firstNode.value === 'page') {
120
+ return;
121
+ }
122
+ // Insert 'page' tag and a combinator (space) at the beginning
123
+ selector.prepend(postcss_selector_parser_1.default.combinator({ value: ' ' }));
124
+ selector.prepend(postcss_selector_parser_1.default.tag({ value: 'page' }));
131
125
  }
132
126
  externalPlugin.postcss = true;
133
127
  exports.default = externalPlugin;
@@ -49,7 +49,6 @@ export interface EncryptPackageJson {
49
49
  export declare function initCheckEnv(): Record<string, unknown>;
50
50
  export declare function resolveEncryptUniModule(id: string, platform: typeof process.env.UNI_UTS_PLATFORM, isX?: boolean): string | undefined;
51
51
  type CloudCompileSdkType = 'utssdk' | 'easycom' | 'all';
52
- type VaporRenderTarget = 'bytecode' | 'nativecode';
53
52
  export interface CloudCompileParams {
54
53
  mode: 'development' | 'production';
55
54
  packType: 'debug' | 'release';
@@ -58,11 +57,8 @@ export interface CloudCompileParams {
58
57
  appname: string;
59
58
  platform: typeof process.env.UNI_UTS_PLATFORM;
60
59
  'uni-app-x': boolean;
61
- vapor: boolean;
62
- vaporRenderTarget?: VaporRenderTarget;
63
60
  env: Record<string, string>;
64
61
  }
65
- export declare function validateCloudCompileAppInfo(params: Pick<CloudCompileParams, 'appid' | 'appname'>): string;
66
62
  export declare function checkEncryptUniModules(inputDir: string, params: CloudCompileParams, sdkType?: CloudCompileSdkType): Promise<{} | undefined>;
67
63
  export declare function getUniModulesEncryptType(pluginId: string): "" | "utssdk" | "easycom" | undefined;
68
64
  export declare function parseUniModulesArtifacts(): {
@@ -71,6 +67,5 @@ export declare function parseUniModulesArtifacts(): {
71
67
  scopedSlots: string[];
72
68
  declaration: string;
73
69
  }[];
74
- export declare function copyEncryptUniModulesDom2Bytes(): boolean | Promise<boolean>;
75
70
  export declare function virtualComponentPath(filepath: string): string;
76
71
  export {};