web icon indicating copy to clipboard operation
web copied to clipboard

Dart VM support.

Open ykmnkmi opened this issue 2 years ago • 5 comments

Any thoughts on generating an unimplemented version for VM?

ykmnkmi avatar Jun 23 '23 03:06 ykmnkmi

Interesting idea – @sigmundch @joshualitt

@ykmnkmi – why do you want this?

kevmoo avatar Jun 23 '23 17:06 kevmoo

For packages like zap. I'm also porting Svelte to Dart and facing a problem with how to eliminate all web-related calls from the generated component for SSR.

Here original example how it would like to look. From svelte template:

<script>
  let m = { x: 0, y: 0 };

  function handleMousemove(event) {
    m.x = event.clientX;
    m.y = event.clientY;
  }
</script>

<div on:mousemove={handleMousemove}>The mouse position is {m.x} x {m.y}</div>

To JS component:

const App = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let m = { x: 0, y: 0 };

  // Not called
  function handleMousemove(event) {
    m.x = event.clientX;
    m.y = event.clientY;
  }

  return `<div>The mouse position is ${escape(m.x)} x ${escape(m.y)} </div>`;
});

ykmnkmi avatar Jun 23 '23 18:06 ykmnkmi

@kevmoo Just to follow up on this, I think there is an interesting movement happening in the JS / WASM ecosystem inside of the Web-interoperable Runtimes Community Group where a number of different runtimes are looking to implement a number of the same APIs that already exist in the browser so that for a given language you could have the same set of APIs to work with client side and server side.

You can see a draft of their proposed minimum common API should look like here: https://common-min-api.proposal.wintercg.org/

Having a VM version of this package would allow for an implementation like that on the Dart side to appear which I think be nice for the overall server side Dart community to grow and align itself with some interesting things happening in other ecosystems at the same time. Just wanted to share it as a use case to consider in the meantime.

mark-dropbear avatar Sep 10 '24 17:09 mark-dropbear