@maxhealth.tech/prefab 0.1.2
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/CHANGELOG.md +51 -0
- package/LICENSE +21 -0
- package/README.md +340 -0
- package/dist/actions/client.d.ts +98 -0
- package/dist/actions/client.d.ts.map +1 -0
- package/dist/actions/client.js +188 -0
- package/dist/actions/client.js.map +1 -0
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/mcp.d.ts +37 -0
- package/dist/actions/mcp.d.ts.map +1 -0
- package/dist/actions/mcp.js +64 -0
- package/dist/actions/mcp.js.map +1 -0
- package/dist/actions/types.d.ts +16 -0
- package/dist/actions/types.d.ts.map +1 -0
- package/dist/actions/types.js +8 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/app.d.ts +65 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +120 -0
- package/dist/app.js.map +1 -0
- package/dist/auto/chart.d.ts +36 -0
- package/dist/auto/chart.d.ts.map +1 -0
- package/dist/auto/chart.js +50 -0
- package/dist/auto/chart.js.map +1 -0
- package/dist/auto/comparison.d.ts +32 -0
- package/dist/auto/comparison.d.ts.map +1 -0
- package/dist/auto/comparison.js +66 -0
- package/dist/auto/comparison.js.map +1 -0
- package/dist/auto/form.d.ts +50 -0
- package/dist/auto/form.d.ts.map +1 -0
- package/dist/auto/form.js +68 -0
- package/dist/auto/form.js.map +1 -0
- package/dist/auto/index.d.ts +84 -0
- package/dist/auto/index.d.ts.map +1 -0
- package/dist/auto/index.js +240 -0
- package/dist/auto/index.js.map +1 -0
- package/dist/auto/metrics.d.ts +44 -0
- package/dist/auto/metrics.d.ts.map +1 -0
- package/dist/auto/metrics.js +55 -0
- package/dist/auto/metrics.js.map +1 -0
- package/dist/auto/progress.d.ts +38 -0
- package/dist/auto/progress.d.ts.map +1 -0
- package/dist/auto/progress.js +72 -0
- package/dist/auto/progress.js.map +1 -0
- package/dist/auto/timeline.d.ts +41 -0
- package/dist/auto/timeline.d.ts.map +1 -0
- package/dist/auto/timeline.js +72 -0
- package/dist/auto/timeline.js.map +1 -0
- package/dist/components/alert/index.d.ts +14 -0
- package/dist/components/alert/index.d.ts.map +1 -0
- package/dist/components/alert/index.js +31 -0
- package/dist/components/alert/index.js.map +1 -0
- package/dist/components/card/index.d.ts +12 -0
- package/dist/components/card/index.d.ts.map +1 -0
- package/dist/components/card/index.js +33 -0
- package/dist/components/card/index.js.map +1 -0
- package/dist/components/charts/index.d.ts +57 -0
- package/dist/components/charts/index.d.ts.map +1 -0
- package/dist/components/charts/index.js +91 -0
- package/dist/components/charts/index.js.map +1 -0
- package/dist/components/control/index.d.ts +48 -0
- package/dist/components/control/index.d.ts.map +1 -0
- package/dist/components/control/index.js +47 -0
- package/dist/components/control/index.js.map +1 -0
- package/dist/components/data/index.d.ts +53 -0
- package/dist/components/data/index.d.ts.map +1 -0
- package/dist/components/data/index.js +88 -0
- package/dist/components/data/index.js.map +1 -0
- package/dist/components/form/index.d.ts +103 -0
- package/dist/components/form/index.d.ts.map +1 -0
- package/dist/components/form/index.js +247 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/interactive/index.d.ts +33 -0
- package/dist/components/interactive/index.d.ts.map +1 -0
- package/dist/components/interactive/index.js +59 -0
- package/dist/components/interactive/index.js.map +1 -0
- package/dist/components/layout/index.d.ts +61 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +86 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/media/index.d.ts +17 -0
- package/dist/components/media/index.d.ts.map +1 -0
- package/dist/components/media/index.js +41 -0
- package/dist/components/media/index.js.map +1 -0
- package/dist/components/table/index.d.ts +28 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/table/index.js +56 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/typography/index.d.ts +34 -0
- package/dist/components/typography/index.d.ts.map +1 -0
- package/dist/components/typography/index.js +93 -0
- package/dist/components/typography/index.js.map +1 -0
- package/dist/core/component.d.ts +67 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +122 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/validate.d.ts +30 -0
- package/dist/core/validate.d.ts.map +1 -0
- package/dist/core/validate.js +178 -0
- package/dist/core/validate.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/display.d.ts +102 -0
- package/dist/mcp/display.d.ts.map +1 -0
- package/dist/mcp/display.js +124 -0
- package/dist/mcp/display.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/types.d.ts +35 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +8 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/renderer/actions.d.ts +36 -0
- package/dist/renderer/actions.d.ts.map +1 -0
- package/dist/renderer/actions.js +296 -0
- package/dist/renderer/actions.js.map +1 -0
- package/dist/renderer/app.d.ts +87 -0
- package/dist/renderer/app.d.ts.map +1 -0
- package/dist/renderer/app.js +166 -0
- package/dist/renderer/app.js.map +1 -0
- package/dist/renderer/bridge.d.ts +91 -0
- package/dist/renderer/bridge.d.ts.map +1 -0
- package/dist/renderer/bridge.js +302 -0
- package/dist/renderer/bridge.js.map +1 -0
- package/dist/renderer/components/alert.d.ts +5 -0
- package/dist/renderer/components/alert.d.ts.map +1 -0
- package/dist/renderer/components/alert.js +44 -0
- package/dist/renderer/components/alert.js.map +1 -0
- package/dist/renderer/components/card.d.ts +5 -0
- package/dist/renderer/components/card.d.ts.map +1 -0
- package/dist/renderer/components/card.js +38 -0
- package/dist/renderer/components/card.js.map +1 -0
- package/dist/renderer/components/charts.d.ts +8 -0
- package/dist/renderer/components/charts.d.ts.map +1 -0
- package/dist/renderer/components/charts.js +232 -0
- package/dist/renderer/components/charts.js.map +1 -0
- package/dist/renderer/components/control.d.ts +5 -0
- package/dist/renderer/components/control.d.ts.map +1 -0
- package/dist/renderer/components/control.js +140 -0
- package/dist/renderer/components/control.js.map +1 -0
- package/dist/renderer/components/data.d.ts +5 -0
- package/dist/renderer/components/data.d.ts.map +1 -0
- package/dist/renderer/components/data.js +268 -0
- package/dist/renderer/components/data.js.map +1 -0
- package/dist/renderer/components/form.d.ts +5 -0
- package/dist/renderer/components/form.d.ts.map +1 -0
- package/dist/renderer/components/form.js +523 -0
- package/dist/renderer/components/form.js.map +1 -0
- package/dist/renderer/components/index.d.ts +5 -0
- package/dist/renderer/components/index.d.ts.map +1 -0
- package/dist/renderer/components/index.js +32 -0
- package/dist/renderer/components/index.js.map +1 -0
- package/dist/renderer/components/interactive.d.ts +5 -0
- package/dist/renderer/components/interactive.d.ts.map +1 -0
- package/dist/renderer/components/interactive.js +324 -0
- package/dist/renderer/components/interactive.js.map +1 -0
- package/dist/renderer/components/layout.d.ts +5 -0
- package/dist/renderer/components/layout.d.ts.map +1 -0
- package/dist/renderer/components/layout.js +113 -0
- package/dist/renderer/components/layout.js.map +1 -0
- package/dist/renderer/components/media.d.ts +5 -0
- package/dist/renderer/components/media.d.ts.map +1 -0
- package/dist/renderer/components/media.js +132 -0
- package/dist/renderer/components/media.js.map +1 -0
- package/dist/renderer/components/table.d.ts +5 -0
- package/dist/renderer/components/table.d.ts.map +1 -0
- package/dist/renderer/components/table.js +101 -0
- package/dist/renderer/components/table.js.map +1 -0
- package/dist/renderer/components/typography.d.ts +5 -0
- package/dist/renderer/components/typography.d.ts.map +1 -0
- package/dist/renderer/components/typography.js +90 -0
- package/dist/renderer/components/typography.js.map +1 -0
- package/dist/renderer/engine.d.ts +53 -0
- package/dist/renderer/engine.d.ts.map +1 -0
- package/dist/renderer/engine.js +112 -0
- package/dist/renderer/engine.js.map +1 -0
- package/dist/renderer/index.d.ts +94 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +215 -0
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/rx.d.ts +37 -0
- package/dist/renderer/rx.d.ts.map +1 -0
- package/dist/renderer/rx.js +360 -0
- package/dist/renderer/rx.js.map +1 -0
- package/dist/renderer/state.d.ts +34 -0
- package/dist/renderer/state.d.ts.map +1 -0
- package/dist/renderer/state.js +132 -0
- package/dist/renderer/state.js.map +1 -0
- package/dist/renderer/theme.d.ts +13 -0
- package/dist/renderer/theme.d.ts.map +1 -0
- package/dist/renderer/theme.js +69 -0
- package/dist/renderer/theme.js.map +1 -0
- package/dist/renderer/transport.d.ts +22 -0
- package/dist/renderer/transport.d.ts.map +1 -0
- package/dist/renderer/transport.js +69 -0
- package/dist/renderer/transport.js.map +1 -0
- package/dist/renderer.min.js +83 -0
- package/dist/rx/index.d.ts +2 -0
- package/dist/rx/index.d.ts.map +1 -0
- package/dist/rx/index.js +2 -0
- package/dist/rx/index.js.map +1 -0
- package/dist/rx/rx.d.ts +81 -0
- package/dist/rx/rx.d.ts.map +1 -0
- package/dist/rx/rx.js +196 -0
- package/dist/rx/rx.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core component base classes.
|
|
3
|
+
*
|
|
4
|
+
* Every UI component inherits from Component. Container components
|
|
5
|
+
* (Column, Row, Card, etc.) extend ContainerComponent which adds children.
|
|
6
|
+
* StatefulMixin adds name/value tracking for form elements.
|
|
7
|
+
*
|
|
8
|
+
* Serialization: Components produce a flat JSON tree matching the
|
|
9
|
+
* Python prefab-ui wire format:
|
|
10
|
+
* { type: "Button", label: "Hi", variant: "default" }
|
|
11
|
+
* { type: "Column", gap: 4, children: [...] }
|
|
12
|
+
*/
|
|
13
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
14
|
+
/** Convert snake_case or camelCase prop name to JSON camelCase */
|
|
15
|
+
function toCamelCase(key) {
|
|
16
|
+
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
17
|
+
}
|
|
18
|
+
/** Serialize a value for JSON output */
|
|
19
|
+
export function serializeValue(v) {
|
|
20
|
+
if (v === undefined || v === null)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean')
|
|
23
|
+
return v;
|
|
24
|
+
if (v instanceof Component)
|
|
25
|
+
return v.toJSON();
|
|
26
|
+
if (typeof v === 'object' && 'toJSON' in v && typeof v.toJSON === 'function') {
|
|
27
|
+
return v.toJSON();
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(v))
|
|
30
|
+
return v.map(serializeValue);
|
|
31
|
+
if (typeof v === 'object') {
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const [k, val] of Object.entries(v)) {
|
|
34
|
+
const serialized = serializeValue(val);
|
|
35
|
+
if (serialized !== undefined)
|
|
36
|
+
result[toCamelCase(k)] = serialized;
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
return v;
|
|
41
|
+
}
|
|
42
|
+
export class Component {
|
|
43
|
+
componentType;
|
|
44
|
+
id;
|
|
45
|
+
cssClass;
|
|
46
|
+
onMount;
|
|
47
|
+
constructor(type, props) {
|
|
48
|
+
this.componentType = type;
|
|
49
|
+
if (props?.id)
|
|
50
|
+
this.id = props.id;
|
|
51
|
+
if (props?.cssClass)
|
|
52
|
+
this.cssClass = props.cssClass;
|
|
53
|
+
if (props?.onMount)
|
|
54
|
+
this.onMount = props.onMount;
|
|
55
|
+
}
|
|
56
|
+
/** Override in subclasses to add component-specific props */
|
|
57
|
+
getProps() {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
toJSON() {
|
|
61
|
+
const json = { type: this.componentType };
|
|
62
|
+
if (this.id)
|
|
63
|
+
json.id = this.id;
|
|
64
|
+
if (this.cssClass)
|
|
65
|
+
json.cssClass = this.cssClass;
|
|
66
|
+
if (this.onMount) {
|
|
67
|
+
json.onMount = Array.isArray(this.onMount)
|
|
68
|
+
? this.onMount.map(a => a.toJSON())
|
|
69
|
+
: this.onMount.toJSON();
|
|
70
|
+
}
|
|
71
|
+
// Merge component-specific props
|
|
72
|
+
const props = this.getProps();
|
|
73
|
+
for (const [key, value] of Object.entries(props)) {
|
|
74
|
+
const serialized = serializeValue(value);
|
|
75
|
+
if (serialized !== undefined) {
|
|
76
|
+
json[toCamelCase(key)] = serialized;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return json;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export class ContainerComponent extends Component {
|
|
83
|
+
children;
|
|
84
|
+
constructor(type, props) {
|
|
85
|
+
super(type, props);
|
|
86
|
+
this.children = props?.children ?? [];
|
|
87
|
+
}
|
|
88
|
+
toJSON() {
|
|
89
|
+
const json = super.toJSON();
|
|
90
|
+
if (this.children.length > 0) {
|
|
91
|
+
json.children = this.children.map(c => c.toJSON());
|
|
92
|
+
}
|
|
93
|
+
return json;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Base class for stateful form components (Input, Checkbox, Select, etc.).
|
|
98
|
+
* Provides a `name` for state binding and an optional `onChange` action.
|
|
99
|
+
*/
|
|
100
|
+
export class StatefulComponent extends Component {
|
|
101
|
+
name;
|
|
102
|
+
value;
|
|
103
|
+
onChange;
|
|
104
|
+
constructor(type, props) {
|
|
105
|
+
super(type, props);
|
|
106
|
+
this.name = props.name;
|
|
107
|
+
this.value = props.value;
|
|
108
|
+
this.onChange = props.onChange;
|
|
109
|
+
}
|
|
110
|
+
getProps() {
|
|
111
|
+
return {
|
|
112
|
+
name: this.name,
|
|
113
|
+
...(this.value !== undefined && { value: this.value }),
|
|
114
|
+
...(this.onChange && {
|
|
115
|
+
onChange: Array.isArray(this.onChange)
|
|
116
|
+
? this.onChange.map(a => a.toJSON())
|
|
117
|
+
: this.onChange.toJSON(),
|
|
118
|
+
}),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/core/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,gFAAgF;AAEhF,kEAAkE;AAClE,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACpE,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,cAAc,CAAC,CAAU;IACvC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACnD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAA;IACtF,IAAI,CAAC,YAAY,SAAS;QAAE,OAAO,CAAC,CAAC,MAAM,EAAE,CAAA;IAC7C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,QAAQ,IAAI,CAAC,IAAI,OAAQ,CAA+B,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC5G,OAAQ,CAA+B,CAAC,MAAM,EAAE,CAAA;IAClD,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAClD,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,MAAM,GAA4B,EAAE,CAAA;QAC1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E,KAAoB;QAC5C,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;IAChC,CAAC;IAED,QAAQ;QACN,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;YACtD,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI;gBACnB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;oBACpC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;oBACpC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;aAC3B,CAAC;SACH,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Component, ContainerComponent, StatefulComponent, serializeValue } from './component.js';
|
|
2
|
+
export type { ComponentJSON, ComponentProps, ContainerProps, StatefulProps, RxStr } from './component.js';
|
|
3
|
+
export { validateWireFormat, isValidWireFormat } from './validate.js';
|
|
4
|
+
export type { ValidationError, ValidationResult } from './validate.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACjG,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACzG,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACrE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEjG,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire format validation — runtime schema checks for $prefab wire data.
|
|
3
|
+
*
|
|
4
|
+
* Validates that incoming JSON conforms to the $prefab wire format
|
|
5
|
+
* and returns structured error information.
|
|
6
|
+
*/
|
|
7
|
+
import type { PrefabWireFormat } from '../app.js';
|
|
8
|
+
export interface ValidationError {
|
|
9
|
+
path: string;
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ValidationResult {
|
|
13
|
+
valid: boolean;
|
|
14
|
+
errors: ValidationError[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Validate a wire format payload. Returns `{ valid: true, errors: [] }` if OK,
|
|
18
|
+
* or `{ valid: false, errors: [...] }` with details about what's wrong.
|
|
19
|
+
*
|
|
20
|
+
* @param data - The raw parsed JSON to validate
|
|
21
|
+
* @param opts - Optional: `strict` mode warns on unknown component types
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateWireFormat(data: unknown, opts?: {
|
|
24
|
+
strict?: boolean;
|
|
25
|
+
}): ValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Quick boolean check — returns true if data looks like valid $prefab wire format.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidWireFormat(data: unknown): data is PrefabWireFormat;
|
|
30
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAIjD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,eAAe,EAAE,CAAA;CAC1B;AA0CD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,gBAAgB,CA+DlB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,gBAAgB,CAEzE"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire format validation — runtime schema checks for $prefab wire data.
|
|
3
|
+
*
|
|
4
|
+
* Validates that incoming JSON conforms to the $prefab wire format
|
|
5
|
+
* and returns structured error information.
|
|
6
|
+
*/
|
|
7
|
+
// ── Known component types (all registered) ───────────────────────────────────
|
|
8
|
+
const KNOWN_TYPES = new Set([
|
|
9
|
+
// Layout
|
|
10
|
+
'Column', 'Row', 'Grid', 'GridItem', 'Container', 'Div', 'Span',
|
|
11
|
+
'Dashboard', 'DashboardItem', 'Pages', 'Page',
|
|
12
|
+
// Typography
|
|
13
|
+
'Heading', 'H1', 'H2', 'H3', 'H4', 'Text', 'P', 'Lead', 'Large',
|
|
14
|
+
'Small', 'Muted', 'BlockQuote', 'Label', 'Link', 'Code', 'Markdown', 'Kbd',
|
|
15
|
+
// Card
|
|
16
|
+
'Card', 'CardHeader', 'CardTitle', 'CardDescription', 'CardContent', 'CardFooter',
|
|
17
|
+
// Data
|
|
18
|
+
'DataTable', 'Badge', 'Dot', 'Metric', 'Ring', 'Progress', 'Separator', 'Loader', 'Icon',
|
|
19
|
+
// Table
|
|
20
|
+
'Table', 'TableHead', 'TableBody', 'TableFooter', 'TableRow',
|
|
21
|
+
'TableHeader', 'TableCell', 'TableCaption', 'ExpandableRow',
|
|
22
|
+
// Form
|
|
23
|
+
'Form', 'Input', 'Textarea', 'Button', 'ButtonGroup',
|
|
24
|
+
'Select', 'SelectOption', 'SelectGroup', 'SelectLabel', 'SelectSeparator',
|
|
25
|
+
'Checkbox', 'Switch', 'Slider',
|
|
26
|
+
'Radio', 'RadioGroup',
|
|
27
|
+
'Combobox', 'ComboboxOption', 'ComboboxGroup', 'ComboboxLabel', 'ComboboxSeparator',
|
|
28
|
+
'Calendar', 'DatePicker',
|
|
29
|
+
'Field', 'FieldTitle', 'FieldDescription', 'FieldContent', 'FieldError', 'ChoiceCard',
|
|
30
|
+
// Interactive
|
|
31
|
+
'Tabs', 'Tab', 'Accordion', 'AccordionItem', 'Dialog', 'Popover',
|
|
32
|
+
'Tooltip', 'HoverCard', 'Carousel',
|
|
33
|
+
// Control
|
|
34
|
+
'ForEach', 'If', 'Elif', 'Else', 'Define', 'Use', 'Slot',
|
|
35
|
+
// Alert
|
|
36
|
+
'Alert', 'AlertTitle', 'AlertDescription',
|
|
37
|
+
// Media
|
|
38
|
+
'Image', 'Audio', 'Video', 'Embed', 'Svg', 'DropZone', 'Mermaid',
|
|
39
|
+
// Charts
|
|
40
|
+
'BarChart', 'LineChart', 'AreaChart', 'PieChart', 'RadarChart',
|
|
41
|
+
'ScatterChart', 'Sparkline', 'RadialChart', 'Histogram',
|
|
42
|
+
]);
|
|
43
|
+
// ── Validator ────────────────────────────────────────────────────────────────
|
|
44
|
+
/**
|
|
45
|
+
* Validate a wire format payload. Returns `{ valid: true, errors: [] }` if OK,
|
|
46
|
+
* or `{ valid: false, errors: [...] }` with details about what's wrong.
|
|
47
|
+
*
|
|
48
|
+
* @param data - The raw parsed JSON to validate
|
|
49
|
+
* @param opts - Optional: `strict` mode warns on unknown component types
|
|
50
|
+
*/
|
|
51
|
+
export function validateWireFormat(data, opts = {}) {
|
|
52
|
+
const errors = [];
|
|
53
|
+
const strict = opts.strict ?? false;
|
|
54
|
+
if (data == null || typeof data !== 'object') {
|
|
55
|
+
errors.push({ path: '$', message: 'Wire data must be a non-null object' });
|
|
56
|
+
return { valid: false, errors };
|
|
57
|
+
}
|
|
58
|
+
const obj = data;
|
|
59
|
+
// $prefab header
|
|
60
|
+
if (obj.$prefab == null || typeof obj.$prefab !== 'object') {
|
|
61
|
+
errors.push({ path: '$.$prefab', message: 'Missing or invalid $prefab header' });
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const header = obj.$prefab;
|
|
65
|
+
if (typeof header.version !== 'string') {
|
|
66
|
+
errors.push({ path: '$.$prefab.version', message: 'version must be a string' });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// view (required)
|
|
70
|
+
if (obj.view == null) {
|
|
71
|
+
errors.push({ path: '$.view', message: 'Missing required "view" field' });
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
validateComponent(obj.view, '$.view', errors, strict);
|
|
75
|
+
}
|
|
76
|
+
// state (optional)
|
|
77
|
+
if (obj.state !== undefined) {
|
|
78
|
+
if (obj.state === null || typeof obj.state !== 'object' || Array.isArray(obj.state)) {
|
|
79
|
+
errors.push({ path: '$.state', message: 'state must be a plain object' });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// theme (optional)
|
|
83
|
+
if (obj.theme !== undefined) {
|
|
84
|
+
validateTheme(obj.theme, errors);
|
|
85
|
+
}
|
|
86
|
+
// defs (optional)
|
|
87
|
+
if (obj.defs !== undefined) {
|
|
88
|
+
if (obj.defs === null || typeof obj.defs !== 'object' || Array.isArray(obj.defs)) {
|
|
89
|
+
errors.push({ path: '$.defs', message: 'defs must be a plain object' });
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
for (const [name, def] of Object.entries(obj.defs)) {
|
|
93
|
+
validateComponent(def, `$.defs.${name}`, errors, strict);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// keyBindings (optional)
|
|
98
|
+
if (obj.keyBindings !== undefined) {
|
|
99
|
+
if (obj.keyBindings === null || typeof obj.keyBindings !== 'object' || Array.isArray(obj.keyBindings)) {
|
|
100
|
+
errors.push({ path: '$.keyBindings', message: 'keyBindings must be a plain object' });
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
for (const [key, action] of Object.entries(obj.keyBindings)) {
|
|
104
|
+
validateAction(action, `$.keyBindings.${key}`, errors);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return { valid: errors.length === 0, errors };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Quick boolean check — returns true if data looks like valid $prefab wire format.
|
|
112
|
+
*/
|
|
113
|
+
export function isValidWireFormat(data) {
|
|
114
|
+
return validateWireFormat(data).valid;
|
|
115
|
+
}
|
|
116
|
+
// ── Internal helpers ─────────────────────────────────────────────────────────
|
|
117
|
+
function validateComponent(node, path, errors, strict) {
|
|
118
|
+
if (node == null || typeof node !== 'object' || Array.isArray(node)) {
|
|
119
|
+
errors.push({ path, message: 'Component must be a plain object' });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const comp = node;
|
|
123
|
+
if (typeof comp.type !== 'string' || comp.type.length === 0) {
|
|
124
|
+
errors.push({ path: `${path}.type`, message: 'Component must have a non-empty "type" string' });
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (strict && !KNOWN_TYPES.has(comp.type)) {
|
|
128
|
+
errors.push({ path: `${path}.type`, message: `Unknown component type: "${comp.type}"` });
|
|
129
|
+
}
|
|
130
|
+
// Validate children recursively
|
|
131
|
+
if (comp.children !== undefined) {
|
|
132
|
+
if (!Array.isArray(comp.children)) {
|
|
133
|
+
errors.push({ path: `${path}.children`, message: 'children must be an array' });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
for (let i = 0; i < comp.children.length; i++) {
|
|
137
|
+
validateComponent(comp.children[i], `${path}.children[${i}]`, errors, strict);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Validate action props
|
|
142
|
+
for (const prop of ['onClick', 'onChange', 'onSubmit', 'onMount', 'onClose']) {
|
|
143
|
+
if (comp[prop] !== undefined) {
|
|
144
|
+
validateAction(comp[prop], `${path}.${prop}`, errors);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function validateAction(action, path, errors) {
|
|
149
|
+
if (Array.isArray(action)) {
|
|
150
|
+
for (let i = 0; i < action.length; i++) {
|
|
151
|
+
validateAction(action[i], `${path}[${i}]`, errors);
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (action == null || typeof action !== 'object') {
|
|
156
|
+
errors.push({ path, message: 'Action must be an object or array of objects' });
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const act = action;
|
|
160
|
+
if (typeof act.type !== 'string' || act.type.length === 0) {
|
|
161
|
+
errors.push({ path: `${path}.type`, message: 'Action must have a non-empty "type" string' });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function validateTheme(theme, errors) {
|
|
165
|
+
if (theme === null || typeof theme !== 'object' || Array.isArray(theme)) {
|
|
166
|
+
errors.push({ path: '$.theme', message: 'theme must be a plain object' });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const t = theme;
|
|
170
|
+
for (const mode of ['light', 'dark']) {
|
|
171
|
+
if (t[mode] !== undefined) {
|
|
172
|
+
if (t[mode] === null || typeof t[mode] !== 'object' || Array.isArray(t[mode])) {
|
|
173
|
+
errors.push({ path: `$.theme.${mode}`, message: `theme.${mode} must be a plain object` });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/core/validate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,gFAAgF;AAEhF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,SAAS;IACT,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM;IAC/D,WAAW,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM;IAC7C,aAAa;IACb,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO;IAC/D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK;IAC1E,OAAO;IACP,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY;IACjF,OAAO;IACP,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IACxF,QAAQ;IACR,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU;IAC5D,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe;IAC3D,OAAO;IACP,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa;IACpD,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,iBAAiB;IACzE,UAAU,EAAE,QAAQ,EAAE,QAAQ;IAC9B,OAAO,EAAE,YAAY;IACrB,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB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AAE,4CAA4C,EAAE,CAAC,CAAA;IAC9F,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,MAAyB;IAC9D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAA;QACzE,OAAM;IACR,CAAC;IAED,MAAM,CAAC,GAAG,KAAgC,CAAA;IAC1C,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC9E,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,IAAI,yBAAyB,EAAE,CAAC,CAAA;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prefab — TypeScript declarative UI component library for MCP apps.
|
|
3
|
+
*
|
|
4
|
+
* Wire-compatible with the Python prefab-ui library.
|
|
5
|
+
* Serializes to JSON component trees using the $prefab wire format.
|
|
6
|
+
*/
|
|
7
|
+
export { Component, ContainerComponent, StatefulComponent } from './core/index.js';
|
|
8
|
+
export type { ComponentJSON, ComponentProps, ContainerProps, StatefulProps, RxStr } from './core/index.js';
|
|
9
|
+
export { validateWireFormat, isValidWireFormat } from './core/validate.js';
|
|
10
|
+
export type { ValidationError, ValidationResult } from './core/validate.js';
|
|
11
|
+
export { PrefabApp } from './app.js';
|
|
12
|
+
export type { PrefabAppOptions, PrefabWireFormat, Theme } from './app.js';
|
|
13
|
+
export { Column, Row, Grid, GridItem, Container, Div, Span, Dashboard, DashboardItem, Pages, Page } from './components/layout/index.js';
|
|
14
|
+
export { Heading, H1, H2, H3, H4, Text, P, Lead, Large, Small, Muted, BlockQuote, Label, Link, Code, Markdown, Kbd } from './components/typography/index.js';
|
|
15
|
+
export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './components/card/index.js';
|
|
16
|
+
export { DataTable, col, Badge, Dot, Metric, Ring, Progress, Separator, Loader, Icon } from './components/data/index.js';
|
|
17
|
+
export type { DataTableColumnDef, DataTableProps, BadgeVariant, MetricProps } from './components/data/index.js';
|
|
18
|
+
export { Table, TableHead, TableBody, TableFooter, TableRow, TableHeader, TableCell, TableCaption, ExpandableRow } from './components/table/index.js';
|
|
19
|
+
export { Form, Input, Textarea, Button, ButtonGroup, Select, SelectOption, SelectGroup, SelectLabel, SelectSeparator, Checkbox, Switch, Slider, Radio, RadioGroup, Combobox, ComboboxOption, ComboboxGroup, ComboboxLabel, ComboboxSeparator, Calendar, DatePicker, Field, FieldTitle, FieldDescription, FieldContent, FieldError, ChoiceCard, } from './components/form/index.js';
|
|
20
|
+
export type { FormProps, InputProps, ButtonVariant, ButtonSize } from './components/form/index.js';
|
|
21
|
+
export { Tabs, Tab, Accordion, AccordionItem, Dialog, Popover, Tooltip, HoverCard, Carousel } from './components/interactive/index.js';
|
|
22
|
+
export { ForEach, If, Elif, Else, Define, Use, Slot } from './components/control/index.js';
|
|
23
|
+
export { Alert, AlertTitle, AlertDescription } from './components/alert/index.js';
|
|
24
|
+
export { Image, Audio, Video, Embed, Svg, DropZone, Mermaid } from './components/media/index.js';
|
|
25
|
+
export { BarChart, LineChart, AreaChart, PieChart, RadarChart, ScatterChart, Sparkline, RadialChart, Histogram } from './components/charts/index.js';
|
|
26
|
+
export type { ChartSeries, BaseChartProps, BarChartProps, SparklineProps, RadialChartProps, HistogramProps } from './components/charts/index.js';
|
|
27
|
+
export { autoDetail, autoTable, statusVariant, registerStatusVariants } from './auto/index.js';
|
|
28
|
+
export { autoChart } from './auto/chart.js';
|
|
29
|
+
export { autoForm } from './auto/form.js';
|
|
30
|
+
export { autoComparison } from './auto/comparison.js';
|
|
31
|
+
export { autoMetrics } from './auto/metrics.js';
|
|
32
|
+
export { autoTimeline } from './auto/timeline.js';
|
|
33
|
+
export { autoProgress } from './auto/progress.js';
|
|
34
|
+
export type { AutoDetailOptions, AutoTableOptions } from './auto/index.js';
|
|
35
|
+
export type { AutoChartOptions, ChartType } from './auto/chart.js';
|
|
36
|
+
export type { AutoFormField, AutoFormOptions } from './auto/form.js';
|
|
37
|
+
export type { AutoComparisonOptions } from './auto/comparison.js';
|
|
38
|
+
export type { AutoMetricDef, AutoMetricsOptions } from './auto/metrics.js';
|
|
39
|
+
export type { AutoTimelineEvent, AutoTimelineOptions } from './auto/timeline.js';
|
|
40
|
+
export type { AutoProgressStep, AutoProgressOptions } from './auto/progress.js';
|
|
41
|
+
export { display, display_form, display_update, display_error } from './mcp/display.js';
|
|
42
|
+
export type { DisplayOptions, DisplayFormOptions, DisplayErrorOptions, StateUpdate, PrefabUpdateWire } from './mcp/display.js';
|
|
43
|
+
export type { McpToolResult, McpContent, McpTextContent } from './mcp/types.js';
|
|
44
|
+
export { rx, Rx, ITEM, INDEX, EVENT, ERROR, RESULT, STATE } from './rx/index.js';
|
|
45
|
+
export { SetState, ToggleState, AppendState, PopState, ShowToast, CloseOverlay, OpenLink, SetInterval, Fetch, OpenFilePicker, CallHandler } from './actions/client.js';
|
|
46
|
+
export { CallTool, SendMessage, UpdateContext, RequestDisplayMode } from './actions/mcp.js';
|
|
47
|
+
export type { Action, ActionJSON } from './actions/types.js';
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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B,CAAA;AAC9H,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAG/E,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtK,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC3F,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prefab — TypeScript declarative UI component library for MCP apps.
|
|
3
|
+
*
|
|
4
|
+
* Wire-compatible with the Python prefab-ui library.
|
|
5
|
+
* Serializes to JSON component trees using the $prefab wire format.
|
|
6
|
+
*/
|
|
7
|
+
// ── Core ─────────────────────────────────────────────────────────────────────
|
|
8
|
+
export { Component, ContainerComponent, StatefulComponent } from './core/index.js';
|
|
9
|
+
export { validateWireFormat, isValidWireFormat } from './core/validate.js';
|
|
10
|
+
// ── App ──────────────────────────────────────────────────────────────────────
|
|
11
|
+
export { PrefabApp } from './app.js';
|
|
12
|
+
// ── Layout ───────────────────────────────────────────────────────────────────
|
|
13
|
+
export { Column, Row, Grid, GridItem, Container, Div, Span, Dashboard, DashboardItem, Pages, Page } from './components/layout/index.js';
|
|
14
|
+
// ── Typography ───────────────────────────────────────────────────────────────
|
|
15
|
+
export { Heading, H1, H2, H3, H4, Text, P, Lead, Large, Small, Muted, BlockQuote, Label, Link, Code, Markdown, Kbd } from './components/typography/index.js';
|
|
16
|
+
// ── Card ─────────────────────────────────────────────────────────────────────
|
|
17
|
+
export { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './components/card/index.js';
|
|
18
|
+
// ── Data Display ─────────────────────────────────────────────────────────────
|
|
19
|
+
export { DataTable, col, Badge, Dot, Metric, Ring, Progress, Separator, Loader, Icon } from './components/data/index.js';
|
|
20
|
+
// ── Table ────────────────────────────────────────────────────────────────────
|
|
21
|
+
export { Table, TableHead, TableBody, TableFooter, TableRow, TableHeader, TableCell, TableCaption, ExpandableRow } from './components/table/index.js';
|
|
22
|
+
// ── Form ─────────────────────────────────────────────────────────────────────
|
|
23
|
+
export { Form, Input, Textarea, Button, ButtonGroup, Select, SelectOption, SelectGroup, SelectLabel, SelectSeparator, Checkbox, Switch, Slider, Radio, RadioGroup, Combobox, ComboboxOption, ComboboxGroup, ComboboxLabel, ComboboxSeparator, Calendar, DatePicker, Field, FieldTitle, FieldDescription, FieldContent, FieldError, ChoiceCard, } from './components/form/index.js';
|
|
24
|
+
// ── Interactive ──────────────────────────────────────────────────────────────
|
|
25
|
+
export { Tabs, Tab, Accordion, AccordionItem, Dialog, Popover, Tooltip, HoverCard, Carousel } from './components/interactive/index.js';
|
|
26
|
+
// ── Control Flow ─────────────────────────────────────────────────────────────
|
|
27
|
+
export { ForEach, If, Elif, Else, Define, Use, Slot } from './components/control/index.js';
|
|
28
|
+
// ── Alert ────────────────────────────────────────────────────────────────────
|
|
29
|
+
export { Alert, AlertTitle, AlertDescription } from './components/alert/index.js';
|
|
30
|
+
// ── Media ────────────────────────────────────────────────────────────────────
|
|
31
|
+
export { Image, Audio, Video, Embed, Svg, DropZone, Mermaid } from './components/media/index.js';
|
|
32
|
+
// ── Charts ───────────────────────────────────────────────────────────────────
|
|
33
|
+
export { BarChart, LineChart, AreaChart, PieChart, RadarChart, ScatterChart, Sparkline, RadialChart, Histogram } from './components/charts/index.js';
|
|
34
|
+
// ── Auto-rendering ───────────────────────────────────────────────────────────
|
|
35
|
+
export { autoDetail, autoTable, statusVariant, registerStatusVariants } from './auto/index.js';
|
|
36
|
+
export { autoChart } from './auto/chart.js';
|
|
37
|
+
export { autoForm } from './auto/form.js';
|
|
38
|
+
export { autoComparison } from './auto/comparison.js';
|
|
39
|
+
export { autoMetrics } from './auto/metrics.js';
|
|
40
|
+
export { autoTimeline } from './auto/timeline.js';
|
|
41
|
+
export { autoProgress } from './auto/progress.js';
|
|
42
|
+
// ── MCP Display Helpers ──────────────────────────────────────────────────────
|
|
43
|
+
export { display, display_form, display_update, display_error } from './mcp/display.js';
|
|
44
|
+
// ── Re-export actions and rx for convenience ─────────────────────────────────
|
|
45
|
+
export { rx, Rx, ITEM, INDEX, EVENT, ERROR, RESULT, STATE } from './rx/index.js';
|
|
46
|
+
export { SetState, ToggleState, AppendState, PopState, ShowToast, CloseOverlay, OpenLink, SetInterval, Fetch, OpenFilePicker, CallHandler } from './actions/client.js';
|
|
47
|
+
export { CallTool, SendMessage, UpdateContext, RequestDisplayMode } from './actions/mcp.js';
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gFAAgF;AAChF,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAElF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAG1E,gFAAgF;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC,gFAAgF;AAChF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AAEvI,gFAAgF;AAChF,OAAO,EAAE,OAAO,EA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QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtK,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Display Helpers — return prefab UIs as MCP tool results.
|
|
3
|
+
*
|
|
4
|
+
* These functions wrap PrefabApp / Component trees into MCP-compatible
|
|
5
|
+
* tool result content arrays, ready to return from tool handlers.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { display, display_error } from '@maxhealth.tech/prefab/mcp'
|
|
10
|
+
* import { autoTable } from '@maxhealth.tech/prefab'
|
|
11
|
+
*
|
|
12
|
+
* // In a FastMCP tool handler:
|
|
13
|
+
* async function listPatients(args, context) {
|
|
14
|
+
* const patients = await fetchPatients()
|
|
15
|
+
* return display(autoTable(patients), { title: 'Patient List' })
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { type Component } from '../core/component.js';
|
|
20
|
+
import { PrefabApp } from '../app.js';
|
|
21
|
+
import type { Theme } from '../app.js';
|
|
22
|
+
import type { Action } from '../actions/types.js';
|
|
23
|
+
import type { McpToolResult } from './types.js';
|
|
24
|
+
export interface DisplayOptions {
|
|
25
|
+
/** Page / app title. */
|
|
26
|
+
title?: string;
|
|
27
|
+
/** Initial reactive state. */
|
|
28
|
+
state?: Record<string, unknown>;
|
|
29
|
+
/** Light/dark theme overrides. */
|
|
30
|
+
theme?: Theme;
|
|
31
|
+
/** Reusable component definitions. */
|
|
32
|
+
defs?: Record<string, Component>;
|
|
33
|
+
/** Action(s) to run when the UI mounts. */
|
|
34
|
+
onMount?: Action | Action[];
|
|
35
|
+
/** Keyboard shortcuts. */
|
|
36
|
+
keyBindings?: Record<string, Action | Action[]>;
|
|
37
|
+
/** Extra CSS class on root element. */
|
|
38
|
+
cssClass?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Wrap a Component (or PrefabApp) as an MCP tool result.
|
|
42
|
+
*
|
|
43
|
+
* If given a Component, it's wrapped in a PrefabApp automatically.
|
|
44
|
+
* If given a PrefabApp, it's serialized as-is.
|
|
45
|
+
*
|
|
46
|
+
* @returns MCP tool result with the prefab wire format JSON as text content.
|
|
47
|
+
*/
|
|
48
|
+
export declare function display(viewOrApp: Component | PrefabApp, options?: DisplayOptions): McpToolResult;
|
|
49
|
+
import type { AutoFormField, AutoFormOptions } from '../auto/form.js';
|
|
50
|
+
export interface DisplayFormOptions extends AutoFormOptions {
|
|
51
|
+
/** Initial state values for form fields. */
|
|
52
|
+
state?: Record<string, unknown>;
|
|
53
|
+
/** Theme overrides. */
|
|
54
|
+
theme?: Theme;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Return a form UI as an MCP tool result.
|
|
58
|
+
*
|
|
59
|
+
* The form submits back to the specified MCP tool via CallTool.
|
|
60
|
+
* Field definitions map to Input components; the submit action
|
|
61
|
+
* invokes `submitTool` with all field values.
|
|
62
|
+
*
|
|
63
|
+
* @returns MCP tool result with form prefab UI.
|
|
64
|
+
*/
|
|
65
|
+
export declare function display_form(fields: AutoFormField[], submitTool: string, options?: DisplayFormOptions): McpToolResult;
|
|
66
|
+
export interface StateUpdate {
|
|
67
|
+
/** State key-value pairs to merge into the existing UI state. */
|
|
68
|
+
state: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
export interface PrefabUpdateWire {
|
|
71
|
+
$prefab: {
|
|
72
|
+
version: string;
|
|
73
|
+
};
|
|
74
|
+
update: StateUpdate;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Return a partial state update for an existing prefab UI.
|
|
78
|
+
*
|
|
79
|
+
* Instead of re-rendering the entire UI, this sends a state delta
|
|
80
|
+
* that the renderer merges into its reactive store.
|
|
81
|
+
*
|
|
82
|
+
* @returns MCP tool result with a $prefab update payload.
|
|
83
|
+
*/
|
|
84
|
+
export declare function display_update(state: Record<string, unknown>): McpToolResult;
|
|
85
|
+
export interface DisplayErrorOptions {
|
|
86
|
+
/** Error detail / stack trace to show in a code block. */
|
|
87
|
+
detail?: string;
|
|
88
|
+
/** Hint for the user on how to fix the issue. */
|
|
89
|
+
hint?: string;
|
|
90
|
+
/** Theme overrides. */
|
|
91
|
+
theme?: Theme;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Return a standardized error view as an MCP tool result.
|
|
95
|
+
*
|
|
96
|
+
* Renders a destructive Alert with title + message, optional detail
|
|
97
|
+
* code block, and optional hint. Sets `isError: true` on the MCP result.
|
|
98
|
+
*
|
|
99
|
+
* @returns MCP tool result with error UI and isError flag.
|
|
100
|
+
*/
|
|
101
|
+
export declare function display_error(title: string, message: string, options?: DisplayErrorOptions): McpToolResult;
|
|
102
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/mcp/display.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAI/C,MAAM,WAAW,cAAc;IAC7B,wBAAwB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,C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