Ink(y) / Porting the Ink compiler to the browser?

I know very little about porting c# apps to the browser, so I thought I’d ask here and hope there’s someone more knowledgeable than me willing to answer.

How hard would it be to port the Ink compiler from C# to the browser (JavaScript or Webassembly)? Possibly not rewriting the whole thing from scratch, but doing it (semi-)automatically via some kind of transpiler.

Ink games already run in the browser, of course, but it would be cool to move the whole stack to the browser, so to speak. Building on that you could create an Inky editor that runs entirely client-side in the browser, for example.

Hello Daniel,
You’ll be very happy to know that :slightly_smiling_face: … it’s been done already !
We’re in the final stages of releasing inkjs with the parser+compiler : GitHub - y-lohse/inkjs at compiler (there are some last issues to iron), and you are more than welcome to contribute a PR to speed up the process a little.

I’m also writing a web adaptation of inky (but this is far from done) : GitHub - smwhr/inkyweb (with a way to try it here : Inky Web but beware) : it’s not production ready and may break anytime but I’m already using it on a regular basis to test some ink on the go. Here, feel free to PR also if you want to contribute !


(By the way : we translated the C# quite litteraly to typescript, this is maybe very time consuming, but lessons learnt from the player/engine part : this is really easy to port subsequent commits by the inkle team when they develop on the C# project)

1 Like

Wow, this is great! Thank you so much for this! I’ll start playing with it right away.

Also, someone on inkle’s discord made a prototype for use with Eleventy (most of the conversation takes place over there, I can send you an invite if you wish)

Is it possible to make a design request?

Please could you make it possible to turn off that little box attached to the cursor making typing completion suggestions? I found it made it impossible for me to think about what I was actually trying to type, because it was always exactly where I was looking. Plus it was also a nuisance when I hit return to start a new paragraph, and it thought I wanted the completion it was suggesting.

Thanks! :slight_smile:

1 Like

This is now official, inkjs 2.1.0, out just now, offers a build that includes the ink compiler :partying_face:

It means you can do things like :

const story  = (new inkjs.Compiler(`Hello World`)).Compile()
// story is an inkjs.Story that can be played right away

const jsonBytecode = story.ToJson();
// the generated json can be further re-used

instead of having to compile your ink files locally. Everything works in the browser.

@chance_the_ripper have you had time to play with the partial build ?