@seip/bluebird-js 0.1.7 → 0.2.0

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.
Files changed (148) hide show
  1. package/AGENTS.md +726 -620
  2. package/README.md +615 -607
  3. package/app/models/user.js +19 -0
  4. package/app/resources/html/home.html +137 -0
  5. package/app/resources/html/layouts/main.html +54 -0
  6. package/app/resources/html/notFound.html +14 -0
  7. package/app/resources/html/terms.html +46 -0
  8. package/app/resources/index.html +27 -0
  9. package/app/resources/layouts/AppLayout.jsx +89 -0
  10. package/app/resources/main.jsx +18 -0
  11. package/app/resources/pages/Dashboard.jsx +98 -0
  12. package/app/resources/pages/Home.jsx +140 -0
  13. package/app/resources/pages/Login.jsx +35 -0
  14. package/app/resources/pages/NotFound.jsx +16 -0
  15. package/app/resources/pages/Register.jsx +55 -0
  16. package/app/resources/routes.jsx +54 -0
  17. package/app/resources/spa.js +67 -0
  18. package/app/resources/styles.css +9 -0
  19. package/app/routes/api.js +85 -50
  20. package/app/routes/auth.js +209 -0
  21. package/app/routes/web.js +59 -47
  22. package/core/ai.js +30 -10
  23. package/core/app.d.ts +2 -18
  24. package/core/app.js +987 -801
  25. package/core/auth.d.ts +2 -13
  26. package/core/auth.js +444 -326
  27. package/core/cli/build.js +37 -0
  28. package/core/cli/dev.js +155 -0
  29. package/core/cli/doctor.js +37 -2
  30. package/core/cli/export.js +191 -0
  31. package/core/cli/init.js +91 -322
  32. package/core/cli/nginx.js +1 -1
  33. package/core/cli/templates.js +139 -0
  34. package/core/cli/view.js +98 -161
  35. package/core/config.js +44 -2
  36. package/core/csrf.js +156 -24
  37. package/core/database.js +1184 -1131
  38. package/core/debug.js +1 -1
  39. package/core/html.js +8 -1
  40. package/core/index.d.ts +126 -310
  41. package/core/paths.js +55 -0
  42. package/core/ratelimit.js +10 -1
  43. package/core/react/client/api.js +237 -0
  44. package/core/react/client/auth.js +236 -0
  45. package/core/react/client/components.js +1321 -0
  46. package/core/react/client/i18n.js +338 -0
  47. package/core/react/client/index.d.ts +249 -0
  48. package/core/react/client/index.js +49 -0
  49. package/core/react/client/router.js +26 -0
  50. package/core/react/client/theme.css +512 -0
  51. package/core/render-cache.js +250 -212
  52. package/core/render.d.ts +25 -21
  53. package/core/render.js +738 -736
  54. package/core/router.d.ts +2 -3
  55. package/core/router.js +171 -171
  56. package/core/seo.js +10 -0
  57. package/core/spa.js +599 -0
  58. package/core/view-loader.js +155 -613
  59. package/core/vite-plugin.d.ts +18 -0
  60. package/core/vite-plugin.js +162 -0
  61. package/core/vite.js +250 -145
  62. package/index.js +22 -18
  63. package/jsconfig.json +5 -3
  64. package/package.json +114 -92
  65. package/production.md +8 -3
  66. package/public/js/bluebird.js +1160 -0
  67. package/templates/_auth/app/database.js +19 -0
  68. package/templates/_auth/app/models/user.js +22 -0
  69. package/templates/_auth/app/routes/auth-router.js +304 -0
  70. package/templates/_base/app/resources/html/layouts/main.html +55 -0
  71. package/templates/_base/app/resources/html/notFound.html +14 -0
  72. package/templates/_base/app/resources/index.html +27 -0
  73. package/templates/_base/app/resources/styles.css +9 -0
  74. package/templates/api/app/models/note.js +18 -0
  75. package/templates/api/app/routes/api.js +82 -0
  76. package/templates/api/app/routes/auth.js +11 -0
  77. package/templates/api/index.js +19 -0
  78. package/templates/api/template.json +13 -0
  79. package/templates/auth/app/mail.js +11 -0
  80. package/templates/auth/app/models/password_reset.js +18 -0
  81. package/templates/auth/app/resources/html/home.html +21 -0
  82. package/templates/auth/app/resources/html/partials/nav.html +2 -0
  83. package/templates/auth/app/resources/layouts/AppLayout.jsx +60 -0
  84. package/templates/auth/app/resources/main.jsx +18 -0
  85. package/templates/auth/app/resources/pages/Dashboard.jsx +51 -0
  86. package/templates/auth/app/resources/pages/ForgotPassword.jsx +34 -0
  87. package/templates/auth/app/resources/pages/Login.jsx +36 -0
  88. package/templates/auth/app/resources/pages/NotFound.jsx +16 -0
  89. package/templates/auth/app/resources/pages/Profile.jsx +99 -0
  90. package/templates/auth/app/resources/pages/Register.jsx +50 -0
  91. package/templates/auth/app/resources/pages/ResetPassword.jsx +50 -0
  92. package/templates/auth/app/resources/routes.jsx +54 -0
  93. package/templates/auth/app/resources/spa.js +29 -0
  94. package/templates/auth/app/routes/api.js +17 -0
  95. package/templates/auth/app/routes/auth.js +13 -0
  96. package/templates/auth/app/routes/web.js +21 -0
  97. package/templates/auth/index.js +19 -0
  98. package/templates/auth/template.json +15 -0
  99. package/templates/blank/app/models/.gitkeep +0 -0
  100. package/templates/blank/app/resources/html/home.html +27 -0
  101. package/templates/blank/app/resources/html/partials/nav.html +1 -0
  102. package/templates/blank/app/resources/main.jsx +16 -0
  103. package/templates/blank/app/resources/pages/Home.jsx +42 -0
  104. package/templates/blank/app/resources/pages/NotFound.jsx +27 -0
  105. package/templates/blank/app/resources/routes.jsx +15 -0
  106. package/templates/blank/app/resources/spa.js +24 -0
  107. package/templates/blank/app/routes/api.js +11 -0
  108. package/templates/blank/app/routes/web.js +21 -0
  109. package/templates/blank/index.js +13 -0
  110. package/templates/blank/template.json +12 -0
  111. package/templates/blog/app/lib/blog.js +149 -0
  112. package/templates/blog/app/models/post.js +22 -0
  113. package/templates/blog/app/resources/html/home.html +28 -0
  114. package/templates/blog/app/resources/html/not-found.html +5 -0
  115. package/templates/blog/app/resources/html/partials/nav.html +2 -0
  116. package/templates/blog/app/resources/html/partials/post-card.html +9 -0
  117. package/templates/blog/app/resources/html/post.html +8 -0
  118. package/templates/blog/app/resources/layouts/AdminLayout.jsx +54 -0
  119. package/templates/blog/app/resources/main.jsx +18 -0
  120. package/templates/blog/app/resources/pages/Login.jsx +31 -0
  121. package/templates/blog/app/resources/pages/NotFound.jsx +16 -0
  122. package/templates/blog/app/resources/pages/PostEditor.jsx +51 -0
  123. package/templates/blog/app/resources/pages/Posts.jsx +83 -0
  124. package/templates/blog/app/resources/pages/Register.jsx +43 -0
  125. package/templates/blog/app/resources/routes.jsx +51 -0
  126. package/templates/blog/app/resources/spa.js +25 -0
  127. package/templates/blog/app/resources/styles.css +40 -0
  128. package/templates/blog/app/routes/api.js +77 -0
  129. package/templates/blog/app/routes/auth.js +10 -0
  130. package/templates/blog/app/routes/web.js +114 -0
  131. package/templates/blog/index.js +21 -0
  132. package/templates/blog/template.json +14 -0
  133. package/vite.config.js +11 -0
  134. package/app/views/components/Header.jsx +0 -42
  135. package/app/views/components/LiveCounter.jsx +0 -67
  136. package/app/views/layouts/main/view.jsx +0 -201
  137. package/app/views/legal/terms.html +0 -29
  138. package/app/views/pages/about.jsx +0 -98
  139. package/app/views/pages/dashboard.jsx +0 -278
  140. package/app/views/pages/index.jsx +0 -123
  141. package/app/views/pages/login.jsx +0 -141
  142. package/core/actions.d.ts +0 -4
  143. package/core/actions.js +0 -355
  144. package/core/jsx.d.ts +0 -38
  145. package/core/jsx.js +0 -1597
  146. package/core/vite.d.ts +0 -3
  147. package/public/js/bluebird-client.js +0 -3265
  148. package/public/js/tailwind.js +0 -8
