@dcloudio/uni-cli-shared 3.0.0-alpha-4030320241109002 → 3.0.0-alpha-4030420241120001
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/deps.d.ts +2 -2
- package/dist/deps.js +45 -34
- package/dist/easycom.js +15 -8
- package/dist/env/define.js +1 -0
- package/dist/hbx/log.d.ts +1 -0
- package/dist/hbx/log.js +56 -25
- package/dist/json/mp/pages.js +5 -0
- package/dist/json/uni-x/index.js +6 -1
- package/dist/json/uni-x/uniConfig.d.ts +15 -1
- package/dist/json/uni-x/uniConfig.js +1 -1
- package/dist/logs/format.js +1 -0
- package/dist/mp/template.d.ts +9 -0
- package/dist/preprocess/context.js +1 -0
- package/dist/uni_modules.js +6 -6
- package/dist/vite/autoImport.js +7 -0
- package/dist/vite/plugins/index.d.ts +1 -0
- package/dist/vite/plugins/index.js +1 -0
- package/dist/vite/plugins/pre.d.ts +6 -0
- package/dist/vite/plugins/pre.js +59 -0
- package/dist/vite/plugins/uts/uni_modules.d.ts +1 -0
- package/dist/vite/plugins/uts/uni_modules.js +19 -2
- package/dist/vite/utils/utils.js +1 -1
- package/dist/vue/transforms/index.d.ts +2 -0
- package/dist/vue/transforms/index.js +2 -0
- package/dist/vue/transforms/x/transformDirection.d.ts +6 -0
- package/dist/vue/transforms/x/transformDirection.js +52 -0
- package/dist/vue/transforms/x/transformMPBuiltInTag.d.ts +12 -0
- package/dist/vue/transforms/x/transformMPBuiltInTag.js +94 -0
- package/dist/vue/utils.d.ts +1 -0
- package/dist/vue/utils.js +13 -1
- package/package.json +4 -4
package/dist/deps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const API_DEPS_CSS: {
|
|
1
|
+
export declare const API_DEPS_CSS: (isX: boolean) => {
|
|
2
2
|
showModal: string[];
|
|
3
3
|
showToast: string[];
|
|
4
4
|
showActionSheet: string[];
|
|
@@ -6,7 +6,7 @@ export declare const API_DEPS_CSS: {
|
|
|
6
6
|
openLocation: string[];
|
|
7
7
|
chooseLocation: string[];
|
|
8
8
|
};
|
|
9
|
-
export declare const COMPONENT_DEPS_CSS: {
|
|
9
|
+
export declare const COMPONENT_DEPS_CSS: (isX: boolean) => {
|
|
10
10
|
canvas: string[];
|
|
11
11
|
image: string[];
|
|
12
12
|
'movable-area': string[];
|
package/dist/deps.js
CHANGED
|
@@ -4,39 +4,50 @@ exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = void 0;
|
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
5
|
const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
|
|
6
6
|
const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
const API_DEPS_CSS = (isX) => {
|
|
8
|
+
return {
|
|
9
|
+
showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
|
|
10
|
+
showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
|
|
11
|
+
showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
|
|
12
|
+
previewImage: [
|
|
13
|
+
RESIZE_SENSOR_CSS,
|
|
14
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper.css`,
|
|
15
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper-item.css`,
|
|
16
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-area.css`,
|
|
17
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
|
|
18
|
+
],
|
|
19
|
+
openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
|
|
20
|
+
chooseLocation: [
|
|
21
|
+
...(isX
|
|
22
|
+
? [
|
|
23
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/view.css`,
|
|
24
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/text.css`,
|
|
25
|
+
]
|
|
26
|
+
: [`${constants_1.H5_API_STYLE_PATH}/location-picker.css`]),
|
|
27
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
|
|
28
|
+
`${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
|
|
29
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
|
|
30
|
+
],
|
|
31
|
+
};
|
|
25
32
|
};
|
|
26
|
-
exports.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
RESIZE_SENSOR_CSS,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
exports.API_DEPS_CSS = API_DEPS_CSS;
|
|
34
|
+
const COMPONENT_DEPS_CSS = (isX) => {
|
|
35
|
+
return {
|
|
36
|
+
canvas: [RESIZE_SENSOR_CSS],
|
|
37
|
+
image: [RESIZE_SENSOR_CSS],
|
|
38
|
+
'movable-area': [RESIZE_SENSOR_CSS],
|
|
39
|
+
'picker-view': [RESIZE_SENSOR_CSS],
|
|
40
|
+
'picker-view-column': [RESIZE_SENSOR_CSS],
|
|
41
|
+
'rich-text': [RESIZE_SENSOR_CSS],
|
|
42
|
+
textarea: [RESIZE_SENSOR_CSS],
|
|
43
|
+
'web-view': [RESIZE_SENSOR_CSS],
|
|
44
|
+
picker: [
|
|
45
|
+
RESIZE_SENSOR_CSS,
|
|
46
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
|
|
47
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
|
|
48
|
+
],
|
|
49
|
+
'scroll-view': [REFRESHER_CSS],
|
|
50
|
+
'list-view': [RESIZE_SENSOR_CSS, REFRESHER_CSS],
|
|
51
|
+
};
|
|
42
52
|
};
|
|
53
|
+
exports.COMPONENT_DEPS_CSS = COMPONENT_DEPS_CSS;
|
package/dist/easycom.js
CHANGED
|
@@ -64,8 +64,11 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
64
64
|
globalThis.uts2jsSourceCodeMap.initUts2jsEasycom(easycoms);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
// ext-api 模式下,不存在 easycom 特性
|
|
68
|
+
if (process.env.UNI_COMPILE_TARGET !== 'ext-api') {
|
|
69
|
+
initEasycom(options);
|
|
70
|
+
initUTSEasycom();
|
|
71
|
+
}
|
|
69
72
|
const componentExtNames = isX ? 'uvue|vue' : 'vue';
|
|
70
73
|
const res = {
|
|
71
74
|
options,
|
|
@@ -79,8 +82,10 @@ function initEasycoms(inputDir, { dirs, platform, isX, }) {
|
|
|
79
82
|
}),
|
|
80
83
|
refresh() {
|
|
81
84
|
res.options = initEasycomOptions();
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
if (process.env.UNI_COMPILE_TARGET !== 'ext-api') {
|
|
86
|
+
initEasycom(res.options);
|
|
87
|
+
initUTSEasycom();
|
|
88
|
+
}
|
|
84
89
|
},
|
|
85
90
|
easycoms,
|
|
86
91
|
};
|
|
@@ -186,11 +191,13 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
|
186
191
|
return easycoms;
|
|
187
192
|
}
|
|
188
193
|
const is_uni_modules = path_1.default.basename(path_1.default.resolve(dir, '../..')) === 'uni_modules';
|
|
189
|
-
const
|
|
194
|
+
const is_easycom_encrypt_uni_modules = // uni_modules模式不需要此逻辑
|
|
190
195
|
process.env.UNI_COMPILE_TARGET !== 'uni_modules' &&
|
|
191
196
|
is_uni_modules &&
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
// 前端加密插件,不能包含utssdk目录
|
|
198
|
+
fs_1.default.existsSync(path_1.default.resolve(dir, '../encrypt')) &&
|
|
199
|
+
!fs_1.default.existsSync(path_1.default.resolve(dir, '../utssdk'));
|
|
200
|
+
const uni_modules_plugin_id = is_easycom_encrypt_uni_modules && path_1.default.basename(path_1.default.resolve(dir, '..'));
|
|
194
201
|
fs_1.default.readdirSync(dir).forEach((name) => {
|
|
195
202
|
const folder = path_1.default.resolve(dir, name);
|
|
196
203
|
if (!isDir(folder)) {
|
|
@@ -202,7 +209,7 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
|
202
209
|
for (let i = 0; i < extensions.length; i++) {
|
|
203
210
|
const ext = extensions[i];
|
|
204
211
|
if (files.includes(name + ext)) {
|
|
205
|
-
easycoms[`^${name}$`] =
|
|
212
|
+
easycoms[`^${name}$`] = is_easycom_encrypt_uni_modules
|
|
206
213
|
? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${
|
|
207
214
|
// android 走 proxy
|
|
208
215
|
process.env.UNI_APP_X === 'true' &&
|
package/dist/env/define.js
CHANGED
|
@@ -8,6 +8,7 @@ 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
|
+
process.env['UNI_APP_ID'] = manifestJson.appid;
|
|
11
12
|
return {
|
|
12
13
|
...initCustomDefine(),
|
|
13
14
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
package/dist/hbx/log.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export declare function formatAtFilename(filename: string, line?: number, column
|
|
|
4
4
|
export declare const h5ServeFormatter: Formatter;
|
|
5
5
|
export declare const removeInfoFormatter: Formatter;
|
|
6
6
|
export declare const removeWarnFormatter: Formatter;
|
|
7
|
+
export declare const removeDuplicatePluginFormatter: Formatter;
|
|
7
8
|
export declare const errorFormatter: Formatter<LogErrorOptions>;
|
package/dist/hbx/log.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.errorFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
|
|
6
|
+
exports.errorFormatter = exports.removeDuplicatePluginFormatter = exports.removeWarnFormatter = exports.removeInfoFormatter = exports.h5ServeFormatter = exports.formatAtFilename = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
@@ -44,7 +44,10 @@ if (typeof console !== 'undefined') {
|
|
|
44
44
|
// overridedConsole('error', console.error, ZERO_WIDTH_CHAR.ERROR)
|
|
45
45
|
}
|
|
46
46
|
function formatAtFilename(filename, line, column) {
|
|
47
|
-
|
|
47
|
+
filename = filename.replace('\x00', '').split('?')[0];
|
|
48
|
+
const file = process.env.UNI_INPUT_DIR
|
|
49
|
+
? path_1.default.relative(process.env.UNI_INPUT_DIR, filename)
|
|
50
|
+
: filename;
|
|
48
51
|
return `at ${picocolors_1.default.cyan((0, utils_1.normalizePath)(file === 'pages-json-uts' ? 'pages.json' : file) +
|
|
49
52
|
':' +
|
|
50
53
|
(line || 1) +
|
|
@@ -100,6 +103,20 @@ exports.removeWarnFormatter = {
|
|
|
100
103
|
return '';
|
|
101
104
|
},
|
|
102
105
|
};
|
|
106
|
+
exports.removeDuplicatePluginFormatter = {
|
|
107
|
+
test() {
|
|
108
|
+
return true;
|
|
109
|
+
},
|
|
110
|
+
format(msg) {
|
|
111
|
+
// [plugin:vite:vue] [plugin vite:vue]
|
|
112
|
+
// 正则匹配获取第一个插件名称,然后移除 [plugin vite:vue]
|
|
113
|
+
const pluginName = msg.match(/\[plugin\s([^\]]+)\]/)?.[1];
|
|
114
|
+
if (pluginName) {
|
|
115
|
+
return msg.replace(`[plugin ${pluginName}]`, '');
|
|
116
|
+
}
|
|
117
|
+
return msg;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
103
120
|
exports.errorFormatter = {
|
|
104
121
|
test(_, opts) {
|
|
105
122
|
return !!(opts && opts.error);
|
|
@@ -110,32 +127,46 @@ exports.errorFormatter = {
|
|
|
110
127
|
};
|
|
111
128
|
function buildErrorMessage(err, args = [], includeStack = true) {
|
|
112
129
|
if (err.plugin) {
|
|
113
|
-
|
|
114
|
-
if (err.message.
|
|
115
|
-
|
|
116
|
-
err.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
130
|
+
// 避免出现这样的错误:[plugin:vite:vue] [plugin vite:vue]
|
|
131
|
+
if (err.message.startsWith(`[plugin ${err.plugin}]`)) {
|
|
132
|
+
let msg = err.message.replace(`[plugin ${err.plugin}]`, '');
|
|
133
|
+
if (err.loc) {
|
|
134
|
+
// [plugin:vite:vue] pages/index/index.vue (2:12): v-on="" is not supported
|
|
135
|
+
const locStr = `(${err.loc.line}:${err.loc.column}):`;
|
|
136
|
+
if (msg.includes(locStr)) {
|
|
137
|
+
msg = msg.split(locStr)[1];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(msg)}`);
|
|
120
141
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
else {
|
|
143
|
+
const otherMsgs = [];
|
|
144
|
+
if (err.message.includes(': [plugin ')) {
|
|
145
|
+
const messages = err.message.split(': [plugin ');
|
|
146
|
+
err.message = messages[0];
|
|
147
|
+
messages.slice(1).forEach((msg) => {
|
|
148
|
+
otherMsgs.push(`[plugin:${msg}`);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
|
|
152
|
+
args.push(...otherMsgs);
|
|
153
|
+
if (err.loc &&
|
|
154
|
+
err.hook === 'transform' &&
|
|
155
|
+
err.plugin === 'rollup-plugin-dynamic-import-variables' &&
|
|
156
|
+
err.id &&
|
|
157
|
+
constants_1.EXTNAME_VUE_RE.test(err.id)) {
|
|
158
|
+
try {
|
|
159
|
+
const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
|
|
160
|
+
const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
|
|
161
|
+
if (scriptNode) {
|
|
162
|
+
const scriptLoc = scriptNode.loc;
|
|
163
|
+
args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
|
|
164
|
+
// correct error location
|
|
165
|
+
err.loc.line = scriptLoc.start.line + err.loc.line - 1;
|
|
166
|
+
}
|
|
136
167
|
}
|
|
168
|
+
catch (e) { }
|
|
137
169
|
}
|
|
138
|
-
catch (e) { }
|
|
139
170
|
}
|
|
140
171
|
}
|
|
141
172
|
else {
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -14,7 +14,12 @@ const utils_2 = require("../../utils");
|
|
|
14
14
|
const project_1 = require("./project");
|
|
15
15
|
const manifest_1 = require("../manifest");
|
|
16
16
|
const theme_1 = require("../theme");
|
|
17
|
+
const uni_x_1 = require("../uni-x");
|
|
17
18
|
function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
|
|
19
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
20
|
+
// 目前仅对x开放
|
|
21
|
+
(0, uni_x_1.checkPagesJson)(jsonStr, process.env.UNI_INPUT_DIR);
|
|
22
|
+
}
|
|
18
23
|
return parsePagesJson(jsonStr, platform, options);
|
|
19
24
|
}
|
|
20
25
|
exports.parseMiniProgramPagesJson = parseMiniProgramPagesJson;
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -229,7 +229,12 @@ function normalizePageStyle(pageStyle) {
|
|
|
229
229
|
* @returns
|
|
230
230
|
*/
|
|
231
231
|
function normalizeUniAppXAppConfig(pagesJson, manifestJson) {
|
|
232
|
-
|
|
232
|
+
const uniConfig = (0, uniConfig_1.normalizeAppXUniConfig)(pagesJson, manifestJson);
|
|
233
|
+
const tabBar = uniConfig.tabBar;
|
|
234
|
+
delete uniConfig.tabBar;
|
|
235
|
+
return `const __uniConfig = ${JSON.stringify(uniConfig)};
|
|
236
|
+
__uniConfig.getTabBarConfig = () => {return ${tabBar ? JSON.stringify(tabBar) : 'undefined'}};
|
|
237
|
+
__uniConfig.tabBar = __uniConfig.getTabBarConfig();
|
|
233
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));
|
|
234
239
|
|
|
235
240
|
`;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
interface AppXUniConfig {
|
|
2
|
+
pages: unknown[];
|
|
3
|
+
globalStyle: unknown;
|
|
4
|
+
appname: string;
|
|
5
|
+
compilerVersion: string;
|
|
6
|
+
fallbackLocale: unknown;
|
|
7
|
+
tabBar: unknown;
|
|
8
|
+
entryPagePath: string;
|
|
9
|
+
entryPageQuery?: string;
|
|
10
|
+
conditionUrl?: string;
|
|
11
|
+
realEntryPagePath?: string;
|
|
12
|
+
themeConfig?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare function normalizeAppXUniConfig(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): AppXUniConfig;
|
|
15
|
+
export {};
|
package/dist/logs/format.js
CHANGED
|
@@ -83,6 +83,7 @@ function formatWarnMsg(msg, options) {
|
|
|
83
83
|
options.timestamp = false;
|
|
84
84
|
}
|
|
85
85
|
initWarnFormattersOnce();
|
|
86
|
+
msg = log_1.removeDuplicatePluginFormatter.format(msg);
|
|
86
87
|
const formatter = warnFormatters.find(({ test }) => test(msg, options));
|
|
87
88
|
if (formatter) {
|
|
88
89
|
return formatter.format(msg, options);
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -53,8 +53,17 @@ export interface MiniProgramCompilerOptions {
|
|
|
53
53
|
};
|
|
54
54
|
filter?: {
|
|
55
55
|
lang: string;
|
|
56
|
+
/**
|
|
57
|
+
* 是否支持 setStyle
|
|
58
|
+
*/
|
|
59
|
+
setStyle?: boolean;
|
|
60
|
+
generate?: Parameters<typeof findMiniProgramTemplateFiles>[0];
|
|
56
61
|
};
|
|
57
62
|
component?: {
|
|
63
|
+
/**
|
|
64
|
+
* 是否支持 :host 伪类
|
|
65
|
+
*/
|
|
66
|
+
':host'?: boolean;
|
|
58
67
|
/**
|
|
59
68
|
* 平台自定义组件目录,如 wxcomponents
|
|
60
69
|
*/
|
package/dist/uni_modules.js
CHANGED
|
@@ -150,12 +150,12 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
|
|
|
150
150
|
platform !== 'app-android' &&
|
|
151
151
|
platform !== 'app-ios' &&
|
|
152
152
|
platform !== 'app-harmony') {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
else if (
|
|
157
|
-
|
|
158
|
-
}
|
|
153
|
+
// uts2js 已经处理了类型信息,无需再处理,否则还要考虑各种文件后缀,比如.ts,.js
|
|
154
|
+
// if (fs.existsSync(platformIndexFileName)) {
|
|
155
|
+
// source = `${source}/utssdk/${platform}/index.uts`
|
|
156
|
+
// } else if (fs.existsSync(rootIndexFileName)) {
|
|
157
|
+
// source = `${source}/utssdk/index.uts`
|
|
158
|
+
// }
|
|
159
159
|
}
|
|
160
160
|
else if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
|
|
161
161
|
if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-js', 'index.uts'))) {
|
package/dist/vite/autoImport.js
CHANGED
|
@@ -84,6 +84,10 @@ const uniH5Preset = {
|
|
|
84
84
|
'UniPickerElement',
|
|
85
85
|
],
|
|
86
86
|
};
|
|
87
|
+
const uniMiniProgramPreset = {
|
|
88
|
+
from: 'vue',
|
|
89
|
+
imports: ['UniElement', 'UniElementImpl'],
|
|
90
|
+
};
|
|
87
91
|
const cloudPreset = {
|
|
88
92
|
'@dcloudio/uni-cloud': ['uniCloud', 'UniCloudError'],
|
|
89
93
|
};
|
|
@@ -160,6 +164,9 @@ function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
|
|
|
160
164
|
if (platform === 'web') {
|
|
161
165
|
autoImport.push(uniH5Preset);
|
|
162
166
|
}
|
|
167
|
+
else if (platform.startsWith('mp-')) {
|
|
168
|
+
autoImport.push(uniMiniProgramPreset);
|
|
169
|
+
}
|
|
163
170
|
return {
|
|
164
171
|
...userOptions,
|
|
165
172
|
include: [/\.[u]?ts$/, /\.[u]?vue/],
|
|
@@ -10,6 +10,7 @@ export * from './uts/uvue';
|
|
|
10
10
|
export * from './uts/ext-api';
|
|
11
11
|
export * from './easycom';
|
|
12
12
|
export * from './json';
|
|
13
|
+
export * from './pre';
|
|
13
14
|
export { uniViteSfcSrcImportPlugin } from './sfc';
|
|
14
15
|
export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
|
|
15
16
|
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, rewriteScssReadFileSync, getCssDepMap, } from './vitejs/plugins/css';
|
|
@@ -27,6 +27,7 @@ __exportStar(require("./uts/uvue"), exports);
|
|
|
27
27
|
__exportStar(require("./uts/ext-api"), exports);
|
|
28
28
|
__exportStar(require("./easycom"), exports);
|
|
29
29
|
__exportStar(require("./json"), exports);
|
|
30
|
+
__exportStar(require("./pre"), exports);
|
|
30
31
|
var sfc_1 = require("./sfc");
|
|
31
32
|
Object.defineProperty(exports, "uniViteSfcSrcImportPlugin", { enumerable: true, get: function () { return sfc_1.uniViteSfcSrcImportPlugin; } });
|
|
32
33
|
var asset_1 = require("./vitejs/plugins/asset");
|
|
@@ -0,0 +1,59 @@
|
|
|
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.uniPrePlugin = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const debug_1 = __importDefault(require("debug"));
|
|
9
|
+
const pluginutils_1 = require("@rollup/pluginutils");
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
|
+
const preprocess_1 = require("../../preprocess");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const debugPreJs = (0, debug_1.default)('uni:pre-js');
|
|
14
|
+
const debugPreHtml = (0, debug_1.default)('uni:pre-html');
|
|
15
|
+
// const debugPreJsTry = debug('uni:pre-js-try')
|
|
16
|
+
function uniPrePlugin(config, options) {
|
|
17
|
+
const isX = process.env.UNI_APP_X === 'true';
|
|
18
|
+
const PRE_JS_EXTNAME = ['.json', '.css']
|
|
19
|
+
.concat(isX ? constants_1.X_EXTNAME_VUE : constants_1.EXTNAME_VUE)
|
|
20
|
+
.concat(constants_1.EXTNAME_JS); // 因为 1.0 也会使用 uts uni_modules,所以 EXTNAME_JS 直接包含了 .uts 后缀
|
|
21
|
+
const PRE_HTML_EXTNAME = isX ? constants_1.X_EXTNAME_VUE : constants_1.EXTNAME_VUE;
|
|
22
|
+
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
23
|
+
const isNVue = config.nvue;
|
|
24
|
+
const preJsFile = isNVue ? preprocess_1.preNVueJs : preprocess_1.preJs;
|
|
25
|
+
const preHtmlFile = isNVue ? preprocess_1.preNVueHtml : preprocess_1.preHtml;
|
|
26
|
+
return {
|
|
27
|
+
name: 'uni:pre',
|
|
28
|
+
transform(code, id) {
|
|
29
|
+
if (!filter(id)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const { filename, query } = (0, utils_1.parseVueRequest)(id);
|
|
33
|
+
const extname = path_1.default.extname(filename);
|
|
34
|
+
const isHtml = query.type === 'template' || PRE_HTML_EXTNAME.includes(extname);
|
|
35
|
+
const isJs = PRE_JS_EXTNAME.includes(extname);
|
|
36
|
+
const isPre = isHtml || isJs;
|
|
37
|
+
if (isPre) {
|
|
38
|
+
// debugPreJsTry(id)
|
|
39
|
+
}
|
|
40
|
+
const hasEndif = isPre && code.includes('#endif');
|
|
41
|
+
if (!hasEndif) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (isHtml) {
|
|
45
|
+
code = preHtmlFile(code);
|
|
46
|
+
debugPreHtml(id);
|
|
47
|
+
}
|
|
48
|
+
if (isJs) {
|
|
49
|
+
code = preJsFile(code);
|
|
50
|
+
debugPreJs(id);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
code,
|
|
54
|
+
map: (0, utils_1.withSourcemap)(config) ? this.getCombinedSourcemap() : null,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.uniPrePlugin = uniPrePlugin;
|
|
@@ -10,6 +10,7 @@ interface UniUTSPluginOptions {
|
|
|
10
10
|
isSingleThread?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare function getCurrentCompiledUTSPlugins(): Set<string>;
|
|
13
|
+
export declare function getCurrentCompiledUTSProviders(): Set<string>;
|
|
13
14
|
export declare function uniUTSAppUniModulesPlugin(options?: UniUTSPluginOptions): Plugin;
|
|
14
15
|
export declare function buildUniExtApis(): Promise<void>;
|
|
15
16
|
export declare function resolveExtApiProvider(pkg: Record<string, any>): {
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSAppUniModulesPlugin = exports.getCurrentCompiledUTSPlugins = exports.createAppHarmonyUniModulesSyncFilePreprocessorOnce = exports.createAppIosUniModulesSyncFilePreprocessorOnce = exports.createAppAndroidUniModulesSyncFilePreprocessorOnce = exports.rewriteUniModulesConsoleExpr = void 0;
|
|
6
|
+
exports.uniDecryptUniModulesPlugin = exports.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSAppUniModulesPlugin = exports.getCurrentCompiledUTSProviders = exports.getCurrentCompiledUTSPlugins = exports.createAppHarmonyUniModulesSyncFilePreprocessorOnce = exports.createAppIosUniModulesSyncFilePreprocessorOnce = exports.createAppAndroidUniModulesSyncFilePreprocessorOnce = exports.rewriteUniModulesConsoleExpr = void 0;
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
@@ -60,7 +60,7 @@ function createUniModulesSyncFilePreprocessor(platform, utsPlatform, isX) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
else if (extname === '.uts' || extname === '.ts') {
|
|
63
|
-
return rewriteUniModulesConsoleExpr(fileName, preJs(content));
|
|
63
|
+
return replaceExtApiPages(rewriteUniModulesConsoleExpr(fileName, preJs(content)));
|
|
64
64
|
}
|
|
65
65
|
else if (extname === '.uvue' || extname === '.vue') {
|
|
66
66
|
return rewriteUniModulesConsoleExpr(fileName, preJs(preHtml(content)));
|
|
@@ -68,6 +68,16 @@ function createUniModulesSyncFilePreprocessor(platform, utsPlatform, isX) {
|
|
|
68
68
|
return content;
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
+
function replaceExtApiPages(code) {
|
|
72
|
+
// 定制实现
|
|
73
|
+
if (process.env.UNI_COMPILE_EXT_API_PAGES) {
|
|
74
|
+
const pages = JSON.parse(process.env.UNI_COMPILE_EXT_API_PAGES);
|
|
75
|
+
Object.keys(pages).forEach((page) => {
|
|
76
|
+
code = code.replaceAll(page, pages[page]);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return code;
|
|
80
|
+
}
|
|
71
81
|
function createAppAndroidUniModulesSyncFilePreprocessorOnce(isX) {
|
|
72
82
|
return isX
|
|
73
83
|
? createUniXAppAndroidUniModulesSyncFilePreprocessorOnce()
|
|
@@ -106,10 +116,15 @@ const createUniXAppHarmonyUniModulesSyncFilePreprocessorOnce = (0, uni_shared_1.
|
|
|
106
116
|
});
|
|
107
117
|
const utsModuleCaches = new Map();
|
|
108
118
|
const utsPlugins = new Set();
|
|
119
|
+
const utsProviders = new Set();
|
|
109
120
|
function getCurrentCompiledUTSPlugins() {
|
|
110
121
|
return utsPlugins;
|
|
111
122
|
}
|
|
112
123
|
exports.getCurrentCompiledUTSPlugins = getCurrentCompiledUTSPlugins;
|
|
124
|
+
function getCurrentCompiledUTSProviders() {
|
|
125
|
+
return utsProviders;
|
|
126
|
+
}
|
|
127
|
+
exports.getCurrentCompiledUTSProviders = getCurrentCompiledUTSProviders;
|
|
113
128
|
let uniExtApiCompiler = async () => { };
|
|
114
129
|
function emptyCacheDir(platform) {
|
|
115
130
|
const uvueOutputDir = (0, uts_1.uvueOutDir)(platform);
|
|
@@ -304,6 +319,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
304
319
|
});
|
|
305
320
|
};
|
|
306
321
|
uniExtApiCompiler = async () => {
|
|
322
|
+
// 此方法为兜底方法,确保uni_modules中的所有插件都会编译,目前仅用于编译provider
|
|
307
323
|
// 获取 provider 扩展(编译所有uni)
|
|
308
324
|
const plugins = (0, uni_modules_1.getUniExtApiPlugins)().filter((provider) => !utsPlugins.has(provider.plugin));
|
|
309
325
|
for (const plugin of plugins) {
|
|
@@ -321,6 +337,7 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
321
337
|
continue;
|
|
322
338
|
}
|
|
323
339
|
}
|
|
340
|
+
utsProviders.add(plugin.plugin);
|
|
324
341
|
const result = await compilePlugin(pluginDir);
|
|
325
342
|
if (result) {
|
|
326
343
|
// 时机不对,不能addWatch
|
package/dist/vite/utils/utils.js
CHANGED
|
@@ -7,7 +7,7 @@ const utils_1 = require("../plugins/vitejs/utils");
|
|
|
7
7
|
const utils_2 = require("../../utils");
|
|
8
8
|
function withSourcemap(config) {
|
|
9
9
|
if (!process.env.UNI_APP_SOURCEMAP) {
|
|
10
|
-
if ((0, shared_1.hasOwn)(config.build, 'sourcemap')) {
|
|
10
|
+
if (config.build && (0, shared_1.hasOwn)(config.build, 'sourcemap')) {
|
|
11
11
|
if (!!config.build.sourcemap) {
|
|
12
12
|
process.env.UNI_APP_SOURCEMAP = 'true';
|
|
13
13
|
}
|
|
@@ -13,3 +13,5 @@ export declare const transformH5BuiltInComponents: import("@vue/compiler-core").
|
|
|
13
13
|
export declare const transformMatchMedia: import("@vue/compiler-core").NodeTransform;
|
|
14
14
|
export declare const transformTapToClick: import("@vue/compiler-core").NodeTransform;
|
|
15
15
|
export declare const transformComponentLink: (node: import("@vue/compiler-core").RootNode | import("@vue/compiler-core").TemplateChildNode, context: import("@vue/compiler-core").TransformContext) => void;
|
|
16
|
+
export * from './x/transformMPBuiltInTag';
|
|
17
|
+
export * from './x/transformDirection';
|
|
@@ -53,3 +53,5 @@ exports.transformTapToClick = (0, transformEvent_1.createTransformEvent)({
|
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
exports.transformComponentLink = (0, transformComponent_1.createTransformComponentLink)(constants_1.COMPONENT_BIND_LINK);
|
|
56
|
+
__exportStar(require("./x/transformMPBuiltInTag"), exports);
|
|
57
|
+
__exportStar(require("./x/transformDirection"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RootNode, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
|
|
2
|
+
/**
|
|
3
|
+
* 将direction属性转化为scroll-x和scroll-y
|
|
4
|
+
* 注意transformMPBuiltInTag内会讲list-view转化为scroll-view,所以此transform应该在transformMPBuiltInTag之后执行
|
|
5
|
+
*/
|
|
6
|
+
export declare const transformDirection: (node: RootNode | TemplateChildNode, context: TransformContext) => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformDirection = void 0;
|
|
4
|
+
const vite_1 = require("../../../vite");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
7
|
+
/**
|
|
8
|
+
* 将direction属性转化为scroll-x和scroll-y
|
|
9
|
+
* 注意transformMPBuiltInTag内会讲list-view转化为scroll-view,所以此transform应该在transformMPBuiltInTag之后执行
|
|
10
|
+
*/
|
|
11
|
+
const transformDirection = function (node, context) {
|
|
12
|
+
if (!(0, vite_1.isElementNode)(node)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (node.tag !== 'scroll-view') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const directionPropIndex = node.props.findIndex((prop) => (0, utils_1.isPropNameEquals)(prop, 'direction'));
|
|
19
|
+
const scrollXPropIndex = node.props.findIndex((prop) => (0, utils_1.isPropNameEquals)(prop, 'scrollX'));
|
|
20
|
+
const scrollYPropIndex = node.props.findIndex((prop) => (0, utils_1.isPropNameEquals)(prop, 'scrollY'));
|
|
21
|
+
if (directionPropIndex === -1 ||
|
|
22
|
+
(scrollXPropIndex !== -1 && scrollYPropIndex !== -1)) {
|
|
23
|
+
node.props.push((0, utils_1.createAttributeNode)('scroll-y', 'true'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const directionProp = node.props[directionPropIndex];
|
|
27
|
+
if (directionProp.type === compiler_core_1.NodeTypes.ATTRIBUTE) {
|
|
28
|
+
const directionValue = directionProp.value?.content;
|
|
29
|
+
const scrollX = directionValue === 'horizontal' || directionValue === 'all';
|
|
30
|
+
const scrollY = !directionValue ||
|
|
31
|
+
directionValue === 'vertical' ||
|
|
32
|
+
directionValue === 'all';
|
|
33
|
+
node.props.splice(directionPropIndex, 1);
|
|
34
|
+
scrollX && node.props.push((0, utils_1.createAttributeNode)('scroll-x', '' + scrollX));
|
|
35
|
+
scrollY && node.props.push((0, utils_1.createAttributeNode)('scroll-y', '' + scrollY));
|
|
36
|
+
}
|
|
37
|
+
else if (directionProp.type === compiler_core_1.NodeTypes.DIRECTIVE) {
|
|
38
|
+
if (!directionProp.arg ||
|
|
39
|
+
!(0, compiler_core_1.isStaticExp)(directionProp.arg) ||
|
|
40
|
+
!directionProp.exp ||
|
|
41
|
+
!(0, compiler_core_1.isStaticExp)(directionProp.exp)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const exp = directionProp.exp.content;
|
|
45
|
+
const scrollX = `(${exp}) === 'horizontal' || (${exp}) === 'all'`;
|
|
46
|
+
const scrollY = `!(${exp}) || (${exp}) === 'vertical' || (${exp}) === 'all'`;
|
|
47
|
+
node.props.splice(directionPropIndex, 1);
|
|
48
|
+
scrollX && node.props.push((0, utils_1.createBindDirectiveNode)('scroll-x', scrollX));
|
|
49
|
+
scrollY && node.props.push((0, utils_1.createBindDirectiveNode)('scroll-y', scrollY));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
exports.transformDirection = transformDirection;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RootNode, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
|
|
2
|
+
export interface TransformMPBuiltInTagOptions {
|
|
3
|
+
propRename?: Record<string, Record<string, string>>;
|
|
4
|
+
propAdd?: Record<string, {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[]>;
|
|
8
|
+
tagRename?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare const defaultTransformMPBuiltInTagOptions: TransformMPBuiltInTagOptions;
|
|
11
|
+
export declare function createMPBuiltInTagTransform(options: TransformMPBuiltInTagOptions): (node: RootNode | TemplateChildNode, context: TransformContext) => void;
|
|
12
|
+
export declare const transformMPBuiltInTag: (node: RootNode | TemplateChildNode, context: TransformContext) => void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformMPBuiltInTag = exports.createMPBuiltInTagTransform = exports.defaultTransformMPBuiltInTagOptions = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const vite_1 = require("../../../vite");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
8
|
+
exports.defaultTransformMPBuiltInTagOptions = {
|
|
9
|
+
propRename: {
|
|
10
|
+
checkbox: {
|
|
11
|
+
// "backgroundColor": "",
|
|
12
|
+
// "borderColor": "",
|
|
13
|
+
// "activeBackgroundColor": "",
|
|
14
|
+
// "activeBorderColor": "",
|
|
15
|
+
foreColor: 'color',
|
|
16
|
+
},
|
|
17
|
+
radio: {
|
|
18
|
+
// "backgroundColor": "",
|
|
19
|
+
// "borderColor": "",
|
|
20
|
+
activeBackgroundColor: 'color',
|
|
21
|
+
// "activeBorderColor": "",
|
|
22
|
+
// "foreColor": ""
|
|
23
|
+
},
|
|
24
|
+
slider: {
|
|
25
|
+
backgroundColor: 'backgroundColor',
|
|
26
|
+
activeBackgroundColor: 'activeColor',
|
|
27
|
+
foreColor: 'block-color',
|
|
28
|
+
},
|
|
29
|
+
switch: {
|
|
30
|
+
// "backgroundColor": "",
|
|
31
|
+
activeBackgroundColor: 'color',
|
|
32
|
+
// "foreColor": "",
|
|
33
|
+
// "activeForeColor": ""
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
propAdd: {
|
|
37
|
+
canvas: [
|
|
38
|
+
{
|
|
39
|
+
name: 'type',
|
|
40
|
+
value: '2d',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
'scroll-view': [
|
|
44
|
+
{
|
|
45
|
+
name: 'enable-flex',
|
|
46
|
+
value: 'true',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
tagRename: {
|
|
51
|
+
'list-view': 'scroll-view',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
function createMPBuiltInTagTransform(options) {
|
|
55
|
+
return function (node, context) {
|
|
56
|
+
if (!(0, vite_1.isElementNode)(node)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (options.tagRename && node.tag in options.tagRename) {
|
|
60
|
+
node.tag = options.tagRename[node.tag];
|
|
61
|
+
}
|
|
62
|
+
if (options.propRename && node.tag in options.propRename) {
|
|
63
|
+
const propMap = options.propRename[node.tag];
|
|
64
|
+
node.props.forEach((prop) => {
|
|
65
|
+
if (prop.type === compiler_core_1.NodeTypes.ATTRIBUTE) {
|
|
66
|
+
const propName = (0, shared_1.camelize)(prop.name);
|
|
67
|
+
if (propName in propMap && propMap[propName]) {
|
|
68
|
+
(0, utils_1.renameProp)(propMap[propName], prop);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (prop.type === compiler_core_1.NodeTypes.DIRECTIVE) {
|
|
72
|
+
if (!prop.rawName || !prop.arg || !(0, compiler_core_1.isStaticExp)(prop.arg)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const propName = (0, shared_1.camelize)(prop.rawName.slice(1));
|
|
76
|
+
if (propName in propMap && propMap[propName]) {
|
|
77
|
+
(0, utils_1.renameProp)(propMap[propName], prop);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (options.propAdd && node.tag in options.propAdd) {
|
|
83
|
+
const add = options.propAdd[node.tag];
|
|
84
|
+
add.forEach(({ name, value }) => {
|
|
85
|
+
if (node.props.some((item) => (0, utils_1.isPropNameEquals)(item, name))) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
node.props.push((0, utils_1.createAttributeNode)(name, value));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.createMPBuiltInTagTransform = createMPBuiltInTagTransform;
|
|
94
|
+
exports.transformMPBuiltInTag = createMPBuiltInTagTransform(exports.defaultTransformMPBuiltInTagOptions);
|
package/dist/vue/utils.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare function createUniVueTransformAssetUrls(base: string): {
|
|
|
29
29
|
};
|
|
30
30
|
export declare function getBaseNodeTransforms(base: string): import("@vue/compiler-core").NodeTransform[];
|
|
31
31
|
export declare function renameProp(name: string, prop?: DirectiveNode | AttributeNode): void;
|
|
32
|
+
export declare function isPropNameEquals(prop: AttributeNode | DirectiveNode, name: string): boolean;
|
|
32
33
|
export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
|
|
33
34
|
export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
34
35
|
export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
|
package/dist/vue/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.advancePositionWithMutation = exports.advancePositionWithClone = exports.getInnerRange = exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
3
|
+
exports.advancePositionWithMutation = exports.advancePositionWithClone = exports.getInnerRange = exports.isPropNameEquals = exports.renameProp = exports.getBaseNodeTransforms = exports.createUniVueTransformAssetUrls = exports.createBindDirectiveNode = exports.createOnDirectiveNode = exports.createDirectiveNode = exports.addStaticClass = exports.createAttributeNode = exports.isUserComponent = exports.isVueSfcFile = exports.VUE_REF_IN_FOR = exports.VUE_REF = void 0;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
5
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
6
6
|
const compiler_core_1 = require("@vue/compiler-core");
|
|
@@ -119,6 +119,18 @@ function renameProp(name, prop) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
exports.renameProp = renameProp;
|
|
122
|
+
function isPropNameEquals(prop, name) {
|
|
123
|
+
if (prop.type === compiler_core_1.NodeTypes.ATTRIBUTE) {
|
|
124
|
+
const propName = (0, shared_1.camelize)(prop.name);
|
|
125
|
+
return propName === name;
|
|
126
|
+
}
|
|
127
|
+
else if (prop.type === compiler_core_1.NodeTypes.DIRECTIVE && prop.rawName) {
|
|
128
|
+
const propName = (0, shared_1.camelize)(prop.rawName.slice(1));
|
|
129
|
+
return propName === name;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
exports.isPropNameEquals = isPropNameEquals;
|
|
122
134
|
// @vue/compiler-core 没有导出 getLoc,先使用旧版本的 getInnerRange
|
|
123
135
|
function getInnerRange(loc, offset, length) {
|
|
124
136
|
const source = loc.source.slice(offset, offset + length);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-4030420241120001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
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-alpha-
|
|
30
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
29
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-4030420241120001",
|
|
30
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-4030420241120001",
|
|
31
31
|
"@intlify/core-base": "9.1.9",
|
|
32
32
|
"@intlify/shared": "9.1.9",
|
|
33
33
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
74
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4030420241120001",
|
|
75
75
|
"@types/adm-zip": "^0.5.5",
|
|
76
76
|
"@types/babel__code-frame": "^7.0.6",
|
|
77
77
|
"@types/babel__core": "^7.1.19",
|