@deepseek-ai/libreoffice-kit 0.2.2 → 0.2.3-rc.4

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.
Files changed (34) hide show
  1. package/README.md +12 -0
  2. package/README.zh.md +12 -0
  3. package/frame-forwarding/README.md +6 -2
  4. package/frame-forwarding/README.zh.md +6 -2
  5. package/frame-forwarding/include/dsh_frame_forwarding.h +10 -1
  6. package/frame-forwarding/index.d.ts +1 -1
  7. package/frame-forwarding/prebuilds/darwin-arm64/frame-forwarding.node +0 -0
  8. package/frame-forwarding/prebuilds/darwin-arm64/libdsh_frame_forwarding_sdk.a +0 -0
  9. package/frame-forwarding/prebuilds/darwin-arm64/manifest.json +13 -12
  10. package/frame-forwarding/prebuilds/darwin-x64/frame-forwarding.node +0 -0
  11. package/frame-forwarding/prebuilds/darwin-x64/libdsh_frame_forwarding_sdk.a +0 -0
  12. package/frame-forwarding/prebuilds/darwin-x64/manifest.json +13 -12
  13. package/frame-forwarding/prebuilds/win32-arm64/dsh_frame_forwarding_sdk.lib +0 -0
  14. package/frame-forwarding/prebuilds/win32-arm64/frame-forwarding.node +0 -0
  15. package/frame-forwarding/prebuilds/win32-arm64/manifest.json +13 -12
  16. package/frame-forwarding/prebuilds/win32-x64/dsh_frame_forwarding_sdk.lib +0 -0
  17. package/frame-forwarding/prebuilds/win32-x64/frame-forwarding.node +0 -0
  18. package/frame-forwarding/prebuilds/win32-x64/manifest.json +13 -12
  19. package/frame-forwarding/receipt.json +9 -8
  20. package/frame-forwarding/scripts/metadata.mjs +4 -3
  21. package/frame-forwarding/sdk.json +3 -2
  22. package/frame-forwarding/src/producer.cc +30 -7
  23. package/frame-forwarding/src/receiver.cc +7 -1
  24. package/frame-forwarding/src/transport.cc +28 -21
  25. package/frame-forwarding/src/transport.h +13 -0
  26. package/lib/cli.js +69 -20
  27. package/lib/editor.js +52 -15
  28. package/lib/index.js +69 -20
  29. package/lib/types/engine.d.ts +15 -4
  30. package/lib/types/errors.d.ts +6 -0
  31. package/lib/types/index.d.ts +7 -0
  32. package/lib/types/options.d.ts +9 -1
  33. package/lib/types/runtime.d.ts +5 -1
  34. package/package.json +6 -6
