@ttmg/cli 0.3.6-beta.3 → 0.3.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 +4 -1
- package/dist/index.js +551 -66
- package/dist/index.js.map +1 -1
- package/dist/package.json +2 -2
- package/dist/public/assets/Detail-BInCTDTx.js +1 -0
- package/dist/public/assets/Detail-BInCTDTx.js.br +0 -0
- package/dist/public/assets/Detail-BaQ9eM95.css +1 -0
- package/dist/public/assets/{baseForm-Dnb99UJB.js → baseForm-B7tArmif.js} +4 -4
- package/dist/public/assets/baseForm-B7tArmif.js.br +0 -0
- package/dist/public/assets/{index-UihZn1LL.css → index-6LE--ADL.css} +1 -1
- package/dist/public/assets/index-6LE--ADL.css.br +0 -0
- package/dist/public/assets/index-AtMMzkp0.css +1 -0
- package/dist/public/assets/index-B-rc2X1H.js +1 -0
- package/dist/public/assets/index-B0CT2rYr.js +1 -0
- package/dist/public/assets/index-BACeBrQR.css +1 -0
- package/dist/public/assets/index-BOiN8aIS.js +1 -0
- package/dist/public/assets/index-BVi9swz_.js +1 -0
- package/dist/public/assets/index-BVi9swz_.js.br +0 -0
- package/dist/public/assets/index-BlXhGm9R.js +1 -0
- package/dist/public/assets/{index-BkiB8M4Y.css → index-BnU4EHWL.css} +1 -1
- package/dist/public/assets/index-BnU4EHWL.css.br +0 -0
- package/dist/public/assets/index-BswgGVlz.js +1 -0
- package/dist/public/assets/index-BswgGVlz.js.br +0 -0
- package/dist/public/assets/index-C4wGgEDm.css +1 -0
- package/dist/public/assets/{index-DHyyb3Gw.js → index-CDrq3KnY.js} +1 -1
- package/dist/public/assets/index-CH7igbHY.css +1 -0
- package/dist/public/assets/index-Cj-lTEG1.js +1 -0
- package/dist/public/assets/index-Cj-lTEG1.js.br +0 -0
- package/dist/public/assets/index-D35C4ac4.js +1 -0
- package/dist/public/assets/index-DQqzytdw.js +1 -0
- package/dist/public/assets/index-DQqzytdw.js.br +0 -0
- package/dist/public/assets/index-DbiZkOAh.css +1 -0
- package/dist/public/assets/{index-CqK4Ymjd.js → index-DdH9Yin-.js} +1 -1
- package/dist/public/assets/index-DkXWo3Jg.js +14 -0
- package/dist/public/assets/index-DkXWo3Jg.js.br +0 -0
- package/dist/public/assets/index-OIQapQiA.js +1 -0
- package/dist/public/assets/{index-BGkIaNEY.js → index-Sk6u8HWP.js} +1 -1
- package/dist/public/assets/index-TYa4eXxF.css +1 -0
- package/dist/public/assets/{index-DKKMC8UM.js → index-aD1InxYk.js} +1 -1
- package/dist/public/assets/index-jaMAKGHW.css +1 -0
- package/dist/public/assets/{index-C5pU_dUf.js → index-tXDZpXMk.js} +1 -1
- package/dist/public/assets/index-tXDZpXMk.js.br +0 -0
- package/dist/public/assets/times-CCIAbLYL.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/scripts/docs/capture.js +255 -0
- package/dist/scripts/docs/render.js +199 -0
- package/dist/scripts/docs/server.js +164 -0
- package/package.json +2 -2
- package/dist/public/assets/baseForm-Dnb99UJB.js.br +0 -0
- package/dist/public/assets/index-B8aFXzhN.js +0 -1
- package/dist/public/assets/index-BB5kLk47.css +0 -1
- package/dist/public/assets/index-BaXjsvp9.js +0 -1
- package/dist/public/assets/index-BedicqfR.css +0 -1
- package/dist/public/assets/index-BkiB8M4Y.css.br +0 -0
- package/dist/public/assets/index-BmSg7a2H.js +0 -14
- package/dist/public/assets/index-BmSg7a2H.js.br +0 -0
- package/dist/public/assets/index-Bovw-Ai8.js +0 -1
- package/dist/public/assets/index-Bovw-Ai8.js.br +0 -0
- package/dist/public/assets/index-Bq6YxKLX.css +0 -1
- package/dist/public/assets/index-BwbPFgZF.css +0 -1
- package/dist/public/assets/index-C5pU_dUf.js.br +0 -0
- package/dist/public/assets/index-C8f539tK.css +0 -1
- package/dist/public/assets/index-CJtCELuI.js +0 -1
- package/dist/public/assets/index-CPEErQsP.js +0 -1
- package/dist/public/assets/index-CkcOz6VJ.js +0 -1
- package/dist/public/assets/index-D0piMtcL.js +0 -1
- package/dist/public/assets/index-DNZgHncv.js +0 -1
- package/dist/public/assets/index-DhmPFuxl.css +0 -1
- package/dist/public/assets/index-OPfpZTmc.js +0 -1
- package/dist/public/assets/index-OPfpZTmc.js.br +0 -0
- package/dist/public/assets/index-UihZn1LL.css.br +0 -0
- package/dist/public/assets/index-vPoeqDW1.js +0 -1
- package/dist/public/assets/index-vPoeqDW1.js.br +0 -0
- package/dist/public/assets/index-yh4tKekV.css +0 -1
- package/dist/public/assets/isPlainObject-CKjwQ9bg.js +0 -1
- package/dist/public/assets/times-BsXqTKq4.js +0 -1
- /package/dist/public/assets/{index-C7C5ulLg.css → times-C7C5ulLg.css} +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const WebSocket = require('ws');
|
|
5
|
+
|
|
6
|
+
function parseArgs(argv) {
|
|
7
|
+
return argv.reduce((acc, arg) => {
|
|
8
|
+
if (!arg.startsWith('--')) {
|
|
9
|
+
return acc;
|
|
10
|
+
}
|
|
11
|
+
const [key, value] = arg.slice(2).split('=');
|
|
12
|
+
acc[key] = value === undefined ? true : value;
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function normalizeLang(value) {
|
|
18
|
+
const raw = String(value || '').toLowerCase();
|
|
19
|
+
if (raw.includes('en')) {
|
|
20
|
+
return 'en-US';
|
|
21
|
+
}
|
|
22
|
+
return 'zh-CN';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolveLang(req) {
|
|
26
|
+
return normalizeLang(
|
|
27
|
+
req.query.lang || req.headers['x-ttmg-docs-lang'] || req.headers['accept-language'],
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isLocaleMap(value) {
|
|
32
|
+
if (!value || Array.isArray(value) || typeof value !== 'object') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const keys = Object.keys(value);
|
|
36
|
+
return (
|
|
37
|
+
keys.length > 0 &&
|
|
38
|
+
keys.every(key => key === 'zh-CN' || key === 'en-US')
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function localizeValue(value, lang) {
|
|
43
|
+
if (Array.isArray(value)) {
|
|
44
|
+
return value.map(item => localizeValue(item, lang));
|
|
45
|
+
}
|
|
46
|
+
if (!value || typeof value !== 'object') {
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
if (isLocaleMap(value)) {
|
|
50
|
+
return value[lang] ?? value['zh-CN'] ?? value['en-US'] ?? '';
|
|
51
|
+
}
|
|
52
|
+
return Object.fromEntries(
|
|
53
|
+
Object.entries(value).map(([key, nestedValue]) => [key, localizeValue(nestedValue, lang)]),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function readFixture(fixturesDir, fileName, lang) {
|
|
58
|
+
const fixturePath = path.join(fixturesDir, fileName);
|
|
59
|
+
const raw = fs.readFileSync(fixturePath, 'utf8');
|
|
60
|
+
return localizeValue(JSON.parse(raw), lang);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function readRawFixture(fixturesDir, fileName) {
|
|
64
|
+
const fixturePath = path.join(fixturesDir, fileName);
|
|
65
|
+
return JSON.parse(fs.readFileSync(fixturePath, 'utf8'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function createOrigin(req) {
|
|
69
|
+
return `${req.protocol}://${req.get('host')}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const args = parseArgs(process.argv.slice(2));
|
|
73
|
+
const port = Number(args.port || process.env.TTMG_DOCS_PORT || 4317);
|
|
74
|
+
const publicDir = path.resolve(args['public-dir'] || path.resolve(__dirname, '../../public'));
|
|
75
|
+
const fixturesDir = path.resolve(
|
|
76
|
+
args['fixtures-dir'] || path.resolve(__dirname, '../../../../../../scripts/ttmg-docs/fixtures'),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (!fs.existsSync(publicDir)) {
|
|
80
|
+
console.error(`[ttmg-docs] public directory not found: ${publicDir}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!fs.existsSync(fixturesDir)) {
|
|
85
|
+
console.error(`[ttmg-docs] fixtures directory not found: ${fixturesDir}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const app = express();
|
|
90
|
+
app.use(express.json());
|
|
91
|
+
|
|
92
|
+
const rawConfigFixture = readRawFixture(fixturesDir, 'game-config.json');
|
|
93
|
+
const nodeWsPort = Number(rawConfigFixture?.data?.nodeWsPort || 17890);
|
|
94
|
+
const wsServer = new WebSocket.Server({ port: nodeWsPort });
|
|
95
|
+
|
|
96
|
+
wsServer.on('connection', socket => {
|
|
97
|
+
socket.on('message', () => {
|
|
98
|
+
// Intentionally ignored. The docs pipeline only needs a healthy idle Node WS.
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
app.get('/__health', (_req, res) => {
|
|
103
|
+
res.json({ ok: true });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
app.get('/__docs/blank', (_req, res) => {
|
|
107
|
+
res
|
|
108
|
+
.type('html')
|
|
109
|
+
.send('<!doctype html><html><head><meta charset="utf-8"><title>ttmg docs blank</title></head><body></body></html>');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
app.get('/game/config', (req, res) => {
|
|
113
|
+
const lang = resolveLang(req);
|
|
114
|
+
const fixture = readFixture(fixturesDir, 'game-config.json', lang);
|
|
115
|
+
fixture.data.lang = lang;
|
|
116
|
+
fixture.data.nodeStaticBaseUrl = `${createOrigin(req)}/game/files`;
|
|
117
|
+
res.json(fixture);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
app.post('/game/config-fillback', (req, res) => {
|
|
121
|
+
res.json({
|
|
122
|
+
isSuccess: true,
|
|
123
|
+
data: {
|
|
124
|
+
received: req.body || {},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
app.get('/game/detail', (req, res) => {
|
|
130
|
+
const lang = resolveLang(req);
|
|
131
|
+
const fixture = readFixture(fixturesDir, 'game-detail.json', lang);
|
|
132
|
+
res.json(fixture);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
app.get('/game/check', (req, res) => {
|
|
136
|
+
const lang = resolveLang(req);
|
|
137
|
+
const fixture = readFixture(fixturesDir, 'game-check.json', lang);
|
|
138
|
+
res.json(fixture);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
app.use(express.static(publicDir));
|
|
142
|
+
|
|
143
|
+
app.get('*', (_req, res) => {
|
|
144
|
+
res.sendFile(path.join(publicDir, 'index.html'));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const server = app.listen(port, () => {
|
|
148
|
+
console.log(`[ttmg-docs] server ready at http://127.0.0.1:${port}`);
|
|
149
|
+
console.log(`[ttmg-docs] public dir: ${publicDir}`);
|
|
150
|
+
console.log(`[ttmg-docs] fixtures dir: ${fixturesDir}`);
|
|
151
|
+
console.log(`[ttmg-docs] node ws mock ready at ws://127.0.0.1:${nodeWsPort}`);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
function shutdown(signal) {
|
|
155
|
+
wsServer.close(() => {
|
|
156
|
+
server.close(() => {
|
|
157
|
+
console.log(`[ttmg-docs] server stopped by ${signal}`);
|
|
158
|
+
process.exit(0);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
164
|
+
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttmg/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7-beta.1",
|
|
4
4
|
"description": "TikTok Mini Game Command Line Tool",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"qs": "6.12.1",
|
|
54
54
|
"semver": "^7.7.2",
|
|
55
55
|
"socks-proxy-agent": "^9.0.0",
|
|
56
|
-
"ttmg-pack": "0.4.
|
|
56
|
+
"ttmg-pack": "0.4.8",
|
|
57
57
|
"ws": "^8.18.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as U,r as t,j as e,o as b,i as a,c as k,a9 as y,h as D,T as u,f as F,aa as A}from"./index-BmSg7a2H.js";import{I as x,F as f}from"./baseForm-Dnb99UJB.js";import"./index-CPEErQsP.js";import"./index-C5pU_dUf.js";import"./times-BsXqTKq4.js";import"./isPlainObject-CKjwQ9bg.js";const B=()=>{const{state:{user:r}}=U(),[h,i]=t.useState(!1),[g,l]=t.useState(!1),[j,c]=t.useState(""),[d,n]=t.useState(""),p=t.useRef(null),m=()=>{l(!1),n(""),c("")},v=()=>{i(!1),m(),p.current?.formApi?.reset?.()},C=()=>{r?.email&&i(!0)},N=s=>{const o=s;if(o?.code===0)A.success({title:a("uploadPlatformSuccess"),content:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:a("uploadPlatformDesc")}),e.jsx("div",{style:{marginTop:12,display:"flex",justifyContent:"flex-end"},children:e.jsx(u.Text,{link:!0,onClick:()=>{window.open(o?.data?.detail,"_blank")},children:a("viewOnPlatform")})})]}),duration:10}),i(!1),m();else{const P=o?.error?.StatusMessage||o?.detail||a("uploadPlatformFailed");n(P),l(!1)}},S=s=>{const o=s?.error?.StatusMessage||s?.response?.detail||s?.message||a("uploadPlatformFailed");n(o),l(!1)},T=()=>{l(!0),F({method:"POST",url:"/game/upload",headers:{"ttmg-game-desc":encodeURIComponent(j||"--")}}).then(s=>{N(s)}).catch(s=>{S(s)})};return e.jsxs(e.Fragment,{children:[e.jsx(b,{content:()=>r?.email?null:e.jsx("div",{className:"uploader-login-tip",children:a("loginToUpload")}),children:e.jsxs("div",{className:k("resource-uploader",{"resource-uploader-disabled":!r?.email}),onClick:C,children:[e.jsx(x,{size:"default"}),e.jsx("div",{className:"uploader-text",children:a("upload")})]})}),e.jsx(y,{footer:null,visible:h,onCancel:v,title:a("uploadToPlatform"),children:e.jsxs("div",{className:"uploader-modal-content",children:[g&&e.jsx("div",{className:"upload-loading-container",children:e.jsx("div",{className:"loading-spin",children:e.jsx(D,{size:"large"})})}),d&&e.jsx(u.Text,{style:{color:"red",marginBottom:12,marginTop:12},children:d}),e.jsxs(f,{ref:p,onChange:({values:s})=>{c(s?.gameDescription||"--"),n("")},children:[e.jsx(f.TextArea,{label:a("gameAssetDescription"),placeholder:a("gameAssetDescription"),field:"gameDescription"}),e.jsxs("div",{className:"uploader-button-container",onClick:T,children:[e.jsx(x,{className:"uploader-button-icon"}),e.jsx("div",{className:"uploader-button-text",children:a("uploadGamePackageTip")})]})]})]})})]})};export{B as GameUploader};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.login-user-popover{padding:12px 24px}.not-login-status-popover{padding:12px 24px;max-width:200px}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as n,j as s,o as e,ab as t,i}from"./index-BmSg7a2H.js";const r="/api/passport/web/email/login",a={aid:"2471",account_sdk_source:"web",sdk_version:"2.1.1"};r+""+new URLSearchParams(a);const c=()=>{const{state:{user:o}}=n();return o?.email?s.jsx(e,{position:"bottom",content:s.jsx("div",{className:"login-user-popover",children:o.email}),children:s.jsx(t,{color:"amber",style:{flexShrink:0},alt:o?.email,size:"small",children:o?.email?.split("@")[0][0]})}):s.jsx(e,{position:"bottom",trigger:"hover",content:s.jsx("div",{className:"not-login-status-popover",children:i("notLoginTip")}),children:s.jsx(t,{color:"grey",style:{flexShrink:0},size:"small",children:i("notLogin")})})};export{c as LoginStatus};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.manual-connect-container{padding:16px;height:100%;overflow:hidden}.manual-connect-back{margin:0 0 12px}
|
|
Binary file
|