A small websocket plugin in tiddlywiki

I created a small websocket server under node.js tiddlywiki to live communicate with external tools (e.g. vs code and R).

The codes can be found here: https://tw-livebridge.bangyou.me/

I used this bidirectional communication features of TW into VS Code and R to open and/or edit a tiddler.

  • TiddlyEdit (VS Code extension) – allows seamless editing of tiddlers directly from VS Code.
  • rtiddlywiki (R package) – enables preview of R Markdown files inside TiddlyWiki.

These tools don’t use the plugin code directly; instead, they rely on the real-time communication channel established by TW LiveBridge.

This small websocket server might be useful in other external programs.

1 Like

Hi @Zheng_Bangyou I use TiddlyWiki App from @oeyoews and tried to do a drag and drop install as the instructions laid out. After refreshing one wiki I didn’t notice any changes, so I tried restarting TiddlyWiki app and got some javascript errors, so this looks to not be compatible at this time. If you have ideas for installing for TiddlyWiki app I’d love to try it.

I also use R with TiddlyWiki (posted here) and expected the PUT to reflect instantly in my wiki (I use TiddlyWiki App and then use the “view in browser” so I get the URL (localhost:9090) to PUT to. It didn’t show up instantly, it was the same as before, so again, might just have not been working.

I think having a way to add Websocket to the TiddlyWiki app so that changes on different tabs or different machines would be awesome as it has multi-user implications, I hope there’s a way to figure this out!

Thanks!

I don’t use TiddlywikiApp. This plugin is only working for node.js and will not have any changes to interface.

I will add more documentation later. A short explanation here.

tw-livebridge has two components

  • server: it starts websocket server in the same domain of node.js http server (i.e. ws://127.0.0.1:8080/ws in default). The ws server passes all messages to clients.
  • browser: it accepts message open-tiddler to open a tiddler, and send message edit-tiddler to edit a tiddler in third parties (e.g. vs code)

PUT method only sends updates to server. Browser will have to sync from server before viewing it (the default frequency would be 30s or 60s).

If you want to open a tiddler in R, you can see this internal function .send_open_tiddler in my rtiddlywiki package. This function connects ws server and send an open-tiddler message. If your tiddlywiki is opening in the browser, this tiddler will sync from server and open in the story river.