@tbox.cn/app-template-h5 0.1.27 → 1.0.0-alpha.10
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/._.gitignore +0 -0
- package/._.npmignore +0 -0
- package/._.nvmrc +0 -0
- package/._AGENTS.md +0 -0
- package/._LEGAL.md +0 -0
- package/._LICENSE +0 -0
- package/._README.md +0 -0
- package/._eslint.config.mjs +0 -0
- package/._package.json +0 -0
- package/._pnpm-lock.template.yaml +0 -0
- package/._pnpm-workspace.template.yaml +0 -0
- package/._tsconfig.base.json +0 -0
- package/.gitignore +11 -7
- package/.npmignore +7 -0
- package/.tbox/._app.json +0 -0
- package/.tbox/app.json +3 -2
- package/AGENTS.md +22 -62
- package/README.md +20 -31
- package/apps/._AGENTS.md +0 -0
- package/apps/AGENTS.md +13 -0
- package/apps/client/._index.html +0 -0
- package/apps/client/._package.json +0 -0
- package/apps/client/._tsconfig.json +0 -0
- package/apps/client/._vite.config.ts +0 -0
- package/apps/client/._vitest.config.ts +0 -0
- package/apps/client/index.html +0 -4
- package/apps/client/package.json +7 -6
- package/apps/client/src/._app.config.ts +0 -0
- package/apps/client/src/._vite-env.d.ts +0 -0
- package/apps/client/src/app.config.ts +10 -0
- package/apps/client/src/pages/._page.tsx +0 -0
- package/apps/client/src/pages/page.tsx +37 -0
- package/apps/client/src/styles/._tailwind.css +0 -0
- package/apps/client/src/styles/tailwind.css +101 -0
- package/apps/client/tsconfig.json +3 -6
- package/apps/client/vite.config.ts +36 -39
- package/apps/client/vitest.config.ts +10 -0
- package/apps/server/._package.json +0 -0
- package/apps/server/._tsconfig.json +0 -0
- package/apps/server/._tsup.config.ts +0 -0
- package/apps/server/._vitest.config.ts +0 -0
- package/apps/server/package.json +6 -4
- package/apps/server/src/._app.ts +0 -0
- package/apps/server/src/._dev.ts +0 -0
- package/apps/server/src/._index.ts +0 -0
- package/apps/server/src/app.ts +2 -35
- package/apps/server/src/dev.ts +37 -123
- package/apps/server/src/functions/._greet.server.ts +0 -0
- package/apps/server/src/functions/greet.server.ts +5 -0
- package/apps/server/src/index.ts +17 -39
- package/apps/server/tests/._app.test.ts +0 -0
- package/apps/server/tests/app.test.ts +30 -5
- package/apps/server/tsconfig.json +5 -3
- package/apps/server/tsup.config.ts +4 -7
- package/apps/server/vitest.config.ts +0 -1
- package/eslint.config.mjs +1 -1
- package/modules/._.gitkeep +0 -0
- package/modules/.gitkeep +0 -0
- package/package.json +37 -16
- package/packages/shared/._AGENTS.md +0 -0
- package/packages/shared/._package.json +0 -0
- package/packages/shared/._tsconfig.json +0 -0
- package/packages/shared/AGENTS.md +11 -0
- package/packages/shared/package.json +13 -0
- package/packages/shared/src/._index.ts +0 -0
- package/packages/shared/src/index.ts +7 -0
- package/packages/shared/tsconfig.json +7 -0
- package/pnpm-lock.template.yaml +554 -187
- package/pnpm-workspace.template.yaml +13 -18
- package/scripts/._build.sh +0 -0
- package/scripts/._check-css-target.mjs +0 -0
- package/scripts/._check.mjs +0 -0
- package/scripts/._dev.sh +0 -0
- package/scripts/._generate.mjs +0 -0
- package/scripts/._start.sh +0 -0
- package/scripts/._stop.sh +0 -0
- package/scripts/build.sh +2 -26
- package/scripts/check-css-target.mjs +54 -0
- package/scripts/check.mjs +7 -0
- package/scripts/dev.sh +1 -9
- package/scripts/generate.mjs +3 -0
- package/scripts/start.sh +1 -7
- package/apps/client/src/business/App.tsx +0 -3
- package/apps/client/src/business/routes.json +0 -3
- package/apps/client/src/main.tsx +0 -29
- package/apps/client/src/platform/bootstrap.ts +0 -18
- package/apps/client/src/platform/mount-page.tsx +0 -34
- package/apps/client/src/styles/base.css +0 -16
- package/scripts/check-workspace.mjs +0 -144
- package/scripts/prepare.sh +0 -11
package/apps/server/src/app.ts
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* 静态产物见 index.ts(唯一 tsup entry),vite dev 见 dev.ts(仅 tsx)。
|
|
4
|
-
* 平台微调(inspector)在入口级接线(index.ts / dev.ts),保持本模块测试纯净。
|
|
5
|
-
*/
|
|
6
|
-
import { createServer } from 'http';
|
|
7
|
-
import express from 'express';
|
|
8
|
-
import { createLogger } from '@tbox.cn/app-sdk-server';
|
|
9
|
-
|
|
10
|
-
export const app = express();
|
|
11
|
-
const logger = createLogger('server');
|
|
12
|
-
|
|
13
|
-
app.use(express.json());
|
|
14
|
-
|
|
15
|
-
// 健康检查契约(平台探活):GET /api/health → {"status":"ok"}
|
|
16
|
-
app.get('/api/health', (_req, res) => {
|
|
17
|
-
res.json({ status: 'ok' });
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
// 未知 /api/* 恒 JSON 404(不落 SPA 兜底)
|
|
21
|
-
app.use('/api', (_req, res) => {
|
|
22
|
-
res.status(404).json({ error: 'Not Found' });
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export function start() {
|
|
26
|
-
const port = Number(process.env.PORT ?? 8000);
|
|
27
|
-
const host = process.env.HOST ?? '0.0.0.0';
|
|
28
|
-
const server = createServer(app);
|
|
29
|
-
server.on('error', (err) => {
|
|
30
|
-
logger.error('server error:', err);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
});
|
|
33
|
-
server.listen(port, host, () => logger.info(`listening on http://${host}:${port}`));
|
|
34
|
-
return server;
|
|
35
|
-
}
|
|
1
|
+
export { createApp, createPageRuntime, start } from '@tbox.cn/app-sdk-server';
|
|
2
|
+
export type { AppManifest, AppServerModule, ServerRegistry } from '@tbox.cn/app-sdk-server';
|
package/apps/server/src/dev.ts
CHANGED
|
@@ -1,129 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
installInspector,
|
|
20
|
-
isReady,
|
|
21
|
-
resolveDevTokenFromEnv,
|
|
22
|
-
} from '@tbox.cn/app-sdk-server/platform';
|
|
23
|
-
import { createLogger } from '@tbox.cn/app-sdk-server';
|
|
24
|
-
import { app, start } from './app.js';
|
|
25
|
-
|
|
26
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
27
|
-
const serverLogger = createLogger('server');
|
|
28
|
-
const clientRoot = path.resolve(__dirname, '../../client');
|
|
29
|
-
const appRoot = path.resolve(__dirname, '../..');
|
|
30
|
-
|
|
31
|
-
// HMR WS 独立路径与协议常量(scripts/smoke-dev-hmr.sh 断言消费,不得改名):
|
|
32
|
-
// dev 基础设施命名空间(双下划线),与业务命名空间解耦。协议白名单与 Spanner 子协议
|
|
33
|
-
// 补写内聚于 SDK handleUpgrade(本模板 upgrade 形态 = server.on 直连,见文件尾)。
|
|
34
|
-
const HMR_WS_PATH = '/__vite_hmr';
|
|
35
|
-
|
|
36
|
-
// HMR WS hub:永不 listen 的纯事件载体。hmr.server 在场 → vite 不自建独立端口,
|
|
37
|
-
// 客户端按页面同源端口连接。vite 对 hub 仅 on/off('upgrade')。
|
|
38
|
-
const hmrHub = createServer();
|
|
39
|
-
|
|
40
|
-
const tokenState = resolveDevTokenFromEnv(process.env);
|
|
41
|
-
const protectedMode = tokenState.mode === 'protected';
|
|
42
|
-
|
|
43
|
-
// protected 面 fs.allow 收窄(classic 恒默认不传——红线):client 源 + 工作区依赖真源
|
|
44
|
-
// (filter(existsSync):生成应用无 packages/ 时自动滤除,不影响沙箱半径)。
|
|
45
|
-
const workspaceRoot = searchForWorkspaceRoot(clientRoot);
|
|
46
|
-
const fsAllowNarrowed = protectedMode
|
|
47
|
-
? [
|
|
48
|
-
...new Set(
|
|
49
|
-
[
|
|
50
|
-
clientRoot,
|
|
51
|
-
path.join(appRoot, 'packages'),
|
|
52
|
-
path.join(appRoot, 'node_modules'),
|
|
53
|
-
path.join(workspaceRoot, 'packages'),
|
|
54
|
-
path.join(workspaceRoot, 'node_modules'),
|
|
55
|
-
].filter((p) => existsSync(p)),
|
|
56
|
-
),
|
|
57
|
-
]
|
|
58
|
-
: undefined;
|
|
59
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createServer } from 'node:http';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { createServer as createViteServer } from 'vite';
|
|
5
|
+
import { generateApp } from '@tbox.cn/app-build';
|
|
6
|
+
import { createApp, start } from '@tbox.cn/app-sdk-server';
|
|
7
|
+
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const root = path.resolve(here, '../../..');
|
|
10
|
+
const clientDir = path.join(root, 'apps', 'client');
|
|
11
|
+
|
|
12
|
+
const generated = await generateApp({ root, watch: true });
|
|
13
|
+
const [{ registry }] = await Promise.all([
|
|
14
|
+
import('../../client/.tbox-gen/registry.server.ts'),
|
|
15
|
+
]);
|
|
16
|
+
const { appKind } = generated;
|
|
17
|
+
|
|
18
|
+
const httpServer = createServer();
|
|
60
19
|
const vite = await createViteServer({
|
|
61
|
-
|
|
62
|
-
server: {
|
|
63
|
-
|
|
64
|
-
allowedHosts: true, // 沙箱域名 Host 透传放行(dev-only;dist 物理不含 vite)
|
|
65
|
-
fs: {
|
|
66
|
-
...(fsAllowNarrowed ? { allow: fsAllowNarrowed } : {}),
|
|
67
|
-
deny: ['.env', '.env.*', '*.{crt,pem}', '**/.git/**'],
|
|
68
|
-
},
|
|
69
|
-
hmr: { server: hmrHub, path: HMR_WS_PATH },
|
|
70
|
-
},
|
|
71
|
-
appType: 'custom', // 不加 Vite 自己的 SPA fallback,HTML 路由由 runtime.final() 统一处理
|
|
20
|
+
configFile: path.join(clientDir, 'vite.config.ts'),
|
|
21
|
+
server: { middlewareMode: true, hmr: { server: httpServer } },
|
|
22
|
+
appType: 'custom',
|
|
72
23
|
});
|
|
73
24
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
decorateHtml: (html) => (isReady() ? injectScript(html) : html),
|
|
83
|
-
logger: serverLogger,
|
|
84
|
-
sseKeepaliveMs: process.env.TBOX_DEV_SSE_KEEPALIVE_MS ? Number(process.env.TBOX_DEV_SSE_KEEPALIVE_MS) : undefined,
|
|
85
|
-
// v3.2 严格文档模式(G8 模式开关):routes.json 在场 ⇔ strict(dev 面 entry 替换 +
|
|
86
|
-
// public 目录索引;static 面 dist 文件真源)。缺席 = legacy SPA fallback,零变化。
|
|
87
|
-
pagePolicy: {
|
|
88
|
-
routesModule: path.join(clientRoot, 'src/business/routes.json'),
|
|
89
|
-
},
|
|
25
|
+
const app = await createApp({
|
|
26
|
+
manifest: generated.manifest,
|
|
27
|
+
getManifest: () => generated.manifest,
|
|
28
|
+
appKind,
|
|
29
|
+
registry,
|
|
30
|
+
mode: 'dev',
|
|
31
|
+
htmlFile: path.join(clientDir, 'index.html'),
|
|
32
|
+
vite,
|
|
90
33
|
});
|
|
91
34
|
|
|
92
|
-
|
|
93
|
-
|
|
35
|
+
const server = await start(app, { server: httpServer });
|
|
36
|
+
const close = async () => {
|
|
37
|
+
await generated.close();
|
|
38
|
+
await vite.close();
|
|
39
|
+
server.close();
|
|
40
|
+
};
|
|
94
41
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
installInspector(app);
|
|
98
|
-
// 探针路由:smoke-dev-protected.sh ⑩ 断言两面可见性(dev 基础设施,dist 物理不含)
|
|
99
|
-
app.get('/__tbox_dev_freezone_probe', (_req, res) => {
|
|
100
|
-
res.type('text/plain').send('freezone-ok');
|
|
101
|
-
});
|
|
102
|
-
// ── 自由区结束 ──
|
|
103
|
-
|
|
104
|
-
app.use(runtime.final);
|
|
105
|
-
|
|
106
|
-
// protected 面构建通知:watch 增量构建 → BUNDLE_END → SSE 广播 → static 面 reload。
|
|
107
|
-
// fire-and-forget;watch 启动 emptyOutDir 清空 dist 为已定价行为(首建完成前 static 面纯 404)。
|
|
108
|
-
if (protectedMode) {
|
|
109
|
-
viteBuild({ root: clientRoot, build: { watch: {}, sourcemap: false } })
|
|
110
|
-
.then((result) => {
|
|
111
|
-
const watcher = Array.isArray(result) ? result[0] : result;
|
|
112
|
-
if (!watcher || !('on' in watcher)) return;
|
|
113
|
-
watcher.on('event', (e) => {
|
|
114
|
-
if (e.code === 'BUNDLE_START') runtime.notifyBuildStart();
|
|
115
|
-
if (e.code === 'BUNDLE_END') runtime.notifyBuildEnd();
|
|
116
|
-
});
|
|
117
|
-
})
|
|
118
|
-
.catch((err) => console.error('[dev] watch build failed:', err));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const server = start();
|
|
122
|
-
|
|
123
|
-
// 升级处理:唯一 WS 入口 = runtime.handleUpgrade(认领 /__vite_hmr + 子协议白名单 +
|
|
124
|
-
// protected token 校验失败 401;其余一律销毁——本模板无业务 WS,smoke-dev-hmr 断言消费)
|
|
125
|
-
server.on('upgrade', (request, socket, head) => {
|
|
126
|
-
if (!runtime.handleUpgrade(request, socket, head)) {
|
|
127
|
-
socket.destroy();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
42
|
+
process.once('SIGINT', () => void close());
|
|
43
|
+
process.once('SIGTERM', () => void close());
|
|
Binary file
|
package/apps/server/src/index.ts
CHANGED
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import { existsSync } from 'node:fs';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
|
-
import express from 'express';
|
|
10
|
-
import { createLogger } from '@tbox.cn/app-sdk-server';
|
|
11
|
-
import { createStrictStaticHandler, installInspector } from '@tbox.cn/app-sdk-server/platform';
|
|
12
|
-
import { app, start } from './app.js';
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { createApp, start, type AppManifest } from '@tbox.cn/app-sdk-server';
|
|
4
|
+
import manifest from '../../client/.tbox-gen/manifest.json';
|
|
5
|
+
import appMeta from '../../../.tbox/app.json';
|
|
6
|
+
import { registry } from '../../client/.tbox-gen/registry.server';
|
|
13
7
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const clientDir = path.resolve(here, '../../client/dist');
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const app = await createApp({
|
|
12
|
+
manifest: manifest as AppManifest,
|
|
13
|
+
appKind: appMeta.appKind as 'web',
|
|
14
|
+
registry,
|
|
15
|
+
mode: 'prod',
|
|
16
|
+
clientDir,
|
|
17
|
+
});
|
|
20
18
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
logger.warn(`client/dist 缺失(${clientDistPath})——页面将不可用;请先执行 pnpm build:client`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// v3.2 严格文档模式(G8 模式开关):routes.json 在场 ⇔ strict(dist 文件存在性 =
|
|
27
|
-
// 唯一路由真源,未知页面 404 是文件系统的自然结果);缺席 = legacy SPA fallback(等价历史)。
|
|
28
|
-
const routesModule = path.join(__dirname, '../../client/src/business/routes.json');
|
|
29
|
-
if (existsSync(routesModule)) {
|
|
30
|
-
logger.info('page_mode', { mode: 'strict-pages' });
|
|
31
|
-
app.use(createStrictStaticHandler({ distDir: clientDistPath }));
|
|
32
|
-
} else {
|
|
33
|
-
logger.info('page_mode', { mode: 'legacy-spa' });
|
|
34
|
-
app.use(express.static(clientDistPath));
|
|
35
|
-
app.get('*', (req, res) => {
|
|
36
|
-
if (!req.path.startsWith('/api')) {
|
|
37
|
-
res.sendFile(path.join(clientDistPath, 'index.html'));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
start();
|
|
19
|
+
const server = await start(app);
|
|
20
|
+
process.once('SIGTERM', () => server.close());
|
|
Binary file
|
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
import request from 'supertest';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import {
|
|
2
|
+
import { beforeAll, describe, expect, it } from 'vitest';
|
|
3
|
+
import { createApp } from '@tbox.cn/app-sdk-server';
|
|
4
|
+
|
|
5
|
+
const manifest = {
|
|
6
|
+
schemaVersion: 1 as const,
|
|
7
|
+
pages: [{ path: '/', document: 'index.html', title: '首页' }],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const registry = {
|
|
11
|
+
functions: {
|
|
12
|
+
'hello.world': async (input: unknown) => ({ input }),
|
|
13
|
+
},
|
|
14
|
+
tools: [],
|
|
15
|
+
skills: [],
|
|
16
|
+
cards: {},
|
|
17
|
+
modules: [],
|
|
18
|
+
};
|
|
4
19
|
|
|
5
20
|
describe('HTTP API', () => {
|
|
6
|
-
|
|
21
|
+
let app: Awaited<ReturnType<typeof createApp>>;
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
app = await createApp({ manifest, appKind: 'web', registry, mode: 'dev' });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('GET /api/health', async () => {
|
|
7
27
|
const res = await request(app).get('/api/health');
|
|
8
28
|
expect(res.status).toBe(200);
|
|
9
29
|
expect(res.body).toEqual({ status: 'ok' });
|
|
10
30
|
});
|
|
11
31
|
|
|
12
|
-
it('
|
|
32
|
+
it('RPC uses bare body', async () => {
|
|
33
|
+
const res = await request(app).post('/api/fn/hello.world').send({ ok: true }).expect(200);
|
|
34
|
+
expect(res.body).toEqual({ input: { ok: true } });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('unknown /api/* is JSON 404', async () => {
|
|
13
38
|
const res = await request(app).get('/api/nope');
|
|
14
39
|
expect(res.status).toBe(404);
|
|
15
|
-
expect(res.body).
|
|
40
|
+
expect(res.body.error.code).toBe('API_NOT_FOUND');
|
|
16
41
|
});
|
|
17
42
|
});
|
|
@@ -8,19 +8,16 @@ export default defineConfig({
|
|
|
8
8
|
outDir: 'dist',
|
|
9
9
|
clean: true,
|
|
10
10
|
sourcemap: true,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
external: ['express'],
|
|
12
|
+
noExternal: [/^@tbox\.cn\//, /^@app\//],
|
|
13
13
|
esbuildPlugins: [
|
|
14
14
|
{
|
|
15
15
|
name: 'forbid-vite-in-bundle',
|
|
16
16
|
setup(build) {
|
|
17
17
|
build.onResolve({ filter: /^vite(\/|$)/ }, () => ({
|
|
18
|
-
errors: [
|
|
19
|
-
{ text: 'vite 禁止进入 server bundle:dev 形态走 src/dev.ts(仅 tsx),禁入 tsup entry' },
|
|
20
|
-
],
|
|
18
|
+
errors: [{ text: 'vite 禁止进入 server bundle:dev 形态走 src/dev.ts(仅 tsx)' }],
|
|
21
19
|
}));
|
|
22
20
|
},
|
|
23
21
|
},
|
|
24
22
|
],
|
|
25
|
-
|
|
26
|
-
});
|
|
23
|
+
});
|
package/eslint.config.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import reactHooks from "eslint-plugin-react-hooks";
|
|
|
3
3
|
|
|
4
4
|
export default [
|
|
5
5
|
{
|
|
6
|
-
files: ["apps/**/*.ts", "apps/**/*.tsx"],
|
|
6
|
+
files: ["apps/**/*.ts", "apps/**/*.tsx", "modules/**/*.ts", "modules/**/*.tsx"],
|
|
7
7
|
plugins: {
|
|
8
8
|
"@typescript-eslint": tseslint.plugin,
|
|
9
9
|
"react-hooks": reactHooks,
|
|
Binary file
|
package/modules/.gitkeep
ADDED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-template-h5",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "tbox Web 全栈模板(单 workspace:apps/client + apps/server;h5 为家族历史名,不预设端形态),运行时与页面微调经 @tbox.cn/app-sdk。",
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
5
4
|
"type": "module",
|
|
5
|
+
"description": "tbox-app 1.0 Web 全栈模板:apps/client + apps/server 唯一应用代码根 + modules/ 源码根;appKind=web。",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.0.0 <25.0.0"
|
|
8
8
|
},
|
|
@@ -12,14 +12,19 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"apps",
|
|
15
|
+
"packages",
|
|
15
16
|
"!apps/**/dist",
|
|
16
|
-
"!apps
|
|
17
|
-
"!apps/**/.vite",
|
|
17
|
+
"!apps/**/.tbox-gen",
|
|
18
18
|
"!apps/**/node_modules",
|
|
19
|
+
"!apps/**/.vite",
|
|
19
20
|
"!apps/**/*.tsbuildinfo",
|
|
21
|
+
"!packages/**/node_modules",
|
|
22
|
+
"!packages/**/*.tsbuildinfo",
|
|
23
|
+
"modules",
|
|
20
24
|
"scripts",
|
|
21
25
|
".tbox",
|
|
22
26
|
".gitignore",
|
|
27
|
+
".npmignore",
|
|
23
28
|
".nvmrc",
|
|
24
29
|
"AGENTS.md",
|
|
25
30
|
"LEGAL.md",
|
|
@@ -30,24 +35,40 @@
|
|
|
30
35
|
"pnpm-lock.template.yaml",
|
|
31
36
|
"tsconfig.base.json"
|
|
32
37
|
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"express": "4.22.2"
|
|
40
|
+
},
|
|
33
41
|
"devDependencies": {
|
|
42
|
+
"@tbox.cn/app-build": "1.0.0-alpha.10",
|
|
43
|
+
"@tbox.cn/app-sdk-client": "1.0.0-alpha.10",
|
|
44
|
+
"@tbox.cn/app-sdk-server": "1.0.0-alpha.10",
|
|
45
|
+
"@types/node": "24.13.3",
|
|
46
|
+
"@vitejs/plugin-react": "4.7.0",
|
|
34
47
|
"eslint": "9.39.5",
|
|
35
48
|
"eslint-plugin-react-hooks": "5.2.0",
|
|
49
|
+
"typescript": "5.9.3",
|
|
36
50
|
"typescript-eslint": "8.67.0",
|
|
37
|
-
"vite": "6.4.3"
|
|
38
|
-
|
|
51
|
+
"vite": "6.4.3"
|
|
52
|
+
},
|
|
53
|
+
"tbox": {
|
|
54
|
+
"compat": {
|
|
55
|
+
"baseline": {
|
|
56
|
+
"safari": 16.4,
|
|
57
|
+
"chrome": 105
|
|
58
|
+
}
|
|
59
|
+
}
|
|
39
60
|
},
|
|
40
61
|
"scripts": {
|
|
41
|
-
"dev": "pnpm --
|
|
42
|
-
"build": "
|
|
43
|
-
"
|
|
44
|
-
"
|
|
62
|
+
"dev": "pnpm --dir apps/server dev",
|
|
63
|
+
"build": "node scripts/generate.mjs && vite build --config apps/client/vite.config.ts && pnpm --dir apps/server build && node scripts/check-css-target.mjs",
|
|
64
|
+
"start": "node apps/server/dist/index.js",
|
|
65
|
+
"generate": "node scripts/generate.mjs",
|
|
66
|
+
"typecheck": "node scripts/generate.mjs && tsc -p packages/shared/tsconfig.json --noEmit && pnpm -r --filter \"./apps/*\" typecheck",
|
|
45
67
|
"test": "pnpm -r --filter \"./apps/*\" test",
|
|
46
|
-
"lint": "eslint apps",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"check:
|
|
51
|
-
"verify:fast": "pnpm typecheck && pnpm test && pnpm check"
|
|
68
|
+
"lint": "eslint apps packages scripts",
|
|
69
|
+
"check": "node scripts/check.mjs",
|
|
70
|
+
"verify:fast": "pnpm typecheck && pnpm test && pnpm check",
|
|
71
|
+
"verify": "pnpm verify:fast && pnpm build",
|
|
72
|
+
"check:css": "node scripts/check-css-target.mjs"
|
|
52
73
|
}
|
|
53
74
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# packages/shared
|
|
2
|
+
|
|
3
|
+
这是应用唯一的跨端 DTO 包,包名 `@app/shared`。
|
|
4
|
+
|
|
5
|
+
- 只放纯类型、常量、可序列化数据结构。
|
|
6
|
+
- 不 import React、Node、Express、数据库、网络客户端。
|
|
7
|
+
- 不 import `apps/*` 或 `modules/*`。
|
|
8
|
+
- 不放服务端实现、鉴权逻辑、HTTP 客户端。
|
|
9
|
+
- client 与 server 都使用 `import type { ... } from '@app/shared'`。
|
|
10
|
+
- 新增类型按 `<Domain><Action>Input` / `<Domain><Action>Output` 命名。
|
|
11
|
+
- 不放空 `export {}`;至少有一个真实导出。
|
|
Binary file
|