mirror of
https://github.com/varkor/quiver.git
synced 2024-09-11 05:46:13 +03:00
Add manifest and offline mode
This commit is contained in:
parent
4a5f197691
commit
90d8045d88
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
||||
src/KaTeX/*
|
||||
src/icon-*.png
|
||||
src/workbox-*
|
||||
src/service-worker.js*
|
||||
|
26
Makefile
26
Makefile
@ -3,14 +3,36 @@
|
||||
# Ensure `cd` works properly by forcing everything to be executed in a single shell.
|
||||
.ONESHELL:
|
||||
|
||||
# Build KaTeX.
|
||||
all:
|
||||
# Note: the order matters; the service worker must be built last to have a complete assets
|
||||
# precaching manifest.
|
||||
all: src/KaTeX src/icon-192.png src/icon-512.png src/workbox-window.prod.mjs src/service-worker.js
|
||||
|
||||
# Vendor KaTeX dependencies.
|
||||
src/KaTeX:
|
||||
set -e
|
||||
curl -L -O "https://github.com/KaTeX/KaTeX/releases/download/v0.16.4/katex.zip"
|
||||
unzip katex.zip
|
||||
rm katex.zip
|
||||
mv katex src/KaTeX
|
||||
|
||||
# Vendor any workbox dependency.
|
||||
src/workbox-%:
|
||||
mkdir -p $(@D)
|
||||
curl -L -o $@ https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-$*
|
||||
curl -L -o $@.map https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-$*.map
|
||||
|
||||
# Build service worker.
|
||||
src/service-worker.js: service-worker/build.js
|
||||
cd $(dir $<)
|
||||
. $$NVM_DIR/nvm.sh
|
||||
nvm use 20 && npm install && node build.js
|
||||
|
||||
# Generate icons required by the webapp manifest. Requires ImageMagick.
|
||||
src/icon-512.png: src/icon.png
|
||||
convert $< -background none -resize 512x512 $@
|
||||
src/icon-192.png: src/icon.png
|
||||
convert $< -background none -resize 192x192 $@
|
||||
|
||||
# Update the `dev` branch from `master`.
|
||||
dev:
|
||||
set -e
|
||||
|
1
service-worker/.gitignore
vendored
Normal file
1
service-worker/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
18
service-worker/build.js
Normal file
18
service-worker/build.js
Normal file
@ -0,0 +1,18 @@
|
||||
const { generateSW } = require("workbox-build");
|
||||
|
||||
generateSW({
|
||||
globDirectory: "../src/",
|
||||
globPatterns: ["**/*"],
|
||||
swDest: "../src/service-worker.js",
|
||||
}).then(({ count, size, warnings }) => {
|
||||
if (warnings.length > 0) {
|
||||
console.warn(
|
||||
"Warnings encountered while generating a service worker:",
|
||||
warnings.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Generated a service worker, which will precache ${count} files, totaling ${size} bytes.`
|
||||
);
|
||||
});
|
4474
service-worker/package-lock.json
generated
Normal file
4474
service-worker/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
5
service-worker/package.json
Normal file
5
service-worker/package.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"workbox-build": "^7.0.0"
|
||||
}
|
||||
}
|
@ -42,6 +42,13 @@
|
||||
<script type="text/javascript" src="arrow.js"></script>
|
||||
<script type="text/javascript" src="parser.js"></script>
|
||||
<script type="text/javascript" src="ui.js"></script>
|
||||
<!-- Web app manifest -->
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<!-- Service worker -->
|
||||
<script type="module">
|
||||
import { Workbox } from "./workbox-window.prod.mjs";
|
||||
if ("serviceWorker" in navigator) new Workbox("service-worker.js").register();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a id="logo-link" href="https://github.com/varkor/quiver" target="_blank">
|
||||
|
20
src/manifest.json
Normal file
20
src/manifest.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "quiver",
|
||||
"description": "A modern commutative diagram editor.",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#1a1a1a",
|
||||
"background_color": "#ffffff",
|
||||
"icons": [
|
||||
{
|
||||
"src": "icon-192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "icon-512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user