ttmg-pack 0.4.5 → 0.4.7-beta.1
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/CHANGELOG.md +7 -1
- package/dist/index.js +42 -17
- package/dist/index.js.map +1 -1
- package/dist/libs/checkPkgs/checkAPI.d.ts +1 -1
- package/dist/typings/index.d.ts +14 -0
- package/dist/utils/i18n.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ==========================================
|
|
3
3
|
* @Description: ttmg pack
|
|
4
|
-
* @Version: 0.4.
|
|
4
|
+
* @Version: 0.4.7-beta.1
|
|
5
5
|
* @Author: zhanghongyang.mocha
|
|
6
|
-
* @Date: 2026-03
|
|
6
|
+
* @Date: 2026-04-03 16:58:16
|
|
7
7
|
* ==========================================
|
|
8
8
|
*/
|
|
9
9
|
'use strict';
|
|
@@ -331,11 +331,14 @@ const messages = {
|
|
|
331
331
|
'check.project.gameJson.subPackagesInvalid': "'subPackages' is found in game.json. Please use 'subpackages' (all lowercase) instead.",
|
|
332
332
|
'check.project.gameJson.success': 'Check game.json config successfully.',
|
|
333
333
|
'check.project.size.failed': 'Project size check failed: {sizeMB}MB. It must not exceed {limitMB}MB.',
|
|
334
|
+
'check.project.size.doc': 'View package size limits',
|
|
334
335
|
'check.project.size.success': 'Project size check passed: {sizeMB}MB.',
|
|
335
336
|
'check.project.perf.noSplitNeeded': 'wasmFuncCount < {limit}. No wasm code splitting is needed.',
|
|
336
337
|
'check.project.perf.needSplit': 'The Wasm function count in wasmcode/ exceeds {limit}. Please enable code splitting to optimize performance.',
|
|
338
|
+
'check.project.perf.doc': 'View wasm split guide',
|
|
337
339
|
'check.project.perf.splitEnabled': 'wasmFuncCount >= {limit}, and wasm split is enabled.',
|
|
338
340
|
'check.main.size.failed': 'Main package size check failed: {sizeMB}MB. It must not exceed {limitMB}MB.',
|
|
341
|
+
'check.main.size.doc': 'View package size limits',
|
|
339
342
|
'check.main.size.success': 'Main package size check passed: {sizeMB}MB.',
|
|
340
343
|
'check.main.entry.missing': 'Main package entry check failed: game.js must exist in the main package.',
|
|
341
344
|
'check.main.entry.success': 'Main package entry check passed: game.js exists in the main package.',
|
|
@@ -348,6 +351,7 @@ const messages = {
|
|
|
348
351
|
'check.independent.config.success': 'Independent subpackage<{name}> config check passed.',
|
|
349
352
|
'check.pkgSize.success': 'Package<{pkgName}> size check passed: {sizeMB}MB.',
|
|
350
353
|
'check.pkgSize.exceeds': 'Package<{pkgName}> size check failed: {sizeMB}MB exceeds limit {limitMB}MB.',
|
|
354
|
+
'check.pkgSize.doc': 'View package size limits',
|
|
351
355
|
'check.api.integrated': '{name} integrated.',
|
|
352
356
|
'check.api.notIntegrated': '{name} not integrated.',
|
|
353
357
|
'check.api.suggestedActionSuffix': 'Please resolve this before submission to avoid review rejection.',
|
|
@@ -404,11 +408,14 @@ const messages = {
|
|
|
404
408
|
'check.project.gameJson.subPackagesInvalid': "在 game.json 中发现了 'subPackages' 字段,请改为全小写的 'subpackages'。",
|
|
405
409
|
'check.project.gameJson.success': 'game.json 配置检查通过。',
|
|
406
410
|
'check.project.size.failed': '项目大小检查失败:当前 {sizeMB}MB,不能超过 {limitMB}MB。',
|
|
411
|
+
'check.project.size.doc': '查看包大小限制说明',
|
|
407
412
|
'check.project.size.success': '项目大小检查通过:当前 {sizeMB}MB。',
|
|
408
413
|
'check.project.perf.noSplitNeeded': 'wasmFuncCount < {limit},无需进行 wasm 代码拆分。',
|
|
409
414
|
'check.project.perf.needSplit': 'wasmcode/ 中的 Wasm 函数数量超过 {limit},请开启代码拆分以优化性能。',
|
|
415
|
+
'check.project.perf.doc': '查看分包文档',
|
|
410
416
|
'check.project.perf.splitEnabled': 'wasmFuncCount >= {limit},且已开启 wasm 拆分。',
|
|
411
417
|
'check.main.size.failed': '主包大小检查失败:当前 {sizeMB}MB,不能超过 {limitMB}MB。',
|
|
418
|
+
'check.main.size.doc': '查看包大小限制说明',
|
|
412
419
|
'check.main.size.success': '主包大小检查通过:当前 {sizeMB}MB。',
|
|
413
420
|
'check.main.entry.missing': '主包入口检查失败:主包中必须存在 game.js。',
|
|
414
421
|
'check.main.entry.success': '主包入口检查通过:主包中存在 game.js。',
|
|
@@ -421,6 +428,7 @@ const messages = {
|
|
|
421
428
|
'check.independent.config.success': '独立分包<{name}> 配置检查通过。',
|
|
422
429
|
'check.pkgSize.success': '包<{pkgName}> 大小检查通过:{sizeMB}MB。',
|
|
423
430
|
'check.pkgSize.exceeds': '包<{pkgName}> 大小检查失败:当前 {sizeMB}MB,超过限制 {limitMB}MB。',
|
|
431
|
+
'check.pkgSize.doc': '查看包大小限制说明',
|
|
424
432
|
'check.api.integrated': '{name} 已接入。',
|
|
425
433
|
'check.api.notIntegrated': '{name} 未接入。',
|
|
426
434
|
'check.api.suggestedActionSuffix': '请在提审之前完成问题处理,避免审核阶段被拒审。',
|
|
@@ -1133,6 +1141,7 @@ function checkGameJson(config, t) {
|
|
|
1133
1141
|
* @returns
|
|
1134
1142
|
*/
|
|
1135
1143
|
function checkProjectSize(config, t) {
|
|
1144
|
+
const pkgSizeDocLink = 'https://bytedance.larkoffice.com/wiki/LkihwQCMfiBpr3khwNuceCBkn3e';
|
|
1136
1145
|
logger.info(t('log.check.projectSize.start'));
|
|
1137
1146
|
const { entry: entryDir, dev } = config;
|
|
1138
1147
|
const { pkgSizeLimit } = getCheckConfig(config);
|
|
@@ -1144,7 +1153,10 @@ function checkProjectSize(config, t) {
|
|
|
1144
1153
|
const errMsg = t('check.project.size.failed', { sizeMB: gameSizeMB, limitMB });
|
|
1145
1154
|
logger.error(errMsg);
|
|
1146
1155
|
if (enableDev) {
|
|
1147
|
-
return Object.assign({ passed: false, name: 'project', msg: errMsg, type: 'size', level: 'warning',
|
|
1156
|
+
return Object.assign({ passed: false, name: 'project', msg: errMsg, type: 'size', level: 'warning', detail: {
|
|
1157
|
+
link: pkgSizeDocLink,
|
|
1158
|
+
text: t('check.project.size.doc'),
|
|
1159
|
+
}, size: gameSize }, defaultCheckConfig$3);
|
|
1148
1160
|
}
|
|
1149
1161
|
else {
|
|
1150
1162
|
throw new Error(errMsg);
|
|
@@ -1160,6 +1172,7 @@ function checkProjectSize(config, t) {
|
|
|
1160
1172
|
}
|
|
1161
1173
|
}
|
|
1162
1174
|
function checkPerformance(config, t) {
|
|
1175
|
+
const wasmSplitDocLink = 'https://bytedance.larkoffice.com/wiki/DZDzwzYdDiJpBSkrhcTcWailnuh?from=from_parent_docx';
|
|
1163
1176
|
const { entry } = config;
|
|
1164
1177
|
if (!isUnityEngine(entry)) {
|
|
1165
1178
|
return null;
|
|
@@ -1177,7 +1190,10 @@ function checkPerformance(config, t) {
|
|
|
1177
1190
|
const splitConfigPath = path.join(entry, GAME_WASM_SPLIT_CONFIG_FILE_NAME);
|
|
1178
1191
|
const errResult = Object.assign(Object.assign({}, defaultCheckConfig$3), { passed: false, msg: t('check.project.perf.needSplit', {
|
|
1179
1192
|
limit: WASM_FUNC_COUNT_LIMIT,
|
|
1180
|
-
}), type: 'performance', level: 'warning',
|
|
1193
|
+
}), type: 'performance', level: 'warning', detail: {
|
|
1194
|
+
link: wasmSplitDocLink,
|
|
1195
|
+
text: t('check.project.perf.doc'),
|
|
1196
|
+
}, name: 'project' });
|
|
1181
1197
|
if (!fs.existsSync(splitConfigPath)) {
|
|
1182
1198
|
return errResult;
|
|
1183
1199
|
}
|
|
@@ -1203,6 +1219,7 @@ const defaultCheckConfig$2 = {
|
|
|
1203
1219
|
* @returns
|
|
1204
1220
|
*/
|
|
1205
1221
|
function checkMainPackageSize(config, t) {
|
|
1222
|
+
const pkgSizeDocLink = 'https://bytedance.larkoffice.com/wiki/LkihwQCMfiBpr3khwNuceCBkn3e';
|
|
1206
1223
|
logger.info(t('log.check.mainPackageSize.start'));
|
|
1207
1224
|
const { entry: entryDir, dev } = config;
|
|
1208
1225
|
const { mainPkgSizeLimit } = getCheckConfig(config);
|
|
@@ -1216,7 +1233,10 @@ function checkMainPackageSize(config, t) {
|
|
|
1216
1233
|
});
|
|
1217
1234
|
logger.error(errMsg);
|
|
1218
1235
|
if (dev === null || dev === void 0 ? void 0 : dev.enable) {
|
|
1219
|
-
return Object.assign({ passed: false, msg: errMsg, size: mainPkgSize, type: 'size', level: 'warning'
|
|
1236
|
+
return Object.assign({ passed: false, msg: errMsg, size: mainPkgSize, type: 'size', level: 'warning', detail: {
|
|
1237
|
+
link: pkgSizeDocLink,
|
|
1238
|
+
text: t('check.main.size.doc'),
|
|
1239
|
+
} }, defaultCheckConfig$2);
|
|
1220
1240
|
}
|
|
1221
1241
|
else {
|
|
1222
1242
|
throw new Error(errMsg);
|
|
@@ -1442,6 +1462,7 @@ function checkIndependentPackages(config, t) {
|
|
|
1442
1462
|
return checkResults;
|
|
1443
1463
|
}
|
|
1444
1464
|
function checkPkgSize({ entryDir, limit, pkgName, dimension, level, t, }) {
|
|
1465
|
+
const pkgSizeDocLink = 'https://bytedance.larkoffice.com/wiki/LkihwQCMfiBpr3khwNuceCBkn3e';
|
|
1445
1466
|
const size = getDirSizeSync({
|
|
1446
1467
|
rootDir: entryDir,
|
|
1447
1468
|
entryDir,
|
|
@@ -1449,9 +1470,7 @@ function checkPkgSize({ entryDir, limit, pkgName, dimension, level, t, }) {
|
|
|
1449
1470
|
const passed = size <= limit;
|
|
1450
1471
|
const sizeMB = size / 1024 / 1024;
|
|
1451
1472
|
const limitMB = limit / 1024 / 1024;
|
|
1452
|
-
return {
|
|
1453
|
-
passed,
|
|
1454
|
-
msg: passed
|
|
1473
|
+
return Object.assign(Object.assign({ passed, msg: passed
|
|
1455
1474
|
? t('check.pkgSize.success', {
|
|
1456
1475
|
pkgName,
|
|
1457
1476
|
sizeMB: sizeMB.toFixed(2),
|
|
@@ -1460,14 +1479,15 @@ function checkPkgSize({ entryDir, limit, pkgName, dimension, level, t, }) {
|
|
|
1460
1479
|
pkgName,
|
|
1461
1480
|
sizeMB: sizeMB.toFixed(2),
|
|
1462
1481
|
limitMB: limitMB.toFixed(2),
|
|
1463
|
-
}),
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1482
|
+
}), type: 'size', level }, (passed
|
|
1483
|
+
? {}
|
|
1484
|
+
: {
|
|
1485
|
+
detail: {
|
|
1486
|
+
link: pkgSizeDocLink,
|
|
1487
|
+
text: t('check.pkgSize.doc'),
|
|
1488
|
+
},
|
|
1489
|
+
})), { size,
|
|
1490
|
+
dimension, required: true, name: pkgName });
|
|
1471
1491
|
}
|
|
1472
1492
|
|
|
1473
1493
|
/**
|
|
@@ -1504,6 +1524,11 @@ function checkAPI(config, t) {
|
|
|
1504
1524
|
if (!((_a = config === null || config === void 0 ? void 0 : config.build) === null || _a === void 0 ? void 0 : _a.enableAPICheck)) {
|
|
1505
1525
|
return [];
|
|
1506
1526
|
}
|
|
1527
|
+
// Unity 游戏产物通常无法通过源码/产物扫描稳定识别必接 API(多为 wasm/unityweb),
|
|
1528
|
+
// 为避免误报,这里直接跳过必接能力扫描与结果透出。
|
|
1529
|
+
if (isUnityEngine(config.entry)) {
|
|
1530
|
+
return [];
|
|
1531
|
+
}
|
|
1507
1532
|
const exts = ['.js', '.ts'];
|
|
1508
1533
|
// 预编译正则,尽量减少误报:匹配独立的标识符或对象调用形式
|
|
1509
1534
|
// 例如:\b(login)\b 或 \.login\s*\( 或 =\s*login\b
|
|
@@ -2420,7 +2445,7 @@ async function buildPkgs(config, context = {}) {
|
|
|
2420
2445
|
let startTime = Date.now();
|
|
2421
2446
|
logger.init(outputDir, true);
|
|
2422
2447
|
logger.info(t('log.build.version', {
|
|
2423
|
-
version: "0.4.
|
|
2448
|
+
version: "0.4.7-beta.1",
|
|
2424
2449
|
}));
|
|
2425
2450
|
logger.info(t('log.build.start', { startTime }));
|
|
2426
2451
|
/**
|