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

Create an entrypoint for just folding API #750

Open
wants to merge 3 commits into
base: refactor/extract-scripting-api
Choose a base branch
from

Conversation

guyguy2001
Copy link
Contributor

@guyguy2001 guyguy2001 commented Jun 14, 2024

Summary

TODO

Implementation Notes

Currently I provide an html entrypoint containing a maingame element which has the same external folding API as the main maingame object used in the regular eterna puzzles.

This is stacked on top of #749 ! change this to point to dev after merging #749 and before merging this.

Testing

I ran the following in the terminal:

document.getElementById("maingame").fold("AAUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUAAAAAAAAAAAAAAAAAAAAA") 

Related Issues

A per-requesit of eternagame/eternagame.org#378
Stacked on top of #749

@guyguy2001 guyguy2001 marked this pull request as draft June 14, 2024 14:55
Comment on lines +20 to +35
<script src="./frontend/jscripts/jquery/jquery-1.7.2.min.js"></script>
<script src="./frontend/jscripts/jquery/jquery-unselectable.js"></script>
<script src="./frontend/jscripts/jquery-ui/jquery-ui-1.8.7.custom.min.js"></script>
<script src="./frontend/jscripts/json/json2.js"></script>

<script src="./frontend/jscripts/application.js"></script>
<script src="./frontend/jscripts/utils.js"></script>
<script src="./frontend/jscripts/ajaxmanager.js"></script>
<script src="./frontend/jscripts/datamanager.js"></script>
<script src="./frontend/jscripts/usermanager.js"></script>

<script src="./frontend/jscripts/eterna/eterna-application.js"></script>
<script src="./frontend/jscripts/eterna/eterna-utils.js"></script>
<script src="./frontend/jscripts/eterna/script-library.js"></script>
<script src="./frontend/jscripts/eterna/script-interface.js"></script>
<script src="./frontend/jscripts/eterna/presenter.js"></script>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which of these is necessary - I would rather not have all of them in the script editor

Comment on lines +12 to +19
FoldingAPIApp: typeof FoldingAPIApp;
app: EternaApp; // this syntax is used in index.html.tmpl, at least...
__PIXI_APP__?: PIXI.Application;
}
}

window.EternaApp = EternaApp;
window.FoldingAPIApp = FoldingAPIApp;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I'd use a different index.ts for folding-api.html, so that we don't have to import pixi in the script editor - I'm not sure what is the relationship between eterna/index.ts and index.html though.

@guyguy2001 guyguy2001 force-pushed the feat/create-folding-api-entrypoint branch from 48fedc4 to 228cd42 Compare June 14, 2024 15:03
@guyguy2001 guyguy2001 marked this pull request as ready for review June 14, 2024 15:57

public async run(): Promise<void> {
if (!FoldingAPIApp.isWebAssemblySupported()) {
throw new WasmNotSupportedError(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to leave handling this error to the Vue app trying to import it. Does it make sense?

Currently it wouldn't propagate to the vue app because of how I used it in folding-api.html.tmpl

log.info('Initializing folding engines...');
console.time('Test');
const folders: (Folder | null)[] = await Promise.all([
Vienna.create(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folders duplication with EternaApp.ts - I should probably move this to a LoadAllFolders.ts thing, so that new folders wouldn't be missed

@guyguy2001 guyguy2001 changed the title Add comment in index.html.tmpl Create an entrypoint for just folding API Nov 30, 2024
luxaritas pushed a commit that referenced this pull request Dec 20, 2024
## Summary
This is part of the process of extracting the script-facing API from
PoseEditMode in order to make it usable for non-booster scripts.
Replaces #749

## Implementation Notes
I did it like the previous PR, except I didn't implement
get_folder/select_folder, since they are behind a "lock", and I didn't
want to think yet of whether or not I want the extracted logic to
inherit the lock.
However, while get_folder is locked, the calculation functions (such as
`fold`) which also access the folder, aren't locked (even on `dev`). Is
this intended?

## Testing
I ran https://eternagame.org/scripts/13774466, and it passed.
The script checks that all of the extracted functions (expect folding
with binding sites) work and return the same values.

This is an unrelated issue, but : For some reason, both on main/master
(https://eternagame.org/puzzles/6096060/play) and on my branch, the
first time I run it I get the following errors, and on future runs it
passes. Reloading the page makes the issue appear again for a single
execution.
Errors:

![image](https://github.com/user-attachments/assets/1fca8f90-85f4-485c-9ff4-a44fcdb2445a)
Successful run:

![image](https://github.com/user-attachments/assets/ecfe8020-2724-44f3-819f-0a6c13182786)
(In my branch I just copy pasted the script, since I didn't have it on
eternadev.org, and changed `Lib.fold`->`applet.fold`. I shouldn't have
Lib in the terminal, right?)


## Related Issues
Enables eternagame/eternagame.org#378,
#750
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

Successfully merging this pull request may close these issues.

1 participant