ionbeam 1.0.0-alpha.3 → 1.0.0-alpha.5

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/README.md CHANGED
@@ -22,17 +22,17 @@ npm install ionbeam
22
22
  1. Create your server (`src/server.tsx`) with a simple route:
23
23
 
24
24
  ```tsx
25
- import { createServer, Page } from 'ionbeam';
25
+ import { createServer } from 'ionbeam';
26
26
  import type { Request, Response } from 'express';
27
27
 
28
28
  const app = createServer();
29
29
 
30
30
  app.get('/', async (req: Request, res: Response) => {
31
- await req.ionbeam.render(
32
- <Page title="Home Page">
31
+ await req.ionbeam.renderPage("Home",
32
+ <>
33
33
  <h1>Home Page</h1>
34
34
  <p>Built with IonBeam - A flexible React SSR framework</p>
35
- </Page>
35
+ </>
36
36
  );
37
37
  });
38
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Page/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,IAAI,GAAI,qBAAqB,KAAK,KAAG,GAAG,CAAC,OAkBrD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Page/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,UAAU,KAAK;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,IAAI,GAAI,qBAAqB,KAAK,KAAG,GAAG,CAAC,OAoBrD,CAAC"}
@@ -2,6 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useAssets } from "../../utils/assets-context.js";
3
3
  export const Page = ({ children, title }) => {
4
4
  const { styleSheet, clientScript } = useAssets();
5
- return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" }), _jsx("title", { children: title }), styleSheet && _jsx("link", { rel: "stylesheet", href: `/${styleSheet}` }), clientScript && _jsx("script", { src: `/${clientScript}`, defer: true })] }), _jsx("body", { children: children })] }));
5
+ return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" }), _jsx("title", { children: title }), _jsx("script", { src: "https://cdn.jsdelivr.net/npm/htmx.org@2.0.8/dist/htmx.min.js" }), styleSheet && _jsx("link", { rel: "stylesheet", href: `/${styleSheet}` }), clientScript && _jsx("script", { src: `/${clientScript}`, defer: true })] }), _jsx("body", { children: children })] }));
6
6
  };
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Page/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAO1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAS,EAAe,EAAE;IAC9D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,CAAC;IAEjD,OAAO,CACL,gBAAM,IAAI,EAAC,IAAI,aACb,2BACE,eAAM,OAAO,EAAC,OAAO,GAAG,EACxB,eAAM,IAAI,EAAC,UAAU,EAAC,OAAO,EAAC,uCAAuC,GAAG,EACxE,0BAAQ,KAAK,GAAS,EACrB,UAAU,IAAI,eAAM,GAAG,EAAC,YAAY,EAAC,IAAI,EAAE,IAAI,UAAU,EAAE,GAAI,EAC/D,YAAY,IAAI,iBAAQ,GAAG,EAAE,IAAI,YAAY,EAAE,EAAE,KAAK,SAAG,IACrD,EAEP,yBACG,QAAQ,GACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Page/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAO1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAS,EAAe,EAAE;IAC9D,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,SAAS,EAAE,CAAC;IAEjD,OAAO,CACL,gBAAM,IAAI,EAAC,IAAI,aACb,2BACE,eAAM,OAAO,EAAC,OAAO,GAAG,EACxB,eAAM,IAAI,EAAC,UAAU,EAAC,OAAO,EAAC,uCAAuC,GAAG,EACxE,0BAAQ,KAAK,GAAS,EACtB,iBAAQ,GAAG,EAAC,8DAA8D,GAAU,EAEnF,UAAU,IAAI,eAAM,GAAG,EAAC,YAAY,EAAC,IAAI,EAAE,IAAI,UAAU,EAAE,GAAI,EAC/D,YAAY,IAAI,iBAAQ,GAAG,EAAE,IAAI,YAAY,EAAE,EAAE,KAAK,SAAG,IACrD,EAEP,yBACG,QAAQ,GACJ,IACF,CACR,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { createServer, ionBeamMiddleware } from './server/index.js';
2
2
  export type { ServerOptions, IonBeam } from './server/index.js';
3
- export { Page } from './components/Page/index.js';
4
3
  export { getAsset, getManifest } from './utils/manifest.js';
5
4
  export { Builder } from './build/index.js';
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAGhE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // Server exports
2
2
  export { createServer, ionBeamMiddleware } from './server/index.js';
3
- export { Page } from './components/Page/index.js';
4
3
  // Utility exports
5
4
  export { getAsset, getManifest } from './utils/manifest.js';
6
5
  // Build exports (for advanced users)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,kBAAkB;AAClB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE5D,qCAAqC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iBAAiB;AACjB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGpE,kBAAkB;AAClB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE5D,qCAAqC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,4 +1,3 @@
1
- import { JSX } from 'react/jsx-runtime';
2
1
  import { Express, Request, Response, NextFunction } from 'express';
3
2
  declare global {
4
3
  namespace Express {
@@ -8,19 +7,12 @@ declare global {
8
7
  }
9
8
  }
10
9
  export interface IonBeam {
11
- render: (component: JSX.Element) => Promise<void>;
10
+ renderElement: (element: React.ReactNode) => Promise<void>;
11
+ renderPage: (title: string, content: React.ReactNode) => Promise<void>;
12
12
  }
13
13
  export interface ServerOptions {
14
14
  staticDir?: string;
15
15
  }
16
- /**
17
- * Middleware that adds IonBeam context to request object
18
- * This allows route handlers to access assets and rendering utilities
19
- */
20
- export declare function ionBeamMiddleware(options?: ServerOptions): (req: Request, res: Response, next: NextFunction) => void;
21
- /**
22
- * Create an Express server with IonBeam defaults
23
- * Returns a configured Express app that you can customize
24
- */
25
- export declare function createServer(options?: ServerOptions): Express;
16
+ export declare const ionBeamMiddleware: () => (req: Request, res: Response, next: NextFunction) => void;
17
+ export declare const createServer: (options?: ServerOptions) => Express;
26
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5E,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,OAAO,EAAE,OAAO,CAAC;SAClB;KACF;CACF;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,aAAkB,IACnD,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,UAqBxD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAajE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.tsx"],"names":[],"mappings":"AACA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5E,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,OAAO,EAAE,OAAO,CAAC;SAClB;KACF;CACF;AAED,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,iBAAiB,SACpB,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAqBxD,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,UAAS,aAAkB,KAAG,OAW1D,CAAA"}
@@ -4,39 +4,31 @@ import { prerenderToNodeStream } from 'react-dom/static';
4
4
  import { getAsset } from '../utils/manifest.js';
5
5
  import { AssetsProvider } from '../utils/assets-context.js';
6
6
  import path from 'node:path';
7
- /**
8
- * Middleware that adds IonBeam context to request object
9
- * This allows route handlers to access assets and rendering utilities
10
- */
11
- export function ionBeamMiddleware(options = {}) {
7
+ import { Page } from '../components/Page/index.js';
8
+ export const ionBeamMiddleware = () => {
12
9
  return (req, res, next) => {
13
10
  const clientScript = getAsset('client.js');
14
11
  const styleSheet = getAsset('server.css');
15
- console.log('IonBeam Middleware: Attaching IonBeam context to request');
16
- console.log(` - Client Script: ${clientScript}`);
17
- console.log(` - Style Sheet: ${styleSheet}`);
18
12
  req.ionbeam = {
19
- render: async (element) => {
20
- const { prelude } = await prerenderToNodeStream(_jsx(AssetsProvider, { value: { clientScript, styleSheet }, children: element }));
13
+ renderPage: async (title, element) => {
14
+ const { prelude } = await prerenderToNodeStream(_jsx(AssetsProvider, { value: { clientScript, styleSheet }, children: _jsx(Page, { title: title, children: element }) }));
21
15
  prelude.pipe(res);
22
16
  },
17
+ renderElement: async (element) => {
18
+ const { prelude } = await prerenderToNodeStream(element);
19
+ prelude.pipe(res);
20
+ }
23
21
  };
24
22
  next();
25
23
  };
26
- }
27
- /**
28
- * Create an Express server with IonBeam defaults
29
- * Returns a configured Express app that you can customize
30
- */
31
- export function createServer(options = {}) {
24
+ };
25
+ export const createServer = (options = {}) => {
32
26
  const app = express();
33
27
  const staticDir = options.staticDir || path.join(process.cwd(), 'dist', 'static');
34
- // Default middleware
35
28
  app.use(express.static(staticDir));
36
29
  app.use(express.urlencoded({ extended: true }));
37
30
  app.use(express.json());
38
- // Add IonBeam context to all requests
39
- app.use(ionBeamMiddleware(options));
31
+ app.use(ionBeamMiddleware());
40
32
  return app;
41
- }
33
+ };
42
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.tsx"],"names":[],"mappings":";AACA,OAAO,OAAqD,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAmB7B;;;GAGG;AACH,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CAAC;SACF,CAAC;QAEF,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAyB,EAAE,EAAW,EAAE;IACnE,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAElF,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAExB,GAAG,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAE7B,OAAO,GAAG,CAAC;AACb,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ionbeam",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "A pure React SSR framework with automatic asset hashing and CSS modules",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",