Initial proof of concept

This commit is contained in:
Jakub 2026-07-07 21:47:41 +08:00
parent b80602e230
commit 85e9e1f5f1
8 changed files with 101 additions and 0 deletions

2
.dir-locals.el Normal file
View file

@ -0,0 +1,2 @@
((nil . ((geiser-mode-auto-p . nil)
(geiser-mode-start-repl-p . nil))))

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*~

15
app.scm Normal file
View file

@ -0,0 +1,15 @@
(define root document.body)
(define click-count 0)
(m.mount
root
`&(:view
,(lambda ()
(m "main"
(vector
(m "h1" "LIPS! PWA!")
(m "button"
`&(:onclick
,(lambda () (set! click-count (+ click-count 1))))
(format "~a clicks" click-count)))))))

BIN
icon-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
icon-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

29
index.html Normal file
View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>LIPS PWA</title>
<link rel="manifest" href="/manifest.json"/>
</head>
<body>
<!-- Load the scheme interpreter -->
<script src="https://cdn.jsdelivr.net/npm/lips@beta/dist/lips.min.js" bootstrap></script>
<!-- Mithril -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/2.2.2/mithril.min.js"></script>
<!-- Load the application code -->
<script type="text/x-scheme" src="/app.scm"></script>
<!-- Load the service worker -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
console.log('ServiceWorker registration failed: ', err);
});
});
}
</script>
</body>
</html>

21
manifest.json Normal file
View file

@ -0,0 +1,21 @@
{
"short_name": "PWA",
"name": "LIPS PWA Experiment",
"description": "A PWA built with LIPS Scheme.",
"start_url": "/",
"display": "standalone",
"theme_color": "black",
"background_color": "white",
"icons": [
{
"src": "icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

33
sw.js Normal file
View file

@ -0,0 +1,33 @@
const CACHE_NAME = 'lips-pwa';
const urlsToCache = ['/',
'/index.html',
'/app.scm',
'/manifest.json',
'https://cdn.jsdelivr.net/npm/lips@beta/dist/lips.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/mithril/2.2.2/mithril.min.js'];
// Install event: cache the assets
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
// Fetch event: serve cached assets when offline
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
// Cache hit - return the response
if (response) {
return response;
}
// Otherwise, fetch from network
return fetch(event.request);
})
);
});