Merge pull request 'added pwa support' (#1) from feature/Capacitor into dev

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
pablo committed 2025-04-08 12:14:23 +00:00
commit cd8a8d746d
17 files changed
+5097 -27

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
import type { CapacitorConfig } from "@capacitor/cli";
const config: CapacitorConfig = {
appId: "bettersplit.shrt.solutions",
appName: "bettersplit",
webDir: "out",
};
export default config;
+11 -3
View File
@@ -3,8 +3,16 @@
* for Docker builds.
*/
import "./src/env.js";
import pwa from "next-pwa";
import { env } from "./src/env.js";
/** @type {import("next").NextConfig} */
const config = {};
const withPWA = pwa({
dest: "public",
disable: env.NODE_ENV === "development",
register: true, // register the PWA service worker
skipWaiting: true,
});
export default config;
export default withPWA({
eslint: { ignoreDuringBuilds: true },
});
+7 -1
View File
@@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"build": "next build",
"export": "next export",
"check": "biome check .",
"check:unsafe": "biome check --write --unsafe .",
"check:write": "biome check --write .",
@@ -15,10 +16,13 @@
"dev": "next dev --turbo",
"preview": "next build && next start",
"start": "next start",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"android": "pnpm build && pnpm export && pnpm dlx cap sync android && pnpm dlx cap open android"
},
"dependencies": {
"@auth/drizzle-adapter": "^1.7.2",
"@capacitor/cli": "^7.2.0",
"@capacitor/core": "^7.2.0",
"@hookform/resolvers": "^5.0.1",
"@paralleldrive/cuid2": "^2.2.2",
"@radix-ui/react-avatar": "^1.1.3",
@@ -35,6 +39,7 @@
"@trpc/client": "^11.0.0",
"@trpc/react-query": "^11.0.0",
"@trpc/server": "^11.0.0",
"@types/next-pwa": "^5.6.9",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
@@ -42,6 +47,7 @@
"lucide-react": "^0.487.0",
"next": "^15.2.3",
"next-auth": "5.0.0-beta.25",
"next-pwa": "^5.6.0",
"next-themes": "^0.4.6",
"postgres": "^3.4.4",
"react": "^19.0.0",
+4936 -10
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
if(!self.define){let e,s={};const t=(t,a)=>(t=new URL(t+".js",a).href,s[t]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=t,e.onload=s,document.head.appendChild(e)}else e=t,importScripts(t),s()})).then((()=>{let e=s[t];if(!e)throw new Error(`Module ${t} didn’t register its module`);return e})));self.define=(a,n)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let c={};const r=e=>t(e,i),w={module:{uri:i},exports:c,require:r};s[i]=Promise.all(a.map((e=>w[e]||r(e)))).then((e=>(n(...e),c)))}}define(["./workbox-e9849328"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"9ddae6fb651604de7630293119506ed4"},{url:"/_next/static/D_QH_2w1wpvaQUPstb-Bw/_buildManifest.js",revision:"01b09b3e9dda7539be2313c35bd1b563"},{url:"/_next/static/D_QH_2w1wpvaQUPstb-Bw/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/1-af1f1e25dae140be.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/200-1def31964b2356b0.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/23-54b4ab21f3550ebc.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/283-d8ce32dab0aedc01.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/315-7943c6e46aec5d5e.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/323-cfe0cbab1e5ba15a.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/369-b616bc8f00fc0b77.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/427-8d8c459025f4dcb9.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/47edcb22-e33a29a5fce76af4.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/748-db3977eb7f9230bd.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/75-789b1b8b478cf3fd.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/(router)/add/page-a77d7554a2057d55.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/(router)/expense/page-ff0cf84c8ba67037.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/(router)/friend/page-0681de5cb14c92a3.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/(router)/group/page-9b31fbf8a9666021.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/(router)/layout-c185c2070dd928d9.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/(router)/page-644f0b4f976f6a09.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/_not-found/page-50a202315221fd62.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/api/auth/%5B...nextauth%5D/route-c76daf5c74849c0b.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/api/trpc/%5Btrpc%5D/route-3f6b1acc32fca989.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/layout-65f84582b7fce980.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/app/manifest.webmanifest/route-1cba1848fd15aa6a.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/framework-289b5a20f31bf2b1.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/main-094812ef791a00bb.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/main-app-da974a6306d5a606.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/pages/_app-7e5d4a60281b6427.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/pages/_error-77fa64d81664a8ec.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-69c67d16c363604a.js",revision:"D_QH_2w1wpvaQUPstb-Bw"},{url:"/_next/static/css/74d14436e2fb3a38.css",revision:"74d14436e2fb3a38"},{url:"/_next/static/media/569ce4b8f30dc480-s.p.woff2",revision:"ef6cefb32024deac234e82f932a95cbd"},{url:"/_next/static/media/ba015fad6dcf6784-s.woff2",revision:"8ea4f719af3312a055caf09f34c89a77"},{url:"/favicon.ico",revision:"7f98bbc43ba0d1dbf3564adf0821a304"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:s,event:t,state:a})=>s&&"opaqueredirect"===s.type?new Response(s.body,{status:200,statusText:"OK",headers:s.headers}):s}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GETLine truncated
+1
View File
@@ -0,0 +1 @@
define(["exports"],(function(t){"use strict";try{self["workbox:core:6.5.4"]&&_()}catch(t){}const e=(t,...e)=>{let s=t;return e.length>0&&(s+=` :: ${JSON.stringify(e)}`),s};class s extends Error{constructor(t,s){super(e(t,s)),this.name=t,this.details=s}}try{self["workbox:routing:6.5.4"]&&_()}catch(t){}const n=t=>t&&"object"==typeof t?t:{handle:t};class r{constructor(t,e,s="GET"){this.handler=n(e),this.match=t,this.method=s}setCatchHandler(t){this.catchHandler=n(t)}}class i extends r{constructor(t,e,s){super((({url:e})=>{const s=t.exec(e.href);if(s&&(e.origin===location.origin||0===s.index))return s.slice(1)}),e,s)}}class a{constructor(){this.t=new Map,this.i=new Map}get routes(){return this.t}addFetchListener(){self.addEventListener("fetch",(t=>{const{request:e}=t,s=this.handleRequest({request:e,event:t});s&&t.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,s=Promise.all(e.urlsToCache.map((e=>{"string"==typeof e&&(e=[e]);const s=new Request(...e);return this.handleRequest({request:s,event:t})})));t.waitUntil(s),t.ports&&t.ports[0]&&s.then((()=>t.ports[0].postMessage(!0)))}}))}handleRequest({request:t,event:e}){const s=new URL(t.url,location.href);if(!s.protocol.startsWith("http"))return;const n=s.origin===location.origin,{params:r,route:i}=this.findMatchingRoute({event:e,request:t,sameOrigin:n,url:s});let a=i&&i.handler;const o=t.method;if(!a&&this.i.has(o)&&(a=this.i.get(o)),!a)return;let c;try{c=a.handle({url:s,request:t,event:e,params:r})}catch(t){c=Promise.reject(t)}const h=i&&i.catchHandler;return c instanceof Promise&&(this.o||h)&&(c=c.catch((async n=>{if(h)try{return await h.handle({url:s,request:t,event:e,params:r})}catch(t){t instanceof Error&&(n=t)}if(this.o)return this.o.handle({url:s,request:t,event:e});throw n}))),c}findMatchingRoute({url:t,sameOrigin:e,request:s,event:n}){const r=this.t.get(s.method)||[];for(const i of r){let r;const a=i.match({url:t,sameOrigin:e,request:s,event:n});if(a)return r=a,(Array.isArray(r)&&0===r.length||a.constructor===Object&&0===Object.keys(a).length||"boolean"==typeof a)&&(r=void 0),{route:i,params:r}}return{}}setDefaultHandler(t,e="GET"){this.i.set(e,n(t))}setCatchHandler(t){this.o=n(t)}registerRoute(t){this.t.has(t.method)||this.t.set(t.method,[]),this.t.get(t.method).push(t)}unregisterRoute(t){if(!this.t.has(t.method))throw new s("unregister-route-but-not-found-with-method",{method:t.method});const e=this.t.get(t.method).indexOf(t);if(!(e>-1))throw new s("unregister-route-route-not-registered");this.t.get(t.method).splice(e,1)}}let o;const c=()=>(o||(o=new a,o.addFetchListener(),o.addCacheListener()),o);function h(t,e,n){let a;if("string"==typeof t){const s=new URL(t,location.href);a=new r((({url:t})=>t.href===s.href),e,n)}else if(t instanceof RegExp)a=new i(t,e,n);else if("function"==typeof t)a=new r(t,e,n);else{if(!(t instanceof r))throw new s("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});a=t}return c().registerRoute(a),a}try{self["workbox:strategies:6.5.4"]&&_()}catch(t){}const u={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null},l={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:"undefined"!=typeof registration?registration.scope:""},f=t=>[l.prefix,t,l.suffix].filter((t=>t&&t.length>0)).join("-"),w=t=>t||f(l.precache),d=t=>t||f(l.runtime);function p(t,e){const s=new URL(t);for(const t of e)s.searchParams.delete(t);return s.href}class y{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}}const g=new Set;function m(t){return"string"==typeof t?new Request(t):t}class v{constructor(t,e){this.h={},Object.assign(this,e),this.event=e.event,this.u=t,this.l=new y,this.p=[],this.m=[...t.plugins],this.v=new Map;for(const t of this.m)this.v.set(t,{});this.event.waitUntil(this.l.promise)}async fetch(t){const{event:e}=this;let n=m(t);if("navigate"===n.mode&&e instanceof FetchEvent&&e.preloadResponse){const t=await e.preloadResponse;if(t)return t}const r=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const t of this.iterateCallbacks("requestWillFetch"))n=await t({request:n.clone(),event:e})}catch(t){if(t instanceof Error)throw new s("plugin-error-request-will-fetch",{thrownErrorMessage:t.message})}const i=n.clone();try{let t;t=await fetch(n,"navigate"===n.mode?void 0:this.u.fetchOptions);for(const s of this.iterateCallbacks("fetchDidSucceed"))t=await s({event:e,request:i,response:t});return t}catch(t){throw r&&await this.runCallbacks("fetchDidFail",{error:t,event:e,originalRequest:r.clone(),request:i.clone()}),t}}async fetchAndCachePut(t){const e=await this.fetch(t),s=e.clone();return this.waitUntil(this.cachePut(t,s)),e}async cacheMatch(t){const e=m(t);let s;const{cacheName:n,matchOptions:r}=this.u,i=await this.getCacheKey(e,"read"),a=Object.assign(Object.assign({},r),{cacheName:n});s=await caches.match(i,a);for(constLine truncated
+1 -1
View File
@@ -4,7 +4,7 @@ type AppConfig = {
};
export const appConfig: AppConfig = {
name: "Betterwise",
name: "Bettesplit",
navigator: [
{
name: "Home",
+3 -1
View File
@@ -1,11 +1,13 @@
import AddFriendDrawer from "@/app/_components/friend/add-friend-drawer";
import FriendList from "@/app/_components/friend/friend-list";
import Header from "@/components/header";
import { auth } from "@/server/auth";
import { api, HydrateClient } from "@/trpc/server";
import React from "react";
export default async function Page() {
void api.friend.getAll.prefetch();
const session = await auth();
if (session?.user) void api.friend.getAll.prefetch();
return (
<HydrateClient>
@@ -4,13 +4,14 @@ import React from "react";
export default function FriendRequestButton({}: {}) {
return (
<div>
<Button
{/* <Button
variant={requestedBy === "me" ? "destructive" : "outline"}
className="ml-auto"
size="sm"
>
{requestedBy === "me" ? "Cancel" : "Accept"}
</Button>
</Button> */}
friendRequestButton
</div>
);
}
+86
View File
@@ -0,0 +1,86 @@
// "use client";
// import React, { useEffect, useState } from "react";
// export function usePwaInstallStatus() {
// const [isStandalone, setIsStandalone] = useState(false);
// const [isIOS, setIsIOS] = useState(false);
// const [isAndroid, setIsAndroid] = useState(false);
// useEffect(() => {
// const userAgent =
// navigator.userAgent || navigator.vendor || (window as any).opera;
// // iOS detection
// const iOS = /iPad|iPhone|iPod/.test(userAgent) && !(window as any).MSStream;
// setIsIOS(iOS);
// // Android detection
// const android = /android/i.test(userAgent);
// setIsAndroid(android);
// // PWA "standalone" mode detection (works for both iOS & Android)
// const isInStandaloneMode =
// window.matchMedia("(display-mode: standalone)").matches ||
// (navigator as any).standalone === true; // for iOS Safari
// setIsStandalone(isInStandaloneMode);
// }, []);
// return { isIOS, isAndroid, isStandalone };
// }
// function InstallPrompt() {
// const { isIOS, isAndroid, isStandalone } = usePwaInstallStatus();
// const [deferredPrompt, setDeferredPrompt] = useState<any>(null);
// useEffect(() => {
// const handler = (e: any) => {
// e.preventDefault();
// setDeferredPrompt(e);
// };
// window.addEventListener("beforeinstallprompt", handler);
// return () => {
// window.removeEventListener("beforeinstallprompt", handler);
// };
// }, []);
// const handleInstallClick = () => {
// console.log("install clicked");
// if (deferredPrompt) {
// deferredPrompt.prompt();
// deferredPrompt.userChoice.then((choiceResult: any) => {
// if (choiceResult.outcome === "accepted") {
// console.log("User accepted the A2HS prompt");
// } else {
// console.log("User dismissed the A2HS prompt");
// }
// setDeferredPrompt(null);
// });
// }
// };
// if (isStandalone) {
// return null; // Already running as a PWA, no need to show install prompt
// }
// return (
// <div className="absolute w-full h-20 z-50 bg-red-500 left-0 flex items-center justify-center right-0 bottom-0 text-white">
// {isIOS && <p>Tap "Share" and "Add to Home Screen" to install the app.</p>}
// {isAndroid && <button onClick={handleInstallClick}>Install App</button>}
// </div>
// );
// }
// export default function PWAWrapper({
// children,
// }: {
// children: React.ReactNode;
// }) {
// return (
// <>
// <InstallPrompt />
// {children}
// </>
// );
// }
+3
View File
@@ -5,6 +5,7 @@ import { Geist } from "next/font/google";
import { Toaster } from "@/components/ui/sonner";
import { TRPCReactProvider } from "@/trpc/react";
import { ThemeProvider } from "@/components/theme-provider";
// import PWAWrapper from "./_components/install-prompt";
export const metadata: Metadata = {
title: "Create T3 App",
@@ -30,6 +31,8 @@ export default function RootLayout({
enableSystem
disableTransitionOnChange
>
{/* <PWAWrapper>
</PWAWrapper> */}
{children}
<Toaster position="top-center" />
</ThemeProvider>
+26
View File
@@ -0,0 +1,26 @@
import { appConfig } from "@/app.config";
import type { MetadataRoute } from "next";
export default function manifest(): MetadataRoute.Manifest {
return {
name: appConfig.name,
short_name: "NextPWA",
description: "A Progressive Web App built with Next.js",
start_url: "/",
display: "standalone",
background_color: "#ffffff",
theme_color: "#000000",
icons: [
{
src: "/icon-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "/icon-512x512.png",
sizes: "512x512",
type: "image/png",
},
],
};
}
+1 -1
View File
@@ -15,7 +15,7 @@ function NavLink({ href, name, icon }: NavLink) {
asChild
variant={"ghost"}
className={cn(
"p-2 size-12 text-muted-foreground/75 flex flex-col gap-2 ",
"p-2 size-12 text-muted-foreground/75 flex flex-col gap-2 hover:bg-transparent dark:hover:bg-transparent ",
active && "text-foreground "
)}
>
+7 -7
View File
@@ -1,10 +1,10 @@
"use client"
"use client";
import { useTheme } from "next-themes"
import { Toaster as Sonner, ToasterProps } from "sonner"
import { useTheme } from "next-themes";
import { Toaster as Sonner, type ToasterProps } from "sonner";
const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme()
const { theme = "system" } = useTheme();
return (
<Sonner
@@ -19,7 +19,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
}
{...props}
/>
)
}
);
};
export { Toaster }
export { Toaster };
View File
File renamed without changes.
+1
View File
@@ -38,6 +38,7 @@ declare module "next-auth" {
* @see https://next-auth.js.org/configuration/options
*/
export const authConfig = {
trustHost: true,
providers: [
DiscordProvider,
/**
+1 -1
View File
@@ -39,5 +39,5 @@
"**/*.js",
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
"exclude": ["node_modules", "public/sw.js", "public/workbox-*.js"]
}