-
Notifications
You must be signed in to change notification settings - Fork 238
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
Add local storage extension #55
Conversation
Co-authored-by: !Ryan <[email protected]>
My current concern with this extension is that the storage keys are global instead of per-project, so if one project uses something generic like "data" then it will probably break some other project I'm not sure the best way to resolve that |
hm, is there a way to get the project id or smth? |
then we could do something like |
You can't post projects with custom extensions on scratch right |
No, you can't, |
Yeah so It won't work, and there probably aren't any other non-exploitable ways left. |
maybe based on project name? this would cause collisions with same project names but that is pretty rare (especially with how many people use extensions) |
actually if we're loading, just use the url. this would be nonexploitable [unless you have 2 .sb3s in the exact same spot] and probably work fine. in editor we just read project name. if no name somehow then just some default. i think that would work |
I don't know any ways to access the name of the project in the editor via extensions, it might even just be impossible. The URL sounds fine, but you will lose your data when the url changes, and you would have to restore or remove it manually. To be truly unexploitable and safe, the project should have a unique and an independent parameter, that is also accesible to the extension, basically project ID but turbowarp doesn't have that. |
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.
requested by mistake?
urls changing is pretty unlikely, especially for a static file |
You can add a block (local ID[ID]) and that is the ID for the project. Really easy to use and make. |
Those keys arent saved on the whole turbowarp.org, they are too, saved on slash domains like: turbowarp.org/834792364, so it well save those keys on specific domains, it won't cause any issues. |
I'm agreeing with you |
This might still introduce collision |
Unfortunately, you can't upload projects with custom extensions on scratch, so slash domains are not an option |
I had never mentioned scratch in the comment, I even used turbowarp links. |
Those slash domains have own localStorage. They won't collide with other projects. turbowarp.org/1 has own, and turbowarp.org/2 has completely own localStorage too. |
I think the path forward is to add some API to the VM that lets the extension figure out the project ID. In the packager any projects with the same ID on the same domain will share local cloud variables; I think we want to copy that here. |
You can't store a project on a turbowarp's slash domain if it is not on scratch under the same ID |
Turbowarp links are connected with scratch project IDs |
Aaaa, okay. |
Well that tells that we cant have localStorage then. You can probably close the case/issue. |
Or we can
|
It could be the solution... |
That's a good one. |
is it possible to store a value in a project via an extension without creating a scratch variable? if so, maybe you could generate a UUID for the project once the extension is loaded, and store keys based on that. |
@GarboMuffin, let’s close this case, doesn’t look like it’s active anymore. I don't think there are any solutions for adding stable local storage to turbowarp as an extension. |
Let's leave this open |
if the extension generates a UUID for the project file (or better yet uses the timestamp the extension was installed at to guarantee no conflict) and save keys via |
Nice! took a while but we got it finally, major W [been busy so I haven't taken a look in a while] |
Basically just a wrapper for it but it's simple and works well enough