Skip to content

Commit 1361b55

Browse files
authored
Merge pull request #147 from lann/unstable
Include unstable features in published packages
2 parents c6bd2aa + 2b568a6 commit 1361b55

File tree

7 files changed

+252
-167
lines changed

7 files changed

+252
-167
lines changed

Cargo.lock

Lines changed: 12 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ futures-util = "0.3.30"
1818
oci-client = { version = "0.14", default-features = false, features = [
1919
"rustls-tls",
2020
] }
21-
oci-wasm = { version = "0.2", default-features = false, features = [
21+
oci-wasm = { version = "0.2.1", default-features = false, features = [
2222
"rustls-tls",
2323
] }
2424
semver = "1.0.23"

crates/wasm-pkg-core/src/resolver.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ impl DecodedDependency<'_> {
267267
match self {
268268
Self::Wit { package, .. } => {
269269
let mut resolve = Resolve::new();
270+
resolve.all_features = true;
270271
let source_files = package
271272
.source_map
272273
.source_files()
@@ -677,7 +678,11 @@ impl DependencyResolutionMap {
677678
/// Given a path to a component or a directory containing wit, use the given dependencies to
678679
/// generate a [`Resolve`] for the root package.
679680
pub async fn generate_resolve(&self, dir: impl AsRef<Path>) -> Result<(Resolve, PackageId)> {
680-
let mut merged = Resolve::default();
681+
let mut merged = Resolve {
682+
// Retain @unstable features; downstream tooling will process them further
683+
all_features: true,
684+
..Resolve::default()
685+
};
681686

682687
let deps = self.decode_dependencies().await?;
683688

crates/wasm-pkg-core/tests/build.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use wasm_pkg_core::{config::Config as WkgConfig, lock::LockFile};
22
use wit_component::DecodedWasm;
3+
use wit_parser::Stability;
34

45
mod common;
56

@@ -28,7 +29,7 @@ async fn test_build_wit() {
2829
);
2930
assert_eq!(
3031
version.unwrap().to_string(),
31-
"0.2.0",
32+
"0.2.3",
3233
"Should have the correct version"
3334
);
3435

@@ -53,18 +54,31 @@ async fn test_build_wit() {
5354
_ => panic!("Should be a package"),
5455
};
5556

56-
let name = resolve
57-
.package_names
58-
.iter()
59-
.find_map(|(name, id)| (pkg_id == *id).then_some(name))
60-
.expect("Should be able to find the package name");
57+
let package = resolve
58+
.packages
59+
.get(pkg_id)
60+
.expect("Should contain decoded package");
6161

6262
assert_eq!(
63-
name.to_string(),
64-
63+
package.name.to_string(),
64+
6565
"Should have the correct package name"
6666
);
6767

68+
// @unstable items are retained
69+
let types_id = package
70+
.interfaces
71+
.get("types")
72+
.expect("wasi:http should have a types interface");
73+
let send_informational = resolve.interfaces[*types_id]
74+
.functions
75+
.get("[method]response-outparam.send-informational")
76+
.expect("Should have send-informational method");
77+
assert!(
78+
matches!(send_informational.stability, Stability::Unstable { .. }),
79+
"response-outparam.send-informational should be unstable"
80+
);
81+
6882
assert!(
6983
resolve.package_direct_deps(pkg_id).count() > 0,
7084
"Should have direct dependencies embedded"
@@ -85,8 +99,8 @@ async fn test_bad_dep_failure() {
8599
.await
86100
.expect("Should be able to read the world file");
87101
let str_world = str_world.replace(
88-
"import wasi:cli/[email protected].0;",
89-
"import totally:not/[email protected].0;",
102+
"import wasi:cli/[email protected].3;",
103+
"import totally:not/[email protected].3;",
90104
);
91105
tokio::fs::write(world_file, str_world)
92106
.await

crates/wasm-pkg-core/tests/fixtures/wasi-http/wit/handler.wit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/// This interface defines a handler of incoming HTTP Requests. It should
22
/// be exported by components which can respond to HTTP Requests.
3+
@since(version = 0.2.0)
34
interface incoming-handler {
5+
@since(version = 0.2.0)
46
use types.{incoming-request, response-outparam};
57

68
/// This function is invoked with an incoming HTTP Request, and a resource
@@ -13,6 +15,7 @@ interface incoming-handler {
1315
/// The implementor of this function must write a response to the
1416
/// `response-outparam` before returning, or else the caller will respond
1517
/// with an error on its behalf.
18+
@since(version = 0.2.0)
1619
handle: func(
1720
request: incoming-request,
1821
response-out: response-outparam
@@ -21,7 +24,9 @@ interface incoming-handler {
2124

2225
/// This interface defines a handler of outgoing HTTP Requests. It should be
2326
/// imported by components which wish to make HTTP Requests.
27+
@since(version = 0.2.0)
2428
interface outgoing-handler {
29+
@since(version = 0.2.0)
2530
use types.{
2631
outgoing-request, request-options, future-incoming-response, error-code
2732
};
@@ -36,6 +41,7 @@ interface outgoing-handler {
3641
/// This function may return an error if the `outgoing-request` is invalid
3742
/// or not allowed to be made. Otherwise, protocol errors are reported
3843
/// through the `future-incoming-response`.
44+
@since(version = 0.2.0)
3945
handle: func(
4046
request: outgoing-request,
4147
options: option<request-options>
Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,50 @@
1-
package wasi:http@0.2.0;
1+
package wasi:http@0.2.3;
22

3-
/// The `wasi:http/proxy` world captures a widely-implementable intersection of
4-
/// hosts that includes HTTP forward and reverse proxies. Components targeting
5-
/// this world may concurrently stream in and out any number of incoming and
6-
/// outgoing HTTP requests.
7-
world proxy {
3+
/// The `wasi:http/imports` world imports all the APIs for HTTP proxies.
4+
/// It is intended to be `include`d in other worlds.
5+
@since(version = 0.2.0)
6+
world imports {
87
/// HTTP proxies have access to time and randomness.
9-
include wasi:clocks/imports@0.2.0;
10-
import wasi:random/random@0.2.0;
8+
@since(version = 0.2.0)
9+
import wasi:clocks/monotonic-clock@0.2.3;
10+
@since(version = 0.2.0)
11+
import wasi:clocks/wall-clock@0.2.3;
12+
@since(version = 0.2.0)
13+
import wasi:random/random@0.2.3;
1114

1215
/// Proxies have standard output and error streams which are expected to
1316
/// terminate in a developer-facing console provided by the host.
14-
import wasi:cli/stdout@0.2.0;
15-
import wasi:cli/stderr@0.2.0;
17+
@since(version = 0.2.0)
18+
import wasi:cli/stdout@0.2.3;
19+
@since(version = 0.2.0)
20+
import wasi:cli/stderr@0.2.3;
1621

1722
/// TODO: this is a temporary workaround until component tooling is able to
1823
/// gracefully handle the absence of stdin. Hosts must return an eof stream
1924
/// for this import, which is what wasi-libc + tooling will do automatically
2025
/// when this import is properly removed.
21-
import wasi:cli/stdin@0.2.0;
26+
@since(version = 0.2.0)
27+
import wasi:cli/stdin@0.2.3;
2228

2329
/// This is the default handler to use when user code simply wants to make an
2430
/// HTTP request (e.g., via `fetch()`).
31+
@since(version = 0.2.0)
2532
import outgoing-handler;
33+
}
34+
35+
/// The `wasi:http/proxy` world captures a widely-implementable intersection of
36+
/// hosts that includes HTTP forward and reverse proxies. Components targeting
37+
/// this world may concurrently stream in and out any number of incoming and
38+
/// outgoing HTTP requests.
39+
@since(version = 0.2.0)
40+
world proxy {
41+
@since(version = 0.2.0)
42+
include imports;
2643

2744
/// The host delivers incoming HTTP requests to a component by calling the
2845
/// `handle` function of this exported interface. A host may arbitrarily reuse
2946
/// or not reuse component instance when delivering incoming HTTP requests and
3047
/// thus a component must be able to handle 0..N calls to `handle`.
48+
@since(version = 0.2.0)
3149
export incoming-handler;
3250
}

0 commit comments

Comments
 (0)