tina4-nodejs 3.13.33 → 3.13.34
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/CLAUDE.md +2 -2
- package/package.json +1 -1
- package/packages/cli/src/commands/init.ts +3 -3
- package/packages/core/src/server.ts +12 -20
package/CLAUDE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# CLAUDE.md — AI Developer Guide for tina4-nodejs (v3.13.
|
|
1
|
+
# CLAUDE.md — AI Developer Guide for tina4-nodejs (v3.13.34)
|
|
2
2
|
|
|
3
3
|
> This file helps AI assistants (Claude, Copilot, Cursor, etc.) understand and work on this codebase effectively.
|
|
4
4
|
|
|
@@ -946,7 +946,7 @@ The `tina4` Rust CLI is the sole file watcher for the Tina4 stack — there is n
|
|
|
946
946
|
|
|
947
947
|
No configuration needed — set `TINA4_DEBUG=true` to enable. If you're running without the Rust CLI (e.g. Docker), there is no automatic reload; the production path is unaffected.
|
|
948
948
|
|
|
949
|
-
**AI dual-port mode:** when `TINA4_DEBUG=true` and `TINA4_NO_AI_PORT` is unset, the main port
|
|
949
|
+
**AI dual-port mode:** when `TINA4_DEBUG=true` and `TINA4_NO_AI_PORT` is unset, the **main port** provides the normal hot-reload experience (dev toolbar + `/__dev_reload` injected) for the human dev, and a second server on `port+1000` is the **stable AI port** — it suppresses reload/toolbar injection (and returns 404 for `/__dev_reload`) so an AI tool can drive it without its own edits triggering a refresh. The `tina4` client posts `/__dev/api/reload` to the **main port**. Matches Python (master), PHP, and Ruby.
|
|
950
950
|
|
|
951
951
|
## Conventions You Must Follow
|
|
952
952
|
|
package/package.json
CHANGED
|
@@ -63,11 +63,11 @@ export async function initProject(name: string): Promise<void> {
|
|
|
63
63
|
private: true,
|
|
64
64
|
type: "module",
|
|
65
65
|
scripts: {
|
|
66
|
-
dev: "
|
|
67
|
-
serve: "
|
|
66
|
+
dev: "npx tina4nodejs serve",
|
|
67
|
+
serve: "npx tina4nodejs serve",
|
|
68
68
|
},
|
|
69
69
|
dependencies: {
|
|
70
|
-
"tina4-nodejs": "^0.0
|
|
70
|
+
"tina4-nodejs": "^3.0.0",
|
|
71
71
|
},
|
|
72
72
|
devDependencies: {
|
|
73
73
|
typescript: "^5.7.0",
|
|
@@ -1379,17 +1379,11 @@ ${reset}
|
|
|
1379
1379
|
// Assign to module-level so handle() can dispatch without a server reference
|
|
1380
1380
|
_dispatchFn = dispatch;
|
|
1381
1381
|
|
|
1382
|
-
//
|
|
1383
|
-
//
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
const
|
|
1387
|
-
? async (req: IncomingMessage, res: ServerResponse) => {
|
|
1388
|
-
(req as any)._tina4AiPort = true;
|
|
1389
|
-
await dispatch(req, res);
|
|
1390
|
-
}
|
|
1391
|
-
: dispatch;
|
|
1392
|
-
const server = createServer(mainPortDispatch);
|
|
1382
|
+
// Dual-port (debug + no TINA4_NO_AI_PORT): the MAIN port hot-reloads for the human
|
|
1383
|
+
// dev; the stable AI port (port+1000, created below) suppresses reload/toolbar so an
|
|
1384
|
+
// AI tool can drive it without its own edits triggering refreshes. The tina4 client
|
|
1385
|
+
// posts /__dev/api/reload to the MAIN port. Matches Python (master).
|
|
1386
|
+
const server = createServer(dispatch);
|
|
1393
1387
|
|
|
1394
1388
|
return new Promise((resolvePromise) => {
|
|
1395
1389
|
server.listen(port, host, () => {
|
|
@@ -1405,16 +1399,17 @@ ${reset}
|
|
|
1405
1399
|
// Determine server mode label
|
|
1406
1400
|
const serverMode = isDebug ? "single" : (cluster.isWorker ? "cluster-worker" : "single");
|
|
1407
1401
|
|
|
1408
|
-
// AI dual-port: main port =
|
|
1409
|
-
//
|
|
1410
|
-
//
|
|
1402
|
+
// AI dual-port: main port = hot-reload (human dev); port+1000 = stable AI port
|
|
1403
|
+
// (reload/toolbar suppressed) so an AI tool can drive it without its edits
|
|
1404
|
+
// triggering refreshes. The tina4 client fires reloads at the MAIN port. Matches Python.
|
|
1411
1405
|
const noAiPort = isTruthy(process.env.TINA4_NO_AI_PORT ?? "");
|
|
1412
1406
|
let aiServer: ReturnType<typeof createServer> | null = null;
|
|
1413
1407
|
let testPort = port + 1000;
|
|
1414
1408
|
|
|
1415
1409
|
if (isDebug && !noAiPort) {
|
|
1416
|
-
//
|
|
1410
|
+
// Stable AI port (port+1000): tag requests so /__dev_reload + toolbar are suppressed.
|
|
1417
1411
|
aiServer = createServer(async (req, res) => {
|
|
1412
|
+
(req as any)._tina4AiPort = true;
|
|
1418
1413
|
await dispatch(req, res);
|
|
1419
1414
|
});
|
|
1420
1415
|
|
|
@@ -1451,11 +1446,8 @@ ${reset}
|
|
|
1451
1446
|
}
|
|
1452
1447
|
const noBrowser = isTruthy(process.env.TINA4_NO_BROWSER);
|
|
1453
1448
|
if (!noBrowser) {
|
|
1454
|
-
// Open browser on
|
|
1455
|
-
|
|
1456
|
-
? `http://${displayHost}:${testPort}`
|
|
1457
|
-
: `http://${displayHost}:${port}`;
|
|
1458
|
-
openBrowser(browserTarget);
|
|
1449
|
+
// Open the browser on the MAIN port — that's the hot-reload port.
|
|
1450
|
+
openBrowser(`http://${displayHost}:${port}`);
|
|
1459
1451
|
}
|
|
1460
1452
|
resolvePromise({
|
|
1461
1453
|
close: () => {
|