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

Add local storage extension #55

Merged
merged 13 commits into from
May 15, 2023
Merged

Conversation

infernostars
Copy link
Contributor

@infernostars infernostars commented Dec 2, 2022

Basically just a wrapper for it but it's simple and works well enough

localStorageExtension.js Outdated Show resolved Hide resolved
@softedco
Copy link
Contributor

softedco commented Dec 7, 2022

Might I suggest adding a remove key block

image

image

That way clearing site's data or interacting with the console is not needed to remove the keys

local-storage.js Outdated Show resolved Hide resolved
local-storage.js Outdated Show resolved Hide resolved
Co-authored-by: !Ryan <[email protected]>
@infernostars
Copy link
Contributor Author

Might I suggest adding a remove key block

image

image

That way clearing site's data or interacting with the console is not needed to remove the keys

To be honest I completely forgot. Thanks!

@GarboMuffin
Copy link
Member

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

@infernostars
Copy link
Contributor Author

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?

@infernostars
Copy link
Contributor Author

then we could do something like prefix:1234567890:value

@softedco
Copy link
Contributor

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?

You can't post projects with custom extensions on scratch right

@CST1229
Copy link
Collaborator

CST1229 commented Dec 11, 2022

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?

You can't post projects with custom extensions on scratch right

No, you can't,

@softedco
Copy link
Contributor

softedco commented Dec 11, 2022

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?

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.

@infernostars
Copy link
Contributor Author

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)

@infernostars
Copy link
Contributor Author

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

@infernostars infernostars requested review from softedco and removed request for GarboMuffin December 11, 2022 23:32
@softedco
Copy link
Contributor

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.

Copy link
Contributor

@softedco softedco left a comment

Choose a reason for hiding this comment

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

requested by mistake?

@infernostars
Copy link
Contributor Author

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.

urls changing is pretty unlikely, especially for a static file

@StioStudio
Copy link

You can add a block (local ID[ID]) and that is the ID for the project. Really easy to use and make.

@nikeedev
Copy link

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

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.

@nikeedev
Copy link

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.

I'm agreeing with you

@softedco
Copy link
Contributor

You can add a block (local ID[ID]) and that is the ID for the project. Really easy to use and make.

This might still introduce collision

@softedco
Copy link
Contributor

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

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.

Unfortunately, you can't upload projects with custom extensions on scratch, so slash domains are not an option

@nikeedev
Copy link

nikeedev commented Dec 23, 2022

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

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.

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.

@nikeedev
Copy link

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.

@GarboMuffin
Copy link
Member

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.

@softedco
Copy link
Contributor

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.

You can't store a project on a turbowarp's slash domain if it is not on scratch under the same ID

@softedco
Copy link
Contributor

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

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.

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.

Turbowarp links are connected with scratch project IDs

@nikeedev
Copy link

Turbowarp links are connected with scratch project IDs

Aaaa, okay.

@nikeedev
Copy link

Turbowarp links are connected with scratch project IDs

Well that tells that we cant have localStorage then. You can probably close the case/issue.

@softedco
Copy link
Contributor

Turbowarp links are connected with scratch project IDs

Well that tells that we cant have localStorage then. You can probably close the case/issue.

Or we can

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.

@nikeedev
Copy link

It could be the solution...

@SIPC
Copy link
Contributor

SIPC commented Feb 13, 2023

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.

That's a good one.

@DT-is-not-available
Copy link
Contributor

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.

@nikeedev
Copy link

@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.

@GarboMuffin
Copy link
Member

Let's leave this open

@DT-is-not-available
Copy link
Contributor

I don't think there are any solutions for adding stable local storage to turbowarp as an extension.

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 localStorage.setItem(UUID+key, value) it would work

@CST1229 CST1229 mentioned this pull request Apr 1, 2023
@GarboMuffin GarboMuffin merged commit 50b6bda into TurboWarp:master May 15, 2023
@infernostars
Copy link
Contributor Author

Nice! took a while but we got it finally, major W [been busy so I haven't taken a look in a while]

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.

8 participants