@dcloudio/uni-cli-shared 3.0.0-alpha-3061420221216001 → 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 +26 -10
- package/dist/json/mp/pages.js +1 -1
- package/dist/json/pages.js +1 -1
- package/dist/uts.d.ts +2 -0
- package/dist/uts.js +64 -1
- package/package.json +4 -4
package/dist/easycom.d.ts
CHANGED
package/dist/easycom.js
CHANGED
|
@@ -13,6 +13,7 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const pages_1 = require("./json/pages");
|
|
15
15
|
const messages_1 = require("./messages");
|
|
16
|
+
const uts_1 = require("./uts");
|
|
16
17
|
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
|
17
18
|
const easycoms = [];
|
|
18
19
|
const easycomsCache = new Map();
|
|
@@ -45,18 +46,33 @@ function initEasycoms(inputDir, { dirs, platform }) {
|
|
|
45
46
|
return easycomOptions;
|
|
46
47
|
};
|
|
47
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
|
+
};
|
|
48
60
|
initEasycom(options);
|
|
61
|
+
initUTSEasycom();
|
|
49
62
|
const res = {
|
|
50
63
|
options,
|
|
51
64
|
filter: (0, pluginutils_1.createFilter)([
|
|
52
65
|
'components/*/*.(vue|jsx|tsx)',
|
|
53
66
|
'uni_modules/*/components/*/*.(vue|jsx|tsx)',
|
|
67
|
+
'utssdk/*/**/*.vue',
|
|
68
|
+
'uni_modules/*/utssdk/*/*.vue',
|
|
54
69
|
], [], {
|
|
55
70
|
resolve: inputDir,
|
|
56
71
|
}),
|
|
57
72
|
refresh() {
|
|
58
73
|
res.options = initEasycomOptions();
|
|
59
74
|
initEasycom(res.options);
|
|
75
|
+
initUTSEasycom();
|
|
60
76
|
},
|
|
61
77
|
easycoms,
|
|
62
78
|
};
|
|
@@ -157,28 +173,28 @@ function initAutoScanEasycoms(dirs, rootDir, extensions) {
|
|
|
157
173
|
const curEasycoms = initAutoScanEasycom(dir, rootDir, extensions);
|
|
158
174
|
Object.keys(curEasycoms).forEach((name) => {
|
|
159
175
|
// Use the first component when name conflict
|
|
160
|
-
const
|
|
161
|
-
if (!
|
|
176
|
+
const componentPath = easycoms[name];
|
|
177
|
+
if (!componentPath) {
|
|
162
178
|
easycoms[name] = curEasycoms[name];
|
|
163
179
|
}
|
|
164
180
|
else {
|
|
165
181
|
;
|
|
166
|
-
(conflict[
|
|
182
|
+
(conflict[componentPath] || (conflict[componentPath] = [])).push(normalizeComponentPath(curEasycoms[name], rootDir));
|
|
167
183
|
}
|
|
168
184
|
});
|
|
169
185
|
return easycoms;
|
|
170
186
|
}, Object.create(null));
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
187
|
+
const conflictComponents = Object.keys(conflict);
|
|
188
|
+
if (conflictComponents.length) {
|
|
173
189
|
console.warn(messages_1.M['easycom.conflict']);
|
|
174
|
-
|
|
175
|
-
console.warn([
|
|
190
|
+
conflictComponents.forEach((com) => {
|
|
191
|
+
console.warn([normalizeComponentPath(com, rootDir), conflict[com]].join(','));
|
|
176
192
|
});
|
|
177
193
|
}
|
|
178
194
|
return res;
|
|
179
195
|
}
|
|
180
|
-
function
|
|
181
|
-
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));
|
|
182
198
|
}
|
|
183
199
|
function addImportDeclaration(importDeclarations, local, source, imported) {
|
|
184
200
|
importDeclarations.push(createImportDeclaration(local, source, imported));
|
|
@@ -187,7 +203,7 @@ function addImportDeclaration(importDeclarations, local, source, imported) {
|
|
|
187
203
|
exports.addImportDeclaration = addImportDeclaration;
|
|
188
204
|
function createImportDeclaration(local, source, imported) {
|
|
189
205
|
if (imported) {
|
|
190
|
-
return `import {${imported} as ${local}} from '${source}';`;
|
|
206
|
+
return `import { ${imported} as ${local} } from '${source}';`;
|
|
191
207
|
}
|
|
192
208
|
return `import ${local} from '${source}';`;
|
|
193
209
|
}
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -114,7 +114,7 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
;
|
|
117
|
-
['preloadRule', 'workers', 'plugins'].forEach((name) => {
|
|
117
|
+
['preloadRule', 'workers', 'plugins', 'entryPagePath'].forEach((name) => {
|
|
118
118
|
if ((0, shared_1.hasOwn)(pagesJson, name)) {
|
|
119
119
|
appJson[name] = pagesJson[name];
|
|
120
120
|
}
|
package/dist/json/pages.js
CHANGED
|
@@ -305,7 +305,7 @@ function normalizeNavigationBar(pageStyle) {
|
|
|
305
305
|
return navigationBar;
|
|
306
306
|
}
|
|
307
307
|
function normalizeNavigationBarButton(btn, type, titleColor) {
|
|
308
|
-
btn.color =
|
|
308
|
+
btn.color = btn.color || titleColor;
|
|
309
309
|
if (!btn.fontSize) {
|
|
310
310
|
btn.fontSize =
|
|
311
311
|
type === 'transparent' || (btn.text && /\\u/.test(btn.text))
|
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",
|