@dcloudio/uni-cli-shared 3.0.0-alpha-4070720250804001 → 3.0.0-alpha-4070620250731002

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 (163) hide show
  1. package/dist/easycom.d.ts +0 -1
  2. package/dist/easycom.js +13 -17
  3. package/dist/hbx/alias.js +10 -43
  4. package/dist/hbx/index.js +0 -10
  5. package/dist/hbx/log.js +1 -23
  6. package/dist/index.d.ts +1 -2
  7. package/dist/index.js +1 -3
  8. package/dist/json/index.d.ts +1 -1
  9. package/dist/json/index.js +1 -2
  10. package/dist/json/manifest.d.ts +0 -1
  11. package/dist/json/manifest.js +1 -11
  12. package/dist/json/mp/jsonFile.js +2 -4
  13. package/dist/json/mp/pages.js +0 -1
  14. package/dist/json/mp/types.d.ts +1 -4
  15. package/dist/json/uni-x/manifest.d.ts +0 -1
  16. package/dist/json/uni-x/manifest.js +1 -5
  17. package/dist/messages/zh_CN.js +0 -1
  18. package/dist/uni_modules.cloud.d.ts +4 -10
  19. package/dist/uni_modules.cloud.js +19 -58
  20. package/dist/uni_modules.d.ts +0 -2
  21. package/dist/uni_modules.js +2 -81
  22. package/dist/uts.js +0 -16
  23. package/dist/vite/autoImport.js +0 -2
  24. package/dist/vite/cloud.js +5 -51
  25. package/dist/vite/plugins/index.d.ts +0 -1
  26. package/dist/vite/plugins/index.js +1 -3
  27. package/dist/vite/plugins/inject.js +1 -3
  28. package/dist/vite/plugins/uts/uni_modules.d.ts +0 -1
  29. package/dist/vite/plugins/uts/uni_modules.js +14 -63
  30. package/dist/vite/plugins/uts/uvue.js +3 -17
  31. package/dist/vite/plugins/vitejs/plugins/css.js +5 -40
  32. package/dist/vue/transforms/transformUTSComponent.js +3 -8
  33. package/package.json +38 -38
  34. package/dist/vite/plugins/stats.d.ts +0 -2
  35. package/dist/vite/plugins/stats.js +0 -42
  36. package/dist/workers.d.ts +0 -14
  37. package/dist/workers.js +0 -187
  38. package/lib/vapor/@vitejs/plugin-vue/LICENSE +0 -21
  39. package/lib/vapor/@vitejs/plugin-vue/README.md +0 -278
  40. package/lib/vapor/@vitejs/plugin-vue/dist/index.cjs +0 -3105
  41. package/lib/vapor/@vitejs/plugin-vue/dist/index.d.cts +0 -113
  42. package/lib/vapor/@vitejs/plugin-vue/dist/index.d.mts +0 -111
  43. package/lib/vapor/@vitejs/plugin-vue/dist/index.d.ts +0 -113
  44. package/lib/vapor/@vitejs/plugin-vue/dist/index.mjs +0 -3090
  45. package/lib/vapor/@vitejs/plugin-vue/package.json +0 -50
  46. package/lib/vapor/@vue/compiler-core/LICENSE +0 -21
  47. package/lib/vapor/@vue/compiler-core/README.md +0 -1
  48. package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +0 -6902
  49. package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +0 -6779
  50. package/lib/vapor/@vue/compiler-core/dist/compiler-core.esm-bundler.js +0 -5870
  51. package/lib/vapor/@vue/compiler-core/index.js +0 -7
  52. package/lib/vapor/@vue/compiler-core/package.json +0 -58
  53. package/lib/vapor/@vue/compiler-dom/LICENSE +0 -21
  54. package/lib/vapor/@vue/compiler-dom/README.md +0 -1
  55. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -936
  56. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +0 -856
  57. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +0 -6682
  58. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +0 -14
  59. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +0 -693
  60. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.js +0 -6855
  61. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.prod.js +0 -14
  62. package/lib/vapor/@vue/compiler-dom/index.js +0 -7
  63. package/lib/vapor/@vue/compiler-dom/package.json +0 -57
  64. package/lib/vapor/@vue/compiler-sfc/LICENSE +0 -21
  65. package/lib/vapor/@vue/compiler-sfc/README.md +0 -80
  66. package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -21682
  67. package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +0 -66272
  68. package/lib/vapor/@vue/compiler-sfc/package.json +0 -68
  69. package/lib/vapor/@vue/compiler-ssr/LICENSE +0 -21
  70. package/lib/vapor/@vue/compiler-ssr/README.md +0 -1
  71. package/lib/vapor/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +0 -1402
  72. package/lib/vapor/@vue/compiler-ssr/package.json +0 -34
  73. package/lib/vapor/@vue/compiler-vapor/LICENSE +0 -21
  74. package/lib/vapor/@vue/compiler-vapor/README.md +0 -1
  75. package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +0 -4540
  76. package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +0 -37020
  77. package/lib/vapor/@vue/compiler-vapor/package.json +0 -49
  78. package/lib/vapor/@vue/reactivity/LICENSE +0 -21
  79. package/lib/vapor/@vue/reactivity/README.md +0 -19
  80. package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.js +0 -2033
  81. package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.prod.js +0 -1841
  82. package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.js +0 -2023
  83. package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.prod.js +0 -5
  84. package/lib/vapor/@vue/reactivity/dist/reactivity.esm-bundler.js +0 -1992
  85. package/lib/vapor/@vue/reactivity/dist/reactivity.global.js +0 -2082
  86. package/lib/vapor/@vue/reactivity/dist/reactivity.global.prod.js +0 -5
  87. package/lib/vapor/@vue/reactivity/index.js +0 -7
  88. package/lib/vapor/@vue/reactivity/package.json +0 -55
  89. package/lib/vapor/@vue/runtime-core/LICENSE +0 -21
  90. package/lib/vapor/@vue/runtime-core/README.md +0 -28
  91. package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.js +0 -8972
  92. package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.prod.js +0 -7088
  93. package/lib/vapor/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8913
  94. package/lib/vapor/@vue/runtime-core/index.js +0 -7
  95. package/lib/vapor/@vue/runtime-core/package.json +0 -54
  96. package/lib/vapor/@vue/runtime-dom/LICENSE +0 -21
  97. package/lib/vapor/@vue/runtime-dom/README.md +0 -13
  98. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.js +0 -1797
  99. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +0 -1646
  100. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +0 -12929
  101. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +0 -6
  102. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1838
  103. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.js +0 -13086
  104. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.prod.js +0 -6
  105. package/lib/vapor/@vue/runtime-dom/index.js +0 -7
  106. package/lib/vapor/@vue/runtime-dom/package.json +0 -60
  107. package/lib/vapor/@vue/runtime-vapor/LICENSE +0 -21
  108. package/lib/vapor/@vue/runtime-vapor/README.md +0 -8
  109. package/lib/vapor/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js +0 -3242
  110. package/lib/vapor/@vue/runtime-vapor/package.json +0 -47
  111. package/lib/vapor/@vue/server-renderer/LICENSE +0 -21
  112. package/lib/vapor/@vue/server-renderer/README.md +0 -178
  113. package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.js +0 -1144
  114. package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.prod.js +0 -871
  115. package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.js +0 -8756
  116. package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +0 -5
  117. package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-bundler.js +0 -1366
  118. package/lib/vapor/@vue/server-renderer/index.js +0 -7
  119. package/lib/vapor/@vue/server-renderer/package.json +0 -55
  120. package/lib/vapor/@vue/shared/LICENSE +0 -21
  121. package/lib/vapor/@vue/shared/README.md +0 -3
  122. package/lib/vapor/@vue/shared/dist/shared.cjs.js +0 -698
  123. package/lib/vapor/@vue/shared/dist/shared.cjs.prod.js +0 -690
  124. package/lib/vapor/@vue/shared/dist/shared.esm-bundler.js +0 -616
  125. package/lib/vapor/@vue/shared/index.js +0 -7
  126. package/lib/vapor/@vue/shared/package.json +0 -47
  127. package/lib/vapor/@vue/vue/LICENSE +0 -21
  128. package/lib/vapor/@vue/vue/README.md +0 -62
  129. package/lib/vapor/@vue/vue/compiler-sfc/index.browser.js +0 -1
  130. package/lib/vapor/@vue/vue/compiler-sfc/index.browser.mjs +0 -1
  131. package/lib/vapor/@vue/vue/compiler-sfc/index.d.mts +0 -1
  132. package/lib/vapor/@vue/vue/compiler-sfc/index.d.ts +0 -1
  133. package/lib/vapor/@vue/vue/compiler-sfc/index.js +0 -3
  134. package/lib/vapor/@vue/vue/compiler-sfc/index.mjs +0 -3
  135. package/lib/vapor/@vue/vue/compiler-sfc/package.json +0 -4
  136. package/lib/vapor/@vue/vue/compiler-sfc/register-ts.js +0 -3
  137. package/lib/vapor/@vue/vue/dist/vue.cjs.js +0 -80
  138. package/lib/vapor/@vue/vue/dist/vue.cjs.prod.js +0 -66
  139. package/lib/vapor/@vue/vue/dist/vue.esm-browser.js +0 -18840
  140. package/lib/vapor/@vue/vue/dist/vue.esm-browser.prod.js +0 -12
  141. package/lib/vapor/@vue/vue/dist/vue.esm-bundler.js +0 -72
  142. package/lib/vapor/@vue/vue/dist/vue.global.js +0 -18820
  143. package/lib/vapor/@vue/vue/dist/vue.global.prod.js +0 -12
  144. package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.js +0 -15648
  145. package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.prod.js +0 -9
  146. package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.js +0 -12953
  147. package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.prod.js +0 -6
  148. package/lib/vapor/@vue/vue/dist/vue.runtime.esm-bundler.js +0 -29
  149. package/lib/vapor/@vue/vue/dist/vue.runtime.global.js +0 -13111
  150. package/lib/vapor/@vue/vue/dist/vue.runtime.global.prod.js +0 -6
  151. package/lib/vapor/@vue/vue/index.js +0 -7
  152. package/lib/vapor/@vue/vue/index.mjs +0 -1
  153. package/lib/vapor/@vue/vue/jsx-runtime/index.d.ts +0 -25
  154. package/lib/vapor/@vue/vue/jsx-runtime/index.js +0 -15
  155. package/lib/vapor/@vue/vue/jsx-runtime/index.mjs +0 -12
  156. package/lib/vapor/@vue/vue/jsx-runtime/package.json +0 -5
  157. package/lib/vapor/@vue/vue/jsx.d.ts +0 -22
  158. package/lib/vapor/@vue/vue/package.json +0 -114
  159. package/lib/vapor/@vue/vue/server-renderer/index.d.mts +0 -1
  160. package/lib/vapor/@vue/vue/server-renderer/index.d.ts +0 -1
  161. package/lib/vapor/@vue/vue/server-renderer/index.js +0 -1
  162. package/lib/vapor/@vue/vue/server-renderer/index.mjs +0 -1
  163. package/lib/vapor/@vue/vue/server-renderer/package.json +0 -4
@@ -3,83 +3,12 @@ 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.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApi = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.formatExtApiProviderName = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = exports.isNonTreeShakingPlugin = exports.getNonTreeShakingPlugins = void 0;
6
+ exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApi = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.formatExtApiProviderName = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = void 0;
7
7
  // 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const extApiProviders = [];
11
11
  const extApiPlugins = new Set();
12
- function getNonTreeShakingPlugins() {
13
- const result = [];
14
- if (!process.env.UNI_INPUT_DIR || !process.env.UNI_UTS_PLATFORM) {
15
- return result;
16
- }
17
- const uniModulesDir = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'uni_modules');
18
- if (!fs_extra_1.default.existsSync(uniModulesDir)) {
19
- return result;
20
- }
21
- const platform = process.env.UNI_UTS_PLATFORM;
22
- fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
23
- const uniModuleRootDir = path_1.default.resolve(uniModulesDir, uniModuleDir);
24
- const pkgPath = path_1.default.resolve(uniModuleRootDir, 'package.json');
25
- if (!fs_extra_1.default.existsSync(pkgPath)) {
26
- return;
27
- }
28
- try {
29
- /**
30
- "uni_modules": {
31
- "treeShaking": {
32
- "app": {
33
- "android": false,
34
- "ios": true,
35
- "harmony": false
36
- },
37
- "web": false
38
- }
39
- }
40
- */
41
- const pkg = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'));
42
- if (isPlainObject(pkg.uni_modules)) {
43
- if (isNonTreeShakingPlugin(platform, pkg.uni_modules)) {
44
- result.push(uniModuleDir);
45
- }
46
- }
47
- }
48
- catch (e) { }
49
- });
50
- return result;
51
- }
52
- exports.getNonTreeShakingPlugins = getNonTreeShakingPlugins;
53
- function isNonTreeShakingPlugin(platform, uni_modules) {
54
- const treeShaking = uni_modules.treeShaking;
55
- // uni_modules.treeShaking 为 false,表示不进行treeShaking
56
- if (treeShaking === false) {
57
- return true;
58
- }
59
- else if (isPlainObject(treeShaking)) {
60
- // 如果 treeShaking 为对象,则需要根据平台判断是否进行treeShaking
61
- // uni_modules.treeShaking.web 为 false,表示不进行treeShaking
62
- if (treeShaking[platform] === false) {
63
- return true;
64
- }
65
- else {
66
- const parts = platform.split('-');
67
- if (parts.length === 2) {
68
- const [basePlatform, subPlatform] = parts;
69
- // uni_modules.treeShaking.app 为 false,表示不进行treeShaking
70
- if (treeShaking[basePlatform] === false) {
71
- return true;
72
- // uni_modules.treeShaking.app.android 为 false,表示不进行treeShaking
73
- }
74
- else if (treeShaking[basePlatform]?.[subPlatform] === false) {
75
- return true;
76
- }
77
- }
78
- }
79
- }
80
- return false;
81
- }
82
- exports.isNonTreeShakingPlugin = isNonTreeShakingPlugin;
83
12
  function getUniExtApiProviders() {
84
13
  return extApiProviders;
85
14
  }
