Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDEA] Allow sync-adaptor load json plugins #7685

Closed
linonetwo opened this issue Aug 19, 2023 · 5 comments
Closed

[IDEA] Allow sync-adaptor load json plugins #7685

linonetwo opened this issue Aug 19, 2023 · 5 comments

Comments

@linonetwo
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Allow sync-adaptor load plugins before booting, and make all plugins work without refreshing the page.

Describe the solution you'd like

I thought "js plugins require reload" is just a security mechanism, so we disable it for plugins loaded by the sync-adaptor.

Then in an empty html, the only plugin needs installing is a sync-adaptor plugin, then fill in the endpoint, it will fetch skinny tiddlers, including those plugin tiddlers.
Disable plugin related security mechanism while loading those plugin tiddlers. Then turn on security, and start lazy loading other tiddlers when requested.

Describe alternatives you've considered

Maybe work with indexed-db, save plugins in it, and auto refresh the page...
wait, why localstorage plugin can save other plugins in it and make them work without refreshing?

Also I remember there is a Filesystem API plugin that can save html wiki without server or app, did you consider the usage like this issue?

Additional context

Trying to make HTML wiki know how to read nodejs wiki's .tid/.md files and json plugins.

@linonetwo linonetwo changed the title [IDEA] [IDEA] Allow sync-adaptor load json plugins Aug 19, 2023
@rmunn
Copy link
Contributor

rmunn commented Aug 19, 2023

I thought "js plugins require reload" is just a security mechanism, so we disable it for plugins loaded by the sync-adaptor.

The commit message for 93e0143 suggests that you're correct: "We might in the future offer support for certain types of JS module to be hot loaded."

At the moment, the "doesPluginRequireReload" check is still simply "is it a Javascript module? Then yes, otherwise no". But yes, the framework has been put into place to allow certain types of modules to be loaded without a reload. It makes sense to me that any plugin loaded at boot time, before the rest of the wiki is loaded, can (and should) be put on the "no reload" list.

@linonetwo
Copy link
Contributor Author

Thank you @rmunn , so we can make sure that all modules could have taken effect immediately, this require-reload just for security reasons.

We will need to add another check here "// The lazy-load plugin never requires reloading"

https://github.com/Jermolene/TiddlyWiki5/blob/779ac28bd02defa158af470a1ce3e3f0125cba38/core/modules/wiki.js#L1657-L1659

(I'm not sure what fields["plugin-type"] === "import" means here, because when dragging importing a JSON plugin that contains JS tiddler, it does require reloading, right?

@Jermolene
Copy link
Member

Thanks @linonetwo @rmunn

Allow sync-adaptor load plugins before booting, and make all plugins work without refreshing the page.

The expectation behind the current design is that the syncadaptor would work in tandem with the mechanism that constructs the initial HTML file. I think you're working in situations where the initial HTML file is not dynamically generated.

In such situations in my own code I have use a raw markup tiddler to handle the pre-startup loading. You can see an example of the approach via a view source here: https://xememex.com/jermolene/

@linonetwo
Copy link
Contributor Author

I see, similar to the demo-alternate-store PR #7521 , and this is a temporary workaround before it is done. But it means I can already do it now.

Maybe just use a zx script to append script tags to HTML generated by nodejs, so it won't be messy to upgrade tw...

@linonetwo
Copy link
Contributor Author

Close this because it can be done in user-land, as a new distribution version. I need this because Tiddloid Android is too slow to use with my 100M personal wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants