fedwiki / wiki-client

Federated wiki client-side javascript as a npm module.
Other
117 stars 38 forks source link

Convert plugin loading to async/await forward JS #321

Closed nrn closed 3 months ago

nrn commented 4 months ago

The main reason for this conversion is to contain errors on a per plugin basis so one broken/missing plugin doesn't break the rest of the page.

paul90 commented 4 months ago

There probably needs to be some memory that a plugin has not been found. Each load attempt looks in two places, /plugins/chess/chess.js and /plugins/chess.js, and this is done twice. Looks as if the second place goes back to a change in plugin location 12 years ago - see SFW commit.

plugin.get() is used in two? places to load the plugin - line 84, in renderFrom(), and line 267, in plugin.emit(). Once in the render, and then in the bind?

Screenshot 2024-07-13 at 11 42 40

I think much of this is old problems. It has been determined that "Could not find plugin chess", but the code still goes down the path of throwing an error, and repeating the attempt to load the plugin.

paul90 commented 4 months ago

Toggling the wiki button, on or off, results in content following the item with the failed plugin to get duplicated. The number of times seems to be dependent on the number of pages in the lineup to the left of the page with the failed plugin! Very strange.

Screenshot 2024-07-13 at 11 53 39

This behaviour previously existed.

nrn commented 4 months ago

Yeah, I think those will both be easier fixes after this change, but I was trying not to do too much in the one pr. Trying to load the code multiple times may even just be fixed by import(), but I saw a potential quick fix for it while I was working on the rest of this I'll add as a suggestion.

paul90 commented 3 months ago

As mentioned in the call earlier this week - I have created a branch withgit mv plugin.coffee plugin.js as the first step. This helps retain the history of the decaffeinate step. A pre-release is available as wiki-client@0.30.0-rc.1

See https://github.com/fedwiki/wiki-client/commits/bind-error-with-mv/ for the commits in the modified branch with the initial git mv.

paul90 commented 3 months ago

The force push was to add git mv as the first commit, and to convince this PR has been merged.