@@ -233,13 +162,6 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
233
162
  source = `${source}/utssdk/app-js/index.uts`;
234
163
  }
235
164
  }
236
- else if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
237
- // 出于兼容历史项目考虑,鸿蒙优先使用app-harmony,无app-harmony的情况下再使用app-js
238
- if (!fs_extra_1.default.existsSync(platformIndexFileName) &&
239
- fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-js', 'index.uts'))) {
240
- source = `${source}/utssdk/app-js/index.uts`;
241
- }
242
- }
243
165
  for (const key in rootDefines) {
244
166
  Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
245
167
  }
@@ -291,8 +213,7 @@ function parseInject(vite = true, platform, language, source, globalObject, defi
291
213
  const appOptions = defineOptions.app;
292
214
  if (isPlainObject(appOptions)) {
293
215
  // js engine 下且存在 app-js,不检查
294
- const skipCheck = (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' ||
295
- process.env.UNI_UTS_PLATFORM === 'app-harmony') &&
216
+ const skipCheck = process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' &&
296
217
  source.includes('app-js');
297
218
  if (!skipCheck) {
298
219
  const targetLanguage = language === 'javascript' ? 'js' : language;
package/dist/uts.js CHANGED
@@ -45,22 +45,6 @@ function resolveUTSAppModule(platform, id, importer, includeUTSSDK = true) {
45
45
  }
46
46
  }
47
47
  }
48
- /**
49
- * 鸿蒙平台解析优先级
50
- * 1. utssdk/app-harmony/index.uts (native)
51
- * 2. utssdk/app-js/index.uts (js)
52
- * 3. utssdk/index.uts (native)
53
- */
54
- if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
55
- // 出于兼容历史项目考虑,鸿蒙优先使用app-harmony,无app-harmony的情况下再使用app-js
56
- if (parentDir === 'uni_modules') {
57
- const appHarmonyIndex = path_1.default.resolve(id, basedir, 'app-harmony', 'index.uts');
58
- const appJsIndex = path_1.default.resolve(id, basedir, 'app-js', 'index.uts');
59
- if (!fs_extra_1.default.existsSync(appHarmonyIndex) && fs_extra_1.default.existsSync(appJsIndex)) {
60
- return appJsIndex;
61
- }
62
- }
63
- }
64
48
  if (fs_extra_1.default.existsSync(path_1.default.resolve(id, basedir, 'index.uts'))) {
65
49
  return id;
66
50
  }
