@benqoder/beam 0.1.3 → 0.3.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.
package/dist/collect.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ActionHandler, ModalHandler, DrawerHandler } from './types';
1
+ import type { ActionHandler } from './types';
2
2
  /**
3
3
  * Type for glob import results from import.meta.glob
4
4
  */
@@ -18,51 +18,5 @@ type GlobImport = Record<string, Record<string, unknown>>;
18
18
  * - `./actions/cart.tsx` exports `addToCart` → `addToCart`
19
19
  */
20
20
  export declare function collectActions<TEnv = object>(glob: GlobImport): Record<string, ActionHandler<TEnv>>;
21
- /**
22
- * Collects modal handlers from glob imports.
23
- *
24
- * @example
25
- * ```typescript
26
- * const modals = collectModals<Env>(
27
- * import.meta.glob('./modals/*.tsx', { eager: true })
28
- * )
29
- * ```
30
- */
31
- export declare function collectModals<TEnv = object>(glob: GlobImport): Record<string, ModalHandler<TEnv>>;
32
- /**
33
- * Collects drawer handlers from glob imports.
34
- *
35
- * @example
36
- * ```typescript
37
- * const drawers = collectDrawers<Env>(
38
- * import.meta.glob('./drawers/*.tsx', { eager: true })
39
- * )
40
- * ```
41
- */
42
- export declare function collectDrawers<TEnv = object>(glob: GlobImport): Record<string, DrawerHandler<TEnv>>;
43
- /**
44
- * Collects all handlers (actions, modals, drawers) from glob imports.
45
- * This is a convenience function that collects all three at once.
46
- *
47
- * @example
48
- * ```typescript
49
- * const { actions, modals, drawers } = collectHandlers<Env>({
50
- * actions: import.meta.glob('./actions/*.tsx', { eager: true }),
51
- * modals: import.meta.glob('./modals/*.tsx', { eager: true }),
52
- * drawers: import.meta.glob('./drawers/*.tsx', { eager: true }),
53
- * })
54
- *
55
- * export const beam = createBeam<Env>({ actions, modals, drawers })
56
- * ```
57
- */
58
- export declare function collectHandlers<TEnv = object>(globs: {
59
- actions?: GlobImport;
60
- modals?: GlobImport;
61
- drawers?: GlobImport;
62
- }): {
63
- actions: Record<string, ActionHandler<TEnv>>;
64
- modals: Record<string, ModalHandler<TEnv>>;
65
- drawers: Record<string, DrawerHandler<TEnv>>;
66
- };
67
21
  export {};
68
22
  //# sourceMappingURL=collect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../src/collect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzE;;GAEG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAEzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAG,MAAM,EAC1C,IAAI,EAAE,UAAU,GACf,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAarC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAG,MAAM,EACzC,IAAI,EAAE,UAAU,GACf,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAYpC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAG,MAAM,EAC1C,IAAI,EAAE,UAAU,GACf,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAYrC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAG,MAAM,EAAE,KAAK,EAAE;IACpD,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB,GAAG;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAA;IAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;IAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAA;CAC7C,CAMA"}
1
+ {"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../src/collect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C;;GAEG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AAEzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAG,MAAM,EAC1C,IAAI,EAAE,UAAU,GACf,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAarC"}
package/dist/collect.js CHANGED
@@ -24,67 +24,3 @@ export function collectActions(glob) {
24
24
  }
25
25
  return handlers;
26
26
  }
