@benqoder/beam 0.1.3 → 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.
- package/README.md +180 -90
- package/dist/client.d.ts +12 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +275 -123
- package/dist/collect.d.ts +1 -47
- package/dist/collect.d.ts.map +1 -1
- package/dist/collect.js +0 -64
- package/dist/createBeam.d.ts +5 -19
- package/dist/createBeam.d.ts.map +1 -1
- package/dist/createBeam.js +74 -54
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/types.d.ts +48 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.d.ts +0 -12
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +4 -10
- package/package.json +1 -1
- package/src/beam.css +2 -0
- package/dist/DrawerFrame.d.ts +0 -16
- package/dist/DrawerFrame.d.ts.map +0 -1
- package/dist/DrawerFrame.js +0 -12
- package/dist/ModalFrame.d.ts +0 -12
- package/dist/ModalFrame.d.ts.map +0 -1
- package/dist/ModalFrame.js +0 -8
package/dist/createBeam.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RpcTarget } from 'capnweb';
|
|
2
|
-
import type { ActionHandler, ActionResponse,
|
|
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
|
-
|
|
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
|
|
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>>,
|
|
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
|
package/dist/createBeam.d.ts.map
CHANGED
|
@@ -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,
|
|
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,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,WAAW,EACX,aAAa,EAGd,MAAM,SAAS,CAAA;AAwDhB;;;;;;;;;;GAUG;AACH,qBAAa,SAAU,YAAW,WAAW;IAC3C,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,EAAE,CAAa;gBAEX,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW;IAK9C,OAAO,CAAC,GAAG;IAIL,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAMhD,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,MAAM,CAAC,GAAG,EAAE,MA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M1D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EACrD,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,GACvB,YAAY,CAAC,IAAI,CAAC,CAkOpB;AAED;;;;;;;GAOG;AACH,cAAM,gBAAgB,CAAC,IAAI,SAAS,MAAM,CAAE,SAAQ,SAAS;IAC3D,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,IAAI,CAA2F;gBAGrG,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,SAAS,EAC9C,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,EAC5C,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,SAAS,EAAE,QAAQ,GAAG,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"}
|
package/dist/createBeam.js
CHANGED
|
@@ -152,29 +152,81 @@ function parseSessionDataFromRequest(request) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
|
-
*
|
|
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: (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
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 {
|
|
4
|
-
export {
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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,
|
|
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(
|
|
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) } }) */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,CA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CAAC,CAAC,CAAA;IAC5C,kCAAkC;IAClC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,SAAS,CAAA;IACpC,mFAAmF;IACnF,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,IAAI,CAAA;IACxE,kFAAkF;IAClF,cAAc,EAAE,MAAM,iBAAiB,CAAC;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,SAAS,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
|
* })
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -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,
|
|
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',
|
|
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,
|
|
61
|
+
import { createBeam, collectActions } from '@benqoder/beam'
|
|
64
62
|
${authImport}
|
|
65
63
|
${storageImport}
|
|
66
64
|
|
|
67
|
-
const {
|
|
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
|
|
67
|
+
export const beam = createBeam({ actions${authConfig}${sessionConfig} })
|
|
74
68
|
`;
|
|
75
69
|
}
|
|
76
70
|
},
|
package/package.json
CHANGED
package/src/beam.css
CHANGED
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
transform: scale(0.95);
|
|
128
128
|
opacity: 0;
|
|
129
129
|
transition: transform 200ms ease-out, opacity 200ms ease-out;
|
|
130
|
+
padding: 15px;
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
#modal-backdrop.open #modal-content {
|
|
@@ -175,6 +176,7 @@
|
|
|
175
176
|
max-height: 100vh;
|
|
176
177
|
overflow: auto;
|
|
177
178
|
transition: transform 200ms ease-out;
|
|
179
|
+
padding: 15px;
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
/* Drawer positions */
|
package/dist/DrawerFrame.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Child } from 'hono/jsx';
|
|
2
|
-
type Props = {
|
|
3
|
-
title: string;
|
|
4
|
-
children: Child;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Reusable drawer wrapper component.
|
|
8
|
-
* Provides consistent header with title and close button.
|
|
9
|
-
*
|
|
10
|
-
* Note: The position (left/right) and size (small/medium/large) are
|
|
11
|
-
* controlled by the client via beam-position and beam-size attributes
|
|
12
|
-
* on the trigger element.
|
|
13
|
-
*/
|
|
14
|
-
export declare function DrawerFrame({ title, children }: Props): import("hono/jsx/jsx-dev-runtime").JSX.Element;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=DrawerFrame.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerFrame.d.ts","sourceRoot":"","sources":["../src/DrawerFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,KAAK,CAAA;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,kDAcrD"}
|
package/dist/DrawerFrame.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "hono/jsx/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Reusable drawer wrapper component.
|
|
4
|
-
* Provides consistent header with title and close button.
|
|
5
|
-
*
|
|
6
|
-
* Note: The position (left/right) and size (small/medium/large) are
|
|
7
|
-
* controlled by the client via beam-position and beam-size attributes
|
|
8
|
-
* on the trigger element.
|
|
9
|
-
*/
|
|
10
|
-
export function DrawerFrame({ title, children }) {
|
|
11
|
-
return (_jsxs(_Fragment, { children: [_jsxs("header", { class: "drawer-header", children: [_jsx("h2", { children: title }), _jsx("button", { type: "button", "beam-close": true, "aria-label": "Close", class: "drawer-close", children: "\u00D7" })] }), _jsx("div", { class: "drawer-body", children: children })] }));
|
|
12
|
-
}
|
package/dist/ModalFrame.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Child } from 'hono/jsx';
|
|
2
|
-
type Props = {
|
|
3
|
-
title: string;
|
|
4
|
-
children: Child;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Reusable modal wrapper component.
|
|
8
|
-
* Provides consistent header with title and close button.
|
|
9
|
-
*/
|
|
10
|
-
export declare function ModalFrame({ title, children }: Props): import("hono/jsx/jsx-dev-runtime").JSX.Element;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=ModalFrame.d.ts.map
|
package/dist/ModalFrame.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalFrame.d.ts","sourceRoot":"","sources":["../src/ModalFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,KAAK,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,kDAcpD"}
|
package/dist/ModalFrame.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "hono/jsx/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Reusable modal wrapper component.
|
|
4
|
-
* Provides consistent header with title and close button.
|
|
5
|
-
*/
|
|
6
|
-
export function ModalFrame({ title, children }) {
|
|
7
|
-
return (_jsxs(_Fragment, { children: [_jsxs("header", { class: "modal-header", children: [_jsx("h2", { children: title }), _jsx("button", { type: "button", "beam-close": true, "aria-label": "Close", class: "modal-close", children: "\u00D7" })] }), _jsx("div", { class: "modal-body", children: children })] }));
|
|
8
|
-
}
|