package/README.md CHANGED
@@ -106,6 +106,18 @@ The Node API reports its release version through `ENGINE_VERSION`; `ENGINE_VERSI
106
106
 
107
107
  Defaults and all options are documented in the shipped TypeScript declarations in `lib/types/index.d.ts`. Font directories use conventional system/user paths for the selected OS. Indexing skips missing or protected sources and propagates other filesystem errors. `fontkit` indexes original font files and selects installed faces and glyph coverage; it does not rewrite fonts. Each operation discovers font candidates again and revalidates cached file identities. It uses one ordered metadata snapshot; matching entries are invalidated when that snapshot changes. A detected font change during conversion rejects the operation and removes its output. Glyph matching queries only requested Unicode scalars and shares decoding across faces in one physical font collection. It retains scalar answers within the operation and releases each parsed file before examining another; it does not enumerate every glyph or cache font bytes across documents. `missingFonts` contains absent families declared in readable document XML, excluding unrelated engine defaults. Missing glyphs without a named missing family are not a complete document accessibility report.
108
108
 
109
+ ### Engine package resolver
110
+
111
+ By default the adapter locates engine packages with Node module resolution from its own installation. Applications whose engine files live elsewhere on disk pass `resolveEnginePackage` in the options of `createConverter()`, `createConverterFactory()`, `openDocument({ options })`, and `discoverRuntime()`. `discoverRuntime()` accepts and validates the same options object as `createConverter()`, so one object can serve every entry point and all of them select the same engine. The option type is `EnginePackageResolver = (name: string) => string`:
112
+
113
+ - `name` is the platform package (`@deepseek-ai/libreoffice-kit-<target>`) when the host has a native target, then `@deepseek-ai/libreoffice-kit-wasm` if WASM is selected.
114
+ - Return the absolute path of that package's `package.json` synchronously. A relative path, a missing path, a path that is not a file, or a non-string result is an error; it never falls back to WASM.
115
+ - To report that the native package is absent, throw an error whose `code` is `MODULE_NOT_FOUND`, as `require.resolve` does. WASM is then selected through the same resolver. Any other thrown value is an error.
116
+ - The resolver alone decides whether its packages exist: the adapter does not probe its own installation for a package the resolver reports missing. Throw a different error to report a present but incomplete package.
117
+ - Converters, factories, and `discoverRuntime()` reject these errors as `ConversionError` with code `unavailable` and the original error as `cause`. `openDocument()` rejects with the original error, as it does for its other engine errors.
118
+
119
+ The adapter still selects the platform target, applies glibc floors, and validates the version pin and engine assets of the resolved package. The resolver runs on the caller's thread and is not passed to conversion workers. An Electron example is in the [packaging guide](https://github.com/deepseek-ai/dsh-libreoffice-kit/blob/master/docs/packaging.md#engine-package-resolver-for-electron-applications).
120
+
109
121
  ### Font metadata cache
110
122
 
111
123
  Both `createConverter()` and `createConverterFactory()` accept:
package/README.zh.md CHANGED
@@ -106,6 +106,18 @@ Node API 通过 `ENGINE_VERSION` 报告其发布版本;`ENGINE_VERSIONS` 独
106
106
 
107
107
  默认值和所有选项记录在随包发布的 `lib/types/index.d.ts` 类型声明中。字体目录使用所选操作系统的常规系统/用户路径。索引会跳过缺失或受保护的来源,并传播其他文件系统错误。`fontkit` 索引原始字体文件并选择已安装的字面和字形覆盖;它不重写字体。每次操作都会重新发现字体候选并验证缓存中的文件身份。一次操作使用一份有序元数据快照;快照变化后字体匹配条目失效。检测到转换期间字体变化时,操作会失败并删除其输出。字形匹配仅查询请求中的 Unicode 码点,同一物理字体集合中的各字面共享一次解码。码点查询结果只在本次操作内保留,开始检查下一文件前释放当前解析对象;不会遍历所有字形,也不会跨文档缓存字体字节。精确的 family 匹配优先于 `fontFallbacks`。`missingFonts` 包含可读文档 XML 中声明但缺失的 family,不包含无关的引擎默认值。未命名缺失 family 的缺字并不构成完整的文档可访问性报告。
108
108
 
109
+ ### 引擎包解析器
110
+
111
+ 默认情况下,适配器从自身安装位置按 Node 模块解析查找引擎包。引擎文件位于其他磁盘位置的应用,可在 `createConverter()`、`createConverterFactory()`、`openDocument({ options })` 和 `discoverRuntime()` 的选项中传入 `resolveEnginePackage`。`discoverRuntime()` 接受并按相同规则校验与 `createConverter()` 相同的选项对象,因此各入口可共用同一个对象并选择同一引擎。选项类型为 `EnginePackageResolver = (name: string) => string`:
112
+
113
+ - 宿主有原生目标时,`name` 先是平台包(`@deepseek-ai/libreoffice-kit-<target>`);选择 WASM 时为 `@deepseek-ai/libreoffice-kit-wasm`。
114
+ - 同步返回该包 `package.json` 的绝对路径。返回相对路径、不存在的路径、非文件路径或非字符串结果均视为错误,不会回退到 WASM。
115
+ - 要表示原生包不存在,抛出 `code` 为 `MODULE_NOT_FOUND` 的错误(与 `require.resolve` 一致);随后通过同一解析器选择 WASM。抛出其他值均视为错误。
116
+ - 包是否存在只由解析器决定:解析器报告缺失的包,适配器不会再检查自身安装位置。要报告包存在但不完整,请抛出其他错误。
117
+ - 转换器、factory 和 `discoverRuntime()` 以 code 为 `unavailable` 的 `ConversionError` 拒绝上述错误,原始错误保留在 `cause` 中。`openDocument()` 与其处理其他引擎错误的方式一致,直接以原始错误拒绝。
118
+
119
+ 适配器仍负责选择平台目标、应用 glibc 下限,并校验所解析包的版本固定与引擎资源。解析器在调用方线程运行,不会传入转换 Worker。Electron 示例见[打包指南](https://github.com/deepseek-ai/dsh-libreoffice-kit/blob/master/docs/packaging.md#engine-package-resolver-for-electron-applications)。
120
+
109
121
  ### 字体元数据缓存
110
122
 
111
123
  `createConverter()` 和 `createConverterFactory()` 均接受:
@@ -26,6 +26,8 @@ A channel serves one producer connection at a time. Each `connected` event carri
26
26
 
27
27
  Producers and receivers of protocol version 1 declare transferable channels in their handshake. A receiver refuses a producer without that declaration with `transferable-tx-required`, and a producer refuses a receiver whose ready carries no connection ID, so builds that bind producers by PID cannot interoperate with these sources. A producer of another protocol version is refused with `protocol-mismatch`, naming both versions.
28
28
 
29
+ Producers also declare that every handle they name belongs to them. On Windows a frame carries a handle value in the producer's process, and the receiver duplicates it from that process with the access it opened when the producer connected; a value that names no handle of a live producer ends the connection without touching any receiver handle, and a producer that exited took its handles with it, so its connection ends as lost. A receiver refuses a producer without the declaration with `producer-local-handles-required`, and ready echoes the declarations the receiver accepted, so a producer refuses a receiver that would read its handle values as handles of its own. Builds of 0.2.2 and earlier therefore cannot interoperate with these sources in either direction. A receiver that sandboxes its producers can keep this scheme, since only the receiver needs access to the other process.
30
+
29
31
  On Windows, CPU relay retains one imported texture per allocation across staging slots. Reuse requires the NT handle to name the same object and dimensions to match; every frame still acquires key 0 before copying. Allocation retirement drops cached imports before returning credit, while pending copies retain their active source until completion. Systems without `CompareObjectHandles` continue opening and validating each frame.
30
32
 
31
33
  ## Node/TypeScript producer
@@ -46,6 +48,8 @@ The only public C header is `include/dsh_frame_forwarding.h`. The Graphite WebGP
46
48
 
47
49
  On Windows, `dsh_frame_forwarding_connect_with_device` accepts the application’s `ID3D11Device` and retains it until close. Passing null, or using `dsh_frame_forwarding_connect`, creates a default device. Every connect function takes the channel's TX credential. `dsh_frame_forwarding_connect_with_options` additionally bounds connection/handshake time, including a wait while a previous producer drains, and accepts a cancellation callback on the connecting thread; a busy channel fails with text starting `channel-busy`. Applications choose their own GPU; DSH selects the transport. Serialize the adopted device’s immediate context with SDK writes. macOS requires a null device.
48
50
 
51
+ `dsh_frame_forwarding_trim` returns every idle surface to the receiver's shared byte budget: available surfaces, the queued latest frame, granted allocations not yet created and pending requests; acquired and submitted surfaces stay. Call it when the view stops displaying frames, for example after applying an invisible viewport, and the next acquisition requests allocations again. On Windows it flushes the immediate context of the producer's D3D11 device, because D3D11 destroys released textures only at the next flush; call it on the thread that uses that context. The Office engine trims after acknowledging an invisible viewport.
52
+
49
53
  Acquisition initially returns null while the receiver grants allocation credit. Poll and retry when the owning application is ready; do not spin. Allocation requests enter a shared FIFO budget queue. Grants cover idle pool allocations as well as displayed frames. A null acquisition otherwise indicates exhausted credits; terminal allocation errors are reported by polling with `kind = -1` and explanatory text. Stop processing on a negative poll result and preserve its diagnostic before closing. A consumer must bound its overall operation lifetime and disconnect on timeout.
50
54
 
51
55
  Textures use top-left BGRA8 premultiplied pixels in sRGB. Windows surfaces have a keyed mutex using key 0. Acquisition grants a lease without locking: SDK CPU uploads own the write lock; external GPU writers own it themselves through `dsh_frame_forwarding_surface_keyed_mutex` or their import API. Writers release key 0 after queueing commands and release imported objects/views before submit or discard. CPU uploads copy the input before returning and do not wait for GPU completion; `dsh_frame_forwarding_write_bgra_with_timeout` bounds mutex acquisition. `AcquireSync` can block the CPU. macOS writers must complete GPU work before submit or discard. Reusing a surface requires both a new acquisition and the write lock on Windows. If GPU access release fails, close the connection without reusing the surface.
@@ -60,7 +64,7 @@ Application JSON, frame correlation, input semantics, viewport generations and i
60
64
 
61
65
  ## Build and validation
62
66
 
63
- Run `node scripts/build.mjs` on the target platform with complete matching Node headers available. The SDK version comes from the public Kit package metadata. Set `DSH_NODE_INCLUDE` explicitly when necessary; Windows additionally requires a developer toolchain environment and `DSH_NODE_LIB`. Builds produce precompiled Node-API and static SDK artifacts with SHA-256 receipts. Installation never invokes a compiler. Public Kit packing requires all four supported targets from one source commit. Partial payloads cannot be packed. The verifier checks addon and static-library architectures, artifact hashes, source hashes, versions, protocol and the `transferable-tx` capability before signing. Desktop runtime packaging retains only the selected target’s frame-forwarding prebuilds, along with the package license.
67
+ Run `node scripts/build.mjs` on the target platform with complete matching Node headers available. The SDK version comes from the public Kit package metadata. Set `DSH_NODE_INCLUDE` explicitly when necessary; Windows additionally requires a developer toolchain environment and `DSH_NODE_LIB`. Builds produce precompiled Node-API and static SDK artifacts with SHA-256 receipts. Installation never invokes a compiler. Public Kit packing requires all four supported targets from one source commit. Partial payloads cannot be packed. The verifier checks addon and static-library architectures, artifact hashes, source hashes, versions, protocol and the `transferable-tx` and `producer-local-handles` capabilities before signing. Desktop runtime packaging retains only the selected target’s frame-forwarding prebuilds, along with the package license.
64
68
 
65
69
  Run `pnpm test` in this directory after building. `DSH_FRAME_FORWARDING_PACKAGE_ROOT` selects an installed SDK payload for transport and lifecycle tests; diagnostics may be retained outside the package with `DSH_FRAME_FORWARDING_DIAGNOSTICS`. Fixture setup gives each complete compile/link group 120 seconds within a 180-second setup hook; protocol and runner deadlines are separate. Compiler receipts preserve the resolved executable, arguments, working directory, elapsed time, direct-child outcome and stdout/stderr. Compiler descendant exit is not observed. Parent fixtures prepare GPU inspectors and pass their paths only to owned runners, retaining the temporary files until those runners exit. The native CI lane runs C transport and Node producer integration tests serially before packing, including asynchronous shutdown and Worker termination. Performance and Electron shared-texture import require separate actual GPU validation; a successful native transport test alone does not establish those results.
66
70
 
@@ -80,4 +84,4 @@ The public Kit package exports the Node SDK, SDK metadata, verifier, browser and
80
84
 
81
85
  The browser painters/display, Electron adapter probe and generic texture ownership tests originate from DeepSeek Harness commit `21261bee8b9a820c62c9e42cade3ff644b747a29`, under `packages/client/frame-forwarding` and `apps/desktop`. Their unit tests are maintained with these implementations; DSH retains application integration tests.
82
86
 
83
- The MIT SDK originated in DeepSeek Harness commit `4438b67c13d529c9882d89893ed5cd610ace11cc`. Its WebGPU adapter retains the Office fixes from LibreOffice Kit commit `2ae2de8c7e88df00e74ee538ebd5662f47c7a1df`. The Node binding and standalone C SDK share the source tree used by the Kit engine build. Protocol version 1 is unchanged; the `capabilities` field of `sdk.json`, `receipt.json` and each prebuild manifest records `transferable-tx`, which distinguishes current builds from earlier protocol 1 builds.
87
+ The MIT SDK originated in DeepSeek Harness commit `4438b67c13d529c9882d89893ed5cd610ace11cc`. Its WebGPU adapter retains the Office fixes from LibreOffice Kit commit `2ae2de8c7e88df00e74ee538ebd5662f47c7a1df`. The Node binding and standalone C SDK share the source tree used by the Kit engine build. Protocol version 1 is unchanged; the `capabilities` field of `sdk.json`, `receipt.json` and each prebuild manifest records `transferable-tx` and `producer-local-handles`, which distinguish current builds from earlier protocol 1 builds.
@@ -26,6 +26,8 @@ shared-texture 的 `framePolicy` 默认为 `ordered`,保留 Office 瓦片等
26
26
 
27
27
  协议版本 1 的生产者与接收端在握手中声明可转交通道。接收端以 `transferable-tx-required` 拒绝未声明该能力的生产者,生产者拒绝 ready 中不含连接 ID 的接收端,因此按 PID 绑定生产者的旧构建无法与这些源码互通。其他协议版本的生产者以 `protocol-mismatch` 被拒绝,拒绝原因写明双方版本。
28
28
 
29
+ 生产者还声明它指名的每个句柄都属于自己。在 Windows 上,帧携带的是生产者进程中的句柄值,接收端用生产者连接时打开的访问权限从该进程复制它;值若不对应仍在运行的生产者的任何句柄,连接即结束,且不触碰接收端的任何句柄;已退出的生产者带走了自己的句柄,其连接以丢失结束。接收端以 `producer-local-handles-required` 拒绝未作此声明的生产者,ready 回显接收端接受的声明,因此生产者拒绝会把其句柄值当作自身句柄读取的接收端。0.2.2 及更早的构建因此在两个方向上都无法与这些源码互通。为生产者加沙箱的接收端可以沿用该方案,因为只有接收端需要访问另一进程。
30
+
29
31
  Windows CPU 中继按分配保留已导入纹理,供不同 staging 槽使用。仅在 NT 句柄指向同一对象且尺寸一致时复用;每帧复制前仍获取 key 0。分配退役时,先清除缓存导入再返还额度,未完成的复制仍持有其活动源纹理直至完成。不提供 `CompareObjectHandles` 的系统仍逐帧打开并验证纹理。
30
32
 
31
33
  ## Node/TypeScript 生产者
@@ -46,6 +48,8 @@ CPU 上传借用非共享的 Node Buffer,直到返回的 promise 完成。在
46
48
 
47
49
  在 Windows 上,`dsh_frame_forwarding_connect_with_device` 接受应用的 `ID3D11Device`,并保留引用至关闭。传入空值或使用 `dsh_frame_forwarding_connect` 会创建默认设备。所有连接函数都接受通道的 TX 凭据。`dsh_frame_forwarding_connect_with_options` 还限制连接及握手时长(包括等待前一个生产者排空),并接受在连接线程执行的取消回调;通道忙时以 `channel-busy` 开头的文本失败。应用自行选择 GPU,DSH 选择传输方式。使用被接管设备的即时上下文时须与 SDK 写入串行执行。macOS 要求传入空设备。
48
50
 
51
+ `dsh_frame_forwarding_trim` 把所有空闲表面归还接收端的共享字节预算:可用表面、排队中的最新帧、已获批但尚未创建的分配以及尚在申请中的分配;已获取和已提交的表面保留。在视图停止显示帧时调用它,例如应用不可见视口之后,下一次获取会重新申请分配。在 Windows 上它会刷新生产者 D3D11 设备的立即上下文,因为 D3D11 只在下一次刷新时销毁已释放的纹理;请在使用该上下文的线程上调用它。Office 引擎在确认不可见视口后执行收缩。
52
+
49
53
  首次获取表面时返回空值,等待接收端授予分配额度。轮询后在所属应用适合的时机重试,不得忙等。分配请求进入共享 FIFO 预算队列。额度同时覆盖闲置池和显示中的帧。其他获取空值表示额度不足;终止性分配错误由轮询返回 `kind = -1` 和说明文本。轮询返回负数时停止处理,并在关闭前保留诊断信息。消费者必须限制操作总时长,超时后断开连接。
50
54
 
51
55
  纹理采用左上原点、sRGB、BGRA8 预乘像素。Windows 表面带有使用 key 0 的 keyed mutex。获取租约不加锁:SDK CPU 上传持有写锁;外部 GPU 写入方通过 `dsh_frame_forwarding_surface_keyed_mutex` 或导入 API 自行持锁。写入方将命令排队后释放 key 0,并在提交或归还前释放导入对象和视图。CPU 上传在返回前复制输入,不等待 GPU 完成;`dsh_frame_forwarding_write_bgra_with_timeout` 限制锁获取时间。`AcquireSync` 可能阻塞 CPU。macOS 写入方必须在提交或归还前完成 GPU 工作。复用表面需要重新获取租约,Windows 上还必须取得写锁。GPU 访问释放失败时,应关闭连接,不得复用表面。
@@ -60,7 +64,7 @@ Windows Vulkan 和 D3D12 消费者在表面获取期间,通过 `dsh_frame_forw
60
64
 