package/core/cli/init.js CHANGED
@@ -7,6 +7,7 @@ import { stdin as input, stdout as output } from "node:process";
7
7
  import crypto from "node:crypto";
8
8
  import { execSync } from "node:child_process";
9
9
  import colors from "../util/colors.js";
10
+ import { describeTemplates, listTemplates, loadTemplate, parseTemplateArg, readFlag, scaffoldTemplate } from "./templates.js";
10
11
 
11
12
  try {
12
13
  process.loadEnvFile?.();
@@ -27,9 +28,22 @@ class ProjectInit {
27
28
  async run() {
28
29
  console.log(colors.cyan("Starting Bluebird project initialization..."));
29
30
 
31
+ const argv = process.argv.slice(2);
32
+ let templateName = parseTemplateArg(argv, listTemplates(this.sourceDir).map((t) => t.name));
33
+ let template = null;
34
+ if (templateName) {
35
+ if (!listTemplates(this.sourceDir).some((t) => t.name === templateName)) {
36
+ console.error(colors.red(`[ERROR] Unknown template '${templateName}'.`));
37
+ console.log(describeTemplates(this.sourceDir));
38
+ process.exitCode = 1;
39
+ return;
40
+ }
41
+ template = loadTemplate(this.sourceDir, templateName);
42
+ }
43
+
30
44
  const rl = readline.createInterface({ input, output });
31
45
 
32
- let title = "Bluebird App";
46
+ let title = readFlag(argv, "title") || "Bluebird App";
33
47
  let port = 3000;
34
48
  let appUrl = "http://localhost:3000";
35
49
  let dbType = "sqlite";
@@ -55,6 +69,17 @@ class ProjectInit {
55
69
 
56
70
  title = await ask("Project Title", title);
57
71
 
72
+ if (!templateName) {
73
+ const names = listTemplates(this.sourceDir).map((t) => t.name);
74
+ console.log(colors.gray(describeTemplates(this.sourceDir)));
75
+ const picked = String(await ask(`Template (${names.join(" / ")})`, "blank")).trim().toLowerCase();
76
+ templateName = names.includes(picked) ? picked : "blank";
77
+ if (picked !== templateName) {
78
+ console.log(colors.yellow(`[WARN] Unknown template '${picked}'. Using 'blank'.`));
79
+ }
80
+ }
81
+ template = loadTemplate(this.sourceDir, templateName);
82
+
58
83
  const portInput = await ask("Server Port", port);
59
84
  port = parseInt(portInput, 10);
60
85
  if (Number.isNaN(port)) {
@@ -99,6 +124,10 @@ class ProjectInit {
99
124
  cleanDbTypeAns === "0"
100
125
  ) {
101
126
  dbType = "none";
127
+ if (template.database === "required") {
128
+ console.log(colors.yellow(`[WARN] The '${template.name}' template needs a database. Using 'sqlite'.`));
129
+ dbType = "sqlite";
130
+ }
102
131
  } else {
103
132
  console.log(colors.yellow(`[WARN] Unknown database '${dbTypeAns}'. Defaulting to 'sqlite'.`));
104
133
  dbType = "sqlite";
@@ -151,17 +180,23 @@ class ProjectInit {
151
180
  rl.close();
152
181
  }
153
182
 
154
- const itemsToCopy = [
155
- "index.js",
156
- "app",
157
- "public",
158
- ".env_example",
159
- "AGENTS.md",
160
- "jsconfig.json",
161
- ".vscode",
162
- ];
183
+ const itemsToCopy = template.demo
184
+ ? ["index.js", "vite.config.js", "app", "public", ".env_example", "AGENTS.md", "jsconfig.json", ".vscode"]
185
+ : template.client
186
+ ? ["vite.config.js", "public", ".env_example", "AGENTS.md", "jsconfig.json", ".vscode"]
187
+ : [".env_example", "AGENTS.md", "jsconfig.json", ".vscode"];
163
188
 
164
189
  try {
190
+ if (!template.demo) {
191
+ const result = scaffoldTemplate(this.sourceDir, this.appDir, template, { title });
192
+ console.log(
193
+ colors.green(`[OK] Created the '${template.name}' template (${result.written.length} files).`)
194
+ );
195
+ if (result.skipped.length > 0) {
196
+ console.log(colors.yellow(`[SKIP] ${result.skipped.length} existing files kept: ${result.skipped.join(", ")}`));
197
+ }
198
+ }
199
+
165
200
  itemsToCopy.forEach((item) => {
166
201
  const src = path.join(this.sourceDir, item);
167
202
  const dest = path.join(this.appDir, item);
@@ -176,7 +211,7 @@ class ProjectInit {
176
211
  }
177
212
  });
178
213
 
179
- const gitignoreContent = "node_modules\nlogs\n.env\napp/cache\npackage-lock.json\n*.db\n*.sqlite\n*.sqlite-wal\n*.sqlite-shm\n*.db-wal\n*.db-shm\nbackups/*.sql\nbackups/*.db\n";
214
+ const gitignoreContent = "node_modules\nlogs\n.env\napp/cache\ndist\npublic/build\npackage-lock.json\n*.db\n*.sqlite\n*.sqlite-wal\n*.sqlite-shm\n*.db-wal\n*.db-shm\nbackups/*.sql\nbackups/*.db\n";
180
215
  const gitignoreDest = path.join(this.appDir, ".gitignore");
181
216
  const gitignoreSrc = path.join(this.sourceDir, ".gitignore");
182
217
 
@@ -261,8 +296,12 @@ ${dbEnvBlock}
261
296
  }
262
297
  }
263
298
 
264
- console.log(colors.blue("\nBluebird initialization completed!"));
299
+ console.log(colors.blue(`\nBluebird initialization completed! Template: ${template.name}`));
300
+ for (const line of template.routes || []) console.log(colors.gray(` ${line}`));
265
301
  console.log(colors.white("Next steps:"));
302
+ if (!fs.existsSync(path.join(this.appDir, "node_modules", "@seip", "bluebird-js"))) {
303
+ console.log(colors.bold(" npm install"));
304
+ }
266
305
  console.log(colors.bold(" npm run dev"));
267
306
  } catch (error) {
268
307
  console.error(colors.red("[ERROR] Error during initialization:"), error.message);
@@ -290,7 +329,7 @@ ${dbEnvBlock}
290
329
  version: "1.0.0",
291
330
  type: "module",
292
331
  dependencies: {
293
- "@seip/bluebird-js": "^0.1.6",
332
+ "@seip/bluebird-js": this.frameworkVersion(),
294
333
  },
295
334
  };
296
335
  }
@@ -299,8 +338,10 @@ ${dbEnvBlock}
299
338
  const entryFile = "index.js";
300
339
 
301
340
  const scriptsToAdd = {
302
- dev: `node --watch --env-file=.env ${entryFile}`,
303
- start: `node --env-file=.env ${entryFile}`,
341
+ dev: `bluebird-js dev ${entryFile}`,
342
+ build: "bluebird-js build",
343
+ export: "bluebird-js export",
344
+ start: `node --env-file-if-exists=.env ${entryFile}`,
304
345
  init: "bluebird-js",
305
346
  doctor: "bluebird-js doctor",
306
347
  route: "bluebird-js make:route",
@@ -326,13 +367,26 @@ ${dbEnvBlock}
326
367
  pkg.dependencies = {};
327
368
  }
328
369
  if (!pkg.dependencies["@seip/bluebird-js"]) {
329
- pkg.dependencies["@seip/bluebird-js"] = "^0.1.6";
370
+ pkg.dependencies["@seip/bluebird-js"] = this.frameworkVersion();
330
371
  }
331
372
 
332
373
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
333
374
  console.log(colors.green("[OK] Configured package.json with scripts and dependencies."));
334
375
  }
335
376
 
377
+ /**
378
+ * Returns the semver range of the running framework package (e.g. "^1.0.0-alpha.0").
379
+ * @returns {string}
380
+ */
381
+ frameworkVersion() {
382
+ try {
383
+ const own = JSON.parse(fs.readFileSync(path.join(this.sourceDir, "package.json"), "utf-8"));
384
+ return own.version ? `^${own.version}` : "latest";
385
+ } catch {
386
+ return "latest";
387
+ }
388
+ }
389
+
336
390
  /**
337
391
  * Copies a file or directory recursively.
338
392
  * @param {string} src - Source path.
@@ -350,6 +404,7 @@ ${dbEnvBlock}
350
404
  if (
351
405
  childItemName === "node_modules" ||
352
406
  childItemName === "dist" ||
407
+ childItemName === "build" ||
353
408
  childItemName === ".git" ||
354
409
  childItemName === "cache"
355
410
  ) {
@@ -366,292 +421,6 @@ ${dbEnvBlock}
366
421
  }
367
422
  }
368
423
 
369
- /**
370
- * Scaffolds React Islands architecture with Vite.
371
- */
372
- function setupReactIslands() {
373
- const appDir = process.cwd();
374
- console.log(colors.cyan("[INFO] Setting up React Islands with Vite..."));
375
-
376
- try {
377
- execSync("npm install react react-dom", { stdio: "inherit", cwd: appDir });
378
- execSync("npm install -D vite @vitejs/plugin-react", { stdio: "inherit", cwd: appDir });
379
- console.log(colors.green("[OK] Installed React and Vite dependencies."));
380
- } catch (err) {
381
- console.warn(colors.yellow("[WARN] Package installation failed. Run 'npm install react react-dom && npm install -D vite @vitejs/plugin-react' manually."));
382
- }
383
-
384
- const viteConfigPath = path.join(appDir, "vite.config.js");
385
- if (!fs.existsSync(viteConfigPath)) {
386
- const viteConfigContent = `import { defineConfig } from "vite";
387
- import react from "@vitejs/plugin-react";
388
-
389
- export default defineConfig({
390
- plugins: [react()],
391
- build: {
392
- outDir: "public/dist",
393
- emptyOutDir: true,
394
- manifest: true,
395
- rollupOptions: {
396
- input: "src/islands/main.jsx",
397
- },
398
- },
399
- server: {
400
- port: 5173,
401
- strictPort: true,
402
- cors: true,
403
- },
404
- });
405
- `;
406
- fs.writeFileSync(viteConfigPath, viteConfigContent, "utf-8");
407
- console.log(colors.green("[OK] Created vite.config.js"));
408
- }
409
-
410
- const islandsDir = path.join(appDir, "src/islands");
411
- if (!fs.existsSync(islandsDir)) {
412
- fs.mkdirSync(islandsDir, { recursive: true });
413
- }
414
-
415
- const mainPath = path.join(islandsDir, "main.jsx");
416
- if (!fs.existsSync(mainPath)) {
417
- const mainContent = `import React from "react";
418
- import ReactDOM from "react-dom/client";
419
- import RadioPlayer from "./RadioPlayer.jsx";
420
- import LiveCounter from "./LiveCounter.jsx";
421
-
422
- window.__BLUEBIRD_ISLANDS__ = window.__BLUEBIRD_ISLANDS__ || {};
423
-
424
- window.__BLUEBIRD_ISLANDS__["RadioPlayer"] = RadioPlayer;
425
- window.__BLUEBIRD_ISLANDS__["LiveCounter"] = LiveCounter;
426
-
427
- window.__BLUEBIRD_MOUNT__ = (el, Component, props, hydrate = false) => {
428
- const element = React.createElement(Component, props);
429
- if (hydrate && el.innerHTML.trim().length > 0 && typeof ReactDOM.hydrateRoot === "function") {
430
- const root = ReactDOM.hydrateRoot(el, element);
431
- return () => root.unmount();
432
- }
433
- const root = ReactDOM.createRoot(el);
434
- root.render(element);
435
- return () => root.unmount();
436
- };
437
-
438
- if (window.Bluebird && typeof window.Bluebird.hydrate === "function") {
439
- window.Bluebird.hydrate();
440
- }
441
- `;
442
- fs.writeFileSync(mainPath, mainContent, "utf-8");
443
- console.log(colors.green("[OK] Created src/islands/main.jsx"));
444
- }
445
-
446
- const radioPath = path.join(islandsDir, "RadioPlayer.jsx");
447
- if (!fs.existsSync(radioPath)) {
448
- const radioContent = `import React, { useState, useEffect } from "react";
449
-
450
- export default function RadioPlayer({ title = "Bluebird Radio", streamUrl = "" }) {
451
- const [isPlaying, setIsPlaying] = useState(false);
452
- const [currentTrack, setCurrentTrack] = useState("Live Broadcast #1");
453
- const [listeners, setListeners] = useState(142);
454
-
455
- useEffect(() => {
456
- const interval = setInterval(() => {
457
- setListeners((prev) => prev + Math.floor(Math.random() * 5) - 2);
458
- }, 4000);
459
-
460
- const unsubscribe = window.Bluebird?.on?.("radio:track", (track) => {
461
- if (track) setCurrentTrack(track);
462
- });
463
-
464
- return () => {
465
- clearInterval(interval);
466
- if (unsubscribe) unsubscribe();
467
- };
468
- }, []);
469
-
470
- const togglePlay = () => {
471
- setIsPlaying((prev) => !prev);
472
- window.Bluebird?.emit?.("radio:state", { playing: !isPlaying, track: currentTrack });
473
- };
474
-
475
- return (
476
- <div style={{
477
- background: "linear-gradient(135deg, #0f172a 0%, #1e293b 100%)",
478
- color: "#f8fafc",
479
- padding: "1.25rem",
480
- borderRadius: "1rem",
481
- border: "1px solid #334155",
482
- boxShadow: "0 10px 25px -5px rgba(0,0,0,0.3)",
483
- display: "flex",
484
- alignItems: "center",
485
- justifyContent: "space-between",
486
- gap: "1rem",
487
- fontFamily: "system-ui, -apple-system, sans-serif"
488
- }}>
489
- <div style={{ display: "flex", alignItems: "center", gap: "1rem" }}>
490
- <button
491
- onClick={togglePlay}
492
- style={{
493
- width: "3rem",
494
- height: "3rem",
495
- borderRadius: "50%",
496
- border: "none",
497
- background: isPlaying ? "#ef4444" : "#3b82f6",
498
- color: "#ffffff",
499
- fontSize: "1.25rem",
500
- cursor: "pointer",
501
- display: "flex",
502
- alignItems: "center",
503
- justifyContent: "center",
504
- boxShadow: isPlaying ? "0 0 15px rgba(239, 68, 68, 0.5)" : "0 0 15px rgba(59, 130, 246, 0.5)"
505
- }}
506
- >
507
- {isPlaying ? "āø" : "ā–¶"}
508
- </button>
509
- <div>
510
- <div style={{ fontSize: "0.875rem", fontWeight: 700, color: "#93c5fd" }}>{title}</div>
511
- <div style={{ fontSize: "1rem", fontWeight: 600 }}>{currentTrack}</div>
512
- <div style={{ fontSize: "0.75rem", color: "#94a3b8" }}>{listeners} active listeners • Live Stream</div>
513
- </div>
514
- </div>
515
- <div style={{
516
- padding: "0.25rem 0.75rem",
517
- borderRadius: "9999px",
518
- background: isPlaying ? "rgba(34, 197, 94, 0.2)" : "rgba(148, 163, 184, 0.2)",
519
- color: isPlaying ? "#4ade80" : "#94a3b8",
520
- fontSize: "0.75rem",
521
- fontWeight: 700,
522
- textTransform: "uppercase"
523
- }}>
524
- {isPlaying ? "ā— On Air" : "ā—‹ Paused"}
525
- </div>
526
- </div>
527
- );
528
- }
529
- `;
530
- fs.writeFileSync(radioPath, radioContent, "utf-8");
531
- console.log(colors.green("[OK] Created src/islands/RadioPlayer.jsx (sample persistent island)"));
532
- }
533
-
534
- const counterPath = path.join(islandsDir, "LiveCounter.jsx");
535
- if (!fs.existsSync(counterPath)) {
536
- const counterContent = `import React, { useState } from "react";
537
-
538
- export default function LiveCounter({ initial = 0, label = "Interactive Counter" }) {
539
- const [count, setCount] = useState(initial);
540
-
541
- const increment = () => {
542
- const next = count + 1;
543
- setCount(next);
544
- window.Bluebird?.emit?.("counter:change", next);
545
- };
546
-
547
- const decrement = () => {
548
- const next = count - 1;
549
- setCount(next);
550
- window.Bluebird?.emit?.("counter:change", next);
551
- };
552
-
553
- return (
554
- <div style={{
555
- display: "inline-flex",
556
- alignItems: "center",
557
- gap: "0.75rem",
558
- padding: "0.5rem 1rem",
559
- background: "#f1f5f9",
560
- borderRadius: "0.75rem",
561
- border: "1px solid #cbd5e1",
562
- fontFamily: "system-ui, sans-serif"
563
- }}>
564
- <span style={{ fontWeight: 600, color: "#334155" }}>{label}:</span>
565
- <button onClick={decrement} style={{ padding: "0.25rem 0.5rem", borderRadius: "0.375rem", border: "1px solid #94a3b8", cursor: "pointer" }}>-</button>
566
- <span style={{ minWidth: "1.5rem", textAlign: "center", fontWeight: 700, color: "#0f172a" }}>{count}</span>
567
- <button onClick={increment} style={{ padding: "0.25rem 0.5rem", borderRadius: "0.375rem", border: "1px solid #94a3b8", cursor: "pointer" }}>+</button>
568
- </div>
569
- );
570
- }
571
- `;
572
- fs.writeFileSync(counterPath, counterContent, "utf-8");
573
- console.log(colors.green("[OK] Created src/islands/LiveCounter.jsx"));
574
- }
575
-
576
- const demoViewPath = path.join(appDir, "app/views/islands-demo.html");
577
- if (!fs.existsSync(demoViewPath)) {
578
- const demoContent = `<!DOCTYPE html>
579
- <html lang="en">
580
- <head>
581
- <meta charset="UTF-8">
582
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
583
- <title>{{ title }}</title>
584
- <meta name="description" content="{{ description }}">
585
- <link rel="preconnect" href="https://fonts.googleapis.com">
586
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
587
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
588
- <script src="/js/tailwind.js"></script>
589
- <style type="text/tailwindcss">
590
- @custom-variant dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));
591
- @theme {
592
- --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
593
- }
594
- </style>
595
- {{{ bluebirdHead }}}
596
- </head>
597
- <body style="padding: 2rem; max-width: 800px; margin: 0 auto; font-family: system-ui, sans-serif;">
598
- <header style="margin-bottom: 2rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 1rem;">
599
- <h1>{{ title }}</h1>
600
- <p style="color: #64748b;">{{ description }}</p>
601
- <nav style="display: flex; gap: 1rem; margin-top: 1rem;">
602
- <a href="/islands-demo">Demo Home</a>
603
- <a href="/about">About Us (Test Navigation)</a>
604
- </nav>
605
- </header>
606
-
607
- <main style="display: flex; flex-direction: column; gap: 2rem;">
608
- <section>
609
- <h2>1. Persistent Audio Stream Island</h2>
610
- <p style="color: #64748b; font-size: 0.9rem;">
611
- Click Play, then navigate to other pages above. Notice the audio player keeps playing without interrupting!
612
- </p>
613
- <div data-island="RadioPlayer" data-persist="true" data-props='{"title": "Bluebird Live FM"}'></div>
614
- </section>
615
-
616
- <section>
617
- <h2>2. Standard Reactive Island</h2>
618
- <p style="color: #64748b; font-size: 0.9rem;">
619
- Interactive state-driven React component rendered inside pure SSR HTML.
620
- </p>
621
- <div data-island="LiveCounter" data-props='{"initial": 10, "label": "Session Taps"}'></div>
622
- </section>
623
- </main>
624
-
625
- <script src="/js/bluebird-client.js"></script>
626
- </body>
627
- </html>
628
- `;
629
- fs.writeFileSync(demoViewPath, demoContent, "utf-8");
630
- console.log(colors.green("[OK] Created app/views/islands-demo.html"));
631
- }
632
-
633
- const pkgPath = path.join(appDir, "package.json");
634
- if (fs.existsSync(pkgPath)) {
635
- try {
636
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
637
- pkg.scripts = pkg.scripts || {};
638
- pkg.scripts["build:client"] = "vite build";
639
- pkg.scripts["dev:client"] = "vite";
640
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
641
- console.log(colors.green("[OK] Added 'build:client' and 'dev:client' scripts to package.json"));
642
- } catch { }
643
- }
644
-
645
- console.log(colors.bold.green("\nReact Islands setup complete!"));
646
- console.log(colors.white("Next steps:"));
647
- console.log(colors.cyan(" 1. In development, start Vite in a separate terminal:"));
648
- console.log(colors.bold(" npm run dev:client"));
649
- console.log(colors.cyan(" 2. In production, compile your islands before starting:"));
650
- console.log(colors.bold(" npm run build:client"));
651
- console.log(colors.cyan(" 3. View the live demo by registering a route in app/routes/web.js:"));
652
- console.log(colors.bold(' routerWeb.get("/islands-demo", Render.view("islands-demo", { title: "Islands Demo", description: "Bluebird React Islands" }));\n'));
653
- }
654
-
655
424
  /**
656
425
  * Scaffolds Electron desktop integration, desktop.js entrypoint, and build configuration.
657
426
  */
@@ -673,13 +442,14 @@ function setupElectron() {
673
442
  const desktopContent = `import { app as electronApp, BrowserWindow, shell } from "electron";
674
443
  import App from "@seip/bluebird-js/core/app.js";
675
444
  import routerWeb from "./app/routes/web.js";
445
+ import routerAuth from "./app/routes/auth.js";
676
446
  import routerApi from "./app/routes/api.js";
677
447
 
678
448
  const app = new App({
679
449
  desktop: true,
680
450
  appPath: electronApp.getAppPath(),
681
451
  userDataPath: electronApp.getPath("userData"),
682
- routes: [routerWeb, routerApi],
452
+ routes: [routerWeb, routerAuth, routerApi],
683
453
  });
684
454
 
685
455
  electronApp.whenReady().then(async () => {
@@ -723,10 +493,10 @@ electronApp.whenReady().then(async () => {
723
493
  const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
724
494
  pkg.scripts = pkg.scripts || {};
725
495
  pkg.scripts["desktop"] = "electron desktop.js";
726
- pkg.scripts["desktop:build"] = "electron-builder --win";
727
- pkg.scripts["desktop:portable"] = "electron-builder --win portable";
728
- pkg.scripts["desktop:dist"] = "electron-builder";
729
- pkg.scripts["desktop:all"] = "electron-builder -mwl";
496
+ pkg.scripts["desktop:build"] = "bluebird-js build && electron-builder --win";
497
+ pkg.scripts["desktop:portable"] = "bluebird-js build && electron-builder --win portable";
498
+ pkg.scripts["desktop:dist"] = "bluebird-js build && electron-builder";
499
+ pkg.scripts["desktop:all"] = "bluebird-js build && electron-builder -mwl";
730
500
 
731
501
  if (!pkg.build) {
732
502
  const appName = (pkg.name || "bluebird-app").replace(/^@.+\//, "");
@@ -735,7 +505,7 @@ electronApp.whenReady().then(async () => {
735
505
  productName: appName.charAt(0).toUpperCase() + appName.slice(1),
736
506
  asar: true,
737
507
  asarUnpack: [
738
- "app/views/**/*",
508
+ "app/resources/**/*",
739
509
  "database/**/*"
740
510
  ],
741
511
  directories: {
@@ -756,7 +526,7 @@ electronApp.whenReady().then(async () => {
756
526
  }
757
527
  };
758
528
  } else {
759
- pkg.build.asarUnpack = pkg.build.asarUnpack || ["app/views/**/*", "database/**/*"];
529
+ pkg.build.asarUnpack = pkg.build.asarUnpack || ["app/resources/**/*", "database/**/*"];
760
530
  }
761
531
 
762
532
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), "utf-8");
@@ -784,7 +554,6 @@ function addCommand(feature) {
784
554
  console.log(colors.yellow("Usage: npx bluebird-js add <feature>"));
785
555
  console.log("Available features:");
786
556
  console.log(" electron | desktop - Configures Electron desktop mode, desktop.js & electron-builder");
787
- console.log(" react | islands - Installs React + Vite with Islands architecture");
788
557
  console.log(" upload | multer - Installs multer for file uploads");
789
558
  console.log(" ws | websocket - Installs ws for WebSockets");
790
559
  console.log(" redis - Installs redis for distributed caching and sessions");
@@ -808,15 +577,6 @@ function addCommand(feature) {
808
577
  return;
809
578
  }
810
579
 
811
- if (
812
- cleanFeature === "react" ||
813
- cleanFeature === "react-islands" ||
814
- cleanFeature === "islands"
815
- ) {
816
- setupReactIslands();
817
- return;
818
- }
819
-
820
580
  const packageMap = {
821
581
  upload: "multer",
822
582
  multer: "multer",
@@ -867,10 +627,14 @@ function showHelp() {
867
627
  console.log(colors.bold.cyan("\n🐦 Bluebird Framework CLI Reference"));
868
628
  console.log(colors.gray("────────────────────────────────────────────────────────────"));
869
629
  console.log(` ${colors.green("npx bluebird-js")} Interactive project initialization`);
630
+ console.log(` ${colors.green("npx bluebird-js --auth | --blog | --api")} Scaffold from a template (default: --blank; also --demo)`);
631
+ console.log(` ${colors.green("npx bluebird-js dev [entry] [--watch dir]")} Dev server with Vite HMR, restarts on server file changes`);
870
632
  console.log(` ${colors.green("npx bluebird-js doctor")} Runs system audit and HTTP smoke tests`);
871
633
  console.log(` ${colors.green("npx bluebird-js make:model <Name>")} Generates a new BaseModel class`);
872
634
  console.log(` ${colors.green("npx bluebird-js make:route <name> [--auth]")} Scaffolds REST route with validation`);
873
- console.log(` ${colors.green("npx bluebird-js make:view <name> [--jsx|--js|--html]")} Scaffolds React JSX, JS or HTML view`);
635
+ console.log(` ${colors.green("npx bluebird-js build")} Builds the Vite client SPA & CSS bundle (public/build/)`);
636
+ console.log(` ${colors.green("npx bluebird-js export [--api url] [--out dir]")} Exports the React SPA as 100% static HTML/JS/CSS (Electron, Capacitor)`);
637
+ console.log(` ${colors.green("npx bluebird-js make:view <name> [--partial|--layout]")} Scaffolds an HTML {{ }} view in app/resources/html/`);
874
638
  console.log(` ${colors.green("npx bluebird-js make:migration <name> [--model <M>]")} Creates new SQL migration`);
875
639
  console.log(` ${colors.green("npx bluebird-js migrate")} Applies pending SQL migrations`);
876
640
  console.log(` ${colors.green("npx bluebird-js migrate:status")} Displays applied migration batches`);
@@ -882,8 +646,7 @@ function showHelp() {
882
646
  console.log(` ${colors.green("npx bluebird-js nginx:conf [domain] [port] [root]")} Generates Host Nginx reverse proxy`);
883
647
  console.log(` ${colors.green("npx bluebird-js make:ecosystem [--start]")} Generates PM2 cluster config`);
884
648
  console.log(` ${colors.green("npx bluebird-js add <module>")} Installs optional on-demand package
885
- ${colors.green("npx bluebird-js add electron")} Scaffolds Electron desktop app, desktop.js & build config
886
- ${colors.green("npx bluebird-js add react-islands")} Installs React + Vite with Islands architecture`);
649
+ ${colors.green("npx bluebird-js add electron")} Scaffolds Electron desktop app, desktop.js & build config`);
887
650
  console.log(colors.gray("────────────────────────────────────────────────────────────\n"));
888
651
  }
889
652
 
@@ -896,6 +659,12 @@ if (command === "make:ecosystem" || command === "ecosystem") {
896
659
  import("./ecosystem.js");
897
660
  } else if (command === "make:view" || command === "view") {
898
661
  import("./view.js");
662
+ } else if (command === "dev") {
663
+ import("./dev.js");
664
+ } else if (command === "build") {
665
+ import("./build.js");
666
+ } else if (command === "export" || command === "build:static") {
667
+ import("./export.js");
899
668
  } else if (command === "route" || command === "make:route") {
900
669
  import("./route.js");
901
670
  } else if (command === "model" || command === "make:model") {
package/core/cli/nginx.js CHANGED
@@ -126,7 +126,7 @@ server {
126
126
  }
127
127
 
128
128
  # Vite compiled production bundles (immutable long-term cache)
129
- location /dist/ {
129
+ location /build/ {
130
130
  try_files $uri =404;
131
131
  expires 365d;
132
132
  add_header Cache-Control "public, max-age=31536000, immutable";