three.js
                                
                                 three.js copied to clipboard
                                
                                    three.js copied to clipboard
                            
                            
                            
                        SW: Add secure headers and clean up
Fixes https://github.com/mrdoob/three.js/issues/24212
Description
Add the required secure headers to the editor's service worker and clean up it.
@mattrossman Please confirm this works.
I'm testing it here: https://rawcdn.githack.com/LeviPesin/three.js-1/a0f8cbd345e98f3e9ecf3fc1bf922add84d98905/editor/index.html
It isn't working for me.
The FetchEvent for "https://rawcdn.githack.com/LeviPesin/three.js-1/a0f8cbd345e98f3e9ecf3fc1bf922add84d98905/editor/index.html" resulted in a network error response: a Response whose "body" is locked cannot be used to respond to a request.
The trace points to this line:
https://github.com/LeviPesin/three.js-1/blob/a0f8cbd345e98f3e9ecf3fc1bf922add84d98905/editor/sw.js#L257
Perhaps there is some additional code from coi-serviceworker that should be copied over.
Should be fixed now.
Not seeing it on my end: https://rawcdn.githack.com/LeviPesin/three.js-1/9d87837f28a96116bea898506350269f2bf59a8c/editor/index.html

It seems that unpkg does not provide CORP header, so we cannot use COEP: require-corp and should use the new COEP: credentialless.
But it still does not work... I am unsure why.
In my case https://github.com/mattrossman/three.js/commit/bc818a752ae2e3ad13adceaa142608c7c9f56de0 I had to copy the two libs (ffmpeg.wasm and es-module-shims) from unpkg locally. Working demo.
I think @mrdoob should decide should we keep these libs locally, investigate ways to enable the SW to work with cross-origin requests, or just use a non-SharedArrayBuffer version.
Is the non-SharedArrayBuffer version 10x slower or something? 🤔
I think it is exactly number-of-coresX slower, because SharedArrayBuffer allows multithreading. I think we can actually keep the libs like we do with the other libs?
Alright, lets host the libraries then 👍
Done.
Is there something preventing merging this PR?
@mrdoob Can this PR be merged, please?
@mrdoob @Mugen87 Something preventing the merge?
Sorry for the delay!
Thanks!