• 16 posts
  • 20 comments
Joined 2 years ago
Cake day: June 14th, 2024

TLDR; The title of this post.

Feel free to reach out for clarity instead of reading the code/docs.

I was working on a “react-like syntax for webcomponents”, I wanted to create something robust and flexible for secure data storage and management.

I started off with an approach for asynchronous state management so that components outside the shadow-root could receive updates. (The events are also encrypted to secure against things like browser extensions.)

https://positive-intentions.com/docs/projects/dim/async-state-management

It then made sense to be able to persist that data so it can work between page releoads.

https://positive-intentions.com/docs/projects/dim/bottom-up-storage

The result looks and works like the following when used in a project.

https://positive-intentions.com/docs/projects/dim/encrypted-store

The Dim framework seems like a dead-end. I wanted to try it out on my existing React projects. So I created the equivalent React hooks.

https://positive-intentions.com/docs/projects/dim/use-dim-store-react

I find it to be performant and I want to push the scale of the approach, so I am in the process of testing it out on my projects. A notable use-case there is storing encrypted files at rest.

IMPORTANT: Im not trying to promote “yet another ui framework”, this is an investigation to see what is possible. You should not use this in your own code. It is not reviewed, audited or production-ready. It is not on npm. Shared for testing, feedback and demo purposes only.

Im investigating an idea i had about React-like syntax for webcomponents after some experience with Lit.

Lit is a nice lightweight UI framework, but i didnt like that it was using class-based components.

Vue has a nice approach but i prefer working with the syntax that React uses. I find it more intuitive for debugging and deterministic rendering. I wondered if with webcomponents, i could create a UI framework that didnt need to be transpiled.

(My intentions with this framework is to get to a reasonable level of stability, to then replace React on some of my existing projects.)

IMPORTANT: Dont be misled by it being open-source. Im not trying to push “yet another ui framework”, this is an investigation to see what is possible. You should not use this framework in your own code. It is not production-ready. It is intended for myself on my own projects. This project is far from finished. I am sharing because it might be interesting/educational for someone. Feel free to reach out for clarity if you have any questions.

TLDR; I’ve been experimenting with react-like jsx-syntax with webcomponents to see if I could theoretically replace React in one of my projects. It is not ready for production use, but rather an exploration into CustomElements and modern browser capabilities.

https://github.com/positive-intentions/dim

The goal was to build functional Web Components that handle state management and DOM updates without the overhead of a massive JavaScript framework. By leveraging standard Web APIs and Proxy objects, I’ve managed to create a reactive programming model that feels familiar—using JSX—but stays much closer to the browser platform.

I wanted to see how far i could take web components before the architecture broke down. If you’re interested in frontend software engineering or web standards, you might find the logic behind the updates (which avoid a traditional virtual DOM) interesting.

Full technical tutorial and deep dive: https://positive-intentions.com/docs/research/Tutorials/dim/dim-functional-webcomponents

Disclaimer: This project is not ready for production use. In fact, this project may be getting deprecated soon, but I’m sharing it because the unique details into custom elements and modern JavaScript performance might be interesting or educational for others exploring the web platform.

https://positive-intentions.com/docs/technical/architecture

i cooked a bit too hard on this. i don’t advise you use this approach. its something I wanted to investigate for myself.

https://webpack.js.org/concepts/module-federation/#promise-based-dynamic-remotes

i was already using microfrontends for my project. when i came across dynamic remotes, i figured i could use it for statics redundency management. (tbh… a problem that doesnt exist.)

my project is far from finished and it would make sense to add additional safety nets for static-resource-integrity, but the basic concept seems to work and i wanted to share some details ive put together.

TLDR; for my project i wanted the signal protocol that would work in a browser. following a previous post i made about looking for the signal protocol in javascript, i couldnt find something suitable… so empowered by AI, i tried to create something myself. i dont want to inspire undue confidence.

IMPORTANT: this project is not professionally audited or production ready.


for my p2p messaging project (a webapp) i wanted to explore an usage of the Signal protocol… the investigation is still in progress and far from finished. its clear that the Signal protocol is not intended for a p2p architecture with it needing things like pre-keys stored on servers. so it seems nessesary to adapt it.

i looked around for a suitable implementation i could use. compiling the implementation in lib-signal-go to a wasm seemed like an option that worked… but given AI is everywhere, i decided to see if it could put something better together. i started off creating something using browser-based cryptograpy primitives. i would have like to keep it that way, but an ealier AI audit disagreed to using those primitives and so here is an attempt in rust that compiles to wasm.

https://github.com/positive-intentions/cryptography/tree/staging/src/rust

i added several unit tests and and got AI to try create better securty audits, and i think its working well. (or at least well enough). AI’s security audit points me to many things i can improve throughout (so i will when i can).

this is fairly complicated stuff and i know better than to ask people to spend their own time to review my experimental project… im not sharing for you to review my code; im sharing this here if this is interesting for anyone to take a look.


(note: the repo is getting a bit too “full” and i will be splitting it into a separate repo for just the signal implementation.)

Decentralized Architecture: https://positive-intentions.com/blog/decentralised-architecture

While my approach here could be considered overly complicated (because, well, it is), I’m trying something new, and it’s entirely possible this strategy won’t be viable long-term. My philosophy is “there’s only one way to find out.” I’m not necessarily recommending this approach, just sharing my journey and what I’m doing.

Potential Benefits

I’ve identified some interesting benefits to this approach:

