@dcloudio/uni-cli-shared 3.0.0-alpha-3061420221219001 → 3.0.0-alpha-3061520221220001
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/easycom.d.ts +1 -1
- package/dist/easycom.js +39 -82
- package/dist/uts.d.ts +2 -0
- package/dist/uts.js +64 -1
- package/package.json +4 -4
- package/lib/.DS_Store +0 -0
- package/lib/vue-i18n/.DS_Store +0 -0
package/dist/easycom.d.ts
CHANGED
package/dist/easycom.js
CHANGED
|
@@ -7,13 +7,13 @@ exports.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportD
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const debug_1 = __importDefault(require("debug"));
|
|
10
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
11
10
|
const shared_1 = require("@vue/shared");
|
|
12
11
|
const pluginutils_1 = require("@rollup/pluginutils");
|
|
13
12
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
14
13
|
const utils_1 = require("./utils");
|
|
15
14
|
const pages_1 = require("./json/pages");
|
|
16
15
|
const messages_1 = require("./messages");
|
|
16
|
+
const uts_1 = require("./uts");
|
|
17
17
|
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
|
18
18
|
const easycoms = [];
|
|
19
19
|
const easycomsCache = new Map();
|
|
@@ -26,7 +26,6 @@ function clearEasycom() {
|
|
|
26
26
|
}
|
|
27
27
|
function initEasycoms(inputDir, { dirs, platform }) {
|
|
28
28
|
const componentsDir = path_1.default.resolve(inputDir, 'components');
|
|
29
|
-
const utssdkDir = path_1.default.resolve(inputDir, 'utssdk');
|
|
30
29
|
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
31
30
|
const initEasycomOptions = (pagesJson) => {
|
|
32
31
|
// 初始化时,从once中读取缓存,refresh时,实时读取
|
|
@@ -38,17 +37,7 @@ function initEasycoms(inputDir, { dirs, platform }) {
|
|
|
38
37
|
...dirs,
|
|
39
38
|
componentsDir,
|
|
40
39
|
...initUniModulesEasycomDirs(uniModulesDir),
|
|
41
|
-
]
|
|
42
|
-
.concat(platform === 'app'
|
|
43
|
-
? initUniModulesUTSSDKDirs(uniModulesDir)
|
|
44
|
-
: [])
|
|
45
|
-
.concat(platform === 'app' && fs_1.default.existsSync(utssdkDir)
|
|
46
|
-
? fast_glob_1.default.sync('*', {
|
|
47
|
-
cwd: utssdkDir,
|
|
48
|
-
absolute: true,
|
|
49
|
-
onlyDirectories: true,
|
|
50
|
-
})
|
|
51
|
-
: []),
|
|
40
|
+
],
|
|
52
41
|
rootDir: inputDir,
|
|
53
42
|
autoscan: !!(easycom && easycom.autoscan),
|
|
54
43
|
custom: (easycom && easycom.custom) || {},
|
|
@@ -57,7 +46,19 @@ function initEasycoms(inputDir, { dirs, platform }) {
|
|
|
57
46
|
return easycomOptions;
|
|
58
47
|
};
|
|
59
48
|
const options = initEasycomOptions((0, pages_1.parsePagesJsonOnce)(inputDir, platform));
|
|
49
|
+
const initUTSEasycom = () => {
|
|
50
|
+
(0, uts_1.initUTSComponents)(inputDir, platform).forEach((item) => {
|
|
51
|
+
const index = easycoms.findIndex((easycom) => item.pattern.toString() === easycom.pattern.toString());
|
|
52
|
+
if (index > -1) {
|
|
53
|
+
easycoms.splice(index, 1, item);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
easycoms.push(item);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
60
|
initEasycom(options);
|
|
61
|
+
initUTSEasycom();
|
|
61
62
|
const res = {
|
|
62
63
|
options,
|
|
63
64
|
filter: (0, pluginutils_1.createFilter)([
|
|
@@ -71,6 +72,7 @@ function initEasycoms(inputDir, { dirs, platform }) {
|
|
|
71
72
|
refresh() {
|
|
72
73
|
res.options = initEasycomOptions();
|
|
73
74
|
initEasycom(res.options);
|
|
75
|
+
initUTSEasycom();
|
|
74
76
|
},
|
|
75
77
|
easycoms,
|
|
76
78
|
};
|
|
@@ -92,20 +94,6 @@ function initUniModulesEasycomDirs(uniModulesDir) {
|
|
|
92
94
|
})
|
|
93
95
|
.filter(Boolean);
|
|
94
96
|
}
|
|
95
|
-
function initUniModulesUTSSDKDirs(uniModulesDir) {
|
|
96
|
-
if (!fs_1.default.existsSync(uniModulesDir)) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
return fs_1.default
|
|
100
|
-
.readdirSync(uniModulesDir)
|
|
101
|
-
.map((uniModuleDir) => {
|
|
102
|
-
const uniModuleComponentsDir = path_1.default.resolve(uniModulesDir, uniModuleDir, 'utssdk');
|
|
103
|
-
if (fs_1.default.existsSync(uniModuleComponentsDir)) {
|
|
104
|
-
return uniModuleComponentsDir;
|
|
105
|
-
}
|
|
106
|
-
})
|
|
107
|
-
.filter(Boolean);
|
|
108
|
-
}
|
|
109
97
|
function initEasycom({ dirs, rootDir, custom, extensions = ['.vue', '.jsx', '.tsx'], }) {
|
|
110
98
|
clearEasycom();
|
|
111
99
|
const easycomsObj = Object.create(null);
|
|
@@ -161,83 +149,52 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
|
161
149
|
if (!fs_1.default.existsSync(dir)) {
|
|
162
150
|
return easycoms;
|
|
163
151
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (name) {
|
|
180
|
-
const importDir = (0, utils_1.normalizePath)(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
|
|
181
|
-
easycoms[`^${name}$`] = `\0${importDir}?uts-proxy`;
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
fs_1.default.readdirSync(dir).forEach((name) => {
|
|
187
|
-
const folder = path_1.default.resolve(dir, name);
|
|
188
|
-
if (!isDir(folder)) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const importDir = (0, utils_1.normalizePath)(folder);
|
|
192
|
-
const files = fs_1.default.readdirSync(folder);
|
|
193
|
-
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
|
|
194
|
-
for (let i = 0; i < extensions.length; i++) {
|
|
195
|
-
const ext = extensions[i];
|
|
196
|
-
if (files.includes(name + ext)) {
|
|
197
|
-
easycoms[`^${name}$`] = `${importDir}/${name}${ext}`;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
152
|
+
fs_1.default.readdirSync(dir).forEach((name) => {
|
|
153
|
+
const folder = path_1.default.resolve(dir, name);
|
|
154
|
+
if (!isDir(folder)) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const importDir = (0, utils_1.normalizePath)(folder);
|
|
158
|
+
const files = fs_1.default.readdirSync(folder);
|
|
159
|
+
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
|
|
160
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
161
|
+
const ext = extensions[i];
|
|
162
|
+
if (files.includes(name + ext)) {
|
|
163
|
+
easycoms[`^${name}$`] = `${importDir}/${name}${ext}`;
|
|
164
|
+
break;
|
|
200
165
|
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
203
168
|
return easycoms;
|
|
204
169
|
}
|
|
205
|
-
const nameRE = /name\s*:\s*['|"](.*)['|"]/;
|
|
206
|
-
function parseVueComponentName(file) {
|
|
207
|
-
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
208
|
-
const matches = content.match(nameRE);
|
|
209
|
-
if (matches) {
|
|
210
|
-
return matches[1];
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
170
|
function initAutoScanEasycoms(dirs, rootDir, extensions) {
|
|
214
171
|
const conflict = {};
|
|
215
172
|
const res = dirs.reduce((easycoms, dir) => {
|
|
216
173
|
const curEasycoms = initAutoScanEasycom(dir, rootDir, extensions);
|
|
217
174
|
Object.keys(curEasycoms).forEach((name) => {
|
|
218
175
|
// Use the first component when name conflict
|
|
219
|
-
const
|
|
220
|
-
if (!
|
|
176
|
+
const componentPath = easycoms[name];
|
|
177
|
+
if (!componentPath) {
|
|
221
178
|
easycoms[name] = curEasycoms[name];
|
|
222
179
|
}
|
|
223
180
|
else {
|
|
224
181
|
;
|
|
225
|
-
(conflict[
|
|
182
|
+
(conflict[componentPath] || (conflict[componentPath] = [])).push(normalizeComponentPath(curEasycoms[name], rootDir));
|
|
226
183
|
}
|
|
227
184
|
});
|
|
228
185
|
return easycoms;
|
|
229
186
|
}, Object.create(null));
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
187
|
+
const conflictComponents = Object.keys(conflict);
|
|
188
|
+
if (conflictComponents.length) {
|
|
232
189
|
console.warn(messages_1.M['easycom.conflict']);
|
|
233
|
-
|
|
234
|
-
console.warn([
|
|
190
|
+
conflictComponents.forEach((com) => {
|
|
191
|
+
console.warn([normalizeComponentPath(com, rootDir), conflict[com]].join(','));
|
|
235
192
|
});
|
|
236
193
|
}
|
|
237
194
|
return res;
|
|
238
195
|
}
|
|
239
|
-
function
|
|
240
|
-
return (0, utils_1.normalizePath)(path_1.default.relative(rootDir,
|
|
196
|
+
function normalizeComponentPath(componentPath, rootDir) {
|
|
197
|
+
return (0, utils_1.normalizePath)(path_1.default.relative(rootDir, componentPath));
|
|
241
198
|
}
|
|
242
199
|
function addImportDeclaration(importDeclarations, local, source, imported) {
|
|
243
200
|
importDeclarations.push(createImportDeclaration(local, source, imported));
|
package/dist/uts.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as UTSCompiler from '@dcloudio/uni-uts-v1';
|
|
2
|
+
import type { EasycomMatcher } from './easycom';
|
|
2
3
|
/**
|
|
3
4
|
* 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
|
|
4
5
|
* @param id
|
|
@@ -8,3 +9,4 @@ import * as UTSCompiler from '@dcloudio/uni-uts-v1';
|
|
|
8
9
|
export declare function resolveUtsAppModule(id: string, importer: string): string | undefined;
|
|
9
10
|
export declare function resolveUtsModule(id: string, importer: string): string | undefined;
|
|
10
11
|
export declare function resolveUTSCompiler(): typeof UTSCompiler;
|
|
12
|
+
export declare function initUTSComponents(inputDir: string, platform: UniApp.PLATFORM): EasycomMatcher[];
|
package/dist/uts.js
CHANGED
|
@@ -3,9 +3,10 @@ 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.resolveUTSCompiler = exports.resolveUtsModule = exports.resolveUtsAppModule = void 0;
|
|
6
|
+
exports.initUTSComponents = exports.resolveUTSCompiler = exports.resolveUtsModule = exports.resolveUtsAppModule = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
9
10
|
const hbx_1 = require("./hbx");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
/**
|
|
@@ -99,3 +100,65 @@ function resolveUTSCompiler() {
|
|
|
99
100
|
return require(compilerPath);
|
|
100
101
|
}
|
|
101
102
|
exports.resolveUTSCompiler = resolveUTSCompiler;
|
|
103
|
+
function initUTSComponents(inputDir, platform) {
|
|
104
|
+
const components = [];
|
|
105
|
+
if (platform !== 'app' && platform !== 'app-plus') {
|
|
106
|
+
return components;
|
|
107
|
+
}
|
|
108
|
+
const easycomsObj = Object.create(null);
|
|
109
|
+
const dirs = resolveUTSComponentDirs(inputDir);
|
|
110
|
+
dirs.forEach((dir) => {
|
|
111
|
+
const is_uni_modules_utssdk = dir.endsWith('utssdk');
|
|
112
|
+
const is_ussdk = !is_uni_modules_utssdk && path_1.default.dirname(dir).endsWith('utssdk');
|
|
113
|
+
if (is_uni_modules_utssdk || is_ussdk) {
|
|
114
|
+
fast_glob_1.default
|
|
115
|
+
.sync('**/*.vue', {
|
|
116
|
+
cwd: dir,
|
|
117
|
+
absolute: true,
|
|
118
|
+
})
|
|
119
|
+
.forEach((file) => {
|
|
120
|
+
let name = parseVueComponentName(file);
|
|
121
|
+
if (!name) {
|
|
122
|
+
if (file.endsWith('index.vue')) {
|
|
123
|
+
name = path_1.default.basename(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (name) {
|
|
127
|
+
const importDir = (0, utils_1.normalizePath)(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
|
|
128
|
+
easycomsObj[`^${name}$`] = `\0${importDir}?uts-proxy`;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.keys(easycomsObj).forEach((name) => {
|
|
134
|
+
components.push({
|
|
135
|
+
pattern: new RegExp(name),
|
|
136
|
+
replacement: easycomsObj[name],
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return components;
|
|
140
|
+
}
|
|
141
|
+
exports.initUTSComponents = initUTSComponents;
|
|
142
|
+
function resolveUTSComponentDirs(inputDir) {
|
|
143
|
+
const utssdkDir = path_1.default.resolve(inputDir, 'utssdk');
|
|
144
|
+
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
145
|
+
return fast_glob_1.default
|
|
146
|
+
.sync('*', {
|
|
147
|
+
cwd: utssdkDir,
|
|
148
|
+
absolute: true,
|
|
149
|
+
onlyDirectories: true,
|
|
150
|
+
})
|
|
151
|
+
.concat(fast_glob_1.default.sync('*/utssdk', {
|
|
152
|
+
cwd: uniModulesDir,
|
|
153
|
+
absolute: true,
|
|
154
|
+
onlyDirectories: true,
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
const nameRE = /name\s*:\s*['|"](.*)['|"]/;
|
|
158
|
+
function parseVueComponentName(file) {
|
|
159
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
160
|
+
const matches = content.match(nameRE);
|
|
161
|
+
if (matches) {
|
|
162
|
+
return matches[1];
|
|
163
|
+
}
|
|
164
|
+
}
|
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-3061520221220001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@babel/core": "^7.19.6",
|
|
26
26
|
"@babel/parser": "^7.19.6",
|
|
27
27
|
"@babel/types": "^7.20.0",
|
|
28
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
29
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
28
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3061520221220001",
|
|
29
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3061520221220001",
|
|
30
30
|
"@intlify/core-base": "9.1.9",
|
|
31
31
|
"@intlify/shared": "9.1.9",
|
|
32
32
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
67
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-3061520221220001",
|
|
68
68
|
"@types/babel__core": "^7.1.19",
|
|
69
69
|
"@types/debug": "^4.1.7",
|
|
70
70
|
"@types/estree": "^0.0.51",
|
package/lib/.DS_Store
DELETED
|
Binary file
|
package/lib/vue-i18n/.DS_Store
DELETED
|
Binary file
|