27
- /**
28
- * Collects modal handlers from glob imports.
29
- *
30
- * @example
31
- * ```typescript
32
- * const modals = collectModals<Env>(
33
- * import.meta.glob('./modals/*.tsx', { eager: true })
34
- * )
35
- * ```
36
- */
37
- export function collectModals(glob) {
38
- const handlers = {};
39
- for (const [, module] of Object.entries(glob)) {
40
- for (const [exportName, exportValue] of Object.entries(module)) {
41
- if (typeof exportValue === 'function' && exportName !== 'default') {
42
- handlers[exportName] = exportValue;
43
- }
44
- }
45
- }
46
- return handlers;
47
- }
48
- /**
49
- * Collects drawer handlers from glob imports.
50
- *
51
- * @example
52
- * ```typescript
53
- * const drawers = collectDrawers<Env>(
54
- * import.meta.glob('./drawers/*.tsx', { eager: true })
55
- * )
56
- * ```
57
- */
58
- export function collectDrawers(glob) {
59
- const handlers = {};
60
- for (const [, module] of Object.entries(glob)) {
61
- for (const [exportName, exportValue] of Object.entries(module)) {
62
- if (typeof exportValue === 'function' && exportName !== 'default') {
63
- handlers[exportName] = exportValue;
64
- }
65
- }
66
- }
67
- return handlers;
68
- }
69
- /**
70
- * Collects all handlers (actions, modals, drawers) from glob imports.
71
- * This is a convenience function that collects all three at once.
72
- *
73
- * @example
74
- * ```typescript
75
- * const { actions, modals, drawers } = collectHandlers<Env>({
76
- * actions: import.meta.glob('./actions/*.tsx', { eager: true }),
77
- * modals: import.meta.glob('./modals/*.tsx', { eager: true }),
78
- * drawers: import.meta.glob('./drawers/*.tsx', { eager: true }),
79
- * })
80
- *
81
- * export const beam = createBeam<Env>({ actions, modals, drawers })
82
- * ```
83
- */
84
- export function collectHandlers(globs) {
85
- return {
86
- actions: globs.actions ? collectActions(globs.actions) : {},
87
- modals: globs.modals ? collectModals(globs.modals) : {},
88
- drawers: globs.drawers ? collectDrawers(globs.drawers) : {},
89
- };
90
- }
@@ -1,5 +1,5 @@
1
1
  import { RpcTarget } from 'capnweb';
2
- import type { ActionHandler, ActionResponse, ModalHandler, DrawerHandler, BeamConfig, BeamInstance, BeamContext, BeamSession, SessionConfig } from './types';
2
+ import type { ActionHandler, ActionResponse, BeamConfig, BeamInstance, BeamContext, BeamSession, SessionConfig } from './types';
3
3
  /**
4
4
  * Session implementation using KV storage.
5
5
  * Exported for users who need custom storage adapter.
@@ -50,21 +50,11 @@ export declare class CookieSession implements BeamSession {
50
50
  declare class BeamServer<TEnv extends object> extends RpcTarget {
51
51
  private ctx;
52
52
  private actions;
53
- private modals;
54
- private drawers;
55
- constructor(ctx: BeamContext<TEnv>, actions: Record<string, ActionHandler<TEnv>>, modals: Record<string, ModalHandler<TEnv>>, drawers: Record<string, DrawerHandler<TEnv>>);
53
+ constructor(ctx: BeamContext<TEnv>, actions: Record<string, ActionHandler<TEnv>>);
56
54
  /**
57
55
  * Call an action handler
58
56
  */
59
57
  call(action: string, data?: Record<string, unknown>): Promise<ActionResponse>;
