From b590eaa2f64ead3384eadc6fe58f6358aa1a0478 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 22 Dec 2021 16:39:34 +0100 Subject: reworked build system; added missing license notices --- common/broadcast.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'common/broadcast.js') diff --git a/common/broadcast.js b/common/broadcast.js index cc11a20..b69f352 100644 --- a/common/broadcast.js +++ b/common/broadcast.js @@ -41,11 +41,9 @@ * proprietary program, I am not going to enforce this in court. */ -/* - * IMPORTS_START - * IMPORT CONNECTION_TYPE - * IMPORTS_END - */ +#IMPORT common/connection_types.js AS CONNECTION_TYPE + +#FROM common/browser.js IMPORT browser function sender_connection() { @@ -53,11 +51,13 @@ function sender_connection() port: browser.runtime.connect({name: CONNECTION_TYPE.BROADCAST_SEND}) }; } +#EXPORT sender_connection function out(sender_conn, channel_name, value) { sender_conn.port.postMessage(["broadcast", channel_name, value]); } +#EXPORT out /* * prepare()'d message will be broadcasted if the connection is closed or when @@ -77,16 +77,19 @@ function prepare(sender_conn, channel_name, value, timeout=5000) { sender_conn.port.postMessage(["prepare", channel_name, value, timeout]); } +#EXPORT prepare function discard(sender_conn) { sender_conn.port.postMessage(["discard"]); } +#EXPORT discard function flush(sender_conn) { sender_conn.port.postMessage(["flush"]); } +#EXPORT flush function listener_connection(cb) { @@ -98,30 +101,22 @@ function listener_connection(cb) return conn; } +#EXPORT listener_connection function subscribe(listener_conn, channel_name) { listener_conn.port.postMessage(["subscribe", channel_name]); } +#EXPORT subscribe function unsubscribe(listener_conn, channel_name) { listener_conn.port.postMessage(["unsubscribe", channel_name]); } +#EXPORT unsubscribe function close(conn) { conn.port.disconnect(); } - -const broadcast = { - sender_connection, out, prepare, discard, flush, - listener_connection, subscribe, unsubscribe, - close -}; - -/* - * EXPORTS_START - * EXPORT broadcast - * EXPORTS_END - */ +#EXPORT close -- cgit v1.2.3