From 053e1a0ed43729b1a00c2ef00a1d8c3f8ea68692 Mon Sep 17 00:00:00 2001 From: "nekomimi.pet" Date: Sat, 3 Jan 2026 20:35:03 -0500 Subject: [PATCH] lexicon work i shouldve done ages ago --- cli/Cargo.lock | 343 +++++------------- cli/Cargo.toml | 15 +- cli/crates/lexicons/Cargo.toml | 15 + .../lexicons}/src/builder_types.rs | 0 cli/{ => crates/lexicons}/src/lib.rs | 2 + cli/{ => crates/lexicons}/src/place_wisp.rs | 0 .../lexicons}/src/place_wisp/fs.rs | 68 ++-- .../lexicons}/src/place_wisp/settings.rs | 0 .../lexicons}/src/place_wisp/subfs.rs | 60 +-- cli/src/blob_map.rs | 2 +- cli/src/main.rs | 28 +- cli/src/mod.rs | 9 - cli/src/pull.rs | 24 +- cli/src/serve.rs | 2 +- cli/src/subfs_utils.rs | 28 +- .../lexicons/lexicons => lexicons}/fs.json | 0 .../lexicons => lexicons}/settings.json | 0 .../lexicons/lexicons => lexicons}/subfs.json | 0 package.json | 3 +- packages/@wisp/lexicons/package.json | 2 +- packages/@wisp/lexicons/src/index.ts | 2 +- packages/@wisp/lexicons/src/lexicons.ts | 2 +- scripts/codegen.sh | 28 ++ 23 files changed, 251 insertions(+), 382 deletions(-) create mode 100644 cli/crates/lexicons/Cargo.toml rename cli/{ => crates/lexicons}/src/builder_types.rs (100%) rename cli/{ => crates/lexicons}/src/lib.rs (92%) rename cli/{ => crates/lexicons}/src/place_wisp.rs (100%) rename cli/{ => crates/lexicons}/src/place_wisp/fs.rs (99%) rename cli/{ => crates/lexicons}/src/place_wisp/settings.rs (100%) rename cli/{ => crates/lexicons}/src/place_wisp/subfs.rs (99%) delete mode 100644 cli/src/mod.rs rename {packages/@wisp/lexicons/lexicons => lexicons}/fs.json (100%) rename {packages/@wisp/lexicons/lexicons => lexicons}/settings.json (100%) rename {packages/@wisp/lexicons/lexicons => lexicons}/subfs.json (100%) create mode 100755 scripts/codegen.sh diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 473c0c0..384fc6d 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -2,25 +2,6 @@ # It is not intended for manual editing. version = 4 -[[package]] -name = "abnf" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087113bd50d9adce24850eed5d0476c7d199d532fce8fab5173650331e09033a" -dependencies = [ - "abnf-core", - "nom", -] - -[[package]] -name = "abnf-core" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c44e09c43ae1c368fb91a03a566472d0087c26cf7e1b9e8e289c14ede681dd7d" -dependencies = [ - "nom", -] - [[package]] name = "addr2line" version = "0.25.1" @@ -72,6 +53,12 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -378,30 +365,6 @@ dependencies = [ "serde", ] -[[package]] -name = "btree-range-map" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be5c9672446d3800bcbcaabaeba121fe22f1fb25700c4562b22faf76d377c33" -dependencies = [ - "btree-slab", - "cc-traits", - "range-traits", - "serde", - "slab", -] - -[[package]] -name = "btree-slab" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2b56d3029f075c4fa892428a098425b86cef5c89ae54073137ece416aef13c" -dependencies = [ - "cc-traits", - "slab", - "smallvec", -] - [[package]] name = "buf_redux" version = "0.8.4" @@ -452,15 +415,6 @@ dependencies = [ "shlex", ] -[[package]] -name = "cc-traits" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060303ef31ef4a522737e1b1ab68c67916f2a787bb2f4f54f383279adba962b5" -dependencies = [ - "slab", -] - [[package]] name = "cesu8" version = "1.1.0" @@ -881,7 +835,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" dependencies = [ "powerfmt", - "serde_core", ] [[package]] @@ -955,12 +908,6 @@ dependencies = [ "syn 2.0.111", ] -[[package]] -name = "dyn-clone" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" - [[package]] name = "ecdsa" version = "0.16.9" @@ -1100,6 +1047,12 @@ 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 = "form_urlencoded" version = "1.2.2" @@ -1365,7 +1318,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.12.1", + "indexmap", "slab", "tokio", "tokio-util", @@ -1394,15 +1347,20 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] [[package]] name = "hashbrown" @@ -1448,12 +1406,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hex_fmt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" - [[package]] name = "hickory-proto" version = "0.24.4" @@ -1787,17 +1739,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.12.1" @@ -1806,8 +1747,6 @@ checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", "hashbrown 0.16.1", - "serde", - "serde_core", ] [[package]] @@ -1823,15 +1762,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "indoc" -version = "2.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" -dependencies = [ - "rustversion", -] - [[package]] name = "inventory" version = "0.3.21" @@ -1900,8 +1830,8 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jacquard" -version = "0.9.4" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.5" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "bytes", "getrandom 0.2.16", @@ -1917,7 +1847,6 @@ dependencies = [ "regex", "regex-lite", "reqwest", - "ring", "serde", "serde_html_form", "serde_json", @@ -1931,8 +1860,8 @@ dependencies = [ [[package]] name = "jacquard-api" -version = "0.9.2" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.5" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "bon", "bytes", @@ -1950,34 +1879,37 @@ dependencies = [ [[package]] name = "jacquard-common" -version = "0.9.2" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.5" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "base64 0.22.1", "bon", "bytes", "chrono", "ciborium", + "ciborium-io", "cid", "futures", "getrandom 0.2.16", "getrandom 0.3.4", + "hashbrown 0.15.5", "http", "ipld-core", "k256", - "langtag", + "maitake-sync", "miette", "multibase", "multihash", "n0-future 0.1.3", "ouroboros", + "oxilangtag", "p256", "postcard", "rand 0.9.2", "regex", + "regex-automata", "regex-lite", "reqwest", - "ring", "serde", "serde_bytes", "serde_html_form", @@ -1985,6 +1917,7 @@ dependencies = [ "serde_json", "signature", "smol_str", + "spin 0.10.0", "thiserror 2.0.17", "tokio", "tokio-tungstenite-wasm", @@ -1995,8 +1928,8 @@ dependencies = [ [[package]] name = "jacquard-derive" -version = "0.9.4" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.5" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "heck 0.5.0", "jacquard-lexicon", @@ -2007,8 +1940,8 @@ dependencies = [ [[package]] name = "jacquard-identity" -version = "0.9.2" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.5" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "bon", "bytes", @@ -2018,11 +1951,10 @@ dependencies = [ "jacquard-common", "jacquard-lexicon", "miette", - "mini-moka", + "mini-moka-wasm", "n0-future 0.1.3", "percent-encoding", "reqwest", - "ring", "serde", "serde_html_form", "serde_json", @@ -2035,8 +1967,8 @@ dependencies = [ [[package]] name = "jacquard-lexicon" -version = "0.9.2" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.5" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "cid", "dashmap", @@ -2061,8 +1993,8 @@ dependencies = [ [[package]] name = "jacquard-oauth" -version = "0.9.2" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +version = "0.9.6" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "base64 0.22.1", "bytes", @@ -2077,7 +2009,6 @@ dependencies = [ "miette", "p256", "rand 0.8.5", - "ring", "rouille", "serde", "serde_html_form", @@ -2171,17 +2102,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "langtag" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecb4c689a30e48ebeaa14237f34037e300dd072e6ad21a9ec72e810ff3c6600" -dependencies = [ - "serde", - "static-regular-grammar", - "thiserror 1.0.69", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -2281,6 +2201,19 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" +[[package]] +name = "maitake-sync" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6816ab14147f80234c675b80ed6dc4f440d8a1cefc158e766067aedb84c0bcd5" +dependencies = [ + "cordyceps", + "loom", + "mycelium-bitfield", + "pin-project", + "portable-atomic", +] + [[package]] name = "markup5ever" version = "0.12.1" @@ -2386,9 +2319,9 @@ dependencies = [ ] [[package]] -name = "mini-moka" +name = "mini-moka-wasm" version = "0.10.99" -source = "git+https://tangled.org/nekomimi.pet/jacquard#69a1552424ffa439ea1022aa8e3f311ed77ab4df" +source = "git+https://tangled.org/nonbinary.computer/jacquard#5bcf7f8e87324b8e67fc273c678d0490c9c6d15b" dependencies = [ "crossbeam-channel", "crossbeam-utils", @@ -2399,12 +2332,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -2467,6 +2394,12 @@ dependencies = [ "twoway", ] +[[package]] +name = "mycelium-bitfield" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e0cc5e2c585acbd15c5ce911dff71e1f4d5313f43345873311c4f5efd741cc" + [[package]] name = "n0-future" version = "0.1.3" @@ -2521,16 +2454,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -2705,6 +2628,15 @@ version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" +[[package]] +name = "oxilangtag" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f3f87617a86af77fa3691e6350483e7154c2ead9f1261b75130e21ca0f8acb" +dependencies = [ + "serde", +] + [[package]] name = "p256" version = "0.13.2" @@ -2930,30 +2862,6 @@ dependencies = [ "elliptic-curve", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.103" @@ -3111,12 +3019,6 @@ dependencies = [ "getrandom 0.3.4", ] -[[package]] -name = "range-traits" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20581732dd76fa913c7dff1a2412b714afe3573e94d41c34719de73337cc8ab" - [[package]] name = "redox_syscall" version = "0.5.18" @@ -3137,26 +3039,6 @@ dependencies = [ "thiserror 2.0.17", ] -[[package]] -name = "ref-cast" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.111", -] - [[package]] name = "regex" version = "1.12.2" @@ -3428,30 +3310,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "schemars" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - [[package]] name = "scoped-tls" version = "1.0.1" @@ -3555,14 +3413,13 @@ dependencies = [ [[package]] name = "serde_html_form" -version = "0.2.8" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2f2d7ff8a2140333718bb329f5c40fc5f0865b84c426183ce14c97d2ab8154f" +checksum = "2acf96b1d9364968fce46ebb548f1c0e1d7eceae27bdff73865d42e6c7369d94" dependencies = [ "form_urlencoded", - "indexmap 2.12.1", + "indexmap", "itoa", - "ryu", "serde_core", ] @@ -3634,10 +3491,6 @@ dependencies = [ "base64 0.22.1", "chrono", "hex", - "indexmap 1.9.3", - "indexmap 2.12.1", - "schemars 0.9.0", - "schemars 1.1.0", "serde_core", "serde_json", "serde_with_macros", @@ -3812,26 +3665,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "static-regular-grammar" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4a6c40247579acfbb138c3cd7de3dab113ab4ac6227f1b7de7d626ee667957" -dependencies = [ - "abnf", - "btree-range-map", - "ciborium", - "hex_fmt", - "indoc", - "proc-macro-error", - "proc-macro2", - "quote", - "serde", - "sha2", - "syn 2.0.111", - "thiserror 1.0.69", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -4074,14 +3907,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" dependencies = [ "deranged", - "itoa", "libc", "num-conv", "num_threads", "powerfmt", "serde", "time-core", - "time-macros", ] [[package]] @@ -4090,16 +3921,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" -[[package]] -name = "time-macros" -version = "0.2.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tiny_http" version = "0.12.0" @@ -5184,6 +5005,18 @@ dependencies = [ "tower-http", "url", "walkdir", + "wisp-lexicons", +] + +[[package]] +name = "wisp-lexicons" +version = "0.1.0" +dependencies = [ + "jacquard-common", + "jacquard-derive", + "jacquard-lexicon", + "rustversion", + "serde", ] [[package]] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b8ac8e0..d61fa63 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -8,13 +8,14 @@ default = ["place_wisp"] place_wisp = [] [dependencies] -jacquard = { git = "https://tangled.org/nekomimi.pet/jacquard", features = ["loopback"] } -jacquard-oauth = { git = "https://tangled.org/nekomimi.pet/jacquard" } -jacquard-api = { git = "https://tangled.org/nekomimi.pet/jacquard", features = ["streaming"] } -jacquard-common = { git = "https://tangled.org/nekomimi.pet/jacquard", features = ["websocket"] } -jacquard-identity = { git = "https://tangled.org/nekomimi.pet/jacquard", features = ["dns"] } -jacquard-derive = { git = "https://tangled.org/nekomimi.pet/jacquard" } -jacquard-lexicon = { git = "https://tangled.org/nekomimi.pet/jacquard" } +jacquard = { git = "https://tangled.org/nonbinary.computer/jacquard", features = ["loopback"] } +jacquard-oauth = { git = "https://tangled.org/nonbinary.computer/jacquard" } +jacquard-api = { git = "https://tangled.org/nonbinary.computer/jacquard", features = ["streaming"] } +jacquard-common = { git = "https://tangled.org/nonbinary.computer/jacquard", features = ["websocket"] } +jacquard-identity = { git = "https://tangled.org/nonbinary.computer/jacquard", features = ["dns"] } +jacquard-derive = { git = "https://tangled.org/nonbinary.computer/jacquard" } +jacquard-lexicon = { git = "https://tangled.org/nonbinary.computer/jacquard" } +wisp-lexicons = { path = "crates/lexicons" } #jacquard = { path = "../../jacquard/crates/jacquard", features = ["loopback"] } #jacquard-oauth = { path = "../../jacquard/crates/jacquard-oauth" } #jacquard-api = { path = "../../jacquard/crates/jacquard-api", features = ["streaming"] } diff --git a/cli/crates/lexicons/Cargo.toml b/cli/crates/lexicons/Cargo.toml new file mode 100644 index 0000000..a9bf5b9 --- /dev/null +++ b/cli/crates/lexicons/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "wisp-lexicons" +version = "0.1.0" +edition = "2024" + +[features] +default = ["place_wisp"] +place_wisp = [] + +[dependencies] +jacquard-common = { git = "https://tangled.org/nonbinary.computer/jacquard" } +jacquard-derive = { git = "https://tangled.org/nonbinary.computer/jacquard" } +jacquard-lexicon = { git = "https://tangled.org/nonbinary.computer/jacquard" } +serde = { version = "1.0", features = ["derive"] } +rustversion = "1.0" diff --git a/cli/src/builder_types.rs b/cli/crates/lexicons/src/builder_types.rs similarity index 100% rename from cli/src/builder_types.rs rename to cli/crates/lexicons/src/builder_types.rs diff --git a/cli/src/lib.rs b/cli/crates/lexicons/src/lib.rs similarity index 92% rename from cli/src/lib.rs rename to cli/crates/lexicons/src/lib.rs index 0b686ca..51b1f1e 100644 --- a/cli/src/lib.rs +++ b/cli/crates/lexicons/src/lib.rs @@ -1,3 +1,5 @@ +extern crate alloc; + // @generated by jacquard-lexicon. DO NOT EDIT. // // This file was automatically generated from Lexicon schemas. diff --git a/cli/src/place_wisp.rs b/cli/crates/lexicons/src/place_wisp.rs similarity index 100% rename from cli/src/place_wisp.rs rename to cli/crates/lexicons/src/place_wisp.rs diff --git a/cli/src/place_wisp/fs.rs b/cli/crates/lexicons/src/place_wisp/fs.rs similarity index 99% rename from cli/src/place_wisp/fs.rs rename to cli/crates/lexicons/src/place_wisp/fs.rs index c15e06f..27be1e9 100644 --- a/cli/src/place_wisp/fs.rs +++ b/cli/crates/lexicons/src/place_wisp/fs.rs @@ -554,37 +554,37 @@ pub mod entry_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Name; type Node; + type Name; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Name = Unset; type Node = Unset; - } - ///State transition - sets the `name` field to Set - pub struct SetName(PhantomData S>); - impl sealed::Sealed for SetName {} - impl State for SetName { - type Name = Set; - type Node = S::Node; + type Name = Unset; } ///State transition - sets the `node` field to Set pub struct SetNode(PhantomData S>); impl sealed::Sealed for SetNode {} impl State for SetNode { - type Name = S::Name; type Node = Set; + type Name = S::Name; + } + ///State transition - sets the `name` field to Set + pub struct SetName(PhantomData S>); + impl sealed::Sealed for SetName {} + impl State for SetName { + type Node = S::Node; + type Name = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `name` field - pub struct name(()); ///Marker type for the `node` field pub struct node(()); + ///Marker type for the `name` field + pub struct name(()); } } @@ -657,8 +657,8 @@ where impl<'a, S> EntryBuilder<'a, S> where S: entry_state::State, - S::Name: entry_state::IsSet, S::Node: entry_state::IsSet, + S::Name: entry_state::IsSet, { /// Build the final struct pub fn build(self) -> Entry<'a> { @@ -749,18 +749,18 @@ impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Entry<'a> { pub struct File<'a> { /// True if blob content is base64-encoded (used to bypass PDS content sniffing) #[serde(skip_serializing_if = "std::option::Option::is_none")] - pub base64: Option, + pub base64: std::option::Option, /// Content blob ref #[serde(borrow)] pub blob: jacquard_common::types::blob::BlobRef<'a>, /// Content encoding (e.g., gzip for compressed files) #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] - pub encoding: Option>, + pub encoding: std::option::Option>, /// Original MIME type before compression #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] - pub mime_type: Option>, + pub mime_type: std::option::Option>, #[serde(borrow)] pub r#type: jacquard_common::CowStr<'a>, } @@ -994,7 +994,7 @@ impl<'a> ::jacquard_lexicon::schema::LexiconSchema for File<'a> { pub struct Fs<'a> { pub created_at: jacquard_common::types::string::Datetime, #[serde(skip_serializing_if = "std::option::Option::is_none")] - pub file_count: Option, + pub file_count: std::option::Option, #[serde(borrow)] pub root: crate::place_wisp::fs::Directory<'a>, #[serde(borrow)] @@ -1011,51 +1011,51 @@ pub mod fs_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { + type CreatedAt; type Site; type Root; - type CreatedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { + type CreatedAt = Unset; type Site = Unset; type Root = Unset; - type CreatedAt = Unset; + } + ///State transition - sets the `created_at` field to Set + pub struct SetCreatedAt(PhantomData S>); + impl sealed::Sealed for SetCreatedAt {} + impl State for SetCreatedAt { + type CreatedAt = Set; + type Site = S::Site; + type Root = S::Root; } ///State transition - sets the `site` field to Set pub struct SetSite(PhantomData S>); impl sealed::Sealed for SetSite {} impl State for SetSite { + type CreatedAt = S::CreatedAt; type Site = Set; type Root = S::Root; - type CreatedAt = S::CreatedAt; } ///State transition - sets the `root` field to Set pub struct SetRoot(PhantomData S>); impl sealed::Sealed for SetRoot {} impl State for SetRoot { - type Site = S::Site; - type Root = Set; type CreatedAt = S::CreatedAt; - } - ///State transition - sets the `created_at` field to Set - pub struct SetCreatedAt(PhantomData S>); - impl sealed::Sealed for SetCreatedAt {} - impl State for SetCreatedAt { type Site = S::Site; - type Root = S::Root; - type CreatedAt = Set; + type Root = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { + ///Marker type for the `created_at` field + pub struct created_at(()); ///Marker type for the `site` field pub struct site(()); ///Marker type for the `root` field pub struct root(()); - ///Marker type for the `created_at` field - pub struct created_at(()); } } @@ -1162,9 +1162,9 @@ where impl<'a, S> FsBuilder<'a, S> where S: fs_state::State, + S::CreatedAt: fs_state::IsSet, S::Site: fs_state::IsSet, S::Root: fs_state::IsSet, - S::CreatedAt: fs_state::IsSet, { /// Build the final struct pub fn build(self) -> Fs<'a> { @@ -1306,9 +1306,9 @@ impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Fs<'a> { )] #[serde(rename_all = "camelCase")] pub struct Subfs<'a> { - /// If true, the subfs record's root entries are merged (flattened) into the parent directory, replacing the subfs entry. If false (default), the subfs entries are placed in a subdirectory with the subfs entry's name. Flat merging is useful for splitting large directories across multiple records while maintaining a flat structure. + /// If true (default), the subfs record's root entries are merged (flattened) into the parent directory, replacing the subfs entry. If false, the subfs entries are placed in a subdirectory with the subfs entry's name. Flat merging is useful for splitting large directories across multiple records while maintaining a flat structure. #[serde(skip_serializing_if = "std::option::Option::is_none")] - pub flat: Option, + pub flat: std::option::Option, /// AT-URI pointing to a place.wisp.subfs record containing this subtree. #[serde(borrow)] pub subject: jacquard_common::types::string::AtUri<'a>, diff --git a/cli/src/place_wisp/settings.rs b/cli/crates/lexicons/src/place_wisp/settings.rs similarity index 100% rename from cli/src/place_wisp/settings.rs rename to cli/crates/lexicons/src/place_wisp/settings.rs diff --git a/cli/src/place_wisp/subfs.rs b/cli/crates/lexicons/src/place_wisp/subfs.rs similarity index 99% rename from cli/src/place_wisp/subfs.rs rename to cli/crates/lexicons/src/place_wisp/subfs.rs index b2c10aa..a6a0e51 100644 --- a/cli/src/place_wisp/subfs.rs +++ b/cli/crates/lexicons/src/place_wisp/subfs.rs @@ -725,18 +725,18 @@ impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Entry<'a> { pub struct File<'a> { /// True if blob content is base64-encoded (used to bypass PDS content sniffing) #[serde(skip_serializing_if = "std::option::Option::is_none")] - pub base64: Option, + pub base64: std::option::Option, /// Content blob ref #[serde(borrow)] pub blob: jacquard_common::types::blob::BlobRef<'a>, /// Content encoding (e.g., gzip for compressed files) #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] - pub encoding: Option>, + pub encoding: std::option::Option>, /// Original MIME type before compression #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] - pub mime_type: Option>, + pub mime_type: std::option::Option>, #[serde(borrow)] pub r#type: jacquard_common::CowStr<'a>, } @@ -751,37 +751,37 @@ pub mod file_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Type; type Blob; + type Type; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Type = Unset; type Blob = Unset; - } - ///State transition - sets the `type` field to Set - pub struct SetType(PhantomData S>); - impl sealed::Sealed for SetType {} - impl State for SetType { - type Type = Set; - type Blob = S::Blob; + type Type = Unset; } ///State transition - sets the `blob` field to Set pub struct SetBlob(PhantomData S>); impl sealed::Sealed for SetBlob {} impl State for SetBlob { - type Type = S::Type; type Blob = Set; + type Type = S::Type; + } + ///State transition - sets the `type` field to Set + pub struct SetType(PhantomData S>); + impl sealed::Sealed for SetType {} + impl State for SetType { + type Blob = S::Blob; + type Type = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `type` field - pub struct r#type(()); ///Marker type for the `blob` field pub struct blob(()); + ///Marker type for the `type` field + pub struct r#type(()); } } @@ -905,8 +905,8 @@ where impl<'a, S> FileBuilder<'a, S> where S: file_state::State, - S::Type: file_state::IsSet, S::Blob: file_state::IsSet, + S::Type: file_state::IsSet, { /// Build the final struct pub fn build(self) -> File<'a> { @@ -970,7 +970,7 @@ impl<'a> ::jacquard_lexicon::schema::LexiconSchema for File<'a> { pub struct SubfsRecord<'a> { pub created_at: jacquard_common::types::string::Datetime, #[serde(skip_serializing_if = "std::option::Option::is_none")] - pub file_count: Option, + pub file_count: std::option::Option, #[serde(borrow)] pub root: crate::place_wisp::subfs::Directory<'a>, } @@ -1260,37 +1260,37 @@ pub mod subfs_state { } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { - type Type; type Subject; + type Type; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { - type Type = Unset; type Subject = Unset; - } - ///State transition - sets the `type` field to Set - pub struct SetType(PhantomData S>); - impl sealed::Sealed for SetType {} - impl State for SetType { - type Type = Set; - type Subject = S::Subject; + type Type = Unset; } ///State transition - sets the `subject` field to Set pub struct SetSubject(PhantomData S>); impl sealed::Sealed for SetSubject {} impl State for SetSubject { - type Type = S::Type; type Subject = Set; + type Type = S::Type; + } + ///State transition - sets the `type` field to Set + pub struct SetType(PhantomData S>); + impl sealed::Sealed for SetType {} + impl State for SetType { + type Subject = S::Subject; + type Type = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { - ///Marker type for the `type` field - pub struct r#type(()); ///Marker type for the `subject` field pub struct subject(()); + ///Marker type for the `type` field + pub struct r#type(()); } } @@ -1363,8 +1363,8 @@ where impl<'a, S> SubfsBuilder<'a, S> where S: subfs_state::State, - S::Type: subfs_state::IsSet, S::Subject: subfs_state::IsSet, + S::Type: subfs_state::IsSet, { /// Build the final struct pub fn build(self) -> Subfs<'a> { diff --git a/cli/src/blob_map.rs b/cli/src/blob_map.rs index 86b04d1..8b73996 100644 --- a/cli/src/blob_map.rs +++ b/cli/src/blob_map.rs @@ -2,7 +2,7 @@ use jacquard_common::types::blob::BlobRef; use jacquard_common::IntoStatic; use std::collections::HashMap; -use crate::place_wisp::fs::{Directory, EntryNode}; +use wisp_lexicons::place_wisp::fs::{Directory, EntryNode}; /// Extract blob information from a directory tree /// Returns a map of file paths to their blob refs and CIDs diff --git a/cli/src/main.rs b/cli/src/main.rs index f858ef3..6357c8e 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,5 +1,3 @@ -mod builder_types; -mod place_wisp; mod cid; mod blob_map; mod metadata; @@ -28,8 +26,8 @@ use base64::Engine; use futures::stream::{self, StreamExt}; use indicatif::{ProgressBar, ProgressStyle, MultiProgress}; -use place_wisp::fs::*; -use place_wisp::settings::*; +use wisp_lexicons::place_wisp::fs::*; +use wisp_lexicons::place_wisp::settings::*; /// Maximum number of concurrent file uploads to the PDS const MAX_CONCURRENT_UPLOADS: usize = 2; @@ -512,7 +510,7 @@ async fn deploy_site( let chunk_file_count = subfs_utils::count_files_in_directory(chunk); let chunk_size = subfs_utils::estimate_directory_size(chunk); - let chunk_manifest = crate::place_wisp::subfs::SubfsRecord::new() + let chunk_manifest = wisp_lexicons::place_wisp::subfs::SubfsRecord::new() .root(convert_fs_dir_to_subfs_dir(chunk.clone())) .file_count(Some(chunk_file_count as i64)) .created_at(Datetime::now()) @@ -535,7 +533,7 @@ async fn deploy_site( // Each chunk reference MUST have flat: true to merge chunk contents println!(" → Creating parent subfs with {} chunk references...", chunk_uris.len()); use jacquard_common::CowStr; - use crate::place_wisp::fs::{Subfs}; + use wisp_lexicons::place_wisp::fs::{Subfs}; // Convert to fs::Subfs (which has the 'flat' field) instead of subfs::Subfs let parent_entries_fs: Vec = chunk_uris.iter().enumerate().map(|(i, (uri, _))| { @@ -565,7 +563,7 @@ async fn deploy_site( let parent_tid = Tid::now_0(); let parent_rkey = parent_tid.to_string(); - let parent_manifest = crate::place_wisp::subfs::SubfsRecord::new() + let parent_manifest = wisp_lexicons::place_wisp::subfs::SubfsRecord::new() .root(parent_root_subfs) .file_count(Some(largest_dir.file_count as i64)) .created_at(Datetime::now()) @@ -584,7 +582,7 @@ async fn deploy_site( let subfs_tid = Tid::now_0(); let subfs_rkey = subfs_tid.to_string(); - let subfs_manifest = crate::place_wisp::subfs::SubfsRecord::new() + let subfs_manifest = wisp_lexicons::place_wisp::subfs::SubfsRecord::new() .root(convert_fs_dir_to_subfs_dir(largest_dir.directory.clone())) .file_count(Some(largest_dir.file_count as i64)) .created_at(Datetime::now()) @@ -952,12 +950,12 @@ async fn process_file( /// Convert fs::Directory to subfs::Directory /// They have the same structure, but different types -fn convert_fs_dir_to_subfs_dir(fs_dir: place_wisp::fs::Directory<'static>) -> place_wisp::subfs::Directory<'static> { - use place_wisp::subfs::{Directory as SubfsDirectory, Entry as SubfsEntry, EntryNode as SubfsEntryNode, File as SubfsFile}; +fn convert_fs_dir_to_subfs_dir(fs_dir: wisp_lexicons::place_wisp::fs::Directory<'static>) -> wisp_lexicons::place_wisp::subfs::Directory<'static> { + use wisp_lexicons::place_wisp::subfs::{Directory as SubfsDirectory, Entry as SubfsEntry, EntryNode as SubfsEntryNode, File as SubfsFile}; let subfs_entries: Vec = fs_dir.entries.into_iter().map(|entry| { let node = match entry.node { - place_wisp::fs::EntryNode::File(file) => { + wisp_lexicons::place_wisp::fs::EntryNode::File(file) => { SubfsEntryNode::File(Box::new(SubfsFile::new() .r#type(file.r#type) .blob(file.blob) @@ -966,18 +964,18 @@ fn convert_fs_dir_to_subfs_dir(fs_dir: place_wisp::fs::Directory<'static>) -> pl .base64(file.base64) .build())) } - place_wisp::fs::EntryNode::Directory(dir) => { + wisp_lexicons::place_wisp::fs::EntryNode::Directory(dir) => { SubfsEntryNode::Directory(Box::new(convert_fs_dir_to_subfs_dir(*dir))) } - place_wisp::fs::EntryNode::Subfs(subfs) => { + wisp_lexicons::place_wisp::fs::EntryNode::Subfs(subfs) => { // Nested subfs in the directory we're converting // Note: subfs::Subfs doesn't have the 'flat' field - that's only in fs::Subfs - SubfsEntryNode::Subfs(Box::new(place_wisp::subfs::Subfs::new() + SubfsEntryNode::Subfs(Box::new(wisp_lexicons::place_wisp::subfs::Subfs::new() .r#type(subfs.r#type) .subject(subfs.subject) .build())) } - place_wisp::fs::EntryNode::Unknown(unknown) => { + wisp_lexicons::place_wisp::fs::EntryNode::Unknown(unknown) => { SubfsEntryNode::Unknown(unknown) } }; diff --git a/cli/src/mod.rs b/cli/src/mod.rs deleted file mode 100644 index 0b686ca..0000000 --- a/cli/src/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -// @generated by jacquard-lexicon. DO NOT EDIT. -// -// This file was automatically generated from Lexicon schemas. -// Any manual changes will be overwritten on the next regeneration. - -pub mod builder_types; - -#[cfg(feature = "place_wisp")] -pub mod place_wisp; \ No newline at end of file diff --git a/cli/src/pull.rs b/cli/src/pull.rs index bf9407a..2100838 100644 --- a/cli/src/pull.rs +++ b/cli/src/pull.rs @@ -1,7 +1,7 @@ use crate::blob_map; use crate::download; use crate::metadata::SiteMetadata; -use crate::place_wisp::fs::*; +use wisp_lexicons::place_wisp::fs::*; use crate::subfs_utils; use jacquard::CowStr; use jacquard::prelude::IdentityResolver; @@ -410,9 +410,9 @@ async fn expand_subfs_in_pull_with_client<'a>( ) -> miette::Result> { use jacquard_common::IntoStatic; use jacquard_common::types::value::from_data; - use crate::place_wisp::subfs::SubfsRecord; + use wisp_lexicons::place_wisp::subfs::SubfsRecord; - let mut all_subfs_map: HashMap = HashMap::new(); + let mut all_subfs_map: HashMap = HashMap::new(); let mut to_fetch = subfs_utils::extract_subfs_uris(directory, String::new()); if to_fetch.is_empty() { @@ -516,7 +516,7 @@ async fn expand_subfs_in_pull_with_client<'a>( /// Extract subfs URIs from a subfs::Directory (helper for pull) fn extract_subfs_uris_from_subfs_dir( - directory: &crate::place_wisp::subfs::Directory, + directory: &wisp_lexicons::place_wisp::subfs::Directory, current_path: String, ) -> Vec<(String, String)> { let mut uris = Vec::new(); @@ -529,10 +529,10 @@ fn extract_subfs_uris_from_subfs_dir( }; match &entry.node { - crate::place_wisp::subfs::EntryNode::Subfs(subfs_node) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Subfs(subfs_node) => { uris.push((subfs_node.subject.to_string(), full_path.clone())); } - crate::place_wisp::subfs::EntryNode::Directory(subdir) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Directory(subdir) => { let nested = extract_subfs_uris_from_subfs_dir(subdir, full_path); uris.extend(nested); } @@ -546,7 +546,7 @@ fn extract_subfs_uris_from_subfs_dir( /// Recursively replace subfs nodes with their actual content fn replace_subfs_with_content( directory: Directory, - subfs_map: &HashMap, + subfs_map: &HashMap, current_path: String, ) -> Directory<'static> { use jacquard_common::IntoStatic; @@ -628,11 +628,11 @@ fn replace_subfs_with_content( } /// Convert a subfs entry to a fs entry (they have the same structure but different types) -fn convert_subfs_entry_to_fs(subfs_entry: crate::place_wisp::subfs::Entry<'static>) -> Entry<'static> { +fn convert_subfs_entry_to_fs(subfs_entry: wisp_lexicons::place_wisp::subfs::Entry<'static>) -> Entry<'static> { use jacquard_common::IntoStatic; let node = match subfs_entry.node { - crate::place_wisp::subfs::EntryNode::File(file) => { + wisp_lexicons::place_wisp::subfs::EntryNode::File(file) => { EntryNode::File(Box::new( File::new() .r#type(file.r#type.into_static()) @@ -643,7 +643,7 @@ fn convert_subfs_entry_to_fs(subfs_entry: crate::place_wisp::subfs::Entry<'stati .build() )) } - crate::place_wisp::subfs::EntryNode::Directory(dir) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Directory(dir) => { let converted_entries: Vec> = dir .entries .into_iter() @@ -657,7 +657,7 @@ fn convert_subfs_entry_to_fs(subfs_entry: crate::place_wisp::subfs::Entry<'stati .build() )) } - crate::place_wisp::subfs::EntryNode::Subfs(_nested_subfs) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Subfs(_nested_subfs) => { // Nested subfs should have been expanded already - if we get here, it means expansion failed // Treat it like a directory reference that should have been expanded eprintln!(" ⚠️ Warning: unexpanded nested subfs at path, treating as empty directory"); @@ -668,7 +668,7 @@ fn convert_subfs_entry_to_fs(subfs_entry: crate::place_wisp::subfs::Entry<'stati .build() )) } - crate::place_wisp::subfs::EntryNode::Unknown(unknown) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Unknown(unknown) => { EntryNode::Unknown(unknown) } }; diff --git a/cli/src/serve.rs b/cli/src/serve.rs index 3d4ea22..dd6c23a 100644 --- a/cli/src/serve.rs +++ b/cli/src/serve.rs @@ -1,6 +1,6 @@ use crate::pull::pull_site; use crate::redirects::{load_redirect_rules, match_redirect_rule, RedirectRule}; -use crate::place_wisp::settings::Settings; +use wisp_lexicons::place_wisp::settings::Settings; use axum::{ Router, extract::Request, diff --git a/cli/src/subfs_utils.rs b/cli/src/subfs_utils.rs index a2a2178..6f0ff0f 100644 --- a/cli/src/subfs_utils.rs +++ b/cli/src/subfs_utils.rs @@ -6,8 +6,8 @@ use jacquard::prelude::IdentityResolver; use miette::IntoDiagnostic; use std::collections::HashMap; -use crate::place_wisp::fs::{Directory as FsDirectory, EntryNode as FsEntryNode}; -use crate::place_wisp::subfs::SubfsRecord; +use wisp_lexicons::place_wisp::fs::{Directory as FsDirectory, EntryNode as FsEntryNode}; +use wisp_lexicons::place_wisp::subfs::SubfsRecord; /// Extract all subfs URIs from a directory tree with their mount paths pub fn extract_subfs_uris(directory: &FsDirectory, current_path: String) -> Vec<(String, String)> { @@ -145,14 +145,14 @@ pub async fn fetch_all_subfs_records_recursive( /// Extract subfs URIs from a subfs::Directory fn extract_subfs_uris_from_subfs_dir( - directory: &crate::place_wisp::subfs::Directory, + directory: &wisp_lexicons::place_wisp::subfs::Directory, current_path: String, ) -> Vec<(String, String)> { let mut uris = Vec::new(); for entry in &directory.entries { match &entry.node { - crate::place_wisp::subfs::EntryNode::Subfs(subfs_node) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Subfs(subfs_node) => { // Check if this is a chunk entry (chunk0, chunk1, etc.) // Chunks should be flat-merged, so use the parent's path let mount_path = if entry.name.starts_with("chunk") && @@ -171,7 +171,7 @@ fn extract_subfs_uris_from_subfs_dir( uris.push((subfs_node.subject.to_string(), mount_path)); } - crate::place_wisp::subfs::EntryNode::Directory(subdir) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Directory(subdir) => { let full_path = if current_path.is_empty() { entry.name.to_string() } else { @@ -204,7 +204,7 @@ pub async fn merge_subfs_blob_maps( for (mount_path, subfs_record) in all_subfs { // Check if this record only contains chunk subfs references (no files) let only_has_chunks = subfs_record.root.entries.iter().all(|e| { - matches!(&e.node, crate::place_wisp::subfs::EntryNode::Subfs(_)) && + matches!(&e.node, wisp_lexicons::place_wisp::subfs::EntryNode::Subfs(_)) && e.name.starts_with("chunk") && e.name.chars().skip(5).all(|c| c.is_ascii_digit()) }); @@ -232,7 +232,7 @@ pub async fn merge_subfs_blob_maps( /// Extract blobs from a subfs directory (works with subfs::Directory) /// Returns a map of file paths to their blob refs and CIDs fn extract_subfs_blobs( - directory: &crate::place_wisp::subfs::Directory, + directory: &wisp_lexicons::place_wisp::subfs::Directory, current_path: String, ) -> HashMap, String)> { let mut blob_map = HashMap::new(); @@ -245,7 +245,7 @@ fn extract_subfs_blobs( }; match &entry.node { - crate::place_wisp::subfs::EntryNode::File(file_node) => { + wisp_lexicons::place_wisp::subfs::EntryNode::File(file_node) => { let blob_ref = &file_node.blob; let cid_string = blob_ref.blob().r#ref.to_string(); blob_map.insert( @@ -253,16 +253,16 @@ fn extract_subfs_blobs( (blob_ref.clone().into_static(), cid_string) ); } - crate::place_wisp::subfs::EntryNode::Directory(subdir) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Directory(subdir) => { let sub_map = extract_subfs_blobs(subdir, full_path); blob_map.extend(sub_map); } - crate::place_wisp::subfs::EntryNode::Subfs(_nested_subfs) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Subfs(_nested_subfs) => { // Nested subfs - these should be resolved recursively in the main flow // For now, we skip them (they'll be fetched separately) eprintln!(" ⚠️ Found nested subfs at {}, skipping (should be fetched separately)", full_path); } - crate::place_wisp::subfs::EntryNode::Unknown(_) => { + wisp_lexicons::place_wisp::subfs::EntryNode::Unknown(_) => { // Skip unknown nodes } } @@ -352,7 +352,7 @@ pub fn replace_directory_with_subfs( flat: bool, ) -> miette::Result> { use jacquard_common::CowStr; - use crate::place_wisp::fs::{Entry, Subfs}; + use wisp_lexicons::place_wisp::fs::{Entry, Subfs}; let path_parts: Vec<&str> = target_path.split('/').collect(); @@ -430,7 +430,7 @@ pub async fn delete_subfs_record( // Construct AT-URI and convert to RecordUri let at_uri = AtUri::new(uri).into_diagnostic()?; - let record_uri: RecordUri<'_, crate::place_wisp::subfs::SubfsRecordRecord> = RecordUri::try_from_uri(at_uri).into_diagnostic()?; + let record_uri: RecordUri<'_, wisp_lexicons::place_wisp::subfs::SubfsRecordRecord> = RecordUri::try_from_uri(at_uri).into_diagnostic()?; let rkey = record_uri.rkey() .ok_or_else(|| miette::miette!("Invalid subfs URI: missing rkey"))? @@ -489,7 +489,7 @@ pub fn split_directory_into_chunks( } /// Estimate the JSON size of a single entry -fn estimate_entry_size(entry: &crate::place_wisp::fs::Entry) -> usize { +fn estimate_entry_size(entry: &wisp_lexicons::place_wisp::fs::Entry) -> usize { match serde_json::to_string(entry) { Ok(json) => json.len(), Err(_) => 500, // Conservative estimate if serialization fails diff --git a/packages/@wisp/lexicons/lexicons/fs.json b/lexicons/fs.json similarity index 100% rename from packages/@wisp/lexicons/lexicons/fs.json rename to lexicons/fs.json diff --git a/packages/@wisp/lexicons/lexicons/settings.json b/lexicons/settings.json similarity index 100% rename from packages/@wisp/lexicons/lexicons/settings.json rename to lexicons/settings.json diff --git a/packages/@wisp/lexicons/lexicons/subfs.json b/lexicons/subfs.json similarity index 100% rename from packages/@wisp/lexicons/lexicons/subfs.json rename to lexicons/subfs.json diff --git a/package.json b/package.json index bbde9b2..e12201b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "check": "cd apps/main-app && npm run check && cd ../hosting-service && npm run check", "screenshot": "bun run apps/main-app/scripts/screenshot-sites.ts", "hosting:dev": "cd apps/hosting-service && npm run dev", - "hosting:start": "cd apps/hosting-service && npm run start" + "hosting:start": "cd apps/hosting-service && npm run start", + "codegen": "./scripts/codegen.sh" }, "trustedDependencies": [ "@parcel/watcher", diff --git a/packages/@wisp/lexicons/package.json b/packages/@wisp/lexicons/package.json index 53b1a1c..2355131 100644 --- a/packages/@wisp/lexicons/package.json +++ b/packages/@wisp/lexicons/package.json @@ -32,7 +32,7 @@ } }, "scripts": { - "codegen": "lex gen-server ./src ./lexicons" + "codegen": "lex gen-server ./src ../../../lexicons/*.json" }, "dependencies": { "@atproto/lexicon": "^0.5.1", diff --git a/packages/@wisp/lexicons/src/index.ts b/packages/@wisp/lexicons/src/index.ts index a3fcf7b..19fe80a 100644 --- a/packages/@wisp/lexicons/src/index.ts +++ b/packages/@wisp/lexicons/src/index.ts @@ -9,7 +9,7 @@ import { type MethodConfigOrHandler, createServer as createXrpcServer, } from '@atproto/xrpc-server' -import { schemas } from './lexicons' +import { schemas } from './lexicons.js' export function createServer(options?: XrpcOptions): Server { return new Server(options) diff --git a/packages/@wisp/lexicons/src/lexicons.ts b/packages/@wisp/lexicons/src/lexicons.ts index 49e6b59..7eca070 100644 --- a/packages/@wisp/lexicons/src/lexicons.ts +++ b/packages/@wisp/lexicons/src/lexicons.ts @@ -7,7 +7,7 @@ import { ValidationError, type ValidationResult, } from '@atproto/lexicon' -import { type $Typed, is$typed, maybe$typed } from './util' +import { type $Typed, is$typed, maybe$typed } from './util.js' export const schemaDict = { PlaceWispFs: { diff --git a/scripts/codegen.sh b/scripts/codegen.sh new file mode 100755 index 0000000..6aaab3b --- /dev/null +++ b/scripts/codegen.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(dirname "$SCRIPT_DIR")" + +# Parse arguments +AUTO_ACCEPT="" +if [[ "$1" == "-y" || "$1" == "--yes" ]]; then + AUTO_ACCEPT="yes |" +fi + +echo "=== Generating TypeScript lexicons ===" +cd "$ROOT_DIR/packages/@wisp/lexicons" +eval "$AUTO_ACCEPT npm run codegen" + +echo "=== Generating Rust lexicons ===" +echo "Installing jacquard-lexgen..." +cargo install jacquard-lexgen --version 0.9.5 2>/dev/null || true +echo "Running jacquard-codegen..." +echo " Input: $ROOT_DIR/lexicons" +echo " Output: $ROOT_DIR/cli/crates/lexicons/src" +jacquard-codegen -i "$ROOT_DIR/lexicons" -o "$ROOT_DIR/cli/crates/lexicons/src" + +# Add extern crate alloc for the macro to work +sed -i '' '1s/^/extern crate alloc;\n\n/' "$ROOT_DIR/cli/crates/lexicons/src/lib.rs" + +echo "=== Done ===" -- 2.54.0