@seip/bluebird-js 0.1.1 → 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 +124 -64
- package/README.md +236 -103
- 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 +129 -22
- package/core/auth.js +1 -1
- package/core/cli/doctor.js +3 -4
- package/core/cli/init.js +153 -6
- package/core/cli/migrate.js +418 -145
- package/core/cli/view.js +76 -11
- package/core/config.js +35 -5
- package/core/csrf.js +1 -1
- package/core/database.js +52 -17
- package/core/debug.js +1 -1
- package/core/html.d.ts +54 -42
- package/core/html.js +473 -217
- package/core/index.d.ts +187 -85
- package/core/jsx.d.ts +38 -0
- package/core/jsx.js +1180 -0
- package/core/model.js +282 -61
- package/core/queue.js +7 -4
- package/core/render-cache.js +212 -212
- package/core/render.d.ts +20 -2
- package/core/render.js +320 -43
- package/core/upload.js +7 -1
- package/core/validate.js +1 -1
- package/core/view-loader.js +341 -19
- package/core/vite.js +1 -1
- 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] });
|
|
@@ -306,18 +320,46 @@ For complete deployment details including Nginx reverse proxy configuration and
|
|
|
306
320
|
|
|
307
321
|
Bluebird supports running embedded inside Electron or Tauri desktop applications where the application bundle (`.asar`) is read-only:
|
|
308
322
|
|
|
309
|
-
-
|
|
310
|
-
-
|
|
323
|
+
- **Base Directory Resolution (`appPath`)**: Accepts `appPath: electronApp.getAppPath()` (or `Config.setAppDir()`) to ensure views (`app/views/`) and static assets (`public/`) resolve accurately regardless of shortcut launch locations (`process.cwd()`).
|
|
324
|
+
- **Writable User Data (`userDataPath`)**: Automatically routes SQLite database files, `logs/`, `app/cache/`, and file uploads (`Upload.storage()`) to `Config.userDataDir()` (`electronApp.getPath("userData")`), copying bundled initial SQLite template databases from `appPath`, `process.resourcesPath`, or `.asar.unpacked` on first launch.
|
|
325
|
+
- **Dynamic Port & LAN / QR Access**:
|
|
326
|
+
- By default, binds to `127.0.0.1` with dynamic port allocation (`port: 0`) via `await app.runDesktop()`.
|
|
327
|
+
- When `{ allowLan: true }` is enabled, binds to `0.0.0.0` and returns `{ server, port, url, lanUrl, lanIp }` ready for mobile QR code access on local WiFi.
|
|
328
|
+
- **Uploads & Static Serving**:
|
|
329
|
+
- In desktop mode, `Upload.storage()` writes to `userDataDir/uploads` and `App` automatically mounts `/uploads` to serve uploaded files statically without read-only filesystem errors.
|
|
330
|
+
- **Clean Shutdown & WAL Checkpoint**:
|
|
331
|
+
- Invoking `await app.close()` (e.g. in Electron `app.on("before-quit")`) automatically checkpoints SQLite WAL (`PRAGMA wal_checkpoint(TRUNCATE)`), closes open database handles via `Database.closeAll()`, and frees Windows file locks cleanly.
|
|
332
|
+
- **Packaging with electron-builder**:
|
|
333
|
+
- Recommended `electron-builder` configuration in `package.json`:
|
|
334
|
+
```json
|
|
335
|
+
"build": {
|
|
336
|
+
"asar": true,
|
|
337
|
+
"asarUnpack": ["app/views/**/*", "database/**/*"]
|
|
338
|
+
}
|
|
339
|
+
```
|
|
311
340
|
|
|
312
341
|
```javascript
|
|
342
|
+
import App from "@seip/bluebird-js/core/app.js";
|
|
343
|
+
import { app as electronApp, BrowserWindow } from "electron";
|
|
344
|
+
import routerApi from "./app/routes/api.js";
|
|
345
|
+
import routerWeb from "./app/routes/web.js";
|
|
346
|
+
|
|
313
347
|
const app = new App({
|
|
314
348
|
desktop: true,
|
|
349
|
+
appPath: electronApp.getAppPath(),
|
|
315
350
|
userDataPath: electronApp.getPath("userData"),
|
|
316
351
|
routes: [routerWeb, routerApi],
|
|
317
352
|
});
|
|
318
353
|
|
|
319
|
-
|
|
320
|
-
|
|
354
|
+
electronApp.whenReady().then(async () => {
|
|
355
|
+
const { url, port, lanUrl, lanIp } = await app.runDesktop({ allowLan: true });
|
|
356
|
+
const mainWindow = new BrowserWindow({ width: 1200, height: 800 });
|
|
357
|
+
mainWindow.loadURL(url);
|
|
358
|
+
|
|
359
|
+
electronApp.on("before-quit", async () => {
|
|
360
|
+
await app.close();
|
|
361
|
+
});
|
|
362
|
+
});
|
|
321
363
|
```
|
|
322
364
|
|
|
323
365
|
## 14. Developer Tooling CLI
|
|
@@ -328,10 +370,9 @@ npx bluebird-js make:model <Name> # BaseModel scaffolding
|
|
|
328
370
|
npx bluebird-js make:route <name> # REST route scaffolding
|
|
329
371
|
npx bluebird-js make:route <name> --auth # Authenticated REST route scaffolding
|
|
330
372
|
npx bluebird-js make:view <name> # HTML or EJS template scaffolding
|
|
331
|
-
npx bluebird-js make:migration
|
|
332
|
-
npx bluebird-js make:migration --model <Model> # Auto DDL migration
|
|
333
|
-
npx bluebird-js
|
|
334
|
-
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
|
|
335
376
|
npx bluebird-js migrate:status # Displays applied batches
|
|
336
377
|
npx bluebird-js migrate:rollback # Reverts latest batch
|
|
337
378
|
npx bluebird-js make:seed <name> # Database seed file creation
|
|
@@ -355,66 +396,85 @@ await Queue.dispatch("sendWelcomeEmail", { email: "user@example.com" });
|
|
|
355
396
|
await Queue.work();
|
|
356
397
|
```
|
|
357
398
|
|
|
358
|
-
## 16.
|
|
359
|
-
|
|
360
|
-
Bluebird provides a modern, zero-build view architecture uniting database-driven server-rendered HTML with
|
|
361
|
-
|
|
362
|
-
- **
|
|
363
|
-
-
|
|
364
|
-
-
|
|
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 }`.
|
|
365
428
|
- When requested with `X-Bluebird-Partial: 1`, layouts are automatically bypassed for fast partial swaps.
|
|
366
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.
|
|
367
|
-
- **
|
|
368
|
-
-
|
|
369
|
-
-
|
|
370
|
-
-
|
|
371
|
-
-
|
|
372
|
-
-
|
|
373
|
-
-
|
|
374
|
-
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
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";
|
|
384
446
|
|
|
447
|
+
export const route = "/dashboard";
|
|
385
448
|
export const layout = "main";
|
|
386
|
-
export const
|
|
387
|
-
|
|
388
|
-
export
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
})();
|
|
416
|
-
</script>
|
|
417
|
-
`;
|
|
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
|
+
);
|
|
418
478
|
}
|
|
419
479
|
```
|
|
420
480
|
|