aklinker1 / webext-core

Collection of essential libraries and tools for building web extensions
https://webext-core.aklinker1.io
MIT License
96 stars 11 forks source link

chore(messaging): Share messaging logic and types for more implementations #28

Closed aklinker1 closed 1 year ago

aklinker1 commented 1 year ago

Overview

Refactor to make #27 easier to implement. I'm now shared all the defineMessenger logic and types.

devnomic commented 1 year ago

I think maybe it's better to add namespace option in defineWindowMessaging to prevent collision with other ext.

aklinker1 commented 1 year ago

I can add that.

aklinker1 commented 1 year ago

I think maybe it's better to add namespace option in defineWindowMessaging to prevent collision with other ext.

I'm just going to use browser.runtime.id internally for this. It should be unique across extensions on all browsers, preventing accidental communication. @devnomic with that, do you still think a namespace option for defineWindowMessenger is required?

Edit: Unless you want to communicate with other extensions, that would disallow that. I think I'll add an optional namespace option that defaults to browser.runtime.id, but it can be overrided to something else if needed. That should cover all cases.

devnomic commented 1 year ago

I think maybe it's better to add namespace option in defineWindowMessaging to prevent collision with other ext.

I'm just going to use browser.runtime.id internally for this. It should be unique across extensions on all browsers, preventing accidental communication. @devnomic with that, do you still think a namespace option for defineWindowMessenger is required?

Edit: Unless you want to communicate with other extensions, that would disallow that. I think I'll add an optional namespace option that defaults to browser.runtime.id, but it can be overrided to something else if needed. That should cover all cases.

Yeah that would be the best.

aklinker1 commented 1 year ago

Pulled the new messengers features out into #33