-
Notifications
You must be signed in to change notification settings - Fork 10
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
Refactor/extract scripting api #749
base: dev
Are you sure you want to change the base?
Conversation
@@ -22,6 +22,7 @@ | |||
"core-js": "^3.13.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally comitted this file - Should I keep it if this is what npm install gives me?
@@ -1269,140 +1270,11 @@ export default class PoseEditMode extends GameMode { | |||
this._puzzle.getBarcodeHairpin(Sequence.fromSequenceString(seq)).sequenceString() | |||
)); | |||
|
|||
this._scriptInterface.addCallback('current_folder', (): string | null => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should go commit by commit, since the first commit doesn't modify this code, only moves it (and adds code around it)
This commit only copies the relevant lines from PoseEditMode.ts to ScriptsApi.ts - it doesn't modify them, only adds code around them. Because of that, ScriptsApi.ts is broken for this commit.
844640e
to
c7ce02a
Compare
'select_folder', (folderName: string): boolean => this.selectFolder(folderName) | ||
); | ||
addSelectFolderAPIToInterface({ | ||
selectFolder: this.selectFolder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably broken due to this
shenanigans
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 eternagame/eternagame.org#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 eternagame/eternagame.org#378
TODO
Blocking merge:
Rename the class and the file nameProbably change the class into a function- I decided against it.Move the fileMake eslint not angryDirect Follow-Up / maybe this PR
extract setting the folding engine as wellLater
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?