@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.
Files changed (49) hide show
  1. package/.vscode/extensions.json +7 -0
  2. package/.vscode/settings.json +10 -0
  3. package/AGENTS.md +124 -64
  4. package/README.md +236 -103
  5. package/app/routes/web.js +47 -55
  6. package/app/views/about.jsx +98 -0
  7. package/app/views/components/Header.jsx +42 -0
  8. package/app/views/components/LiveCounter.jsx +67 -0
  9. package/app/views/dashboard.jsx +300 -0
  10. package/app/views/index.jsx +123 -0
  11. package/app/views/layouts/main/view.jsx +201 -0
  12. package/app/views/legal/terms.html +29 -19
  13. package/app/views/login.jsx +141 -0
  14. package/core/actions.d.ts +4 -0
  15. package/core/actions.js +329 -0
  16. package/core/app.js +129 -22
  17. package/core/auth.js +1 -1
  18. package/core/cli/doctor.js +3 -4
  19. package/core/cli/init.js +153 -6
  20. package/core/cli/migrate.js +418 -145
  21. package/core/cli/view.js +76 -11
  22. package/core/config.js +35 -5
  23. package/core/csrf.js +1 -1
  24. package/core/database.js +52 -17
  25. package/core/debug.js +1 -1
  26. package/core/html.d.ts +54 -42
  27. package/core/html.js +473 -217
  28. package/core/index.d.ts +187 -85
  29. package/core/jsx.d.ts +38 -0
  30. package/core/jsx.js +1180 -0
  31. package/core/model.js +282 -61
  32. package/core/queue.js +7 -4
  33. package/core/render-cache.js +212 -212
  34. package/core/render.d.ts +20 -2
  35. package/core/render.js +320 -43
  36. package/core/upload.js +7 -1
  37. package/core/validate.js +1 -1
  38. package/core/view-loader.js +341 -19
  39. package/core/vite.js +1 -1
  40. package/package.json +9 -3
  41. package/public/js/bluebird-client.js +2313 -1049
  42. package/public/js/tailwind.js +8 -0
  43. package/app/views/about.js +0 -63
  44. package/app/views/dashboard.js +0 -147
  45. package/app/views/index.js +0 -80
  46. package/app/views/layouts/main/view.js +0 -81
  47. package/app/views/login.js +0 -80
  48. package/public/css/bluebird.min.css +0 -2
  49. package/public/js/bluebird.min.js +0 -1073
package/core/cli/init.js CHANGED
@@ -290,7 +290,7 @@ ${dbEnvBlock}
290
290
  version: "1.0.0",
291
291
  type: "module",
292
292
  dependencies: {
293
- "@seip/bluebird-js": "^0.1.0",
293
+ "@seip/bluebird-js": "^0.1.4",
294
294
  },
295
295
  };
296
296
  }
@@ -326,7 +326,7 @@ ${dbEnvBlock}
326
326
  pkg.dependencies = {};
327
327
  }
328
328
  if (!pkg.dependencies["@seip/bluebird-js"]) {
329
- pkg.dependencies["@seip/bluebird-js"] = "^0.1.0";
329
+ pkg.dependencies["@seip/bluebird-js"] = "^0.1.4";
330
330
  }
331
331
 
332
332
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
@@ -424,9 +424,14 @@ window.__BLUEBIRD_ISLANDS__ = window.__BLUEBIRD_ISLANDS__ || {};
424
424
  window.__BLUEBIRD_ISLANDS__["RadioPlayer"] = RadioPlayer;
425
425
  window.__BLUEBIRD_ISLANDS__["LiveCounter"] = LiveCounter;
426
426
 
427
- window.__BLUEBIRD_MOUNT__ = (el, Component, props) => {
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
+ }
428
433
  const root = ReactDOM.createRoot(el);
429
- root.render(React.createElement(Component, props));
434
+ root.render(element);
430
435
  return () => root.unmount();
431
436
  };
432
437
 
