From aa8e0dfbd16c609005b8fcbd64ae59e8dab34958 Mon Sep 17 00:00:00 2001 From: karthik2804 Date: Fri, 21 Mar 2025 13:48:50 +0100 Subject: [PATCH 1/6] initial support for js sdk v4 bindings generation Signed-off-by: karthik2804 --- Cargo.lock | 698 +++++++++++++++++++++++++-------------- Cargo.toml | 14 +- src/commands/add.rs | 212 +++++++++++- src/commands/bindings.rs | 96 ------ src/commands/mod.rs | 1 - src/common/constants.rs | 1 - src/common/wit.rs | 3 +- src/main.rs | 5 +- 8 files changed, 669 insertions(+), 361 deletions(-) delete mode 100644 src/commands/bindings.rs diff --git a/Cargo.lock b/Cargo.lock index 5dba84e..bf8dc02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "arbitrary" @@ -286,7 +286,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -321,7 +321,7 @@ checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -341,6 +341,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "auditable-serde" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7bf8143dfc3c0258df908843e169b5cc5fcf76c7718bd66135ef4a9cd558c5" +dependencies = [ + "semver", + "serde 1.0.219", + "serde_json", + "topological-sort", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -581,7 +593,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits 0.2.19", - "serde 1.0.210", + "serde 1.0.219", "wasm-bindgen", "windows-targets 0.52.6", ] @@ -627,7 +639,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -666,7 +678,7 @@ dependencies = [ "lazy_static 1.5.0", "nom", "rust-ini", - "serde 1.0.210", + "serde 1.0.219", "serde-hjson", "serde_json", "toml 0.5.11", @@ -682,7 +694,7 @@ dependencies = [ "encode_unicode", "lazy_static 1.5.0", "libc", - "unicode-width", + "unicode-width 0.1.14", "windows-sys 0.52.0", ] @@ -692,6 +704,15 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "convert_case" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation" version = "0.9.4" @@ -732,7 +753,7 @@ version = "0.112.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69792bd40d21be8059f7c709f44200ded3bbd073df7eb3fa3c282b387c7ffa5b" dependencies = [ - "cranelift-entity", + "cranelift-entity 0.112.3", ] [[package]] @@ -741,7 +762,17 @@ version = "0.112.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38da1eb6f7d8cdfa92f05acfae63c9a1d7a337e49ce7a2d0769c7fa03a2613a5" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", + "serde_derive", +] + +[[package]] +name = "cranelift-bitset" +version = "0.117.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "573c641174c40ef31021ae4a5a3ad78974e280633502d0dfc6e362385e0c100f" +dependencies = [ + "serde 1.0.219", "serde_derive", ] @@ -753,11 +784,11 @@ checksum = "709f5567a2bff9f06edf911a7cb5ebb091e4c81701714dc6ab574d08b4a69a0d" dependencies = [ "bumpalo", "cranelift-bforest", - "cranelift-bitset", + "cranelift-bitset 0.112.3", "cranelift-codegen-meta", "cranelift-codegen-shared", "cranelift-control", - "cranelift-entity", + "cranelift-entity 0.112.3", "cranelift-isle", "gimli 0.29.0", "hashbrown 0.14.5", @@ -765,7 +796,7 @@ dependencies = [ "regalloc2", "rustc-hash", "smallvec", - "target-lexicon", + "target-lexicon 0.12.16", ] [[package]] @@ -798,8 +829,19 @@ version = "0.112.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70b85ed43567e13782cd1b25baf42a8167ee57169a60dfd3d7307c6ca3839da0" dependencies = [ - "cranelift-bitset", - "serde 1.0.210", + "cranelift-bitset 0.112.3", + "serde 1.0.219", + "serde_derive", +] + +[[package]] +name = "cranelift-entity" +version = "0.117.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb0fd6d4aae680275fcbceb08683416b744e65c8b607352043d3f0951d72b3b2" +dependencies = [ + "cranelift-bitset 0.117.2", + "serde 1.0.219", "serde_derive", ] @@ -812,7 +854,7 @@ dependencies = [ "cranelift-codegen", "log", "smallvec", - "target-lexicon", + "target-lexicon 0.12.16", ] [[package]] @@ -829,7 +871,7 @@ checksum = "ffc4acaf6894ee323ff4e9ce786bec09f0ebbe49941e8012f1c1052f1d965034" dependencies = [ "cranelift-codegen", "libc", - "target-lexicon", + "target-lexicon 0.12.16", ] [[package]] @@ -839,12 +881,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b878860895cca97454ef8d8b12bfda9d0889dd49efee175dba78d54ff8363ec2" dependencies = [ "cranelift-codegen", - "cranelift-entity", + "cranelift-entity 0.112.3", "cranelift-frontend", "itertools 0.12.1", "log", "smallvec", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.217.0", "wasmtime-types", ] @@ -925,7 +967,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -936,7 +978,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -966,7 +1008,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -1083,7 +1125,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31951f49556e34d90ed28342e1df7e1cb7a229c4cab0aecc627b5d91edd41d07" dependencies = [ "base64 0.21.7", - "serde 1.0.210", + "serde 1.0.219", "serde_json", ] @@ -1161,7 +1203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -1172,7 +1214,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -1277,12 +1319,28 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flate2" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foreign-types" version = "0.3.2" @@ -1402,7 +1460,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -1453,7 +1511,7 @@ dependencies = [ "bitflags 2.6.0", "debugid", "fxhash", - "serde 1.0.210", + "serde 1.0.219", "serde_json", ] @@ -1486,7 +1544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" dependencies = [ "fallible-iterator", - "indexmap 2.5.0", + "indexmap 2.8.0", "stable_deref_trait", ] @@ -1495,6 +1553,9 @@ name = "gimli" version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +dependencies = [ + "indexmap 2.8.0", +] [[package]] name = "glob" @@ -1525,7 +1586,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.5.0", + "indexmap 2.8.0", "slab", "tokio", "tokio-util", @@ -1545,7 +1606,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", - "serde 1.0.210", + "serde 1.0.219", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash", + "serde 1.0.219", ] [[package]] @@ -1795,18 +1866,18 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] name = "indexmap" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", - "hashbrown 0.14.5", - "serde 1.0.210", + "hashbrown 0.15.2", + "serde 1.0.219", ] [[package]] @@ -1920,6 +1991,24 @@ dependencies = [ "libc", ] +[[package]] +name = "js-component-bindgen" +version = "1.10.0" +source = "git+https://github.com/bytecodealliance/jco?rev=48c1a3c91a9c71d35aedc9572e180ce67ca3a4f5#48c1a3c91a9c71d35aedc9572e180ce67ca3a4f5" +dependencies = [ + "anyhow", + "base64 0.22.1", + "heck 0.5.0", + "log", + "semver", + "wasm-encoder 0.227.1", + "wasmparser 0.227.1", + "wasmtime-environ 30.0.2", + "wit-bindgen-core", + "wit-component 0.227.1", + "wit-parser 0.227.1", +] + [[package]] name = "js-sys" version = "0.3.70" @@ -1939,7 +2028,7 @@ dependencies = [ "crypto-common", "digest", "hmac", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", ] @@ -1976,6 +2065,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "lexical-core" version = "0.7.6" @@ -2076,7 +2171,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.8.4", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -2154,7 +2249,7 @@ dependencies = [ "cfg-if", "miette-derive", "thiserror", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -2165,7 +2260,7 @@ checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -2176,9 +2271,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", ] @@ -2340,13 +2435,13 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "crc32fast", - "hashbrown 0.14.5", - "indexmap 2.5.0", + "hashbrown 0.15.2", + "indexmap 2.8.0", "memchr", ] @@ -2366,7 +2461,7 @@ dependencies = [ "olpc-cjson", "regex", "reqwest", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "thiserror", @@ -2391,7 +2486,7 @@ dependencies = [ "olpc-cjson", "regex", "reqwest", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "thiserror", @@ -2409,7 +2504,7 @@ dependencies = [ "anyhow", "chrono", "oci-distribution", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "tokio", @@ -2426,7 +2521,7 @@ dependencies = [ "anyhow", "chrono", "oci-client", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "tokio", @@ -2440,7 +2535,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d637c9c15b639ccff597da8f4fa968300651ad2f1e968aefc3b4927a6fb2027a" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", "serde_json", "unicode-normalization", ] @@ -2474,7 +2569,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -2598,7 +2693,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1030c719b0ec2a2d25a5df729d6cff1acf3cc230bf766f4f97833591f7577b90" dependencies = [ "base64 0.21.7", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -2625,7 +2720,7 @@ dependencies = [ "pbjson-build", "prost", "prost-build", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -2650,7 +2745,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.5.0", + "indexmap 2.8.0", ] [[package]] @@ -2670,7 +2765,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -2752,7 +2847,7 @@ dependencies = [ "cobs", "embedded-io 0.4.0", "embedded-io 0.6.1", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -2777,7 +2872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -2801,9 +2896,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -2835,7 +2930,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.87", + "syn 2.0.100", "tempfile", ] @@ -2849,7 +2944,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -2921,7 +3016,7 @@ dependencies = [ "config", "directories", "petgraph", - "serde 1.0.210", + "serde 1.0.219", "serde-value", "tint", ] @@ -3150,7 +3245,7 @@ dependencies = [ "rustls", "rustls-pemfile", "rustls-pki-types", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "serde_urlencoded", "sync_wrapper", @@ -3334,7 +3429,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", "zeroize", ] @@ -3352,7 +3447,7 @@ dependencies = [ "num", "once_cell", "rand", - "serde 1.0.210", + "serde 1.0.219", "sha2", "zbus", ] @@ -3382,11 +3477,11 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.23" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -3397,9 +3492,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -3423,18 +3518,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" dependencies = [ "ordered-float", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -3446,7 +3541,7 @@ dependencies = [ "itoa", "memchr", "ryu", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -3457,7 +3552,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -3466,7 +3561,7 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -3478,7 +3573,7 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -3491,8 +3586,8 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.5.0", - "serde 1.0.210", + "indexmap 2.8.0", + "serde 1.0.219", "serde_derive", "serde_json", "serde_with_macros", @@ -3508,7 +3603,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -3517,10 +3612,10 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.8.0", "itoa", "ryu", - "serde 1.0.210", + "serde 1.0.219", "unsafe-libyaml", ] @@ -3639,7 +3734,7 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -3683,7 +3778,7 @@ version = "3.0.0" source = "git+https://github.com/fermyon/spin?tag=v3.0.0#737778e9d7dc1a7f590a398d2734ff0cc91002f0" dependencies = [ "anyhow", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "spin-locked-app", ] @@ -3707,12 +3802,14 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", + "convert_case", "dialoguer", "futures", + "js-component-bindgen", "openssl", "reqwest", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "spin-common", @@ -3725,11 +3822,11 @@ dependencies = [ "url", "wasm-pkg-client", "wasm-pkg-common 0.5.1", - "wasmparser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wasmparser 0.227.1", "wit-bindgen-core", "wit-bindgen-rust", - "wit-component 0.217.0", - "wit-parser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wit-component 0.227.1", + "wit-parser 0.227.1", ] [[package]] @@ -3756,7 +3853,7 @@ dependencies = [ "rustls", "rustls-pemfile", "rustls-pki-types", - "serde 1.0.210", + "serde 1.0.219", "spin-expressions", "spin-factor-variables", "spin-factor-wasi", @@ -3801,7 +3898,7 @@ version = "3.0.0" source = "git+https://github.com/fermyon/spin?tag=v3.0.0#737778e9d7dc1a7f590a398d2734ff0cc91002f0" dependencies = [ "anyhow", - "serde 1.0.210", + "serde 1.0.219", "spin-app", "spin-factors-derive", "thiserror", @@ -3816,7 +3913,7 @@ source = "git+https://github.com/fermyon/spin?tag=v3.0.0#737778e9d7dc1a7f590a398 dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -3831,7 +3928,7 @@ dependencies = [ "path-absolutize", "reqwest", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "spin-common", @@ -3853,7 +3950,7 @@ source = "git+https://github.com/fermyon/spin?tag=v3.0.0#737778e9d7dc1a7f590a398 dependencies = [ "anyhow", "async-trait", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "spin-serde", "thiserror", @@ -3865,9 +3962,9 @@ version = "3.0.0" source = "git+https://github.com/fermyon/spin?tag=v3.0.0#737778e9d7dc1a7f590a398d2734ff0cc91002f0" dependencies = [ "anyhow", - "indexmap 2.5.0", + "indexmap 2.8.0", "semver", - "serde 1.0.210", + "serde 1.0.219", "spin-serde", "terminal", "thiserror", @@ -3884,7 +3981,7 @@ dependencies = [ "anyhow", "base64 0.22.1", "semver", - "serde 1.0.210", + "serde 1.0.219", "wasm-pkg-common 0.4.1", ] @@ -3950,9 +4047,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -4011,6 +4108,12 @@ version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +[[package]] +name = "target-lexicon" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" + [[package]] name = "tempfile" version = "3.12.0" @@ -4058,7 +4161,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -4081,7 +4184,7 @@ dependencies = [ "itoa", "num-conv", "powerfmt", - "serde 1.0.210", + "serde 1.0.219", "time-core", "time-macros", ] @@ -4152,7 +4255,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -4207,7 +4310,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -4216,8 +4319,8 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ - "indexmap 2.5.0", - "serde 1.0.210", + "indexmap 2.8.0", + "serde 1.0.219", "serde_spanned", "toml_datetime", "toml_edit 0.22.21", @@ -4229,7 +4332,7 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", ] [[package]] @@ -4238,7 +4341,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.8.0", "toml_datetime", "winnow 0.5.40", ] @@ -4249,13 +4352,19 @@ version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ - "indexmap 2.5.0", - "serde 1.0.210", + "indexmap 2.8.0", + "serde 1.0.219", "serde_spanned", "toml_datetime", "winnow 0.6.18", ] +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + [[package]] name = "tower" version = "0.4.13" @@ -4303,7 +4412,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -4383,12 +4492,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + [[package]] name = "unicode-width" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -4479,9 +4600,9 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a22d3c9026f2f6a628cf386963844cdb7baea3b3419ba090c9096da114f977d" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.8.0", "itertools 0.12.1", - "serde 1.0.210", + "serde 1.0.219", "serde_with", "thiserror", "warg-crypto 0.7.0", @@ -4494,9 +4615,9 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44b422328c3a86be288f569694aa97df958ade0cd9514ed00bc562952c6778e" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.8.0", "itertools 0.12.1", - "serde 1.0.210", + "serde 1.0.219", "serde_with", "thiserror", "warg-crypto 0.9.0", @@ -4517,7 +4638,7 @@ dependencies = [ "dialoguer", "dirs 5.0.1", "futures-util", - "indexmap 2.5.0", + "indexmap 2.8.0", "itertools 0.12.1", "keyring", "libc", @@ -4528,7 +4649,7 @@ dependencies = [ "reqwest", "secrecy", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha256", "tempfile", @@ -4563,7 +4684,7 @@ dependencies = [ "dialoguer", "dirs 5.0.1", "futures-util", - "indexmap 2.5.0", + "indexmap 2.8.0", "itertools 0.12.1", "keyring", "libc", @@ -4574,7 +4695,7 @@ dependencies = [ "reqwest", "secrecy", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha256", "tempfile", @@ -4610,7 +4731,7 @@ dependencies = [ "p256", "rand_core", "secrecy", - "serde 1.0.210", + "serde 1.0.219", "sha2", "signature", "thiserror", @@ -4631,7 +4752,7 @@ dependencies = [ "p256", "rand_core", "secrecy", - "serde 1.0.210", + "serde 1.0.219", "sha2", "signature", "thiserror", @@ -4652,7 +4773,7 @@ dependencies = [ "prost-types", "protox", "regex", - "serde 1.0.210", + "serde 1.0.219", "warg-crypto 0.7.0", ] @@ -4671,7 +4792,7 @@ dependencies = [ "prost-types", "protox", "regex", - "serde 1.0.210", + "serde 1.0.219", "warg-crypto 0.9.0", ] @@ -4684,12 +4805,12 @@ dependencies = [ "anyhow", "base64 0.21.7", "hex", - "indexmap 2.5.0", + "indexmap 2.8.0", "pbjson-types", "prost", "prost-types", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_with", "thiserror", "warg-crypto 0.7.0", @@ -4707,12 +4828,12 @@ dependencies = [ "anyhow", "base64 0.21.7", "hex", - "indexmap 2.5.0", + "indexmap 2.8.0", "pbjson-types", "prost", "prost-types", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_with", "thiserror", "warg-crypto 0.9.0", @@ -4728,7 +4849,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "513ef81a5bb1ac5d7bd04f90d3c192dad8f590f4c02b3ef68d3ae4fbbb53c1d7" dependencies = [ "anyhow", - "indexmap 2.5.0", + "indexmap 2.8.0", "prost", "thiserror", "warg-crypto 0.7.0", @@ -4742,7 +4863,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b950a71a544b7ac8f5a5e95f43886ac97c3fe5c7080b955b1b534037596d7be" dependencies = [ "anyhow", - "indexmap 2.5.0", + "indexmap 2.8.0", "prost", "thiserror", "warg-crypto 0.9.0", @@ -4777,7 +4898,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", "wasm-bindgen-shared", ] @@ -4811,7 +4932,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4831,10 +4952,10 @@ dependencies = [ "anyhow", "heck 0.4.1", "im-rc", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "petgraph", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_yaml", "smallvec", @@ -4893,11 +5014,22 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.217.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#156960bbc3f712c9841345a0f699be32ff1f3c7a" +version = "0.224.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab7a13a23790fe91ea4eb7526a1f3131001d874e3e00c2976c48861f2e82920" dependencies = [ "leb128", - "wasmparser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wasmparser 0.224.1", +] + +[[package]] +name = "wasm-encoder" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bb72f02e7fbf07183443b27b0f3d4144abf8c114189f2e088ed95b696a7822" +dependencies = [ + "leb128fmt", + "wasmparser 0.227.1", ] [[package]] @@ -4907,8 +5039,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d32029ce424f6d3c2b39b4419fb45a0e2d84fb0751e0c0a32b7ce8bd5d97f46" dependencies = [ "anyhow", - "indexmap 2.5.0", - "serde 1.0.210", + "indexmap 2.8.0", + "serde 1.0.219", "serde_derive", "serde_json", "spdx", @@ -4923,8 +5055,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6bb07c5576b608f7a2a9baa2294c1a3584a249965d695a9814a496cb6d232f" dependencies = [ "anyhow", - "indexmap 2.5.0", - "serde 1.0.210", + "indexmap 2.8.0", + "serde 1.0.219", "serde_derive", "serde_json", "spdx", @@ -4939,8 +5071,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47c8154d703a6b0e45acf6bd172fa002fc3c7058a9f7615e517220aeca27c638" dependencies = [ "anyhow", - "indexmap 2.5.0", - "serde 1.0.210", + "indexmap 2.8.0", + "serde 1.0.219", "serde_derive", "serde_json", "spdx", @@ -4950,17 +5082,21 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.217.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#156960bbc3f712c9841345a0f699be32ff1f3c7a" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce1ef0faabbbba6674e97a56bee857ccddf942785a336c8b47b42373c922a91d" dependencies = [ "anyhow", - "indexmap 2.5.0", - "serde 1.0.210", + "auditable-serde", + "flate2", + "indexmap 2.8.0", + "serde 1.0.219", "serde_derive", "serde_json", "spdx", - "wasm-encoder 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", - "wasmparser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "url", + "wasm-encoder 0.227.1", + "wasmparser 0.227.1", ] [[package]] @@ -4979,7 +5115,7 @@ dependencies = [ "oci-client", "oci-wasm 0.0.5", "secrecy", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "thiserror", @@ -5007,7 +5143,7 @@ dependencies = [ "http", "reqwest", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "thiserror", "toml 0.8.19", @@ -5027,7 +5163,7 @@ dependencies = [ "http", "reqwest", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "thiserror", @@ -5052,7 +5188,7 @@ dependencies = [ "oci-distribution", "oci-wasm 0.0.4", "secrecy", - "serde 1.0.210", + "serde 1.0.219", "serde_json", "sha2", "thiserror", @@ -5087,7 +5223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ "bitflags 2.6.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "semver", ] @@ -5100,7 +5236,7 @@ dependencies = [ "ahash", "bitflags 2.6.0", "hashbrown 0.14.5", - "indexmap 2.5.0", + "indexmap 2.8.0", "semver", ] @@ -5113,7 +5249,7 @@ dependencies = [ "ahash", "bitflags 2.6.0", "hashbrown 0.14.5", - "indexmap 2.5.0", + "indexmap 2.8.0", "semver", ] @@ -5126,7 +5262,7 @@ dependencies = [ "ahash", "bitflags 2.6.0", "hashbrown 0.14.5", - "indexmap 2.5.0", + "indexmap 2.8.0", "semver", ] @@ -5139,22 +5275,35 @@ dependencies = [ "ahash", "bitflags 2.6.0", "hashbrown 0.14.5", - "indexmap 2.5.0", + "indexmap 2.8.0", "semver", - "serde 1.0.210", + "serde 1.0.219", ] [[package]] name = "wasmparser" -version = "0.217.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#156960bbc3f712c9841345a0f699be32ff1f3c7a" +version = "0.224.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04f17a5917c2ddd3819e84c661fae0d6ba29d7b9c1f0e96c708c65a9c4188e11" dependencies = [ - "ahash", "bitflags 2.6.0", - "hashbrown 0.14.5", - "indexmap 2.5.0", + "hashbrown 0.15.2", + "indexmap 2.8.0", "semver", - "serde 1.0.210", + "serde 1.0.219", +] + +[[package]] +name = "wasmparser" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f51cad774fb3c9461ab9bccc9c62dfb7388397b5deda31bf40e8108ccd678b2" +dependencies = [ + "bitflags 2.6.0", + "hashbrown 0.15.2", + "indexmap 2.8.0", + "semver", + "serde 1.0.219", ] [[package]] @@ -5175,7 +5324,18 @@ checksum = "50dc568b3e0d47e8f96ea547c90790cfa783f0205160c40de894a427114185ce" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.217.0", +] + +[[package]] +name = "wasmprinter" +version = "0.224.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0095b53a3b09cbc2f90f789ea44aa1b17ecc2dad8b267e657c7391f3ded6293d" +dependencies = [ + "anyhow", + "termcolor", + "wasmparser 0.224.1", ] [[package]] @@ -5195,7 +5355,7 @@ dependencies = [ "fxprof-processed-profile", "gimli 0.29.0", "hashbrown 0.14.5", - "indexmap 2.5.0", + "indexmap 2.8.0", "ittapi", "libc", "libm", @@ -5210,20 +5370,20 @@ dependencies = [ "rayon", "rustix 0.38.37", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "smallvec", "sptr", - "target-lexicon", - "wasm-encoder 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.12.16", + "wasm-encoder 0.217.0", + "wasmparser 0.217.0", "wasmtime-asm-macros", "wasmtime-cache", "wasmtime-component-macro", - "wasmtime-component-util", + "wasmtime-component-util 25.0.3", "wasmtime-cranelift", - "wasmtime-environ", + "wasmtime-environ 25.0.3", "wasmtime-fiber", "wasmtime-jit-debug", "wasmtime-jit-icache-coherence", @@ -5255,7 +5415,7 @@ dependencies = [ "log", "postcard", "rustix 0.38.37", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "sha2", "toml 0.8.19", @@ -5272,10 +5432,10 @@ dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.87", - "wasmtime-component-util", + "syn 2.0.100", + "wasmtime-component-util 25.0.3", "wasmtime-wit-bindgen", - "wit-parser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wit-parser 0.217.0", ] [[package]] @@ -5284,6 +5444,12 @@ version = "25.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdc29d2b56629d66d2fd791d1b46471d0016e0d684ed2dc299e870d127082268" +[[package]] +name = "wasmtime-component-util" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7108498a8a0afc81c7d2d81b96cdc509cd631d7bbaa271b7db5137026f10e3" + [[package]] name = "wasmtime-cranelift" version = "25.0.3" @@ -5294,7 +5460,7 @@ dependencies = [ "cfg-if", "cranelift-codegen", "cranelift-control", - "cranelift-entity", + "cranelift-entity 0.112.3", "cranelift-frontend", "cranelift-native", "cranelift-wasm", @@ -5302,10 +5468,10 @@ dependencies = [ "log", "object", "smallvec", - "target-lexicon", + "target-lexicon 0.12.16", "thiserror", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmtime-environ", + "wasmparser 0.217.0", + "wasmtime-environ 25.0.3", "wasmtime-versioned-export-macros", ] @@ -5317,25 +5483,50 @@ checksum = "3f1b5af7bac868c5bce3b78a366a10677caacf6e6467c156301297e36ed31f3e" dependencies = [ "anyhow", "cpp_demangle", - "cranelift-bitset", - "cranelift-entity", + "cranelift-bitset 0.112.3", + "cranelift-entity 0.112.3", "gimli 0.29.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "object", "postcard", "rustc-demangle", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", - "target-lexicon", - "wasm-encoder 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.12.16", + "wasm-encoder 0.217.0", + "wasmparser 0.217.0", "wasmprinter 0.217.0", - "wasmtime-component-util", + "wasmtime-component-util 25.0.3", "wasmtime-types", ] +[[package]] +name = "wasmtime-environ" +version = "30.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e90f6cba665939381839bbf2ddf12d732fca03278867910348ef1281b700954" +dependencies = [ + "anyhow", + "cranelift-bitset 0.117.2", + "cranelift-entity 0.117.2", + "gimli 0.31.0", + "indexmap 2.8.0", + "log", + "object", + "postcard", + "semver", + "serde 1.0.219", + "serde_derive", + "smallvec", + "target-lexicon 0.13.2", + "wasm-encoder 0.224.1", + "wasmparser 0.224.1", + "wasmprinter 0.224.1", + "wasmtime-component-util 30.0.2", +] + [[package]] name = "wasmtime-fiber" version = "25.0.3" @@ -5388,11 +5579,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6d83a7816947a4974e2380c311eacb1db009b8bad86081dc726b705603c93c7" dependencies = [ "anyhow", - "cranelift-entity", - "serde 1.0.210", + "cranelift-entity 0.112.3", + "serde 1.0.219", "serde_derive", "smallvec", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.217.0", ] [[package]] @@ -5403,7 +5594,7 @@ checksum = "6879a8e168aef3fe07335343b7fbede12fa494215e83322e173d4018e124a846" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -5447,10 +5638,10 @@ dependencies = [ "cranelift-codegen", "gimli 0.29.0", "object", - "target-lexicon", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.12.16", + "wasmparser 0.217.0", "wasmtime-cranelift", - "wasmtime-environ", + "wasmtime-environ 25.0.3", "winch-codegen", ] @@ -5462,8 +5653,8 @@ checksum = "3f571f63ac1d532e986eb3973bbef3a45e4ae83de521a8d573b0fe0594dc9608" dependencies = [ "anyhow", "heck 0.4.1", - "indexmap 2.5.0", - "wit-parser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 2.8.0", + "wit-parser 0.217.0", ] [[package]] @@ -5477,24 +5668,24 @@ dependencies = [ [[package]] name = "wast" -version = "217.0.0" +version = "227.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79004ecebded92d3c710d4841383368c7f04b63d0992ddd6b0c7d5029b7629b7" +checksum = "85c14e5042b16c9d267da3b9b0f4529870455178415286312c25c34dfc1b2816" dependencies = [ "bumpalo", - "leb128", + "leb128fmt", "memchr", - "unicode-width", - "wasm-encoder 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.2.0", + "wasm-encoder 0.227.1", ] [[package]] name = "wat" -version = "1.217.0" +version = "1.227.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c126271c3d92ca0f7c63e4e462e40c69cca52fd4245fcda730d1cf558fb55088" +checksum = "b3d394d5bef7006ff63338d481ca10f1af76601e65ebdf5ed33d29302994e9cc" dependencies = [ - "wast 217.0.0", + "wast 227.0.1", ] [[package]] @@ -5542,7 +5733,7 @@ dependencies = [ "proc-macro2", "quote", "shellexpand", - "syn 2.0.87", + "syn 2.0.100", "witx", ] @@ -5554,7 +5745,7 @@ checksum = "6e1c266e16c4b24a29e055ec651e27fce1389c886bb00fbe78b8924a253a439b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", "wiggle-generate", ] @@ -5600,10 +5791,10 @@ dependencies = [ "gimli 0.29.0", "regalloc2", "smallvec", - "target-lexicon", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.12.16", + "wasmparser 0.217.0", "wasmtime-cranelift", - "wasmtime-environ", + "wasmtime-environ 25.0.3", ] [[package]] @@ -5823,27 +6014,29 @@ dependencies = [ [[package]] name = "wit-bindgen-core" -version = "0.32.0" -source = "git+https://github.com/fibonacci1729/wit-bindgen?branch=deps#83aa28293258fd6c3697e044b3a3d69397a2fe81" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92fa781d4f2ff6d3f27f3cc9b74a73327b31ca0dc4a3ef25a0ce2983e0e5af9b" dependencies = [ "anyhow", "heck 0.5.0", - "wit-parser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wit-parser 0.227.1", ] [[package]] name = "wit-bindgen-rust" -version = "0.32.0" -source = "git+https://github.com/fibonacci1729/wit-bindgen?branch=deps#83aa28293258fd6c3697e044b3a3d69397a2fe81" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0809dc5ba19e2e98661bf32fc0addc5a3ca5bf3a6a7083aa6ba484085ff3ce" dependencies = [ "anyhow", "heck 0.5.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "prettyplease", - "syn 2.0.87", - "wasm-metadata 0.217.0", + "syn 2.0.100", + "wasm-metadata 0.227.1", "wit-bindgen-core", - "wit-component 0.217.0", + "wit-component 0.227.1", ] [[package]] @@ -5854,9 +6047,9 @@ checksum = "25a2bb5b039f9cb03425e1d5a6e54b441ca4ca1b1d4fa6a0924db67a55168f99" dependencies = [ "anyhow", "bitflags 2.6.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "wasm-encoder 0.209.1", @@ -5873,9 +6066,9 @@ checksum = "f725e3885fc5890648be5c5cbc1353b755dc932aa5f1aa7de968b912a3280743" dependencies = [ "anyhow", "bitflags 2.6.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "wasm-encoder 0.215.0", @@ -5892,9 +6085,9 @@ checksum = "7e2ca3ece38ea2447a9069b43074ba73d96dde1944cba276c54e41371745f9dc" dependencies = [ "anyhow", "bitflags 2.6.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "wasm-encoder 0.216.0", @@ -5905,20 +6098,22 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.217.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#156960bbc3f712c9841345a0f699be32ff1f3c7a" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "635c3adc595422cbf2341a17fb73a319669cc8d33deed3a48368a841df86b676" dependencies = [ "anyhow", "bitflags 2.6.0", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", - "wasm-encoder 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", - "wasm-metadata 0.217.0", - "wasmparser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", - "wit-parser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wasm-encoder 0.227.1", + "wasm-metadata 0.227.1", + "wasmparser 0.227.1", + "wat", + "wit-parser 0.227.1", ] [[package]] @@ -5929,10 +6124,10 @@ checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" dependencies = [ "anyhow", "id-arena", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "unicode-xid", @@ -5947,10 +6142,10 @@ checksum = "935a97eaffd57c3b413aa510f8f0b550a4a9fe7d59e79cd8b89a83dcb860321f" dependencies = [ "anyhow", "id-arena", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "unicode-xid", @@ -5965,10 +6160,10 @@ checksum = "a4d108165c1167a4ccc8a803dcf5c28e0a51d6739fd228cc7adce768632c764c" dependencies = [ "anyhow", "id-arena", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "unicode-xid", @@ -5983,31 +6178,32 @@ checksum = "fb893dcd6d370cfdf19a0d9adfcd403efb8e544e1a0ea3a8b81a21fe392eaa78" dependencies = [ "anyhow", "id-arena", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.217.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.217.0", ] [[package]] name = "wit-parser" -version = "0.217.0" -source = "git+https://github.com/bytecodealliance/wasm-tools#156960bbc3f712c9841345a0f699be32ff1f3c7a" +version = "0.227.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" dependencies = [ "anyhow", "id-arena", - "indexmap 2.5.0", + "indexmap 2.8.0", "log", "semver", - "serde 1.0.210", + "serde 1.0.219", "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.217.0 (git+https://github.com/bytecodealliance/wasm-tools)", + "wasmparser 0.227.1", ] [[package]] @@ -6069,7 +6265,7 @@ dependencies = [ "once_cell", "ordered-stream", "rand", - "serde 1.0.210", + "serde 1.0.219", "serde_repr", "sha1", "static_assertions", @@ -6102,7 +6298,7 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "437d738d3750bed6ca9b8d423ccc7a8eb284f6b1d6d4e225a0e4e6258d864c8d" dependencies = [ - "serde 1.0.210", + "serde 1.0.219", "static_assertions", "zvariant", ] @@ -6125,7 +6321,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.100", ] [[package]] @@ -6171,7 +6367,7 @@ dependencies = [ "byteorder", "enumflags2", "libc", - "serde 1.0.210", + "serde 1.0.219", "static_assertions", "zvariant_derive", ] diff --git a/Cargo.toml b/Cargo.toml index bccedd7..a34af7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,15 +19,17 @@ tokio = { version = "1.40.0", features = ["full"] } toml = "0.8.19" toml_edit = "0.22.21" url = "2.5.2" -wasmparser = { git = "https://github.com/bytecodealliance/wasm-tools" } -wit-component = { git = "https://github.com/bytecodealliance/wasm-tools" } -wit-parser = { git = "https://github.com/bytecodealliance/wasm-tools" } +wasmparser = "0.227.1" +wit-component = "0.227.1" +wit-parser = "0.227.1" futures = "0.3.30" -semver = "1.0.23" -wit-bindgen-rust = { git = "https://github.com/fibonacci1729/wit-bindgen", branch = "deps" } -wit-bindgen-core = { git = "https://github.com/fibonacci1729/wit-bindgen", branch = "deps" } +semver = "1.0.25" +wit-bindgen-rust = "0.41.0" +wit-bindgen-core = "0.41.0" wasm-pkg-common = "0.5.1" wasm-pkg-client = "0.5.1" +js-component-bindgen = { git = "https://github.com/bytecodealliance/jco", rev = "48c1a3c91a9c71d35aedc9572e180ce67ca3a4f5" } +convert_case = "0.8.0" [target.'cfg(target_os = "linux")'.dependencies] # This needs to be an explicit dependency to enable diff --git a/src/commands/add.rs b/src/commands/add.rs index f652773..92046c5 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -1,5 +1,6 @@ use anyhow::{anyhow, bail, Context, Result}; use clap::Args; +use convert_case::{Case, Casing}; use http::HttpAddCommand; use local::LocalAddCommand; use registry::RegistryAddCommand; @@ -25,6 +26,7 @@ use crate::common::{ paths::fs_safe_segment, wit::{get_exported_interfaces, parse_component_bytes, resolve_to_wit}, }; +use js_component_bindgen::{generate_types, TranspileOpts}; mod http; mod local; @@ -198,6 +200,7 @@ impl AddCommand { root_dir, target_component, package_name: package, + resolve: &resolve, interfaces: &interfaces, rel_wit_path: &output_wit_path, }; @@ -402,6 +405,7 @@ struct BindOMatic<'a> { root_dir: &'a Path, target_component: &'a spin_manifest::schema::v2::Component, package_name: &'a wit_parser::PackageName, + resolve: &'a wit_parser::Resolve, interfaces: &'a [String], rel_wit_path: &'a Path, } @@ -457,10 +461,169 @@ async fn try_generate_bindings<'a>(target: &'a BindOMatic<'a>) -> anyhow::Result ) .await } - Language::TypeScript { package_json: _ } => todo!(), + Language::TypeScript { package_json: _ } => { + generate_ts_bindings( + target.root_dir, + target.package_name, + &mut target.resolve.clone(), + ) + .await + } } } +async fn generate_ts_bindings( + root_dir: &Path, + package_name: &wit_parser::PackageName, + resolve: &mut Resolve, +) -> anyhow::Result<()> { + println!( + "Generating TypeScript bindings for {}/{}", + package_name.namespace, package_name.name + ); + + let package_name_str = if let Some(v) = &package_name.version { + format!( + "@spin-deps/{}-{}@{}", + package_name.namespace, package_name.name, v + ) + } else { + format!( + "@spin-deps/{}-{}", + package_name.namespace, package_name.name + ) + }; + + let package_id = resolve + .packages + .iter() + .find(|(_, p)| &p.name.to_string() == "root:component") + .unwrap() + .0; + + let world_id = resolve.select_world(package_id, Some("root"))?; + + let out_world_name = &package_name + .to_string() + .replace("_", "-") + .replace(":", "-") + .replace("@", "") + .replace("/", "-"); + + resolve.importize(world_id, Some(out_world_name.clone()))?; + let out_world_id = resolve.select_world(package_id, Some(&out_world_name))?; + + // Create a new directory within the spin component working directory + let package_dir = root_dir.join(&package_name_str); + fs::create_dir_all(&package_dir).await?; + + // add a package.json file + let package_json = package_dir.join("package.json"); + let package_json_content = package_json_content(&package_name_str, &out_world_name); + fs::write(&package_json, package_json_content) + .await + .context("no package json file")?; + // create tsconfig + let tsconfig = package_dir.join("tsconfig.json"); + let tsconfig_content = tsconfig_content(); + fs::write(&tsconfig, tsconfig_content) + .await + .context("no tsconfig file")?; + // write the wit from the resolve in wit/world.wit + let world_wit = package_dir.join("wit/world.wit"); + // create if not exist + fs::create_dir_all(world_wit.parent().unwrap()).await?; + let world_wit_text = resolve_to_wit(resolve, package_id).context("failed to resolve to wit")?; + fs::write(&world_wit, world_wit_text) + .await + .context("No wit folder")?; + + let files = generate_types( + // This name does not matter as we are not going to use it + "test", + resolve.clone(), + world_id, + TranspileOpts { + name: package_name_str.clone(), + no_typescript: false, + instantiation: None, + import_bindings: None, + map: None, + no_nodejs_compat: false, + base64_cutoff: 0, + async_mode: None, + tla_compat: false, + valid_lifting_optimization: false, + tracing: false, + no_namespaced_exports: false, + multi_memory: true, + guest: true, + }, + )?; + + for (name, contents) in files.iter() { + let output_path = package_dir.join("types").join(name); + // Create parent directories if they don't exist + if let Some(parent) = output_path.parent() { + fs::create_dir_all(parent).await?; + } + fs::write(output_path, contents).await?; + } + // for all interface names in interfaces, import and re-export them in a index.js file + let mut re_exports: Vec = Vec::new(); + let mut name_counts: HashMap = HashMap::new(); + for (_, item) in resolve.worlds[out_world_id].imports.iter() { + match item { + wit_parser::WorldItem::Interface { id, stability: _ } => { + let iface = &resolve.interfaces[*id]; + + let iface_name = &iface.name.clone().unwrap().to_case(Case::Camel); + let package = &resolve.packages[iface.package.unwrap()]; + // Only handle interfaces from the package we are generating bindings for + if package.name != *package_name { + continue; + } + + // Track names to detect collision + let count = name_counts.entry(iface_name.clone()).or_insert(0); + *count += 1; + + let final_name = if *count > 1 { + format!("{}{}", package_name, iface_name) + } else { + iface_name.clone() + }; + + let import_path = qualified_itf_name(&package.name, &iface.name.clone().unwrap()); + + re_exports.push(format!( + "import * as {} from '{}';", + final_name, import_path + )); + re_exports.push(format!("export {{ {} }};", final_name)); + + println!("import * as {} from '{}';", final_name, import_path); + println!("export {{ {} }};", final_name); + } + // TODO: spin deps itself does not importing functions + wit_parser::WorldItem::Function(_) => {} + // Types are not generated by the TypeScript bindings generator + wit_parser::WorldItem::Type(_) => {} + } + } + let index_js = package_dir.join("index.js"); + fs::write(&index_js, re_exports.join("\n")).await?; + + println!("TypeScript bindings generated successfully"); + println!( + "To use the component, run:\ncd {}\n npm install ./{}", + root_dir.to_string_lossy(), + package_name + ); + + Ok(()) +} + async fn generate_rust_bindings( root_dir: &Path, package_name: &wit_parser::PackageName, @@ -556,3 +719,50 @@ async fn generate_rust_bindings( Ok(()) } + +fn package_json_content(package_name: &str, world: &str) -> String { + format!( + r#"{{ + "name": "{package_name}", + "version": "0.1.0", + "description": "Generated Package for {package_name}", + "main": "index.js", + "scripts": {{ + }}, + "author": "", + "license": "ISC", + "config": {{ + "witDeps": + [ + {{ + "witPath": "./wit", + "package": "root:component", + "world": "{world}" + }} + ] + }} +}}"# + ) +} + +fn tsconfig_content() -> String { + r#"{ + "compilerOptions": { + "target": "ES2020", + "module": "ES2020", + "lib": [ + "ES2020" + ], + "moduleResolution": "node", + "declaration": true, + "outDir": "dist", + "strict": true, + "esModuleInterop": true, + }, + "exclude": [ + "node_modules", + "dist" + ] +}"# + .to_owned() +} diff --git a/src/commands/bindings.rs b/src/commands/bindings.rs deleted file mode 100644 index f997682..0000000 --- a/src/commands/bindings.rs +++ /dev/null @@ -1,96 +0,0 @@ -use anyhow::Result; -use clap::{Args, ValueEnum}; -use std::path::PathBuf; -use tokio::fs; -use wit_parser::Resolve; - -use crate::common::constants::{SPIN_DEPS_WIT_FILE_NAME, SPIN_WIT_DIRECTORY}; - -#[derive(Debug, Clone, ValueEnum)] -pub enum BindingsLanguage { - Ts, - Rust, -} - -#[derive(Args, Debug)] -pub struct GenerateBindingsCommand { - /// The programming language to generate bindings in - #[clap(short = 'L', long)] - pub language: BindingsLanguage, - - /// Output directory - #[clap(short = 'o', long)] - pub output: PathBuf, - - /// Id of the component, which dependencies to generate the bindings for - #[clap(short = 'c', long)] - pub component_id: String, -} - -impl GenerateBindingsCommand { - pub async fn run(&self) -> Result<()> { - let wit_path = PathBuf::from(SPIN_WIT_DIRECTORY) - .join(&self.component_id) - .join(SPIN_DEPS_WIT_FILE_NAME); - - if !std::fs::exists(&wit_path)? { - anyhow::bail!( - r#"The WIT file that `spin deps` uses to track component dependencies doesn't exist. This can happen if: -* the component name is incorrect -* you've not previously run `spin deps add` for this component -The expected file is {wit_path:?}"# - ); - } - - let mut resolve = Resolve::default(); - let package_id = resolve.push_file(&wit_path)?; - - let world_id = resolve.select_world(package_id, Some("deps"))?; - - match &self.language { - BindingsLanguage::Rust => { - // TODO: If wit-bindgen is not in Cargo.toml, make sure to add it. - let opts = wit_bindgen_rust::Opts { - generate_all: true, - // TODO: Make the extra attributes a clap option - additional_derive_attributes: vec![ - "serde::Serialize".to_string(), - "serde::Deserialize".to_string(), - "Hash".to_string(), - "Clone".to_string(), - "PartialEq".to_string(), - "Eq".to_string(), - ], - // Uncomment this once spin-sdk is updated and remove dependency on wit_bindgen in Cargo.toml - //runtime_path: Some("::spin_sdk::wit_bindgen".to_string()), - ..Default::default() - }; - - let mut generator = opts.build(); - - let mut files = wit_bindgen_core::source::Files::default(); - generator.generate(&resolve, world_id, &mut files)?; - - fs::create_dir_all(&self.output).await?; - - let mut mod_output = String::new(); - - for (name, contents) in files.iter() { - let output_path = self.output.join(name); - let mod_file = PathBuf::from(name); - let mod_name = mod_file.file_stem().unwrap().to_string_lossy(); - std::fmt::write(&mut mod_output, format_args!("pub mod {mod_name};\n"))?; - fs::write(output_path, contents).await?; - } - - fs::write(self.output.join("mod.rs"), mod_output).await?; - println!("Bindings generated for Rust in {0}. You need to add the `wit-bindgen` crate to your Rust Spin app - e.g., `cargo add wit-bindgen`", self.output.to_str().expect("Failed to parse output path")); - } - BindingsLanguage::Ts => { - todo!("generate ts") - } - } - - Ok(()) - } -} diff --git a/src/commands/mod.rs b/src/commands/mod.rs index c895111..694428d 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,3 +1,2 @@ pub mod add; -pub mod bindings; pub mod publish; diff --git a/src/common/constants.rs b/src/common/constants.rs index 1356d46..c71d7f5 100644 --- a/src/common/constants.rs +++ b/src/common/constants.rs @@ -1,2 +1 @@ pub const SPIN_WIT_DIRECTORY: &str = ".wit/components"; -pub const SPIN_DEPS_WIT_FILE_NAME: &str = "deps.wit"; diff --git a/src/common/wit.rs b/src/common/wit.rs index feed7bc..c5b384e 100644 --- a/src/common/wit.rs +++ b/src/common/wit.rs @@ -14,7 +14,8 @@ pub fn resolve_to_wit(resolve: &Resolve, package_id: PackageId) -> Result>(); - printer.print(resolve, package_id, &ids) + printer.print(resolve, package_id, &ids)?; + Ok(printer.output.to_string()) } pub fn parse_component_bytes(bytes: Vec) -> Result<(Resolve, PackageId)> { diff --git a/src/main.rs b/src/main.rs index ba5c775..05539c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use clap::{Parser, Subcommand}; mod commands; mod common; mod language; -use commands::{add::AddCommand, bindings::GenerateBindingsCommand, publish::PublishCommand}; +use commands::{add::AddCommand, publish::PublishCommand}; /// Main CLI structure for command-line argument parsing. #[derive(Parser)] @@ -19,8 +19,6 @@ struct Cli { enum Commands { /// Add a new component dependency Add(AddCommand), - /// Generates dependency bindings for selected component - GenerateBindings(GenerateBindingsCommand), /// Publish dependency to a compatible registry Publish(PublishCommand), @@ -32,7 +30,6 @@ async fn main() -> Result<()> { match app.command { Commands::Add(cmd) => cmd.run().await?, - Commands::GenerateBindings(cmd) => cmd.run().await?, Commands::Publish(cmd) => cmd.run().await?, } From 6836b18b81f360f875bc55c414209b00deea9129 Mon Sep 17 00:00:00 2001 From: karthik2804 Date: Mon, 24 Mar 2025 22:59:41 +0100 Subject: [PATCH 2/6] fix bugs related to version handing in ts flow Signed-off-by: karthik2804 --- src/commands/add.rs | 49 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/commands/add.rs b/src/commands/add.rs index 92046c5..6af02fc 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -4,7 +4,7 @@ use convert_case::{Case, Casing}; use http::HttpAddCommand; use local::LocalAddCommand; use registry::RegistryAddCommand; -use semver::VersionReq; +use semver::{Version, VersionReq}; use spin_manifest::{ manifest_from_file, schema::v2::{AppManifest, ComponentDependency}, @@ -482,17 +482,10 @@ async fn generate_ts_bindings( package_name.namespace, package_name.name ); - let package_name_str = if let Some(v) = &package_name.version { - format!( - "@spin-deps/{}-{}@{}", - package_name.namespace, package_name.name, v - ) - } else { - format!( - "@spin-deps/{}-{}", - package_name.namespace, package_name.name - ) - }; + let package_name_str = format!( + "@spin-deps/{}-{}", + package_name.namespace, package_name.name + ); let package_id = resolve .packages @@ -503,12 +496,14 @@ async fn generate_ts_bindings( let world_id = resolve.select_world(package_id, Some("root"))?; - let out_world_name = &package_name - .to_string() - .replace("_", "-") - .replace(":", "-") - .replace("@", "") - .replace("/", "-"); + let out_world_name = &format!( + "importized-{}-{}", + package_name.namespace, package_name.name + ) + .replace("_", "-") + .replace(":", "-") + .replace("@", "") + .replace("/", "-"); resolve.importize(world_id, Some(out_world_name.clone()))?; let out_world_id = resolve.select_world(package_id, Some(&out_world_name))?; @@ -519,7 +514,11 @@ async fn generate_ts_bindings( // add a package.json file let package_json = package_dir.join("package.json"); - let package_json_content = package_json_content(&package_name_str, &out_world_name); + let package_json_content = package_json_content( + &package_name_str, + &out_world_name, + package_name.version.clone(), + ); fs::write(&package_json, package_json_content) .await .context("no package json file")?; @@ -601,9 +600,6 @@ async fn generate_ts_bindings( final_name, import_path )); re_exports.push(format!("export {{ {} }};", final_name)); - - println!("import * as {} from '{}';", final_name, import_path); - println!("export {{ {} }};", final_name); } // TODO: spin deps itself does not importing functions wit_parser::WorldItem::Function(_) => {} @@ -618,7 +614,7 @@ async fn generate_ts_bindings( println!( "To use the component, run:\ncd {}\n npm install ./{}", root_dir.to_string_lossy(), - package_name + package_name_str ); Ok(()) @@ -720,11 +716,14 @@ async fn generate_rust_bindings( Ok(()) } -fn package_json_content(package_name: &str, world: &str) -> String { +fn package_json_content(package_name: &str, world: &str, version: Option) -> String { + let version_str = version + .map(|v| v.to_string()) + .unwrap_or_else(|| "0.1.0".to_owned()); format!( r#"{{ "name": "{package_name}", - "version": "0.1.0", + "version": "{version_str}", "description": "Generated Package for {package_name}", "main": "index.js", "scripts": {{ From 3a5d98b1fc031c63b44401f4265718391edb551e Mon Sep 17 00:00:00 2001 From: Karthik Ganeshram Date: Wed, 21 May 2025 21:32:23 +0200 Subject: [PATCH 3/6] fix field name for js bindings Signed-off-by: Karthik Ganeshram --- src/commands/add.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/add.rs b/src/commands/add.rs index 6af02fc..a514582 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -731,7 +731,7 @@ fn package_json_content(package_name: &str, world: &str, version: Option Date: Wed, 21 May 2025 21:34:51 +0200 Subject: [PATCH 4/6] bump rust version in CI Signed-off-by: Karthik Ganeshram --- .github/workflows/release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0790171..d676da4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -35,7 +35,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.81 + toolchain: 1.84 - name: Install dependencies run: | @@ -72,7 +72,7 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable with: - toolchain: 1.81 + toolchain: 1.84 targets: ${{ matrix.config.target }} - name: Install Spin uses: rajatjindal/setup-actions/spin@main From 8ce806a396efa3659135e065aeaabb3abfe120d7 Mon Sep 17 00:00:00 2001 From: Karthik Ganeshram Date: Wed, 21 May 2025 21:45:17 +0200 Subject: [PATCH 5/6] satisfy clippy Signed-off-by: Karthik Ganeshram --- src/commands/add.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/add.rs b/src/commands/add.rs index a514582..ec14784 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -506,7 +506,7 @@ async fn generate_ts_bindings( .replace("/", "-"); resolve.importize(world_id, Some(out_world_name.clone()))?; - let out_world_id = resolve.select_world(package_id, Some(&out_world_name))?; + let out_world_id = resolve.select_world(package_id, Some(out_world_name))?; // Create a new directory within the spin component working directory let package_dir = root_dir.join(&package_name_str); @@ -516,7 +516,7 @@ async fn generate_ts_bindings( let package_json = package_dir.join("package.json"); let package_json_content = package_json_content( &package_name_str, - &out_world_name, + out_world_name, package_name.version.clone(), ); fs::write(&package_json, package_json_content) From 6b2d1f3379d2f024cac912c8deaeb9964f8cb7ae Mon Sep 17 00:00:00 2001 From: Karthik Ganeshram Date: Thu, 22 May 2025 10:23:38 +0200 Subject: [PATCH 6/6] add reference type paths to generated file Signed-off-by: Karthik Ganeshram --- src/commands/add.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/commands/add.rs b/src/commands/add.rs index ec14784..e8ae011 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -560,16 +560,22 @@ async fn generate_ts_bindings( }, )?; + let mut reference_types = Vec::new(); + for (name, contents) in files.iter() { let output_path = package_dir.join("types").join(name); // Create parent directories if they don't exist if let Some(parent) = output_path.parent() { fs::create_dir_all(parent).await?; } + + reference_types.push(format!("/// \n",)); + println!("Writing {name} to {output_path:?}"); fs::write(output_path, contents).await?; } // for all interface names in interfaces, import and re-export them in a index.js file let mut re_exports: Vec = Vec::new(); + re_exports.push(reference_types.join("\n")); let mut name_counts: HashMap = HashMap::new(); for (_, item) in resolve.worlds[out_world_id].imports.iter() { match item {