RangerMauve / webrun

Run Web-first ESM modules outside of the browser
https://webrun-presentation.hashbase.io/
MIT License
77 stars 8 forks source link

Missing sessionStorage #3

Closed allain closed 5 years ago

allain commented 6 years ago

Would work like localStorage but would be bound to the process.id of the shell used to run the script.

RangerMauve commented 6 years ago

What about making it in-memory and having it clear after it runs?

allain commented 6 years ago

Yeah, that's an option. When using sessionStorage in the browser it normally persists even between invocations, the closest thing I could think of to this in a server context is to tie it to the process doing the invocation.

RangerMauve commented 6 years ago

You mean tha parent of the webrun process?

allain commented 6 years ago

Yeah. Opening a new shell would create a new session.

RangerMauve commented 6 years ago

Yeah, I love it!

Maybe the logic could be something like:

allain commented 6 years ago

Fixed. Stores session data in /tmp/.webrun/session-${process.ppid}.

RangerMauve commented 6 years ago

Would you mind adding some logic to make it work cross platform? (windows)

Ideally temporary folders should use fs.mkdtemp

allain commented 6 years ago

I think the latest fixes make this work on Windows (untested though), and using fs.mkdtemp() wouldn't allow for other processes to access the directory since it "Generates six random characters to be appended behind a required prefix".

Close this?