@dcloudio/uni-cli-shared 3.0.0-4040520250104002 → 3.0.0-4050320250303001
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/json/pages.d.ts +1 -0
- package/dist/json/pages.js +9 -1
- package/dist/json/uni-x/index.js +6 -1
- package/dist/mp/usingComponents.d.ts +3 -1
- package/dist/mp/usingComponents.js +6 -2
- package/dist/uni_modules.cloud.d.ts +4 -3
- package/dist/uni_modules.cloud.js +67 -16
- package/dist/utils.js +3 -1
- package/dist/vite/autoImport.js +4 -0
- package/dist/vite/cloud.js +3 -15
- package/dist/vite/plugins/cssScoped.d.ts +1 -1
- package/dist/vite/plugins/cssScoped.js +9 -4
- package/dist/vite/plugins/easycom.js +3 -1
- package/dist/vite/plugins/inject.js +3 -1
- package/dist/vite/plugins/json.js +3 -1
- package/dist/vite/plugins/uts/uni_modules.js +35 -7
- package/dist/vite/plugins/uts/uvue.d.ts +7 -0
- package/dist/vite/plugins/uts/uvue.js +30 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +6 -1
- package/dist/vue/transforms/templateTransformAssetUrl.js +5 -0
- package/dist/watcher.js +1 -1
- package/package.json +4 -4
package/dist/json/pages.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function isUniPageFile(file: string, inputDir?: string): boolean;
|
|
2
|
+
export declare function isUniPageSetupAndUts(file: string): boolean;
|
|
2
3
|
export declare function isUniPageSetupAndTs(file: string): boolean;
|
|
3
4
|
export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
|
|
4
5
|
/**
|
package/dist/json/pages.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.filterPlatformPages = exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
|
|
6
|
+
exports.filterPlatformPages = exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageSetupAndUts = exports.isUniPageFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -23,6 +23,14 @@ function isUniPageFile(file, inputDir = process.env.UNI_INPUT_DIR) {
|
|
|
23
23
|
return pagesCacheSet.has((0, utils_1.removeExt)(file));
|
|
24
24
|
}
|
|
25
25
|
exports.isUniPageFile = isUniPageFile;
|
|
26
|
+
function isUniPageSetupAndUts(file) {
|
|
27
|
+
const { filename, query } = (0, vite_1.parseVueRequest)(file);
|
|
28
|
+
return !!(query.vue &&
|
|
29
|
+
query.setup &&
|
|
30
|
+
(0, shared_1.hasOwn)(query, 'lang.uts') &&
|
|
31
|
+
constants_1.EXTNAME_VUE_RE.test(filename));
|
|
32
|
+
}
|
|
33
|
+
exports.isUniPageSetupAndUts = isUniPageSetupAndUts;
|
|
26
34
|
function isUniPageSetupAndTs(file) {
|
|
27
35
|
const { filename, query } = (0, vite_1.parseVueRequest)(file);
|
|
28
36
|
return !!(query.vue &&
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -232,11 +232,16 @@ function normalizeUniAppXAppConfig(pagesJson, manifestJson) {
|
|
|
232
232
|
const uniConfig = (0, uniConfig_1.normalizeAppXUniConfig)(pagesJson, manifestJson);
|
|
233
233
|
const tabBar = uniConfig.tabBar;
|
|
234
234
|
delete uniConfig.tabBar;
|
|
235
|
-
|
|
235
|
+
let appConfigJs = `const __uniConfig = ${JSON.stringify(uniConfig)};
|
|
236
236
|
__uniConfig.getTabBarConfig = () => {return ${tabBar ? JSON.stringify(tabBar) : 'undefined'}};
|
|
237
237
|
__uniConfig.tabBar = __uniConfig.getTabBarConfig();
|
|
238
238
|
const __uniRoutes = ${(0, uniRoutes_1.normalizeAppUniRoutes)(pagesJson)}.map(uniRoute=>(uniRoute.meta.route=uniRoute.path,__uniConfig.pages.push(uniRoute.path),uniRoute.path='/'+uniRoute.path,uniRoute)).concat(typeof __uniSystemRoutes !== 'undefined' ? __uniSystemRoutes : []);
|
|
239
239
|
|
|
240
240
|
`;
|
|
241
|
+
if (process.env.UNI_UTS_PLATFORM === 'app-harmony') {
|
|
242
|
+
appConfigJs += `globalThis.__uniConfig = __uniConfig;
|
|
243
|
+
globalThis.__uniRoutes = __uniRoutes;`;
|
|
244
|
+
}
|
|
245
|
+
return appConfigJs;
|
|
241
246
|
}
|
|
242
247
|
exports.normalizeUniAppXAppConfig = normalizeUniAppXAppConfig;
|
|
@@ -390,7 +390,9 @@ async function transformDynamicImports(code, imports, { id, sourceMap, dynamicIm
|
|
|
390
390
|
if (!imports.length) {
|
|
391
391
|
return {
|
|
392
392
|
code,
|
|
393
|
-
map:
|
|
393
|
+
map: {
|
|
394
|
+
mappings: '',
|
|
395
|
+
},
|
|
394
396
|
};
|
|
395
397
|
}
|
|
396
398
|
const s = new magic_string_1.default(code);
|
|
@@ -400,7 +402,9 @@ async function transformDynamicImports(code, imports, { id, sourceMap, dynamicIm
|
|
|
400
402
|
}
|
|
401
403
|
return {
|
|
402
404
|
code: s.toString(),
|
|
403
|
-
map:
|
|
405
|
+
map: {
|
|
406
|
+
mappings: '',
|
|
407
|
+
},
|
|
404
408
|
};
|
|
405
409
|
}
|
|
406
410
|
exports.transformDynamicImports = transformDynamicImports;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare function
|
|
2
|
-
export declare function
|
|
1
|
+
export declare function genEncryptEasyComModuleCode(platform: typeof process.env.UNI_UTS_PLATFORM, components: Record<string, '.vue' | '.uvue'>): string;
|
|
2
|
+
export declare function genEncryptUTSModuleCode(module: string, inputDir: string, platform: typeof process.env.UNI_UTS_PLATFORM): string;
|
|
3
|
+
export declare function parseUniModulesWithComponents(inputDir: string, platform: typeof process.env.UNI_UTS_PLATFORM): Record<string, string>;
|
|
3
4
|
/**
|
|
4
5
|
* 解析 easyCom 组件列表
|
|
5
6
|
* @param pluginId
|
|
@@ -7,7 +8,7 @@ export declare function parseUniModulesWithComponents(inputDir: string): Record<
|
|
|
7
8
|
* @returns
|
|
8
9
|
*/
|
|
9
10
|
export declare function parseEasyComComponents(pluginId: string, inputDir: string, detectBinary?: boolean): Record<string, ".vue" | ".uvue">;
|
|
10
|
-
export declare function findEncryptUniModules(inputDir: string, cacheDir?: string): Record<string, EncryptPackageJson | undefined>;
|
|
11
|
+
export declare function findEncryptUniModules(platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string, cacheDir?: string): Record<string, EncryptPackageJson | undefined>;
|
|
11
12
|
export declare function findUploadEncryptUniModulesFiles(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string): Record<string, string[]>;
|
|
12
13
|
export declare function packUploadEncryptUniModules(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string, cacheDir: string): {
|
|
13
14
|
zipFile: string;
|
|
@@ -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.parseUniModulesArtifacts = exports.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.packUploadEncryptUniModules = exports.findUploadEncryptUniModulesFiles = exports.findEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.
|
|
6
|
+
exports.parseUniModulesArtifacts = exports.checkEncryptUniModules = exports.resolveEncryptUniModule = exports.initCheckEnv = exports.packUploadEncryptUniModules = exports.findUploadEncryptUniModulesFiles = exports.findEncryptUniModules = exports.parseEasyComComponents = exports.parseUniModulesWithComponents = exports.genEncryptUTSModuleCode = exports.genEncryptEasyComModuleCode = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const fast_glob_1 = require("fast-glob");
|
|
@@ -25,15 +25,42 @@ function genEncryptEasyComModuleIndex(platform, components) {
|
|
|
25
25
|
imports.push(`import ${id}${instance ? `, { ${instance} }` : ''} from './components/${component}/${component}${components[component]}'`);
|
|
26
26
|
});
|
|
27
27
|
return `
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
${imports.join('\n')}
|
|
29
|
+
export {
|
|
30
|
+
${ids.join(',\n ')}
|
|
31
|
+
}
|
|
32
32
|
`;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
// easyCom
|
|
35
|
+
function genEncryptEasyComModuleCode(platform, components) {
|
|
36
|
+
// easyCom
|
|
37
|
+
if (components && Object.keys(components).length) {
|
|
38
|
+
return genEncryptEasyComModuleIndex(platform, components);
|
|
39
|
+
}
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
exports.genEncryptEasyComModuleCode = genEncryptEasyComModuleCode;
|
|
43
|
+
function genEncryptUTSModuleCode(module, inputDir, platform) {
|
|
44
|
+
const utssdkDir = path_1.default.resolve(inputDir, 'uni_modules', module, 'utssdk');
|
|
45
|
+
let indexUTSFile = '';
|
|
46
|
+
const platformIndexUTSFile = path_1.default.resolve(utssdkDir, platform, 'index.uts');
|
|
47
|
+
if (fs_extra_1.default.existsSync(platformIndexUTSFile)) {
|
|
48
|
+
indexUTSFile = `./utssdk/${platform}/index.uts`;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const rootIndexUTSFile = path_1.default.resolve(utssdkDir, 'index.uts');
|
|
52
|
+
if (fs_extra_1.default.existsSync(rootIndexUTSFile)) {
|
|
53
|
+
indexUTSFile = `./utssdk/index.uts`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (indexUTSFile) {
|
|
57
|
+
return `export * from '${indexUTSFile}'`;
|
|
58
|
+
}
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
exports.genEncryptUTSModuleCode = genEncryptUTSModuleCode;
|
|
35
62
|
// 目前该函数仅在云端使用(目前仅限iOS/web),云端编译时,提交上来的uni_modules是过滤好的
|
|
36
|
-
function parseUniModulesWithComponents(inputDir) {
|
|
63
|
+
function parseUniModulesWithComponents(inputDir, platform) {
|
|
37
64
|
const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
38
65
|
const uniModules = {};
|
|
39
66
|
if (fs_extra_1.default.existsSync(modulesDir)) {
|
|
@@ -41,14 +68,35 @@ function parseUniModulesWithComponents(inputDir) {
|
|
|
41
68
|
if (!fs_extra_1.default.existsSync(path_1.default.resolve(modulesDir, uniModuleDir, 'package.json'))) {
|
|
42
69
|
return;
|
|
43
70
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
let code = genEncryptUTSModuleCode(uniModuleDir, inputDir, platform);
|
|
72
|
+
if (code) {
|
|
73
|
+
// uts插件
|
|
74
|
+
uniModules[uniModuleDir] = code;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const codes = [];
|
|
78
|
+
// 前端组件插件
|
|
79
|
+
if (hasIndexFile(path_1.default.resolve(inputDir, 'uni_modules', uniModuleDir))) {
|
|
80
|
+
codes.push(`export * from './index'`);
|
|
81
|
+
}
|
|
82
|
+
// 解析加密的 easyCom 插件列表
|
|
83
|
+
const components = parseEasyComComponents(uniModuleDir, inputDir, false);
|
|
84
|
+
if (Object.keys(components).length) {
|
|
85
|
+
codes.push(genEncryptEasyComModuleCode(platform, components));
|
|
86
|
+
}
|
|
87
|
+
if (codes.length) {
|
|
88
|
+
uniModules[uniModuleDir] = codes.join(`\n`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
47
91
|
});
|
|
48
92
|
}
|
|
49
93
|
return uniModules;
|
|
50
94
|
}
|
|
51
95
|
exports.parseUniModulesWithComponents = parseUniModulesWithComponents;
|
|
96
|
+
const indexFiles = ['index.uts', 'index.ts', 'index.js'];
|
|
97
|
+
function hasIndexFile(uniModuleDir) {
|
|
98
|
+
return fs_extra_1.default.readdirSync(uniModuleDir).some((file) => indexFiles.includes(file));
|
|
99
|
+
}
|
|
52
100
|
/**
|
|
53
101
|
* 解析 easyCom 组件列表
|
|
54
102
|
* @param pluginId
|
|
@@ -85,7 +133,7 @@ function parseEasyComComponents(pluginId, inputDir, detectBinary = true) {
|
|
|
85
133
|
}
|
|
86
134
|
exports.parseEasyComComponents = parseEasyComComponents;
|
|
87
135
|
// 查找所有普通加密插件 uni_modules
|
|
88
|
-
function findEncryptUniModules(inputDir, cacheDir = '') {
|
|
136
|
+
function findEncryptUniModules(platform, inputDir, cacheDir = '') {
|
|
89
137
|
const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
90
138
|
const uniModules = {};
|
|
91
139
|
if (fs_extra_1.default.existsSync(modulesDir)) {
|
|
@@ -94,9 +142,12 @@ function findEncryptUniModules(inputDir, cacheDir = '') {
|
|
|
94
142
|
if (!fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'encrypt'))) {
|
|
95
143
|
return;
|
|
96
144
|
}
|
|
97
|
-
//
|
|
98
|
-
if (
|
|
99
|
-
|
|
145
|
+
// 只有 app-android 和 app-ios 不需要云编译 utssdk 插件,而是需要自定义基座
|
|
146
|
+
if (platform === 'app-android' || platform === 'app-ios') {
|
|
147
|
+
// 仅扫描普通加密插件,无需依赖
|
|
148
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk'))) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
100
151
|
}
|
|
101
152
|
const pkg = require(path_1.default.resolve(uniModuleRootDir, 'package.json'));
|
|
102
153
|
uniModules[uniModuleDir] = findEncryptUniModuleCache(uniModuleDir, cacheDir, { version: pkg.version, env: initCheckEnv() });
|
|
@@ -246,7 +297,7 @@ function resolveEncryptUniModule(id, platform, isX = true) {
|
|
|
246
297
|
exports.resolveEncryptUniModule = resolveEncryptUniModule;
|
|
247
298
|
async function checkEncryptUniModules(inputDir, params) {
|
|
248
299
|
// 扫描加密插件云编译
|
|
249
|
-
encryptUniModules = findEncryptUniModules(inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
|
|
300
|
+
encryptUniModules = findEncryptUniModules(params.platform, inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
|
|
250
301
|
if (!Object.keys(encryptUniModules).length) {
|
|
251
302
|
return {};
|
|
252
303
|
}
|
|
@@ -311,7 +362,7 @@ async function checkEncryptUniModules(inputDir, params) {
|
|
|
311
362
|
});
|
|
312
363
|
}
|
|
313
364
|
}
|
|
314
|
-
encryptUniModules = findEncryptUniModules(inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
|
|
365
|
+
encryptUniModules = findEncryptUniModules(params.platform, inputDir, process.env.UNI_MODULES_ENCRYPT_CACHE_DIR);
|
|
315
366
|
}
|
|
316
367
|
exports.checkEncryptUniModules = checkEncryptUniModules;
|
|
317
368
|
function parseUniModulesArtifacts() {
|
package/dist/utils.js
CHANGED
|
@@ -203,7 +203,9 @@ function createIdent(platform) {
|
|
|
203
203
|
if (process.env.UNI_INPUT_DIR) {
|
|
204
204
|
const manifestJson = (0, json_1.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR);
|
|
205
205
|
let id = (manifestJson.appid || '').replace('__UNI__', '');
|
|
206
|
-
const platformAppId =
|
|
206
|
+
const platformAppId = platform === 'mp-harmony'
|
|
207
|
+
? (manifestJson[platform]?.distribute?.bundleName || '').replace('com.atomicservice.', '')
|
|
208
|
+
: manifestJson[platform]?.appid;
|
|
207
209
|
if (platformAppId) {
|
|
208
210
|
id += '%%' + platformAppId;
|
|
209
211
|
}
|
package/dist/vite/autoImport.js
CHANGED
package/dist/vite/cloud.js
CHANGED
|
@@ -266,12 +266,8 @@ function initEncryptUniModulesAlias() {
|
|
|
266
266
|
},
|
|
267
267
|
];
|
|
268
268
|
}
|
|
269
|
-
const indexFiles = ['index.uts', 'index.ts', 'index.js'];
|
|
270
|
-
function hasIndexFile(uniModuleDir) {
|
|
271
|
-
return fs_extra_1.default.readdirSync(uniModuleDir).some((file) => indexFiles.includes(file));
|
|
272
|
-
}
|
|
273
269
|
function initEncryptUniModulesBuildOptions(platform, inputDir) {
|
|
274
|
-
const modules = (0, uni_modules_cloud_1.parseUniModulesWithComponents)(inputDir);
|
|
270
|
+
const modules = (0, uni_modules_cloud_1.parseUniModulesWithComponents)(inputDir, platform);
|
|
275
271
|
const moduleNames = Object.keys(modules);
|
|
276
272
|
if (!moduleNames.length) {
|
|
277
273
|
throw new Error('No encrypt uni_modules found');
|
|
@@ -281,16 +277,8 @@ function initEncryptUniModulesBuildOptions(platform, inputDir) {
|
|
|
281
277
|
moduleNames.forEach((module) => {
|
|
282
278
|
const moduleDir = path_1.default.resolve(inputDir, 'uni_modules', module);
|
|
283
279
|
const indexEncryptFile = path_1.default.resolve(moduleDir, 'index.module.uts');
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
codes.push(`export * from './index'`);
|
|
287
|
-
}
|
|
288
|
-
// easyCom
|
|
289
|
-
if (modules[module] && Object.keys(modules[module]).length) {
|
|
290
|
-
codes.push((0, uni_modules_cloud_1.genEncryptEasyComModuleIndex)(platform, modules[module]));
|
|
291
|
-
}
|
|
292
|
-
if (codes.length) {
|
|
293
|
-
fs_extra_1.default.writeFileSync(indexEncryptFile, codes.join(`\n`));
|
|
280
|
+
if (modules[module]) {
|
|
281
|
+
fs_extra_1.default.writeFileSync(indexEncryptFile, modules[module]);
|
|
294
282
|
// 输出 xxx.module ,确保相对路径的准确性,因为真正引用的时候,是从 @/uni_modules/xxx 引入的
|
|
295
283
|
input[module + '.module'] = indexEncryptFile;
|
|
296
284
|
}
|
|
@@ -3,6 +3,6 @@ export declare function addScoped(code: string): string;
|
|
|
3
3
|
interface UniCssScopedPluginOptions {
|
|
4
4
|
filter: (id: string) => boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare function uniRemoveCssScopedPlugin(
|
|
6
|
+
export declare function uniRemoveCssScopedPlugin(_?: UniCssScopedPluginOptions): Plugin;
|
|
7
7
|
export declare function uniCssScopedPlugin({ filter }?: UniCssScopedPluginOptions): Plugin;
|
|
8
8
|
export {};
|
|
@@ -10,6 +10,7 @@ const constants_1 = require("../../constants");
|
|
|
10
10
|
const preprocess_1 = require("../../preprocess");
|
|
11
11
|
const parse_1 = require("../../vue/parse");
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
|
+
const utils_2 = require("../../vue/utils");
|
|
13
14
|
const debugScoped = (0, debug_1.default)('uni:scoped');
|
|
14
15
|
const SCOPED_RE = /<style\s[^>]*scoped[^>]*>/i;
|
|
15
16
|
function addScoped(code) {
|
|
@@ -27,17 +28,19 @@ function removeScoped(code) {
|
|
|
27
28
|
}
|
|
28
29
|
return code.replace(/(<style.*)scoped(.*>)/gi, '$1$2');
|
|
29
30
|
}
|
|
30
|
-
function uniRemoveCssScopedPlugin(
|
|
31
|
+
function uniRemoveCssScopedPlugin(_ = { filter: () => false }) {
|
|
31
32
|
return {
|
|
32
33
|
name: 'uni:css-remove-scoped',
|
|
33
34
|
enforce: 'pre',
|
|
34
35
|
transform(code, id) {
|
|
35
|
-
if (!
|
|
36
|
+
if (!(0, utils_2.isVueSfcFile)(id))
|
|
36
37
|
return null;
|
|
37
38
|
debugScoped(id);
|
|
38
39
|
return {
|
|
39
40
|
code: removeScoped(code),
|
|
40
|
-
map:
|
|
41
|
+
map: {
|
|
42
|
+
mappings: '',
|
|
43
|
+
},
|
|
41
44
|
};
|
|
42
45
|
},
|
|
43
46
|
};
|
|
@@ -53,7 +56,9 @@ function uniCssScopedPlugin({ filter } = { filter: () => false }) {
|
|
|
53
56
|
debugScoped(id);
|
|
54
57
|
return {
|
|
55
58
|
code: addScoped(code),
|
|
56
|
-
map:
|
|
59
|
+
map: {
|
|
60
|
+
mappings: '',
|
|
61
|
+
},
|
|
57
62
|
};
|
|
58
63
|
},
|
|
59
64
|
// 仅 h5
|
|
@@ -161,7 +161,9 @@ function uniViteInjectPlugin(name, options) {
|
|
|
161
161
|
// 比如 App.vue 中,console.log('uniCloud') 触发了 inject 检测,检测完,发现不需要
|
|
162
162
|
// 此时返回 ast,会导致 import { setupApp } from '@dcloudio/uni-h5' 不会被编译
|
|
163
163
|
// ast
|
|
164
|
-
map:
|
|
164
|
+
map: {
|
|
165
|
+
mappings: '',
|
|
166
|
+
},
|
|
165
167
|
};
|
|
166
168
|
}
|
|
167
169
|
const importBlock = Array.from(newImports.values()).join('\n\n');
|
|
@@ -151,6 +151,13 @@ const emptySwiftCacheDirOnce = (0, uni_shared_1.once)(() => {
|
|
|
151
151
|
const emptyHarmonyCacheDirOnce = (0, uni_shared_1.once)(() => {
|
|
152
152
|
emptyCacheDir('app-harmony');
|
|
153
153
|
});
|
|
154
|
+
const handleCompileResult = (result, pluginContext) => {
|
|
155
|
+
if (pluginContext) {
|
|
156
|
+
result.deps.forEach((dep) => {
|
|
157
|
+
pluginContext.addWatchFile(dep);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
154
161
|
// 该插件仅限app-android、app-ios、app-harmony
|
|
155
162
|
function uniUTSAppUniModulesPlugin(options = {}) {
|
|
156
163
|
const isX = process.env.UNI_APP_X === 'true';
|
|
@@ -210,7 +217,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
210
217
|
(0, uts_1.genUniExtApiDeclarationFileOnce)((0, uts_1.tscOutDir)('app-harmony'));
|
|
211
218
|
}
|
|
212
219
|
const changedFiles = new Map();
|
|
213
|
-
const compilePlugin = async (pluginDir) => {
|
|
220
|
+
const compilePlugin = async (pluginDir, pluginContext) => {
|
|
214
221
|
const pluginId = path_1.default.basename(pluginDir);
|
|
215
222
|
if (uniXKotlinCompiler) {
|
|
216
223
|
const platform = 'app-android';
|
|
@@ -279,7 +286,24 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
279
286
|
const deps = (0, uni_modules_1.parseUTSModuleDeps)(pkgJson.uni_modules?.dependencies || [], inputDir);
|
|
280
287
|
if (deps.length) {
|
|
281
288
|
for (const dep of deps) {
|
|
282
|
-
|
|
289
|
+
if (dep) {
|
|
290
|
+
// 本次编译流程中已编译过该插件,直接使用缓存
|
|
291
|
+
const depPluginDir = (0, utils_2.normalizePath)(path_1.default.resolve(uniModulesDir, dep));
|
|
292
|
+
if (utsModuleCaches.get(depPluginDir)) {
|
|
293
|
+
await utsModuleCaches.get(depPluginDir)().then((result) => {
|
|
294
|
+
if (result) {
|
|
295
|
+
handleCompileResult(result, pluginContext);
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
await compilePlugin(path_1.default.resolve(inputDir, 'uni_modules', dep), pluginContext).then((result) => {
|
|
301
|
+
if (result) {
|
|
302
|
+
handleCompileResult(result, pluginContext);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
283
307
|
}
|
|
284
308
|
}
|
|
285
309
|
if (process.env.UNI_PLATFORM === 'app-harmony') {
|
|
@@ -342,9 +366,9 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
342
366
|
continue;
|
|
343
367
|
}
|
|
344
368
|
}
|
|
345
|
-
if (process.env.
|
|
346
|
-
process.env.UNI_PLATFORM === 'app-harmony') {
|
|
369
|
+
if (process.env.UNI_PLATFORM === 'app-harmony') {
|
|
347
370
|
// uniExtApiCompiler本身是为X项目准备的,但是在app-harmony项目中也会调用
|
|
371
|
+
// uni-app-x app-harmony暂不支持其他类型插件
|
|
348
372
|
if (!fs_extra_1.default.existsSync(path_1.default.resolve(pluginDir, 'utssdk', 'app-harmony', 'index.uts'))) {
|
|
349
373
|
continue;
|
|
350
374
|
}
|
|
@@ -446,7 +470,9 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
446
470
|
});
|
|
447
471
|
return {
|
|
448
472
|
code: result.code,
|
|
449
|
-
map:
|
|
473
|
+
map: {
|
|
474
|
+
mappings: '',
|
|
475
|
+
},
|
|
450
476
|
syntheticNamedExports: result.encrypt,
|
|
451
477
|
meta: result.meta,
|
|
452
478
|
};
|
|
@@ -454,7 +480,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
454
480
|
});
|
|
455
481
|
}
|
|
456
482
|
const compile = (0, uni_shared_1.once)(() => {
|
|
457
|
-
return compilePlugin(pluginDir);
|
|
483
|
+
return compilePlugin(pluginDir, this);
|
|
458
484
|
});
|
|
459
485
|
utsModuleCaches.set(pluginDir, compile);
|
|
460
486
|
const result = await compile();
|
|
@@ -464,7 +490,9 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
464
490
|
});
|
|
465
491
|
return {
|
|
466
492
|
code: result.code,
|
|
467
|
-
map:
|
|
493
|
+
map: {
|
|
494
|
+
mappings: '',
|
|
495
|
+
},
|
|
468
496
|
syntheticNamedExports: result.encrypt,
|
|
469
497
|
meta: result.meta,
|
|
470
498
|
};
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
export declare function uniUTSUVueJavaScriptPlugin(options?: {}): Plugin;
|
|
3
|
+
/**
|
|
4
|
+
* 将 <script> 标签中的 lang="uts" 替换为 lang="ts"
|
|
5
|
+
* 主要是当前功能内部使用 x.vite.config.ts 配置
|
|
6
|
+
* @param options
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function uniUVueTypeScriptPlugin(options?: {}): Plugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uniUTSUVueJavaScriptPlugin = void 0;
|
|
3
|
+
exports.uniUVueTypeScriptPlugin = exports.uniUTSUVueJavaScriptPlugin = void 0;
|
|
4
4
|
const vue_1 = require("../../../vue");
|
|
5
5
|
function uniUTSUVueJavaScriptPlugin(options = {}) {
|
|
6
6
|
process.env.UNI_UTS_USING_ROLLUP = 'true';
|
|
@@ -34,3 +34,32 @@ function uniUTSUVueJavaScriptPlugin(options = {}) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
exports.uniUTSUVueJavaScriptPlugin = uniUTSUVueJavaScriptPlugin;
|
|
37
|
+
/**
|
|
38
|
+
* 将 <script> 标签中的 lang="uts" 替换为 lang="ts"
|
|
39
|
+
* 主要是当前功能内部使用 x.vite.config.ts 配置
|
|
40
|
+
* @param options
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
function uniUVueTypeScriptPlugin(options = {}) {
|
|
44
|
+
return {
|
|
45
|
+
name: 'uni:uvue-ts',
|
|
46
|
+
enforce: 'pre',
|
|
47
|
+
transform(code, id) {
|
|
48
|
+
if (!(0, vue_1.isVueSfcFile)(id)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
code: code.replace(/<script([^>]*)>/gi, (match, attributes) => {
|
|
53
|
+
// 如果 <script> 标签中没有 lang 属性,添加 lang="uts"
|
|
54
|
+
if (!/lang=["']?[^"']*["']?/.test(attributes)) {
|
|
55
|
+
return `<script${attributes} lang="ts">`;
|
|
56
|
+
}
|
|
57
|
+
// 否则,将现有的 lang 属性替换为 lang="uts"
|
|
58
|
+
return match.replace(/lang=["']?uts["']?/, 'lang="ts"');
|
|
59
|
+
}),
|
|
60
|
+
map: { mappings: '' },
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.uniUVueTypeScriptPlugin = uniUVueTypeScriptPlugin;
|
|
@@ -387,7 +387,12 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
387
387
|
!isModule &&
|
|
388
388
|
!needInlineImport &&
|
|
389
389
|
!hasUrl) {
|
|
390
|
-
return {
|
|
390
|
+
return {
|
|
391
|
+
code,
|
|
392
|
+
map: {
|
|
393
|
+
mappings: '',
|
|
394
|
+
},
|
|
395
|
+
};
|
|
391
396
|
}
|
|
392
397
|
let preprocessorMap;
|
|
393
398
|
let modules;
|
|
@@ -84,6 +84,11 @@ const transformAssetUrl = (node, context, options = exports.defaultAssetUrlOptio
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
const url = (0, templateUtils_1.parseUrl)(attr.value.content);
|
|
87
|
+
// 这里是有问题的,static的相对路径可能是分包里的,或者uni_modules里的,不能简单的通过base来合并
|
|
88
|
+
// 只不过目前编译器非有意的同时保留了vue标准的transformAssetUrl和uni-app的transformAssetUrl
|
|
89
|
+
// 当static相对路径经过vue的transformAssetUrl后,就变成了 import 语句,不会再走到下边的逻辑里
|
|
90
|
+
// 最初的设计,应该是用uni-app的transformAssetUrl来直接替换vue的transformAssetUrl的。
|
|
91
|
+
// 如果后续要替换,需要考虑这个问题
|
|
87
92
|
if (options.base && attr.value.content[0] === '.' && isStaticAsset) {
|
|
88
93
|
// explicit base - directly rewrite relative urls into absolute url
|
|
89
94
|
// to avoid generating extra imports
|
package/dist/watcher.js
CHANGED
|
@@ -32,7 +32,7 @@ class FileWatcher {
|
|
|
32
32
|
onReady && onReady(this.watcher);
|
|
33
33
|
// 等首次change完,触发完ready,在切换到真实的onChange
|
|
34
34
|
this.onChange = onChange;
|
|
35
|
-
}, watchOptions.readyTimeout ||
|
|
35
|
+
}, watchOptions.readyTimeout || 1000); // 300ms 在部分机器上仍有问题,调整成1000ms
|
|
36
36
|
};
|
|
37
37
|
this.onChange = checkReady;
|
|
38
38
|
this.watcher = (0, chokidar_1.watch)(src, watchOptions)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-4050320250303001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"tapable": "^2.2.0",
|
|
67
67
|
"unplugin-auto-import": "^0.18.2",
|
|
68
68
|
"xregexp": "3.1.0",
|
|
69
|
-
"@dcloudio/uni-i18n": "3.0.0-
|
|
70
|
-
"@dcloudio/uni-shared": "3.0.0-
|
|
69
|
+
"@dcloudio/uni-i18n": "3.0.0-4050320250303001",
|
|
70
|
+
"@dcloudio/uni-shared": "3.0.0-4050320250303001"
|
|
71
71
|
},
|
|
72
72
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
73
73
|
"devDependencies": {
|
|
@@ -88,6 +88,6 @@
|
|
|
88
88
|
"postcss": "^8.4.21",
|
|
89
89
|
"unimport": "^3.11.1",
|
|
90
90
|
"vue": "3.4.21",
|
|
91
|
-
"@dcloudio/uni-uts-v1": "3.0.0-
|
|
91
|
+
"@dcloudio/uni-uts-v1": "3.0.0-4050320250303001"
|
|
92
92
|
}
|
|
93
93
|
}
|