Closed linonetwo closed 8 months ago
Oh, no, the major problem is: even a syncadaptor plugin's JS is not loaded, its wikitext is still shadowing previous syncadaptor plugin's wikitext UI!
We need a way to inform high priority syncadaptor's UI to not overwrite low-priority-but-working plugin's ui.
Thank you @linonetwo. It sounds like you're trying to make a wiki that has two different sync adaptor plugins loaded at the same time, and have the system dynamically choose which one to use according to the environment in which it is loaded.
However, at the moment, dynamically switchable sync adaptors are not supported by the system. The tiddlywebadaptor is active if it is loaded in a wiki, and there is no way to deactivate it without removing the plugin.
I'm not sure how Tidgi works, but might it be possible to splice in the correct syncadaptor plugin at the time the HTML file is being loaded into Electron's webview?
have the system dynamically choose which one to use according to the environment in which it is loaded
Yes, I'm currently registering my syncadaptor depending on environment
if ($tw.browser && typeof window !== 'undefined') {
const isInTidGi = typeof document !== 'undefined' && document?.location?.protocol?.startsWith('tidgi');
const servicesExposed = Boolean(window.service?.wiki);
const hasWorkspaceIDinMeta = Boolean((window.meta as WindowMeta[WindowNames.view] | undefined)?.workspaceID);
if (isInTidGi && servicesExposed && hasWorkspaceIDinMeta) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
exports.adaptorClass = TidGiIPCSyncAdaptor;
}
}
Which is learnt from tiddlyweb/tiddlywebadaptor.js
dynamically switchable sync adaptors
So I don't think I need to dynamically switch them (by user)? Because this happened automatically. And these JS parts just work together well.
The conflict happens in the wikitext part.
splice in the correct syncadaptor plugin at the time the HTML file is being loaded into Electron's webview
Do you mean using $tw.wiki.addTiddler
? I tried, and filesystem
plugin will write a JSON plugin into the /tiddlers folder... Only by preloading these plugins before booting, by doing:
wikiInstance.boot.extraPlugins = [
'plugins/linonetwo/tidgi-ipc-syncadaptor',
'plugins/linonetwo/tidgi-ipc-syncadaptor-ui',
enableHTTPAPI ? 'plugins/tiddlywiki/tiddlyweb' : undefined,
]
can prevent tw write a JSON to /tiddlers folder.
dynamically switchable sync adaptors
So this might need an overhaul, because I hope in the future, nodejs wiki can sync to fs + sync to a tiddlyweb server + communicate between client/server, or even sync to solid server at the same time! Just like how Notion/Office365 feels.
Which will even requires 2 or more syncadaptor runs at the same time, acts like a multiplexer.
Yes, I'm currently registering my syncadaptor depending on environment
Great that looks OK.
The conflict happens in the wikitext part.
Is the problem that you're seeing the wikitext shadow tiddlers from the tiddlywebadaptor even if it is disabled?
splice in the correct syncadaptor plugin at the time the HTML file is being loaded into Electron's webview
I meant modifying the HTML file to add the plugins into the JSON store area.
Do you mean using
$tw.wiki.addTiddler
? I tried, andfilesystem
plugin will write a JSON plugin into the /tiddlers folder... Only by preloading these plugins before booting, by doing:
Great, if the preloading technique works that's much easier.
wikitext shadow tiddlers from the tiddlywebadaptor even if it is disabled
Yes, wikitext can't be disabled using JS, so they are shadowing even corresponding JS is disabled...
Wait, maybe I can access $tw.wiki.xxx to modify the shadow tiddlers, to disable my wikitext if my JS is disabled. This is a hacking way, but maybe is the only way, and we may have to do this in the tiddlyweb plugin too, or make this a core method, to become a standard way.
Describe the bug
We have tiddlyweb with priority 10, which should work when we access wiki from the browser. And I have a tidgi-ipc-adaptor plugin with priority 11, that should work when we access the wiki in the Electron.
In electron env this works fine, but when in the web:
Based on
"plugin-priority": 11
inplugin.info
, a plugin with a largetpriority
should overwrite all smaller ones. Now tiddlyweb's wikitext will be overwritten by tidgi-ipc-adaptor's wikitext. Even tidgi-ipc-adaptor currently is disabled by not exposing adaptorClass.What if we change tidgi-ipc-adaptor plugin with priority 9 to avoid this? Then in the web it works fine, but in Electron env my wikitext UI will be overwritten by tiddlyweb's UI.
Expected behavior
Wikitext should be enabled/disabled with the syncadaptor module. Otherwise
To Reproduce
Well...A bit difficult to construct.
Screenshots
While the working syncadaptor is tidgi-ipc-syncadaptor, the showing wikitext ui is from tiddlyweb-plugin
TiddlyWiki Configuration
Desktop (please complete the following information):
Additional context
I'm adding a ipc syncadaptor that works in electron faster.