munshkr / flok

Web-based P2P collaborative editor for live coding sounds and images
https://flok.cc
GNU General Public License v3.0
263 stars 40 forks source link

Sandbox web languages using iframes #268

Closed munshkr closed 7 months ago

munshkr commented 7 months ago

Fixes #239

Load web libraries in separate pages and embed them using iframes. This way, these libraries do not pollute the global Window from the session page and there are no collisions between the globals each library define.

Incidentally, this also fixes #193: Because the web language libraries are only loaded inside the iframe and thus in a separate JS context, when unloading the Iframe DOM element, sound and visuals stop.

Strudel also adds some extensions to the Codemirror editor and has an animation frame to update decorators. For some reason, these updates need to run in the same context as the editor, and can't be modified from within the Iframe page.

tmhglnd commented 7 months ago

I would have to investigate but currently mercury-web throws a mercury error randomly when you evaluate but there is no clear indication why/where it is coming from and the code is actually still working and sound is running.

munshkr commented 7 months ago

I would have to investigate but currently mercury-web throws a mercury error randomly when you evaluate but there is no clear indication why/where it is coming from and the code is actually still working and sound is running.

Ah, yes, I know what this is about. Will fix it soon.

munshkr commented 7 months ago

@tmhglnd fixed now

tmhglnd commented 7 months ago

Yes all good now!

tmhglnd commented 7 months ago

Ah I spoke a bit too soon. Because now the m variable in Hydra that I made global for mercury audio analysis doesn't seem to work anymore. It gives ReferenceError: m is not defined

Edit: I see you already made an issue for this in #272

munshkr commented 7 months ago

Ah I spoke a bit too soon. Because now the m variable in Hydra that I made global for mercury audio analysis doesn't seem to work anymore. It gives ReferenceError: m is not defined

Edit: I see you already made an issue for this in #272

Ouch, I knew I was forgetting something. Yes, I noticed about this (was thinking of another case..), but I was planning on solving this in #272