61
65
  ## 构建与验证
62
66
 
63
- 在目标平台运行 `node scripts/build.mjs`,并提供完整且匹配的 Node 头文件。SDK 版本读取公开 Kit 包元数据。需要时显式设置 `DSH_NODE_INCLUDE`;Windows 还需要开发者工具链环境和 `DSH_NODE_LIB`。构建产出预编译 Node-API 插件、静态 SDK 及 SHA-256 回执。正常安装不调用编译器。公开 Kit 打包必须包含同一源码提交的四个平台,不能打包局部产物。校验同时检查插件和静态库架构、二进制和源码哈希、版本、协议及 `transferable-tx` 能力。Desktop 运行时仅保留目标平台插件和必要元数据、许可证。
67
+ 在目标平台运行 `node scripts/build.mjs`,并提供完整且匹配的 Node 头文件。SDK 版本读取公开 Kit 包元数据。需要时显式设置 `DSH_NODE_INCLUDE`;Windows 还需要开发者工具链环境和 `DSH_NODE_LIB`。构建产出预编译 Node-API 插件、静态 SDK 及 SHA-256 回执。正常安装不调用编译器。公开 Kit 打包必须包含同一源码提交的四个平台,不能打包局部产物。校验同时检查插件和静态库架构、二进制和源码哈希、版本、协议及 `transferable-tx` 与 `producer-local-handles` 能力。Desktop 运行时仅保留目标平台插件和必要元数据、许可证。
64
68
 
