joystick icon indicating copy to clipboard operation
joystick copied to clipboard

Consider support for a /wasm folder at the root that can ship .wasm to the browser

Open rglover opened this issue 2 years ago • 1 comments

Wrote down a note in my sketchbook about this and I think it would work quite well. The real advantage with WASM is in the browser, not on a third-party platform.

Why: I can write resource-intensive code that needs to run on a per-user basis (e.g., calculating some statistics) and run it on a user's hardware. The advantage is that I'm not resource-capped by a remote instance or any convoluted deployment system.

In Joystick, I think we could set up a way to make it so you could load WASM modules at the component level (e.g., add an option called wasm to the component options):

import calca
const MyComponent = joystick.component({
  wasm: [
    'calculate_monthly_report',
  ],
  events: {
    'click .generate-report': async (event, instance) => {
      const report = await instance.wasm.calculate_monthly_report();
      console.log(report);
    },
  },
});

The whole idea here being that I can call WASM code via my UI and Joystick automatically ships the specified wasm modules down to the client.

In theory, this could help with a lot of performance stuff, but, you'd need to be mindful about security. It seems like the sandboxed nature of WASM modules would help with most of this.

rglover avatar Oct 12 '23 18:10 rglover

See implementation notes: https://claude.ai/chat/f8048055-0675-4369-8cd9-23e73d426deb

rglover avatar Jul 23 '24 20:07 rglover