feat(plugins): overlays, web pages floating over the workbench (API 1.18) (#6046)

[[contributes.overlays]] declares a package web page that floats over the workbench at one of nine anchors while its when clause holds. It never takes the keyboard focus when shown (out of the tab order), sits under dialogs, popups and notifications, and can let every click through (interactive = false). The page moves and resizes itself with openidea.overlay.get() / place({ anchor, width, height }); sizes are clamped to 40-800 px. It needs no code and no capability, since the page sees nothing of the IDE.

Overlays are gated on plugin API 1.18.0 (package openidea:[email protected].0, engine, SDK, api_compat, rebuilt components); 1.17 is listed as shipped with 0.1.53.

Part of #6012

Co-authored-by: xirf <[email protected]>
Цей коміт міститься в:
Anka Tamaтаxirf authored and GitHub committed 2026-11-26 20:11:03 +08:00
1 джерело 14f143b703
коміт 2bbba9b945
183 files changed
+832 -193

No files matched your search

+1 -1
Переглянути файл
@@ -34,7 +34,7 @@ use std::path::{Component, Path, PathBuf};
pub const MANIFEST_FILE: &str = "plugin.toml";
/// The plugin API (engine) version this host implements.
pub const ENGINE_VERSION: &str = "1.17.0";
pub const ENGINE_VERSION: &str = "1.18.0";
/// The 0.1 API, still accepted for contribution-only packages and 0.1 components.
pub const LEGACY_API: &str = "0.1";
/// Marketplace categories, in the order they are shown.
+1
Переглянути файл
@@ -95,6 +95,7 @@ pub fn register_builtin_points(
registry.register(Arc::new(UiPoint::new(p::VIEWS, ui.clone(), p::view)))?;
registry.register(Arc::new(UiPoint::new(p::CUSTOM_EDITORS, ui.clone(), p::custom_editor)))?;
registry.register(Arc::new(UiPoint::new(p::EDITOR_PANELS, ui.clone(), p::editor_panel)))?;
registry.register(Arc::new(UiPoint::new(p::OVERLAYS, ui.clone(), p::overlay)))?;
registry.register(Arc::new(UiPoint::new(p::MARKER_ICONS, ui.clone(), p::marker_icon)))?;
registry.register(Arc::new(UiPoint::new(p::FILE_ICONS, ui.clone(), p::file_icon)))?;
registry.register(Arc::new(UiPoint::new(p::FILE_TEMPLATES, ui.clone(), p::file_template)))?;
+121 -1
Переглянути файл
@@ -44,6 +44,15 @@
//! width = 110 # pixels, 40–400
//! when = "plugin.<id>.enabled" # optional
//!
//! [[contributes.overlays]]
//! id = "stage"
//! web = "web/stage.html" # floats over the workbench, never takes the focus (API 1.18)
//! width = 320 # pixels, 40–800; the page can resize it within those bounds
//! height = 240
//! anchor = "bottom-right" # top-left … bottom-right (nine); the page can move it
//! when = "plugin.<id>.showing" # optional
//! interactive = true # optional; false lets every click through to the IDE
//!
//! [[contributes.fileIcons]]
//! id = "drawing"
//! patterns = ["*.excalidraw"]
@@ -82,8 +91,9 @@ pub const SETTINGS: &str = "settings";
pub const VIEWS: &str = "views";
pub const CUSTOM_EDITORS: &str = "customEditors";
pub const EDITOR_PANELS: &str = "editorPanels";
pub const OVERLAYS: &str = "overlays";
/// The points whose declarations can name a `web` page (served, messaged, sent view events).
pub const WEB_POINTS: [&str; 3] = [VIEWS, CUSTOM_EDITORS, EDITOR_PANELS];
pub const WEB_POINTS: [&str; 4] = [VIEWS, CUSTOM_EDITORS, EDITOR_PANELS, OVERLAYS];
pub const FILE_ICONS: &str = "fileIcons";
pub const MARKER_ICONS: &str = "markerIcons";
pub const FILE_TEMPLATES: &str = "fileTemplates";
@@ -887,6 +897,69 @@ pub(super) fn editor_panel(pkg: &Package, decl: toml::Value) -> Result<UiDecl, S
Ok(out)
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
struct OverlayDecl {
id: String,
web: String,
width: u32,
height: u32,
#[serde(default = "default_overlay_anchor")]
anchor: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
when: Option<String>,
#[serde(default = "default_true")]
interactive: bool,
}
fn default_overlay_anchor() -> String {
"bottom-right".into()
}
fn default_true() -> bool {
true
}
/// Where an overlay can sit in the window (the page may move it to another).
pub const OVERLAY_ANCHORS: [&str; 9] = [
"top-left",
"top-center",
"top-right",
"middle-left",
"center",
"middle-right",
"bottom-left",
"bottom-center",
"bottom-right",
];
const OVERLAY_SIZE: std::ops::RangeInclusive<u32> = 40..=800;
/// `[[contributes.overlays]]` (API 1.18): a web page floating over the workbench at
/// one of nine anchors, shown while `when` holds. It never takes the keyboard focus,
/// sits under dialogs and popups, and sees nothing of the IDE, so it needs no
/// capability.
pub(super) fn overlay(pkg: &Package, decl: toml::Value) -> Result<UiDecl, String> {
let d: OverlayDecl = decode(OVERLAYS, decl)?;
pkg.manifest.needs_api(&format!("contributes.{OVERLAYS}"), 18)?;
validate_item_id(&d.id, "overlay id")?;
let what = format!("overlay {:?}", d.id);
for (name, value) in [("width", d.width), ("height", d.height)] {
if !OVERLAY_SIZE.contains(&value) {
return Err(format!("{what}: `{name}` is {}–{} pixels", OVERLAY_SIZE.start(), OVERLAY_SIZE.end()));
}
}
if !OVERLAY_ANCHORS.contains(&d.anchor.as_str()) {
return Err(format!("{what}: `anchor` is one of {}", OVERLAY_ANCHORS.join(", ")));
}
if let Some(when) = &d.when {
validate_when(when).map_err(|e| format!("{what}: {e}"))?;
}
let files = super::web::web_files(pkg, &d.web, &what)?;
let mut out = UiDecl::new(d.id.clone(), d.id.clone(), json(&d)?);
out.files = files;
Ok(out)
}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
struct FileIconDecl {
@@ -1518,6 +1591,53 @@ web = "web/view.html"
assert!(check(VIEWS, &view_with(r#"["https://example.com"]"#), &ask).unwrap_err().contains("capability"));
}
#[test]
fn overlays_validate_api_size_anchor_when_and_page() {
let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/overlay");
// A Windows checkout may have CRLF line ends; the edits below match on `\n`.
let source = std::fs::read_to_string(root.join("plugin.toml")).unwrap().replace("\r\n", "\n");
let check = |source: &str| {
let manifest = ide_extension::Manifest::parse(source)?;
let decl = manifest.declarations(OVERLAYS).into_iter().next().unwrap();
overlay(&Package::new(manifest, root.clone()), decl)
};
let valid = check(&source).unwrap();
assert_eq!(valid.key, "probe");
assert_eq!(
valid.json,
serde_json::json!({
"id": "probe", "web": "web/index.html", "width": 260, "height": 140,
"anchor": "bottom-right", "interactive": true,
})
);
assert_eq!(valid.files, [PathBuf::from("web/index.html")]);
let placed =
check(&source.replace("height = 140", "height = 140\nanchor = \"top-center\"\ninteractive = false"));
let placed = placed.unwrap();
assert_eq!(placed.json["anchor"], "top-center");
assert_eq!(placed.json["interactive"], false);
let when = source.replace("height = 140", "height = 140\nwhen = \"plugin.overlay.showing\"");
assert_eq!(check(&when).unwrap().json["when"], "plugin.overlay.showing");
for size in ["40", "800"] {
assert!(check(&source.replace("width = 260", &format!("width = {size}"))).is_ok(), "{size}");
}
for (bad, error) in [
(source.replace("^1.18", "^1.17"), "1.18"),
(source.replace("width = 260", "width = 39"), "40–800"),
(source.replace("height = 140", "height = 801"), "`height`"),
(source.replace("height = 140\n", ""), "height"),
(source.replace("height = 140", "height = 140\nanchor = \"left\""), "anchor"),
(source.replace("height = 140", "height = 140\nwhen = \"a &&\""), "when"),
(source.replace("height = 140", "height = 140\nfocus = true"), "focus"),
(source.replace("web/index.html", "index.html"), "directory of its own"),
(source.replace("web/index.html", "web/missing.html"), "no such file"),
(source.replace(r#"id = "probe""#, r#"id = "Pro Be""#), "id"),
] {
let err = check(&bad).unwrap_err();
assert!(err.contains(error), "{bad}\n→ {err}");
}
}
fn package_with_catalogs(files: &[(&str, &str)]) -> (tempfile::TempDir, Package) {
let dir = tempfile::tempdir().unwrap();
std::fs::create_dir(dir.path().join(LOCALES_DIR)).unwrap();
+1 -1
Переглянути файл
@@ -59,7 +59,7 @@ use views_bindings::exports::openidea::plugin::view_provider as wit_view;
use views_bindings::openidea::plugin::view_types as wit_vt;
/// The API version of the world above, `major.minor` of [`host_api`].
pub const API_VERSION: &str = "1.17";
pub const API_VERSION: &str = "1.18";
const EPOCH_TICK: Duration = Duration::from_millis(10);
pub(crate) const MAX_TEXT: usize = 1 << 20;
/// The most text, and the most PNG bytes, `ui.read-clipboard` returns.
+5 -4
Переглянути файл
@@ -95,7 +95,7 @@ fn the_sdk_carries_the_hosts_wit() {
#[test]
fn the_version_check_runs_compatible_components_and_explains_the_rest() {
let host = v("1.17.0");
let host = v("1.18.0");
for ok in [
"1.0.0",
"1.3.0",
@@ -113,15 +113,16 @@ fn the_version_check_runs_compatible_components_and_explains_the_rest() {
"1.15.0",
"1.16.0",
"1.17.0",
"1.18.0",
"1.0.0-rc.1",
] {
assert_eq!(check_api(&v(ok), &host), Ok(()), "{ok}");
}
let newer = check_api(&v("1.18.0"), &host).unwrap_err();
assert!(newer.contains("1.18") && newer.contains("update OpenIDEA"), "{newer}");
let newer = check_api(&v("1.19.0"), &host).unwrap_err();
assert!(newer.contains("1.19") && newer.contains("update OpenIDEA"), "{newer}");
assert!(check_api(&v("2.0.0"), &host).unwrap_err().contains("update OpenIDEA"));
let older = check_api(&v("0.2.0"), &host).unwrap_err();
assert!(older.contains("rebuild it with the 1.17 SDK"), "{older}");
assert!(older.contains("rebuild it with the 1.18 SDK"), "{older}");
// 0.x: every minor is its own API.
assert_eq!(check_api(&v("0.2.0"), &v("0.2.5")), Ok(()));
assert!(check_api(&v("0.1.0"), &v("0.2.0")).is_err());
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
98e9c2b886df177bafb68a712fc1efadc4f3a7b82e8425cd1b3f4c2355bdb785
80e4575f24617a74ffbe378e65fc4c94a787fdf4af0af2bb803b32ea05ee733b
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
bb77bc0963451ca4259591bf68c72ae3eb70b1c6f855fa29dfc84d2be675404c
193aaf067d10c138d450e03439d92b38b33fb3df163be578d8fb7714c0fb5b8a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
f381b0e20520bccf5acd46b95641f5542885184352e52ec2fed3fd53665c353b
7d9a2c8ec95815f6eda56b255532ed5507cfd9b9f4857429c02b46ee565ac73f
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
f72a53e7b800b8c5408c7ac67034821f814da7b1d66f527949450431bcf52e02
9a5bb4274c8c96e2ca1de9b910631dca21894e4bb15c861aab30fb063b509008
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
3cd2f02738b07d9a6294025cbcc6e906716d3e91db50a6f39485df9b1d6a4ead
2d09ba041deac4ddb91a9f1a5cca5b0593cec03af511d6714c741b95538458cc
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
d77b80884163628791b292acc59324d3b9a7c2236034b88f87e8f56af5929a48
6eaacf2bf54a370a1317c5fdc1e66913ad445d8bd28a6a9d493b9f24ac67db30
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
5a79d35e9fc1560a39b6459312a14c27c73739fd385f6c2568f9b1c1bf8fe4a1
c46d5ec0847f4a15344d5820a9552101f72b186ece670e87344f9d38631c445d
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
264be0e527b0cc200e2d97e982b7b297ef6181a7669506ccf09159531f91124d
4c7f16dab179e3cf4cf7336a10aa7172ea24be7f7a51c2aa4e9706709594955d
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
6230dce145f2cce3033c4797566cbbff8c98e5d8c85d41f9342693b19a10b638
1c6aa7527ff3cca00774b732150d49424b7aab42e5eb55c458d08bae84ed9361
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
3d7d853fa40ce14ae6781dbf5607153c4f38b2663a31f1ca29a753e8eba79f03
aa5f02ba0fd04e8076a954f4f8a373aca36589bca6a4423874037ec9d91e20e9
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
a128c5f640b42d323059a7be1bd2e89cb9de1ea1ea635b5af4e9f69b66bfd04c
f1850efd177d0c8c81028f5c0aef6ca93c8b64bbc4a076ea3ca28786b918eb4a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
9e00f4bcad39a99f05c35ac66962a574f7edd5713f1aa404ef72fd7ef945d1e8
63e34c58c4d4459a6e6fbc58ac24d7109d5b891333612078e97c60101857ae4f
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
7e0ae6bfc8217c37a68e9010920a5bd3478f654b6cfaf3f54e0ef5aacae546b8
41d96facedea486aaf0d3c8c6e51b6b1ae99fe06e441fe1314397a0288de2e8b
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
97c4d6aaf88d552d736021e21bb1f1e1594800ceb771644eb1f3356c0efbc42a
1198aa38409c43a6eb8a911245c7eba026d516c9fbf023b015a02b3e626c077d
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
5a65f921bb1f0ed0f0f10811f8960d9ea9e7ded59d5172356e7cc93f05b4bd5e
6f0537694f331d6dcb78c57b1b7abba101ad95f467b9452331a8346013699649
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
2d148151a9b0a2ab4c479183e3d2ab07d0432d8645dbf95c0e04385ef25830d8
26381e6f8271a154f9ff61f284eb136b586a1b59433f344c6668831036acc4b4
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
63136a78f4279b140c74ff07146b79ca2ce6c7a4fffd6176e811828aad911e0e
0fd8c92f74050593e02ffc304181f9ddc2902996312bc63a9aafc1f35480775a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
e6bf5c74e18ab47577c1e88294fa4961fe8a1e56fb3e34fec5154dab74dfd805
381a9c30d98f10c7b1d51628528bf2326036e505b3ff054855517f884fbe05ec
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
ad5a9fef07a6e9db8fe0375d0ba9d2e92247c28303876ac52db2dbf938bf96ae
02e5d5a85c1126572344baaaba661880fb5d373e1e243c3bafd79c306bd01460
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
fdbcd1afce0d106be463ef43d31245fcb4b9e84287ede78fb8abe740ea28b247
2dcabe9069a235e5b1b410eda2e2b532210d4984e05cc20b78d1e4997c635308
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
c9eb17c9f7e334b05bc5104204fb12a88dceafe36dbd04510e439539f2a1d464
7818c157ef1410b36470628b7847690e8715f35a2e93af079aaf4651f6fd0549
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
14ba72bbc8013b8e2a7f87e85a7046edc4fb4a2256f3fae3ac735241096e4428
128d6c8c12db56d04630665329643eab59bcd17a019841b4d20173268b793663
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
91b190eb62077bde52916a09d76a474584725e73cf3acf45613aecbc8c37c421
6a6b8707f24bcb8f1360533c0d29a43fbb40be26b791a7ddf9544065cc734df9
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
90b20d5ec2d36fa585e3f921672b6477c9691f184151f7059dd429fd7ccc09cf
a881c6712ab7e7c67534b65f564e5780d3cac8a10650f7913200b33d17600b8b
+3 -3
Переглянути файл
@@ -5,9 +5,9 @@ wit_bindgen::generate!({
inline: "
package fixture:misbehave;
world misbehave {
include openidea:plugin/plugin-syntax@1.17.0;
export openidea:plugin/providers@1.17.0;
export openidea:plugin/file-actions@1.17.0;
include openidea:plugin/plugin-syntax@1.18.0;
export openidea:plugin/providers@1.18.0;
export openidea:plugin/file-actions@1.18.0;
}
",
path: "../../../../../wit",
+11
Переглянути файл
@@ -0,0 +1,11 @@
id = "overlay"
name = "Overlay Probe"
version = "0.1.0"
description = "Test fixture for [[contributes.overlays]]: a card floating over the workbench that moves itself around with openidea.overlay.place, no code."
engines.openidea = "^1.18"
[[contributes.overlays]]
id = "probe"
web = "web/index.html"
width = 260
height = 140
+44
Переглянути файл
@@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
html, body { margin: 0; height: 100%; background: transparent; }
.card {
box-sizing: border-box;
height: 100%;
padding: 12px;
border-radius: 10px;
background: var(--openidea-bg-elevated);
border: 1px solid var(--openidea-border);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
font: var(--openidea-font-size) var(--openidea-font-ui);
color: var(--openidea-fg);
}
button { font: inherit; margin: 8px 6px 0 0; }
</style>
</head>
<body>
<div class="card">
<strong>Overlay probe</strong>
<div id="where"></div>
<button id="move" type="button">Next anchor</button>
<button id="grow" type="button">Toggle size</button>
</div>
<script>
const anchors = ["top-left", "top-center", "top-right", "middle-right", "bottom-right", "bottom-center", "bottom-left", "middle-left", "center"];
let at = anchors.indexOf("bottom-right");
let big = false;
const show = (p) => { document.getElementById("where").textContent = `${p.anchor}, ${p.width}×${p.height}`; };
openidea.overlay.get().then(show);
document.getElementById("move").onclick = () => {
at = (at + 1) % anchors.length;
openidea.overlay.place({ anchor: anchors[at] }).then(show);
};
document.getElementById("grow").onclick = () => {
big = !big;
openidea.overlay.place(big ? { width: 360, height: 220 } : { width: 260, height: 140 }).then(show);
};
</script>
</body>
</html>
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0f7fc3035725b0262925b9e062bb72bf1e875eab4aa1eb040df4c1708db7c4bd
402e15d6bcc050160cf24e4a2e7f4c05de12961e1461c856f8d78560a3eac059
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0dc9ad2f7c8c73c92e36cf709e5275d13ed4f5067b1322f0a76160ff92bf8bdc
faf3ef90a388276bdf4f392a1049809361068230155893cb0a4250fb1da08063
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
6e17ea89659c70e925075d2825d34c61252ab511ccb2bdbad7af29d76b97b84e
e719093d97accc6044110e49284f385c7dbe803024ea2e3cb9484128a589001e
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
2d221e76206dac71941d749626700537e003642fc862934e832366f73b862831
8effd8434f237afc9afda64c0d65673f13b6435a145afab0442a48b00b902273
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
b6ac119e4a85cf0c53bce81d1fe70a3c086c7c3764f1cbc6bd19878da124cc97
1ccfc02135460f131e62dc4f9c8f2d400a4f866ccb8fb7d82c0eabaf0925fa2c
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
c71e5ea2112f545be3b3c1afadd20c46f931632ee78feeb06e0945a550bc76d3
d8ce268712e42fc00843db24731dbb75d65b1192ad588a812401eba11599402d
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
1b29775537e80017a5d1e5999bbc611204c696f0951818664533b51e3903f3d6
044b352b81cb95f71b5f7f546d630d2bd8cf246fadc6ac1999aa080562b8d85a
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
92b03822689a82c8479751af6b6dfd593ad7a1f0a8e55071819520fdccd90570
6a33758c892776e4e005e29bc5137a69421daaea01f3fa2c8c52cc18ece78e29
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
a8a8b4b2fd8f506f22734d07aa3375dca027aae9eac1d4b243997482c46561c1
8d8c7fe694b260e79494e20cc264c0d6f2be3d1a765ed15db4f0356bcecb39a0
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
51b39ce770af475df93655210932a43616d43653209ade5c5402183f4b63950a
0fbed85e334349fcd1a0aa8e2cbbaa50d2d6fef159271089e181d86bcfdc0d51
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
0bc832accea72dae9df6e95c985ee5ac330cb9b8fb6a0608d9ddeabcd9668610
8d1b14ad05e5d64e1b0664f6454579fa49d7aee20d4bac34b5eb8c5ed4450092
+1
Переглянути файл
@@ -116,6 +116,7 @@ Each contribution point is a table (`[contributes.settings]`) or an array of tab
| `customEditors` | `id`, `title`, `patterns`, `priority`, `layout?`, `web?` | without `web` | [Views and decorations](/en/plugins/guides/views) |
| `markerIcons` | `id`, `icon`, `iconDark?`, `markers?`, `tooltip?` (API 1.3): gutter marker icons | no | [Language features](/en/plugins/guides/language-features) |
| `editorPanels` | `id`, `web`, `width`, `when?` (API 1.9; needs `editor.read`) | no | [README: Editor panels](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#editor-panels) |
| `overlays` | `id`, `web`, `width`, `height`, `anchor?`, `when?`, `interactive?` (API 1.18) | no | [README: Overlays](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#overlays) |
| `fileIcons` | `id`, `patterns`, `icon`, `iconDark?` | no | [Icon themes](/en/plugins/guides/icon-themes) |
| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables` | no | [File actions](/en/plugins/guides/file-actions) |
| `snippets` | `language`, `path` (API 1.4) | no | [Language features](/en/plugins/guides/language-features) |
+2 -1
Переглянути файл
@@ -31,7 +31,8 @@ The plugin API has one version number: the version of the WIT package in [`wit/`
| 1.14.0 | In development on `main` | Optional `hover-actions` export: left-edge line actions revealed by line-edge hover, with an anchor line and inclusive trigger range; `[[contributes.javaAgents]]` `vmOptions` / `jdk`: JVM flags (optionally JetBrains Runtime–only) before `-javaagent:`; `ui.set-status-item-menu` / `set-window-status-item-menu`: a menu on a status bar item |
| 1.15.0 | In development on `main` | `caret-moved` event; declarative `[[contributes.skills]]` (`path = "skills/<name>/SKILL.md"`) for bundling agent skills in plugins |
| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card |
| 1.17.0 | In development on `main` | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette |
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette |
| 1.18.0 | In development on `main` | `[[contributes.overlays]]`: a package web page floating over the workbench that never takes the keyboard focus, placed and resized through `openidea.overlay` |
The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md).
+30 -29
Переглянути файл
@@ -100,35 +100,36 @@ optional = ["net:api.openai.com", "secrets"]
每个贡献点是一张表(`[contributes.settings]`)或一个表数组(`[[contributes.commands]]`)。插件启用后贡献立即生效,不需要等代码加载。
| 贡献点 | 声明字段 | 需要代码 | 指南 |
| ------------------- | ---------------------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `commands` | `id`、`title`、`category?`、`when?`、`icon?` | 执行时需要 | [命令与动作](/zh/plugins/guides/commands) |
| `menus` | `menu`、`command`、`when?`、`view?`、`submenu?` | 否 | [命令与动作](/zh/plugins/guides/commands) |
| `keymaps` | `command`、`key`、`mac?`、`when?`(仅 Escape) | 否 | [命令与动作](/zh/plugins/guides/commands) |
| `statusBar` | `id`、`text`、`tooltip?`、`command?`、`align?`、`priority?` | 否 | [视图与装饰](/zh/plugins/guides/views) |
| `settings` | `schema`(JSON 文件)或 `pages`(API 1.3)、`title?` | 否 | [生命周期与事件](/zh/plugins/lifecycle) |
| `secrets` | `name`、`label`、`description?` | 使用时需要 | [权限与能力](/zh/plugins/capabilities) |
| `providers` | `kinds`、`languages` | 是 | [语言功能](/zh/plugins/guides/language-features) |
| `documentIndexers` | `extensions` | 是 | [索引](/zh/plugins/guides/indexing) |
| `endpoints` | `files`(API 1.3) | 是 | [README:Project HTTP endpoints](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#project-http-endpoints-api-13) |
| `searchCategories` | `id`、`title`(API 1.13) | 是 | [自定义搜索分类](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#custom-search-everywhere-categories-api-111) |
| `views` | `id`、`title`、`icon?`、`location`、`web?`、`group?`、`when?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
| `customEditors` | `id`、`title`、`patterns`、`priority`、`layout?`、`web?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
| `markerIcons` | `id`、`icon`、`iconDark?`、`markers?`、`tooltip?`(API 1.3):装订区标记图标 | 否 | [语言功能](/zh/plugins/guides/language-features) |
| `editorPanels` | `id`、`web`、`width`、`when?`(API 1.9;需要 `editor.read`) | 否 | [README:Editor panels](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#editor-panels) |
| `fileIcons` | `id`、`patterns`、`icon`、`iconDark?` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
| `fileTemplates` | `id`、`name`、`extension`、`path`;API 1.3:`fileName`、`variables` | 否 | [文件操作](/zh/plugins/guides/file-actions) |
| `snippets` | `language`、`path`(API 1.4) | 否 | [语言功能](/zh/plugins/guides/language-features) |
| `commitChecks` | `id`、`title` | 是 | [README:Commits](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commits) |
| `serverCommands` | `server`、`command`、`run`(API 1.9) | 是 | [README:Commands a server hands to the client](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commands-a-server-hands-to-the-client) |
| `runDetectors` | `id`、`name`、`files`、`command`、`args?`、`test?`、`framework?` | 否 | [运行目标](/zh/plugins/guides/run-targets) |
| `runConfigurations` | `files`(API 1.4) | 是 | [运行目标](/zh/plugins/guides/run-targets) |
| `javaAgents` | `path`、`args?`(API 1.10);`vmOptions?`、`jdk?`(API 1.14) | 否 | [README:Java agents](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#java-agents-api-110) |
| `skills` | `path`(`skills/<name>/SKILL.md`,API 1.15) | 否 | [README:API 1.15](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#api-115) |
| `mcpTools` | `name`、`description`、`inputSchema`、`readOnly`、`destructive`(API 1.4) | 是 | [MCP 工具](/zh/plugins/guides/mcp) |
| `themes` | `path`、`editor-scheme?` | 否 | [主题](/zh/plugins/guides/themes) |
| `iconThemes` | `id`、`label`、`path` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
| `languages` | `path`(`languages/<id>.toml` 格式的文件) | 否 | [添加语言](/zh/languages/adding) |
| 贡献点 | 声明字段 | 需要代码 | 指南 |
| ------------------- | ------------------------------------------------------------------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `commands` | `id`、`title`、`category?`、`when?`、`icon?` | 执行时需要 | [命令与动作](/zh/plugins/guides/commands) |
| `menus` | `menu`、`command`、`when?`、`view?`、`submenu?` | 否 | [命令与动作](/zh/plugins/guides/commands) |
| `keymaps` | `command`、`key`、`mac?`、`when?`(仅 Escape) | 否 | [命令与动作](/zh/plugins/guides/commands) |
| `statusBar` | `id`、`text`、`tooltip?`、`command?`、`align?`、`priority?` | 否 | [视图与装饰](/zh/plugins/guides/views) |
| `settings` | `schema`(JSON 文件)或 `pages`(API 1.3)、`title?` | 否 | [生命周期与事件](/zh/plugins/lifecycle) |
| `secrets` | `name`、`label`、`description?` | 使用时需要 | [权限与能力](/zh/plugins/capabilities) |
| `providers` | `kinds`、`languages` | 是 | [语言功能](/zh/plugins/guides/language-features) |
| `documentIndexers` | `extensions` | 是 | [索引](/zh/plugins/guides/indexing) |
| `endpoints` | `files`(API 1.3) | 是 | [README:Project HTTP endpoints](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#project-http-endpoints-api-13) |
| `searchCategories` | `id`、`title`(API 1.13) | 是 | [自定义搜索分类](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#custom-search-everywhere-categories-api-111) |
| `views` | `id`、`title`、`icon?`、`location`、`web?`、`group?`、`when?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
| `customEditors` | `id`、`title`、`patterns`、`priority`、`layout?`、`web?` | 无 `web` 时需要 | [视图与装饰](/zh/plugins/guides/views) |
| `markerIcons` | `id`、`icon`、`iconDark?`、`markers?`、`tooltip?`(API 1.3):装订区标记图标 | 否 | [语言功能](/zh/plugins/guides/language-features) |
| `editorPanels` | `id`、`web`、`width`、`when?`(API 1.9;需要 `editor.read`) | 否 | [README:Editor panels](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#editor-panels) |
| `overlays` | `id`、`web`、`width`、`height`、`anchor?`、`when?`、`interactive?`(API 1.18) | 否 | [README:Overlays](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#overlays) |
| `fileIcons` | `id`、`patterns`、`icon`、`iconDark?` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
| `fileTemplates` | `id`、`name`、`extension`、`path`;API 1.3:`fileName`、`variables` | 否 | [文件操作](/zh/plugins/guides/file-actions) |
| `snippets` | `language`、`path`(API 1.4) | 否 | [语言功能](/zh/plugins/guides/language-features) |
| `commitChecks` | `id`、`title` | 是 | [README:Commits](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commits) |
| `serverCommands` | `server`、`command`、`run`(API 1.9) | 是 | [README:Commands a server hands to the client](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#commands-a-server-hands-to-the-client) |
| `runDetectors` | `id`、`name`、`files`、`command`、`args?`、`test?`、`framework?` | 否 | [运行目标](/zh/plugins/guides/run-targets) |
| `runConfigurations` | `files`(API 1.4) | 是 | [运行目标](/zh/plugins/guides/run-targets) |
| `javaAgents` | `path`、`args?`(API 1.10);`vmOptions?`、`jdk?`(API 1.14) | 否 | [README:Java agents](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#java-agents-api-110) |
| `skills` | `path`(`skills/<name>/SKILL.md`,API 1.15) | 否 | [README:API 1.15](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md#api-115) |
| `mcpTools` | `name`、`description`、`inputSchema`、`readOnly`、`destructive`(API 1.4) | 是 | [MCP 工具](/zh/plugins/guides/mcp) |
| `themes` | `path`、`editor-scheme?` | 否 | [主题](/zh/plugins/guides/themes) |
| `iconThemes` | `id`、`label`、`path` | 否 | [图标主题](/zh/plugins/guides/icon-themes) |
| `languages` | `path`(`languages/<id>.toml` 格式的文件) | 否 | [添加语言](/zh/languages/adding) |
条目 id(命令、视图、主题等)匹配 `[a-z0-9][a-z0-9._-]*`,不超过 64 个字符。菜单、快捷键和状态栏项只能引用插件自己声明的命令;在 IDE 内部,命令的操作 id 是 `plugin.<plugin id>.<command id>`。
+2 -1
Переглянути файл
@@ -28,7 +28,8 @@ description: "engines.openidea、插件 API 从 1.0 到 1.13 的各个版本,
| 1.14.0 | `main` 上开发中 | 可选 `hover-actions` 导出:行内侧 hover 显示的左侧操作,带锚定行和包含式触发行范围; `[[contributes.javaAgents]]` 的 `vmOptions` / `jdk`:在 `-javaagent:` 之前注入 JVM 参数(可选仅 JetBrains Runtime);`ui.set-status-item-menu` / `set-window-status-item-menu`:状态栏项菜单 |
| 1.15.0 | `main` 上开发中 | `caret-moved` 事件;声明式 `[[contributes.skills]]`(`path = "skills/<name>/SKILL.md"`),在插件包中打包代理技能 |
| 1.16.0 | OpenIDEA 0.1.52 | 可选 `completion-list-provider` 导出:标记为不完整的补全在继续输入时再次询问,不会重新询问语言服务器和其他插件;`decorations.set-markdown`:悬停显示 Markdown 卡片的行尾装饰 |
| 1.17.0 | `main` 上开发中 | `decorations.set-styled`:自带 `#rrggbb` / `#rrggbbaa` 前景色和背景色的编辑器装饰,用于主题调色板之外的颜色 |
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`:自带 `#rrggbb` / `#rrggbbaa` 前景色和背景色的编辑器装饰,用于主题调色板之外的颜色 |
| 1.18.0 | `main` 上开发中 | `[[contributes.overlays]]`:悬浮在工作台上方、从不抢占键盘焦点的插件网页,可通过 `openidea.overlay` 移动和调整大小 |
每个版本新增内容的完整列表见 [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md)。
+53 -2
Переглянути файл
@@ -36,7 +36,7 @@ sdk/rust/openidea-plugin/ # the Rust SDK (host API, Plugin trait, mock host)
crates/ide-plugin/tests/fixtures/ # test plugins: hello, jobs, language-toy, misbehave, semantic-tokens, hover, commit, inlay-hints, decorations
```
The plugin API is defined in [`wit/`](../wit/) (`openidea:[email protected]7.0`, world
The plugin API is defined in [`wit/`](../wit/) (`openidea:[email protected]8.0`, world
`plugin`).
## 1. Quick start
@@ -157,6 +157,7 @@ work), but 0.1 code no longer runs: rebuild it against the 1.0 SDK.
| `views` | `id`, `title`, `icon?` (an icon name or a package SVG), `location` (`left`, `right`, `bottom`, `services`), `web?` (_Web views_), `frames?` (API 1.16), `group?`, `when?` (API 1.3) | without `web` |
| `customEditors` | `id`, `title`, `patterns` (file names), `priority` (`default`, `option`), `layout?`, `web?`, `frames?`, `binary?` (API 1.16) | without `web` |
| `editorPanels` | `id`, `web`, `width` (pixels, 40–400), `when?`, `frames?` (API 1.16) — needs `editor.read` (API 1.9; _Editor panels_) | no |
| `overlays` | `id`, `web`, `width`, `height` (pixels, 40–800), `anchor?`, `when?`, `interactive?` — floats over the workbench, never takes the focus (API 1.18; _Overlays_) | no |
| `fileIcons` | `id`, `patterns` (file names), `icon` (SVG), `iconDark?` — whatever icon theme is in use | no |
| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables = [{ name, prompt }]` — New menu | no |
| `commitChecks` | `id`, `title` — a before-commit check in Commit Options (see _Commits_) | yes |
@@ -431,9 +432,19 @@ are always available. Calling a gated function without its capability returns
## 3. Writing code (Rust SDK)
### API 1.18
API 1.18.0 is in development on `main`. Use `engines.openidea = "^1.18"` and the
matching SDK. Plugins for 1.17 and earlier keep working. New in 1.18:
- **Overlays (`[[contributes.overlays]]`).** A web page of the package floats over
the workbench at one of nine anchors while its `when` holds, without ever taking
the keyboard focus — a mascot, a reaction, a timer. The page moves and resizes
itself with `openidea.overlay`. No code or capability needed. See [Overlays](#overlays).
### API 1.17
API 1.17.0 is in development on `main`. Use `engines.openidea = "^1.17"` and the
API 1.17.0 shipped with OpenIDEA 0.1.53. Use `engines.openidea = "^1.17"` and the
matching SDK. Plugins for 1.16 and earlier keep working. New in 1.17:
- [Editor decorations](#editor-and-project-snapshots-api-14):
@@ -2290,6 +2301,46 @@ line's length until it lays the line out; `onLayout` follows when it does.
`crates/ide-plugin/tests/fixtures/editor-panel` is a minimal minimap (each line
2 px, its frame draggable, problems marked at its right edge, folded lines left out, the selected lines and the caret's line tinted, VCS changes at its left edge) to install and try.
#### Overlays
With API 1.18 (`engines.openidea = "^1.18"`), a web page can float over the
workbench — over the editor, tool windows and all — without ever taking the
keyboard focus: a mascot reacting to your work, a timer, a reaction GIF. It needs
no code and no capability, since it sees nothing of the IDE:
```toml
[[contributes.overlays]]
id = "stage"
web = "web/stage.html" # the same rules as a web view's page
width = 320 # pixels, 40–800
height = 240
anchor = "bottom-right" # optional: top-left, top-center, top-right, middle-left,
# center, middle-right, bottom-left, bottom-center, bottom-right
when = "plugin.<id>.showing" # optional: the plugin's own key through `host::set_context`
interactive = true # optional: false lets every click through to the IDE
```
The overlay is in the window while `when` holds (always, without one), clear of
the title and status bars, under dialogs, popups and notifications. Its frame is
out of the tab order and is never focused when it appears, so typing carries on in
the editor; a click in an interactive overlay goes to its page, as any click does.
With `interactive = false` the frame lets every click through. The frame is
transparent: draw only what should show. When the page can't be loaded (the
plugin was disabled meanwhile), the overlay shows nothing.
The page gets `openidea.overlay` (only an overlay's page has it), besides
`postMessage` / `onMessage` to the plugin's code and the theme:
| `openidea.overlay` | What it does |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `get()` | `{ anchor, width, height }`: where the overlay is and its size, the declaration's until the page changes them |
| `place({ anchor?, width?, height? })` | Moves the overlay to another anchor and/or resizes it (sizes clamped to 40–800 and to the window); resolves with `get()`, rejects an unknown anchor |
The placement lasts while the overlay is shown; the next time `when` holds it
starts again from the declaration. To fit a picture, the page measures it and
places the overlay at that size. `crates/ide-plugin/tests/fixtures/overlay` is a
minimal card that moves itself around the window.
### Web frame PTYs (API 1.3)
Packages requiring `engines.openidea = "^1.3"` can exchange JSON strings through
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
25da773f6dee3c966c529d526415bbbd763c5c144660b1e2744737f2bfe0fb65
9707d34e02d000e032f3e63490367d516304938baf700d513ddc7d80498aabd1
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
e42622d525d315a5a5d186197e17624ec713ec1d9a47a0dbc67abfeb61854971
7ad3b999327aa429b7e6a6f526fe80b8d1b183c3e2d88f1a0abb32ea89aa4e8f
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
24f75bb6f4145a4432a5dbe3dec0fbc8fb77b4bdc853f300ccd7208941d6f16d
e956cbd4fb9a1381c5c6873e4571ce97448aa77fd20224afd8dc611d9eca929e
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
701df0210137656bbedab1d7af171c6442bbbce296f885ea63a21a7cf28a76aa
c6022ee42eeaabd243fffb189cc5d9176684ef99f87d50ad3e485678bea0569b
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
d1dae995f46af06e43a21e57b9ad4af31854e7e87c5f120d7b516940ea6bba99
7614c19cd2ad6d36ab4c55e6ec0350398977627246f9b87c56c560108940f3d1
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
7e50407014ba5c0a0d22a1d5c92dff8180e20f153101c9a9a18c83e0ec16cbfe
4a2c897f5a5cae4bf3544b78de8b51f25d58ebd59f91f30b3b1685ad48a37613
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
c58f9d017da99a14b127c51c0ad9ceaa7fd6d1138732d68604653fb0ff97de6b
bf09aabd72a952c0ba1dd92ea82656245630a328c29c30bea97e55942c15ce8c
Бінарний файл не відображається.
+1 -1
Переглянути файл
@@ -1 +1 @@
828ad3a4a9b7e8a9d938a68883254b4eb572309ef48bb11c9155915047d007e2
7c5e6947bfbd0048e174d97b3702206255b7167bb7c53a312b83edcf355cd38e
Бінарний файл не відображається.
Loaded 100 of 183 files, more files were not shown because too many files have changed in this diff. Show more