dsh-univer-office 0.3.9 → 0.4.0
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/artifacts/gateway.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/artifacts/gateway.cjs
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 34432529 bytes
|
|
4
|
+
sha256: 062b049abc7e3b2cba81bb1075ef4e07e21942a01ebe5d4b48985b248aea2055
|
package/docs/architecture.md
CHANGED
|
@@ -174,7 +174,6 @@ src/
|
|
|
174
174
|
collab-service.ts # Gateway 协作领域实现
|
|
175
175
|
comparison/ # 固定版本物化与 Pro History 语义比较
|
|
176
176
|
contract/ # Gateway wire types
|
|
177
|
-
univerfile-sqlite/ # `.univer` 持久化
|
|
178
177
|
viewer-app/ # Viewer browser application
|
|
179
178
|
viewer-support/
|
|
180
179
|
render-preset/ # Viewer 的 Univer 渲染组合
|
|
@@ -212,6 +211,7 @@ src/
|
|
|
212
211
|
actions.ts
|
|
213
212
|
packages/
|
|
214
213
|
unit-comparison-viewer/ # 五类 Unit 的只读双栏比较与差异导航
|
|
214
|
+
univerfile-sqlite/ # `.univer` 持久化、schema 与升级
|
|
215
215
|
lib/
|
|
216
216
|
index.js # gitignored 的 Host 生成入口
|
|
217
217
|
client.js # gitignored 的 ModuleLoader Client bundle
|
|
@@ -220,7 +220,6 @@ artifacts/ # gitignored 的发布运行产物
|
|
|
220
220
|
viewer/ # 从 viewer-app 生成
|
|
221
221
|
render-machine/ # 从 render-machine 生成
|
|
222
222
|
gateway.cjs # 从 gateway-app 生成
|
|
223
|
-
upgrade-worker.cjs # Windows .univer 升级 helper,从 migration/upgrade-worker 生成
|
|
224
223
|
unit-content-worker.mjs # 从 workers/unit-content 生成
|
|
225
224
|
collaboration-runtime-worker.mjs # 从 workers/collaboration-runtime 生成
|
|
226
225
|
worker-chunks/ # 两个 Worker 共享的 SDK chunk,同一次构建生成
|
|
@@ -332,7 +331,7 @@ Unit 的检查、执行和 render-source 读取(lint、截图与 PDF 打印的
|
|
|
332
331
|
|
|
333
332
|
Office 导入与导出由一次性 Unit Content Worker 完成:导入不需要 runtime,导出加载 runtime 后直接写出目标文件,两者都在操作完成或取消后退出,不拥有独立持久状态。Gateway 的 worktree 控制面直接提供 Unit 创建与移除端点,并通过 collaboration service 与 lifecycle event 完成操作。写操作只能针对显式 draft worktree;Gateway 是提交结果和 revision 的唯一依据。
|
|
334
333
|
|
|
335
|
-
Gateway 通过 SDK `register(router)` 注册 HTTP/WebSocket Endpoint,连接跟踪保留路由参数,并在打开失败或关闭时释放记录。Worktree Unit 删除保留应用现有流程;SDK 的可撤销移除接口 `setUnitRemoved` 在本地 Adapter 中明确返回 `INVALID_REQUEST`,不写入移除状态或改变文件格式。Gateway 为 SDK collaboration service 注入 `ILogger`:warn/error 始终写入 Gateway stderr,debug/info 仅在 `UNIVER_DSH_GATEWAY_DEBUG=1` 时输出;SDK 内部失败若没有该 logger 只会表现为不可诊断的通用 500。数据库 Adapter 遵循 SDK 的快照读取契约(`getChangesets`/`getDraftChangesets` 返回裸 changeset 数组,`null` 表示 Unit 不存在)。所有 payload 列(Adapter 与迁移)共用 `univerfile-sqlite/stored-json.ts`:二进制字段编码为与 SDK SQLite Adapter 相同标记的 base64,并在 JSON replacer 中读取 `toJSON` 之前的原值:SDK 的 Rust 物化把 Sheet block 的 `data` 作为 Node `Buffer` 交给 `saveSnapshot`,而 `Buffer#toJSON` 会先于 replacer 把它变成普通对象。
|
|
334
|
+
Gateway 通过 SDK `register(router)` 注册 HTTP/WebSocket Endpoint,连接跟踪保留路由参数,并在打开失败或关闭时释放记录。Worktree Unit 删除保留应用现有流程;SDK 的可撤销移除接口 `setUnitRemoved` 在本地 Adapter 中明确返回 `INVALID_REQUEST`,不写入移除状态或改变文件格式。Gateway 为 SDK collaboration service 注入 `ILogger`:warn/error 始终写入 Gateway stderr,debug/info 仅在 `UNIVER_DSH_GATEWAY_DEBUG=1` 时输出;SDK 内部失败若没有该 logger 只会表现为不可诊断的通用 500。数据库 Adapter 遵循 SDK 的快照读取契约(`getChangesets`/`getDraftChangesets` 返回裸 changeset 数组,`null` 表示 Unit 不存在)。所有 payload 列(Adapter 与迁移)共用 `packages/univerfile-sqlite/src/codec/stored-json.ts`:二进制字段编码为与 SDK SQLite Adapter 相同标记的 base64,并在 JSON replacer 中读取 `toJSON` 之前的原值:SDK 的 Rust 物化把 Sheet block 的 `data` 作为 Node `Buffer` 交给 `saveSnapshot`,而 `Buffer#toJSON` 会先于 replacer 把它变成普通对象。
|
|
336
335
|
|
|
337
336
|
Gateway 中的 Collaboration SDK runtime(trunk Service、Worktree Service、Unit Snapshot Materializer 与 `createUnitRuntime`)统一使用 `execution: { mode: 'in-process' }`。SDK 1.0.4 起默认改为 worker thread,并从 SDK 模块旁加载 `unit-runtime-worker.cjs`;Gateway 打包为单个 CJS,运行时旁边没有该文件,而且按请求创建的 materializer 会为每次调用启动和销毁整个 worker 池。
|
|
338
337
|
|
|
@@ -340,7 +339,7 @@ Viewer Ribbon 的交互式导入导出使用 Gateway 中逐 `.univer` 隔离的
|
|
|
340
339
|
|
|
341
340
|
Gateway 还为 trunk revision 组合 Collaboration SDK History Service 与 Endpoint。Gateway 自己在共享 `.univer` connection 上实现 History database adapter。`history@2` 不再按 revision 派生:每个 Unit 的每个分段保存一条**分段起始**记录(主键 `(unit_id, start_revision)`),`endRevision` 由下一段的起始 revision 计算、不入库,列表按 `startRevision` 降序并以排他的 `beforeRevision` 分页,`hasMore` 只表示页下方仍存在匹配记录。SDK 1.0.0 移除了旧的逐 revision History 读取与重建 API,因此文件 runtime 启动时不再 reconcile 到 trunk head,SDK transport 直接开放。Viewer 为 trunk 的 Sheet、Doc、Slide、Base 与 Board 分别注册官方 History UI;只读审阅可检查历史但不能恢复,可编辑 trunk 视图可显式恢复,worktree 与 merge preview 不呈现历史入口。
|
|
342
341
|
|
|
343
|
-
`.univer` 的整体格式由组件版本表与必要表结构共同识别;当前格式为 v3,对应 core=2、worktree=3、assets=1、history=2。v0 为旧表布局,v1/v2 对应升级前的组件组合;未知版本和混合组件组合拒绝打开。正常打开已有文件必须先通过统一升级入口,再构造当前 Adapter
|
|
342
|
+
Gateway 通过 `@univer/univerfile-sqlite` 的 `openUniverfile()` 打开或新建 `.univer`,得到共用一个连接的 `trunk`、`worktree`、`history`、`assets` 四个 store:前三个满足对应的 SDK 持久化契约并附带 Gateway 需要的查询,`assets` 保存内容寻址的嵌入资产;package 的接口、行为约定和目录职责见 `packages/univerfile-sqlite/README.zh-CN.md`。`.univer` 的整体格式由组件版本表与必要表结构共同识别;当前格式为 v3,对应 core=2、worktree=3、assets=1、history=2。v0 为旧表布局,v1/v2 对应升级前的组件组合;未知版本和混合组件组合拒绝打开。正常打开已有文件必须先通过统一升级入口,再构造当前 Adapter。升级对原文件加锁并备份,在同目录候选文件中完成转换、时间规范化、清理和完整性验证,确认源文件哈希未变后才替换原文件;失败清理候选文件,原文件与备份保持不变。再次打开同一份未变化的文件时复用已有的相同字节备份,不会再写一份新备份。持久化使用 Node 内置的 `node:sqlite`:关闭连接时先 finalize 该连接上的全部语句,再释放文件句柄,因此升级在同一进程内关闭候选连接后直接替换原文件,Windows 上也不需要 helper 进程。替换遇到 `EPERM`、`EBUSY`、`EACCES` 时短暂退避重试,覆盖杀毒或索引服务临时占用文件的情况。Node 22/24 首次加载 `node:sqlite` 时会在 Gateway stderr 打印一条 `ExperimentalWarning`,不影响功能,不做屏蔽。v2→v3 内部按 Core → Worktree → History 转换,前两步读取旧 History 创建信息后才能移除旧表;转换代码归属 `upgrade/`;当前结构(表、索引与组件版本)只在 `schema/v3.ts` 定义,新建文件和升级候选通过 `schema/install.ts` 建表,打开时由格式识别统一校验,Adapter 假定 schema 已就绪,不再建表或校验。Unit 与 Worktree Unit 的创建身份取自 SDK 的 `creatorID`/`createdAt`,trunk 接入的 Worktree Unit 继承其创建信息;旧记录缺失创建者时使用 `anonymous`,时间优先保留文件内已有信息。新提交的 changeset 由 Adapter 写入服务器提交时间,payload 的 `createTime` 使用 Unix 秒,数据库时间列使用 Unix 毫秒;迁移同步规范化旧 payload,History 读取无需猜测单位。History 迁移保留旧分段边界,并与 SDK 官方迁移有意不同:缺失的 revision 2 起点会补齐,超过 Core head 的起点会丢弃,某个 Unit 的旧 History 无法转换时只清空该 Unit 的 History,不让整个升级失败。
|
|
344
343
|
|
|
345
344
|
worktree Compare 由 Gateway 创建有界的固定比较会话:右侧始终是路由指定的 draft 或 ready worktree,左侧默认是 trunk,也可选择同一文件中的另一个活跃 worktree。会话在创建时固定两侧 Unit heads,并为每个 Unit 记录 paired、left-only 或 right-only;后续读取只从这些固定 revision 物化最终 snapshot 与 changeset,不随 live head 漂移。Gateway 使用同版本 Univer Pro History 计算产品语义差异,并通过 `/diff` 返回带版本号、分页、筛选、稳定实体身份与产品定位信息的 JSON;新增或删除的整 Unit 使用镜像空侧的 snapshot 比较。任一 live head 变化只把结果标记为 stale,Viewer 必须由用户显式刷新以创建新会话。
|
|
346
345
|
|
|
@@ -452,7 +451,7 @@ Client 必须满足:
|
|
|
452
451
|
|
|
453
452
|
发布包包含运行所需的 Gateway、Viewer、Unit Content Worker、Collaboration Runtime Worker、Office 转换器、平台依赖、Univer license 与 bundled Skills。Gateway、Worker、Viewer 和 Host 直接使用 manifest 中精确版本的 Univer SDK/API Reference packages;JavaScript SDK 被 bundle,平台原生 package 由包管理器为目标机器安装。发布时只打包从当前源码生成的运行产物。
|
|
454
453
|
|
|
455
|
-
|
|
454
|
+
原生公式引擎与 Office 转换器仍具有平台属性;`.univer` 使用 Node 内置的 `node:sqlite`,不再随包携带 SQLite 原生依赖。release workflow 必须在目标平台安装 lockfile 所指定的依赖后构建和测试,不能把一个平台的 `node_modules` 复制为通用发布物。
|
|
456
455
|
|
|
457
456
|
## 13. 验证策略
|
|
458
457
|
|
package/lib/build-info.json
CHANGED
package/lib/index.js
CHANGED
|
@@ -4498,7 +4498,7 @@ function gatewayLaunch(port) {
|
|
|
4498
4498
|
UNIVER_COLLAB_GATEWAY_PORT: String(port),
|
|
4499
4499
|
UNIVER_VIEW_ASSETS_ROOT: VIEWER_ROOT,
|
|
4500
4500
|
// Let the gateway and worker resolve their native dependencies
|
|
4501
|
-
// (@univerjs-pro/exchange-node-binding, engine-formula-rust-binding
|
|
4501
|
+
// (@univerjs-pro/exchange-node-binding, engine-formula-rust-binding) from this
|
|
4502
4502
|
// plugin's node_modules; the formula binding package resolves its own
|
|
4503
4503
|
// platform binary (no NAPI_RS_NATIVE_LIBRARY_PATH override needed).
|
|
4504
4504
|
NODE_PATH: [PLUGIN_NODE_MODULES, process.env.NODE_PATH].filter((value) => value !== void 0 && value.length > 0).join(delimiter)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-univer-office",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "DSH × Univer integration with a bundled collaboration Gateway and Viewer: inline previews, live floating Worktree windows, and session-end review actions in DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -76,18 +76,18 @@
|
|
|
76
76
|
"lint:fix": "oxlint --fix .",
|
|
77
77
|
"format": "oxfmt .",
|
|
78
78
|
"format:check": "oxfmt --check .",
|
|
79
|
-
"typecheck": "tsc --project tsconfig.json --noEmit && tsc --project tsconfig.client.json && tsc --project tsconfig.viewer.json --noEmit && tsc --project tsconfig.render.json --noEmit && tsc --project tsconfig.test.json",
|
|
79
|
+
"typecheck": "tsc --project tsconfig.json --noEmit && tsc --project tsconfig.client.json && tsc --project tsconfig.viewer.json --noEmit && tsc --project tsconfig.render.json --noEmit && tsc --project tsconfig.test.json && pnpm --filter @univer/univerfile-sqlite typecheck",
|
|
80
80
|
"test:unit": "vitest run --project unit",
|
|
81
81
|
"test:integration": "vitest run --project integration",
|
|
82
82
|
"test:e2e": "vitest run --project e2e",
|
|
83
83
|
"test:comparison": "pnpm --filter @univer/unit-comparison-viewer test",
|
|
84
|
+
"test:univerfile": "pnpm --filter @univer/univerfile-sqlite test",
|
|
84
85
|
"test": "pnpm run build && vitest run",
|
|
85
86
|
"verify:public-dependencies": "node scripts/verify-public-runtime-dependencies.mjs"
|
|
86
87
|
},
|
|
87
88
|
"dependencies": {
|
|
88
89
|
"@puppeteer/browsers": "^3.2.0",
|
|
89
90
|
"@univerjs-pro/cli-assets": "0.1.0",
|
|
90
|
-
"libsql": "^0.5.29",
|
|
91
91
|
"puppeteer-core": "^25.7.0",
|
|
92
92
|
"@univerjs-pro/engine-formula-rust-binding": "1.0.3",
|
|
93
93
|
"@univerjs-pro/exchange-node-binding": "1.0.4"
|
|
@@ -8,31 +8,14 @@ import { fileURLToPath } from 'node:url'
|
|
|
8
8
|
const script = fileURLToPath(import.meta.url)
|
|
9
9
|
const packageRoot = resolve(dirname(script), '..')
|
|
10
10
|
const requireFromPlugin = createRequire(join(packageRoot, 'package.json'))
|
|
11
|
-
const nativePackages = [
|
|
12
|
-
'@libsql/darwin-arm64',
|
|
13
|
-
'@libsql/darwin-x64',
|
|
14
|
-
'@libsql/linux-arm64-gnu',
|
|
15
|
-
'@libsql/linux-arm64-musl',
|
|
16
|
-
'@libsql/linux-x64-gnu',
|
|
17
|
-
'@libsql/linux-x64-musl',
|
|
18
|
-
'@libsql/linux-arm-gnueabihf',
|
|
19
|
-
'@libsql/linux-arm-musleabihf',
|
|
20
|
-
'@libsql/win32-x64-msvc'
|
|
21
|
-
]
|
|
22
11
|
const runtimePackages = [
|
|
23
12
|
'@univerjs-pro/engine-formula-rust-binding',
|
|
24
13
|
'@univerjs-pro/exchange-node-binding',
|
|
25
14
|
'@univerjs-pro/cli-assets'
|
|
26
15
|
]
|
|
27
16
|
|
|
28
|
-
/** Copy
|
|
17
|
+
/** Copy the Gateway's external runtime packages and the platform bindings they resolve. */
|
|
29
18
|
export function copyGatewayDependencies(targetRoot) {
|
|
30
|
-
const libsql = locatePackage('libsql', requireFromPlugin)
|
|
31
|
-
const requireFromLibsql = createRequire(join(libsql, 'index.js'))
|
|
32
|
-
for (const name of ['libsql', '@neon-rs/load', 'detect-libc']) {
|
|
33
|
-
const source = name === 'libsql' ? libsql : locatePackage(name, requireFromLibsql)
|
|
34
|
-
copyPackage(source, join(targetRoot, 'node_modules', ...name.split('/')))
|
|
35
|
-
}
|
|
36
19
|
for (const name of runtimePackages) {
|
|
37
20
|
const source = locatePackage(name, requireFromPlugin)
|
|
38
21
|
copyPackage(source, join(targetRoot, 'node_modules', ...name.split('/')))
|
|
@@ -47,20 +30,6 @@ export function copyGatewayDependencies(targetRoot) {
|
|
|
47
30
|
}
|
|
48
31
|
}
|
|
49
32
|
}
|
|
50
|
-
let nativeCount = 0
|
|
51
|
-
for (const name of nativePackages) {
|
|
52
|
-
try {
|
|
53
|
-
copyPackage(
|
|
54
|
-
locatePackage(name, requireFromLibsql),
|
|
55
|
-
join(targetRoot, 'node_modules', ...name.split('/'))
|
|
56
|
-
)
|
|
57
|
-
nativeCount++
|
|
58
|
-
} catch (error) {
|
|
59
|
-
if (error?.code !== 'MODULE_NOT_FOUND') throw error
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (nativeCount === 0) throw new Error('libsql platform package is not installed')
|
|
63
|
-
return nativeCount
|
|
64
33
|
}
|
|
65
34
|
|
|
66
35
|
function locatePackage(name, requireFrom) {
|
|
@@ -102,6 +71,6 @@ function copyPackage(source, destination) {
|
|
|
102
71
|
if (process.argv[1] !== undefined && resolve(process.argv[1]) === script) {
|
|
103
72
|
const target = process.argv[2]
|
|
104
73
|
if (target === undefined) throw new Error('usage: copy-gateway-dependencies.mjs <package-root>')
|
|
105
|
-
|
|
106
|
-
console.log(
|
|
74
|
+
copyGatewayDependencies(resolve(target))
|
|
75
|
+
console.log('Copied Gateway dependencies')
|
|
107
76
|
}
|