diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-08-07 10:40:54 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-08-09 17:18:37 +0200 |
commit | 33c0938cd50dd3409f8e94878b97d789cc328f23 (patch) | |
tree | fc4cc45265b86746aa37bc3ab4445724d22a98f2 /internal/warpc/js/greet.bundle.js | |
parent | 0c3a1c7288032401327a9c4d7044e297bf3f7da6 (diff) | |
download | hugo-33c0938cd50dd3409f8e94878b97d789cc328f23.tar.gz hugo-33c0938cd50dd3409f8e94878b97d789cc328f23.zip |
Add build time math rendering
While very useful on its own (and combined with the passthrough render hooks), this also serves as a proof of concept of using WASI (WebAssembly System Interface) modules in Hugo.
This will be marked _experimental_ in the documentation. Not because it will be removed or changed in a dramatic way, but we need to think a little more how to best set up/configure similar services, define where these WASM files gets stored, maybe we can allow user provided WASM files plugins via Hugo Modules mounts etc.
See these issues for more context:
* https://github.com/gohugoio/hugo/issues/12736
* https://github.com/gohugoio/hugo/issues/12737
See #11927
Diffstat (limited to 'internal/warpc/js/greet.bundle.js')
-rw-r--r-- | internal/warpc/js/greet.bundle.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/internal/warpc/js/greet.bundle.js b/internal/warpc/js/greet.bundle.js new file mode 100644 index 000000000..c1b9c5264 --- /dev/null +++ b/internal/warpc/js/greet.bundle.js @@ -0,0 +1,2 @@ +(()=>{function i(r){let e=[],a=new Uint8Array(1024);for(;;){let n=0;try{n=Javy.IO.readSync(0,a)}catch(o){if(o.message.includes("os error 29"))break;throw new Error("Error reading from stdin")}if(n<0)throw new Error("Error reading from stdin");if(n===0)break;e=[...e,...a.subarray(0,n)];let t=0;for(let o=0;t<e.length;t++)if(e[t]===10){let f=e.splice(o,t+1),s=new Uint8Array(f),u=JSON.parse(new TextDecoder().decode(s));r(u),o=t+1}e=e.slice(t)}}function d(r){let c=new TextEncoder().encode(JSON.stringify(r)+` +`),e=new Uint8Array(c);Javy.IO.writeSync(1,e)}var l=function(r){d({header:r.header,data:{greeting:"Hello "+r.data.name+"!"}})};console.log("Greet module loaded");i(l);})(); |