Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update upstream deps #5

Closed
wants to merge 10 commits into from
454 changes: 329 additions & 125 deletions Cargo.lock

Large diffs are not rendered by default.

51 changes: 26 additions & 25 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[package]
name = "jco"
version = { workspace = true }
edition = { workspace = true }
publish = false

version.workspace = true
edition.workspace = true

[[bin]]
name = "dummy"
path = "bin/dummy.rs"

[workspace]
members = [
"crates/js-component-bindgen",
"crates/js-component-bindgen-component",
"crates/wasm-tools-component",
"xtask",
"crates/js-component-bindgen",
"crates/js-component-bindgen-component",
"crates/wasm-tools-component",
"xtask",
]
resolver = "2"

Expand All @@ -34,28 +35,28 @@ rpath = false
strip = true

[workspace.dependencies]
anyhow = "1.0.95"
base64 = "0.22.1"
heck = "0.5.0"
log = "0.4.22"
semver = "1.0.25"
anyhow = { version = "1.0.95", default-features = false }
base64 = { version = "0.22.1", default-features = false }
heck = { version = "0.5.0", default-features = false }
log = { version = "0.4.22", default-features = false }
semver = { version = "1.0.25", default-features = false }
js-component-bindgen = { path = "./crates/js-component-bindgen" }
structopt = "0.3.26"
wasm-encoder = "0.220.0"
wasm-metadata = "0.220.0"
wasmparser = "0.220.0"
wasmprinter = "0.220.0"
structopt = { version = "0.3.26", default-features = false }
wasm-encoder = { version = "0.224.0", default-features = false }
wasm-metadata = { version = "0.224.0", default-features = false }
wasmparser = { version = "0.224.0", default-features = false }
wasmprinter = { version = "0.224.0", default-features = false }
wasmtime-environ = { version = "29.0.0", features = [
"component-model",
"compile",
"component-model",
"compile",
] }
wat = "1.220.0"
webidl2wit = "0.1.0"
wit-bindgen = "0.36.0"
wit-bindgen-core = "0.36.0"
wit-component = { version = "0.220.0", features = ["dummy-module"] }
wit-parser = "0.220.0"
xshell = "0.2.6"
wat = { version = "1.224.0", default-features = false }
webidl2wit = { version = "0.1.0", default-features = false }
wit-bindgen = { version = "0.38.0", default-features = false }
wit-bindgen-core = { version = "0.38.0", default-features = false }
wit-component = { version = "0.224.0", features = ["dummy-module"] }
wit-parser = { version = "0.224.0", default-features = false }
xshell = { version = "0.2.6", default-features = false }

[dev-dependencies]
anyhow = { workspace = true }
4 changes: 2 additions & 2 deletions crates/js-component-bindgen-component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ crate-type = ["cdylib"]
[dependencies]
anyhow = { workspace = true }
js-component-bindgen = { path = "../js-component-bindgen" }
wasmtime-environ = { workspace = true }
wasmtime-environ = { workspace = true, features = [ "component-model" ] }
wit-bindgen = { workspace = true }
wat = { workspace = true }
wat = { workspace = true, features = [ "component-model" ]}
4 changes: 2 additions & 2 deletions crates/js-component-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ transpile-bindgen = []

[dependencies]
anyhow = { workspace = true }
base64 = { workspace = true }
base64 = { workspace = true, features = [ "alloc" ] }
heck = { workspace = true }
log = { workspace = true }
semver = { workspace = true }
wasm-encoder = { workspace = true }
wasmparser = { workspace = true }
wasmparser = { workspace = true, features = [ "features", "component-model" ] }
wasmtime-environ = { workspace = true, features = ['component-model'] }
wit-bindgen-core = { workspace = true }
wit-component = { workspace = true }
Expand Down
29 changes: 22 additions & 7 deletions crates/js-component-bindgen/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@
//! Additionally core wasm sections such as data sections and tables are not
//! supported because, again, Wasmtime doesn't use it at this time.

