@cocos/ccbuild 2.2.0 → 2.2.2
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/modules/build-engine/lib/engine-js/index.d.ts.map +1 -1
- package/modules/build-engine/lib/engine-js/index.js +303 -331
- package/modules/build-engine/lib/engine-js/index.js.map +1 -1
- package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.d.ts +5 -0
- package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.d.ts.map +1 -1
- package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.js +111 -128
- package/modules/build-engine/lib/engine-js/rollup-plugins/external-wasm-loader.js.map +1 -1
- package/modules/build-engine/lib/engine-js/rollup-plugins/module-query-plugin.js +2 -31
- package/modules/build-engine/lib/engine-js/rollup-plugins/module-query-plugin.js.map +1 -1
- package/modules/build-engine/lib/engine-ts/engine-builder.js +416 -461
- package/modules/build-engine/lib/engine-ts/engine-builder.js.map +1 -1
- package/modules/build-engine/lib/engine-ts/index.js +19 -48
- package/modules/build-engine/lib/engine-ts/index.js.map +1 -1
- package/modules/build-engine/lib/engine-ts/plugins/external-wasm-loader.js +31 -64
- package/modules/build-engine/lib/engine-ts/plugins/external-wasm-loader.js.map +1 -1
- package/modules/build-engine/lib/engine-ts/plugins/module-query-plugin.js +5 -34
- package/modules/build-engine/lib/engine-ts/plugins/module-query-plugin.js.map +1 -1
- package/modules/build-engine/lib/engine-ts/plugins/node-module-loader.js +28 -59
- package/modules/build-engine/lib/engine-ts/plugins/node-module-loader.js.map +1 -1
- package/modules/build-engine/lib/index.d.ts +6 -1
- package/modules/build-engine/lib/index.d.ts.map +1 -1
- package/modules/build-engine/lib/index.js +47 -80
- package/modules/build-engine/lib/index.js.map +1 -1
- package/modules/dts-bundler/lib/index.js +236 -265
- package/modules/dts-bundler/lib/index.js.map +1 -1
- package/modules/modularize/lib/module-query.js +153 -198
- package/modules/modularize/lib/module-query.js.map +1 -1
- package/modules/stats-query/lib/index.js +47 -80
- package/modules/stats-query/lib/index.js.map +1 -1
- package/modules/utils/lib/path.js +8 -37
- package/modules/utils/lib/path.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,32 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) {
|
|
5
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
6
|
-
resolve(value);
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.next(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function step(result) {
|
|
25
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
-
}
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
3
|
var __importDefault = this && this.__importDefault || function (mod) {
|
|
31
4
|
return mod && mod.__esModule ? mod : {
|
|
32
5
|
"default": mod
|
|
@@ -52,222 +25,204 @@ class ModuleQuery {
|
|
|
52
25
|
/**
|
|
53
26
|
* Get all modules' name defined in engine workspaces.
|
|
54
27
|
*/
|
|
55
|
-
getAllModules() {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return Object.keys(this._cachedModuleName2PkgJson);
|
|
62
|
-
});
|
|
28
|
+
async getAllModules() {
|
|
29
|
+
await this._ensureModuleName2PkgJson();
|
|
30
|
+
if (!this._cachedModuleName2PkgJson) {
|
|
31
|
+
throw new Error(`Failed to resolve engine modules.`);
|
|
32
|
+
}
|
|
33
|
+
return Object.keys(this._cachedModuleName2PkgJson);
|
|
63
34
|
}
|
|
64
35
|
/**
|
|
65
36
|
* Get modules' all exports by module name.
|
|
66
37
|
*/
|
|
67
|
-
getExports(moduleName) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
exportPort = exportPort.slice(0, -1);
|
|
81
|
-
}
|
|
82
|
-
moduleExports.push(exportPort);
|
|
38
|
+
async getExports(moduleName) {
|
|
39
|
+
const config = await this.getConfig(moduleName);
|
|
40
|
+
const moduleExports = [];
|
|
41
|
+
if (!config.exports) {
|
|
42
|
+
return moduleExports;
|
|
43
|
+
}
|
|
44
|
+
for (let exportPort in config.exports) {
|
|
45
|
+
if (exportPort === '.' || exportPort === './') {
|
|
46
|
+
moduleExports.push(moduleName);
|
|
47
|
+
} else {
|
|
48
|
+
exportPort = utils_1.ps.join(moduleName, exportPort);
|
|
49
|
+
if (exportPort.endsWith('/')) {
|
|
50
|
+
exportPort = exportPort.slice(0, -1);
|
|
83
51
|
}
|
|
52
|
+
moduleExports.push(exportPort);
|
|
84
53
|
}
|
|
85
|
-
|
|
86
|
-
|
|
54
|
+
}
|
|
55
|
+
return moduleExports;
|
|
87
56
|
}
|
|
88
57
|
/**
|
|
89
58
|
* Get all the modules' exports.
|
|
90
59
|
*/
|
|
91
|
-
getAllExports() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return allExports;
|
|
99
|
-
});
|
|
60
|
+
async getAllExports() {
|
|
61
|
+
const allModules = await this.getAllModules();
|
|
62
|
+
const allExports = [];
|
|
63
|
+
for (const moduleName of allModules) {
|
|
64
|
+
allExports.push(...(await this.getExports(moduleName)));
|
|
65
|
+
}
|
|
66
|
+
return allExports;
|
|
100
67
|
}
|
|
101
68
|
/**
|
|
102
69
|
* Get the map from module name to module path.
|
|
103
70
|
*/
|
|
104
|
-
getExportMap() {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
map[exportPort] = resolved;
|
|
112
|
-
}
|
|
71
|
+
async getExportMap() {
|
|
72
|
+
const allExports = await this.getAllExports();
|
|
73
|
+
const map = {};
|
|
74
|
+
for (const exportPort of allExports) {
|
|
75
|
+
const resolved = await this.resolveExport(exportPort);
|
|
76
|
+
if (resolved) {
|
|
77
|
+
map[exportPort] = resolved;
|
|
113
78
|
}
|
|
114
|
-
|
|
115
|
-
|
|
79
|
+
}
|
|
80
|
+
return map;
|
|
116
81
|
}
|
|
117
82
|
/**
|
|
118
83
|
* Resolve module package.json path by module name.
|
|
119
84
|
*/
|
|
120
|
-
resolvePackageJson(moduleName) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return pkgJson;
|
|
131
|
-
});
|
|
85
|
+
async resolvePackageJson(moduleName) {
|
|
86
|
+
await this._ensureModuleName2PkgJson();
|
|
87
|
+
if (!this._cachedModuleName2PkgJson) {
|
|
88
|
+
throw new Error(`Failed to resolve engine modules.`);
|
|
89
|
+
}
|
|
90
|
+
const pkgJson = this._cachedModuleName2PkgJson[moduleName];
|
|
91
|
+
if (!pkgJson) {
|
|
92
|
+
throw new Error(`Failed resolve package json of module: ${moduleName}.`);
|
|
93
|
+
}
|
|
94
|
+
return pkgJson;
|
|
132
95
|
}
|
|
133
96
|
/**
|
|
134
97
|
* Get module config by module name.
|
|
135
98
|
*/
|
|
136
|
-
getConfig(moduleName) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return yield fs_extra_1.default.readJson(modulePath);
|
|
143
|
-
});
|
|
99
|
+
async getConfig(moduleName) {
|
|
100
|
+
const modulePath = await this.resolvePackageJson(moduleName);
|
|
101
|
+
if (!modulePath) {
|
|
102
|
+
throw new Error(`Failed to resolve engine module: ${moduleName}.`);
|
|
103
|
+
}
|
|
104
|
+
return await fs_extra_1.default.readJson(modulePath);
|
|
144
105
|
}
|
|
145
106
|
/**
|
|
146
107
|
* Resolve module entry path by import source.
|
|
147
108
|
*/
|
|
148
|
-
resolveExport(source) {
|
|
109
|
+
async resolveExport(source) {
|
|
149
110
|
var _a;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport[condition]);
|
|
179
|
-
}
|
|
111
|
+
if (this._resolvedCache[source]) {
|
|
112
|
+
return this._resolvedCache[source];
|
|
113
|
+
}
|
|
114
|
+
if (source.startsWith('.')) {
|
|
115
|
+
// no relative path resolve
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const allModules = await this.getAllModules();
|
|
119
|
+
const moduleName = allModules.find(moduleName => source.startsWith(moduleName));
|
|
120
|
+
if (!moduleName) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let exportPort = '.';
|
|
124
|
+
if (utils_1.ps.relative(moduleName, source) !== '') {
|
|
125
|
+
exportPort = './' + utils_1.ps.relative(moduleName, source);
|
|
126
|
+
}
|
|
127
|
+
const moduleRootDir = utils_1.ps.dirname(await this.resolvePackageJson(moduleName));
|
|
128
|
+
const config = await this.getConfig(moduleName);
|
|
129
|
+
// NOTE: '.' export port can cover all export ports.
|
|
130
|
+
const rootExport = (_a = config.exports) === null || _a === void 0 ? void 0 : _a[exportPort];
|
|
131
|
+
if (!rootExport) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// custom condition
|
|
135
|
+
if (this._context.customExportConditions) {
|
|
136
|
+
for (const condition of this._context.customExportConditions) {
|
|
137
|
+
if (typeof rootExport[condition] === 'string') {
|
|
138
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport[condition]);
|
|
180
139
|
}
|
|
181
140
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
} else if (this._isMiniGamePlatform(platform)) {
|
|
195
|
-
if (typeof rootExport.minigame === 'string') {
|
|
196
|
-
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.minigame);
|
|
197
|
-
} else if (typeof rootExport.minigame === 'object') {
|
|
198
|
-
if (typeof rootExport.minigame[platform] === 'string') {
|
|
199
|
-
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.minigame[platform]);
|
|
200
|
-
} else if (typeof rootExport.minigame.default === 'string') {
|
|
201
|
-
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.minigame.default);
|
|
202
|
-
}
|
|
141
|
+
}
|
|
142
|
+
// platform condition
|
|
143
|
+
const platform = this._context.platform.toLowerCase();
|
|
144
|
+
if (this._isWebPlatform(platform)) {
|
|
145
|
+
if (typeof rootExport.web === 'string') {
|
|
146
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.web);
|
|
147
|
+
} else if (typeof rootExport.web === 'object') {
|
|
148
|
+
if (typeof rootExport.web[platform] === 'string') {
|
|
149
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.web[platform]);
|
|
150
|
+
} else if (typeof rootExport.web.default === 'string') {
|
|
151
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.web.default);
|
|
203
152
|
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
153
|
+
}
|
|
154
|
+
} else if (this._isMiniGamePlatform(platform)) {
|
|
155
|
+
if (typeof rootExport.minigame === 'string') {
|
|
156
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.minigame);
|
|
157
|
+
} else if (typeof rootExport.minigame === 'object') {
|
|
158
|
+
if (typeof rootExport.minigame[platform] === 'string') {
|
|
159
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.minigame[platform]);
|
|
160
|
+
} else if (typeof rootExport.minigame.default === 'string') {
|
|
161
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.minigame.default);
|
|
213
162
|
}
|
|
214
163
|
}
|
|
215
|
-
|
|
216
|
-
if (typeof rootExport.
|
|
217
|
-
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.
|
|
218
|
-
} else if (typeof rootExport === '
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
164
|
+
} else if (this._isNativePlatform(platform)) {
|
|
165
|
+
if (typeof rootExport.native === 'string') {
|
|
166
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.native);
|
|
167
|
+
} else if (typeof rootExport.native === 'object') {
|
|
168
|
+
if (typeof rootExport.native[platform] === 'string') {
|
|
169
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.native[platform]);
|
|
170
|
+
} else if (typeof rootExport.native.default === 'string') {
|
|
171
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.native.default);
|
|
172
|
+
}
|
|
222
173
|
}
|
|
223
|
-
}
|
|
174
|
+
}
|
|
175
|
+
// types condition
|
|
176
|
+
if (typeof rootExport.types === 'string') {
|
|
177
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport.types);
|
|
178
|
+
} else if (typeof rootExport === 'string') {
|
|
179
|
+
return this._resolvedCache[source] = utils_1.ps.join(moduleRootDir, rootExport);
|
|
180
|
+
} else {
|
|
181
|
+
throw new Error(`Cannot resolve export: '${source}'.`);
|
|
182
|
+
}
|
|
224
183
|
}
|
|
225
184
|
/**
|
|
226
185
|
* To detect whether the module has a './editor' export.
|
|
227
186
|
* @param moduleName
|
|
228
187
|
*/
|
|
229
|
-
hasEditorSpecificExport(moduleName) {
|
|
188
|
+
async hasEditorSpecificExport(moduleName) {
|
|
230
189
|
var _a;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return this._cachedHasEditorSpecificExport[moduleName] = typeof ((_a = pkg.exports) === null || _a === void 0 ? void 0 : _a['./editor']) !== 'undefined';
|
|
238
|
-
});
|
|
190
|
+
if (typeof this._cachedHasEditorSpecificExport[moduleName] === 'boolean') {
|
|
191
|
+
return this._cachedHasEditorSpecificExport[moduleName];
|
|
192
|
+
}
|
|
193
|
+
const pkgJson = await this.resolvePackageJson(moduleName);
|
|
194
|
+
const pkg = await fs_extra_1.default.readJson(pkgJson);
|
|
195
|
+
return this._cachedHasEditorSpecificExport[moduleName] = typeof ((_a = pkg.exports) === null || _a === void 0 ? void 0 : _a['./editor']) !== 'undefined';
|
|
239
196
|
}
|
|
240
|
-
_ensureModuleName2PkgJson() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
197
|
+
async _ensureModuleName2PkgJson() {
|
|
198
|
+
if (this._cachedModuleName2PkgJson) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const enginePkg = await fs_extra_1.default.readJson(utils_1.ps.join(this._context.engine, 'package.json'));
|
|
202
|
+
let pkgFiles = [];
|
|
203
|
+
if (enginePkg.workspaces) {
|
|
204
|
+
for (const ws of enginePkg.workspaces) {
|
|
205
|
+
pkgFiles.push(...glob_1.default.sync(utils_1.ps.join(this._context.engine, ws), {
|
|
206
|
+
ignore: '**/node_modules/**/*'
|
|
207
|
+
}));
|
|
253
208
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
209
|
+
}
|
|
210
|
+
pkgFiles = pkgFiles.map(file => {
|
|
211
|
+
if (fs_extra_1.default.statSync(file).isDirectory()) {
|
|
212
|
+
const pkgFile = utils_1.ps.join(file, 'package.json');
|
|
213
|
+
if (fs_extra_1.default.existsSync(pkgFile)) {
|
|
214
|
+
return pkgFile;
|
|
260
215
|
}
|
|
261
|
-
return file;
|
|
262
|
-
});
|
|
263
|
-
pkgFiles = pkgFiles.filter(file => file.endsWith('package.json'));
|
|
264
|
-
pkgFiles = pkgFiles.filter((file, index) => pkgFiles.indexOf(file) === index);
|
|
265
|
-
this._cachedModuleName2PkgJson = {};
|
|
266
|
-
for (const pkg of pkgFiles) {
|
|
267
|
-
const name = (yield fs_extra_1.default.readJson(pkg)).name;
|
|
268
|
-
this._cachedModuleName2PkgJson[name] = pkg;
|
|
269
216
|
}
|
|
217
|
+
return file;
|
|
270
218
|
});
|
|
219
|
+
pkgFiles = pkgFiles.filter(file => file.endsWith('package.json'));
|
|
220
|
+
pkgFiles = pkgFiles.filter((file, index) => pkgFiles.indexOf(file) === index);
|
|
221
|
+
this._cachedModuleName2PkgJson = {};
|
|
222
|
+
for (const pkg of pkgFiles) {
|
|
223
|
+
const name = (await fs_extra_1.default.readJson(pkg)).name;
|
|
224
|
+
this._cachedModuleName2PkgJson[name] = pkg;
|
|
225
|
+
}
|
|
271
226
|
}
|
|
272
227
|
_isWebPlatform(platform) {
|
|
273
228
|
return platform.toUpperCase() in platform_config_1.WebPlatform || platform.toUpperCase() === 'HTML5';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-query.js","sourceRoot":"","sources":["../src/module-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-query.js","sourceRoot":"","sources":["../src/module-query.ts"],"names":[],"mappings":";;;;;;AACA,wDAA0B;AAC1B,uDAAkF;AAClF,gDAAwB;AACxB,0CAAoC;AAuBpC;;GAEG;AACH,MAAa,WAAW;IAQpB,YAAa,OAA2B;QAHhC,mBAAc,GAA2B,EAAE,CAAC,CAAE,wCAAwC;QACtF,mCAA8B,GAA4B,EAAE,CAAC;QAGjE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,aAAa;QACtB,MAAM,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACxD;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACvD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU,CAAE,UAAkB;QACvC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAChD,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACjB,OAAO,aAAa,CAAC;SACxB;QACD,KAAK,IAAI,UAAU,IAAI,MAAM,CAAC,OAAO,EAAE;YACnC,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,IAAI,EAAE;gBAC3C,aAAa,C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AAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC;QAC9E,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;YACxB,MAAM,IAAI,GAAG,CAAC,MAAM,kBAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3C,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;SAC9C;IACL,CAAC;IAEO,cAAc,CAAE,QAAgB;QACpC,OAAO,QAAQ,CAAC,WAAW,EAAE,IAAI,6BAAW,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;IACvF,CAAC;IAEO,mBAAmB,CAAE,QAAgB;QACzC,OAAO,QAAQ,CAAC,WAAW,EAAE,IAAI,kCAAgB,CAAC;IACtD,CAAC;IAEO,iBAAiB,CAAE,QAAgB;QACvC,OAAO,QAAQ,CAAC,WAAW,EAAE,IAAI,gCAAc,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC;IAC3F,CAAC;CACJ;AA5OD,kCA4OC"}
|
|
@@ -31,33 +31,6 @@ var __importStar = this && this.__importStar || function (mod) {
|
|
|
31
31
|
__setModuleDefault(result, mod);
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
35
|
-
function adopt(value) {
|
|
36
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
37
|
-
resolve(value);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
41
|
-
function fulfilled(value) {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.next(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function rejected(value) {
|
|
49
|
-
try {
|
|
50
|
-
step(generator["throw"](value));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
reject(e);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function step(result) {
|
|
56
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
57
|
-
}
|
|
58
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
34
|
var __importDefault = this && this.__importDefault || function (mod) {
|
|
62
35
|
return mod && mod.__esModule ? mod : {
|
|
63
36
|
"default": mod
|
|
@@ -81,16 +54,14 @@ class StatsQuery {
|
|
|
81
54
|
/**
|
|
82
55
|
* @param engine Path to the engine root.
|
|
83
56
|
*/
|
|
84
|
-
static create(engine) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return query;
|
|
93
|
-
});
|
|
57
|
+
static async create(engine) {
|
|
58
|
+
const configFile = path_1.default.join(engine, 'cc.config.json');
|
|
59
|
+
const config = json5_1.default.parse(await fs_extra_1.default.readFile(configFile, 'utf8'));
|
|
60
|
+
// @ts-expect-error we should delete this property
|
|
61
|
+
delete config['$schema'];
|
|
62
|
+
const query = new StatsQuery(engine, config);
|
|
63
|
+
await query._initialize();
|
|
64
|
+
return query;
|
|
94
65
|
}
|
|
95
66
|
/**
|
|
96
67
|
* Gets the path to the engine root.
|
|
@@ -230,21 +201,19 @@ class StatsQuery {
|
|
|
230
201
|
});
|
|
231
202
|
return overrides;
|
|
232
203
|
}
|
|
233
|
-
static _readModulesInDir(exportsDir, mapper) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return result;
|
|
247
|
-
});
|
|
204
|
+
static async _readModulesInDir(exportsDir, mapper) {
|
|
205
|
+
const result = {};
|
|
206
|
+
for (const entryFileName of await fs_extra_1.default.readdir(exportsDir)) {
|
|
207
|
+
const entryExtName = path_1.default.extname(entryFileName);
|
|
208
|
+
if (!entryExtName.toLowerCase().endsWith('.ts')) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const baseName = path_1.default.basename(entryFileName, entryExtName);
|
|
212
|
+
const moduleName = mapper(baseName);
|
|
213
|
+
const entryFile = path_1.default.join(exportsDir, entryFileName);
|
|
214
|
+
result[moduleName] = entryFile;
|
|
215
|
+
}
|
|
216
|
+
return result;
|
|
248
217
|
}
|
|
249
218
|
static _baseNameToFeatureUnitName(baseName) {
|
|
250
219
|
return `${baseName}`;
|
|
@@ -281,38 +250,36 @@ class StatsQuery {
|
|
|
281
250
|
}
|
|
282
251
|
return resultPath;
|
|
283
252
|
}
|
|
284
|
-
_initialize() {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
throw new Error(`Invalid config file: '${moduleFileBaseName}' is not a valid module.`);
|
|
299
|
-
}
|
|
300
|
-
parsedFeature.modules.push(featureUnitName);
|
|
253
|
+
async _initialize() {
|
|
254
|
+
const {
|
|
255
|
+
_config: config,
|
|
256
|
+
_engine: engine
|
|
257
|
+
} = this;
|
|
258
|
+
const featureUnits = this._featureUnits = await StatsQuery._readModulesInDir(path_1.default.join(engine, 'exports'), StatsQuery._baseNameToFeatureUnitName);
|
|
259
|
+
for (const [featureName, feature] of Object.entries(config.features)) {
|
|
260
|
+
const parsedFeature = this._features[featureName] = {
|
|
261
|
+
modules: []
|
|
262
|
+
};
|
|
263
|
+
for (const moduleFileBaseName of feature.modules) {
|
|
264
|
+
const featureUnitName = StatsQuery._baseNameToFeatureUnitName(moduleFileBaseName);
|
|
265
|
+
if (!featureUnits[featureUnitName]) {
|
|
266
|
+
throw new Error(`Invalid config file: '${moduleFileBaseName}' is not a valid module.`);
|
|
301
267
|
}
|
|
302
|
-
parsedFeature.
|
|
268
|
+
parsedFeature.modules.push(featureUnitName);
|
|
303
269
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
270
|
+
parsedFeature.intrinsicFlags = feature.intrinsicFlags;
|
|
271
|
+
}
|
|
272
|
+
if (config.index) {
|
|
273
|
+
if (config.index.modules) {
|
|
274
|
+
for (const [k, v] of Object.entries(config.index.modules)) {
|
|
275
|
+
this._index.modules[StatsQuery._baseNameToFeatureUnitName(k)] = v;
|
|
309
276
|
}
|
|
310
|
-
this._index = Object.assign(Object.assign({}, config.index), {
|
|
311
|
-
modules: this._index.modules
|
|
312
|
-
});
|
|
313
277
|
}
|
|
314
|
-
this.
|
|
315
|
-
|
|
278
|
+
this._index = Object.assign(Object.assign({}, config.index), {
|
|
279
|
+
modules: this._index.modules
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
this._editorPublicModules = await StatsQuery._readModulesInDir(path_1.default.join(engine, 'editor', 'exports'), StatsQuery._editorBaseNameToModuleName);
|
|
316
283
|
}
|
|
317
284
|
}
|
|
318
285
|
exports.StatsQuery = StatsQuery;
|