BinaryRPC – Lightweight WebSocket-based RPC framework in modern C++
https://github.com/efecan0/binaryrpc-framework
#HackerNews #BinaryRPC #WebSocket #C++ #Framework #LightweightRPC #ModernC++
BinaryRPC – Lightweight WebSocket-based RPC framework in modern C++
https://github.com/efecan0/binaryrpc-framework
#HackerNews #BinaryRPC #WebSocket #C++ #Framework #LightweightRPC #ModernC++
New Kitten release
• New: Lovely new icons¹ and new callouts in Kitten Settings²
• New: Markdown now supports attributes and bracketed spans³
• New: client-side `kitten` global with `trigger` function for triggering events on the server from the client. (Useful when streaming client-side JavaScript when using Kitten’s Streaming HTML⁴ workflow. e.g., when you have to use a client-only web API like the Clipboard API but you want to keep all your logic on your server-side page.⁵)
• Fixed: The bound render function returned by `KittenComponent` class’s `component` getter now correctly awaits asynchronous templates. (In Kitten, you don’t have to care whether your templates contain promises. Kitten handles all that for you.)
Enjoy!
¹ https://kitten.small-web.org/reference/#icons
² https://mastodon.ar.al/@aral/114381983893061099
³ https://kitten.small-web.org/reference/#markdown-support (also see https://mastodon.ar.al/@aral/114381462302862256)
⁴ https://kitten.small-web.org/tutorials/streaming-html/
⁵ e.g., See how I use this to implement a copy to clipboard button in the database page of Kitten’s Settings: https://codeberg.org/kitten/app/src/branch/main/web/%F0%9F%90%B1/settings%F0%9F%94%92/db/index.page.js#L33 Of course, you don’t have to use this and you can just write client-side JavaScript or use the built-in Alpine.js integration. e.g., how I do it on the (older) settings/identity page: https://codeberg.org/kitten/app/src/branch/main/web/%F0%9F%90%B1/settings%F0%9F%94%92/identity/index.page.js#L7
New Kitten Release
• Automatic message routing: if the element that triggers an event on the client does not have a `name` attribute, Kitten now falls back to using its `id` instead to route the event to the correct server-side event handler on your live Kitten pages.
If neither attribute exists, Kitten will fail to route the message but no longer crash as it was due to a regression introduced when I implemented support for colons in element names.¹
For more details on Kitten’s live pages and automatic message routing, please see the Streaming HTML tutorial:
https://kitten.small-web.org/tutorials/streaming-html/
Enjoy!
¹ A colon in an element name is ignored for message routing purposes, letting you, for example, give unique names to <details> elements, allowing more than one to be open at a time, while having their events be handled by the same handler.
New Kitten release
• Fixes issue with routes where dynamic routes with file names that had more than two extensions were not recognised as the correct type of route. e.g., A route called index.xml.get.js would previously have been treated as a static route instead of a dynamic GET route.
For more details, see the Valid File Types section of the Kitten reference¹ and the Dynamic Pages tutorial².
Enjoy!
¹ https://kitten.small-web.org/reference/#valid-file-types
² https://kitten.small-web.org/tutorials/dynamic-pages/
New Kitten release
• You can now use key paths in the names of your client-side live components and these will automatically be transformed into object hierarchies on the server for you.¹
• Self heals zombie live pages (see Streaming HTML workflow²) if they return to life due to client-side browser cache.³
• Removes htmx⁴ headers from `data` property into separate `header` property in Kitten Page events and the data your Kitten Page message handlers receive.
• Automatically passes references to the live page object (if any) and the request and response objects to the layout templates of Markdown pages⁵ (so you can, for example, check if `request.session.authenticated`⁶ is true from the your layout template and customise the layout accordingly).
Enjoy!
¹ e.g., See https://codeberg.org/small-tech/site/src/branch/kitten/admin%F0%9F%94%92/news/index_%5Boptional-postId%5D.page.js#L356 (markup) and https://codeberg.org/small-tech/site/src/branch/kitten/admin%F0%9F%94%92/news/index_%5Boptional-postId%5D.page.js#L173 (handler) and https://codeberg.org/small-tech/site/src/branch/kitten/app_modules/database/database.js#L95 (model class method).
² See Streaming HTML tutorial: https://kitten.small-web.org/tutorials/streaming-html/ (There’s actually more to it now but I haven’t had a chance to document the new class-based and event-driven live page workflow yet. It’s experimental but working very well for me so far so I will do so shortly.)
³ When a person leaves a live/connected page (a page connected to its default web socket), we clean up and remove that live page from memory. However, browsers being what they are, cache the page on the client. If a person uses the back/forward buttons to return to the page, the browser will serve the cached source from memory, which has the old page ID, for the page that no longer exists in Kitten’s memory. So now we have a problem. The only way to recover from this is to tell the page to reload itself. So we accept the WebSocket connection, send a command to the page for it to reload itself, and then close the socket. That makes the stale page self heal by replacing itself with a fresh one. Yay, go us!
⁴ HTMX: https://htmx.org
⁵ Kitten Markdown pages reference: https://kitten.small-web.org/reference/#markdown-pages-page-md-files
⁶ See Session tutorial: https://kitten.small-web.org/tutorials/sessions/
Does anyone here have experience with the #azure cognitive services #api in the browser client? I'm getting an unexplainable #websocket error 1006 that's only happening to my user in certain circumstances, and the reason is `undefined`
I'm confident it's not a bad key, because the same code and deployment works for another user.
#boosts welcome, #help please! This is for a #FOSS accessibility project.
May I just say so myself that I‘m loving playing with Kitten¹ to build Domain² (shown below) and Place³.
¹ https://kitten.small-web.org
² https://codeberg.org/domain/app
³ https://codeberg.org/place/app
New Kitten¹ update
Experimental:
• Adds `data` property to Kitten components
• Adds swap target to `page.send` so you can have an element added before, after, as first child of, or as last child of another (this is syntactic sugar over htmx and works around some of the complexities with out-of-band swaps in htmx, especially when streaming table rows to tables).
Also, check out the latest live page and page events state view in Kitten’s Settings (every Kitten app has this settings view).
So last night, while recording the preview of Kitten’s¹ improved component model², I made a silly mistake (copying raw HTML into a JavaScript function instead of wrapping it in a kitten.html`` tagged template, easy to do when you’re refactoring to pull out components from pages).
Then, once I figured out what I’d done, I made another one by forgetting to return the value from the function (easy to do when you’re used to using one-line closures as render functions).
I would have caught both of those so much faster if Kitten had helpful error messages for those two pitfalls. And guess what, this morning, it does :)
Attached are screenshot showing the before and after error messages.
Enjoy!
¹ https://kitten.small-web.org
² Scroll up the thread to watch the video.
Little preview video: Kitten’s improved component model
• Class-based page routes and components
• Object-oriented
• Event-based
• Seamless hypermedia-driven WebSocket-based event mapping and interface updates (Streaming HTML)
• A light server-side live component hierarchy with event bubbling
• Almost as if you’re building a desktop or mobile app instead of a web app…
… another authoring simplification made possible because on the Small Web – which is a peer-to-peer web – you build a web app/site as a tool for one person (the owner of the site/app) instead of as a tool for you to farm millions of people.
… still experimental ;)
Learn more about Kitten:
If you like what you see and want us to keep existing, we could definitely use your support:
https://small-tech.org/fund-us/
@lumen Hey, thanks so much :)
The main two apps that will initially be using it are Place (https://codeberg.org/place/app) and Domain (https://codeberg.org/domain/app) — both under heavy development at the moment.
There are some mini apps I made that you can play, each with their own tutorial.
• Draw Together (https://draw-together.small-web.org; tutorial: https://kitten.small-web.org/tutorials/streaming-html/)
• Kitten Kawaii (https://kitten-kawaii.small-web.org/character/blissful/granny-smith-apple/cat/, write up: https://ar.al/2024/08/19/kitten-kawaii-porting-a-react-library-and-next-js-web-site-to-kitten/)
• Streamiverse¹ (https://streamiverse.small-web.org, tutorial: https://kitten.small-web.org/tutorials/htmx-the-htmx-web-socket-extension-and-socket-routes/)
And you can find a host of little examples in the codebase:
https://codeberg.org/kitten/app/src/branch/main/examples
Hope that helps. Until the Small Web stuff is publicly released I don’t really foresee a lot of folks using it. Although I know a few people are playing with it.
¹ Just noticed I need to improve it so it recaches profile images if they’ve changed. Noticed a couple of broken ones.
New Kitten release
• Live events view in //settings/state/pages
• Fix automatic event handler binding
I’ve also updated the Kitten Count example in the Streaming HTML tutorial to use the new, simpler, event handler syntax in the improved (and experimental) Kitten component model. There’s more to the latter (e.g., class-based routes) that’s not documented yet but will be soon.
https://kitten.small-web.org/tutorials/streaming-html/#o-counter-my-counter
Enjoy!
TIL Network protocols Sans I/O
“… network protocol implementations written in Python that perform no I/O (this means libraries that operate directly on text or bytes; this excludes libraries that just abstract out I/O).”
Read the reference page
https://sans-io.readthedocs.io/
Streamiverse is written in Kitten and you can follow the “htmx, the htmx WebSocket extension, and socket routes” tutorial to create a Kitten app that consumes the API:
https://kitten.small-web.org/tutorials/htmx-the-htmx-web-socket-extension-and-socket-routes/
To get started with Kitten, see:
(Could be a fun little thing to play with this weekend.)
Starlette 0.41.0 released!
Allow to raise HTTPException before websocket.accept()
Kitten¹ update
I just added a new htmx header to #WebSocket messages in Kitten that contains the actual event type (name) that triggered the message.
This is useful, for example, if your trigger is a horizontal swipe and you need to differentiate between whether it was a swipe left or a swipe right that caused it.
Upstream issue: https://github.com/bigskysoftware/htmx-extensions/issues/74
Upstream merge request: https://github.com/aral/htmx-extensions/commit/359da12563fd0ef6709d801972f98ba1ab61c302
Enjoy!
Also, not immediately relevant to your current issue but something that might be worth considering for the future: using the htmx websocket extension, you can basically implement a streaming HTML approach (example using Kitten: https://ar.al/2024/03/08/streaming-html/) where you can just stream errors to the page as they happen.
#htmx #webSocket #Kitten #SmallWeb #StreamingHTML #errorHandling (2/2)
Let’s build Draw Together… umm, together.
Video: https://vimeo.com/927628184
Blog post: https://ar.al/2024/03/26/draw-together/
Play with it: https://draw-together.small-web.org
I’ve also updated the readme with instructions on how to run Draw Together yourself (you could have it up and running locally in under a minute by installing Kitten, cloning the repository, and running the kitten command) and links to where you can learn more about the Streaming HTML magic in Kitten that means that the whole app is ~60 lines of code :)
Update: I forgot to make the toast message `div` into an `aria-live` region so toast messages are read out when they arrive for people who use screen readers.
Now fixed.
Source code: https://codeberg.org/kitten/app/src/branch/main/examples/streaming-html/toast/index.page.js
Thanks to @hi_mayank for catching that one. Appreciate it!