While I often see module federation and microfrontends discouraged in online discussions, I believe they’re a good fit for my specific approach. I’m optimistic about the benefits and wanted to share the details.

When serving the federated modules, I can also host the Storybook statics. I think this could be an excellent way to document the modules in isolation.

Modules and Applications

Here are some examples of the modules and how they’re being used:

This setup allows me to create microfrontends that consume these modules, enabling me to share functionality between different applications. The following applications, which have distinct codebases (and a distinction between open and closed source), would be able to leverage this:

Sharing these dependencies should make it easier to roll out updates to core mechanics across these diverse applications.

Furthermore, this functionality also works when I create an Android build with Tauri. This could streamline the process of creating new applications that utilize these established modules.

Considerations and Future

I’m sure there will be some distinct testing and maintenance overhead with this architecture. However, depending on how it’s implemented, I believe it could work and make it easier to improve upon the current functionality.

It’s important to note that everything about this project is far from finished. Some might view this as an overly complicated way to achieve what npm already does. However, I think this approach offers greater flexibility by allowing for the separation of open and closed-source code for the web. Of course, being JavaScript, the “source code” will always be accessible, especially in the age of AI where reverse-engineering is more possible than ever before.

  • thanks. thats what id like to aim for and i dont think its far off. the build script there is mainly for the storybook statics (as seen in the link provided for “website”).

    couple things i hope to do soon, remove lit as a dependency - i use this right now because its useful for template rendering and lifecycle methods. webcomponents have a an ugly approach to this which Lit makes easier, and so i pushed it back, but its still on the todo.

    after that i should be able to have a more vanilla web dx.

Introducing Dim – a new framework that brings React-like functional JSX-syntax with JS. Check it out here:

🔗 Project: https://github.com/positive-intentions/dim

🔗 Website: https://dim.positive-intentions.com/

My journey with web components started with Lit, and while I appreciated its native browser support (less tooling!), coming from ReactJS, the class components felt like a step backward. The functional approach in React significantly improved my developer experience and debugging flow.

So, I set out to build a thin, functional wrapper around Lit, and Dim is the result! It’s a proof-of-concept right now, with “main” hooks similar to React, plus some custom ones like useStore for encryption-at-rest. (Note: state management for encryption-at-rest is still unstable and currently uses a hardcoded password while I explore passwordless options like WebAuthn/Passkeys).

You can dive deeper into the documentation and see how it works here:

📚 Dim Docs: https://positive-intentions.com/docs/category/dim

This project is still in its early stages and very unstable, so expect breaking changes. I’ve already received valuable feedback on some functions regarding security, and I’m actively investigating those. I’m genuinely open to all feedback as I continue to develop it!

  • thanks for your thoughts!

    a scenario so that people who aren’t immediately familiar ‘get’ what it is you’re achieving

    i think the ability to tell a story is important here and id like to put more time to learn how to frame it. its a very secure chat implementation from what i understand about what ive created. im keen to be challenged on if its the most secure chat app out there, but this typically seen as confrontational and seems to hurt public opnion of the project (and thus i dial it down).

    here is an attempt to try explain it as “more secure than mainstream solutions”: https://www.reddit.com/r/cryptography/comments/1evdby4/is_this_a_secure_messaging_app

    while i think i have a point about the security implementation. im also aware that the project is not very user friendly and full of bugs which makes for a very unappealing product.

    its worth noting, that im trying to communicate about the project to cybersecurity professionals at the moment to see if the theory hold up and i think it does. i iteratively improved the UI in an attempt to gain traction. as a webdeveloper i know that i can spend more time on the UI that everything else combined, but that wouldnt be a good use of my time compared to some under-the-hood changes for stability and fixes.

  • completely understandable conclusion.

    it started off as a curiosity, but i think there is something to it. I’m aiming for something that looks and behaves like react, but without the overhead of the react tooling for transpiling.

    im not trying to take a share of that market, i come across this solution as pf of the chat app project. id like to build up this ui framework well enough to rebuild the chat proct with it… the chat app is made with react and material UI. with this framework, i am aiming to create a more simplified version of the chat app where the “no need to transpile” is a feature for its transparency. perhaps it doesnt make sense right now without the ability to effectively demonstrate it.

  • thanks for you thoughts.

    i previously didnt have the “unstable” warning. this results is people saying that i should make it more clear. i think the project is in its early enough stages for it to be sensible to include there. im already planning on breaking changes which could make things worse so this is something i hope make it clear to users about the status of the project. before i had that notice, i would get complains from people that the app is terrible and doesnt work (which was basically true because it still is a work in progress and full of bugs.). i added a bit of a polish on it so it leads people to think its a finished product.

    im looking for contributors on the dim repo because there part things i would like to do (and tried), but reached the limits of what i understand. i can learn and figure it out if i pour more time into it, but i have already poured time into it. im hoping someone with relevent experience would want to help.

    im hoping to get a following on lemmy, mastodon, reddit in order to get traction on the projects. as it stand its just me and so its a bit of an uphill to get traction on something like the chat project. what you might be interpreting as ego, is a mannerism i have to adopt if i want to actively promote it as being a “secure chat system”. otherwise, feedback is a lot more dismissive about the project. that would surely sink the project immidiately.

    im a developer not a sales person… but since working on these project ive learnt to moderate how cautious my tone should be to balance the communication of technical details as well as promoting something. i dont think i do the best job of it, but im still in the learning process.