@seip/bluebird-js 0.1.2 → 0.1.4
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 +92 -60
- package/README.md +224 -152
- 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 +67 -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 +172 -84
- package/core/jsx.d.ts +38 -0
- package/core/jsx.js +1180 -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 +320 -43
- package/core/validate.js +1 -1
- package/core/view-loader.js +313 -22
- package/package.json +9 -3
- package/public/js/bluebird-client.js +2313 -1049
- 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/AGENTS.md
CHANGED
|
@@ -119,6 +119,20 @@ const postWithAuthor = await Post.find(10, { belongsTo: User });
|
|
|
119
119
|
const page = await User.paginate({ where: { role: "user" }, page: 1, limit: 10 });
|
|
120
120
|
await User.update(userId, { name: "Alice Smith" });
|
|
121
121
|
|
|
122
|
+
const totalUsers = await User.count({ role: "user" });
|
|
123
|
+
const exists = await User.exists({ email: "alice@example.com" });
|
|
124
|
+
|
|
125
|
+
const matching = await User.all({
|
|
126
|
+
where: {
|
|
127
|
+
id: [1, 2, 3],
|
|
128
|
+
role: { $ne: "banned" },
|
|
129
|
+
views: { $gt: 100 },
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const userRecord = await User.firstOrCreate({ email: "john@example.com" }, { name: "John Doe" });
|
|
134
|
+
const updatedRecord = await User.updateOrCreate({ email: "john@example.com" }, { name: "Johnathan" });
|
|
135
|
+
|
|
122
136
|
await User.delete(userId);
|
|
123
137
|
await User.delete(userId, { force: true });
|
|
124
138
|
await User.delete(userId, { cascade: [Post] });
|
|
@@ -356,10 +370,9 @@ npx bluebird-js make:model <Name> # BaseModel scaffolding
|
|
|
356
370
|
npx bluebird-js make:route <name> # REST route scaffolding
|
|
357
371
|
npx bluebird-js make:route <name> --auth # Authenticated REST route scaffolding
|
|
358
372
|
npx bluebird-js make:view <name> # HTML or EJS template scaffolding
|
|
359
|
-
npx bluebird-js make:migration
|
|
360
|
-
npx bluebird-js make:migration --model <Model> # Auto DDL migration
|
|
361
|
-
npx bluebird-js
|
|
362
|
-
npx bluebird-js migrate # Applies pending migrations
|
|
373
|
+
npx bluebird-js make:migration [name] # Smart auto-migration from app/models/
|
|
374
|
+
npx bluebird-js make:migration --model <Model> # Auto DDL migration for specific Model schema
|
|
375
|
+
npx bluebird-js migrate [--yes] # Executes pending migrations with auto-detection
|
|
363
376
|
npx bluebird-js migrate:status # Displays applied batches
|
|
364
377
|
npx bluebird-js migrate:rollback # Reverts latest batch
|
|
365
378
|
npx bluebird-js make:seed <name> # Database seed file creation
|
|
@@ -383,66 +396,85 @@ await Queue.dispatch("sendWelcomeEmail", { email: "user@example.com" });
|
|
|
383
396
|
await Queue.work();
|
|
384
397
|
```
|
|
385
398
|
|
|
386
|
-
## 16.
|
|
387
|
-
|
|
388
|
-
Bluebird provides a modern, zero-build view architecture uniting database-driven server-rendered HTML with
|
|
389
|
-
|
|
390
|
-
- **
|
|
391
|
-
-
|
|
392
|
-
-
|
|
399
|
+
## 16. React JSX SSR, Auto-Routes, Client Islands & View Transitions
|
|
400
|
+
|
|
401
|
+
Bluebird provides a modern, zero-build view architecture uniting database-driven server-rendered HTML with native React JSX (`.jsx`) and JavaScript (`.js`) views, declarative file-based Auto-Routes, shared layouts, Tailwind CSS v4, `<Client>` / `<Island>` components with anti-CLS skeletons, and instant View Transitions SPA navigation:
|
|
402
|
+
|
|
403
|
+
- **Built-In Tailwind CSS v4 & Inter Font**:
|
|
404
|
+
- `public/js/tailwind.js` and Google Fonts `Inter` are loaded by default in the main layout (`app/views/layouts/main/view.jsx`).
|
|
405
|
+
- Zero build steps, zero transpilation, pure modern utilities out of the box with dark mode synchronization.
|
|
406
|
+
- **Native Zero-Build React JSX SSR (`app/views/*.jsx`)**:
|
|
407
|
+
- Powered by `core/jsx.js` and Node 22.18+ native `module.registerHooks()`. Compiles `.jsx` modules in memory with **zero temporary files on disk** and **zero external npm dependencies** required.
|
|
408
|
+
- Supports `async` Server Components, Fragments (`<>...</>`), spread props, `style` objects, automatic XSS escaping, and mixed `html\`...\`` templates.
|
|
409
|
+
- **Declarative Auto-Routes from Views (`ViewLoader.discoverRoutes()` / `Render.autoRoutes()`)**:
|
|
410
|
+
- Automatically scans `app/views/` (ignoring `layouts/`, `components/`, `partials/`, `islands/`, and `/api`) and mounts GET routes when `App` starts.
|
|
411
|
+
- Export route settings directly from any view file:
|
|
412
|
+
- `export const route = "/login"` (or inferred automatically from filename; `false` disables auto-routing)
|
|
413
|
+
- `export const cache = 300` (applies `Render.cache(300)` automatically)
|
|
414
|
+
- `export const layout = "main"` (uses `app/views/layouts/main/view.jsx`)
|
|
415
|
+
- `export const middlewares = [Auth.protect({ redirect: "/login" })]`
|
|
416
|
+
- `export const seo = true` (registers route in `/sitemap.xml` and `/robots.txt`)
|
|
417
|
+
- Disable auto-discovery if desired via `new App({ noAutoDiscoverRoutes: true })`.
|
|
418
|
+
- **Client Components & Anti-Accordion Skeletons (`<Client>` / `<Island>`)**:
|
|
419
|
+
- Everything renders as pure SSR by default (0 KB client JS).
|
|
420
|
+
- For client-side interactivity (`useEffect`, `useState`, or native DOM logic), use `<Client>` or `<Island>` from `@seip/bluebird-js/core/jsx.js`.
|
|
421
|
+
- Pass `skeleton={...}`, `minHeight`, and `minWidth` to lock container dimensions before hydration and prevent layout shift ("accordion" effect), plus `persistent={true}` to preserve state across View Transitions.
|
|
422
|
+
- Supports zero-build declarative client components with standard hooks (`useState`, `useEffect`, `useRef`, `html` tagged templates) via `component={LiveCounter}` (`LiveCounter.jsx`), inline functions via `client={(el, props) => { ... }}`, and full React Islands (`npx bluebird-js add react-islands`).
|
|
423
|
+
- **Native Server Actions (`core/actions.js` & `export const actions = { ... }`)**:
|
|
424
|
+
- Next.js-style Server Actions executed on the server with automatic CSRF verification (`_csrf` cookie + `X-CSRF-Token` header), payload byte limit guards (`maxBytes`, default 64KB), prototype-pollution & depth/key sanitization (`sanitizeActionPayload`), and optional `Validator` schema checks.
|
|
425
|
+
- Triggered from the client via `await Bluebird.action("syncCount", { count: 10 })` or declarative `data-action="syncCount"` attributes on buttons/forms.
|
|
426
|
+
- **Shared Layouts (`app/views/layouts/main/view.jsx`)**:
|
|
427
|
+
- Exported via `export const layout = "main"` on any view (defaults to `"main"`). Layout receives `{ body, children, head, ctx, data }`.
|
|
393
428
|
- When requested with `X-Bluebird-Partial: 1`, layouts are automatically bypassed for fast partial swaps.
|
|
394
429
|
- Elements with `data-bb-outlet="true"` enable layout outlet swapping so navigation between pages sharing the same layout preserves header, menus, and media playback uninterrupted.
|
|
395
|
-
- **
|
|
396
|
-
-
|
|
397
|
-
-
|
|
398
|
-
-
|
|
399
|
-
-
|
|
400
|
-
-
|
|
401
|
-
-
|
|
402
|
-
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
import { html } from "@seip/bluebird-js/core/html.js";
|
|
430
|
+
- **Comprehensive Built-In Client UI Kit (`public/js/bluebird-client.js`)**:
|
|
431
|
+
- `toast({ title, description, type, position, duration })`
|
|
432
|
+
- `snackbar({ message, type, duration })`
|
|
433
|
+
- `bluebird('drawer', { id, action: 'open'|'close'|'toggle' })`
|
|
434
|
+
- `new ResponsiveDataTable(containerId, options)`
|
|
435
|
+
- `bluebird('command')` palette (`Ctrl+K`), `bluebird('tab')`, `bluebird('popover')`, `bluebird('carousel')`
|
|
436
|
+
- Declarative forms via `form[data-bb-form="true"]`: submits via `fetch`, auto-injects CSRF tokens, and follows `X-Bluebird-Redirect`.
|
|
437
|
+
- Native `document.startViewTransition()` page navigation with preserved elements via `data-persist="true"`.
|
|
438
|
+
|
|
439
|
+
```jsx
|
|
440
|
+
// app/views/dashboard.jsx
|
|
441
|
+
import Auth from "@seip/bluebird-js/core/auth.js";
|
|
442
|
+
import Actions from "@seip/bluebird-js/core/actions.js";
|
|
443
|
+
import { Client } from "@seip/bluebird-js/core/jsx.js";
|
|
444
|
+
import Header from "./components/Header.jsx";
|
|
445
|
+
import LiveCounter from "./components/LiveCounter.js";
|
|
412
446
|
|
|
447
|
+
export const route = "/dashboard";
|
|
413
448
|
export const layout = "main";
|
|
414
|
-
export const
|
|
415
|
-
|
|
416
|
-
export
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
})();
|
|
444
|
-
</script>
|
|
445
|
-
`;
|
|
449
|
+
export const middlewares = [Auth.protect({ redirect: "/login" })];
|
|
450
|
+
export const seo = false;
|
|
451
|
+
export const head = (data) => ({ title: `Dashboard — ${data.user?.name}` });
|
|
452
|
+
|
|
453
|
+
export const actions = {
|
|
454
|
+
syncCount: Actions.define(
|
|
455
|
+
{
|
|
456
|
+
maxBytes: "16kb",
|
|
457
|
+
schema: { count: { required: true, number: true } },
|
|
458
|
+
},
|
|
459
|
+
async ({ body, user }) => {
|
|
460
|
+
return { syncedCount: Number(body.count), updatedBy: user?.email };
|
|
461
|
+
}
|
|
462
|
+
),
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export default async function DashboardView({ user, syncedCount = 7 }) {
|
|
466
|
+
return (
|
|
467
|
+
<>
|
|
468
|
+
<Header title="Dashboard" user={user} count={syncedCount} />
|
|
469
|
+
<Client
|
|
470
|
+
component={LiveCounter}
|
|
471
|
+
props={{ initial: syncedCount }}
|
|
472
|
+
persistent={true}
|
|
473
|
+
minHeight={56}
|
|
474
|
+
skeleton={<div className="h-14 animate-pulse bg-slate-900 rounded-xl" />}
|
|
475
|
+
/>
|
|
476
|
+
</>
|
|
477
|
+
);
|
|
446
478
|
}
|
|
447
479
|
```
|
|
448
480
|
|