zlacker

[parent] [thread] 3 comments
1. zachri+(OP)[view] [source] 2026-02-03 17:26:51
Would like to see the eval version - the dialogue version just seems like normal code with extra steps?
replies(1): >>mavdol+V5
2. mavdol+V5[view] [source] 2026-02-03 17:49:21
>>zachri+(OP)
yeah, the previous example was quite basic. I will write a complete example for that, but here is how you can run dynamic code:

   import { task } from "@capsule-run/sdk";

   export default task({
     name: "main",
     compute: "HIGH",
   }, async () => {
     const untrustedCode = "const x = 10; x * 2 + 5;";
     const result = eval(untrustedCode);
     return result;
   });
Hope that helps!
replies(1): >>zachri+9A6
◧◩
3. zachri+9A6[view] [source] [discussion] 2026-02-05 13:16:05
>>mavdol+V5
Is the code in the eval also turned into wasm first then? Does this work as a JIT for wasm?
replies(1): >>mavdol+8B8
◧◩◪
4. mavdol+8B8[view] [source] [discussion] 2026-02-05 23:40:26
>>zachri+9A6
It actually works a bit differently. The eval is executed by the interpreter running inside the isolated wasm sandbox (StarlingMonkey). You can think of it as each sandbox having its own dedicated JavaScript engine.
[go to top]