@maxhealth.tech/prefab 0.2.35 → 0.2.36
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 +41 -0
- package/dist/app.d.ts +1 -1
- package/dist/app.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -275,6 +275,24 @@ Button('Save', { onClick: new ShowToast('Saved!', { variant: 'success' }) })
|
|
|
275
275
|
|
|
276
276
|
**MCP actions:** `CallTool`, `SendMessage`, `UpdateContext`, `RequestDisplayMode`
|
|
277
277
|
|
|
278
|
+
**Real-time:** `Subscribe`, `Unsubscribe` — resource subscriptions with automatic polling fallback
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
import { Subscribe, Unsubscribe, ShowToast } from '@maxhealth.tech/prefab'
|
|
282
|
+
|
|
283
|
+
// Live updates — uses native push when available, polls otherwise
|
|
284
|
+
new Subscribe('chess://game/abc123', {
|
|
285
|
+
stateKey: '$game',
|
|
286
|
+
fallbackInterval: 2000,
|
|
287
|
+
fallbackTool: '_action',
|
|
288
|
+
fallbackArgs: { action: 'refresh' },
|
|
289
|
+
onData: new ShowToast('Game updated'),
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
// Cleanup
|
|
293
|
+
Button('Leave', { onClick: new Unsubscribe('chess://game/abc123') })
|
|
294
|
+
```
|
|
295
|
+
|
|
278
296
|
## Auto-Renderers
|
|
279
297
|
|
|
280
298
|
Generate complete UIs from raw data — no manual component wiring:
|
|
@@ -339,6 +357,29 @@ return display_update({ count: 42, status: 'complete' })
|
|
|
339
357
|
return display_error('User not found', { code: 404 })
|
|
340
358
|
```
|
|
341
359
|
|
|
360
|
+
### `rendererHtml()` — Viewer HTML Shell
|
|
361
|
+
|
|
362
|
+
Generate the complete HTML page for an MCP Apps viewer resource. Loads `prefab.css` + `renderer.auto.min.js` from the CDN automatically — no manual script wiring needed:
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
import { rendererHtml, registerViewerResource } from '@maxhealth.tech/prefab/mcp'
|
|
366
|
+
|
|
367
|
+
// Minimal — just works
|
|
368
|
+
const html = rendererHtml()
|
|
369
|
+
|
|
370
|
+
// With extras
|
|
371
|
+
const html = rendererHtml({
|
|
372
|
+
title: 'My App',
|
|
373
|
+
stylesheets: ['https://cdn.example.com/theme.css'],
|
|
374
|
+
scripts: ['https://cdn.example.com/plugin.js'],
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
// One-liner resource registration on your MCP server
|
|
378
|
+
registerViewerResource(server, { title: 'Patient Browser' })
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Options: `title`, `scripts`, `stylesheets`, `cdnBase` (override CDN URL).
|
|
382
|
+
|
|
342
383
|
## Browser Renderer
|
|
343
384
|
|
|
344
385
|
Two bundles, zero external dependencies:
|
package/dist/app.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { ComponentJSON } from './core/component.js';
|
|
|
9
9
|
import type { Action, ActionJSON } from './actions/types.js';
|
|
10
10
|
import type { PipeFn } from './rx/pipes.js';
|
|
11
11
|
/** Package version — injected by build script, updated at release time. */
|
|
12
|
-
export declare const VERSION = "0.2.
|
|
12
|
+
export declare const VERSION = "0.2.36";
|
|
13
13
|
export interface Theme {
|
|
14
14
|
light?: Record<string, string>;
|
|
15
15
|
dark?: Record<string, string>;
|
package/dist/app.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {} from './core/component.js';
|
|
8
8
|
import { drainAutoState } from './rx/state-collector.js';
|
|
9
9
|
/** Package version — injected by build script, updated at release time. */
|
|
10
|
-
export const VERSION = '0.2.
|
|
10
|
+
export const VERSION = '0.2.36';
|
|
11
11
|
export class PrefabApp {
|
|
12
12
|
title;
|
|
13
13
|
view;
|
package/package.json
CHANGED