Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

zed_extension_api: Release v0.2.0 (#20683)

Marshall Bowersb5ce8e7aa500
diff --git a/crates/extension_api/Cargo.toml b/crates/extension_api/Cargo.toml
index 1a2b25b0f6a..29b00628b9b 100644
--- a/crates/extension_api/Cargo.toml
+++ b/crates/extension_api/Cargo.toml
@@ -8,9 +8,6 @@ keywords = ["zed", "extension"]
edition = "2021"
license = "Apache-2.0"
-# Remove when we're ready to publish v0.2.0.
-publish = false
-
[lints]
workspace = true
diff --git a/crates/extension_api/README.md b/crates/extension_api/README.md
index d3ba5c1c3c1..54b66b24026 100644
--- a/crates/extension_api/README.md
+++ b/crates/extension_api/README.md
@@ -63,6 +63,7 @@ Here is the compatibility of the `zed_extension_api` with versions of Zed:
| Zed version | `zed_extension_api` version |
| ----------- | --------------------------- |
+| `0.162.x` | `0.0.1` - `0.2.0` |
| `0.149.x` | `0.0.1` - `0.1.0` |
| `0.131.x` | `0.0.1` - `0.0.6` |
| `0.130.x` | `0.0.1` - `0.0.5` |
diff --git a/crates/extension_host/src/wasm_host/wit.rs b/crates/extension_host/src/wasm_host/wit.rs
index 77e28b824fb..3296c54defc 100644
--- a/crates/extension_host/src/wasm_host/wit.rs
+++ b/crates/extension_host/src/wasm_host/wit.rs
@@ -57,12 +57,35 @@ pub fn wasm_api_version_range(release_channel: ReleaseChannel) -> RangeInclusive
let max_version = match release_channel {
ReleaseChannel::Dev | ReleaseChannel::Nightly => latest::MAX_VERSION,
- ReleaseChannel::Stable | ReleaseChannel::Preview => since_v0_1_0::MAX_VERSION,
+ ReleaseChannel::Stable | ReleaseChannel::Preview => latest::MAX_VERSION,
};
since_v0_0_1::MIN_VERSION..=max_version
}
+/// Authorizes access to use unreleased versions of the Wasm API, based on the provided [`ReleaseChannel`].
+///
+/// Note: If there isn't currently an unreleased Wasm API version this function may be unused. Don't delete it!
+pub fn authorize_access_to_unreleased_wasm_api_version(
+ release_channel: ReleaseChannel,
+) -> Result<()> {
+ let allow_unreleased_version = match release_channel {
+ ReleaseChannel::Dev | ReleaseChannel::Nightly => true,
+ ReleaseChannel::Stable | ReleaseChannel::Preview => {
+ // We always allow the latest in tests so that the extension tests pass on release branches.
+ cfg!(any(test, feature = "test-support"))
+ }
+ };
+
+ if !allow_unreleased_version {
+ Err(anyhow!(
+ "unreleased versions of the extension API can only be used on development builds of Zed"
+ ))?;
+ }
+
+ Ok(())
+}
+
pub enum Extension {
V020(since_v0_2_0::Extension),
V010(since_v0_1_0::Extension),
@@ -78,20 +101,10 @@ impl Extension {
version: SemanticVersion,
component: &Component,
) -> Result<Self> {
+ // Note: The release channel can be used to stage a new version of the extension API.
+ let _ = release_channel;
+
if version >= latest::MIN_VERSION {
- // Note: The release channel can be used to stage a new version of the extension API.
- // We always allow the latest in tests so that the extension tests pass on release branches.
- let allow_latest_version = match release_channel {
- ReleaseChannel::Dev | ReleaseChannel::Nightly => true,
- ReleaseChannel::Stable | ReleaseChannel::Preview => {
- cfg!(any(test, feature = "test-support"))
- }
- };
- if !allow_latest_version {
- Err(anyhow!(
- "unreleased versions of the extension API can only be used on development builds of Zed"
- ))?;
- }
let extension =
latest::Extension::instantiate_async(store, component, latest::linker())
.await
diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs
index ff48a2fdaac..18f4bc0234c 100644
--- a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs
+++ b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs
@@ -22,7 +22,6 @@ use wasmtime::component::{Linker, Resource};
use super::latest;
pub const MIN_VERSION: SemanticVersion = SemanticVersion::new(0, 1, 0);
-pub const MAX_VERSION: SemanticVersion = SemanticVersion::new(0, 1, 0);
wasmtime::component::bindgen!({
async: true,