Repository navigation
feat(plugins): 视图事件带 width,画布可以写 resize 跟随窗口重新排版 - #109
Merged
Merged
Conversation
会报告宽度的宿主在每个视图事件里带 width(排版视图节点用的宽度,也是顶层画布的宽度),量到宽度之后才发 open;画布的 on 可以写 resize,宽度停止变化 400 ms 后宿主发 resize 和新的 width。契约 README 同时写明缩放为 1 时怎样放 viewBox:不写 pan 时显示整个 viewBox、从左上角开始,写了 pan 时宽度占满视图。 Core 画布校验接受 on: ["viewport", "resize"],schema 同步;Rust、Java、Node 三个 SDK 支持 width 和 resize 并补 README;settings.md 中英说明区域画布按 width 排版和旧宿主下的固定宽度;更新记录登记本次补充,并把 #105 的条目移到时间线。取代 #107。
xiaoyumuxi
marked this pull request as ready for review
November 19, 2026 05:28
This was referenced Nov 19, 2026
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 19, 2026
- shared/plugins/sdk/go:模块 github.com/Lithe-IDEA/Lithe-core-rust/shared/plugins/sdk/go, 包 lithe,Go 1.22+,只用标准库。实现函数协议、宿主服务(凭据、工作区、文档与编辑器、 预览、浏览器、窗口消息、functions/providers 与 functions/invoke、原生终端、订阅)、 插件视图 View(id, handler)、litheKeymapImport 0 和结构化诊断;不实现构建和 VCS 提供者。 Unix 上把协议移到 stdout 的副本、stdout 指向 stderr;处理函数 panic 只结束该次调用, 只发固定的 panic 类别。 - 示例后端 sdk/go/examples/sample-backend 与 Rust 示例跑同一个插件后端场景; 新增 e2e 测试 plugin_sdk_go,sdk-e2e.mjs 先构建 Go 示例再运行。 - 发布方式:Go 模块标签 shared/plugins/sdk/go/v<版本>,没有版本文件和发布工作流; 这次不推送标签。 - 文档:插件总览推荐新插件优先用 Rust 或 Go SDK(构建后端用 Node.js/Java,VCS 后端用 Node.js);契约 README、日志指南、原生终端指南(补 Go 示例)、各参考页和 SDK README 把 Go 列进官方 SDK;e2e 依赖补上 Go 1.22+。 - 协议更新记录:待合入写本 PR;补记已合入的 #109(ui 0 width/resize)和 #108 (managedRuntimes 1 镜像地址),能力表加 managedRuntimes 1。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
类型
feat:在 API-13(插件视图)里做补充。不新增能力版本、宿主方法、通知、清单字段或 SDK 版本;旧宿主、旧插件的行为不变。
改动
契约 README(
shared/plugins/contract/v1/README.md)事件参数
widthwidth:宿主排版视图节点用的宽度,单位为点,是至少为 1 的整数,也是顶层画布的宽度。open,插件第一次排版就能拿到真实宽度。事件
resizeon除viewport外可以写resize。resize和新的width。resize和viewport、settings一样,可以合并成最新的一个。缩放为 1 时怎样放
viewBox(来自 #107)pan:显示整个viewBox,按视图宽度缩放,但不超过height,从左上角开始画。pan:和原来一样,宽度占满视图;缩小到比区域窄时水平居中。跟随窗口的场景
viewBox宽度设成width,按这个宽度排版,并在on里写resize。width的宿主不发resize,它的 Core 也会拒绝写了resize的画布。所以插件只在收到带width的事件后才写resize,否则按自己选的固定宽度排版。Core 校验(
rust/crates/plugin-ui)canvas.rs:画布的on接受viewport和resize。lib.rs:测试 fixture 改成["viewport","resize"],并新增两个用例:未知事件(click)和重复的resize都会被拒绝,报出的字段路径正确。schema(
plugin-ui.schema.json)canvas的说明同步缩放规则和resize。on改为maxItems: 2,items.enum: ["viewport", "resize"]。SDK
ViewEventKind::Resize和ViewEvent::width: Option<f64>;width不是数字时报sdk.view.invalidEventViewEvent.Kind.RESIZE和width()(Double,没有时为 null),校验方式同上resize加入事件种类;width不是数字时拒绝;类型声明加上ViewEvent.width?、'resize'和画布on?: Array<'viewport' | 'resize'>三个 SDK 的 README 都补了一句用法:读
width、写resize、回应 resize 事件。各自的单元测试覆盖四种情况:有width、width为 null、resize 事件、width是字符串时拒绝。参考文档(
reference/domains/settings.md)中英两段各加一条:
width排版,on写resize。viewBox。width的旧宿主下,用固定宽度排版:语言页约 610 点,构建系统页和编译器页右侧详情约 340 点。更新记录(
reference/protocol-changelog.md)后续
open,每个事件都带width,按 400 ms 规则发resize,并实现缩放规则。Core 固定版本会升到本 PR 的 commit。width时按宽度排版并写resize,没有时保留 610/340 的固定宽度。验证
cargo test -p lithe-plugin-ui:10 个通过。cargo test -p lithe-plugin-sdk(Rust SDK):全部通过。mvn -o test(Java SDK):全部通过。npm test:86 个通过;npm run test:types通过。node shared/plugins/scripts/verify-docs.mjs:通过。node shared/plugins/scripts/sdk-e2e.mjs:全部通过(build 2、Java 2、Node 3、Rust 2)。