套件目錄
依內容、協同、編譯、渲染、程序與應用程式任務選擇 AI SDK 套件。
AI SDK 目前提供 25 個獨立的 package。安裝應用所需的基礎功能包;當同一行的預設命令包預設終端互動符合產品需求時,再加入該預設命令包。
兩種套件角色
| 角色 | 提供內容 |
|---|---|
| 基礎套件 | 結構化 TypeScript API,不依賴 Commander,也不規定命令名稱、輸出和退出行為 |
| 命令預設集套件 | 基於基礎功能包封裝一個原生 Commander Command,提供預設參數、help 和終端互動 |
預設命令包通常以 -command 結尾。並非每個基礎功能包都需要預設命令包。
內容與協同執行環境
這裡的標準 headless Univer 由 Web SDK 的內容外掛組合而成。內容包、UI 包和 engine-render 之間的分工見 Headless 包分類。下文的協同 Runtime 和渲染 Runtime 都是在內容執行時之上按需增加的能力。
| 任務 | 基礎套件 | 命令預設集套件 |
|---|---|---|
| 建立標準無介面 Univer | @univer-cli/headless-univer | — |
| 離線搜尋 Univer Facade API | @univer-cli/api-reference | @univer-cli/api-reference-command |
| 準備並繫結一次 Facade execution | @univer-cli/content-execution | — |
| 讀取 Sheet、Doc 或 Slide 內容 | @univer-cli/content-inspection | @univer-cli/content-inspection-command |
| 執行單一協同 Unit | @univer-cli/univer-collaboration-runtime | — |
| 在 Worker 中重用協同執行環境 | @univer-cli/univer-collaboration-runtime-pool | — |
內容編譯
| 任務 | 基礎套件 | 命令預設集套件 |
|---|---|---|
| 把 SVG 轉成 Slide Facade code | @univer-cli/svg-facade | @univer-cli/svg-facade-command |
| 把 Typst bundle 轉成 Doc Facade code | @univer-cli/doc-typst-facade | @univer-cli/doc-typst-facade-command |
渲染與診斷
| 任務 | 基礎套件 | 命令預設集套件 |
|---|---|---|
| 把 Unit 截成 PNG | @univer-cli/unit-screenshot | @univer-cli/unit-screenshot-command |
| 對 Slide layout 做 lint | @univer-cli/unit-layout-lint | @univer-cli/unit-layout-lint-command |
| 託管 Render Page,驅動瀏覽器 | @univer-cli/univer-render-runtime | — |
| 組合並建置渲染頁面 | @univer-cli/univer-render-page | — |
程序與生命週期
| 任務 | 基礎套件 | 命令預設集套件 |
|---|---|---|
| 依鍵獨占取得、快取並淘汰有狀態物件 | @univer-cli/generic-keyed-instance-pool | — |
| 讓多個 CLI 程序存取同一本機常駐程序 | @univer-cli/daemon | @univer-cli/daemon-command |
應用程式輔助工具
| 任務 | 基礎套件 | 命令預設集套件 |
|---|---|---|
| 宣告、讀取並保存應用程式設定 | @univer-cli/config | @univer-cli/config-command |
| 查詢、快取並匯出視覺資源 | @univer-cli/resource-library | @univer-cli/resource-library-command |
如何選擇
- 先按業務需求找到對應的基礎功能包。
- 預設的 Commander 互動符合產品需求時,再加入對應的預設命令包。
- CLI、Web 和 Server 共享同一個 Unit 時,使用 Collaboration Runtime,而不是直接訪問協同資料庫。
- 應用需要複用、跨程序訪問或瀏覽器渲染時,再引入 pool、daemon 或 Render Runtime。
- 閱讀目標 package 的 README,確認其公共 API、資源所有權和釋放方式。
具體概念和核心用法見文件內容載入與讀寫、視覺檢查和 Runtime 複用與 Daemon。
你覺得這篇文檔如何?