65
69
  构建后在本目录运行 `pnpm test`。测试沿用串行范围,覆盖 C 传输、Node 生产者、异步关闭及 Worker 终止。`DSH_FRAME_FORWARDING_PACKAGE_ROOT` 可选择已安装 SDK,`DSH_FRAME_FORWARDING_DIAGNOSTICS` 可将失败诊断保留到包外目录。性能及 Electron 共享纹理导入仍需实际 GPU 验证。
66
70
 
@@ -80,4 +84,4 @@ Windows Vulkan 和 D3D12 消费者在表面获取期间,通过 `dsh_frame_forw
80
84
 
81
85
  浏览器绘制器、display、Electron 适配器探测及通用纹理所有权测试源自 DeepSeek Harness 提交 `21261bee8b9a820c62c9e42cade3ff644b747a29` 的 `packages/client/frame-forwarding` 与 `apps/desktop`。单元测试随实现维护;DSH 保留产品集成测试。
82
86
 
83
- MIT SDK 来自 DeepSeek Harness 提交 `4438b67c13d529c9882d89893ed5cd610ace11cc`,WebGPU 适配器保留 LibreOffice Kit 提交 `2ae2de8c7e88df00e74ee538ebd5662f47c7a1df` 的 Office 修复。Node 绑定、独立 C SDK 与 Kit 引擎使用同一源码目录。协议版本 1 保持不变;`sdk.json`、`receipt.json` 与各预构建清单的 `capabilities` 字段记录 `transferable-tx`,用以区分当前构建与早期协议 1 构建。
87
+ MIT SDK 来自 DeepSeek Harness 提交 `4438b67c13d529c9882d89893ed5cd610ace11cc`,WebGPU 适配器保留 LibreOffice Kit 提交 `2ae2de8c7e88df00e74ee538ebd5662f47c7a1df` 的 Office 修复。Node 绑定、独立 C SDK 与 Kit 引擎使用同一源码目录。协议版本 1 保持不变;`sdk.json`、`receipt.json` 与各预构建清单的 `capabilities` 字段记录 `transferable-tx` 与 `producer-local-handles`,用以区分当前构建与早期协议 1 构建。
@@ -24,7 +24,8 @@ typedef struct dsh_frame_forwarding_event { int kind; char text[DSH_FRAME_FORWAR
24
24
  * starts. The channel serves one connection at a time. While another producer is connected, connect fails with an
25
25
  * error starting "channel-busy". After that producer disconnects, the first authenticated successor waits until the
26
26
  * receiver has released every frame and resource of the previous connection; further candidates fail as busy.
27
- * Without options the wait is unbounded. Receivers that predate transferable credentials are refused.
27
+ * Without options the wait is unbounded. Receivers that predate transferable credentials, or that do not acknowledge
28
+ * that a producer names only handles of its own process, are refused.
28
29
  */
29
30
  dsh_frame_forwarding_client* dsh_frame_forwarding_connect(const char* tx, char* error, size_t error_size);
30
31
  /** Connect using the application's ID3D11Device on Windows; NULL selects the default
@@ -101,6 +102,14 @@ int dsh_frame_forwarding_submit(dsh_frame_forwarding_client* client, dsh_frame_f
101
102
  * Return 0 on failure; a valid acquisition stays with the caller for retry or discard.
102
103
  */
103
104
  int dsh_frame_forwarding_submit_latest(dsh_frame_forwarding_client* client, dsh_frame_forwarding_surface* surface, uint64_t frame_id, const char* metadata_json);
105
+ /** Return every idle surface to the receiver's byte budget: available surfaces, the queued submit_latest frame,
106
+ * granted allocations not yet created, and pending allocation requests. Acquired and submitted surfaces stay. A later
107
+ * acquire requests allocations again. Call it when the view stops displaying frames, for example after applying an
108
+ * invisible viewport. On Windows it flushes the D3D11 immediate context of the producer's device so the released
109
+ * textures are destroyed; call it on the thread that uses that context. Return 1 when every deallocation was sent; 0
110
+ * for a closed client, and then poll reports the error.
111
+ */
112
+ int dsh_frame_forwarding_trim(dsh_frame_forwarding_client* client);
104
113
  /** Return an acquired, unsubmitted surface under the same GPU ownership rules as
105
114
  * submit. If releasing GPU access failed, terminate the connection instead of
106
115
  * discarding. The next writer must acquire key 0 even after a discard.
@@ -24,7 +24,7 @@ export type FrameForwardingEvent =
24
24
  /** GPU completion is unknown, so the connection keeps its resources and budget and its drain waits. */
25
25
  | { type: 'drain-blocked'; connectionId: FrameForwardingConnectionId; text: string }
26
26
  /**
27
- * A candidate was refused: channel-busy, transferable-tx-required, invalid-credential, channel-closed, protocol-mismatch
27
+ * A candidate was refused: channel-busy, transferable-tx-required, producer-local-handles-required, invalid-credential, channel-closed, protocol-mismatch
28
28
  * naming both protocol versions, or a setup failure.
29
29
  */
30
30
  | { type: 'rejected'; text: string }
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "sources": {
3
- "include/dsh_frame_forwarding.h": "b60cb71c80d0401b89990f8faeb19416ec553b231d9f84c7f06a71d0fe0acd02",
3
+ "include/dsh_frame_forwarding.h": "20990b72d6da7494b5abd44a0146767b85d9ba9d8d4ace7fe24e6bbf944a06b2",
4
4
  "src/graphite-interop-internal.hxx": "012bba82e8e0e49f8ed9e62a357d61d5932d248582eafbcd914358d46711bfab",
5
5
  "src/node-producer.cc": "69f4dd6499a7af1d0efce3aa78710e6b6d3564363db077d109eb09791cc565cb",
6
6
  "src/producer-internal.h": "7ebe4756fa7d693567be6fbff3b25e6c29a3be474f0ac42fd51986ecdd14bc72",
7
- "src/transport.h": "e844c1ef2efdc490ad0be400d1f45dc31b9b071d9258bca3ca4b27e12ce8b069",
8
- "src/transport.cc": "c3e752f6213eeeb4070e1885a1fc4b15e9307041834ab8a0f907018107224a8f",
7
+ "src/transport.h": "4ca800c74069e11d3a58ef9261cc003af115ea7b6cfcfa2950473e82e0f79a1e",
8
+ "src/transport.cc": "6927d4f7424ae80b155fb5b83cf4455c17c132cf292437b6c3e8a6b3caceadcc",
9
9
  "src/relay-transport.inc": "3e96b42414c3397ed59fc3323ee29de040f9889c0c474c277e02fd077a92c607",
10
- "src/producer.cc": "df01da4048d8e7849407708be978e98232a5090fed59afbba617e896f6fad156",
11
- "src/receiver.cc": "08346d8020744adefdc5e1b59d011f9ecffa6c161bbbd59eed17068d696a301b",
10
+ "src/producer.cc": "8e90a7d0ee173e2c62823d4962288581e34fb3567cf6e8942aa3fa9935dc0e21",
11
+ "src/receiver.cc": "96fbe8e9b1d8d173de5df5a9455b5a24128570de0213b5f6e0ad757d48d0342e",
12
12
  "src/win-delay-load.cc": "7acf6bad7bdea695163cbf151286787eb0f9144bc53a7a137f3373888c54cb20",
13
13
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
14
14
  "src/graphite-interop.cc": "4f2de8e9ad4bd1aef9220c95d3660937980893f12af006116bed720e7dfaf013",
15
15
  "CMakeLists.txt": "90e821d3718037a60d989b80bc156cb4cc267d66487139e81cf568cb8a54d344",
16
- "sdk.json": "e8f6b12f2772ae71aabae2a10616ffc8eb999d33698084522ab8afe82d52e1b9",
16
+ "sdk.json": "05d5fdf0845272540838c9ce3c453f60391f9c344c8048691ffdba5dc0a37e17",
17
17
  "scripts/build.mjs": "0824c5975106ce2101026d3c7f451643fe28e358b8bff644739fe7614e82c6fa",
18
- "scripts/metadata.mjs": "dd794ba154b147ee37ce10926fb6fae2bb1f60b3c32c10c14b4b498b8a49d589",
18
+ "scripts/metadata.mjs": "a4848f50df31eb905dba1feb5d7df9fed60af4213c14f6ace7f40c5d066ab20c",
19
19
  "scripts/source-identity.mjs": "e8360e59c4c83eeb4110d3a1c278d330f4a2d20b87edefb1f1e527dc17301602",
20
20
  "scripts/build-webgpu.mjs": "919d40e78b7f5d3e2a7de6d5d2e46ca4a26bcce18f98abc1220c59f8cb79ebdd",
21
21
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
22
22
  },
23
- "sourceCommit": "ed3e1c52a8c78b5038ca5d624360a3eed6f0c705",
23
+ "sourceCommit": "ba41be02572d5d0f550f122bd3aaaf7f81af1518",
24
24
  "sourceDirty": false,
25
- "version": "0.2.2",
25
+ "version": "0.2.3-rc.4",
26
26
  "protocolVersion": 1,
27
27
  "capabilities": [
28
- "transferable-tx"
28
+ "transferable-tx",
29
+ "producer-local-handles"
29
30
  ],
30
31
  "platform": "darwin-arm64",
31
32
  "files": {
32
- "frame-forwarding.node": "78d7969a3096eb6930944f2722e3233b9886a3db9a84c371bee8a0f556acd18e",
33
- "libdsh_frame_forwarding_sdk.a": "3ad0d84ca86efd81e9f95aac5214ff34c8d78e504187aa864fb0f846a67b2a80"
33
+ "frame-forwarding.node": "4682ac70dc8c02e17e659a1cd28e4dda7db44b7ff6a939bf46f5436e4fb91a5b",
34
+ "libdsh_frame_forwarding_sdk.a": "6dcd2f07a9a019bd493a5a124686bc284bfdcbbcc75a2fc9eed5f12099ae9f2c"
34
35
  }
35
36
  }
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "sources": {
3
- "include/dsh_frame_forwarding.h": "b60cb71c80d0401b89990f8faeb19416ec553b231d9f84c7f06a71d0fe0acd02",
3
+ "include/dsh_frame_forwarding.h": "20990b72d6da7494b5abd44a0146767b85d9ba9d8d4ace7fe24e6bbf944a06b2",
4
4
  "src/graphite-interop-internal.hxx": "012bba82e8e0e49f8ed9e62a357d61d5932d248582eafbcd914358d46711bfab",
5
5
  "src/node-producer.cc": "69f4dd6499a7af1d0efce3aa78710e6b6d3564363db077d109eb09791cc565cb",
6
6
  "src/producer-internal.h": "7ebe4756fa7d693567be6fbff3b25e6c29a3be474f0ac42fd51986ecdd14bc72",
7
- "src/transport.h": "e844c1ef2efdc490ad0be400d1f45dc31b9b071d9258bca3ca4b27e12ce8b069",
8
- "src/transport.cc": "c3e752f6213eeeb4070e1885a1fc4b15e9307041834ab8a0f907018107224a8f",
7
+ "src/transport.h": "4ca800c74069e11d3a58ef9261cc003af115ea7b6cfcfa2950473e82e0f79a1e",
8
+ "src/transport.cc": "6927d4f7424ae80b155fb5b83cf4455c17c132cf292437b6c3e8a6b3caceadcc",
9
9
  "src/relay-transport.inc": "3e96b42414c3397ed59fc3323ee29de040f9889c0c474c277e02fd077a92c607",
10
- "src/producer.cc": "df01da4048d8e7849407708be978e98232a5090fed59afbba617e896f6fad156",
11
- "src/receiver.cc": "08346d8020744adefdc5e1b59d011f9ecffa6c161bbbd59eed17068d696a301b",
10
+ "src/producer.cc": "8e90a7d0ee173e2c62823d4962288581e34fb3567cf6e8942aa3fa9935dc0e21",
11
+ "src/receiver.cc": "96fbe8e9b1d8d173de5df5a9455b5a24128570de0213b5f6e0ad757d48d0342e",
12
12
  "src/win-delay-load.cc": "7acf6bad7bdea695163cbf151286787eb0f9144bc53a7a137f3373888c54cb20",
13
13
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
14
14
  "src/graphite-interop.cc": "4f2de8e9ad4bd1aef9220c95d3660937980893f12af006116bed720e7dfaf013",
15
15
  "CMakeLists.txt": "90e821d3718037a60d989b80bc156cb4cc267d66487139e81cf568cb8a54d344",
16
- "sdk.json": "e8f6b12f2772ae71aabae2a10616ffc8eb999d33698084522ab8afe82d52e1b9",
16
+ "sdk.json": "05d5fdf0845272540838c9ce3c453f60391f9c344c8048691ffdba5dc0a37e17",
17
17
  "scripts/build.mjs": "0824c5975106ce2101026d3c7f451643fe28e358b8bff644739fe7614e82c6fa",
18
- "scripts/metadata.mjs": "dd794ba154b147ee37ce10926fb6fae2bb1f60b3c32c10c14b4b498b8a49d589",
18
+ "scripts/metadata.mjs": "a4848f50df31eb905dba1feb5d7df9fed60af4213c14f6ace7f40c5d066ab20c",
19
19
  "scripts/source-identity.mjs": "e8360e59c4c83eeb4110d3a1c278d330f4a2d20b87edefb1f1e527dc17301602",
20
20
  "scripts/build-webgpu.mjs": "919d40e78b7f5d3e2a7de6d5d2e46ca4a26bcce18f98abc1220c59f8cb79ebdd",
21
21
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
22
22
  },
23
- "sourceCommit": "ed3e1c52a8c78b5038ca5d624360a3eed6f0c705",
23
+ "sourceCommit": "ba41be02572d5d0f550f122bd3aaaf7f81af1518",
24
24
  "sourceDirty": false,
25
- "version": "0.2.2",
25
+ "version": "0.2.3-rc.4",
26
26
  "protocolVersion": 1,
27
27
  "capabilities": [
28
- "transferable-tx"
28
+ "transferable-tx",
29
+ "producer-local-handles"
29
30
  ],
30
31
  "platform": "darwin-x64",
31
32
  "files": {
32
- "frame-forwarding.node": "caff4701541dea921809a963e79629f16ff3474dff50cc87e6afd2c6758e3a14",
33
- "libdsh_frame_forwarding_sdk.a": "9b92cf49ac886048c8019da9d066776365ad8e4389794ac64920c3ebebe4d0df"
33
+ "frame-forwarding.node": "ca36836fabbf9217102eab0226e3590984f34491b044a7ef7587e06cca877ed4",
34
+ "libdsh_frame_forwarding_sdk.a": "46c47bed559cfa36c734693dc58a8a8342bded73901592fc01be3ba2c4eefc3c"
34
35
  }
35
36
  }
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "sources": {
3
- "include/dsh_frame_forwarding.h": "b60cb71c80d0401b89990f8faeb19416ec553b231d9f84c7f06a71d0fe0acd02",
3
+ "include/dsh_frame_forwarding.h": "20990b72d6da7494b5abd44a0146767b85d9ba9d8d4ace7fe24e6bbf944a06b2",
4
4
  "src/graphite-interop-internal.hxx": "012bba82e8e0e49f8ed9e62a357d61d5932d248582eafbcd914358d46711bfab",
5
5
  "src/node-producer.cc": "69f4dd6499a7af1d0efce3aa78710e6b6d3564363db077d109eb09791cc565cb",
6
6
  "src/producer-internal.h": "7ebe4756fa7d693567be6fbff3b25e6c29a3be474f0ac42fd51986ecdd14bc72",
7
- "src/transport.h": "e844c1ef2efdc490ad0be400d1f45dc31b9b071d9258bca3ca4b27e12ce8b069",
8
- "src/transport.cc": "c3e752f6213eeeb4070e1885a1fc4b15e9307041834ab8a0f907018107224a8f",
7
+ "src/transport.h": "4ca800c74069e11d3a58ef9261cc003af115ea7b6cfcfa2950473e82e0f79a1e",
8
+ "src/transport.cc": "6927d4f7424ae80b155fb5b83cf4455c17c132cf292437b6c3e8a6b3caceadcc",
9
9
  "src/relay-transport.inc": "3e96b42414c3397ed59fc3323ee29de040f9889c0c474c277e02fd077a92c607",
10
- "src/producer.cc": "df01da4048d8e7849407708be978e98232a5090fed59afbba617e896f6fad156",
11
- "src/receiver.cc": "08346d8020744adefdc5e1b59d011f9ecffa6c161bbbd59eed17068d696a301b",
10
+ "src/producer.cc": "8e90a7d0ee173e2c62823d4962288581e34fb3567cf6e8942aa3fa9935dc0e21",
11
+ "src/receiver.cc": "96fbe8e9b1d8d173de5df5a9455b5a24128570de0213b5f6e0ad757d48d0342e",
12
12
  "src/win-delay-load.cc": "7acf6bad7bdea695163cbf151286787eb0f9144bc53a7a137f3373888c54cb20",
13
13
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
14
14
  "src/graphite-interop.cc": "4f2de8e9ad4bd1aef9220c95d3660937980893f12af006116bed720e7dfaf013",
15
15
  "CMakeLists.txt": "90e821d3718037a60d989b80bc156cb4cc267d66487139e81cf568cb8a54d344",
16
- "sdk.json": "e8f6b12f2772ae71aabae2a10616ffc8eb999d33698084522ab8afe82d52e1b9",
16
+ "sdk.json": "05d5fdf0845272540838c9ce3c453f60391f9c344c8048691ffdba5dc0a37e17",
17
17
  "scripts/build.mjs": "0824c5975106ce2101026d3c7f451643fe28e358b8bff644739fe7614e82c6fa",
18
- "scripts/metadata.mjs": "dd794ba154b147ee37ce10926fb6fae2bb1f60b3c32c10c14b4b498b8a49d589",
18
+ "scripts/metadata.mjs": "a4848f50df31eb905dba1feb5d7df9fed60af4213c14f6ace7f40c5d066ab20c",
19
19
  "scripts/source-identity.mjs": "e8360e59c4c83eeb4110d3a1c278d330f4a2d20b87edefb1f1e527dc17301602",
20
20
  "scripts/build-webgpu.mjs": "919d40e78b7f5d3e2a7de6d5d2e46ca4a26bcce18f98abc1220c59f8cb79ebdd",
21
21
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
22
22
  },
23
- "sourceCommit": "ed3e1c52a8c78b5038ca5d624360a3eed6f0c705",
23
+ "sourceCommit": "ba41be02572d5d0f550f122bd3aaaf7f81af1518",
24
24
  "sourceDirty": false,
25
- "version": "0.2.2",
25
+ "version": "0.2.3-rc.4",
26
26
  "protocolVersion": 1,
27
27
  "capabilities": [
28
- "transferable-tx"
28
+ "transferable-tx",
29
+ "producer-local-handles"
29
30
  ],
30
31
  "platform": "win32-arm64",
31
32
  "files": {
32
- "frame-forwarding.node": "28159458b8e421ad74e5b5bde84fa2ea2ef77f5cd458422cafac5f8e4c0d53bc",
33
- "dsh_frame_forwarding_sdk.lib": "e1c3f5a995cb742a0b58748a9e70f971dc82db5c7d12359e9b2558271c9ff4a1"
33
+ "frame-forwarding.node": "c3dec1215309909564755b4f97d5560a5417ae4299ea4d6af60859be88197487",
34
+ "dsh_frame_forwarding_sdk.lib": "1442d0b93d13aaa9a4cd1aef8875a042eb5d4f13d471822381fd8001d72cbc3a"
34
35
  }
35
36
  }
@@ -1,35 +1,36 @@
1
1
  {
2
2
  "sources": {
3
- "include/dsh_frame_forwarding.h": "b60cb71c80d0401b89990f8faeb19416ec553b231d9f84c7f06a71d0fe0acd02",
3
+ "include/dsh_frame_forwarding.h": "20990b72d6da7494b5abd44a0146767b85d9ba9d8d4ace7fe24e6bbf944a06b2",
4
4
  "src/graphite-interop-internal.hxx": "012bba82e8e0e49f8ed9e62a357d61d5932d248582eafbcd914358d46711bfab",
5
5
  "src/node-producer.cc": "69f4dd6499a7af1d0efce3aa78710e6b6d3564363db077d109eb09791cc565cb",
6
6
  "src/producer-internal.h": "7ebe4756fa7d693567be6fbff3b25e6c29a3be474f0ac42fd51986ecdd14bc72",
7
- "src/transport.h": "e844c1ef2efdc490ad0be400d1f45dc31b9b071d9258bca3ca4b27e12ce8b069",
8
- "src/transport.cc": "c3e752f6213eeeb4070e1885a1fc4b15e9307041834ab8a0f907018107224a8f",
7
+ "src/transport.h": "4ca800c74069e11d3a58ef9261cc003af115ea7b6cfcfa2950473e82e0f79a1e",
8
+ "src/transport.cc": "6927d4f7424ae80b155fb5b83cf4455c17c132cf292437b6c3e8a6b3caceadcc",
9
9
  "src/relay-transport.inc": "3e96b42414c3397ed59fc3323ee29de040f9889c0c474c277e02fd077a92c607",
10
- "src/producer.cc": "df01da4048d8e7849407708be978e98232a5090fed59afbba617e896f6fad156",
11
- "src/receiver.cc": "08346d8020744adefdc5e1b59d011f9ecffa6c161bbbd59eed17068d696a301b",
10
+ "src/producer.cc": "8e90a7d0ee173e2c62823d4962288581e34fb3567cf6e8942aa3fa9935dc0e21",
11
+ "src/receiver.cc": "96fbe8e9b1d8d173de5df5a9455b5a24128570de0213b5f6e0ad757d48d0342e",
12
12
  "src/win-delay-load.cc": "7acf6bad7bdea695163cbf151286787eb0f9144bc53a7a137f3373888c54cb20",
13
13
  "src/win-delay-load.LICENSE": "662a1b0115251cfb29c6aed0f221f8847bc49c6365d1c53a62c9f4bccc2489c3",
14
14
  "src/graphite-interop.cc": "4f2de8e9ad4bd1aef9220c95d3660937980893f12af006116bed720e7dfaf013",
15
15
  "CMakeLists.txt": "90e821d3718037a60d989b80bc156cb4cc267d66487139e81cf568cb8a54d344",
16
- "sdk.json": "e8f6b12f2772ae71aabae2a10616ffc8eb999d33698084522ab8afe82d52e1b9",
16
+ "sdk.json": "05d5fdf0845272540838c9ce3c453f60391f9c344c8048691ffdba5dc0a37e17",
17
17
  "scripts/build.mjs": "0824c5975106ce2101026d3c7f451643fe28e358b8bff644739fe7614e82c6fa",
18
- "scripts/metadata.mjs": "dd794ba154b147ee37ce10926fb6fae2bb1f60b3c32c10c14b4b498b8a49d589",
18
+ "scripts/metadata.mjs": "a4848f50df31eb905dba1feb5d7df9fed60af4213c14f6ace7f40c5d066ab20c",
19
19
  "scripts/source-identity.mjs": "e8360e59c4c83eeb4110d3a1c278d330f4a2d20b87edefb1f1e527dc17301602",
20
20
  "scripts/build-webgpu.mjs": "919d40e78b7f5d3e2a7de6d5d2e46ca4a26bcce18f98abc1220c59f8cb79ebdd",
21
21
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2"
22
22
  },
23
- "sourceCommit": "ed3e1c52a8c78b5038ca5d624360a3eed6f0c705",
23
+ "sourceCommit": "ba41be02572d5d0f550f122bd3aaaf7f81af1518",
24
24
  "sourceDirty": false,
25
- "version": "0.2.2",
25
+ "version": "0.2.3-rc.4",
26
26
  "protocolVersion": 1,
27
27
  "capabilities": [
28
- "transferable-tx"
28
+ "transferable-tx",
29
+ "producer-local-handles"
29
30
  ],
30
31
  "platform": "win32-x64",
31
32
  "files": {
32
- "frame-forwarding.node": "db9c21bedc21773284c5832c1925f319f781254f836540b68ca6af03cef51081",
33
- "dsh_frame_forwarding_sdk.lib": "3f4b81468c5de6df0986259b06d188c7b14a487a2edc6a621911edcd182cf3de"
33
+ "frame-forwarding.node": "e11cb4c485de307d9f0ba63e310ae1bb10decf1001ac84b524238c24f6bf6e15",
34
+ "dsh_frame_forwarding_sdk.lib": "cee40c709874a84b6b895d863c732593c8cd48cd27b246f0365632e45a924775"
34
35
  }
35
36
  }
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "package": "@deepseek-ai/libreoffice-kit",
3
- "version": "0.2.2",
3
+ "version": "0.2.3-rc.4",
4
4
  "protocolVersion": 1,
5
5
  "capabilities": [
6
- "transferable-tx"
6
+ "transferable-tx",
7
+ "producer-local-handles"
7
8
  ],
8
9
  "files": {
9
10
  "LICENSE": "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
10
11
  "CMakeLists.txt": "90e821d3718037a60d989b80bc156cb4cc267d66487139e81cf568cb8a54d344",
11
- "sdk.json": "e8f6b12f2772ae71aabae2a10616ffc8eb999d33698084522ab8afe82d52e1b9",
12
- "scripts/metadata.mjs": "dd794ba154b147ee37ce10926fb6fae2bb1f60b3c32c10c14b4b498b8a49d589",
12
+ "sdk.json": "05d5fdf0845272540838c9ce3c453f60391f9c344c8048691ffdba5dc0a37e17",
13
+ "scripts/metadata.mjs": "a4848f50df31eb905dba1feb5d7df9fed60af4213c14f6ace7f40c5d066ab20c",
13
14
  "webgpu-dependencies.json": "99fd5b4763f3621ffe72290ca5ddaa9c26f8d2404b54c9158f20f6fd29a403c2",
14
15
  "scripts/build-webgpu.mjs": "919d40e78b7f5d3e2a7de6d5d2e46ca4a26bcce18f98abc1220c59f8cb79ebdd",
15
- "include/dsh_frame_forwarding.h": "b60cb71c80d0401b89990f8faeb19416ec553b231d9f84c7f06a71d0fe0acd02",
16
+ "include/dsh_frame_forwarding.h": "20990b72d6da7494b5abd44a0146767b85d9ba9d8d4ace7fe24e6bbf944a06b2",
16
17
  "src/graphite-interop-internal.hxx": "012bba82e8e0e49f8ed9e62a357d61d5932d248582eafbcd914358d46711bfab",
17
- "src/producer.cc": "df01da4048d8e7849407708be978e98232a5090fed59afbba617e896f6fad156",
18
+ "src/producer.cc": "8e90a7d0ee173e2c62823d4962288581e34fb3567cf6e8942aa3fa9935dc0e21",
18
19
  "src/producer-internal.h": "7ebe4756fa7d693567be6fbff3b25e6c29a3be474f0ac42fd51986ecdd14bc72",
19
- "src/transport.cc": "c3e752f6213eeeb4070e1885a1fc4b15e9307041834ab8a0f907018107224a8f",
20
- "src/transport.h": "e844c1ef2efdc490ad0be400d1f45dc31b9b071d9258bca3ca4b27e12ce8b069",
20
+ "src/transport.cc": "6927d4f7424ae80b155fb5b83cf4455c17c132cf292437b6c3e8a6b3caceadcc",
21
+ "src/transport.h": "4ca800c74069e11d3a58ef9261cc003af115ea7b6cfcfa2950473e82e0f79a1e",
21
22
  "src/relay-transport.inc": "3e96b42414c3397ed59fc3323ee29de040f9889c0c474c277e02fd077a92c607",
22
23
  "src/graphite-interop.cc": "4f2de8e9ad4bd1aef9220c95d3660937980893f12af006116bed720e7dfaf013"
23
24
  }
@@ -7,10 +7,11 @@ import { fileURLToPath } from 'node:url';
7
7
  export const sdkRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
8
8
  export const targets = ['darwin-arm64', 'darwin-x64', 'win32-x64', 'win32-arm64'];
9
9
  /**
10
- * Wire capabilities beyond protocol version 1 that every build of these sources implements. Version 1 builds without
11
- * `transferable-tx` bind producers by PID and cannot interoperate with these sources.
10
+ * Wire capabilities beyond protocol version 1 that every build of these sources implements and requires of its peer.
11
+ * Version 1 builds without `transferable-tx` bind producers by PID, and builds without `producer-local-handles` send
12
+ * Windows handles duplicated into the receiver; neither interoperates with these sources.
12
13
  */
13
- export const capabilities = ['transferable-tx'];
14
+ export const capabilities = ['transferable-tx', 'producer-local-handles'];
14
15
  export const buildSources = [
15
16
  'include/dsh_frame_forwarding.h', 'src/graphite-interop-internal.hxx', 'src/node-producer.cc', 'src/producer-internal.h', 'src/transport.h', 'src/transport.cc', 'src/relay-transport.inc',
16
17
  'src/producer.cc', 'src/receiver.cc', 'src/win-delay-load.cc', 'src/win-delay-load.LICENSE', 'src/graphite-interop.cc',
@@ -1,8 +1,9 @@
1
1
  {
2
- "version": "0.2.2",
2
+ "version": "0.2.3-rc.4",
3
3
  "protocolVersion": 1,
4
4
  "capabilities": [
5
- "transferable-tx"
5
+ "transferable-tx",
6
+ "producer-local-handles"
6
7
  ],
7
8
  "header": "include/dsh_frame_forwarding.h",
8
9
  "sources": [
@@ -83,6 +83,19 @@ void send_queued(dsh_frame_forwarding_client* client) {
83
83
  void copy_error(char* output, size_t size, const char* message) {
84
84
  if (output && size) { std::strncpy(output, message, size - 1); output[size - 1] = 0; }
85
85
  }
86
+ /**
87
+ * Return every surface that is neither acquired nor submitted to the receiver; the caller holds pool_mutex.
88
+ * @returns Whether every deallocation was sent.
89
+ */
90
+ bool release_idle(dsh_frame_forwarding_client* client) {
91
+ bool sent = true;
92
+ client->surfaces.erase(std::remove_if(client->surfaces.begin(), client->surfaces.end(), [&](auto& surface) {
93
+ if (surface->state == dsh_frame_forwarding_surface::acquired || surface->state == dsh_frame_forwarding_surface::submitted) return false;
94
+ Packet packet; packet.kind = deallocate; packet.allocation_id = surface->allocation_id;
95
+ sent = client->channel->send(packet) && sent; return true;
96
+ }), client->surfaces.end());
97
+ return sent;
98
+ }
86
99
  bool set_text(Packet& packet, const char* text) {
87
100
  if (!text || std::strlen(text) >= sizeof(packet.text)) return false;
88
101
  std::strcpy(packet.text, text); return true;
@@ -92,6 +105,7 @@ std::string refusal(const Packet& packet) {
92
105
  const std::string reason(packet.text, strnlen(packet.text, sizeof(packet.text)));
93
106
  if (reason == reject_busy) return "channel-busy: the frame-forwarding channel already has a producer or a waiting successor";
94
107
  if (reason == reject_capability) return "Frame-forwarding receiver requires a transferable TX producer";
108
+ if (reason == reject_local_handles) return "Frame-forwarding receiver requires a producer that names only its own handles";
95
109
  if (reason == reject_credential) return "Frame-forwarding TX credential was rejected";
96
110
  if (reason == reject_closed) return "Frame-forwarding channel is closed";
97
111
  if (reason.rfind(reject_protocol, 0) == 0) return "Frame-forwarding " + reason;
@@ -129,10 +143,10 @@ static dsh_frame_forwarding_client* connect_impl(const char* endpoint_text, void
129
143
  nullptr, 0, D3D11_SDK_VERSION, &client->device, nullptr, &client->context)))
130
144
  throw std::runtime_error("D3D11 hardware device unavailable");
131
145
  set_text(packet, device_adapter(client->device.Get()).c_str());
132
- packet.max_frames = hello_keyed_mutex | hello_transferable;
146
+ packet.max_frames = hello_keyed_mutex | hello_transferable | hello_producer_local_handles;
133
147
  #else
134
148
  if (device) throw std::runtime_error("IOSurface producer does not accept a graphics device");
135
- packet.max_frames = hello_transferable;
149
+ packet.max_frames = hello_transferable | hello_producer_local_handles;
136
150
  #endif
137
151
  if (!client->channel->send(packet)) throw std::runtime_error("Cannot send frame-forwarding handshake");
138
152
  Received received;
@@ -149,6 +163,8 @@ static dsh_frame_forwarding_client* connect_impl(const char* endpoint_text, void
149
163
  if (reply.kind != ready || !reply.max_frames || !reply.max_bytes) throw std::runtime_error("Frame-forwarding receiver rejected handshake");
150
164
  // A receiver that predates transferable channels answers without a connection identifier.
151
165
  if (!connection) throw std::runtime_error("Frame-forwarding receiver does not support transferable TX credentials");
166
+ // A receiver that does not echo the capability would read this producer's handle values as handles of its own.
167
+ if (!(reply.stride & hello_producer_local_handles)) throw std::runtime_error("Frame-forwarding receiver does not accept producer-local handles");
152
168
  client->channel->bind_connection(connection);
153
169
  client->max_frames = reply.max_frames; client->max_bytes = reply.max_bytes;
154
170
  return client.release();
@@ -183,11 +199,7 @@ dsh_frame_forwarding_surface* dsh_frame_forwarding_acquire(dsh_frame_forwarding_
183
199
  }
184
200
  if (!granted_surface && allocation_pending) return nullptr;
185
201
  if (!granted_surface) {
186
- client->surfaces.erase(std::remove_if(client->surfaces.begin(), client->surfaces.end(), [&](auto& surface) {
187
- if (surface->state == dsh_frame_forwarding_surface::acquired || surface->state == dsh_frame_forwarding_surface::submitted) return false;
188
- Packet packet; packet.kind = deallocate; packet.allocation_id = surface->allocation_id;
189
- client->channel->send(packet); return true;
190
- }), client->surfaces.end());
202
+ release_idle(client);
191
203
  uint64_t allocated_bytes = 0;
192
204
  for (auto& surface : client->surfaces) allocated_bytes += surface->bytes;
193
205
  #if defined(__APPLE__)
@@ -314,6 +326,17 @@ int dsh_frame_forwarding_submit_latest(dsh_frame_forwarding_client* client, dsh_
314
326
  try { surface->metadata = metadata_json; } catch (const std::bad_alloc&) { return 0; }
315
327
  surface->frame_id = frame_id; surface->state = dsh_frame_forwarding_surface::queued; return 1;
316
328
  }
329
+ int dsh_frame_forwarding_trim(dsh_frame_forwarding_client* client) {
330
+ if (!client || client->stopped) return 0;
331
+ std::lock_guard<std::mutex> lock(client->pool_mutex);
332
+ const bool sent = release_idle(client);
333
+ #if defined(_WIN32)
334
+ // D3D11 destroys a released texture only when its context next flushes, which an idle producer would not do.
335
+ client->context->Flush();
336
+ #endif
337
+ if (sent) return 1;
338
+ client->error = "Frame-forwarding allocation channel closed"; return 0;
339
+ }
317
340
  void dsh_frame_forwarding_discard(dsh_frame_forwarding_client* client, dsh_frame_forwarding_surface* surface) {
318
341
  if (!client || !surface || surface->owner != client) return;
319
342
  std::lock_guard<std::mutex> lock(client->pool_mutex);
@@ -663,6 +663,7 @@ struct Connection : std::enable_shared_from_this<Connection> {
663
663
  if (result == 0) continue;
664
664
  if (result < 0) {
665
665
  if (channel->foreign_packet()) fail_connection("Frame-forwarding producer sent a packet for another connection");
666
+ else if (channel->invalid_resource()) fail_connection("Frame-forwarding producer sent a handle it does not own");
666
667
  else if (!stopped) fail_connection("Frame-forwarding producer connection lost");
667
668
  break;
668
669
  }
@@ -847,7 +848,10 @@ struct Receiver {
847
848
  candidate.channel.reset();
848
849
  auto event = new Event; event->type = "rejected"; event->text = reason; emit(event);
849
850
  }
850
- /** @returns The refusal reason, or empty for a producer holding the credential that supports transferable channels. */
851
+ /**
852
+ * @returns The refusal reason, or empty for a producer holding the credential that supports transferable channels and
853
+ * names only handles of its own.
854
+ */
851
855
  std::string authenticate(const Candidate& candidate) const {
852
856
  const auto& packet = candidate.hello.packet;
853
857
  if (packet.marker != magic || packet.kind != hello || !std::memchr(packet.text, 0, sizeof(packet.text))) return reject_credential;
@@ -856,6 +860,7 @@ struct Receiver {
856
860
  + ", receiver version " + std::to_string(DSH_FRAME_FORWARDING_PROTOCOL_VERSION);
857
861
  if (!same_secret(packet.token, endpoint.token)) return reject_credential;
858
862
  if (!(packet.max_frames & hello_transferable)) return reject_capability;
863
+ if (!(packet.max_frames & hello_producer_local_handles)) return reject_local_handles;
859
864
  return {};
860
865
  }
861
866
  /** Promote an authenticated candidate to the current connection; the caller holds state_mutex. */
@@ -873,6 +878,7 @@ struct Receiver {
873
878
  connection->channel->bind_connection(connection->id);
874
879
  Packet response; response.kind = ready; response.max_frames = max_frames;
875
880
  response.max_bytes = source_byte_budget(connection->presentation_path, max_frames, max_bytes);
881
+ response.stride = hello_packet.max_frames & hello_capabilities;
876
882
  // A candidate that vanished while waiting takes no connection.
877
883
  if (!connection->channel->send(response)) return;
878
884
  connection->ledger->connected = true;