Closed guest271314 closed 1 year ago
Are ServiceWorkers even a reasonable thing for WinterCG to support? I don't believe they're supported now.
Sure.
Just look at how Deno emulates the ServiceWorker
onfetch
handler https://github.com/guest271314/native-messaging-espeak-ng/blob/deno-server/deno_server.js
requestEvent.respondWith(
new Response(body, {
headers: {
'Content-Type': requestEvent.request.method === 'POST' ? 'audio/wav' : 'application/octet-stream',
'Cross-Origin-Opener-Policy': 'unsafe-none',
'Cross-Origin-Embedder-Policy': 'unsafe-none',
'Access-Control-Allow-Origin': '*',
'Content-Security-Policy': 'treat-as-public-address',
//'Access-Control-Request-Private-Network': 'true',
'Access-Control-Allow-Private-Network': 'true',
'Access-Control-Allow-Headers':
'Access-Control-Request-Private-Network',
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET,HEAD',
},
})
);
The concept is to solve https://github.com/GoogleChrome/chrome-extensions-samples/issues/766.
Whereas I created several workarounds which are close to the requirement, yet each lacks completely fulfilling the requirement.
We should not have to create an HTML document or open a new Window
just to transfer data from a ServiceWorker
to an arbitrary Web page. We should be able to use Transferable objects and Transferable Streams.
file:
protocol https://github.com/guest271314/offscreen-webrtc;Window
will flash for a fraction of a second before the active document gains focus, a distraction https://github.com/guest271314/sw-transfer-stream;This is not currently in scope for wintercg.
Explainer https://github.com/guest271314/requestClient