// examples/40_sdk_https_registry_and_wayland.vk // Demonstrates Veko's single-binary portable SDK & `veko-lang.org` / decentralized HTTPS `.vkp` // registry conventions (`pkg/lock`), `VEKO_LIB` shared-library resolution (`ffi`), and pure-Veko // Linux Wayland (`wl_shm` + `xdg_wm_base`) wire-protocol framing (`ui/wayland`). use [ ffi hex = codec/hex lk = pkg/lock vkp = pkg/vkp wl = ui/wayland ] main = fn [] any [ // 1. Official veko-lang.org registry expansion + decentralized HTTPS spec preservation official_url = lk/expand-spec-with-registry 'http_router@1.2.0' 'https://veko-lang.org/pkg' custom_url = lk/expand-spec-with-registry 'https://pkg.example.org/veko/kv_extra-0.4.0.vkp' 'https://veko-lang.org/pkg' if official_url != 'https://veko-lang.org/pkg/http_router/1.2.0.vkp' [ return (err `unexpected official registry URL: {official_url}`) ] if custom_url != 'https://pkg.example.org/veko/kv_extra-0.4.0.vkp' [ return (err `unexpected custom HTTPS URL: {custom_url}`) ] // 2. Signed .vkp bundle + ~/.veko_modules content-addressed cache layout seed = hex/decode '1112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f30' if err? seed [ return seed ] pkg_bytes = vkp/pack-ed25519 { name = 'http_router', version = '1.2.0' } { 'mod.vk' = (bytes/from-str 'pub version = fn [] str [ \'1.2.0\' ]\n') } seed if err? pkg_bytes [ return pkg_bytes ] locked = lk/lock-vkp-bytes 'http_router' official_url pkg_bytes [] if err? locked [ return locked ] // 3. VEKO_LIB shared-library candidate expansion lib_cands = ffi/candidate-paths 'zstd' '/opt/veko/lib:/usr/local/lib' false if (len lib_cands) < 3 [ return (err 'expected VEKO_LIB candidate search paths') ] // 4. Zero-libc Linux Wayland wire-protocol framing (wl_registry.bind, wl_shm, present) wl_sock = wl/socket-path '/run/user/1000' 'wayland-0' bind_pkt = wl/encode-registry-bind 2 4 'wl_shm' 1 5 pool_pkt = wl/encode-shm-create-pool 5 7 (800 * 600 * 4) frame_pkt = wl/encode-surface-present 9 8 800 600 hdr = wl/decode-hdr bind_pkt 0 if err? hdr [ return hdr ] if wl_sock != '/run/user/1000/wayland-0' or hdr.object_id != 2 or (len pool_pkt) != 16 or (len frame_pkt) != 52 [ return (err 'wayland wire framing mismatch') ] println `[Example 40 OK] reg={official_url} | sha256={locked.sha256[0..12]}... | wl_sock={wl_sock} | present={len frame_pkt}B` 0 ] main