@dcloudio/uni-cli-shared 3.0.0-4030620241128001 → 3.0.0-4040420241231001
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/LICENSE +0 -0
- package/dist/env/define.d.ts +1 -0
- package/dist/env/define.js +14 -0
- package/dist/env/index.d.ts +1 -1
- package/dist/env/index.js +1 -2
- package/dist/env/provide.d.ts +0 -3
- package/dist/env/provide.js +1 -7
- package/dist/hbx/index.d.ts +1 -0
- package/dist/hbx/index.js +8 -1
- package/dist/json/mp/jsonFile.d.ts +15 -0
- package/dist/json/mp/jsonFile.js +16 -2
- package/dist/json/mp/pages.js +1 -0
- package/dist/json/uni-x/index.js +1 -1
- package/dist/logs/console.d.ts +1 -0
- package/dist/logs/console.js +6 -2
- package/dist/mp/plugin.js +8 -1
- package/dist/mp/usingComponents.js +2 -2
- package/dist/platform.js +3 -0
- package/dist/preprocess/context.js +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +25 -1
- package/dist/uts.d.ts +1 -0
- package/dist/uts.js +26 -17
- package/dist/vite/plugins/console.js +7 -0
- package/dist/vite/plugins/index.d.ts +1 -0
- package/dist/vite/plugins/index.js +1 -0
- package/dist/vite/plugins/sourceMap.d.ts +5 -0
- package/dist/vite/plugins/sourceMap.js +70 -0
- package/dist/vite/plugins/uts/uni_modules.js +12 -0
- package/dist/vue/transforms/x/transformDirection.js +7 -4
- package/dist/vue/transforms/x/transformMPBuiltInTag.js +7 -0
- package/lib/preprocess/LICENSE +0 -0
- package/lib/preprocess/README.md +0 -0
- package/lib/preprocess/lib/preprocess.js +0 -0
- package/lib/preprocess/lib/regexrules.js +0 -0
- package/lib/preprocess/package.json +0 -0
- package/package.json +7 -7
package/LICENSE
CHANGED
|
File without changes
|
package/dist/env/define.d.ts
CHANGED
package/dist/env/define.js
CHANGED
|
@@ -8,7 +8,20 @@ function initDefine(stringifyBoolean = false) {
|
|
|
8
8
|
const platformManifestJson = (0, json_1.getPlatformManifestJsonOnce)();
|
|
9
9
|
const isRunByHBuilderX = (0, env_1.runByHBuilderX)();
|
|
10
10
|
const isDebug = !!manifestJson.debug;
|
|
11
|
+
const isX = process.env.UNI_APP_X === 'true';
|
|
12
|
+
const isMP = process.env.UNI_PLATFORM.startsWith('mp');
|
|
11
13
|
process.env['UNI_APP_ID'] = manifestJson.appid;
|
|
14
|
+
let mpXDefine = isX && isMP
|
|
15
|
+
? {
|
|
16
|
+
__UNI_FEATURE_VIRTUAL_HOST__: true,
|
|
17
|
+
}
|
|
18
|
+
: {
|
|
19
|
+
__UNI_FEATURE_VIRTUAL_HOST__: false,
|
|
20
|
+
};
|
|
21
|
+
if (isX && isMP) {
|
|
22
|
+
mpXDefine.__UNI_FEATURE_VIRTUAL_HOST__ =
|
|
23
|
+
platformManifestJson.enableVirtualHost !== false;
|
|
24
|
+
}
|
|
12
25
|
return {
|
|
13
26
|
...initCustomDefine(),
|
|
14
27
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
@@ -34,6 +47,7 @@ function initDefine(stringifyBoolean = false) {
|
|
|
34
47
|
// 兼容旧版本
|
|
35
48
|
'process.env.VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM || ''),
|
|
36
49
|
'process.env.VUE_APP_DARK_MODE': JSON.stringify(platformManifestJson.darkmode || false),
|
|
50
|
+
...mpXDefine,
|
|
37
51
|
};
|
|
38
52
|
}
|
|
39
53
|
exports.initDefine = initDefine;
|
package/dist/env/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initDefine } from './define';
|
|
2
|
-
export { initAppProvide
|
|
2
|
+
export { initAppProvide } from './provide';
|
package/dist/env/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.initAppProvide = exports.initDefine = void 0;
|
|
4
4
|
var define_1 = require("./define");
|
|
5
5
|
Object.defineProperty(exports, "initDefine", { enumerable: true, get: function () { return define_1.initDefine; } });
|
|
6
6
|
var provide_1 = require("./provide");
|
|
7
7
|
Object.defineProperty(exports, "initAppProvide", { enumerable: true, get: function () { return provide_1.initAppProvide; } });
|
|
8
|
-
Object.defineProperty(exports, "initH5Provide", { enumerable: true, get: function () { return provide_1.initH5Provide; } });
|
package/dist/env/provide.d.ts
CHANGED
package/dist/env/provide.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.
|
|
6
|
+
exports.initAppProvide = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const libDir = path_1.default.resolve(__dirname, '../../lib');
|
|
9
9
|
function initAppProvide() {
|
|
@@ -18,9 +18,3 @@ function initAppProvide() {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
exports.initAppProvide = initAppProvide;
|
|
21
|
-
function initH5Provide() {
|
|
22
|
-
return {
|
|
23
|
-
__f__: ['@dcloudio/uni-app', 'formatH5Log'],
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.initH5Provide = initH5Provide;
|
package/dist/hbx/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { formatAtFilename } from './log';
|
|
|
2
2
|
export * from './env';
|
|
3
3
|
export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
|
|
4
4
|
export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
|
|
5
|
+
export declare function isEnableConsole(): boolean;
|
package/dist/hbx/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.uniHBuilderXConsolePlugin = exports.formatInstallHBuilderXPluginTips = exports.installHBuilderXPlugin = exports.initModuleAlias = exports.formatAtFilename = void 0;
|
|
20
|
+
exports.isEnableConsole = exports.uniHBuilderXConsolePlugin = exports.formatInstallHBuilderXPluginTips = exports.installHBuilderXPlugin = exports.initModuleAlias = exports.formatAtFilename = void 0;
|
|
21
21
|
const path_1 = __importDefault(require("path"));
|
|
22
22
|
const utils_1 = require("../utils");
|
|
23
23
|
const console_1 = require("../vite/plugins/console");
|
|
@@ -41,3 +41,10 @@ function uniHBuilderXConsolePlugin(method = '__f__') {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
exports.uniHBuilderXConsolePlugin = uniHBuilderXConsolePlugin;
|
|
44
|
+
function isEnableConsole() {
|
|
45
|
+
return !!(process.env.NODE_ENV === 'development' &&
|
|
46
|
+
process.env.UNI_SOCKET_HOSTS &&
|
|
47
|
+
process.env.UNI_SOCKET_PORT &&
|
|
48
|
+
process.env.UNI_SOCKET_ID);
|
|
49
|
+
}
|
|
50
|
+
exports.isEnableConsole = isEnableConsole;
|
|
@@ -24,5 +24,20 @@ export declare function findMiniProgramUsingComponents({ filename, inputDir, com
|
|
|
24
24
|
inputDir: string;
|
|
25
25
|
componentsDir?: string;
|
|
26
26
|
}): MiniProgramComponents;
|
|
27
|
+
/**
|
|
28
|
+
* 开发者在配置usingComponents时,可以指向具体路径(不含文件后缀),也可以指向目录(指向目录时查找目录下的index.wxml/.json等)
|
|
29
|
+
* 当usingComponents配置为`"demo": "/components/demo"`时,查找优先级为:
|
|
30
|
+
* 1. /components/demo.wxml
|
|
31
|
+
* 2. /components/demo/index.wxml
|
|
32
|
+
*
|
|
33
|
+
* 注意如下配置是非法的:
|
|
34
|
+
* - "demo": "/components/demo.wxml"
|
|
35
|
+
* - "demo": "/components/demo/"
|
|
36
|
+
*
|
|
37
|
+
* 注意用户的pages.json内可以配置如下三种路径:
|
|
38
|
+
* - "demo": "/wxcomponents/demo"
|
|
39
|
+
* - "demo": "wxcomponents/demo"
|
|
40
|
+
* - [TODO 待确认] "demo": "../wxcomponents/demo"
|
|
41
|
+
*/
|
|
27
42
|
export declare function findUsingComponentsJson(pathInpages: string, componentsDir: string): Record<any, any>;
|
|
28
43
|
export {};
|
package/dist/json/mp/jsonFile.js
CHANGED
|
@@ -165,6 +165,21 @@ function findMiniProgramUsingComponent(usingComponents, componentsDir) {
|
|
|
165
165
|
return res;
|
|
166
166
|
}, {});
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* 开发者在配置usingComponents时,可以指向具体路径(不含文件后缀),也可以指向目录(指向目录时查找目录下的index.wxml/.json等)
|
|
170
|
+
* 当usingComponents配置为`"demo": "/components/demo"`时,查找优先级为:
|
|
171
|
+
* 1. /components/demo.wxml
|
|
172
|
+
* 2. /components/demo/index.wxml
|
|
173
|
+
*
|
|
174
|
+
* 注意如下配置是非法的:
|
|
175
|
+
* - "demo": "/components/demo.wxml"
|
|
176
|
+
* - "demo": "/components/demo/"
|
|
177
|
+
*
|
|
178
|
+
* 注意用户的pages.json内可以配置如下三种路径:
|
|
179
|
+
* - "demo": "/wxcomponents/demo"
|
|
180
|
+
* - "demo": "wxcomponents/demo"
|
|
181
|
+
* - [TODO 待确认] "demo": "../wxcomponents/demo"
|
|
182
|
+
*/
|
|
168
183
|
function findUsingComponentsJson(pathInpages, componentsDir) {
|
|
169
184
|
// 兼容test case
|
|
170
185
|
if (!process.env.UNI_INPUT_DIR)
|
|
@@ -176,8 +191,7 @@ function findUsingComponentsJson(pathInpages, componentsDir) {
|
|
|
176
191
|
}
|
|
177
192
|
dir = '.' + dir;
|
|
178
193
|
const fulldir = path_1.default.resolve(process.env.UNI_INPUT_DIR, componentsDir, dir);
|
|
179
|
-
let
|
|
180
|
-
let jsonPath = path_1.default.resolve(fulldir, filename);
|
|
194
|
+
let jsonPath = fulldir + '.json';
|
|
181
195
|
if (fs_1.default.existsSync(jsonPath)) {
|
|
182
196
|
return require(jsonPath);
|
|
183
197
|
}
|
package/dist/json/mp/pages.js
CHANGED
package/dist/json/uni-x/index.js
CHANGED
|
@@ -235,7 +235,7 @@ function normalizeUniAppXAppConfig(pagesJson, manifestJson) {
|
|
|
235
235
|
return `const __uniConfig = ${JSON.stringify(uniConfig)};
|
|
236
236
|
__uniConfig.getTabBarConfig = () => {return ${tabBar ? JSON.stringify(tabBar) : 'undefined'}};
|
|
237
237
|
__uniConfig.tabBar = __uniConfig.getTabBarConfig();
|
|
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));
|
|
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
241
|
}
|
package/dist/logs/console.d.ts
CHANGED
package/dist/logs/console.js
CHANGED
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.rewriteConsoleExpr = void 0;
|
|
6
|
+
exports.restoreConsoleExpr = exports.rewriteConsoleExpr = void 0;
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
10
10
|
filename = (0, utils_1.normalizePath)(filename);
|
|
11
|
-
const re = /(console\.(log|info|debug|warn|error))\(([^)]+)\)/g;
|
|
11
|
+
const re = /(console\.(log|info|debug|warn|error))\s*\(([^)]+)\)/g;
|
|
12
12
|
const locate = getLocator(code);
|
|
13
13
|
const s = new magic_string_1.default(code);
|
|
14
14
|
let match;
|
|
@@ -25,6 +25,10 @@ function rewriteConsoleExpr(method, id, filename, code, sourceMap = false) {
|
|
|
25
25
|
return { code, map: { mappings: '' } };
|
|
26
26
|
}
|
|
27
27
|
exports.rewriteConsoleExpr = rewriteConsoleExpr;
|
|
28
|
+
function restoreConsoleExpr(code) {
|
|
29
|
+
return code.replace(/(?:uni\.)?__f__\('([^']+)','at ([^:]+):(\d+)',/g, 'console.$1(');
|
|
30
|
+
}
|
|
31
|
+
exports.restoreConsoleExpr = restoreConsoleExpr;
|
|
28
32
|
function getLocator(source) {
|
|
29
33
|
const originalLines = source.split('\n');
|
|
30
34
|
const lineOffsets = [];
|
package/dist/mp/plugin.js
CHANGED
|
@@ -14,7 +14,14 @@ exports.copyMiniProgramPluginJson = {
|
|
|
14
14
|
return process.env.UNI_OUTPUT_DIR;
|
|
15
15
|
},
|
|
16
16
|
transform(source) {
|
|
17
|
-
|
|
17
|
+
const pluginJson = (0, json_1.parseJson)(source.toString(), true);
|
|
18
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
19
|
+
const pluginMainJs = pluginJson.main;
|
|
20
|
+
if (pluginMainJs && pluginMainJs.endsWith('.uts')) {
|
|
21
|
+
pluginJson.main = pluginMainJs.replace(/\.uts$/, '.js');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(pluginJson, null, 2);
|
|
18
25
|
},
|
|
19
26
|
};
|
|
20
27
|
const copyMiniProgramThemeJson = () => {
|
|
@@ -299,10 +299,10 @@ function parseGlobalComponents(ast) {
|
|
|
299
299
|
}
|
|
300
300
|
const [name, value] = args;
|
|
301
301
|
if (!(0, types_1.isStringLiteral)(name)) {
|
|
302
|
-
return console.warn(messages_1.M['mp.component.args[0]']);
|
|
302
|
+
return console.warn(messages_1.M['mp.component.args[0]'].replace('{0}', 'app.component'));
|
|
303
303
|
}
|
|
304
304
|
if (!(0, types_1.isIdentifier)(value)) {
|
|
305
|
-
return console.warn(messages_1.M['mp.component.args[1]']);
|
|
305
|
+
return console.warn(messages_1.M['mp.component.args[1]'].replace('{0}', 'app.component'));
|
|
306
306
|
}
|
|
307
307
|
bindingComponents[value.name] = {
|
|
308
308
|
tag: name.value,
|
package/dist/platform.js
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -36,3 +36,10 @@ export declare function requireUniHelpers(): any;
|
|
|
36
36
|
export declare function normalizeEmitAssetFileName(fileName: string): string;
|
|
37
37
|
export declare function createShadowImageUrl(cdn: number, type?: string): string;
|
|
38
38
|
export declare function isNormalCompileTarget(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* copy from entities 用于转义实体字符
|
|
41
|
+
* @param regex
|
|
42
|
+
* @param map
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
export declare function getEscaper(regex: RegExp, map: Map<number, string>): (data: string) => string;
|
package/dist/utils.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.isNormalCompileTarget = exports.createShadowImageUrl = exports.normalizeEmitAssetFileName = exports.requireUniHelpers = exports.enableSourceMap = exports.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isArray = exports.capitalize = exports.camelize = exports.hash = void 0;
|
|
6
|
+
exports.getEscaper = exports.isNormalCompileTarget = exports.createShadowImageUrl = exports.normalizeEmitAssetFileName = exports.requireUniHelpers = exports.enableSourceMap = exports.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isArray = exports.capitalize = exports.camelize = exports.hash = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -227,3 +227,27 @@ function isNormalCompileTarget() {
|
|
|
227
227
|
return !process.env.UNI_COMPILE_TARGET;
|
|
228
228
|
}
|
|
229
229
|
exports.isNormalCompileTarget = isNormalCompileTarget;
|
|
230
|
+
/**
|
|
231
|
+
* copy from entities 用于转义实体字符
|
|
232
|
+
* @param regex
|
|
233
|
+
* @param map
|
|
234
|
+
* @returns
|
|
235
|
+
*/
|
|
236
|
+
function getEscaper(regex, map) {
|
|
237
|
+
return function escape(data) {
|
|
238
|
+
let match;
|
|
239
|
+
let lastIndex = 0;
|
|
240
|
+
let result = '';
|
|
241
|
+
while ((match = regex.exec(data))) {
|
|
242
|
+
if (lastIndex !== match.index) {
|
|
243
|
+
result += data.substring(lastIndex, match.index);
|
|
244
|
+
}
|
|
245
|
+
// We know that this character will be in the map.
|
|
246
|
+
result += map.get(match[0].charCodeAt(0));
|
|
247
|
+
// Every match will be of length 1
|
|
248
|
+
lastIndex = match.index + 1;
|
|
249
|
+
}
|
|
250
|
+
return result + data.substring(lastIndex);
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
exports.getEscaper = getEscaper;
|
package/dist/uts.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { EasycomMatcher } from './easycom';
|
|
|
11
11
|
export declare function resolveUTSAppModule(platform: typeof process.env.UNI_UTS_PLATFORM, id: string, importer: string, includeUTSSDK?: boolean): string | undefined;
|
|
12
12
|
export declare function resolveUTSModule(id: string, importer: string, includeUTSSDK?: boolean): string | undefined;
|
|
13
13
|
export declare function resolveUTSCompiler(throwError?: boolean): typeof UTSCompiler;
|
|
14
|
+
export declare function resolveUTSCompilerVersion(): string;
|
|
14
15
|
export declare function isUTSComponent(name: string): boolean;
|
|
15
16
|
export declare function getUTSComponentAutoImports(language: 'kotlin' | 'swift'): Record<string, [[string]]>;
|
|
16
17
|
export declare function parseUTSComponent(name: string, type: 'kotlin' | 'swift'): {
|
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.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.getUTSComponentAutoImports = exports.isUTSComponent = 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.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.getUTSComponentAutoImports = exports.isUTSComponent = exports.resolveUTSCompilerVersion = exports.resolveUTSCompiler = 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"));
|
|
@@ -127,27 +127,31 @@ function resolveUTSCompiler(throwError = false) {
|
|
|
127
127
|
if (throwError) {
|
|
128
128
|
throw `Error: Cannot find module '@dcloudio/uni-uts-v1'`;
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
utsCompilerVersion = require('../package.json').version;
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
try {
|
|
136
|
-
// vue2
|
|
137
|
-
utsCompilerVersion = require('../../package.json').version;
|
|
138
|
-
}
|
|
139
|
-
catch (e) { }
|
|
140
|
-
}
|
|
141
|
-
if (utsCompilerVersion.startsWith('2.0.')) {
|
|
142
|
-
utsCompilerVersion = '^3.0.0-alpha-3060920221117001';
|
|
143
|
-
}
|
|
144
|
-
console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', utsCompilerVersion));
|
|
130
|
+
console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', resolveUTSCompilerVersion()));
|
|
145
131
|
process.exit(0);
|
|
146
132
|
}
|
|
147
133
|
}
|
|
148
134
|
return require(compilerPath);
|
|
149
135
|
}
|
|
150
136
|
exports.resolveUTSCompiler = resolveUTSCompiler;
|
|
137
|
+
function resolveUTSCompilerVersion() {
|
|
138
|
+
let utsCompilerVersion = '';
|
|
139
|
+
try {
|
|
140
|
+
utsCompilerVersion = require('../package.json').version;
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
try {
|
|
144
|
+
// vue2
|
|
145
|
+
utsCompilerVersion = require('../../package.json').version;
|
|
146
|
+
}
|
|
147
|
+
catch (e) { }
|
|
148
|
+
}
|
|
149
|
+
if (utsCompilerVersion.startsWith('2.0.')) {
|
|
150
|
+
utsCompilerVersion = '^3.0.0-alpha-3060920221117001';
|
|
151
|
+
}
|
|
152
|
+
return utsCompilerVersion;
|
|
153
|
+
}
|
|
154
|
+
exports.resolveUTSCompilerVersion = resolveUTSCompilerVersion;
|
|
151
155
|
const utsComponents = new Map();
|
|
152
156
|
function isUTSComponent(name) {
|
|
153
157
|
return utsComponents.has(name);
|
|
@@ -196,9 +200,14 @@ function initUTSComponents(inputDir, platform) {
|
|
|
196
200
|
? path_1.default.basename(path_1.default.dirname(dir))
|
|
197
201
|
: path_1.default.basename(dir);
|
|
198
202
|
if (is_uni_modules_utssdk || is_ussdk) {
|
|
203
|
+
// dir 是 uni_modules/test-plugin/utssdk 或者 utssdk/test-plugin
|
|
204
|
+
// 需要分平台解析,不能直接解析 utssdk 目录下的文件,因为 utssdk 目录下可能存在多个平台的文件
|
|
205
|
+
const cwd = isApp
|
|
206
|
+
? dir
|
|
207
|
+
: path_1.default.join(dir, platform === 'h5' ? 'web' : platform);
|
|
199
208
|
fast_glob_1.default
|
|
200
209
|
.sync('**/*.vue', {
|
|
201
|
-
cwd
|
|
210
|
+
cwd,
|
|
202
211
|
absolute: true,
|
|
203
212
|
})
|
|
204
213
|
.forEach((file) => {
|
|
@@ -9,6 +9,7 @@ const pluginutils_1 = require("@rollup/pluginutils");
|
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const console_1 = require("../../logs/console");
|
|
11
11
|
const utils_2 = require("../../vite/utils/utils");
|
|
12
|
+
const filter_1 = require("../../filter");
|
|
12
13
|
const debugConsole = (0, debug_1.default)('uni:console');
|
|
13
14
|
function uniConsolePlugin(options) {
|
|
14
15
|
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
@@ -20,6 +21,12 @@ function uniConsolePlugin(options) {
|
|
|
20
21
|
resolvedConfig = config;
|
|
21
22
|
},
|
|
22
23
|
transform(code, id) {
|
|
24
|
+
if ((0, filter_1.isRenderjs)(id) || (0, filter_1.isWxs)(id)) {
|
|
25
|
+
return {
|
|
26
|
+
code: (0, console_1.restoreConsoleExpr)(code),
|
|
27
|
+
map: { mappings: '' },
|
|
28
|
+
};
|
|
29
|
+
}
|
|
23
30
|
if (!filter(id))
|
|
24
31
|
return null;
|
|
25
32
|
if (!(0, utils_1.isJsFile)(id))
|
|
@@ -11,6 +11,7 @@ export * from './uts/ext-api';
|
|
|
11
11
|
export * from './easycom';
|
|
12
12
|
export * from './json';
|
|
13
13
|
export * from './pre';
|
|
14
|
+
export * from './sourceMap';
|
|
14
15
|
export { uniViteSfcSrcImportPlugin } from './sfc';
|
|
15
16
|
export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
|
|
16
17
|
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, rewriteScssReadFileSync, getCssDepMap, } from './vitejs/plugins/css';
|
|
@@ -28,6 +28,7 @@ __exportStar(require("./uts/ext-api"), exports);
|
|
|
28
28
|
__exportStar(require("./easycom"), exports);
|
|
29
29
|
__exportStar(require("./json"), exports);
|
|
30
30
|
__exportStar(require("./pre"), exports);
|
|
31
|
+
__exportStar(require("./sourceMap"), exports);
|
|
31
32
|
var sfc_1 = require("./sfc");
|
|
32
33
|
Object.defineProperty(exports, "uniViteSfcSrcImportPlugin", { enumerable: true, get: function () { return sfc_1.uniViteSfcSrcImportPlugin; } });
|
|
33
34
|
var asset_1 = require("./vitejs/plugins/asset");
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.uniSourceMapPlugin = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const debugSourceMap = (0, debug_1.default)('uni:sourcemap');
|
|
13
|
+
function uniSourceMapPlugin(options) {
|
|
14
|
+
// 使用 WeakMap 存储文件内容的哈希值,避免内存泄漏
|
|
15
|
+
const contentHashMap = new Map();
|
|
16
|
+
return {
|
|
17
|
+
name: 'uni:sourcemap',
|
|
18
|
+
enforce: 'post',
|
|
19
|
+
async generateBundle(_, bundle) {
|
|
20
|
+
if (!(0, utils_1.enableSourceMap)()) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// 批量处理所有 sourcemap 文件
|
|
24
|
+
const tasks = Object.entries(bundle)
|
|
25
|
+
.filter(([file]) => file.endsWith('.js.map'))
|
|
26
|
+
.map(async ([file, asset]) => {
|
|
27
|
+
const source = asset.source;
|
|
28
|
+
const targetPath = path_1.default.resolve(options.sourceMapDir, file);
|
|
29
|
+
// 快速计算内容哈希
|
|
30
|
+
const hash = crypto_1.default
|
|
31
|
+
.createHash('md5') // xxhash 比 md5 快很多
|
|
32
|
+
.update(source)
|
|
33
|
+
.digest('hex');
|
|
34
|
+
let needsUpdate = true;
|
|
35
|
+
try {
|
|
36
|
+
// 使用 stat 检查文件是否存在,比 pathExists 更快
|
|
37
|
+
const stat = await fs_extra_1.default.stat(targetPath);
|
|
38
|
+
if (stat.isFile()) {
|
|
39
|
+
const oldHash = contentHashMap.get(file);
|
|
40
|
+
needsUpdate = !oldHash || oldHash !== hash;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// 文件不存在,需要写入
|
|
45
|
+
needsUpdate = true;
|
|
46
|
+
}
|
|
47
|
+
if (needsUpdate) {
|
|
48
|
+
await fs_extra_1.default.outputFile(targetPath, source);
|
|
49
|
+
contentHashMap.set(file, hash);
|
|
50
|
+
debugSourceMap.enabled &&
|
|
51
|
+
debugSourceMap('write sourcemap file %s', file);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
debugSourceMap.enabled &&
|
|
55
|
+
debugSourceMap('skip unchanged sourcemap file %s', file);
|
|
56
|
+
}
|
|
57
|
+
// 更新引用
|
|
58
|
+
const jsFile = file.replace('.js.map', '.js');
|
|
59
|
+
const outputChunk = bundle[jsFile];
|
|
60
|
+
if (outputChunk) {
|
|
61
|
+
outputChunk.code = outputChunk.code.replace(/\/\/# sourceMappingURL=.*/, `//# sourceMappingURL=${(0, utils_1.normalizePath)(path_1.default.relative(file, options.relativeSourceMapDir))}/${file}`);
|
|
62
|
+
}
|
|
63
|
+
delete bundle[file];
|
|
64
|
+
});
|
|
65
|
+
// 使用 Promise.all 并行处理所有文件
|
|
66
|
+
await Promise.all(tasks);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.uniSourceMapPlugin = uniSourceMapPlugin;
|
|
@@ -167,6 +167,18 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
167
167
|
name: 'uni:uts-uni_modules-placeholder',
|
|
168
168
|
apply: 'build',
|
|
169
169
|
enforce: 'pre',
|
|
170
|
+
resolveId(id) {
|
|
171
|
+
if ((0, uts_1.isUTSProxy)(id) || (0, uts_1.isUniHelpers)(id)) {
|
|
172
|
+
return id;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
load(id) {
|
|
176
|
+
if ((0, uts_1.isUTSProxy)(id)) {
|
|
177
|
+
console.error((0, utils_2.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', (0, uts_1.resolveUTSCompilerVersion)()));
|
|
178
|
+
process.exit(0);
|
|
179
|
+
return '';
|
|
180
|
+
}
|
|
181
|
+
},
|
|
170
182
|
};
|
|
171
183
|
}
|
|
172
184
|
}
|
|
@@ -18,6 +18,9 @@ const transformDirection = function (node, context) {
|
|
|
18
18
|
const directionPropIndex = node.props.findIndex((prop) => (0, utils_1.isPropNameEquals)(prop, 'direction'));
|
|
19
19
|
const scrollXPropIndex = node.props.findIndex((prop) => (0, utils_1.isPropNameEquals)(prop, 'scrollX'));
|
|
20
20
|
const scrollYPropIndex = node.props.findIndex((prop) => (0, utils_1.isPropNameEquals)(prop, 'scrollY'));
|
|
21
|
+
if (scrollXPropIndex > -1 || scrollYPropIndex > -1) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
21
24
|
if (directionPropIndex === -1 ||
|
|
22
25
|
(scrollXPropIndex !== -1 && scrollYPropIndex !== -1)) {
|
|
23
26
|
node.props.push((0, utils_1.createAttributeNode)('scroll-y', 'true'));
|
|
@@ -36,17 +39,17 @@ const transformDirection = function (node, context) {
|
|
|
36
39
|
}
|
|
37
40
|
else if (directionProp.type === compiler_core_1.NodeTypes.DIRECTIVE) {
|
|
38
41
|
if (!directionProp.arg ||
|
|
39
|
-
|
|
42
|
+
directionProp.arg.type !== compiler_core_1.NodeTypes.SIMPLE_EXPRESSION ||
|
|
40
43
|
!directionProp.exp ||
|
|
41
|
-
|
|
44
|
+
directionProp.exp.type !== compiler_core_1.NodeTypes.SIMPLE_EXPRESSION) {
|
|
42
45
|
return;
|
|
43
46
|
}
|
|
44
47
|
const exp = directionProp.exp.content;
|
|
45
48
|
const scrollX = `(${exp}) === 'horizontal' || (${exp}) === 'all'`;
|
|
46
49
|
const scrollY = `!(${exp}) || (${exp}) === 'vertical' || (${exp}) === 'all'`;
|
|
47
50
|
node.props.splice(directionPropIndex, 1);
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
node.props.push((0, utils_1.createBindDirectiveNode)('scroll-x', scrollX));
|
|
52
|
+
node.props.push((0, utils_1.createBindDirectiveNode)('scroll-y', scrollY));
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
55
|
exports.transformDirection = transformDirection;
|
|
@@ -32,6 +32,9 @@ exports.defaultTransformMPBuiltInTagOptions = {
|
|
|
32
32
|
// "foreColor": "",
|
|
33
33
|
// "activeForeColor": ""
|
|
34
34
|
},
|
|
35
|
+
'rich-text': {
|
|
36
|
+
selectable: 'user-select',
|
|
37
|
+
},
|
|
35
38
|
},
|
|
36
39
|
propAdd: {
|
|
37
40
|
canvas: [
|
|
@@ -45,6 +48,10 @@ exports.defaultTransformMPBuiltInTagOptions = {
|
|
|
45
48
|
name: 'enable-flex',
|
|
46
49
|
value: 'true',
|
|
47
50
|
},
|
|
51
|
+
{
|
|
52
|
+
name: 'enhanced',
|
|
53
|
+
value: 'true',
|
|
54
|
+
},
|
|
48
55
|
],
|
|
49
56
|
},
|
|
50
57
|
tagRename: {
|
package/lib/preprocess/LICENSE
CHANGED
|
File without changes
|
package/lib/preprocess/README.md
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
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-4040420241231001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,8 +26,6 @@
|
|
|
26
26
|
"@babel/core": "^7.23.3",
|
|
27
27
|
"@babel/parser": "^7.23.9",
|
|
28
28
|
"@babel/types": "^7.20.7",
|
|
29
|
-
"@dcloudio/uni-i18n": "3.0.0-4030620241128001",
|
|
30
|
-
"@dcloudio/uni-shared": "3.0.0-4030620241128001",
|
|
31
29
|
"@intlify/core-base": "9.1.9",
|
|
32
30
|
"@intlify/shared": "9.1.9",
|
|
33
31
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -67,11 +65,12 @@
|
|
|
67
65
|
"source-map-js": "^1.0.2",
|
|
68
66
|
"tapable": "^2.2.0",
|
|
69
67
|
"unplugin-auto-import": "^0.18.2",
|
|
70
|
-
"xregexp": "3.1.0"
|
|
68
|
+
"xregexp": "3.1.0",
|
|
69
|
+
"@dcloudio/uni-i18n": "3.0.0-4040420241231001",
|
|
70
|
+
"@dcloudio/uni-shared": "3.0.0-4040420241231001"
|
|
71
71
|
},
|
|
72
72
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@dcloudio/uni-uts-v1": "3.0.0-4030620241128001",
|
|
75
74
|
"@types/adm-zip": "^0.5.5",
|
|
76
75
|
"@types/babel__code-frame": "^7.0.6",
|
|
77
76
|
"@types/babel__core": "^7.1.19",
|
|
@@ -88,6 +87,7 @@
|
|
|
88
87
|
"code-frame": "link:@types/@babel/code-frame",
|
|
89
88
|
"postcss": "^8.4.21",
|
|
90
89
|
"unimport": "^3.11.1",
|
|
91
|
-
"vue": "3.4.21"
|
|
90
|
+
"vue": "3.4.21",
|
|
91
|
+
"@dcloudio/uni-uts-v1": "3.0.0-4040420241231001"
|
|
92
92
|
}
|
|
93
|
-
}
|
|
93
|
+
}
|