kreftjs 0.0.0-stage → 0.0.2-beta
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.
- package/README.md +103 -2
- package/bin/add.js +1074 -0
- package/bin/artisan-more.js +994 -0
- package/bin/artisan.js +1877 -0
- package/bin/backend/app.js +161 -0
- package/bin/backend/cache.js +196 -0
- package/bin/backend/collection.js +117 -0
- package/bin/backend/command.js +45 -0
- package/bin/backend/config.js +234 -0
- package/bin/backend/error-page.js +773 -0
- package/bin/backend/events.js +49 -0
- package/bin/backend/factory.js +223 -0
- package/bin/backend/fake.js +180 -0
- package/bin/backend/form.js +102 -0
- package/bin/backend/gate.js +79 -0
- package/bin/backend/gc.js +69 -0
- package/bin/backend/html.js +322 -0
- package/bin/backend/http.js +652 -0
- package/bin/backend/index.js +452 -0
- package/bin/backend/mail.js +77 -0
- package/bin/backend/mcp.js +433 -0
- package/bin/backend/migrator.js +370 -0
- package/bin/backend/model.js +781 -0
- package/bin/backend/namespace.js +213 -0
- package/bin/backend/notifications.js +68 -0
- package/bin/backend/qr.js +164 -0
- package/bin/backend/query.js +387 -0
- package/bin/backend/queue.js +412 -0
- package/bin/backend/redis.js +479 -0
- package/bin/backend/schedule.js +112 -0
- package/bin/backend/schema.js +321 -0
- package/bin/backend/seo-pages.js +100 -0
- package/bin/backend/storage.js +153 -0
- package/bin/backend/support.js +567 -0
- package/bin/backend/typescript.js +166 -0
- package/bin/build.js +540 -0
- package/bin/db-api.js +249 -0
- package/bin/db.js +275 -0
- package/bin/deps.js +138 -0
- package/bin/electron.js +509 -0
- package/bin/env.js +97 -0
- package/bin/guard.js +80 -0
- package/bin/kreftjs-config.js +40 -0
- package/bin/kreftjs.js +1373 -0
- package/bin/lang.js +241 -0
- package/bin/layout.js +74 -0
- package/bin/no-auth.js +162 -0
- package/bin/prerender.js +258 -0
- package/bin/safe-json.js +24 -0
- package/bin/server-routes.js +154 -0
- package/bin/ssr.js +133 -0
- package/bin/terminal.js +195 -0
- package/bin/to-ts.js +36 -0
- package/bin/update.js +237 -0
- package/bin/urls-file.js +27 -0
- package/bin/vite.js +228 -0
- package/docs/Docs.kreftjs +557 -0
- package/docs/README.md +2302 -0
- package/docs/markdown.js +186 -0
- package/editors/vscode/README.md +13 -0
- package/editors/vscode/extension.js +183 -0
- package/editors/vscode/language-configuration.json +17 -0
- package/editors/vscode/package.json +57 -0
- package/editors/vscode/snippets/kreftjs.json +21 -0
- package/editors/vscode/syntaxes/kreftjs.tmLanguage.json +207 -0
- package/kreftjs.d.ts +579 -0
- package/kreftjs.js +5108 -0
- package/package.json +97 -4
- package/server.d.ts +1028 -0
- package/server.js +8 -0
- package/templates/app/README.md +127 -0
- package/templates/app/_env.example +64 -0
- package/templates/app/_gitignore +5 -0
- package/templates/app/_vscode/settings.json +9 -0
- package/templates/app/backend/app/Auth/Session.js +177 -0
- package/templates/app/backend/app/Auth/Throttle.js +29 -0
- package/templates/app/backend/app/Console/Commands/.gitkeep +0 -0
- package/templates/app/backend/app/Events/.gitkeep +0 -0
- package/templates/app/backend/app/Http/Controllers/Admin/DashboardController.js +34 -0
- package/templates/app/backend/app/Http/Controllers/Admin/UserController.js +53 -0
- package/templates/app/backend/app/Http/Controllers/Auth/ApiTokenController.js +47 -0
- package/templates/app/backend/app/Http/Controllers/Auth/AuthenticatedSessionController.js +41 -0
- package/templates/app/backend/app/Http/Controllers/Auth/ConfirmablePasswordController.js +14 -0
- package/templates/app/backend/app/Http/Controllers/Auth/EmailVerificationController.js +23 -0
- package/templates/app/backend/app/Http/Controllers/Auth/NewPasswordController.js +29 -0
- package/templates/app/backend/app/Http/Controllers/Auth/PasswordResetLinkController.js +20 -0
- package/templates/app/backend/app/Http/Controllers/Auth/RegisteredUserController.js +19 -0
- package/templates/app/backend/app/Http/Controllers/Auth/SessionController.js +36 -0
- package/templates/app/backend/app/Http/Controllers/Auth/TwoFactorChallengeController.js +41 -0
- package/templates/app/backend/app/Http/Controllers/Auth/TwoFactorController.js +63 -0
- package/templates/app/backend/app/Http/Controllers/ProfileController.js +66 -0
- package/templates/app/backend/app/Http/Kernel.js +8 -0
- package/templates/app/backend/app/Http/Middleware/Authenticate.js +84 -0
- package/templates/app/backend/app/Http/Middleware/CheckAbilities.js +17 -0
- package/templates/app/backend/app/Http/Middleware/CheckForAnyAbility.js +12 -0
- package/templates/app/backend/app/Http/Middleware/EnsureEmailIsVerified.js +11 -0
- package/templates/app/backend/app/Http/Middleware/EnsureHasRole.js +11 -0
- package/templates/app/backend/app/Http/Middleware/EnsureIsAdmin.js +11 -0
- package/templates/app/backend/app/Http/Middleware/RequirePassword.js +15 -0
- package/templates/app/backend/app/Http/Requests/Auth/LoginRequest.js +45 -0
- package/templates/app/backend/app/Http/Resources/.gitkeep +1 -0
- package/templates/app/backend/app/Jobs/.gitkeep +0 -0
- package/templates/app/backend/app/Listeners/.gitkeep +0 -0
- package/templates/app/backend/app/Mail/.gitkeep +0 -0
- package/templates/app/backend/app/Models/PersonalAccessToken.js +21 -0
- package/templates/app/backend/app/Models/User.js +64 -0
- package/templates/app/backend/app/Notifications/.gitkeep +0 -0
- package/templates/app/backend/app/Observers/.gitkeep +0 -0
- package/templates/app/backend/app/Policies/.gitkeep +0 -0
- package/templates/app/backend/app/Providers/AppServiceProvider.js +12 -0
- package/templates/app/backend/app/Rules/.gitkeep +1 -0
- package/templates/app/backend/config/app.js +16 -0
- package/templates/app/backend/config/auth.js +34 -0
- package/templates/app/backend/config/database.js +38 -0
- package/templates/app/backend/config/redis.js +28 -0
- package/templates/app/backend/config/session.js +36 -0
- package/templates/app/backend/database/migrations/0001_01_01_000000_create_users_table.js +49 -0
- package/templates/app/backend/database/migrations/0001_01_01_000001_create_cache_table.js +13 -0
- package/templates/app/backend/database/migrations/0001_01_01_000002_create_jobs_table.js +26 -0
- package/templates/app/backend/database/migrations/0001_01_01_000003_create_notifications_table.js +18 -0
- package/templates/app/backend/database/seeders/DatabaseSeeder.js +15 -0
- package/templates/app/backend/lang/ar/messages.json +10 -0
- package/templates/app/backend/lang/ar/validation.json +21 -0
- package/templates/app/backend/lang/en/messages.json +10 -0
- package/templates/app/backend/lang/en/validation.json +19 -0
- package/templates/app/backend/routes/api.js +25 -0
- package/templates/app/backend/routes/auth.js +52 -0
- package/templates/app/backend/routes/console.js +15 -0
- package/templates/app/frontend/App.kreftjs +4 -0
- package/templates/app/frontend/components/Field.kreftjs +19 -0
- package/templates/app/frontend/components/StatCard.kreftjs +47 -0
- package/templates/app/frontend/components/profile/ApiTokens.kreftjs +70 -0
- package/templates/app/frontend/components/profile/Sessions.kreftjs +42 -0
- package/templates/app/frontend/components/profile/TwoFactor.kreftjs +90 -0
- package/templates/app/frontend/errors/ErrorMonitor.kreftjs +264 -0
- package/templates/app/frontend/index.html +79 -0
- package/templates/app/frontend/kreftjs.d.ts +579 -0
- package/templates/app/frontend/kreftjs.js +5108 -0
- package/templates/app/frontend/layouts/app.kreftjs +718 -0
- package/templates/app/frontend/layouts/docs.kreftjs +37 -0
- package/templates/app/frontend/layouts/guest.kreftjs +18 -0
- package/templates/app/frontend/pages/Dashboard.kreftjs +273 -0
- package/templates/app/frontend/pages/ErrorMonitor.kreftjs +96 -0
- package/templates/app/frontend/pages/Home.kreftjs +617 -0
- package/templates/app/frontend/pages/Profile.kreftjs +104 -0
- package/templates/app/frontend/pages/Users.kreftjs +240 -0
- package/templates/app/frontend/pages/auth/ConfirmPassword.kreftjs +33 -0
- package/templates/app/frontend/pages/auth/ForgotPassword.kreftjs +36 -0
- package/templates/app/frontend/pages/auth/Login.kreftjs +89 -0
- package/templates/app/frontend/pages/auth/Register.kreftjs +48 -0
- package/templates/app/frontend/pages/auth/ResetPassword.kreftjs +45 -0
- package/templates/app/frontend/pages/auth/VerifyEmail.kreftjs +59 -0
- package/templates/app/frontend/routes/web.kreftjs +34 -0
- package/templates/app/frontend/tests/components/Counter.kreftjs +15 -0
- package/templates/app/frontend/tests/pages/About.kreftjs +12 -0
- package/templates/app/frontend/tests/pages/Test.kreftjs +31 -0
- package/templates/app/frontend/ui.css +517 -0
- package/templates/app/lang/ar/auth.json +6 -0
- package/templates/app/lang/ar/messages.json +6 -0
- package/templates/app/lang/ar/pagination.json +5 -0
- package/templates/app/lang/ar/passwords.json +8 -0
- package/templates/app/lang/ar/validation.json +22 -0
- package/templates/app/lang/ar.json +10 -0
- package/templates/app/lang/en/auth.json +6 -0
- package/templates/app/lang/en/messages.json +6 -0
- package/templates/app/lang/en/pagination.json +5 -0
- package/templates/app/lang/en/passwords.json +8 -0
- package/templates/app/lang/en/validation.json +22 -0
- package/templates/app/lang/en.json +10 -0
- package/templates/errors/401.kreftjs +11 -0
- package/templates/errors/402.kreftjs +11 -0
- package/templates/errors/403.kreftjs +11 -0
- package/templates/errors/404.kreftjs +11 -0
- package/templates/errors/419.kreftjs +11 -0
- package/templates/errors/429.kreftjs +11 -0
- package/templates/errors/500.kreftjs +11 -0
- package/templates/errors/503.kreftjs +11 -0
- package/templates/errors/ErrorMonitor.kreftjs +502 -0
- package/templates/errors/error.kreftjs +11 -0
- package/templates/errors/minimal.kreftjs +25 -0
- package/tools/dev-client.js +125 -0
- package/tools/devtools.js +172 -0
- package/tools/vite-plugin-kreftjs.d.ts +52 -0
- package/tools/vite-plugin-kreftjs.js +466 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!-- The layout of the documentation page (/docs): a slim top bar and the page, without the dashboard sidebar.
|
|
2
|
+
The route asks for it with .layout('docs') in routes/web.kreftjs. The documentation viewer (docs/Docs.kreftjs)
|
|
3
|
+
assumes a bar this tall (60px) above it. -->
|
|
4
|
+
<view>
|
|
5
|
+
<header>
|
|
6
|
+
<kreft-link to="/" class="brand"><span class="mark" aria-hidden="true"></span>{env.PUBLIC_APP_NAME || 'My app'}</kreft-link>
|
|
7
|
+
<span class="label">Documentation</span>
|
|
8
|
+
<nav>
|
|
9
|
+
<kreft-link to={$store.auth.user ? '/dashboard' : '/'} class="back">← {$store.auth.user ? 'Back to the app' : 'Home'}</kreft-link>
|
|
10
|
+
<button type="button" class="theme" @click="theme.toggle()" aria-label="Toggle theme" title="Toggle theme">
|
|
11
|
+
<span k-if="theme.dark">☀ Light</span>
|
|
12
|
+
<span k-else>🌙 Dark</span>
|
|
13
|
+
</button>
|
|
14
|
+
</nav>
|
|
15
|
+
</header>
|
|
16
|
+
<main>
|
|
17
|
+
<slot></slot>
|
|
18
|
+
</main>
|
|
19
|
+
</view>
|
|
20
|
+
|
|
21
|
+
<style scoped>
|
|
22
|
+
header { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 var(--container-pad, 28px); background: var(--background); border-bottom: 1px solid var(--border); box-sizing: border-box; }
|
|
23
|
+
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; color: var(--foreground); text-decoration: none; }
|
|
24
|
+
.mark { width: 16px; height: 16px; background: var(--primary); }
|
|
25
|
+
.label { padding-inline-start: 14px; border-inline-start: 1px solid var(--border); font-size: 14px; color: var(--muted); }
|
|
26
|
+
nav { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }
|
|
27
|
+
.back { padding: 6px 10px; font-size: 14px; color: var(--muted); text-decoration: none; border-radius: var(--radius); }
|
|
28
|
+
.back:hover { color: var(--foreground); background: var(--accent); }
|
|
29
|
+
.theme { height: 34px; padding: 0 12px; background: var(--card); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius); font: inherit; font-size: 13px; cursor: pointer; }
|
|
30
|
+
.theme:hover { background: var(--accent); }
|
|
31
|
+
main { width: 100%; max-width: calc(var(--container, 1240px) + var(--container-pad, 28px) * 2); margin: 0 auto; padding: 0 var(--container-pad, 28px) 48px; box-sizing: border-box; }
|
|
32
|
+
@media (max-width: 640px) {
|
|
33
|
+
header { padding: 0 16px; gap: 10px; }
|
|
34
|
+
.label { display: none; }
|
|
35
|
+
main { padding: 0 16px 36px; }
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- The layout of the sign-in pages (login, register, forgot password…): a small box in the middle.
|
|
2
|
+
The routes in index.html ask for it with layout: 'guest'. -->
|
|
3
|
+
<view>
|
|
4
|
+
<main>
|
|
5
|
+
<kreft-link to="/" class="brand"><span class="mark" aria-hidden="true"></span>{env.PUBLIC_APP_NAME || 'My app'}</kreft-link>
|
|
6
|
+
<div class="box">
|
|
7
|
+
<slot></slot>
|
|
8
|
+
</div>
|
|
9
|
+
</main>
|
|
10
|
+
</view>
|
|
11
|
+
|
|
12
|
+
<style scoped>
|
|
13
|
+
main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 72px 16px 48px; background: var(--accent); }
|
|
14
|
+
.brand { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 24px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; color: var(--foreground); text-decoration: none; }
|
|
15
|
+
.mark { width: 16px; height: 16px; background: var(--primary); }
|
|
16
|
+
.box { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); padding: 32px; }
|
|
17
|
+
@media (max-width: 480px) { main { padding-top: 40px; } .box { padding: 24px 20px; } }
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Dashboard Page: Default Overview UI for the application.
|
|
3
|
+
Stat cards, user insights, and system status. Strictly zero border-radius and zero shadows.
|
|
4
|
+
-->
|
|
5
|
+
load stats = api.get('/api/admin/stats')
|
|
6
|
+
load board = api.get('/api/dashboard')
|
|
7
|
+
|
|
8
|
+
<view>
|
|
9
|
+
<div class="dashboard-page">
|
|
10
|
+
<div class="dashboard-header">
|
|
11
|
+
<div>
|
|
12
|
+
<h1 class="dash-title">Dashboard Overview</h1>
|
|
13
|
+
<p class="lead">
|
|
14
|
+
System telemetry, user accounts, and platform status.
|
|
15
|
+
</p>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="header-actions">
|
|
18
|
+
<kreft-link to="/users" class="btn primary sm">Manage Users →</kreft-link>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<!-- Verified email toast notice if redirected from email verification -->
|
|
23
|
+
<p k-if="$route.query.verified" class="alert success" role="status">
|
|
24
|
+
Your email address has been successfully verified! Welcome to the dashboard.
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<!-- Stat Cards Grid -->
|
|
28
|
+
<div class="stats-grid">
|
|
29
|
+
<stat-card
|
|
30
|
+
label="Total Users"
|
|
31
|
+
value={stats.data ? stats.data.users : 1}
|
|
32
|
+
hint={stats.data && stats.data.newThisWeek ? stats.data.newThisWeek + ' joined this week' : 'Registered members'}>
|
|
33
|
+
</stat-card>
|
|
34
|
+
|
|
35
|
+
<stat-card
|
|
36
|
+
label="Administrators"
|
|
37
|
+
value={stats.data ? stats.data.admins : 1}
|
|
38
|
+
hint="Full system access">
|
|
39
|
+
</stat-card>
|
|
40
|
+
|
|
41
|
+
<stat-card
|
|
42
|
+
label="Email Verified"
|
|
43
|
+
value={stats.data ? (stats.data.users - stats.data.unverified) : 1}
|
|
44
|
+
hint="Active confirmed accounts">
|
|
45
|
+
</stat-card>
|
|
46
|
+
|
|
47
|
+
<stat-card
|
|
48
|
+
label="Active Sessions"
|
|
49
|
+
value={stats.data ? stats.data.signedIn : 1}
|
|
50
|
+
hint="HttpOnly tokens">
|
|
51
|
+
</stat-card>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<!-- Main Content Split Grid -->
|
|
55
|
+
<div class="content-split">
|
|
56
|
+
<!-- Recent Users Table -->
|
|
57
|
+
<section class="card content-card">
|
|
58
|
+
<div class="card-title-bar">
|
|
59
|
+
<div>
|
|
60
|
+
<h2 class="card-heading">Recent Accounts</h2>
|
|
61
|
+
<p class="card-sub">Latest registered users in the database.</p>
|
|
62
|
+
</div>
|
|
63
|
+
<kreft-link to="/users" class="btn ghost sm">View All →</kreft-link>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div k-if="stats.loading" class="state-msg muted">
|
|
67
|
+
Loading user records…
|
|
68
|
+
</div>
|
|
69
|
+
<div k-elif="stats.data && stats.data.latest && stats.data.latest.length > 0">
|
|
70
|
+
<table class="table">
|
|
71
|
+
<thead>
|
|
72
|
+
<tr>
|
|
73
|
+
<th>User</th>
|
|
74
|
+
<th>Email</th>
|
|
75
|
+
<th>Role</th>
|
|
76
|
+
<th>Joined</th>
|
|
77
|
+
</tr>
|
|
78
|
+
</thead>
|
|
79
|
+
<tbody>
|
|
80
|
+
{for u in stats.data.latest key u.id}
|
|
81
|
+
<tr>
|
|
82
|
+
<td>
|
|
83
|
+
<div class="user-inline">
|
|
84
|
+
<span class="user-chip">{u.name ? u.name.charAt(0).toUpperCase() : 'U'}</span>
|
|
85
|
+
<strong>{u.name}</strong>
|
|
86
|
+
</div>
|
|
87
|
+
</td>
|
|
88
|
+
<td><code>{u.email}</code></td>
|
|
89
|
+
<td>
|
|
90
|
+
<span class={u.is_admin ? 'badge solid' : 'badge'}>
|
|
91
|
+
{u.is_admin ? 'Admin' : (u.role || 'User')}
|
|
92
|
+
</span>
|
|
93
|
+
</td>
|
|
94
|
+
<td class="muted font-mono">{String(u.created_at || '').slice(0, 10) || 'Recently'}</td>
|
|
95
|
+
</tr>
|
|
96
|
+
{/for}
|
|
97
|
+
</tbody>
|
|
98
|
+
</table>
|
|
99
|
+
</div>
|
|
100
|
+
<div k-else class="state-msg">
|
|
101
|
+
<p class="muted">Signed in as <strong>{$store.auth.user ? $store.auth.user.name : 'Administrator'}</strong>.</p>
|
|
102
|
+
</div>
|
|
103
|
+
</section>
|
|
104
|
+
|
|
105
|
+
<!-- System Quick Links & Info -->
|
|
106
|
+
<section class="card content-card side-card">
|
|
107
|
+
<h2 class="card-heading">Platform Architecture</h2>
|
|
108
|
+
<p class="card-sub">Configured environment & quick developer tools.</p>
|
|
109
|
+
|
|
110
|
+
<div class="info-list">
|
|
111
|
+
<div class="info-item">
|
|
112
|
+
<span class="info-label">Framework Engine</span>
|
|
113
|
+
<span class="info-value">Kreft {Kreftjs.version || '0.0.2-beta'}</span>
|
|
114
|
+
</div>
|
|
115
|
+
<div class="info-item">
|
|
116
|
+
<span class="info-label">Active Database</span>
|
|
117
|
+
<span class="info-value">SQLite / Active Record</span>
|
|
118
|
+
</div>
|
|
119
|
+
<div class="info-item">
|
|
120
|
+
<span class="info-label">UI Design System</span>
|
|
121
|
+
<span class="info-value">High-Precision Brutalist</span>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="info-item">
|
|
124
|
+
<span class="info-label">Borders & Corners</span>
|
|
125
|
+
<span class="info-value">Square (0px / No Shadows)</span>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="quick-nav-group">
|
|
130
|
+
<kreft-link to="/profile" class="btn secondary sm w-full">Edit Profile Settings</kreft-link>
|
|
131
|
+
<kreft-link to="/docs" class="btn ghost sm w-full">API Documentation</kreft-link>
|
|
132
|
+
<kreft-link to="/welcome" class="btn ghost sm w-full">Landing Page Showcase</kreft-link>
|
|
133
|
+
</div>
|
|
134
|
+
</section>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</view>
|
|
138
|
+
|
|
139
|
+
<style scoped>
|
|
140
|
+
.dashboard-page {
|
|
141
|
+
width: 100%;
|
|
142
|
+
color: var(--foreground);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.dashboard-header {
|
|
146
|
+
display: flex;
|
|
147
|
+
justify-content: space-between;
|
|
148
|
+
align-items: flex-start;
|
|
149
|
+
gap: 20px;
|
|
150
|
+
flex-wrap: wrap;
|
|
151
|
+
margin-bottom: 24px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.dash-title {
|
|
155
|
+
margin: 0 0 6px;
|
|
156
|
+
font-size: 28px;
|
|
157
|
+
font-weight: 800;
|
|
158
|
+
letter-spacing: -0.04em;
|
|
159
|
+
color: var(--foreground);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.stats-grid {
|
|
163
|
+
display: grid;
|
|
164
|
+
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
|
|
165
|
+
gap: 16px;
|
|
166
|
+
margin-bottom: 24px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.content-split {
|
|
170
|
+
display: grid;
|
|
171
|
+
grid-template-columns: 2fr 1fr;
|
|
172
|
+
gap: 16px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.content-card {
|
|
176
|
+
margin-bottom: 0;
|
|
177
|
+
padding: 24px;
|
|
178
|
+
background: var(--card);
|
|
179
|
+
color: var(--foreground);
|
|
180
|
+
border: 1px solid var(--card-border);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.card-title-bar {
|
|
184
|
+
display: flex;
|
|
185
|
+
justify-content: space-between;
|
|
186
|
+
align-items: flex-start;
|
|
187
|
+
margin-bottom: 16px;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.card-heading {
|
|
191
|
+
margin: 0 0 4px;
|
|
192
|
+
font-size: 16px;
|
|
193
|
+
font-weight: 700;
|
|
194
|
+
letter-spacing: -0.02em;
|
|
195
|
+
color: var(--foreground);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.card-sub {
|
|
199
|
+
margin: 0;
|
|
200
|
+
font-size: 12px;
|
|
201
|
+
color: var(--muted);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.user-inline {
|
|
205
|
+
display: flex;
|
|
206
|
+
align-items: center;
|
|
207
|
+
gap: 8px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.user-chip {
|
|
211
|
+
width: 20px;
|
|
212
|
+
height: 20px;
|
|
213
|
+
background: var(--primary);
|
|
214
|
+
color: var(--primary-foreground);
|
|
215
|
+
font-size: 10px;
|
|
216
|
+
font-weight: 700;
|
|
217
|
+
font-family: var(--mono);
|
|
218
|
+
display: inline-flex;
|
|
219
|
+
align-items: center;
|
|
220
|
+
justify-content: center;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.font-mono {
|
|
224
|
+
font-family: var(--mono);
|
|
225
|
+
font-size: 12px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.state-msg {
|
|
229
|
+
padding: 32px 0;
|
|
230
|
+
text-align: center;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.info-list {
|
|
234
|
+
display: grid;
|
|
235
|
+
gap: 10px;
|
|
236
|
+
margin: 16px 0 24px;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.info-item {
|
|
240
|
+
display: flex;
|
|
241
|
+
justify-content: space-between;
|
|
242
|
+
align-items: center;
|
|
243
|
+
padding-bottom: 8px;
|
|
244
|
+
border-bottom: 1px solid var(--border);
|
|
245
|
+
font-size: 12px;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.info-label {
|
|
249
|
+
color: var(--muted);
|
|
250
|
+
font-family: var(--mono);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.info-value {
|
|
254
|
+
font-weight: 600;
|
|
255
|
+
color: var(--foreground);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.quick-nav-group {
|
|
259
|
+
display: grid;
|
|
260
|
+
gap: 8px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.w-full {
|
|
264
|
+
width: 100%;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@media (max-width: 900px) {
|
|
269
|
+
.content-split {
|
|
270
|
+
grid-template-columns: 1fr;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
</style>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
ErrorMonitor Page — Interactive Kreft Diagnostic Inspector Showcase
|
|
3
|
+
Uses Kreft's own minimalist geometric UI and authentic JavaScript/.kreftjs stack traces.
|
|
4
|
+
-->
|
|
5
|
+
import ErrorMonitor from '../errors/ErrorMonitor.kreftjs'
|
|
6
|
+
|
|
7
|
+
state scenario = 'method'
|
|
8
|
+
|
|
9
|
+
derive sampleError = scenario === 'method' ? {
|
|
10
|
+
name: 'TypeError',
|
|
11
|
+
message: 'Post.qquery is not a function',
|
|
12
|
+
frames: [
|
|
13
|
+
{ fn: 'PostController.index', file: 'backend/app/Http/Controllers/PostController.js', line: 13, col: 25, isApp: true, snippet: [
|
|
14
|
+
{ num: 10, code: 'class PostController {' },
|
|
15
|
+
{ num: 11, code: ' async index(req) {' },
|
|
16
|
+
{ num: 12, code: ' // Typo in static query builder call' },
|
|
17
|
+
{ num: 13, code: ' const posts = await Post.qquery().orderByDesc("id").get()', isTarget: true },
|
|
18
|
+
{ num: 14, code: ' return { posts }' },
|
|
19
|
+
{ num: 15, code: ' }' },
|
|
20
|
+
{ num: 16, code: '}' }
|
|
21
|
+
]},
|
|
22
|
+
{ fn: 'Router.dispatch', file: 'bin/backend/http.js', line: 182, col: 12, isApp: false },
|
|
23
|
+
{ fn: 'Server.handleRequest', file: 'bin/kreftjs.js', line: 412, col: 9, isApp: false }
|
|
24
|
+
],
|
|
25
|
+
solution: {
|
|
26
|
+
title: 'Unknown Model Method',
|
|
27
|
+
message: 'Did you mean Post.query() instead of Post.qquery()?'
|
|
28
|
+
}
|
|
29
|
+
} : scenario === 'null' ? {
|
|
30
|
+
name: 'TypeError',
|
|
31
|
+
message: "Cannot read properties of undefined (reading 'email')",
|
|
32
|
+
frames: [
|
|
33
|
+
{ fn: 'ProfileController.update', file: 'backend/app/Http/Controllers/ProfileController.js', line: 31, col: 32, isApp: true, snippet: [
|
|
34
|
+
{ num: 28, code: ' async update(req) {' },
|
|
35
|
+
{ num: 29, code: ' const user = req.user' },
|
|
36
|
+
{ num: 30, code: ' // Accessing nested property without optional chaining' },
|
|
37
|
+
{ num: 31, code: ' const email = user.account.email', isTarget: true },
|
|
38
|
+
{ num: 32, code: ' return { ok: true, email }' },
|
|
39
|
+
{ num: 33, code: ' }' }
|
|
40
|
+
]},
|
|
41
|
+
{ fn: 'Router.dispatch', file: 'bin/backend/http.js', line: 210, col: 14, isApp: false }
|
|
42
|
+
],
|
|
43
|
+
solution: {
|
|
44
|
+
title: 'Null Reference Guard',
|
|
45
|
+
message: 'user.account is undefined. Use optional chaining (user.account?.email) or verify req.user before reading.'
|
|
46
|
+
}
|
|
47
|
+
} : {
|
|
48
|
+
name: 'DatabaseError',
|
|
49
|
+
message: 'SQLITE_ERROR: no such table: tasks_archive',
|
|
50
|
+
frames: [
|
|
51
|
+
{ fn: 'TaskController.archive', file: 'backend/app/Http/Controllers/TaskController.js', line: 44, col: 18, isApp: true, snippet: [
|
|
52
|
+
{ num: 41, code: ' async archive(req) {' },
|
|
53
|
+
{ num: 42, code: ' // Querying a table whose migration has not run yet' },
|
|
54
|
+
{ num: 43, code: " const rows = await DB.table('tasks_archive').get()", isTarget: true },
|
|
55
|
+
{ num: 44, code: ' return { rows }' },
|
|
56
|
+
{ num: 45, code: ' }' }
|
|
57
|
+
]},
|
|
58
|
+
{ fn: 'Database.query', file: 'bin/backend/db.js', line: 120, col: 9, isApp: false }
|
|
59
|
+
],
|
|
60
|
+
solution: {
|
|
61
|
+
title: 'Pending Database Migration',
|
|
62
|
+
message: "Run 'kreftjs db:migrate' or create the table with 'kreftjs make:migration create_tasks_archive_table'."
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
<view>
|
|
67
|
+
<h1>Error Monitor</h1>
|
|
68
|
+
<p class="lead">Kreft catches unhandled server and component exceptions with its own geometric inspector: interactive stack frames, terminal code preview, and fix suggestions.</p>
|
|
69
|
+
|
|
70
|
+
<div class="switcher" role="group" aria-label="Exception Scenarios">
|
|
71
|
+
<span class="label-inline">Simulate Exception:</span>
|
|
72
|
+
<button class={scenario === 'method' ? 'primary sm' : 'secondary sm'} @click="scenario = 'method'">
|
|
73
|
+
1. Method Typo (Post.qquery)
|
|
74
|
+
</button>
|
|
75
|
+
<button class={scenario === 'null' ? 'primary sm' : 'secondary sm'} @click="scenario = 'null'">
|
|
76
|
+
2. Null Reference (TypeError)
|
|
77
|
+
</button>
|
|
78
|
+
<button class={scenario === 'sql' ? 'primary sm' : 'secondary sm'} @click="scenario = 'sql'">
|
|
79
|
+
3. Missing Table (DatabaseError)
|
|
80
|
+
</button>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<error-monitor
|
|
84
|
+
error={sampleError}
|
|
85
|
+
status={500}
|
|
86
|
+
title={sampleError.name}
|
|
87
|
+
message={sampleError.message}
|
|
88
|
+
frames={sampleError.frames}
|
|
89
|
+
solution={sampleError.solution}>
|
|
90
|
+
</error-monitor>
|
|
91
|
+
</view>
|
|
92
|
+
|
|
93
|
+
<style scoped>
|
|
94
|
+
.switcher { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--border); background: var(--accent); margin-bottom: 16px; }
|
|
95
|
+
.label-inline { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted); margin-inline-end: 4px; }
|
|
96
|
+
</style>
|