@seip/bluebird-js 0.1.6 → 0.1.7

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/app/routes/web.js CHANGED
@@ -1,47 +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
- * 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;
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;
@@ -1,42 +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
-
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
+
@@ -1,16 +1,16 @@
1
- import { useState, useEffect, useAction } from "@seip/bluebird-js/core/jsx.js";
2
- import { html } from "@seip/bluebird-js/core/html.js";
1
+ import { useState, useEffect, useAction, client } from "@seip/bluebird-js/core/jsx.js";
3
2
 
4
3
  /**
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).
4
+ * Reusable reactive Client Counter component with pure JSX/TSX support.
5
+ * Powered by Bluebird's zero-build client runtime with hooks (useState, useEffect, useAction) and real JSX.
7
6
  *
8
7
  * @param {Object} props
9
8
  * @param {number} [props.initial=7]
10
9
  * @param {string} [props.label="Client Component Counter"]
11
10
  * @returns {any}
12
11
  */
13
- export default function LiveCounter({ initial = 7, label = "Client Component Counter" }) {
12
+
13
+ export function LiveCounter({ initial = 7, label = "Client Component Counter" }) {
14
14
  const [count, setCount] = useState(Number(initial) || 0);
15
15
  const [sync, isPending] = useAction("syncCount", {
16
16
  onSuccess(res) {
@@ -29,38 +29,39 @@ export default function LiveCounter({ initial = 7, label = "Client Component Cou
29
29
  if (badge) badge.textContent = String(count);
30
30
  }, [count]);
31
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>
32
+ return (
33
+ <div className="h-14 rounded-xl border border-slate-800 bg-slate-950/90 px-4 flex items-center justify-between">
34
+ <div className="flex items-center gap-2.5">
35
+ <span className={`w-2 h-2 rounded-full ${isPending ? "bg-amber-400" : "bg-emerald-400"} animate-pulse`} />
36
+ <span className="text-xs font-medium text-slate-300">{label}:</span>
37
+ <strong data-counter-val className="font-mono text-base text-sky-400">{count}</strong>
38
38
  </div>
39
- <div class="flex items-center gap-2">
39
+ <div className="flex items-center gap-2">
40
40
  <button
41
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"
42
+ onClick={() => setCount(Math.max(0, count - 1))}
43
+ className="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
44
  >
45
45
  &minus;
46
46
  </button>
47
47
  <button
48
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"
49
+ onClick={() => setCount(count + 1)}
50
+ className="px-2.5 py-1 rounded-lg bg-sky-500 hover:bg-sky-400 text-xs font-bold text-slate-950 transition-colors"
51
51
  >
52
52
  &plus;
53
53
  </button>
54
54
  <button
55
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"
56
+ onClick={() => sync({ count })}
57
+ disabled={isPending}
58
+ className="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
59
  >
60
- ${isPending ? "Syncing..." : "Sync Action"}
60
+ {isPending ? "Syncing..." : "Sync Action"}
61
61
  </button>
62
62
  </div>
63
63
  </div>
64
- `;
64
+ );
65
65
  }
66
66
 
67
+ export default client(LiveCounter, { minHeight: 56 });