60
- /**
61
- * Open a modal
62
- */
63
- modal(modalId: string, data?: Record<string, unknown>): Promise<string>;
64
- /**
65
- * Open a drawer
66
- */
67
- drawer(drawerId: string, data?: Record<string, unknown>): Promise<string>;
68
58
  /**
69
59
  * Register a client callback for server-initiated updates
70
60
  * This enables bidirectional communication - server can push to client
@@ -76,7 +66,7 @@ declare class BeamServer<TEnv extends object> extends RpcTarget {
76
66
  notify(event: string, data: unknown): Promise<void>;
77
67
  }
78
68
  /**
79
- * Creates a Beam instance configured with actions, modals, and drawers.
69
+ * Creates a Beam instance configured with actions.
80
70
  * Uses capnweb for RPC, enabling promise pipelining and bidirectional calls.
81
71
  *
82
72
  * @example
@@ -86,9 +76,7 @@ declare class BeamServer<TEnv extends object> extends RpcTarget {
86
76
  * import type { Env } from './types'
87
77
  *
88
78
  * export const beam = createBeam<Env>({
89
- * actions: { createProduct, deleteProduct },
90
- * modals: { confirmDelete },
91
- * drawers: { productDetails }
79
+ * actions: { createProduct, deleteProduct, confirmDelete }
92
80
  * })
93
81
  *
94
82
  * // app/server.ts
@@ -114,10 +102,8 @@ declare class PublicBeamServer<TEnv extends object> extends RpcTarget {
114
102
  private env;
115
103
  private request;
116
104
  private actions;
117
- private modals;
118
- private drawers;
119
105
  private auth;
120
- constructor(secret: string, sessionConfig: SessionConfig<TEnv> | undefined, env: TEnv, request: Request, actions: Record<string, ActionHandler<TEnv>>, modals: Record<string, ModalHandler<TEnv>>, drawers: Record<string, DrawerHandler<TEnv>>, auth: ((request: Request, env: TEnv) => Promise<import('./types').BeamUser | null>) | undefined);
106
+ constructor(secret: string, sessionConfig: SessionConfig<TEnv> | undefined, env: TEnv, request: Request, actions: Record<string, ActionHandler<TEnv>>, auth: ((request: Request, env: TEnv) => Promise<import('./types').BeamUser | null>) | undefined);
121
107
  /**
122
108
  * Authenticate with a token and return the authenticated API
123
109
  * This is the only method available on the public API
@@ -1 +1 @@
1
- {"version":3,"file":"createBeam.d.ts","sourceRoot":"","sources":["../src/createBeam.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAyB,MAAM,SAAS,CAAA;AAC1D,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY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IAAI,CAAC,CAAC,GAAG,SAAS;IAWjG;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;CA4C7D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAInD;AAGD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAA"}
@@ -152,29 +152,81 @@ function parseSessionDataFromRequest(request) {
152
152
  }
153
153
  }
154
154
  /**
155
- * Create a BeamContext with script() and render() helpers
155
+ * Helper to convert JSX/Promise/string to HTML string.
156
+ * Handles HonoX HtmlEscapedString, Promises, and plain strings.
157
+ *
158
+ * HonoX async components have `.toString()` that returns a Promise<string>.
159
+ * We need to await that result as well.
160
+ */
161
+ async function toHtml(content) {
162
+ // First, await if content itself is a Promise
163
+ const resolved = await content;
164
+ // Plain string - return as-is
165
+ if (typeof resolved === 'string')
166
+ return resolved;
167
+ // Null/undefined - return empty string
168
+ if (resolved == null)
169
+ return '';
170
+ // HtmlEscapedString or JSX element - call toString()
171
+ // For async components, toString() returns a Promise<string>
172
+ const maybeStringable = resolved;
173
+ if (typeof maybeStringable.toString === 'function') {
174
+ const str = await maybeStringable.toString();
175
+ // Ensure it's a plain string
176
+ return '' + str;
177
+ }
178
+ // Fallback
179
+ return '' + resolved;
180
+ }
181
+ /**
182
+ * Create a BeamContext with script(), render(), modal(), drawer() helpers
156
183
  */
