Open steely-glint opened 1 month ago
Good point. The current specification defines the API to be available in both the Window and Worker context:
[Exposed=(Window,Worker), SecureContext]
I'm not sure if we need to add anything specific to also expose it in the service worker context. I'd have to do some research on that.
Exposed=Worker
means this API is available in all worker contexts, including dedicated worker, shared worker and service worker, see blow link for details: https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/bindings/IDLExtendedAttributes.md#exposed
Thanks for digging that up @wangw-1991. For me this satisfies the requirement. Let me know if you agree @steely-glint.
Our experience of building similar things in the IoT space with webRTC (cameras, baby monitors etc.) Shows that there is a lot of value in being able to use P2P communications within a service worker. The upper layers do a 'normal' fetch() - but the service worker sends it to a local peer instead of a cloud service - this means the UI code can remain the same for both local/offline and remote/online cases.