summaryrefslogtreecommitdiff
path: root/common/broadcast.js
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2021-12-22 16:39:34 +0100
committerWojtek Kosior <koszko@koszko.org>2021-12-22 16:39:34 +0100
commitb590eaa2f64ead3384eadc6fe58f6358aa1a0478 (patch)
tree8f1e9403c1a75246c2a9a0afc4ab30706ea7afbe /common/broadcast.js
parentb7378a9994724750198e0d165c575be8538334fb (diff)
downloadbrowser-extension-b590eaa2f64ead3384eadc6fe58f6358aa1a0478.tar.gz
browser-extension-b590eaa2f64ead3384eadc6fe58f6358aa1a0478.zip
reworked build system; added missing license notices
Diffstat (limited to 'common/broadcast.js')
-rw-r--r--common/broadcast.js29
1 files changed, 12 insertions, 17 deletions
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