@seip/bluebird-js 0.1.2 → 0.1.5
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/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +10 -0
- package/AGENTS.md +495 -454
- package/README.md +528 -353
- package/app/routes/web.js +47 -55
- package/app/views/about.jsx +98 -0
- package/app/views/components/Header.jsx +42 -0
- package/app/views/components/LiveCounter.jsx +66 -0
- package/app/views/dashboard.jsx +300 -0
- package/app/views/index.jsx +123 -0
- package/app/views/layouts/main/view.jsx +201 -0
- package/app/views/legal/terms.html +29 -19
- package/app/views/login.jsx +141 -0
- package/core/actions.d.ts +4 -0
- package/core/actions.js +329 -0
- package/core/app.js +38 -6
- package/core/cli/doctor.js +3 -4
- package/core/cli/init.js +20 -6
- package/core/cli/migrate.js +418 -145
- package/core/cli/view.js +76 -11
- package/core/database.js +6 -10
- package/core/debug.js +1 -1
- package/core/html.d.ts +54 -42
- package/core/html.js +473 -217
- package/core/index.d.ts +1385 -1190
- package/core/jsx.d.ts +38 -0
- package/core/jsx.js +1432 -0
- package/core/model.js +271 -61
- package/core/render-cache.js +212 -212
- package/core/render.d.ts +20 -2
- package/core/render.js +459 -51
- package/core/validate.js +1 -1
- package/core/view-loader.js +360 -24
- package/package.json +9 -3
- package/public/js/bluebird-client.js +3160 -1780
- package/public/js/tailwind.js +8 -0
- package/app/views/about.js +0 -63
- package/app/views/dashboard.js +0 -147
- package/app/views/index.js +0 -80
- package/app/views/layouts/main/view.js +0 -81
- package/app/views/login.js +0 -80
- package/public/css/bluebird.min.css +0 -2
- package/public/js/bluebird.min.js +0 -1073
package/app/routes/web.js
CHANGED
|
@@ -1,55 +1,47 @@
|
|
|
1
|
-
import Router from "@seip/bluebird-js/core/router.js";
|
|
2
|
-
import Render from "@seip/bluebird-js/core/render.js";
|
|
3
|
-
import Auth from "@seip/bluebird-js/core/auth.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
req.headers
|
|
34
|
-
req.headers
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
routerWeb.get("/dashboard", Auth.protect({ redirect: "/login" }), async (req, res) => {
|
|
49
|
-
await Render.send(res, "dashboard", {
|
|
50
|
-
title: "Dashboard — Blue Bird",
|
|
51
|
-
user: req.user,
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export default routerWeb;
|
|
1
|
+
import Router from "@seip/bluebird-js/core/router.js";
|
|
2
|
+
import Render from "@seip/bluebird-js/core/render.js";
|
|
3
|
+
import Auth from "@seip/bluebird-js/core/auth.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Web Router for custom actions and static HTML files.
|
|
7
|
+
* Page GET routes (`/`, `/about`, `/login`, `/dashboard`) are automatically
|
|
8
|
+
* generated from `app/views/*.jsx` via declarative exports (`route`, `cache`, `middlewares`, `layout`, `seo`).
|
|
9
|
+
*/
|
|
10
|
+
const routerWeb = new Router("/", { seo: true });
|
|
11
|
+
|
|
12
|
+
routerWeb.get("/terms", (req, res) => Render.html(res, "legal/terms.html", { ttl: 86400 }));
|
|
13
|
+
|
|
14
|
+
routerWeb.post("/login", async (req, res) => {
|
|
15
|
+
const email = req.body?.email || "alex@example.com";
|
|
16
|
+
const rawPrefix = email.split("@")[0] || "alex";
|
|
17
|
+
const name = req.body?.name || (rawPrefix.charAt(0).toUpperCase() + rawPrefix.slice(1));
|
|
18
|
+
|
|
19
|
+
const user = {
|
|
20
|
+
id: 1,
|
|
21
|
+
name,
|
|
22
|
+
email,
|
|
23
|
+
role: "admin",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
await Auth.login(res, user);
|
|
27
|
+
return res.redirect("/dashboard");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
routerWeb.get("/logout", async (req, res) => {
|
|
31
|
+
if (
|
|
32
|
+
req.headers["x-bluebird-prefetch"] ||
|
|
33
|
+
req.headers.purpose === "prefetch" ||
|
|
34
|
+
req.headers["sec-purpose"] === "prefetch"
|
|
35
|
+
) {
|
|
36
|
+
return res.status(204).end();
|
|
37
|
+
}
|
|
38
|
+
await Auth.logout(res);
|
|
39
|
+
return res.redirect("/login");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
routerWeb.post("/logout", async (req, res) => {
|
|
43
|
+
await Auth.logout(res);
|
|
44
|
+
return res.redirect("/login");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default routerWeb;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export const route = "/about";
|
|
2
|
+
export const cache = 300;
|
|
3
|
+
export const layout = "main";
|
|
4
|
+
export const seo = true;
|
|
5
|
+
|
|
6
|
+
export const head = () => ({
|
|
7
|
+
title: "About Us — Blue Bird Framework",
|
|
8
|
+
description: "Learn about the architecture and design philosophy of Blue Bird.",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* About page React JSX view module.
|
|
13
|
+
*/
|
|
14
|
+
export default function AboutView() {
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<section className="py-10 md:py-14 border-b border-slate-800/80">
|
|
18
|
+
<h1 className="mt-3 text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 via-blue-500 to-indigo-400 bg-clip-text text-transparent">
|
|
19
|
+
About Blue Bird
|
|
20
|
+
</h1>
|
|
21
|
+
<p className="mt-4 text-base md:text-lg text-slate-300 max-w-2xl leading-relaxed">
|
|
22
|
+
Built for performance, simplicity, and raw speed with native React JSX SSR.
|
|
23
|
+
</p>
|
|
24
|
+
</section>
|
|
25
|
+
|
|
26
|
+
<article className="mt-8 rounded-2xl border border-slate-800 bg-slate-900/60 p-6 md:p-8">
|
|
27
|
+
<header>
|
|
28
|
+
<h2 className="text-xl font-bold text-sky-400 mb-3">Our Philosophy</h2>
|
|
29
|
+
</header>
|
|
30
|
+
<p className="text-slate-300 leading-relaxed">
|
|
31
|
+
Blue Bird was born out of a desire for a clean, performance-first approach to web development. We
|
|
32
|
+
believe in harnessing the raw power of Express.js and modern Node.js ESM, stripping away unnecessary bloat, and
|
|
33
|
+
providing developers with a robust foundation that just works.
|
|
34
|
+
</p>
|
|
35
|
+
<p className="text-slate-300 leading-relaxed mt-4">
|
|
36
|
+
By combining server-rendered React JSX views with selective client hydration, anti-CLS skeletons, and native browser View Transitions,
|
|
37
|
+
Blue Bird eliminates heavy compilation pipelines and excessive memory usage.
|
|
38
|
+
</p>
|
|
39
|
+
</article>
|
|
40
|
+
|
|
41
|
+
<div className="mt-8">
|
|
42
|
+
<h2 className="text-xl font-bold text-slate-100 mb-4">Why Blue Bird?</h2>
|
|
43
|
+
|
|
44
|
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
45
|
+
<div className="space-y-4">
|
|
46
|
+
<details
|
|
47
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
48
|
+
open
|
|
49
|
+
>
|
|
50
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
51
|
+
Production Ready
|
|
52
|
+
</summary>
|
|
53
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
54
|
+
Seamless transition from development to production with PM2 clustering, systemd, and high performance multi-level caching.
|
|
55
|
+
</p>
|
|
56
|
+
</details>
|
|
57
|
+
<details
|
|
58
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
59
|
+
open
|
|
60
|
+
>
|
|
61
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
62
|
+
Military Grade Security
|
|
63
|
+
</summary>
|
|
64
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
65
|
+
Built-in AES-256-GCM JWT encryption, secure HttpOnly cookie sessions, security headers, and rate limiting.
|
|
66
|
+
</p>
|
|
67
|
+
</details>
|
|
68
|
+
</div>
|
|
69
|
+
<div className="space-y-4">
|
|
70
|
+
<details
|
|
71
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
72
|
+
open
|
|
73
|
+
>
|
|
74
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
75
|
+
Multi-Tier Caching
|
|
76
|
+
</summary>
|
|
77
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
78
|
+
In-memory LRU, Redis clustering, and persistent file caching for maximum requests per second with minimum CPU usage.
|
|
79
|
+
</p>
|
|
80
|
+
</details>
|
|
81
|
+
<details
|
|
82
|
+
className="rounded-xl border border-slate-800 bg-slate-900/50 p-4 open:border-slate-700 transition-colors"
|
|
83
|
+
open
|
|
84
|
+
>
|
|
85
|
+
<summary className="font-semibold text-slate-200 cursor-pointer select-none">
|
|
86
|
+
React JSX SSR & Auto-Routes
|
|
87
|
+
</summary>
|
|
88
|
+
<p className="mt-2 text-sm text-slate-400 leading-relaxed">
|
|
89
|
+
Write clean JSX components with declarative route exports (<code>cache</code>, <code>middlewares</code>, <code>layout</code>) and zero build steps.
|
|
90
|
+
</p>
|
|
91
|
+
</details>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable Header component for dashboard and application views in React JSX.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} [props={}]
|
|
5
|
+
* @param {string} [props.title]
|
|
6
|
+
* @param {string} [props.subtitle]
|
|
7
|
+
* @param {number} [props.count]
|
|
8
|
+
* @param {Object} [props.user]
|
|
9
|
+
* @param {Object} [props.props]
|
|
10
|
+
*/
|
|
11
|
+
export default function Header(props = {}) {
|
|
12
|
+
const actualProps = props.props || props;
|
|
13
|
+
const title = actualProps.title || "Dashboard Overview";
|
|
14
|
+
const subtitle =
|
|
15
|
+
actualProps.subtitle || "Welcome to your high-performance Bluebird.js control center.";
|
|
16
|
+
const count = actualProps.count !== undefined ? actualProps.count : 0;
|
|
17
|
+
const userName = actualProps.user?.name || "Member";
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<header className="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 mb-8 border-b border-slate-800">
|
|
21
|
+
<div>
|
|
22
|
+
<div className="flex items-center gap-3">
|
|
23
|
+
<h1 className="text-2xl md:text-3xl font-bold tracking-tight text-slate-100">{title}</h1>
|
|
24
|
+
<span className="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-sky-500/10 text-sky-400 border border-sky-500/20">
|
|
25
|
+
Active: <span id="header-counter-badge" className="ml-1 font-semibold">{count}</span>
|
|
26
|
+
</span>
|
|
27
|
+
</div>
|
|
28
|
+
<p className="text-sm text-slate-400 mt-1">{subtitle}</p>
|
|
29
|
+
</div>
|
|
30
|
+
<div className="flex items-center gap-3">
|
|
31
|
+
<div className="text-right hidden sm:block">
|
|
32
|
+
<div className="text-xs text-slate-400">Logged in as</div>
|
|
33
|
+
<div className="text-sm font-semibold text-slate-200">{userName}</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-sky-400 to-indigo-600 flex items-center justify-center text-slate-950 font-bold text-sm shadow-md">
|
|
36
|
+
{userName.slice(0, 1).toUpperCase()}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</header>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useState, useEffect, useAction } from "@seip/bluebird-js/core/jsx.js";
|
|
2
|
+
import { html } from "@seip/bluebird-js/core/html.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reusable reactive Client Counter component for `<Client component={LiveCounter} ... />`.
|
|
6
|
+
* Powered by Bluebird's zero-build client runtime with hooks (useState, useEffect, useAction, html).
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} props
|
|
9
|
+
* @param {number} [props.initial=7]
|
|
10
|
+
* @param {string} [props.label="Client Component Counter"]
|
|
11
|
+
* @returns {any}
|
|
12
|
+
*/
|
|
13
|
+
export default function LiveCounter({ initial = 7, label = "Client Component Counter" }) {
|
|
14
|
+
const [count, setCount] = useState(Number(initial) || 0);
|
|
15
|
+
const [sync, isPending] = useAction("syncCount", {
|
|
16
|
+
onSuccess(res) {
|
|
17
|
+
if (res?.data?.message && typeof window.toast === "function") {
|
|
18
|
+
window.toast({
|
|
19
|
+
title: "Server Action Executed",
|
|
20
|
+
description: res.data.message,
|
|
21
|
+
type: "success",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const badge = document.getElementById("header-counter-badge");
|
|
29
|
+
if (badge) badge.textContent = String(count);
|
|
30
|
+
}, [count]);
|
|
31
|
+
|
|
32
|
+
return html`
|
|
33
|
+
<div class="h-14 rounded-xl border border-slate-800 bg-slate-950/90 px-4 flex items-center justify-between">
|
|
34
|
+
<div class="flex items-center gap-2.5">
|
|
35
|
+
<span class="w-2 h-2 rounded-full ${isPending ? "bg-amber-400" : "bg-emerald-400"} animate-pulse"></span>
|
|
36
|
+
<span class="text-xs font-medium text-slate-300">${label}:</span>
|
|
37
|
+
<strong data-counter-val class="font-mono text-base text-sky-400">${count}</strong>
|
|
38
|
+
</div>
|
|
39
|
+
<div class="flex items-center gap-2">
|
|
40
|
+
<button
|
|
41
|
+
type="button"
|
|
42
|
+
onClick=${() => setCount(Math.max(0, count - 1))}
|
|
43
|
+
class="px-2.5 py-1 rounded-lg border border-slate-700 bg-slate-800 hover:bg-slate-700 text-xs font-semibold text-slate-200 transition-colors"
|
|
44
|
+
>
|
|
45
|
+
−
|
|
46
|
+
</button>
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
onClick=${() => setCount(count + 1)}
|
|
50
|
+
class="px-2.5 py-1 rounded-lg bg-sky-500 hover:bg-sky-400 text-xs font-bold text-slate-950 transition-colors"
|
|
51
|
+
>
|
|
52
|
+
+
|
|
53
|
+
</button>
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
onClick=${() => sync({ count })}
|
|
57
|
+
disabled=${isPending}
|
|
58
|
+
class="px-2.5 py-1 rounded-lg border border-emerald-500/30 bg-emerald-500/15 hover:bg-emerald-500/25 text-xs font-semibold text-emerald-300 transition-colors disabled:opacity-50"
|
|
59
|
+
>
|
|
60
|
+
${isPending ? "Syncing..." : "Sync Action"}
|
|
61
|
+
</button>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import Auth from "@seip/bluebird-js/core/auth.js";
|
|
2
|
+
import Actions from "@seip/bluebird-js/core/actions.js";
|
|
3
|
+
import { script } from "@seip/bluebird-js/core/html.js";
|
|
4
|
+
import { Client } from "@seip/bluebird-js/core/jsx.js";
|
|
5
|
+
import Header from "./components/Header.jsx";
|
|
6
|
+
import LiveCounter from "./components/LiveCounter.jsx";
|
|
7
|
+
|
|
8
|
+
export const route = "/dashboard";
|
|
9
|
+
export const layout = "main";
|
|
10
|
+
export const middlewares = [Auth.protect({ redirect: "/login" })];
|
|
11
|
+
export const seo = false;
|
|
12
|
+
|
|
13
|
+
export const actions = {
|
|
14
|
+
syncCount: Actions.define(
|
|
15
|
+
{
|
|
16
|
+
schema: { count: { required: true, number: true } },
|
|
17
|
+
maxBytes: "16kb",
|
|
18
|
+
},
|
|
19
|
+
async ({ body, user }) => {
|
|
20
|
+
return {
|
|
21
|
+
synced: true,
|
|
22
|
+
count: Number(body.count),
|
|
23
|
+
message: `Counter (${body.count}) verified on server for ${user?.name || "Member"} with CSRF & payload guard!`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const head = (data) => ({
|
|
30
|
+
title: `Dashboard — ${data.user?.name || "Member"}`,
|
|
31
|
+
description: "Protected member dashboard for Blue Bird framework.",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Dashboard page React JSX view module.
|
|
36
|
+
* @param {Object} props
|
|
37
|
+
* @param {Object} [props.user={}]
|
|
38
|
+
*/
|
|
39
|
+
export default function DashboardView({ user = {} }) {
|
|
40
|
+
const initialCount = 7;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Header title="Protected Dashboard" user={user} count={initialCount} />
|
|
45
|
+
|
|
46
|
+
<div className="space-y-6">
|
|
47
|
+
<div className="rounded-xl border border-emerald-500/30 bg-emerald-950/20 p-4 text-emerald-200 flex items-start gap-3">
|
|
48
|
+
<span className="inline-flex items-center justify-center w-6 h-6 rounded-full bg-emerald-500/20 text-emerald-400 text-xs font-bold shrink-0 mt-0.5">
|
|
49
|
+
✓
|
|
50
|
+
</span>
|
|
51
|
+
<div>
|
|
52
|
+
<strong className="font-semibold block text-emerald-100">
|
|
53
|
+
Active Protected Session (React JSX SSR)
|
|
54
|
+
</strong>
|
|
55
|
+
<p className="text-sm text-emerald-300/80 mt-0.5 leading-relaxed">
|
|
56
|
+
This route is declaratively configured via{" "}
|
|
57
|
+
<code className="px-1.5 py-0.5 rounded bg-emerald-900/40 text-emerald-200 text-xs">
|
|
58
|
+
export const middlewares = [Auth.protect({'{'} redirect: "/login" {'}'})]
|
|
59
|
+
</code>{" "}
|
|
60
|
+
inside <code>app/views/dashboard.jsx</code>.
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 shadow-sm">
|
|
66
|
+
<header className="flex items-center justify-between pb-4 border-b border-slate-800/80">
|
|
67
|
+
<div>
|
|
68
|
+
<h3 className="text-lg font-bold text-slate-100">User Profile</h3>
|
|
69
|
+
<p className="text-xs text-slate-400 mt-0.5">
|
|
70
|
+
Decoded JWT payload stored in <code className="text-sky-400">req.user</code>.
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
<span className="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">
|
|
74
|
+
Active Session
|
|
75
|
+
</span>
|
|
76
|
+
</header>
|
|
77
|
+
|
|
78
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mt-5">
|
|
79
|
+
<div className="rounded-xl border border-slate-800/80 bg-slate-950/60 p-4">
|
|
80
|
+
<span className="text-[11px] uppercase font-bold tracking-wider text-slate-400 block">
|
|
81
|
+
User Name
|
|
82
|
+
</span>
|
|
83
|
+
<div className="font-bold text-base text-slate-100 mt-1">
|
|
84
|
+
{user.name || "Anonymous"}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
<div className="rounded-xl border border-slate-800/80 bg-slate-950/60 p-4">
|
|
88
|
+
<span className="text-[11px] uppercase font-bold tracking-wider text-slate-400 block">
|
|
89
|
+
Email Address
|
|
90
|
+
</span>
|
|
91
|
+
<div className="font-bold text-base text-slate-100 mt-1">
|
|
92
|
+
{user.email || "user@example.com"}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<div className="rounded-xl border border-slate-800/80 bg-slate-950/60 p-4">
|
|
96
|
+
<span className="text-[11px] uppercase font-bold tracking-wider text-slate-400 block">
|
|
97
|
+
Account Role
|
|
98
|
+
</span>
|
|
99
|
+
<div className="mt-1">
|
|
100
|
+
<span className="inline-block px-2.5 py-0.5 rounded-md text-xs font-semibold bg-sky-500/15 text-sky-400 border border-sky-500/30">
|
|
101
|
+
{user.role || "user"}
|
|
102
|
+
</span>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
<div className="rounded-xl border border-slate-800/80 bg-slate-950/60 p-4">
|
|
106
|
+
<span className="text-[11px] uppercase font-bold tracking-wider text-slate-400 block">
|
|
107
|
+
Session Identifier
|
|
108
|
+
</span>
|
|
109
|
+
<div className="mt-1 font-mono text-xs text-slate-300 truncate">
|
|
110
|
+
{user._sessionId || "sess_active"}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<footer className="flex flex-wrap items-center justify-between gap-3 pt-5 mt-5 border-t border-slate-800/80">
|
|
116
|
+
<a
|
|
117
|
+
href="/logout"
|
|
118
|
+
data-no-prefetch="true"
|
|
119
|
+
className="px-4 py-2 rounded-lg text-sm font-semibold text-red-400 bg-red-500/10 border border-red-500/20 hover:bg-red-500/20 transition-colors"
|
|
120
|
+
>
|
|
121
|
+
Sign Out →
|
|
122
|
+
</a>
|
|
123
|
+
<div className="flex items-center gap-2">
|
|
124
|
+
<a
|
|
125
|
+
href="/about"
|
|
126
|
+
className="px-3.5 py-2 rounded-lg text-sm font-medium text-slate-300 bg-slate-800/80 border border-slate-700 hover:text-white hover:bg-slate-700 transition-colors"
|
|
127
|
+
>
|
|
128
|
+
Test Transition to /about
|
|
129
|
+
</a>
|
|
130
|
+
<a
|
|
131
|
+
href="/"
|
|
132
|
+
className="px-3.5 py-2 rounded-lg text-sm font-medium text-slate-300 bg-slate-800/80 border border-slate-700 hover:text-white hover:bg-slate-700 transition-colors"
|
|
133
|
+
>
|
|
134
|
+
Test Transition to /
|
|
135
|
+
</a>
|
|
136
|
+
</div>
|
|
137
|
+
</footer>
|
|
138
|
+
</article>
|
|
139
|
+
|
|
140
|
+
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 shadow-sm">
|
|
141
|
+
<header className="flex items-center justify-between pb-4 border-b border-slate-800/80">
|
|
142
|
+
<div>
|
|
143
|
+
<h3 className="text-lg font-bold text-slate-100">Interactive Client Controls</h3>
|
|
144
|
+
<p className="text-xs text-slate-400 mt-0.5">
|
|
145
|
+
Native inline client script and <code><Client /></code> skeleton boundary with zero layout shift.
|
|
146
|
+
</p>
|
|
147
|
+
</div>
|
|
148
|
+
<span className="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-semibold bg-sky-500/10 text-sky-400 border border-sky-500/20">
|
|
149
|
+
Live Interactive
|
|
150
|
+
</span>
|
|
151
|
+
</header>
|
|
152
|
+
|
|
153
|
+
<div className="mt-5 space-y-5">
|
|
154
|
+
<p className="text-sm text-slate-300">
|
|
155
|
+
Click the buttons below to interact without page reloads:
|
|
156
|
+
</p>
|
|
157
|
+
|
|
158
|
+
<div className="flex items-center gap-3">
|
|
159
|
+
<button
|
|
160
|
+
id="btnDec"
|
|
161
|
+
type="button"
|
|
162
|
+
className="px-3.5 py-2 rounded-lg border border-slate-700 bg-slate-800 hover:bg-slate-700 text-slate-100 font-semibold text-sm transition-colors"
|
|
163
|
+
>
|
|
164
|
+
− Decrement
|
|
165
|
+
</button>
|
|
166
|
+
<span
|
|
167
|
+
id="counterVal"
|
|
168
|
+
className="font-mono text-2xl font-bold px-4 py-1.5 bg-slate-950 border border-slate-800 text-sky-400 rounded-lg min-w-14 text-center"
|
|
169
|
+
>
|
|
170
|
+
{initialCount}
|
|
171
|
+
</span>
|
|
172
|
+
<button
|
|
173
|
+
id="btnInc"
|
|
174
|
+
type="button"
|
|
175
|
+
className="px-3.5 py-2 rounded-lg border border-slate-700 bg-slate-800 hover:bg-slate-700 text-slate-100 font-semibold text-sm transition-colors"
|
|
176
|
+
>
|
|
177
|
+
+ Increment
|
|
178
|
+
</button>
|
|
179
|
+
<button
|
|
180
|
+
id="btnReset"
|
|
181
|
+
type="button"
|
|
182
|
+
className="px-3.5 py-2 rounded-lg border border-red-500/30 bg-red-500/10 hover:bg-red-500/20 text-red-300 font-semibold text-sm transition-colors"
|
|
183
|
+
>
|
|
184
|
+
Reset
|
|
185
|
+
</button>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
<div className="pt-4 border-t border-slate-800/60">
|
|
189
|
+
<label
|
|
190
|
+
htmlFor="filterQuery"
|
|
191
|
+
className="text-xs font-semibold uppercase tracking-wider text-slate-400 block mb-2"
|
|
192
|
+
>
|
|
193
|
+
Live Input Event Listener:
|
|
194
|
+
</label>
|
|
195
|
+
<input
|
|
196
|
+
type="text"
|
|
197
|
+
id="filterQuery"
|
|
198
|
+
placeholder="Type here to test live event handling..."
|
|
199
|
+
className="w-full max-w-lg rounded-lg border border-slate-700 bg-slate-950 px-3.5 py-2.5 text-sm text-slate-100 placeholder-slate-500 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-500/20 transition-all"
|
|
200
|
+
/>
|
|
201
|
+
<p id="summaryText" className="text-xs text-slate-400 mt-2">
|
|
202
|
+
Type in the field above to test live event listening.
|
|
203
|
+
</p>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<div className="pt-4 border-t border-slate-800/60">
|
|
207
|
+
<span className="text-xs font-semibold uppercase tracking-wider text-slate-400 block mb-2">
|
|
208
|
+
Imported Client Component (<code><Client component={LiveCounter} persistent /></code>) + Server Action:
|
|
209
|
+
</span>
|
|
210
|
+
<Client
|
|
211
|
+
component={LiveCounter}
|
|
212
|
+
props={{ initial: initialCount, label: "Client Counter" }}
|
|
213
|
+
persistent={true}
|
|
214
|
+
minHeight={56}
|
|
215
|
+
skeleton={
|
|
216
|
+
<div className="h-14 rounded-xl border border-slate-800 bg-slate-950/70 px-4 flex items-center justify-between text-xs text-slate-400 animate-pulse">
|
|
217
|
+
<span>Loading Client Component...</span>
|
|
218
|
+
<span className="px-2 py-0.5 rounded bg-slate-800 text-sky-400 font-mono">
|
|
219
|
+
minHeight: 56px
|
|
220
|
+
</span>
|
|
221
|
+
</div>
|
|
222
|
+
}
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
</article>
|
|
227
|
+
|
|
228
|
+
{script(
|
|
229
|
+
(state) => {
|
|
230
|
+
let count = state.initialCount;
|
|
231
|
+
const valEl = document.getElementById("counterVal");
|
|
232
|
+
const headerBadge = document.getElementById("header-counter-badge");
|
|
233
|
+
const incBtn = document.getElementById("btnInc");
|
|
234
|
+
const decBtn = document.getElementById("btnDec");
|
|
235
|
+
const resetBtn = document.getElementById("btnReset");
|
|
236
|
+
const queryInput = document.getElementById("filterQuery");
|
|
237
|
+
const summaryEl = document.getElementById("summaryText");
|
|
238
|
+
|
|
239
|
+
const update = () => {
|
|
240
|
+
if (valEl) valEl.textContent = String(count);
|
|
241
|
+
if (headerBadge) headerBadge.textContent = String(count);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
incBtn?.addEventListener("click", () => {
|
|
245
|
+
count++;
|
|
246
|
+
update();
|
|
247
|
+
});
|
|
248
|
+
decBtn?.addEventListener("click", () => {
|
|
249
|
+
if (count > 0) count--;
|
|
250
|
+
update();
|
|
251
|
+
});
|
|
252
|
+
resetBtn?.addEventListener("click", () => {
|
|
253
|
+
count = 0;
|
|
254
|
+
update();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
queryInput?.addEventListener("input", (e) => {
|
|
258
|
+
if (summaryEl) {
|
|
259
|
+
summaryEl.textContent = e.target.value
|
|
260
|
+
? `Active query: ${e.target.value}`
|
|
261
|
+
: "Type in the field above to test live event listening.";
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
{ initialCount },
|
|
266
|
+
{ onLoad: true }
|
|
267
|
+
)}
|
|
268
|
+
|
|
269
|
+
<article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6 shadow-sm">
|
|
270
|
+
<header className="pb-3 border-b border-slate-800/80">
|
|
271
|
+
<h4 className="text-base font-bold text-slate-100">
|
|
272
|
+
Transition & Middleware Diagnostics
|
|
273
|
+
</h4>
|
|
274
|
+
</header>
|
|
275
|
+
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mt-4">
|
|
276
|
+
<div className="rounded-xl border border-slate-800 bg-slate-950/60 p-4">
|
|
277
|
+
<h5 className="font-semibold text-sm text-slate-200 mb-1">Stateful Navigation</h5>
|
|
278
|
+
<p className="text-xs text-slate-400 leading-relaxed">
|
|
279
|
+
Click links between Home, About, and Dashboard. Notice how the View Transitions API animates without page refreshes while preserving session cookies.
|
|
280
|
+
</p>
|
|
281
|
+
</div>
|
|
282
|
+
<div className="rounded-xl border border-slate-800 bg-slate-950/60 p-4">
|
|
283
|
+
<h5 className="font-semibold text-sm text-slate-200 mb-1">Zero Cache On Dashboard</h5>
|
|
284
|
+
<p className="text-xs text-slate-400 leading-relaxed">
|
|
285
|
+
Response header <code className="text-sky-400">X-Bluebird-Cache: MISS</code> is returned, verifying that user-sensitive data is never statically cached.
|
|
286
|
+
</p>
|
|
287
|
+
</div>
|
|
288
|
+
<div className="rounded-xl border border-slate-800 bg-slate-950/60 p-4">
|
|
289
|
+
<h5 className="font-semibold text-sm text-slate-200 mb-1">Automatic Revocation</h5>
|
|
290
|
+
<p className="text-xs text-slate-400 leading-relaxed">
|
|
291
|
+
Clicking "Sign Out" revokes the session in memory/Redis and clears the HttpOnly cookie, blocking subsequent dashboard visits.
|
|
292
|
+
</p>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</article>
|
|
296
|
+
</div>
|
|
297
|
+
</>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|