Compare commits
8 Commits
3f771bf7b0
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
755f46a66c | ||
|
|
83f3b45d6e | ||
|
|
4f957d4da6 | ||
|
|
f6360edef3 | ||
|
|
28fc22fcd8 | ||
|
|
c881d660e2 | ||
|
|
90287e098e | ||
|
|
1d4cae35a5 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "scan-wave",
|
"name": "scan-wave",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await authManager.checkConnection();
|
await authManager.checkConnection();
|
||||||
|
if (authState.isConnected && authState.token) {
|
||||||
|
onSuccess?.(authState.token);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
async function handleConnect() {
|
async function handleConnect() {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { google } from 'googleapis';
|
import { google } from 'googleapis';
|
||||||
import { getAuthenticatedClient } from '../auth/server.js';
|
import { getAuthenticatedClient } from '../auth/server.js';
|
||||||
import { GoogleSheet } from './types.ts';
|
import { GoogleSheet } from './types';
|
||||||
|
|
||||||
// Type for sheet data
|
// Type for sheet data
|
||||||
export interface SheetData {
|
export interface SheetData {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<h1 class="text-3xl font-bold text-center mb-2">ScanWave</h1>
|
<h1 class="text-3xl font-bold text-center mb-2">ScanWave</h1>
|
||||||
<h2 class="text-lg text-gray-600 text-center mb-8">Make entrance to your events a breeze.</h2>
|
<h2 class="text-lg text-gray-600 text-center mb-8">Make entrance to your events a breeze.</h2>
|
||||||
<div class="flex space-x-4 w-full justify-center">
|
<div class="flex space-x-4 w-full justify-center">
|
||||||
<a href="/private/home" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300 w-64 text-center transition">
|
<a href="/private/home" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-8 rounded-full shadow-none border border-gray-300 w-64 text-center transition" data-sveltekit-reload>
|
||||||
Get started
|
Get started
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="border-b border-gray-300 bg-gray-50 p-2 text-gray-900">
|
<nav class="border-b border-gray-300 bg-gray-50 p-2 text-gray-900">
|
||||||
<div class="container mx-auto max-w-2xl p-2">
|
<div class="container mx-auto max-w-4xl p-2">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<a href="/private/home" class="text-lg font-bold" aria-label="ScanWave Home">ScanWave</a>
|
<a href="/private/home" class="text-lg font-bold" aria-label="ScanWave Home">ScanWave</a>
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
<div class="container mx-auto max-w-2xl bg-white p-2">
|
<div class="container mx-auto max-w-4xl bg-white p-2">
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
{$debouncedSearch ? `Search Results: "${$debouncedSearch}"` : 'All Events'}
|
{$debouncedSearch ? `Search Results: "${$debouncedSearch}"` : 'All Events'}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 max-w-2xl mx-auto mb-10">
|
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 mx-auto mb-10">
|
||||||
{#if isLoading}
|
{#if isLoading}
|
||||||
<!-- Loading placeholders -->
|
<!-- Loading placeholders -->
|
||||||
{#each Array(4) as _}
|
{#each Array(4) as _}
|
||||||
|
|||||||
@@ -1,87 +1,66 @@
|
|||||||
|
/// <reference lib="webworker" />
|
||||||
/// <reference types="@sveltejs/kit" />
|
/// <reference types="@sveltejs/kit" />
|
||||||
import { build, files, version } from '$service-worker';
|
import { build, files, version } from '$service-worker';
|
||||||
|
|
||||||
// Create a unique cache name for this deployment
|
declare const self: ServiceWorkerGlobalScope;
|
||||||
const CACHE = `cache-${version}`;
|
|
||||||
|
|
||||||
|
const CACHE = `cache-${version}`;
|
||||||
const ASSETS = [
|
const ASSETS = [
|
||||||
...build, // the app itself
|
...build,
|
||||||
...files // everything in `static`
|
...files
|
||||||
];
|
];
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event: ExtendableEvent) => {
|
||||||
// Create a new cache and add all files to it
|
const addFilesToCache = async () => {
|
||||||
async function addFilesToCache() {
|
const cache = await caches.open(CACHE);
|
||||||
const cache = await caches.open(CACHE);
|
await cache.addAll(ASSETS);
|
||||||
await cache.addAll(ASSETS);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
event.waitUntil(addFilesToCache());
|
console.log(`[SW] Installing new service worker, cache name: ${CACHE}`);
|
||||||
|
|
||||||
|
event.waitUntil(addFilesToCache());
|
||||||
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('activate', (event) => {
|
self.addEventListener('activate', (event: ExtendableEvent) => {
|
||||||
// Remove previous cached data from disk
|
const deleteOldCaches = async () => {
|
||||||
async function deleteOldCaches() {
|
for (const key of await caches.keys()) {
|
||||||
for (const key of await caches.keys()) {
|
if (key !== CACHE) await caches.delete(key);
|
||||||
if (key !== CACHE) await caches.delete(key);
|
console.log("[SW] Removing old service worker")
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
event.waitUntil(deleteOldCaches());
|
event.waitUntil(deleteOldCaches());
|
||||||
|
self.clients.claim();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('fetch', (event) => {
|
self.addEventListener('fetch', (event: FetchEvent) => {
|
||||||
// ignore POST requests etc
|
if (event.request.method !== 'GET') return;
|
||||||
if (event.request.method !== 'GET') return;
|
|
||||||
|
|
||||||
async function respond() {
|
// For navigation requests, always fetch from the network to ensure
|
||||||
const url = new URL(event.request.url);
|
// server-side authentication checks are performed.
|
||||||
|
if (event.request.mode === 'navigate') {
|
||||||
|
event.respondWith(fetch(event.request));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Skip caching for auth routes
|
// For other requests (e.g., static assets), use a cache-first strategy.
|
||||||
if (url.pathname.startsWith('/auth/')) {
|
const respond = async () => {
|
||||||
return fetch(event.request);
|
const cache = await caches.open(CACHE);
|
||||||
}
|
|
||||||
|
|
||||||
const cache = await caches.open(CACHE);
|
const cachedResponse = await cache.match(event.request);
|
||||||
|
if (cachedResponse) {
|
||||||
|
return cachedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
// `build`/`files` can always be served from the cache
|
try {
|
||||||
if (ASSETS.includes(url.pathname)) {
|
return await fetch(event.request);
|
||||||
const response = await cache.match(url.pathname);
|
} catch {
|
||||||
|
// If the network fails, and it's not in the cache, it will fail,
|
||||||
|
// which is the expected behavior for non-navigation requests.
|
||||||
|
return new Response('Not found', { status: 404 });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (response) {
|
event.respondWith(respond());
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for everything else, try the network first, but
|
|
||||||
// fall back to the cache if we're offline
|
|
||||||
try {
|
|
||||||
const response = await fetch(event.request);
|
|
||||||
|
|
||||||
// if we're offline, fetch can return a value that is not a Response
|
|
||||||
// instead of throwing - and we can't pass this non-Response to respondWith
|
|
||||||
if (!(response instanceof Response)) {
|
|
||||||
throw new Error('invalid response from fetch');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do not cache private pages
|
|
||||||
if (response.status === 200 && !url.pathname.startsWith('/private')) {
|
|
||||||
cache.put(event.request, response.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
} catch (err) {
|
|
||||||
const response = await cache.match(event.request);
|
|
||||||
|
|
||||||
if (response) {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if there's no cache, then just error out
|
|
||||||
// as there is nothing we can do to respond to this request
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.respondWith(respond());
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user