@dcloudio/uni-cli-shared 3.0.0-5000720260410001 → 3.0.0-5010420260703001
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.
- package/dist/constants.d.ts +1 -3
- package/dist/constants.js +2 -6
- package/dist/deps.d.ts +1 -0
- package/dist/deps.js +22 -13
- package/dist/dom2/fontFamily.d.ts +4 -0
- package/dist/dom2/fontFamily.js +21 -0
- package/dist/dom2/index.d.ts +3 -0
- package/dist/dom2/index.js +3 -0
- package/dist/dom2/rootScrollView.d.ts +47 -0
- package/dist/dom2/rootScrollView.js +283 -0
- package/dist/dom2/sharedData.d.ts +4 -0
- package/dist/dom2/sharedData.js +40 -5
- package/dist/dom2/vue.d.ts +17 -0
- package/dist/dom2/vue.js +50 -0
- package/dist/easycom.d.ts +1 -0
- package/dist/easycom.js +23 -9
- package/dist/env/define.d.ts +0 -1
- package/dist/env/define.js +3 -11
- package/dist/hbx/alias.js +66 -10
- package/dist/hbx/log.js +9 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/json/app/manifest/plus.js +9 -1
- package/dist/json/index.d.ts +1 -1
- package/dist/json/index.js +2 -1
- package/dist/json/uni-x/index.d.ts +6 -0
- package/dist/json/uni-x/index.js +54 -1
- package/dist/json/uni-x/manifest.d.ts +1 -1
- package/dist/json/uni-x/manifest.js +2 -1
- package/dist/json/utils.js +24 -0
- package/dist/messages/en.d.ts +10 -2
- package/dist/messages/en.js +10 -2
- package/dist/messages/index.d.ts +20 -4
- package/dist/messages/zh_CN.d.ts +10 -2
- package/dist/messages/zh_CN.js +10 -2
- package/dist/mp/style.js +6 -2
- package/dist/postcss/plugins/stylePluginExternal.d.ts +9 -10
- package/dist/postcss/plugins/stylePluginExternal.js +51 -45
- package/dist/uni_modules.cloud.d.ts +7 -1
- package/dist/uni_modules.cloud.js +131 -14
- package/dist/uni_modules.js +3 -2
- package/dist/utils.js +5 -0
- package/dist/uts.d.ts +1 -0
- package/dist/uts.js +90 -6
- package/dist/vite/autoImport.js +7 -4
- package/dist/vite/cloud.js +13 -6
- package/dist/vite/extApi.js +4 -1
- package/dist/vite/plugins/inject.js +4 -1
- package/dist/vite/plugins/json.js +2 -69
- package/dist/vite/plugins/pre.js +2 -0
- package/dist/vite/plugins/stats.d.ts +5 -1
- package/dist/vite/plugins/stats.js +74 -3
- package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
- package/dist/vite/plugins/uts/uni_modules.js +30 -12
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -2
- package/dist/vite/plugins/vitejs/plugins/css.js +10 -5
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +1 -0
- package/dist/vue/transforms/transformTeleport.d.ts +2 -0
- package/dist/vue/transforms/transformTeleport.js +68 -0
- package/dist/vue/transforms/x/transformDirection.js +33 -4
- package/dist/workers.d.ts +1 -0
- package/dist/workers.js +12 -5
- package/dist/x.d.ts +10 -0
- package/dist/x.js +39 -0
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +0 -7
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +0 -7
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +58 -63
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +58 -63
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +7 -1
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +22 -47
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +12 -23
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +12 -22
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +23 -74
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +5 -5
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +3 -20
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +310 -363
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +5 -5
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +810 -579
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.d.ts +33 -11114
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +1638 -1250
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +1031 -599
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +470 -328
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +1154 -709
- package/lib/dom2/app/@vue/compiler-vapor-dom2/dist/compiler-vapor-dom2.cjs.js +1 -1
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.js +16 -25
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +16 -25
- package/lib/dom2/app/@vue/shared/dist/shared.d.ts +5 -0
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +11 -23
- package/package.json +6 -6
package/dist/uts.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isUniHelpers = exports.isUTSProxy = exports.tscOutDir = exports.uvueOutDir = exports.genUniExtApiDeclarationFileOnce = exports.initUTSSwiftAutoImportsOnce = exports.initUTSKotlinAutoImportsOnce = exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftModuleWithPluginId = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.parseCustomElementExports = exports.initUTSCustomElements = exports.initUTSComponents = exports.parseUTSCustomElement = exports.parseUTSComponent = exports.getUTSCustomElementAutoImports = exports.getUTSComponentAutoImports = exports.getUTSCustomElement = exports.isUTSCustomElement = exports.getUTSPluginCustomElements = exports.getUTSCustomElements = exports.clearUTSCustomElements = exports.isUTSComponent = exports.clearUTSComponents = exports.getUTSCustomElementsExports = exports.resolveUTSCompilerVersion = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
6
|
+
exports.isUniHelpers = exports.isUTSProxy = exports.tscOutDir = exports.uvueOutDir = exports.genUniExtApiDeclarationFileOnce = exports.initUTSSwiftAutoImportsOnce = exports.initUTSKotlinAutoImportsOnce = exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftModuleWithPluginId = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.parseCustomElementExports = exports.initUTSCustomElements = exports.initUTSComponents = exports.parseUTSCustomElement = exports.parseUTSComponent = exports.getUTSCustomElementAutoImports = exports.getUTSComponentAutoImports = exports.getUTSCustomElement = exports.isUTSCustomElement = exports.getUTSPluginCustomElements = exports.getUTSCustomElements = exports.clearUTSCustomElements = exports.isUTSComponent = exports.clearUTSComponents = exports.getUTSCustomElementsExports = exports.resolveUTSCompilerVersion = exports.resolveUTSCompiler = exports.hasUTSModulePlatformFile = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
7
7
|
// 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -11,7 +11,10 @@ const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
|
11
11
|
const unimport_1 = require("unimport");
|
|
12
12
|
const hbx_1 = require("./hbx");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
|
+
const messages_1 = require("./messages");
|
|
14
15
|
const uni_modules_1 = require("./uni_modules");
|
|
16
|
+
const preprocess_1 = require("./preprocess");
|
|
17
|
+
const x_1 = require("./x");
|
|
15
18
|
function once(fn, ctx = null) {
|
|
16
19
|
let res;
|
|
17
20
|
return ((...args) => {
|
|
@@ -36,7 +39,7 @@ function resolveUTSAppModule(platform, id, importer, includeUTSSDK = true) {
|
|
|
36
39
|
if (parentDir === 'uni_modules' ||
|
|
37
40
|
(includeUTSSDK && parentDir === 'utssdk')) {
|
|
38
41
|
const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
|
|
39
|
-
if (
|
|
42
|
+
if ((0, x_1.isUniAppXJsEngine)()) {
|
|
40
43
|
// js engine
|
|
41
44
|
if (parentDir === 'uni_modules') {
|
|
42
45
|
const appJsIndex = path_1.default.resolve(id, basedir, 'app-js', 'index.uts');
|
|
@@ -74,21 +77,64 @@ function resolveUTSAppModule(platform, id, importer, includeUTSSDK = true) {
|
|
|
74
77
|
};
|
|
75
78
|
const extname = ['.uts', '.vue', '.uvue'];
|
|
76
79
|
if (platform === 'app-harmony') {
|
|
77
|
-
|
|
80
|
+
const indexFile = resolveUTSFile(resolvePlatformDir(platform), extname);
|
|
81
|
+
// dom2 下,如果平台入口直接是 utssdk/平台/index.vue,
|
|
82
|
+
// 说明该插件仍然使用旧版 uni-app 兼容模式组件实现,需要提前给出明确提示。
|
|
83
|
+
if (isDom2CompatibleVueComponent(indexFile)) {
|
|
84
|
+
throw createDom2CompatibleComponentError(path_1.default.basename(id), indexFile);
|
|
85
|
+
}
|
|
86
|
+
if (indexFile) {
|
|
78
87
|
return id;
|
|
79
88
|
}
|
|
80
89
|
return;
|
|
81
90
|
}
|
|
82
|
-
|
|
91
|
+
const appAndroidIndexFile = resolveUTSFile(resolvePlatformDir('app-android'), extname);
|
|
92
|
+
// Android / iOS 保持与现有解析顺序一致,只在命中旧版兼容模式入口时中断。
|
|
93
|
+
if (isDom2CompatibleVueComponent(appAndroidIndexFile)) {
|
|
94
|
+
throw createDom2CompatibleComponentError(path_1.default.basename(id), appAndroidIndexFile);
|
|
95
|
+
}
|
|
96
|
+
if (appAndroidIndexFile) {
|
|
83
97
|
return id;
|
|
84
98
|
}
|
|
85
|
-
|
|
99
|
+
const appIOSIndexFile = resolveUTSFile(resolvePlatformDir('app-ios'), extname);
|
|
100
|
+
if (isDom2CompatibleVueComponent(appIOSIndexFile)) {
|
|
101
|
+
throw createDom2CompatibleComponentError(path_1.default.basename(id), appIOSIndexFile);
|
|
102
|
+
}
|
|
103
|
+
if (appIOSIndexFile) {
|
|
86
104
|
return id;
|
|
87
105
|
}
|
|
88
106
|
}
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
109
|
exports.resolveUTSAppModule = resolveUTSAppModule;
|
|
110
|
+
function isDom2CompatibleVueComponent(file) {
|
|
111
|
+
if (!file || process.env.UNI_APP_X_DOM2 !== 'true') {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// 这里按目录层级做结构化判断:
|
|
115
|
+
// uni_modules/插件名/utssdk/平台/index.vue
|
|
116
|
+
const normalizedFile = (0, utils_1.normalizePath)(file);
|
|
117
|
+
const relativeFile = (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR || process.cwd(), normalizedFile));
|
|
118
|
+
const segments = relativeFile.split('/');
|
|
119
|
+
const uniModulesIndex = segments.lastIndexOf('uni_modules');
|
|
120
|
+
if (uniModulesIndex < 0) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const pluginName = segments[uniModulesIndex + 1];
|
|
124
|
+
const utssdkDir = segments[uniModulesIndex + 2];
|
|
125
|
+
const platformDir = segments[uniModulesIndex + 3];
|
|
126
|
+
const entryFile = segments[uniModulesIndex + 4];
|
|
127
|
+
return (!!pluginName &&
|
|
128
|
+
utssdkDir === 'utssdk' &&
|
|
129
|
+
!!platformDir &&
|
|
130
|
+
entryFile === 'index.vue' &&
|
|
131
|
+
uniModulesIndex + 5 === segments.length);
|
|
132
|
+
}
|
|
133
|
+
function createDom2CompatibleComponentError(name, file) {
|
|
134
|
+
return new Error(messages_1.M['dom2.compatible.component']
|
|
135
|
+
.replace('{name}', `[${name}]`)
|
|
136
|
+
.replace('{file}', (0, utils_1.normalizePath)(path_1.default.relative(process.env.UNI_INPUT_DIR || process.cwd(), file))));
|
|
137
|
+
}
|
|
92
138
|
// 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
|
|
93
139
|
function resolveUTSModule(id, importer, includeUTSSDK = true) {
|
|
94
140
|
if (process.env.UNI_PLATFORM === 'app' ||
|
|
@@ -119,6 +165,36 @@ function resolveUTSModule(id, importer, includeUTSSDK = true) {
|
|
|
119
165
|
}
|
|
120
166
|
}
|
|
121
167
|
exports.resolveUTSModule = resolveUTSModule;
|
|
168
|
+
function hasUTSModulePlatformFile(pluginDir, platform) {
|
|
169
|
+
const utssdkDir = path_1.default.resolve(pluginDir, 'utssdk');
|
|
170
|
+
if (!fs_extra_1.default.existsSync(utssdkDir)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
// 根目录 index.uts 视为当前平台可复用,和现有 uts 解析逻辑保持一致
|
|
174
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(utssdkDir, 'index.uts'))) {
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
if (platform === 'app-harmony') {
|
|
178
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(utssdkDir, 'app-js', 'index.uts')) ||
|
|
179
|
+
resolveUTSFile(path_1.default.resolve(utssdkDir, platform), [
|
|
180
|
+
'.uts',
|
|
181
|
+
'.vue',
|
|
182
|
+
'.uvue',
|
|
183
|
+
])) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (platform === 'app-android' || platform === 'app-ios') {
|
|
189
|
+
return !!resolveUTSFile(path_1.default.resolve(utssdkDir, platform), [
|
|
190
|
+
'.uts',
|
|
191
|
+
'.vue',
|
|
192
|
+
'.uvue',
|
|
193
|
+
]);
|
|
194
|
+
}
|
|
195
|
+
return !!resolveUTSFile(path_1.default.resolve(utssdkDir, platform));
|
|
196
|
+
}
|
|
197
|
+
exports.hasUTSModulePlatformFile = hasUTSModulePlatformFile;
|
|
122
198
|
function resolveUTSEncryptFile(pluginId, index) {
|
|
123
199
|
if (!pluginId) {
|
|
124
200
|
return;
|
|
@@ -335,12 +411,18 @@ function initUTSComponents(inputDir, platform) {
|
|
|
335
411
|
const kotlinPackage = parseKotlinPackageWithPluginId(pluginId, is_uni_modules_utssdk);
|
|
336
412
|
const swiftModule = parseSwiftModuleWithPluginId(pluginId, is_uni_modules_utssdk);
|
|
337
413
|
const swiftNamespace = parseSwiftPackageWithPluginId(pluginId, is_uni_modules_utssdk);
|
|
414
|
+
// App 平台依旧沿用 uts-proxy 机制,这里只补充兼容性标记,不改变现有导入方式。
|
|
338
415
|
easycomsObj[`^${name}$`] = {
|
|
339
416
|
source: isApp ? `${source}?uts-proxy` : source,
|
|
340
417
|
kotlinPackage: kotlinPackage,
|
|
341
418
|
swiftModule: swiftModule,
|
|
342
419
|
kotlinNamespace: kotlinPackage,
|
|
343
420
|
swiftNamespace: swiftNamespace,
|
|
421
|
+
// 仅记录命中的旧版兼容模式文件,真正报错放到 easycom / resolve 阶段,
|
|
422
|
+
// 这样既能复用已有扫描结果,也不会影响非 dom2 场景。
|
|
423
|
+
dom2IncompatibleFile: isDom2CompatibleVueComponent(file)
|
|
424
|
+
? (0, utils_1.normalizePath)(path_1.default.relative(inputDir, file))
|
|
425
|
+
: undefined,
|
|
344
426
|
};
|
|
345
427
|
}
|
|
346
428
|
});
|
|
@@ -353,6 +435,8 @@ function initUTSComponents(inputDir, platform) {
|
|
|
353
435
|
name: componentName,
|
|
354
436
|
pattern: new RegExp(name),
|
|
355
437
|
replacement: obj.source,
|
|
438
|
+
// 透传给 easycom 匹配逻辑,便于在模板中引用组件时直接给出更准确的错误信息。
|
|
439
|
+
dom2IncompatibleFile: obj.dom2IncompatibleFile,
|
|
356
440
|
});
|
|
357
441
|
utsComponents.set(componentName, {
|
|
358
442
|
source: obj.source,
|
|
@@ -510,7 +594,7 @@ async function parseUniExtApiAutoImports(uniExtApiAutoImports, extApis, parseSou
|
|
|
510
594
|
const filename = `uni_modules/${pluginId}/utssdk/interface.uts`;
|
|
511
595
|
const interfaceFileName = path_1.default.resolve(process.env.UNI_INPUT_DIR, filename);
|
|
512
596
|
if (fs_extra_1.default.existsSync(interfaceFileName)) {
|
|
513
|
-
const ids = await parseExportIdentifiers(interfaceFileName);
|
|
597
|
+
const ids = await parseExportIdentifiers(interfaceFileName, preprocess_1.preUVueJs);
|
|
514
598
|
ids
|
|
515
599
|
// 过滤掉 Uni
|
|
516
600
|
.filter((id) => id !== 'Uni')
|
package/dist/vite/autoImport.js
CHANGED
|
@@ -9,6 +9,7 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
|
9
9
|
const uts_1 = require("../uts");
|
|
10
10
|
const workers_1 = require("../workers");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
|
+
const x_1 = require("../x");
|
|
12
13
|
const uniWebLifeCyclePreset = {
|
|
13
14
|
from: '@dcloudio/uni-app',
|
|
14
15
|
imports: [
|
|
@@ -284,8 +285,10 @@ const vuePreset = {
|
|
|
284
285
|
function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
|
|
285
286
|
rewriteAutoImportOnce();
|
|
286
287
|
const autoImport = [vuePreset];
|
|
287
|
-
//
|
|
288
|
-
if (platform === 'app-ios' ||
|
|
288
|
+
// JS 引擎的 App 平台统一走 vue 生命周期导入
|
|
289
|
+
if (platform === 'app-ios' ||
|
|
290
|
+
platform === 'app-harmony' ||
|
|
291
|
+
(0, x_1.isUniAppXAndroidJsEngine)(platform)) {
|
|
289
292
|
autoImport.push(uniAppLifeCyclePreset);
|
|
290
293
|
}
|
|
291
294
|
else if (platform === 'web') {
|
|
@@ -317,8 +320,8 @@ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
|
|
|
317
320
|
include: [/\.[u]?ts$/, /\.[u]?vue/],
|
|
318
321
|
exclude,
|
|
319
322
|
imports: imports.concat(
|
|
320
|
-
//
|
|
321
|
-
platform
|
|
323
|
+
// 旧版 Android x 仍由专有编译流程处理,Android Vapor 对齐 iOS 走通用自动导入
|
|
324
|
+
(0, x_1.isUniAppXAndroidNative)(platform) ? [] : autoImport),
|
|
322
325
|
dts: false,
|
|
323
326
|
};
|
|
324
327
|
}
|
package/dist/vite/cloud.js
CHANGED
|
@@ -15,6 +15,8 @@ const uni_modules_1 = require("./plugins/uts/uni_modules");
|
|
|
15
15
|
const utils_3 = require("./utils");
|
|
16
16
|
const json_1 = require("../json");
|
|
17
17
|
const workers_1 = require("../workers");
|
|
18
|
+
const dom2_1 = require("../dom2");
|
|
19
|
+
const x_1 = require("../x");
|
|
18
20
|
function createEncryptCssUrlReplacer(resolve) {
|
|
19
21
|
return async (url, importer) => {
|
|
20
22
|
if (url.startsWith('/') && !url.startsWith('//')) {
|
|
@@ -64,6 +66,7 @@ exports.uniEncryptUniModulesAssetsPlugin = uniEncryptUniModulesAssetsPlugin;
|
|
|
64
66
|
function uniEncryptUniModulesPlugin() {
|
|
65
67
|
let resolvedConfig;
|
|
66
68
|
const isMp = process.env.UNI_UTS_PLATFORM.startsWith('mp-');
|
|
69
|
+
const useUniAppXAndroidNative = (0, x_1.isUniAppXAndroidNative)();
|
|
67
70
|
const encryptModuleOutputFiles = [];
|
|
68
71
|
return {
|
|
69
72
|
name: 'uni:encrypt-uni-modules',
|
|
@@ -92,7 +95,7 @@ function uniEncryptUniModulesPlugin() {
|
|
|
92
95
|
resolvedConfig = config;
|
|
93
96
|
},
|
|
94
97
|
resolveId(id, importer) {
|
|
95
|
-
if (
|
|
98
|
+
if (!useUniAppXAndroidNative) {
|
|
96
99
|
if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
|
|
97
100
|
id = (0, utils_2.normalizePath)(id);
|
|
98
101
|
if (importer && (id.startsWith('./') || id.startsWith('../'))) {
|
|
@@ -106,7 +109,7 @@ function uniEncryptUniModulesPlugin() {
|
|
|
106
109
|
}
|
|
107
110
|
},
|
|
108
111
|
load(id) {
|
|
109
|
-
if (
|
|
112
|
+
if (!useUniAppXAndroidNative) {
|
|
110
113
|
if (resolvedConfig.assetsInclude((0, utils_1.cleanUrl)(id))) {
|
|
111
114
|
return {
|
|
112
115
|
code: `export default ${JSON.stringify(id.replace(/\0/g, ''))}`,
|
|
@@ -119,8 +122,8 @@ function uniEncryptUniModulesPlugin() {
|
|
|
119
122
|
Object.keys(bundle).forEach((fileName) => {
|
|
120
123
|
if (fileName.endsWith('.module.js')) {
|
|
121
124
|
const uniModuleId = path_1.default.basename(fileName).replace('.module.js', '');
|
|
122
|
-
//
|
|
123
|
-
if (
|
|
125
|
+
// 仅旧版 Android x 不需要 js
|
|
126
|
+
if (!useUniAppXAndroidNative) {
|
|
124
127
|
const newFileName = 'uni_modules/' +
|
|
125
128
|
fileName.replace('.module.js', '/index.module.js');
|
|
126
129
|
bundle[newFileName] = bundle[fileName];
|
|
@@ -171,12 +174,13 @@ function uniEncryptUniModulesPlugin() {
|
|
|
171
174
|
}
|
|
172
175
|
},
|
|
173
176
|
async writeBundle() {
|
|
174
|
-
if (
|
|
177
|
+
if (!useUniAppXAndroidNative) {
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
177
180
|
const uniXKotlinCompiler = process.env.UNI_APP_X_TSC === 'true'
|
|
178
181
|
? (0, uts_1.resolveUTSCompiler)().createUniXKotlinCompilerOnce({
|
|
179
182
|
resolveWorkers: () => (0, workers_1.getWorkers)(),
|
|
183
|
+
sourceFileCallback: (0, dom2_1.initSourceFileCallback)(),
|
|
180
184
|
})
|
|
181
185
|
: null;
|
|
182
186
|
if (uniXKotlinCompiler) {
|
|
@@ -393,7 +397,10 @@ function compileCloudUniModuleWithTsc(platform, pluginDir) {
|
|
|
393
397
|
const isX = process.env.UNI_APP_X === 'true';
|
|
394
398
|
const resolveWorkers = () => (0, workers_1.getWorkers)();
|
|
395
399
|
return compileUniModuleWithTsc(platform, pluginDir, platform === 'app-android'
|
|
396
|
-
? createUniXKotlinCompilerOnce({
|
|
400
|
+
? createUniXKotlinCompilerOnce({
|
|
401
|
+
resolveWorkers,
|
|
402
|
+
sourceFileCallback: (0, dom2_1.initSourceFileCallback)(),
|
|
403
|
+
})
|
|
397
404
|
: platform === 'app-harmony'
|
|
398
405
|
? createUniXArkTSCompilerOnce({ resolveWorkers })
|
|
399
406
|
: createUniXSwiftCompilerOnce({ resolveWorkers }), {
|
package/dist/vite/extApi.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.uniUniModulesExtApiPlugin = void 0;
|
|
4
4
|
const uts_1 = require("../uts");
|
|
5
5
|
const resolve_1 = require("../resolve");
|
|
6
|
+
const x_1 = require("../x");
|
|
6
7
|
function uniUniModulesExtApiPlugin() {
|
|
7
8
|
return {
|
|
8
9
|
name: 'uni:uni-modules_ext-api',
|
|
@@ -21,7 +22,9 @@ function uniUniModulesExtApiPlugin() {
|
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
24
|
const build = {};
|
|
24
|
-
if (
|
|
25
|
+
if (process.env.UNI_UTS_PLATFORM === 'app-ios' ||
|
|
26
|
+
process.env.UNI_UTS_PLATFORM === 'app-harmony' ||
|
|
27
|
+
(0, x_1.isUniAppXAndroidJsEngine)()) {
|
|
25
28
|
build.rollupOptions = rollupOptions;
|
|
26
29
|
}
|
|
27
30
|
return {
|
|
@@ -39,12 +39,15 @@ function uniViteInjectPlugin(name, options) {
|
|
|
39
39
|
normalizeModulesMap(namespaceModulesMap);
|
|
40
40
|
}
|
|
41
41
|
const firstpass = new RegExp(`(?:${Array.from(modulesMap.keys()).map(escape).join('|')})`, 'g');
|
|
42
|
-
|
|
42
|
+
let sourceMap = options.sourceMap !== false;
|
|
43
43
|
const callback = options.callback;
|
|
44
44
|
return {
|
|
45
45
|
name,
|
|
46
46
|
// 确保在 commonjs 之后,否则会混合 es6 module 与 cjs 的代码,导致 commonjs 失效
|
|
47
47
|
enforce: options.enforce ?? 'post',
|
|
48
|
+
configResolved(config) {
|
|
49
|
+
sourceMap = options.sourceMap !== false && (0, utils_1.withSourcemap)(config);
|
|
50
|
+
},
|
|
48
51
|
transform(code, id) {
|
|
49
52
|
if (!filter(id))
|
|
50
53
|
return null;
|
|
@@ -9,86 +9,19 @@ const json_1 = require("../../json");
|
|
|
9
9
|
const preprocess_1 = require("../../preprocess");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
function uniJsonPlugin() {
|
|
12
|
-
const UTS_CAST_ARRAY_MARKER = '/*__UTS_CAST_UTSJSON_ARRAY__*/';
|
|
13
|
-
const UTS_CAST_OBJECT_MARKER = '/*__UTS_CAST_UTSJSON_OBJECT__*/';
|
|
14
|
-
const IS_UNI_X_ANDROID = process.env.UNI_APP_X === 'true' &&
|
|
15
|
-
process.env.UNI_UTS_PLATFORM === 'app-android';
|
|
16
12
|
return {
|
|
17
13
|
name: 'uni:json',
|
|
18
14
|
enforce: 'pre',
|
|
19
|
-
generateBundle(options, bundle) {
|
|
20
|
-
if (IS_UNI_X_ANDROID) {
|
|
21
|
-
for (const [fileName, file] of Object.entries(bundle)) {
|
|
22
|
-
if (fileName.endsWith('.json.ts')) {
|
|
23
|
-
if (file.type === 'asset' && file.source) {
|
|
24
|
-
const source = file.source.toString();
|
|
25
|
-
if (source.includes(UTS_CAST_ARRAY_MARKER) ||
|
|
26
|
-
source.includes(UTS_CAST_OBJECT_MARKER)) {
|
|
27
|
-
file.source = source
|
|
28
|
-
.replace(new RegExp(UTS_CAST_ARRAY_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ' as UTSJSONObject[]')
|
|
29
|
-
.replace(new RegExp(UTS_CAST_OBJECT_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ' as UTSJSONObject');
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
15
|
transform(code, id) {
|
|
37
16
|
// 如果已经被其他插件处理过了,就不再处理,比如 commonjs 插件,ICAPRegistrar.json?commonjs-external
|
|
38
17
|
if (id.startsWith('\0')) {
|
|
39
18
|
return;
|
|
40
19
|
}
|
|
41
|
-
|
|
42
|
-
if (path_1.default.extname(filename) !== '.json') {
|
|
20
|
+
if (path_1.default.extname((0, utils_1.parseVueRequest)(id).filename) !== '.json') {
|
|
43
21
|
return;
|
|
44
22
|
}
|
|
45
|
-
let codeObj = (0, json_1.parseJson)((0, preprocess_1.preJson)(code, id), false, id);
|
|
46
|
-
let codeJson = '';
|
|
47
|
-
if (IS_UNI_X_ANDROID) {
|
|
48
|
-
if (Array.isArray(codeObj)) {
|
|
49
|
-
codeJson +=
|
|
50
|
-
'export default JSON.parseArray(`' +
|
|
51
|
-
JSON.stringify(codeObj, null, 2) +
|
|
52
|
-
'`)' +
|
|
53
|
-
UTS_CAST_ARRAY_MARKER +
|
|
54
|
-
';\n';
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
codeJson +=
|
|
58
|
-
'let __jsonObj = JSON.parseObject(`' +
|
|
59
|
-
JSON.stringify(codeObj, null, 2) +
|
|
60
|
-
'`);\n';
|
|
61
|
-
for (const key in codeObj) {
|
|
62
|
-
if (!Object.hasOwn(codeObj, key))
|
|
63
|
-
continue;
|
|
64
|
-
const element = codeObj[key];
|
|
65
|
-
if (Array.isArray(element)) {
|
|
66
|
-
codeJson += `export const ${key} = __jsonObj?.getArray("${key}")${UTS_CAST_ARRAY_MARKER};\n`;
|
|
67
|
-
}
|
|
68
|
-
else if (typeof element === 'object' && element !== null) {
|
|
69
|
-
codeJson += `export const ${key} = __jsonObj?.get("${key}")${UTS_CAST_OBJECT_MARKER};\n`;
|
|
70
|
-
}
|
|
71
|
-
else if (typeof element === 'string') {
|
|
72
|
-
codeJson += `export const ${key} = __jsonObj?.getString("${key}") ?? '';\n`;
|
|
73
|
-
}
|
|
74
|
-
else if (typeof element === 'number') {
|
|
75
|
-
codeJson += `export const ${key} = __jsonObj?.getNumber("${key}") ?? 0;\n`;
|
|
76
|
-
}
|
|
77
|
-
else if (typeof element === 'boolean') {
|
|
78
|
-
codeJson += `export const ${key} = __jsonObj?.getBoolean("${key}") ?? false;\n`;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
codeJson += `export const ${key} = __jsonObj?.get("${key}")${UTS_CAST_OBJECT_MARKER};\n`;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
codeJson += `export default __jsonObj;`;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
codeJson = JSON.stringify(codeObj, null, 2);
|
|
89
|
-
}
|
|
90
23
|
return {
|
|
91
|
-
code:
|
|
24
|
+
code: JSON.stringify((0, json_1.parseJson)((0, preprocess_1.preJson)(code, id), false, id), null, 2),
|
|
92
25
|
map: {
|
|
93
26
|
mappings: '',
|
|
94
27
|
},
|
package/dist/vite/plugins/pre.js
CHANGED
|
@@ -8,6 +8,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
8
8
|
const debug_1 = __importDefault(require("debug"));
|
|
9
9
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
10
10
|
const constants_1 = require("../../constants");
|
|
11
|
+
const dom2_1 = require("../../dom2");
|
|
11
12
|
const preprocess_1 = require("../../preprocess");
|
|
12
13
|
const utils_1 = require("../utils");
|
|
13
14
|
const debugPreJs = (0, debug_1.default)('uni:pre-js');
|
|
@@ -41,6 +42,7 @@ function uniPrePlugin(config, options) {
|
|
|
41
42
|
if (!hasEndif) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
45
|
+
(0, dom2_1.warnDom2RootScrollView)(code, filename, !!query.vue);
|
|
44
46
|
// 因为完整的 vue 会先条件编译,而 vue&type=template 等会再次条件编译,如果走error模式会报两次错误,且第二次错误没有正确的位置映射
|
|
45
47
|
const unbalanced = query.vue ? 'skip' : 'error';
|
|
46
48
|
if (isHtml) {
|
|
@@ -9,11 +9,64 @@ const utils_1 = require("../../utils");
|
|
|
9
9
|
const json_1 = require("../../json");
|
|
10
10
|
const messages_1 = require("../../messages");
|
|
11
11
|
const emittedHashMap = new WeakMap();
|
|
12
|
-
function
|
|
12
|
+
function normalizeVaporRenderTarget(target) {
|
|
13
|
+
if (typeof target !== 'string') {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (target.includes('bytecode')) {
|
|
17
|
+
return 'bytecode';
|
|
18
|
+
}
|
|
19
|
+
if (target.includes('nativecode')) {
|
|
20
|
+
return 'nativecode';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function formatVaporRenderTarget(target) {
|
|
24
|
+
return messages_1.M[`view.render.compiler.target.${target}`];
|
|
25
|
+
}
|
|
26
|
+
function getManifestVaporRenderTarget(manifest) {
|
|
27
|
+
return normalizeVaporRenderTarget(manifest['uni-app-x']?.['vapor-render-target']);
|
|
28
|
+
}
|
|
29
|
+
function appendChangedFile(changedFiles, seenFiles, filename) {
|
|
30
|
+
if (seenFiles.has(filename)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
seenFiles.add(filename);
|
|
34
|
+
changedFiles.push(filename);
|
|
35
|
+
}
|
|
36
|
+
function appendImporterFiles(changedFiles, seenFiles, bundle) {
|
|
37
|
+
const importerMap = new Map();
|
|
38
|
+
Object.keys(bundle).forEach((filename) => {
|
|
39
|
+
const outputFile = bundle[filename];
|
|
40
|
+
if (outputFile.type !== 'chunk') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const imports = outputFile.imports.concat(outputFile.dynamicImports);
|
|
44
|
+
imports.forEach((file) => {
|
|
45
|
+
const importers = importerMap.get(file);
|
|
46
|
+
if (importers) {
|
|
47
|
+
importers.push(filename);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
importerMap.set(file, [filename]);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
for (let i = 0; i < changedFiles.length; i++) {
|
|
55
|
+
const importers = importerMap.get(changedFiles[i]);
|
|
56
|
+
if (!importers) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
importers.forEach((filename) => {
|
|
60
|
+
appendChangedFile(changedFiles, seenFiles, filename);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function uniStatsPlugin(options = {}) {
|
|
13
65
|
let resolvedConfig;
|
|
14
66
|
let isManifestChanged = false;
|
|
15
|
-
const shouldTrackManifestChange = process.env.
|
|
67
|
+
const shouldTrackManifestChange = process.env.UNI_PLATFORM === 'app' ||
|
|
16
68
|
process.env.UNI_PLATFORM === 'app-harmony';
|
|
69
|
+
const shouldAppendImporterFiles = process.env.UNI_PLATFORM === 'app-harmony';
|
|
17
70
|
let isVapor = shouldTrackManifestChange && process.env.UNI_APP_X_DOM2 === 'true';
|
|
18
71
|
return {
|
|
19
72
|
name: 'uni:app-stats',
|
|
@@ -28,21 +81,36 @@ function uniStatsPlugin() {
|
|
|
28
81
|
try {
|
|
29
82
|
const manifest = (0, json_1.parseJson)(fs_extra_1.default.readFileSync(id, 'utf-8'), true, 'manifest.json');
|
|
30
83
|
const uniAppX = manifest['uni-app-x'] || {};
|
|
84
|
+
const vaporRenderTarget = getManifestVaporRenderTarget(manifest);
|
|
85
|
+
const runtimeVaporRenderTarget = normalizeVaporRenderTarget(process.env.UNI_APP_X_VAPOR_RENDER_TARGET);
|
|
86
|
+
if (vaporRenderTarget &&
|
|
87
|
+
runtimeVaporRenderTarget &&
|
|
88
|
+
vaporRenderTarget !== runtimeVaporRenderTarget) {
|
|
89
|
+
console.warn(messages_1.M['dev.watching.vapor.render.target']
|
|
90
|
+
.replace('{manifestTarget}', formatVaporRenderTarget(vaporRenderTarget))
|
|
91
|
+
.replace('{runtimeTarget}', formatVaporRenderTarget(runtimeVaporRenderTarget)));
|
|
92
|
+
}
|
|
31
93
|
if (uniAppX.vapor !== isVapor) {
|
|
32
94
|
isVapor = uniAppX.vapor === true;
|
|
33
95
|
console.warn(messages_1.M['dev.watching.restart.vapor']);
|
|
96
|
+
// 主动退出,避免后续会打印正在编译中等日志
|
|
97
|
+
process.exit(0);
|
|
34
98
|
}
|
|
35
99
|
}
|
|
36
100
|
catch (e) { }
|
|
37
101
|
}
|
|
38
102
|
},
|
|
39
103
|
writeBundle(_, bundle) {
|
|
104
|
+
if (options.manifestOnly) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
40
107
|
if (resolvedConfig.isProduction) {
|
|
41
108
|
// 仅dev生效
|
|
42
109
|
return;
|
|
43
110
|
}
|
|
44
111
|
const emittedHash = emittedHashMap.get(resolvedConfig);
|
|
45
112
|
const changedFiles = [];
|
|
113
|
+
const seenFiles = new Set();
|
|
46
114
|
Object.keys(bundle).forEach((filename) => {
|
|
47
115
|
// 不处理sourcemap
|
|
48
116
|
if (filename.endsWith('.map')) {
|
|
@@ -58,9 +126,12 @@ function uniStatsPlugin() {
|
|
|
58
126
|
}
|
|
59
127
|
if (emittedHash.get(filename) !== outputFileHash) {
|
|
60
128
|
emittedHash.set(filename, outputFileHash);
|
|
61
|
-
changedFiles
|
|
129
|
+
appendChangedFile(changedFiles, seenFiles, filename);
|
|
62
130
|
}
|
|
63
131
|
});
|
|
132
|
+
if (shouldAppendImporterFiles) {
|
|
133
|
+
appendImporterFiles(changedFiles, seenFiles, bundle);
|
|
134
|
+
}
|
|
64
135
|
if (isManifestChanged) {
|
|
65
136
|
isManifestChanged = false;
|
|
66
137
|
changedFiles.unshift('manifest.json');
|
|
@@ -12,7 +12,7 @@ interface UniUTSPluginOptions {
|
|
|
12
12
|
export declare function getCurrentCompiledUTSPlugins(): Set<string>;
|
|
13
13
|
export declare function getCurrentCompiledUTSProviders(): Set<string>;
|
|
14
14
|
export declare function uniUTSAppUniModulesPlugin(options?: UniUTSPluginOptions): Plugin;
|
|
15
|
-
export declare function buildUniExtApis(): Promise<void>;
|
|
15
|
+
export declare function buildUniExtApis(providerOnly?: boolean): Promise<void>;
|
|
16
16
|
export declare function buildNonTreeShakingUniModules(): Promise<void>;
|
|
17
17
|
export declare function resolveExtApiProvider(pkg: Record<string, any>): {
|
|
18
18
|
name?: string | undefined;
|