157
184
  function createBeamContext(base) {
158
185
  return {
159
186
  ...base,
160
187
  script: (code) => ({ script: code }),
161
- render: (html, options) => {
162
- if (html instanceof Promise) {
163
- return html.then((resolved) => ({
164
- html: resolved,
165
- script: options?.script,
166
- target: options?.target,
167
- swap: options?.swap,
168
- }));
169
- }
170
- return {
171
- html,
172
- script: options?.script,
173
- target: options?.target,
174
- swap: options?.swap,
188
+ render: (content, options) => {
189
+ // Helper to build response without undefined values
190
+ const buildResponse = (html) => {
191
+ const response = { html };
192
+ if (options?.script)
193
+ response.script = options.script;
194
+ if (options?.target)
195
+ response.target = options.target;
196
+ if (options?.swap)
197
+ response.swap = options.swap;
198
+ return response;
175
199
  };
200
+ // Handle array of JSX/strings for multi-target rendering
201
+ if (Array.isArray(content)) {
202
+ return Promise.all(content.map(toHtml)).then(buildResponse);
203
+ }
204
+ // Single content - always convert via toHtml to handle HtmlEscapedString
205
+ return toHtml(content).then(buildResponse);
176
206
  },
177
207
  redirect: (url) => ({ redirect: url }),
208
+ modal: (html, options) => {
209
+ return toHtml(html).then((resolved) => {
210
+ const modalObj = { html: resolved };
211
+ if (options?.size)
212
+ modalObj.size = options.size;
213
+ if (options?.spacing !== undefined)
214
+ modalObj.spacing = options.spacing;
215
+ return { modal: modalObj };
216
+ });
217
+ },
218
+ drawer: (html, options) => {
219
+ return toHtml(html).then((resolved) => {
220
+ const drawerObj = { html: resolved };
221
+ if (options?.position)
222
+ drawerObj.position = options.position;
223
+ if (options?.size)
224
+ drawerObj.size = options.size;
225
+ if (options?.spacing !== undefined)
226
+ drawerObj.spacing = options.spacing;
227
+ return { drawer: drawerObj };
228
+ });
229
+ },
178
230
  };
179
231
  }
180
232
  /**
@@ -189,14 +241,10 @@ function createBeamContext(base) {
189
241
  class BeamServer extends RpcTarget {
190
242
  ctx;
191
243
  actions;
192
- modals;
193
- drawers;
194
- constructor(ctx, actions, modals, drawers) {
244
+ constructor(ctx, actions) {
195
245
  super();
196
246
  this.ctx = ctx;
197
247
  this.actions = actions;
198
- this.modals = modals;
199
- this.drawers = drawers;
200
248
  }
201
249
  /**
202
250
  * Call an action handler
@@ -213,26 +261,6 @@ class BeamServer extends RpcTarget {
213
261
  }
214
262
  return result;
215
263
  }
216
- /**
217
- * Open a modal
218
- */
219
- async modal(modalId, data = {}) {
220
- const handler = this.modals[modalId];
221
- if (!handler) {
222
- throw new Error(`Unknown modal: ${modalId}`);
223
- }
224
- return await handler(this.ctx, data);
225
- }
226
- /**
227
- * Open a drawer
228
- */
229
- async drawer(drawerId, data = {}) {
230
- const handler = this.drawers[drawerId];
231
- if (!handler) {
232
- throw new Error(`Unknown drawer: ${drawerId}`);
233
- }
234
- return await handler(this.ctx, data);
235
- }
236
264
  /**
237
265
  * Register a client callback for server-initiated updates
238
266
  * This enables bidirectional communication - server can push to client
@@ -253,7 +281,7 @@ class BeamServer extends RpcTarget {
253
281
  }
254
282
  }
255
283
  /**
256
- * Creates a Beam instance configured with actions, modals, and drawers.
284
+ * Creates a Beam instance configured with actions.
257
285
  * Uses capnweb for RPC, enabling promise pipelining and bidirectional calls.
258
286
  *
259
287
  * @example
@@ -263,9 +291,7 @@ class BeamServer extends RpcTarget {
263
291
  * import type { Env } from './types'
264
292
  *
265
293
  * export const beam = createBeam<Env>({
266
- * actions: { createProduct, deleteProduct },
267
- * modals: { confirmDelete },
268
- * drawers: { productDetails }
294
+ * actions: { createProduct, deleteProduct, confirmDelete }
269
295
  * })
270
296
  *
271
297
  * // app/server.ts
@@ -277,14 +303,12 @@ class BeamServer extends RpcTarget {
277
303
  * ```
278
304
  */
279
305
  export function createBeam(config) {
280
- const { actions, modals, drawers = {}, auth, session: sessionConfig } = config;
306
+ const { actions, auth, session: sessionConfig } = config;
281
307
  // Session defaults
282
308
  const cookieName = sessionConfig?.cookieName ?? 'beam_sid';
283
309
  const maxAge = sessionConfig?.maxAge ?? 365 * 24 * 60 * 60; // 1 year
284
310
  return {
285
311
  actions,
286
- modals,
287
- drawers,
288
312
  auth,
289
313
  /**
290
314
  * Middleware that resolves auth, session, and sets beam context in Hono.
@@ -468,7 +492,7 @@ export function createBeam(config) {
468
492
  return c.text('Session secret is required for secure WebSocket connections', 500);
469
493
  }
470
494
  // Create PublicBeamServer - client must authenticate to get full API
471
- const server = new PublicBeamServer(secret, sessionConfig, c.env, c.req.raw, actions, modals, drawers, auth);
495
+ const server = new PublicBeamServer(secret, sessionConfig, c.env, c.req.raw, actions, auth);
472
496
  // Use capnweb to handle the RPC connection
473
497
  return newWorkersRpcResponse(c.req.raw, server);
474
498
  });
@@ -489,18 +513,14 @@ class PublicBeamServer extends RpcTarget {
489
513
  env;
490
514
  request;
491
515
  actions;
492
- modals;
493
- drawers;
494
516
  auth;
495
- constructor(secret, sessionConfig, env, request, actions, modals, drawers, auth) {
517
+ constructor(secret, sessionConfig, env, request, actions, auth) {
496
518
  super();
497
519
  this.secret = secret;
498
520
  this.sessionConfig = sessionConfig;
499
521
  this.env = env;
500
522
  this.request = request;
501
523
  this.actions = actions;
502
- this.modals = modals;
503
- this.drawers = drawers;
504
524
  this.auth = auth;
505
525
  }
506
526
  /**
@@ -546,7 +566,7 @@ class PublicBeamServer extends RpcTarget {
546
566
  session,
547
567
  });
548
568
  // Return the authenticated BeamServer
549
- return new BeamServer(ctx, this.actions, this.modals, this.drawers);
569
+ return new BeamServer(ctx, this.actions);
550
570
  }
551
571
  }
552
572
  /**
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  export { createBeam, KVSession, CookieSession, beamTokenMeta } from './createBeam';
2
2
  export { render } from './render';
3
- export { ModalFrame } from './ModalFrame';
4
- export { DrawerFrame } from './DrawerFrame';
5
- export { collectActions, collectModals, collectDrawers, collectHandlers, } from './collect';
6
- export type { ActionHandler, ModalHandler, DrawerHandler, BeamConfig, BeamInstance, BeamInitOptions, BeamUser, BeamContext, BeamVariables, AuthResolver, BeamSession, SessionConfig, SessionStorageFactory, AuthTokenPayload, } from './types';
3
+ export { collectActions, } from './collect';
4
+ export type { ActionHandler, ActionResponse, ModalOptions, DrawerOptions, BeamConfig, BeamInstance, BeamInitOptions, BeamUser, BeamContext, BeamVariables, AuthResolver, BeamSession, SessionConfig, SessionStorageFactory, AuthTokenPayload, } from './types';
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,WAAW,CAAA;AAGlB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EACL,cAAc,GACf,MAAM,WAAW,CAAA;AAGlB,YAAY,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  // Main server-side exports for @benqoder/beam
2
2
  export { createBeam, KVSession, CookieSession, beamTokenMeta } from './createBeam';
3
3
  export { render } from './render';
4
- export { ModalFrame } from './ModalFrame';
5
- export { DrawerFrame } from './DrawerFrame';
6
4
  // Auto-discovery utilities
7
- export { collectActions, collectModals, collectDrawers, collectHandlers, } from './collect';
5
+ export { collectActions, } from './collect';
package/dist/types.d.ts CHANGED
@@ -43,16 +43,38 @@ export interface BeamContext<TEnv = object> {
43
43
  */
44
44
  script(code: string): ActionResponse;
45
45
  /**
46
- * Return HTML with optional script to execute
46
+ * Return HTML with optional script to execute.
47
+ * Accepts JSX directly (converts to string), single string, or array for multi-target rendering.
47
48
  * @example ctx.render(<ProductList />, { script: 'playSound("ding")' })
49
+ * @example ctx.render([<StatsWidget />, <NotificationList />], { target: '#stats, #notifications' })
50
+ * @example ctx.render([<div id="stats">...</div>, <div id="notifications">...</div>]) // auto-detects targets by ID
48
51
  */
49
- render(html: string | Promise<string>, options?: RenderOptions): ActionResponse | Promise<ActionResponse>;
52
+ render(content: string | Promise<string> | (string | Promise<string>)[], options?: RenderOptions): ActionResponse | Promise<ActionResponse>;
50
53
  /**
51
54
  * Redirect the client to a new URL
52
55
  * @example ctx.redirect('/dashboard')
53
56
  * @example ctx.redirect('https://example.com')
54
57
  */
55
58
  redirect(url: string): ActionResponse;
59
+ /**
60
+ * Open a modal with HTML content
61
+ * @example ctx.modal(render(<MyModal />))
62
+ * @example ctx.modal(render(<MyModal />), { size: 'large', spacing: 20 })
63
+ */
64
+ modal(html: string | Promise<string>, options?: {
65
+ size?: string;
66
+ spacing?: number;
67
+ }): ActionResponse | Promise<ActionResponse>;
68
+ /**
69
+ * Open a drawer with HTML content
70
+ * @example ctx.drawer(render(<MyDrawer />))
71
+ * @example ctx.drawer(render(<MyDrawer />), { position: 'left', size: 'large', spacing: 20 })
72
+ */
73
+ drawer(html: string | Promise<string>, options?: {
74
+ position?: string;
75
+ size?: string;
76
+ spacing?: number;
77
+ }): ActionResponse | Promise<ActionResponse>;
56
78
  }
57
79
  /**
58
80
  * Auth resolver function - user provides this to extract user from request
@@ -77,33 +99,46 @@ export interface AuthTokenConfig {
77
99
  /** Token lifetime in milliseconds (default: 5 minutes) */
78
100
  tokenLifetime?: number;
79
101
  }
102
+ /**
103
+ * Modal options for ActionResponse
104
+ */
105
+ export interface ModalOptions {
106
+ html: string;
107
+ size?: string;
108
+ spacing?: number;
109
+ }
110
+ /**
111
+ * Drawer options for ActionResponse
112
+ */
113
+ export interface DrawerOptions {
114
+ html: string;
115
+ position?: string;
116
+ size?: string;
117
+ spacing?: number;
118
+ }
80
119
  /**
81
120
  * Response type for actions - can include HTML and/or script to execute
82
121
  */
83
122
  export interface ActionResponse {
84
- /** HTML to render (optional) */
85
- html?: string;
123
+ /** HTML to render (optional) - single string or array of HTML strings for multi-target rendering */
124
+ html?: string | string[];
86
125
  /** JavaScript to execute on client (optional) */
87
126
  script?: string;
88
127
  /** URL to redirect to (optional) */
89
128
  redirect?: string;
90
- /** CSS selector for target element (optional - overrides frontend target) */
129
+ /** CSS selector for target element (optional - overrides frontend target). Can be comma-separated for array html: "#a, #b, #c" */
91
130
  target?: string;
92
131
  /** Swap mode: 'morph' | 'replace' | 'append' | 'prepend' | 'delete' (optional) */
93
132
  swap?: string;
133
+ /** Open a modal with HTML content */
134
+ modal?: string | ModalOptions;
135
+ /** Open a drawer with HTML content */
136
+ drawer?: string | DrawerOptions;
94
137
  }
95
138
  /**
96
139
  * Type for action handlers - receives context and data, returns ActionResponse
97
140
  */
98
141
  export type ActionHandler<TEnv = object> = (ctx: BeamContext<TEnv>, data: Record<string, unknown>) => Promise<ActionResponse> | ActionResponse;
99
- /**
100
- * Type for modal handlers - receives context and params, returns HTML string
101
- */
102
- export type ModalHandler<TEnv = object> = (ctx: BeamContext<TEnv>, params: Record<string, unknown>) => Promise<string>;
103
- /**
104
- * Type for drawer handlers - receives context and params, returns HTML string
105
- */
106
- export type DrawerHandler<TEnv = object> = (ctx: BeamContext<TEnv>, params: Record<string, unknown>) => Promise<string>;
107
142
  /**
108
143
  * Factory function to create a session storage adapter.
109
144
  * Called with the session ID and environment, returns a BeamSession implementation.
@@ -136,8 +171,6 @@ export interface SessionConfig<TEnv = object> {
136
171
  */
137
172
  export interface BeamConfig<TEnv = object> {
138
173
  actions: Record<string, ActionHandler<TEnv>>;
139
- modals: Record<string, ModalHandler<TEnv>>;
140
- drawers?: Record<string, DrawerHandler<TEnv>>;
141
174
  auth?: AuthResolver<TEnv>;
142
175
  /** Session config - default uses cookie storage, or provide storageFactory for custom storage */
143
176
  session?: SessionConfig<TEnv>;
@@ -163,8 +196,6 @@ export interface BeamVariables<TEnv = object> {
163
196
  */
164
197
  export interface BeamInstance<TEnv extends object = object> {
165
198
  actions: Record<string, ActionHandler<TEnv>>;
166
- modals: Record<string, ModalHandler<TEnv>>;
167
- drawers: Record<string, DrawerHandler<TEnv>>;
168
199
  /** Auth resolver (if provided) */
169
200
  auth: AuthResolver<TEnv> | undefined;
170
201
  /** Init function for HonoX createApp({ init(app) { beam.init(app, options) } }) */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IAChD,2BAA2B;IAC3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,gCAAgC;IAChC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAA;C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EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAA;IAC3F;;;;;OAKG;IACH,iBAAiB,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC/D"}
package/dist/vite.d.ts CHANGED
@@ -5,16 +5,6 @@ export interface BeamPluginOptions {
5
5
  * @default '/app/actions/*.tsx'
6
6
  */
7
7
  actions?: string;
8
- /**
9
- * Glob pattern for modal handlers (must start with '/' for virtual modules)
10
- * @default '/app/modals/*.tsx'
11
- */
12
- modals?: string;
13
- /**
14
- * Glob pattern for drawer handlers (must start with '/' for virtual modules)
15
- * @default '/app/drawers/*.tsx'
16
- */
17
- drawers?: string;
18
8
  /**
19
9
  * Path to auth resolver module (must export default AuthResolver function)
20
10
  * @example '/app/auth.ts'
@@ -55,8 +45,6 @@ export interface BeamPluginOptions {
55
45
  * plugins: [
56
46
  * beamPlugin({
57
47
  * actions: '/app/actions/*.tsx',
58
- * modals: '/app/modals/*.tsx',
59
- * drawers: '/app/drawers/*.tsx',
60
48
  * })
61
49
  * ]
62
50
  * })
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG;QAClB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,wFAAwF;QACxF,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;CACF;AAKD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAgElE;AAED,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAElC,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG;QAClB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,wFAAwF;QACxF,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;CACF;AAKD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CA0DlE;AAED,eAAe,UAAU,CAAA"}
package/dist/vite.js CHANGED
@@ -12,8 +12,6 @@ const RESOLVED_VIRTUAL_MODULE_ID = '\0' + VIRTUAL_MODULE_ID;
12
12
  * plugins: [
13
13
  * beamPlugin({
14
14
  * actions: '/app/actions/*.tsx',
15
- * modals: '/app/modals/*.tsx',
16
- * drawers: '/app/drawers/*.tsx',
17
15
  * })
18
16
  * ]
19
17
  * })
@@ -25,7 +23,7 @@ const RESOLVED_VIRTUAL_MODULE_ID = '\0' + VIRTUAL_MODULE_ID;
25
23
  * ```
26
24
  */
27
25
  export function beamPlugin(options = {}) {
28
- const { actions = '/app/actions/*.tsx', modals = '/app/modals/*.tsx', drawers = '/app/drawers/*.tsx', auth, session, } = options;
26
+ const { actions = '/app/actions/*.tsx', auth, session, } = options;
29
27
  return {
30
28
  name: 'beam-plugin',
31
29
  resolveId(id) {
@@ -60,17 +58,13 @@ export function beamPlugin(options = {}) {
60
58
  }
61
59
  // Generate plain JavaScript - TypeScript types are handled via virtual-beam.d.ts
62
60
  return `
63
- import { createBeam, collectHandlers } from '@benqoder/beam'
61
+ import { createBeam, collectActions } from '@benqoder/beam'
64
62
  ${authImport}
65
63
  ${storageImport}
66
64
 
67
- const { actions, modals, drawers } = collectHandlers({
68
- actions: import.meta.glob('${actions}', { eager: true }),
69
- modals: import.meta.glob('${modals}', { eager: true }),
70
- drawers: import.meta.glob('${drawers}', { eager: true }),
71
- })
65
+ const actions = collectActions(import.meta.glob('${actions}', { eager: true }))
72
66
 
73
- export const beam = createBeam({ actions, modals, drawers${authConfig}${sessionConfig} })
67
+ export const beam = createBeam({ actions${authConfig}${sessionConfig} })
74
68
  `;
75
69
  }
76
70
  },