🚀 TwoFold v0.6

I just released TwoFold v0.6, 3 years & 7 months after the release of v0.5.

The new repository is located at: https://github.com/ShinyTrinkets/twofold.ts
The old repository was called twofold.js and it will be archived soon.

Everything is re-written in TypeScript and the engine is now Bun, instead of Node.js.
This allowed me to compile a standalone executable directly from Bun, with the code for parsing the tags, and all the core tags bundled inside.
The executable is between 92MB and 105MB, something around that size, depending on the Bun version.

I also started using the native fetch() function, which allows accessing lots of API endpoints natively.
In the previous version, I was using the node-fetch package, but it was included in the twofold-extras repository, so you had to install that on top of TwoFold.

Also I’m taking advantage of the builtin Bun.spawn() function, which replaces execa, so I can call lots of external programs from the core tags.
In the previous version, launching external programs was included in the twofold-extras, so again you had to install it.

I fixed a few tricky bugs in the lexer and parser, added more tests and parsing the tags is now much more reliable.
I have a ton of texts for the lexer and parser, I’m very confident that there are no serious bugs.
I also ran TwoFold on large HTML pages downloaded from the internet, just to see how it will handle them and I’m happy with the results.

I implemented a new type of property on tags, called “zero” props, which allows sending the default value for tag functions.
For single tags, it looks like this:

{ jsEval '1 + Math.random()*100' /}
{ cmd 'ls -la' /}
{ req "ipinfo.io" headers=`{"User-Agent": "curl/8.0.1"}` /}
{ ping '1.1.1.1' /}

For double tags, it’s pretty much the same:

{ cat 'README.md' }
# Hello world
This is a readme
{/ cat }

{ cmd 'ls -la' }
drwxr-xr-x  7 root root  4096 Jul  1 22:12 .
drwxr-xr-x 18 root root  4096 Jul  1 11:43 ..
-rw-r--r--  1 root root  123  Jun 30 11:59 README.md
{/ cmd }

I created a super important { ignore } tag. This allows wrapping a part of a text file and protecting it from render.
For example, in a README file, some paragraphs are examples of code that should NOT be executed by TwoFold, to they can be wrapped inside { ignore }…{/ ignore }.

I renamed some core properties:

  • once=true --becomes–> freeze=true , because it makes more sense
  • consume=true --becomes–> cut=true , because it’s shorter to write

What’s next ?

I added lots of new tags, thanks to the native Fetch and Spawn functions from Bun.
However, I think the core tags need to be polished a bit more, to make them more useful for other people.

I also need a lot more documentation.

Another important thing is how to save tag state using tag properties.
I’m thinking about using this to return tag function errors, among other things.
I already tested a hacky way of returning a tag from a single-tag, which allows creating “TwoFold animations”. Pretty cool stuff!

@notes #trinkets #twofold #project