@moudrey/fluxa-chrome
v0.0.1
Published
Fluxa plugin for Chrome extension transport.
Maintainers
Readme
@moudrey/fluxa-chrome
Fluxa transport plugin for Chrome extensions. It lets extension surfaces share Fluxa events through chrome.runtime.sendMessage, chrome.runtime.onMessage, and chrome.tabs.sendMessage.
This is intended for MV3 extension UIs such as side panels, popups, extension pages, service workers, and content scripts.
Install
npm install @moudrey/fluxa-core @moudrey/fluxa-chromeUsage
import { Fluxa } from "@moudrey/fluxa-core";
import { chromePlugin } from "@moudrey/fluxa-chrome";
type Events = {
"profile:capture": { name: string; company?: string };
"call:start": { prospectId: string };
};
const bus = new Fluxa<Events>({
context: { id: "side-panel" },
plugins: [
chromePlugin<Events>({
channel: "tahaak-extension",
targets: "runtime",
}),
],
});
bus.emit("call:start", { prospectId: "prospect_123" });Send To The Active Tab
chromePlugin<Events>({
channel: "tahaak-extension",
targets: "activeTab",
});Send To A Specific Tab
chromePlugin<Events>({
channel: "tahaak-extension",
targets: [{ type: "tab", tabId: 123 }],
});Dynamic Routing
chromePlugin<Events>({
channel: "tahaak-extension",
targets: (event) => {
if (event === "call:start") return "activeTab";
return "runtime";
},
});Options
channel: Logical message channel. Defaults tofluxa.targets: Outbound target or target resolver. Defaults toruntime.direction:in,out, orboth. Defaults toboth.filter: Allows or blocks events before sending or receiving.maxHops: Prevents routing loops. Defaults to8.runtime: Custom runtime implementation for tests or non-Chrome adapters.tabs: Custom tabs implementation for tests or non-Chrome adapters.serialize/deserialize: Override the envelope format.
Notes
The plugin intentionally uses one-off Chrome messages. Long-lived runtime.connect ports can be added later for lifecycle-heavy workflows such as live call sessions, reconnect behavior, or streaming state.
Repository
https://github.com/janMoudry/fluxa-chrome