@@ -203,8 +203,6 @@ const vuePreset = {
203
203
  'getCurrentScope',
204
204
  'onScopeDispose',
205
205
  // types 全部全局导入
206
- // vapor
207
- 'getCurrentGenericInstance',
208
206
  ],
209
207
  };
210
208
  function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
@@ -12,9 +12,6 @@ const uts_1 = require("../uts");
12
12
  const utils_2 = require("../utils");
13
13
  const easycom_1 = require("../easycom");
14
14
  const uni_modules_1 = require("./plugins/uts/uni_modules");
15
- const utils_3 = require("./utils");
16
- const json_1 = require("../json");
17
- const workers_1 = require("../workers");
18
15
  function createEncryptCssUrlReplacer(resolve) {
19
16
  return async (url, importer) => {
20
17
  if (url.startsWith('/') && !url.startsWith('//')) {
@@ -63,29 +60,18 @@ function uniEncryptUniModulesAssetsPlugin() {
63
60
  exports.uniEncryptUniModulesAssetsPlugin = uniEncryptUniModulesAssetsPlugin;
64
61
  function uniEncryptUniModulesPlugin() {
65
62
  let resolvedConfig;
66
- const isMp = process.env.UNI_UTS_PLATFORM.startsWith('mp-');
67
- const encryptModuleOutputFiles = [];
68
63
  return {
69
64
  name: 'uni:encrypt-uni-modules',
70
65
  apply: 'build',
71
66
  config() {
72
- const build = initEncryptUniModulesBuildOptions(process.env.UNI_UTS_PLATFORM, process.env.UNI_INPUT_DIR);
73
- Object.keys(build.rollupOptions?.input || {}).forEach((key) => {
74
- encryptModuleOutputFiles.push(key + '.js');
75
- });
76
67
  return {
77
68
  resolve: {
78
69
  alias: initEncryptUniModulesAlias(),
79
70
  },
80
- build,
71
+ build: initEncryptUniModulesBuildOptions(process.env.UNI_UTS_PLATFORM, process.env.UNI_INPUT_DIR),
81
72
  };
82
73
  },
83
74
  configResolved(config) {
84
- const isMp = process.env.UNI_UTS_PLATFORM.startsWith('mp-');
85
- if (isMp) {
86
- // 云编译时,禁用了lib:false,但默认会生成 preload 等代码,需要主动移除该插件
87
- (0, utils_3.removePlugins)(['vite:build-import-analysis'], config);
88
- }
89
75
  // 编译组件时,禁用内联资源
90
76
  config.build.assetsInlineLimit = 0;
91
77
  config.build.rollupOptions.external = createExternal(config);
@@ -139,45 +125,14 @@ function uniEncryptUniModulesPlugin() {
139
125
  }),
140
126
  };
141
127
  }
142
- else if (fileName.endsWith('.js')) {
143
- if (isMp) {
144
- const output = bundle[fileName];
145
- if (output.type === 'chunk') {
146
- // 组件 js 可能会引用 index.module.js,需要替换路径
147
- const relativePath = path_1.default.relative(path_1.default.dirname(fileName), 'index.module.js');
148
- let code = output.code;
149
- encryptModuleOutputFiles.forEach((file) => {
150
- const relativeModulePath = relativePath.replace('index.module.js', file);
151
- // import { TuiCharts } from "../../../../tui-xechars_2.0.0.module.js";
152
- if (code.includes(relativeModulePath)) {
153
- code = code.replaceAll(relativeModulePath, relativeModulePath
154
- .replace('../../', '')
155
- .replace(file, 'index.module.js'));
156
- }
157
- });
158
- output.code = code;
159
- }
160
- }
161
- }
162
128
  });
163
- if (isMp) {
164
- (0, json_1.findChangedJsonFiles)(false).forEach((value, key) => {
165
- this.emitFile({
166
- type: 'asset',
167
- fileName: key + '.json',
168
- source: value,
169
- });
170
- });
171
- }
172
129
  },
173
130
  async writeBundle() {
174
131
  if (process.env.UNI_UTS_PLATFORM !== 'app-android') {
175
132
  return;
176
133
  }
177
134
  const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true'
178
- ? (0, uts_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce({
179
- resolveWorkers: () => (0, workers_1.getWorkers)(),
180
- })
135
+ ? (0, uts_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce()
181
136
  : null;
182
137
  if (uniXKotlinCompiler) {
183
138
  const tscOutputDir = tscOutDir('app-android');
@@ -391,12 +346,11 @@ function getUniModulesExtApiComponents(uniModuleId) {
391
346
  function compileCloudUniModuleWithTsc(platform, pluginDir) {
392
347
  const { compileUniModuleWithTsc, createUniXKotlinCompilerOnce, createUniXSwiftCompilerOnce, createUniXArkTSCompilerOnce, } = (0, uts_1.resolveUTSCompiler)();
393
348
  const isX = process.env.UNI_APP_X === 'true';
394
- const resolveWorkers = () => (0, workers_1.getWorkers)();
395
349
  return compileUniModuleWithTsc(platform, pluginDir, platform === 'app-android'
396
- ? createUniXKotlinCompilerOnce({ resolveWorkers })
350
+ ? createUniXKotlinCompilerOnce()
397
351
  : platform === 'app-harmony'
398
- ? createUniXArkTSCompilerOnce({ resolveWorkers })
399
- : createUniXSwiftCompilerOnce({ resolveWorkers }), {
352
+ ? createUniXArkTSCompilerOnce()
353
+ : createUniXSwiftCompilerOnce(), {
400
354
  rootFiles: [],
401
355
  preprocessor: platform === 'app-android'
402
356
  ? (0, uni_modules_1.createAppAndroidUniModulesSyncFilePreprocessorOnce)(isX)
@@ -13,7 +13,6 @@ export * from './json';
13
13
  export * from './pre';
14
14
  export * from './sourceMap';
15
15
  export { uniViteSfcSrcImportPlugin } from './sfc';
16
- export { uniStatsPlugin } from './stats';
17
16
  export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
18
17
  export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, rewriteScssReadFileSync, getCssDepMap, } from './vitejs/plugins/css';
19
18
  export { generateCodeFrame, locToStartAndEnd, offsetToStartAndEnd, } from './vitejs/utils';
@@ -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.offsetToStartAndEnd = exports.locToStartAndEnd = exports.generateCodeFrame = exports.getCssDepMap = exports.rewriteScssReadFileSync = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = exports.uniStatsPlugin = exports.uniViteSfcSrcImportPlugin = void 0;
17
+ exports.offsetToStartAndEnd = exports.locToStartAndEnd = exports.generateCodeFrame = exports.getCssDepMap = exports.rewriteScssReadFileSync = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = exports.uniViteSfcSrcImportPlugin = void 0;
18
18
  __exportStar(require("./cssScoped"), exports);
19
19
  __exportStar(require("./copy"), exports);
20
20
  __exportStar(require("./inject"), exports);
@@ -31,8 +31,6 @@ __exportStar(require("./pre"), exports);
31
31
  __exportStar(require("./sourceMap"), exports);
32
32
  var sfc_1 = require("./sfc");
33
33
  Object.defineProperty(exports, "uniViteSfcSrcImportPlugin", { enumerable: true, get: function () { return sfc_1.uniViteSfcSrcImportPlugin; } });
34
- var stats_1 = require("./stats");
35
- Object.defineProperty(exports, "uniStatsPlugin", { enumerable: true, get: function () { return stats_1.uniStatsPlugin; } });
36
34
  var asset_1 = require("./vitejs/plugins/asset");
37
35
  Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
38
36
  Object.defineProperty(exports, "parseAssets", { enumerable: true, get: function () { return asset_1.parseAssets; } });
@@ -11,7 +11,6 @@ const estree_walker_1 = require("estree-walker");
11
11
  const shared_1 = require("@vue/shared");
12
12
  const magic_string_1 = __importDefault(require("magic-string"));
13
13
  const utils_1 = require("../utils");
14
- const uts_1 = require("../../uts");
15
14
  const debugInject = (0, debug_1.default)('uni:inject');
16
15
  // const debugInjectTry = debug('uni:inject-try')
17
16
  function uniViteInjectPlugin(name, options) {
@@ -48,8 +47,7 @@ function uniViteInjectPlugin(name, options) {
48
47
  transform(code, id) {
49
48
  if (!filter(id))
50
49
  return null;
51
- // 加密插件也要走后续注入逻辑
52
- if (!(0, utils_1.isJsFile)(id) && !(0, uts_1.isUniHelpers)(id))
50
+ if (!(0, utils_1.isJsFile)(id))
53
51
  return null;
54
52
  // debugInjectTry(id)
55
53
  if (code.search(firstpass) === -1)
@@ -13,7 +13,6 @@ export declare function getCurrentCompiledUTSPlugins(): Set<string>;
13
13
  export declare function getCurrentCompiledUTSProviders(): Set<string>;
14
14
  export declare function uniUTSAppUniModulesPlugin(options?: UniUTSPluginOptions): Plugin;
15
15
  export declare function buildUniExtApis(): Promise<void>;
16
- export declare function buildNonTreeShakingUniModules(): Promise<void>;
17
16
  export declare function resolveExtApiProvider(pkg: Record<string, any>): {
18
17
  name?: string | undefined;
19
18
  plugin?: string | undefined;
@@ -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.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildNonTreeShakingUniModules = exports.buildUniExtApis = exports.uniUTSAppUniModulesPlugin = exports.getCurrentCompiledUTSProviders = exports.getCurrentCompiledUTSPlugins = exports.createAppHarmonyUniModulesSyncFilePreprocessorOnce = exports.createAppIosUniModulesSyncFilePreprocessorOnce = exports.createAppAndroidUniModulesSyncFilePreprocessorOnce = exports.rewriteUniModulesConsoleExpr = void 0;
6
+ exports.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSAppUniModulesPlugin = exports.getCurrentCompiledUTSProviders = exports.getCurrentCompiledUTSPlugins = exports.createAppHarmonyUniModulesSyncFilePreprocessorOnce = exports.createAppIosUniModulesSyncFilePreprocessorOnce = exports.createAppAndroidUniModulesSyncFilePreprocessorOnce = exports.rewriteUniModulesConsoleExpr = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const uni_shared_1 = require("@dcloudio/uni-shared");
@@ -18,7 +18,6 @@ const fs_1 = require("../../../fs");
18
18
  const context_1 = require("../../../preprocess/context");
19
19
  const hbx_1 = require("../../../hbx");
20
20
  const console_1 = require("../../../logs/console");
21
- const workers_1 = require("../../../workers");
22
21
  /* eslint-disable no-restricted-globals */
23
22
  const { preprocess } = require('../../../../lib/preprocess');
24
23
  function rewriteUniModulesConsoleExpr(fileName, content) {
@@ -144,7 +143,6 @@ function getCurrentCompiledUTSProviders() {
144
143
  }
145
144
  exports.getCurrentCompiledUTSProviders = getCurrentCompiledUTSProviders;
146
145
  let uniExtApiCompiler = async () => { };
147
- let nonTreeShakingUniModulesCompiler = async () => { };
148
146
  function emptyCacheDir(platform) {
149
147
  const uvueOutputDir = (0, uts_1.uvueOutDir)(platform);
150
148
  const tscOutputDir = (0, uts_1.tscOutDir)(platform);
@@ -209,20 +207,19 @@ function uniUTSAppUniModulesPlugin(options = {}) {
209
207
  }
210
208
  }
211
209
  const { createUniXKotlinCompilerOnce, createUniXSwiftCompilerOnce, createUniXArkTSCompilerOnce, syncUniModuleFilesByCompiler, resolveTscUniModuleIndexFileName, } = (0, uts_1.resolveUTSCompiler)();
212
- const resolveWorkers = () => (0, workers_1.getWorkers)();
213
210
  const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true' &&
214
211
  (process.env.UNI_UTS_PLATFORM === 'app-android' ||
215
212
  process.env.UNI_UTS_PLATFORM === 'app')
216
- ? createUniXKotlinCompilerOnce({ resolveWorkers })
213
+ ? createUniXKotlinCompilerOnce()
217
214
  : null;
218
215
  const uniXSwiftCompiler = process.env.UNI_APP_X_TSC === 'true' &&
219
216
  (process.env.UNI_UTS_PLATFORM === 'app-ios' ||
220
217
  process.env.UNI_UTS_PLATFORM === 'app')
221
- ? createUniXSwiftCompilerOnce({ resolveWorkers })
218
+ ? createUniXSwiftCompilerOnce()
222
219
  : null;
223
220
  const uniXArkTSCompiler = process.env.UNI_APP_X_TSC === 'true' &&
224
221
  process.env.UNI_UTS_PLATFORM === 'app-harmony'
225
- ? createUniXArkTSCompilerOnce({ resolveWorkers })
222
+ ? createUniXArkTSCompilerOnce()
226
223
  : null;
227
224
  if (uniXKotlinCompiler) {
228
225
  emptyKotlinCacheDirOnce();
@@ -395,11 +392,10 @@ function uniUTSAppUniModulesPlugin(options = {}) {
395
392
  continue;
396
393
  }
397
394
  }
398
- if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
395
+ if (process.env.UNI_PLATFORM === 'app-harmony') {
399
396
  // uniExtApiCompiler本身是为X项目准备的,但是在app-harmony项目中也会调用
400
397
  // uni-app-x app-harmony暂不支持其他类型插件
401
- if (!fs_extra_1.default.existsSync(path_1.default.resolve(pluginDir, 'utssdk', 'app-harmony', 'index.uts')) ||
402
- fs_extra_1.default.existsSync(path_1.default.resolve(pluginDir, 'utssdk', 'app-js', 'index.uts'))) {
398
+ if (!fs_extra_1.default.existsSync(path_1.default.resolve(pluginDir, 'utssdk', 'app-harmony', 'index.uts'))) {
403
399
  continue;
404
400
  }
405
401
  }
@@ -413,13 +409,6 @@ function uniUTSAppUniModulesPlugin(options = {}) {
413
409
  }
414
410
  }
415
411
  };
416
- nonTreeShakingUniModulesCompiler = async () => {
417
- const nonTreeShakingUniModules = (0, uni_modules_1.getNonTreeShakingPlugins)().filter((plugin) => !utsPlugins.has(plugin));
418
- for (const plugin of nonTreeShakingUniModules) {
419
- const pluginDir = path_1.default.resolve(inputDir, 'uni_modules', plugin);
420
- await compilePlugin(pluginDir);
421
- }
422
- };
423
412
  return {
424
413
  name: 'uni:uts-uni_modules',
425
414
  apply: 'build',
@@ -505,7 +494,9 @@ function uniUTSAppUniModulesPlugin(options = {}) {
505
494
  if (utsModuleCaches.get(pluginDir)) {
506
495
  return utsModuleCaches.get(pluginDir)().then((result) => {
507
496
  if (result) {
508
- handleCompileResult(result, this);
497
+ result.deps.forEach((dep) => {
498
+ this.addWatchFile(dep);
499
+ });
509
500
  return {
510
501
  code: result.code,
511
502
  map: null,
@@ -521,7 +512,9 @@ function uniUTSAppUniModulesPlugin(options = {}) {
521
512
  utsModuleCaches.set(pluginDir, compile);
522
513
  const result = await compile();
523
514
  if (result) {
524
- handleCompileResult(result, this);
515
+ result.deps.forEach((dep) => {
516
+ this.addWatchFile(dep);
517
+ });
525
518
  return {
526
519
  code: result.code,
527
520
  map: null,
@@ -537,10 +530,6 @@ async function buildUniExtApis() {
537
530
  await uniExtApiCompiler();
538
531
  }
539
532
  exports.buildUniExtApis = buildUniExtApis;
540
- async function buildNonTreeShakingUniModules() {
541
- await nonTreeShakingUniModulesCompiler();
542
- }
543
- exports.buildNonTreeShakingUniModules = buildNonTreeShakingUniModules;
544
533
  function resolveExtApiProvider(pkg) {
545
534
  const provider = pkg.uni_modules?.['uni-ext-api']?.provider;
546
535
  if (provider?.service) {
@@ -554,15 +543,13 @@ exports.resolveExtApiProvider = resolveExtApiProvider;
554
543
  function uniDecryptUniModulesPlugin() {
555
544
  const inputDir = process.env.UNI_INPUT_DIR;
556
545
  const isX = process.env.UNI_APP_X === 'true';
557
- const isMp = process.env.UNI_UTS_PLATFORM.startsWith('mp-');
558
546
  return {
559
547
  name: 'uni:uni_modules-d',
560
548
  enforce: 'pre',
561
549
  async configResolved() {
562
550
  if (isX && (0, utils_2.isNormalCompileTarget)()) {
563
551
  const manifest = (0, json_1.parseManifestJsonOnce)(inputDir);
564
- const env = {};
565
- const options = {
552
+ await (0, uni_modules_cloud_1.checkEncryptUniModules)(inputDir, {
566
553
  mode: process.env.NODE_ENV !== 'development'
567
554
  ? 'production'
568
555
  : 'development',
@@ -573,32 +560,7 @@ function uniDecryptUniModulesPlugin() {
573
560
  appname: manifest.name,
574
561
  platform: process.env.UNI_UTS_PLATFORM,
575
562
  'uni-app-x': isX,
576
- env,
577
- };
578
- // 鸿蒙平台需要拆分两次云编译
579
- if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
580
- const harmonyEnv = {
581
- ...env,
582
- UNI_HARMONY_COMPATIBLE_SDK_VERSION: process.env.UNI_HARMONY_COMPATIBLE_SDK_VERSION || '',
583
- };
584
- await (0, uni_modules_cloud_1.checkEncryptUniModules)(inputDir, {
585
- ...options,
586
- env: {
587
- ...harmonyEnv,
588
- UNI_HARMONY_SDK_TYPE: 'utssdk',
589
- },
590
- }, 'utssdk');
591
- await (0, uni_modules_cloud_1.checkEncryptUniModules)(inputDir, {
592
- ...options,
593
- env: {
594
- ...harmonyEnv,
595
- UNI_HARMONY_SDK_TYPE: 'easycom',
596
- },
597
- }, 'easycom');
598
- }
599
- else {
600
- await (0, uni_modules_cloud_1.checkEncryptUniModules)(inputDir, options, 'all');
601
- }
563
+ });
602
564
  }
603
565
  },
604
566
  resolveId(id) {
@@ -612,17 +574,6 @@ function uniDecryptUniModulesPlugin() {
612
574
  }
613
575
  }
614
576
  },
615
- load(id) {
616
- if (isMp && (0, uts_1.isUniHelpers)(id)) {
617
- const { path: urlPath, query } = (0, uni_shared_1.parseUrl)(id);
618
- if (query.component) {
619
- const componentId = (0, utils_2.capitalize)((0, utils_2.camelize)(query.component));
620
- return `import { define${componentId} } from '@/uni_modules/${path_1.default.basename(urlPath)}?uni_helpers'
621
- define${componentId}()
622
- `;
623
- }
624
- }
625
- },
626
577
  };
627
578
  }
628
579
  exports.uniDecryptUniModulesPlugin = uniDecryptUniModulesPlugin;
@@ -21,26 +21,12 @@ function uniUTSUVueJavaScriptPlugin(options = {}) {
21
21
  }
22
22
  return {
23
23
  code: code.replace(/<script([^>]*)>/gi, (match, attributes) => {
24
- let vapor = false;
25
- if (process.env.UNI_VUE_VAPOR_ALL === 'true') {
26
- if (attributes.includes('setup') && !attributes.includes('vapor')) {
27
- vapor = true;
28
- }
29
- }
30
- let result = '';
31
24
  // 如果 <script> 标签中没有 lang 属性,添加 lang="uts"
32
25
  if (!/lang=["']?[^"']*["']?/.test(attributes)) {
33
- result = `<script${attributes} lang="uts">`;
34
- }
35
- else {
36
- // 否则,将现有的 lang 属性替换为 lang="uts"
37
- result = match.replace(/lang=["']?ts["']?/, 'lang="uts"');
26
+ return `<script${attributes} lang="uts">`;
38
27
  }
39
- if (vapor) {
40
- // 追加 vapor 属性
41
- result = result.replace('lang=', 'vapor lang=');
42
- }
43
- return result;
28
+ // 否则,将现有的 lang 属性替换为 lang="uts"
29
+ return match.replace(/lang=["']?ts["']?/, 'lang="uts"');
44
30
  }),
45
31
  map: { mappings: '' },
46
32
  };
@@ -242,39 +242,6 @@ function cssPostPlugin(config, { platform, isJsCode, preserveModules, chunkCssFi
242
242
  async renderChunk(_code, chunk, _opts) {
243
243
  const id = chunk.facadeModuleId;
244
244
  if (id) {
245
- // 云编译小程序时,只会生成一个chunk(index.module.js),不会动态import,给每个组件产生一个chunk,所以这里需要自行处理组件wxss
246
- if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
247
- if (platform &&
248
- platform.startsWith('mp-') &&
249
- id.endsWith('index.module.uts')) {
250
- // 第一遍:处理以.uvue、.vue结尾的组件
251
- Object.keys(chunk.modules).forEach((id) => {
252
- if (id.endsWith('.uvue') || id.endsWith('.vue')) {
253
- const filename = chunkCssFilename('uni_modules://' + id);
254
- if (filename) {
255
- cssChunks.set(filename, [
256
- ...findCssModuleIds.call(this, id, includeComponentCss),
257
- ]);
258
- }
259
- }
260
- });
261
- // 第二遍:处理包含vue&type=style的组件,当使用setup时,该chunk的modules没有包含.uvue、.vue结尾的组件,仅包含type=script、type=style的导入
262
- Object.keys(chunk.modules).forEach((id) => {
263
- if (id.includes('vue&type=style')) {
264
- const filename = chunkCssFilename('uni_modules://' + id);
265
- if (filename) {
266
- if (!cssChunks.has(filename)) {
267
- cssChunks.set(filename, [
268
- id,
269
- ...findCssModuleIds.call(this, id, includeComponentCss),
270
- ]);
271
- }
272
- }
273
- }
274
- });
275
- }
276
- return null;
277
- }
278
245
  const filename = chunkCssFilename(id);
279
246
  if (filename) {
280
247
  if (platform === 'app' &&
@@ -357,13 +324,11 @@ function cssPostPlugin(config, { platform, isJsCode, preserveModules, chunkCssFi
357
324
  inlined: false,
358
325
  minify: true,
359
326
  });
360
- if (source.trim()) {
361
- this.emitFile({
362
- fileName: filename,
363
- type: 'asset',
364
- source,
365
- });
366
- }
327
+ this.emitFile({
328
+ fileName: filename,
329
+ type: 'asset',
330
+ source,
331
+ });
367
332
  }
368
333
  },
369
334
  };
@@ -14,20 +14,15 @@ const transformUTSComponent = (node, context) => {
14
14
  if (!(0, ast_1.isElementNode)(node)) {
15
15
  return;
16
16
  }
17
- // @ts-expect-error 同时兼容 vapor 编译器
18
- const components = context.component || context.components;
19
- if (!components) {
20
- return;
21
- }
22
17
  // 1. 增加components,让sfc生成resolveComponent代码
23
18
  // 2. easycom插件会根据resolveComponent生成import插件代码触发编译
24
19
  const utsCustomElement = (0, uts_1.getUTSCustomElement)(node.tag);
25
20
  if (utsCustomElement) {
26
- components.add(node.tag);
21
+ context.components.add(node.tag);
27
22
  }
28
23
  else if ((0, utsUtils_1.matchUTSComponent)(node.tag)) {
29
- if (components.has(node.tag)) {
30
- components.add(node.tag);
24
+ if (!context.root.components.includes(node.tag)) {
25
+ context.components.add(node.tag);
31
26
  }
32
27
  }
33
28
  };