@xcanwin/manyoyo 7.0.1 → 7.0.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/lib/web/server.js CHANGED
@@ -4076,20 +4076,30 @@ function applyServeTitle(html, ctx) {
4076
4076
  if (typeof ctx.serveTitle !== 'string') {
4077
4077
  return html;
4078
4078
  }
4079
- // serveTitle 已配置(含空字符串):固定 <title>,覆盖模板默认的 MANYOYO Web
4080
- return html.replace('<title>MANYOYO Web</title>', () => `<title>${escapeHtmlText(ctx.serveTitle)}</title>`);
4079
+ // 正则匹配任意 <title> 内容而非硬编码 "MANYOYO Web",兼容 app.html/shadcn.html 各自的默认标题
4080
+ return html.replace(/<title>[^<]*<\/title>/, () => `<title>${escapeHtmlText(ctx.serveTitle)}</title>`);
4081
4081
  }
4082
4082
 
4083
- function renderIndexHtml(ctx) {
4084
- let html = applyServeTitle(loadTemplate('app.html'), ctx);
4085
- if (typeof ctx.serveTitle === 'string') {
4086
- // 告知前端跳过按会话动态改写 document.title
4087
- html = html.replace(
4088
- '</head>',
4089
- () => ` <script>window.__MANYOYO_SERVE_TITLE__ = ${jsonForInlineScript(ctx.serveTitle)};</script>\n</head>`
4090
- );
4083
+ function injectServeTitleFlag(html, ctx) {
4084
+ if (typeof ctx.serveTitle !== 'string') {
4085
+ return html;
4091
4086
  }
4092
- return html;
4087
+ // 告知 app.js 跳过按会话动态改写 document.title
4088
+ return html.replace(
4089
+ '</head>',
4090
+ () => ` <script>window.__MANYOYO_SERVE_TITLE__ = ${jsonForInlineScript(ctx.serveTitle)};</script>\n</head>`
4091
+ );
4092
+ }
4093
+
4094
+ function renderIndexHtml(ctx) {
4095
+ return injectServeTitleFlag(applyServeTitle(loadTemplate('app.html'), ctx), ctx);
4096
+ }
4097
+
4098
+ function renderShadcnHtml(ctx) {
4099
+ // shadcn 前端目前没有按会话动态改写 document.title 的逻辑,不需要 __MANYOYO_SERVE_TITLE__ 标记;
4100
+ // 且 shadcn.html 是 vite singlefile 打包产物,全部依赖内联成一个 <script>,用 .replace('</head>', ...)
4101
+ // 有极小概率命中某个库源码里字面量出现的 "</head>",把注入脚本插进内联脚本中间导致整页解析错乱
4102
+ return applyServeTitle(loadTemplate('shadcn.html'), ctx);
4093
4103
  }
4094
4104
 
4095
4105
  function renderLoginHtml(ctx) {
@@ -4301,7 +4311,7 @@ async function handleWebAuthRoutes(req, res, pathname, ctx, state) {
4301
4311
  // shadcn/ui 版前端的登录页:与 /shadcn 复用同一份构建产物,
4302
4312
  // 由前端按 pathname 自行渲染登录表单,登录逻辑仍复用 /auth/login 接口
4303
4313
  if (req.method === 'GET' && pathname === '/shadcn/auth/login') {
4304
- sendHtml(res, 200, loadTemplate('shadcn.html'));
4314
+ sendHtml(res, 200, applyServeTitle(loadTemplate('shadcn.html'), ctx));
4305
4315
  return true;
4306
4316
  }
4307
4317
 
@@ -5480,7 +5490,7 @@ async function startWebServer(options) {
5480
5490
 
5481
5491
  // shadcn/ui 版前端的试验性入口,构建产物见 frontend-shadcn/(npm run build:web-shadcn)
5482
5492
  if (req.method === 'GET' && pathname === '/shadcn') {
5483
- sendHtml(res, 200, loadTemplate('shadcn.html'));
5493
+ sendHtml(res, 200, renderShadcnHtml(ctx));
5484
5494
  return;
5485
5495
  }
5486
5496
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcanwin/manyoyo",
3
- "version": "7.0.1",
3
+ "version": "7.0.3",
4
4
  "imageVersion": "1.9.1-common",
5
5
  "playwrightCliVersion": "0.1.18",
6
6
  "description": "AI Agent CLI Security Sandbox for Docker and Podman",