summaryrefslogtreecommitdiff
path: root/common/storage_light.js
diff options
context:
space:
mode:
Diffstat (limited to 'common/storage_light.js')
-rw-r--r--common/storage_light.js39
1 files changed, 18 insertions, 21 deletions
diff --git a/common/storage_light.js b/common/storage_light.js
index a315858..9ec3020 100644
--- a/common/storage_light.js
+++ b/common/storage_light.js
@@ -41,14 +41,10 @@
* proprietary program, I am not going to enforce this in court.
*/
-/*
- * IMPORTS_START
- * IMPORT TYPE_PREFIX
- * IMPORT raw_storage
- * IMPORT is_mozilla
- * IMPORT observables
- * IMPORTS_END
- */
+#IMPORT common/storage_raw.js AS raw_storage
+#IMPORT common/observables.js
+
+#FROM common/stored_types.js IMPORT TYPE_PREFIX
const reg_spec = new Set(["\\", "[", "]", "(", ")", "{", "}", ".", "*", "+"]);
const escape_reg_special = c => reg_spec.has(c) ? "\\" + c : c;
@@ -80,6 +76,7 @@ function listen(callback, prefix, name)
by_name.set(name, name_reg);
}
}
+#EXPORT listen
function no_listen(callback, prefix, name)
{
@@ -103,11 +100,16 @@ function no_listen(callback, prefix, name)
if (by_prefix.size === 0)
listeners_by_callback.delete(callback);
}
+#EXPORT no_listen
function storage_change_callback(changes, area)
{
- if (is_mozilla && area !== "local")
- {console.log("area", area);return;}
+#IF MOZILLA
+ if (area !== "local") {
+ console.warn("change in storage area", area);
+ return;
+ }
+#ENDIF
for (const item of Object.keys(changes)) {
for (const [callback, by_prefix] of listeners_by_callback.entries()) {
@@ -144,22 +146,17 @@ async function observe(prefix, name)
return observable;
}
+#EXPORT observe
-const observe_var = name => observe(TYPE_PREFIX.VAR, name);
+#EXPORT name => observe(TYPE_PREFIX.VAR, name) AS observe_var
function no_observe(observable)
{
no_listen(...created_observables.get(observable) || []);
created_observables.delete(observable);
}
+#EXPORT no_observe
-const light_storage = {};
-Object.assign(light_storage, raw_storage);
-Object.assign(light_storage,
- {listen, no_listen, observe, observe_var, no_observe});
-
-/*
- * EXPORTS_START
- * EXPORT light_storage
- * EXPORTS_END
- */
+#EXPORT raw_storage.set AS set
+#EXPORT raw_storage.set_var AS set_var
+#EXPORT raw_storage.get_var AS get_var