cookie and pwa stuff

This commit is contained in:
yohlo
2026-02-14 12:59:01 -06:00
parent 236fcda671
commit 6e9e014fcc
11 changed files with 180 additions and 24 deletions

View File

@@ -46,7 +46,7 @@ class Logger {
constructor(context?: string, options: LoggerOptions = {}) {
this.context = context;
this.options = {
enabled: import.meta.env.NODE_ENV !== "production",
enabled: true,
showTimestamp: true,
collapsed: true,
colors: true,
@@ -75,27 +75,44 @@ class Logger {
const groupLabel = `${timestamp}${style.label}${context}${label}`;
const group = this.options.collapsed
? console.groupCollapsed
: console.group;
// In server environment (no window), use simple console.log instead of groups
const isServer = typeof window === "undefined";
if (this.options.colors && typeof window !== "undefined") {
group(`%c${groupLabel}`, `color: ${style.color}; font-weight: bold;`);
} else {
group(groupLabel);
}
if (data !== undefined) {
console.log(data);
}
if (rest.length > 0) {
for (const item of rest) {
console.log(item);
if (isServer) {
// Server-side: Simple formatted output (no console.group in Node.js)
console.log(groupLabel);
if (data !== undefined) {
console.log(JSON.stringify(data, null, 2));
}
}
if (rest.length > 0) {
for (const item of rest) {
console.log(JSON.stringify(item, null, 2));
}
}
} else {
// Browser: Use console.group with colors
const group = this.options.collapsed
? console.groupCollapsed
: console.group;
console.groupEnd();
if (this.options.colors) {
group(`%c${groupLabel}`, `color: ${style.color}; font-weight: bold;`);
} else {
group(groupLabel);
}
if (data !== undefined) {
console.log(data);
}
if (rest.length > 0) {
for (const item of rest) {
console.log(item);
}
}
console.groupEnd();
}
}
info(label: string, data?: any, ...rest: any[]): void {