summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Makefile20
-rw-r--r--src/content/service-worker.js8
-rw-r--r--src/content/sw.js8
-rw-r--r--src/sw-main.js5
5 files changed, 18 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 21335e8..8787e69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-/src/sw-pre.js
+/src/content/images.js
/src/content/papo.exported.js
/src/content/sw.exported.js
-/src/content/service-worker.js
diff --git a/Makefile b/Makefile
index f1e01eb..11547c6 100644
--- a/Makefile
+++ b/Makefile
@@ -42,15 +42,16 @@ contents = \
src/content/papo.js \
src/content/style.css \
src/content/index.html \
+ src/content/sw.js \
+ src/content/images.js \
src/content/service-worker.js \
$(img.svg) \
derived-assets = \
- src/sw-pre.js \
+ src/content/images.js \
src/content/papo.exported.js \
src/content/sw.exported.js \
- src/content/service-worker.js \
side-assets = \
@@ -60,17 +61,10 @@ side-assets = \
## and installation.
all: $(derived-assets)
-src/sw-pre.js: Makefile deps.mk
+src/content/images.js: Makefile deps.mk
printf 'const IMG_PATHS = [\n' > $@
printf '\t"%s",\n' $(img.svg) >> $@
- printf '];\n\n' >> $@
-
-## The use of static `import` statements inside service workers
-## isn't supported. So in order to have tests for the code in
-## it, a "main()" function is included in the generated file
-## so that is can be ran as a standalone file.
-src/content/service-worker.js: src/sw-pre.js src/content/sw.js src/sw-main.js
- tail -n+2 src/content/sw.js | cat src/sw-pre.js - src/sw-main.js > $@
+ printf '];\n' >> $@
src/content/papo.exported.js src/content/sw.exported.js: \
Makefile src/exported.sh
@@ -88,11 +82,7 @@ tests/sw.js-check: src/content/sw.exported.js
tests/papo.js-check tests/sw.js-check:
node tests/node-driver.js $*.js
-src/content/service-worker.js-check: src/content/service-worker.js
- test "`grep -c '^const IMG_PATHS ' $*.js`" = 1
-
check-unit: tests/papo.js-check tests/sw.js-check
-check-unit: src/content/service-worker.js-check
integration-tests = \
diff --git a/src/content/service-worker.js b/src/content/service-worker.js
new file mode 100644
index 0000000..1afe76c
--- /dev/null
+++ b/src/content/service-worker.js
@@ -0,0 +1,8 @@
+importScripts("sw.js", "images.js");
+
+main({
+ self,
+ caches,
+ clients,
+ IMG_PATHS,
+});
diff --git a/src/content/sw.js b/src/content/sw.js
index 51089f2..c86cb43 100644
--- a/src/content/sw.js
+++ b/src/content/sw.js
@@ -1,5 +1,3 @@
-const IMG_PATHS = [];
-
const CACHE_NAME = "static-shared-assets";
const leafValues = tree =>
@@ -114,7 +112,7 @@ const STRATEGIES = [
"index.html",
"style.css",
"papo.js",
- ...IMG_PATHS,
+ // ...IMG_PATHS,
]),
},
{
@@ -211,7 +209,8 @@ const main = ({
clients,
out = console.log,
err = console.warn,
-} = {}) =>
+} = {}) => {
+ return; // FIXME
registerListeners({
self,
caches,
@@ -220,6 +219,7 @@ const main = ({
out,
err,
});
+};
// handy resources for pushes:
// https://web.dev/articles/offline-cookbook
diff --git a/src/sw-main.js b/src/sw-main.js
deleted file mode 100644
index be45ba4..0000000
--- a/src/sw-main.js
+++ /dev/null
@@ -1,5 +0,0 @@
-main({
- self,
- caches,
- clients,
-});