@ttmg/cli 0.1.3-beta.1 → 0.1.3-beta.3

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 CHANGED
@@ -51,3 +51,10 @@ feat: 支持文件变更监听,告知浏览器文件变更,提醒开发者
51
51
  ## 0.1.3-beta.1
52
52
 
53
53
  优化显示二维码问题
54
+
55
+ ## 0.1.3-beta.2
56
+
57
+ 彻底修复二维码兼容问题
58
+
59
+ ## 0.1.3-beta.3
60
+ 修复 sourcemap 错乱问题
package/dist/index.js CHANGED
@@ -913,15 +913,11 @@ async function createServer() {
913
913
  */
914
914
  const outputDir = getOutputDir();
915
915
  /**
916
- *
916
+ * 支持静态资源
917
917
  */
918
- app.use(express.static(outputDir));
919
- /**
920
- * 支持获取文件
921
- */
922
- app.get('/game/files/:fileName', async (req, res) => {
923
- const { fileName } = req.params;
924
- res.sendFile(path.join(outputDir, fileName));
918
+ app.use('/game/files', express.static(outputDir));
919
+ app.get('/game/qrcode', async (req, res) => {
920
+ res.sendFile(path.join(OUTPUT_DIR, `dev-qrcode.png`));
925
921
  });
926
922
  /**
927
923
  * 支持文件访问
@@ -1269,18 +1265,41 @@ async function watchChange() {
1269
1265
  });
1270
1266
  }
1271
1267
 
1268
+ // 保持你原来的 import
1269
+ // 你的静态服务器运行的端口
1270
+ // --- 修改结束 ---
1272
1271
  async function showSchema() {
1272
+ if (!fs.existsSync(OUTPUT_DIR)) {
1273
+ fs.mkdirSync(OUTPUT_DIR, { recursive: true });
1274
+ }
1273
1275
  const clientKey = getClientKey();
1274
- const outputDir = path.join(OUTPUT_DIR, clientKey);
1275
- const localIP = getLocalIP();
1276
- console.log(chalk.green.bold('Tips:'));
1277
- console.log(` 1. ${chalk.yellow.bold('Scan the QR code to start the client devServer.')}`);
1278
- console.log(` 2. ${chalk.yellow.bold('Will auto upload compiled resource to client.')} ${chalk.bold(outputDir)}`);
1279
- console.log(` 3. ${chalk.yellow.bold('Debug your game in the browser.')}\n`);
1280
- const schema = `https://www.tiktok.com/ttmg/dev/${clientKey}?host=${localIP}&port=${DEV_WS_PORT}`;
1281
- QRCode.toString(schema, { type: 'terminal', small: true }, (err, qr) => {
1282
- console.log(qr);
1283
- });
1276
+ // 2. 定义二维码图片的文件名和完整路径
1277
+ const qrCodeFileName = 'dev-qrcode.png';
1278
+ const qrCodeImagePath = path.join(OUTPUT_DIR, qrCodeFileName);
1279
+ const schema = `https://www.tiktok.com/ttmg/dev/${clientKey}?host=${getLocalIP()}&port=${DEV_WS_PORT}`;
1280
+ try {
1281
+ // 3. 使用 QRCode.toFile 生成图片到你的静态目录
1282
+ await QRCode.toFile(qrCodeImagePath, schema, {
1283
+ type: 'png',
1284
+ width: 200,
1285
+ margin: 1,
1286
+ });
1287
+ // 4. 构建可通过静态服务器访问的 URL
1288
+ const qrCodeUrl = `http://localhost:${DEV_PORT}/game/qrcode`;
1289
+ // 5. 打印更新后的提示信息
1290
+ console.log(chalk.green.bold('Tips:'));
1291
+ console.log(` 1. ${chalk.yellow.bold('Open the link below in your browser to see the QR code, then scan it.')}`);
1292
+ console.log(` ${chalk.cyan.underline(qrCodeUrl)}`);
1293
+ console.log(` 2. ${chalk.yellow.bold('Will auto upload compiled resource to client.')}`);
1294
+ console.log(` 3. ${chalk.yellow.bold('Debug your game in the browser.')}\n`);
1295
+ /**
1296
+ * 自动打开浏览器
1297
+ */
1298
+ openUrl(qrCodeUrl);
1299
+ }
1300
+ catch (err) {
1301
+ console.error(chalk.red('Failed to generate QR code image.'), err);
1302
+ }
1284
1303
  }
1285
1304
 
1286
1305
  async function dev() {
@@ -1302,7 +1321,7 @@ async function dev() {
1302
1321
  await watchChange();
1303
1322
  }
1304
1323
 
1305
- var version = "0.1.3-beta.1";
1324
+ var version = "0.1.3-beta.3";
1306
1325
  var pkg = {
1307
1326
  version: version};
1308
1327
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttmg/cli",
3
- "version": "0.1.3-beta.1",
3
+ "version": "0.1.3-beta.3",
4
4
  "description": "TikTok Mini Game Command Line Tool",
5
5
  "license": "ISC",
6
6
  "bin": {
@@ -43,7 +43,7 @@
43
43
  "prettier": "^3.6.2",
44
44
  "qrcode": "^1.5.4",
45
45
  "semver": "^7.7.2",
46
- "ttmg-pack": "0.0.25",
46
+ "ttmg-pack": "0.0.27",
47
47
  "ws": "^8.18.3"
48
48
  },
49
49
  "devDependencies": {