From 5b095d677f377f02bf20e1d9cbec69bf8f184bd7 Mon Sep 17 00:00:00 2001 From: noelorin Date: Sat, 26 Sep 2026 23:46:21 +0800 Subject: [PATCH] fix(danmaku): browser-safe entry, yarn test wiring, AGENTS map --- AGENTS.md | 6 +++++- app/web/src/lib/danmaku-render.ts | 2 +- package.json | 1 + packages/danmaku/package.json | 4 ++++ packages/danmaku/src/browser.ts | 7 +++++++ turbo.json | 4 ++++ 6 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 packages/danmaku/src/browser.ts diff --git a/AGENTS.md b/AGENTS.md index 86ad5a4..e86ce4d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,6 +13,7 @@ | 包 | 职责 | 依赖 | |----|------|------| | `@app/types` | Zod 入参 schema + 共享输出类型 | zod | +| `@app/danmaku` | 弹幕开放协议纯函数(签名/hash/XML/匹配/过滤;`./browser` 无 node:crypto) | — | | `@app/models` | Drizzle 表定义(唯一 schema 源) | drizzle-orm | | `@app/db` | libSQL/Turso 客户端单例 + drizzle-kit | models | | `@app/dao` | 数据访问层(`userDao` / `mountDao` / `mediaItemDao` 等) | db, models | @@ -29,8 +30,10 @@ ``` web ──► trpc ──► dao ──► db ──► models - │ │ │ + │ │ │ │ + │ │ └──► danmaku │ │ └─────────────────┴──► types + ├──► danmaku(浏览器侧走 ./browser) ├──► design-tokens ├──► seo-geo ├──► i18n @@ -55,6 +58,7 @@ docs(独立,不依赖上述业务包) ```bash yarn install +yarn test # 各包 vitest(turbo run test) yarn typecheck # 全仓 typecheck yarn lint # Biome yarn build # 全仓 build(依赖拓扑) diff --git a/app/web/src/lib/danmaku-render.ts b/app/web/src/lib/danmaku-render.ts index 5bffec1..3c66bcb 100644 --- a/app/web/src/lib/danmaku-render.ts +++ b/app/web/src/lib/danmaku-render.ts @@ -4,7 +4,7 @@ import { serializeDanmakuXml, type DanmakuComment, type FilterOptions, -} from "@app/danmaku"; +} from "@app/danmaku/browser"; export { filterComments, parseDanmakuXml, serializeDanmakuXml }; export type { DanmakuComment, FilterOptions }; diff --git a/package.json b/package.json index ea9bb44..bd5a7bf 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "docs:dev": "yarn workspace @app/docs dev", "docs:build": "yarn workspace @app/docs build", "typecheck": "turbo run typecheck", + "test": "turbo run test", "test:e2e": "playwright test", "lint": "turbo run lint", "clean": "turbo run clean", diff --git a/packages/danmaku/package.json b/packages/danmaku/package.json index 4cb1b01..ec61ca1 100644 --- a/packages/danmaku/package.json +++ b/packages/danmaku/package.json @@ -9,6 +9,10 @@ ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" + }, + "./browser": { + "import": "./dist/browser.js", + "types": "./dist/browser.d.ts" } }, "scripts": { diff --git a/packages/danmaku/src/browser.ts b/packages/danmaku/src/browser.ts new file mode 100644 index 0000000..1f1f740 --- /dev/null +++ b/packages/danmaku/src/browser.ts @@ -0,0 +1,7 @@ +/** 浏览器安全入口:不含 node:crypto(hash/signature)与 fetch 客户端(client)。 */ +export { openCommentsToXml, parseDanmakuXml, serializeDanmakuXml } from "./xml.js"; +export { filterComments, modeToKind } from "./filter.js"; +export type { FilterOptions } from "./filter.js"; +export { parseMatchOutcome, rankCandidates } from "./match.js"; +export type { OpenMatchOutcome } from "./match.js"; +export type { DanmakuComment, MatchCandidate } from "./types.js"; diff --git a/turbo.json b/turbo.json index 9149789..1d0dce3 100644 --- a/turbo.json +++ b/turbo.json @@ -27,6 +27,10 @@ "lint": { "outputs": [] }, + "test": { + "dependsOn": ["^build"], + "outputs": [] + }, "db:generate": { "cache": false, "dependsOn": ["^build"]