# `src-tauri/tauri.conf.json` — Notes / 说明 ## CSP / 内容安全策略 `app.security.csp` 已配置: - `script-src 'self' 'wasm-unsafe-eval'` — 允许 typst.ts 的 WASM 执行 / allows typst.ts WASM - `connect-src 'self' https://cdn.jsdelivr.net ...` — 允许从 jsdelivr 加载 typst 字体资源 / allows font assets from jsdelivr - `style-src 'self' 'unsafe-inline'` — Svelte 内联样式 / Svelte inline styles ## COOP / COEP (跨源隔离) — ⚠️ 如实说明 AGENTS.md 原假设 Tauri v2 通过 `app.security.headers` 字段设置 COOP/COEP。 但研究表明 **Tauri v2 没有这个字段**(v2 通过自定义 `tauri://` 协议提供前端, 而非可配置 HTTP 服务器)。 **当前处理 / Current handling:** | 环境 / Env | COOP/COEP | 状态 / Status | |---|---|---| | Web (`yarn frontend:dev`) | Vite dev server (`vite.config.ts`) | ✅ 已配置 / configured | | `yarn tauri dev` | 同上 (走 Vite dev server) | ✅ 已配置 / configured | | 生产桌面 (`yarn tauri build`) | 需自定义 protocol handler | ⚠️ **TODO** | **生产桌面的 TODO 方案 / TODO for production desktop:** typst.ts 的线程化 WASM 需要 `SharedArrayBuffer`,后者需要跨源隔离 (COOP `same-origin` + COEP `require-corp`)。 在打包后的桌面应用中,需要: 1. 注册一个自定义 URI scheme(如 `viztyp://`),在其响应中注入这两个 header; 或 2. 使用 Tauri 的 `tauri::http::Response` 自定义 protocol handler; 或 3. 如 typst.ts 0.7.0 在 `tauri://` 单源场景下不需要线程化(降级为单线程 WASM), 则 COOP/COEP 可省略 —— 需在桌面端实测确认。 在桌面端实测确认前,生产构建的跨源隔离标记为 **待验证/待实现**。 web 端与 `tauri dev` 已通过 Vite 完整支持。 --- ## AGENTS.md deviation notes This file documents the honest deviation from AGENTS.md's claim that `app.security.headers` configures COOP/COEP in Tauri v2. See also the top-level `README.md` "Implementation Notes" section.