use anyhow::{bail, Result};
use std::collections::{HashMap, HashSet};
use wasm_encoder::*;
use wasmparser::*;

use anyhow::{bail, Result};
use wasm_encoder::{
CodeSection, EntityType, ExportKind, ExportSection, Function, FunctionSection, ImportSection,
Module, TypeSection,
};
use wasmparser::{
Export, ExternalKind, FunctionBody, Import, Parser, Payload, TypeRef, Validator, VisitOperator,
VisitSimdOperator, WasmFeatures,
};
use wasmtime_environ::component::CoreDef;
use wasmtime_environ::{EntityIndex, MemoryIndex, ModuleTranslation, PrimaryMap};

Expand Down Expand Up @@ -547,12 +554,16 @@ macro_rules! define_visit {
impl<'a> VisitOperator<'a> for CollectMemOps<'_, 'a> {
type Output = ();

wasmparser::for_each_operator!(define_visit);
wasmparser::for_each_visit_operator!(define_visit);
}

impl<'a> VisitSimdOperator<'a> for CollectMemOps<'_, 'a> {
wasmparser::for_each_visit_simd_operator!(define_visit);
}

impl AugmentedOp {
fn encode_type(&self, section: &mut TypeSection) {
use wasm_encoder::ValType::*;
use wasm_encoder::ValType::{F32, F64, I32, I64};
match self {
// Loads take two arguments: the first is the address being loaded
// from and the second is the static offset that was listed on the
Expand Down Expand Up @@ -773,7 +784,11 @@ macro_rules! define_translate {
impl<'a> VisitOperator<'a> for Translator<'_, 'a> {
type Output = ();

wasmparser::for_each_operator!(define_translate);
wasmparser::for_each_visit_operator!(define_translate);
}

impl<'a> VisitSimdOperator<'a> for Translator<'_, 'a> {
wasmparser::for_each_visit_simd_operator!(define_translate);
}

#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
Expand Down Expand Up @@ -828,7 +843,7 @@ impl Translator<'_, '_> {
insn: fn(wasm_encoder::MemArg) -> wasm_encoder::Instruction<'static>,
memarg: wasmparser::MemArg,
) {
use wasm_encoder::Instruction::*;
use wasm_encoder::Instruction::{Call, I32Const};
if memarg.memory < 1 {
self.func.instruction(&insn(self.memarg(memarg)));
return;
Expand Down
41 changes: 35 additions & 6 deletions crates/js-component-bindgen/src/function_bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use crate::intrinsics::Intrinsic;
use crate::source;
use crate::{uwrite, uwriteln};
use heck::*;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::Write;
use std::mem;

use heck::{ToLowerCamelCase, ToUpperCamelCase};
use wasmtime_environ::component::{ResourceIndex, TypeResourceTableIndex};
use wit_bindgen_core::abi::{Bindgen, Bitcast, Instruction};
use wit_component::StringEncoding;
use wit_parser::abi::WasmType;
use wit_parser::*;
use wit_parser::{ArchitectureSize, Handle, Resolve, SizeAlign, Type, TypeDefKind, TypeId};

use crate::intrinsics::Intrinsic;
use crate::source;
use crate::{uwrite, uwriteln};

#[derive(PartialEq)]
pub enum ErrHandling {
Expand Down Expand Up @@ -1071,7 +1073,7 @@ impl Bindgen for FunctionBindgen<'_> {
}
}

Instruction::CallInterface { func } => {
Instruction::CallInterface { func, .. } => {
let results_length = func.results.len();
let maybe_async_await = if self.is_async { "await " } else { "" };
let call = if self.callee_resource_dynamic {
Expand Down Expand Up @@ -1512,6 +1514,33 @@ impl Bindgen for FunctionBindgen<'_> {
}
results.push(handle);
}

// For most non-Promise objects, flushing or evaluating the object is a no-op,
// so in general we only evaluate things that are promises, and pass through all other objects
// without modification
Instruction::Flush { amt } => {
for n in 0..*amt {
let operand = &operands[n];
let var = format!("flushedResult{n}");
uwriteln!(self.src, "const {var} = typeof {operand} == 'object' && typeof {operand}.then == 'function' ? {operand}.await : {operand};");
results.push(var);
}
}

// TODO: implement async
Instruction::FutureLower { .. }
| Instruction::FutureLift { .. }
| Instruction::StreamLower { .. }
| Instruction::StreamLift { .. }
| Instruction::AsyncMalloc { .. }
| Instruction::AsyncCallWasm { .. }
| Instruction::AsyncPostCallInterface { .. }
| Instruction::AsyncCallReturn { .. }
| Instruction::ErrorContextLift { .. }
| Instruction::ErrorContextLower { .. } => {
uwrite!(self.src, "throw new Error('async is not yet implemented');");
}

Instruction::GuestDeallocate { .. }
| Instruction::GuestDeallocateString
| Instruction::GuestDeallocateList { .. }
Expand Down
34 changes: 22 additions & 12 deletions crates/js-component-bindgen/src/transpile_bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
use crate::core;
use crate::esm_bindgen::EsmBindgen;
use crate::files::Files;
use crate::function_bindgen::{
ErrHandling, FunctionBindgen, ResourceData, ResourceMap, ResourceTable,
};
use crate::intrinsics::{render_intrinsics, Intrinsic};
use crate::names::{is_js_reserved_word, maybe_quote_id, maybe_quote_member, LocalNames};
use crate::source;
use crate::{uwrite, uwriteln};
use base64::{engine::general_purpose, Engine as _};
use heck::*;
use std::cell::RefCell;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt::Write;
use std::mem;

use base64::{engine::general_purpose, Engine as _};
use heck::{ToKebabCase, ToLowerCamelCase, ToUpperCamelCase};
use wasmtime_environ::component::{ExportIndex, NameMap, NameMapNoIntern, Transcode};
use wasmtime_environ::{
component,
Expand All @@ -34,6 +25,17 @@ use wit_parser::{
WorldItem, WorldKey,
};

use crate::core;
use crate::esm_bindgen::EsmBindgen;
use crate::files::Files;
use crate::function_bindgen::{
ErrHandling, FunctionBindgen, ResourceData, ResourceMap, ResourceTable,
};
use crate::intrinsics::{render_intrinsics, Intrinsic};
use crate::names::{is_js_reserved_word, maybe_quote_id, maybe_quote_member, LocalNames};
use crate::source;
use crate::{uwrite, uwriteln};

#[derive(Default, Clone)]
pub struct TranspileOpts {
pub name: String,
Expand Down Expand Up @@ -1705,6 +1707,9 @@ impl<'a> Instantiator<'a, '_> {
match abi {
AbiVariant::GuestExport => ErrHandling::ThrowResultErr,
AbiVariant::GuestImport => ErrHandling::ResultCatchHandler,
AbiVariant::GuestImportAsync => todo!("async not yet implemented"),
AbiVariant::GuestExportAsync => todo!("async not yet implemented"),
AbiVariant::GuestExportAsyncStackful => todo!("async not yet implemented"),
}
} else {
ErrHandling::None
Expand Down Expand Up @@ -1738,9 +1743,14 @@ impl<'a> Instantiator<'a, '_> {
match abi {
AbiVariant::GuestImport => LiftLower::LiftArgsLowerResults,
AbiVariant::GuestExport => LiftLower::LowerArgsLiftResults,
AbiVariant::GuestImportAsync => todo!("async not yet implemented"),
AbiVariant::GuestExportAsync => todo!("async not yet implemented"),
AbiVariant::GuestExportAsyncStackful => todo!("async not yet implemented"),
},
func,
&mut f,
// TODO: implement async
false,
);
self.src.js(&f.src);
self.src.js("}");
Expand Down
35 changes: 22 additions & 13 deletions crates/js-component-bindgen/src/ts_bindgen.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
use crate::files::Files;
use crate::function_bindgen::{array_ty, as_nullable, maybe_null};
use crate::names::{is_js_identifier, maybe_quote_id, LocalNames, RESERVED_KEYWORDS};
use crate::source::Source;
use crate::transpile_bindgen::{parse_world_key, AsyncMode, InstantiationMode, TranspileOpts};
use crate::{dealias, feature_gate_allowed, uwrite, uwriteln};
use anyhow::{Context as _, Result};
use heck::*;
use log::debug;
use std::collections::btree_map::Entry;
use std::collections::{BTreeMap, HashSet};
use std::fmt::Write;

use anyhow::{Context as _, Result};
use heck::{ToKebabCase, ToLowerCamelCase, ToUpperCamelCase};
use log::debug;
use wit_bindgen_core::wit_parser::{
Docs, Enum, Flags, Function, FunctionKind, Handle, InterfaceId, Record, Resolve, Result_,
Tuple, Type, TypeDefKind, TypeId, TypeOwner, Variant, WorldId, WorldItem, WorldKey,
};

use crate::files::Files;
use crate::function_bindgen::{array_ty, as_nullable, maybe_null};
use crate::names::{is_js_identifier, maybe_quote_id, LocalNames, RESERVED_KEYWORDS};
use crate::source::Source;
use crate::transpile_bindgen::{parse_world_key, AsyncMode, InstantiationMode, TranspileOpts};
use crate::{dealias, feature_gate_allowed, uwrite, uwriteln};

struct TsBindgen {
/// The source code for the "main" file that's going to be created for the
/// component we're generating bindings for. This is incrementally added to
Expand Down Expand Up @@ -168,8 +170,11 @@ pub fn ts_bindgen(
TypeDefKind::Result(r) => gen.type_result(*tid, name, r, &ty.docs),
TypeDefKind::List(t) => gen.type_list(*tid, name, t, &ty.docs),
TypeDefKind::Type(t) => gen.type_alias(*tid, name, t, None, &ty.docs),
TypeDefKind::Future(_) => todo!("generate for future"),
TypeDefKind::Stream(_) => todo!("generate for stream"),
TypeDefKind::Future(_) => todo!("(async impl) generate for future"),
TypeDefKind::Stream(_) => todo!("(async impl) generate for stream"),
TypeDefKind::ErrorContext => {
todo!("(async impl) generate for error-context")
}
TypeDefKind::Unknown => unreachable!(),
TypeDefKind::Resource => {}
TypeDefKind::Handle(_) => todo!(),
Expand Down Expand Up @@ -669,8 +674,11 @@ impl<'a> TsInterface<'a> {
TypeDefKind::Result(r) => self.type_result(*id, name, r, &ty.docs),
TypeDefKind::List(t) => self.type_list(*id, name, t, &ty.docs),
TypeDefKind::Type(t) => self.type_alias(*id, name, t, Some(iface_id), &ty.docs),
TypeDefKind::Future(_) => todo!("generate for future"),
TypeDefKind::Stream(_) => todo!("generate for stream"),
TypeDefKind::Future(_) => todo!("(async impl) generate for future"),
TypeDefKind::Stream(_) => todo!("(async impl) generate for stream"),
TypeDefKind::ErrorContext { .. } => {
todo!("(async impl) generate for error-context")
}
TypeDefKind::Unknown => unreachable!(),
TypeDefKind::Resource => {}
TypeDefKind::Handle(_) => todo!(),
Expand Down Expand Up @@ -739,6 +747,7 @@ impl<'a> TsInterface<'a> {
}
panic!("anonymous resource handle");
}
TypeDefKind::ErrorContext => todo!("(async impl) anonymous error-context)"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm-tools-component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ anyhow = { workspace = true }
wasm-encoder = { workspace = true }
wasm-metadata = { workspace = true }
wasmparser = { workspace = true }
wasmprinter = { workspace = true }
wasmprinter = { workspace = true, features = ["component-model"] }
wat = { workspace = true }
wit-bindgen = { workspace = true }
wit-bindgen = { workspace = true, features = ["macros"] }
wit-component = { workspace = true }
wit-parser = { workspace = true }
Loading