@dcloudio/uni-cli-shared 3.0.0-alpha-5020520260829001 → 3.0.0-alpha-1000920260909822
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/dom2/script.js +2 -0
- package/dist/hbx/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/json/manifest.d.ts +3 -0
- package/dist/json/manifest.js +13 -1
- package/dist/json/uni-x/index.d.ts +1 -0
- package/dist/json/uni-x/index.js +4 -0
- package/dist/logs/console.js +12 -1
- package/dist/resolve.js +5 -0
- package/dist/uasm.d.ts +1 -0
- package/dist/uasm.js +11 -5
- package/dist/uts/scriptMacros.d.ts +13 -0
- package/dist/uts/scriptMacros.js +52 -0
- package/dist/vite/autoImport.js +8 -2
- package/dist/vite/cloud.js +10 -9
- package/dist/vite/extApi.js +2 -2
- package/dist/vite/index.d.ts +9 -4
- package/dist/vite/plugins/console.js +2 -1
- package/dist/vite/plugins/dynamicImportPolyfill.d.ts +8 -1
- package/dist/vite/plugins/index.d.ts +1 -0
- package/dist/vite/plugins/index.js +1 -0
- package/dist/vite/plugins/inject.js +1 -1
- package/dist/vite/plugins/jsonJs.d.ts +2 -2
- package/dist/vite/plugins/mainJs.d.ts +1 -1
- package/dist/vite/plugins/sourceMap.js +4 -1
- package/dist/vite/plugins/uts/standardScript.d.ts +15 -0
- package/dist/vite/plugins/uts/standardScript.js +137 -0
- package/dist/vite/plugins/uts/uni_modules.js +9 -15
- package/dist/vite/plugins/uts/uvue.js +103 -44
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +12 -5
- package/dist/vite/plugins/vitejs/plugins/asset.js +4 -2
- package/dist/vue/transforms/transformTeleport.js +15 -1
- package/dist/watcher.d.ts +1 -0
- package/dist/workers.d.ts +1 -0
- package/dist/workers.js +16 -12
- package/dist/x.d.ts +1 -0
- package/dist/x.js +6 -1
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.js +16 -23
- package/lib/@vue/compiler-core/dist/compiler-core.cjs.prod.js +16 -23
- package/lib/@vue/compiler-core/dist/compiler-core.esm-bundler.js +16 -23
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +23 -66
- package/lib/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +67 -115
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.cjs +6 -2
- package/lib/dom2/app/@vitejs/plugin-vue/dist/index.mjs +6 -2
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.js +249 -237
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.cjs.prod.js +235 -230
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.d.ts +252 -285
- package/lib/dom2/app/@vue/compiler-core/dist/compiler-core.esm-bundler.js +159 -162
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.js +50 -50
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +49 -49
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.d.ts +10 -11
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +210 -214
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +6 -6
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +49 -49
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.js +210 -214
- package/lib/dom2/app/@vue/compiler-dom/dist/compiler-dom.global.prod.js +6 -6
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +656 -377
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.d.ts +138 -137
- package/lib/dom2/app/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +1222 -1057
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +209 -195
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.d.ts +364 -356
- package/lib/dom2/app/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +569 -507
- 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 +41 -20
- package/lib/dom2/app/@vue/shared/dist/shared.cjs.prod.js +41 -20
- package/lib/dom2/app/@vue/shared/dist/shared.d.ts +235 -235
- package/lib/dom2/app/@vue/shared/dist/shared.esm-bundler.js +41 -20
- package/package.json +6 -6
package/dist/dom2/script.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.uniVaporScriptPlugin = void 0;
|
|
|
4
4
|
const uts_1 = require("../uts");
|
|
5
5
|
const extApi_1 = require("../uts/extApi");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const scriptMacros_1 = require("../uts/scriptMacros");
|
|
7
8
|
const sharedData_1 = require("./sharedData");
|
|
8
9
|
function uniVaporScriptPlugin(options = {}) {
|
|
9
10
|
const { uasm, ...sharedData } = options;
|
|
@@ -14,6 +15,7 @@ function uniVaporScriptPlugin(options = {}) {
|
|
|
14
15
|
: undefined;
|
|
15
16
|
return D2SP({
|
|
16
17
|
typescript: (0, uts_1.resolveUTSCompiler)().getTypeScript(),
|
|
18
|
+
createUniAppXScriptMacrosTransformer: scriptMacros_1.createUniAppXScriptMacrosTransformer,
|
|
17
19
|
extApi,
|
|
18
20
|
uasm,
|
|
19
21
|
sharedData: {
|
package/dist/hbx/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { formatAtFilename, createErrorWithBlockFlag } from './log';
|
|
2
2
|
export * from './env';
|
|
3
3
|
export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
|
|
4
|
-
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
|
|
4
|
+
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite/dist/node").Plugin<any>;
|
|
5
5
|
export declare function isEnableConsole(): boolean;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./ssr"), exports);
|
|
|
24
24
|
__exportStar(require("./vue"), exports);
|
|
25
25
|
__exportStar(require("./uts"), exports);
|
|
26
26
|
__exportStar(require("./uts/extApi"), exports);
|
|
27
|
+
__exportStar(require("./uts/scriptMacros"), exports);
|
|
27
28
|
__exportStar(require("./x"), exports);
|
|
28
29
|
__exportStar(require("./logs"), exports);
|
|
29
30
|
__exportStar(require("./dom2"), exports);
|
package/dist/json/manifest.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare const parseManifestJson: (inputDir: string) => any;
|
|
2
2
|
export declare const parseManifestJsonOnce: (inputDir: string) => any;
|
|
3
|
+
export type UniAppXVaporScriptLang = 'js' | 'ts' | 'uts';
|
|
4
|
+
export declare function resolveUniAppXVaporScriptLang(manifestJson: Record<string, any>): UniAppXVaporScriptLang;
|
|
5
|
+
export declare function getUniAppXVaporScriptLang(inputDir?: string): UniAppXVaporScriptLang;
|
|
3
6
|
export declare const parseRpx2UnitOnce: (inputDir: string, platform?: UniApp.PLATFORM) => any;
|
|
4
7
|
export declare function getNativeTags(inputDir?: string, platform?: UniApp.PLATFORM): any;
|
|
5
8
|
interface CompilerCompatConfig {
|
package/dist/json/manifest.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.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getPlatformManifestJson = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.getNativeTags = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
6
|
+
exports.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getPlatformManifestJson = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.getNativeTags = exports.parseRpx2UnitOnce = exports.getUniAppXVaporScriptLang = exports.resolveUniAppXVaporScriptLang = exports.parseManifestJsonOnce = exports.parseManifestJson = 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");
|
|
@@ -21,6 +21,18 @@ const parseManifestJson = (inputDir) => {
|
|
|
21
21
|
};
|
|
22
22
|
exports.parseManifestJson = parseManifestJson;
|
|
23
23
|
exports.parseManifestJsonOnce = (0, uni_shared_1.once)(exports.parseManifestJson);
|
|
24
|
+
function resolveUniAppXVaporScriptLang(manifestJson) {
|
|
25
|
+
const lang = manifestJson['uni-app-x']?.['vapor-default-script-lang'];
|
|
26
|
+
return lang === 'js' || lang === 'ts' || lang === 'uts' ? lang : 'ts';
|
|
27
|
+
}
|
|
28
|
+
exports.resolveUniAppXVaporScriptLang = resolveUniAppXVaporScriptLang;
|
|
29
|
+
function getUniAppXVaporScriptLang(inputDir) {
|
|
30
|
+
if (!inputDir) {
|
|
31
|
+
return 'ts';
|
|
32
|
+
}
|
|
33
|
+
return resolveUniAppXVaporScriptLang((0, exports.parseManifestJsonOnce)(inputDir));
|
|
34
|
+
}
|
|
35
|
+
exports.getUniAppXVaporScriptLang = getUniAppXVaporScriptLang;
|
|
24
36
|
exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir, platform = 'h5') => {
|
|
25
37
|
const rpx2unit = platform === 'h5' || platform === 'app' || platform === 'app-harmony'
|
|
26
38
|
? uni_shared_1.defaultRpx2Unit
|
|
@@ -8,6 +8,7 @@ export interface UniXPageOptions {
|
|
|
8
8
|
androidOverscroll?: boolean;
|
|
9
9
|
androidRefresherColor?: string;
|
|
10
10
|
backgroundColor?: string;
|
|
11
|
+
backgroundTextStyle?: 'dark' | 'light';
|
|
11
12
|
}
|
|
12
13
|
export declare function normalizeUniAppXAppPagesJson(jsonStr: string): UniApp.PagesJson;
|
|
13
14
|
export declare function parseUniXPageOptions(filename: string): UniXPageOptions | undefined;
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -97,6 +97,7 @@ function updateUniXPageOptions(pagesJson) {
|
|
|
97
97
|
function normalizeRootPageOptions(pageStyle, globalStyle) {
|
|
98
98
|
const androidRefresherColor = pageStyle?.androidRefresherColor ?? globalStyle.androidRefresherColor;
|
|
99
99
|
const backgroundColor = pageStyle?.backgroundColor ?? globalStyle.backgroundColor;
|
|
100
|
+
const backgroundTextStyle = pageStyle?.backgroundTextStyle ?? globalStyle.backgroundTextStyle;
|
|
100
101
|
return {
|
|
101
102
|
disableScroll: pageStyle?.disableScroll === true || undefined,
|
|
102
103
|
enablePullDownRefresh: (pageStyle && isEnablePullDownRefresh(pageStyle)) || undefined,
|
|
@@ -111,6 +112,9 @@ function normalizeRootPageOptions(pageStyle, globalStyle) {
|
|
|
111
112
|
backgroundColor: backgroundColor?.startsWith('@')
|
|
112
113
|
? undefined
|
|
113
114
|
: backgroundColor,
|
|
115
|
+
backgroundTextStyle: backgroundTextStyle?.startsWith('@')
|
|
116
|
+
? undefined
|
|
117
|
+
: backgroundTextStyle,
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
function initUniXPageOptions() {
|
package/dist/logs/console.js
CHANGED
|
@@ -21,13 +21,24 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
|
21
21
|
return {
|
|
22
22
|
code: s.toString(),
|
|
23
23
|
map: sourceMap
|
|
24
|
-
? s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() })
|
|
24
|
+
? normalizeSourceMap(s.generateMap({ hires: (0, x_1.shouldUseHighResolutionSourceMap)() }))
|
|
25
25
|
: { mappings: '' },
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
return { code, map: null };
|
|
29
29
|
}
|
|
30
30
|
exports.rewriteConsoleExpr = rewriteConsoleExpr;
|
|
31
|
+
function normalizeSourceMap(map) {
|
|
32
|
+
return {
|
|
33
|
+
...map,
|
|
34
|
+
file: map.file || '',
|
|
35
|
+
names: map.names || [],
|
|
36
|
+
sources: map.sources || [],
|
|
37
|
+
sourcesContent: map.sourcesContent || [],
|
|
38
|
+
toString: () => map.toString(),
|
|
39
|
+
toUrl: () => map.toUrl(),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
31
42
|
function restoreConsoleExpr(code) {
|
|
32
43
|
return code.replace(/(?:uni\.)?__f__\('([^']+)','at ([^:]+):(\d+)',/g, 'console.$1(');
|
|
33
44
|
}
|
package/dist/resolve.js
CHANGED
|
@@ -47,6 +47,11 @@ exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
|
|
|
47
47
|
if (fs_1.default.existsSync(mainTsPath)) {
|
|
48
48
|
return (0, utils_1.normalizePath)(mainTsPath);
|
|
49
49
|
}
|
|
50
|
+
if (process.env.UNI_APP_X === 'true' &&
|
|
51
|
+
process.env.UNI_UTS_PLATFORM === 'app-android' &&
|
|
52
|
+
process.env.UNI_APP_X_DOM2 !== 'true') {
|
|
53
|
+
throw new Error('uni-app x Android VDOM 模式仅支持 main.uts 或 main.ts 入口文件');
|
|
54
|
+
}
|
|
50
55
|
return (0, utils_1.normalizePath)(path_1.default.resolve(inputDir, 'main.js'));
|
|
51
56
|
});
|
|
52
57
|
const ownerModules = [
|
package/dist/uasm.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface LoadUasmTransformOptions {
|
|
|
12
12
|
}
|
|
13
13
|
export interface LoadUasmTransformerOptions extends LoadUasmTransformOptions {
|
|
14
14
|
typescript: TypeScriptCompiler;
|
|
15
|
+
methodNames?: readonly string[];
|
|
15
16
|
resolveLoader?: (modulePath: string) => ResolvedUasmLoader | undefined;
|
|
16
17
|
onSourceEdit?: (edit: UasmSourceEdit) => void;
|
|
17
18
|
resolveError?: (modulePath: string) => string;
|
package/dist/uasm.js
CHANGED
|
@@ -68,6 +68,7 @@ function initUasmWebTransformOptions() {
|
|
|
68
68
|
createLoadUasmTransformer(options) {
|
|
69
69
|
return createLoadUasmTransformer({
|
|
70
70
|
...options,
|
|
71
|
+
methodNames: ['loadUasm'],
|
|
71
72
|
resolveError(modulePath) {
|
|
72
73
|
const moduleName = parseUasmModuleName(modulePath);
|
|
73
74
|
const entry = moduleName
|
|
@@ -92,6 +93,7 @@ function createUasmDiagnostic(options, sourceFile, node, messageText) {
|
|
|
92
93
|
}
|
|
93
94
|
function createLoadUasmTransformer(options) {
|
|
94
95
|
const { typescript, resolve, reportDiagnostic } = options;
|
|
96
|
+
const methodNames = new Set(options.methodNames || ['loadUasm', 'loadUasmSync']);
|
|
95
97
|
const targetArchs = options.targetArchs?.join(', ') || '未指定';
|
|
96
98
|
return (context) => {
|
|
97
99
|
const { factory } = context;
|
|
@@ -101,13 +103,14 @@ function createLoadUasmTransformer(options) {
|
|
|
101
103
|
if (typescript.isCallExpression(node) &&
|
|
102
104
|
node.arguments.length >= 1 &&
|
|
103
105
|
typescript.isPropertyAccessExpression(node.expression) &&
|
|
104
|
-
node.expression.name.
|
|
106
|
+
methodNames.has(node.expression.name.text) &&
|
|
105
107
|
typescript.isIdentifier(node.expression.expression) &&
|
|
106
108
|
node.expression.expression.escapedText === 'uni') {
|
|
109
|
+
const methodName = node.expression.name.text;
|
|
107
110
|
const firstArg = node.arguments[0];
|
|
108
111
|
if (!typescript.isStringLiteral(firstArg) &&
|
|
109
112
|
!typescript.isNoSubstitutionTemplateLiteral(firstArg)) {
|
|
110
|
-
reportDiagnostic(context, createUasmDiagnostic(options, sourceFile, firstArg,
|
|
113
|
+
reportDiagnostic(context, createUasmDiagnostic(options, sourceFile, firstArg, `uni.${methodName}(modulePath) 的 modulePath 参数必须是字符串字面量`));
|
|
111
114
|
return node;
|
|
112
115
|
}
|
|
113
116
|
const resolved = resolve(firstArg.text);
|
|
@@ -223,7 +226,7 @@ function copyUasmIOSFrameworks(inputDir) {
|
|
|
223
226
|
return;
|
|
224
227
|
}
|
|
225
228
|
const libraryIdentifier = process.env.HX_RUN_DEVICE_TYPE === 'ios_simulator'
|
|
226
|
-
? 'ios-
|
|
229
|
+
? 'ios-arm64_x86_64-simulator'
|
|
227
230
|
: 'ios-arm64';
|
|
228
231
|
const targetDir = node_path_1.default.resolve(dependenciesDir, 'modules');
|
|
229
232
|
for (const module of Object.values(uasmModules)) {
|
|
@@ -338,6 +341,9 @@ function parseUasmModuleName(modulePath) {
|
|
|
338
341
|
return /^uni_modules\/([^/]+)$/.exec(normalized)?.[1];
|
|
339
342
|
}
|
|
340
343
|
exports.parseUasmModuleName = parseUasmModuleName;
|
|
344
|
+
function resolveUasmLibraryFileName(moduleName) {
|
|
345
|
+
return `libUasm${(0, utils_1.capitalize)((0, utils_1.camelize)(moduleName))}.so`;
|
|
346
|
+
}
|
|
341
347
|
function resolveUasmWebLoad(modulePath) {
|
|
342
348
|
const moduleName = parseUasmModuleName(modulePath);
|
|
343
349
|
const entry = moduleName && uasmModules[moduleName]?.web?.entry;
|
|
@@ -359,7 +365,7 @@ function resolveUasmLoadPath(modulePath, platform, isProduction = (process.env.U
|
|
|
359
365
|
if (platform === 'app-ios') {
|
|
360
366
|
return moduleName;
|
|
361
367
|
}
|
|
362
|
-
const libraryName =
|
|
368
|
+
const libraryName = resolveUasmLibraryFileName(moduleName);
|
|
363
369
|
if (isProduction) {
|
|
364
370
|
return libraryName;
|
|
365
371
|
}
|
|
@@ -429,7 +435,7 @@ function scanUasmPlatform(inputDir, moduleName, platform) {
|
|
|
429
435
|
return;
|
|
430
436
|
}
|
|
431
437
|
const relativeArchDir = (0, utils_1.normalizePath)(node_path_1.default.join(relativeDir, entry.name));
|
|
432
|
-
const file = (0, utils_1.normalizePath)(node_path_1.default.join(relativeArchDir,
|
|
438
|
+
const file = (0, utils_1.normalizePath)(node_path_1.default.join(relativeArchDir, resolveUasmLibraryFileName(moduleName)));
|
|
433
439
|
if (!fs_extra_1.default.existsSync(node_path_1.default.resolve(inputDir, file))) {
|
|
434
440
|
return;
|
|
435
441
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SourceFile, TransformerFactory } from 'typescript';
|
|
2
|
+
export type ScriptMacrosTypeScript = typeof import('typescript');
|
|
3
|
+
export interface UniAppXScriptMacroSourceEdit {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UniAppXScriptMacrosTransformerOptions {
|
|
9
|
+
typescript: ScriptMacrosTypeScript;
|
|
10
|
+
onSourceEdit?: (edit: UniAppXScriptMacroSourceEdit) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function hasUniAppXScriptMacros(code: string): boolean;
|
|
13
|
+
export declare function createUniAppXScriptMacrosTransformer(options: UniAppXScriptMacrosTransformerOptions): TransformerFactory<SourceFile>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUniAppXScriptMacrosTransformer = exports.hasUniAppXScriptMacros = void 0;
|
|
4
|
+
const UNI_APP_X_SCRIPT_MACROS = new Set(['defineMixin', 'definePlugin']);
|
|
5
|
+
function hasUniAppXScriptMacros(code) {
|
|
6
|
+
return code.includes('defineMixin') || code.includes('definePlugin');
|
|
7
|
+
}
|
|
8
|
+
exports.hasUniAppXScriptMacros = hasUniAppXScriptMacros;
|
|
9
|
+
function createUniAppXScriptMacrosTransformer(options) {
|
|
10
|
+
const { typescript, onSourceEdit } = options;
|
|
11
|
+
return (context) => {
|
|
12
|
+
return (sourceFile) => {
|
|
13
|
+
const visitor = (node) => {
|
|
14
|
+
const transformed = typescript.visitEachChild(node, visitor, context);
|
|
15
|
+
if (!typescript.isCallExpression(node) ||
|
|
16
|
+
!typescript.isIdentifier(node.expression) ||
|
|
17
|
+
node.arguments.length === 0 ||
|
|
18
|
+
!UNI_APP_X_SCRIPT_MACROS.has(node.expression.text)) {
|
|
19
|
+
return transformed;
|
|
20
|
+
}
|
|
21
|
+
if (onSourceEdit) {
|
|
22
|
+
// 保留原调用括号,只移除宏名称及其余参数,局部编辑之间可以安全嵌套。
|
|
23
|
+
onSourceEdit({
|
|
24
|
+
start: node.getStart(sourceFile),
|
|
25
|
+
end: node.arguments.pos,
|
|
26
|
+
content: '(',
|
|
27
|
+
});
|
|
28
|
+
if (node.arguments.length > 1 || node.arguments.hasTrailingComma) {
|
|
29
|
+
const children = node.getChildren(sourceFile);
|
|
30
|
+
const syntaxList = children.find((child) => child.kind === typescript.SyntaxKind.SyntaxList &&
|
|
31
|
+
child.pos === node.arguments.pos &&
|
|
32
|
+
child.end === node.arguments.end);
|
|
33
|
+
const separator = syntaxList
|
|
34
|
+
.getChildren(sourceFile)
|
|
35
|
+
.find((child) => child.kind === typescript.SyntaxKind.CommaToken);
|
|
36
|
+
const closeParen = children.find((child) => child.kind === typescript.SyntaxKind.CloseParenToken);
|
|
37
|
+
onSourceEdit({
|
|
38
|
+
start: separator.getStart(sourceFile),
|
|
39
|
+
end: closeParen.getStart(sourceFile),
|
|
40
|
+
content: '',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return typescript.isCallExpression(transformed)
|
|
45
|
+
? transformed.arguments[0]
|
|
46
|
+
: transformed;
|
|
47
|
+
};
|
|
48
|
+
return typescript.visitNode(sourceFile, visitor);
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.createUniAppXScriptMacrosTransformer = createUniAppXScriptMacrosTransformer;
|
package/dist/vite/autoImport.js
CHANGED
|
@@ -311,13 +311,19 @@ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
|
|
|
311
311
|
autoImport.push(utsJsPreset);
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
|
|
314
|
+
// node_modules 可能包含依赖 auto import 的 uni-app x 源码包,不能恢复 unplugin 的默认排除项。
|
|
315
|
+
const exclude = [
|
|
316
|
+
/[\\/]\.git[\\/]/,
|
|
317
|
+
// @dcloudio 包中的 JS 是自带完整导入的官方产物,正则扫描导出别名或继承类时可能误判,
|
|
318
|
+
// 进而产生自引用或重复声明。
|
|
319
|
+
/[\\/]@dcloudio[\\/].*\.js$/,
|
|
320
|
+
];
|
|
315
321
|
if (process.env.UNI_INPUT_DIR) {
|
|
316
322
|
exclude.push(...(0, workers_1.resolveWorkersDir)(process.env.UNI_INPUT_DIR).map((dir) => (0, utils_1.normalizePath)(path_1.default.join(process.env.UNI_INPUT_DIR, dir, '*'))));
|
|
317
323
|
}
|
|
318
324
|
return {
|
|
319
325
|
...userOptions,
|
|
320
|
-
include: [/\.
|
|
326
|
+
include: [/\.(?:js|ts|uts)$/, /\.[u]?vue/],
|
|
321
327
|
exclude,
|
|
322
328
|
imports: imports.concat(
|
|
323
329
|
// 旧版 Android x 仍由专有编译流程处理,Android Vapor 对齐 iOS 走通用自动导入
|
package/dist/vite/cloud.js
CHANGED
|
@@ -74,7 +74,7 @@ function uniEncryptUniModulesPlugin() {
|
|
|
74
74
|
apply: 'build',
|
|
75
75
|
config() {
|
|
76
76
|
const build = initEncryptUniModulesBuildOptions(process.env.UNI_UTS_PLATFORM, process.env.UNI_INPUT_DIR);
|
|
77
|
-
Object.keys(build.
|
|
77
|
+
Object.keys(build.rolldownOptions?.input || {}).forEach((key) => {
|
|
78
78
|
encryptModuleOutputFiles.push(key + '.js');
|
|
79
79
|
});
|
|
80
80
|
return {
|
|
@@ -92,7 +92,7 @@ function uniEncryptUniModulesPlugin() {
|
|
|
92
92
|
}
|
|
93
93
|
// 编译组件时,禁用内联资源
|
|
94
94
|
config.build.assetsInlineLimit = 0;
|
|
95
|
-
config.build.
|
|
95
|
+
config.build.rolldownOptions.external = createExternal(config);
|
|
96
96
|
resolvedConfig = config;
|
|
97
97
|
},
|
|
98
98
|
resolveId(id, importer) {
|
|
@@ -132,16 +132,13 @@ function uniEncryptUniModulesPlugin() {
|
|
|
132
132
|
}
|
|
133
133
|
delete bundle[fileName];
|
|
134
134
|
const pkg = `uni_modules/${uniModuleId}/package.json`;
|
|
135
|
-
|
|
135
|
+
this.emitFile({
|
|
136
136
|
type: 'asset',
|
|
137
137
|
fileName: pkg,
|
|
138
|
-
name: pkg,
|
|
139
|
-
originalFileName: null,
|
|
140
|
-
needsCodeReference: false,
|
|
141
138
|
source: genUniModulesPackageJson(uniModuleId, process.env.UNI_INPUT_DIR, {
|
|
142
139
|
env: (0, uni_modules_cloud_1.initCheckEnv)(),
|
|
143
140
|
}),
|
|
144
|
-
};
|
|
141
|
+
});
|
|
145
142
|
}
|
|
146
143
|
else if (fileName.endsWith('.js')) {
|
|
147
144
|
if (isMp) {
|
|
@@ -188,14 +185,18 @@ function uniEncryptUniModulesPlugin() {
|
|
|
188
185
|
if (uniXKotlinCompiler) {
|
|
189
186
|
const tscOutputDir = tscOutDir('app-android');
|
|
190
187
|
const uniModulesDir = path_1.default.resolve(tscOutputDir, 'uni_modules');
|
|
188
|
+
const rootFiles = [];
|
|
191
189
|
if (fs_extra_1.default.existsSync(uniModulesDir)) {
|
|
192
190
|
for (const plugin of fs_extra_1.default.readdirSync(uniModulesDir)) {
|
|
193
191
|
const indexFileName = path_1.default.join(uniModulesDir, plugin, 'index.module.uts.ts');
|
|
194
192
|
if (fs_extra_1.default.existsSync(indexFileName)) {
|
|
195
|
-
|
|
193
|
+
rootFiles.push(indexFileName);
|
|
196
194
|
}
|
|
197
195
|
}
|
|
198
196
|
}
|
|
197
|
+
if (rootFiles.length) {
|
|
198
|
+
await uniXKotlinCompiler.addRootFiles([...new Set(rootFiles)]);
|
|
199
|
+
}
|
|
199
200
|
await uniXKotlinCompiler.close();
|
|
200
201
|
}
|
|
201
202
|
// 编译所有 uni_modules 插件
|
|
@@ -341,7 +342,7 @@ function initEncryptUniModulesBuildOptions(platform, inputDir) {
|
|
|
341
342
|
lib: false, // 不使用 lib 模式,lib模式会直接内联资源
|
|
342
343
|
cssCodeSplit: false,
|
|
343
344
|
// outDir: process.env.UNI_OUTPUT_DIR,
|
|
344
|
-
|
|
345
|
+
rolldownOptions: {
|
|
345
346
|
preserveEntrySignatures: 'strict',
|
|
346
347
|
input,
|
|
347
348
|
output: {
|
package/dist/vite/extApi.js
CHANGED
|
@@ -9,7 +9,7 @@ function uniUniModulesExtApiPlugin() {
|
|
|
9
9
|
name: 'uni:uni-modules_ext-api',
|
|
10
10
|
apply: 'build',
|
|
11
11
|
config() {
|
|
12
|
-
const
|
|
12
|
+
const rolldownOptions = {
|
|
13
13
|
input: (0, resolve_1.resolveMainPathOnce)(process.env.UNI_INPUT_DIR),
|
|
14
14
|
external: ['vue'],
|
|
15
15
|
output: {
|
|
@@ -25,7 +25,7 @@ function uniUniModulesExtApiPlugin() {
|
|
|
25
25
|
if (process.env.UNI_UTS_PLATFORM === 'app-ios' ||
|
|
26
26
|
process.env.UNI_UTS_PLATFORM === 'app-harmony' ||
|
|
27
27
|
(0, x_1.isUniAppXAndroidJsEngine)()) {
|
|
28
|
-
build.
|
|
28
|
+
build.rolldownOptions = rolldownOptions;
|
|
29
29
|
}
|
|
30
30
|
return {
|
|
31
31
|
build,
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
import type { EmittedAsset } from 'rollup';
|
|
1
|
+
import type { Plugin, ResolvedConfig, Rolldown } from 'vite';
|
|
3
2
|
import type { ExistingRawSourceMap } from 'rollup';
|
|
4
3
|
import type { ParserOptions } from '@vue/compiler-core';
|
|
5
4
|
import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
|
|
@@ -27,7 +26,7 @@ interface UniVitePluginUniOptions {
|
|
|
27
26
|
styleOptions?: Pick<SFCStyleCompileOptions, 'postcssPlugins'>;
|
|
28
27
|
compilerOptions?: {
|
|
29
28
|
miniProgram?: {
|
|
30
|
-
emitFile?: (emittedFile: EmittedAsset) => string;
|
|
29
|
+
emitFile?: (emittedFile: Rolldown.EmittedAsset) => string;
|
|
31
30
|
};
|
|
32
31
|
isNativeTag?: ParserOptions['isNativeTag'];
|
|
33
32
|
isVoidTag?: ParserOptions['isVoidTag'];
|
|
@@ -41,7 +40,13 @@ interface UniVitePluginUniOptions {
|
|
|
41
40
|
};
|
|
42
41
|
copyOptions?: CopyOptions | (() => CopyOptions);
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
type UniViteConfigResolvedHook = ((config: ResolvedConfig) => void | Promise<void>) | {
|
|
44
|
+
handler: (config: ResolvedConfig) => void | Promise<void>;
|
|
45
|
+
order?: 'pre' | 'post' | null;
|
|
46
|
+
sequential?: boolean;
|
|
47
|
+
};
|
|
48
|
+
export interface UniVitePlugin extends Omit<Plugin, 'configResolved'> {
|
|
49
|
+
configResolved?: UniViteConfigResolvedHook;
|
|
45
50
|
uni?: UniVitePluginUniOptions;
|
|
46
51
|
}
|
|
47
52
|
export * from './utils';
|
|
@@ -22,7 +22,8 @@ function uniConsolePlugin(options) {
|
|
|
22
22
|
resolvedConfig = config;
|
|
23
23
|
// 理论上发行模式就不应该有这个逻辑了,只不过为了尽量不引发兼容性问题,目前严谨一些判断是否配置了 drop_console
|
|
24
24
|
if (process.env.NODE_ENV !== 'development') {
|
|
25
|
-
const compressOptions = resolvedConfig.build.terserOptions
|
|
25
|
+
const compressOptions = resolvedConfig.build.terserOptions
|
|
26
|
+
?.compress;
|
|
26
27
|
if (compressOptions && typeof compressOptions === 'object') {
|
|
27
28
|
dropConsole = !!compressOptions.drop_console;
|
|
28
29
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
|
|
2
|
+
interface DynamicImportPolyfillPlugin extends Plugin {
|
|
3
|
+
renderDynamicImport(): {
|
|
4
|
+
left: string;
|
|
5
|
+
right: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function dynamicImportPolyfill(promise?: boolean): DynamicImportPolyfillPlugin;
|
|
9
|
+
export {};
|
|
@@ -7,6 +7,7 @@ export * from './console';
|
|
|
7
7
|
export * from './dynamicImportPolyfill';
|
|
8
8
|
export * from './uts/uni_modules';
|
|
9
9
|
export * from './uts/uvue';
|
|
10
|
+
export * from './uts/standardScript';
|
|
10
11
|
export * from './uts/ext-api';
|
|
11
12
|
export * from './easycom';
|
|
12
13
|
export * from './json';
|
|
@@ -24,6 +24,7 @@ __exportStar(require("./console"), exports);
|
|
|
24
24
|
__exportStar(require("./dynamicImportPolyfill"), exports);
|
|
25
25
|
__exportStar(require("./uts/uni_modules"), exports);
|
|
26
26
|
__exportStar(require("./uts/uvue"), exports);
|
|
27
|
+
__exportStar(require("./uts/standardScript"), exports);
|
|
27
28
|
__exportStar(require("./uts/ext-api"), exports);
|
|
28
29
|
__exportStar(require("./easycom"), exports);
|
|
29
30
|
__exportStar(require("./json"), exports);
|
|
@@ -39,7 +39,7 @@ function uniViteInjectPlugin(name, options) {
|
|
|
39
39
|
normalizeModulesMap(modulesMap);
|
|
40
40
|
normalizeModulesMap(namespaceModulesMap);
|
|
41
41
|
}
|
|
42
|
-
const firstpass = new RegExp(`(?:${Array.from(modulesMap.keys()).map(escape).join('|')})
|
|
42
|
+
const firstpass = new RegExp(`(?:${Array.from(modulesMap.keys()).map(escape).join('|')})`);
|
|
43
43
|
let sourceMap = options.sourceMap !== false;
|
|
44
44
|
const callback = options.callback;
|
|
45
45
|
return {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CreateUniViteFilterPlugin } from '../utils/plugin';
|
|
2
|
-
export declare const defineUniPagesJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin<any>;
|
|
3
|
-
export declare const defineUniManifestJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin<any>;
|
|
2
|
+
export declare const defineUniPagesJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite/dist/node").Plugin<any>;
|
|
3
|
+
export declare const defineUniManifestJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite/dist/node").Plugin<any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CreateUniViteFilterPlugin } from '../utils/plugin';
|
|
2
|
-
export declare function defineUniMainJsPlugin(createUniMainJsPlugin: CreateUniViteFilterPlugin): import("vite").Plugin<any>;
|
|
2
|
+
export declare function defineUniMainJsPlugin(createUniMainJsPlugin: CreateUniViteFilterPlugin): import("vite/dist/node").Plugin<any>;
|
|
@@ -24,6 +24,9 @@ function uniSourceMapPlugin(options) {
|
|
|
24
24
|
const tasks = Object.entries(bundle)
|
|
25
25
|
.filter(([file]) => file.endsWith('.js.map'))
|
|
26
26
|
.map(async ([file, asset]) => {
|
|
27
|
+
if (asset.type !== 'asset') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
27
30
|
const source = asset.source;
|
|
28
31
|
const targetPath = path_1.default.resolve(options.sourceMapDir, file);
|
|
29
32
|
// 快速计算内容哈希
|
|
@@ -57,7 +60,7 @@ function uniSourceMapPlugin(options) {
|
|
|
57
60
|
// 更新引用
|
|
58
61
|
const jsFile = file.replace('.js.map', '.js');
|
|
59
62
|
const outputChunk = bundle[jsFile];
|
|
60
|
-
if (outputChunk) {
|
|
63
|
+
if (outputChunk?.type === 'chunk') {
|
|
61
64
|
outputChunk.code = outputChunk.code.replace(/\/\/# sourceMappingURL=.*/, `//# sourceMappingURL=${(0, utils_1.normalizePath)(path_1.default.relative(file, options.relativeSourceMapDir))}/${file}`);
|
|
62
65
|
}
|
|
63
66
|
delete bundle[file];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExistingRawSourceMap } from 'rollup';
|
|
2
|
+
import type { Plugin } from 'vite';
|
|
3
|
+
import type { UasmTransformOptions } from '../../../uasm';
|
|
4
|
+
type TypeScriptCompiler = typeof import('typescript');
|
|
5
|
+
type StandardScriptRequest = 'module' | 'sfc';
|
|
6
|
+
export interface UniAppXStandardScriptPluginOptions {
|
|
7
|
+
uasm?: UasmTransformOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare function resolveUniAppXStandardScriptRequest(id: string): StandardScriptRequest | undefined;
|
|
10
|
+
export declare function transformUniAppXStandardScript(code: string, id: string, typescript: TypeScriptCompiler, options?: UniAppXStandardScriptPluginOptions): {
|
|
11
|
+
code: string;
|
|
12
|
+
map: ExistingRawSourceMap;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export declare function uniAppXStandardScriptPlugin(options?: UniAppXStandardScriptPluginOptions): Plugin;
|
|
15
|
+
export {};
|