@mdguggenbichler/slugbase-core 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,6 +52,25 @@ function SharedRedirect() {
52
52
  return <Navigate to={to} replace />;
53
53
  }
54
54
 
55
+ /** Diagnostic: catches errors in login subtree and rethrows with a prefix so cloud boundary shows where the throw came from. */
56
+ class LoginRouteErrorBoundary extends Component<{ children: ReactNode }, { error: Error | null }> {
57
+ state = { error: null as Error | null };
58
+
59
+ static getDerivedStateFromError(raw: unknown): { error: Error } {
60
+ const msg = raw instanceof Error ? raw.message : String(raw);
61
+ return { error: new Error(`[LoginRoute] ${msg || '(no message)'}`) };
62
+ }
63
+
64
+ componentDidCatch(error: unknown, info: React.ErrorInfo) {
65
+ console.error('[Login route boundary]', error, info.componentStack);
66
+ }
67
+
68
+ render() {
69
+ if (this.state.error != null) throw this.state.error;
70
+ return this.props.children;
71
+ }
72
+ }
73
+
55
74
  function AppRoutes() {
56
75
  const { user, loading } = useAuth();
57
76
  const { t } = useTranslation();
@@ -76,7 +95,7 @@ function AppRoutes() {
76
95
  return (
77
96
  <Suspense fallback={<div className="min-h-screen flex items-center justify-center"><div className="text-lg">{t('common.loading')}</div></div>}>
78
97
  <Routes>
79
- <Route path="/login" element={!user ? <Login /> : <Navigate to={appRootPath} replace />} />
98
+ <Route path="/login" element={!user ? <LoginRouteErrorBoundary><Login /></LoginRouteErrorBoundary> : <Navigate to={appRootPath} replace />} />
80
99
  <Route path="/signup" element={!user ? <Signup /> : <Navigate to={appRootPath} replace />} />
81
100
  <Route path="/reset-password" element={<PasswordReset />} />
82
101
  <Route path="/password-reset" element={<PasswordReset />} />
@@ -137,14 +156,16 @@ interface AppErrorFallbackProps {
137
156
  }
138
157
 
139
158
  function AppErrorFallback({ error, onReset }: AppErrorFallbackProps) {
140
- const { t } = useTranslation();
159
+ // Use hardcoded strings so this fallback never throws (e.g. when i18n context is missing in embedded host).
141
160
  const message = error?.message ?? (error != null ? String(error) : '');
142
161
  return (
143
162
  <div className="min-h-screen flex flex-col items-center justify-center gap-4 p-4" role="alert">
144
- <p className="text-lg text-gray-700 dark:text-gray-300 text-center">{t('common.error')}</p>
145
- {message && (
146
- <details className="w-full max-w-md text-sm text-gray-600 dark:text-gray-400" open={import.meta.env?.DEV}>
147
- <summary className="cursor-pointer">{message}</summary>
163
+ <p className="text-lg text-gray-700 dark:text-gray-300 text-center">
164
+ Something went wrong loading this page. Please try again.
165
+ </p>
166
+ {(message || error?.stack) && (
167
+ <details className="w-full max-w-md text-sm text-gray-600 dark:text-gray-400" open>
168
+ <summary className="cursor-pointer">{message || 'Error details'}</summary>
148
169
  {error?.stack && <pre className="mt-2 overflow-auto whitespace-pre-wrap">{error.stack}</pre>}
149
170
  </details>
150
171
  )}
@@ -153,7 +174,7 @@ function AppErrorFallback({ error, onReset }: AppErrorFallbackProps) {
153
174
  onClick={() => (onReset ? onReset() : window.location.reload())}
154
175
  className="px-4 py-2 rounded-md bg-primary text-primary-foreground hover:opacity-90"
155
176
  >
156
- {t('common.reload')}
177
+ Reload
157
178
  </button>
158
179
  </div>
159
180
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdguggenbichler/slugbase-core",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "SlugBase core: backend and frontend entrypoints for self-hosted and cloud apps",
5
5
  "type": "module",
6
6
  "exports": {