In order to prepare the ground for creating a new EternaJS app that just exposes the folding API without any additional state (which would allow fixing https://github.com/eternagame/eternagame.org/issues/378), and in order to just simplify PoseEditMode, this PR extracts logic related the to the folding scripting (booster) API from PoseEditMode to a new class (/function), which would have very few dependencies.
Implementation Notes
Moved the code responsible for exposing the folding API (which only depends on the folding context, i.e read-only access to this._folder and understanding whether or not we are in psuedoknot mode) from PoseEditMode.ts to a separate ScriptsApi.ts flie (name WIP)
Testing
I currently only ran document.getElementById("maingame").fold("AUGGGGGGGGGGGGGGGGGGGGCCCCCCCCCCCCCCCCCCCC") after running the script evaluator (in order to load the script interface)`.
~Probably change the class into a function~ - I decided against it.
~Move the file~
~Make eslint not angry~
Testing
Direct Follow-Up / maybe this PR
~extract setting the folding engine as well~
Later
Extract the rest of the scripting API to helper classes / functions
Notes / Questions for CR
Notes
It's still WIP, but I'd appriciate an early review to make sure I'm on the right track
You should probably review this commit by commit, they are much more indicative than the diff
Questions
Do you think the idea with _getFolder and _getIsPseudoknot make sense? I couldn't find a better way without a) making a SwitchableFolder proxy object or b) giving this class access to the entire PoseEditMode (now that I think about it, we could define an interface containing folder and isPseudoknot... but I think it's better to just pass these 2, although I haven't done typescript in years)
Well apparently there is a SwitchableFolder - it's FolderSwitcher. Should I use it for this? Or the getter thing?
FolderSwitcher is coupled to pixi and the GUI, so I think I'm satisfied with the current way.
And is isPseudoknot ever going to change?
About pseudoknots - what does it mean to be in pseudoknots mode? That we look at tertiary structure when folding? This makes Lib.fold behave differently between different puzzles - but now it will also (or maybe has) behave differently between the editor and the scripts page and the game
Where should I put this file? I put this in eterna/eternaScript, but ExternalInterfaceCtx should probably also sit there - however, I'm not sure if they should sit together - the code I moved is "user" code using the interface context, while the interface context itself is more of a "library" thing. Should I move it there as well in a follow up PR?
Summary
In order to prepare the ground for creating a new EternaJS app that just exposes the folding API without any additional state (which would allow fixing https://github.com/eternagame/eternagame.org/issues/378), and in order to just simplify PoseEditMode, this PR extracts logic related the to the folding scripting (booster) API from PoseEditMode to a new class (/function), which would have very few dependencies.
Implementation Notes
Moved the code responsible for exposing the folding API (which only depends on the folding context, i.e read-only access to
this._folder
and understanding whether or not we are in psuedoknot mode) from PoseEditMode.ts to a separate ScriptsApi.ts flie (name WIP)Testing
I currently only ran
document.getElementById("maingame").fold("AUGGGGGGGGGGGGGGGGGGGGCCCCCCCCCCCCCCCCCCCC")
after running the script evaluator (in order to load the script interface)`.Related Issues
Preparations for fixing https://github.com/eternagame/eternagame.org/issues/378
TODO
Blocking merge:
Direct Follow-Up / maybe this PR
Later
Notes / Questions for CR
Notes
Questions
_getFolder
and_getIsPseudoknot
make sense? I couldn't find a better way without a) making aSwitchableFolder
proxy object or b) giving this class access to the entire PoseEditMode (now that I think about it, we could define an interface containingfolder
andisPseudoknot
... but I think it's better to just pass these 2, although I haven't done typescript in years)SwitchableFolder
- it'sFolderSwitcher
. Should I use it for this? Or the getter thing?FolderSwitcher
is coupled to pixi and the GUI, so I think I'm satisfied with the current way.isPseudoknot
ever going to change?Lib.fold
behave differently between different puzzles - but now it will also (or maybe has) behave differently between the editor and the scripts page and the gameeterna/eternaScript
, butExternalInterfaceCtx
should probably also sit there - however, I'm not sure if they should sit together - the code I moved is "user" code using the interface context, while the interface context itself is more of a "library" thing. Should I move it there as well in a follow up PR?