Inter wiki communications in browser and other features

Folks,

In this discussion Consider solutions to avoid losing data when using tiddlyhost on multiple devices · Issue #219 · simonbaird/tiddlyhost · GitHub Mario pointed out

There is the Broadcast Channel API - Web APIs | MDN which allows us to create a message that is broadcasted, whenever a new tab, window or even an iframe is opened from the same origin.

This seems to me an example where developer contributions to tiddlywiki could be used to empower tools and innovation on tiddlywiki, rather than to solve specific problems. Although in this case Mario’s suggestion for the specific issue of multi-device wikis is of course a valid one.

My idea here is to provide a small set of Broadcast Channel macros and actions within a plugin. Such as open/create channel name, list channels opened, broadcast to channel, read channel (get) and ideally even an action that that will be triggered on any broadcast or if a specific string is broadcasted.

This is to me similar to Eric’s Get/Set cookies js macros, my set/get windows.name /target windows, also a reset dirty macro I collected, in that they are very simple javascript - interfacing with the browser in a generic way and exposing useful features.
Other examples may include;

  • Get geo-location
  • Get/Set unique session ID’s

The idea is these just expose features without any judgement to how these will be used, I will not bore you but I see a lot of opportunities for really interesting solutions built on top of tiddlywiki.

  • We may want to encourage some de facto or de jure standards that can be applied on wikis like wikinames and a standard broadcast channel for those cases where it will prove useful for different solutions to used a shared standard.

Advanced examples
In time I see people building an in browser interwiki messaging environment perhaps to request a search in another wiki, and return tiddler titles and be able to apply a permalink and target windows to then open them from one wiki in another.

The key idea here is exposing tools and features without too much judgment how they will be used. Many of the Javascript dev’s here could do dozens of these in your sleep (Even I am starting to).

Always keep KISS/MVP in mind and set them free.

I have experimented briefly with inter-tab communication using “Broadcast Channel” between 2 instances of the same Wiki in different tabs. Right now, with my Yjs experiment, wikis are sync’d very closely, but I see the ability to have 2 totally different layouts “in view”, and changing a tiddler in one, updates both wikis and thus both views independently.

I actually took that code out of my current branch of the Yjs experiment, as I wanted to focus on websocket client->server communications, which also works with multiple tabs with the same wiki open.

Your work sounds very interesting @joshuafontany. Is it possible to extract the key scripting, just the calls to create send and receive on broadcast on channels?

I would be happy have a go at implementing small plugins as I did here Javascript plugin to set the current window name - #3 by TW_Tones (with a little help) the other day.

I could not find a link to any Yjs experiment, code or demos, however I understand it will not contain the messaging.

Of note with inter wiki communications on file:// since local storage and cookies etc… are all inside the same “namespace” it is possible to build a rich inter wiki environment just with current tools. Operating between file:// wikis makes sense in many ways because it is all a private space. I imagine a set of dashboard wikis that exchange some key values.

  • On reflection I can see this is also an opportunity to test interwiki communications.
  • I would love to know how to be able to separate tabs/sessions in file:// as well.

Here I am just trying to get a few “Lego bricks”/“code modules” to facilitate the possibilities into the future. Nothing too complex.

1 Like