@@ -577,7 +582,16 @@ export default function LiveCounter({ initial = 0, label = "Interactive Counter"
577
582
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
578
583
  <title>{{ title }}</title>
579
584
  <meta name="description" content="{{ description }}">
580
- <link rel="stylesheet" href="/css/bluebird.min.css">
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>
581
595
  {{{ bluebirdHead }}}
582
596
  </head>
583
597
  <body style="padding: 2rem; max-width: 800px; margin: 0 auto; font-family: system-ui, sans-serif;">
@@ -638,6 +652,129 @@ export default function LiveCounter({ initial = 0, label = "Interactive Counter"
638
652
  console.log(colors.bold(' routerWeb.get("/islands-demo", Render.view("islands-demo", { title: "Islands Demo", description: "Bluebird React Islands" }));\n'));
639
653
  }
640
654
 
655
+ /**
656
+ * Scaffolds Electron desktop integration, desktop.js entrypoint, and build configuration.
657
+ */
658
+ function setupElectron() {
659
+ const appDir = process.cwd();
660
+ console.log(colors.cyan("[INFO] Setting up Electron Desktop integration for Bluebird.js..."));
661
+
662
+ try {
663
+ console.log(colors.cyan("[INFO] Installing electron and electron-builder as devDependencies..."));
664
+ execSync("npm install --save-dev electron electron-builder", { stdio: "inherit", cwd: appDir });
665
+ console.log(colors.green("[OK] Successfully installed electron and electron-builder."));
666
+ } catch (err) {
667
+ console.warn(colors.yellow(`[WARN] Could not install electron automatically: ${err.message}`));
668
+ console.log("You can install them manually via: npm install --save-dev electron electron-builder");
669
+ }
670
+
671
+ const desktopFilePath = path.join(appDir, "desktop.js");
672
+ if (!fs.existsSync(desktopFilePath)) {
673
+ const desktopContent = `import { app as electronApp, BrowserWindow, shell } from "electron";
674
+ import App from "@seip/bluebird-js/core/app.js";
675
+ import routerWeb from "./app/routes/web.js";
676
+ import routerApi from "./app/routes/api.js";
677
+
678
+ const app = new App({
679
+ desktop: true,
680
+ appPath: electronApp.getAppPath(),
681
+ userDataPath: electronApp.getPath("userData"),
682
+ routes: [routerWeb, routerApi],
683
+ });
684
+
685
+ electronApp.whenReady().then(async () => {
686
+ const { url, lanUrl, lanIp } = await app.runDesktop({ allowLan: true });
687
+
688
+ const mainWindow = new BrowserWindow({
689
+ width: 1280,
690
+ height: 800,
691
+ minWidth: 900,
692
+ minHeight: 600,
693
+ webPreferences: {
694
+ nodeIntegration: false,
695
+ contextIsolation: true,
696
+ },
697
+ });
698
+
699
+ mainWindow.loadURL(url);
700
+
701
+ mainWindow.webContents.setWindowOpenHandler(({ url }) => {
702
+ if (!url.startsWith("http://127.0.0.1") && !url.startsWith("http://localhost")) {
703
+ shell.openExternal(url);
704
+ return { action: "deny" };
705
+ }
706
+ return { action: "allow" };
707
+ });
708
+
709
+ electronApp.on("before-quit", async () => {
710
+ await app.close();
711
+ });
712
+ });
713
+ `;
714
+ fs.writeFileSync(desktopFilePath, desktopContent, "utf-8");
715
+ console.log(colors.green("[OK] Created desktop.js"));
716
+ } else {
717
+ console.log(colors.yellow("[SKIP] desktop.js already exists."));
718
+ }
719
+
720
+ const pkgPath = path.join(appDir, "package.json");
721
+ if (fs.existsSync(pkgPath)) {
722
+ try {
723
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
724
+ pkg.scripts = pkg.scripts || {};
725
+ 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";
730
+
731
+ if (!pkg.build) {
732
+ const appName = (pkg.name || "bluebird-app").replace(/^@.+\//, "");
733
+ pkg.build = {
734
+ appId: `com.${appName.replace(/[^a-zA-Z0-9]/g, "")}.app`,
735
+ productName: appName.charAt(0).toUpperCase() + appName.slice(1),
736
+ asar: true,
737
+ asarUnpack: [
738
+ "app/views/**/*",
739
+ "database/**/*"
740
+ ],
741
+ directories: {
742
+ output: "dist-desktop"
743
+ },
744
+ files: [
745
+ "**/*",
746
+ "!dist-desktop/**/*"
747
+ ],
748
+ win: {
749
+ target: ["nsis", "portable"]
750
+ },
751
+ mac: {
752
+ target: ["dmg", "zip"]
753
+ },
754
+ linux: {
755
+ target: ["AppImage", "deb"]
756
+ }
757
+ };
758
+ } else {
759
+ pkg.build.asarUnpack = pkg.build.asarUnpack || ["app/views/**/*", "database/**/*"];
760
+ }
761
+
762
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), "utf-8");
763
+ console.log(colors.green("[OK] Configured desktop scripts and electron-builder build in package.json"));
764
+ } catch (err) {
765
+ console.warn(colors.yellow(`[WARN] Could not update package.json: ${err.message}`));
766
+ }
767
+ }
768
+
769
+ console.log(colors.bold.green("\nElectron Desktop integration complete!"));
770
+ console.log(colors.white("Commands available:"));
771
+ console.log(colors.cyan(" npm run desktop - Runs the Electron desktop application locally"));
772
+ console.log(colors.cyan(" npm run desktop:build - Builds Windows installer (.exe)"));
773
+ console.log(colors.cyan(" npm run desktop:portable - Builds standalone Windows portable (.exe)"));
774
+ console.log(colors.cyan(" npm run desktop:dist - Builds for current host platform"));
775
+ console.log(colors.cyan(" npm run desktop:all - Builds for Windows, Mac & Linux\n"));
776
+ }
777
+
641
778
  /**
642
779
  * Handles adding on-demand modules and dependencies.
643
780
  * @param {string} [feature]
@@ -646,6 +783,7 @@ function addCommand(feature) {
646
783
  if (!feature) {
647
784
  console.log(colors.yellow("Usage: npx bluebird-js add <feature>"));
648
785
  console.log("Available features:");
786
+ console.log(" electron | desktop - Configures Electron desktop mode, desktop.js & electron-builder");
649
787
  console.log(" react | islands - Installs React + Vite with Islands architecture");
650
788
  console.log(" upload | multer - Installs multer for file uploads");
651
789
  console.log(" ws | websocket - Installs ws for WebSockets");
@@ -662,6 +800,14 @@ function addCommand(feature) {
662
800
 
663
801
  const cleanFeature = feature.toLowerCase().trim();
664
802
 
803
+ if (
804
+ cleanFeature === "electron" ||
805
+ cleanFeature === "desktop"
806
+ ) {
807
+ setupElectron();
808
+ return;
809
+ }
810
+
665
811
  if (
666
812
  cleanFeature === "react" ||
667
813
  cleanFeature === "react-islands" ||
@@ -724,7 +870,7 @@ function showHelp() {
724
870
  console.log(` ${colors.green("npx bluebird-js doctor")} Runs system audit and HTTP smoke tests`);
725
871
  console.log(` ${colors.green("npx bluebird-js make:model <Name>")} Generates a new BaseModel class`);
726
872
  console.log(` ${colors.green("npx bluebird-js make:route <name> [--auth]")} Scaffolds REST route with validation`);
727
- console.log(` ${colors.green("npx bluebird-js make:view <name> [--ejs]")} Scaffolds HTML or EJS template`);
873
+ console.log(` ${colors.green("npx bluebird-js make:view <name> [--jsx|--js|--html]")} Scaffolds React JSX, JS or HTML view`);
728
874
  console.log(` ${colors.green("npx bluebird-js make:migration <name> [--model <M>]")} Creates new SQL migration`);
729
875
  console.log(` ${colors.green("npx bluebird-js migrate")} Applies pending SQL migrations`);
730
876
  console.log(` ${colors.green("npx bluebird-js migrate:status")} Displays applied migration batches`);
@@ -734,6 +880,7 @@ function showHelp() {
734
880
  console.log(` ${colors.green("npx bluebird-js nginx:conf [domain] [port] [root]")} Generates Host Nginx reverse proxy`);
735
881
  console.log(` ${colors.green("npx bluebird-js make:ecosystem [--start]")} Generates PM2 cluster config`);
736
882
  console.log(` ${colors.green("npx bluebird-js add <module>")} Installs optional on-demand package
883
+ ${colors.green("npx bluebird-js add electron")} Scaffolds Electron desktop app, desktop.js & build config
737
884
  ${colors.green("npx bluebird-js add react-islands")} Installs React + Vite with Islands architecture`);
738
885
  console.log(colors.gray("────────────────────────────────────────────────────────────\n"));
739
886
  }